Tor  0.4.7.0-alpha-dev
Data Structures | Functions | Variables
type_defs.c File Reference

Definitions for various low-level configuration types. More...

#include "orconfig.h"
#include "lib/conf/conftypes.h"
#include "lib/conf/confdecl.h"
#include "lib/confmgt/typedvar.h"
#include "lib/confmgt/type_defs.h"
#include "lib/confmgt/unitparse.h"
#include "lib/cc/compat_compiler.h"
#include "lib/container/smartlist.h"
#include "lib/encoding/confline.h"
#include "lib/encoding/time_fmt.h"
#include "lib/log/escape.h"
#include "lib/log/log.h"
#include "lib/log/util_bug.h"
#include "lib/malloc/malloc.h"
#include "lib/string/parse_int.h"
#include "lib/string/printf.h"
#include "lib/confmgt/var_type_def_st.h"
#include <stddef.h>
#include <string.h>
#include <errno.h>

Go to the source code of this file.

Data Structures

struct  int_parse_params_t
 
struct  enumeration_table_t
 
struct  enumeration_params_t
 

Functions

static int string_parse (void *target, const char *value, char **errmsg, const void *params)
 
static char * string_encode (const void *value, const void *params)
 
static void string_clear (void *value, const void *params)
 
static int int_parse (void *target, const char *value, char **errmsg, const void *params)
 
static char * int_encode (const void *value, const void *params)
 
static void int_clear (void *value, const void *params)
 
static bool int_ok (const void *value, const void *params)
 
static int uint64_parse (void *target, const char *value, char **errmsg, const void *params)
 
static char * uint64_encode (const void *value, const void *params)
 
static void uint64_clear (void *value, const void *params)
 
static int units_parse_u64 (void *target, const char *value, char **errmsg, const void *params)
 
static int units_parse_int (void *target, const char *value, char **errmsg, const void *params)
 
static bool units_ok_int (const void *value, const void *params)
 
static int double_parse (void *target, const char *value, char **errmsg, const void *params)
 
static char * double_encode (const void *value, const void *params)
 
static void double_clear (void *value, const void *params)
 
static int enum_parse (void *target, const char *value, char **errmsg, const void *params_)
 
static char * enum_encode (const void *value, const void *params_)
 
static void enum_clear (void *value, const void *params_)
 
static bool enum_ok (const void *value, const void *params_)
 
static int time_parse (void *target, const char *value, char **errmsg, const void *params)
 
static char * time_encode (const void *value, const void *params)
 
static void time_clear (void *value, const void *params)
 
static int csv_parse (void *target, const char *value, char **errmsg, const void *params)
 
static char * csv_encode (const void *value, const void *params)
 
static void csv_clear (void *value, const void *params)
 
static int legacy_csv_interval_parse (void *target, const char *value, char **errmsg, const void *params)
 
static int linelist_kv_parse (void *target, const struct config_line_t *line, char **errmsg, const void *params)
 
static int linelist_kv_virt_noparse (void *target, const struct config_line_t *line, char **errmsg, const void *params)
 
static struct config_line_tlinelist_kv_encode (const char *key, const void *value, const void *params)
 
static struct config_line_tlinelist_s_kv_encode (const char *key, const void *value, const void *params)
 
static void linelist_clear (void *target, const void *params)
 
static bool linelist_eq (const void *a, const void *b, const void *params)
 
static int linelist_copy (void *target, const void *value, const void *params)
 
static void linelist_mark_fragile (void *target, const void *params)
 
static int ignore_parse (void *target, const char *value, char **errmsg, const void *params)
 
static char * ignore_encode (const void *value, const void *params)
 
const var_type_def_tlookup_type_def (config_type_t type)
 

Variables

static const var_type_fns_t string_fns
 
static const int_parse_params_t INT_PARSE_UNRESTRICTED
 
static const int_parse_params_t INT_PARSE_POSINT
 
static const var_type_fns_t int_fns
 
static const var_type_fns_t uint64_fns
 
static const var_type_fns_t memunit_fns
 
static const var_type_fns_t interval_fns
 
static const var_type_fns_t double_fns
 
static const enumeration_table_t enum_table_bool []
 
static const enumeration_params_t enum_params_bool
 
static const enumeration_table_t enum_table_autobool []
 
static const enumeration_params_t enum_params_autobool
 
static const var_type_fns_t enum_fns
 
static const var_type_fns_t time_fns
 
static const var_type_fns_t csv_fns
 
static const var_type_fns_t legacy_csv_interval_fns
 
static const var_type_fns_t linelist_fns
 
static const var_type_fns_t linelist_v_fns
 
static const var_type_fns_t linelist_s_fns
 
static const var_type_fns_t ignore_fns
 
const var_type_def_t STRING_type_defn
 
const var_type_def_t FILENAME_type_defn
 
const var_type_def_t INT_type_defn
 
const var_type_def_t POSINT_type_defn
 
const var_type_def_t UINT64_type_defn
 
