diff options
Diffstat (limited to 'unpack.c')
-rw-r--r-- | unpack.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -27,12 +27,12 @@ struct dest { size_t count; }; -static uintmax_t read_val(const unsigned char *buf, size_t size, enum pack_endian e) +static uintmax_t read_val(const unsigned char *src, size_t size, enum pack_endian e) { uintmax_t val = 0; for (size_t i = 0; i < size; i++) { - val |= (uintmax_t)(buf[i] & 0xff) << (e == PACK_ENDIAN_LITTLE ? i : size - i - 1) * 8; + val |= (uintmax_t)(src[i] & 0xff) << (e == PACK_ENDIAN_LITTLE ? i : size - i - 1) * 8; } return val; @@ -100,15 +100,15 @@ static void read_fields(struct dest dest, const void *src_, enum pack_endian end } } -enum pack_status unpack(const void *buf_, size_t size, const char *fmt, ...) +enum pack_status unpack(const void *src_, size_t size, const char *fmt, ...) { enum pack_endian endianness = PACK_ENDIAN_BIG; - const unsigned char *buf = buf_; + const unsigned char *src = src_; enum pack_status ret = PACK_OK; size_t offset = 0; va_list ap; - tr_call("unpack(%p, %" PRIuSIZE ", %s, ...)", (const void *)buf, size, fmt); + tr_call("unpack(%p, %" PRIuSIZE ", %s, ...)", (const void *)src, size, fmt); va_start(ap, fmt); @@ -155,7 +155,7 @@ enum pack_status unpack(const void *buf_, size_t size, const char *fmt, ...) SET_AND_GOTO(ret, PACK_TOOSMALL, stop); if (dest.type != PACK_TYPE_PADDING) - read_fields(dest, &buf[offset], endianness); + read_fields(dest, &src[offset], endianness); offset += s * dest.count; } @@ -166,15 +166,15 @@ stop: return ret; } -enum pack_status unpack_struct(const void *buf_, size_t size, +enum pack_status unpack_struct(const void *src_, size_t size, const struct pack_args *args, void *dest_) { - const unsigned char *buf = buf_; + const unsigned char *src = src_; char *dest = dest_; size_t offset = 0; tr_call("unpack_struct(%p, %" PRIuSIZE ", %p, %p)", \ - (const void *)buf, size, (const void *)args, (const void *)dest); + (const void *)src, size, (const void *)args, (const void *)dest); tr_debug("args->endian: %s, args->fields: %p, args->num_fields: %" PRIuSIZE, args->endian == PACK_ENDIAN_BIG ? "big" : "little", @@ -217,7 +217,7 @@ enum pack_status unpack_struct(const void *buf_, size_t size, if (size - offset < s * field.count) return PACK_TOOSMALL; if (f->type != PACK_TYPE_PADDING) - read_fields(field, &buf[offset], args->endian); + read_fields(field, &src[offset], args->endian); offset += s * field.count; #undef FIELD |