summaryrefslogtreecommitdiffstats
path: root/src/foodopts.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2022-11-26 17:41:37 +0200
committergramanas <anastasis.gramm2@gmail.com>2022-11-26 17:41:37 +0200
commit00160bcc716e4368246d04617f6d6d57433074a3 (patch)
tree83f58fa08c7322cdb2fdc92b79ad22b046f3f731 /src/foodopts.c
parent8ef08604932c05ebfabb041704dc6f994d7a93a7 (diff)
downloadfoodtools-master.tar.gz
foodtools-master.tar.bz2
foodtools-master.zip
shorten longoptsHEADmaster
Diffstat (limited to 'src/foodopts.c')
-rw-r--r--src/foodopts.c36
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++;
}
}