static void ProcessResponseFile(const char *filename) { int word_len = 0; int in_quote = 0; FILE *fp = fopen(filename, "rb"); if (! fp) TextFatalError("Error: Cannot find RESPONSE file: %s\n", filename); // the word buffer is always kept NUL-terminated word_buffer[0] = 0; for (;;) { int ch = fgetc(fp); if (ch == EOF) break; if (isspace(ch) && !in_quote) { if (word_len > 0) AddArg(word_buffer); word_len = 0; in_quote = 0; continue; } if (isspace(ch) && !in_quote) continue; if ((ch == '\n' || ch == '\r') && in_quote) break; // causes the unclosed-quotes error if (ch == '"') { in_quote = ! in_quote; continue; } if (word_len >= MAX_WORD_LEN) TextFatalError("Error: option in RESPONSE file too long (limit %d chars)\n", MAX_WORD_LEN); word_buffer[word_len++] = ch; word_buffer[word_len] = 0; } if (in_quote) TextFatalError("Error: unclosed quotes in RESPONSE file\n"); if (word_len > 0) AddArg(word_buffer); fclose(fp); }
// // TextDisplaySetBar // void TextDisplaySetBar(int barnum, int count) { int perc; if (curr_disp == DIS_INVALID || disable_progress || progress_target <= 0) { return; } // select the correct bar if ((curr_disp == DIS_FILEPROGRESS && barnum != 1) || (curr_disp == DIS_BUILDPROGRESS && barnum != 1)) { return; } if (count > progress_target) TextFatalError("\nINTERNAL ERROR: Progress went past target !\n\n"); perc = count * 100 / progress_target; if (perc == progress_shown) return; if (perc == 0) ClearProgress(); else fprintf(stderr, "--%3d%%--\b\b\b\b\b\b\b\b", perc); progress_shown = perc; }
static void AddArg(const char *str) { if (resp_argc >= RESP_MAX_ARGS) TextFatalError("Error: Too many options! (limit is %d)\n", RESP_MAX_ARGS); resp_argv[resp_argc++] = GlbspStrDup(str); #if 0 // DEBUGGING fprintf(stderr, "Arg [%s]\n", str); #endif }
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; }