int main(int ac, char **av) { t_data *d; if (init_start(&d, ac, av) < 0 || render_init(d) < 0) { exit_free(); return (error("main:: Initialization error")); } run_the_game(d); return (0); }
int main(int argc, char **argv) { int port; char buf[512]; int pos = 1; char *dir; port = DFLT_PORT; dir = DFLT_DIR; while ((pos < argc) && (*(argv[pos]) == '-')) { switch (*(argv[pos] + 1)) { case 'l': lawful = 1; log("Lawful mode selected."); break; case 'd': if (*(argv[pos] + 2)) dir = argv[pos] + 2; else if (++pos < argc) dir = argv[pos]; else { log("Directory arg expected after option -d."); exit(0); } break; case 's': no_specials = 1; log("Suppressing assignment of special routines."); break; default: sprintf(buf, "Unknown option -% in argument string.", *(argv[pos] + 1)); log(buf); break; } pos++; } if (pos < argc) if (!isdigit(*argv[pos])) { fprintf(stderr, "Usage: %s [-l] [-s] [-d pathname] [ port # ]\n", argv[0]); exit(0); } else if ((port = atoi(argv[pos])) <= 1024) { printf("Illegal port #\n"); exit(0); } sprintf(buf, "Running game on port %d.", port); log(buf); if (chdir(dir) < 0) { perror("chdir"); exit(0); } sprintf(buf, "Using %s as data directory.", dir); log(buf); srandom(time(0)); run_the_game(port); return(0); }