summaryrefslogtreecommitdiffstats
path: root/src/prototype/getopt.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/prototype/getopt.c')
-rw-r--r--src/prototype/getopt.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/prototype/getopt.c b/src/prototype/getopt.c
new file mode 100644
index 0000000000..66cbad5d43
--- /dev/null
+++ b/src/prototype/getopt.c
@@ -0,0 +1,29 @@
+extern int optind;
+extern char *optarg;
+
+main(argc, argv)
+ int argc;
+ char **argv;
+{
+ int c;
+ int errflg = 0;
+
+ <<<other globals here>>>;
+
+ while ((c = getopt(argc, argv, "<<<>>>")) != EOF) {
+ switch (c) {
+ <<<add cases for arguments here>>>;
+ case '?':
+ default:
+ errflg++;
+ break;
+ }
+ }
+ if (errflg) {
+ fprintf(stderr, "Usage: %s <<<args>>>", argv[0]);
+ exit(2);
+ }
+ for (; optind < argc; optind++) {
+ <<<process arg optind>>>;
+ }
+}