diff options
author | Bart Polot <bart@net.in.tum.de> | 2012-09-28 12:36:36 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2012-09-28 12:36:36 +0000 |
commit | 18950c7644481d5ea1a3789d8fc394404eca591d (patch) | |
tree | 145bf85cc054c8983f2dc35440caa7e4dee66bfe | |
parent | 15e0bcb27f2d9eede1f4ae2ce80bc87f2bca6c65 (diff) |
Passing -v or -h options to a command no longer returns error code
-rw-r--r-- | src/include/gnunet_getopt_lib.h | 4 | ||||
-rw-r--r-- | src/util/getopt.c | 4 | ||||
-rw-r--r-- | src/util/getopt_helpers.c | 8 | ||||
-rw-r--r-- | src/util/service.c | 11 | ||||
-rw-r--r-- | src/util/test_getopt.c | 4 |
5 files changed, 19 insertions, 12 deletions
diff --git a/src/include/gnunet_getopt_lib.h b/src/include/gnunet_getopt_lib.h index 14ba15d669..3008b81460 100644 --- a/src/include/gnunet_getopt_lib.h +++ b/src/include/gnunet_getopt_lib.h @@ -333,7 +333,7 @@ GNUNET_GETOPT_increment_value (struct GNUNET_GETOPT_CommandLineProcessorContext * @param scls additional closure (points to about text) * @param option name of the option * @param value not used (NULL) - * @return GNUNET_SYSERR (do not continue) + * @return GNUNET_NO (do not continue, not an error) */ int GNUNET_GETOPT_format_help_ (struct GNUNET_GETOPT_CommandLineProcessorContext @@ -347,7 +347,7 @@ GNUNET_GETOPT_format_help_ (struct GNUNET_GETOPT_CommandLineProcessorContext * @param scls additional closure (points to version string) * @param option name of the option * @param value not used (NULL) - * @return GNUNET_SYSERR (do not continue) + * @return GNUNET_NO (do not continue, not an error) */ int GNUNET_GETOPT_print_version_ (struct GNUNET_GETOPT_CommandLineProcessorContext diff --git a/src/util/getopt.c b/src/util/getopt.c index 415bb4b6b7..b5dc3031b5 100644 --- a/src/util/getopt.c +++ b/src/util/getopt.c @@ -939,8 +939,8 @@ GNUNET_GETOPT_run (const char *binaryOptions, GNUNET_free (shorts); GNUNET_free (long_options); - if (cont == GNUNET_SYSERR) - return GNUNET_SYSERR; + if (cont != GNUNET_OK) + return cont; return GNoptind; } diff --git a/src/util/getopt_helpers.c b/src/util/getopt_helpers.c index a80bff4a36..1e3b05cb56 100644 --- a/src/util/getopt_helpers.c +++ b/src/util/getopt_helpers.c @@ -38,7 +38,7 @@ * @param scls additional closure (points to version string) * @param option name of the option * @param value not used (NULL) - * @return GNUNET_SYSERR (do not continue) + * @return GNUNET_NO (do not continue, not an error) */ int GNUNET_GETOPT_print_version_ (struct GNUNET_GETOPT_CommandLineProcessorContext @@ -48,7 +48,7 @@ GNUNET_GETOPT_print_version_ (struct GNUNET_GETOPT_CommandLineProcessorContext const char *version = scls; printf ("%s v%s\n", ctx->binaryName, version); - return GNUNET_SYSERR; + return GNUNET_NO; } @@ -62,7 +62,7 @@ GNUNET_GETOPT_print_version_ (struct GNUNET_GETOPT_CommandLineProcessorContext * @param scls additional closure (points to about text) * @param option name of the option * @param value not used (NULL) - * @return GNUNET_SYSERR (do not continue) + * @return GNUNET_NO (do not continue, not an error) */ int GNUNET_GETOPT_format_help_ (struct GNUNET_GETOPT_CommandLineProcessorContext @@ -152,7 +152,7 @@ OUTER: printf ("Report bugs to gnunet-developers@gnu.org.\n" "GNUnet home page: http://www.gnu.org/software/gnunet/\n" "General help using GNU software: http://www.gnu.org/gethelp/\n"); - return GNUNET_SYSERR; + return GNUNET_NO; } diff --git a/src/util/service.c b/src/util/service.c index e2d056d7ff..67d8583cc9 100644 --- a/src/util/service.c +++ b/src/util/service.c @@ -1729,6 +1729,7 @@ GNUNET_SERVICE_run (int argc, char *const *argv, const char *service_name, #define HANDLE_ERROR do { GNUNET_break (0); goto shutdown; } while (0) int err; + int ret; char *cfg_fn; char *loglev; char *logfile; @@ -1765,10 +1766,16 @@ GNUNET_SERVICE_run (int argc, char *const *argv, const char *service_name, sctx.task_cls = task_cls; sctx.service_name = service_name; sctx.cfg = cfg = GNUNET_CONFIGURATION_create (); + /* setup subsystems */ - if (GNUNET_SYSERR == - GNUNET_GETOPT_run (service_name, service_options, argc, argv)) + ret = GNUNET_GETOPT_run (service_name, service_options, argc, argv); + if (GNUNET_SYSERR == ret) goto shutdown; + if (GNUNET_NO == ret) + { + err = 0; + goto shutdown; + } if (GNUNET_OK != GNUNET_log_setup (service_name, loglev, logfile)) HANDLE_ERROR; if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, cfg_fn)) diff --git a/src/util/test_getopt.c b/src/util/test_getopt.c index f068a6ab04..65c3b5d2ee 100644 --- a/src/util/test_getopt.c +++ b/src/util/test_getopt.c @@ -89,7 +89,7 @@ testVersion () GNUNET_GETOPT_OPTION_END }; - if (-1 != GNUNET_GETOPT_run ("test_getopt", versionoptionlist, 2, myargv)) + if (0 != GNUNET_GETOPT_run ("test_getopt", versionoptionlist, 2, myargv)) { GNUNET_break (0); return 1; @@ -111,7 +111,7 @@ testAbout () GNUNET_GETOPT_OPTION_END }; - if (-1 != GNUNET_GETOPT_run ("test_getopt", aboutoptionlist, 2, myargv)) + if (0 != GNUNET_GETOPT_run ("test_getopt", aboutoptionlist, 2, myargv)) { GNUNET_break (0); return 1; |