diff options
author | midipix <writeonce@midipix.org> | 2016-12-26 08:42:40 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-12-26 03:48:03 -0500 |
commit | 97d3f37f9f03c7bf99d633701c7dd8ad920c50ed (patch) | |
tree | 0110da0b47b93f44c1d78058fa3c5cea9502720a /src/driver | |
parent | ff63f9a47bb5a47aa5dc9e0ea20e93be1ee17c6f (diff) | |
download | ptycon-97d3f37f9f03c7bf99d633701c7dd8ad920c50ed.tar.bz2 ptycon-97d3f37f9f03c7bf99d633701c7dd8ad920c50ed.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/ptyc_driver_ctx.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/driver/ptyc_driver_ctx.c b/src/driver/ptyc_driver_ctx.c index 1a79c79..a30063b 100644 --- a/src/driver/ptyc_driver_ctx.c +++ b/src/driver/ptyc_driver_ctx.c @@ -127,7 +127,7 @@ static uint32_t ptyc_argv_flags(uint32_t flags) static int ptyc_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]; @@ -136,7 +136,7 @@ static int ptyc_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 PTYC_USAGE; @@ -229,7 +229,7 @@ int ptyc_get_driver_ctx( struct ptyc_driver_ctx_impl * ctx; struct ptyc_common_ctx cctx; struct ptyc_split_vector sargv; - const struct argv_option * options; + const struct argv_option * optv[PTYC_OPTV_ELEMENTS]; struct argv_meta * meta; struct argv_entry * entry; size_t nunits; @@ -244,7 +244,7 @@ int ptyc_get_driver_ctx( if (ptyc_vtbl_init()) return -1; - options = ptyc_default_options; + argv_optv_init(ptyc_default_options,optv); sargv.targv = targv; sargv.eargv = 0; @@ -252,7 +252,7 @@ int ptyc_get_driver_ctx( if (ptyc_split_argv(argv,&sargv)) return -1; - if (!(meta = argv_get(sargv.targv,options,ptyc_argv_flags(flags)))) + if (!(meta = argv_get(sargv.targv,optv,ptyc_argv_flags(flags)))) return -1; nunits = 0; @@ -262,7 +262,7 @@ int ptyc_get_driver_ctx( cctx.eargv = sargv.eargv; if (!argv[1] && (flags & PTYC_DRIVER_VERBOSITY_USAGE)) - return ptyc_driver_usage(program,0,options,meta); + return ptyc_driver_usage(program,0,optv,meta); /* get options, count units */ for (entry=meta->entries; entry->fopt || entry->arg; entry++) { @@ -270,7 +270,7 @@ int ptyc_get_driver_ctx( switch (entry->tag) { case TAG_HELP: if (flags & PTYC_DRIVER_VERBOSITY_USAGE) - return ptyc_driver_usage(program,entry->arg,options,meta); + return ptyc_driver_usage(program,entry->arg,optv,meta); case TAG_VERSION: cctx.drvflags |= PTYC_DRIVER_VERSION; @@ -322,7 +322,7 @@ int ptyc_get_driver_ctx( } } else /* strict */ - return ptyc_driver_usage(program,0,options,meta); + return ptyc_driver_usage(program,0,optv,meta); } if (cctx.sysroot && ptyc_open_dir(&cctx.hroot,0,cctx.sysroot,false)) { @@ -350,6 +350,7 @@ int ptyc_create_driver_ctx( const struct ptyc_common_ctx * cctx, struct ptyc_driver_ctx ** pctx) { + const struct argv_option * optv[PTYC_OPTV_ELEMENTS]; struct argv_meta * meta; struct ptyc_driver_ctx_impl * ctx; char * argv[] = {"ptycon_driver",0}; @@ -360,7 +361,9 @@ int ptyc_create_driver_ctx( if (ptyc_vtbl_init()) return -1; - if (!(meta = argv_get(argv,ptyc_default_options,0))) + argv_optv_init(ptyc_default_options,optv); + + if (!(meta = argv_get(argv,optv,0))) return -1; if (!(ctx = ptyc_driver_ctx_alloc(meta,cctx,0))) |