X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2Fbinio.h;h=c67ad584862125a51a53d5c92e8989d7d1246678;hb=24004d6ab1e68faaf85ece11b566449997da5013;hp=71016ed9f044eedfa09b569dfa419c2ec212cae5;hpb=1eec4500c708d0619abf36759454f59fa175cacf;p=lugaru.git diff --git a/Source/binio.h b/Source/binio.h index 71016ed..c67ad58 100644 --- a/Source/binio.h +++ b/Source/binio.h @@ -10,7 +10,7 @@ of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -29,90 +29,89 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern "C" { #endif - /* - Notes on format of format strings: - * whitespace is ignored - * each "group" consists of an optional count (defaults to 1), - an optional byte-order marker (defaults to H, "host-native"), - and a data-type specifier. - * when unpacking, each variable argument is a pointer to the - appropriate number of objects of the appropriate type. - * when packing, each variable argument is an object of the - appropriate type if the count is omitted, or a pointer to the - appropriate number of objects of the appropriate type if the - count is specified. - * the buffer supplied to pack/unpack must be of sufficient length - to hold all the data, or the behavior is unspecified. - * the file provided to the "f" versions of the functions must be - open in the appropriate mode, or the behavior is unspecified. - * the file supplied to funpackf must be of sufficient length to - hold all the data, or the behavior is unspecified. - * the behavior of all functions is unspecified if the format string - is incorrectly-formed. - - Data-type specifiers: - x skipped byte; no corresponding argument - b byte - s two-byte two's-complement integer - i four-byte two's-complement integer - l eight-byte two's-complement integer - f four-byte IEEE754 float - d eight-byte IEEE754 double - - Byte-order specifiers: - L little-endian - B big-endian - H host's native byte order - N network byte order - */ + /* + Notes on format of format strings: + * whitespace is ignored + * each "group" consists of an optional count (defaults to 1), + an optional byte-order marker (defaults to H, "host-native"), + and a data-type specifier. + * when unpacking, each variable argument is a pointer to the + appropriate number of objects of the appropriate type. + * when packing, each variable argument is an object of the + appropriate type if the count is omitted, or a pointer to the + appropriate number of objects of the appropriate type if the + count is specified. + * the buffer supplied to pack/unpack must be of sufficient length + to hold all the data, or the behavior is unspecified. + * the file provided to the "f" versions of the functions must be + open in the appropriate mode, or the behavior is unspecified. + * the file supplied to funpackf must be of sufficient length to + hold all the data, or the behavior is unspecified. + * the behavior of all functions is unspecified if the format string + is incorrectly-formed. + + Data-type specifiers: + x skipped byte; no corresponding argument + b byte + s two-byte two's-complement integer + i four-byte two's-complement integer + l eight-byte two's-complement integer + f four-byte IEEE754 float + d eight-byte IEEE754 double + + Byte-order specifiers: + L little-endian + B big-endian + H host's native byte order + N network byte order + */ #ifndef ALREADY_DID_BINIO_STDINT #define ALREADY_DID_BINIO_STDINT #if defined(BinIO_STDINT_HEADER) #include BinIO_STDINT_HEADER - typedef float float32_t; - typedef double float64_t; + typedef float float32_t; + typedef double float64_t; #else - typedef unsigned char uint8_t; - typedef unsigned short uint16_t; - typedef unsigned long uint32_t; + typedef unsigned char uint8_t; + typedef unsigned short uint16_t; + typedef unsigned long uint32_t; #ifdef WIN32 - typedef unsigned __int64 uint64_t; + typedef unsigned __int64 uint64_t; #else - typedef unsigned long long uint64_t; + typedef unsigned long long uint64_t; #endif - typedef float float32_t; - typedef double float64_t; + typedef float float32_t; + typedef double float64_t; #endif #endif - typedef struct - { - float64_t d; - uint64_t l; - int i; - float32_t f; - uint16_t s; - uint8_t b; - } - test_data; - - extern void packf ( const char *format, ...); - extern void spackf (void *buffer, const char *format, ...); - extern void fpackf (FILE *file, const char *format, ...); - extern void vspackf (void *buffer, const char *format, va_list args); - extern void vfpackf (FILE *file, const char *format, va_list args); - - extern void unpackf ( const char *format, ...); - extern void sunpackf (const void *buffer, const char *format, ...); - extern void funpackf (FILE *file, const char *format, ...); - extern void vsunpackf(const void *buffer, const char *format, va_list args); - extern void vfunpackf(FILE *file, const char *format, va_list args); + typedef struct { + float64_t d; + uint64_t l; + int i; + float32_t f; + uint16_t s; + uint8_t b; + } + test_data; + + extern void packf ( const char *format, ...); + extern void spackf (void *buffer, const char *format, ...); + extern void fpackf (FILE *file, const char *format, ...); + extern void vspackf (void *buffer, const char *format, va_list args); + extern void vfpackf (FILE *file, const char *format, va_list args); + + extern void unpackf ( const char *format, ...); + extern void sunpackf (const void *buffer, const char *format, ...); + extern void funpackf (FILE *file, const char *format, ...); + extern void vsunpackf(const void *buffer, const char *format, va_list args); + extern void vfunpackf(FILE *file, const char *format, va_list args); #ifdef _MSC_VER - #ifndef va_copy - #define va_copy(dest,src) do { dest = src; } while (0) - #endif +#ifndef va_copy +#define va_copy(dest,src) do { dest = src; } while (0) +#endif #endif #if defined(__cplusplus)