version 1.1.2.1, 2012/03/29 12:24:40
|
version 1.4.4.3, 2012/08/29 13:49:04
|
Line 14 cmpfunc(const void *a, const void *b)
|
Line 14 cmpfunc(const void *a, const void *b)
|
return strcmp(AIT_GET_STR(*(ait_val_t**) a), AIT_GET_STR(*(ait_val_t**) b)); |
return strcmp(AIT_GET_STR(*(ait_val_t**) a), AIT_GET_STR(*(ait_val_t**) b)); |
} |
} |
|
|
|
static void |
|
makevars() |
|
{ |
|
ait_val_t *v; |
|
|
|
v = io_makeVar(empty); |
|
printf("Variable is empty? %d\n", AIT_ISEMPTY(v)); |
|
io_freeVar(&v); |
|
v = io_makeVar(ptr, 0x12345678, 42); |
|
printf("Variable is ptr=%p len=%u\n", AIT_GET_PTR(v), AIT_LEN(v)); |
|
io_freeVar(&v); |
|
v = io_makeVar(data, "TEST DATA !!!", 14); |
|
printf("Variable is data=%s len=%u\n", AIT_GET_DATA(v), AIT_LEN(v)); |
|
io_freeVar(&v); |
|
v = io_makeVar(buffer, "TEST Buffer !!!", 16); |
|
printf("Variable is buf=%s len=%u\n", AIT_GET_BUF(v), AIT_LEN(v)); |
|
io_freeVar(&v); |
|
v = io_makeVar(string, "TEST String ..."); |
|
printf("Variable is str=%s len=%u\n", AIT_GET_STR(v), AIT_LEN(v)); |
|
io_freeVar(&v); |
|
v = io_makeVar(blob, 1234, 10000); |
|
printf("Variable is blob=%u len=%u\n", AIT_GET_BLOB(v), AIT_LEN(v)); |
|
io_freeVar(&v); |
|
v = io_makeVar(f32, 1.0123); |
|
printf("Variable is f32=%f\n", AIT_GET_F32(v)); |
|
io_freeVar(&v); |
|
v = io_makeVar(f64, 0.00123321); |
|
printf("Variable is f64=%f\n", AIT_GET_F64(v)); |
|
io_freeVar(&v); |
|
v = io_makeVar(u8, 1); |
|
printf("Variable is u8=%hhu\n", AIT_GET_U8(v)); |
|
io_freeVar(&v); |
|
v = io_makeVar(u16, 32000); |
|
printf("Variable is u16=%hu\n", AIT_GET_U16(v)); |
|
io_freeVar(&v); |
|
v = io_makeVar(u32, 0xfedecaa0); |
|
printf("Variable is u32=%u\n", AIT_GET_U32(v)); |
|
io_freeVar(&v); |
|
v = io_makeVar(u64, 0xffeedccfedecaa01LL); |
|
printf("Variable is u64=%llu\n", AIT_GET_U64(v)); |
|
io_freeVar(&v); |
|
v = io_makeVar(i8, -1); |
|
printf("Variable is i8=%hhd\n", AIT_GET_I8(v)); |
|
io_freeVar(&v); |
|
v = io_makeVar(i16, -28888); |
|
printf("Variable is i16=%hd\n", AIT_GET_I16(v)); |
|
io_freeVar(&v); |
|
v = io_makeVar(i32, -23424234); |
|
printf("Variable is i32=%d\n", AIT_GET_I32(v)); |
|
io_freeVar(&v); |
|
v = io_makeVar(i64, -123234200000342LL); |
|
printf("Variable is i64=%lld\n", AIT_GET_I64(v)); |
|
io_freeVar(&v); |
|
} |
|
|
int |
int |
main(int argc, char **argv) |
main(int argc, char **argv) |
{ |
{ |
Line 21 main(int argc, char **argv)
|
Line 76 main(int argc, char **argv)
|
ait_val_t *v; |
ait_val_t *v; |
register int i; |
register int i; |
|
|
|
if (argc < 2) { |
|
makevars(); |
|
return 0; |
|
} |
|
|
arr = io_allocVars((argc - 1 ) / 2); |
arr = io_allocVars((argc - 1 ) / 2); |
if (!arr) { |
if (!arr) { |
printf("Error:: #%d - %s\n", io_GetErrno(), io_GetError()); |
printf("Error:: #%d - %s\n", io_GetErrno(), io_GetError()); |
Line 33 main(int argc, char **argv)
|
Line 93 main(int argc, char **argv)
|
AIT_SET_STR(v, argv[i * 2 + 2]); |
AIT_SET_STR(v, argv[i * 2 + 2]); |
} |
} |
|
|
|
v = io_getVars(&arr, io_arraySize(arr)); |
|
AIT_SET_STR(v, "mauhahahaha ohoho and bottle of rum!"); |
|
io_hashVar(v, "Baba Yaga #1"); |
|
|
|
v = io_findKeyVars(arr, 7); |
|
printf("v=%p\n", v); |
|
fflush(stdout); |
|
printf("search for key=7 %s\n", v ? AIT_GET_LIKE(v, char*) : ""); |
|
v = io_findKeyVars(arr, 23); |
|
printf("search for key=23 %s\n", v ? AIT_GET_LIKE(v, char*) : ""); |
|
v = io_findKeyVars(arr, 0); |
|
printf("search for key=0 %s\n", v ? AIT_GET_LIKE(v, char*) : ""); |
|
v = io_findKeyVars(arr, 99); |
|
printf("search for key=99 %s\n", v ? AIT_GET_LIKE(v, char*) : ""); |
|
|
|
io_hashKeyVars(arr); |
|
v = io_findKeyHash(arr, "Baba Yaga #1"); |
|
printf("search for hash='Baba Yaga #1' %s\n", v ? AIT_GET_LIKE(v, char*) : ""); |
|
|
printf("Before sorting::\n"); |
printf("Before sorting::\n"); |
for (i = 0; i < io_arraySize(arr); i++) |
for (i = 0; i < io_arraySize(arr); i++) |
printf("%d) KEY=%d %s\n", i, AIT_KEY(io_array(arr, i, ait_val_t*)), |
printf("%d) KEY=%d %s\n", i, AIT_KEY(io_array(arr, i, ait_val_t*)), |
AIT_GET_STR(io_array(arr, i, ait_val_t*))); |
AIT_GET_STR(io_array(arr, i, ait_val_t*))); |
|
|
printf("search for key=7 %s\n", AIT_GET_LIKE(io_findKeyVars(arr, 7), char*)); | io_sortVarsByKey(arr, 0); |
printf("search for key=23 %s\n", AIT_GET_LIKE(io_findKeyVars(arr, 23), char*)); | |
printf("search for key=0 %s\n", AIT_GET_LIKE(io_findKeyVars(arr, 0), char*)); | |
printf("search for key=99 %s\n", AIT_GET_LIKE(io_findKeyVars(arr, 99), char*)); | |
| |
io_sortVars(arr, 0, NULL); | |
printf("After KEY ascend sorting::\n"); |
printf("After KEY ascend sorting::\n"); |
for (i = 0; i < io_arraySize(arr); i++) |
for (i = 0; i < io_arraySize(arr); i++) |
printf("%d) KEY=%d %s\n", i, AIT_KEY(io_array(arr, i, ait_val_t*)), |
printf("%d) KEY=%d %s\n", i, AIT_KEY(io_array(arr, i, ait_val_t*)), |
AIT_GET_STR(io_array(arr, i, ait_val_t*))); |
AIT_GET_STR(io_array(arr, i, ait_val_t*))); |
|
|
io_sortVars(arr, 42, NULL); | io_sortVarsByKey(arr, 42); |
printf("After KEY descend sorting::\n"); |
printf("After KEY descend sorting::\n"); |
for (i = 0; i < io_arraySize(arr); i++) |
for (i = 0; i < io_arraySize(arr); i++) |
printf("%d) KEY=%d %s\n", i, AIT_KEY(io_array(arr, i, ait_val_t*)), |
printf("%d) KEY=%d %s\n", i, AIT_KEY(io_array(arr, i, ait_val_t*)), |
AIT_GET_STR(io_array(arr, i, ait_val_t*))); |
AIT_GET_STR(io_array(arr, i, ait_val_t*))); |
|
|
io_sortVars(arr, 0, cmpfunc); | io_sortVarsByVal(arr, 0, cmpfunc); |
printf("After string sorting::\n"); |
printf("After string sorting::\n"); |
for (i = 0; i < io_arraySize(arr); i++) |
for (i = 0; i < io_arraySize(arr); i++) |
printf("%d) KEY=%d %s\n", i, AIT_KEY(io_array(arr, i, ait_val_t*)), |
printf("%d) KEY=%d %s\n", i, AIT_KEY(io_array(arr, i, ait_val_t*)), |