summaryrefslogtreecommitdiff
path: root/src/lib/container/namemap_st.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-03-26 20:13:49 -0400
committerNick Mathewson <nickm@torproject.org>2019-03-26 20:13:49 -0400
commita47b61f329fbe06b7b4935cf9c1923d96a74b649 (patch)
tree283c23aa4230a26fe9b40b1001cb05a457995b4d /src/lib/container/namemap_st.h
parent57999e330b82fa3a360406dfb28b7a35fb50d602 (diff)
parent3767eff9bb712bccc86718647c7dc84998a7f95f (diff)
downloadtor-a47b61f329fbe06b7b4935cf9c1923d96a74b649.tar.gz
tor-a47b61f329fbe06b7b4935cf9c1923d96a74b649.zip
Merge branch 'messaging_v3' into messaging_v3_merged
Diffstat (limited to 'src/lib/container/namemap_st.h')
-rw-r--r--src/lib/container/namemap_st.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/lib/container/namemap_st.h b/src/lib/container/namemap_st.h
new file mode 100644
index 0000000000..5717352fa2
--- /dev/null
+++ b/src/lib/container/namemap_st.h
@@ -0,0 +1,34 @@
+/* Copyright (c) 2003-2004, Roger Dingledine
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2018, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#ifndef NAMEMAP_ST_H
+#define NAMEMAP_ST_H
+
+#include "lib/cc/compat_compiler.h"
+#include "ext/ht.h"
+
+struct smartlist_t;
+
+/** Longest allowed name that's allowed in a namemap_t. */
+#define MAX_NAMEMAP_NAME_LEN 128
+
+/** An entry inside a namemap_t. Maps a string to a numeric identifier. */
+typedef struct mapped_name_t {
+ HT_ENTRY(mapped_name_t) node;
+ unsigned intval;
+ char name[FLEXIBLE_ARRAY_MEMBER];
+} mapped_name_t;
+
+/** A structure that allocates small numeric identifiers for names and maps
+ * back and forth between them. */
+struct namemap_t {
+ HT_HEAD(namemap_ht, mapped_name_t) ht;
+ struct smartlist_t *names;
+};
+
+/** Macro to initialize a namemap. */
+#define NAMEMAP_INIT() { HT_INITIALIZER(), NULL }
+
+#endif