| 1 |
pylon |
1.1 |
#include <stdio.h> |
| 2 |
|
|
#include <ctype.h> |
| 3 |
|
|
#include <string.h> |
| 4 |
|
|
#include <malloc.h> |
| 5 |
|
|
|
| 6 |
|
|
char * macMachineType(void) { |
| 7 |
|
|
FILE * fd; |
| 8 |
|
|
char buf[256], *bufptr, *rc; |
| 9 |
|
|
char *id; |
| 10 |
|
|
|
| 11 |
|
|
if (!(fd = fopen("/proc/cpuinfo", "r"))) |
| 12 |
|
|
return NULL; |
| 13 |
|
|
|
| 14 |
|
|
while ((rc = fgets(buf, 255, fd)) != NULL) |
| 15 |
|
|
{ |
| 16 |
|
|
if (strncasecmp(buf, "machine", 7) == 0) |
| 17 |
|
|
{ |
| 18 |
|
|
bufptr = buf + 7; /* Set up a pointer into the string */ |
| 19 |
|
|
|
| 20 |
|
|
/* Skip blanks and : */ |
| 21 |
|
|
while ((*bufptr == ':' || isspace(*bufptr)) && *bufptr != 0) |
| 22 |
|
|
bufptr++; |
| 23 |
|
|
|
| 24 |
|
|
id = malloc(sizeof(buf)); |
| 25 |
|
|
sprintf(id, "%s", bufptr); |
| 26 |
|
|
return id; |
| 27 |
|
|
} |
| 28 |
|
|
} |
| 29 |
|
|
return NULL; |
| 30 |
|
|
} |
| 31 |
|
|
|
| 32 |
|
|
void help() |
| 33 |
|
|
{ |
| 34 |
|
|
printf("Options:\n"); |
| 35 |
josejx |
1.2 |
printf("\t--keymap=KEYMAP\t\tUse local keymap instead of us\n"); |
| 36 |
josejx |
1.3 |
printf("\t--list-keymaps\t\tList available keymaps\n"); |
| 37 |
josejx |
1.2 |
printf("\n\tOnly one of the video options below may be used at a time:\n"); |
| 38 |
pylon |
1.1 |
printf("\t--fbdepth\t\tuse current framebuffer color depth for X\n"); |
| 39 |
|
|
printf("\t--fbdev\t\t\tuse the fbdev driver in X\n"); |
| 40 |
josejx |
1.3 |
printf("\t--safe\t\t\tprovides a config that \"always works\"\n"); |
| 41 |
pylon |
1.1 |
|
| 42 |
|
|
} |
| 43 |
|
|
|
| 44 |
|
|
void usage() |
| 45 |
|
|
{ |
| 46 |
|
|
printf("usage: Xorgautoconfig [option]\n"); |
| 47 |
|
|
help(); |
| 48 |
|
|
} |