Annotation of libaitio/example/test_sess.c, revision 1.2.2.3

1.2       misho       1: #include <stdio.h>
                      2: #include <string.h>
1.2.2.1   misho       3: #include <elwix.h>
1.2       misho       4: #include <aitsess.h>
                      5: 
                      6: int main()
                      7: {
1.2.2.1   misho       8:        sess_t *n = NULL;
1.2       misho       9:        int i = 255;
                     10:        char *dat, szVal[256];
1.2.2.1   misho      11:        ait_val_t *v = NULL;
1.2       misho      12:        
                     13:        /*
                     14:        map_createSession("/tmp/abra-kadabra-123", 1003, 4096, &n);
                     15:        if (sess_GetErrno()) {
                     16:                printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
                     17:                return 2;
                     18:        }
                     19:        dat = map_attachSession(n, NULL);
                     20:        if (!dat)
                     21:                return 1;
                     22:        printf("brym n=%d dat=%p dat=%s\n", n, dat, dat);
                     23:        strcpy(dat, "nAuth=1:nStatus=0:szChanne=SIP/0765-4802:szSID=437d9371-3977e2de-099999:szUser=099999:szPass=123123:szCaller=123123123:szRadGro=ppcards:szPhone=0768:ExtCode=07:szDispl=Bulgaria:nMasterG=1:nPrice=82:nGPrice=82:nMPrice=82:nBillInc=2:nGBillIn=2:nMBillIn=2:nMCache=807901468:nCache=999338:nAccount=29297:nPricePa=1:nGPriceP=1:nMPriceP=1:WarnTime=0:GratisTi=0:ActTime=1132220092:");
                     24:        sess_SetValue(n, "nAuth", NULL);
                     25:        printf("begin>>> String=%s\n", dat);
                     26:        printf("find=%d\n", sess_GetValue(n, "000", NULL, NULL));
                     27:        if (sess_GetErrno()) {
                     28:                printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
                     29:                return 2;
                     30:        }
                     31:        sess_DelValue(n, "000");
                     32:        printf("CLOSE %p>>> String=%s\n", n->addr, n->addr);
                     33:        strcat(dat, "Blaaaaaaaaaaaaaaaaaa da mu eb* mamataaaaa .....\n");
                     34:        map_detachSession(n);
                     35:        getchar();
                     36:        freeSession(NULL, &n);
                     37:        */
                     38: 
                     39:        sess_initSession(SHARED_MAP, "/tmp/abra-kadabra-123", &n);
                     40:        ALLOC_MEMORY(1003, 4096, n);
                     41:        if (io_GetErrno()) {
                     42:                printf("Error:: #%d - %s\n", io_GetErrno(), io_GetError());
                     43:                return 2;
                     44:        }
                     45:        ATTACH_MEMORY(n);
                     46:        if (!dat)
                     47:                return 1;
                     48: //     sess_SetValue(n, "piuk_gniah++", "mryyynnnnn");
1.2.2.1   misho      49:        printf(">>> String=%s\n", n->sess_addr);
1.2       misho      50:        getchar();
1.2.2.3 ! misho      51:        printf("12345678 Define? %d\n", SESS_RET_DEF(sess_GetValue(n, "12345678", &v)));
1.2.2.2   misho      52:        ait_freeVar(&v);
1.2.2.3 ! misho      53:        printf("111 Define? %d\n", SESS_RET_DEF(sess_SetValue(n, "111", "321")));
        !            54:        printf("88 Define? %d\n", SESS_RET_DEF(sess_GetValue(n, "88", &v)));
1.2.2.2   misho      55:        ait_freeVar(&v);
1.2.2.3 ! misho      56:        printf("222 find=%d value=%s vlen=%d\n", SESS_RET_DEF(sess_SetValue(n, "222", NULL)));
1.2.2.2   misho      57:        printf("12345678 find=%d value=%s vlen=%d\n", sess_GetValue(n, "12345678", &v), AIT_GET_STR(v));
                     58:        ait_freeVar(&v);
                     59:        printf("111 find=%d value=%s vlen=%d\n", sess_GetValue(n, "111", &v), AIT_GET_STR(v));
                     60:        ait_freeVar(&v);
1.2.2.3 ! misho      61:        printf("222 find=%d value=%s vlen=%d\n", SESS_RET_DEF(sess_GetValue(n, "222", &v)), AIT_GET_STR(v));
1.2.2.2   misho      62:        ait_freeVar(&v);
                     63:        printf("000 find=%d value=%s vlen=%d\n", sess_GetValue(n, "000", &v), AIT_GET_STR(v));
                     64:        ait_freeVar(&v);
                     65:        printf("00 find=%d value=%s vlen=%d\n", sess_GetValue(n, "00", &v), AIT_GET_STR(v));
                     66:        ait_freeVar(&v);
1.2.2.3 ! misho      67:        printf("insert Result?%d\n", SESS_RET_NEW(sess_SetValue(n, "789", "Gniah40")));
1.2.2.2   misho      68:        printf("00 find=%d value=%s vlen=%d\n", sess_GetValue(n, "00", &v), AIT_GET_STR(v));
                     69:        ait_freeVar(&v);
                     70:        printf(">>> String=%s\n", n->sess_addr);
1.2       misho      71:        printf("update Result=%d\n", sess_SetValue(n, "789", NULL));
                     72: //     printf(">>> String=%s\n", dat);
                     73: //     sess_DelValue(n, "789");
                     74:        sess_DelValue(n, "GratisT");
                     75:        sess_DelValue(n, "szUser");
                     76:        getchar();
1.2.2.2   misho      77:        printf("end %p>>> String=%s\n", n->sess_addr, n->sess_addr);
1.2       misho      78:        DETACH_MEMORY(n);
                     79:        getchar();
                     80:        FREE_MEMORY(n);
                     81:        sess_freeSession(&n);
                     82:        return 0;
                     83: }

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