diff options
Diffstat (limited to 'src/opt.c')
-rw-r--r-- | src/opt.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/opt.c b/src/opt.c new file mode 100644 index 0000000..7b6d083 --- /dev/null +++ b/src/opt.c @@ -0,0 +1,46 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <errno.h> +#include <string.h> + +#include "config.h" +#include "opt.h" + +#define CONFIG_OPT(default_val) { {0},0,{default_val} } + +struct opt config_opts[] = { CONFIG_OPT(DEFAULT_FIFO), CONFIG_OPT(NULL) }; +const int opt_siz = ( sizeof(config_opts)/sizeof(config_opts[0]) ); + + +void +usage(char *arg0) +{ + fprintf(stderr, "\n%s (%s)\n %s\n", PKGNAME, VERSION, PKGDESC); + fprintf(stderr, " Written by %s (%s).\n", AUTHOR, AUTHOR_EMAIL); + fprintf(stderr, " License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n\n"); + fprintf(stderr, " Command:\n\t%s [args]\n", arg0); + fprintf(stderr, " Arguments:\n\t-h this\n\t-f [passfifo] default: %s\n\t-c [cryptcreate]\n", DEFAULT_FIFO); +} + +int +parse_cmd(int argc, char **argv) +{ + int opt; + + while ((opt = getopt(argc, argv, "hf:c:")) != -1) { + switch (opt) { + case 'h': + usage(argv[0]); + return 1; + case 'f': + s_OPT(FIFO_PATH, strdup(optarg)); + break; + case 'c': + s_OPT(CRYPT_CMD, strdup(optarg)); + break; + } + } + return 0; +} + |