Tor  0.4.4.0-alpha-dev
Data Structures | Macros | Typedefs | Functions
confline.h File Reference

Header for confline.c. More...

Go to the source code of this file.

Data Structures

struct  config_decl_LINELIST_V
 

Macros

#define CONFIG_LINE_NORMAL   0
 
#define CONFIG_LINE_APPEND   1
 
#define CONFIG_LINE_CLEAR   2
 
#define MAX_INCLUDE_RECURSION_LEVEL   31
 
#define config_free_lines(front)
 

Typedefs

typedef int(* include_handler_fn) (const char *, int, int, struct config_line_t **, struct config_line_t **, struct smartlist_t *)
 

Functions

void config_line_append (config_line_t **lst, const char *key, const char *val)
 
void config_line_prepend (config_line_t **lst, const char *key, const char *val)
 
config_line_tconfig_lines_dup (const config_line_t *inp)
 
config_line_tconfig_lines_dup_and_filter (const config_line_t *inp, const char *key)
 
const config_line_tconfig_line_find (const config_line_t *lines, const char *key)
 
const config_line_tconfig_line_find_case (const config_line_t *lines, const char *key)
 
config_line_tconfig_lines_partition (config_line_t *inp, const char *header)
 
int config_lines_eq (const config_line_t *a, const config_line_t *b)
 
int config_count_key (const config_line_t *a, const char *key)
 
void config_free_lines_ (config_line_t *front)
 
const char * parse_config_line_from_str_verbose (const char *line, char **key_out, char **value_out, const char **err_out)
 
int config_get_lines (const char *string, struct config_line_t **result, int extended)
 
int config_get_lines_aux (const char *string, struct config_line_t **result, int extended, int allow_include, int *has_include, struct smartlist_t *opened_lst, int recursion_level, config_line_t **last, include_handler_fn handle_include)
 

Detailed Description

Header for confline.c.

Definition in file confline.h.

Macro Definition Documentation

◆ config_free_lines

#define config_free_lines (   front)
Value:
do { \
config_free_lines_(front); \
(front) = NULL; \
} while (0)

Definition at line 57 of file confline.h.

◆ CONFIG_LINE_APPEND

#define CONFIG_LINE_APPEND   1

Appends to previous configuration for the same option, even if we would ordinary replace it.

Definition at line 22 of file confline.h.

◆ CONFIG_LINE_NORMAL

#define CONFIG_LINE_NORMAL   0

Ordinary configuration line.

Definition at line 19 of file confline.h.

Function Documentation

◆ config_count_key()

int config_count_key ( const config_line_t a,
const char *  key 
)

Return the number of lines in a whose key is key.

Definition at line 303 of file confline.c.

◆ config_free_lines_()

void config_free_lines_ ( config_line_t front)

Free all the configuration lines on the linked list front.

Definition at line 211 of file confline.c.

◆ config_get_lines()

int config_get_lines ( const char *  string,
config_line_t **  result,
int  extended 
)

Same as config_get_lines_include but does not allow include

Definition at line 201 of file confline.c.

Referenced by storage_dir_map_labeled().

◆ config_get_lines_aux()

int config_get_lines_aux ( const char *  string,
config_line_t **  result,
int  extended,
int  allow_include,
int *  has_include,
struct smartlist_t opened_lst,
int  recursion_level,
config_line_t **  last,
include_handler_fn  handle_include 
)

Auxiliary function that does all the work of config_get_lines. recursion_level is the count of how many nested includes we have. opened_lst will have a list of opened files if provided. Returns the a pointer to the last element of the result in last.

Definition at line 104 of file confline.c.

Referenced by config_get_lines(), and config_get_lines_include().

◆ config_line_append()

void config_line_append ( config_line_t **  lst,
const char *  key,
const char *  val 
)

Helper: allocate a new configuration option mapping 'key' to 'val', append it to *lst.

Definition at line 32 of file confline.c.

Referenced by get_options_defaults().

◆ config_line_find()

const config_line_t* config_line_find ( const config_line_t lines,
const char *  key 
)

Return the first line in lines whose key is exactly key, or NULL if no such key exists.

(In options parsing, this is for handling commandline-only options only; other options should be looked up in the appropriate data structure.)

Definition at line 74 of file confline.c.

Referenced by consensus_cache_entry_get_value(), and options_init_from_torrc().

◆ config_line_find_case()

const config_line_t* config_line_find_case ( const config_line_t lines,
const char *  key 
)

As config_line_find(), but perform a case-insensitive comparison.

Definition at line 87 of file confline.c.

Referenced by config_lines_contain_flag(), and handle_control_postdescriptor().

◆ config_line_prepend()

void config_line_prepend ( config_line_t **  lst,
const char *  key,
const char *  val 
)

Helper: allocate a new configuration option mapping 'key' to 'val', and prepend it to *lst

Definition at line 53 of file confline.c.

Referenced by directory_request_add_header().

◆ config_lines_dup()

config_line_t* config_lines_dup ( const config_line_t inp)

Return a newly allocated deep copy of the lines in inp.

Definition at line 227 of file confline.c.

Referenced by consensus_compress_worker_threadfn(), control_setconf_helper(), and dirauth_options_pre_normalize().

◆ config_lines_dup_and_filter()

config_line_t* config_lines_dup_and_filter ( const config_line_t inp,
const char *  key 
)

Return a newly allocated deep copy of the lines in inp, but only the ones whose keys begin with key (case-insensitive). If key is NULL, do not filter.

Definition at line 236 of file confline.c.

Referenced by config_lines_dup().

◆ config_lines_eq()

int config_lines_eq ( const config_line_t a,
const config_line_t b 
)

Return true iff a and b contain identical keys and values in identical order.

Definition at line 288 of file confline.c.

Referenced by options_act_bridge_stats().

◆ config_lines_partition()

config_line_t* config_lines_partition ( config_line_t inp,
const char *  header 
)

Given a linelist inp beginning with the key header, find the next line with that key, and remove that instance and all following lines from the list. Return the lines that were removed. Operate case-insensitively.

For example, if the header is "H", and inp contains "H, A, B, H, C, H, D", this function will alter inp to contain only "H, A, B", and return the elements "H, C, H, D" as a separate list.

Definition at line 267 of file confline.c.

◆ parse_config_line_from_str_verbose()

const char* parse_config_line_from_str_verbose ( const char *  line,
char **  key_out,
char **  value_out,
const char **  err_out 
)

Given a string containing part of a configuration file or similar format, advance past comments and whitespace and try to parse a single line. If we parse a line successfully, set *key_out to a new string holding the key portion and *value_out to a new string holding the value portion of the line, and return a pointer to the start of the next line. If we run out of data, return a pointer to the end of the string. If we encounter an error, return NULL and set *err_out (if provided) to an error message.

Definition at line 325 of file confline.c.