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