namemap_st.h 931 B

12345678910111213141516171819202122232425262728293031323334
  1. /* Copyright (c) 2003-2004, Roger Dingledine
  2. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  3. * Copyright (c) 2007-2018, The Tor Project, Inc. */
  4. /* See LICENSE for licensing information */
  5. #ifndef NAMEMAP_ST_H
  6. #define NAMEMAP_ST_H
  7. #include "lib/cc/compat_compiler.h"
  8. #include "ext/ht.h"
  9. struct smartlist_t;
  10. /** Longest allowed name that's allowed in a namemap_t. */
  11. #define MAX_NAMEMAP_NAME_LEN 128
  12. /** An entry inside a namemap_t. Maps a string to a numeric identifier. */
  13. typedef struct mapped_name_t {
  14. HT_ENTRY(mapped_name_t) node;
  15. unsigned intval;
  16. char name[FLEXIBLE_ARRAY_MEMBER];
  17. } mapped_name_t;
  18. /** A structure that allocates small numeric identifiers for names and maps
  19. * back and forth between them. */
  20. struct namemap_t {
  21. HT_HEAD(namemap_ht, mapped_name_t) ht;
  22. struct smartlist_t *names;
  23. };
  24. /** Macro to initialize a namemap. */
  25. #define NAMEMAP_INIT() { HT_INITIALIZER(), NULL }
  26. #endif