| 348 | } |
| 349 | |
| 350 | int parse_option(void *optctx, const char *opt, const char *arg, |
| 351 | const OptionDef *options) |
| 352 | { |
| 353 | const OptionDef *po; |
| 354 | int ret; |
| 355 | |
| 356 | po = find_option(options, opt); |
| 357 | if (!po->name && opt[0] == 'n' && opt[1] == 'o') { |
| 358 | /* handle 'no' bool option */ |
| 359 | po = find_option(options, opt + 2); |
| 360 | if ((po->name && (po->flags & OPT_BOOL))) |
| 361 | arg = "0"; |
| 362 | } else if (po->flags & OPT_BOOL) |
| 363 | arg = "1"; |
| 364 | |
| 365 | if (!po->name) |
| 366 | po = find_option(options, "default"); |
| 367 | if (!po->name) { |
| 368 | av_log(NULL, AV_LOG_ERROR, "Unrecognized option '%s'\n", opt); |
| 369 | return AVERROR(EINVAL); |
| 370 | } |
| 371 | if (po->flags & HAS_ARG && !arg) { |
| 372 | av_log(NULL, AV_LOG_ERROR, "Missing argument for option '%s'\n", opt); |
| 373 | return AVERROR(EINVAL); |
| 374 | } |
| 375 | |
| 376 | ret = write_option(optctx, po, opt, arg); |
| 377 | if (ret < 0) |
| 378 | return ret; |
| 379 | |
| 380 | return !!(po->flags & HAS_ARG); |
| 381 | } |
| 382 | |
| 383 | void parse_options(void *optctx, int argc, char **argv, const OptionDef *options, |
| 384 | void (*parse_arg_function)(void *, const char*)) |
no test coverage detected