FreeBSD/contrib/subversion/subversion/libsvn_repos/config_pool.c
/* Set *CFG to the configuration passed in as text in CONTENTS and *KEY to
 * the corresponding object pool key.  If no such configuration exists in
 * CONFIG_POOL, yet, parse CONTENTS and cache the result.  CASE_SENSITIVE
 * controls option and section name matching.
 *
 * RESULT_POOL determines the lifetime of the returned reference and
 * SCRATCH_POOL is being used for temporary allocations.
 */
Set *CFG to the configuration passed in as text in CONTENTS and *KEY to
the corresponding object pool key.  If no such configuration exists in
CONFIG_POOL, yet, parse CONTENTS and cache the result.  CASE_SENSITIVE
controls option and section name matching.

RESULT_POOL determines the lifetime of the returned reference and
SCRATCH_POOL is being used for temporary allocations.
Set * CFG to the configuration passed in as text in CONTENTS and * KEY to the corresponding object pool key . If no such configuration exists in CONFIG_POOL yet parse CONTENTS and cache the result . CASE_SENSITIVE controls option and section name matching . RESULT_POOL determines the lifetime of the returned reference and SCRATCH_POOL is being used for temporary allocations .
static svn_error_t *
auto_parse(svn_config_t **cfg,
           svn_membuf_t **key,
           svn_repos__config_pool_t *config_pool,
           svn_stringbuf_t *contents,
           svn_boolean_t case_sensitive,
           apr_pool_t *result_pool,
           apr_pool_t *scratch_pool)
{
  svn_checksum_t *checksum;
  config_object_t *config_object;
  apr_pool_t *cfg_pool;
  SVN_ERR(svn_stream_close
              (svn_stream_checksummed2
                  (svn_stream_from_stringbuf(contents, scratch_pool),
                   &checksum, NULL, svn_checksum_sha1, TRUE, scratch_pool)));
  *key = checksum_as_key(checksum, result_pool);
  SVN_ERR(svn_object_pool__lookup((void **)cfg, config_pool->object_pool,
                                  *key, &case_sensitive, result_pool));
  if (*cfg)
    return SVN_NO_ERROR;
  cfg_pool = svn_object_pool__new_wrapper_pool(config_pool->object_pool);
  config_object = apr_pcalloc(cfg_pool, sizeof(*config_object));
  SVN_ERR(svn_config_parse(case_sensitive ? &config_object->cs_cfg
                                          : &config_object->ci_cfg,
                           svn_stream_from_stringbuf(contents, scratch_pool),
                           case_sensitive, case_sensitive, cfg_pool));
  svn_config__set_read_only(case_sensitive ? config_object->cs_cfg
                                           : config_object->ci_cfg,
                            cfg_pool);
  SVN_ERR(svn_object_pool__insert((void **)cfg, config_pool->object_pool,
                                  *key, config_object, &case_sensitive,
                                  cfg_pool, result_pool));
  return SVN_NO_ERROR;
}
static svn_error_t * auto_parse ( svn_config_t * * cfg , svn_membuf_t * * key , svn_repos__config_pool_t * config_pool , svn_stringbuf_t * contents , svn_boolean_t case_sensitive , apr_pool_t * result_pool , apr_pool_t * scratch_pool ) { svn_checksum_t * checksum ; config_object_t * config_object ; apr_pool_t * cfg_pool ; SVN_ERR ( svn_stream_close ( svn_stream_checksummed2 ( svn_stream_from_stringbuf ( contents , scratch_pool ) , & checksum , NULL , svn_checksum_sha1 , TRUE , scratch_pool ) ) ) ; * key = checksum_as_key ( checksum , result_pool ) ; SVN_ERR ( svn_object_pool__lookup ( ( void * * ) cfg , config_pool -> object_pool , * key , & case_sensitive , result_pool ) ) ; if ( * cfg ) return SVN_NO_ERROR ; cfg_pool = svn_object_pool__new_wrapper_pool ( config_pool -> object_pool ) ; config_object = apr_pcalloc ( cfg_pool , sizeof ( * config_object ) ) ; SVN_ERR ( svn_config_parse ( case_sensitive ? & config_object -> cs_cfg : & config_object -> ci_cfg , svn_stream_from_stringbuf ( contents , scratch_pool ) , case_sensitive , case_sensitive , cfg_pool ) ) ; svn_config__set_read_only ( case_sensitive ? config_object -> cs_cfg : config_object -> ci_cfg , cfg_pool ) ; SVN_ERR ( svn_object_pool__insert ( ( void * * ) cfg , config_pool -> object_pool , * key , config_object , & case_sensitive , cfg_pool , result_pool ) ) ; return SVN_NO_ERROR ; }
Set *CFG to the configuration passed in as text in CONTENTS and *KEY to
 the corresponding object pool key.
Set * CFG to the configuration passed in as text in CONTENTS and * KEY to the corresponding object pool key .
/* calculate SHA1 over the whole file contents */ /* return reference to suitable config object if that already exists */ /* create a pool for the new config object and parse the data into it  */ /* switch config data to r/o mode to guarantee thread-safe access */ /* add config in pool, handle loads races and return the right config */