lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Thanks to Ignacio Castaño, I've extended and updated my pack library for
Lua 5.0:
	http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/lpack.tar.gz

This library packs and unpacks binary data in a way similar to what is
available in Perl.

I'm not completely happy with the format letter codes -- see below; I welcome
suggestions.

I plan to add suport to read from and write to Lua tables, if there's interest.

Enjoy.
--lhf

#define OP_ZSTRING      'z'             /* zero-terminated string */
#define OP_BSTRING      'p'             /* string preceded by length byte */
#define OP_WSTRING      'P'             /* string preceded by length word */
#define OP_SSTRING      'a'             /* string preceded by length size_t */
#define OP_STRING       'A'             /* string */
#define OP_FLOAT        'f'             /* float */
#define OP_DOUBLE       'd'             /* double */
#define OP_NUMBER       'n'             /* Lua number */
#define OP_CHAR         'c'             /* char */
#define OP_BYTE         'b'             /* byte = unsigned char */
#define OP_SHORT        'h'             /* short */
#define OP_USHORT       'H'             /* unsigned short */
#define OP_INT          'i'             /* int */
#define OP_UINT         'I'             /* unsigned int */
#define OP_LONG         'l'             /* long */
#define OP_ULONG        'L'             /* unsigned long */