diff options
author | midipix <writeonce@midipix.org> | 2016-12-26 22:02:42 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-12-27 04:40:59 -0500 |
commit | 2404cd8761998d454dd7f0e2e276d2a14970f32a (patch) | |
tree | 623917d620c6eb6dc10ee8b5ff66364072953216 /src/driver | |
parent | 26e14f4143ec690a120e197a3adf547145e4ce59 (diff) | |
download | ntux-2404cd8761998d454dd7f0e2e276d2a14970f32a.tar.bz2 ntux-2404cd8761998d454dd7f0e2e276d2a14970f32a.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/ntux_driver_ctx.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/driver/ntux_driver_ctx.c b/src/driver/ntux_driver_ctx.c index 2cd3cdf..3759ef7 100644 --- a/src/driver/ntux_driver_ctx.c +++ b/src/driver/ntux_driver_ctx.c @@ -63,7 +63,7 @@ static uint32_t ntux_argv_flags(uint32_t flags) static int ntux_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]; @@ -72,7 +72,7 @@ static int ntux_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 NTUX_USAGE; @@ -129,7 +129,7 @@ int ntux_get_driver_ctx( { struct ntux_driver_ctx_impl * ctx; struct ntux_common_ctx cctx; - const struct argv_option * options; + const struct argv_option * optv[NTUX_OPTV_ELEMENTS]; struct argv_meta * meta; struct argv_entry * entry; size_t nunits; @@ -137,12 +137,12 @@ int ntux_get_driver_ctx( (void)envp; - options = ntux_default_options; + argv_optv_init(ntux_default_options,optv); if (ntux_init()) return -1; - if (!(meta = argv_get(argv,options,ntux_argv_flags(flags)))) + if (!(meta = argv_get(argv,optv,ntux_argv_flags(flags)))) return -1; nunits = 0; @@ -151,7 +151,7 @@ int ntux_get_driver_ctx( cctx.drvflags = flags; if (!argv[1] && (flags & NTUX_DRIVER_VERBOSITY_USAGE)) - return ntux_driver_usage(program,0,options,meta); + return ntux_driver_usage(program,0,optv,meta); /* get options, count units */ for (entry=meta->entries; entry->fopt || entry->arg; entry++) { @@ -159,7 +159,7 @@ int ntux_get_driver_ctx( switch (entry->tag) { case TAG_HELP: if (flags & NTUX_DRIVER_VERBOSITY_USAGE) - return ntux_driver_usage(program,entry->arg,options,meta); + return ntux_driver_usage(program,entry->arg,optv,meta); case TAG_VERSION: cctx.drvflags |= NTUX_DRIVER_VERSION; @@ -183,6 +183,7 @@ int ntux_create_driver_ctx( const struct ntux_common_ctx * cctx, struct ntux_driver_ctx ** pctx) { + const struct argv_option * optv[NTUX_OPTV_ELEMENTS]; struct argv_meta * meta; struct ntux_driver_ctx_impl * ctx; char * argv[] = {"ntux_driver",0}; @@ -190,7 +191,9 @@ int ntux_create_driver_ctx( if (ntux_init()) return -1; - if (!(meta = argv_get(argv,ntux_default_options,0))) + argv_optv_init(ntux_default_options,optv); + + if (!(meta = argv_get(argv,optv,0))) return -1; if (!(ctx = ntux_driver_ctx_alloc(meta,cctx,0))) |