Do not reverse command-line configuration options; Use new minimal-listener-close code; Add code to canonicalize configuration names.

svn:r4529
This commit is contained in:
Nick Mathewson 2005-07-11 17:35:36 +00:00
parent 658e1196d0
commit 50a206e800
2 changed files with 18 additions and 9 deletions

View File

@ -389,7 +389,7 @@ options_act(void)
if (accounting_is_enabled(options)) if (accounting_is_enabled(options))
configure_accounting(time(NULL)); configure_accounting(time(NULL));
if (!we_are_hibernating() && retry_all_listeners(1) < 0) { if (!we_are_hibernating() && retry_all_listeners(0) < 0) {
log_fn(LOG_ERR,"Failed to bind one of the listener ports."); log_fn(LOG_ERR,"Failed to bind one of the listener ports.");
return -1; return -1;
} }
@ -429,8 +429,8 @@ expand_abbrev(const char *option, int command_line)
static struct config_line_t * static struct config_line_t *
config_get_commandlines(int argc, char **argv) config_get_commandlines(int argc, char **argv)
{ {
struct config_line_t *new;
struct config_line_t *front = NULL; struct config_line_t *front = NULL;
struct config_line_t **new = &front;
char *s; char *s;
int i = 1; int i = 1;
@ -447,19 +447,19 @@ config_get_commandlines(int argc, char **argv)
continue; continue;
} }
new = tor_malloc(sizeof(struct config_line_t)); *new = tor_malloc_zero(sizeof(struct config_line_t));
s = argv[i]; s = argv[i];
while (*s == '-') while (*s == '-')
s++; s++;
new->key = tor_strdup(expand_abbrev(s, 1)); (*new)->key = tor_strdup(expand_abbrev(s, 1));
new->value = tor_strdup(argv[i+1]); (*new)->value = tor_strdup(argv[i+1]);
(*new)->next = NULL;
log(LOG_DEBUG,"Commandline: parsed keyword '%s', value '%s'", log(LOG_DEBUG,"Commandline: parsed keyword '%s', value '%s'",
new->key, new->value); (*new)->key, (*new)->value);
new->next = front;
front = new; new = &((*new)->next);
i += 2; i += 2;
} }
return front; return front;
@ -694,6 +694,14 @@ config_option_is_recognized(const char *key)
return (var != NULL); return (var != NULL);
} }
/** Return the canonical name of a configuration option. */
const char *
config_option_get_canonical_name(const char *key)
{
config_var_t *var = config_find_option(key);
return var->name;
}
/** Return a canonicalized list of the options assigned for key. /** Return a canonicalized list of the options assigned for key.
*/ */
struct config_line_t * struct config_line_t *

View File

@ -1337,6 +1337,7 @@ int config_parse_addr_policy(struct config_line_t *cfg,
void config_append_default_exit_policy(addr_policy_t **policy); void config_append_default_exit_policy(addr_policy_t **policy);
void addr_policy_free(addr_policy_t *p); void addr_policy_free(addr_policy_t *p);
int config_option_is_recognized(const char *key); int config_option_is_recognized(const char *key);
const char *config_option_get_canonical_name(const char *key);
struct config_line_t *config_get_assigned_option(or_options_t *options, struct config_line_t *config_get_assigned_option(or_options_t *options,
const char *key); const char *key);
char *config_dump_options(or_options_t *options, int minimal); char *config_dump_options(or_options_t *options, int minimal);