Annotation of libaitsess/contrib/test2.c, revision 1.1.2.7
1.1.2.1 misho 1: #include <stdio.h>
2: #include <string.h>
3: #include <aitsess.h>
1.1.2.2 misho 4: #include <aitio.h>
1.1.2.1 misho 5:
1.1.2.6 misho 6:
1.1.2.2 misho 7: int main(int argc, char **argv)
1.1.2.1 misho 8: {
1.1.2.6 misho 9: ait_sess_t *n = NULL;
1.1.2.2 misho 10: array_t *inp;
1.1.2.4 misho 11: ait_val_t *v;
1.1.2.3 misho 12: int i;
1.1.2.2 misho 13:
1.1.2.4 misho 14: inp = io_arrayInit(argc);
15: for (i = 0; i < argc; i++) {
16: v = malloc(sizeof(ait_val_t));
17: AIT_SET_STR(v, argv[i]);
18: io_arraySet(inp, i, v);
19: }
1.1.2.2 misho 20:
1.1.2.1 misho 21: /*
22: map_createSession("/tmp/abra-kadabra-123", 1003, 4096, &n);
23: if (sess_GetErrno()) {
24: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
25: return 2;
26: }
27: dat = map_attachSession(n, NULL);
28: if (!dat)
29: return 1;
30: printf("brym n=%d dat=%p dat=%s\n", n, dat, dat);
31: 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:");
32: sess_SetValue(n, "nAuth", NULL);
33: printf("begin>>> String=%s\n", dat);
34: printf("find=%d\n", sess_GetValue(n, "000", NULL, NULL));
35: if (sess_GetErrno()) {
36: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
37: return 2;
38: }
39: sess_DelValue(n, "000");
40: printf("CLOSE %p>>> String=%s\n", n->addr, n->addr);
41: strcat(dat, "Blaaaaaaaaaaaaaaaaaa da mu eb* mamataaaaa .....\n");
42: map_detachSession(n);
43: getchar();
44: freeSession(NULL, &n);
45: */
46:
1.1.2.6 misho 47: sess_initSession(SHARED_IPC, "/tmp/abra-kadabra-321", &n);
1.1.2.7 ! misho 48: if (ALLOC_MEMORY(1003, 4096, n) == -1) {
1.1.2.1 misho 49: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
50: return 2;
51: }
1.1.2.3 misho 52: if (sess_commitSession(n, inp) == -1) {
53: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
1.1.2.7 ! misho 54: FREE_MEMORY(n);
! 55: sess_freeSession(&n);
1.1.2.3 misho 56: return 2;
57: }
1.1.2.7 ! misho 58: sess_freeSession(&n);
1.1.2.4 misho 59: io_arrayFree(inp);
1.1.2.3 misho 60: io_arrayDestroy(&inp);
61: printf("set session");
1.1.2.1 misho 62: getchar();
1.1.2.6 misho 63: sess_initSession(SHARED_IPC, "/tmp/abra-kadabra-321", &n);
1.1.2.7 ! misho 64: ALLOC_MEMORY(1003, 4096, n);
1.1.2.3 misho 65: if (sess_GetErrno()) {
66: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
67: return 3;
68: }
1.1.2.5 misho 69: if (!(inp = sess_prepareSession(n, 42))) {
1.1.2.3 misho 70: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
1.1.2.7 ! misho 71: FREE_MEMORY(n);
! 72: sess_freeSession(&n);
1.1.2.3 misho 73: return 3;
74: }
75: for (i = 0; i < io_arraySize(inp); i++)
1.1.2.4 misho 76: printf("i=%d->%s\n", i, AIT_GET_STR(io_array(inp, i, ait_val_t*)));
1.1.2.3 misho 77: sess_doneSession(n, &inp);
1.1.2.7 ! misho 78: sess_freeSession(&n);
1.1.2.1 misho 79: getchar();
1.1.2.6 misho 80: sess_initSession(SHARED_IPC, "/tmp/abra-kadabra-321", &n);
1.1.2.7 ! misho 81: ALLOC_MEMORY(1003, 4096, n);
1.1.2.3 misho 82: if (sess_GetErrno()) {
83: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
84: return 4;
85: }
86: if (!(inp = sess_prepareSession(n, 0))) {
87: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
1.1.2.7 ! misho 88: FREE_MEMORY(n);
! 89: sess_freeSession(&n);
1.1.2.3 misho 90: return 4;
91: }
1.1.2.4 misho 92: AIT_FREE_VAL(io_array(inp, 2, ait_val_t*));
93: AIT_SET_STR(io_array(inp, 2, ait_val_t*), "djmy");
94: for (i = 0; i < io_arraySize(inp); i++)
95: printf("i=%d->%s\n", i, AIT_GET_STR(io_array(inp, i, ait_val_t*)));
96: sess_commitSession(n, inp);
97: sess_doneSession(n, &inp);
1.1.2.7 ! misho 98: sess_freeSession(&n);
1.1.2.4 misho 99: getchar();
1.1.2.7 ! misho 100: sess_initSession(SHARED_IPC, "/tmp/abra-kadabra-321", &n);
! 101: ALLOC_MEMORY(1003, 4096, n);
1.1.2.4 misho 102: if (sess_GetErrno()) {
103: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
104: return 3;
105: }
1.1.2.5 misho 106: if (!(inp = sess_prepareSession(n, 42))) {
1.1.2.4 misho 107: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
1.1.2.7 ! misho 108: FREE_MEMORY(n);
! 109: sess_freeSession(&n);
1.1.2.4 misho 110: return 3;
111: }
1.1.2.3 misho 112: for (i = 0; i < io_arraySize(inp); i++)
1.1.2.4 misho 113: printf("i=%d->%s\n", i, AIT_GET_STR(io_array(inp, i, ait_val_t*)));
1.1.2.3 misho 114: sess_doneSession(n, &inp);
1.1.2.7 ! misho 115: FREE_MEMORY(n);
! 116: sess_freeSession(&n);
1.1.2.1 misho 117: return 0;
118: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>