diff options
author | Michael Adam <obnox@samba.org> | 2017-01-04 13:59:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-04 13:59:14 +0100 |
commit | 302738dee5dd247881a4a5eba173f4333dc2a7d4 (patch) | |
tree | 16973c4b6b975cd6849845afb5133102c78cd690 /src/hashmap.c | |
parent | e4ae0d10d28dece1fe6d06c0f479b3968478fed8 (diff) | |
parent | fdb1aae3a98d94da90b2ee36bd5ae4423e3b213b (diff) |
Merge pull request #71 from gmp216/lookup
Move lookup_variable from html-error.c to hashmap.c
Diffstat (limited to 'src/hashmap.c')
-rw-r--r-- | src/hashmap.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/hashmap.c b/src/hashmap.c index b99f838..7793d08 100644 --- a/src/hashmap.c +++ b/src/hashmap.c @@ -493,3 +493,24 @@ ssize_t hashmap_remove (hashmap_t map, const char *key) /* The key was not found, so return 0 */ return deleted; } + +/* + * Look up the value for a variable. + */ +char *lookup_variable (hashmap_t map, const char *varname) +{ + hashmap_iter result_iter; + char *key; + char *data; + + result_iter = hashmap_find (map, varname); + + if (hashmap_is_end (map, result_iter)) + return (NULL); + + if (hashmap_return_entry (map, result_iter, + &key, (void **) &data) < 0) + return (NULL); + + return (data); +} |