tor  0.4.2.1-alpha-dev
Data Structures | Typedefs | Functions | Variables
type_defs.c File Reference
#include "orconfig.h"
#include "lib/conf/conftypes.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_type_params_t
 
struct  enumeration_table_t
 

Typedefs

typedef struct int_type_params_t int_parse_params_t
 
typedef struct enumeration_table_t enumeration_table_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_table_t enum_table_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
 
static const var_type_def_t type_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 767 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 498 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 325 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 406 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 399 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 393 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 711 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 153 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 99 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 94 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 267 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 533 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 648 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 666 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 657 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 261 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 76 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 450 of file type_defs.c.

◆ type_definitions_table

const var_type_def_t type_definitions_table[]
static

Table mapping conf_type_t values to var_type_def_t objects.

Definition at line 719 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 200 of file type_defs.c.