Rename cross-format config.c stuff to config_* and or_options_t-specific stuff to option[s]_*

svn:r4641
This commit is contained in:
Nick Mathewson 2005-07-23 01:58:05 +00:00
parent 3cb7b97660
commit 2bd6040f62
6 changed files with 32 additions and 32 deletions

View File

@ -371,7 +371,7 @@ options_act(void)
return 0;
mark_logs_temp(); /* Close current logs once new logs are open. */
if (config_init_logs(options, 0)<0) /* Configure the log(s) */
if (options_init_logs(options, 0)<0) /* Configure the log(s) */
return -1;
/* Close the temporary log we used while starting up, if it isn't already
@ -741,7 +741,7 @@ config_reset_line(config_format_t *fmt, or_options_t *options, const char *key)
/** Return true iff key is a valid configuration option. */
int
config_option_is_recognized(const char *key)
option_is_recognized(const char *key)
{
config_var_t *var = config_find_option(&config_format, key);
return (var != NULL);
@ -749,7 +749,7 @@ config_option_is_recognized(const char *key)
/** Return the canonical name of a configuration option. */
const char *
config_option_get_canonical_name(const char *key)
option_get_canonical_name(const char *key)
{
config_var_t *var = config_find_option(&config_format, key);
return var->name;
@ -758,7 +758,7 @@ config_option_get_canonical_name(const char *key)
/** Return a canonicalized list of the options assigned for key.
*/
config_line_t *
config_get_assigned_option(or_options_t *options, const char *key)
option_get_assignment(or_options_t *options, const char *key)
{
return get_assigned_option(&config_format, options, key);
}
@ -904,7 +904,7 @@ config_assign(config_format_t *fmt,
* keys, -2 on bad values, -3 on bad transition.
*/
int
config_trial_assign(config_line_t *list, int reset)
options_trial_assign(config_line_t *list, int reset)
{
int r;
or_options_t *trial_options = options_dup(&config_format, get_options());
@ -1300,7 +1300,7 @@ config_dump(config_format_t *fmt, or_options_t *options, int minimal)
* include options that are the same as Tor's defaults.
*/
char *
config_dump_options(or_options_t *options, int minimal)
options_dump(or_options_t *options, int minimal)
{
return config_dump(&config_format, options, minimal);
}
@ -1386,7 +1386,7 @@ options_validate(or_options_t *options)
config_line_append(&options->Logs, "Log", "notice stdout");
}
if (config_init_logs(options, 1)<0) /* Validate the log(s) */
if (options_init_logs(options, 1)<0) /* Validate the log(s) */
return -1;
if (server_mode(options)) {
@ -1672,7 +1672,7 @@ options_validate(or_options_t *options)
log_fn(LOG_WARN, "Error in Exit Policy entry.");
result = -1;
}
config_append_default_exit_policy(&addr_policy);
options_append_default_exit_policy(&addr_policy);
if (server_mode(options)) {
exit_policy_implicitly_allows_local_networks(addr_policy, 1);
}
@ -1853,7 +1853,7 @@ check_nickname_list(const char *lst, const char *name)
* validate them for consistency, then take actions based on them.
* Return 0 if success, -1 if failure. */
int
init_from_config(int argc, char **argv)
options_init_from_torrc(int argc, char **argv)
{
or_options_t *oldoptions, *newoptions;
config_line_t *cl;
@ -2117,7 +2117,7 @@ convert_log_option(or_options_t *options, config_line_t *level_opt,
* Initialize the logs based on the configuration file.
*/
int
config_init_logs(or_options_t *options, int validate_only)
options_init_logs(or_options_t *options, int validate_only)
{
config_line_t *opt;
int ok;
@ -2277,7 +2277,7 @@ normalize_log_options(or_options_t *options)
/** Add the default exit policy entries to <b>policy</b>
*/
void
config_append_default_exit_policy(addr_policy_t **policy)
options_append_default_exit_policy(addr_policy_t **policy)
{
config_line_t tmp;
addr_policy_t *ap;
@ -2552,7 +2552,7 @@ write_configuration_file(const char *fname, or_options_t *options)
}
}
if (!(new_conf = config_dump_options(options, 1))) {
if (!(new_conf = options_dump(options, 1))) {
log_fn(LOG_WARN, "Couldn't get configuration string");
goto err;
}
@ -2599,7 +2599,7 @@ write_configuration_file(const char *fname, or_options_t *options)
* success, -1 on failure.
**/
int
save_current_config(void)
options_save_current(void)
{
char *fn;
if (config_fname) {

View File

@ -657,7 +657,7 @@ handle_control_setconf(connection_t *conn, uint32_t len, char *body)
}
}
if ((r=config_trial_assign(lines, 1)) < 0) {
if ((r=options_trial_assign(lines, 1)) < 0) {
log_fn(LOG_WARN,"Controller gave us config lines that didn't validate.");
if (r==-1) {
if (v0)
@ -709,7 +709,7 @@ handle_control_getconf(connection_t *conn, uint32_t body_len, const char *body)
unrecognized = smartlist_create();
SMARTLIST_FOREACH(questions, char *, q,
{
if (!config_option_is_recognized(q)) {
if (!option_is_recognized(q)) {
if (v0) {
send_control0_error(conn, ERR_UNRECOGNIZED_CONFIG_KEY, q);
goto done;
@ -717,9 +717,9 @@ handle_control_getconf(connection_t *conn, uint32_t body_len, const char *body)
smartlist_add(unrecognized, q);
}
} else {
config_line_t *answer = config_get_assigned_option(options,q);
config_line_t *answer = option_get_assignment(options,q);
if (!v0 && !answer) {
const char *name = config_option_get_canonical_name(q);
const char *name = option_get_canonical_name(q);
size_t alen = strlen(name)+8;
char *astr = tor_malloc(alen);
tor_snprintf(astr, alen, "250-%s\r\n", name);
@ -959,7 +959,7 @@ static int
handle_control_saveconf(connection_t *conn, uint32_t len,
const char *body)
{
if (save_current_config()<0) {
if (options_save_current()<0) {
if (STATE_IS_V0(conn->state))
send_control0_error(conn, ERR_INTERNAL,
"Unable to write configuration to disk.");

View File

@ -911,7 +911,7 @@ do_hup(void)
addressmap_clear_transient();
/* first, reload config variables, in case they've changed */
/* no need to provide argc/v, they've been cached inside init_from_config */
if (init_from_config(0, NULL) < 0) {
if (options_init_from_torrc(0, NULL) < 0) {
log_fn(LOG_ERR,"Reading config failed--see warnings above. For usage, try -h.");
return -1;
}
@ -1303,7 +1303,7 @@ tor_init(int argc, char *argv[])
}
atexit(exit_function);
if (init_from_config(argc,argv) < 0) {
if (options_init_from_torrc(argc,argv) < 0) {
log_fn(LOG_ERR,"Reading config failed--see warnings above. For usage, try -h.");
return -1;
}

View File

@ -1333,21 +1333,21 @@ const char *safe_str(const char *address);
int config_get_lines(char *string, config_line_t **result);
void config_free_lines(config_line_t *front);
int config_trial_assign(config_line_t *list, int reset);
int options_trial_assign(config_line_t *list, int reset);
int resolve_my_address(or_options_t *options, uint32_t *addr);
void options_init(or_options_t *options);
int init_from_config(int argc, char **argv);
int config_init_logs(or_options_t *options, int validate_only);
int options_init_from_torrc(int argc, char **argv);
int options_init_logs(or_options_t *options, int validate_only);
int config_parse_addr_policy(config_line_t *cfg,
addr_policy_t **dest);
void config_append_default_exit_policy(addr_policy_t **policy);
void options_append_default_exit_policy(addr_policy_t **policy);
void addr_policy_free(addr_policy_t *p);
int config_option_is_recognized(const char *key);
const char *config_option_get_canonical_name(const char *key);
config_line_t *config_get_assigned_option(or_options_t *options,
const char *key);
char *config_dump_options(or_options_t *options, int minimal);
int save_current_config(void);
int option_is_recognized(const char *key);
const char *option_get_canonical_name(const char *key);
config_line_t *option_get_assignment(or_options_t *options,
const char *key);
char *options_dump(or_options_t *options, int minimal);
int options_save_current(void);
/********************************* connection.c ***************************/

View File

@ -752,7 +752,7 @@ router_rebuild_descriptor(int force)
ri->bandwidthrate = (int)options->MaxAdvertisedBandwidth;
config_parse_addr_policy(get_options()->ExitPolicy, &ri->exit_policy);
config_append_default_exit_policy(&ri->exit_policy);
options_append_default_exit_policy(&ri->exit_policy);
if (desc_routerinfo) /* inherit values */
ri->is_verified = desc_routerinfo->is_verified;

View File

@ -1406,7 +1406,7 @@ test_exit_policies(void)
/* Copied from router.c */
policy = NULL;
config_append_default_exit_policy(&policy);
options_append_default_exit_policy(&policy);
test_assert(policy);
test_assert(!exit_policy_implicitly_allows_local_networks(policy, 1));