diff options
author | Anton Khirnov <anton@khirnov.net> | 2011-08-28 14:27:27 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2011-09-04 13:12:00 +0200 |
commit | 7efe05ab298ae18437c9796f43b9f47474763a39 (patch) | |
tree | 291991d85e03f5e38e47f9e67cf6367dfdfd1b90 | |
parent | cac651c83417dde3b64a6620cac32f078c9c399f (diff) | |
download | ffmpeg-7efe05ab298ae18437c9796f43b9f47474763a39.tar.gz |
cmdutils: declare only one pointer type in OptionDef
This will be useful in the following commit.
-rw-r--r-- | cmdutils.c | 12 | ||||
-rw-r--r-- | cmdutils.h | 5 |
2 files changed, 8 insertions, 9 deletions
diff --git a/cmdutils.c b/cmdutils.c index 9e34e43128..53ef7aed3c 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -216,6 +216,7 @@ void parse_options(int argc, char **argv, const OptionDef *options, /* parse options */ optindex = 1; while (optindex < argc) { + void *dst; opt = argv[optindex++]; if (handleoptions && opt[0] == '-' && opt[1] != '\0') { @@ -248,18 +249,19 @@ unknown_opt: exit_program(1); } } + dst = po->u.dst_ptr; if (po->flags & OPT_STRING) { char *str; str = av_strdup(arg); - *po->u.str_arg = str; + *(char**)dst = str; } else if (po->flags & OPT_BOOL) { - *po->u.int_arg = bool_val; + *(int*)dst = bool_val; } else if (po->flags & OPT_INT) { - *po->u.int_arg = parse_number_or_die(opt, arg, OPT_INT64, INT_MIN, INT_MAX); + *(int*)dst = parse_number_or_die(opt, arg, OPT_INT64, INT_MIN, INT_MAX); } else if (po->flags & OPT_INT64) { - *po->u.int64_arg = parse_number_or_die(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX); + *(int64_t*)dst = parse_number_or_die(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX); } else if (po->flags & OPT_FLOAT) { - *po->u.float_arg = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, INFINITY); + *(float*)dst = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, INFINITY); } else if (po->u.func_arg) { if (po->u.func_arg(opt, arg) < 0) { fprintf(stderr, "%s: failed to set value '%s' for option '%s'\n", argv[0], arg, opt); diff --git a/cmdutils.h b/cmdutils.h index 2173f0d34b..e72c730fa7 100644 --- a/cmdutils.h +++ b/cmdutils.h @@ -125,11 +125,8 @@ typedef struct { #define OPT_EXIT 0x0800 #define OPT_DATA 0x1000 union { - int *int_arg; - char **str_arg; - float *float_arg; + void *dst_ptr; int (*func_arg)(const char *, const char *); - int64_t *int64_arg; } u; const char *help; const char *argname; |