Mercurial > code
diff pack.h @ 161:81d64d4a5473
Complete rewrite of pack.c:
o more concise,
o for buffer, available in autoallocation and static,
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 03 Sep 2012 21:21:33 +0200 |
parents | c7ad101ed4a1 |
children | 3e63d94b495f |
line wrap: on
line diff
--- a/pack.h Fri Aug 03 17:50:46 2012 +0200 +++ b/pack.h Mon Sep 03 21:21:33 2012 +0200 @@ -20,11 +20,9 @@ #define _PACK_H_ #include <stdarg.h> -#include <stdint.h> -#ifdef __cplusplus -extern "C" { -#endif +#define PACK_LE 1234 +#define PACK_BE 4321 /* * Endian detection based on SDL_endian.h @@ -32,9 +30,6 @@ #undef PACK_HOST_BYTEORDER -#define PACK_LE 1234 -#define PACK_BE 4321 - #if defined(__hppa__) || \ defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ (defined(__MIPS__) && defined(__MISPEB__)) || \ @@ -53,29 +48,24 @@ | (((x) << 8) & 0x00FF0000L) \ | (((x) << 24) & 0xFF000000L)) -#define pack_swap64(x) (((uint64_t) \ - ((uint32_t) pack_swap32((uint32_t) (((x) << 32) >> 32))) << 32) \ - | (uint32_t) pack_swap32((uint32_t) ((x) >> 32))) - -size_t pack_fmtlen(const char *, ...); -size_t pack_vfmtlen(const char *, va_list); +#define pack_swap64(x) (((long) \ + ((int) pack_swap32((int) (((x) << 32) >> 32))) << 32) \ + | (int) pack_swap32((int) ((x) >> 32))) -int pack_swrite(int, uint8_t **, size_t *, const char *, ...); -int pack_vswrite(int, uint8_t **, size_t *, const char *, va_list); -int pack_write(int, const char *, const char *, ...); -int pack_vwrite(int, const char *, const char *, va_list); -int pack_fwrite(int, FILE *, const char *, ...); -int pack_vfwrite(int, FILE *, const char *, va_list); +long pack_write(short, const char *, const char *, ...); +long pack_vwrite(short, const char *, const char *, va_list); +long pack_fwrite(short, FILE *, const char *, ...); +long pack_vfwrite(short, FILE *, const char *, va_list); +long pack_swrite(short, char *, size_t, const char *, ...); +long pack_vswrite(short, char *, size_t, const char *, va_list); +long pack_aswrite(short, char **, const char *, ...); +long pack_vaswrite(short, char **, const char *, va_list); -int pack_sread(int, uint8_t *, size_t, const char *, ...); -int pack_vsread(int, uint8_t *, size_t, const char *, va_list); -int pack_read(int, const char *, const char *, ...); -int pack_vread(int, const char *, const char *, va_list); -int pack_fread(int, FILE *, const char *, ...); -int pack_vfread(int, FILE *, const char *, va_list); - -#ifdef __cplusplus -} -#endif +long pack_read(short, const char *, const char *, ...); +long pack_vread(short, const char *, const char *, va_list); +long pack_fread(short, FILE *, const char *, ...); +long pack_vfread(short, FILE *, const char *, va_list); +long pack_sread(short, const char *, size_t, const char *, ...); +long pack_vsread(short, const char *, size_t, const char *, va_list); #endif /* _PACK_H_ */