From ed06f2d59b33a88faea3f7fc0bb11576467caf1e Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 25 Jun 2013 15:26:21 +0200 Subject: m + implement the reset of the optmap functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/argparser.c | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/src/argparser.c b/src/argparser.c index d8c2be3..c71927e 100644 --- a/src/argparser.c +++ b/src/argparser.c @@ -25,7 +25,7 @@ #define false 0 #define null 0 -/* Constants */ +/* Constants */ /* TODO */ #define ARGUMENTLESS 0 #define ARGUMENTED 1 #define VARIADIC 2 @@ -75,6 +75,16 @@ typedef struct } args_Option; +/** + * char* to void* map structure + */ +typedef struct +{ + char** keys; + long key_count; +} args_Map; /*TODO*/ + + /** * Whether the Linux VT is being used @@ -345,6 +355,10 @@ extern char* args_options_get_help(long index) } /* +TODO + +args_map_get(args_optmap, name) + args_get_opts() args_get_opts_count() args_opts_contains(char*) @@ -354,11 +368,28 @@ args_opts_clear(char*) args_opts_get(char*) args_opts_put(char*, ::args_opts_get(char*)) args_opts_used(char*) - -args_get_optmap() -args_get_optmap_count() */ +/** + * Gets all alternativ names that exists for all options combined + * + * @return All alternativ names that exists for all options + */ +extern char** args_get_optmap() +{ + return args_optmap.keys; +} + +/** + * Gets the number of elements returned by `args_get_optmap` + * + * @return The number of elements returned by `args_get_optmap` + */ +extern long args_get_optmap_count() +{ + return args_optmap.key_count; +} + /** * Gets the option with a specific alternative name * @@ -376,10 +407,10 @@ extern args_Option args_optmap_get(char* name) * @param name The option's alternative name * @return The option's index, negative if not found */ -/*extern long args_optmap_get_index(char* name) +extern long args_optmap_get_index(char* name) { - TODO -}*/ + return (long)(args_map_get(args_optmap, name)); +} /** * Checks whether an options with a specific alternative name exists -- cgit v1.2.3-70-g09d2