Annotation of libaitcfg/example/test.c, revision 1.1.2.3
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.3 ! misho 16:
! 17: /*
! 18: SLIST_FOREACH(av, &lst, cfg_next) {
! 19: printf("av=%p\n", av);
! 20: /*
! 21: printf("s=%s a=%s v=%s\n", AIT_GET_LIKE(&av->cfg_sec, char*),
! 22: AIT_GET_LIKE(&av->cfg_attr, char*), AIT_GET_LIKE(&av->cfg_val, char*));
! 23: */
! 24: //}
! 25:
1.1.2.1 misho 26: /*
27: printf("SetAttribute=%d\n", SetAttribute(&lst, "global", "attr2", "1111111122222222222"));
28: printf("GetAttribute value=%s\n", GetAttribute(&lst, "global", "attr2"));
29: printf("SetAttribute=%d\n", SetAttribute(&lst, NULL, "att", "0001122222222222"));
30: printf("SetAttribute=%d\n", SetAttribute(&lst, "global", "att", "0001122222222222"));
31: printf("SetAttribute=%d\n", SetAttribute(&lst, "global", "attr2", "1111111122222222222"));
32: printf("GetAttribute value=%s\n", GetAttribute(&lst, "global", "attr2"));
33: printf("UnsetAttribute=%d\n", UnsetAttribute(&lst, "global", "a"));
34: printf("UnsetAttribute=%d\n", UnsetAttribute(&lst, "global", ""));
35: printf("UnsetAttribute=%d\n", UnsetAttribute(&lst, NULL, "att"));
36: printf("UnsetAttribute=%d\n", UnsetAttribute(&lst, "global", "attr2"));
37: printf("GetAttribute value=%s\n", GetAttribute(&lst, "global", "attr2"));
38:
39: printf("SetAttribute=%d\n", SetAttribute(&lst, "section", "attr3", NULL));
40: printf("LoadValue=%d :: ", LoadAttribute(&lst, "section", "attr3", szStr, 255, "iH"));
41: printf("Str=%s\n", szStr);
42: */
43: #if 0
44: InitConfig(&tmp);
45: printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&tmp, "global", "piuk", "blahz"));
46: printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&tmp, "bzyt", "00", "99999"));
47: printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&tmp, "global", "gniah", "tiiiiiii"));
48: printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&tmp, NULL, "att", "0001122777777"));
49: InitConfig(&lst);
50: printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, NULL, "zzz", "ZZZ"));
51: printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, NULL, "att", "0001122222222222"));
52: printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, "global", "att", "0001122222222222"));
53: printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, "global", "attr2", "1111111122222222222"));
54: printf("GetAttribute value=%s\n", cfg_GetAttribute(&lst, "global", "attr2"));
55: printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, "global", "a"));
56: printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, "global", ""));
57: printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, NULL, "att"));
58: printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, "global", "attr2"));
59: printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&lst, "bzyt", "111", "99999"));
60:
61: WriteConfig(stdout, &tmp);
62: WriteConfig(stdout, &lst);
63: printf("---------------------------------\n");
64: printf("%d\n---------------------------------\n", MergeConfig(&lst, &tmp));
65: WriteConfig(stdout, &lst);
66: // printf("%d\n---------------------------------\n", ConcatConfig(&lst, &tmp));
67: // WriteConfig(stdout, &lst);
68: printf("%d\n---------------------------------\n", ConcatConfig(&lst, &tmp));
69: WriteConfig(stdout, &lst);
70:
71: printf("CreateConfig=%d\n", CreateConfig("test4e.cfg", &lst));
72: printf("errno=%d error=%s\n", cfg_GetErrno(), cfg_GetError());
73: #endif
74: cfgUnloadConfig(&lst);
75: return 0;
76: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>