tor  0.4.1.0-alpha-dev
Data Structures | Macros | Typedefs | Functions
confline.h File Reference

Go to the source code of this file.

Data Structures

struct  config_line_t
 

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 struct config_line_t config_line_t
 
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)
 
int config_lines_eq (config_line_t *a, 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 54 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.

Referenced by config_parse_commandline().

Typedef Documentation

◆ config_line_t

typedef struct config_line_t config_line_t

A linked list of lines in a config file, or elsewhere

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 261 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 198 of file confline.c.

References tor_free.

◆ 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 188 of file confline.c.

References config_get_lines_aux().

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 91 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.

References tor_assert().

◆ 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 options_init_from_torrc().

◆ 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.

References tor_assert().

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 214 of file confline.c.

References config_lines_dup_and_filter().

◆ 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 223 of file confline.c.

References strcasecmpstart().

Referenced by config_lines_dup().

◆ config_lines_eq()

int config_lines_eq ( config_line_t a,
config_line_t b 
)

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

Definition at line 246 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 283 of file confline.c.

References tor_assert().