/* $OpenBSD: getopt,v 1.8 2006/02/01 09:27:28 otto Exp $ */ /* * Main/getopt(3) fragment. * * from: @(#)getopt 5.3 (Berkeley) 3/28/94 */ #include #include #include __dead void usage(void); int main(int argc, char *argv[]) { int bflag, ch; char *file; bflag = 0; file = NULL; while ((ch = getopt(argc, argv, "bf:")) != -1) switch (ch) { case 'b': bflag = 1; break; case 'f': file = optarg; break; default: usage(); /* NOTREACHED */ } argc -= optind; argv += optind; return (0); } void usage(void) { extern char *__progname; (void)fprintf(stderr, "usage: %s [-b] [-f file]\n", __progname); exit(1); }