diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-04-08 10:28:56 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-04-25 14:13:03 -0400 |
commit | dab35386cafc837c29fd251213337dec092043fe (patch) | |
tree | fd08f56f95d4a8fd6348cd9580c6352f43f8c9ee /src/lib/encoding | |
parent | 9471391694168f3d82365ced07b14e466b32b612 (diff) | |
download | tor-dab35386cafc837c29fd251213337dec092043fe.tar.gz tor-dab35386cafc837c29fd251213337dec092043fe.zip |
Add a case-insensitive variant to config_line_find()
Diffstat (limited to 'src/lib/encoding')
-rw-r--r-- | src/lib/encoding/confline.c | 13 | ||||
-rw-r--r-- | src/lib/encoding/confline.h | 2 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/encoding/confline.c b/src/lib/encoding/confline.c index 8110f3dd9c..fdb575e03f 100644 --- a/src/lib/encoding/confline.c +++ b/src/lib/encoding/confline.c @@ -82,6 +82,19 @@ config_line_find(const config_line_t *lines, return NULL; } +/** As config_line_find(), but perform a case-insensitive comparison. */ +const config_line_t * +config_line_find_case(const config_line_t *lines, + const char *key) +{ + const config_line_t *cl; + for (cl = lines; cl; cl = cl->next) { + if (!strcasecmp(cl->key, key)) + return cl; + } + return NULL; +} + /** Auxiliary function that does all the work of config_get_lines. * <b>recursion_level</b> is the count of how many nested %includes we have. * <b>opened_lst</b> will have a list of opened files if provided. diff --git a/src/lib/encoding/confline.h b/src/lib/encoding/confline.h index 3d9ae8a662..56ea36bf61 100644 --- a/src/lib/encoding/confline.h +++ b/src/lib/encoding/confline.h @@ -48,6 +48,8 @@ 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); +const config_line_t *config_line_find_case(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); |