diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-11-09 06:40:32 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-11-09 06:40:32 +0000 |
commit | 48a0b6c476dee067685a66a955cdffc8a37ea9d3 (patch) | |
tree | be7cf99ec4d744cfd5448926e761ad556ee44985 /src/or/config.c | |
parent | 005b02fd57136b2deb53185458cbedd9c2d7c1a6 (diff) | |
download | tor-48a0b6c476dee067685a66a955cdffc8a37ea9d3.tar.gz tor-48a0b6c476dee067685a66a955cdffc8a37ea9d3.zip |
Separate is-recognized-option from get-option-value, since NULL is ambiguous and returning "" misrepresents.
svn:r2731
Diffstat (limited to 'src/or/config.c')
-rw-r--r-- | src/or/config.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/or/config.c b/src/or/config.c index 0843e855a2..7d405b63e6 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -255,7 +255,7 @@ options_act(void) { if (options->command != CMD_RUN_TOR) return 0; - if (set_max_file_descriptors(get_options()->MaxConn) < 0) + if (set_max_file_descriptors(options->MaxConn) < 0) return -1; /* Configure the log(s) */ @@ -542,6 +542,14 @@ config_reset_line(or_options_t *options, const char *key) option_reset(options, var); } +/** Return true iff key is a valid configuration option. */ +int +config_option_is_recognized(const char *key) +{ + config_var_t *var = config_find_option(key); + return (var != NULL); +} + /** Return a canonicalized list of the options assigned for key. */ struct config_line_t * @@ -551,6 +559,7 @@ config_get_assigned_option(or_options_t *options, const char *key) const void *value; char buf[32]; struct config_line_t *result; + tor_assert(options && key); var = config_find_option(key); if (!var) { @@ -583,7 +592,13 @@ config_get_assigned_option(or_options_t *options, const char *key) switch(var->type) { case CONFIG_TYPE_STRING: - result->value = tor_strdup(*(char**)value ? *(char**)value : ""); + if (*(char**)value) { + result->value = tor_strdup(*(char**)value); + } else { + tor_free(result->key); + tor_free(result); + return NULL; + } break; case CONFIG_TYPE_UINT: /* XXX This means every or_options_t uint or bool element @@ -633,6 +648,7 @@ static int config_assign(or_options_t *options, struct config_line_t *list, int reset) { struct config_line_t *p; + tor_assert(options); /* pass 1: normalize keys */ for (p = list; p; p = p->next) { |