| 378 | } |
| 379 | |
| 380 | int parse_option(void *optctx, const char *opt, const char *arg, |
| 381 | const OptionDef *options) |
| 382 | { |
| 383 | static const OptionDef opt_avoptions = { |
| 384 | .name = "AVOption passthrough", |
| 385 | .type = OPT_TYPE_FUNC, |
| 386 | .flags = OPT_FUNC_ARG, |
| 387 | .u.func_arg = opt_default, |
| 388 | }; |
| 389 | |
| 390 | const OptionDef *po; |
| 391 | int ret; |
| 392 | |
| 393 | po = find_option(options, opt); |
| 394 | if (!po->name && opt[0] == 'n' && opt[1] == 'o') { |
| 395 | /* handle 'no' bool option */ |
| 396 | po = find_option(options, opt + 2); |
| 397 | if ((po->name && po->type == OPT_TYPE_BOOL)) |
| 398 | arg = "0"; |
| 399 | } else if (po->type == OPT_TYPE_BOOL) |
| 400 | arg = "1"; |
| 401 | |
| 402 | if (!po->name) |
| 403 | po = &opt_avoptions; |
| 404 | if (!po->name) { |
| 405 | av_log(NULL, AV_LOG_ERROR, "Unrecognized option '%s'\n", opt); |
| 406 | return AVERROR(EINVAL); |
| 407 | } |
| 408 | if (opt_has_arg(po) && !arg) { |
| 409 | av_log(NULL, AV_LOG_ERROR, "Missing argument for option '%s'\n", opt); |
| 410 | return AVERROR(EINVAL); |
| 411 | } |
| 412 | |
| 413 | ret = write_option(optctx, po, opt, arg, options); |
| 414 | if (ret < 0) |
| 415 | return ret; |
| 416 | |
| 417 | return opt_has_arg(po); |
| 418 | } |
| 419 | |
| 420 | int parse_options(void *optctx, int argc, char **argv, const OptionDef *options, |
| 421 | int (*parse_arg_function)(void *, const char*)) |
no test coverage detected