Beispiel #1
0
int main(int argc, char *argv[])
{
	int errors = 0;
	char c;
	++errors;

	/* parse command line args */
	while ((c = getopt(argc, argv, "hgf:r:T:1:2:3:")) != -1)
		switch (c) {
			case 'h': /* help */
				usage(argv[0]);
				break;
			case 'g': /* grading option for autograder */
				grade = 1;
				break;
			case 'f': /* test only one function */
				test_fname = strdup(optarg);
				break;
			case 'r': /* set global rating for each problem */
				global_rating = atoi(optarg);
				if (global_rating < 0)
					usage(argv[0]);
				break;
			case '1': /* Get first argument */
				has_arg[0] = get_num_val(optarg, &argval[0]);
				if (!has_arg[0]) {
					printf("Bad argument '%s'\n", optarg);
					exit(0);
				}
				break;
			case '2': /* Get first argument */
				has_arg[1] = get_num_val(optarg, &argval[1]);
				if (!has_arg[1]) {
					printf("Bad argument '%s'\n", optarg);
					exit(0);
				}
				break;
			case '3': /* Get first argument */
				has_arg[2] = get_num_val(optarg, &argval[2]);
				if (!has_arg[2]) {
					printf("Bad argument '%s'\n", optarg);
					exit(0);
				}
				break;
			case 'T': /* Set timeout limit */
				timeout_limit = atoi(optarg);
				break;
			default:
				usage(argv[0]);
		}

	if (timeout_limit > 0) {
		Signal(SIGALRM, timeout_handler);
	}

	/* test each function */
	errors = run_tests();

	return 0;
}
Beispiel #2
0
int main(int argc, char *argv[])
{
  int i;
  unsigned uf;
  if (argc < 2)
    usage(argv[0]);
  for (i = 1; i < argc; i++) {
    char *sval = argv[i];
    if (get_num_val(sval, &uf)) {
      show_float(uf);
    } else {
      printf("Invalid 32-bit number: '%s'\n", sval);
      usage(argv[0]);
    }
  }
  return 0;
}
Beispiel #3
0
void get_global_opts() {
const char * v;
uint32 temp;

v = gtkopts_getvalue("sound");
    if (stricmp(v,"on")==0) {sound=1;};

v = gtkopts_getvalue("fastsound");
    if (stricmp(v,"true")==0) {fastsound=1;};

v = gtkopts_getvalue("samplerate");
    sound_rate=atoi(v);

v = gtkopts_getvalue("llsfilter");
    if (stricmp(v,"on")==0) {llsfilter=1;} else { llsfilter=0; };

/*
v = gtkopts_getvalue("rotateright");
    if (stricmp(v,"true")==0) {rotateright=1;};
*/
v = gtkopts_getvalue("sound_sem");
    if (stricmp(v,"true")==0) {use_sem=1;};

v = gtkopts_getvalue("show_keys");
    if (stricmp(v,"true")==0) {show_keys=1;} else { show_keys=0; };

/*
v = gtkopts_getvalue("landscape");
    if (stricmp(v,"true")==0) {landscape=1;} else { landscape=0; };

v = gtkopts_getvalue("crop_screen");
    crop_screen=2; //auto
    if (stricmp(v,"true")==0) {crop_screen=1;};
    if (stricmp(v,"false")==0) {crop_screen=0;};
*/
v = gtkopts_getvalue("z80");
    if (stricmp(v,"off")==0) {use_z80=0;};
    if (stricmp(v,"on")==0) {use_z80=1;};

v = gtkopts_getvalue("frameskip");
    if (stricmp(v,"auto")==0) { 
    autofs=1; frameskip=0;
    } else {
    get_num_val("frameskip",&frameskip); autofs=0;
    }

v = gtkopts_getvalue("savefolder");
    sdir=2; //User-defined by default
    if (stricmp(v,"romfolder")==0) {sdir=0;};
    if (stricmp(v,"appfolder")==0) {sdir=1;};

v = gtkopts_getvalue("configfolder");
    cdir=2; //User-defined by default
    if (stricmp(v,"romfolder")==0) {cdir=0;};
    if (stricmp(v,"appfolder")==0) {cdir=1;};

v = gtkopts_getvalue("country");
    country = 0; //autodetect	
    if (stricmp(v,"u")==0) country=4;
    if (stricmp(v,"j")==0) country=1;
    if (stricmp(v,"e")==0) country=8;

v = gtkopts_getvalue("fullscreen");
    if (stricmp(v,"true")==0) {fullscreen=1;} else { fullscreen=0; };

v = gtkopts_getvalue("benchmark");    
    if (stricmp(v,"true")==0) {benchmark=1;} else { benchmark=0; };

v = gtkopts_getvalue("mt");
    mt = 0;	
    if (stricmp(v,"none")==0) mt=0;
    if (stricmp(v,"two")==0) mt=1;
    if (stricmp(v,"four")==0) mt=2;

//
    get_num_val("renderer",&renderer);

    get_num_val("scale",&scale);

v = gtkopts_getvalue("sixbuttonpad");
    if (stricmp(v,"true")==0) {sixbuttonpad=1;} else { sixbuttonpad=0; };

//get_num_val("key_switch",&key_switch);
get_num_val("key_start",&key_start);
get_num_val("key_up",&key_up);
get_num_val("key_down",&key_down);
get_num_val("key_left",&key_left);
get_num_val("key_right",&key_right);
get_num_val("key_up_left",&key_up_left);
get_num_val("key_up_right",&key_up_right);
get_num_val("key_down_right",&key_down_right);
get_num_val("key_down_left",&key_down_left);
get_num_val("key_a",&key_a);
get_num_val("key_b",&key_b);
get_num_val("key_c",&key_c);
get_num_val("key_x",&key_x);
get_num_val("key_y",&key_y);
get_num_val("key_z",&key_z);
get_num_val("key_mode",&key_mode);

/*
get_num_val("tapzones",&temp);
if (temp==6) tmod=2;
if (temp==9) tmod=3;

get_tz("tapzone_1",&tzones[0]);
get_tz("tapzone_2",&tzones[1]);
get_tz("tapzone_3",&tzones[2]);
get_tz("tapzone_4",&tzones[3]);
get_tz("tapzone_5",&tzones[4]);
get_tz("tapzone_6",&tzones[5]);
get_tz("tapzone_7",&tzones[6]);
get_tz("tapzone_8",&tzones[7]);
get_tz("tapzone_9",&tzones[8]);

*/

}