diff --git a/CMakeLists.txt b/CMakeLists.txt index ea3b4c9..a69a6a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,14 @@ include(VersionString) # Find required libraries +# Win32 API +if(WIN32) + # Ensure we aren't using functionalities not found under Window XP SP1 + add_definitions(-D_WIN32_WINNT=0x0502) + add_definitions(-DNOMINMAX) + add_definitions(-DWIN32_LEAN_AND_MEAN) +endif() + if(USE_STATIC_LIBS) add_cxxflag("-static-libgcc") add_cxxflag("-static-libstdc++") @@ -131,7 +139,7 @@ if(NOT INNOEXTRACT_HAVE_TIMEGM) endif() check_symbol_exists(gmtime_r "time.h" INNOEXTRACT_HAVE_GMTIME_R) if(NOT INNOEXTRACT_HAVE_GMTIME_R) - check_symbol_exists(_gmtime_s "time.h" INNOEXTRACT_HAVE_GMTIME_S) + check_symbol_exists(gmtime_s "time.h" INNOEXTRACT_HAVE_GMTIME_S) endif() if(NOT WIN32) check_symbol_exists(utimensat "sys/stat.h" INNOEXTRACT_HAVE_UTIMENSAT) diff --git a/src/cli/debug.cpp b/src/cli/debug.cpp index ed4c028..c3d198f 100644 --- a/src/cli/debug.cpp +++ b/src/cli/debug.cpp @@ -219,7 +219,7 @@ static void print_entry(const setup::info & info, size_t i, const setup::file_en } else { cout << " - " << quoted(entry.destination); } - if(entry.location != uint32_t(-1)) { + if(entry.location != boost::uint32_t(-1)) { cout << " (location: " << color::cyan << entry.location << color::reset << ')'; } cout << '\n'; diff --git a/src/cli/main.cpp b/src/cli/main.cpp index b4ef370..51a4a09 100644 --- a/src/cli/main.cpp +++ b/src/cli/main.cpp @@ -190,7 +190,7 @@ static void process_file(const fs::path & file, const options & o) { } #endif - uint64_t total_size = 0; + boost::uint64_t total_size = 0; std::vector< std::vector > files_for_location; files_for_location.resize(info.data_entries.size()); @@ -235,7 +235,7 @@ static void process_file(const fs::path & file, const options & o) { chunk_source = stream::chunk_reader::get(*slice_reader, chunk.first); } - uint64_t offset = 0; + boost::uint64_t offset = 0; BOOST_FOREACH(const Files::value_type & location, chunk.second) { const stream::file & file = location.first; @@ -351,7 +351,7 @@ static void process_file(const fs::path & file, const options & o) { + out.name.string() + '"'); } } - extract_progress.update(uint64_t(n)); + extract_progress.update(boost::uint64_t(n)); } } diff --git a/src/crypto/adler32.cpp b/src/crypto/adler32.cpp index ce7e518..71a0021 100644 --- a/src/crypto/adler32.cpp +++ b/src/crypto/adler32.cpp @@ -27,15 +27,15 @@ namespace crypto { void adler32::update(const char * input, size_t length) { - const uint_fast32_t base = 65521; + const boost::uint_fast32_t base = 65521; - uint_fast32_t s1 = this->s1; - uint_fast32_t s2 = this->s2; + boost::uint_fast32_t s1 = this->s1; + boost::uint_fast32_t s2 = this->s2; if(length % 8 != 0) { do { - s1 += uint8_t(*input++); + s1 += boost::uint8_t(*input++); s2 += s1; length--; } while(length % 8 != 0); @@ -49,14 +49,14 @@ void adler32::update(const char * input, size_t length) { while(length > 0) { - s1 += uint8_t(input[0]), s2 += s1; - s1 += uint8_t(input[1]), s2 += s1; - s1 += uint8_t(input[2]), s2 += s1; - s1 += uint8_t(input[3]), s2 += s1; - s1 += uint8_t(input[4]), s2 += s1; - s1 += uint8_t(input[5]), s2 += s1; - s1 += uint8_t(input[6]), s2 += s1; - s1 += uint8_t(input[7]), s2 += s1; + s1 += boost::uint8_t(input[0]), s2 += s1; + s1 += boost::uint8_t(input[1]), s2 += s1; + s1 += boost::uint8_t(input[2]), s2 += s1; + s1 += boost::uint8_t(input[3]), s2 += s1; + s1 += boost::uint8_t(input[4]), s2 += s1; + s1 += boost::uint8_t(input[5]), s2 += s1; + s1 += boost::uint8_t(input[6]), s2 += s1; + s1 += boost::uint8_t(input[7]), s2 += s1; length -= 8; input += 8; @@ -70,8 +70,8 @@ void adler32::update(const char * input, size_t length) { } } - this->s1 = uint16_t(s1); - this->s2 = uint16_t(s2); + this->s1 = boost::uint16_t(s1); + this->s2 = boost::uint16_t(s2); } } // namespace crypto diff --git a/src/crypto/adler32.hpp b/src/crypto/adler32.hpp index 27fac23..fd72e6a 100644 --- a/src/crypto/adler32.hpp +++ b/src/crypto/adler32.hpp @@ -22,7 +22,8 @@ #define INNOEXTRACT_CRYPTO_ADLER32_HPP #include -#include + +#include #include "crypto/checksum.hpp" @@ -35,11 +36,11 @@ struct adler32 : public checksum_base { void update(const char * data, size_t length); - uint32_t finalize() const { return (uint32_t(s2) << 16) | s1; } + boost::uint32_t finalize() const { return (boost::uint32_t(s2) << 16) | s1; } private: - uint16_t s1, s2; + boost::uint16_t s1, s2; }; } // namespace crypto diff --git a/src/crypto/checksum.cpp b/src/crypto/checksum.cpp index cae488a..0057bbb 100644 --- a/src/crypto/checksum.cpp +++ b/src/crypto/checksum.cpp @@ -68,13 +68,13 @@ std::ostream & operator<<(std::ostream & os, const crypto::checksum & checksum) } case crypto::MD5: { for(size_t i = 0; i < ARRAY_SIZE(checksum.md5); i++) { - os << std::setfill('0') << std::hex << std::setw(2) << int(uint8_t(checksum.md5[i])); + os << std::setfill('0') << std::hex << std::setw(2) << int(boost::uint8_t(checksum.md5[i])); } break; } case crypto::SHA1: { for(size_t i = 0; i < ARRAY_SIZE(checksum.sha1); i++) { - os << std::setfill('0') << std::hex << std::setw(2) << int(uint8_t(checksum.sha1[i])); + os << std::setfill('0') << std::hex << std::setw(2) << int(boost::uint8_t(checksum.sha1[i])); } break; } diff --git a/src/crypto/checksum.hpp b/src/crypto/checksum.hpp index d33f430..cb56959 100644 --- a/src/crypto/checksum.hpp +++ b/src/crypto/checksum.hpp @@ -21,11 +21,12 @@ #ifndef INNOEXTRACT_CRYPTO_CHECKSUM_HPP #define INNOEXTRACT_CRYPTO_CHECKSUM_HPP -#include #include #include #include +#include + #include "util/endian.hpp" #include "util/enum.hpp" #include "util/types.hpp" @@ -42,8 +43,8 @@ enum checksum_type { struct checksum { union { - uint32_t adler32; - uint32_t crc32; + boost::uint32_t adler32; + boost::uint32_t crc32; char md5[16]; char sha1[20]; }; diff --git a/src/crypto/crc32.cpp b/src/crypto/crc32.cpp index 445649f..bb4cbb1 100644 --- a/src/crypto/crc32.cpp +++ b/src/crypto/crc32.cpp @@ -38,7 +38,7 @@ namespace crypto { #endif /* Table of CRC-32's of all single byte values (made by makecrc.c) */ -const uint32_t crc32::table[] = { +const boost::uint32_t crc32::table[] = { #if INNOEXTRACT_ENDIANNESS == LITTLE_ENDIAN 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, @@ -151,11 +151,11 @@ const uint32_t crc32::table[] = { void crc32::update(const char * s, size_t n) { for(; (size_t(s) % 4 != 0) && n > 0; n--) { - crc = table[CRC32_INDEX(crc) ^ uint8_t(*s++)] ^ CRC32_SHIFTED(crc); + crc = table[CRC32_INDEX(crc) ^ boost::uint8_t(*s++)] ^ CRC32_SHIFTED(crc); } while(n >= 4) { - crc ^= *reinterpret_cast(s); + crc ^= *reinterpret_cast(s); crc = table[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc); crc = table[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc); crc = table[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc); @@ -165,7 +165,7 @@ void crc32::update(const char * s, size_t n) { } while(n--) { - crc = table[CRC32_INDEX(crc) ^ uint8_t(*s++)] ^ CRC32_SHIFTED(crc); + crc = table[CRC32_INDEX(crc) ^ boost::uint8_t(*s++)] ^ CRC32_SHIFTED(crc); } } diff --git a/src/crypto/crc32.hpp b/src/crypto/crc32.hpp index f04a54f..2ea59b3 100644 --- a/src/crypto/crc32.hpp +++ b/src/crypto/crc32.hpp @@ -21,7 +21,7 @@ #ifndef INNOEXTRACT_CRYPTO_CRC32_HPP #define INNOEXTRACT_CRYPTO_CRC32_HPP -#include +#include #include "crypto/checksum.hpp" @@ -34,14 +34,14 @@ struct crc32 : public checksum_base { void update(const char * data, size_t length); - uint32_t finalize() const { return crc ^ CRC32_NEGL; } + boost::uint32_t finalize() const { return crc ^ CRC32_NEGL; } private: - static const uint32_t CRC32_NEGL = 0xffffffffl; + static const boost::uint32_t CRC32_NEGL = 0xffffffffl; - static const uint32_t table[256]; - uint32_t crc; + static const boost::uint32_t table[256]; + boost::uint32_t crc; }; } // namespace crypto diff --git a/src/crypto/iteratedhash.hpp b/src/crypto/iteratedhash.hpp index e7a4fba..e55f7d2 100644 --- a/src/crypto/iteratedhash.hpp +++ b/src/crypto/iteratedhash.hpp @@ -23,8 +23,10 @@ // Taken from Crypto++ and modified to fit the project. -#include #include + +#include + #include "crypto/checksum.hpp" #include "util/endian.hpp" #include "util/types.hpp" @@ -52,7 +54,7 @@ public: private: size_t hash(const hash_word * input, size_t length); - void pad(size_t last_block_size, uint8_t pad_first = 0x80); + void pad(size_t last_block_size, boost::uint8_t pad_first = 0x80); hash_word bit_count_hi() const { return (count_lo >> (8 * sizeof(hash_word) - 3)) + (count_hi << 3); @@ -78,7 +80,7 @@ void iterated_hash::update(const char * input, size_t len) { count_hi += hash_word(safe_right_shift<8 * sizeof(hash_word)>(len)); size_t num = mod_power_of_2(old_count_lo, size_t(block_size)); - uint8_t * d = reinterpret_cast(data); + boost::uint8_t * d = reinterpret_cast(data); if(num != 0) { // process left over data if(num + len >= block_size) { @@ -137,11 +139,11 @@ size_t iterated_hash::hash(const hash_word * input, size_t length) { } template -void iterated_hash::pad(size_t last_block_size, uint8_t pad_first) { +void iterated_hash::pad(size_t last_block_size, boost::uint8_t pad_first) { size_t num = mod_power_of_2(count_lo, size_t(block_size)); - uint8_t * d = reinterpret_cast(data); + boost::uint8_t * d = reinterpret_cast(data); d[num++] = pad_first; diff --git a/src/crypto/md5.hpp b/src/crypto/md5.hpp index 745782d..dcd7a6f 100644 --- a/src/crypto/md5.hpp +++ b/src/crypto/md5.hpp @@ -21,7 +21,7 @@ #ifndef INNOEXTRACT_CRYPTO_MD5_HPP #define INNOEXTRACT_CRYPTO_MD5_HPP -#include +#include #include "crypto/iteratedhash.hpp" #include "util/endian.hpp" @@ -32,7 +32,7 @@ class md5_transform { public: - typedef uint32_t hash_word; + typedef boost::uint32_t hash_word; typedef little_endian byte_order; static const size_t block_size = 64; static const size_t hash_size = 16; diff --git a/src/crypto/sha1.hpp b/src/crypto/sha1.hpp index 4428ede..34ba7c4 100644 --- a/src/crypto/sha1.hpp +++ b/src/crypto/sha1.hpp @@ -21,7 +21,7 @@ #ifndef INNOEXTRACT_CRYPTO_SHA1_HPP #define INNOEXTRACT_CRYPTO_SHA1_HPP -#include +#include #include "crypto/iteratedhash.hpp" #include "util/endian.hpp" @@ -32,7 +32,7 @@ class sha1_transform { public: - typedef uint32_t hash_word; + typedef boost::uint32_t hash_word; typedef big_endian byte_order; static const size_t block_size = 64; static const size_t hash_size = 20; diff --git a/src/loader/exereader.cpp b/src/loader/exereader.cpp index cee8f6e..45318c2 100644 --- a/src/loader/exereader.cpp +++ b/src/loader/exereader.cpp @@ -20,13 +20,14 @@ #include "loader/exereader.hpp" -#include #include #include #include #include #include +#include + #include "util/load.hpp" namespace loader { @@ -38,22 +39,22 @@ struct exe_reader_impl : public exe_reader { struct header { //! Number of CoffSection structures following this header after optionalHeaderSize bytes - uint16_t nsections; + boost::uint16_t nsections; //! Offset of the section table in the file - uint32_t section_table_offset; + boost::uint32_t section_table_offset; //! Virtual memory address of the resource root table - uint32_t resource_table_address; + boost::uint32_t resource_table_address; }; struct section { - uint32_t virtual_size; //!< Section size in virtual memory - uint32_t virtual_address; //!< Base virtual memory address + boost::uint32_t virtual_size; //!< Section size in virtual memory + boost::uint32_t virtual_address; //!< Base virtual memory address - uint32_t raw_address; //!< Base file offset + boost::uint32_t raw_address; //!< Base file offset }; @@ -70,7 +71,7 @@ struct exe_reader_impl : public exe_reader { * Remaining 31 bits: Offset to the resource table / leaf relative to * the directory start. */ - static uint32_t find_resource_entry(std::istream & is, uint32_t id); + static boost::uint32_t find_resource_entry(std::istream & is, boost::uint32_t id); static bool load_header(std::istream & is, header & coff); @@ -79,25 +80,25 @@ struct exe_reader_impl : public exe_reader { /*! * Convert a memory address to a file offset according to the given section list. */ - static uint32_t to_file_offset(const section_list & sections, uint32_t address); + static boost::uint32_t to_file_offset(const section_list & sections, boost::uint32_t address); - static resource find_resource(std::istream & is, uint32_t name, uint32_t type = TypeData, - uint32_t language = LanguageDefault); + static resource find_resource(std::istream & is, boost::uint32_t name, boost::uint32_t type = TypeData, + boost::uint32_t language = LanguageDefault); }; static const char PE_MAGIC[] = { 'P', 'E', 0, 0 }; -bool get_resource_table(uint32_t & entry, uint32_t resource_offset) { +bool get_resource_table(boost::uint32_t & entry, boost::uint32_t resource_offset) { - bool is_table = (entry & (uint32_t(1) << 31)); + bool is_table = (entry & (boost::uint32_t(1) << 31)); entry &= ~(1 << 31), entry += resource_offset; return is_table; } -uint32_t exe_reader_impl::find_resource_entry(std::istream & is, uint32_t needle) { +boost::uint32_t exe_reader_impl::find_resource_entry(std::istream & is, boost::uint32_t needle) { // skip: characteristics + timestamp + major version + minor version if(is.seekg(4 + 4 + 2 + 2, std::ios_base::cur).fail()) { @@ -105,22 +106,22 @@ uint32_t exe_reader_impl::find_resource_entry(std::istream & is, uint32_t needle } // Number of named resource entries. - uint16_t nbnames = load_number(is); + boost::uint16_t nbnames = load_number(is); // Number of id resource entries. - uint16_t nbids = load_number(is); + boost::uint16_t nbids = load_number(is); // Ignore named resource entries. - const uint32_t entry_size = 4 + 4; // id / string address + offset + const boost::uint32_t entry_size = 4 + 4; // id / string address + offset if(is.seekg(nbnames * entry_size, std::ios_base::cur).fail()) { return 0; } for(size_t i = 0; i < nbids; i++) { - uint32_t id = load_number(is); - uint32_t offset = load_number(is); + boost::uint32_t id = load_number(is); + boost::uint32_t offset = load_number(is); if(is.fail()) { return 0; } @@ -136,7 +137,7 @@ uint32_t exe_reader_impl::find_resource_entry(std::istream & is, uint32_t needle bool exe_reader_impl::load_header(std::istream & is, header & coff) { // Skip the DOS stub. - uint16_t peOffset = load_number(is.seekg(0x3c)); + boost::uint16_t peOffset = load_number(is.seekg(0x3c)); if(is.fail()) { return false; } @@ -150,15 +151,15 @@ bool exe_reader_impl::load_header(std::istream & is, header & coff) { } is.seekg(2, std::ios_base::cur); // machine - coff.nsections = load_number(is); + coff.nsections = load_number(is); is.seekg(4 + 4 + 4, std::ios_base::cur); // creation time + symbol table offset + nbsymbols - uint16_t optional_header_size = load_number(is); + boost::uint16_t optional_header_size = load_number(is); is.seekg(2, std::ios_base::cur); // characteristics - coff.section_table_offset = uint32_t(is.tellg()) + optional_header_size; + coff.section_table_offset = boost::uint32_t(is.tellg()) + optional_header_size; // Skip the optional header. - uint16_t optionalHeaderMagic = load_number(is); + boost::uint16_t optionalHeaderMagic = load_number(is); if(is.fail()) { return false; } @@ -168,16 +169,16 @@ bool exe_reader_impl::load_header(std::istream & is, header & coff) { is.seekg(90, std::ios_base::cur); } - uint32_t ndirectories = load_number(is); + boost::uint32_t ndirectories = load_number(is); if(is.fail() || ndirectories < 3) { return false; } - const uint32_t directory_header_size = 4 + 4; // address + size + const boost::uint32_t directory_header_size = 4 + 4; // address + size is.seekg(2 * directory_header_size, std::ios_base::cur); // Virtual memory address and size of the start of resource directory. - coff.resource_table_address = load_number(is); - uint32_t resource_size = load_number(is); + coff.resource_table_address = load_number(is); + boost::uint32_t resource_size = load_number(is); if(is.fail() || !coff.resource_table_address || !resource_size) { return false; } @@ -196,11 +197,11 @@ bool exe_reader_impl::load_section_list(std::istream & is, const header & coff, is.seekg(8, std::ios_base::cur); // name - section.virtual_size = load_number(is); - section.virtual_address = load_number(is); + section.virtual_size = load_number(is); + section.virtual_address = load_number(is); is.seekg(4, std::ios_base::cur); // raw size - section.raw_address = load_number(is); + section.raw_address = load_number(is); // relocation addr + line number addr + relocation count // + line number count + characteristics @@ -211,7 +212,7 @@ bool exe_reader_impl::load_section_list(std::istream & is, const header & coff, return !is.fail(); } -uint32_t exe_reader_impl::to_file_offset(const section_list & sections, uint32_t memory) { +boost::uint32_t exe_reader_impl::to_file_offset(const section_list & sections, boost::uint32_t memory) { for(section_list::const_iterator i = sections.begin(); i != sections.end(); ++i) { const section & s = *i; @@ -223,8 +224,8 @@ uint32_t exe_reader_impl::to_file_offset(const section_list & sections, uint32_t return 0; } -exe_reader_impl::resource exe_reader_impl::find_resource(std::istream & is, uint32_t name, - uint32_t type, uint32_t language) { +exe_reader_impl::resource exe_reader_impl::find_resource(std::istream & is, boost::uint32_t name, + boost::uint32_t type, boost::uint32_t language) { is.seekg(0); @@ -241,39 +242,39 @@ exe_reader_impl::resource exe_reader_impl::find_resource(std::istream & is, uint return result; } - uint32_t resource_offset = to_file_offset(sections, coff.resource_table_address); + boost::uint32_t resource_offset = to_file_offset(sections, coff.resource_table_address); if(!resource_offset) { return result; } is.seekg(resource_offset); - uint32_t type_offset = find_resource_entry(is, type); + boost::uint32_t type_offset = find_resource_entry(is, type); if(!get_resource_table(type_offset, resource_offset)) { return result; } is.seekg(type_offset); - uint32_t name_offset = find_resource_entry(is, name); + boost::uint32_t name_offset = find_resource_entry(is, name); if(!get_resource_table(name_offset, resource_offset)) { return result; } is.seekg(name_offset); - uint32_t leaf_offset = find_resource_entry(is, language); + boost::uint32_t leaf_offset = find_resource_entry(is, language); if(!leaf_offset || get_resource_table(leaf_offset, resource_offset)) { return result; } // Virtual memory address and size of the resource data. is.seekg(leaf_offset); - uint32_t data_address = load_number(is); - uint32_t data_size = load_number(is); + boost::uint32_t data_address = load_number(is); + boost::uint32_t data_size = load_number(is); // ignore codepage and reserved word if(is.fail()) { return result; } - uint32_t data_offset = to_file_offset(sections, data_address); + boost::uint32_t data_offset = to_file_offset(sections, data_address); if(!data_offset) { return result; } @@ -286,8 +287,8 @@ exe_reader_impl::resource exe_reader_impl::find_resource(std::istream & is, uint } // anonymous namespace -exe_reader::resource exe_reader::find_resource(std::istream & is, uint32_t name, - uint32_t type, uint32_t language) { +exe_reader::resource exe_reader::find_resource(std::istream & is, boost::uint32_t name, + boost::uint32_t type, boost::uint32_t language) { return exe_reader_impl::find_resource(is, name, type, language); } diff --git a/src/loader/exereader.hpp b/src/loader/exereader.hpp index f91ad18..731902d 100644 --- a/src/loader/exereader.hpp +++ b/src/loader/exereader.hpp @@ -21,9 +21,10 @@ #ifndef INNOEXTRACT_LOADER_EXEREADER_HPP #define INNOEXTRACT_LOADER_EXEREADER_HPP -#include #include +#include + namespace loader { /*! @@ -38,9 +39,9 @@ public: //! Position and size of a resource entry struct resource { - uint32_t offset; //!< File offset of the resource data in bytes + boost::uint32_t offset; //!< File offset of the resource data in bytes - uint32_t size; //!< Size of the resource data in bytes + boost::uint32_t size; //!< Size of the resource data in bytes }; @@ -61,8 +62,8 @@ public: * * \return the location of the resource or `(0, 0)` if the requested resource does not exist. */ - static resource find_resource(std::istream & is, uint32_t name, uint32_t type = TypeData, - uint32_t language = LanguageDefault); + static resource find_resource(std::istream & is, boost::uint32_t name, boost::uint32_t type = TypeData, + boost::uint32_t language = LanguageDefault); }; diff --git a/src/loader/offsets.cpp b/src/loader/offsets.cpp index 29011ba..c8d6900 100644 --- a/src/loader/offsets.cpp +++ b/src/loader/offsets.cpp @@ -20,9 +20,9 @@ #include "loader/offsets.hpp" -#include #include +#include #include #include @@ -57,8 +57,8 @@ const setup_loader_version known_setup_loader_versions[] = { const int ResourceNameInstaller = 11111; -const uint32_t SetupLoaderHeaderOffset = 0x30; -const uint32_t SetupLoaderHeaderMagic = 0x6f6e6e49; +const boost::uint32_t SetupLoaderHeaderOffset = 0x30; +const boost::uint32_t SetupLoaderHeaderMagic = 0x6f6e6e49; } // anonymous namespace @@ -66,14 +66,14 @@ bool offsets::load_from_exe_file(std::istream & is) { is.seekg(SetupLoaderHeaderOffset); - uint32_t magic = load_number(is); + boost::uint32_t magic = load_number(is); if(is.fail() || magic != SetupLoaderHeaderMagic) { is.clear(); return false; } - uint32_t offset_table_offset = load_number(is); - uint32_t not_offset_table_offset = load_number(is); + boost::uint32_t offset_table_offset = load_number(is); + boost::uint32_t not_offset_table_offset = load_number(is); if(is.fail() || offset_table_offset != ~not_offset_table_offset) { is.clear(); return false; @@ -93,7 +93,7 @@ bool offsets::load_from_exe_resource(std::istream & is) { return load_offsets_at(is, resource.offset); } -bool offsets::load_offsets_at(std::istream & is, uint32_t pos) { +bool offsets::load_offsets_at(std::istream & is, boost::uint32_t pos) { if(is.seekg(pos).fail()) { is.clear(); @@ -124,40 +124,40 @@ bool offsets::load_offsets_at(std::istream & is, uint32_t pos) { checksum.update(magic, ARRAY_SIZE(magic)); if(version >= INNO_VERSION(5, 1, 5)) { - uint32_t revision = checksum.load_number(is); + boost::uint32_t revision = checksum.load_number(is); if(is.fail() || revision != 1) { is.clear(); return false; } } - (void)checksum.load_number(is); - exe_offset = checksum.load_number(is); + (void)checksum.load_number(is); + exe_offset = checksum.load_number(is); if(version >= INNO_VERSION(4, 1, 6)) { exe_compressed_size = 0; } else { - exe_compressed_size = checksum.load_number(is); + exe_compressed_size = checksum.load_number(is); } - exe_uncompressed_size = checksum.load_number(is); + exe_uncompressed_size = checksum.load_number(is); if(version >= INNO_VERSION(4, 0, 3)) { exe_checksum.type = crypto::CRC32; - exe_checksum.crc32 = checksum.load_number(is); + exe_checksum.crc32 = checksum.load_number(is); } else { exe_checksum.type = crypto::Adler32; - exe_checksum.adler32 = checksum.load_number(is); + exe_checksum.adler32 = checksum.load_number(is); } if(version >= INNO_VERSION(4, 0, 0)) { message_offset = 0; } else { - message_offset = load_number(is); + message_offset = load_number(is); } - header_offset = checksum.load_number(is); - data_offset = checksum.load_number(is); + header_offset = checksum.load_number(is); + data_offset = checksum.load_number(is); if(is.fail()) { is.clear(); @@ -165,7 +165,7 @@ bool offsets::load_offsets_at(std::istream & is, uint32_t pos) { } if(version >= INNO_VERSION(4, 0, 10)) { - uint32_t expected = load_number(is); + boost::uint32_t expected = load_number(is); if(is.fail()) { is.clear(); return false; diff --git a/src/loader/offsets.hpp b/src/loader/offsets.hpp index 8921bf7..bd1bbe3 100644 --- a/src/loader/offsets.hpp +++ b/src/loader/offsets.hpp @@ -21,9 +21,10 @@ #ifndef INNOEXTRACT_LOADER_OFFSETS_HPP #define INNOEXTRACT_LOADER_OFFSETS_HPP -#include #include +#include + #include "crypto/checksum.hpp" namespace loader { @@ -49,17 +50,17 @@ struct offsets { * * A value of \c 0 means there is no setup.e32 embedded in this file */ - uint32_t exe_offset; + boost::uint32_t exe_offset; /*! * Size of `setup.e32` after compression, in bytes * * A value of \c 0 means the executable size is not known */ - uint32_t exe_compressed_size; + boost::uint32_t exe_compressed_size; //! Size of `setup.e32` before compression, in bytes - uint32_t exe_uncompressed_size; + boost::uint32_t exe_uncompressed_size; /*! * Checksum of `setup.e32` before compression @@ -69,7 +70,7 @@ struct offsets { crypto::checksum exe_checksum; //! Offset of embedded setup messages - uint32_t message_offset; + boost::uint32_t message_offset; /*! * Offset of embedded `setup-0.bin` data (the setup headers) @@ -82,7 +83,7 @@ struct offsets { * * Loading the version and headers is done in \ref setup::info. */ - uint32_t header_offset; + boost::uint32_t header_offset; /*! * Offset of embedded `setup-1.bin` data @@ -98,7 +99,7 @@ struct offsets { * The layout of the chunks and files is stored in the \ref setup::data_entry headers * while the \ref setup::file_entry headers provide the filenames and meta information. */ - uint32_t data_offset; + boost::uint32_t data_offset; /*! * \brief Find the setup loader offsets in a file @@ -117,7 +118,7 @@ private: bool load_from_exe_resource(std::istream & is); - bool load_offsets_at(std::istream & is, uint32_t pos); + bool load_offsets_at(std::istream & is, boost::uint32_t pos); }; diff --git a/src/setup/component.cpp b/src/setup/component.cpp index 23d5fdd..eeb9594 100644 --- a/src/setup/component.cpp +++ b/src/setup/component.cpp @@ -70,14 +70,14 @@ void component_entry::load(std::istream & is, const version & version) { } if(version >= INNO_VERSION(4, 0, 0)) { - extra_disk_pace_required = load_number(is); + extra_disk_pace_required = load_number(is); } else { - extra_disk_pace_required = load_number(is); + extra_disk_pace_required = load_number(is); } if(version >= INNO_VERSION_EXT(3, 0, 6, 1)) { - level = load_number(is); - used = load_number(is); + level = load_number(is); + used = load_number(is); } else { level = 0, used = true; } @@ -92,7 +92,7 @@ void component_entry::load(std::istream & is, const version & version) { options = stored_flags(is).get(); } - size = (version >= INNO_VERSION(4, 0, 0)) ? load_number(is) : load_number(is); + size = (version >= INNO_VERSION(4, 0, 0)) ? load_number(is) : load_number(is); } } // namespace setup diff --git a/src/setup/component.hpp b/src/setup/component.hpp index a806e36..7e45952 100644 --- a/src/setup/component.hpp +++ b/src/setup/component.hpp @@ -21,10 +21,11 @@ #ifndef INNOEXTRACT_SETUP_COMPONENT_HPP #define INNOEXTRACT_SETUP_COMPONENT_HPP -#include #include #include +#include + #include "setup/windows.hpp" #include "util/enum.hpp" #include "util/flags.hpp" @@ -51,7 +52,7 @@ struct component_entry { std::string languages; std::string check; - uint64_t extra_disk_pace_required; + boost::uint64_t extra_disk_pace_required; int level; bool used; @@ -60,7 +61,7 @@ struct component_entry { flags options; - uint64_t size; + boost::uint64_t size; void load(std::istream & is, const version & version); diff --git a/src/setup/data.cpp b/src/setup/data.cpp index 25ad6ea..199dbe3 100644 --- a/src/setup/data.cpp +++ b/src/setup/data.cpp @@ -31,8 +31,8 @@ namespace setup { void data_entry::load(std::istream & is, const version & version) { - chunk.first_slice = load_number(is, version.bits); - chunk.last_slice = load_number(is, version.bits); + chunk.first_slice = load_number(is, version.bits); + chunk.last_slice = load_number(is, version.bits); if(version < INNO_VERSION(4, 0, 0)) { if(chunk.first_slice < 1 || chunk.last_slice < 1) { log_warning << "[file location] unexpected disk number: " << chunk.first_slice @@ -42,20 +42,20 @@ void data_entry::load(std::istream & is, const version & version) { } } - chunk.offset = load_number(is); + chunk.offset = load_number(is); if(version >= INNO_VERSION(4, 0, 1)) { - file.offset = load_number(is); + file.offset = load_number(is); } else { file.offset = 0; } if(version >= INNO_VERSION(4, 0, 0)) { - file.size = load_number(is); - chunk.size = load_number(is); + file.size = load_number(is); + chunk.size = load_number(is); } else { - file.size = load_number(is); - chunk.size = load_number(is); + file.size = load_number(is); + chunk.size = load_number(is); } if(version >= INNO_VERSION(5, 3, 9)) { @@ -65,10 +65,10 @@ void data_entry::load(std::istream & is, const version & version) { is.read(file.checksum.md5, std::streamsize(sizeof(file.checksum.md5))); file.checksum.type = crypto::MD5; } else if(version >= INNO_VERSION(4, 0, 1)) { - file.checksum.crc32 = load_number(is); + file.checksum.crc32 = load_number(is); file.checksum.type = crypto::CRC32; } else { - file.checksum.adler32 = load_number(is); + file.checksum.adler32 = load_number(is); file.checksum.type = crypto::Adler32; } @@ -76,8 +76,8 @@ void data_entry::load(std::istream & is, const version & version) { // 16-bit installers use the FAT filetime format - uint16_t time = load_number(is); - uint16_t date = load_number(is); + boost::uint16_t time = load_number(is); + boost::uint16_t date = load_number(is); struct tm t; t.tm_sec = get_bits(time, 0, 4) * 2; // [0, 58] @@ -94,21 +94,21 @@ void data_entry::load(std::istream & is, const version & version) { // 32-bit installers use the Win32 FILETIME format - int64_t filetime = load_number(is); + boost::int64_t filetime = load_number(is); - static const int64_t FiletimeOffset = 0x19DB1DED53E8000ll; + static const boost::int64_t FiletimeOffset = 0x19DB1DED53E8000ll; if(filetime < FiletimeOffset) { log_warning << "[file location] unexpected filetime: " << filetime; } filetime -= FiletimeOffset; timestamp = std::time_t(filetime / 10000000); - timestamp_nsec = uint32_t(filetime % 10000000) * 100; + timestamp_nsec = boost::uint32_t(filetime % 10000000) * 100; } - file_version_ms = load_number(is); - file_version_ls = load_number(is); + file_version_ms = load_number(is); + file_version_ls = load_number(is); options = 0; diff --git a/src/setup/data.hpp b/src/setup/data.hpp index 5012a24..8c9337e 100644 --- a/src/setup/data.hpp +++ b/src/setup/data.hpp @@ -22,10 +22,11 @@ #define INNOEXTRACT_SETUP_DATA_HPP #include -#include #include #include +#include + #include "crypto/checksum.hpp" #include "stream/chunk.hpp" #include "stream/file.hpp" @@ -59,10 +60,10 @@ struct data_entry { stream::file file; std::time_t timestamp; - uint32_t timestamp_nsec; + boost::uint32_t timestamp_nsec; - uint32_t file_version_ms; - uint32_t file_version_ls; + boost::uint32_t file_version_ms; + boost::uint32_t file_version_ls; flags options; diff --git a/src/setup/delete.cpp b/src/setup/delete.cpp index bd11a78..675fc19 100644 --- a/src/setup/delete.cpp +++ b/src/setup/delete.cpp @@ -39,7 +39,7 @@ STORED_ENUM_MAP(delete_target_type_map, delete_entry::Files, void delete_entry::load(std::istream & is, const version & version) { if(version < INNO_VERSION(1, 3, 21)) { - ::load(is); // uncompressed size of the directory entry structure + ::load(is); // uncompressed size of the directory entry structure } is >> encoded_string(name, version.codepage()); diff --git a/src/setup/directory.cpp b/src/setup/directory.cpp index 44f696b..2ece298 100644 --- a/src/setup/directory.cpp +++ b/src/setup/directory.cpp @@ -48,7 +48,7 @@ STORED_FLAGS_MAP(stored_inno_directory_options_1, void directory_entry::load(std::istream & is, const version & version) { if(version < INNO_VERSION(1, 3, 21)) { - ::load(is); // uncompressed size of the directory entry structure + ::load(is); // uncompressed size of the directory entry structure } is >> encoded_string(name, version.codepage()); @@ -62,7 +62,7 @@ void directory_entry::load(std::istream & is, const version & version) { } if(version >= INNO_VERSION(2, 0, 11)) { - attributes = load_number(is); + attributes = load_number(is); } else { attributes = 0; } @@ -70,7 +70,7 @@ void directory_entry::load(std::istream & is, const version & version) { load_version_data(is, version); if(version >= INNO_VERSION(4, 1, 0)) { - permission = load_number(is); + permission = load_number(is); } else { permission = -1; } diff --git a/src/setup/directory.hpp b/src/setup/directory.hpp index 12abc78..00c159b 100644 --- a/src/setup/directory.hpp +++ b/src/setup/directory.hpp @@ -21,10 +21,11 @@ #ifndef INNOEXTRACT_SETUP_DIRECTORY_HPP #define INNOEXTRACT_SETUP_DIRECTORY_HPP -#include #include #include +#include + #include "setup/item.hpp" #include "util/enum.hpp" #include "util/flags.hpp" @@ -46,7 +47,7 @@ struct directory_entry : public item { std::string name; std::string permissions; - uint32_t attributes; + boost::uint32_t attributes; int permission; //!< index into the permission entry list diff --git a/src/setup/file.cpp b/src/setup/file.cpp index 4a7d484..19b772e 100644 --- a/src/setup/file.cpp +++ b/src/setup/file.cpp @@ -77,7 +77,7 @@ void file_entry::load(std::istream & is, const version & version) { options = 0; if(version < INNO_VERSION(1, 3, 21)) { - ::load(is); // uncompressed size of the file entry structure + ::load(is); // uncompressed size of the file entry structure } is >> encoded_string(source, version.codepage()); @@ -93,10 +93,10 @@ void file_entry::load(std::istream & is, const version & version) { load_version_data(is, version); - location = load_number(is, version.bits); - attributes = load_number(is, version.bits); - external_size = (version >= INNO_VERSION(4, 0, 0)) ? load_number(is) - : load_number(is); + location = load_number(is, version.bits); + attributes = load_number(is, version.bits); + external_size = (version >= INNO_VERSION(4, 0, 0)) ? load_number(is) + : load_number(is); if(version < INNO_VERSION(3, 0, 5)) { file_copy_mode copyMode = stored_enum(is).get(); @@ -109,7 +109,7 @@ void file_entry::load(std::istream & is, const version & version) { } if(version >= INNO_VERSION(4, 1, 0)) { - permission = load_number(is); + permission = load_number(is); } else { permission = -1; } diff --git a/src/setup/file.hpp b/src/setup/file.hpp index dc849cf..95a24ae 100644 --- a/src/setup/file.hpp +++ b/src/setup/file.hpp @@ -21,10 +21,11 @@ #ifndef INNOEXTRACT_SETUP_FILE_HPP #define INNOEXTRACT_SETUP_FILE_HPP -#include #include #include +#include + #include "setup/item.hpp" #include "util/enum.hpp" #include "util/flags.hpp" @@ -85,9 +86,9 @@ struct file_entry : public item { std::string install_font_name; std::string strong_assembly_name; - uint32_t location; //!< index into the data entry list - uint32_t attributes; - uint64_t external_size; + boost::uint32_t location; //!< index into the data entry list + boost::uint32_t attributes; + boost::uint64_t external_size; int permission; //!< index into the permission entry list diff --git a/src/setup/filename.hpp b/src/setup/filename.hpp index 37ee404..9a6b43f 100644 --- a/src/setup/filename.hpp +++ b/src/setup/filename.hpp @@ -23,6 +23,7 @@ #include #include + #include namespace setup { diff --git a/src/setup/header.cpp b/src/setup/header.cpp index bde98e0..3d6f546 100644 --- a/src/setup/header.cpp +++ b/src/setup/header.cpp @@ -128,7 +128,7 @@ void header::load(std::istream & is, const version & version) { options = 0; if(version < INNO_VERSION(1, 3, 21)) { - ::load(is); // uncompressed size of the setup header structure + ::load(is); // uncompressed size of the setup header structure } is >> encoded_string(app_name, version.codepage()); @@ -237,7 +237,7 @@ void header::load(std::istream & is, const version & version) { } if(version >= INNO_VERSION(4, 0, 0)) { - language_count = load_number(is); + language_count = load_number(is); } else if(version >= INNO_VERSION(2, 0, 1)) { language_count = 1; } else { @@ -245,62 +245,62 @@ void header::load(std::istream & is, const version & version) { } if(version >= INNO_VERSION(4, 2, 1)) { - message_count = load_number(is); + message_count = load_number(is); } else { message_count = 0; } if(version >= INNO_VERSION(4, 1, 0)) { - permission_count = load_number(is); + permission_count = load_number(is); } else { permission_count = 0; } if(version >= INNO_VERSION(2, 0, 0)) { - type_count = load_number(is); - component_count = load_number(is); - task_count = load_number(is); + type_count = load_number(is); + component_count = load_number(is); + task_count = load_number(is); } else { type_count = 0, component_count = 0, task_count = 0; } - directory_count = load_number(is, version.bits); - file_count = load_number(is, version.bits); - data_entry_count = load_number(is, version.bits); - icon_count = load_number(is, version.bits); - ini_entry_count = load_number(is, version.bits); - registry_entry_count = load_number(is, version.bits); - delete_entry_count = load_number(is, version.bits); - uninstall_delete_entry_count = load_number(is, version.bits); - run_entry_count = load_number(is, version.bits); - uninstall_run_entry_count = load_number(is, version.bits); - - int32_t license_size = 0; - int32_t info_before_size = 0; - int32_t info_after_size = 0; + directory_count = load_number(is, version.bits); + file_count = load_number(is, version.bits); + data_entry_count = load_number(is, version.bits); + icon_count = load_number(is, version.bits); + ini_entry_count = load_number(is, version.bits); + registry_entry_count = load_number(is, version.bits); + delete_entry_count = load_number(is, version.bits); + uninstall_delete_entry_count = load_number(is, version.bits); + run_entry_count = load_number(is, version.bits); + uninstall_run_entry_count = load_number(is, version.bits); + + boost::int32_t license_size = 0; + boost::int32_t info_before_size = 0; + boost::int32_t info_after_size = 0; if(version < INNO_VERSION(1, 3, 21)) { - license_size = load_number(is, version.bits); - info_before_size = load_number(is, version.bits); - info_after_size = load_number(is, version.bits); + license_size = load_number(is, version.bits); + info_before_size = load_number(is, version.bits); + info_after_size = load_number(is, version.bits); } winver.load(is, version); - back_color = load_number(is); + back_color = load_number(is); if(version >= INNO_VERSION(1, 3, 21)) { - back_color2 = load_number(is); + back_color2 = load_number(is); } else { back_color2 = 0; } - image_back_color = load_number(is); + image_back_color = load_number(is); if(version >= INNO_VERSION(2, 0, 0) && version < INNO_VERSION(5, 0, 4)) { - small_image_back_color = load_number(is); + small_image_back_color = load_number(is); } else { small_image_back_color = 0; } if(version < INNO_VERSION(4, 2, 0)) { - password.crc32 = load_number(is); + password.crc32 = load_number(is); password.type = crypto::CRC32; } else if(version < INNO_VERSION(5, 3, 9)) { is.read(password.md5, std::streamsize(sizeof(password.md5))); @@ -316,10 +316,10 @@ void header::load(std::istream & is, const version & version) { } if(version >= INNO_VERSION(4, 0, 0)) { - extra_disk_space_required = load_number(is); - slices_per_disk = load_number(is); + extra_disk_space_required = load_number(is); + slices_per_disk = load_number(is); } else { - extra_disk_space_required = load_number(is); + extra_disk_space_required = load_number(is); slices_per_disk = 1; } @@ -386,8 +386,8 @@ void header::load(std::istream & is, const version & version) { } if(version >= INNO_VERSION(5, 2, 1) && version < INNO_VERSION(5, 3, 10)) { - signed_uninstaller_original_size = load_number(is); - signed_uninstaller_header_checksum = load_number(is); + signed_uninstaller_original_size = load_number(is); + signed_uninstaller_header_checksum = load_number(is); } else { signed_uninstaller_original_size = signed_uninstaller_header_checksum = 0; } @@ -398,9 +398,9 @@ void header::load(std::istream & is, const version & version) { } if(version >= INNO_VERSION(5, 5, 0)) { - uninstall_display_size = load_number(is); + uninstall_display_size = load_number(is); } else if(version >= INNO_VERSION(5, 3, 6)) { - uninstall_display_size = load_number(is); + uninstall_display_size = load_number(is); } else { uninstall_display_size = 0; } diff --git a/src/setup/header.hpp b/src/setup/header.hpp index 425b05c..c42b1e1 100644 --- a/src/setup/header.hpp +++ b/src/setup/header.hpp @@ -21,12 +21,13 @@ #ifndef INNOEXTRACT_SETUP_HEADER_HPP #define INNOEXTRACT_SETUP_HEADER_HPP -#include #include #include #include #include +#include + #include "crypto/checksum.hpp" #include "setup/windows.hpp" #include "stream/chunk.hpp" @@ -171,7 +172,7 @@ struct header { windows_version_range winver; - typedef uint32_t Color; + typedef boost::uint32_t Color; Color back_color; Color back_color2; Color image_back_color; @@ -180,7 +181,7 @@ struct header { crypto::checksum password; salt password_salt; - int64_t extra_disk_space_required; + boost::int64_t extra_disk_space_required; size_t slices_per_disk; enum install_verbosity { @@ -233,13 +234,13 @@ struct header { architecture_types architectures_allowed; architecture_types architectures_installed_in_64bit_mode; - uint32_t signed_uninstaller_original_size; - uint32_t signed_uninstaller_header_checksum; + boost::uint32_t signed_uninstaller_original_size; + boost::uint32_t signed_uninstaller_header_checksum; auto_bool disable_dir_page; auto_bool disable_program_group_page; - uint64_t uninstall_display_size; + boost::uint64_t uninstall_display_size; flags options; diff --git a/src/setup/icon.cpp b/src/setup/icon.cpp index 5baebb6..5f21fa1 100644 --- a/src/setup/icon.cpp +++ b/src/setup/icon.cpp @@ -39,7 +39,7 @@ STORED_ENUM_MAP(stored_close_setting, icon_entry::NoSetting, void icon_entry::load(std::istream & is, const version & version) { if(version < INNO_VERSION(1, 3, 21)) { - ::load(is); // uncompressed size of the icon entry structure + ::load(is); // uncompressed size of the icon entry structure } is >> encoded_string(name, version.codepage()); @@ -59,17 +59,17 @@ void icon_entry::load(std::istream & is, const version & version) { load_version_data(is, version); - icon_index = load_number(is, version.bits); + icon_index = load_number(is, version.bits); if(version >= INNO_VERSION(1, 3, 21)) { - show_command = load_number(is); + show_command = load_number(is); close_on_exit = stored_enum(is).get(); } else { show_command = 1, close_on_exit = NoSetting; } if(version >= INNO_VERSION(2, 0, 7)) { - hotkey = load_number(is); + hotkey = load_number(is); } else { hotkey = 0; } diff --git a/src/setup/icon.hpp b/src/setup/icon.hpp index f9e257c..e455696 100644 --- a/src/setup/icon.hpp +++ b/src/setup/icon.hpp @@ -21,10 +21,11 @@ #ifndef INNOEXTRACT_SETUP_ICON_HPP #define INNOEXTRACT_SETUP_ICON_HPP -#include #include #include +#include + #include "setup/item.hpp" #include "util/enum.hpp" #include "util/flags.hpp" @@ -66,7 +67,7 @@ struct icon_entry : public item { close_setting close_on_exit; - uint16_t hotkey; + boost::uint16_t hotkey; flags options; diff --git a/src/setup/info.cpp b/src/setup/info.cpp index dfdd09d..058ce4a 100644 --- a/src/setup/info.cpp +++ b/src/setup/info.cpp @@ -149,7 +149,7 @@ void info::load(std::istream & ifs, entry_types e, const setup::version & v) { continue; } - uint32_t codepage; + boost::uint32_t codepage; if(entry.language < 0) { codepage = v.codepage(); } else { diff --git a/src/setup/ini.cpp b/src/setup/ini.cpp index 7020217..cbcb04b 100644 --- a/src/setup/ini.cpp +++ b/src/setup/ini.cpp @@ -20,7 +20,7 @@ #include "setup/ini.hpp" -#include +#include #include "setup/version.hpp" #include "util/load.hpp" @@ -43,7 +43,7 @@ STORED_FLAGS_MAP(stored_ini_flags, void ini_entry::load(std::istream & is, const version & version) { if(version < INNO_VERSION(1, 3, 21)) { - ::load(is); // uncompressed size of the ini entry structure + ::load(is); // uncompressed size of the ini entry structure } is >> encoded_string(inifile, version.codepage()); diff --git a/src/setup/language.cpp b/src/setup/language.cpp index 82c3584..103cc42 100644 --- a/src/setup/language.cpp +++ b/src/setup/language.cpp @@ -52,10 +52,10 @@ void language_entry::load(std::istream & is, const version & version) { license_text.clear(), info_before.clear(), info_after.clear(); } - language_id = load_number(is); + language_id = load_number(is); if(version >= INNO_VERSION(4, 2, 2) && (version < INNO_VERSION(5, 3, 0) || !version.unicode)) { - codepage = load_number(is); + codepage = load_number(is); } else { codepage = 0; } @@ -63,20 +63,20 @@ void language_entry::load(std::istream & is, const version & version) { codepage = version.codepage(); } - dialog_font_size = load_number(is); + dialog_font_size = load_number(is); if(version < INNO_VERSION(4, 1, 0)) { - dialog_font_standard_height = load_number(is); + dialog_font_standard_height = load_number(is); } else { dialog_font_standard_height = 0; } - title_font_size = load_number(is); - welcome_font_size = load_number(is); - copyright_font_size = load_number(is); + title_font_size = load_number(is); + welcome_font_size = load_number(is); + copyright_font_size = load_number(is); if(version >= INNO_VERSION(5, 2, 3)) { - right_to_left = ::load(is); + right_to_left = ::load(is); } else { right_to_left = false; } diff --git a/src/setup/language.hpp b/src/setup/language.hpp index bd1cc84..8f0126d 100644 --- a/src/setup/language.hpp +++ b/src/setup/language.hpp @@ -21,10 +21,11 @@ #ifndef INNOEXTRACT_SETUP_LANGUAGE_HPP #define INNOEXTRACT_SETUP_LANGUAGE_HPP -#include #include #include +#include + namespace setup { struct version; @@ -44,8 +45,8 @@ struct language_entry { std::string info_before; std::string info_after; - uint32_t language_id; - uint32_t codepage; + boost::uint32_t language_id; + boost::uint32_t codepage; size_t dialog_font_size; size_t dialog_font_standard_height; size_t title_font_size; diff --git a/src/setup/message.cpp b/src/setup/message.cpp index e82188f..d8978c0 100644 --- a/src/setup/message.cpp +++ b/src/setup/message.cpp @@ -20,7 +20,7 @@ #include "setup/message.hpp" -#include +#include #include "setup/version.hpp" #include "util/load.hpp" @@ -32,7 +32,7 @@ void message_entry::load(std::istream & is, const version & version) { is >> encoded_string(name, version.codepage()); is >> binary_string(value); // encoding depends on the codepage in the LanguageEntry - language = load_number(is); + language = load_number(is); } diff --git a/src/setup/permission.cpp b/src/setup/permission.cpp index d4a01f2..131d7ff 100644 --- a/src/setup/permission.cpp +++ b/src/setup/permission.cpp @@ -20,13 +20,14 @@ #include "setup/permission.hpp" +#include "setup/version.hpp" #include "util/load.hpp" namespace setup { -void permission_entry::load(std::istream & is, const version & version) { +void permission_entry::load(std::istream & is, const version & v) { - (void)version; + (void)v; is >> binary_string(permissions); // an array of TGrantPermissionEntry's diff --git a/src/setup/registry.cpp b/src/setup/registry.cpp index 7599db9..bc2b434 100644 --- a/src/setup/registry.cpp +++ b/src/setup/registry.cpp @@ -20,7 +20,7 @@ #include "setup/registry.hpp" -#include +#include #include "setup/version.hpp" #include "util/load.hpp" @@ -61,7 +61,7 @@ STORED_ENUM_MAP(stored_registry_entry_type_2, registry_entry::None, void registry_entry::load(std::istream & is, const version & version) { if(version < INNO_VERSION(1, 3, 21)) { - ::load(is); // uncompressed size of the directory entry structure + ::load(is); // uncompressed size of the directory entry structure } is >> encoded_string(key, version.codepage()); @@ -83,13 +83,13 @@ void registry_entry::load(std::istream & is, const version & version) { load_version_data(is, version); if(version.bits != 16) { - hive = hive_name(load_number(is) & ~0x80000000); + hive = hive_name(load_number(is) & ~0x80000000); } else { hive = Unset; } if(version >= INNO_VERSION(4, 1, 0)) { - permission = load_number(is); + permission = load_number(is); } else { permission = -1; } diff --git a/src/setup/run.cpp b/src/setup/run.cpp index a0cce81..58464e0 100644 --- a/src/setup/run.cpp +++ b/src/setup/run.cpp @@ -20,7 +20,7 @@ #include "setup/run.hpp" -#include +#include #include "setup/version.hpp" #include "util/load.hpp" @@ -41,7 +41,7 @@ STORED_ENUM_MAP(stored_run_wait_condition, run_entry::WaitUntilTerminated, void run_entry::load(std::istream & is, const version & version) { if(version < INNO_VERSION(1, 3, 21)) { - ::load(is); // uncompressed size of the directory entry structure + ::load(is); // uncompressed size of the directory entry structure } is >> encoded_string(name, version.codepage()); @@ -71,7 +71,7 @@ void run_entry::load(std::istream & is, const version & version) { load_version_data(is, version); if(version >= INNO_VERSION(1, 3, 21)) { - show_command = load_number(is); + show_command = load_number(is); } else { show_command = 0; } diff --git a/src/setup/task.cpp b/src/setup/task.cpp index a8a035f..00ed998 100644 --- a/src/setup/task.cpp +++ b/src/setup/task.cpp @@ -20,7 +20,7 @@ #include "setup/task.hpp" -#include +#include #include "setup/version.hpp" #include "util/load.hpp" @@ -41,8 +41,8 @@ void task_entry::load(std::istream & is, const version & version) { } if(version >= INNO_VERSION_EXT(3, 0, 6, 1)) { is >> encoded_string(check, version.codepage()); - level = load_number(is); - used = load_number(is); + level = load_number(is); + used = load_number(is); } else { check.clear(), level = 0, used = true; } diff --git a/src/setup/type.cpp b/src/setup/type.cpp index 30375d3..3bb0744 100644 --- a/src/setup/type.cpp +++ b/src/setup/type.cpp @@ -79,7 +79,7 @@ void type_entry::load(std::istream & is, const version & version) { type = User; } - size = (version >= INNO_VERSION(4, 0, 0)) ? load_number(is) : load_number(is); + size = (version >= INNO_VERSION(4, 0, 0)) ? load_number(is) : load_number(is); } } // namespace setup diff --git a/src/setup/type.hpp b/src/setup/type.hpp index 73f5888..8c41f5a 100644 --- a/src/setup/type.hpp +++ b/src/setup/type.hpp @@ -21,10 +21,11 @@ #ifndef INNOEXTRACT_SETUP_TYPE_HPP #define INNOEXTRACT_SETUP_TYPE_HPP -#include #include #include +#include + #include "setup/windows.hpp" #include "util/enum.hpp" #include "util/flags.hpp" @@ -55,7 +56,7 @@ struct type_entry { setup_type type; - uint64_t size; + boost::uint64_t size; void load(std::istream & is, const version & version); diff --git a/src/setup/version.hpp b/src/setup/version.hpp index 3bacc23..6ec813c 100644 --- a/src/setup/version.hpp +++ b/src/setup/version.hpp @@ -21,15 +21,16 @@ #ifndef INNOEXTRACT_SETUP_VERSION_HPP #define INNOEXTRACT_SETUP_VERSION_HPP -#include #include #include +#include + namespace setup { struct version_error : public std::exception { }; -typedef uint32_t version_constant; +typedef boost::uint32_t version_constant; #define INNO_VERSION_EXT(a, b, c, d) ( \ (::setup::version_constant(a) << 24) \ | (::setup::version_constant(b) << 16) \ @@ -42,7 +43,7 @@ struct version { version_constant value; - uint8_t bits; // 16 or 32 + boost::uint8_t bits; // 16 or 32 bool unicode; @@ -51,12 +52,12 @@ struct version { version() : known(false) { } version(version_constant value, bool unicode = false, - bool known = false, uint8_t bits = 32) + bool known = false, boost::uint8_t bits = 32) : value(value), bits(bits), unicode(unicode), known(known) { } - version(uint8_t a, uint8_t b, uint8_t c, uint8_t d = 0, bool unicode = false, - bool known = false, uint8_t bits = 32) + version(boost::uint8_t a, boost::uint8_t b, boost::uint8_t c, boost::uint8_t d = 0, bool unicode = false, + bool known = false, boost::uint8_t bits = 32) : value(INNO_VERSION_EXT(a, b, c, d)), bits(bits), unicode(unicode), known(known) { } unsigned int a() const { return value >> 24; } @@ -67,7 +68,7 @@ struct version { void load(std::istream & is); //! \return the Windows codepage used to encode strings - uint32_t codepage() const { return uint32_t(unicode ? 1200 : 1252); } + boost::uint32_t codepage() const { return boost::uint32_t(unicode ? 1200 : 1252); } //! \return true if the version stored might not be correct bool is_ambiguous() const; diff --git a/src/setup/windows.cpp b/src/setup/windows.cpp index bd07ca8..498a9d9 100644 --- a/src/setup/windows.cpp +++ b/src/setup/windows.cpp @@ -20,9 +20,10 @@ #include "setup/windows.hpp" -#include #include +#include + #include "setup/version.hpp" #include "util/load.hpp" #include "util/util.hpp" @@ -34,13 +35,13 @@ const windows_version windows_version::none = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0 void windows_version::data::load(std::istream & is, const version & version) { if(version >= INNO_VERSION(1, 3, 21)) { - build = load_number(is); + build = load_number(is); } else { build = 0; } - minor = load_number(is); - major = load_number(is); + minor = load_number(is); + major = load_number(is); } @@ -50,8 +51,8 @@ void windows_version::load(std::istream & is, const version & version) { nt_version.load(is, version); if(version >= INNO_VERSION(1, 3, 21)) { - nt_service_pack.minor = load_number(is); - nt_service_pack.major = load_number(is); + nt_service_pack.minor = load_number(is); + nt_service_pack.major = load_number(is); } else { nt_service_pack.major = 0, nt_service_pack.minor = 0; } diff --git a/src/stream/block.cpp b/src/stream/block.cpp index e8c4542..7eb33ec 100644 --- a/src/stream/block.cpp +++ b/src/stream/block.cpp @@ -20,13 +20,13 @@ #include "stream/block.hpp" -#include #include #include #include #include #include +#include #include #include #include @@ -82,7 +82,7 @@ public: template bool read_chunk(Source & src) { - uint32_t block_crc32; + boost::uint32_t block_crc32; char temp[sizeof(block_crc32)]; std::streamsize temp_size = std::streamsize(sizeof(temp)); std::streamsize nread = boost::iostreams::read(src, temp, temp_size); @@ -157,33 +157,33 @@ block_reader::pointer block_reader::get(std::istream & base, const setup::versio USE_ENUM_NAMES(block_compression) - uint32_t expected_checksum = load_number(base); + boost::uint32_t expected_checksum = load_number(base); crypto::crc32 actual_checksum; actual_checksum.init(); - uint32_t stored_size; + boost::uint32_t stored_size; block_compression compression; if(version >= INNO_VERSION(4, 0, 9)) { - stored_size = actual_checksum.load_number(base); - uint8_t compressed = actual_checksum.load_number(base); + stored_size = actual_checksum.load_number(base); + boost::uint8_t compressed = actual_checksum.load_number(base); compression = compressed ? (version >= INNO_VERSION(4, 1, 6) ? LZMA1 : Zlib) : Stored; } else { - uint32_t compressed_size = actual_checksum.load_number(base); - uint32_t uncompressed_size = actual_checksum.load_number(base); + boost::uint32_t compressed_size = actual_checksum.load_number(base); + boost::uint32_t uncompressed_size = actual_checksum.load_number(base); - if(compressed_size == uint32_t(-1)) { + if(compressed_size == boost::uint32_t(-1)) { stored_size = uncompressed_size, compression = Stored; } else { stored_size = compressed_size, compression = Zlib; } // Add the size of a CRC32 checksum for each 4KiB subblock. - stored_size += uint32_t(ceildiv(stored_size, 4096) * 4); + stored_size += boost::uint32_t(ceildiv(stored_size, 4096) * 4); } if(actual_checksum.finalize() != expected_checksum) { diff --git a/src/stream/chunk.cpp b/src/stream/chunk.cpp index d99e731..bf469e7 100644 --- a/src/stream/chunk.cpp +++ b/src/stream/chunk.cpp @@ -91,7 +91,7 @@ chunk_reader::pointer chunk_reader::get(slice_reader & base, const chunk & chunk default: throw chunk_error("unknown compression"); } - result->push(io::restrict(boost::ref(base), 0, int64_t(chunk.size))); + result->push(io::restrict(boost::ref(base), 0, boost::int64_t(chunk.size))); return result; } diff --git a/src/stream/chunk.hpp b/src/stream/chunk.hpp index 80ba21d..0fcceda 100644 --- a/src/stream/chunk.hpp +++ b/src/stream/chunk.hpp @@ -22,11 +22,11 @@ #define INNOEXTRACT_STREAM_CHUNK_HPP #include -#include #include -#include +#include #include +#include #include "util/enum.hpp" @@ -54,8 +54,8 @@ struct chunk { size_t first_slice; //!< Slice where the chunk starts. size_t last_slice; - uint32_t offset; //!< Offset of the compressed chunk in firstSlice. - uint64_t size; //! Total compressed size of the chunk. + boost::uint32_t offset; //!< Offset of the compressed chunk in firstSlice. + boost::uint64_t size; //! Total compressed size of the chunk. compression_method compression; bool encrypted; diff --git a/src/stream/exefilter.hpp b/src/stream/exefilter.hpp index 5a0cb88..af449a6 100644 --- a/src/stream/exefilter.hpp +++ b/src/stream/exefilter.hpp @@ -21,10 +21,10 @@ #ifndef INNOEXTRACT_STREAM_EXEFILTER_HPP #define INNOEXTRACT_STREAM_EXEFILTER_HPP -#include #include #include +#include #include #include #include @@ -51,9 +51,9 @@ public: addr_bytes_left = 0, addr_offset = 5; } - uint32_t addr; + boost::uint32_t addr; size_t addr_bytes_left; - uint32_t addr_offset; + boost::uint32_t addr_offset; }; @@ -104,10 +104,10 @@ private: static const size_t block_size = 0x10000; const bool flip_high_byte; - uint32_t offset; //! Total number of bytes read from the source. + boost::uint32_t offset; //! Total number of bytes read from the source. - int8_t flush_bytes; - uint8_t buffer[4]; + boost::int8_t flush_bytes; + boost::uint8_t buffer[4]; }; @@ -131,13 +131,13 @@ std::streamsize inno_exe_decoder_4108::read(Source & src, char * dest, std::stre } } else { - addr += uint8_t(byte); - byte = uint8_t(addr); + addr += boost::uint8_t(byte); + byte = boost::uint8_t(addr); addr >>= 8; addr_bytes_left--; } - *dest++ = char(uint8_t(byte)); + *dest++ = char(boost::uint8_t(byte)); } return n; @@ -200,20 +200,20 @@ std::streamsize inno_exe_decoder_5200::read(Source & src, char * dest, std::stre char * dst = reinterpret_cast(buffer + 4 + flush_bytes); std::streamsize nread = boost::iostreams::read(src, dst, -flush_bytes); if(nread == EOF) { - flush(int8_t(4 + flush_bytes)); + flush(boost::int8_t(4 + flush_bytes)); return total_read ? total_read : EOF; } - flush_bytes = int8_t(flush_bytes + nread), offset += uint32_t(nread); + flush_bytes = boost::int8_t(flush_bytes + nread), offset += boost::uint32_t(nread); if(flush_bytes) { return total_read; } // Verify that the high byte of the address is 0x00 or 00xff. if(buffer[3] == 0x00 || buffer[3] == 0xff) { - uint32_t addr = offset & 0xffffff; // may wrap, but OK + boost::uint32_t addr = offset & 0xffffff; // may wrap, but OK - uint32_t rel = buffer[0] | (uint32_t(buffer[1]) << 8) | (uint32_t(buffer[2]) << 16); + boost::uint32_t rel = buffer[0] | (boost::uint32_t(buffer[1]) << 8) | (boost::uint32_t(buffer[2]) << 16); rel -= addr; - buffer[0] = uint8_t(rel), buffer[1] = uint8_t(rel >> 8), buffer[2] = uint8_t(rel >> 16); + buffer[0] = boost::uint8_t(rel), buffer[1] = boost::uint8_t(rel >> 8), buffer[2] = boost::uint8_t(rel >> 16); if(flip_high_byte) { // For a slightly higher compression ratio, we want the resulting high @@ -221,7 +221,7 @@ std::streamsize inno_exe_decoder_5200::read(Source & src, char * dest, std::stre // of the original relative address is likely to be the sign extension // of bit 23, so if bit 23 is set, toggle all bits in the high byte. if(rel & 0x800000) { - buffer[3] = uint8_t(~buffer[3]); + buffer[3] = boost::uint8_t(~buffer[3]); } } diff --git a/src/stream/file.cpp b/src/stream/file.cpp index 07595ec..fe61097 100644 --- a/src/stream/file.cpp +++ b/src/stream/file.cpp @@ -67,7 +67,7 @@ file_reader::pointer file_reader::get(base_type & base, const file & file, case InstructionFilter5309: result->push(inno_exe_decoder_5200(true), 8192); break; } - result->push(io::restrict(base, 0, int64_t(file.size))); + result->push(io::restrict(base, 0, boost::int64_t(file.size))); return result; } diff --git a/src/stream/file.hpp b/src/stream/file.hpp index 2acc3f1..090d32d 100644 --- a/src/stream/file.hpp +++ b/src/stream/file.hpp @@ -39,8 +39,8 @@ enum compression_filter { struct file { - uint64_t offset; //!< Offset of this file within the decompressed chunk. - uint64_t size; //!< Decompressed size of this file. + boost::uint64_t offset; //!< Offset of this file within the decompressed chunk. + boost::uint64_t size; //!< Decompressed size of this file. crypto::checksum checksum; diff --git a/src/stream/lzma.cpp b/src/stream/lzma.cpp index 8311077..aabfafe 100644 --- a/src/stream/lzma.cpp +++ b/src/stream/lzma.cpp @@ -20,7 +20,7 @@ #include "stream/lzma.hpp" -#include +#include #include @@ -30,7 +30,7 @@ static lzma_stream * init_raw_lzma_stream(lzma_vli filter, lzma_options_lzma & o options.preset_dict = NULL; - if(options.dict_size > (uint32_t(1) << 28)) { + if(options.dict_size > (boost::uint32_t(1) << 28)) { throw lzma_error("inno lzma dict size too large", LZMA_FORMAT_ERROR); } @@ -55,10 +55,10 @@ bool lzma_decompressor_impl_base::filter(const char * & begin_in, const char * e lzma_stream * strm = static_cast(stream); - strm->next_in = reinterpret_cast(begin_in); + strm->next_in = reinterpret_cast(begin_in); strm->avail_in = size_t(end_in - begin_in); - strm->next_out = reinterpret_cast(begin_out); + strm->next_out = reinterpret_cast(begin_out); strm->avail_out = size_t(end_out - begin_out); lzma_ret ret = lzma_code(strm, LZMA_RUN); @@ -98,7 +98,7 @@ bool inno_lzma1_decompressor_impl::filter(const char * & begin_in, const char * lzma_options_lzma options; - uint8_t properties = uint8_t(header[0]); + boost::uint8_t properties = boost::uint8_t(header[0]); if(properties > (9 * 5 * 5)) { throw lzma_error("inno lzma1 property error", LZMA_FORMAT_ERROR); } @@ -108,7 +108,7 @@ bool inno_lzma1_decompressor_impl::filter(const char * & begin_in, const char * options.dict_size = 0; for(size_t i = 0; i < 4; i++) { - options.dict_size += uint32_t(uint8_t(header[i + 1])) << (i * 8); + options.dict_size += boost::uint32_t(boost::uint8_t(header[i + 1])) << (i * 8); } stream = init_raw_lzma_stream(LZMA_FILTER_LZMA1, options); @@ -129,7 +129,7 @@ bool inno_lzma2_decompressor_impl::filter(const char * & begin_in, const char * lzma_options_lzma options; - uint8_t prop = uint8_t(*begin_in++); + boost::uint8_t prop = boost::uint8_t(*begin_in++); if(prop > 40) { throw lzma_error("inno lzma2 property error", LZMA_FORMAT_ERROR); } @@ -137,7 +137,7 @@ bool inno_lzma2_decompressor_impl::filter(const char * & begin_in, const char * if(prop == 40) { options.dict_size = 0xffffffff; } else { - options.dict_size = ((uint32_t(2) | uint32_t((prop) & 1)) << ((prop) / 2 + 11)); + options.dict_size = ((boost::uint32_t(2) | boost::uint32_t((prop) & 1)) << ((prop) / 2 + 11)); } stream = init_raw_lzma_stream(LZMA_FILTER_LZMA2, options); diff --git a/src/stream/slice.cpp b/src/stream/slice.cpp index d0a5714..89f82ab 100644 --- a/src/stream/slice.cpp +++ b/src/stream/slice.cpp @@ -20,11 +20,12 @@ #include "stream/slice.hpp" -#include #include #include #include +#include + #include "util/console.hpp" #include "util/load.hpp" #include "util/log.hpp" @@ -41,13 +42,13 @@ const char slice_ids[][8] = { } // anonymous namespace -slice_reader::slice_reader(const path_type & setup_file, uint32_t data_offset) +slice_reader::slice_reader(const path_type & setup_file, boost::uint32_t data_offset) : dir(), last_dir(), base_file(), data_offset(data_offset), slices_per_disk(1), current_slice(0) { ifs.open(setup_file, std::ios_base::binary | std::ios_base::in | std::ios_base::ate); - slice_size = uint32_t(std::min(ifs.tellg(), std::numeric_limits::max())); + slice_size = boost::uint32_t(std::min(ifs.tellg(), std::numeric_limits::max())); if(ifs.seekg(data_offset).fail()) { ifs.close(); } @@ -105,7 +106,7 @@ bool slice_reader::open_file(const path_type & file) { return false; } - slice_size = load_number(ifs); + slice_size = load_number(ifs); if(ifs.fail() || std::streampos(slice_size) > fileSize) { log_error << "[slice] bad slice size: " << slice_size << " > " << fileSize; ifs.close(); @@ -140,7 +141,7 @@ bool slice_reader::open(size_t slice, const path_type & file) { } else { size_t major = (slice / slices_per_disk) + 1; size_t minor = slice % slices_per_disk; - oss << major << char(uint8_t('a') + minor); + oss << major << char(boost::uint8_t('a') + minor); } oss << ".bin"; @@ -158,7 +159,7 @@ bool slice_reader::open(size_t slice, const path_type & file) { return false; } -bool slice_reader::seek(size_t slice, uint32_t offset) { +bool slice_reader::seek(size_t slice, boost::uint32_t offset) { if(!seek(slice)) { return false; diff --git a/src/stream/slice.hpp b/src/stream/slice.hpp index d266def..d044aed 100644 --- a/src/stream/slice.hpp +++ b/src/stream/slice.hpp @@ -34,12 +34,12 @@ class slice_reader : public boost::iostreams::source { path_type dir; path_type last_dir; path_type base_file; - const uint32_t data_offset; + const boost::uint32_t data_offset; const size_t slices_per_disk; size_t current_slice; path_type slice_file; - uint32_t slice_size; + boost::uint32_t slice_size; boost::filesystem::ifstream ifs; @@ -48,11 +48,11 @@ class slice_reader : public boost::iostreams::source { public: - slice_reader(const path_type & setup_file, uint32_t data_offset); + slice_reader(const path_type & setup_file, boost::uint32_t data_offset); slice_reader(const path_type & dir, const path_type & base_file, size_t slices_per_disk); - bool seek(size_t slice, uint32_t offset); + bool seek(size_t slice, boost::uint32_t offset); std::streamsize read(char * buffer, std::streamsize bytes); diff --git a/src/util/console.cpp b/src/util/console.cpp index 857b4e9..96d1e8e 100644 --- a/src/util/console.cpp +++ b/src/util/console.cpp @@ -225,12 +225,14 @@ static int query_screen_width() { #endif +#if !defined(_WIN32) try { char * columns = std::getenv("COLUMNS"); if(columns) { return boost::lexical_cast(columns); } } catch(...) { /* ignore bad values */ } +#endif // Assume a default screen width of 80 columns return 80; @@ -365,12 +367,12 @@ void progress::show_unbounded(float value, const std::string & label) { progress_cleared = false; } -progress::progress(uint64_t max, bool show_rate) +progress::progress(boost::uint64_t max, bool show_rate) : max(max), value(0), show_rate(show_rate), start_time(boost::posix_time::microsec_clock::universal_time()), last_status(-1.f), last_time(0), last_rate(0.f) { } -void progress::update(uint64_t delta, bool force) { +void progress::update(boost::uint64_t delta, bool force) { if(!show_progress) { return; @@ -390,9 +392,9 @@ void progress::update(uint64_t delta, bool force) { } boost::posix_time::ptime now(boost::posix_time::microsec_clock::universal_time()); - uint64_t time = uint64_t((now - start_time).total_microseconds()); + boost::uint64_t time = boost::uint64_t((now - start_time).total_microseconds()); - const uint64_t update_interval = 100000; + const boost::uint64_t update_interval = 100000; if(!force && time - last_time < update_interval) { return; } diff --git a/src/util/console.hpp b/src/util/console.hpp index 91d69c8..90f698b 100644 --- a/src/util/console.hpp +++ b/src/util/console.hpp @@ -22,7 +22,6 @@ #define INNOEXTRACT_UTIL_CONSOLE_HPP #include -#include #include #include #include @@ -84,27 +83,27 @@ void init(is_enabled color = automatic, is_enabled progress = automatic); class progress { - uint64_t max; - uint64_t value; + boost::uint64_t max; + boost::uint64_t value; bool show_rate; boost::posix_time::ptime start_time; float last_status; - uint64_t last_time; + boost::uint64_t last_time; float last_rate; std::ostringstream label; public: - progress(uint64_t max = 0, bool show_rate = true); + progress(boost::uint64_t max = 0, bool show_rate = true); progress(const progress & o) : max(o.max), value(o.value), show_rate(o.show_rate), start_time(o.start_time), last_status(o.last_status), last_time(o.last_time), last_rate(o.last_rate), label(o.label.str()) { } - void update(uint64_t delta = 0, bool force = false); + void update(boost::uint64_t delta = 0, bool force = false); static void show(float value, const std::string & label = std::string()); diff --git a/src/util/endian.hpp b/src/util/endian.hpp index 469d2b3..7caf6e6 100644 --- a/src/util/endian.hpp +++ b/src/util/endian.hpp @@ -29,29 +29,31 @@ #include #endif -inline uint8_t byteswap(uint8_t value) { +#include + +inline boost::uint8_t byteswap(boost::uint8_t value) { return value; } -inline int8_t byteswap(int8_t value) { - return int8_t(byteswap(uint8_t(value))); +inline boost::int8_t byteswap(boost::int8_t value) { + return boost::int8_t(byteswap(boost::uint8_t(value))); } -inline uint16_t byteswap(uint16_t value) { +inline boost::uint16_t byteswap(boost::uint16_t value) { #if defined(_MSC_VER) && _MSC_VER >= 1300 return _byteswap_ushort(value); #elif INNOEXTRACT_HAVE_BSWAP_16 return bswap_16(value); #else - return uint16_t((uint16_t(uint8_t(value)) << 8) | uint8_t(value >> 8)); + return boost::uint16_t((boost::uint16_t(boost::uint8_t(value)) << 8) | boost::uint8_t(value >> 8)); #endif } -inline int16_t byteswap(int16_t value) { - return int16_t(byteswap(uint16_t(value))); +inline boost::int16_t byteswap(boost::int16_t value) { + return boost::int16_t(byteswap(boost::uint16_t(value))); } -inline uint32_t byteswap(uint32_t value) { +inline boost::uint32_t byteswap(boost::uint32_t value) { #if defined(__GNUC__) && !defined(__PATHCC__) \ && __GNUC__ >= 4 && (__GNUC__ > 4 || __GNUC_MINOR__ >= 3) return __builtin_bswap32(value); @@ -60,15 +62,15 @@ inline uint32_t byteswap(uint32_t value) { #elif INNOEXTRACT_HAVE_BSWAP_32 return bswap_32(value); #else - return (uint32_t(byteswap(uint16_t(value))) << 16) | byteswap(uint16_t(value >> 16)); + return (boost::uint32_t(byteswap(boost::uint16_t(value))) << 16) | byteswap(boost::uint16_t(value >> 16)); #endif } -inline int32_t byteswap(int32_t value) { - return int32_t(byteswap(uint32_t(value))); +inline boost::int32_t byteswap(boost::int32_t value) { + return boost::int32_t(byteswap(boost::uint32_t(value))); } -inline uint64_t byteswap(uint64_t value) { +inline boost::uint64_t byteswap(boost::uint64_t value) { #if defined(__GNUC__) && !defined(__PATHCC__) \ && __GNUC__ >= 4 && (__GNUC__ > 4 || __GNUC_MINOR__ >= 3) return __builtin_bswap64(value); @@ -77,12 +79,12 @@ inline uint64_t byteswap(uint64_t value) { #elif INNOEXTRACT_HAVE_BSWAP_64 return bswap_64(value); #else - return (uint64_t(byteswap(uint32_t(value))) << 32) | byteswap(uint32_t(value >> 32)); + return (boost::uint64_t(byteswap(boost::uint32_t(value))) << 32) | byteswap(boost::uint32_t(value >> 32)); #endif } -inline int64_t byteswap(int64_t value) { - return int64_t(byteswap(uint64_t(value))); +inline boost::int64_t byteswap(boost::int64_t value) { + return boost::int64_t(byteswap(boost::uint64_t(value))); } template diff --git a/src/util/enum.hpp b/src/util/enum.hpp index d7848e9..49ef8f3 100644 --- a/src/util/enum.hpp +++ b/src/util/enum.hpp @@ -46,7 +46,7 @@ struct enum_names { const char * name; - const char * names[]; + const char * names[1]; }; diff --git a/src/util/load.cpp b/src/util/load.cpp index eca0dbd..245cbf1 100644 --- a/src/util/load.cpp +++ b/src/util/load.cpp @@ -32,11 +32,11 @@ namespace { -std::map converters; +std::map converters; -iconv_t get_converter(uint32_t codepage) { +iconv_t get_converter(boost::uint32_t codepage) { - std::map::iterator i = converters.find(codepage); + std::map::iterator i = converters.find(codepage); if(i != converters.end()) { return i->second; @@ -59,7 +59,7 @@ iconv_t get_converter(uint32_t codepage) { void binary_string::load(std::istream & is, std::string & target) { - int32_t length = load_number(is); + boost::int32_t length = load_number(is); if(is.fail()) { return; } @@ -68,14 +68,14 @@ void binary_string::load(std::istream & is, std::string & target) { while(length) { char buffer[10 * 1024]; - int32_t buf_size = std::min(length, int32_t(sizeof(buffer))); + boost::int32_t buf_size = std::min(length, boost::int32_t(sizeof(buffer))); is.read(buffer, buf_size); target.append(buffer, size_t(buf_size)); length -= buf_size; } } -void encoded_string::load(std::istream & is, std::string & target, uint32_t codepage) { +void encoded_string::load(std::istream & is, std::string & target, boost::uint32_t codepage) { std::string temp; binary_string::load(is, temp); @@ -83,7 +83,7 @@ void encoded_string::load(std::istream & is, std::string & target, uint32_t code to_utf8(temp, target, codepage); } -void to_utf8(const std::string & from, std::string & to, uint32_t codepage) { +void to_utf8(const std::string & from, std::string & to, boost::uint32_t codepage) { iconv_t converter = get_converter(codepage); diff --git a/src/util/load.hpp b/src/util/load.hpp index 9f545f2..81a0a09 100644 --- a/src/util/load.hpp +++ b/src/util/load.hpp @@ -21,11 +21,12 @@ #ifndef INNOEXTRACT_UTIL_LOAD_HPP #define INNOEXTRACT_UTIL_LOAD_HPP -#include #include #include #include +#include + #include "util/endian.hpp" #include "util/types.hpp" #include "util/util.hpp" @@ -45,17 +46,17 @@ inline std::istream & operator>>(std::istream & is, const binary_string & str) { return is; } -void to_utf8(const std::string & from, std::string & to, uint32_t codepage = 1252); +void to_utf8(const std::string & from, std::string & to, boost::uint32_t codepage = 1252); struct encoded_string { std::string & data; - uint32_t codepage; + boost::uint32_t codepage; - encoded_string(std::string & target, uint32_t _codepage) + encoded_string(std::string & target, boost::uint32_t _codepage) : data(target), codepage(_codepage) { } - static void load(std::istream & is, std::string & target, uint32_t codepage); + static void load(std::istream & is, std::string & target, boost::uint32_t codepage); }; @@ -108,12 +109,12 @@ T load_number(std::istream & is, size_t bits) { } template -void discard(T & is, uint64_t bytes) { +void discard(T & is, boost::uint64_t bytes) { char buf[1024]; while(bytes) { - std::streamsize n = std::streamsize(std::min(bytes, ARRAY_SIZE(buf))); + std::streamsize n = std::streamsize(std::min(bytes, ARRAY_SIZE(buf))); is.read(buf, n); - bytes -= uint64_t(n); + bytes -= boost::uint64_t(n); } } diff --git a/src/util/output.hpp b/src/util/output.hpp index 583948a..89824fd 100644 --- a/src/util/output.hpp +++ b/src/util/output.hpp @@ -21,10 +21,11 @@ #ifndef INNOEXTRACT_UTIL_OUTPUT_HPP #define INNOEXTRACT_UTIL_OUTPUT_HPP -#include #include #include +#include + #include "util/console.hpp" #include "util/util.hpp" @@ -172,8 +173,8 @@ std::ostream & operator<<(std::ostream & os, const print_bytes & s) { std::streamsize precision = os.precision(); - size_t frac = size_t(1024 * (s.value - T(uint64_t(s.value)))); - uint64_t whole = uint64_t(s.value); + size_t frac = size_t(1024 * (s.value - T(boost::uint64_t(s.value)))); + boost::uint64_t whole = boost::uint64_t(s.value); size_t i = 0; diff --git a/src/util/storedenum.hpp b/src/util/storedenum.hpp index eba695b..029fb52 100644 --- a/src/util/storedenum.hpp +++ b/src/util/storedenum.hpp @@ -21,13 +21,13 @@ #ifndef INNOEXTRACT_UTIL_STOREDENUM_HPP #define INNOEXTRACT_UTIL_STOREDENUM_HPP -#include #include #include -#include +#include #include #include +#include #include "util/enum.hpp" #include "util/load.hpp" @@ -69,7 +69,7 @@ public: explicit stored_enum(std::istream & is) { BOOST_STATIC_ASSERT(size <= (1 << 8)); - value = load_number(is); + value = load_number(is); } enum_type get() { @@ -92,7 +92,7 @@ public: template class stored_bitfield { - typedef uint8_t base_type; + typedef boost::uint8_t base_type; static const size_t base_size = sizeof(base_type) * 8; static const size_t count = (Bits + (base_size - 1)) / base_size; // ceildiv @@ -113,14 +113,14 @@ public: } } - uint64_t lower_bits() const { + boost::uint64_t lower_bits() const { - BOOST_STATIC_ASSERT(sizeof(uint64_t) % sizeof(base_type) == 0); + BOOST_STATIC_ASSERT(sizeof(boost::uint64_t) % sizeof(base_type) == 0); - uint64_t result = 0; + boost::uint64_t result = 0; - for(size_t i = 0; i < std::min(sizeof(uint64_t) / sizeof(base_type), size_t(count)); i++) { - result |= (uint64_t(bits[i]) << (i * base_size)); + for(size_t i = 0; i < std::min(sizeof(boost::uint64_t) / sizeof(base_type), size_t(count)); i++) { + result |= (boost::uint64_t(bits[i]) << (i * base_size)); } return result; @@ -168,13 +168,13 @@ public: flag_type get() { - uint64_t bits = this->lower_bits(); + boost::uint64_t bits = this->lower_bits(); flag_type result = 0; for(size_t i = 0; i < this->size; i++) { - if(bits & (uint64_t(1) << i)) { + if(bits & (boost::uint64_t(1) << i)) { result |= Mapping::values[i]; - bits &= ~(uint64_t(1) << i); + bits &= ~(boost::uint64_t(1) << i); } } @@ -207,7 +207,7 @@ private: std::istream & is; - typedef uint8_t stored_type; + typedef boost::uint8_t stored_type; static const size_t stored_bits = sizeof(stored_type) * 8; size_t pos; diff --git a/src/util/time.cpp b/src/util/time.cpp index 6cdf2b1..926bcbd 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -48,7 +48,7 @@ static void set_timezone(const char * value) { const char * variable = "TZ"; -#if defined(WIN32) +#if defined(_WIN32) SetEnvironmentVariable(variable, value); _tzset(); @@ -100,7 +100,7 @@ std::time_t parse_time(std::tm tm) { } -std::tm format_time(time_t t) { +std::tm format_time(std::time_t t) { std::tm ret; @@ -114,7 +114,7 @@ std::tm format_time(time_t t) { // Windows (MSVC) - _gmtime_s(&ret, &t); + gmtime_s(&ret, &t); #else @@ -174,7 +174,7 @@ static HANDLE open_file(LPCWSTR name) { #endif -bool set_file_time(const boost::filesystem::path & path, std::time_t t, uint32_t nsec) { +bool set_file_time(const boost::filesystem::path & path, std::time_t t, boost::uint32_t nsec) { #if INNOEXTRACT_HAVE_UTIMENSAT && INNOEXTRACT_HAVE_AT_FDCWD @@ -182,7 +182,7 @@ bool set_file_time(const boost::filesystem::path & path, std::time_t t, uint32_t struct timespec times[2]; times[0].tv_sec = t; - times[0].tv_nsec = int32_t(nsec); + times[0].tv_nsec = boost::int32_t(nsec); times[1] = times[0]; return (utimensat(AT_FDCWD, path.string().c_str(), times, 0) == 0); @@ -201,8 +201,8 @@ bool set_file_time(const boost::filesystem::path & path, std::time_t t, uint32_t } // Convert the std::time_t and nanoseconds to a FILETIME struct - static const int64_t FiletimeOffset = 0x19DB1DED53E8000ll; - int64_t time = int64_t(t) * 10000000 + int64_t(nsec) / 100; + static const boost::int64_t FiletimeOffset = 0x19DB1DED53E8000ll; + boost::int64_t time = boost::int64_t(t) * 10000000 + boost::int64_t(nsec) / 100; time += FiletimeOffset; FILETIME filetime; filetime.dwLowDateTime = DWORD(time); @@ -219,7 +219,7 @@ bool set_file_time(const boost::filesystem::path & path, std::time_t t, uint32_t struct timeval times[2]; times[0].tv_sec = t; - times[0].tv_usec = int32_t(nsec / 1000); + times[0].tv_usec = boost::int32_t(nsec / 1000); times[1] = times[0]; return (utimes(path.string().c_str(), times) == 0); diff --git a/src/util/time.hpp b/src/util/time.hpp index 24ede46..ee4e6d6 100644 --- a/src/util/time.hpp +++ b/src/util/time.hpp @@ -21,10 +21,10 @@ #ifndef INNOEXTRACT_UTIL_TIME_HPP #define INNOEXTRACT_UTIL_TIME_HPP -#include #include #include +#include #include namespace util { @@ -51,7 +51,7 @@ std::time_t to_local_time(std::time_t t); void set_local_timezone(std::string timezone); //! Set a file's creation/modification time -bool set_file_time(const boost::filesystem::path & path, std::time_t t, uint32_t nsec); +bool set_file_time(const boost::filesystem::path & path, std::time_t t, boost::uint32_t nsec); } // namespace util diff --git a/src/util/types.hpp b/src/util/types.hpp index 211c795..6c08a49 100644 --- a/src/util/types.hpp +++ b/src/util/types.hpp @@ -44,22 +44,22 @@ namespace detail { template <> struct uint_t<8> : public boost::uint_t<8> { - typedef uint8_t exact; + typedef boost::uint8_t exact; }; template <> struct uint_t<16> : public boost::uint_t<16> { - typedef uint16_t exact; + typedef boost::uint16_t exact; }; template <> struct uint_t<32> : public boost::uint_t<32> { - typedef uint32_t exact; + typedef boost::uint32_t exact; }; template <> struct uint_t<64> { - typedef uint64_t exact; + typedef boost::uint64_t exact; }; template @@ -67,22 +67,22 @@ namespace detail { template <> struct int_t<8> : public boost::int_t<8> { - typedef int8_t exact; + typedef boost::int8_t exact; }; template <> struct int_t<16> : public boost::int_t<16> { - typedef int16_t exact; + typedef boost::int16_t exact; }; template <> struct int_t<32> : public boost::int_t<32> { - typedef int32_t exact; + typedef boost::int32_t exact; }; template <> struct int_t<64> { - typedef int64_t exact; + typedef boost::int64_t exact; }; } diff --git a/src/util/util.hpp b/src/util/util.hpp index ac057e0..463bab2 100644 --- a/src/util/util.hpp +++ b/src/util/util.hpp @@ -21,6 +21,10 @@ #ifndef INNOEXTRACT_UTIL_UTIL_HPP #define INNOEXTRACT_UTIL_UTIL_HPP +#ifdef _MSC_VER +#include +#endif + #define ARRAY_SIZE(array) (sizeof(array)/sizeof(*(array))) template @@ -88,27 +92,24 @@ template T rotl_fixed(T x, unsigned int y) { #if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(__INTEL_COMPILER) -template<> uint8_t rotl_fixed(uint8_t x, unsigned int y) { +template<> inline unsigned char rotl_fixed(unsigned char x, unsigned int y) { return y ? _rotl8(x, y) : x; } -// Intel C++ Compiler 10.0 gives undefined externals with these -template<> uint16_t rotl_fixed(uint16_t x, unsigned int y) { +template<> inline unsigned short rotl_fixed(unsigned short x, unsigned int y) { return y ? _rotl16(x, y) : x; } #endif #ifdef _MSC_VER -template<> uint32_t rotl_fixed(uint32_t x, unsigned int y) { +template<> inline unsigned long rotl_fixed(unsigned long x, unsigned int y) { return y ? _lrotl(x, y) : x; } #endif #if defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(__INTEL_COMPILER) -// Intel C++ Compiler 10.0 calls a function instead of using the rotate instruction when -// using these instructions -template<> uint64_t rotl_fixed(uint64_t x, unsigned int y) { +template<> inline __int64 rotl_fixed<__int64>(__int64 x, unsigned int y) { return y ? _rotl64(x, y) : x; } #endif