aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxrs <xrs@mail36.net>2019-06-22 22:57:55 +0200
committerxrs <xrs@mail36.net>2019-06-22 22:57:55 +0200
commitd6c25f60406596d84900aa6ac012bf8ce111d57c (patch)
tree7418c56cf25b7e0fc4e84c714f76deddf15f75f6
parent93c332be89c4c65f10b7c4c49b6ed15d91b91884 (diff)
downloadgnunet-d6c25f60406596d84900aa6ac012bf8ce111d57c.tar.gz
gnunet-d6c25f60406596d84900aa6ac012bf8ce111d57c.zip
add flag for exlusive options as program agruments
-rw-r--r--src/include/gnunet_getopt_lib.h7
-rw-r--r--src/util/getopt.c12
-rw-r--r--src/util/getopt_helpers.c1
3 files changed, 18 insertions, 2 deletions
diff --git a/src/include/gnunet_getopt_lib.h b/src/include/gnunet_getopt_lib.h
index ddeeffef4..17e36d889 100644
--- a/src/include/gnunet_getopt_lib.h
+++ b/src/include/gnunet_getopt_lib.h
@@ -136,6 +136,11 @@ struct GNUNET_GETOPT_CommandLineOption
136 int option_mandatory; 136 int option_mandatory;
137 137
138 /** 138 /**
139 * Is the option exclusive?
140 */
141 int option_exclusive;
142
143 /**
139 * Handler for the option. 144 * Handler for the option.
140 */ 145 */
141 GNUNET_GETOPT_CommandLineOptionProcessor processor; 146 GNUNET_GETOPT_CommandLineOptionProcessor processor;
@@ -424,7 +429,7 @@ GNUNET_GETOPT_option_mandatory (struct GNUNET_GETOPT_CommandLineOption opt);
424 * Marker for the end of the list of options. 429 * Marker for the end of the list of options.
425 */ 430 */
426#define GNUNET_GETOPT_OPTION_END \ 431#define GNUNET_GETOPT_OPTION_END \
427 { '\0', NULL, NULL, NULL, 0, 0, NULL, NULL, NULL } 432 { '\0', NULL, NULL, NULL, 0, 0, 0, NULL, NULL, NULL }
428 433
429 434
430/** 435/**
diff --git a/src/util/getopt.c b/src/util/getopt.c
index 5e8571ee5..44f6dcda2 100644
--- a/src/util/getopt.c
+++ b/src/util/getopt.c
@@ -954,7 +954,16 @@ GNUNET_GETOPT_run (const char *binaryOptions,
954 954
955 if (GNUNET_YES == cont) 955 if (GNUNET_YES == cont)
956 { 956 {
957 for (count = 0; NULL != allOptions[count].name; count++) 957 for (count = 0; NULL != allOptions[count].name; count++)
958 {
959 if (allOptions[count].option_exclusive)
960 {
961 FPRINTF (stderr,
962 _("Option `%s' can't be used with other options.\n"),
963 allOptions[count].name);
964 cont = GNUNET_SYSERR;
965 }
966
958 if ( (0 == seen[count]) && 967 if ( (0 == seen[count]) &&
959 (allOptions[count].option_mandatory) ) 968 (allOptions[count].option_mandatory) )
960 { 969 {
@@ -963,6 +972,7 @@ GNUNET_GETOPT_run (const char *binaryOptions,
963 allOptions[count].name); 972 allOptions[count].name);
964 cont = GNUNET_SYSERR; 973 cont = GNUNET_SYSERR;
965 } 974 }
975 }
966 } 976 }
967 GNUNET_free (seen); 977 GNUNET_free (seen);
968 978
diff --git a/src/util/getopt_helpers.c b/src/util/getopt_helpers.c
index 77032e501..d6ba85733 100644
--- a/src/util/getopt_helpers.c
+++ b/src/util/getopt_helpers.c
@@ -68,6 +68,7 @@ GNUNET_GETOPT_option_version (const char *version)
68 .shortName = 'v', 68 .shortName = 'v',
69 .name = "version", 69 .name = "version",
70 .description = gettext_noop("print the version number"), 70 .description = gettext_noop("print the version number"),
71 .option_exclusive = 1,
71 .processor = &print_version, 72 .processor = &print_version,
72 .scls = (void *) version 73 .scls = (void *) version
73 }; 74 };