1 #include "pack_private.h"
3 void BinIOPack(void *context, int type, int byte_order, int count)
5 struct BinIOPackContext *ctx = (struct BinIOPackContext*)context;
10 case BinIO_TYPE_IGNORE_BYTE:
17 uint8_t value = va_arg(ctx->args, int);
18 BinIOConvert1(BinIO_HOST_BYTE_ORDER, byte_order, (const uint8_t *)&value, ctx->buffer, 1);
22 case BinIO_TYPE_INT16:
24 uint16_t value = va_arg(ctx->args, int);
25 BinIOConvert2(BinIO_HOST_BYTE_ORDER, byte_order, (const uint8_t *)&value, ctx->buffer, 1);
29 case BinIO_TYPE_INT32:
31 int value = va_arg(ctx->args, int);
32 BinIOConvert4(BinIO_HOST_BYTE_ORDER, byte_order, (const uint8_t *)&value, ctx->buffer, 1);
36 case BinIO_TYPE_INT64:
38 uint64_t value = va_arg(ctx->args, uint64_t);
39 BinIOConvert8(BinIO_HOST_BYTE_ORDER, byte_order, (const uint8_t *)&value, ctx->buffer, 1);
43 case BinIO_TYPE_FLOAT32:
45 float32_t value = (float32_t)va_arg(ctx->args, double);
46 BinIOConvert4(BinIO_HOST_BYTE_ORDER, byte_order, (const uint8_t *)&value, ctx->buffer, 1);
50 case BinIO_TYPE_FLOAT64:
52 float64_t value = va_arg(ctx->args, float64_t);
53 BinIOConvert8(BinIO_HOST_BYTE_ORDER, byte_order, (const uint8_t *)&value, ctx->buffer, 1);
63 case BinIO_TYPE_IGNORE_BYTE: ctx->buffer += 1 * count; break;
64 case BinIO_TYPE_BYTE: BinIOConvert1(BinIO_HOST_BYTE_ORDER, byte_order, va_arg(ctx->args, uint8_t *), ctx->buffer, count); ctx->buffer += 1 * count; break;
65 case BinIO_TYPE_INT16: BinIOConvert2(BinIO_HOST_BYTE_ORDER, byte_order, va_arg(ctx->args, uint8_t *), ctx->buffer, count); ctx->buffer += 2 * count; break;
66 case BinIO_TYPE_INT32: BinIOConvert4(BinIO_HOST_BYTE_ORDER, byte_order, va_arg(ctx->args, uint8_t *), ctx->buffer, count); ctx->buffer += 4 * count; break;
67 case BinIO_TYPE_INT64: BinIOConvert8(BinIO_HOST_BYTE_ORDER, byte_order, va_arg(ctx->args, uint8_t *), ctx->buffer, count); ctx->buffer += 8 * count; break;
68 case BinIO_TYPE_FLOAT32: BinIOConvert4(BinIO_HOST_BYTE_ORDER, byte_order, va_arg(ctx->args, uint8_t *), ctx->buffer, count); ctx->buffer += 4 * count; break;
69 case BinIO_TYPE_FLOAT64: BinIOConvert8(BinIO_HOST_BYTE_ORDER, byte_order, va_arg(ctx->args, uint8_t *), ctx->buffer, count); ctx->buffer += 8 * count; break;