const var_type_def_t MEMUNIT_type_defn
 
const var_type_def_t INTERVAL_type_defn
 
const var_type_def_t MSEC_INTERVAL_type_defn
 
const var_type_def_t DOUBLE_type_defn
 
const var_type_def_t BOOL_type_defn
 
const var_type_def_t AUTOBOOL_type_defn
 
const var_type_def_t ISOTIME_type_defn
 
const var_type_def_t CSV_type_defn
 
const var_type_def_t CSV_INTERVAL_type_defn
 
const var_type_def_t LINELIST_type_defn
 
const var_type_def_t LINELIST_S_type_defn
 
const var_type_def_t LINELIST_V_type_defn
 
const var_type_def_t IGNORE_type_defn
 
const var_type_def_t OBSOLETE_type_defn
 
static const var_type_def_ttype_definitions_table []
 

Detailed Description

Definitions for various low-level configuration types.

This module creates a number of var_type_def_t objects, to be used by typedvar.c in manipulating variables.

The types here are common types that can be implemented with Tor's low-level functionality. To define new types, see var_type_def_st.h.

Definition in file type_defs.c.

Function Documentation

◆ lookup_type_def()

const var_type_def_t* lookup_type_def ( config_type_t  type)

Return a pointer to the var_type_def_t object for the given config_type_t value, or NULL if no such type definition exists.

Definition at line 842 of file type_defs.c.

Referenced by get_type_def().

Variable Documentation

◆ csv_fns

const var_type_fns_t csv_fns
static
Initial value:
= {
.parse = csv_parse,
.encode = csv_encode,
.clear = csv_clear,
}

Definition at line 538 of file type_defs.c.

◆ double_fns

const var_type_fns_t double_fns
static
Initial value:
= {
.parse = double_parse,
.encode = double_encode,
.clear = double_clear,
}

Definition at line 345 of file type_defs.c.

◆ enum_fns

const var_type_fns_t enum_fns
static
Initial value:
= {
.parse = enum_parse,
.encode = enum_encode,
.clear = enum_clear,
.ok = enum_ok,
}

Definition at line 446 of file type_defs.c.

◆ enum_params_autobool

const enumeration_params_t enum_params_autobool
static
Initial value:
= {
"Allowed values are 0, 1, and auto.",
enum_table_autobool
}

Definition at line 441 of file type_defs.c.

◆ enum_params_bool

const enumeration_params_t enum_params_bool
static
Initial value:
= {
"Allowed values are 0 and 1.",
enum_table_bool
}

Definition at line 429 of file type_defs.c.

◆ enum_table_autobool

const enumeration_table_t enum_table_autobool[]
static
Initial value:
= {
{ "0", 0 },
{ "1", 1 },
{ "auto", -1 },
{ NULL, 0 },
}

Definition at line 434 of file type_defs.c.

◆ enum_table_bool

const enumeration_table_t enum_table_bool[]
static
Initial value:
= {
{ "0", 0 },
{ "1", 1 },
{ NULL, 0 },
}

Definition at line 423 of file type_defs.c.

◆ ignore_fns

const var_type_fns_t ignore_fns
static
Initial value:
= {
.parse = ignore_parse,
.encode = ignore_encode,
}

Definition at line 745 of file type_defs.c.

◆ int_fns

const var_type_fns_t int_fns
static
Initial value:
= {
.parse = int_parse,
.encode = int_encode,
.clear = int_clear,
.ok = int_ok,
}

Definition at line 161 of file type_defs.c.

◆ INT_PARSE_POSINT

const int_parse_params_t INT_PARSE_POSINT
static
Initial value:
= {
.minval = 0,
.maxval = INT_MAX,
}

Definition at line 106 of file type_defs.c.

◆ INT_PARSE_UNRESTRICTED

const int_parse_params_t INT_PARSE_UNRESTRICTED
static
Initial value:
= {
.minval = INT_MIN,
.maxval = INT_MAX,
}

Definition at line 101 of file type_defs.c.

◆ interval_fns

const var_type_fns_t interval_fns
static
Initial value:
= {
.parse = units_parse_int,
.encode = int_encode,
.clear = int_clear,
.ok = units_ok_int
}

Definition at line 287 of file type_defs.c.

◆ legacy_csv_interval_fns

const var_type_fns_t legacy_csv_interval_fns
static
Initial value:
= {
.parse = legacy_csv_interval_parse,
.encode = int_encode,
.clear = int_clear,
}

Definition at line 573 of file type_defs.c.

◆ linelist_fns

const var_type_fns_t linelist_fns
static
Initial value:
= {
.kv_parse = linelist_kv_parse,
.kv_encode = linelist_kv_encode,
.clear = linelist_clear,
.eq = linelist_eq,
.copy = linelist_copy,
.mark_fragile = linelist_mark_fragile,
}

Definition at line 688 of file type_defs.c.

◆ linelist_s_fns

