File:  [ELWIX - Embedded LightWeight unIX -] / libaitcfg / example / test_av2.c
Revision 1.3.4.1: download - view: text, annotated - select for diffs - revision graph
Thu Jan 17 13:46:59 2013 UTC (11 years, 3 months ago) by misho
Branches: cfg7_0
Diff to: branchpoint 1.3: preferred, colored
fix examples

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


int
main(int argc, char **argv)
{
	cfg_root_t cfg;
	FILE *f;
	ait_val_t *v;

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

	f = fopen("test_lines.txt", "r");
	if (!f) {
		cfgUnloadConfig(&cfg);
		return 2;
	} else {
		if (argc > 1)
			cfgReadLines(f, argv[1], "\r\n", &cfg);
		else
			cfgReadLines(f, ":", "\r\n", &cfg);

		printf("WriteLines::\n");
		if (argc > 1)
			v = cfgWriteLines(f, argv[1], "\r\n", NULL, &cfg);
		else
			v = cfgWriteLines(stdout, ":", "\r\n", NULL, &cfg);

		fclose(f);

		printf("\nait_val_t::\n");
		if (!AIT_ISEMPTY(v))
			printf("V=%s\n", AIT_GET_STR(v));
		ait_freeVar(&v);
	}

	printf("WriteConfig::\n");
	cfgWriteConfig(stdout, &cfg, 0);
	cfgUnloadConfig(&cfg);
	return 0;
}

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