Functions | |
const char * | di_system_subarch_analyze (void) |
const char* di_system_subarch_analyze | ( | void | ) |
Returns a string describing the current subarchitecture, e.g. "powermac_newworld".
00062 { 00063 FILE *cpuinfo; 00064 char line[1024]; 00065 char entry[256]; 00066 char *pos; 00067 int i; 00068 00069 cpuinfo = fopen("/proc/cpuinfo", "r"); 00070 if (cpuinfo == NULL) 00071 return "unknown"; 00072 00073 while (fgets(line, sizeof(line), cpuinfo) != NULL) 00074 { 00075 if (strstr(line, "Hardware") == line) 00076 { 00077 pos = strchr(line, ':'); 00078 if (pos == NULL) 00079 continue; 00080 while (*++pos && (*pos == '\t' || *pos == ' ')); 00081 00082 strncpy(entry, pos, sizeof(entry)); 00083 break; 00084 } 00085 } 00086 00087 fclose(cpuinfo); 00088 00089 for (i = 0; map_hardware[i].entry; i++) 00090 { 00091 if (!strncasecmp(map_hardware[i].entry, entry, 00092 strlen(map_hardware[i].entry))) 00093 { 00094 return( map_hardware[i].ret ); 00095 } 00096 } 00097 00098 return "unknown"; 00099 }