5 #include "unpack_private.h"
7 void unpackf(const char *format, ...)
10 va_start(args, format);
11 vfunpackf(stdin, format, args);
15 void sunpackf(const void *buffer, const char *format, ...)
18 va_start(args, format);
19 vsunpackf(buffer, format, args);
23 void funpackf(FILE *file, const char *format, ...)
26 va_start(args, format);
27 vfunpackf(file, format, args);
31 void vsunpackf(const void *buffer, const char *format, va_list args)
33 struct BinIOFormatCursor cursor;
34 struct BinIOUnpackContext context;
36 BinIOInitFormatCursor(&cursor, format);
38 context.data = (const unsigned char*)buffer;
41 while (BinIONextChar(&context, &cursor, BinIOUnpack)) {}
44 void vfunpackf(FILE *file, const char *format, va_list args)
46 size_t n_bytes = BinIOFormatByteCount(format);
47 void* buffer = malloc(n_bytes);
48 fread(buffer, n_bytes, 1, file);
50 vsunpackf(buffer, format, args);