version 1.1.2.2, 2011/09/07 21:06:56
|
version 1.3.4.1, 2013/01/17 13:54:53
|
Line 1
|
Line 1
|
#include <stdio.h> |
#include <stdio.h> |
#include <string.h> |
#include <string.h> |
#include <aitsess.h> |
#include <aitsess.h> |
#include <aitio.h> | #include <elwix.h> |
|
|
|
|
int main(int argc, char **argv) |
int main(int argc, char **argv) |
{ |
{ |
tagSess *n = NULL; | ait_sess_t *n = NULL; |
array_t *inp; |
array_t *inp; |
|
ait_val_t *v; |
|
int i; |
|
|
inp = io_arrayFrom(&argv, argc); | 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); |
map_createSession("/tmp/abra-kadabra-123", 1003, 4096, &n); |
Line 36 int main(int argc, char **argv)
|
Line 44 int main(int argc, char **argv)
|
freeSession(NULL, &n); |
freeSession(NULL, &n); |
*/ |
*/ |
|
|
ipc_createSession("/tmp/abra-kadabra-321", 1003, 4096, &n); | sess_initSession(SHARED_IPC, "/tmp/abra-kadabra-321", &n); |
if (sess_GetErrno()) { | if (ALLOC_MEMORY(1003, 4096, n) == -1) { |
printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError()); |
printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError()); |
return 2; |
return 2; |
} |
} |
ipc_attachSession(n, NULL); | if (sess_commitSession(n, inp) == -1) { |
if (!dat) | printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError()); |
return 1; | FREE_MEMORY(n); |
// sess_SetValue(n, "piuk_gniah++", "mryyynnnnn"); | sess_freeSession(&n); |
printf(">>> String=%s\n", n->addr); | 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(); |
getchar(); |
printf("12345678 Define? %d\n", ISDEF(sess_GetValue(n, "12345678", szVal, &i))); | sess_initSession(SHARED_IPC, "/tmp/abra-kadabra-321", &n); |
printf("111 Define? %d\n", ISDEF(sess_SetValue(n, "111", "321"))); | ALLOC_MEMORY(1003, 4096, n); |
printf("88 Define? %d\n", ISDEF(sess_GetValue(n, "88", szVal, &i))); | if (sess_GetErrno()) { |
printf("222 find=%d value=%s vlen=%d\n", ISDEF(sess_SetValue(n, "222", NULL))); | printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError()); |
printf("12345678 find=%d value=%s vlen=%d\n", sess_GetValue(n, "12345678", szVal, &i), szVal, i); | return 3; |
printf("111 find=%d value=%s vlen=%d\n", sess_GetValue(n, "111", szVal, &i), szVal, i); | } |
printf("222 find=%d value=%s vlen=%d\n", ISDEF(sess_GetValue(n, "222", szVal, &i)), szVal, i); | if (!(inp = sess_prepareSession(n, 42))) { |
printf("000 find=%d value=%s vlen=%d\n", sess_GetValue(n, "000", szVal, &i), szVal, i); | printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError()); |
printf("00 find=%d value=%s vlen=%d\n", sess_GetValue(n, "00", szVal, &i), szVal, i); | FREE_MEMORY(n); |
printf("insert Result?%d\n", ISNEW(sess_SetValue(n, "789", "Gniah40"))); | sess_freeSession(&n); |
printf("00 find=%d value=%s vlen=%d\n", sess_GetValue(n, "00", szVal, &i), szVal, i); | return 3; |
printf(">>> String=%s\n", n->addr); | } |
printf("update Result=%d\n", sess_SetValue(n, "789", NULL)); | for (i = 0; i < array_Size(inp); i++) |
// printf(">>> String=%s\n", dat); | printf("i=%d->%s\n", i, AIT_GET_STR(array(inp, i, ait_val_t*))); |
// sess_DelValue(n, "789"); | sess_doneSession(n, &inp); |
sess_DelValue(n, "GratisT"); | sess_freeSession(&n); |
sess_DelValue(n, "szUser"); | |
getchar(); |
getchar(); |
printf("end %p>>> String=%s\n", n->addr, n->addr); | sess_initSession(SHARED_IPC, "/tmp/abra-kadabra-321", &n); |
ipc_detachSession(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(); |
getchar(); |
ipc_destroySession("/tmp/abra-kadabra-123", &n); | 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; |
return 0; |
} |
} |