Annotation of libaitcfg/example/test.c, revision 1.1.2.4
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];
1.1.2.3 misho 9: struct tagCfg *av;
1.1.2.1 misho 10:
11: printf("LoadConfig=%d\n", cfgLoadConfig("test.conf", &lst));
12: printf("errno=%d error=%s\n", cfg_GetErrno(), cfg_GetError());
1.1.2.2 misho 13: printf("Find Attribute at position=%d\n", cfg_findAttribute(&lst, NULL, "testattr"));
14: printf("GetAttribute value=%s\n", cfg_getAttribute(&lst, "", "testattr"));
15: printf("GetAttribute value=%s\n", cfg_getAttribute(&lst, "global", "attr2"));
1.1.2.4 ! misho 16: printf("SetAttribute=%d\n", cfg_setAttribute(&lst, "global", "attr2", "1111111122222222222"));
! 17: printf("GetAttribute value=%s\n", cfg_getAttribute(&lst, "global", "attr2"));
! 18: printf("SetAttribute=%d\n", cfg_setAttribute(&lst, NULL, "att", "0001122277777777"));
! 19: printf("SetAttribute=%d\n", cfg_setAttribute(&lst, "global", "att", "0001122222222222"));
! 20: printf("SetAttribute=%d\n", cfg_setAttribute(&lst, "global", "attr2", "1111111122222222222"));
! 21: printf("GetAttribute value=%s\n", cfg_getAttribute(&lst, "global", "attr2"));
! 22: printf("GetAttribute value=%s\n", cfg_getAttribute(&lst, "", "att"));
! 23: printf("GetAttribute value=%s\n", cfg_getAttribute(&lst, NULL, "att"));
1.1.2.1 misho 24: /*
25: printf("UnsetAttribute=%d\n", UnsetAttribute(&lst, "global", "a"));
26: printf("UnsetAttribute=%d\n", UnsetAttribute(&lst, "global", ""));
27: printf("UnsetAttribute=%d\n", UnsetAttribute(&lst, NULL, "att"));
28: printf("UnsetAttribute=%d\n", UnsetAttribute(&lst, "global", "attr2"));
29: printf("GetAttribute value=%s\n", GetAttribute(&lst, "global", "attr2"));
30:
31: printf("SetAttribute=%d\n", SetAttribute(&lst, "section", "attr3", NULL));
32: printf("LoadValue=%d :: ", LoadAttribute(&lst, "section", "attr3", szStr, 255, "iH"));
33: printf("Str=%s\n", szStr);
34: */
35: #if 0
36: InitConfig(&tmp);
37: printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&tmp, "global", "piuk", "blahz"));
38: printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&tmp, "bzyt", "00", "99999"));
39: printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&tmp, "global", "gniah", "tiiiiiii"));
40: printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&tmp, NULL, "att", "0001122777777"));
41: InitConfig(&lst);
42: printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, NULL, "zzz", "ZZZ"));
43: printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, NULL, "att", "0001122222222222"));
44: printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, "global", "att", "0001122222222222"));
45: printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, "global", "attr2", "1111111122222222222"));
46: printf("GetAttribute value=%s\n", cfg_GetAttribute(&lst, "global", "attr2"));
47: printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, "global", "a"));
48: printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, "global", ""));
49: printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, NULL, "att"));
50: printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, "global", "attr2"));
51: printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&lst, "bzyt", "111", "99999"));
52:
53: WriteConfig(stdout, &tmp);
54: WriteConfig(stdout, &lst);
55: printf("---------------------------------\n");
56: printf("%d\n---------------------------------\n", MergeConfig(&lst, &tmp));
57: WriteConfig(stdout, &lst);
58: // printf("%d\n---------------------------------\n", ConcatConfig(&lst, &tmp));
59: // WriteConfig(stdout, &lst);
60: printf("%d\n---------------------------------\n", ConcatConfig(&lst, &tmp));
61: WriteConfig(stdout, &lst);
62:
63: printf("CreateConfig=%d\n", CreateConfig("test4e.cfg", &lst));
64: printf("errno=%d error=%s\n", cfg_GetErrno(), cfg_GetError());
65: #endif
66: cfgUnloadConfig(&lst);
67: return 0;
68: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>