version 1.13.2.1, 2012/09/03 09:26:34
|
version 1.13.2.3, 2012/09/17 13:44:22
|
Line 778 io_sprintfVar(ait_val_t * __restrict v, const char *fm
|
Line 778 io_sprintfVar(ait_val_t * __restrict v, const char *fm
|
free(str); |
free(str); |
return ret; |
return ret; |
} |
} |
|
|
|
/* |
|
* io_setlikeVar() - Set variable like ... |
|
* |
|
* @v = variable |
|
* @t = type of data |
|
* @l = length of data |
|
* @... = data |
|
* return: -1 error or 0 ok |
|
*/ |
|
inline int |
|
io_setlikeVar(ait_val_t * __restrict v, ait_type_t t, u_int l, ...) |
|
{ |
|
va_list lst; |
|
|
|
if (!v) |
|
return -1; |
|
|
|
AIT_FREE_VAL(v); |
|
AIT_INIT_VAL2(v, t); |
|
AIT_LEN(v) = l; |
|
AIT_IN(v) = 1; |
|
|
|
va_start(lst, l); |
|
switch (AIT_TYPE(v)) { |
|
case ptr: |
|
case buffer: |
|
case string: |
|
AIT_ADDR(v) = va_arg(lst, void*); |
|
break; |
|
default: |
|
AIT_RAW(v) = va_arg(lst, uint64_t); |
|
break; |
|
} |
|
va_end(lst); |
|
|
|
return 0; |
|
} |
|
|
|
/* |
|
* io_cmpVar() - Compare two variables |
|
* |
|
* @a = 1st variable |
|
* @b = 2nd variable |
|
* return: 0 is equal or !=0 is different |
|
*/ |
|
inline int |
|
io_cmpVar(ait_val_t * __restrict a, ait_val_t * __restrict b) |
|
{ |
|
intptr_t ret; |
|
|
|
if (!(ret = (a - b))) |
|
return ret; |
|
if ((ret = AIT_TYPE(a) - AIT_TYPE(b))) |
|
return ret; |
|
if ((ret = AIT_LEN(a) - AIT_LEN(b))) |
|
return ret; |
|
|
|
switch (AIT_TYPE(a)) { |
|
case buffer: |
|
ret = memcmp(AIT_GET_BUF(a), AIT_GET_BUF(b), AIT_LEN(a)); |
|
break; |
|
case string: |
|
ret = strncmp(AIT_GET_STR(a), AIT_GET_STR(b), AIT_LEN(a)); |
|
break; |
|
case data: |
|
ret = memcmp(AIT_GET_DATA(a), AIT_GET_DATA(b), AIT_LEN(a)); |
|
break; |
|
case ptr: |
|
ret = AIT_ADDR(a) - AIT_ADDR(b); |
|
break; |
|
default: |
|
ret = AIT_RAW(a) - AIT_RAW(b); |
|
break; |
|
} |
|
|
|
return (int) ret; |
|
} |