int main(int argc, char **argv) { int num; char *name = argv[0]; if (argc < 3) usage(name); if (!strcmp(argv[1], "start")) { if (argc < 4) usage(name); num = atoi(argv[3]); if (num <= 0) usage(name); btrace_start(argv[2], num); } else if (!strcmp(argv[1], "stop")) { if (argc < 4) usage(name); btrace_stop(argv[2], argv[3]); } else if (!strcmp(argv[1], "reset")) { btrace_reset(argv[2]); } else if (!strcmp(argv[1], "dump")) { btrace_dump(argv[2]); } else usage(name); return EXIT_SUCCESS; }
int main(int argc, char** argv) { struct gengetopt_args_info info; char *infile = NULL, *outfile = NULL; glopt_t opt = {0}; /* use gengetopt */ if (options(argc, argv, &info) != 0) { fprintf(stderr, "failed to parse command line\n"); return EXIT_FAILURE; } /* check arguments & transfer to opt structure */ opt.verbose = info.verbose_given; opt.numsamp = info.samples_arg; if (opt.numsamp < 1) { fprintf(stderr,"bad number of samples %zu\n",opt.numsamp); return EXIT_FAILURE; } /* null outfile for stdout */ outfile = (info.output_given ? info.output_arg : NULL); if (!outfile && opt.verbose) { fprintf(stderr,"verbosity suppressed (<stdout> for results)\n"); opt.verbose = 0; } /* null infile for stdin */ switch (info.inputs_num) { case 0: infile = NULL; break; case 1: infile = info.inputs[0]; break; default: fprintf(stderr,"Sorry, only one file at a time\n"); return EXIT_FAILURE; } if (opt.verbose) printf("This is gimplut (version %s)\n", VERSION); btrace_enable("gimplut"); int err = gimplut(infile, outfile, opt); if (err) { btrace("failed (error %i)", err); btrace_print_stream(stderr, BTRACE_PLAIN); if (info.backtrace_file_given) { int format = BTRACE_XML; if (info.backtrace_format_given) { format = btrace_format(info.backtrace_format_arg); if (format == BTRACE_ERROR) { fprintf(stderr, "no such backtrace format %s\n", info.backtrace_format_arg); return EXIT_FAILURE; } } btrace_print(info.backtrace_file_arg, format); } } else if (opt.verbose) printf("lookup table written to %s\n",(outfile ? outfile : "<stdin>")); btrace_reset(); btrace_disable(); if (opt.verbose) printf("done.\n"); options_free(&info); return (err ? EXIT_FAILURE : EXIT_SUCCESS); }
int main(int argc,char** argv) { struct gengetopt_args_info info; cptcat_opt_t opt = {0}; /* use gengetopt */ if (options(argc, argv, &info) != 0) { fprintf(stderr,"failed to parse command line\n"); return EXIT_FAILURE; } /* check arguments & transfer to opt structure */ opt.verbose = info.verbose_given; opt.output = (info.output_given ? info.output_arg : NULL); if (!opt.output && opt.verbose) { fprintf(stderr,"verbosity suppressed (<stdout> for results)\n"); opt.verbose = 0; } if (info.inputs_num < 2) { fprintf(stderr,"at least 2 input files required\n"); return EXIT_FAILURE; } opt.input.n = info.inputs_num; opt.input.file = (const char**)info.inputs; if (opt.verbose) printf("This is cptcat (version %s)\n",VERSION); btrace_enable("cptcat"); int err = cptcat(opt); if (err) { btrace("failed (error %i)", err); btrace_print_stream(stderr, BTRACE_PLAIN); if (info.backtrace_file_given) { int format = BTRACE_XML; if (info.backtrace_format_given) { format = btrace_format(info.backtrace_format_arg); if (format == BTRACE_ERROR) { fprintf(stderr, "no such backtrace format %s\n", info.backtrace_format_arg); return EXIT_FAILURE; } } btrace_print(info.backtrace_file_arg, format); } } btrace_reset(); btrace_disable(); if (opt.verbose) printf("done.\n"); options_free(&info); return (err ? EXIT_FAILURE : EXIT_SUCCESS); }
int main(int argc, char** argv) { struct gengetopt_args_info info; char *infile = NULL, *outfile = NULL; gimpsvg_opt_t opt = {0}; /* use gengetopt */ if (options(argc, argv, &info) != 0) { fprintf(stderr, "failed to parse command line\n"); return EXIT_FAILURE; } /* check arguments & transfer to opt structure */ opt.verbose = info.verbose_given; opt.reverse = false; if ((opt.samples = info.samples_arg) < SAMPLES_MIN) { fprintf(stderr, "at least %i samples required\n", SAMPLES_MIN); opt.samples = SAMPLES_MIN; } /* handle preview */ if (info.preview_flag || info.geometry_given) { opt.preview.use = true; if (svg_preview_geometry(info.geometry_arg, &(opt.preview)) != 0) { fprintf(stderr, "failed parse of geometry : %s\n", info.geometry_arg); return EXIT_FAILURE; } } else opt.preview.use = false; /* null outfile for stdout */ outfile = (info.output_given ? info.output_arg : NULL); if (!outfile && opt.verbose) { fprintf(stderr, "verbosity suppressed (<stdout> for results)\n"); opt.verbose = 0; } /* null infile for stdin */ switch (info.inputs_num) { case 0: infile = NULL; break; case 1: infile = info.inputs[0]; break; default: fprintf(stderr, "Sorry, only one file at a time\n"); return EXIT_FAILURE; } if (opt.verbose) printf("This is gimpsvg (version %s)\n", VERSION); svg_srand(); btrace_enable("gimpsvg"); int err = gimpsvg(infile, outfile, opt); if (err) { btrace("failed (error %i)", err); btrace_print_stream(stderr, BTRACE_PLAIN); if (info.backtrace_file_given) { int format = BTRACE_XML; if (info.backtrace_format_given) { format = btrace_format(info.backtrace_format_arg); if (format == BTRACE_ERROR) { fprintf(stderr, "no such backtrace format %s\n", info.backtrace_format_arg); return EXIT_FAILURE; } } btrace_print(info.backtrace_file_arg, format); } } else if (opt.verbose) { printf("palette written to %s\n", (outfile ? outfile : "<stdin>")); if (opt.preview.use) { printf("with preview (%zu x %zu px)\n", opt.preview.width, opt.preview.height); } } btrace_reset(); btrace_disable(); if (opt.verbose) printf("done.\n"); options_free(&info); return (err ? EXIT_FAILURE : EXIT_SUCCESS); }