version 1.1.2.2, 2011/08/31 12:29:32
|
version 1.1.2.5, 2011/09/07 01:26:08
|
Line 54 SUCH DAMAGE.
|
Line 54 SUCH DAMAGE.
|
* 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_vals2buffer(u_char *buf, int buflen, array_t *vars) |
{ |
{ |
int Limit = 0; |
int Limit = 0; |
register int i; |
register int i; |
Line 63 io_vals2buffer(u_char **buf, int buflen, array_t *vars
|
Line 63 io_vals2buffer(u_char **buf, int buflen, array_t *vars
|
|
|
assert(buf); |
assert(buf); |
assert(vars); |
assert(vars); |
if (!buf || !vars || !*buf) | if (!buf || !vars) |
return -1; |
return -1; |
if (!buflen || !io_arraySize(vars)) |
if (!buflen || !io_arraySize(vars)) |
return 0; |
return 0; |
Line 74 io_vals2buffer(u_char **buf, int buflen, array_t *vars
|
Line 74 io_vals2buffer(u_char **buf, int buflen, array_t *vars
|
buflen, Limit); |
buflen, Limit); |
return -1; |
return -1; |
} else { |
} else { |
memset(*buf, 0, buflen); | memset(buf, 0, buflen); |
|
|
v = (ait_val_t*) *buf; | v = (ait_val_t*) buf; |
data = *buf + Limit; | data = buf + Limit; |
} |
} |
|
|
/* marshaling */ |
/* marshaling */ |
Line 112 io_vals2buffer(u_char **buf, int buflen, array_t *vars
|
Line 112 io_vals2buffer(u_char **buf, int buflen, array_t *vars
|
|
|
memcpy(data, val->val.buffer, AIT_LEN(val)); |
memcpy(data, val->val.buffer, AIT_LEN(val)); |
/* Debug:: data offset in packet, not matter for anything! */ |
/* Debug:: data offset in packet, not matter for anything! */ |
v[i].val.net = data - *buf; | v[i].val.net = data - buf; |
data += AIT_LEN(val); |
data += AIT_LEN(val); |
break; |
break; |
default: |
default: |
Line 175 io_buffer2vals(u_char *buf, int buflen, int vnum, int
|
Line 175 io_buffer2vals(u_char *buf, int buflen, int vnum, int
|
io_arraySet(vars, i, val); |
io_arraySet(vars, i, val); |
|
|
val->val_type = v[i].val_type; |
val->val_type = v[i].val_type; |
|
#if defined(__OpenBSD__) |
AIT_LEN(val) = betoh32(AIT_LEN(&v[i])); |
AIT_LEN(val) = betoh32(AIT_LEN(&v[i])); |
|
#else |
|
AIT_LEN(val) = be32toh(AIT_LEN(&v[i])); |
|
#endif |
|
|
switch (AIT_TYPE(val)) { |
switch (AIT_TYPE(val)) { |
case blob: |
case blob: |
Line 189 io_buffer2vals(u_char *buf, int buflen, int vnum, int
|
Line 193 io_buffer2vals(u_char *buf, int buflen, int vnum, int
|
case u16: |
case u16: |
case u32: |
case u32: |
case u64: |
case u64: |
|
#if defined(__OpenBSD__) |
val->val.net = betoh64(v[i].val.net); |
val->val.net = betoh64(v[i].val.net); |
|
#else |
|
val->val.net = be64toh(v[i].val.net); |
|
#endif |
break; |
break; |
case buffer: |
case buffer: |
case string: |
case string: |
Line 203 io_buffer2vals(u_char *buf, int buflen, int vnum, int
|
Line 211 io_buffer2vals(u_char *buf, int buflen, int vnum, int
|
} else |
} else |
Limit += AIT_LEN(val); |
Limit += AIT_LEN(val); |
|
|
if (!zcpy) | if (!zcpy) { |
memcpy(val->val.buffer, data, AIT_LEN(val)); | val->val.buffer = malloc(AIT_LEN(val)); |
else | if (!val->val.buffer) { |
| LOGERR; |
| io_arrayFree(vars); |
| io_arrayDestroy(&vars); |
| return NULL; |
| } else |
| memcpy(val->val.buffer, data, AIT_LEN(val)); |
| } else |
val->val.buffer = data; |
val->val.buffer = data; |
data += AIT_LEN(val); |
data += AIT_LEN(val); |
break; |
break; |