aboutsummaryrefslogtreecommitdiff
path: root/src/hashmap.c
diff options
context:
space:
mode:
authorDanny van Kooten <dannyvankooten@users.noreply.github.com>2020-03-12 17:36:00 +0100
committerDanny van Kooten <dannyvankooten@users.noreply.github.com>2020-03-12 17:36:00 +0100
commit2d1d7bd16100eb9d702ef67897b2f62a972d6426 (patch)
tree249a995c033e17b87c8a633867e2e5de531c9633 /src/hashmap.c
parent9acd91d41469ed4024e3a8aa85ef1fb2eec909bd (diff)
downloadunja-2d1d7bd16100eb9d702ef67897b2f62a972d6426.tar.gz
unja-2d1d7bd16100eb9d702ef67897b2f62a972d6426.zip
add hashmap_resolve which handles dot notation
Diffstat (limited to 'src/hashmap.c')
-rw-r--r--src/hashmap.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/hashmap.c b/src/hashmap.c
index b56b364..9f36a58 100644
--- a/src/hashmap.c
+++ b/src/hashmap.c
@@ -55,8 +55,32 @@ void *hashmap_get(struct hashmap *hm, char *key) {
return NULL;
}
-void hashmap_remove(char *key) {
+void *hashmap_resolve(struct hashmap *hm, char *key) {
+ char tmp_key[64];
+ int i = 0;
+ int j = 0;
+
+ while (1) {
+ for (j=0; key[i] != '.' && key[i] != '\0'; i++, j++) {
+ tmp_key[j] = key[i];
+ }
+ tmp_key[j] = '\0';
+ hm = hashmap_get(hm, tmp_key);
+
+ // stop if we read key to end of string
+ if (key[i] == '\0') {
+ break;
+ }
+
+ // otherwise, continue reading keys
+ i++;
+ }
+ return hm;
+}
+
+void hashmap_remove(char *key) {
+ // TODO: Implement this
}
void hashmap_free(struct hashmap *hm) {