#include <stdio.h>
#include <string.h>
#include <aitsess.h>
#include <elwix.h>
int main(int argc, char **argv)
{
ait_sess_t *n = NULL;
array_t *inp;
ait_val_t *v;
int i;
inp = array_Init(argc);
for (i = 0; i < argc; i++) {
v = ait_allocVar();
AIT_SET_STR(v, argv[i]);
array_Set(inp, i, v);
}
/*
map_createSession("/tmp/abra-kadabra-123", 1003, 4096, &n);
if (sess_GetErrno()) {
printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
return 2;
}
dat = map_attachSession(n, NULL);
if (!dat)
return 1;
printf("brym n=%d dat=%p dat=%s\n", n, dat, dat);
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:");
sess_SetValue(n, "nAuth", NULL);
printf("begin>>> String=%s\n", dat);
printf("find=%d\n", sess_GetValue(n, "000", NULL, NULL));
if (sess_GetErrno()) {
printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
return 2;
}
sess_DelValue(n, "000");
printf("CLOSE %p>>> String=%s\n", n->addr, n->addr);
strcat(dat, "Blaaaaaaaaaaaaaaaaaa da mu eb* mamataaaaa .....\n");
map_detachSession(n);
getchar();
freeSession(NULL, &n);
*/
sess_initSession(SHARED_IPC, "/tmp/abra-kadabra-321", &n);
if (ALLOC_MEMORY(1003, 4096, n) == -1) {
printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
return 2;
}
if (sess_commitSession(n, inp) == -1) {
printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
FREE_MEMORY(n);
sess_freeSession(&n);
return 2;
}
sess_freeSession(&n);
for (i = 0; i < array_Size(inp); i++)
AIT_FREE_VAL(array_Get(inp, i));
array_Free(inp);
array_Destroy(&inp);
printf("set session");
getchar();
sess_initSession(SHARED_IPC, "/tmp/abra-kadabra-321", &n);
ALLOC_MEMORY(1003, 4096, n);
if (sess_GetErrno()) {
printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
return 3;
}
if (!(inp = sess_prepareSession(n, 42))) {
printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
FREE_MEMORY(n);
sess_freeSession(&n);
return 3;
}
for (i = 0; i < array_Size(inp); i++)
printf("i=%d->%s\n", i, AIT_GET_STR(array(inp, i, ait_val_t*)));
sess_doneSession(n, &inp);
sess_freeSession(&n);
getchar();
sess_initSession(SHARED_IPC, "/tmp/abra-kadabra-321", &n);
ALLOC_MEMORY(1003, 4096, n);
if (sess_GetErrno()) {
printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
return 4;
}
if (!(inp = sess_prepareSession(n, 0))) {
printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
FREE_MEMORY(n);
sess_freeSession(&n);
return 4;
}
AIT_FREE_VAL(array(inp, 2, ait_val_t*));
AIT_SET_STR(array(inp, 2, ait_val_t*), "djmy");
for (i = 0; i < array_Size(inp); i++)
printf("i=%d->%s\n", i, AIT_GET_STR(array(inp, i, ait_val_t*)));
sess_commitSession(n, inp);
for (i = 0; i < array_Size(inp); i++)
AIT_FREE_VAL(array_Get(inp, i));
sess_doneSession(n, &inp);
sess_freeSession(&n);
getchar();
sess_initSession(SHARED_IPC, "/tmp/abra-kadabra-321", &n);
ALLOC_MEMORY(1003, 4096, n);
if (sess_GetErrno()) {
printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
return 3;
}
if (!(inp = sess_prepareSession(n, 42))) {
printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError());
FREE_MEMORY(n);
sess_freeSession(&n);
return 3;
}
for (i = 0; i < array_Size(inp); i++)
printf("i=%d->%s\n", i, AIT_GET_STR(array(inp, i, ait_val_t*)));
/*
for (i = 0; i < array_Size(inp); i++)
AIT_FREE_VAL(array_Get(inp, i));
*/
sess_doneSession(n, &inp);
FREE_MEMORY(n);
sess_freeSession(&n);
return 0;
}
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>