Tor  0.4.7.0-alpha-dev
namemap_st.h
Go to the documentation of this file.
1 /* Copyright (c) 2003-2004, Roger Dingledine
2  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3  * Copyright (c) 2007-2021, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
5 
6 #ifndef NAMEMAP_ST_H
7 #define NAMEMAP_ST_H
8 
9 /**
10  * @file namemap_st.h
11  * @brief Internal declarations for namemap structure.
12  **/
13 
14 #include "lib/cc/compat_compiler.h"
15 #include "ext/ht.h"
16 
17 struct smartlist_t;
18 
19 /** Longest allowed name that's allowed in a namemap_t. */
20 #define MAX_NAMEMAP_NAME_LEN 128
21 
22 /** An entry inside a namemap_t. Maps a string to a numeric identifier. */
23 typedef struct mapped_name_t {
24  HT_ENTRY(mapped_name_t) node;
25  unsigned intval;
26  char name[FLEXIBLE_ARRAY_MEMBER];
28 
29 /** A structure that allocates small numeric identifiers for names and maps
30  * back and forth between them. */
31 struct namemap_t {
32  HT_HEAD(namemap_ht, mapped_name_t) ht;
33  struct smartlist_t *names;
34 };
35 
36 #ifndef COCCI
37 /** Macro to initialize a namemap. */
38 #define NAMEMAP_INIT() { HT_INITIALIZER(), NULL }
39 #endif
40 
41 #endif /* !defined(NAMEMAP_ST_H) */
Utility macros to handle different features and behavior in different compilers.