aboutsummaryrefslogtreecommitdiff
path: root/check_opt.h
diff options
context:
space:
mode:
authorKlaatu <[email protected]>2015-05-17 15:33:21 +1200
committerKlaatu <[email protected]>2015-05-17 15:33:21 +1200
commitb0de699679e8f1e39af847ed172d1ba605b4370c (patch)
tree01dac00471d61f727394e508c613b29cff0ceae5 /check_opt.h
bulk upload of source
Diffstat (limited to 'check_opt.h')
-rw-r--r--check_opt.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/check_opt.h b/check_opt.h
new file mode 100644
index 0000000..610edd8
--- /dev/null
+++ b/check_opt.h
@@ -0,0 +1,8 @@
+static int check_opt(char **argv, char **opt) {
+ if (argv[0][2]) { *opt = argv[0]+2; return 0; }
+ else if (argv[1]) { *opt = argv[1]; return 1; }
+ carp("Option ",argv[0]," requires an argument");
+ _exit(1);
+}
+
+#define chk_opt(argv,opt) argv+=check_opt(argv,&opt)