Tor  0.4.6.0-alpha-dev
Macros | Functions | Variables
dispatch_naming.c File Reference

Name-to-ID maps for our message dispatch system. More...

#include "orconfig.h"
#include "lib/cc/compat_compiler.h"
#include "lib/dispatch/dispatch_naming.h"
#include "lib/dispatch/msgtypes.h"
#include "lib/container/namemap.h"
#include "lib/container/namemap_st.h"
#include "lib/log/util_bug.h"
#include "lib/log/log.h"
#include <stdlib.h>

Go to the source code of this file.

Macros

#define DECLARE_ID_MAP_FNS(type)
 

Functions

void dispatch_naming_init (void)
 
 DECLARE_ID_MAP_FNS (message)
 
 DECLARE_ID_MAP_FNS (channel)
 
 DECLARE_ID_MAP_FNS (subsys)
 
 DECLARE_ID_MAP_FNS (msg_type)
 

Variables

static namemap_t message_id_map = NAMEMAP_INIT()
 
static namemap_t subsys_id_map = NAMEMAP_INIT()
 
static namemap_t channel_id_map = NAMEMAP_INIT()
 
static namemap_t msg_type_id_map = NAMEMAP_INIT()
 

Detailed Description

Name-to-ID maps for our message dispatch system.

Definition in file dispatch_naming.c.

Macro Definition Documentation

◆ DECLARE_ID_MAP_FNS

#define DECLARE_ID_MAP_FNS (   type)
Value:
type##_id_t \
get_##type##_id(const char *name) \
{ \
unsigned u = namemap_get_or_create_id(&type##_id_map, name); \
tor_assert(u != NAMEMAP_ERR); \
tor_assert(u != ERROR_ID); \
return (type##_id_t) u; \
} \
const char * \
get_##type##_id_name(type##_id_t id) \
{ \
return namemap_fmt_name(&type##_id_map, id); \
} \
size_t \
get_num_##type##_ids(void) \
{ \
return namemap_get_size(&type##_id_map); \
} \
EAT_SEMICOLON

Definition at line 45 of file dispatch_naming.c.

Variable Documentation

◆ channel_id_map

namemap_t channel_id_map = NAMEMAP_INIT()
static

Global namemap for channel IDs.

Definition at line 32 of file dispatch_naming.c.

◆ message_id_map

namemap_t message_id_map = NAMEMAP_INIT()
static

Global namemap for message IDs.

Definition at line 28 of file dispatch_naming.c.

◆ msg_type_id_map

namemap_t msg_type_id_map = NAMEMAP_INIT()
static

Global namemap for message type IDs.

Definition at line 34 of file dispatch_naming.c.

◆ subsys_id_map

namemap_t subsys_id_map = NAMEMAP_INIT()
static

Global namemap for subsystem IDs.

Definition at line 30 of file dispatch_naming.c.

name
const char * name
Definition: config.c:2447
namemap_get_size
size_t namemap_get_size(const namemap_t *map)
Definition: namemap.c:165
namemap_fmt_name
const char * namemap_fmt_name(const namemap_t *map, unsigned id)
Definition: namemap.c:70
namemap_get_or_create_id
unsigned namemap_get_or_create_id(namemap_t *map, const char *name)
Definition: namemap.c:133
ERROR_ID
#define ERROR_ID
Definition: msgtypes.h:34
NAMEMAP_ERR
#define NAMEMAP_ERR
Definition: namemap.h:23