aboutsummaryrefslogtreecommitdiff
path: root/src/rpt.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rpt.c')
-rw-r--r--src/rpt.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/rpt.c b/src/rpt.c
new file mode 100644
index 0000000..f0a9472
--- /dev/null
+++ b/src/rpt.c
@@ -0,0 +1,56 @@
+#define _GNU_SOURCE /* getopt_long */
+
+#include <getopt.h>
+#include <stdio.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+void
+print_usage(FILE *output)
+{
+ fprintf(output, "Usage:\n");
+ fprintf(output, "rpt [-n | --count COUNT] [-f | --force] COMMAND\n");
+ fprintf(output, "rpt [-h | --help]\n");
+ fprintf(output, "rpt [-V | --version]\n");
+}
+
+int
+main(int argc, char* argv[])
+{
+ struct option const opts[] = {
+ {"count", required_argument, NULL, 'n'},
+ {"force", no_argument, NULL, 'f'},
+ {"version", no_argument, NULL, 'V'},
+ {"help", no_argument, NULL, 'h'},
+ {NULL, 0, NULL, 0}
+ };
+
+ opterr = 0; /* dismiss getopt error message */
+ int opt;
+
+ char *strcount = NULL;
+ long count;
+
+ void (*handle_exit_f)(int status);
+
+ while ((opt = getopt_long(argc, argv, "+:n:fVh", opts, NULL)) >= 0)
+ {
+ switch(opt)
+ {
+ case 'n':
+ strcount = optarg;
+ break;
+ case 'f':
+
+ case ':':
+ fprintf(stderr, "COUNT value missing.\n");
+ print_usage(stderr);
+ return 1;
+ default:
+ print_usage(stderr);
+ return 1;
+ }
+ }
+
+ return 0;
+}