Annotation of libaitcfg/example/test.c, revision 1.1.2.2
1.1.2.1 misho 1: #include <stdio.h>
2: #include <sys/types.h>
3: #include <aitcfg.h>
4:
5: int main()
6: {
7: cfg_root_t lst, tmp;
8: char szStr[256];
9:
10: printf("LoadConfig=%d\n", cfgLoadConfig("test.conf", &lst));
11: printf("errno=%d error=%s\n", cfg_GetErrno(), cfg_GetError());
1.1.2.2 ! misho 12: printf("Find Attribute at position=%d\n", cfg_findAttribute(&lst, NULL, "testattr"));
! 13: printf("GetAttribute value=%s\n", cfg_getAttribute(&lst, "", "testattr"));
! 14: printf("GetAttribute value=%s\n", cfg_getAttribute(&lst, "global", "attr2"));
1.1.2.1 misho 15: /*
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: */
32: #if 0
33: InitConfig(&tmp);
34: printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&tmp, "global", "piuk", "blahz"));
35: printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&tmp, "bzyt", "00", "99999"));
36: printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&tmp, "global", "gniah", "tiiiiiii"));
37: printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&tmp, NULL, "att", "0001122777777"));
38: InitConfig(&lst);
39: printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, NULL, "zzz", "ZZZ"));
40: printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, NULL, "att", "0001122222222222"));
41: printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, "global", "att", "0001122222222222"));
42: printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, "global", "attr2", "1111111122222222222"));
43: printf("GetAttribute value=%s\n", cfg_GetAttribute(&lst, "global", "attr2"));
44: printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, "global", "a"));
45: printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, "global", ""));
46: printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, NULL, "att"));
47: printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, "global", "attr2"));
48: printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&lst, "bzyt", "111", "99999"));
49:
50: WriteConfig(stdout, &tmp);
51: WriteConfig(stdout, &lst);
52: printf("---------------------------------\n");
53: printf("%d\n---------------------------------\n", MergeConfig(&lst, &tmp));
54: WriteConfig(stdout, &lst);
55: // printf("%d\n---------------------------------\n", ConcatConfig(&lst, &tmp));
56: // WriteConfig(stdout, &lst);
57: printf("%d\n---------------------------------\n", ConcatConfig(&lst, &tmp));
58: WriteConfig(stdout, &lst);
59:
60: printf("CreateConfig=%d\n", CreateConfig("test4e.cfg", &lst));
61: printf("errno=%d error=%s\n", cfg_GetErrno(), cfg_GetError());
62: #endif
63: cfgUnloadConfig(&lst);
64: return 0;
65: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>