X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=byteorder.h;h=783e904c0432e6109dcf737b54ce15fa15acdcd9;hb=9c19f1c350c5d075a47a193c1b5b2d9f8fa41f04;hp=6071e53628796e9063736d940e6b53837676e271;hpb=42336b017ba010d03c1db3c28c8549e5d97a1cd9;p=debian%2Fgcpegg diff --git a/byteorder.h b/byteorder.h index 6071e53..783e904 100644 --- a/byteorder.h +++ b/byteorder.h @@ -12,25 +12,25 @@ on RISC machines which typically require values to be aligned at an even multiple of their length. */ -#define packShort(x) { \ - short s = htons((short) (x)); \ - memcpy(pktP, &s, sizeof(short)); \ - pktP += sizeof(short); \ +#define pack16(x) { \ + uint16 s = htons((uint16) (x)); \ + memcpy(pktP, &s, sizeof(uint16)); \ + pktP += sizeof(uint16); \ } -#define packLong(x) { \ - long l = htonl((long) (x)); \ - memcpy(pktP, &l, sizeof(long)); \ - pktP += sizeof(long); \ +#define pack32(x) { \ + uint32 i = htonl((uint32) (x)); \ + memcpy(pktP, &i, sizeof(uint32)); \ + pktP += sizeof(uint32); \ } -#define packByte(x) { \ +#define pack8(x) { \ char c = (x); \ memcpy(pktP, &c, sizeof(char)); \ pktP += sizeof(char); \ } -#define packBytes(x, n) { \ +#define pack8s(x, n) { \ memcpy(pktP, x, n); \ pktP += n; \ } @@ -40,25 +40,25 @@ pktP. Note that the argument of these macros must be an lvalue. */ -#define unpackShort(x) { \ - short s; \ - memcpy(&s, pktP, sizeof(short)); \ - pktP += sizeof(short); \ +#define unpack16(x) { \ + uint16 s; \ + memcpy(&s, pktP, sizeof(uint16)); \ + pktP += sizeof(uint16); \ x = ntohs(s); \ } -#define unpackLong(x) { \ - long l; \ - memcpy(&l, pktP, sizeof(long)); \ - pktP += sizeof(long); \ - x = ntohl(l); \ +#define unpack32(x) { \ + uint32 i; \ + memcpy(&i, pktP, sizeof(uint32)); \ + pktP += sizeof(uint32); \ + x = ntohl(i); \ } -#define unpackByte(x) { \ +#define unpack8(x) { \ *((char *) &x) = (char) *pktP++; \ } -#define unpackBytes(x, n) { \ +#define unpack8s(x, n) { \ memcpy(x, pktP, n); \ pktP += n; \ }