int main(int argc, char * argv[]) { if(argc != 2) { puts("No file detected"); exit(0); } FILE * fp; char * snitch = NULL; time_t tiem = 0; uint8_t verbosity = 0; uint8_t NameOffset = 9+PLAYER_N; struct Planet TheirPlanet = {NULL,NULL,0,0,0}; struct Resource TheirResource = {0,0,0}; struct Fleet TheirFleet = {0,0,0,0,0,0,0,0,0,0,0,0,0,0}; struct Defense TheirDefense = {0,0,0,0,0,0,0,0,0,0}; struct Building TheirBuildings = {0,0,0,0,0,0,0,0}; struct Research TheirResearch = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; fp = fopen(argv[1],"r"); if(fp == NULL) { puts("Null or nonexistent file"); exit(0); } snitch = whosaidthat(&fp); get_tango(&fp, &TheirPlanet); puts("Calling function..."); tiem = r_time(&fp); TheirPlanet.Owner = losersname(&fp,NameOffset); booty(&fp, &TheirResource); verbosity = get_verbosity(&fp); if(verbosity == 1) { verbosity += dummies(&fp,&TheirFleet); } if(verbosity == 2) { verbosity += bunker(&fp,&TheirDefense); } if(verbosity == 3) { verbosity += shanty(&fp,&TheirBuildings); } if(verbosity == 4) { edumucation(&fp,&TheirResearch); } /* printf("Metal: %lu\nCrystal: %lu\nDeuterium: %lu\n",TheirResource.Metal,TheirResource.Crystal,TheirResource.Deuterium); */ printf("%llu\n",(long long)tiem); puts(snitch); fclose(fp); return 0; }
int main(void) { struct tms tstart, tend; register int ncpy; int each; char *from; from = malloc (SIZE+1); if (!from) { fprintf (stderr, "malloc: %s\n", strerror(errno)); _exit (1); } printf ("Using values: %d bytes; %d times\n\n", SIZE, NCPY); printf ("setting string ... "); fflush (stdout); { char *p = from; register char r; ncpy = SIZE; /* temp */ while (ncpy--) { srand (rand()); r = (rand() % 255) + 1; /* return 0-254, add 1 */ *p++ = r; } *p = 0; } printf ("strlen = %u\n", (unsigned) strlen (from)); each = EACH; do { lx_s sfrom; /* explicitly defined */ sfrom.s = from; sfrom.len = SIZE; sfrom.alloc = SIZE; printf ("testing lx_strrev ... "); fflush(stdout); times (&tstart); for (ncpy = NCPY; ncpy > 0; ncpy-=3) { lx_strrev (&sfrom); lx_strrev (&sfrom); lx_strrev (&sfrom); } times (&tend); printf ("\t%s\n", r_time (&tstart, &tend)); } while (--each); return 0; }