File:  [ELWIX - Embedded LightWeight unIX -] / libaitcfg / example / test_av2.c
Revision 1.5: download - view: text, annotated - select for diffs - revision graph
Wed May 18 15:18:10 2016 UTC (7 years, 11 months ago) by misho
Branches: MAIN
CVS tags: cfg9_5, cfg9_4, cfg9_3, cfg9_2, cfg9_1, cfg8_2, cfg8_1, cfg8_0, cfg7_9, cfg7_8, HEAD, CFG9_4, CFG9_3, CFG9_2, CFG9_1, CFG9_0, CFG8_1, CFG8_0, CFG7_9, CFG7_8, CFG7_7
7.7

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


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

	if (!(cfg = cfgInitConfig())) {
		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>