aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-06-25 15:26:21 +0200
committerMattias Andrée <maandree@operamail.com>2013-06-25 15:26:21 +0200
commited06f2d59b33a88faea3f7fc0bb11576467caf1e (patch)
treea2c09bf603375dca86955e1b22387b5e6ebcc119
parentuse realloc (diff)
downloadargparser-ed06f2d59b33a88faea3f7fc0bb11576467caf1e.tar.gz
argparser-ed06f2d59b33a88faea3f7fc0bb11576467caf1e.tar.bz2
argparser-ed06f2d59b33a88faea3f7fc0bb11576467caf1e.tar.xz
m + implement the reset of the optmap functions
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--src/argparser.c45
1 files 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,12 +368,29 @@ 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
*
* @param name The option's 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