File:
[ELWIX - Embedded LightWeight unIX -] /
libaitio /
example /
test2_sess.c
Revision
1.3:
download - view:
text,
annotated -
select for diffs -
revision graph
Tue Mar 19 17:31:38 2013 UTC (11 years, 5 months ago) by
misho
Branches:
MAIN
CVS tags:
io7_3,
io7_2,
io7_1,
io7_0,
io6_9,
io6_8,
io6_7,
io6_6,
io6_5,
io6_4,
io6_3,
io6_2,
io6_1,
io6_0,
io5_9,
io5_8,
io5_7,
io5_6,
io5_5,
io5_4,
io5_3,
io5_2,
IO7_2,
IO7_1,
IO7_0,
IO6_9,
IO6_8,
IO6_7,
IO6_6,
IO6_5,
IO6_4,
IO6_3,
IO6_2,
IO6_1,
IO6_0,
IO5_9,
IO5_8,
IO5_7,
IO5_6,
IO5_5,
IO5_4,
IO5_3,
IO5_2,
IO5_1,
HEAD
version 5.1
1: #include <stdio.h>
2: #include <string.h>
3: #include <aitsess.h>
4: #include <elwix.h>
5:
6:
7: int main(int argc, char **argv)
8: {
9: sess_t *n = NULL;
10: array_t *inp;
11: ait_val_t *v;
12: int i;
13:
14: inp = array_Init(argc);
15: for (i = 0; i < argc; i++) {
16: v = ait_allocVar();
17: AIT_SET_STR(v, argv[i]);
18: array_Set(inp, i, v);
19: }
20:
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:
47: sess_initSession(SHARED_IPC, "/tmp/abra-kadabra-321", &n);
48: if (ALLOC_MEMORY(1003, 4096, n) == -1) {
49: printf("Error:: #%d - %s\n", io_GetErrno(), io_GetError());
50: return 2;
51: }
52: if (sess_commitSession(n, inp) == -1) {
53: printf("Error:: #%d - %s\n", io_GetErrno(), io_GetError());
54: FREE_MEMORY(n);
55: sess_freeSession(&n);
56: return 2;
57: }
58: sess_freeSession(&n);
59: for (i = 0; i < array_Size(inp); i++)
60: AIT_FREE_VAL(array_Get(inp, i));
61: array_Free(inp);
62: array_Destroy(&inp);
63: printf("set session");
64: getchar();
65: sess_initSession(SHARED_IPC, "/tmp/abra-kadabra-321", &n);
66: ALLOC_MEMORY(1003, 4096, n);
67: if (io_GetErrno()) {
68: printf("Error:: #%d - %s\n", io_GetErrno(), io_GetError());
69: return 3;
70: }
71: if (!(inp = sess_prepareSession(n, 42))) {
72: printf("Error:: #%d - %s\n", io_GetErrno(), io_GetError());
73: FREE_MEMORY(n);
74: sess_freeSession(&n);
75: return 3;
76: }
77: for (i = 0; i < array_Size(inp); i++)
78: printf("i=%d->%s\n", i, AIT_GET_STR(array(inp, i, ait_val_t*)));
79: sess_doneSession(n, &inp);
80: sess_freeSession(&n);
81: getchar();
82: sess_initSession(SHARED_IPC, "/tmp/abra-kadabra-321", &n);
83: ALLOC_MEMORY(1003, 4096, n);
84: if (io_GetErrno()) {
85: printf("Error:: #%d - %s\n", io_GetErrno(), io_GetError());
86: return 4;
87: }
88: if (!(inp = sess_prepareSession(n, 0))) {
89: printf("Error:: #%d - %s\n", io_GetErrno(), io_GetError());
90: FREE_MEMORY(n);
91: sess_freeSession(&n);
92: return 4;
93: }
94: AIT_FREE_VAL(array(inp, 2, ait_val_t*));
95: AIT_SET_STR(array(inp, 2, ait_val_t*), "djmy");
96: for (i = 0; i < array_Size(inp); i++)
97: printf("i=%d->%s\n", i, AIT_GET_STR(array(inp, i, ait_val_t*)));
98: sess_commitSession(n, inp);
99: for (i = 0; i < array_Size(inp); i++)
100: AIT_FREE_VAL(array_Get(inp, i));
101: sess_doneSession(n, &inp);
102: sess_freeSession(&n);
103: getchar();
104: sess_initSession(SHARED_IPC, "/tmp/abra-kadabra-321", &n);
105: ALLOC_MEMORY(1003, 4096, n);
106: if (io_GetErrno()) {
107: printf("Error:: #%d - %s\n", io_GetErrno(), io_GetError());
108: return 3;
109: }
110: if (!(inp = sess_prepareSession(n, 42))) {
111: printf("Error:: #%d - %s\n", io_GetErrno(), io_GetError());
112: FREE_MEMORY(n);
113: sess_freeSession(&n);
114: return 3;
115: }
116: for (i = 0; i < array_Size(inp); i++)
117: printf("i=%d->%s\n", i, AIT_GET_STR(array(inp, i, ait_val_t*)));
118: /*
119: for (i = 0; i < array_Size(inp); i++)
120: AIT_FREE_VAL(array_Get(inp, i));
121: */
122: sess_doneSession(n, &inp);
123: FREE_MEMORY(n);
124: sess_freeSession(&n);
125:
126: return 0;
127: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>