189
193
if (sys_registry_path)
191
SVN_ERR(svn_config_read2(cfgp, sys_registry_path, FALSE, FALSE, pool));
195
SVN_ERR(svn_config_read3(cfgp, sys_registry_path, FALSE, FALSE, FALSE,
192
197
red_config = TRUE;
194
199
#endif /* WIN32 */
214
219
SVN_ERR(svn_config_merge(*cfgp, usr_registry_path, FALSE));
217
SVN_ERR(svn_config_read2(cfgp, usr_registry_path,
218
FALSE, FALSE, pool));
222
SVN_ERR(svn_config_read3(cfgp, usr_registry_path,
223
FALSE, FALSE, FALSE, pool));
219
224
red_config = TRUE;
243
248
/* CONFIG_DIR provides an override for the default behavior of reading
244
249
the default set of overlay files described by read_all()'s doc
250
string. Returns non-NULL *CFG or an error. */
246
251
static svn_error_t *
247
252
get_category_config(svn_config_t **cfg,
248
253
const char *config_dir,
261
266
sys_reg_path = apr_pstrcat(pool, SVN_REGISTRY_SYS_CONFIG_PATH,
267
category, SVN_VA_NULL);
263
268
usr_reg_path = apr_pstrcat(pool, SVN_REGISTRY_USR_CONFIG_PATH,
269
category, SVN_VA_NULL);
265
270
#endif /* WIN32 */
267
272
err = svn_config__sys_config_path(&sys_cfg_path, category, pool);
291
296
svn_config_t *cfg;
292
297
*cfg_hash = apr_hash_make(pool);
294
#define CATLEN (sizeof(SVN_CONFIG_CATEGORY_SERVERS) - 1)
295
299
SVN_ERR(get_category_config(&cfg, config_dir, SVN_CONFIG_CATEGORY_SERVERS,
298
apr_hash_set(*cfg_hash, SVN_CONFIG_CATEGORY_SERVERS, CATLEN, cfg);
301
svn_hash_sets(*cfg_hash, SVN_CONFIG_CATEGORY_SERVERS, cfg);
301
#define CATLEN (sizeof(SVN_CONFIG_CATEGORY_CONFIG) - 1)
302
303
SVN_ERR(get_category_config(&cfg, config_dir, SVN_CONFIG_CATEGORY_CONFIG,
305
apr_hash_set(*cfg_hash, SVN_CONFIG_CATEGORY_CONFIG, CATLEN, cfg);
305
svn_hash_sets(*cfg_hash, SVN_CONFIG_CATEGORY_CONFIG, cfg);
311
svn_config__get_default_config(apr_hash_t **cfg_hash,
314
svn_config_t *empty_cfg;
315
*cfg_hash = apr_hash_make(pool);
317
SVN_ERR(svn_config_create2(&empty_cfg, FALSE, FALSE, pool));
318
svn_hash_sets(*cfg_hash, SVN_CONFIG_CATEGORY_CONFIG, empty_cfg);
320
SVN_ERR(svn_config_create2(&empty_cfg, FALSE, FALSE, pool));
321
svn_hash_sets(*cfg_hash, SVN_CONFIG_CATEGORY_SERVERS, empty_cfg);
308
323
return SVN_NO_ERROR;
433
/* Return the value for KEY in HASH. If CASE_SENSITIVE is FALSE,
434
BUFFER will be used to construct the normalized hash key. */
436
get_hash_value(apr_hash_t *hash,
437
svn_stringbuf_t *buffer,
439
svn_boolean_t case_sensitive)
442
apr_size_t len = strlen(key);
445
return apr_hash_get(hash, key, len);
447
svn_stringbuf_ensure(buffer, len);
448
for (i = 0; i < len; ++i)
449
buffer->data[i] = (char)apr_tolower(key[i]);
451
return apr_hash_get(hash, buffer->data, len);
419
454
/* Return a pointer to an option in CFG, or NULL if it doesn't exist.
420
455
if SECTIONP is non-null, return a pointer to the option's section.
423
458
find_option(svn_config_t *cfg, const char *section, const char *option,
424
459
cfg_section_t **sectionp)
428
/* Canonicalize the hash key */
429
svn_stringbuf_set(cfg->tmp_key, section);
430
if (! cfg->section_names_case_sensitive)
431
make_hash_key(cfg->tmp_key->data);
433
sec_ptr = apr_hash_get(cfg->sections, cfg->tmp_key->data,
461
void *sec_ptr = get_hash_value(cfg->sections, cfg->tmp_key, section,
462
cfg->section_names_case_sensitive);
435
463
if (sectionp != NULL)
436
464
*sectionp = sec_ptr;
438
466
if (sec_ptr != NULL && option != NULL)
440
468
cfg_section_t *sec = sec_ptr;
443
/* Canonicalize the option key */
444
svn_stringbuf_set(cfg->tmp_key, option);
445
if (! cfg->option_names_case_sensitive)
446
make_hash_key(cfg->tmp_key->data);
448
opt = apr_hash_get(sec->options, cfg->tmp_key->data,
469
cfg_option_t *opt = get_hash_value(sec->options, cfg->tmp_key, option,
470
cfg->option_names_case_sensitive);
450
471
/* NOTE: ConfigParser's sections are case sensitive. */
452
473
&& apr_strnatcasecmp(section, SVN_CONFIG__DEFAULT_SECTION) != 0)
483
504
if (opt->value && strchr(opt->value, '%'))
485
apr_pool_t *tmp_pool = (x_pool ? x_pool : svn_pool_create(cfg->x_pool));
506
apr_pool_t *tmp_pool;
508
/* setting read-only mode should have expanded all values
510
assert(!cfg->read_only);
512
tmp_pool = (x_pool ? x_pool : svn_pool_create(cfg->x_pool));
487
514
expand_option_value(cfg, section, opt->value, &opt->x_value, tmp_pool);
488
515
opt->expanded = TRUE;
673
svn_config__is_expanded(svn_config_t *cfg,
682
/* does the option even exist? */
683
opt = find_option(cfg, section, option, NULL);
687
/* already expanded? */
691
/* needs expansion? */
692
if (opt->value && strchr(opt->value, '%'))
695
/* no expansion necessary */
647
701
svn_config_get(svn_config_t *cfg, const char **valuep,
661
715
/* before attempting to expand an option, check for the placeholder.
662
* If none is there, there is no point in calling expand_option_value.
716
* If there is none, there is no point in calling expand_option_value.
664
718
if (default_value && strchr(default_value, '%'))
666
apr_pool_t *tmp_pool = svn_pool_create(cfg->x_pool);
720
apr_pool_t *tmp_pool = svn_pool_create(cfg->pool);
667
721
const char *x_default;
668
722
expand_option_value(cfg, sec, default_value, &x_default, tmp_pool);
686
740
cfg_section_t *sec;
687
741
cfg_option_t *opt;
743
/* Ignore write attempts to r/o configurations.
745
* Since we should never try to modify r/o data, trigger an assertion
749
SVN_ERR_ASSERT_NO_RETURN(!cfg->read_only);
689
754
remove_expansions(cfg);
691
756
opt = find_option(cfg, section, option, &sec);
1198
1263
svn_config_has_section(svn_config_t *cfg, const char *section)
1202
/* Canonicalize the hash key */
1203
svn_stringbuf_set(cfg->tmp_key, section);
1204
if (! cfg->section_names_case_sensitive)
1205
make_hash_key(cfg->tmp_key->data);
1207
sec = svn_hash_gets(cfg->sections, cfg->tmp_key->data);
1265
return NULL != get_hash_value(cfg->sections, cfg->tmp_key, section,
1266
cfg->section_names_case_sensitive);