File:  [ELWIX - Embedded LightWeight unIX -] / libaitcfg / contrib / Attic / test.c
Revision 1.1.1.1.4.1: download - view: text, annotated - select for diffs - revision graph
Wed Sep 23 14:20:53 2009 UTC (14 years, 8 months ago) by misho
Branches: cfg3_1
Diff to: branchpoint 1.1.1.1: preferred, colored
added new feature ConcatConfig

#include <stdio.h>
#include <sys/types.h>
#include <aitcfg.h>

int main()
{
	sl_config lst, tmp;
	char szStr[256];

	/*
	printf("LoadConfig=%d\n", LoadConfig("test.conf", &lst));
	printf("errno=%d error=%s\n", cfg_GetErrno(), cfg_GetError());
	printf("Find Attribute at position=%d\n", FindAttribute(&lst, NULL, "testattr"));
	printf("GetAttribute value=%s\n", GetAttribute(&lst, "", "testattr"));
	printf("GetAttribute value=%s\n", GetAttribute(&lst, "global", "attr2"));
	printf("SetAttribute=%d\n", SetAttribute(&lst, "global", "attr2", "1111111122222222222"));
	printf("GetAttribute value=%s\n", GetAttribute(&lst, "global", "attr2"));
	printf("SetAttribute=%d\n", SetAttribute(&lst, NULL, "att", "0001122222222222"));
	printf("SetAttribute=%d\n", SetAttribute(&lst, "global", "att", "0001122222222222"));
	printf("SetAttribute=%d\n", SetAttribute(&lst, "global", "attr2", "1111111122222222222"));
	printf("GetAttribute value=%s\n", GetAttribute(&lst, "global", "attr2"));
	printf("UnsetAttribute=%d\n", UnsetAttribute(&lst, "global", "a"));
	printf("UnsetAttribute=%d\n", UnsetAttribute(&lst, "global", ""));
	printf("UnsetAttribute=%d\n", UnsetAttribute(&lst, NULL, "att"));
	printf("UnsetAttribute=%d\n", UnsetAttribute(&lst, "global", "attr2"));
	printf("GetAttribute value=%s\n", GetAttribute(&lst, "global", "attr2"));

	printf("SetAttribute=%d\n", SetAttribute(&lst, "section", "attr3", NULL));
	printf("LoadValue=%d :: ", LoadAttribute(&lst, "section", "attr3", szStr, 255, "iH"));
	printf("Str=%s\n", szStr);
	*/
	InitConfig(&tmp);
	printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&tmp, "global", "piuk", "blahz"));
	printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&tmp, "bzyt", "00", "99999"));
	printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&tmp, "global", "gniah", "tiiiiiii"));
	InitConfig(&lst);
	printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, NULL, "zzz", "ZZZ"));
	printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, NULL, "att", "0001122222222222"));
	printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, "global", "att", "0001122222222222"));
	printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, "global", "attr2", "1111111122222222222"));
	printf("GetAttribute value=%s\n", cfg_GetAttribute(&lst, "global", "attr2"));
	printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, "global", "a"));
	printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, "global", ""));
	printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, NULL, "att"));
	printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, "global", "attr2"));

	WriteConfig(stdout, &tmp);
	ConcatConfig(&lst, &tmp);
	WriteConfig(stdout, &lst);

	printf("CreateConfig=%d\n", CreateConfig("test4e.cfg", &lst));
	printf("errno=%d error=%s\n", cfg_GetErrno(), cfg_GetError());
	UnloadConfig(&lst);
	return 0;
}

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