Exemple #1
0
DLLIMPORT void cfg_opt_setnbool(cfg_opt_t *opt, cfg_bool_t value,
                                unsigned int index)
{
    cfg_value_t *val;
    assert(opt && opt->type == CFGT_BOOL);
    val = cfg_opt_getval(opt, index);
    val->boolean = value;
}
Exemple #2
0
DLLIMPORT void cfg_opt_setnint(cfg_opt_t *opt, long int value,
                               unsigned int index)
{
    cfg_value_t *val;
    assert(opt && opt->type == CFGT_INT);
    val = cfg_opt_getval(opt, index);
    val->number = value;
}
Exemple #3
0
DLLIMPORT void cfg_opt_setnfloat(cfg_opt_t *opt, double value,
                                 unsigned int index)
{
    cfg_value_t *val;
    assert(opt && opt->type == CFGT_FLOAT);
    val = cfg_opt_getval(opt, index);
    val->fpnumber = value;
}
Exemple #4
0
DLLIMPORT void cfg_opt_setnstr(cfg_opt_t *opt, const char *value,
                               unsigned int index)
{
    cfg_value_t *val;
    assert(opt && opt->type == CFGT_STR);
    val = cfg_opt_getval(opt, index);
    free(val->string);
    val->string = value ? strdup(value) : 0;
}
Exemple #5
0
DLLIMPORT void cfg_opt_rmnsec(cfg_opt_t *opt, unsigned int index)
{
	unsigned int n;
	cfg_value_t *val;

	assert(opt && opt->type == CFGT_SEC);
	n = cfg_opt_size(opt);
	if (index >= n)
		return;
	val = cfg_opt_getval(opt, index);
	if (index + 1 != n) {
		/* not removing last, move the tail */
		memmove(&opt->values[index], &opt->values[index + 1], sizeof(opt->values[index]) * (n - index - 1));
	}
	--opt->nvalues;
	val->section->path = 0;
	cfg_free(val->section);
	free(val);
}