Annotation of libaitsess/contrib/test2.c, revision 1.1.2.3
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.3 ! misho 10: int i;
1.1.2.2 misho 11:
1.1.2.3 ! misho 12: inp = io_arrayFrom((const char***) &argv, argc);
1.1.2.2 misho 13:
1.1.2.1 misho 14: /*
15: map_createSession("/tmp/abra-kadabra-123", 1003, 4096, &n);
16: if (sess_GetErrno()) {
17: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
18: return 2;
19: }
20: dat = map_attachSession(n, NULL);
21: if (!dat)
22: return 1;
23: printf("brym n=%d dat=%p dat=%s\n", n, dat, dat);
24: 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:");
25: sess_SetValue(n, "nAuth", NULL);
26: printf("begin>>> String=%s\n", dat);
27: printf("find=%d\n", sess_GetValue(n, "000", NULL, NULL));
28: if (sess_GetErrno()) {
29: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
30: return 2;
31: }
32: sess_DelValue(n, "000");
33: printf("CLOSE %p>>> String=%s\n", n->addr, n->addr);
34: strcat(dat, "Blaaaaaaaaaaaaaaaaaa da mu eb* mamataaaaa .....\n");
35: map_detachSession(n);
36: getchar();
37: freeSession(NULL, &n);
38: */
39:
1.1.2.3 ! misho 40: if (ipc_createSession("/tmp/abra-kadabra-321", 1003, 4096, &n) == -1) {
1.1.2.1 misho 41: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
42: return 2;
43: }
1.1.2.3 ! misho 44: if (sess_commitSession(n, inp) == -1) {
! 45: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
! 46: DESTROY_SESSION("/tmp/abra-kadabra-321", &n);
! 47: return 2;
! 48: }
! 49: DESTROY_SESSION(NULL, &n);
! 50: io_arrayDestroy(&inp);
! 51: printf("set session");
1.1.2.1 misho 52: getchar();
1.1.2.3 ! misho 53: ipc_createSession("/tmp/abra-kadabra-321", 1003, 4096, &n);
! 54: if (sess_GetErrno()) {
! 55: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
! 56: return 3;
! 57: }
! 58: if (!(inp = sess_prepareSession(n, 42))) {
! 59: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
! 60: DESTROY_SESSION("/tmp/abra-kadabra-321", &n);
! 61: return 3;
! 62: }
! 63: for (i = 0; i < io_arraySize(inp); i++)
! 64: printf("i=%d->%s\n", i, io_arrayGet(inp, i));
! 65: sess_doneSession(n, &inp);
! 66: DESTROY_SESSION(NULL, &n);
1.1.2.1 misho 67: getchar();
1.1.2.3 ! misho 68: ipc_createSession("/tmp/abra-kadabra-321", 1003, 4096, &n);
! 69: if (sess_GetErrno()) {
! 70: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
! 71: return 4;
! 72: }
! 73: if (!(inp = sess_prepareSession(n, 0))) {
! 74: printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
! 75: DESTROY_SESSION("/tmp/abra-kadabra-321", &n);
! 76: return 4;
! 77: }
! 78: for (i = 0; i < io_arraySize(inp); i++)
! 79: printf("i=%d->%s\n", i, io_arrayGet(inp, i));
! 80: sess_doneSession(n, &inp);
! 81: DESTROY_SESSION("/tmp/abra-kadabra-321", &n);
1.1.2.1 misho 82: return 0;
83: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>