/* p a r s _ A r g v () */ static int pars_Argv(int argc, char **argv) { int c; while ((c = bu_getopt(argc, argv, "hF:s:S:w:W:n:N:")) != -1) { switch (c) { case 'h' : scr_width = scr_height = 1024; break; case 'F': framebuffer = bu_optarg; break; case 'S': case 's': /* square file size */ scr_height = scr_width = atoi(bu_optarg); break; case 'w': case 'W': scr_width = atoi(bu_optarg); break; case 'n': case 'N': scr_height = atoi(bu_optarg); break; case '?' : return 0; } } if (argv[bu_optind] != NULL) flavor = atoi(argv[bu_optind]); return 1; }
int get_args(int argc, char **argv) { int c; while ((c = bu_getopt(argc, argv, "t:")) != -1) { switch (c) { case 't': switch (*bu_optarg) { case 'o': case 'O': dm_type = DM_TYPE_OGL; break; case 'x': case 'X': default: dm_type = DM_TYPE_X; break; } break; default: /* '?' */ return 0; } } if (bu_optind >= argc) { if (isatty(fileno(stdin))) return 0; } return 1; /* OK */ }
int get_args(int argc, register char **argv) { register int c; while ( (c = bu_getopt( argc, argv, "b:f:l:" )) != EOF ) { switch ( c ) { case 'b': bytes_per_sample = atoi(bu_optarg); break; case 'f': file_name = bu_optarg; break; case 'l': file_length = atoi(bu_optarg); break; default: /* '?' */ return(0); } } if ( argc > ++bu_optind ) (void)fprintf( stderr, "pixautosize: excess argument(s) ignored\n" ); return(1); /* OK */ }
int get_args(int argc, char **argv) { int c; verbose = 1; specify_base = force_shell = suppress_shell = 0; frame_offset = 0; while ((c=bu_getopt(argc, argv, OPT_STR)) != -1) { switch (c) { case 'q': verbose = 0; break; case 'b': specify_base = 1; user_base = atoi(bu_optarg); break; case 'f': force_shell = 1; suppress_shell = 0; break; case 's': suppress_shell = 1; force_shell = 0; break; case 'o': frame_offset = atoi(bu_optarg); break; default: fprintf(stderr, "Unknown option: -%c\n", c); return 0; } } return 1; }
/* code to read command line arguments*/ int get_args(int argc, char **argv) { int c; double scan; estimate_f = 0; while ((c=bu_getopt(argc, argv, OPT_STR)) != -1) { switch (c) { case 'b': sscanf(bu_optarg, "%lf", &scan); max_bank = scan; /* double to fastf_t */ estimate_f = 1; break; case 'f': sscanf(bu_optarg, "%lf", &scan); magic_factor = scan; /* double to fastf_t */ magic_factor *= 0.001; /* to put factors in a more reasonable range */ break; case 'p': sscanf(bu_optarg, "%d", &print_int); break; case 'r': loop = 0; break; case 's': sscanf(bu_optarg, "%lf", &scan); desired_step = scan; /* double to fastf_t */ break; default: return 0; } } return 1; }
/** @if no * P A R S E _ A R G S * @endif * @brief Parse command line flags. * * This routine handles parsing of all command line options. * * @param ac count of arguments * @param av array of pointers to null-terminated strings * @return index into av of first argument past options (new ac value) */ int parse_args(int ac, char *av[]) { int c; char *strrchr(); char *tmp_basename = NULL; /* Turn off bu_getopt's error messages */ bu_opterr = 0; /* get all the option flags from the command line */ while ((c=bu_getopt(ac, av, options)) != -1) { switch (c) { case 'd': debug = strtol(bu_optarg, NULL, 16); break; case '?': case 'h': default: tmp_basename = bu_basename(av[0]); usage(tmp_basename, "Bad or help flag specified\n"); bu_free(tmp_basename, "tmp_basename free"); break; } } return bu_optind; }
/* p a r s A r g ( ) Parse the command line arguments. */ int parsArg(int argc, char **argv) { register int i, c, arg_cnt; extern int bu_optind; while ( (c = bu_getopt( argc, argv, "d" )) != EOF ) { switch ( c ) { case 'd' : debug = 1; break; case '?' : return 0; } } if ( bu_optind >= argc ) { (void) fprintf( stderr, "Missing name of input file!\n" ); return 0; } else objfile = argv[bu_optind++]; if ( (dbip = db_open( objfile, "r" )) == DBI_NULL ) { perror(objfile); return( 0 ); /* FAIL */ } arg_list[0] = argv[0]; /* Program name goes in first. */ for ( i = bu_optind, arg_cnt = 1; i < argc; i++, arg_cnt++ ) /* Insert objects. */ arg_list[arg_cnt] = argv[i]; return 1; }
int get_args(int argc, char **argv) { int c; mode = QUATERNION; /* default */ units = DEGREES; while ( (c=bu_getopt(argc, argv, OPT_STR)) != EOF) { switch (c) { case 'y': mode = YPR; break; case 'z': mode = XYZ; break; case 'q': mode = QUATERNION; break; case 'r': units = RADIANS; break; default: fprintf(stderr, "Unknown option: -%c\n", c); return(0); } } return(1); }
int main(int argc, char **argv) { int c; FBIO *fbp; while ((c = bu_getopt(argc, argv, "F:h?")) != -1) { switch (c) { case 'F': framebuffer = bu_optarg; break; default: /* '?' */ (void)fputs(usage, stderr); return 1; } } if (argc > ++bu_optind) { fprintf(stderr, "fbfree: excess argument(s) ignored\n"); } if ((fbp = fb_open(framebuffer, 0, 0)) == FBIO_NULL) { fprintf(stderr, "fbfree: Can't open frame buffer\n"); return 1; } return fb_free(fbp); }
int parse_args(int ac, char **av) { int c; if (! (progname=strrchr(*av, '/'))) progname = *av; else ++progname; bu_strlcpy(plotfilename, progname, sizeof(plotfilename)); bu_strlcat(plotfilename, ".plot3", sizeof(plotfilename)); bu_strlcpy(mfilename, progname, sizeof(mfilename)); bu_strlcat(mfilename, ".g", sizeof(mfilename)); /* get all the option flags from the command line */ while ((c=bu_getopt(ac, av, options)) != -1) switch (c) { case '3' : manifold[3] = 0; break; case '2' : manifold[2] = 0; break; case '1' : manifold[1] = 0; break; case '0' : manifold[0] = 0; break; default : usage((char *)NULL,1); break; } return bu_optind; }
/* * P A R S E _ A R G S --- Parse through command line flags */ int parse_args(int ac, char **av) { int c; if ( ! (progname=strrchr(*av, '/')) ) progname = *av; else ++progname; /* Turn off bu_getopt's error messages */ bu_opterr = 0; /* get all the option flags from the command line */ while ((c=bu_getopt(ac, av, options)) != EOF) switch (c) { case 'd' : if ((c=atoi(bu_optarg)) > 0 ) depth = c; else fprintf(stderr, "bad # of bytes per pixel (%d)\n", c); break; case '?' : case 'h' : default : usage("Bad or help flag specified\n"); break; } return(bu_optind); }
int get_args(int argc, register char **argv) { register int c; while ( (c = bu_getopt( argc, argv, "m:p:f:" )) != EOF ) { switch ( c ) { case 'm': max = atoi(bu_optarg); if ((max < 0) || (max > 255)) { fprintf(stderr, "pixfade: max out of range"); bu_exit (1, NULL); } break; case 'p': multiplier = atof(bu_optarg) / 100.0; if (multiplier < 0.0) { fprintf(stderr, "pixfade: percent is negitive"); bu_exit (1, NULL); } break; case 'f': multiplier = atof(bu_optarg); if (multiplier < 0.0) { fprintf(stderr, "pixfade: fraction is negitive"); bu_exit (1, NULL); } break; default: /* '?' */ return(0); } } if ( bu_optind >= argc ) { if ( isatty(fileno(stdin)) ) { fprintf(stderr, "pixfade: stdin is a tty\n"); return(0); } inp = stdin; } else { if ( (inp = fopen(argv[bu_optind], "r")) == NULL ) { (void)fprintf( stderr, "pixfade: cannot open \"%s\" for reading\n", argv[bu_optind] ); return(0); } } if ( argc > ++bu_optind ) (void)fprintf( stderr, "pixfade: excess argument(s) ignored\n" ); if ( isatty(fileno(stdout)) ) { fprintf(stderr, "pixfade: stdout is a tty\n"); return(0); } return(1); /* OK */ }
int get_args(int argc, register char **argv) { register int c; while ( (c = bu_getopt( argc, argv, "hiF:X:Y:s:w:n:" )) != EOF ) { switch ( c ) { case 'h': /* high-res */ height = width = 1024; break; case 'i': inverse = 1; break; case 'F': framebuffer = bu_optarg; break; case 'X': scr_xoff = atoi(bu_optarg); break; case 'Y': scr_yoff = atoi(bu_optarg); break; case 's': /* square size */ height = width = atoi(bu_optarg); break; case 'w': width = atoi(bu_optarg); break; case 'n': height = atoi(bu_optarg); break; default: /* '?' */ return(0); } } if ( bu_optind >= argc ) { if ( isatty(fileno(stdout)) ) return(0); file_name = "-"; outfp = stdout; } else { file_name = argv[bu_optind]; if ( (outfp = fopen(file_name, "wb")) == NULL ) { (void)fprintf( stderr, "fb-bw: cannot open \"%s\" for writing\n", file_name ); return(0); } } if ( argc > ++bu_optind ) (void)fprintf( stderr, "fb-bw: excess argument(s) ignored\n" ); return(1); /* OK */ }
int get_args(int argc, char **argv) { int c; while ((c = bu_getopt(argc, argv, "chiF:s:w:n:")) != -1) { switch (c) { case 'c': crunch = 1; break; case 'h': /* high-res */ screen_height = screen_width = 1024; break; case 'i': inverse = 1; break; case 'F': framebuffer = bu_optarg; break; case 's': /* square size */ screen_height = screen_width = atoi(bu_optarg); break; case 'w': screen_width = atoi(bu_optarg); break; case 'n': screen_height = atoi(bu_optarg); break; default: /* '?' */ return 0; } } if (bu_optind >= argc) { if (isatty(fileno(stdout))) return 0; file_name = "-"; outfp = stdout; } else { file_name = argv[bu_optind]; if ((outfp = fopen(file_name, "wb")) == NULL) { fprintf(stderr, "fb-pix: cannot open \"%s\" for writing\n", file_name); return 0; } (void)bu_fchmod(fileno(outfp), 0444); } if (argc > ++bu_optind) fprintf(stderr, "fb-pix: excess argument(s) ignored\n"); return 1; /* OK */ }
field1.pix field2.pix > file.pix\n"; int get_args(int argc, register char **argv) { register int c; while ( (c = bu_getopt( argc, argv, "vw:n:s:" )) != EOF ) { switch ( c ) { case 'v': verbose++; break; case 'w': width = atoi(bu_optarg); break; case 'n': height = atoi(bu_optarg); break; case 's': width = height = atoi(bu_optarg); break; default: /* '?' */ return(0); } } if ( bu_optind >= argc + 1 ) { (void) fprintf( stderr, "pixfields: must supply two file names\n"); return(0); } else { if ( (fldonefp = fopen(argv[bu_optind], "r")) == NULL ) { (void)fprintf( stderr, "pixfields: cannot open \"%s\" for reading\n", argv[bu_optind] ); return(0); } if ( (fldtwofp = fopen(argv[++bu_optind], "r")) == NULL ) { (void)fprintf( stderr, "pixfields: cannot open \"%s\" for reading\n", argv[bu_optind] ); return(0); } } if ( isatty(fileno(stdout)) ) return(0); if ( argc > ++bu_optind ) (void)fprintf( stderr, "pixfields: excess argument(s) ignored\n" ); return(1); /* OK */ }
int get_args(int argc, register char **argv) { register int c; while ( (c = bu_getopt( argc, argv, "ahs:w:n:" )) != EOF ) { switch ( c ) { case 'a': autosize = 1; break; case 'h': /* high-res */ file_width = 1024L; autosize = 0; break; case 's': /* square file size */ file_width = atol(bu_optarg); autosize = 0; break; case 'w': file_width = atol(bu_optarg); autosize = 0; break; case 'n': autosize = 0; break; default: /* '?' */ return(0); } } if ( bu_optind >= argc ) { if ( isatty(fileno(stdin)) ) return(0); file_name = "-"; infp = stdin; } else { file_name = argv[bu_optind]; if ( (infp = fopen(file_name, "r")) == NULL ) { perror(file_name); (void)fprintf( stderr, "pixhalve: cannot open \"%s\" for reading\n", file_name ); return(0); } fileinput++; } if ( argc > ++bu_optind ) (void)fprintf( stderr, "pixhalve: excess argument(s) ignored\n" ); return(1); /* OK */ }
int main(int argc, char *argv[]) { static const char usage[] = "Usage:\n%s [-o outfile] \n\n -o file \tFile to write out (default: ringworld.g)\n\n"; char outfile[MAXPATHLEN] = "ringworld.g"; int optc; struct rt_wdb *fp; while ((optc = bu_getopt(argc, argv, "o:h?")) != -1) { if (bu_optopt == '?') optc='h'; switch (optc) { case 'o': snprintf(outfile, MAXPATHLEN, "%s", bu_optarg); break; default: fprintf(stderr,usage, *argv); return optc == '?' ? EXIT_FAILURE : EXIT_SUCCESS; } } if (argc == 1) { fprintf(stderr,usage, *argv); fprintf(stderr," Program continues running:\n"); } if (bu_file_exists(outfile, NULL)) bu_exit(EXIT_FAILURE, "ERROR: %s already exists. Remove file and try again.", outfile); bu_log("Writing ringworld out to [%s]\n", outfile); fp = wdb_fopen(outfile); mk_sol(fp, SUN_DIAMETER); mk_ring(fp, RING_ORBIT, RING_WIDTH, RING_FLOOR_THICKNESS, RING_WALL_THICKNESS, RING_WALL_HEIGHT); mk_shadowring(fp, SHADOWRING_ORBIT, SHADOWRING_NUM, SHADOWRING_WIDTH, SHADOWRING_LENGTH, SHADOWRING_THICKNESS); /* generate a comb all.g */ { struct wmember c; BU_LIST_INIT(&c.l); mk_addmember("ring.r", &c.l, NULL, WMOP_UNION); mk_addmember("sun.r", &c.l, NULL, WMOP_UNION); /* mk_addmember("shadowring.r", &c.l, NULL, WMOP_UNION); */ mk_lcomb(fp, "all.g", &c, 0, NULL, NULL, NULL, 0); } wdb_close(fp); bu_log("BRL-CAD geometry database file [%s] created.\nDone.\n", outfile); return EXIT_SUCCESS; }
int get_args(int argc, register char **argv) { register int c; while ( (c = bu_getopt( argc, argv, "hvF:s:w:n:S:W:N:p:" )) != EOF ) { switch ( c ) { case 'v': verbose = 1; break; case 'h': /* high-res */ height = width = 1024; break; case 'F': framebuffer = bu_optarg; break; case 's': case 'S': height = width = atoi(bu_optarg); break; case 'w': case 'W': width = atoi(bu_optarg); break; case 'n': case 'N': height = atoi(bu_optarg); break; case 'p': port = atoi(bu_optarg); port_set = 1; break; default: /* '?' */ return(0); } } /* If no "-p port", port comes from 1st extra */ if ( (bu_optind < argc) && (port_set == 0) ) { port = atoi(argv[bu_optind++]); port_set = 1; } /* If no "-F framebuffer", fb comes from 2nd extra */ if ( (bu_optind < argc) && (framebuffer == NULL) ) { framebuffer = argv[bu_optind++]; } if ( argc > bu_optind ) return(0); /* print usage */ return(1); /* OK */ }
int get_args(int argc, char **argv) { int c; while ((c = bu_getopt(argc, argv, "as:w:n:h?")) != -1) { switch (c) { case 'a': autosize = 1; break; case 's': /* square file size */ file_height = file_width = atol(bu_optarg); autosize = 0; break; case 'w': file_width = atol(bu_optarg); autosize = 0; break; case 'n': file_height = atol(bu_optarg); autosize = 0; break; default: /* '?' */ return 0; } } if (bu_optind >= argc) { if (isatty(fileno(stdin))) return 0; file_name = "-"; infp = stdin; } else { file_name = argv[bu_optind]; if ((infp = fopen(file_name, "r")) == NULL) { perror(file_name); fprintf(stderr, "bw-png: cannot open \"%s\" for reading\n", file_name); bu_exit (1, NULL); } fileinput++; } if (argc > ++bu_optind) fprintf(stderr, "bw-png: excess argument(s) ignored\n"); return 1; /* OK */ }
int main(int argc, char **argv) { int c = 0; int in_num = 0; int format = 0; /* 0 = XML, 1 = HTML */ int list = 0; char outfile[MAXPATHLEN] = "attributes.xml"; char xref_id[MAXPATHLEN] = "auto_attributes"; const char *usage_str = "[-o output file] [-x xref id] [-f format number (0 = XML, 1 = HTML)] [-l]"; while ((c=bu_getopt(argc, argv, "f:lo:x:")) != -1) { switch (c) { case 'o' : memset(outfile, 0, MAXPATHLEN); bu_strlcpy(outfile, bu_optarg, MAXPATHLEN); break; case 'x' : memset(xref_id, 0, MAXPATHLEN); bu_strlcpy(xref_id, bu_optarg, MAXPATHLEN); break; case 'f' : sscanf(bu_optarg, "%d", &in_num); format = in_num; break; case 'l' : list = 1; break; default: bu_log("%s: %s\n", argv[0], usage_str); return -1; } } switch (format) { case 0: if (list) { gen_attr_xml_list(outfile, xref_id); } else { gen_attr_xml_table(outfile, xref_id); } break; case 1: break; default: bu_log("Error - unknown format %d\n", format); return -1; } return 0; }
static int GetArgs(int argc, const char *argv[]) /* process command arguments */ /* argument count */ /* argument strings */ { static int iflag = 0; /* set if "-i" option found */ static int oflag = 0; /* set if "-o" option found */ int c; /* option letter */ bu_optind = 1; while ((c = bu_getopt(argc, (char * const *)argv, "i:o:h?")) != -1) switch (c) { case 'i': if (iflag) { printf("cad_parea: too many -i options\n"); return 0; } iflag = 1; if (!BU_STR_EQUAL(bu_optarg, "-") && freopen(bu_optarg, "r", stdin) == NULL ) { printf("cad_parea: can't open \"%s\" for reading\n", bu_optarg); return 0; } break; case 'o': if (oflag) { printf("cad_parea: too many -o options\n"); return 0; } oflag = 1; if (!BU_STR_EQUAL(bu_optarg, "-") && freopen(bu_optarg, "w", stdout) == NULL ) { printf("cad_parea: can't open \"%s\" for writing\n", bu_optarg); return 0; } break; default: Usage(); /* print usage message */ return 0; } return 1; }
int parse_args (int ac, char *av[], struct beset_options *opts) { int c; bu_setprogname(av[0]); /* handle options */ bu_opterr = 0; bu_optind = 0; av++; ac--; while ((c=bu_getopt(ac, av, OPTIONS)) != -1) { switch (c) { case 'm': opts->mut_rate = atoi(bu_optarg); continue; case 'c': opts->cross_rate = atoi(bu_optarg); continue; case 'x': sscanf(bu_optarg, "%x", (unsigned int *)&RTG.debug ); continue; case 'p': opts->pop_size = atoi(bu_optarg); continue; case 'g': opts->gens = atoi(bu_optarg); continue; case 'r': opts->res = atoi(bu_optarg); continue; case 'u': opts->keep_upper = atoi(bu_optarg); continue; case 'l': opts->kill_lower = atoi(bu_optarg); continue; default: fprintf(stderr, "Unrecognized option: -%c\n", c); usage(); } } opts->keep_upper *= opts->pop_size/100.0; opts->kill_lower *= opts->pop_size/100.0; return bu_optind; }
/** * main application for both the client and server */ int main(int argc, char *argv[]) { const char * const argv0 = argv[0]; int c; int port = 2000; if (argc > 2) { usage("ERROR: Incorrect number of arguments\n", argv[0]); } /* process the command-line arguments after the application name */ while ((c = bu_getopt(argc, argv, "p:P:hH")) != -1) { switch (c) { case 'p': case 'P': port = atoi(bu_optarg); break; case 'h': case 'H': /* help */ usage(NULL, argv0); break; default: usage("ERROR: Unknown argument\n", argv0); } } argc -= bu_optind; argv += bu_optind; if (argc > 0) { usage("ERROR: Unexpected extra server arguments\n", argv0); } /* ignore broken pipes, on platforms where we have SIGPIPE */ #ifdef SIGPIPE (void)signal(SIGPIPE, SIG_IGN); #endif /* fire up the server */ bu_log("Listening on port %d\n", port); run_server(port); return 0; }
int main(int argc, char *argv[]) { static const char usage[] = "Usage:\n%s [-o outfile] [-n count]\n\n -o file \tFile to write out (default: metaball.g)\n -n count\tTotal metaball point count (default %d)\n\n"; static const int COUNTMAX = 555; char outfile[MAXPATHLEN] = "metaball.g"; int optc; long count = COUNTMAX; if (argc == 1) { fprintf(stderr,usage, *argv, COUNTMAX); fprintf(stderr," Program continues running:\n"); } while ((optc = bu_getopt(argc, argv, "o:n:h?")) != -1) { if (bu_optopt == '?') optc='h'; switch (optc) { case 'o': snprintf(outfile, MAXPATHLEN, "%s", bu_optarg); break; case 'n': count = atoi(bu_optarg); break; default: fprintf(stderr,usage, *argv, COUNTMAX); return optc == '?' ? EXIT_FAILURE : EXIT_SUCCESS; } } if (count <= 0) bu_exit(EXIT_FAILURE, "ERROR: count must be greater than zero"); if (bu_file_exists(outfile, NULL)) bu_exit(EXIT_FAILURE, "ERROR: %s already exists. Remove file and try again.", outfile); bu_log("Writing metaballs out to [%s]\n", outfile); /* make dinner */ make_spaghetti(outfile, "meatballs.s", count); bu_log("BRL-CAD geometry database file [%s] created.\nDone.\n", outfile); return EXIT_SUCCESS; }
int get_args(int argc, register char **argv) { register int c; while ( (c = bu_getopt( argc, argv, "efshF:S:W:N:" )) != EOF ) { switch ( c ) { case 'e': mode = M_EIA; break; case 's': mode = M_SMPTE; break; case 'f': mode = M_FCC; break; case 'h': /* high-res */ scr_height = scr_width = 1024; break; case 'F': framebuffer = bu_optarg; break; case 'S': scr_height = scr_width = atoi(bu_optarg); break; case 'W': scr_width = atoi(bu_optarg); break; case 'N': scr_height = atoi(bu_optarg); break; default: /* '?' */ return(0); } } if ( argc > ++bu_optind ) (void)fprintf( stderr, "fbcbars: excess argument(s) ignored\n" ); return(1); /* OK */ }
/* * G E T _ A R G S */ int get_args(int argc, register char **argv) { register int c; while ( (c = bu_getopt( argc, argv, "dhF:s:S:w:W:n:N:" )) != EOF ) { switch ( c ) { case 'd': debug = 1; break; case 'h': /* high-res */ scr_height = scr_width = 1024; break; case 'F': framebuffer = bu_optarg; break; case 'S': case 's': /* square file size */ scr_height = scr_width = atoi(bu_optarg); break; case 'w': case 'W': scr_width = atoi(bu_optarg); break; case 'n': case 'N': scr_height = atoi(bu_optarg); break; default: /* '?' */ return(0); } } if ( bu_optind >= argc ) return(0); return(1); /* OK */ }
int dm_processOptions(dm *dmp, struct bu_vls *init_proc_vls, int argc, char **argv) { int c; bu_optind = 0; /* re-init bu_getopt */ bu_opterr = 0; while ((c = bu_getopt(argc, argv, "N:S:W:s:d:i:n:t:")) != -1) { switch (c) { case 'N': dmp->dm_height = atoi(bu_optarg); break; case 'S': case 's': dmp->dm_width = dmp->dm_height = atoi(bu_optarg); break; case 'W': dmp->dm_width = atoi(bu_optarg); break; case 'd': bu_vls_strcpy(&dmp->dm_dName, bu_optarg); break; case 'i': bu_vls_strcpy(init_proc_vls, bu_optarg); break; case 'n': if (*bu_optarg != '.') bu_vls_printf(&dmp->dm_pathName, ".%s", bu_optarg); else bu_vls_strcpy(&dmp->dm_pathName, bu_optarg); break; case 't': dmp->dm_top = atoi(bu_optarg); break; default: bu_log("dm_processOptions: option '%c' unknown\n", bu_optopt); break; } } return bu_optind; }
[-w file_width] [-n file_height] [file.pix] > outfile.pix\n"; static int get_args(int argc, char **argv) { int c; while ((c = bu_getopt(argc, argv, "hs:w:n:")) != -1) { switch (c) { case 'h': /* high-res */ file_height = file_width = 1024; break; case 's': /* square file size */ file_height = file_width = atoi(bu_optarg); break; case 'w': file_width = atoi(bu_optarg); break; case 'n': file_height = atoi(bu_optarg); break; case '?': return 0; } } if (argv[bu_optind] != NULL) { if ((infp = fopen(argv[bu_optind], "r")) == NULL) { perror(argv[bu_optind]); return 0; } bu_optind++; } if (argc > ++bu_optind) (void) fprintf(stderr, "Excess arguments ignored\n"); if (isatty(fileno(infp)) || isatty(fileno(stdout))) return 0; return 1; }
int get_args(int argc, char **argv) { int c; suppressed = 0; while ((c=bu_getopt(argc, argv, OPT_STR)) != -1) { switch (c) { case 'c': suppressed = 1; break; case 'i': incremental = 1; break; default: fprintf(stderr, "Unknown option: -%c\n", c); return 0; } } return 1; }
int get_args(int argc, char **argv) { int c; while ((c = bu_getopt(argc, argv, "hF:s:S:w:W:n:N:")) != -1) { switch (c) { case 'h': /* high-res */ scr_height = scr_width = 1024; break; case 'F': framebuffer = bu_optarg; break; case 's': case 'S': scr_height = scr_width = atoi(bu_optarg); break; case 'w': case 'W': scr_width = atoi(bu_optarg); break; case 'n': case 'N': scr_height = atoi(bu_optarg); break; default: /* '?' */ return 0; } } if (bu_optind < argc) { nframes = atoi(argv[bu_optind]); } if (argc > ++bu_optind) fprintf(stderr, "dunnsnap: excess argument(s) ignored\n"); return 1; /* OK */ }