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