summaryrefslogtreecommitdiff
path: root/src/lib/container/namemap.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-10-25 12:04:19 -0400
committerNick Mathewson <nickm@torproject.org>2019-03-25 16:35:33 -0400
commitdfd7a7f5b63eb968caebf6823395689e6b77b654 (patch)
treee22bf2ff8738be2f145c6670eb4d9ed387aa5656 /src/lib/container/namemap.h
parent9a61d3f5adf1e4e61a0d51fb6f9368339f5330cc (diff)
downloadtor-dfd7a7f5b63eb968caebf6823395689e6b77b654.tar.gz
tor-dfd7a7f5b63eb968caebf6823395689e6b77b654.zip
Add a type to map names to short identifiers
We'll be using this for four kinds of identifier in dispatch.c
Diffstat (limited to 'src/lib/container/namemap.h')
-rw-r--r--src/lib/container/namemap.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/lib/container/namemap.h b/src/lib/container/namemap.h
new file mode 100644
index 0000000000..97792e13ba
--- /dev/null
+++ b/src/lib/container/namemap.h
@@ -0,0 +1,35 @@
+/* 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 TOR_NAMEMAP_H
+#define TOR_NAMEMAP_H
+
+/**
+ * \file namemap.h
+ *
+ * \brief Header for namemap.c
+ **/
+
+#include "lib/cc/compat_compiler.h"
+#include "ext/ht.h"
+
+#include <stddef.h>
+
+typedef struct namemap_t namemap_t;
+
+/** Returned in place of an identifier when an error occurs. */
+#define NAMEMAP_ERR UINT_MAX
+
+void namemap_init(namemap_t *map);
+const char *namemap_get_name(const namemap_t *map, unsigned id);
+const char *namemap_fmt_name(const namemap_t *map, unsigned id);
+unsigned namemap_get_id(const namemap_t *map,
+ const char *name);
+unsigned namemap_get_or_create_id(namemap_t *map,
+ const char *name);
+size_t namemap_get_size(const namemap_t *map);
+void namemap_clear(namemap_t *map);
+
+#endif