version 1.1.2.1, 2011/09/07 15:59:46
|
version 1.1.2.4, 2011/09/07 23:38:39
|
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> |
|
|
int main() | int main(int argc, char **argv) |
{ |
{ |
tagSess *n = NULL; |
tagSess *n = NULL; |
int i = 255; | array_t *inp; |
char *dat, szVal[256]; | ait_val_t *v; |
| int i; |
| |
| inp = io_arrayInit(argc); |
| for (i = 0; i < argc; i++) { |
| v = malloc(sizeof(ait_val_t)); |
| AIT_SET_STR(v, argv[i]); |
| io_arraySet(inp, i, v); |
| } |
| |
/* |
/* |
map_createSession("/tmp/abra-kadabra-123", 1003, 4096, &n); |
map_createSession("/tmp/abra-kadabra-123", 1003, 4096, &n); |
if (sess_GetErrno()) { |
if (sess_GetErrno()) { |
Line 34 int main()
|
Line 43 int main()
|
freeSession(NULL, &n); |
freeSession(NULL, &n); |
*/ |
*/ |
|
|
ipc_createSession("/tmp/abra-kadabra-123", 1003, 4096, &n); | if (ipc_createSession("/tmp/abra-kadabra-321", 1003, 4096, &n) == -1) { |
if (sess_GetErrno()) { | |
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; | DESTROY_SESSION("/tmp/abra-kadabra-321", &n); |
// sess_SetValue(n, "piuk_gniah++", "mryyynnnnn"); | return 2; |
printf(">>> String=%s\n", n->addr); | } |
| freeSession(NULL, &n); |
| io_arrayFree(inp); |
| io_arrayDestroy(&inp); |
| printf("set session"); |
getchar(); |
getchar(); |
printf("12345678 Define? %d\n", ISDEF(sess_GetValue(n, "12345678", szVal, &i))); | ipc_createSession("/tmp/abra-kadabra-321", 1003, 4096, &n); |
printf("111 Define? %d\n", ISDEF(sess_SetValue(n, "111", "321"))); | if (sess_GetErrno()) { |
printf("88 Define? %d\n", ISDEF(sess_GetValue(n, "88", szVal, &i))); | printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError()); |
printf("222 find=%d value=%s vlen=%d\n", ISDEF(sess_SetValue(n, "222", NULL))); | return 3; |
printf("12345678 find=%d value=%s vlen=%d\n", sess_GetValue(n, "12345678", szVal, &i), szVal, i); | } |
printf("111 find=%d value=%s vlen=%d\n", sess_GetValue(n, "111", szVal, &i), szVal, i); | if (!(inp = sess_prepareSession(n, 0))) { |
printf("222 find=%d value=%s vlen=%d\n", ISDEF(sess_GetValue(n, "222", szVal, &i)), szVal, i); | printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError()); |
printf("000 find=%d value=%s vlen=%d\n", sess_GetValue(n, "000", szVal, &i), szVal, i); | DESTROY_SESSION("/tmp/abra-kadabra-321", &n); |
printf("00 find=%d value=%s vlen=%d\n", sess_GetValue(n, "00", szVal, &i), szVal, i); | return 3; |
printf("insert Result?%d\n", ISNEW(sess_SetValue(n, "789", "Gniah40"))); | } |
printf("00 find=%d value=%s vlen=%d\n", sess_GetValue(n, "00", szVal, &i), szVal, i); | for (i = 0; i < io_arraySize(inp); i++) |
printf(">>> String=%s\n", n->addr); | printf("i=%d->%s\n", i, AIT_GET_STR(io_array(inp, i, ait_val_t*))); |
printf("update Result=%d\n", sess_SetValue(n, "789", NULL)); | sess_doneSession(n, &inp); |
// printf(">>> String=%s\n", dat); | freeSession(NULL, &n); |
// sess_DelValue(n, "789"); | |
sess_DelValue(n, "GratisT"); | |
sess_DelValue(n, "szUser"); | |
getchar(); |
getchar(); |
printf("end %p>>> String=%s\n", n->addr, n->addr); | ipc_createSession("/tmp/abra-kadabra-321", 1003, 4096, &n); |
ipc_detachSession(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()); |
| DESTROY_SESSION("/tmp/abra-kadabra-321", &n); |
| return 4; |
| } |
| AIT_FREE_VAL(io_array(inp, 2, ait_val_t*)); |
| AIT_SET_STR(io_array(inp, 2, ait_val_t*), "djmy"); |
| for (i = 0; i < io_arraySize(inp); i++) |
| printf("i=%d->%s\n", i, AIT_GET_STR(io_array(inp, i, ait_val_t*))); |
| sess_commitSession(n, inp); |
| sess_doneSession(n, &inp); |
| freeSession(NULL, &n); |
getchar(); |
getchar(); |
ipc_destroySession("/tmp/abra-kadabra-123", &n); | ipc_createSession("/tmp/abra-kadabra-321", 1003, 4096, &n); |
| if (sess_GetErrno()) { |
| printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError()); |
| return 3; |
| } |
| if (!(inp = sess_prepareSession(n, 0))) { |
| printf("Error:: #%d - %s\n", sess_GetErrno(), sess_GetError()); |
| DESTROY_SESSION("/tmp/abra-kadabra-321", &n); |
| return 3; |
| } |
| for (i = 0; i < io_arraySize(inp); i++) |
| printf("i=%d->%s\n", i, AIT_GET_STR(io_array(inp, i, ait_val_t*))); |
| sess_doneSession(n, &inp); |
| DESTROY_SESSION("/tmp/abra-kadabra-321", &n); |
return 0; |
return 0; |
} |
} |