const var_type_fns_t linelist_s_fns
static
Initial value:
= {
.kv_parse = linelist_kv_parse,
.kv_encode = linelist_s_kv_encode,
.clear = linelist_clear,
.eq = linelist_eq,
.copy = linelist_copy,
}

Definition at line 706 of file type_defs.c.

◆ linelist_v_fns

const var_type_fns_t linelist_v_fns
static
Initial value:
= {
.kv_parse = linelist_kv_virt_noparse,
.kv_encode = linelist_kv_encode,
.clear = linelist_clear,
.eq = linelist_eq,
.copy = linelist_copy,
.mark_fragile = linelist_mark_fragile,
}

Definition at line 697 of file type_defs.c.

◆ memunit_fns

const var_type_fns_t memunit_fns
static
Initial value:
= {
.parse = units_parse_u64,
.encode = uint64_encode,
.clear = uint64_clear,
}

Definition at line 281 of file type_defs.c.

◆ string_fns

const var_type_fns_t string_fns
static
Initial value:
= {
.parse = string_parse,
.encode = string_encode,
.clear = string_clear,
}

Definition at line 80 of file type_defs.c.

◆ time_fns

const var_type_fns_t time_fns
static
Initial value:
= {
.parse = time_parse,
.encode = time_encode,
.clear = time_clear,
}

Definition at line 490 of file type_defs.c.

◆ type_definitions_table

const var_type_def_t* type_definitions_table[]
static
Initial value:
= {
[CONFIG_TYPE_STRING] = &STRING_type_defn,
[CONFIG_TYPE_FILENAME] = &FILENAME_type_defn,
[CONFIG_TYPE_INT] = &INT_type_defn,
[CONFIG_TYPE_POSINT] = &POSINT_type_defn,
[CONFIG_TYPE_UINT64] = &UINT64_type_defn,
[CONFIG_TYPE_MEMUNIT] = &MEMUNIT_type_defn,
[CONFIG_TYPE_INTERVAL] = &INTERVAL_type_defn,
[CONFIG_TYPE_MSEC_INTERVAL] = &MSEC_INTERVAL_type_defn,
[CONFIG_TYPE_DOUBLE] = &DOUBLE_type_defn,
[CONFIG_TYPE_BOOL] = &BOOL_type_defn,
[CONFIG_TYPE_AUTOBOOL] = &AUTOBOOL_type_defn,
[CONFIG_TYPE_ISOTIME] = &ISOTIME_type_defn,
[CONFIG_TYPE_CSV] = &CSV_type_defn,
[CONFIG_TYPE_CSV_INTERVAL] = &CSV_INTERVAL_type_defn,
[CONFIG_TYPE_LINELIST] = &LINELIST_type_defn,
[CONFIG_TYPE_LINELIST_S] = &LINELIST_S_type_defn,
[CONFIG_TYPE_LINELIST_V] = &LINELIST_V_type_defn,
[CONFIG_TYPE_IGNORE] = &IGNORE_type_defn,
[CONFIG_TYPE_OBSOLETE] = &OBSOLETE_type_defn,
}
@ CONFIG_TYPE_AUTOBOOL
Definition: conftypes.h:51
@ CONFIG_TYPE_ISOTIME
Definition: conftypes.h:53
@ CONFIG_TYPE_CSV_INTERVAL
Definition: conftypes.h:56
@ CONFIG_TYPE_LINELIST_V
Definition: conftypes.h:64
@ CONFIG_TYPE_CSV
Definition: conftypes.h:54
@ CONFIG_TYPE_LINELIST_S
Definition: conftypes.h:62
@ CONFIG_TYPE_DOUBLE
Definition: conftypes.h:49
@ CONFIG_TYPE_IGNORE
Definition: conftypes.h:77
@ CONFIG_TYPE_INTERVAL
Definition: conftypes.h:45
@ CONFIG_TYPE_MSEC_INTERVAL
Definition: conftypes.h:46
@ CONFIG_TYPE_INT
Definition: conftypes.h:43
@ CONFIG_TYPE_FILENAME
Definition: conftypes.h:41
@ CONFIG_TYPE_MEMUNIT
Definition: conftypes.h:48
@ CONFIG_TYPE_STRING
Definition: conftypes.h:40
@ CONFIG_TYPE_OBSOLETE
Definition: conftypes.h:71
@ CONFIG_TYPE_UINT64
Definition: conftypes.h:44
@ CONFIG_TYPE_BOOL
Definition: conftypes.h:50
@ CONFIG_TYPE_POSINT
Definition: conftypes.h:42
@ CONFIG_TYPE_LINELIST
Definition: conftypes.h:61

Table mapping conf_type_t values to var_type_def_t objects.

Definition at line 815 of file type_defs.c.

◆ uint64_fns

const var_type_fns_t uint64_fns
static
Initial value:
= {
.parse = uint64_parse,
.encode = uint64_encode,
.clear = uint64_clear,
}

Definition at line 208 of file type_defs.c.