tor  0.4.2.1-alpha-dev
Macros | Typedefs | Functions
namemap.h File Reference
#include "lib/cc/compat_compiler.h"
#include "ext/ht.h"
#include <stddef.h>

Go to the source code of this file.

Macros

#define NAMEMAP_ERR   UINT_MAX
 

Typedefs

typedef struct namemap_t namemap_t
 

Functions

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)
 

Detailed Description

Header for namemap.c.

Definition in file namemap.h.

Macro Definition Documentation

◆ NAMEMAP_ERR

#define NAMEMAP_ERR   UINT_MAX

Returned in place of an identifier when an error occurs.

Definition at line 23 of file namemap.h.

Function Documentation

◆ namemap_clear()

void namemap_clear ( namemap_t map)

Release all storage held in map.

Definition at line 172 of file namemap.c.

References SMARTLIST_FOREACH, and tor_free.

◆ namemap_fmt_name()

const char* namemap_fmt_name ( const namemap_t map,
unsigned  id 
)

Return the name that map associates with a given id, or a pointer to a statically allocated string describing the value of id if no such name exists.

Definition at line 65 of file namemap.c.

◆ namemap_get_id()

unsigned namemap_get_id ( const namemap_t map,
const char *  name 
)

Return the identifier currently associated by map with the name name, or NAMEMAP_ERR if no such identifier exists.

Definition at line 109 of file namemap.c.

◆ namemap_get_name()

const char* namemap_get_name ( const namemap_t map,
unsigned  id 
)

Return the name that map associates with a given id, or NULL if there is no such name.

Definition at line 49 of file namemap.c.

◆ namemap_get_or_create_id()

unsigned namemap_get_or_create_id ( namemap_t map,
const char *  name 
)

Return the identifier associated by map with the name name, allocating a new identifier in map if none exists.

Return NAMEMAP_ERR if name is too long, or if there are no more identifiers we can allocate.

Definition at line 128 of file namemap.c.

◆ namemap_get_size()

size_t namemap_get_size ( const namemap_t map)

Return the number of entries in 'names'

Definition at line 160 of file namemap.c.