void svn_config_set(svn_config_t *cfg, const char *section, const char *option, const char *value) { cfg_section_t *sec; cfg_option_t *opt; /* Ignore write attempts to r/o configurations. * * Since we should never try to modify r/o data, trigger an assertion * in debug mode. */ #ifdef SVN_DEBUG SVN_ERR_ASSERT_NO_RETURN(!cfg->read_only); #endif if (cfg->read_only) return; remove_expansions(cfg); opt = find_option(cfg, section, option, &sec); if (opt != NULL) { /* Replace the option's value. */ opt->value = apr_pstrdup(cfg->pool, value); opt->expanded = FALSE; return; } /* Create a new option */ svn_config_create_option(&opt, option, value, cfg->option_names_case_sensitive, cfg->pool); if (sec == NULL) { /* Even the section doesn't exist. Create it. */ sec = svn_config_addsection(cfg, section); } svn_hash_sets(sec->options, opt->hash_key, opt); }
void svn_config_set(svn_config_t *cfg, const char *section, const char *option, const char *value) { cfg_section_t *sec; cfg_option_t *opt; remove_expansions(cfg); opt = find_option(cfg, section, option, &sec); if (opt != NULL) { /* Replace the option's value. */ opt->value = apr_pstrdup(cfg->pool, value); opt->expanded = FALSE; return; } /* Create a new option */ opt = apr_palloc(cfg->pool, sizeof(*opt)); opt->name = apr_pstrdup(cfg->pool, option); opt->hash_key = make_hash_key(apr_pstrdup(cfg->pool, option)); opt->value = apr_pstrdup(cfg->pool, value); opt->x_value = NULL; opt->expanded = FALSE; if (sec == NULL) { /* Even the section doesn't exist. Create it. */ sec = apr_palloc(cfg->pool, sizeof(*sec)); sec->name = apr_pstrdup(cfg->pool, section); sec->hash_key = make_hash_key(apr_pstrdup(cfg->pool, section)); sec->options = apr_hash_make(cfg->pool); apr_hash_set(cfg->sections, sec->hash_key, APR_HASH_KEY_STRING, sec); } apr_hash_set(sec->options, opt->hash_key, APR_HASH_KEY_STRING, opt); }