Beispiel #1
0
json_ref cfg_get_json(const char* name) {
  json_ref val;
  auto state = configState.rlock();

  // Highest precedence: command line arguments
  val = cfg_get_raw(name, &state->arg_cfg);
  // then: global config options
  if (!val) {
    val = cfg_get_raw(name, &state->global_cfg);
  }
  return val;
}
Beispiel #2
0
void property_load(const char *section, const char *name, const char *defval, PROPERTY * prop)
{
    char *expression;

    /* initialize structure */
    prop->valid = 0;
    prop->name = NULL;
    prop->expression = NULL;
    prop->compiled = NULL;
    DelResult(&prop->result);

    /* remember the name */
    prop->name = strdup(name);

    /* load expression from config, but do not evaluate it */
    expression = cfg_get_raw(section, name, NULL);

    if (expression == NULL) {
	if (defval != NULL && *defval != '\0')
	    debug("Notice: using default value <%s> for property '%s.%s'", defval, section, name);
	prop->expression = (char *) defval;
    } else {
	prop->valid = 1;
	prop->expression = expression;
    }

    /* pre-compile the expression */
    Compile(prop->expression, &prop->compiled);

}
Beispiel #3
0
json_t *cfg_get_json(w_root_t *root, const char *name)
{
  json_t *val = NULL;

  // Highest precedence: options set on the root
  if (root && root->config_file) {
    val = json_object_get(root->config_file, name);
  }
  // then: command line arguments
  if (!val) {
    val = cfg_get_raw(name, &arg_cfg);
  }
  // then: global config options
  if (!val) {
    val = cfg_get_raw(name, &global_cfg);
  }
  return val;
}
Beispiel #4
0
json_ref Configuration::get(const char* name) const {
  // Highest precedence: options set locally
  json_ref val;
  if (local_) {
    val = local_.get_default(name);
    if (val) {
      return val;
    }
  }
  auto state = configState.rlock();

  // then: command line arguments
  if (!val) {
    val = cfg_get_raw(name, &state->arg_cfg);
  }
  // then: global config options
  if (!val) {
    val = cfg_get_raw(name, &state->global_cfg);
  }
  return val;
}