diff options
author | midipix <writeonce@midipix.org> | 2016-12-25 12:22:05 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-12-25 13:53:59 -0500 |
commit | a6ad51943c98c3f075d527a9d2a84a3b613655d2 (patch) | |
tree | 100916999a20df003a0a576dfa8777cf9275c40b /src/driver | |
parent | c774e5ee3b57a33564e1824fe7bca3526d7e783f (diff) | |
download | apimagic-a6ad51943c98c3f075d527a9d2a84a3b613655d2.tar.bz2 apimagic-a6ad51943c98c3f075d527a9d2a84a3b613655d2.tar.xz |
argv.h: use an option vector rather than a direct pointer to the option table.
Diffstat (limited to 'src/driver')
-rw-r--r-- | src/driver/amgc_driver_ctx.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/driver/amgc_driver_ctx.c b/src/driver/amgc_driver_ctx.c index d287008..e5b218e 100644 --- a/src/driver/amgc_driver_ctx.c +++ b/src/driver/amgc_driver_ctx.c @@ -61,7 +61,7 @@ static uint32_t amgc_argv_flags(uint32_t flags) static int amgc_driver_usage( const char * program, const char * arg, - const struct argv_option * options, + const struct argv_option ** optv, struct argv_meta * meta) { char header[512]; @@ -70,7 +70,7 @@ static int amgc_driver_usage( "Usage: %s [options] <file>...\n" "Options:\n", program); - argv_usage(stdout,header,options,arg); + argv_usage(stdout,header,optv,arg); argv_free(meta); return AMGC_USAGE; @@ -151,7 +151,7 @@ int amgc_get_driver_ctx( { struct amgc_driver_ctx_impl * ctx; struct amgc_common_ctx cctx; - const struct argv_option * options; + const struct argv_option * optv[AMGC_OPTV_ELEMENTS]; struct argv_meta * meta; struct argv_entry * entry; size_t nunits; @@ -160,9 +160,9 @@ int amgc_get_driver_ctx( (void)envp; - options = amgc_default_options; + argv_optv_init(amgc_default_options,optv); - if (!(meta = argv_get(argv,options,amgc_argv_flags(flags)))) + if (!(meta = argv_get(argv,optv,amgc_argv_flags(flags)))) return -1; nunits = 0; @@ -172,7 +172,7 @@ int amgc_get_driver_ctx( cctx.drvflags = flags; if (!argv[1] && (flags & AMGC_DRIVER_VERBOSITY_USAGE)) - return amgc_driver_usage(program,0,options,meta); + return amgc_driver_usage(program,0,optv,meta); /* compiler defaults */ cctx.std = STANDARD_C99; @@ -183,7 +183,7 @@ int amgc_get_driver_ctx( switch (entry->tag) { case TAG_HELP: if (flags & AMGC_DRIVER_VERBOSITY_USAGE) - return amgc_driver_usage(program,entry->arg,options,meta); + return amgc_driver_usage(program,entry->arg,optv,meta); case TAG_VERSION: cctx.drvflags |= AMGC_DRIVER_VERSION; @@ -253,11 +253,14 @@ int amgc_create_driver_ctx( const struct amgc_common_ctx * cctx, struct amgc_driver_ctx ** pctx) { + const struct argv_option * optv[AMGC_OPTV_ELEMENTS]; struct argv_meta * meta; struct amgc_driver_ctx_impl * ctx; char * argv[] = {"apimagic_driver",0}; - if (!(meta = argv_get(argv,amgc_default_options,0))) + argv_optv_init(amgc_default_options,optv); + + if (!(meta = argv_get(argv,optv,0))) return -1; if (!(ctx = amgc_driver_ctx_alloc(meta,cctx,0,0))) |