Annotation of libaitcfg/example/test.c, revision 1.1.2.7

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));
1.1.2.7 ! misho      34:        AIT_FREE_VAL(&v);
1.1.2.6   misho      35:        printf("LoadValue=%d :: ", cfg_loadAttribute(&lst, "", "testattr", &v, "iH2"));
                     36:        printf("Str=%s\n", AIT_GET_STR(&v));
1.1.2.7 ! misho      37:        AIT_FREE_VAL(&v);
1.1.2.6   misho      38: 
                     39:        printf("GetAttribute value=%s\n", cfg_getAttribute(&lst, "section1", "attrtest"));
1.1.2.5   misho      40: 
1.1.2.1   misho      41: #if 0
                     42:        InitConfig(&tmp);
                     43:        printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&tmp, "global", "piuk", "blahz"));
                     44:        printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&tmp, "bzyt", "00", "99999"));
                     45:        printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&tmp, "global", "gniah", "tiiiiiii"));
                     46:        printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&tmp, NULL, "att", "0001122777777"));
                     47:        InitConfig(&lst);
                     48:        printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, NULL, "zzz", "ZZZ"));
                     49:        printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, NULL, "att", "0001122222222222"));
                     50:        printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, "global", "att", "0001122222222222"));
                     51:        printf("SetAttribute=%d\n", cfg_SetAttribute(&lst, "global", "attr2", "1111111122222222222"));
                     52:        printf("GetAttribute value=%s\n", cfg_GetAttribute(&lst, "global", "attr2"));
                     53:        printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, "global", "a"));
                     54:        printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, "global", ""));
                     55:        printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, NULL, "att"));
                     56:        printf("UnsetAttribute=%d\n", cfg_UnsetAttribute(&lst, "global", "attr2"));
                     57:        printf("tmp: SetAttribute=%d\n", cfg_SetAttribute(&lst, "bzyt", "111", "99999"));
                     58: 
                     59:        WriteConfig(stdout, &tmp);
                     60:        WriteConfig(stdout, &lst);
                     61:        printf("---------------------------------\n");
                     62:        printf("%d\n---------------------------------\n", MergeConfig(&lst, &tmp));
                     63:        WriteConfig(stdout, &lst);
                     64: //     printf("%d\n---------------------------------\n", ConcatConfig(&lst, &tmp));
                     65: //     WriteConfig(stdout, &lst);
                     66:        printf("%d\n---------------------------------\n", ConcatConfig(&lst, &tmp));
                     67:        WriteConfig(stdout, &lst);
                     68: 
                     69:        printf("CreateConfig=%d\n", CreateConfig("test4e.cfg", &lst));
                     70:        printf("errno=%d error=%s\n", cfg_GetErrno(), cfg_GetError());
                     71: #endif
                     72:        cfgUnloadConfig(&lst);
                     73:        return 0;
                     74: }

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