3 * @author Nicolas VIVIEN
6 * @note CopyRight Nicolas VIVIEN
8 * @brief COD debug file parser
11 * - 2009/08/01 : N. VIVIEN
15 * Copyright (C) 2009-2010, Nicolas VIVIEN
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
26 * See the GNU General Public License in the COPYING file at the
27 * root directory of this project for more details.
31 #ifndef __BARRYJDG_PARSER_H__
32 #define __BARRYJDG_PARSER_H__
42 // The following is a byteswap.h replacement, for systems like Mac OS X.
43 // It was taken from a patch to the GPL software cowpatty, patch
45 // http://www.netstumbler.org/showpost.php?s=79764fd1526e4653d5cb4432225da6ee&p=190494&postcount=29
47 //#warning "byteswap.h is an unportable GNU extension! Don't use!"
49 static inline unsigned short bswap_16(unsigned short x
) {
50 return (x
>>8) | (x
<<8);
53 static inline unsigned int bswap_32(unsigned int x
) {
54 return (bswap_16(x
&0xffff)<<16) | (bswap_16(x
>>16));
57 static inline uint64_t bswap_64(uint64_t x
) {
58 return (((uint64_t)bswap_32(x
&0xffffffffull
))<<32) | (bswap_32(x
>>32));
61 #ifndef WORDS_BIGENDIAN
63 // For when Blackberry needs big endian (often in JavaLoader protocol)
64 #define be_btohs(x) bswap_16(x) // for uint16_t
65 #define be_btohl(x) bswap_32(x) // for uint32_t
66 #define be_btohll(x) bswap_64(x) // for uint64_t
67 #define be_htobs(x) bswap_16(x) // for uint16_t
68 #define be_htobl(x) bswap_32(x) // for uint32_t
69 #define be_htobll(x) bswap_64(x) // for uint64_t
73 // For when Blackberry needs big endian (often in JavaLoader protocol)
74 #define be_btohs(x) x // for uint16_t
75 #define be_btohl(x) x // for uint32_t
76 #define be_btohll(x) x // for uint64_t
77 #define be_htobs(x) x // for uint16_t
78 #define be_htobl(x) x // for uint32_t
79 #define be_htobll(x) x // for uint64_t
84 std::string
ParseString(std::istream
&input
, const int length
);
85 uint32_t ParseInteger(std::istream
&input
);