Annotation of libaitcfg/contrib/test.c, revision 1.1.1.1.4.1
1.1 misho 1: #include <stdio.h>
2: #include <sys/types.h>
3: #include <aitcfg.h>
4:
5: int main()
6: {
1.1.1.1.4.1! misho 7: sl_config lst, tmp;
1.1 misho 8: char szStr[256];
9:
10: /*
11: printf("LoadConfig=%d\n", LoadConfig("test.conf", &lst));
12: printf("errno=%d error=%s\n", cfg_GetErrno(), cfg_GetError());
13: printf("Find Attribute at position=%d\n", FindAttribute(&lst, NULL, "testattr"));
14: printf("GetAttribute value=%s\n", GetAttribute(&lst, "", "testattr"));
15: printf("GetAttribute value=%s\n", GetAttribute(&lst, "global", "attr2"));
16: printf("SetAttribute=%d\n", SetAttribute(&lst, "global", "attr2", "1111111122222222222"));
17: printf("GetAttribute value=%s\n", GetAttribute(&lst, "global", "attr2"));
18: printf("SetAttribute=%d\n", SetAttribute(&lst, NULL, "att", "0001122222222222"));
19: printf("SetAttribute=%d\n", SetAttribute(&lst, "global", "att", "0001122222222222"));
20: printf("SetAttribute=%d\n", SetAttribute(&lst, "global", "attr2", "1111111122222222222"));
21: printf("GetAttribute value=%s\n", GetAttribute(&lst, "global", "attr2"));
22: printf("UnsetAttribute=%d\n", UnsetAttribute(&lst, "global", "a"));
23: printf("UnsetAttribute=%d\n", UnsetAttribute(&lst, "global", ""));
24: printf("UnsetAttribute=%d\n", UnsetAttribute(&lst, NULL, "att"));
25: printf("UnsetAttribute=%d\n", UnsetAttribute(&lst, "global", "attr2"));
26: printf("GetAttribute value=%s\n", GetAttribute(&lst, "global", "attr2"));
27:
28: printf("SetAttribute=%d\n", SetAttribute(&lst, "section", "attr3", NULL));
29: printf("LoadValue=%d :: ", LoadAttribute(&lst, "section", "attr3", szStr, 255, "iH"));
30: printf("Str=%s\n", szStr);
31: */
1.1.1.1.4.1! misho 32: InitConfig(&tmp);
! 33: printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&tmp, "global", "piuk", "blahz"));
! 34: printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&tmp, "bzyt", "00", "99999"));
! 35: printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&tmp, "global", "gniah", "tiiiiiii"));
1.1 misho 36: InitConfig(&lst);
1.1.1.1.4.1! misho 37: printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, NULL, "zzz", "ZZZ"));
1.1 misho 38: printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, NULL, "att", "0001122222222222"));
39: printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, "global", "att", "0001122222222222"));
40: printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, "global", "attr2", "1111111122222222222"));
41: printf("GetAttribute value=%s\n", cfg_GetAttribute(&lst, "global", "attr2"));
42: printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, "global", "a"));
43: printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, "global", ""));
44: printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, NULL, "att"));
45: printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, "global", "attr2"));
46:
1.1.1.1.4.1! misho 47: WriteConfig(stdout, &tmp);
! 48: ConcatConfig(&lst, &tmp);
! 49: WriteConfig(stdout, &lst);
! 50:
1.1 misho 51: printf("CreateConfig=%d\n", CreateConfig("test4e.cfg", &lst));
52: printf("errno=%d error=%s\n", cfg_GetErrno(), cfg_GetError());
53: UnloadConfig(&lst);
54: return 0;
55: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>