namemap.h 1000 B

1234567891011121314151617181920212223242526272829303132333435
  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 TOR_NAMEMAP_H
  6. #define TOR_NAMEMAP_H
  7. /**
  8. * \file namemap.h
  9. *
  10. * \brief Header for namemap.c
  11. **/
  12. #include "lib/cc/compat_compiler.h"
  13. #include "ext/ht.h"
  14. #include <stddef.h>
  15. typedef struct namemap_t namemap_t;
  16. /** Returned in place of an identifier when an error occurs. */
  17. #define NAMEMAP_ERR UINT_MAX
  18. void namemap_init(namemap_t *map);
  19. const char *namemap_get_name(const namemap_t *map, unsigned id);
  20. const char *namemap_fmt_name(const namemap_t *map, unsigned id);
  21. unsigned namemap_get_id(const namemap_t *map,
  22. const char *name);
  23. unsigned namemap_get_or_create_id(namemap_t *map,
  24. const char *name);
  25. size_t namemap_get_size(const namemap_t *map);
  26. void namemap_clear(namemap_t *map);
  27. #endif /* !defined(TOR_NAMEMAP_H) */