diff options
author | Tomasz Kramkowski <tk@the-tk.com> | 2021-08-08 04:34:55 +0100 |
---|---|---|
committer | Tomasz Kramkowski <tk@the-tk.com> | 2021-08-08 05:01:00 +0100 |
commit | 7b213a99c973f16d0150c42dbd5dba1c95180982 (patch) | |
tree | 01a371d43109791130a470221f9c540b3ccd047d | |
parent | bd0969cb8af8b1e34931e06489de0343bbfa9a69 (diff) | |
download | pack-7b213a99c973f16d0150c42dbd5dba1c95180982.tar.gz pack-7b213a99c973f16d0150c42dbd5dba1c95180982.tar.xz pack-7b213a99c973f16d0150c42dbd5dba1c95180982.zip |
add the PACK_TYPE_COUNT pack_type
-rw-r--r-- | pack.h | 1 | ||||
-rw-r--r-- | unpack.c | 3 |
2 files changed, 3 insertions, 1 deletions
@@ -34,6 +34,7 @@ enum pack_type { PACK_TYPE_FLOAT = 'f', PACK_TYPE_DOUBLE = 'd', PACK_TYPE_PADDING = 'x', + PACK_TYPE_COUNT = '*', }; enum pack_endian { @@ -95,6 +95,7 @@ static void read_fields(struct dest dest, const void *src_, enum pack_endian end case PACK_TYPE_FLOAT: dest.ptr.f[i] = val.f; break; case PACK_TYPE_DOUBLE: dest.ptr.d[i] = val.d; break; case PACK_TYPE_PADDING: break; + case PACK_TYPE_COUNT: return; } } } @@ -125,7 +126,7 @@ enum pack_status unpack(const void *buf_, size_t size, const char *fmt, ...) SET_AND_GOTO(ret, PACK_FMTINVAL, stop); dest.count = c; i += end - &fmt[i]; - } else if (fmt[i] == '*') { + } else if (fmt[i] == PACK_TYPE_COUNT) { dest.count = va_arg(ap, size_t); i++; } |