From: Andre Date: Mon, 27 Mar 2006 08:50:08 +0000 (+0200) Subject: specify the three grab modes as values in grab_client.ggo X-Git-Tag: v0.2.12~121 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=c6a9d624a8e7334b08dbd0acf8c7df016044cb9e;p=paraslash.git specify the three grab modes as values in grab_client.ggo That makes gengetopt check that the argument to the --mode option is one of sloppy, pedantic, or aggressive, so get rid of E_INVALID_GRAB_MODE, the gc_modes array and of the error check in grab_client.c. Another nice side-effect is that also "s", "p", "a" work as abreviations for the grab mode argument. Reformat grab_client.ggo as we are at it. --- diff --git a/error.h b/error.h index 80507753..c72bdae4 100644 --- a/error.h +++ b/error.h @@ -135,7 +135,6 @@ extern const char **para_errlist[]; #define GRAB_CLIENT_ERRORS \ PARA_ERROR(PEDANTIC_GRAB, "fd not ready and pedantic grab requested"), \ PARA_ERROR(GC_WRITE, "grab client write error"), \ - PARA_ERROR(INVALID_GRAB_MODE, "invalid grab client mode"), \ PARA_ERROR(BAD_GC_SLOT, "invalid slot requested by grab client"), \ PARA_ERROR(BAD_GC_FILTER_NUM, "invalid filter number given"), \ PARA_ERROR(GC_SYNTAX, "grab client syntax error"), \ diff --git a/grab_client.c b/grab_client.c index 5fb9a83b..2dfb295b 100644 --- a/grab_client.c +++ b/grab_client.c @@ -33,15 +33,6 @@ #include "error.h" #include "string.h" - -/** this maps the enum to the text used at the command line */ -static const char *gc_modes[] = { - [GRAB_PEDANTIC] = "pedantic", - [GRAB_SLOPPY] = "sloppy", - [GRAB_AGGRESSIVE] = "aggressive", - NULL -}; - /** grab clients that are not yet attached to a filter node */ struct list_head inactive_grab_client_list; @@ -99,13 +90,12 @@ static int check_gc_args(struct grab_client *gc) { int i; struct grab_client_args_info *conf = gc->conf; + char **mv = grab_client_cmdline_parser_mode_values; PARA_INFO_LOG("filter_num: %d\n", gc->conf->filter_num_arg); - for (i = 0; gc_modes[i]; i++) - if (!strcmp(conf->mode_arg, gc_modes[i])) + for (i = 0; mv[i]; i++) + if (!strcmp(conf->mode_arg, mv[i])) break; - if (!gc_modes[i]) - return -E_INVALID_GRAB_MODE; gc->mode = i; if (conf->audio_format_given) { gc->audio_format_num = get_audio_format_num(conf->audio_format_arg); diff --git a/grab_client.ggo b/grab_client.ggo index c48b7ef5..ded7ee75 100644 --- a/grab_client.ggo +++ b/grab_client.ggo @@ -1,6 +1,35 @@ -option "filter_num" f "point of filter chain to grab" int typestr="num" default="1" optional -option "slot" s "only grab this slot; grab any slot if negative" int typestr="num" default="-1" optional -option "mode" m "sloppy, pedantic, or aggressive" string typestr="grab_mode" default="sloppy" optional -option "audio_format" a "only grab this type of input stream; grab any if empty" string typestr="name" default="" optional -option "input_grab" i "grab the filter input instead of its output" flag off optional -option "one_shot" o "stop grabbing if audio file changes" flag off optional +option "filter_num" f + "point of filter chain to grab" + int typestr="num" + default="1" + optional + +option "slot" s + "only grab this slot; grab any slot if negative" + int typestr="num" + default="-1" + optional + +option "audio_format" a + "only grab this type of input stream; + grab any if empty" + string typestr="name" + default="" + optional + +option "input_grab" i + "grab the filter input instead of its output" + flag off + optional + +option "one_shot" o + "stop grabbing if audio file changes" + flag off + optional + +option "mode" m + "select grab mode" + typestr="grab_mode" + values="sloppy","aggressive","pedantic" + default="sloppy" + optional diff --git a/grab_client.h b/grab_client.h index e66e9b24..8cc0a203 100644 --- a/grab_client.h +++ b/grab_client.h @@ -27,7 +27,7 @@ * - aggressive: write anyway (default) * */ -enum grab_mode {GRAB_PEDANTIC, GRAB_SLOPPY, GRAB_AGGRESSIVE}; +enum grab_mode {GRAB_SLOPPY, GRAB_AGGRESSIVE, GRAB_PEDANTIC}; /** describes one active grab client *