Annotation of libaitsess/contrib/test2.c, revision 1.1.2.8
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.8 ! misho 59: for (i = 0; i < io_arraySize(inp); i++)
! 60: AIT_FREE_VAL(io_arrayGet(inp, i));
1.1.2.4 misho 61: io_arrayFree(inp);
1.1.2.3 misho 62: io_arrayDestroy(&inp);
63: printf("set session");
1.1.2.1 misho 64: getchar();
1.1.2.6 misho 65: sess_initSession(SHARED_IPC, "/tmp/abra-kadabra-321", &n);
1.1.2.7 misho 66: ALLOC_MEMORY(1003, 4096, n);
1.1.2.3 misho 67: if (sess_GetErrno()) {
68: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
69: return 3;
70: }
1.1.2.5 misho 71: if (!(inp = sess_prepareSession(n, 42))) {
1.1.2.3 misho 72: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
1.1.2.7 misho 73: FREE_MEMORY(n);
74: sess_freeSession(&n);
1.1.2.3 misho 75: return 3;
76: }
77: for (i = 0; i < io_arraySize(inp); i++)
1.1.2.4 misho 78: printf("i=%d->%s\n", i, AIT_GET_STR(io_array(inp, i, ait_val_t*)));
1.1.2.3 misho 79: sess_doneSession(n, &inp);
1.1.2.7 misho 80: sess_freeSession(&n);
1.1.2.1 misho 81: getchar();
1.1.2.6 misho 82: sess_initSession(SHARED_IPC, "/tmp/abra-kadabra-321", &n);
1.1.2.7 misho 83: ALLOC_MEMORY(1003, 4096, n);
1.1.2.3 misho 84: if (sess_GetErrno()) {
85: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
86: return 4;
87: }
88: if (!(inp = sess_prepareSession(n, 0))) {
89: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
1.1.2.7 misho 90: FREE_MEMORY(n);
91: sess_freeSession(&n);
1.1.2.3 misho 92: return 4;
93: }
1.1.2.4 misho 94: AIT_FREE_VAL(io_array(inp, 2, ait_val_t*));
95: AIT_SET_STR(io_array(inp, 2, ait_val_t*), "djmy");
96: for (i = 0; i < io_arraySize(inp); i++)
97: printf("i=%d->%s\n", i, AIT_GET_STR(io_array(inp, i, ait_val_t*)));
98: sess_commitSession(n, inp);
1.1.2.8 ! misho 99: for (i = 0; i < io_arraySize(inp); i++)
! 100: AIT_FREE_VAL(io_arrayGet(inp, i));
1.1.2.4 misho 101: sess_doneSession(n, &inp);
1.1.2.7 misho 102: sess_freeSession(&n);
1.1.2.4 misho 103: getchar();
1.1.2.7 misho 104: sess_initSession(SHARED_IPC, "/tmp/abra-kadabra-321", &n);
105: ALLOC_MEMORY(1003, 4096, n);
1.1.2.4 misho 106: if (sess_GetErrno()) {
107: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
108: return 3;
109: }
1.1.2.5 misho 110: if (!(inp = sess_prepareSession(n, 42))) {
1.1.2.4 misho 111: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
1.1.2.7 misho 112: FREE_MEMORY(n);
113: sess_freeSession(&n);
1.1.2.4 misho 114: return 3;
115: }
1.1.2.3 misho 116: for (i = 0; i < io_arraySize(inp); i++)
1.1.2.4 misho 117: printf("i=%d->%s\n", i, AIT_GET_STR(io_array(inp, i, ait_val_t*)));
1.1.2.8 ! misho 118: for (i = 0; i < io_arraySize(inp); i++)
! 119: AIT_FREE_VAL(io_arrayGet(inp, i));
1.1.2.3 misho 120: sess_doneSession(n, &inp);
1.1.2.7 misho 121: FREE_MEMORY(n);
122: sess_freeSession(&n);
1.1.2.8 ! misho 123:
1.1.2.1 misho 124: return 0;
125: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>