Beispiel #1
0
void
svn_config_get(svn_config_t *cfg, const char **valuep,
               const char *section, const char *option,
               const char *default_value)
{
  *valuep = default_value;
  if (cfg)
    {
      cfg_section_t *sec;
      cfg_option_t *opt = find_option(cfg, section, option, &sec);
      if (opt != NULL)
        {
          make_string_from_option(valuep, cfg, sec, opt, NULL);
        }
      else
        /* before attempting to expand an option, check for the placeholder.
         * If there is none, there is no point in calling expand_option_value.
         */
        if (default_value && strchr(default_value, '%'))
          {
            apr_pool_t *tmp_pool = svn_pool_create(cfg->pool);
            const char *x_default;
            expand_option_value(cfg, sec, default_value, &x_default, tmp_pool);
            if (x_default)
              {
                svn_stringbuf_set(cfg->tmp_value, x_default);
                *valuep = cfg->tmp_value->data;
              }
            svn_pool_destroy(tmp_pool);
          }
    }
}
Beispiel #2
0
void
svn_config_get(svn_config_t *cfg, const char **valuep,
               const char *section, const char *option,
               const char *default_value)
{
  if (cfg)
    {
      cfg_section_t *sec;
      cfg_option_t *opt = find_option(cfg, section, option, &sec);
      if (opt != NULL)
        {
          make_string_from_option(valuep, cfg, sec, opt, NULL);
        }
      else
        {
          apr_pool_t *tmp_pool = svn_pool_create(cfg->x_pool);
          const char *x_default;
          expand_option_value(cfg, sec, default_value, &x_default, tmp_pool);
          if (x_default)
            {
              svn_stringbuf_set(cfg->tmp_value, x_default);
              *valuep = cfg->tmp_value->data;
            }
          else
            *valuep = default_value;
          svn_pool_destroy(tmp_pool);
        }
    }
  else
    {
      *valuep = default_value;
    }
}
Beispiel #3
0
/* Set *VALUEP according to the OPT's value.  A value for X_POOL must
   only ever be passed into this function by expand_option_value(). */
static void
make_string_from_option(const char **valuep, svn_config_t *cfg,
                        cfg_section_t *section, cfg_option_t *opt,
                        apr_pool_t* x_pool)
{
  /* Expand the option value if necessary. */
  if (!opt->expanded)
    {
      apr_pool_t *tmp_pool = (x_pool ? x_pool : svn_pool_create(cfg->x_pool));

      expand_option_value(cfg, section, opt->value, &opt->x_value, tmp_pool);
      opt->expanded = TRUE;

      if (!x_pool)
        {
          /* Grab the fully expanded value from tmp_pool before its
             disappearing act. */
          if (opt->x_value)
            opt->x_value = apr_pstrmemdup(cfg->x_pool, opt->x_value,
                                          strlen(opt->x_value));
          svn_pool_destroy(tmp_pool);
        }
    }

  if (opt->x_value)
    *valuep = opt->x_value;
  else
    *valuep = opt->value;
}
Beispiel #4
0
/* Set *VALUEP according to the OPT's value.  A value for X_POOL must
   only ever be passed into this function by expand_option_value(). */
static void
make_string_from_option(const char **valuep, svn_config_t *cfg,
                        cfg_section_t *section, cfg_option_t *opt,
                        apr_pool_t* x_pool)
{
  /* Expand the option value if necessary. */
  if (!opt->expanded)
    {
      /* before attempting to expand an option, check for the placeholder.
       * If none is there, there is no point in calling expand_option_value.
       */
      if (opt->value && strchr(opt->value, '%'))
        {
          apr_pool_t *tmp_pool;

          /* setting read-only mode should have expanded all values
           * automatically. */
          assert(!cfg->read_only);

          tmp_pool = (x_pool ? x_pool : svn_pool_create(cfg->x_pool));

          expand_option_value(cfg, section, opt->value, &opt->x_value, tmp_pool);
          opt->expanded = TRUE;

          if (x_pool != cfg->x_pool)
            {
              /* Grab the fully expanded value from tmp_pool before its
                 disappearing act. */
              if (opt->x_value)
                opt->x_value = apr_pstrmemdup(cfg->x_pool, opt->x_value,
                                              strlen(opt->x_value));
              if (!x_pool)
                svn_pool_destroy(tmp_pool);
            }
        }
      else
        {
          opt->expanded = TRUE;
        }
    }

  if (opt->x_value)
    *valuep = opt->x_value;
  else
    *valuep = opt->value;
}