From: Andre Date: Mon, 27 Mar 2006 06:04:55 +0000 (+0200) Subject: fix grab -V X-Git-Tag: v0.2.12~123 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=741023c2fdff99a9402939fe5e5cafad4ac08df3;p=paraslash.git fix grab -V Currently, -V is silently ignored, i.e. "grab -V" dumps binary data to stdout which probably doesn't meet the expectation of the user ;) --- diff --git a/audiod.c b/audiod.c index adfcbf41..56d022fa 100644 --- a/audiod.c +++ b/audiod.c @@ -1348,7 +1348,7 @@ static int com_grab(int fd, int argc, char **argv) struct grab_client *gc; struct filter_node *fn; int i, err; - char *help; + char *msg; PARA_INFO_LOG("argc: %d, argv[0]: %s, optind: %d\n", argc, argv[0], optind); gc = grab_client_new(fd, argc, argv, &err); @@ -1360,17 +1360,22 @@ static int com_grab(int fd, int argc, char **argv) activate_grab_client(gc, fn); return 1; err_out: - if (err != -E_GC_HELP_GIVEN) + if (err != -E_GC_HELP_GIVEN && err != -E_GC_VERSION_GIVEN) return err; - help = make_message("%s\n\n", grab_client_args_info_usage); - for (i = 0; grab_client_args_info_help[i]; i++) { - char *tmp = make_message("%s%s\n", help, - grab_client_args_info_help[i]); - free(help); - help = tmp; - } - err = client_write(fd, help); - free(help); + if (err == -E_GC_HELP_GIVEN) { + msg = make_message("%s\n\n", grab_client_args_info_usage); + for (i = 0; grab_client_args_info_help[i]; i++) { + char *tmp = make_message("%s%s\n", msg, + grab_client_args_info_help[i]); + free(msg); + msg = tmp; + } + } else + msg = make_message("%s %s\n", + GRAB_CLIENT_CMDLINE_PARSER_PACKAGE, + GRAB_CLIENT_CMDLINE_PARSER_VERSION); + err = client_write(fd, msg); + free(msg); if (err < 0) return err; close(fd); diff --git a/error.h b/error.h index b72f5fa6..80507753 100644 --- a/error.h +++ b/error.h @@ -140,6 +140,7 @@ extern const char **para_errlist[]; PARA_ERROR(BAD_GC_FILTER_NUM, "invalid filter number given"), \ PARA_ERROR(GC_SYNTAX, "grab client syntax error"), \ PARA_ERROR(GC_HELP_GIVEN, ""), /* not really an error */ \ + PARA_ERROR(GC_VERSION_GIVEN, ""), /* not really an error */ \ #define MP3DEC_ERRORS \ diff --git a/grab_client.c b/grab_client.c index 2a98b35f..5fb9a83b 100644 --- a/grab_client.c +++ b/grab_client.c @@ -263,6 +263,9 @@ __malloc struct grab_client *grab_client_new(int fd, int argc, char **argv, int *err = -E_GC_HELP_GIVEN; if (gc->conf->help_given) goto err_out; + *err = -E_GC_VERSION_GIVEN; + if (gc->conf->version_given) + goto err_out; *err = check_gc_args(gc); if (*err < 0) goto err_out;