diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-03-31 10:24:38 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-04-04 11:11:01 -0400 |
commit | c2947dbb8645ed7c1db58dabff8752abf9625e0d (patch) | |
tree | 8f226a69fbb0d2718dad2da3c9dcace527c46352 /src/common/confline.h | |
parent | 321c1c453e4ee757be7df823da28b0f4af7ae60a (diff) | |
download | tor-c2947dbb8645ed7c1db58dabff8752abf9625e0d.tar.gz tor-c2947dbb8645ed7c1db58dabff8752abf9625e0d.zip |
Move config_line_t functions from confparse.c into common.
I'm doing this to storagedir to used config_line_t.
Diffstat (limited to 'src/common/confline.h')
-rw-r--r-- | src/common/confline.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/common/confline.h b/src/common/confline.h new file mode 100644 index 0000000000..86eabe00b2 --- /dev/null +++ b/src/common/confline.h @@ -0,0 +1,45 @@ +/* Copyright (c) 2001 Matej Pfajfar. + * Copyright (c) 2001-2004, Roger Dingledine. + * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. + * Copyright (c) 2007-2017, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +#ifndef TOR_CONFLINE_H +#define TOR_CONFLINE_H + +/** Ordinary configuration line. */ +#define CONFIG_LINE_NORMAL 0 +/** Appends to previous configuration for the same option, even if we + * would ordinary replace it. */ +#define CONFIG_LINE_APPEND 1 +/* Removes all previous configuration for an option. */ +#define CONFIG_LINE_CLEAR 2 + +/** A linked list of lines in a config file, or elsewhere */ +typedef struct config_line_t { + char *key; + char *value; + struct config_line_t *next; + + /** What special treatment (if any) does this line require? */ + unsigned int command:2; + /** If true, subsequent assignments to this linelist should replace + * it, not extend it. Set only on the first item in a linelist in an + * or_options_t. */ + unsigned int fragile:1; +} config_line_t; + +void config_line_append(config_line_t **lst, + const char *key, const char *val); +config_line_t *config_lines_dup(const config_line_t *inp); +config_line_t *config_lines_dup_and_filter(const config_line_t *inp, + const char *key); +const config_line_t *config_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); +int config_get_lines(const char *string, config_line_t **result, int extended); +void config_free_lines(config_line_t *front); + +#endif + |