From eed29b6cd28bf11d810fa0722bcf42c80c10c426 Mon Sep 17 00:00:00 2001 From: Radim Kolar <> Date: Tue, 22 Sep 2009 23:56:05 +0200 Subject: [PATCH] removed use of nonstandard type BYTE and SIZEOF defines from tweak.h --- include/server_def.h | 2 +- include/tweak.h | 57 ++++---------------------------------------- server/file.c | 2 +- 3 files changed, 7 insertions(+), 54 deletions(-) diff --git a/include/server_def.h b/include/server_def.h index c3ec64c..d2667da 100644 --- a/include/server_def.h +++ b/include/server_def.h @@ -63,7 +63,7 @@ typedef struct { FILE *fp; /* DIRLISTING holds open directory listings */ typedef struct { - BYTE *listing; /* pointer to directory listing */ + int8_t *listing; /* pointer to directory listing */ size_t listing_size; /* how many bytes has listing? */ time_t mtime; /* when cache was build */ } DIRLISTING; diff --git a/include/tweak.h b/include/tweak.h index d951622..036a2bd 100644 --- a/include/tweak.h +++ b/include/tweak.h @@ -1,6 +1,7 @@ #ifndef _FSP_TWEAK_H_ #define _FSP_TWEAK_H_ 1 +#include #include #ifndef HAVE_FSEEKO @@ -37,63 +38,15 @@ #endif #endif -#if !defined(BYTE) - #if SIZEOF_CHAR == 1 - #define BYTE char - #elif SIZEOF_VOID == 1 - #define BYTE void - #else - #error "Need 1 byte wide type" - #endif -#endif /**************************************************************************** * Macros to read and write multi-byte fields from the message header. ****************************************************************************/ -#if SIZEOF_SHORT == 2 -#define WORD_TYPE_2 unsigned short -#else -#if SIZEOF_UNSIGNED == 2 -#define WORD_TYPE_2 unsigned -#endif -#endif +#define BB_READ4(V) ntohl(*(const u_int32_t *)(V)) +#define BB_WRITE4(V,A) *(u_int32_t *)(V) = htonl(A) -#if SIZEOF_LONG == 4 -#define WORD_TYPE_4 unsigned long -#else -#if SIZEOF_UNSIGNED == 4 -#define WORD_TYPE_4 unsigned -#endif -#endif - -#ifdef WORD_TYPE_4 -/* there is an integer type of size 4 */ -#define BB_READ4(V) ntohl(*(const WORD_TYPE_4 *)(V)) -#define BB_WRITE4(V,A) *(WORD_TYPE_4 *)(V) = htonl(A) -#else -/* there is no integer type of size 4 */ -#define BB_READ4(V) ((((V)[0] << 24) & 0xff000000) + \ - (((V)[1] << 16) & 0x00ff0000) + \ - (((V)[2] << 8) & 0x0000ff00) + \ - (((V)[3] ) & 0x000000ff)) - -#define BB_WRITE4(V,A) ((V)[0] = ((A) >> 24) & 0xff, \ - (V)[1] = ((A) >> 16) & 0xff, \ - (V)[2] = ((A) >> 8) & 0xff, \ - (V)[3] = ((A) ) & 0xff) -#endif - -#ifdef WORD_TYPE_2 /* there is an integer type of size 2 */ -#define BB_READ2(V) ntohs(*(WORD_TYPE_2 *)(V)) -#define BB_WRITE2(V,A) *(WORD_TYPE_2 *)(V) = htons(A) -#else -/* there is no integer type of size 2 */ -#define BB_READ2(V) ((((V)[0] << 8) & 0xff00) + \ - (((V)[1] ) & 0x00ff)) - -#define BB_WRITE2(V,A) ((V)[0] = ((A) >> 8) & 0xff, \ - (V)[1] = ((A) ) & 0xff) -#endif +#define BB_READ2(V) ntohs(*(const u_int16_t *)(V)) +#define BB_WRITE2(V,A) *(u_int16_t *)(V) = htons(A) #endif /* _FSP_TWEAK_H_ */ diff --git a/server/file.c b/server/file.c index ec28602..f3ce18a 100644 --- a/server/file.c +++ b/server/file.c @@ -375,7 +375,7 @@ static const char *copy_file (const char * n1, const char * n2) /* appends new packet to directory listing, return 0 on success */ static int append_dir_listing (DIRLISTING * dl,const char * buf,unsigned int size) { - BYTE *newbuf; + int8_t *newbuf; /* append this buffer */ newbuf=realloc(dl->listing,dl->listing_size+size);