int main(int argc, char **argv) { program_name = argv[0]; int opt; static const struct option long_options[] = { { "help", no_argument, 0, CHAR_MAX + 1 }, { "version", no_argument, 0, 'v' }, { NULL, 0, 0, 0 } }; while ((opt = getopt_long(argc, argv, "CI:rtv", long_options, NULL)) != EOF) switch (opt) { case 'v': printf("GNU soelim (groff) version %s\n", Version_string); exit(0); break; case 'C': compatible_flag = 1; break; case 'I': include_search_path.command_line_dir(optarg); break; case 'r': raw_flag = 1; break; case 't': tex_flag = 1; break; case CHAR_MAX + 1: // --help usage(stdout); exit(0); break; case '?': usage(stderr); exit(1); break; default: assert(0); } int nbad = 0; if (optind >= argc) nbad += !do_file("-"); else for (int i = optind; i < argc; i++) nbad += !do_file(argv[i]); if (ferror(stdout) || fflush(stdout) < 0) fatal("output error"); return nbad != 0; }
int main(int argc, char **argv) { setlocale(LC_NUMERIC, "C"); program_name = argv[0]; string env; static char stderr_buf[BUFSIZ]; setbuf(stderr, stderr_buf); int c; static const struct option long_options[] = { { "help", no_argument, 0, CHAR_MAX + 1 }, { "version", no_argument, 0, 'v' }, { NULL, 0, 0, 0 } }; while ((c = getopt_long(argc, argv, "b:c:F:gI:lmp:P:vw:", long_options, NULL)) != EOF) switch(c) { case 'b': // XXX check this broken_flags = atoi(optarg); bflag = 1; break; case 'c': if (sscanf(optarg, "%d", &ncopies) != 1 || ncopies <= 0) { error("bad number of copies `%s'", optarg); ncopies = 1; } break; case 'F': font::command_line_font_dir(optarg); break; case 'g': guess_flag = 1; break; case 'I': include_search_path.command_line_dir(optarg); break; case 'l': landscape_flag = 1; break; case 'm': manual_feed_flag = 1; break; case 'p': if (!font::scan_papersize(optarg, 0, &user_paper_length, &user_paper_width)) error("invalid custom paper size `%1' ignored", optarg); break; case 'P': env = "GROPS_PROLOGUE"; env += '='; env += optarg; env += '\0'; if (putenv(strsave(env.contents()))) fatal("putenv failed"); break; case 'v': printf("GNU grops (groff) version %s\n", Version_string); exit(0); break; case 'w': if (sscanf(optarg, "%d", &linewidth) != 1 || linewidth < 0) { error("bad linewidth `%1'", optarg); linewidth = -1; } break; case CHAR_MAX + 1: // --help usage(stdout); exit(0); break; case '?': usage(stderr); exit(1); break; default: assert(0); } font::set_unknown_desc_command_handler(handle_unknown_desc_command); SET_BINARY(fileno(stdout)); if (optind >= argc) do_file("-"); else { for (int i = optind; i < argc; i++) do_file(argv[i]); } return 0; }
void font::command_line_font_dir(const char *dir) { font_path.command_line_dir(dir); }
static int scanArguments(int argc, char **argv) { const char *command_prefix = getenv("GROFF_COMMAND_PREFIX"); if (!command_prefix) command_prefix = PROG_PREFIX; char *troff_name = new char[strlen(command_prefix) + strlen("troff") + 1]; strcpy(troff_name, command_prefix); strcat(troff_name, "troff"); int c, i; static const struct option long_options[] = { { "help", no_argument, 0, CHAR_MAX + 1 }, { "version", no_argument, 0, 'v' }, { NULL, 0, 0, 0 } }; while ((c = getopt_long(argc, argv, "+a:bdD:eF:g:hi:I:j:lno:prs:S:vVx:y", long_options, NULL)) != EOF) switch(c) { case 'a': textAlphaBits = min(max(MIN_ALPHA_BITS, atoi(optarg)), MAX_ALPHA_BITS); if (textAlphaBits == 3) { error("cannot use 3 bits of antialiasing information"); exit(1); } break; case 'b': // handled by post-grohtml (set background color to white) break; case 'd': #if defined(DEBUGGING) debug = TRUE; #endif break; case 'D': image_dir = optarg; break; case 'e': eqn_flag = TRUE; break; case 'F': font_path.command_line_dir(optarg); break; case 'g': graphicAlphaBits = min(max(MIN_ALPHA_BITS, atoi(optarg)), MAX_ALPHA_BITS); if (graphicAlphaBits == 3) { error("cannot use 3 bits of antialiasing information"); exit(1); } break; case 'h': // handled by post-grohtml break; case 'i': image_res = atoi(optarg); break; case 'I': image_template = optarg; break; case 'j': // handled by post-grohtml (set job name for multiple file output) break; case 'l': // handled by post-grohtml (no automatic section links) break; case 'n': // handled by post-grohtml (generate simple heading anchors) break; case 'o': vertical_offset = atoi(optarg); break; case 'p': show_progress = TRUE; break; case 'r': // handled by post-grohtml (no header and footer lines) break; case 's': // handled by post-grohtml (use font size n as the html base font size) break; case 'S': // handled by post-grohtml (set file split level) break; case 'v': printf("GNU pre-grohtml (groff) version %s\n", Version_string); exit(0); case 'V': // handled by post-grohtml (create validator button) break; case 'x': // html dialect if (strcmp(optarg, "x") == 0) dialect = xhtml; else if (strcmp(optarg, "4") == 0) dialect = html4; else printf("unsupported html dialect %s (defaulting to html4)\n", optarg); break; case 'y': // handled by post-grohtml (create groff signature) break; case CHAR_MAX + 1: // --help usage(stdout); exit(0); break; case '?': usage(stderr); exit(1); break; default: break; } i = optind; while (i < argc) { if (strcmp(argv[i], troff_name) == 0) troff_arg = i; else if (argv[i][0] != '-') return i; i++; } a_delete troff_name; return argc; }