|
version 1.2.2.1, 2011/11/03 14:17:39
|
version 1.4.4.1, 2012/03/27 20:53:37
|
|
Line 12 terms:
|
Line 12 terms:
|
| All of the documentation and software included in the ELWIX and AITNET |
All of the documentation and software included in the ELWIX and AITNET |
| Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
| |
|
| Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 | Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 |
| by Michael Pounov <misho@elwix.org>. All rights reserved. |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
| |
|
| Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
|
Line 47 SUCH DAMAGE.
|
Line 47 SUCH DAMAGE.
|
| |
|
| |
|
| /* |
/* |
| * io_vals2buffer() Marshaling data from array with variables to buffer | * io_vars2buffer() Marshaling data from array with variables to buffer |
| * @buf = Buffer |
* @buf = Buffer |
| * @buflen = Size of buffer |
* @buflen = Size of buffer |
| * @vars = Variable array |
* @vars = Variable array |
| * return: -1 error, 0 nothing done or >0 size of marshaled data |
* return: -1 error, 0 nothing done or >0 size of marshaled data |
| */ |
*/ |
| int |
int |
| io_vals2buffer(u_char *buf, int buflen, array_t *vars) | io_vars2buffer(u_char *buf, int buflen, array_t *vars) |
| { |
{ |
| int Limit = 0; |
int Limit = 0; |
| register int i; |
register int i; |
|
Line 126 io_vals2buffer(u_char *buf, int buflen, array_t *vars)
|
Line 126 io_vals2buffer(u_char *buf, int buflen, array_t *vars)
|
| } |
} |
| |
|
| /* |
/* |
| * io_buffer2vals() De-marshaling data from buffer to array with variables | * io_buffer2vars() De-marshaling data from buffer to array with variables |
| * @buf = Buffer |
* @buf = Buffer |
| * @buflen = Size of buffer |
* @buflen = Size of buffer |
| * @vnum = Number of variables into buffer |
* @vnum = Number of variables into buffer |
|
Line 135 io_vals2buffer(u_char *buf, int buflen, array_t *vars)
|
Line 135 io_vals2buffer(u_char *buf, int buflen, array_t *vars)
|
| * return: =NULL error, !=NULL allocated variable array, after use must free with io_arrayDestroy() |
* return: =NULL error, !=NULL allocated variable array, after use must free with io_arrayDestroy() |
| */ |
*/ |
| array_t * |
array_t * |
| io_buffer2vals(u_char *buf, int buflen, int vnum, int zcpy) | io_buffer2vars(u_char *buf, int buflen, int vnum, int zcpy) |
| { |
{ |
| array_t *vars; |
array_t *vars; |
| int Limit = 0; |
int Limit = 0; |
|
Line 240 io_buffer2vals(u_char *buf, int buflen, int vnum, int
|
Line 240 io_buffer2vals(u_char *buf, int buflen, int vnum, int
|
| /* buffer marshaling without swapping bytes to network order */ |
/* buffer marshaling without swapping bytes to network order */ |
| |
|
| /* |
/* |
| * io_vals2map() Marshaling data from array with variables to memory map | * io_vars2map() Marshaling data from array with variables to memory map |
| * @buf = Buffer |
* @buf = Buffer |
| * @buflen = Size of buffer |
* @buflen = Size of buffer |
| * @vars = Variable array |
* @vars = Variable array |
| * return: -1 error, 0 nothing done or >0 size of marshaled data |
* return: -1 error, 0 nothing done or >0 size of marshaled data |
| */ |
*/ |
| int |
int |
| io_vals2map(u_char *buf, int buflen, array_t *vars) | io_vars2map(u_char *buf, int buflen, array_t *vars) |
| { |
{ |
| int Limit = 0; |
int Limit = 0; |
| register int i; |
register int i; |
|
Line 319 io_vals2map(u_char *buf, int buflen, array_t *vars)
|
Line 319 io_vals2map(u_char *buf, int buflen, array_t *vars)
|
| } |
} |
| |
|
| /* |
/* |
| * io_map2vals() De-marshaling data from memory map to array with variables | * io_map2vars() De-marshaling data from memory map to array with variables |
| * @buf = Buffer |
* @buf = Buffer |
| * @buflen = Size of buffer |
* @buflen = Size of buffer |
| * @vnum = Number of variables into buffer |
* @vnum = Number of variables into buffer |
|
Line 328 io_vals2map(u_char *buf, int buflen, array_t *vars)
|
Line 328 io_vals2map(u_char *buf, int buflen, array_t *vars)
|
| * return: =NULL error, !=NULL allocated variable array, after use must free with io_arrayDestroy() |
* return: =NULL error, !=NULL allocated variable array, after use must free with io_arrayDestroy() |
| */ |
*/ |
| array_t * |
array_t * |
| io_map2vals(u_char *buf, int buflen, int vnum, int zcpy) | io_map2vars(u_char *buf, int buflen, int vnum, int zcpy) |
| { |
{ |
| array_t *vars; |
array_t *vars; |
| int Limit = 0; |
int Limit = 0; |
|
Line 429 io_map2vals(u_char *buf, int buflen, int vnum, int zcp
|
Line 429 io_map2vals(u_char *buf, int buflen, int vnum, int zcp
|
| * return: =NULL error or !=NULL allocated array |
* return: =NULL error or !=NULL allocated array |
| */ |
*/ |
| inline array_t * |
inline array_t * |
| io_allocVars(u_int varnum) | io_allocVars(int varnum) |
| { |
{ |
| array_t *arr; |
array_t *arr; |
| register int i; |
register int i; |
|
Line 454 io_allocVars(u_int varnum)
|
Line 454 io_allocVars(u_int varnum)
|
| } |
} |
| |
|
| /* |
/* |
| |
* io_clrVars() Clear ait_val_t elements from array |
| |
* @vars = Variable array |
| |
* return: -1 error or size of array |
| |
*/ |
| |
inline int |
| |
io_clrVars(array_t * __restrict vars) |
| |
{ |
| |
register int i; |
| |
|
| |
if (!vars) |
| |
return -1; |
| |
|
| |
for (i = 0; i < io_arraySize(vars); i++) |
| |
if (io_arrayGet(vars, i)) |
| |
AIT_FREE_VAL(io_array(vars, i, ait_val_t*)); |
| |
|
| |
return io_arraySize(vars); |
| |
} |
| |
|
| |
/* |
| * io_freeVars() Free ait_val_t array |
* io_freeVars() Free ait_val_t array |
| * @vars = Variable array |
* @vars = Variable array |
| * return: none |
* return: none |
|
Line 461 io_allocVars(u_int varnum)
|
Line 481 io_allocVars(u_int varnum)
|
| inline void |
inline void |
| io_freeVars(array_t ** __restrict vars) |
io_freeVars(array_t ** __restrict vars) |
| { |
{ |
| register int i; |
|
| |
|
| if (!vars || !*vars) |
if (!vars || !*vars) |
| return; |
return; |
| |
|
| for (i = 0; i < io_arraySize(*vars); i++) | io_clrVars(*vars); |
| if (io_arrayGet(*vars, i)) | |
| AIT_FREE_VAL(io_array(*vars, i, ait_val_t*)); | |
| |
| io_arrayFree(*vars); |
io_arrayFree(*vars); |
| io_arrayDestroy(vars); |
io_arrayDestroy(vars); |
| |
} |
| |
|
| |
/* |
| |
* io_allocVar() Allocate memory for variable |
| |
* return: NULL error or new variable, after use free variable with io_freeVar() |
| |
*/ |
| |
inline ait_val_t * |
| |
io_allocVar(void) |
| |
{ |
| |
ait_val_t *v = NULL; |
| |
|
| |
v = malloc(sizeof(ait_val_t)); |
| |
if (!v) { |
| |
LOGERR; |
| |
return NULL; |
| |
} else |
| |
memset(v, 0, sizeof(ait_val_t)); |
| |
v->val_type = empty; |
| |
|
| |
return v; |
| |
} |
| |
|
| |
/* |
| |
* io_freeVar() Free allocated memory for variable |
| |
* @val = Variable |
| |
* return: none |
| |
*/ |
| |
inline void |
| |
io_freeVar(ait_val_t * __restrict val) |
| |
{ |
| |
if (val) { |
| |
AIT_FREE_VAL(val); |
| |
free(val); |
| |
val = NULL; |
| |
} |
| } |
} |