Annotation of libaitsess/contrib/test.c, revision 1.2
1.1 misho 1: #include <stdio.h>
2: #include <string.h>
3: #include <aitsess.h>
4:
5: int main()
6: {
7: tagSess *n = NULL;
8: int i = 255;
9: char *dat, szVal[256];
10:
11: /*
12: map_createSession("/tmp/abra-kadabra-123", 1003, 4096, &n);
13: if (sess_GetErrno()) {
14: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
15: return 2;
16: }
17: dat = map_attachSession(n, NULL);
18: if (!dat)
19: return 1;
20: printf("brym n=%d dat=%p dat=%s\n", n, dat, dat);
21: 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:");
22: sess_SetValue(n, "nAuth", NULL);
23: printf("begin>>> String=%s\n", dat);
24: printf("find=%d\n", sess_GetValue(n, "000", NULL, NULL));
25: if (sess_GetErrno()) {
26: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
27: return 2;
28: }
29: sess_DelValue(n, "000");
30: printf("CLOSE %p>>> String=%s\n", n->addr, n->addr);
31: strcat(dat, "Blaaaaaaaaaaaaaaaaaa da mu eb* mamataaaaa .....\n");
32: map_detachSession(n);
33: getchar();
34: freeSession(NULL, &n);
35: */
36:
1.2 ! misho 37: ipc_createSession("/tmp/abra-kadabra-123", 1003, 4096, &n);
1.1 misho 38: if (sess_GetErrno()) {
39: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
40: return 2;
41: }
1.2 ! misho 42: ipc_attachSession(n, NULL);
1.1 misho 43: if (!dat)
44: return 1;
1.2 ! misho 45: // sess_SetValue(n, "piuk_gniah++", "mryyynnnnn");
! 46: printf(">>> String=%s\n", n->addr);
! 47: getchar();
1.1 misho 48: printf("12345678 Define? %d\n", ISDEF(sess_GetValue(n, "12345678", szVal, &i)));
49: printf("111 Define? %d\n", ISDEF(sess_SetValue(n, "111", "321")));
50: printf("88 Define? %d\n", ISDEF(sess_GetValue(n, "88", szVal, &i)));
51: printf("222 find=%d value=%s vlen=%d\n", ISDEF(sess_SetValue(n, "222", NULL)));
52: printf("12345678 find=%d value=%s vlen=%d\n", sess_GetValue(n, "12345678", szVal, &i), szVal, i);
53: printf("111 find=%d value=%s vlen=%d\n", sess_GetValue(n, "111", szVal, &i), szVal, i);
54: printf("222 find=%d value=%s vlen=%d\n", ISDEF(sess_GetValue(n, "222", szVal, &i)), szVal, i);
55: printf("000 find=%d value=%s vlen=%d\n", sess_GetValue(n, "000", szVal, &i), szVal, i);
56: printf("00 find=%d value=%s vlen=%d\n", sess_GetValue(n, "00", szVal, &i), szVal, i);
57: printf("insert Result?%d\n", ISNEW(sess_SetValue(n, "789", "Gniah40")));
58: printf("00 find=%d value=%s vlen=%d\n", sess_GetValue(n, "00", szVal, &i), szVal, i);
1.2 ! misho 59: printf(">>> String=%s\n", n->addr);
1.1 misho 60: printf("update Result=%d\n", sess_SetValue(n, "789", NULL));
61: // printf(">>> String=%s\n", dat);
1.2 ! misho 62: // sess_DelValue(n, "789");
1.1 misho 63: sess_DelValue(n, "GratisT");
64: sess_DelValue(n, "szUser");
65: getchar();
66: printf("end %p>>> String=%s\n", n->addr, n->addr);
1.2 ! misho 67: ipc_detachSession(n);
1.1 misho 68: getchar();
1.2 ! misho 69: ipc_destroySession("/tmp/abra-kadabra-123", &n);
1.1 misho 70: return 0;
71: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>