int main(int argc, char **argv) { TextStartup(); ShowTitle(); // skip program name itself argv++, argc--; if (argc <= 0) { ShowInfo(); TextShutdown(); exit(1); } if (strcmp(argv[0], "/?") == 0 || strcmp(argv[0], "-h") == 0 || strcmp(argv[0], "-help") == 0 || strcmp(argv[0], "--help") == 0 || strcmp(argv[0], "-HELP") == 0 || strcmp(argv[0], "--HELP") == 0) { ShowOptions(); TextShutdown(); exit(1); } BuildArgumentList(argc, argv); info = default_buildinfo; comms = default_buildcomms; if (GLBSP_E_OK != GlbspParseArgs(&info, &comms, resp_argv, resp_argc)) { TextFatalError("Error: %s\n", comms.message ? comms.message : "(Unknown error when parsing args)"); } #if 0 if (! FileExists(info.filename)) TextFatalError("Error: Cannot find WAD file: %s\n", info.filename); #endif /* process file */ if (GLBSP_E_OK != GlbspCheckInfo(&info, &comms)) { TextFatalError("Error: %s\n", comms.message ? comms.message : "(Unknown error when checking args)"); } if (info.no_progress) TextDisableProgress(); if (GLBSP_E_OK != GlbspBuildNodes(&info, &cmdline_funcs, &comms)) { TextFatalError("Error: %s\n", comms.message ? comms.message : "(Unknown error during build)"); } TextShutdown(); FreeArgumentList(); return 0; }
int main(int argc, char **argv) { int extra_idx = 0; TextStartup(); ShowTitle(); // skip program name itself argv++, argc--; if (argc <= 0) { ShowInfo(); TextShutdown(); exit(1); } if (strcmp(argv[0], "/?") == 0 || strcmp(argv[0], "-h") == 0 || strcmp(argv[0], "-help") == 0 || strcmp(argv[0], "--help") == 0 || strcmp(argv[0], "-HELP") == 0 || strcmp(argv[0], "--HELP") == 0) { ShowOptions(); TextShutdown(); exit(1); } BuildArgumentList(argc, argv); info = default_buildinfo; comms = default_buildcomms; if (GLBSP_E_OK != GlbspParseArgs(&info, &comms, resp_argv, resp_argc)) { TextFatalError("Error: %s\n", comms.message ? comms.message : "(Unknown error when parsing args)"); } if (info.extra_files) { int ext_j; /* catch this mistake: glbsp in.wad out.wad (forget the -o) */ if (info.input_file && info.extra_files[0] && ! info.extra_files[1] && FileExists(info.input_file) && ! FileExists(info.extra_files[0])) { TextFatalError("Error: Cannot find WAD file: %s (" "Maybe you forgot -o)\n", info.extra_files[0]); } /* balk NOW if any of the input files doesn't exist */ if (! FileExists(info.input_file)) TextFatalError("Error: Cannot find WAD file: %s\n", info.input_file); for (ext_j = 0; info.extra_files[ext_j]; ext_j++) { if (FileExists(info.extra_files[ext_j])) continue; TextFatalError("Error: Cannot find WAD file: %s\n", info.extra_files[ext_j]); } } /* process each input file */ for (;;) { if (GLBSP_E_OK != GlbspCheckInfo(&info, &comms)) { TextFatalError("Error: %s\n", comms.message ? comms.message : "(Unknown error when checking args)"); } if (info.no_progress) TextDisableProgress(); if (GLBSP_E_OK != GlbspBuildNodes(&info, &cmdline_funcs, &comms)) { TextFatalError("Error: %s\n", comms.message ? comms.message : "(Unknown error during build)"); } /* when there are extra input files, process them too */ if (! info.extra_files || ! info.extra_files[extra_idx]) break; ShowDivider(); GlbspFree(info.input_file); GlbspFree(info.output_file); info.input_file = GlbspStrDup(info.extra_files[extra_idx]); info.output_file = NULL; extra_idx++; } TextShutdown(); FreeArgumentList(); return 0; }