#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <malloc.h>

char * macMachineType(void) {
    FILE * fd;
    char buf[256], *bufptr, *rc;
    char *id;

    if (!(fd = fopen("/proc/cpuinfo", "r")))
	return NULL;
                                                                                                                                                             
    while ((rc = fgets(buf, 255, fd)) != NULL)
    {
	if (strncasecmp(buf, "machine", 7) == 0)
	{
	    bufptr = buf + 7; /* Set up a pointer into the string */
                                                                                                                                                             
	    /* Skip blanks and : */
	    while ((*bufptr == ':' || isspace(*bufptr)) && *bufptr != 0)
		bufptr++;

	    id = malloc(sizeof(buf));
	    sprintf(id, "%s", bufptr);
	    return id;
	}
    }
    return NULL;
}

void help()
{
	printf("Options:\n");
	printf("\t--fbdepth\t\tuse current framebuffer color depth for X\n"); 
	printf("\t--fbdev\t\t\tuse the fbdev driver in X\n"); 
	printf("\t--safe\t\t\tcombines above two options to provide a config that \"always works\"\n");

	printf("\nNote: Only only option can be used at a time\n");
}

void usage()
{
	printf("usage: Xorgautoconfig [option]\n");
	help();
}
