removed use of nonstandard type BYTE and SIZEOF defines from tweak.h

This commit is contained in:
Radim Kolar 2009-09-22 23:56:05 +02:00
parent df13788e57
commit eed29b6cd2
3 changed files with 7 additions and 54 deletions

View File

@ -63,7 +63,7 @@ typedef struct { FILE *fp;
/* DIRLISTING holds open directory listings */ /* DIRLISTING holds open directory listings */
typedef struct { typedef struct {
BYTE *listing; /* pointer to directory listing */ int8_t *listing; /* pointer to directory listing */
size_t listing_size; /* how many bytes has listing? */ size_t listing_size; /* how many bytes has listing? */
time_t mtime; /* when cache was build */ time_t mtime; /* when cache was build */
} DIRLISTING; } DIRLISTING;

View File

@ -1,6 +1,7 @@
#ifndef _FSP_TWEAK_H_ #ifndef _FSP_TWEAK_H_
#define _FSP_TWEAK_H_ 1 #define _FSP_TWEAK_H_ 1
#include <sys/types.h>
#include <sysexits.h> #include <sysexits.h>
#ifndef HAVE_FSEEKO #ifndef HAVE_FSEEKO
@ -37,63 +38,15 @@
#endif #endif
#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. * Macros to read and write multi-byte fields from the message header.
****************************************************************************/ ****************************************************************************/
#if SIZEOF_SHORT == 2 #define BB_READ4(V) ntohl(*(const u_int32_t *)(V))
#define WORD_TYPE_2 unsigned short #define BB_WRITE4(V,A) *(u_int32_t *)(V) = htonl(A)
#else
#if SIZEOF_UNSIGNED == 2
#define WORD_TYPE_2 unsigned
#endif
#endif
#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 */ /* there is an integer type of size 2 */
#define BB_READ2(V) ntohs(*(WORD_TYPE_2 *)(V)) #define BB_READ2(V) ntohs(*(const u_int16_t *)(V))
#define BB_WRITE2(V,A) *(WORD_TYPE_2 *)(V) = htons(A) #define BB_WRITE2(V,A) *(u_int16_t *)(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
#endif /* _FSP_TWEAK_H_ */ #endif /* _FSP_TWEAK_H_ */

View File

@ -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 */ /* appends new packet to directory listing, return 0 on success */
static int append_dir_listing (DIRLISTING * dl,const char * buf,unsigned int size) static int append_dir_listing (DIRLISTING * dl,const char * buf,unsigned int size)
{ {
BYTE *newbuf; int8_t *newbuf;
/* append this buffer */ /* append this buffer */
newbuf=realloc(dl->listing,dl->listing_size+size); newbuf=realloc(dl->listing,dl->listing_size+size);