File:  [ELWIX - Embedded LightWeight unIX -] / libaitcfg / example / test_boot.c
Revision 1.2.4.1: download - view: text, annotated - select for diffs - revision graph
Wed Jul 25 12:42:03 2012 UTC (11 years, 9 months ago) by misho
Branches: cfg5_2
Diff to: branchpoint 1.2: preferred, colored
added UT

#include <stdio.h>
#include <aitcfg.h>


int
main(int argc, char **argv)
{
	cfg_root_t cfg;

	if (cfgLoadConfig(argv[1], &cfg)) {
		printf("Error:: #%d - %s\n", cfg_GetErrno(), cfg_GetError());
		return 1;
	}

	cfgWriteConfig(stdout, &cfg, 0);

	printf("\n++++++++++++++++++ update IP with 192.168.234.11 ...\n\n");
	cfg_setAttribute(&cfg, NULL, "IP2", "192.168.2.1");
	cfg_setAttribute(&cfg, NULL, "IP", "192.168.234.11");
	cfg_setAttribute(&cfg, NULL, "OPT", "\"\"");
	cfg_setAttribute(&cfg, NULL, "OZZ", NULL);
	cfg_unsetAttribute(&cfg, NULL, "OPT");
	cfg_unsetAttribute(&cfg, NULL, "OPT2");

	cfgWriteConfig(stdout, &cfg, 0);

	printf("\n............ with whitespaces \n\n");
	cfgWriteConfig(stdout, &cfg, 1);
	cfgClearConfig(&cfg);

	printf("\n============ reuse with whitespaces \n\n");
	cfg_setAttribute(&cfg, NULL, "ALIAS0", "1.1.1.1");
	cfg_setAttribute(&cfg, NULL, "ALIAS1", "2.2.2.2");
	cfgWriteConfig(stdout, &cfg, 1);
	cfgUnloadConfig(&cfg);
	return 0;
}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>