Tor 0.4.9.1-alpha-dev
Macros | Functions
namemap.h File Reference

Header for namemap.c. More...

#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
 

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 177 of file namemap.c.

◆ 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 70 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 114 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 54 of file namemap.c.

Referenced by namemap_fmt_name().

◆ 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 133 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 165 of file namemap.c.

◆ namemap_init()

void namemap_init ( namemap_t map)

Set up an uninitialized map.

Definition at line 44 of file namemap.c.