int main(int argc, char* argv[]) { // check for exactly one command line argument if (argc != 2) { fatal("TOO MANY ARGUMENTS\n", argv[0]); } char* infile = argv[1]; // try to open the file printf("Starting hex player on input file \"%s\"\n", infile); FILE* in; // defines in to be a stream in = fopen(infile, "r"); if (in == NULL) { fatal("Failed to open file %s for reading\n", infile); } Hexboard board = newHex(11,0,0,10); const Geometry* geom = getGeoHex(board); printf("Created board of dimension %i\n",11); printf("Bounding box of board: %i %i %lg %lg\n", (int) geom->x0, (int) geom->y0, geom->x1, geom->y1); printf("Hexagon dimensions:\n"); printf(" radius of inscribed circle = %lg\n", geom->h); printf(" radius of circumscribed circle = %lg\n", geom->s); printf("-----------------------------------------------\n\n"); int lineno; CellContents color = Red; for(lineno = 1;;lineno++) { if(executeGame(board, in, lineno, &color) == EOF) break; } freeHex(board); fclose(in); return 0; }
int mmain(int argc, const char *argv) { int result = 0; strcpy(gameName,argv); if(experimental_cmdline){ parse_cmdline(argv); write_log("executing from experimental cmdline... %s\n", gameName); result = executeGame_cmd(ARGUV[ARGUC-1]); } else { write_log("executing game... %s\n", gameName); result = executeGame(gameName); } return 1; }