version 1.11, 2012/07/22 20:39:45
|
version 1.11.4.3, 2012/07/31 15:58:08
|
Line 463 io_freeVar(ait_val_t ** __restrict val)
|
Line 463 io_freeVar(ait_val_t ** __restrict val)
|
} |
} |
} |
} |
|
|
|
/* |
|
* io_makeVar() - Allocate memory and fill variable |
|
* |
|
* @type = type of variable |
|
* @... = arg1 is value of variable |
|
* @... = arg2 is length of variabla. Not required for numbers and strings! |
|
* return: NULL error or new variable, after use free variable with io_freeVar() |
|
*/ |
|
ait_val_t * |
|
io_makeVar(ait_type_t type, ...) |
|
{ |
|
ait_val_t *v = NULL; |
|
va_list lst; |
|
void *p = NULL; |
|
uint32_t len = 0; |
|
uint64_t n = 0LL; |
|
|
|
v = io_allocVar(); |
|
if (!v) |
|
return NULL; |
|
|
|
va_start(lst, type); |
|
switch (type) { |
|
case empty: |
|
v->val_type = (uint8_t) empty; |
|
break; |
|
case ptr: |
|
p = va_arg(lst, void*); |
|
len = va_arg(lst, uint32_t); |
|
AIT_SET_PTR(v, p, len); |
|
break; |
|
case data: |
|
p = va_arg(lst, void*); |
|
len = va_arg(lst, uint32_t); |
|
AIT_SET_DATA(v, p, len); |
|
break; |
|
case buffer: |
|
p = va_arg(lst, void*); |
|
len = va_arg(lst, uint32_t); |
|
AIT_SET_BUF(v, p, len); |
|
break; |
|
case string: |
|
p = va_arg(lst, char*); |
|
AIT_SET_STR(v, p); |
|
break; |
|
case blob: |
|
n = va_arg(lst, uint32_t); |
|
len = va_arg(lst, uint32_t); |
|
AIT_SET_BLOB(v, n, len); |
|
break; |
|
case f32: |
|
AIT_SET_F32(v, (float) va_arg(lst, double)); |
|
break; |
|
case f64: |
|
AIT_SET_F64(v, va_arg(lst, double)); |
|
break; |
|
case u8: |
|
AIT_SET_U8(v, (uint8_t) va_arg(lst, int)); |
|
break; |
|
case u16: |
|
AIT_SET_U16(v, (uint16_t) va_arg(lst, int)); |
|
break; |
|
case u32: |
|
AIT_SET_U32(v, va_arg(lst, uint32_t)); |
|
break; |
|
case u64: |
|
AIT_SET_U64(v, va_arg(lst, uint64_t)); |
|
break; |
|
case i8: |
|
AIT_SET_I8(v, (int8_t) va_arg(lst, int)); |
|
break; |
|
case i16: |
|
AIT_SET_I16(v, (int16_t) va_arg(lst, int)); |
|
break; |
|
case i32: |
|
AIT_SET_I32(v, va_arg(lst, int32_t)); |
|
break; |
|
case i64: |
|
AIT_SET_I64(v, va_arg(lst, int64_t)); |
|
break; |
|
} |
|
va_end(lst); |
|
|
|
return v; |
|
} |
|
|
static int |
static int |
_cmp_arr_key_asc(const void *a, const void *b) |
_cmp_arr_key_asc(const void *a, const void *b) |
{ |
{ |