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