diff options
Diffstat (limited to 'src/foodopts.c')
-rw-r--r-- | src/foodopts.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/foodopts.c b/src/foodopts.c index fac807d..eff281c 100644 --- a/src/foodopts.c +++ b/src/foodopts.c @@ -36,10 +36,10 @@ to_getopt_longopts(const struct foodoption * src) int get_foodopt(int argc, char *const argv[], const char *optstring, - const struct foodoption *longopts, + const struct foodoption *lopts, int *longindex) { - struct option * o = to_getopt_longopts(longopts); + struct option * o = to_getopt_longopts(lopts); int rc = getopt_long(argc, argv, optstring, o, longindex); free(o); @@ -48,13 +48,13 @@ get_foodopt(int argc, char *const argv[], const char * get_argument(const char opt, - const struct foodoption *longopts) + const struct foodoption *lopts) { int i = 0; - while ((longopts[i].name) - && (longopts[i].val)) { - if (longopts[i].val == opt) - return longopts[i].arg; + while ((lopts[i].name) + && (lopts[i].val)) { + if (lopts[i].val == opt) + return lopts[i].arg; i++; } return NULL; @@ -62,24 +62,26 @@ get_argument(const char opt, void foodopt_help(char * argv0, - const struct foodoption *longopts) + const struct foodoption *lopts) { fprintf(stderr, "%s [OPTION ...] FILE ...\n", argv0); fprintf(stderr, "\nOPTIONS:\n"); int i = 0; - while ((longopts[i].name) - && (longopts[i].val)) { - if (longopts[i].category) { - fprintf(stderr, "\n%s:\n", longopts[i].category); + while ((lopts[i].name) + && (lopts[i].val)) { + if (lopts[i].category) { + fprintf(stderr, "\n%s:\n", lopts[i].category); } fprintf(stderr, "-%c, --%s%s%s: %s\n", - longopts[i].val, - longopts[i].name, - (longopts[i].has_arg == required_argument || longopts[i].has_arg == optional_argument) ? " " : "", - (longopts[i].has_arg == required_argument || longopts[i].has_arg == optional_argument) ? longopts[i].arg : "", - longopts[i].help); + lopts[i].val, + lopts[i].name, + (lopts[i].has_arg == required_argument || + lopts[i].has_arg == optional_argument) ? " " : "", + (lopts[i].has_arg == required_argument || + lopts[i].has_arg == optional_argument) ? lopts[i].arg : "", + lopts[i].help); i++; } } |