+static int check_gc_args(int argc, char **argv, struct grab_client *gc)
+{
+ int i, ret;
+
+ gc->audio_format_num = -1; /* default: grab any audio format */
+ for (i = 1; i < argc; i++) {
+ const char *arg = argv[i];
+ if (arg[0] != '-')
+ break;
+ if (!strcmp(arg, "--")) {
+ i++;
+ break;
+ }
+ if (!strncmp(arg, "-n=", 3)) {
+ ret = para_atoi32(arg + 3, &gc->filter_num);
+ if (ret < 0)
+ return ret;
+ if (gc->filter_num < 0)
+ return -E_BAD_GC_FILTER_NUM;
+ if (gc->filter_num >= max_num_filters())
+ return -E_BAD_GC_FILTER_NUM;
+ continue;
+ }
+ if (!strncmp(arg, "-m", 2)) {
+ if (*(arg + 3))
+ return -E_GC_SYNTAX;
+ switch(*(arg + 2)) {
+ case 's':
+ gc->mode = GM_SLOPPY;
+ continue;
+ case 'a':
+ gc->mode = GM_AGGRESSIVE;
+ continue;
+ case 'p':
+ gc->mode = GM_PEDANTIC;
+ continue;
+ default:
+ return -E_GC_SYNTAX;
+ }
+ }
+ if (!strcmp(arg, "-i")) {
+ gc->flags |= GF_INPUT_GRAB;
+ continue;
+ }
+ if (!strcmp(arg, "-o")) {
+ gc->flags |= GF_ONE_SHOT;
+ continue;
+ }
+ if (!strncmp(arg, "-f=", 3)) {
+ ret = get_audio_format_num(arg + 3);
+ if (ret < 0)
+ return ret;
+ gc->audio_format_num = ret;
+ continue;
+ }
+ return -E_GC_SYNTAX;
+ }
+ if (i != argc)
+ return -E_GC_SYNTAX;
+ return 1;
+}
+