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);
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);
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 \