Annotation of libaitcfg/contrib/test.c, revision 1.2

1.1       misho       1: #include <stdio.h>
                      2: #include <sys/types.h>
                      3: #include <aitcfg.h>
                      4: 
                      5: int main()
                      6: {
1.2     ! 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.2     ! 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"));
        !            36:        printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&tmp, NULL, "att", "0001122777777"));
1.1       misho      37:        InitConfig(&lst);
1.2     ! misho      38:        printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, NULL, "zzz", "ZZZ"));
1.1       misho      39:        printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, NULL, "att", "0001122222222222"));
                     40:        printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, "global", "att", "0001122222222222"));
                     41:        printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, "global", "attr2", "1111111122222222222"));
                     42:        printf("GetAttribute value=%s\n", cfg_GetAttribute(&lst, "global", "attr2"));
                     43:        printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, "global", "a"));
                     44:        printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, "global", ""));
                     45:        printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, NULL, "att"));
                     46:        printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, "global", "attr2"));
1.2     ! misho      47:        printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&lst, "bzyt", "111", "99999"));
        !            48: 
        !            49:        WriteConfig(stdout, &tmp);
        !            50:        WriteConfig(stdout, &lst);
        !            51:        printf("---------------------------------\n");
        !            52:        printf("%d\n---------------------------------\n", MergeConfig(&lst, &tmp));
        !            53:        WriteConfig(stdout, &lst);
        !            54: //     printf("%d\n---------------------------------\n", ConcatConfig(&lst, &tmp));
        !            55: //     WriteConfig(stdout, &lst);
        !            56:        printf("%d\n---------------------------------\n", ConcatConfig(&lst, &tmp));
        !            57:        WriteConfig(stdout, &lst);
1.1       misho      58: 
                     59:        printf("CreateConfig=%d\n", CreateConfig("test4e.cfg", &lst));
                     60:        printf("errno=%d error=%s\n", cfg_GetErrno(), cfg_GetError());
                     61:        UnloadConfig(&lst);
                     62:        return 0;
                     63: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>