Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 57a94fd8eb9a4a6b0138af61a0f7b529 > files > 27

dotconf-examples-1.0.13-2mdv2008.1.x86_64.rpm

#include <stdio.h>
#include <dotconf.h>

/*
        tabsize: 4
        shiftwidth: 4
*/

FUNC_ERRORHANDLER(errorhandler);
DOTCONF_CB(cb_errorhandler);

static configoption_t options[] = {
	{"ErrorHandler", ARG_STR, cb_errorhandler, NULL, 0},
	LAST_OPTION
};

FUNC_ERRORHANDLER(errorhandler)
{
	printf("ERROR %s\n", msg);
	return 0;
}

DOTCONF_CB(cb_errorhandler)
{
	printf("[ErrorHandler Option] %s\n", cmd->data.str);
	return NULL;
}

int main(int argc, char **argv)
{
	configfile_t *configfile;

	configfile = dotconf_create("errorhandler.conf", options, 0, 0);
	configfile->errorhandler = (dotconf_errorhandler_t) errorhandler;

	if (dotconf_command_loop(configfile) == 0)
		fprintf(stderr, "Error reading configfile\n");

	dotconf_cleanup(configfile);
	return 0;
}