summaryrefslogtreecommitdiff
path: root/src/common/util.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-03-19 22:07:24 +0000
committerNick Mathewson <nickm@torproject.org>2004-03-19 22:07:24 +0000
commit9199696182ed385b5645ffce6b0f8e7d74d57a35 (patch)
tree2dd20875044b762c8e1d3a5869728d67c661964d /src/common/util.h
parentdf3f37b84f81ec7757e056ff82530ef6e863fb95 (diff)
downloadtor-9199696182ed385b5645ffce6b0f8e7d74d57a35.tar.gz
tor-9199696182ed385b5645ffce6b0f8e7d74d57a35.zip
Add some wrappers around SPLAY_* for the common map-from-string-to-X case.
It will probably be less blindingly fast than using SPLAY_* directly, but only slightly so. svn:r1306
Diffstat (limited to 'src/common/util.h')
-rw-r--r--src/common/util.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/common/util.h b/src/common/util.h
index f9b2b90eb5..5bdcaed96b 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -58,6 +58,26 @@ void smartlist_intersect(smartlist_t *sl1, smartlist_t *sl2);
void smartlist_subtract(smartlist_t *sl1, smartlist_t *sl2);
void *smartlist_choose(smartlist_t *sl);
+/* Map from const char * to void*. Implemented with a splay tree. */
+typedef struct strmap_t strmap_t;
+typedef struct strmap_entry_t strmap_entry_t;
+typedef struct strmap_entry_t strmap_iter_t;
+strmap_t* strmap_new(void);
+void* strmap_set(strmap_t *map, const char *key, void *val);
+void* strmap_get(strmap_t *map, const char *key);
+void* strmap_remove(strmap_t *map, const char *key);
+void strmap_foreach(strmap_t *map,
+ void* (*fn)(const char *key, void *val, void *data),
+ void *data);
+void strmap_free(strmap_t *map, void (*free_val)(void*));
+
+strmap_iter_t *strmap_iter_init(strmap_t *map);
+strmap_iter_t *strmap_iter_next(strmap_t *map, strmap_iter_t *iter);
+strmap_iter_t *strmap_iter_next_rmv(strmap_t *map, strmap_iter_t *iter);
+void strmap_iter_get(strmap_iter_t *iter, const char **keyp, void **valp);
+
+int strmap_iter_done(strmap_iter_t *iter);
+
const char *eat_whitespace(const char *s);
const char *eat_whitespace_no_nl(const char *s);
const char *find_whitespace(const char *s);