diff options
author | wens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-12-03 09:08:29 +0800 |
---|---|---|
committer | wens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-12-03 09:08:29 +0800 |
commit | 3655862b3fa51afaf5c01a2cfea600169f3cd609 (patch) | |
tree | 7e8aa3d8e50b25920d421f62d59eae06837b26f6 /include | |
parent | 5cefa8237ce2a2c2ad86d956a086c386fb013364 (diff) | |
download | pttbbs-3655862b3fa51afaf5c01a2cfea600169f3cd609.tar pttbbs-3655862b3fa51afaf5c01a2cfea600169f3cd609.tar.gz pttbbs-3655862b3fa51afaf5c01a2cfea600169f3cd609.tar.bz2 pttbbs-3655862b3fa51afaf5c01a2cfea600169f3cd609.tar.lz pttbbs-3655862b3fa51afaf5c01a2cfea600169f3cd609.tar.xz pttbbs-3655862b3fa51afaf5c01a2cfea600169f3cd609.tar.zst pttbbs-3655862b3fa51afaf5c01a2cfea600169f3cd609.zip |
changed money in fileheader_t into union
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2363 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'include')
-rw-r--r-- | include/osdep.h | 13 | ||||
-rw-r--r-- | include/pttstruct.h | 30 |
2 files changed, 40 insertions, 3 deletions
diff --git a/include/osdep.h b/include/osdep.h index 8e790595..84bd04fc 100644 --- a/include/osdep.h +++ b/include/osdep.h @@ -14,6 +14,12 @@ #define _XOPEN_SOURCE #define _ISOC99_SOURCE + + #if BYTE_ORDER == BIG_ENDIAN + #define _BIG_ENDIAN + #else + #define _LITTLE_ENDIAN + #endif #elif defined(__linux__) @@ -22,6 +28,13 @@ #include <sys/ioctl.h> #include <sys/file.h> /* for flock() */ #include <strings.h> /* for strcasecmp() */ + #include <endian.h> /* for __BYTE_ORDER */ + + #if __BYTE_ORDER == __BIG_ENDIAN + #define _BIG_ENDIAN + #else + #define _LITTLE_ENDIAN + #endif #define NEED_STRCASESTR #define NEED_STRLCPY diff --git a/include/pttstruct.h b/include/pttstruct.h index fcdb77bb..23979723 100644 --- a/include/pttstruct.h +++ b/include/pttstruct.h @@ -219,15 +219,39 @@ typedef struct boardheader_t { #define TTLEN 64 /* Length of title */ #define FNLEN 33 /* Length of filename */ -#define FHR_REFERENCE (1<<31) - typedef struct fileheader_t { char filename[FNLEN]; /* M.9876543210.A */ char recommend; /* important level */ char owner[IDLEN + 2]; /* uid[.] */ char date[6]; /* [02/02] or space(5) */ char title[TTLEN + 1]; - int money; /* rocker: if bit32 on ==> reference */ /* XXX dirty, split into flag and money if money of each file is less than 16bit? */ + union { + int money; + int anon_uid; + /* different order to match alignment */ +#ifdef _BIG_ENDIAN + struct { + unsigned char pad[2]; /* money & 0xffff0000 */ + unsigned char logins; /* money & 0xff00 */ + unsigned char posts; /* money & 0xff */ + } vote_limits; + struct { + unsigned int flag:1; + unsigned int ref:31; + } refer; +#else + struct { + unsigned char posts; /* money & 0xff */ + unsigned char logins; /* money & 0xff00 */ + unsigned char pad[2]; /* money & 0xffff0000 */ + } vote_limits; + struct { + unsigned int ref:31; + unsigned int flag:1; + } refer; +#endif + } multi; /* rocker: if bit32 on ==> reference */ + /* XXX dirty, split into flag and money if money of each file is less than 16bit? */ unsigned char filemode; /* must be last field @ boards.c */ } fileheader_t; |