From 2495909f9888df0fba7d9192bc63c1dc3e0d29ca Mon Sep 17 00:00:00 2001 From: midipix Date: Tue, 8 Dec 2015 04:26:32 -0500 Subject: program driver: adjust source tree to support multiple skins. --- src/driver/pe_driver_ctx.c | 47 ++++++++++------------------------------------ 1 file changed, 10 insertions(+), 37 deletions(-) (limited to 'src/driver') diff --git a/src/driver/pe_driver_ctx.c b/src/driver/pe_driver_ctx.c index e5df2a5..016302e 100644 --- a/src/driver/pe_driver_ctx.c +++ b/src/driver/pe_driver_ctx.c @@ -2,46 +2,15 @@ #include #include +#define ARGV_DRIVER + #include #include +#include "perk_driver_impl.h" #include "perk_impl.h" #include "argv/argv.h" -enum app_tags { - TAG_HELP, - TAG_VERSION, - TAG_OUTPUT, - TAG_PRETTY, - TAG_EXPSYMS, - TAG_IMPLIBS, - TAG_IMPSYMS, -}; - -static const struct argv_option options[] = { - {"version", 'v',TAG_VERSION,ARGV_OPTARG_NONE, 0,0, - "show version information"}, - - {"help", 'h',TAG_HELP, ARGV_OPTARG_OPTIONAL, "short|long",0, - "show usage information " - "[listing %s options only]"}, - - {"output", 'o',TAG_OUTPUT, ARGV_OPTARG_REQUIRED, 0,"", - "write output to %s"}, - - {"pretty", 'p',TAG_PRETTY, ARGV_OPTARG_REQUIRED, "yaml",0, - "format output for parsing by %s"}, - - {"expsyms", 'e',TAG_EXPSYMS,ARGV_OPTARG_NONE, 0,0, - "print exported symbols" }, - - {"implibs", 'i',TAG_IMPLIBS,ARGV_OPTARG_NONE, 0,0, - "list direct dependency libraries"}, - - {"impsyms", 'I',TAG_IMPSYMS,ARGV_OPTARG_NONE, 0,0, - "list direct dependency libraries " - "along with required symbols"}, - {0} -}; +extern const struct argv_option pe_default_options[]; struct pe_driver_ctx_alloc { struct argv_meta * meta; @@ -69,6 +38,7 @@ static uint32_t pe_argv_flags(uint32_t flags) static int pe_driver_usage( const char * program, const char * arg, + const struct argv_option * options, struct argv_meta * meta) { char header[512]; @@ -124,6 +94,7 @@ int pe_get_driver_ctx( struct pe_driver_ctx ** pctx) { struct pe_driver_ctx_impl * ctx; + const struct argv_option * options; struct argv_meta * meta; struct argv_entry * entry; size_t nunits; @@ -134,6 +105,8 @@ int pe_get_driver_ctx( const char * pretty; int fdout; + options = pe_default_options; + if (!(meta = argv_get(argv,options,pe_argv_flags(flags)))) return -1; @@ -146,7 +119,7 @@ int pe_get_driver_ctx( program = argv_program_name(argv[0]); if (!argv[1] && (flags & PERK_DRIVER_VERBOSITY_USAGE)) - return pe_driver_usage(program,0,meta); + return pe_driver_usage(program,0,options,meta); /* get options, count units */ for (entry=meta->entries; entry->fopt || entry->arg; entry++) { @@ -154,7 +127,7 @@ int pe_get_driver_ctx( switch (entry->tag) { case TAG_HELP: if (flags & PERK_DRIVER_VERBOSITY_USAGE) - return pe_driver_usage(program,entry->arg,meta); + return pe_driver_usage(program,entry->arg,options,meta); case TAG_VERSION: dflags |= PERK_DRIVER_VERSION; -- cgit v1.2.3