]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
fix grab -V
authorAndre <maan@p133.(none)>
Mon, 27 Mar 2006 06:04:55 +0000 (08:04 +0200)
committerAndre <maan@p133.(none)>
Mon, 27 Mar 2006 06:04:55 +0000 (08:04 +0200)
Currently, -V is silently ignored, i.e. "grab -V" dumps binary data
to stdout which probably doesn't meet the expectation of the user ;)

audiod.c
error.h
grab_client.c

index adfcbf41f767bb489ed6d84eefb740321bb6041a..56d022fac1c3293ef303f819515941261c8f1777 100644 (file)
--- 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 b72f5fa6fc459cbf1a74f752c5290d6f4992603c..805077530168b4605578e290248a303335651bd0 100644 (file)
--- 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 \
index 2a98b35f8831210280321cbb3a48ff984996dd65..5fb9a83b54294960eb6f4df8ccd371aa5d998f3a 100644 (file)
@@ -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;