Subarchitecture detection
[System]


Functions

const char * di_system_subarch_analyze (void)

Detailed Description


Function Documentation

const char* di_system_subarch_analyze ( void   ) 

Returns a string describing the current subarchitecture, e.g. "powermac_newworld".

00051 {
00052         FILE *cpuinfo;
00053         char line[1024];
00054         char entry[256];
00055         char *pos;
00056         int i;
00057 
00058         cpuinfo = fopen("/proc/cpuinfo", "r");
00059         if (cpuinfo == NULL)
00060                 return "unknown";
00061 
00062         while (fgets(line, sizeof(line), cpuinfo) != NULL)
00063         {
00064             if (strstr(line, "Hardware") == line)
00065             {
00066                 pos = strchr(line, ':');
00067                 if (pos == NULL)
00068                            continue;
00069                 while (*++pos && (*pos == '\t' || *pos == ' '));
00070 
00071                 strncpy(entry, pos, sizeof(entry));
00072                 break;
00073             }
00074         }
00075 
00076         fclose(cpuinfo);
00077 
00078         for (i = 0; map_hardware[i].entry; i++)
00079         {
00080             if (!strncasecmp(map_hardware[i].entry, entry,
00081                         strlen(map_hardware[i].entry)))
00082             {
00083                 return( map_hardware[i].ret );
00084             }
00085         }
00086 
00087         return "unknown";
00088 }


Generated on Fri Nov 30 13:45:50 2007 for libdebian-installer by  doxygen 1.5.3-20071008