From abc634a53ae526820f107b97d5af6e14ed5aa7e1 Mon Sep 17 00:00:00 2001 From: Jai <814683@qq.com> Date: Mon, 30 Oct 2023 14:18:06 +0800 Subject: [PATCH] refactor: Use https://github.com/wc3tools/stormlib-rs --- .gitmodules | 3 + Cargo.toml | 4 +- crates/stormlib-bindgen/Cargo.toml | 10 + crates/stormlib-bindgen/src/main.rs | 220 + crates/stormlib-bindgen/src/wrapper.hpp | 4 + crates/stormlib-sys/Cargo.toml | 13 + crates/stormlib-sys/build.rs | 55 + crates/stormlib-sys/src/bindings_linux.rs | 921 + crates/stormlib-sys/src/bindings_macos.rs | 986 + crates/stormlib-sys/src/bindings_windows.rs | 41092 ++++++++++++++++ crates/stormlib-sys/src/lib.rs | 78 + crates/stormlib/Cargo.toml | 16 + crates/stormlib/src/constants.rs | 27 + crates/stormlib/src/error.rs | 80 + crates/stormlib/src/lib.rs | 354 + crates/stormlib/src/util.rs | 11 + libs/ceres-mpq/Cargo.toml | 11 - libs/ceres-mpq/src/lib.rs | 356 - libs/storm-sys/Cargo.toml | 12 - libs/storm-sys/StormCommon.h | 385 - libs/storm-sys/StormLib.h | 1124 - libs/storm-sys/StormLib/LICENSE | 21 - libs/storm-sys/StormLib/src/FileStream.cpp | 2668 - libs/storm-sys/StormLib/src/FileStream.h | 217 - libs/storm-sys/StormLib/src/SBaseCommon.cpp | 1842 - libs/storm-sys/StormLib/src/SBaseDumpData.cpp | 189 - .../storm-sys/StormLib/src/SBaseFileTable.cpp | 2958 -- libs/storm-sys/StormLib/src/SBaseSubTypes.cpp | 618 - libs/storm-sys/StormLib/src/SCompression.cpp | 1145 - libs/storm-sys/StormLib/src/SFileAddFile.cpp | 1312 - .../StormLib/src/SFileAttributes.cpp | 570 - .../StormLib/src/SFileCompactArchive.cpp | 654 - .../StormLib/src/SFileCreateArchive.cpp | 274 - .../StormLib/src/SFileExtractFile.cpp | 64 - libs/storm-sys/StormLib/src/SFileFindFile.cpp | 479 - .../StormLib/src/SFileGetFileInfo.cpp | 1003 - libs/storm-sys/StormLib/src/SFileListFile.cpp | 668 - .../StormLib/src/SFileOpenArchive.cpp | 601 - .../StormLib/src/SFileOpenFileEx.cpp | 399 - .../StormLib/src/SFilePatchArchives.cpp | 1175 - libs/storm-sys/StormLib/src/SFileReadFile.cpp | 899 - libs/storm-sys/StormLib/src/SFileVerify.cpp | 1054 - libs/storm-sys/StormLib/src/StormCommon.h | 385 - libs/storm-sys/StormLib/src/StormLib.h | 1124 - libs/storm-sys/StormLib/src/StormPort.h | 300 - libs/storm-sys/StormLib/src/adpcm/adpcm.cpp | 401 - libs/storm-sys/StormLib/src/adpcm/adpcm.h | 26 - .../StormLib/src/adpcm/adpcm_old.cpp | 358 - libs/storm-sys/StormLib/src/adpcm/adpcm_old.h | 22 - libs/storm-sys/StormLib/src/bzip2/blocksort.c | 1094 - libs/storm-sys/StormLib/src/bzip2/bzlib.c | 1573 - libs/storm-sys/StormLib/src/bzip2/bzlib.h | 282 - .../StormLib/src/bzip2/bzlib_private.h | 509 - libs/storm-sys/StormLib/src/bzip2/compress.c | 672 - libs/storm-sys/StormLib/src/bzip2/crctable.c | 104 - .../storm-sys/StormLib/src/bzip2/decompress.c | 626 - libs/storm-sys/StormLib/src/bzip2/huffman.c | 205 - libs/storm-sys/StormLib/src/bzip2/randtable.c | 84 - libs/storm-sys/StormLib/src/huffman/huff.cpp | 873 - libs/storm-sys/StormLib/src/huffman/huff.h | 143 - libs/storm-sys/StormLib/src/jenkins/lookup.h | 24 - libs/storm-sys/StormLib/src/jenkins/lookup3.c | 1003 - .../src/libtomcrypt/src/hashes/hash_memory.c | 69 - .../StormLib/src/libtomcrypt/src/hashes/md5.c | 368 - .../src/libtomcrypt/src/hashes/sha1.c | 288 - .../src/libtomcrypt/src/headers/tomcrypt.h | 91 - .../libtomcrypt/src/headers/tomcrypt_argchk.h | 38 - .../libtomcrypt/src/headers/tomcrypt_cfg.h | 136 - .../libtomcrypt/src/headers/tomcrypt_cipher.h | 891 - .../libtomcrypt/src/headers/tomcrypt_custom.h | 424 - .../libtomcrypt/src/headers/tomcrypt_hash.h | 378 - .../libtomcrypt/src/headers/tomcrypt_mac.h | 384 - .../libtomcrypt/src/headers/tomcrypt_macros.h | 424 - .../libtomcrypt/src/headers/tomcrypt_math.h | 500 - .../libtomcrypt/src/headers/tomcrypt_misc.h | 23 - .../src/libtomcrypt/src/headers/tomcrypt_pk.h | 558 - .../libtomcrypt/src/headers/tomcrypt_pkcs.h | 89 - .../libtomcrypt/src/headers/tomcrypt_prng.h | 199 - .../src/libtomcrypt/src/math/ltm_desc.c | 483 - .../StormLib/src/libtomcrypt/src/math/multi.c | 61 - .../src/libtomcrypt/src/math/rand_prime.c | 87 - .../src/libtomcrypt/src/misc/base64_decode.c | 104 - .../src/libtomcrypt/src/misc/crypt_argchk.c | 30 - .../libtomcrypt/src/misc/crypt_find_hash.c | 40 - .../libtomcrypt/src/misc/crypt_find_prng.c | 41 - .../src/misc/crypt_hash_descriptor.c | 27 - .../src/misc/crypt_hash_is_valid.c | 36 - .../src/libtomcrypt/src/misc/crypt_libc.c | 43 - .../src/misc/crypt_ltc_mp_descriptor.c | 13 - .../src/misc/crypt_prng_descriptor.c | 26 - .../src/misc/crypt_prng_is_valid.c | 36 - .../src/misc/crypt_register_hash.c | 54 - .../src/misc/crypt_register_prng.c | 54 - .../src/libtomcrypt/src/misc/zeromem.c | 34 - .../src/pk/asn1/der_decode_bit_string.c | 102 - .../src/pk/asn1/der_decode_boolean.c | 47 - .../src/pk/asn1/der_decode_choice.c | 182 - .../src/pk/asn1/der_decode_ia5_string.c | 96 - .../src/pk/asn1/der_decode_integer.c | 110 - .../pk/asn1/der_decode_object_identifier.c | 99 - .../src/pk/asn1/der_decode_octet_string.c | 91 - .../src/pk/asn1/der_decode_printable_string.c | 96 - .../src/pk/asn1/der_decode_sequence_ex.c | 287 - .../src/pk/asn1/der_decode_sequence_flexi.c | 386 - .../src/pk/asn1/der_decode_sequence_multi.c | 139 - .../src/pk/asn1/der_decode_short_integer.c | 68 - .../src/pk/asn1/der_decode_utctime.c | 127 - .../src/pk/asn1/der_decode_utf8_string.c | 111 - .../src/pk/asn1/der_encode_bit_string.c | 89 - .../src/pk/asn1/der_encode_boolean.c | 51 - .../src/pk/asn1/der_encode_ia5_string.c | 85 - .../src/pk/asn1/der_encode_integer.c | 130 - .../pk/asn1/der_encode_object_identifier.c | 111 - .../src/pk/asn1/der_encode_octet_string.c | 86 - .../src/pk/asn1/der_encode_printable_string.c | 85 - .../src/pk/asn1/der_encode_sequence_ex.c | 335 - .../src/pk/asn1/der_encode_sequence_multi.c | 138 - .../libtomcrypt/src/pk/asn1/der_encode_set.c | 103 - .../src/pk/asn1/der_encode_setof.c | 162 - .../src/pk/asn1/der_encode_short_integer.c | 97 - .../src/pk/asn1/der_encode_utctime.c | 83 - .../src/pk/asn1/der_encode_utf8_string.c | 105 - .../src/pk/asn1/der_length_bit_string.c | 54 - .../src/pk/asn1/der_length_boolean.c | 35 - .../src/pk/asn1/der_length_ia5_string.c | 194 - .../src/pk/asn1/der_length_integer.c | 82 - .../pk/asn1/der_length_object_identifier.c | 89 - .../src/pk/asn1/der_length_octet_string.c | 53 - .../src/pk/asn1/der_length_printable_string.c | 166 - .../src/pk/asn1/der_length_sequence.c | 169 - .../src/pk/asn1/der_length_short_integer.c | 70 - .../src/pk/asn1/der_length_utctime.c | 46 - .../src/pk/asn1/der_length_utf8_string.c | 83 - .../src/pk/asn1/der_sequence_free.c | 65 - .../src/libtomcrypt/src/pk/ecc/ltc_ecc_map.c | 76 - .../libtomcrypt/src/pk/ecc/ltc_ecc_mul2add.c | 207 - .../libtomcrypt/src/pk/ecc/ltc_ecc_mulmod.c | 222 - .../libtomcrypt/src/pk/ecc/ltc_ecc_points.c | 60 - .../src/pk/ecc/ltc_ecc_projective_add_point.c | 196 - .../src/pk/ecc/ltc_ecc_projective_dbl_point.c | 147 - .../libtomcrypt/src/pk/pkcs1/pkcs_1_mgf1.c | 108 - .../src/pk/pkcs1/pkcs_1_oaep_decode.c | 189 - .../src/pk/pkcs1/pkcs_1_pss_decode.c | 177 - .../src/pk/pkcs1/pkcs_1_pss_encode.c | 175 - .../src/pk/pkcs1/pkcs_1_v1_5_decode.c | 110 - .../src/pk/pkcs1/pkcs_1_v1_5_encode.c | 111 - .../src/libtomcrypt/src/pk/rsa/rsa_exptmod.c | 113 - .../src/libtomcrypt/src/pk/rsa/rsa_free.c | 34 - .../src/libtomcrypt/src/pk/rsa/rsa_import.c | 143 - .../src/libtomcrypt/src/pk/rsa/rsa_make_key.c | 112 - .../libtomcrypt/src/pk/rsa/rsa_sign_hash.c | 134 - .../libtomcrypt/src/pk/rsa/rsa_verify_hash.c | 167 - .../src/pk/rsa/rsa_verify_simple.c | 87 - .../src/libtommath/bn_fast_mp_invmod.c | 148 - .../libtommath/bn_fast_mp_montgomery_reduce.c | 172 - .../src/libtommath/bn_fast_s_mp_mul_digs.c | 107 - .../libtommath/bn_fast_s_mp_mul_high_digs.c | 98 - .../src/libtommath/bn_fast_s_mp_sqr.c | 114 - .../StormLib/src/libtommath/bn_mp_2expt.c | 48 - .../StormLib/src/libtommath/bn_mp_abs.c | 43 - .../StormLib/src/libtommath/bn_mp_add.c | 53 - .../StormLib/src/libtommath/bn_mp_add_d.c | 112 - .../StormLib/src/libtommath/bn_mp_addmod.c | 41 - .../StormLib/src/libtommath/bn_mp_and.c | 57 - .../StormLib/src/libtommath/bn_mp_clamp.c | 44 - .../StormLib/src/libtommath/bn_mp_clear.c | 44 - .../src/libtommath/bn_mp_clear_multi.c | 34 - .../StormLib/src/libtommath/bn_mp_cmp.c | 43 - .../StormLib/src/libtommath/bn_mp_cmp_d.c | 44 - .../StormLib/src/libtommath/bn_mp_cmp_mag.c | 55 - .../StormLib/src/libtommath/bn_mp_cnt_lsb.c | 53 - .../StormLib/src/libtommath/bn_mp_copy.c | 68 - .../src/libtommath/bn_mp_count_bits.c | 45 - .../StormLib/src/libtommath/bn_mp_div.c | 292 - .../StormLib/src/libtommath/bn_mp_div_2.c | 68 - .../StormLib/src/libtommath/bn_mp_div_2d.c | 97 - .../StormLib/src/libtommath/bn_mp_div_3.c | 79 - .../StormLib/src/libtommath/bn_mp_div_d.c | 115 - .../src/libtommath/bn_mp_dr_is_modulus.c | 43 - .../StormLib/src/libtommath/bn_mp_dr_reduce.c | 94 - .../StormLib/src/libtommath/bn_mp_dr_setup.c | 32 - .../StormLib/src/libtommath/bn_mp_exch.c | 34 - .../StormLib/src/libtommath/bn_mp_expt_d.c | 57 - .../StormLib/src/libtommath/bn_mp_exptmod.c | 112 - .../src/libtommath/bn_mp_exptmod_fast.c | 321 - .../StormLib/src/libtommath/bn_mp_exteuclid.c | 82 - .../StormLib/src/libtommath/bn_mp_fread.c | 67 - .../StormLib/src/libtommath/bn_mp_fwrite.c | 52 - .../StormLib/src/libtommath/bn_mp_gcd.c | 105 - .../StormLib/src/libtommath/bn_mp_get_int.c | 45 - .../StormLib/src/libtommath/bn_mp_grow.c | 57 - .../StormLib/src/libtommath/bn_mp_init.c | 46 - .../StormLib/src/libtommath/bn_mp_init_copy.c | 32 - .../src/libtommath/bn_mp_init_multi.c | 59 - .../StormLib/src/libtommath/bn_mp_init_set.c | 32 - .../src/libtommath/bn_mp_init_set_int.c | 31 - .../StormLib/src/libtommath/bn_mp_init_size.c | 48 - .../StormLib/src/libtommath/bn_mp_invmod.c | 43 - .../src/libtommath/bn_mp_invmod_slow.c | 175 - .../StormLib/src/libtommath/bn_mp_is_square.c | 109 - .../StormLib/src/libtommath/bn_mp_jacobi.c | 105 - .../src/libtommath/bn_mp_karatsuba_mul.c | 167 - .../src/libtommath/bn_mp_karatsuba_sqr.c | 121 - .../StormLib/src/libtommath/bn_mp_lcm.c | 60 - .../StormLib/src/libtommath/bn_mp_lshd.c | 67 - .../StormLib/src/libtommath/bn_mp_mod.c | 48 - .../StormLib/src/libtommath/bn_mp_mod_2d.c | 55 - .../StormLib/src/libtommath/bn_mp_mod_d.c | 27 - .../bn_mp_montgomery_calc_normalization.c | 59 - .../src/libtommath/bn_mp_montgomery_reduce.c | 118 - .../src/libtommath/bn_mp_montgomery_setup.c | 59 - .../StormLib/src/libtommath/bn_mp_mul.c | 66 - .../StormLib/src/libtommath/bn_mp_mul_2.c | 82 - .../StormLib/src/libtommath/bn_mp_mul_2d.c | 85 - .../StormLib/src/libtommath/bn_mp_mul_d.c | 79 - .../StormLib/src/libtommath/bn_mp_mulmod.c | 40 - .../StormLib/src/libtommath/bn_mp_n_root.c | 132 - .../StormLib/src/libtommath/bn_mp_neg.c | 40 - .../StormLib/src/libtommath/bn_mp_or.c | 50 - .../src/libtommath/bn_mp_prime_fermat.c | 62 - .../src/libtommath/bn_mp_prime_is_divisible.c | 50 - .../src/libtommath/bn_mp_prime_is_prime.c | 83 - .../src/libtommath/bn_mp_prime_miller_rabin.c | 103 - .../src/libtommath/bn_mp_prime_next_prime.c | 170 - .../bn_mp_prime_rabin_miller_trials.c | 52 - .../src/libtommath/bn_mp_prime_random_ex.c | 125 - .../src/libtommath/bn_mp_radix_size.c | 78 - .../src/libtommath/bn_mp_radix_smap.c | 24 - .../StormLib/src/libtommath/bn_mp_rand.c | 55 - .../src/libtommath/bn_mp_read_radix.c | 85 - .../src/libtommath/bn_mp_read_signed_bin.c | 41 - .../src/libtommath/bn_mp_read_unsigned_bin.c | 55 - .../StormLib/src/libtommath/bn_mp_reduce.c | 100 - .../StormLib/src/libtommath/bn_mp_reduce_2k.c | 61 - .../src/libtommath/bn_mp_reduce_2k_l.c | 62 - .../src/libtommath/bn_mp_reduce_2k_setup.c | 47 - .../src/libtommath/bn_mp_reduce_2k_setup_l.c | 44 - .../src/libtommath/bn_mp_reduce_is_2k.c | 52 - .../src/libtommath/bn_mp_reduce_is_2k_l.c | 44 - .../src/libtommath/bn_mp_reduce_setup.c | 34 - .../StormLib/src/libtommath/bn_mp_rshd.c | 72 - .../StormLib/src/libtommath/bn_mp_set.c | 29 - .../StormLib/src/libtommath/bn_mp_set_int.c | 48 - .../StormLib/src/libtommath/bn_mp_shrink.c | 35 - .../src/libtommath/bn_mp_signed_bin_size.c | 27 - .../StormLib/src/libtommath/bn_mp_sqr.c | 58 - .../StormLib/src/libtommath/bn_mp_sqrmod.c | 41 - .../StormLib/src/libtommath/bn_mp_sqrt.c | 81 - .../StormLib/src/libtommath/bn_mp_sub.c | 59 - .../StormLib/src/libtommath/bn_mp_sub_d.c | 93 - .../StormLib/src/libtommath/bn_mp_submod.c | 42 - .../src/libtommath/bn_mp_to_signed_bin.c | 33 - .../src/libtommath/bn_mp_to_signed_bin_n.c | 31 - .../src/libtommath/bn_mp_to_unsigned_bin.c | 48 - .../src/libtommath/bn_mp_to_unsigned_bin_n.c | 31 - .../StormLib/src/libtommath/bn_mp_toom_mul.c | 284 - .../StormLib/src/libtommath/bn_mp_toom_sqr.c | 226 - .../StormLib/src/libtommath/bn_mp_toradix.c | 75 - .../StormLib/src/libtommath/bn_mp_toradix_n.c | 88 - .../src/libtommath/bn_mp_unsigned_bin_size.c | 28 - .../StormLib/src/libtommath/bn_mp_xor.c | 51 - .../StormLib/src/libtommath/bn_mp_zero.c | 36 - .../StormLib/src/libtommath/bn_prime_tab.c | 61 - .../StormLib/src/libtommath/bn_reverse.c | 39 - .../StormLib/src/libtommath/bn_s_mp_add.c | 109 - .../StormLib/src/libtommath/bn_s_mp_exptmod.c | 252 - .../src/libtommath/bn_s_mp_mul_digs.c | 90 - .../src/libtommath/bn_s_mp_mul_high_digs.c | 81 - .../StormLib/src/libtommath/bn_s_mp_sqr.c | 84 - .../StormLib/src/libtommath/bn_s_mp_sub.c | 89 - .../StormLib/src/libtommath/bncore.c | 36 - .../StormLib/src/libtommath/tommath.h | 584 - .../StormLib/src/libtommath/tommath_class.h | 999 - .../src/libtommath/tommath_superclass.h | 76 - libs/storm-sys/StormLib/src/lzma/C/LzFind.c | 761 - libs/storm-sys/StormLib/src/lzma/C/LzFind.h | 115 - libs/storm-sys/StormLib/src/lzma/C/LzFindMt.c | 793 - libs/storm-sys/StormLib/src/lzma/C/LzFindMt.h | 105 - libs/storm-sys/StormLib/src/lzma/C/LzHash.h | 54 - libs/storm-sys/StormLib/src/lzma/C/LzmaDec.c | 999 - libs/storm-sys/StormLib/src/lzma/C/LzmaDec.h | 231 - libs/storm-sys/StormLib/src/lzma/C/LzmaEnc.c | 2268 - libs/storm-sys/StormLib/src/lzma/C/LzmaEnc.h | 80 - libs/storm-sys/StormLib/src/lzma/C/Threads.c | 84 - libs/storm-sys/StormLib/src/lzma/C/Threads.h | 59 - libs/storm-sys/StormLib/src/lzma/C/Types.h | 236 - libs/storm-sys/StormLib/src/lzma/info.txt | 1 - libs/storm-sys/StormLib/src/pklib/crc32.c | 66 - libs/storm-sys/StormLib/src/pklib/explode.c | 522 - libs/storm-sys/StormLib/src/pklib/implode.c | 769 - libs/storm-sys/StormLib/src/pklib/pklib.h | 146 - libs/storm-sys/StormLib/src/sparse/sparse.cpp | 282 - libs/storm-sys/StormLib/src/sparse/sparse.h | 17 - libs/storm-sys/StormLib/src/wrapper.h | 1 - libs/storm-sys/StormLib/src/zlib/adler32.c | 169 - libs/storm-sys/StormLib/src/zlib/compress.c | 80 - .../StormLib/src/zlib/compress_zlib.c | 5 - libs/storm-sys/StormLib/src/zlib/crc32.c | 442 - libs/storm-sys/StormLib/src/zlib/crc32.h | 441 - libs/storm-sys/StormLib/src/zlib/deflate.c | 1834 - libs/storm-sys/StormLib/src/zlib/deflate.h | 342 - libs/storm-sys/StormLib/src/zlib/inffast.c | 340 - libs/storm-sys/StormLib/src/zlib/inffast.h | 11 - libs/storm-sys/StormLib/src/zlib/inffixed.h | 94 - libs/storm-sys/StormLib/src/zlib/inflate.c | 1480 - libs/storm-sys/StormLib/src/zlib/inflate.h | 122 - libs/storm-sys/StormLib/src/zlib/inftrees.c | 330 - libs/storm-sys/StormLib/src/zlib/inftrees.h | 62 - libs/storm-sys/StormLib/src/zlib/trees.c | 1244 - libs/storm-sys/StormLib/src/zlib/trees.h | 128 - libs/storm-sys/StormLib/src/zlib/zconf.h | 428 - libs/storm-sys/StormLib/src/zlib/zlib.h | 1613 - libs/storm-sys/StormLib/src/zlib/zutil.c | 318 - libs/storm-sys/StormLib/src/zlib/zutil.h | 274 - libs/storm-sys/StormPort.h | 300 - libs/storm-sys/build.rs | 102 - libs/storm-sys/src/lib.rs | 9 - libs/storm-sys/src/storm.rs | 3273 -- src/main.rs | 37 +- 319 files changed, 43886 insertions(+), 75518 deletions(-) create mode 100644 .gitmodules create mode 100644 crates/stormlib-bindgen/Cargo.toml create mode 100644 crates/stormlib-bindgen/src/main.rs create mode 100644 crates/stormlib-bindgen/src/wrapper.hpp create mode 100644 crates/stormlib-sys/Cargo.toml create mode 100644 crates/stormlib-sys/build.rs create mode 100644 crates/stormlib-sys/src/bindings_linux.rs create mode 100644 crates/stormlib-sys/src/bindings_macos.rs create mode 100644 crates/stormlib-sys/src/bindings_windows.rs create mode 100644 crates/stormlib-sys/src/lib.rs create mode 100644 crates/stormlib/Cargo.toml create mode 100644 crates/stormlib/src/constants.rs create mode 100644 crates/stormlib/src/error.rs create mode 100644 crates/stormlib/src/lib.rs create mode 100644 crates/stormlib/src/util.rs delete mode 100644 libs/ceres-mpq/Cargo.toml delete mode 100644 libs/ceres-mpq/src/lib.rs delete mode 100644 libs/storm-sys/Cargo.toml delete mode 100644 libs/storm-sys/StormCommon.h delete mode 100644 libs/storm-sys/StormLib.h delete mode 100644 libs/storm-sys/StormLib/LICENSE delete mode 100644 libs/storm-sys/StormLib/src/FileStream.cpp delete mode 100644 libs/storm-sys/StormLib/src/FileStream.h delete mode 100644 libs/storm-sys/StormLib/src/SBaseCommon.cpp delete mode 100644 libs/storm-sys/StormLib/src/SBaseDumpData.cpp delete mode 100644 libs/storm-sys/StormLib/src/SBaseFileTable.cpp delete mode 100644 libs/storm-sys/StormLib/src/SBaseSubTypes.cpp delete mode 100644 libs/storm-sys/StormLib/src/SCompression.cpp delete mode 100644 libs/storm-sys/StormLib/src/SFileAddFile.cpp delete mode 100644 libs/storm-sys/StormLib/src/SFileAttributes.cpp delete mode 100644 libs/storm-sys/StormLib/src/SFileCompactArchive.cpp delete mode 100644 libs/storm-sys/StormLib/src/SFileCreateArchive.cpp delete mode 100644 libs/storm-sys/StormLib/src/SFileExtractFile.cpp delete mode 100644 libs/storm-sys/StormLib/src/SFileFindFile.cpp delete mode 100644 libs/storm-sys/StormLib/src/SFileGetFileInfo.cpp delete mode 100644 libs/storm-sys/StormLib/src/SFileListFile.cpp delete mode 100644 libs/storm-sys/StormLib/src/SFileOpenArchive.cpp delete mode 100644 libs/storm-sys/StormLib/src/SFileOpenFileEx.cpp delete mode 100644 libs/storm-sys/StormLib/src/SFilePatchArchives.cpp delete mode 100644 libs/storm-sys/StormLib/src/SFileReadFile.cpp delete mode 100644 libs/storm-sys/StormLib/src/SFileVerify.cpp delete mode 100644 libs/storm-sys/StormLib/src/StormCommon.h delete mode 100644 libs/storm-sys/StormLib/src/StormLib.h delete mode 100644 libs/storm-sys/StormLib/src/StormPort.h delete mode 100644 libs/storm-sys/StormLib/src/adpcm/adpcm.cpp delete mode 100644 libs/storm-sys/StormLib/src/adpcm/adpcm.h delete mode 100644 libs/storm-sys/StormLib/src/adpcm/adpcm_old.cpp delete mode 100644 libs/storm-sys/StormLib/src/adpcm/adpcm_old.h delete mode 100644 libs/storm-sys/StormLib/src/bzip2/blocksort.c delete mode 100644 libs/storm-sys/StormLib/src/bzip2/bzlib.c delete mode 100644 libs/storm-sys/StormLib/src/bzip2/bzlib.h delete mode 100644 libs/storm-sys/StormLib/src/bzip2/bzlib_private.h delete mode 100644 libs/storm-sys/StormLib/src/bzip2/compress.c delete mode 100644 libs/storm-sys/StormLib/src/bzip2/crctable.c delete mode 100644 libs/storm-sys/StormLib/src/bzip2/decompress.c delete mode 100644 libs/storm-sys/StormLib/src/bzip2/huffman.c delete mode 100644 libs/storm-sys/StormLib/src/bzip2/randtable.c delete mode 100644 libs/storm-sys/StormLib/src/huffman/huff.cpp delete mode 100644 libs/storm-sys/StormLib/src/huffman/huff.h delete mode 100644 libs/storm-sys/StormLib/src/jenkins/lookup.h delete mode 100644 libs/storm-sys/StormLib/src/jenkins/lookup3.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/hashes/hash_memory.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/hashes/md5.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/hashes/sha1.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt.h delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_argchk.h delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_cfg.h delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_cipher.h delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_custom.h delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_hash.h delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_mac.h delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_macros.h delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_math.h delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_misc.h delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_pk.h delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_pkcs.h delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_prng.h delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/math/ltm_desc.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/math/multi.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/math/rand_prime.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/misc/base64_decode.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_argchk.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_find_hash.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_find_prng.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_hash_descriptor.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_hash_is_valid.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_libc.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_ltc_mp_descriptor.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_prng_descriptor.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_prng_is_valid.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_register_hash.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_register_prng.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/misc/zeromem.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_bit_string.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_boolean.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_choice.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_ia5_string.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_integer.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_object_identifier.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_octet_string.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_printable_string.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_sequence_ex.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_sequence_flexi.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_sequence_multi.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_short_integer.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_utctime.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_utf8_string.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_bit_string.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_boolean.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_ia5_string.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_integer.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_object_identifier.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_octet_string.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_printable_string.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_sequence_ex.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_sequence_multi.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_set.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_setof.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_short_integer.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_utctime.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_utf8_string.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_bit_string.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_boolean.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_ia5_string.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_integer.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_object_identifier.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_octet_string.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_printable_string.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_sequence.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_short_integer.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_utctime.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_utf8_string.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_sequence_free.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_map.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_mul2add.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_mulmod.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_points.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_projective_add_point.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_projective_dbl_point.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_mgf1.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_decode.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_pss_decode.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_pss_encode.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_decode.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_encode.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_exptmod.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_free.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_import.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_make_key.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_sign_hash.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_verify_hash.c delete mode 100644 libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_verify_simple.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_fast_mp_invmod.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_fast_mp_montgomery_reduce.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_fast_s_mp_mul_digs.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_fast_s_mp_mul_high_digs.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_fast_s_mp_sqr.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_2expt.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_abs.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_add.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_add_d.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_addmod.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_and.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_clamp.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_clear.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_clear_multi.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_cmp.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_cmp_d.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_cmp_mag.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_cnt_lsb.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_copy.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_count_bits.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_div.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_div_2.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_div_2d.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_div_3.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_div_d.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_dr_is_modulus.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_dr_reduce.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_dr_setup.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_exch.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_expt_d.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_exptmod.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_exptmod_fast.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_exteuclid.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_fread.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_fwrite.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_gcd.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_get_int.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_grow.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_init.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_init_copy.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_init_multi.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_init_set.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_init_set_int.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_init_size.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_invmod.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_invmod_slow.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_is_square.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_jacobi.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_karatsuba_mul.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_karatsuba_sqr.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_lcm.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_lshd.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_mod.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_mod_2d.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_mod_d.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_montgomery_calc_normalization.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_montgomery_reduce.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_montgomery_setup.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_mul.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_mul_2.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_mul_2d.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_mul_d.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_mulmod.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_n_root.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_neg.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_or.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_fermat.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_is_divisible.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_is_prime.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_miller_rabin.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_next_prime.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_rabin_miller_trials.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_random_ex.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_radix_size.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_radix_smap.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_rand.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_read_radix.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_read_signed_bin.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_read_unsigned_bin.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_2k.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_2k_l.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_2k_setup.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_2k_setup_l.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_is_2k.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_is_2k_l.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_setup.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_rshd.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_set.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_set_int.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_shrink.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_signed_bin_size.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_sqr.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_sqrmod.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_sqrt.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_sub.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_sub_d.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_submod.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_to_signed_bin.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_to_signed_bin_n.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_to_unsigned_bin.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_to_unsigned_bin_n.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_toom_mul.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_toom_sqr.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_toradix.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_toradix_n.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_unsigned_bin_size.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_xor.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_mp_zero.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_prime_tab.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_reverse.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_s_mp_add.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_s_mp_exptmod.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_s_mp_mul_digs.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_s_mp_mul_high_digs.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_s_mp_sqr.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bn_s_mp_sub.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/bncore.c delete mode 100644 libs/storm-sys/StormLib/src/libtommath/tommath.h delete mode 100644 libs/storm-sys/StormLib/src/libtommath/tommath_class.h delete mode 100644 libs/storm-sys/StormLib/src/libtommath/tommath_superclass.h delete mode 100644 libs/storm-sys/StormLib/src/lzma/C/LzFind.c delete mode 100644 libs/storm-sys/StormLib/src/lzma/C/LzFind.h delete mode 100644 libs/storm-sys/StormLib/src/lzma/C/LzFindMt.c delete mode 100644 libs/storm-sys/StormLib/src/lzma/C/LzFindMt.h delete mode 100644 libs/storm-sys/StormLib/src/lzma/C/LzHash.h delete mode 100644 libs/storm-sys/StormLib/src/lzma/C/LzmaDec.c delete mode 100644 libs/storm-sys/StormLib/src/lzma/C/LzmaDec.h delete mode 100644 libs/storm-sys/StormLib/src/lzma/C/LzmaEnc.c delete mode 100644 libs/storm-sys/StormLib/src/lzma/C/LzmaEnc.h delete mode 100644 libs/storm-sys/StormLib/src/lzma/C/Threads.c delete mode 100644 libs/storm-sys/StormLib/src/lzma/C/Threads.h delete mode 100644 libs/storm-sys/StormLib/src/lzma/C/Types.h delete mode 100644 libs/storm-sys/StormLib/src/lzma/info.txt delete mode 100644 libs/storm-sys/StormLib/src/pklib/crc32.c delete mode 100644 libs/storm-sys/StormLib/src/pklib/explode.c delete mode 100644 libs/storm-sys/StormLib/src/pklib/implode.c delete mode 100644 libs/storm-sys/StormLib/src/pklib/pklib.h delete mode 100644 libs/storm-sys/StormLib/src/sparse/sparse.cpp delete mode 100644 libs/storm-sys/StormLib/src/sparse/sparse.h delete mode 100644 libs/storm-sys/StormLib/src/wrapper.h delete mode 100644 libs/storm-sys/StormLib/src/zlib/adler32.c delete mode 100644 libs/storm-sys/StormLib/src/zlib/compress.c delete mode 100644 libs/storm-sys/StormLib/src/zlib/compress_zlib.c delete mode 100644 libs/storm-sys/StormLib/src/zlib/crc32.c delete mode 100644 libs/storm-sys/StormLib/src/zlib/crc32.h delete mode 100644 libs/storm-sys/StormLib/src/zlib/deflate.c delete mode 100644 libs/storm-sys/StormLib/src/zlib/deflate.h delete mode 100644 libs/storm-sys/StormLib/src/zlib/inffast.c delete mode 100644 libs/storm-sys/StormLib/src/zlib/inffast.h delete mode 100644 libs/storm-sys/StormLib/src/zlib/inffixed.h delete mode 100644 libs/storm-sys/StormLib/src/zlib/inflate.c delete mode 100644 libs/storm-sys/StormLib/src/zlib/inflate.h delete mode 100644 libs/storm-sys/StormLib/src/zlib/inftrees.c delete mode 100644 libs/storm-sys/StormLib/src/zlib/inftrees.h delete mode 100644 libs/storm-sys/StormLib/src/zlib/trees.c delete mode 100644 libs/storm-sys/StormLib/src/zlib/trees.h delete mode 100644 libs/storm-sys/StormLib/src/zlib/zconf.h delete mode 100644 libs/storm-sys/StormLib/src/zlib/zlib.h delete mode 100644 libs/storm-sys/StormLib/src/zlib/zutil.c delete mode 100644 libs/storm-sys/StormLib/src/zlib/zutil.h delete mode 100644 libs/storm-sys/StormPort.h delete mode 100644 libs/storm-sys/build.rs delete mode 100644 libs/storm-sys/src/lib.rs delete mode 100644 libs/storm-sys/src/storm.rs diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..fc6ff09 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "deps/StormLib"] + path = deps/StormLib + url = https://github.com/ladislav-zezula/StormLib.git diff --git a/Cargo.toml b/Cargo.toml index 3001255..7d736b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,8 +5,8 @@ authors = ["Jai <814683@qq.com>"] edition = "2018" [dependencies] -ceres-mpq = {path = "libs/ceres-mpq"} -storm-sys = {path = "libs/storm-sys"} +stormlib-sys = {path = "crates/stormlib-sys"} +stormlib = {path = "crates/stormlib"} failure = "0.1.8" clap = "2.33.1" diff --git a/crates/stormlib-bindgen/Cargo.toml b/crates/stormlib-bindgen/Cargo.toml new file mode 100644 index 0000000..a1bb2ea --- /dev/null +++ b/crates/stormlib-bindgen/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "stormlib-bindgen" +version = "0.1.0" +authors = ["Flux Xu "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +bindgen = "0.59.2" \ No newline at end of file diff --git a/crates/stormlib-bindgen/src/main.rs b/crates/stormlib-bindgen/src/main.rs new file mode 100644 index 0000000..dd6438e --- /dev/null +++ b/crates/stormlib-bindgen/src/main.rs @@ -0,0 +1,220 @@ +use std::path::PathBuf; + +fn main() { + // The bindgen::Builder is the main entry point + // to bindgen, and lets you build up options for + // the resulting bindings. + let mut bindings = bindgen::Builder::default() + // The input header we would like to generate + // bindings for. + .clang_arg("-I./deps/StormLib/src") + .header("./crates/stormlib-bindgen/src/wrapper.hpp") + // Tell cargo to invalidate the built crate whenever any of the + // included header files changed. + .parse_callbacks(Box::new(bindgen::CargoCallbacks)) + .whitelist_type("^S[A-Z].+") + .whitelist_function("^S[A-Z].+") + .whitelist_var("^ERROR_.+"); + + for var in VARS { + bindings = bindings.whitelist_var(var); + } + + #[cfg(target_os = "windows")] + let bindings = bindings.blacklist_function("SetLastError"); + + let bindings = bindings + // Finish the builder and generate the bindings. + .generate() + // Unwrap the Result and panic on failure. + .expect("Unable to generate bindings"); + + // Write the bindings to the $OUT_DIR/bindings.rs file. + let out_path = PathBuf::from("./crates/stormlib-sys/src"); + #[cfg(target_os = "windows")] + let file_name = "bindings_windows.rs"; + #[cfg(target_os = "linux")] + let file_name = "bindings_linux.rs"; + #[cfg(target_os = "macos")] + let file_name = "bindings_macos.rs"; + bindings + .write_to_file(out_path.join(file_name)) + .expect("Couldn't write bindings!"); +} + +const VARS: &[&str] = &[ + "STORMLIB_VERSION", + "STORMLIB_VERSION_STRING", + "ID_MPQ", + "ID_MPQ_USERDATA", + "ID_MPK", + "ERROR_AVI_FILE", + "ERROR_UNKNOWN_FILE_KEY", + "ERROR_CHECKSUM_ERROR", + "ERROR_INTERNAL_FILE", + "ERROR_BASE_FILE_MISSING", + "ERROR_MARKED_FOR_DELETE", + "ERROR_FILE_INCOMPLETE", + "ERROR_UNKNOWN_FILE_NAMES", + "ERROR_CANT_FIND_PATCH_PREFIX", + "HASH_TABLE_SIZE_MIN", + "HASH_TABLE_SIZE_DEFAULT", + "HASH_TABLE_SIZE_MAX", + "HASH_ENTRY_DELETED", + "HASH_ENTRY_FREE", + "HET_ENTRY_DELETED", + "HET_ENTRY_FREE", + "HASH_STATE_SIZE", + "SFILE_OPEN_HARD_DISK_FILE", + "SFILE_OPEN_CDROM_FILE", + "SFILE_OPEN_FROM_MPQ", + "SFILE_OPEN_CHECK_EXISTS", + "SFILE_OPEN_BASE_FILE", + "SFILE_OPEN_ANY_LOCALE", + "SFILE_OPEN_LOCAL_FILE", + "MPQ_FLAG_READ_ONLY", + "MPQ_FLAG_CHANGED", + "MPQ_FLAG_MALFORMED", + "MPQ_FLAG_HASH_TABLE_CUT", + "MPQ_FLAG_BLOCK_TABLE_CUT", + "MPQ_FLAG_CHECK_SECTOR_CRC", + "MPQ_FLAG_SAVING_TABLES", + "MPQ_FLAG_PATCH", + "MPQ_FLAG_WAR3_MAP", + "MPQ_FLAG_LISTFILE_NONE", + "MPQ_FLAG_LISTFILE_NEW", + "MPQ_FLAG_LISTFILE_FORCE", + "MPQ_FLAG_ATTRIBUTES_NONE", + "MPQ_FLAG_ATTRIBUTES_NEW", + "MPQ_FLAG_SIGNATURE_NONE", + "MPQ_FLAG_SIGNATURE_NEW", + "MPQ_SUBTYPE_MPQ", + "MPQ_SUBTYPE_SQP", + "MPQ_SUBTYPE_MPK", + "SFILE_INVALID_SIZE", + "SFILE_INVALID_POS", + "SFILE_INVALID_ATTRIBUTES", + "MPQ_FILE_IMPLODE", + "MPQ_FILE_COMPRESS", + "MPQ_FILE_ENCRYPTED", + "MPQ_FILE_FIX_KEY", + "MPQ_FILE_PATCH_FILE", + "MPQ_FILE_SINGLE_UNIT", + "MPQ_FILE_DELETE_MARKER", + "MPQ_FILE_SECTOR_CRC", + "MPQ_FILE_SIGNATURE", + "MPQ_FILE_EXISTS", + "MPQ_FILE_REPLACEEXISTING", + "MPQ_FILE_COMPRESS_MASK", + "MPQ_FILE_DEFAULT_INTERNAL", + "MPQ_FILE_VALID_FLAGS", + "MPQ_FILE_VALID_FLAGS_W3X", + "BLOCK_INDEX_MASK", + "MPQ_COMPRESSION_HUFFMANN", + "MPQ_COMPRESSION_ZLIB", + "MPQ_COMPRESSION_PKWARE", + "MPQ_COMPRESSION_BZIP2", + "MPQ_COMPRESSION_SPARSE", + "MPQ_COMPRESSION_ADPCM_MONO", + "MPQ_COMPRESSION_ADPCM_STEREO", + "MPQ_COMPRESSION_LZMA", + "MPQ_COMPRESSION_NEXT_SAME", + "MPQ_WAVE_QUALITY_HIGH", + "MPQ_WAVE_QUALITY_MEDIUM", + "MPQ_WAVE_QUALITY_LOW", + "HET_TABLE_SIGNATURE", + "BET_TABLE_SIGNATURE", + "MPQ_KEY_HASH_TABLE", + "MPQ_KEY_BLOCK_TABLE", + "LISTFILE_NAME", + "SIGNATURE_NAME", + "ATTRIBUTES_NAME", + "PATCH_METADATA_NAME", + "MPQ_FORMAT_VERSION_1", + "MPQ_FORMAT_VERSION_2", + "MPQ_FORMAT_VERSION_3", + "MPQ_FORMAT_VERSION_4", + "MPQ_ATTRIBUTE_CRC32", + "MPQ_ATTRIBUTE_FILETIME", + "MPQ_ATTRIBUTE_MD5", + "MPQ_ATTRIBUTE_PATCH_BIT", + "MPQ_ATTRIBUTE_ALL", + "MPQ_ATTRIBUTES_V1", + "BASE_PROVIDER_FILE", + "BASE_PROVIDER_MAP", + "BASE_PROVIDER_HTTP", + "BASE_PROVIDER_MASK", + "STREAM_PROVIDER_FLAT", + "STREAM_PROVIDER_PARTIAL", + "STREAM_PROVIDER_MPQE", + "STREAM_PROVIDER_BLOCK4", + "STREAM_PROVIDER_MASK", + "STREAM_FLAG_READ_ONLY", + "STREAM_FLAG_WRITE_SHARE", + "STREAM_FLAG_USE_BITMAP", + "STREAM_OPTIONS_MASK", + "STREAM_PROVIDERS_MASK", + "STREAM_FLAGS_MASK", + "MPQ_OPEN_NO_LISTFILE", + "MPQ_OPEN_NO_ATTRIBUTES", + "MPQ_OPEN_NO_HEADER_SEARCH", + "MPQ_OPEN_FORCE_MPQ_V1", + "MPQ_OPEN_CHECK_SECTOR_CRC", + "MPQ_OPEN_PATCH", + "MPQ_OPEN_FORCE_LISTFILE", + "MPQ_OPEN_READ_ONLY", + "MPQ_CREATE_LISTFILE", + "MPQ_CREATE_ATTRIBUTES", + "MPQ_CREATE_SIGNATURE", + "MPQ_CREATE_ARCHIVE_V1", + "MPQ_CREATE_ARCHIVE_V2", + "MPQ_CREATE_ARCHIVE_V3", + "MPQ_CREATE_ARCHIVE_V4", + "MPQ_CREATE_ARCHIVE_VMASK", + "FLAGS_TO_FORMAT_SHIFT", + "SFILE_VERIFY_SECTOR_CRC", + "SFILE_VERIFY_FILE_CRC", + "SFILE_VERIFY_FILE_MD5", + "SFILE_VERIFY_RAW_MD5", + "SFILE_VERIFY_ALL", + "VERIFY_OPEN_ERROR", + "VERIFY_READ_ERROR", + "VERIFY_FILE_HAS_SECTOR_CRC", + "VERIFY_FILE_SECTOR_CRC_ERROR", + "VERIFY_FILE_HAS_CHECKSUM", + "VERIFY_FILE_CHECKSUM_ERROR", + "VERIFY_FILE_HAS_MD5", + "VERIFY_FILE_MD5_ERROR", + "VERIFY_FILE_HAS_RAW_MD5", + "VERIFY_FILE_RAW_MD5_ERROR", + "VERIFY_FILE_ERROR_MASK", + "SFILE_VERIFY_MPQ_HEADER", + "SFILE_VERIFY_HET_TABLE", + "SFILE_VERIFY_BET_TABLE", + "SFILE_VERIFY_HASH_TABLE", + "SFILE_VERIFY_BLOCK_TABLE", + "SFILE_VERIFY_HIBLOCK_TABLE", + "SFILE_VERIFY_FILE", + "SIGNATURE_TYPE_NONE", + "SIGNATURE_TYPE_WEAK", + "SIGNATURE_TYPE_STRONG", + "ERROR_NO_SIGNATURE", + "ERROR_VERIFY_FAILED", + "ERROR_WEAK_SIGNATURE_OK", + "ERROR_WEAK_SIGNATURE_ERROR", + "ERROR_STRONG_SIGNATURE_OK", + "ERROR_STRONG_SIGNATURE_ERROR", + "MD5_DIGEST_SIZE", + "SHA1_DIGEST_SIZE", + "LANG_NEUTRAL", + "CCB_CHECKING_FILES", + "CCB_CHECKING_HASH_TABLE", + "CCB_COPYING_NON_MPQ_DATA", + "CCB_COMPACTING_FILES", + "CCB_CLOSING_ARCHIVE", + "MPQ_HEADER_SIZE_V1", + "MPQ_HEADER_SIZE_V2", + "MPQ_HEADER_SIZE_V3", + "MPQ_HEADER_SIZE_V4", + "MPQ_HEADER_DWORDS", +]; diff --git a/crates/stormlib-bindgen/src/wrapper.hpp b/crates/stormlib-bindgen/src/wrapper.hpp new file mode 100644 index 0000000..a49a777 --- /dev/null +++ b/crates/stormlib-bindgen/src/wrapper.hpp @@ -0,0 +1,4 @@ +#define _UNICODE +#define UNICODE + +#include "StormLib.h" \ No newline at end of file diff --git a/crates/stormlib-sys/Cargo.toml b/crates/stormlib-sys/Cargo.toml new file mode 100644 index 0000000..09b9d3e --- /dev/null +++ b/crates/stormlib-sys/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "stormlib-sys" +version = "0.1.1" +authors = ["Flux Xu "] +build = "build.rs" +edition = "2018" + +[dependencies] +libc = "0.2" +bitflags = "1.2" + +[build-dependencies] +cmake = "0.1" \ No newline at end of file diff --git a/crates/stormlib-sys/build.rs b/crates/stormlib-sys/build.rs new file mode 100644 index 0000000..24ea2ce --- /dev/null +++ b/crates/stormlib-sys/build.rs @@ -0,0 +1,55 @@ +extern crate cmake; + +use std::env; + +fn main() { + // Gets StormLib source path from env STORMLIB_DIR + let stormlib_path = env::var("STORMLIB_DIR").unwrap_or("../../deps/StormLib".to_string()); + + println!("cargo:rerun-if-changed={}", stormlib_path); + + // Builds StormLib using cmake + let mut cfg = cmake::Config::new(&stormlib_path); + + #[cfg(target_os = "windows")] + { + cfg.cxxflag("-D UNICODE") + .cxxflag("-D _UNICODE"); + } + + #[cfg(target_os = "macos")] + { + cfg.cflag("-Wno-implicit-function-declaration"); + } + + let dst = cfg + .define("BUILD_SHARED_LIBS", "OFF") + .build(); + + let lib = dst.join("lib"); + + // For gcc should link static storm first! (before adding -l flags) + // That's very important and I've wasted an hour finding it >_< + // source: https://stackoverflow.com/questions/29199107/c-lz-library-link-order-undefined-reference-to-symbol-inflateinit2 + println!("cargo:rustc-link-search=native={}", lib.display()); + println!("cargo:rustc-link-lib=static=stormlib"); + + #[cfg(target_os = "windows")] + { + println!("cargo:rustc-link-lib=user32"); + } + + #[cfg(target_os = "macos")] + { + println!("cargo:rustc-link-lib=dylib=c++"); + println!("cargo:rustc-link-lib=z"); + println!("cargo:rustc-link-lib=bz2"); + } + + #[cfg(target_os = "linux")] + { + println!("cargo:rustc-link-lib=stdc++"); + println!("cargo:rustc-link-lib=z"); + println!("cargo:rustc-link-lib=bz2"); + } +} diff --git a/crates/stormlib-sys/src/bindings_linux.rs b/crates/stormlib-sys/src/bindings_linux.rs new file mode 100644 index 0000000..11cc9ab --- /dev/null +++ b/crates/stormlib-sys/src/bindings_linux.rs @@ -0,0 +1,921 @@ +/* automatically generated by rust-bindgen 0.56.0 */ + +pub const ERROR_SUCCESS: u32 = 0; +pub const ERROR_FILE_NOT_FOUND: u32 = 2; +pub const ERROR_ACCESS_DENIED: u32 = 1; +pub const ERROR_INVALID_HANDLE: u32 = 9; +pub const ERROR_NOT_ENOUGH_MEMORY: u32 = 12; +pub const ERROR_NOT_SUPPORTED: u32 = 95; +pub const ERROR_INVALID_PARAMETER: u32 = 22; +pub const ERROR_NEGATIVE_SEEK: u32 = 29; +pub const ERROR_DISK_FULL: u32 = 28; +pub const ERROR_ALREADY_EXISTS: u32 = 17; +pub const ERROR_INSUFFICIENT_BUFFER: u32 = 105; +pub const ERROR_BAD_FORMAT: u32 = 1000; +pub const ERROR_NO_MORE_FILES: u32 = 1001; +pub const ERROR_HANDLE_EOF: u32 = 1002; +pub const ERROR_CAN_NOT_COMPLETE: u32 = 1003; +pub const ERROR_FILE_CORRUPT: u32 = 1004; +pub const STORMLIB_VERSION: u32 = 2327; +pub const STORMLIB_VERSION_STRING: &'static [u8; 5usize] = b"9.23\0"; +pub const ID_MPQ: u32 = 441536589; +pub const ID_MPQ_USERDATA: u32 = 458313805; +pub const ID_MPK: u32 = 441143373; +pub const ERROR_AVI_FILE: u32 = 10000; +pub const ERROR_UNKNOWN_FILE_KEY: u32 = 10001; +pub const ERROR_CHECKSUM_ERROR: u32 = 10002; +pub const ERROR_INTERNAL_FILE: u32 = 10003; +pub const ERROR_BASE_FILE_MISSING: u32 = 10004; +pub const ERROR_MARKED_FOR_DELETE: u32 = 10005; +pub const ERROR_FILE_INCOMPLETE: u32 = 10006; +pub const ERROR_UNKNOWN_FILE_NAMES: u32 = 10007; +pub const ERROR_CANT_FIND_PATCH_PREFIX: u32 = 10008; +pub const ERROR_FAKE_MPQ_HEADER: u32 = 10009; +pub const HASH_TABLE_SIZE_MIN: u32 = 4; +pub const HASH_TABLE_SIZE_DEFAULT: u32 = 4096; +pub const HASH_TABLE_SIZE_MAX: u32 = 524288; +pub const HASH_ENTRY_DELETED: u32 = 4294967294; +pub const HASH_ENTRY_FREE: u32 = 4294967295; +pub const HET_ENTRY_DELETED: u32 = 128; +pub const HET_ENTRY_FREE: u32 = 0; +pub const HASH_STATE_SIZE: u32 = 96; +pub const SFILE_OPEN_HARD_DISK_FILE: u32 = 2; +pub const SFILE_OPEN_CDROM_FILE: u32 = 3; +pub const SFILE_OPEN_FROM_MPQ: u32 = 0; +pub const SFILE_OPEN_CHECK_EXISTS: u32 = 4294967292; +pub const SFILE_OPEN_BASE_FILE: u32 = 4294967293; +pub const SFILE_OPEN_ANY_LOCALE: u32 = 4294967294; +pub const SFILE_OPEN_LOCAL_FILE: u32 = 4294967295; +pub const MPQ_FLAG_READ_ONLY: u32 = 1; +pub const MPQ_FLAG_CHANGED: u32 = 2; +pub const MPQ_FLAG_MALFORMED: u32 = 4; +pub const MPQ_FLAG_HASH_TABLE_CUT: u32 = 8; +pub const MPQ_FLAG_BLOCK_TABLE_CUT: u32 = 16; +pub const MPQ_FLAG_CHECK_SECTOR_CRC: u32 = 32; +pub const MPQ_FLAG_SAVING_TABLES: u32 = 64; +pub const MPQ_FLAG_PATCH: u32 = 128; +pub const MPQ_FLAG_WAR3_MAP: u32 = 256; +pub const MPQ_FLAG_LISTFILE_NONE: u32 = 512; +pub const MPQ_FLAG_LISTFILE_NEW: u32 = 1024; +pub const MPQ_FLAG_LISTFILE_FORCE: u32 = 2048; +pub const MPQ_FLAG_ATTRIBUTES_NONE: u32 = 4096; +pub const MPQ_FLAG_ATTRIBUTES_NEW: u32 = 8192; +pub const MPQ_FLAG_SIGNATURE_NONE: u32 = 16384; +pub const MPQ_FLAG_SIGNATURE_NEW: u32 = 32768; +pub const MPQ_SUBTYPE_MPQ: u32 = 0; +pub const MPQ_SUBTYPE_SQP: u32 = 1; +pub const MPQ_SUBTYPE_MPK: u32 = 2; +pub const SFILE_INVALID_SIZE: u32 = 4294967295; +pub const SFILE_INVALID_POS: u32 = 4294967295; +pub const SFILE_INVALID_ATTRIBUTES: u32 = 4294967295; +pub const MPQ_FILE_IMPLODE: u32 = 256; +pub const MPQ_FILE_COMPRESS: u32 = 512; +pub const MPQ_FILE_ENCRYPTED: u32 = 65536; +pub const MPQ_FILE_FIX_KEY: u32 = 131072; +pub const MPQ_FILE_PATCH_FILE: u32 = 1048576; +pub const MPQ_FILE_SINGLE_UNIT: u32 = 16777216; +pub const MPQ_FILE_DELETE_MARKER: u32 = 33554432; +pub const MPQ_FILE_SECTOR_CRC: u32 = 67108864; +pub const MPQ_FILE_SIGNATURE: u32 = 268435456; +pub const MPQ_FILE_EXISTS: u32 = 2147483648; +pub const MPQ_FILE_REPLACEEXISTING: u32 = 2147483648; +pub const MPQ_FILE_COMPRESS_MASK: u32 = 65280; +pub const MPQ_FILE_DEFAULT_INTERNAL: u32 = 4294967295; +pub const MPQ_FILE_VALID_FLAGS: u32 = 2534605568; +pub const MPQ_FILE_VALID_FLAGS_W3X: u32 = 2516779776; +pub const BLOCK_INDEX_MASK: u32 = 268435455; +pub const MPQ_COMPRESSION_HUFFMANN: u32 = 1; +pub const MPQ_COMPRESSION_ZLIB: u32 = 2; +pub const MPQ_COMPRESSION_PKWARE: u32 = 8; +pub const MPQ_COMPRESSION_BZIP2: u32 = 16; +pub const MPQ_COMPRESSION_SPARSE: u32 = 32; +pub const MPQ_COMPRESSION_ADPCM_MONO: u32 = 64; +pub const MPQ_COMPRESSION_ADPCM_STEREO: u32 = 128; +pub const MPQ_COMPRESSION_LZMA: u32 = 18; +pub const MPQ_COMPRESSION_NEXT_SAME: u32 = 4294967295; +pub const MPQ_WAVE_QUALITY_HIGH: u32 = 0; +pub const MPQ_WAVE_QUALITY_MEDIUM: u32 = 1; +pub const MPQ_WAVE_QUALITY_LOW: u32 = 2; +pub const HET_TABLE_SIGNATURE: u32 = 441730376; +pub const BET_TABLE_SIGNATURE: u32 = 441730370; +pub const MPQ_KEY_HASH_TABLE: u32 = 3283040112; +pub const MPQ_KEY_BLOCK_TABLE: u32 = 3968054179; +pub const LISTFILE_NAME: &'static [u8; 11usize] = b"(listfile)\0"; +pub const SIGNATURE_NAME: &'static [u8; 12usize] = b"(signature)\0"; +pub const ATTRIBUTES_NAME: &'static [u8; 13usize] = b"(attributes)\0"; +pub const PATCH_METADATA_NAME: &'static [u8; 17usize] = b"(patch_metadata)\0"; +pub const MPQ_FORMAT_VERSION_1: u32 = 0; +pub const MPQ_FORMAT_VERSION_2: u32 = 1; +pub const MPQ_FORMAT_VERSION_3: u32 = 2; +pub const MPQ_FORMAT_VERSION_4: u32 = 3; +pub const MPQ_ATTRIBUTE_CRC32: u32 = 1; +pub const MPQ_ATTRIBUTE_FILETIME: u32 = 2; +pub const MPQ_ATTRIBUTE_MD5: u32 = 4; +pub const MPQ_ATTRIBUTE_PATCH_BIT: u32 = 8; +pub const MPQ_ATTRIBUTE_ALL: u32 = 15; +pub const MPQ_ATTRIBUTES_V1: u32 = 100; +pub const BASE_PROVIDER_FILE: u32 = 0; +pub const BASE_PROVIDER_MAP: u32 = 1; +pub const BASE_PROVIDER_HTTP: u32 = 2; +pub const BASE_PROVIDER_MASK: u32 = 15; +pub const STREAM_PROVIDER_FLAT: u32 = 0; +pub const STREAM_PROVIDER_PARTIAL: u32 = 16; +pub const STREAM_PROVIDER_MPQE: u32 = 32; +pub const STREAM_PROVIDER_BLOCK4: u32 = 48; +pub const STREAM_PROVIDER_MASK: u32 = 240; +pub const STREAM_FLAG_READ_ONLY: u32 = 256; +pub const STREAM_FLAG_WRITE_SHARE: u32 = 512; +pub const STREAM_FLAG_USE_BITMAP: u32 = 1024; +pub const STREAM_OPTIONS_MASK: u32 = 65280; +pub const STREAM_PROVIDERS_MASK: u32 = 255; +pub const STREAM_FLAGS_MASK: u32 = 65535; +pub const MPQ_OPEN_NO_LISTFILE: u32 = 65536; +pub const MPQ_OPEN_NO_ATTRIBUTES: u32 = 131072; +pub const MPQ_OPEN_NO_HEADER_SEARCH: u32 = 262144; +pub const MPQ_OPEN_FORCE_MPQ_V1: u32 = 524288; +pub const MPQ_OPEN_CHECK_SECTOR_CRC: u32 = 1048576; +pub const MPQ_OPEN_PATCH: u32 = 2097152; +pub const MPQ_OPEN_FORCE_LISTFILE: u32 = 4194304; +pub const MPQ_OPEN_READ_ONLY: u32 = 256; +pub const MPQ_CREATE_LISTFILE: u32 = 1048576; +pub const MPQ_CREATE_ATTRIBUTES: u32 = 2097152; +pub const MPQ_CREATE_SIGNATURE: u32 = 4194304; +pub const MPQ_CREATE_ARCHIVE_V1: u32 = 0; +pub const MPQ_CREATE_ARCHIVE_V2: u32 = 16777216; +pub const MPQ_CREATE_ARCHIVE_V3: u32 = 33554432; +pub const MPQ_CREATE_ARCHIVE_V4: u32 = 50331648; +pub const MPQ_CREATE_ARCHIVE_VMASK: u32 = 251658240; +pub const FLAGS_TO_FORMAT_SHIFT: u32 = 24; +pub const SFILE_VERIFY_SECTOR_CRC: u32 = 1; +pub const SFILE_VERIFY_FILE_CRC: u32 = 2; +pub const SFILE_VERIFY_FILE_MD5: u32 = 4; +pub const SFILE_VERIFY_RAW_MD5: u32 = 8; +pub const SFILE_VERIFY_ALL: u32 = 15; +pub const VERIFY_OPEN_ERROR: u32 = 1; +pub const VERIFY_READ_ERROR: u32 = 2; +pub const VERIFY_FILE_HAS_SECTOR_CRC: u32 = 4; +pub const VERIFY_FILE_SECTOR_CRC_ERROR: u32 = 8; +pub const VERIFY_FILE_HAS_CHECKSUM: u32 = 16; +pub const VERIFY_FILE_CHECKSUM_ERROR: u32 = 32; +pub const VERIFY_FILE_HAS_MD5: u32 = 64; +pub const VERIFY_FILE_MD5_ERROR: u32 = 128; +pub const VERIFY_FILE_HAS_RAW_MD5: u32 = 256; +pub const VERIFY_FILE_RAW_MD5_ERROR: u32 = 512; +pub const VERIFY_FILE_ERROR_MASK: u32 = 683; +pub const SFILE_VERIFY_MPQ_HEADER: u32 = 1; +pub const SFILE_VERIFY_HET_TABLE: u32 = 2; +pub const SFILE_VERIFY_BET_TABLE: u32 = 3; +pub const SFILE_VERIFY_HASH_TABLE: u32 = 4; +pub const SFILE_VERIFY_BLOCK_TABLE: u32 = 5; +pub const SFILE_VERIFY_HIBLOCK_TABLE: u32 = 6; +pub const SFILE_VERIFY_FILE: u32 = 7; +pub const SIGNATURE_TYPE_NONE: u32 = 0; +pub const SIGNATURE_TYPE_WEAK: u32 = 1; +pub const SIGNATURE_TYPE_STRONG: u32 = 2; +pub const ERROR_NO_SIGNATURE: u32 = 0; +pub const ERROR_VERIFY_FAILED: u32 = 1; +pub const ERROR_WEAK_SIGNATURE_OK: u32 = 2; +pub const ERROR_WEAK_SIGNATURE_ERROR: u32 = 3; +pub const ERROR_STRONG_SIGNATURE_OK: u32 = 4; +pub const ERROR_STRONG_SIGNATURE_ERROR: u32 = 5; +pub const MD5_DIGEST_SIZE: u32 = 16; +pub const SHA1_DIGEST_SIZE: u32 = 20; +pub const LANG_NEUTRAL: u32 = 0; +pub const CCB_CHECKING_FILES: u32 = 1; +pub const CCB_CHECKING_HASH_TABLE: u32 = 2; +pub const CCB_COPYING_NON_MPQ_DATA: u32 = 3; +pub const CCB_COMPACTING_FILES: u32 = 4; +pub const CCB_CLOSING_ARCHIVE: u32 = 5; +pub const MPQ_HEADER_SIZE_V1: u32 = 32; +pub const MPQ_HEADER_SIZE_V2: u32 = 44; +pub const MPQ_HEADER_SIZE_V3: u32 = 68; +pub const MPQ_HEADER_SIZE_V4: u32 = 208; +pub const MPQ_HEADER_DWORDS: u32 = 52; +pub type LONG = ::std::os::raw::c_int; +pub type DWORD = ::std::os::raw::c_uint; +pub type ULONGLONG = ::std::os::raw::c_ulonglong; +pub type HANDLE = *mut ::std::os::raw::c_void; +pub type LPOVERLAPPED = *mut ::std::os::raw::c_void; +pub type TCHAR = ::std::os::raw::c_char; +pub type LCID = ::std::os::raw::c_uint; +pub type LPDWORD = *mut DWORD; +pub const _SFileInfoClass_SFileMpqFileName: _SFileInfoClass = 0; +pub const _SFileInfoClass_SFileMpqStreamBitmap: _SFileInfoClass = 1; +pub const _SFileInfoClass_SFileMpqUserDataOffset: _SFileInfoClass = 2; +pub const _SFileInfoClass_SFileMpqUserDataHeader: _SFileInfoClass = 3; +pub const _SFileInfoClass_SFileMpqUserData: _SFileInfoClass = 4; +pub const _SFileInfoClass_SFileMpqHeaderOffset: _SFileInfoClass = 5; +pub const _SFileInfoClass_SFileMpqHeaderSize: _SFileInfoClass = 6; +pub const _SFileInfoClass_SFileMpqHeader: _SFileInfoClass = 7; +pub const _SFileInfoClass_SFileMpqHetTableOffset: _SFileInfoClass = 8; +pub const _SFileInfoClass_SFileMpqHetTableSize: _SFileInfoClass = 9; +pub const _SFileInfoClass_SFileMpqHetHeader: _SFileInfoClass = 10; +pub const _SFileInfoClass_SFileMpqHetTable: _SFileInfoClass = 11; +pub const _SFileInfoClass_SFileMpqBetTableOffset: _SFileInfoClass = 12; +pub const _SFileInfoClass_SFileMpqBetTableSize: _SFileInfoClass = 13; +pub const _SFileInfoClass_SFileMpqBetHeader: _SFileInfoClass = 14; +pub const _SFileInfoClass_SFileMpqBetTable: _SFileInfoClass = 15; +pub const _SFileInfoClass_SFileMpqHashTableOffset: _SFileInfoClass = 16; +pub const _SFileInfoClass_SFileMpqHashTableSize64: _SFileInfoClass = 17; +pub const _SFileInfoClass_SFileMpqHashTableSize: _SFileInfoClass = 18; +pub const _SFileInfoClass_SFileMpqHashTable: _SFileInfoClass = 19; +pub const _SFileInfoClass_SFileMpqBlockTableOffset: _SFileInfoClass = 20; +pub const _SFileInfoClass_SFileMpqBlockTableSize64: _SFileInfoClass = 21; +pub const _SFileInfoClass_SFileMpqBlockTableSize: _SFileInfoClass = 22; +pub const _SFileInfoClass_SFileMpqBlockTable: _SFileInfoClass = 23; +pub const _SFileInfoClass_SFileMpqHiBlockTableOffset: _SFileInfoClass = 24; +pub const _SFileInfoClass_SFileMpqHiBlockTableSize64: _SFileInfoClass = 25; +pub const _SFileInfoClass_SFileMpqHiBlockTable: _SFileInfoClass = 26; +pub const _SFileInfoClass_SFileMpqSignatures: _SFileInfoClass = 27; +pub const _SFileInfoClass_SFileMpqStrongSignatureOffset: _SFileInfoClass = 28; +pub const _SFileInfoClass_SFileMpqStrongSignatureSize: _SFileInfoClass = 29; +pub const _SFileInfoClass_SFileMpqStrongSignature: _SFileInfoClass = 30; +pub const _SFileInfoClass_SFileMpqArchiveSize64: _SFileInfoClass = 31; +pub const _SFileInfoClass_SFileMpqArchiveSize: _SFileInfoClass = 32; +pub const _SFileInfoClass_SFileMpqMaxFileCount: _SFileInfoClass = 33; +pub const _SFileInfoClass_SFileMpqFileTableSize: _SFileInfoClass = 34; +pub const _SFileInfoClass_SFileMpqSectorSize: _SFileInfoClass = 35; +pub const _SFileInfoClass_SFileMpqNumberOfFiles: _SFileInfoClass = 36; +pub const _SFileInfoClass_SFileMpqRawChunkSize: _SFileInfoClass = 37; +pub const _SFileInfoClass_SFileMpqStreamFlags: _SFileInfoClass = 38; +pub const _SFileInfoClass_SFileMpqFlags: _SFileInfoClass = 39; +pub const _SFileInfoClass_SFileInfoPatchChain: _SFileInfoClass = 40; +pub const _SFileInfoClass_SFileInfoFileEntry: _SFileInfoClass = 41; +pub const _SFileInfoClass_SFileInfoHashEntry: _SFileInfoClass = 42; +pub const _SFileInfoClass_SFileInfoHashIndex: _SFileInfoClass = 43; +pub const _SFileInfoClass_SFileInfoNameHash1: _SFileInfoClass = 44; +pub const _SFileInfoClass_SFileInfoNameHash2: _SFileInfoClass = 45; +pub const _SFileInfoClass_SFileInfoNameHash3: _SFileInfoClass = 46; +pub const _SFileInfoClass_SFileInfoLocale: _SFileInfoClass = 47; +pub const _SFileInfoClass_SFileInfoFileIndex: _SFileInfoClass = 48; +pub const _SFileInfoClass_SFileInfoByteOffset: _SFileInfoClass = 49; +pub const _SFileInfoClass_SFileInfoFileTime: _SFileInfoClass = 50; +pub const _SFileInfoClass_SFileInfoFileSize: _SFileInfoClass = 51; +pub const _SFileInfoClass_SFileInfoCompressedSize: _SFileInfoClass = 52; +pub const _SFileInfoClass_SFileInfoFlags: _SFileInfoClass = 53; +pub const _SFileInfoClass_SFileInfoEncryptionKey: _SFileInfoClass = 54; +pub const _SFileInfoClass_SFileInfoEncryptionKeyRaw: _SFileInfoClass = 55; +pub const _SFileInfoClass_SFileInfoCRC32: _SFileInfoClass = 56; +pub type _SFileInfoClass = ::std::os::raw::c_uint; +pub use self::_SFileInfoClass as SFileInfoClass; +pub type SFILE_DOWNLOAD_CALLBACK = ::std::option::Option< + unsafe extern "C" fn( + pvUserData: *mut ::std::os::raw::c_void, + ByteOffset: ULONGLONG, + dwTotalBytes: DWORD, + ), +>; +pub type SFILE_ADDFILE_CALLBACK = ::std::option::Option< + unsafe extern "C" fn( + pvUserData: *mut ::std::os::raw::c_void, + dwBytesWritten: DWORD, + dwTotalBytes: DWORD, + bFinalCall: bool, + ), +>; +pub type SFILE_COMPACT_CALLBACK = ::std::option::Option< + unsafe extern "C" fn( + pvUserData: *mut ::std::os::raw::c_void, + dwWorkType: DWORD, + BytesProcessed: ULONGLONG, + TotalBytes: ULONGLONG, + ), +>; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SFILE_FIND_DATA { + pub cFileName: [::std::os::raw::c_char; 1024usize], + pub szPlainName: *mut ::std::os::raw::c_char, + pub dwHashIndex: DWORD, + pub dwBlockIndex: DWORD, + pub dwFileSize: DWORD, + pub dwFileFlags: DWORD, + pub dwCompSize: DWORD, + pub dwFileTimeLo: DWORD, + pub dwFileTimeHi: DWORD, + pub lcLocale: LCID, +} +#[test] +fn bindgen_test_layout__SFILE_FIND_DATA() { + assert_eq!( + ::std::mem::size_of::<_SFILE_FIND_DATA>(), + 1064usize, + concat!("Size of: ", stringify!(_SFILE_FIND_DATA)) + ); + assert_eq!( + ::std::mem::align_of::<_SFILE_FIND_DATA>(), + 8usize, + concat!("Alignment of ", stringify!(_SFILE_FIND_DATA)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).cFileName as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(cFileName) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).szPlainName as *const _ as usize }, + 1024usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(szPlainName) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwHashIndex as *const _ as usize }, + 1032usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(dwHashIndex) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwBlockIndex as *const _ as usize }, + 1036usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(dwBlockIndex) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwFileSize as *const _ as usize }, + 1040usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(dwFileSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwFileFlags as *const _ as usize }, + 1044usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(dwFileFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwCompSize as *const _ as usize }, + 1048usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(dwCompSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwFileTimeLo as *const _ as usize }, + 1052usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(dwFileTimeLo) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwFileTimeHi as *const _ as usize }, + 1056usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(dwFileTimeHi) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).lcLocale as *const _ as usize }, + 1060usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(lcLocale) + ) + ); +} +pub type SFILE_FIND_DATA = _SFILE_FIND_DATA; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SFILE_CREATE_MPQ { + pub cbSize: DWORD, + pub dwMpqVersion: DWORD, + pub pvUserData: *mut ::std::os::raw::c_void, + pub cbUserData: DWORD, + pub dwStreamFlags: DWORD, + pub dwFileFlags1: DWORD, + pub dwFileFlags2: DWORD, + pub dwFileFlags3: DWORD, + pub dwAttrFlags: DWORD, + pub dwSectorSize: DWORD, + pub dwRawChunkSize: DWORD, + pub dwMaxFileCount: DWORD, +} +#[test] +fn bindgen_test_layout__SFILE_CREATE_MPQ() { + assert_eq!( + ::std::mem::size_of::<_SFILE_CREATE_MPQ>(), + 56usize, + concat!("Size of: ", stringify!(_SFILE_CREATE_MPQ)) + ); + assert_eq!( + ::std::mem::align_of::<_SFILE_CREATE_MPQ>(), + 8usize, + concat!("Alignment of ", stringify!(_SFILE_CREATE_MPQ)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).cbSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(cbSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwMpqVersion as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwMpqVersion) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).pvUserData as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(pvUserData) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).cbUserData as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(cbUserData) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwStreamFlags as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwStreamFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwFileFlags1 as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwFileFlags1) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwFileFlags2 as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwFileFlags2) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwFileFlags3 as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwFileFlags3) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwAttrFlags as *const _ as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwAttrFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwSectorSize as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwSectorSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwRawChunkSize as *const _ as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwRawChunkSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwMaxFileCount as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwMaxFileCount) + ) + ); +} +pub type SFILE_CREATE_MPQ = _SFILE_CREATE_MPQ; +pub type PSFILE_CREATE_MPQ = *mut _SFILE_CREATE_MPQ; +pub type SFILESETLOCALE = ::std::option::Option LCID>; +pub type SFILEOPENARCHIVE = ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: DWORD, + arg3: DWORD, + arg4: *mut HANDLE, + ) -> bool, +>; +pub type SFILECLOSEARCHIVE = ::std::option::Option bool>; +pub type SFILEOPENFILEEX = ::std::option::Option< + unsafe extern "C" fn( + arg1: HANDLE, + arg2: *const ::std::os::raw::c_char, + arg3: DWORD, + arg4: *mut HANDLE, + ) -> bool, +>; +pub type SFILECLOSEFILE = ::std::option::Option bool>; +pub type SFILEGETFILESIZE = + ::std::option::Option DWORD>; +pub type SFILESETFILEPOINTER = ::std::option::Option< + unsafe extern "C" fn(arg1: HANDLE, arg2: LONG, arg3: *mut LONG, arg4: DWORD) -> DWORD, +>; +pub type SFILEREADFILE = ::std::option::Option< + unsafe extern "C" fn( + arg1: HANDLE, + arg2: *mut ::std::os::raw::c_void, + arg3: DWORD, + arg4: LPDWORD, + arg5: LPOVERLAPPED, + ) -> bool, +>; +extern "C" { + pub fn SFileGetLocale() -> LCID; +} +extern "C" { + pub fn SFileSetLocale(lcNewLocale: LCID) -> LCID; +} +extern "C" { + pub fn SFileOpenArchive( + szMpqName: *const TCHAR, + dwPriority: DWORD, + dwFlags: DWORD, + phMpq: *mut HANDLE, + ) -> bool; +} +extern "C" { + pub fn SFileCreateArchive( + szMpqName: *const TCHAR, + dwCreateFlags: DWORD, + dwMaxFileCount: DWORD, + phMpq: *mut HANDLE, + ) -> bool; +} +extern "C" { + pub fn SFileCreateArchive2( + szMpqName: *const TCHAR, + pCreateInfo: PSFILE_CREATE_MPQ, + phMpq: *mut HANDLE, + ) -> bool; +} +extern "C" { + pub fn SFileSetDownloadCallback( + hMpq: HANDLE, + DownloadCB: SFILE_DOWNLOAD_CALLBACK, + pvUserData: *mut ::std::os::raw::c_void, + ) -> bool; +} +extern "C" { + pub fn SFileFlushArchive(hMpq: HANDLE) -> bool; +} +extern "C" { + pub fn SFileCloseArchive(hMpq: HANDLE) -> bool; +} +extern "C" { + pub fn SFileAddListFile(hMpq: HANDLE, szListFile: *const TCHAR) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn SFileSetCompactCallback( + hMpq: HANDLE, + CompactCB: SFILE_COMPACT_CALLBACK, + pvUserData: *mut ::std::os::raw::c_void, + ) -> bool; +} +extern "C" { + pub fn SFileCompactArchive(hMpq: HANDLE, szListFile: *const TCHAR, bReserved: bool) -> bool; +} +extern "C" { + pub fn SFileGetMaxFileCount(hMpq: HANDLE) -> DWORD; +} +extern "C" { + pub fn SFileSetMaxFileCount(hMpq: HANDLE, dwMaxFileCount: DWORD) -> bool; +} +extern "C" { + pub fn SFileGetAttributes(hMpq: HANDLE) -> DWORD; +} +extern "C" { + pub fn SFileSetAttributes(hMpq: HANDLE, dwFlags: DWORD) -> bool; +} +extern "C" { + pub fn SFileUpdateFileAttributes(hMpq: HANDLE, szFileName: *const ::std::os::raw::c_char) + -> bool; +} +extern "C" { + pub fn SFileOpenPatchArchive( + hMpq: HANDLE, + szPatchMpqName: *const TCHAR, + szPatchPathPrefix: *const ::std::os::raw::c_char, + dwFlags: DWORD, + ) -> bool; +} +extern "C" { + pub fn SFileIsPatchedArchive(hMpq: HANDLE) -> bool; +} +extern "C" { + pub fn SFileHasFile(hMpq: HANDLE, szFileName: *const ::std::os::raw::c_char) -> bool; +} +extern "C" { + pub fn SFileOpenFileEx( + hMpq: HANDLE, + szFileName: *const ::std::os::raw::c_char, + dwSearchScope: DWORD, + phFile: *mut HANDLE, + ) -> bool; +} +extern "C" { + pub fn SFileGetFileSize(hFile: HANDLE, pdwFileSizeHigh: LPDWORD) -> DWORD; +} +extern "C" { + pub fn SFileSetFilePointer( + hFile: HANDLE, + lFilePos: LONG, + plFilePosHigh: *mut LONG, + dwMoveMethod: DWORD, + ) -> DWORD; +} +extern "C" { + pub fn SFileReadFile( + hFile: HANDLE, + lpBuffer: *mut ::std::os::raw::c_void, + dwToRead: DWORD, + pdwRead: LPDWORD, + lpOverlapped: LPOVERLAPPED, + ) -> bool; +} +extern "C" { + pub fn SFileCloseFile(hFile: HANDLE) -> bool; +} +extern "C" { + pub fn SFileGetFileInfo( + hMpqOrFile: HANDLE, + InfoClass: SFileInfoClass, + pvFileInfo: *mut ::std::os::raw::c_void, + cbFileInfo: DWORD, + pcbLengthNeeded: LPDWORD, + ) -> bool; +} +extern "C" { + pub fn SFileGetFileName(hFile: HANDLE, szFileName: *mut ::std::os::raw::c_char) -> bool; +} +extern "C" { + pub fn SFileFreeFileInfo( + pvFileInfo: *mut ::std::os::raw::c_void, + InfoClass: SFileInfoClass, + ) -> bool; +} +extern "C" { + pub fn SFileExtractFile( + hMpq: HANDLE, + szToExtract: *const ::std::os::raw::c_char, + szExtracted: *const TCHAR, + dwSearchScope: DWORD, + ) -> bool; +} +extern "C" { + pub fn SFileGetFileChecksums( + hMpq: HANDLE, + szFileName: *const ::std::os::raw::c_char, + pdwCrc32: LPDWORD, + pMD5: *mut ::std::os::raw::c_char, + ) -> bool; +} +extern "C" { + pub fn SFileVerifyFile( + hMpq: HANDLE, + szFileName: *const ::std::os::raw::c_char, + dwFlags: DWORD, + ) -> DWORD; +} +extern "C" { + pub fn SFileVerifyRawData( + hMpq: HANDLE, + dwWhatToVerify: DWORD, + szFileName: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn SFileSignArchive(hMpq: HANDLE, dwSignatureType: DWORD) -> bool; +} +extern "C" { + pub fn SFileVerifyArchive(hMpq: HANDLE) -> DWORD; +} +extern "C" { + pub fn SFileFindFirstFile( + hMpq: HANDLE, + szMask: *const ::std::os::raw::c_char, + lpFindFileData: *mut SFILE_FIND_DATA, + szListFile: *const TCHAR, + ) -> HANDLE; +} +extern "C" { + pub fn SFileFindNextFile(hFind: HANDLE, lpFindFileData: *mut SFILE_FIND_DATA) -> bool; +} +extern "C" { + pub fn SFileFindClose(hFind: HANDLE) -> bool; +} +extern "C" { + pub fn SListFileFindFirstFile( + hMpq: HANDLE, + szListFile: *const TCHAR, + szMask: *const ::std::os::raw::c_char, + lpFindFileData: *mut SFILE_FIND_DATA, + ) -> HANDLE; +} +extern "C" { + pub fn SListFileFindNextFile(hFind: HANDLE, lpFindFileData: *mut SFILE_FIND_DATA) -> bool; +} +extern "C" { + pub fn SListFileFindClose(hFind: HANDLE) -> bool; +} +extern "C" { + pub fn SFileEnumLocales( + hMpq: HANDLE, + szFileName: *const ::std::os::raw::c_char, + plcLocales: *mut LCID, + pdwMaxLocales: LPDWORD, + dwSearchScope: DWORD, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn SFileCreateFile( + hMpq: HANDLE, + szArchivedName: *const ::std::os::raw::c_char, + FileTime: ULONGLONG, + dwFileSize: DWORD, + lcLocale: LCID, + dwFlags: DWORD, + phFile: *mut HANDLE, + ) -> bool; +} +extern "C" { + pub fn SFileWriteFile( + hFile: HANDLE, + pvData: *const ::std::os::raw::c_void, + dwSize: DWORD, + dwCompression: DWORD, + ) -> bool; +} +extern "C" { + pub fn SFileFinishFile(hFile: HANDLE) -> bool; +} +extern "C" { + pub fn SFileAddFileEx( + hMpq: HANDLE, + szFileName: *const TCHAR, + szArchivedName: *const ::std::os::raw::c_char, + dwFlags: DWORD, + dwCompression: DWORD, + dwCompressionNext: DWORD, + ) -> bool; +} +extern "C" { + pub fn SFileAddFile( + hMpq: HANDLE, + szFileName: *const TCHAR, + szArchivedName: *const ::std::os::raw::c_char, + dwFlags: DWORD, + ) -> bool; +} +extern "C" { + pub fn SFileAddWave( + hMpq: HANDLE, + szFileName: *const TCHAR, + szArchivedName: *const ::std::os::raw::c_char, + dwFlags: DWORD, + dwQuality: DWORD, + ) -> bool; +} +extern "C" { + pub fn SFileRemoveFile( + hMpq: HANDLE, + szFileName: *const ::std::os::raw::c_char, + dwSearchScope: DWORD, + ) -> bool; +} +extern "C" { + pub fn SFileRenameFile( + hMpq: HANDLE, + szOldFileName: *const ::std::os::raw::c_char, + szNewFileName: *const ::std::os::raw::c_char, + ) -> bool; +} +extern "C" { + pub fn SFileSetFileLocale(hFile: HANDLE, lcNewLocale: LCID) -> bool; +} +extern "C" { + pub fn SFileSetDataCompression(DataCompression: DWORD) -> bool; +} +extern "C" { + pub fn SFileSetAddFileCallback( + hMpq: HANDLE, + AddFileCB: SFILE_ADDFILE_CALLBACK, + pvUserData: *mut ::std::os::raw::c_void, + ) -> bool; +} +extern "C" { + pub fn SCompImplode( + pvOutBuffer: *mut ::std::os::raw::c_void, + pcbOutBuffer: *mut ::std::os::raw::c_int, + pvInBuffer: *mut ::std::os::raw::c_void, + cbInBuffer: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn SCompExplode( + pvOutBuffer: *mut ::std::os::raw::c_void, + pcbOutBuffer: *mut ::std::os::raw::c_int, + pvInBuffer: *mut ::std::os::raw::c_void, + cbInBuffer: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn SCompCompress( + pvOutBuffer: *mut ::std::os::raw::c_void, + pcbOutBuffer: *mut ::std::os::raw::c_int, + pvInBuffer: *mut ::std::os::raw::c_void, + cbInBuffer: ::std::os::raw::c_int, + uCompressionMask: ::std::os::raw::c_uint, + nCmpType: ::std::os::raw::c_int, + nCmpLevel: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn SCompDecompress( + pvOutBuffer: *mut ::std::os::raw::c_void, + pcbOutBuffer: *mut ::std::os::raw::c_int, + pvInBuffer: *mut ::std::os::raw::c_void, + cbInBuffer: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn SCompDecompress2( + pvOutBuffer: *mut ::std::os::raw::c_void, + pcbOutBuffer: *mut ::std::os::raw::c_int, + pvInBuffer: *mut ::std::os::raw::c_void, + cbInBuffer: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} diff --git a/crates/stormlib-sys/src/bindings_macos.rs b/crates/stormlib-sys/src/bindings_macos.rs new file mode 100644 index 0000000..3cc27ad --- /dev/null +++ b/crates/stormlib-sys/src/bindings_macos.rs @@ -0,0 +1,986 @@ +/* automatically generated by rust-bindgen 0.59.2 */ + +pub const ERROR_SUCCESS: u32 = 0; +pub const ERROR_FILE_NOT_FOUND: u32 = 2; +pub const ERROR_ACCESS_DENIED: u32 = 1; +pub const ERROR_INVALID_HANDLE: u32 = 9; +pub const ERROR_NOT_ENOUGH_MEMORY: u32 = 12; +pub const ERROR_NOT_SUPPORTED: u32 = 45; +pub const ERROR_INVALID_PARAMETER: u32 = 22; +pub const ERROR_NEGATIVE_SEEK: u32 = 29; +pub const ERROR_DISK_FULL: u32 = 28; +pub const ERROR_ALREADY_EXISTS: u32 = 17; +pub const ERROR_INSUFFICIENT_BUFFER: u32 = 55; +pub const ERROR_BAD_FORMAT: u32 = 1000; +pub const ERROR_NO_MORE_FILES: u32 = 1001; +pub const ERROR_HANDLE_EOF: u32 = 1002; +pub const ERROR_CAN_NOT_COMPLETE: u32 = 1003; +pub const ERROR_FILE_CORRUPT: u32 = 1004; +pub const STORMLIB_VERSION: u32 = 2327; +pub const STORMLIB_VERSION_STRING: &[u8; 5usize] = b"9.23\0"; +pub const ID_MPQ: u32 = 441536589; +pub const ID_MPQ_USERDATA: u32 = 458313805; +pub const ID_MPK: u32 = 441143373; +pub const ERROR_AVI_FILE: u32 = 10000; +pub const ERROR_UNKNOWN_FILE_KEY: u32 = 10001; +pub const ERROR_CHECKSUM_ERROR: u32 = 10002; +pub const ERROR_INTERNAL_FILE: u32 = 10003; +pub const ERROR_BASE_FILE_MISSING: u32 = 10004; +pub const ERROR_MARKED_FOR_DELETE: u32 = 10005; +pub const ERROR_FILE_INCOMPLETE: u32 = 10006; +pub const ERROR_UNKNOWN_FILE_NAMES: u32 = 10007; +pub const ERROR_CANT_FIND_PATCH_PREFIX: u32 = 10008; +pub const ERROR_FAKE_MPQ_HEADER: u32 = 10009; +pub const HASH_TABLE_SIZE_MIN: u32 = 4; +pub const HASH_TABLE_SIZE_DEFAULT: u32 = 4096; +pub const HASH_TABLE_SIZE_MAX: u32 = 524288; +pub const HASH_ENTRY_DELETED: u32 = 4294967294; +pub const HASH_ENTRY_FREE: u32 = 4294967295; +pub const HET_ENTRY_DELETED: u32 = 128; +pub const HET_ENTRY_FREE: u32 = 0; +pub const SFILE_OPEN_HARD_DISK_FILE: u32 = 2; +pub const SFILE_OPEN_CDROM_FILE: u32 = 3; +pub const SFILE_OPEN_FROM_MPQ: u32 = 0; +pub const SFILE_OPEN_CHECK_EXISTS: u32 = 4294967292; +pub const SFILE_OPEN_BASE_FILE: u32 = 4294967293; +pub const SFILE_OPEN_ANY_LOCALE: u32 = 4294967294; +pub const SFILE_OPEN_LOCAL_FILE: u32 = 4294967295; +pub const MPQ_FLAG_READ_ONLY: u32 = 1; +pub const MPQ_FLAG_CHANGED: u32 = 2; +pub const MPQ_FLAG_MALFORMED: u32 = 4; +pub const MPQ_FLAG_HASH_TABLE_CUT: u32 = 8; +pub const MPQ_FLAG_BLOCK_TABLE_CUT: u32 = 16; +pub const MPQ_FLAG_CHECK_SECTOR_CRC: u32 = 32; +pub const MPQ_FLAG_SAVING_TABLES: u32 = 64; +pub const MPQ_FLAG_PATCH: u32 = 128; +pub const MPQ_FLAG_WAR3_MAP: u32 = 256; +pub const MPQ_FLAG_LISTFILE_NONE: u32 = 512; +pub const MPQ_FLAG_LISTFILE_NEW: u32 = 1024; +pub const MPQ_FLAG_LISTFILE_FORCE: u32 = 2048; +pub const MPQ_FLAG_ATTRIBUTES_NONE: u32 = 4096; +pub const MPQ_FLAG_ATTRIBUTES_NEW: u32 = 8192; +pub const MPQ_FLAG_SIGNATURE_NONE: u32 = 16384; +pub const MPQ_FLAG_SIGNATURE_NEW: u32 = 32768; +pub const MPQ_SUBTYPE_MPQ: u32 = 0; +pub const MPQ_SUBTYPE_SQP: u32 = 1; +pub const MPQ_SUBTYPE_MPK: u32 = 2; +pub const SFILE_INVALID_SIZE: u32 = 4294967295; +pub const SFILE_INVALID_POS: u32 = 4294967295; +pub const SFILE_INVALID_ATTRIBUTES: u32 = 4294967295; +pub const MPQ_FILE_IMPLODE: u32 = 256; +pub const MPQ_FILE_COMPRESS: u32 = 512; +pub const MPQ_FILE_ENCRYPTED: u32 = 65536; +pub const MPQ_FILE_FIX_KEY: u32 = 131072; +pub const MPQ_FILE_PATCH_FILE: u32 = 1048576; +pub const MPQ_FILE_SINGLE_UNIT: u32 = 16777216; +pub const MPQ_FILE_DELETE_MARKER: u32 = 33554432; +pub const MPQ_FILE_SECTOR_CRC: u32 = 67108864; +pub const MPQ_FILE_SIGNATURE: u32 = 268435456; +pub const MPQ_FILE_EXISTS: u32 = 2147483648; +pub const MPQ_FILE_REPLACEEXISTING: u32 = 2147483648; +pub const MPQ_FILE_COMPRESS_MASK: u32 = 65280; +pub const MPQ_FILE_DEFAULT_INTERNAL: u32 = 4294967295; +pub const MPQ_FILE_VALID_FLAGS: u32 = 2534605568; +pub const MPQ_FILE_VALID_FLAGS_W3X: u32 = 2516779776; +pub const BLOCK_INDEX_MASK: u32 = 268435455; +pub const MPQ_COMPRESSION_HUFFMANN: u32 = 1; +pub const MPQ_COMPRESSION_ZLIB: u32 = 2; +pub const MPQ_COMPRESSION_PKWARE: u32 = 8; +pub const MPQ_COMPRESSION_BZIP2: u32 = 16; +pub const MPQ_COMPRESSION_SPARSE: u32 = 32; +pub const MPQ_COMPRESSION_ADPCM_MONO: u32 = 64; +pub const MPQ_COMPRESSION_ADPCM_STEREO: u32 = 128; +pub const MPQ_COMPRESSION_LZMA: u32 = 18; +pub const MPQ_COMPRESSION_NEXT_SAME: u32 = 4294967295; +pub const MPQ_WAVE_QUALITY_HIGH: u32 = 0; +pub const MPQ_WAVE_QUALITY_MEDIUM: u32 = 1; +pub const MPQ_WAVE_QUALITY_LOW: u32 = 2; +pub const HET_TABLE_SIGNATURE: u32 = 441730376; +pub const BET_TABLE_SIGNATURE: u32 = 441730370; +pub const MPQ_KEY_HASH_TABLE: u32 = 3283040112; +pub const MPQ_KEY_BLOCK_TABLE: u32 = 3968054179; +pub const LISTFILE_NAME: &[u8; 11usize] = b"(listfile)\0"; +pub const SIGNATURE_NAME: &[u8; 12usize] = b"(signature)\0"; +pub const ATTRIBUTES_NAME: &[u8; 13usize] = b"(attributes)\0"; +pub const PATCH_METADATA_NAME: &[u8; 17usize] = b"(patch_metadata)\0"; +pub const MPQ_FORMAT_VERSION_1: u32 = 0; +pub const MPQ_FORMAT_VERSION_2: u32 = 1; +pub const MPQ_FORMAT_VERSION_3: u32 = 2; +pub const MPQ_FORMAT_VERSION_4: u32 = 3; +pub const MPQ_ATTRIBUTE_CRC32: u32 = 1; +pub const MPQ_ATTRIBUTE_FILETIME: u32 = 2; +pub const MPQ_ATTRIBUTE_MD5: u32 = 4; +pub const MPQ_ATTRIBUTE_PATCH_BIT: u32 = 8; +pub const MPQ_ATTRIBUTE_ALL: u32 = 15; +pub const MPQ_ATTRIBUTES_V1: u32 = 100; +pub const BASE_PROVIDER_FILE: u32 = 0; +pub const BASE_PROVIDER_MAP: u32 = 1; +pub const BASE_PROVIDER_HTTP: u32 = 2; +pub const BASE_PROVIDER_MASK: u32 = 15; +pub const STREAM_PROVIDER_FLAT: u32 = 0; +pub const STREAM_PROVIDER_PARTIAL: u32 = 16; +pub const STREAM_PROVIDER_MPQE: u32 = 32; +pub const STREAM_PROVIDER_BLOCK4: u32 = 48; +pub const STREAM_PROVIDER_MASK: u32 = 240; +pub const STREAM_FLAG_READ_ONLY: u32 = 256; +pub const STREAM_FLAG_WRITE_SHARE: u32 = 512; +pub const STREAM_FLAG_USE_BITMAP: u32 = 1024; +pub const STREAM_OPTIONS_MASK: u32 = 65280; +pub const STREAM_PROVIDERS_MASK: u32 = 255; +pub const STREAM_FLAGS_MASK: u32 = 65535; +pub const MPQ_OPEN_NO_LISTFILE: u32 = 65536; +pub const MPQ_OPEN_NO_ATTRIBUTES: u32 = 131072; +pub const MPQ_OPEN_NO_HEADER_SEARCH: u32 = 262144; +pub const MPQ_OPEN_FORCE_MPQ_V1: u32 = 524288; +pub const MPQ_OPEN_CHECK_SECTOR_CRC: u32 = 1048576; +pub const MPQ_OPEN_PATCH: u32 = 2097152; +pub const MPQ_OPEN_FORCE_LISTFILE: u32 = 4194304; +pub const MPQ_OPEN_READ_ONLY: u32 = 256; +pub const MPQ_CREATE_LISTFILE: u32 = 1048576; +pub const MPQ_CREATE_ATTRIBUTES: u32 = 2097152; +pub const MPQ_CREATE_SIGNATURE: u32 = 4194304; +pub const MPQ_CREATE_ARCHIVE_V1: u32 = 0; +pub const MPQ_CREATE_ARCHIVE_V2: u32 = 16777216; +pub const MPQ_CREATE_ARCHIVE_V3: u32 = 33554432; +pub const MPQ_CREATE_ARCHIVE_V4: u32 = 50331648; +pub const MPQ_CREATE_ARCHIVE_VMASK: u32 = 251658240; +pub const FLAGS_TO_FORMAT_SHIFT: u32 = 24; +pub const SFILE_VERIFY_SECTOR_CRC: u32 = 1; +pub const SFILE_VERIFY_FILE_CRC: u32 = 2; +pub const SFILE_VERIFY_FILE_MD5: u32 = 4; +pub const SFILE_VERIFY_RAW_MD5: u32 = 8; +pub const SFILE_VERIFY_ALL: u32 = 15; +pub const VERIFY_OPEN_ERROR: u32 = 1; +pub const VERIFY_READ_ERROR: u32 = 2; +pub const VERIFY_FILE_HAS_SECTOR_CRC: u32 = 4; +pub const VERIFY_FILE_SECTOR_CRC_ERROR: u32 = 8; +pub const VERIFY_FILE_HAS_CHECKSUM: u32 = 16; +pub const VERIFY_FILE_CHECKSUM_ERROR: u32 = 32; +pub const VERIFY_FILE_HAS_MD5: u32 = 64; +pub const VERIFY_FILE_MD5_ERROR: u32 = 128; +pub const VERIFY_FILE_HAS_RAW_MD5: u32 = 256; +pub const VERIFY_FILE_RAW_MD5_ERROR: u32 = 512; +pub const VERIFY_FILE_ERROR_MASK: u32 = 683; +pub const SFILE_VERIFY_MPQ_HEADER: u32 = 1; +pub const SFILE_VERIFY_HET_TABLE: u32 = 2; +pub const SFILE_VERIFY_BET_TABLE: u32 = 3; +pub const SFILE_VERIFY_HASH_TABLE: u32 = 4; +pub const SFILE_VERIFY_BLOCK_TABLE: u32 = 5; +pub const SFILE_VERIFY_HIBLOCK_TABLE: u32 = 6; +pub const SFILE_VERIFY_FILE: u32 = 7; +pub const SIGNATURE_TYPE_NONE: u32 = 0; +pub const SIGNATURE_TYPE_WEAK: u32 = 1; +pub const SIGNATURE_TYPE_STRONG: u32 = 2; +pub const ERROR_NO_SIGNATURE: u32 = 0; +pub const ERROR_VERIFY_FAILED: u32 = 1; +pub const ERROR_WEAK_SIGNATURE_OK: u32 = 2; +pub const ERROR_WEAK_SIGNATURE_ERROR: u32 = 3; +pub const ERROR_STRONG_SIGNATURE_OK: u32 = 4; +pub const ERROR_STRONG_SIGNATURE_ERROR: u32 = 5; +pub const MD5_DIGEST_SIZE: u32 = 16; +pub const SHA1_DIGEST_SIZE: u32 = 20; +pub const LANG_NEUTRAL: u32 = 0; +pub const CCB_CHECKING_FILES: u32 = 1; +pub const CCB_CHECKING_HASH_TABLE: u32 = 2; +pub const CCB_COPYING_NON_MPQ_DATA: u32 = 3; +pub const CCB_COMPACTING_FILES: u32 = 4; +pub const CCB_CLOSING_ARCHIVE: u32 = 5; +pub const MPQ_HEADER_SIZE_V1: u32 = 32; +pub const MPQ_HEADER_SIZE_V2: u32 = 44; +pub const MPQ_HEADER_SIZE_V3: u32 = 68; +pub const MPQ_HEADER_SIZE_V4: u32 = 208; +pub const MPQ_HEADER_DWORDS: u32 = 52; +pub type LONG = ::std::os::raw::c_int; +pub type DWORD = ::std::os::raw::c_uint; +pub type ULONGLONG = ::std::os::raw::c_ulonglong; +pub type HANDLE = *mut ::std::os::raw::c_void; +pub type LPOVERLAPPED = *mut ::std::os::raw::c_void; +pub type TCHAR = ::std::os::raw::c_char; +pub type LCID = ::std::os::raw::c_uint; +pub type LPDWORD = *mut DWORD; +pub const _SFileInfoClass_SFileMpqFileName: _SFileInfoClass = 0; +pub const _SFileInfoClass_SFileMpqStreamBitmap: _SFileInfoClass = 1; +pub const _SFileInfoClass_SFileMpqUserDataOffset: _SFileInfoClass = 2; +pub const _SFileInfoClass_SFileMpqUserDataHeader: _SFileInfoClass = 3; +pub const _SFileInfoClass_SFileMpqUserData: _SFileInfoClass = 4; +pub const _SFileInfoClass_SFileMpqHeaderOffset: _SFileInfoClass = 5; +pub const _SFileInfoClass_SFileMpqHeaderSize: _SFileInfoClass = 6; +pub const _SFileInfoClass_SFileMpqHeader: _SFileInfoClass = 7; +pub const _SFileInfoClass_SFileMpqHetTableOffset: _SFileInfoClass = 8; +pub const _SFileInfoClass_SFileMpqHetTableSize: _SFileInfoClass = 9; +pub const _SFileInfoClass_SFileMpqHetHeader: _SFileInfoClass = 10; +pub const _SFileInfoClass_SFileMpqHetTable: _SFileInfoClass = 11; +pub const _SFileInfoClass_SFileMpqBetTableOffset: _SFileInfoClass = 12; +pub const _SFileInfoClass_SFileMpqBetTableSize: _SFileInfoClass = 13; +pub const _SFileInfoClass_SFileMpqBetHeader: _SFileInfoClass = 14; +pub const _SFileInfoClass_SFileMpqBetTable: _SFileInfoClass = 15; +pub const _SFileInfoClass_SFileMpqHashTableOffset: _SFileInfoClass = 16; +pub const _SFileInfoClass_SFileMpqHashTableSize64: _SFileInfoClass = 17; +pub const _SFileInfoClass_SFileMpqHashTableSize: _SFileInfoClass = 18; +pub const _SFileInfoClass_SFileMpqHashTable: _SFileInfoClass = 19; +pub const _SFileInfoClass_SFileMpqBlockTableOffset: _SFileInfoClass = 20; +pub const _SFileInfoClass_SFileMpqBlockTableSize64: _SFileInfoClass = 21; +pub const _SFileInfoClass_SFileMpqBlockTableSize: _SFileInfoClass = 22; +pub const _SFileInfoClass_SFileMpqBlockTable: _SFileInfoClass = 23; +pub const _SFileInfoClass_SFileMpqHiBlockTableOffset: _SFileInfoClass = 24; +pub const _SFileInfoClass_SFileMpqHiBlockTableSize64: _SFileInfoClass = 25; +pub const _SFileInfoClass_SFileMpqHiBlockTable: _SFileInfoClass = 26; +pub const _SFileInfoClass_SFileMpqSignatures: _SFileInfoClass = 27; +pub const _SFileInfoClass_SFileMpqStrongSignatureOffset: _SFileInfoClass = 28; +pub const _SFileInfoClass_SFileMpqStrongSignatureSize: _SFileInfoClass = 29; +pub const _SFileInfoClass_SFileMpqStrongSignature: _SFileInfoClass = 30; +pub const _SFileInfoClass_SFileMpqArchiveSize64: _SFileInfoClass = 31; +pub const _SFileInfoClass_SFileMpqArchiveSize: _SFileInfoClass = 32; +pub const _SFileInfoClass_SFileMpqMaxFileCount: _SFileInfoClass = 33; +pub const _SFileInfoClass_SFileMpqFileTableSize: _SFileInfoClass = 34; +pub const _SFileInfoClass_SFileMpqSectorSize: _SFileInfoClass = 35; +pub const _SFileInfoClass_SFileMpqNumberOfFiles: _SFileInfoClass = 36; +pub const _SFileInfoClass_SFileMpqRawChunkSize: _SFileInfoClass = 37; +pub const _SFileInfoClass_SFileMpqStreamFlags: _SFileInfoClass = 38; +pub const _SFileInfoClass_SFileMpqFlags: _SFileInfoClass = 39; +pub const _SFileInfoClass_SFileInfoPatchChain: _SFileInfoClass = 40; +pub const _SFileInfoClass_SFileInfoFileEntry: _SFileInfoClass = 41; +pub const _SFileInfoClass_SFileInfoHashEntry: _SFileInfoClass = 42; +pub const _SFileInfoClass_SFileInfoHashIndex: _SFileInfoClass = 43; +pub const _SFileInfoClass_SFileInfoNameHash1: _SFileInfoClass = 44; +pub const _SFileInfoClass_SFileInfoNameHash2: _SFileInfoClass = 45; +pub const _SFileInfoClass_SFileInfoNameHash3: _SFileInfoClass = 46; +pub const _SFileInfoClass_SFileInfoLocale: _SFileInfoClass = 47; +pub const _SFileInfoClass_SFileInfoFileIndex: _SFileInfoClass = 48; +pub const _SFileInfoClass_SFileInfoByteOffset: _SFileInfoClass = 49; +pub const _SFileInfoClass_SFileInfoFileTime: _SFileInfoClass = 50; +pub const _SFileInfoClass_SFileInfoFileSize: _SFileInfoClass = 51; +pub const _SFileInfoClass_SFileInfoCompressedSize: _SFileInfoClass = 52; +pub const _SFileInfoClass_SFileInfoFlags: _SFileInfoClass = 53; +pub const _SFileInfoClass_SFileInfoEncryptionKey: _SFileInfoClass = 54; +pub const _SFileInfoClass_SFileInfoEncryptionKeyRaw: _SFileInfoClass = 55; +pub const _SFileInfoClass_SFileInfoCRC32: _SFileInfoClass = 56; +pub type _SFileInfoClass = ::std::os::raw::c_uint; +pub use self::_SFileInfoClass as SFileInfoClass; +pub type SFILE_DOWNLOAD_CALLBACK = ::std::option::Option< + unsafe extern "C" fn( + pvUserData: *mut ::std::os::raw::c_void, + ByteOffset: ULONGLONG, + dwTotalBytes: DWORD, + ), +>; +pub type SFILE_ADDFILE_CALLBACK = ::std::option::Option< + unsafe extern "C" fn( + pvUserData: *mut ::std::os::raw::c_void, + dwBytesWritten: DWORD, + dwTotalBytes: DWORD, + bFinalCall: bool, + ), +>; +pub type SFILE_COMPACT_CALLBACK = ::std::option::Option< + unsafe extern "C" fn( + pvUserData: *mut ::std::os::raw::c_void, + dwWorkType: DWORD, + BytesProcessed: ULONGLONG, + TotalBytes: ULONGLONG, + ), +>; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SFILE_FIND_DATA { + pub cFileName: [::std::os::raw::c_char; 1024usize], + pub szPlainName: *mut ::std::os::raw::c_char, + pub dwHashIndex: DWORD, + pub dwBlockIndex: DWORD, + pub dwFileSize: DWORD, + pub dwFileFlags: DWORD, + pub dwCompSize: DWORD, + pub dwFileTimeLo: DWORD, + pub dwFileTimeHi: DWORD, + pub lcLocale: LCID, +} +#[test] +fn bindgen_test_layout__SFILE_FIND_DATA() { + assert_eq!( + ::std::mem::size_of::<_SFILE_FIND_DATA>(), + 1064usize, + concat!("Size of: ", stringify!(_SFILE_FIND_DATA)) + ); + assert_eq!( + ::std::mem::align_of::<_SFILE_FIND_DATA>(), + 8usize, + concat!("Alignment of ", stringify!(_SFILE_FIND_DATA)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).cFileName as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(cFileName) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).szPlainName as *const _ as usize }, + 1024usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(szPlainName) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwHashIndex as *const _ as usize }, + 1032usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(dwHashIndex) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwBlockIndex as *const _ as usize }, + 1036usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(dwBlockIndex) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwFileSize as *const _ as usize }, + 1040usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(dwFileSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwFileFlags as *const _ as usize }, + 1044usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(dwFileFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwCompSize as *const _ as usize }, + 1048usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(dwCompSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwFileTimeLo as *const _ as usize }, + 1052usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(dwFileTimeLo) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwFileTimeHi as *const _ as usize }, + 1056usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(dwFileTimeHi) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).lcLocale as *const _ as usize }, + 1060usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(lcLocale) + ) + ); +} +pub type SFILE_FIND_DATA = _SFILE_FIND_DATA; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SFILE_CREATE_MPQ { + pub cbSize: DWORD, + pub dwMpqVersion: DWORD, + pub pvUserData: *mut ::std::os::raw::c_void, + pub cbUserData: DWORD, + pub dwStreamFlags: DWORD, + pub dwFileFlags1: DWORD, + pub dwFileFlags2: DWORD, + pub dwFileFlags3: DWORD, + pub dwAttrFlags: DWORD, + pub dwSectorSize: DWORD, + pub dwRawChunkSize: DWORD, + pub dwMaxFileCount: DWORD, +} +#[test] +fn bindgen_test_layout__SFILE_CREATE_MPQ() { + assert_eq!( + ::std::mem::size_of::<_SFILE_CREATE_MPQ>(), + 56usize, + concat!("Size of: ", stringify!(_SFILE_CREATE_MPQ)) + ); + assert_eq!( + ::std::mem::align_of::<_SFILE_CREATE_MPQ>(), + 8usize, + concat!("Alignment of ", stringify!(_SFILE_CREATE_MPQ)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).cbSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(cbSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwMpqVersion as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwMpqVersion) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).pvUserData as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(pvUserData) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).cbUserData as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(cbUserData) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwStreamFlags as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwStreamFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwFileFlags1 as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwFileFlags1) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwFileFlags2 as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwFileFlags2) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwFileFlags3 as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwFileFlags3) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwAttrFlags as *const _ as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwAttrFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwSectorSize as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwSectorSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwRawChunkSize as *const _ as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwRawChunkSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwMaxFileCount as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwMaxFileCount) + ) + ); +} +pub type SFILE_CREATE_MPQ = _SFILE_CREATE_MPQ; +pub type PSFILE_CREATE_MPQ = *mut _SFILE_CREATE_MPQ; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SFILE_MARKERS { + pub dwSize: DWORD, + pub dwSignature: DWORD, + pub szHashTableKey: *const ::std::os::raw::c_char, + pub szBlockTableKey: *const ::std::os::raw::c_char, +} +#[test] +fn bindgen_test_layout__SFILE_MARKERS() { + assert_eq!( + ::std::mem::size_of::<_SFILE_MARKERS>(), + 24usize, + concat!("Size of: ", stringify!(_SFILE_MARKERS)) + ); + assert_eq!( + ::std::mem::align_of::<_SFILE_MARKERS>(), + 8usize, + concat!("Alignment of ", stringify!(_SFILE_MARKERS)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_MARKERS>())).dwSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_MARKERS), + "::", + stringify!(dwSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_MARKERS>())).dwSignature as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_MARKERS), + "::", + stringify!(dwSignature) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_MARKERS>())).szHashTableKey as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_MARKERS), + "::", + stringify!(szHashTableKey) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_MARKERS>())).szBlockTableKey as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_MARKERS), + "::", + stringify!(szBlockTableKey) + ) + ); +} +pub type SFILE_MARKERS = _SFILE_MARKERS; +pub type PSFILE_MARKERS = *mut _SFILE_MARKERS; +pub type SFILESETLOCALE = ::std::option::Option LCID>; +pub type SFILEOPENARCHIVE = ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: DWORD, + arg3: DWORD, + arg4: *mut HANDLE, + ) -> bool, +>; +pub type SFILECLOSEARCHIVE = ::std::option::Option bool>; +pub type SFILEOPENFILEEX = ::std::option::Option< + unsafe extern "C" fn( + arg1: HANDLE, + arg2: *const ::std::os::raw::c_char, + arg3: DWORD, + arg4: *mut HANDLE, + ) -> bool, +>; +pub type SFILECLOSEFILE = ::std::option::Option bool>; +pub type SFILEGETFILESIZE = + ::std::option::Option DWORD>; +pub type SFILESETFILEPOINTER = ::std::option::Option< + unsafe extern "C" fn(arg1: HANDLE, arg2: LONG, arg3: *mut LONG, arg4: DWORD) -> DWORD, +>; +pub type SFILEREADFILE = ::std::option::Option< + unsafe extern "C" fn( + arg1: HANDLE, + arg2: *mut ::std::os::raw::c_void, + arg3: DWORD, + arg4: LPDWORD, + arg5: LPOVERLAPPED, + ) -> bool, +>; +extern "C" { + pub fn SFileSetArchiveMarkers(pMarkers: PSFILE_MARKERS) -> bool; +} +extern "C" { + pub fn SFileGetLocale() -> LCID; +} +extern "C" { + pub fn SFileSetLocale(lcNewLocale: LCID) -> LCID; +} +extern "C" { + pub fn SFileOpenArchive( + szMpqName: *const TCHAR, + dwPriority: DWORD, + dwFlags: DWORD, + phMpq: *mut HANDLE, + ) -> bool; +} +extern "C" { + pub fn SFileCreateArchive( + szMpqName: *const TCHAR, + dwCreateFlags: DWORD, + dwMaxFileCount: DWORD, + phMpq: *mut HANDLE, + ) -> bool; +} +extern "C" { + pub fn SFileCreateArchive2( + szMpqName: *const TCHAR, + pCreateInfo: PSFILE_CREATE_MPQ, + phMpq: *mut HANDLE, + ) -> bool; +} +extern "C" { + pub fn SFileSetDownloadCallback( + hMpq: HANDLE, + DownloadCB: SFILE_DOWNLOAD_CALLBACK, + pvUserData: *mut ::std::os::raw::c_void, + ) -> bool; +} +extern "C" { + pub fn SFileFlushArchive(hMpq: HANDLE) -> bool; +} +extern "C" { + pub fn SFileCloseArchive(hMpq: HANDLE) -> bool; +} +extern "C" { + pub fn SFileAddListFile(hMpq: HANDLE, szListFile: *const TCHAR) -> DWORD; +} +extern "C" { + pub fn SFileSetCompactCallback( + hMpq: HANDLE, + CompactCB: SFILE_COMPACT_CALLBACK, + pvUserData: *mut ::std::os::raw::c_void, + ) -> bool; +} +extern "C" { + pub fn SFileCompactArchive(hMpq: HANDLE, szListFile: *const TCHAR, bReserved: bool) -> bool; +} +extern "C" { + pub fn SFileGetMaxFileCount(hMpq: HANDLE) -> DWORD; +} +extern "C" { + pub fn SFileSetMaxFileCount(hMpq: HANDLE, dwMaxFileCount: DWORD) -> bool; +} +extern "C" { + pub fn SFileGetAttributes(hMpq: HANDLE) -> DWORD; +} +extern "C" { + pub fn SFileSetAttributes(hMpq: HANDLE, dwFlags: DWORD) -> bool; +} +extern "C" { + pub fn SFileUpdateFileAttributes(hMpq: HANDLE, szFileName: *const ::std::os::raw::c_char) + -> bool; +} +extern "C" { + pub fn SFileOpenPatchArchive( + hMpq: HANDLE, + szPatchMpqName: *const TCHAR, + szPatchPathPrefix: *const ::std::os::raw::c_char, + dwFlags: DWORD, + ) -> bool; +} +extern "C" { + pub fn SFileIsPatchedArchive(hMpq: HANDLE) -> bool; +} +extern "C" { + pub fn SFileHasFile(hMpq: HANDLE, szFileName: *const ::std::os::raw::c_char) -> bool; +} +extern "C" { + pub fn SFileOpenFileEx( + hMpq: HANDLE, + szFileName: *const ::std::os::raw::c_char, + dwSearchScope: DWORD, + phFile: *mut HANDLE, + ) -> bool; +} +extern "C" { + pub fn SFileGetFileSize(hFile: HANDLE, pdwFileSizeHigh: LPDWORD) -> DWORD; +} +extern "C" { + pub fn SFileSetFilePointer( + hFile: HANDLE, + lFilePos: LONG, + plFilePosHigh: *mut LONG, + dwMoveMethod: DWORD, + ) -> DWORD; +} +extern "C" { + pub fn SFileReadFile( + hFile: HANDLE, + lpBuffer: *mut ::std::os::raw::c_void, + dwToRead: DWORD, + pdwRead: LPDWORD, + lpOverlapped: LPOVERLAPPED, + ) -> bool; +} +extern "C" { + pub fn SFileCloseFile(hFile: HANDLE) -> bool; +} +extern "C" { + pub fn SFileGetFileInfo( + hMpqOrFile: HANDLE, + InfoClass: SFileInfoClass, + pvFileInfo: *mut ::std::os::raw::c_void, + cbFileInfo: DWORD, + pcbLengthNeeded: LPDWORD, + ) -> bool; +} +extern "C" { + pub fn SFileGetFileName(hFile: HANDLE, szFileName: *mut ::std::os::raw::c_char) -> bool; +} +extern "C" { + pub fn SFileFreeFileInfo( + pvFileInfo: *mut ::std::os::raw::c_void, + InfoClass: SFileInfoClass, + ) -> bool; +} +extern "C" { + pub fn SFileExtractFile( + hMpq: HANDLE, + szToExtract: *const ::std::os::raw::c_char, + szExtracted: *const TCHAR, + dwSearchScope: DWORD, + ) -> bool; +} +extern "C" { + pub fn SFileGetFileChecksums( + hMpq: HANDLE, + szFileName: *const ::std::os::raw::c_char, + pdwCrc32: LPDWORD, + pMD5: *mut ::std::os::raw::c_char, + ) -> bool; +} +extern "C" { + pub fn SFileVerifyFile( + hMpq: HANDLE, + szFileName: *const ::std::os::raw::c_char, + dwFlags: DWORD, + ) -> DWORD; +} +extern "C" { + pub fn SFileVerifyRawData( + hMpq: HANDLE, + dwWhatToVerify: DWORD, + szFileName: *const ::std::os::raw::c_char, + ) -> DWORD; +} +extern "C" { + pub fn SFileSignArchive(hMpq: HANDLE, dwSignatureType: DWORD) -> bool; +} +extern "C" { + pub fn SFileVerifyArchive(hMpq: HANDLE) -> DWORD; +} +extern "C" { + pub fn SFileFindFirstFile( + hMpq: HANDLE, + szMask: *const ::std::os::raw::c_char, + lpFindFileData: *mut SFILE_FIND_DATA, + szListFile: *const TCHAR, + ) -> HANDLE; +} +extern "C" { + pub fn SFileFindNextFile(hFind: HANDLE, lpFindFileData: *mut SFILE_FIND_DATA) -> bool; +} +extern "C" { + pub fn SFileFindClose(hFind: HANDLE) -> bool; +} +extern "C" { + pub fn SListFileFindFirstFile( + hMpq: HANDLE, + szListFile: *const TCHAR, + szMask: *const ::std::os::raw::c_char, + lpFindFileData: *mut SFILE_FIND_DATA, + ) -> HANDLE; +} +extern "C" { + pub fn SListFileFindNextFile(hFind: HANDLE, lpFindFileData: *mut SFILE_FIND_DATA) -> bool; +} +extern "C" { + pub fn SListFileFindClose(hFind: HANDLE) -> bool; +} +extern "C" { + pub fn SFileEnumLocales( + hMpq: HANDLE, + szFileName: *const ::std::os::raw::c_char, + plcLocales: *mut LCID, + pdwMaxLocales: LPDWORD, + dwSearchScope: DWORD, + ) -> DWORD; +} +extern "C" { + pub fn SFileCreateFile( + hMpq: HANDLE, + szArchivedName: *const ::std::os::raw::c_char, + FileTime: ULONGLONG, + dwFileSize: DWORD, + lcLocale: LCID, + dwFlags: DWORD, + phFile: *mut HANDLE, + ) -> bool; +} +extern "C" { + pub fn SFileWriteFile( + hFile: HANDLE, + pvData: *const ::std::os::raw::c_void, + dwSize: DWORD, + dwCompression: DWORD, + ) -> bool; +} +extern "C" { + pub fn SFileFinishFile(hFile: HANDLE) -> bool; +} +extern "C" { + pub fn SFileAddFileEx( + hMpq: HANDLE, + szFileName: *const TCHAR, + szArchivedName: *const ::std::os::raw::c_char, + dwFlags: DWORD, + dwCompression: DWORD, + dwCompressionNext: DWORD, + ) -> bool; +} +extern "C" { + pub fn SFileAddFile( + hMpq: HANDLE, + szFileName: *const TCHAR, + szArchivedName: *const ::std::os::raw::c_char, + dwFlags: DWORD, + ) -> bool; +} +extern "C" { + pub fn SFileAddWave( + hMpq: HANDLE, + szFileName: *const TCHAR, + szArchivedName: *const ::std::os::raw::c_char, + dwFlags: DWORD, + dwQuality: DWORD, + ) -> bool; +} +extern "C" { + pub fn SFileRemoveFile( + hMpq: HANDLE, + szFileName: *const ::std::os::raw::c_char, + dwSearchScope: DWORD, + ) -> bool; +} +extern "C" { + pub fn SFileRenameFile( + hMpq: HANDLE, + szOldFileName: *const ::std::os::raw::c_char, + szNewFileName: *const ::std::os::raw::c_char, + ) -> bool; +} +extern "C" { + pub fn SFileSetFileLocale(hFile: HANDLE, lcNewLocale: LCID) -> bool; +} +extern "C" { + pub fn SFileSetDataCompression(DataCompression: DWORD) -> bool; +} +extern "C" { + pub fn SFileSetAddFileCallback( + hMpq: HANDLE, + AddFileCB: SFILE_ADDFILE_CALLBACK, + pvUserData: *mut ::std::os::raw::c_void, + ) -> bool; +} +extern "C" { + pub fn SCompImplode( + pvOutBuffer: *mut ::std::os::raw::c_void, + pcbOutBuffer: *mut ::std::os::raw::c_int, + pvInBuffer: *mut ::std::os::raw::c_void, + cbInBuffer: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn SCompExplode( + pvOutBuffer: *mut ::std::os::raw::c_void, + pcbOutBuffer: *mut ::std::os::raw::c_int, + pvInBuffer: *mut ::std::os::raw::c_void, + cbInBuffer: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn SCompCompress( + pvOutBuffer: *mut ::std::os::raw::c_void, + pcbOutBuffer: *mut ::std::os::raw::c_int, + pvInBuffer: *mut ::std::os::raw::c_void, + cbInBuffer: ::std::os::raw::c_int, + uCompressionMask: ::std::os::raw::c_uint, + nCmpType: ::std::os::raw::c_int, + nCmpLevel: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn SCompDecompress( + pvOutBuffer: *mut ::std::os::raw::c_void, + pcbOutBuffer: *mut ::std::os::raw::c_int, + pvInBuffer: *mut ::std::os::raw::c_void, + cbInBuffer: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn SCompDecompress2( + pvOutBuffer: *mut ::std::os::raw::c_void, + pcbOutBuffer: *mut ::std::os::raw::c_int, + pvInBuffer: *mut ::std::os::raw::c_void, + cbInBuffer: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} diff --git a/crates/stormlib-sys/src/bindings_windows.rs b/crates/stormlib-sys/src/bindings_windows.rs new file mode 100644 index 0000000..86d0291 --- /dev/null +++ b/crates/stormlib-sys/src/bindings_windows.rs @@ -0,0 +1,41092 @@ +/* automatically generated by rust-bindgen 0.56.0 */ + +#[repr(C)] +#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub struct __BindgenBitfieldUnit { + storage: Storage, + align: [Align; 0], +} +impl __BindgenBitfieldUnit { + #[inline] + pub const fn new(storage: Storage) -> Self { + Self { storage, align: [] } + } +} +impl __BindgenBitfieldUnit +where + Storage: AsRef<[u8]> + AsMut<[u8]>, +{ + #[inline] + pub fn get_bit(&self, index: usize) -> bool { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = self.storage.as_ref()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + byte & mask == mask + } + #[inline] + pub fn set_bit(&mut self, index: usize, val: bool) { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = &mut self.storage.as_mut()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + if val { + *byte |= mask; + } else { + *byte &= !mask; + } + } + #[inline] + pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + let mut val = 0; + for i in 0..(bit_width as usize) { + if self.get_bit(i + bit_offset) { + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + val |= 1 << index; + } + } + val + } + #[inline] + pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + for i in 0..(bit_width as usize) { + let mask = 1 << i; + let val_bit_is_set = val & mask == mask; + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + self.set_bit(index + bit_offset, val_bit_is_set); + } + } +} +#[repr(C)] +#[derive(Default)] +pub struct __IncompleteArrayField(::std::marker::PhantomData, [T; 0]); +impl __IncompleteArrayField { + #[inline] + pub const fn new() -> Self { + __IncompleteArrayField(::std::marker::PhantomData, []) + } + #[inline] + pub fn as_ptr(&self) -> *const T { + self as *const _ as *const T + } + #[inline] + pub fn as_mut_ptr(&mut self) -> *mut T { + self as *mut _ as *mut T + } + #[inline] + pub unsafe fn as_slice(&self, len: usize) -> &[T] { + ::std::slice::from_raw_parts(self.as_ptr(), len) + } + #[inline] + pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { + ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len) + } +} +impl ::std::fmt::Debug for __IncompleteArrayField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + fmt.write_str("__IncompleteArrayField") + } +} +#[repr(C)] +pub struct __BindgenUnionField(::std::marker::PhantomData); +impl __BindgenUnionField { + #[inline] + pub const fn new() -> Self { + __BindgenUnionField(::std::marker::PhantomData) + } + #[inline] + pub unsafe fn as_ref(&self) -> &T { + ::std::mem::transmute(self) + } + #[inline] + pub unsafe fn as_mut(&mut self) -> &mut T { + ::std::mem::transmute(self) + } +} +impl ::std::default::Default for __BindgenUnionField { + #[inline] + fn default() -> Self { + Self::new() + } +} +impl ::std::clone::Clone for __BindgenUnionField { + #[inline] + fn clone(&self) -> Self { + Self::new() + } +} +impl ::std::marker::Copy for __BindgenUnionField {} +impl ::std::fmt::Debug for __BindgenUnionField { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + fmt.write_str("__BindgenUnionField") + } +} +impl ::std::hash::Hash for __BindgenUnionField { + fn hash(&self, _state: &mut H) {} +} +impl ::std::cmp::PartialEq for __BindgenUnionField { + fn eq(&self, _other: &__BindgenUnionField) -> bool { + true + } +} +impl ::std::cmp::Eq for __BindgenUnionField {} +pub const ERROR_SEVERITY_SUCCESS: u32 = 0; +pub const ERROR_SEVERITY_INFORMATIONAL: u32 = 1073741824; +pub const ERROR_SEVERITY_WARNING: u32 = 2147483648; +pub const ERROR_SEVERITY_ERROR: u32 = 3221225472; +pub const LANG_NEUTRAL: u32 = 0; +pub const ERROR_SUCCESS: u32 = 0; +pub const ERROR_INVALID_FUNCTION: u32 = 1; +pub const ERROR_FILE_NOT_FOUND: u32 = 2; +pub const ERROR_PATH_NOT_FOUND: u32 = 3; +pub const ERROR_TOO_MANY_OPEN_FILES: u32 = 4; +pub const ERROR_ACCESS_DENIED: u32 = 5; +pub const ERROR_INVALID_HANDLE: u32 = 6; +pub const ERROR_ARENA_TRASHED: u32 = 7; +pub const ERROR_NOT_ENOUGH_MEMORY: u32 = 8; +pub const ERROR_INVALID_BLOCK: u32 = 9; +pub const ERROR_BAD_ENVIRONMENT: u32 = 10; +pub const ERROR_BAD_FORMAT: u32 = 11; +pub const ERROR_INVALID_ACCESS: u32 = 12; +pub const ERROR_INVALID_DATA: u32 = 13; +pub const ERROR_OUTOFMEMORY: u32 = 14; +pub const ERROR_INVALID_DRIVE: u32 = 15; +pub const ERROR_CURRENT_DIRECTORY: u32 = 16; +pub const ERROR_NOT_SAME_DEVICE: u32 = 17; +pub const ERROR_NO_MORE_FILES: u32 = 18; +pub const ERROR_WRITE_PROTECT: u32 = 19; +pub const ERROR_BAD_UNIT: u32 = 20; +pub const ERROR_NOT_READY: u32 = 21; +pub const ERROR_BAD_COMMAND: u32 = 22; +pub const ERROR_CRC: u32 = 23; +pub const ERROR_BAD_LENGTH: u32 = 24; +pub const ERROR_SEEK: u32 = 25; +pub const ERROR_NOT_DOS_DISK: u32 = 26; +pub const ERROR_SECTOR_NOT_FOUND: u32 = 27; +pub const ERROR_OUT_OF_PAPER: u32 = 28; +pub const ERROR_WRITE_FAULT: u32 = 29; +pub const ERROR_READ_FAULT: u32 = 30; +pub const ERROR_GEN_FAILURE: u32 = 31; +pub const ERROR_SHARING_VIOLATION: u32 = 32; +pub const ERROR_LOCK_VIOLATION: u32 = 33; +pub const ERROR_WRONG_DISK: u32 = 34; +pub const ERROR_SHARING_BUFFER_EXCEEDED: u32 = 36; +pub const ERROR_HANDLE_EOF: u32 = 38; +pub const ERROR_HANDLE_DISK_FULL: u32 = 39; +pub const ERROR_NOT_SUPPORTED: u32 = 50; +pub const ERROR_REM_NOT_LIST: u32 = 51; +pub const ERROR_DUP_NAME: u32 = 52; +pub const ERROR_BAD_NETPATH: u32 = 53; +pub const ERROR_NETWORK_BUSY: u32 = 54; +pub const ERROR_DEV_NOT_EXIST: u32 = 55; +pub const ERROR_TOO_MANY_CMDS: u32 = 56; +pub const ERROR_ADAP_HDW_ERR: u32 = 57; +pub const ERROR_BAD_NET_RESP: u32 = 58; +pub const ERROR_UNEXP_NET_ERR: u32 = 59; +pub const ERROR_BAD_REM_ADAP: u32 = 60; +pub const ERROR_PRINTQ_FULL: u32 = 61; +pub const ERROR_NO_SPOOL_SPACE: u32 = 62; +pub const ERROR_PRINT_CANCELLED: u32 = 63; +pub const ERROR_NETNAME_DELETED: u32 = 64; +pub const ERROR_NETWORK_ACCESS_DENIED: u32 = 65; +pub const ERROR_BAD_DEV_TYPE: u32 = 66; +pub const ERROR_BAD_NET_NAME: u32 = 67; +pub const ERROR_TOO_MANY_NAMES: u32 = 68; +pub const ERROR_TOO_MANY_SESS: u32 = 69; +pub const ERROR_SHARING_PAUSED: u32 = 70; +pub const ERROR_REQ_NOT_ACCEP: u32 = 71; +pub const ERROR_REDIR_PAUSED: u32 = 72; +pub const ERROR_FILE_EXISTS: u32 = 80; +pub const ERROR_CANNOT_MAKE: u32 = 82; +pub const ERROR_FAIL_I24: u32 = 83; +pub const ERROR_OUT_OF_STRUCTURES: u32 = 84; +pub const ERROR_ALREADY_ASSIGNED: u32 = 85; +pub const ERROR_INVALID_PASSWORD: u32 = 86; +pub const ERROR_INVALID_PARAMETER: u32 = 87; +pub const ERROR_NET_WRITE_FAULT: u32 = 88; +pub const ERROR_NO_PROC_SLOTS: u32 = 89; +pub const ERROR_TOO_MANY_SEMAPHORES: u32 = 100; +pub const ERROR_EXCL_SEM_ALREADY_OWNED: u32 = 101; +pub const ERROR_SEM_IS_SET: u32 = 102; +pub const ERROR_TOO_MANY_SEM_REQUESTS: u32 = 103; +pub const ERROR_INVALID_AT_INTERRUPT_TIME: u32 = 104; +pub const ERROR_SEM_OWNER_DIED: u32 = 105; +pub const ERROR_SEM_USER_LIMIT: u32 = 106; +pub const ERROR_DISK_CHANGE: u32 = 107; +pub const ERROR_DRIVE_LOCKED: u32 = 108; +pub const ERROR_BROKEN_PIPE: u32 = 109; +pub const ERROR_OPEN_FAILED: u32 = 110; +pub const ERROR_BUFFER_OVERFLOW: u32 = 111; +pub const ERROR_DISK_FULL: u32 = 112; +pub const ERROR_NO_MORE_SEARCH_HANDLES: u32 = 113; +pub const ERROR_INVALID_TARGET_HANDLE: u32 = 114; +pub const ERROR_INVALID_CATEGORY: u32 = 117; +pub const ERROR_INVALID_VERIFY_SWITCH: u32 = 118; +pub const ERROR_BAD_DRIVER_LEVEL: u32 = 119; +pub const ERROR_CALL_NOT_IMPLEMENTED: u32 = 120; +pub const ERROR_SEM_TIMEOUT: u32 = 121; +pub const ERROR_INSUFFICIENT_BUFFER: u32 = 122; +pub const ERROR_INVALID_NAME: u32 = 123; +pub const ERROR_INVALID_LEVEL: u32 = 124; +pub const ERROR_NO_VOLUME_LABEL: u32 = 125; +pub const ERROR_MOD_NOT_FOUND: u32 = 126; +pub const ERROR_PROC_NOT_FOUND: u32 = 127; +pub const ERROR_WAIT_NO_CHILDREN: u32 = 128; +pub const ERROR_CHILD_NOT_COMPLETE: u32 = 129; +pub const ERROR_DIRECT_ACCESS_HANDLE: u32 = 130; +pub const ERROR_NEGATIVE_SEEK: u32 = 131; +pub const ERROR_SEEK_ON_DEVICE: u32 = 132; +pub const ERROR_IS_JOIN_TARGET: u32 = 133; +pub const ERROR_IS_JOINED: u32 = 134; +pub const ERROR_IS_SUBSTED: u32 = 135; +pub const ERROR_NOT_JOINED: u32 = 136; +pub const ERROR_NOT_SUBSTED: u32 = 137; +pub const ERROR_JOIN_TO_JOIN: u32 = 138; +pub const ERROR_SUBST_TO_SUBST: u32 = 139; +pub const ERROR_JOIN_TO_SUBST: u32 = 140; +pub const ERROR_SUBST_TO_JOIN: u32 = 141; +pub const ERROR_BUSY_DRIVE: u32 = 142; +pub const ERROR_SAME_DRIVE: u32 = 143; +pub const ERROR_DIR_NOT_ROOT: u32 = 144; +pub const ERROR_DIR_NOT_EMPTY: u32 = 145; +pub const ERROR_IS_SUBST_PATH: u32 = 146; +pub const ERROR_IS_JOIN_PATH: u32 = 147; +pub const ERROR_PATH_BUSY: u32 = 148; +pub const ERROR_IS_SUBST_TARGET: u32 = 149; +pub const ERROR_SYSTEM_TRACE: u32 = 150; +pub const ERROR_INVALID_EVENT_COUNT: u32 = 151; +pub const ERROR_TOO_MANY_MUXWAITERS: u32 = 152; +pub const ERROR_INVALID_LIST_FORMAT: u32 = 153; +pub const ERROR_LABEL_TOO_LONG: u32 = 154; +pub const ERROR_TOO_MANY_TCBS: u32 = 155; +pub const ERROR_SIGNAL_REFUSED: u32 = 156; +pub const ERROR_DISCARDED: u32 = 157; +pub const ERROR_NOT_LOCKED: u32 = 158; +pub const ERROR_BAD_THREADID_ADDR: u32 = 159; +pub const ERROR_BAD_ARGUMENTS: u32 = 160; +pub const ERROR_BAD_PATHNAME: u32 = 161; +pub const ERROR_SIGNAL_PENDING: u32 = 162; +pub const ERROR_MAX_THRDS_REACHED: u32 = 164; +pub const ERROR_LOCK_FAILED: u32 = 167; +pub const ERROR_BUSY: u32 = 170; +pub const ERROR_DEVICE_SUPPORT_IN_PROGRESS: u32 = 171; +pub const ERROR_CANCEL_VIOLATION: u32 = 173; +pub const ERROR_ATOMIC_LOCKS_NOT_SUPPORTED: u32 = 174; +pub const ERROR_INVALID_SEGMENT_NUMBER: u32 = 180; +pub const ERROR_INVALID_ORDINAL: u32 = 182; +pub const ERROR_ALREADY_EXISTS: u32 = 183; +pub const ERROR_INVALID_FLAG_NUMBER: u32 = 186; +pub const ERROR_SEM_NOT_FOUND: u32 = 187; +pub const ERROR_INVALID_STARTING_CODESEG: u32 = 188; +pub const ERROR_INVALID_STACKSEG: u32 = 189; +pub const ERROR_INVALID_MODULETYPE: u32 = 190; +pub const ERROR_INVALID_EXE_SIGNATURE: u32 = 191; +pub const ERROR_EXE_MARKED_INVALID: u32 = 192; +pub const ERROR_BAD_EXE_FORMAT: u32 = 193; +pub const ERROR_ITERATED_DATA_EXCEEDS_64k: u32 = 194; +pub const ERROR_INVALID_MINALLOCSIZE: u32 = 195; +pub const ERROR_DYNLINK_FROM_INVALID_RING: u32 = 196; +pub const ERROR_IOPL_NOT_ENABLED: u32 = 197; +pub const ERROR_INVALID_SEGDPL: u32 = 198; +pub const ERROR_AUTODATASEG_EXCEEDS_64k: u32 = 199; +pub const ERROR_RING2SEG_MUST_BE_MOVABLE: u32 = 200; +pub const ERROR_RELOC_CHAIN_XEEDS_SEGLIM: u32 = 201; +pub const ERROR_INFLOOP_IN_RELOC_CHAIN: u32 = 202; +pub const ERROR_ENVVAR_NOT_FOUND: u32 = 203; +pub const ERROR_NO_SIGNAL_SENT: u32 = 205; +pub const ERROR_FILENAME_EXCED_RANGE: u32 = 206; +pub const ERROR_RING2_STACK_IN_USE: u32 = 207; +pub const ERROR_META_EXPANSION_TOO_LONG: u32 = 208; +pub const ERROR_INVALID_SIGNAL_NUMBER: u32 = 209; +pub const ERROR_THREAD_1_INACTIVE: u32 = 210; +pub const ERROR_LOCKED: u32 = 212; +pub const ERROR_TOO_MANY_MODULES: u32 = 214; +pub const ERROR_NESTING_NOT_ALLOWED: u32 = 215; +pub const ERROR_EXE_MACHINE_TYPE_MISMATCH: u32 = 216; +pub const ERROR_EXE_CANNOT_MODIFY_SIGNED_BINARY: u32 = 217; +pub const ERROR_EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY: u32 = 218; +pub const ERROR_FILE_CHECKED_OUT: u32 = 220; +pub const ERROR_CHECKOUT_REQUIRED: u32 = 221; +pub const ERROR_BAD_FILE_TYPE: u32 = 222; +pub const ERROR_FILE_TOO_LARGE: u32 = 223; +pub const ERROR_FORMS_AUTH_REQUIRED: u32 = 224; +pub const ERROR_VIRUS_INFECTED: u32 = 225; +pub const ERROR_VIRUS_DELETED: u32 = 226; +pub const ERROR_PIPE_LOCAL: u32 = 229; +pub const ERROR_BAD_PIPE: u32 = 230; +pub const ERROR_PIPE_BUSY: u32 = 231; +pub const ERROR_NO_DATA: u32 = 232; +pub const ERROR_PIPE_NOT_CONNECTED: u32 = 233; +pub const ERROR_MORE_DATA: u32 = 234; +pub const ERROR_NO_WORK_DONE: u32 = 235; +pub const ERROR_VC_DISCONNECTED: u32 = 240; +pub const ERROR_INVALID_EA_NAME: u32 = 254; +pub const ERROR_EA_LIST_INCONSISTENT: u32 = 255; +pub const ERROR_NO_MORE_ITEMS: u32 = 259; +pub const ERROR_CANNOT_COPY: u32 = 266; +pub const ERROR_DIRECTORY: u32 = 267; +pub const ERROR_EAS_DIDNT_FIT: u32 = 275; +pub const ERROR_EA_FILE_CORRUPT: u32 = 276; +pub const ERROR_EA_TABLE_FULL: u32 = 277; +pub const ERROR_INVALID_EA_HANDLE: u32 = 278; +pub const ERROR_EAS_NOT_SUPPORTED: u32 = 282; +pub const ERROR_NOT_OWNER: u32 = 288; +pub const ERROR_TOO_MANY_POSTS: u32 = 298; +pub const ERROR_PARTIAL_COPY: u32 = 299; +pub const ERROR_OPLOCK_NOT_GRANTED: u32 = 300; +pub const ERROR_INVALID_OPLOCK_PROTOCOL: u32 = 301; +pub const ERROR_DISK_TOO_FRAGMENTED: u32 = 302; +pub const ERROR_DELETE_PENDING: u32 = 303; +pub const ERROR_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING: u32 = 304; +pub const ERROR_SHORT_NAMES_NOT_ENABLED_ON_VOLUME: u32 = 305; +pub const ERROR_SECURITY_STREAM_IS_INCONSISTENT: u32 = 306; +pub const ERROR_INVALID_LOCK_RANGE: u32 = 307; +pub const ERROR_IMAGE_SUBSYSTEM_NOT_PRESENT: u32 = 308; +pub const ERROR_NOTIFICATION_GUID_ALREADY_DEFINED: u32 = 309; +pub const ERROR_INVALID_EXCEPTION_HANDLER: u32 = 310; +pub const ERROR_DUPLICATE_PRIVILEGES: u32 = 311; +pub const ERROR_NO_RANGES_PROCESSED: u32 = 312; +pub const ERROR_NOT_ALLOWED_ON_SYSTEM_FILE: u32 = 313; +pub const ERROR_DISK_RESOURCES_EXHAUSTED: u32 = 314; +pub const ERROR_INVALID_TOKEN: u32 = 315; +pub const ERROR_DEVICE_FEATURE_NOT_SUPPORTED: u32 = 316; +pub const ERROR_MR_MID_NOT_FOUND: u32 = 317; +pub const ERROR_SCOPE_NOT_FOUND: u32 = 318; +pub const ERROR_UNDEFINED_SCOPE: u32 = 319; +pub const ERROR_INVALID_CAP: u32 = 320; +pub const ERROR_DEVICE_UNREACHABLE: u32 = 321; +pub const ERROR_DEVICE_NO_RESOURCES: u32 = 322; +pub const ERROR_DATA_CHECKSUM_ERROR: u32 = 323; +pub const ERROR_INTERMIXED_KERNEL_EA_OPERATION: u32 = 324; +pub const ERROR_FILE_LEVEL_TRIM_NOT_SUPPORTED: u32 = 326; +pub const ERROR_OFFSET_ALIGNMENT_VIOLATION: u32 = 327; +pub const ERROR_INVALID_FIELD_IN_PARAMETER_LIST: u32 = 328; +pub const ERROR_OPERATION_IN_PROGRESS: u32 = 329; +pub const ERROR_BAD_DEVICE_PATH: u32 = 330; +pub const ERROR_TOO_MANY_DESCRIPTORS: u32 = 331; +pub const ERROR_SCRUB_DATA_DISABLED: u32 = 332; +pub const ERROR_NOT_REDUNDANT_STORAGE: u32 = 333; +pub const ERROR_RESIDENT_FILE_NOT_SUPPORTED: u32 = 334; +pub const ERROR_COMPRESSED_FILE_NOT_SUPPORTED: u32 = 335; +pub const ERROR_DIRECTORY_NOT_SUPPORTED: u32 = 336; +pub const ERROR_NOT_READ_FROM_COPY: u32 = 337; +pub const ERROR_FT_WRITE_FAILURE: u32 = 338; +pub const ERROR_FT_DI_SCAN_REQUIRED: u32 = 339; +pub const ERROR_INVALID_KERNEL_INFO_VERSION: u32 = 340; +pub const ERROR_INVALID_PEP_INFO_VERSION: u32 = 341; +pub const ERROR_OBJECT_NOT_EXTERNALLY_BACKED: u32 = 342; +pub const ERROR_EXTERNAL_BACKING_PROVIDER_UNKNOWN: u32 = 343; +pub const ERROR_COMPRESSION_NOT_BENEFICIAL: u32 = 344; +pub const ERROR_STORAGE_TOPOLOGY_ID_MISMATCH: u32 = 345; +pub const ERROR_BLOCKED_BY_PARENTAL_CONTROLS: u32 = 346; +pub const ERROR_BLOCK_TOO_MANY_REFERENCES: u32 = 347; +pub const ERROR_MARKED_TO_DISALLOW_WRITES: u32 = 348; +pub const ERROR_ENCLAVE_FAILURE: u32 = 349; +pub const ERROR_FAIL_NOACTION_REBOOT: u32 = 350; +pub const ERROR_FAIL_SHUTDOWN: u32 = 351; +pub const ERROR_FAIL_RESTART: u32 = 352; +pub const ERROR_MAX_SESSIONS_REACHED: u32 = 353; +pub const ERROR_NETWORK_ACCESS_DENIED_EDP: u32 = 354; +pub const ERROR_DEVICE_HINT_NAME_BUFFER_TOO_SMALL: u32 = 355; +pub const ERROR_EDP_POLICY_DENIES_OPERATION: u32 = 356; +pub const ERROR_EDP_DPL_POLICY_CANT_BE_SATISFIED: u32 = 357; +pub const ERROR_CLOUD_FILE_SYNC_ROOT_METADATA_CORRUPT: u32 = 358; +pub const ERROR_DEVICE_IN_MAINTENANCE: u32 = 359; +pub const ERROR_NOT_SUPPORTED_ON_DAX: u32 = 360; +pub const ERROR_DAX_MAPPING_EXISTS: u32 = 361; +pub const ERROR_CLOUD_FILE_PROVIDER_NOT_RUNNING: u32 = 362; +pub const ERROR_CLOUD_FILE_METADATA_CORRUPT: u32 = 363; +pub const ERROR_CLOUD_FILE_METADATA_TOO_LARGE: u32 = 364; +pub const ERROR_CLOUD_FILE_PROPERTY_BLOB_TOO_LARGE: u32 = 365; +pub const ERROR_CLOUD_FILE_PROPERTY_BLOB_CHECKSUM_MISMATCH: u32 = 366; +pub const ERROR_CHILD_PROCESS_BLOCKED: u32 = 367; +pub const ERROR_STORAGE_LOST_DATA_PERSISTENCE: u32 = 368; +pub const ERROR_FILE_SYSTEM_VIRTUALIZATION_UNAVAILABLE: u32 = 369; +pub const ERROR_FILE_SYSTEM_VIRTUALIZATION_METADATA_CORRUPT: u32 = 370; +pub const ERROR_FILE_SYSTEM_VIRTUALIZATION_BUSY: u32 = 371; +pub const ERROR_FILE_SYSTEM_VIRTUALIZATION_PROVIDER_UNKNOWN: u32 = 372; +pub const ERROR_GDI_HANDLE_LEAK: u32 = 373; +pub const ERROR_CLOUD_FILE_TOO_MANY_PROPERTY_BLOBS: u32 = 374; +pub const ERROR_CLOUD_FILE_PROPERTY_VERSION_NOT_SUPPORTED: u32 = 375; +pub const ERROR_NOT_A_CLOUD_FILE: u32 = 376; +pub const ERROR_CLOUD_FILE_NOT_IN_SYNC: u32 = 377; +pub const ERROR_CLOUD_FILE_ALREADY_CONNECTED: u32 = 378; +pub const ERROR_CLOUD_FILE_NOT_SUPPORTED: u32 = 379; +pub const ERROR_CLOUD_FILE_INVALID_REQUEST: u32 = 380; +pub const ERROR_CLOUD_FILE_READ_ONLY_VOLUME: u32 = 381; +pub const ERROR_CLOUD_FILE_CONNECTED_PROVIDER_ONLY: u32 = 382; +pub const ERROR_CLOUD_FILE_VALIDATION_FAILED: u32 = 383; +pub const ERROR_SMB1_NOT_AVAILABLE: u32 = 384; +pub const ERROR_FILE_SYSTEM_VIRTUALIZATION_INVALID_OPERATION: u32 = 385; +pub const ERROR_CLOUD_FILE_AUTHENTICATION_FAILED: u32 = 386; +pub const ERROR_CLOUD_FILE_INSUFFICIENT_RESOURCES: u32 = 387; +pub const ERROR_CLOUD_FILE_NETWORK_UNAVAILABLE: u32 = 388; +pub const ERROR_CLOUD_FILE_UNSUCCESSFUL: u32 = 389; +pub const ERROR_CLOUD_FILE_NOT_UNDER_SYNC_ROOT: u32 = 390; +pub const ERROR_CLOUD_FILE_IN_USE: u32 = 391; +pub const ERROR_CLOUD_FILE_PINNED: u32 = 392; +pub const ERROR_CLOUD_FILE_REQUEST_ABORTED: u32 = 393; +pub const ERROR_CLOUD_FILE_PROPERTY_CORRUPT: u32 = 394; +pub const ERROR_CLOUD_FILE_ACCESS_DENIED: u32 = 395; +pub const ERROR_CLOUD_FILE_INCOMPATIBLE_HARDLINKS: u32 = 396; +pub const ERROR_CLOUD_FILE_PROPERTY_LOCK_CONFLICT: u32 = 397; +pub const ERROR_CLOUD_FILE_REQUEST_CANCELED: u32 = 398; +pub const ERROR_EXTERNAL_SYSKEY_NOT_SUPPORTED: u32 = 399; +pub const ERROR_THREAD_MODE_ALREADY_BACKGROUND: u32 = 400; +pub const ERROR_THREAD_MODE_NOT_BACKGROUND: u32 = 401; +pub const ERROR_PROCESS_MODE_ALREADY_BACKGROUND: u32 = 402; +pub const ERROR_PROCESS_MODE_NOT_BACKGROUND: u32 = 403; +pub const ERROR_CLOUD_FILE_PROVIDER_TERMINATED: u32 = 404; +pub const ERROR_NOT_A_CLOUD_SYNC_ROOT: u32 = 405; +pub const ERROR_FILE_PROTECTED_UNDER_DPL: u32 = 406; +pub const ERROR_VOLUME_NOT_CLUSTER_ALIGNED: u32 = 407; +pub const ERROR_NO_PHYSICALLY_ALIGNED_FREE_SPACE_FOUND: u32 = 408; +pub const ERROR_APPX_FILE_NOT_ENCRYPTED: u32 = 409; +pub const ERROR_RWRAW_ENCRYPTED_FILE_NOT_ENCRYPTED: u32 = 410; +pub const ERROR_RWRAW_ENCRYPTED_INVALID_EDATAINFO_FILEOFFSET: u32 = 411; +pub const ERROR_RWRAW_ENCRYPTED_INVALID_EDATAINFO_FILERANGE: u32 = 412; +pub const ERROR_RWRAW_ENCRYPTED_INVALID_EDATAINFO_PARAMETER: u32 = 413; +pub const ERROR_LINUX_SUBSYSTEM_NOT_PRESENT: u32 = 414; +pub const ERROR_FT_READ_FAILURE: u32 = 415; +pub const ERROR_STORAGE_RESERVE_ID_INVALID: u32 = 416; +pub const ERROR_STORAGE_RESERVE_DOES_NOT_EXIST: u32 = 417; +pub const ERROR_STORAGE_RESERVE_ALREADY_EXISTS: u32 = 418; +pub const ERROR_STORAGE_RESERVE_NOT_EMPTY: u32 = 419; +pub const ERROR_NOT_A_DAX_VOLUME: u32 = 420; +pub const ERROR_NOT_DAX_MAPPABLE: u32 = 421; +pub const ERROR_TIME_SENSITIVE_THREAD: u32 = 422; +pub const ERROR_DPL_NOT_SUPPORTED_FOR_USER: u32 = 423; +pub const ERROR_CASE_DIFFERING_NAMES_IN_DIR: u32 = 424; +pub const ERROR_FILE_NOT_SUPPORTED: u32 = 425; +pub const ERROR_CLOUD_FILE_REQUEST_TIMEOUT: u32 = 426; +pub const ERROR_NO_TASK_QUEUE: u32 = 427; +pub const ERROR_SRC_SRV_DLL_LOAD_FAILED: u32 = 428; +pub const ERROR_NOT_SUPPORTED_WITH_BTT: u32 = 429; +pub const ERROR_ENCRYPTION_DISABLED: u32 = 430; +pub const ERROR_ENCRYPTING_METADATA_DISALLOWED: u32 = 431; +pub const ERROR_CANT_CLEAR_ENCRYPTION_FLAG: u32 = 432; +pub const ERROR_NO_SUCH_DEVICE: u32 = 433; +pub const ERROR_CAPAUTHZ_NOT_DEVUNLOCKED: u32 = 450; +pub const ERROR_CAPAUTHZ_CHANGE_TYPE: u32 = 451; +pub const ERROR_CAPAUTHZ_NOT_PROVISIONED: u32 = 452; +pub const ERROR_CAPAUTHZ_NOT_AUTHORIZED: u32 = 453; +pub const ERROR_CAPAUTHZ_NO_POLICY: u32 = 454; +pub const ERROR_CAPAUTHZ_DB_CORRUPTED: u32 = 455; +pub const ERROR_CAPAUTHZ_SCCD_INVALID_CATALOG: u32 = 456; +pub const ERROR_CAPAUTHZ_SCCD_NO_AUTH_ENTITY: u32 = 457; +pub const ERROR_CAPAUTHZ_SCCD_PARSE_ERROR: u32 = 458; +pub const ERROR_CAPAUTHZ_SCCD_DEV_MODE_REQUIRED: u32 = 459; +pub const ERROR_CAPAUTHZ_SCCD_NO_CAPABILITY_MATCH: u32 = 460; +pub const ERROR_PNP_QUERY_REMOVE_DEVICE_TIMEOUT: u32 = 480; +pub const ERROR_PNP_QUERY_REMOVE_RELATED_DEVICE_TIMEOUT: u32 = 481; +pub const ERROR_PNP_QUERY_REMOVE_UNRELATED_DEVICE_TIMEOUT: u32 = 482; +pub const ERROR_DEVICE_HARDWARE_ERROR: u32 = 483; +pub const ERROR_INVALID_ADDRESS: u32 = 487; +pub const ERROR_VRF_CFG_ENABLED: u32 = 1183; +pub const ERROR_PARTITION_TERMINATING: u32 = 1184; +pub const ERROR_USER_PROFILE_LOAD: u32 = 500; +pub const ERROR_ARITHMETIC_OVERFLOW: u32 = 534; +pub const ERROR_PIPE_CONNECTED: u32 = 535; +pub const ERROR_PIPE_LISTENING: u32 = 536; +pub const ERROR_VERIFIER_STOP: u32 = 537; +pub const ERROR_ABIOS_ERROR: u32 = 538; +pub const ERROR_WX86_WARNING: u32 = 539; +pub const ERROR_WX86_ERROR: u32 = 540; +pub const ERROR_TIMER_NOT_CANCELED: u32 = 541; +pub const ERROR_UNWIND: u32 = 542; +pub const ERROR_BAD_STACK: u32 = 543; +pub const ERROR_INVALID_UNWIND_TARGET: u32 = 544; +pub const ERROR_INVALID_PORT_ATTRIBUTES: u32 = 545; +pub const ERROR_PORT_MESSAGE_TOO_LONG: u32 = 546; +pub const ERROR_INVALID_QUOTA_LOWER: u32 = 547; +pub const ERROR_DEVICE_ALREADY_ATTACHED: u32 = 548; +pub const ERROR_INSTRUCTION_MISALIGNMENT: u32 = 549; +pub const ERROR_PROFILING_NOT_STARTED: u32 = 550; +pub const ERROR_PROFILING_NOT_STOPPED: u32 = 551; +pub const ERROR_COULD_NOT_INTERPRET: u32 = 552; +pub const ERROR_PROFILING_AT_LIMIT: u32 = 553; +pub const ERROR_CANT_WAIT: u32 = 554; +pub const ERROR_CANT_TERMINATE_SELF: u32 = 555; +pub const ERROR_UNEXPECTED_MM_CREATE_ERR: u32 = 556; +pub const ERROR_UNEXPECTED_MM_MAP_ERROR: u32 = 557; +pub const ERROR_UNEXPECTED_MM_EXTEND_ERR: u32 = 558; +pub const ERROR_BAD_FUNCTION_TABLE: u32 = 559; +pub const ERROR_NO_GUID_TRANSLATION: u32 = 560; +pub const ERROR_INVALID_LDT_SIZE: u32 = 561; +pub const ERROR_INVALID_LDT_OFFSET: u32 = 563; +pub const ERROR_INVALID_LDT_DESCRIPTOR: u32 = 564; +pub const ERROR_TOO_MANY_THREADS: u32 = 565; +pub const ERROR_THREAD_NOT_IN_PROCESS: u32 = 566; +pub const ERROR_PAGEFILE_QUOTA_EXCEEDED: u32 = 567; +pub const ERROR_LOGON_SERVER_CONFLICT: u32 = 568; +pub const ERROR_SYNCHRONIZATION_REQUIRED: u32 = 569; +pub const ERROR_NET_OPEN_FAILED: u32 = 570; +pub const ERROR_IO_PRIVILEGE_FAILED: u32 = 571; +pub const ERROR_CONTROL_C_EXIT: u32 = 572; +pub const ERROR_MISSING_SYSTEMFILE: u32 = 573; +pub const ERROR_UNHANDLED_EXCEPTION: u32 = 574; +pub const ERROR_APP_INIT_FAILURE: u32 = 575; +pub const ERROR_PAGEFILE_CREATE_FAILED: u32 = 576; +pub const ERROR_INVALID_IMAGE_HASH: u32 = 577; +pub const ERROR_NO_PAGEFILE: u32 = 578; +pub const ERROR_ILLEGAL_FLOAT_CONTEXT: u32 = 579; +pub const ERROR_NO_EVENT_PAIR: u32 = 580; +pub const ERROR_DOMAIN_CTRLR_CONFIG_ERROR: u32 = 581; +pub const ERROR_ILLEGAL_CHARACTER: u32 = 582; +pub const ERROR_UNDEFINED_CHARACTER: u32 = 583; +pub const ERROR_FLOPPY_VOLUME: u32 = 584; +pub const ERROR_BIOS_FAILED_TO_CONNECT_INTERRUPT: u32 = 585; +pub const ERROR_BACKUP_CONTROLLER: u32 = 586; +pub const ERROR_MUTANT_LIMIT_EXCEEDED: u32 = 587; +pub const ERROR_FS_DRIVER_REQUIRED: u32 = 588; +pub const ERROR_CANNOT_LOAD_REGISTRY_FILE: u32 = 589; +pub const ERROR_DEBUG_ATTACH_FAILED: u32 = 590; +pub const ERROR_SYSTEM_PROCESS_TERMINATED: u32 = 591; +pub const ERROR_DATA_NOT_ACCEPTED: u32 = 592; +pub const ERROR_VDM_HARD_ERROR: u32 = 593; +pub const ERROR_DRIVER_CANCEL_TIMEOUT: u32 = 594; +pub const ERROR_REPLY_MESSAGE_MISMATCH: u32 = 595; +pub const ERROR_LOST_WRITEBEHIND_DATA: u32 = 596; +pub const ERROR_CLIENT_SERVER_PARAMETERS_INVALID: u32 = 597; +pub const ERROR_NOT_TINY_STREAM: u32 = 598; +pub const ERROR_STACK_OVERFLOW_READ: u32 = 599; +pub const ERROR_CONVERT_TO_LARGE: u32 = 600; +pub const ERROR_FOUND_OUT_OF_SCOPE: u32 = 601; +pub const ERROR_ALLOCATE_BUCKET: u32 = 602; +pub const ERROR_MARSHALL_OVERFLOW: u32 = 603; +pub const ERROR_INVALID_VARIANT: u32 = 604; +pub const ERROR_BAD_COMPRESSION_BUFFER: u32 = 605; +pub const ERROR_AUDIT_FAILED: u32 = 606; +pub const ERROR_TIMER_RESOLUTION_NOT_SET: u32 = 607; +pub const ERROR_INSUFFICIENT_LOGON_INFO: u32 = 608; +pub const ERROR_BAD_DLL_ENTRYPOINT: u32 = 609; +pub const ERROR_BAD_SERVICE_ENTRYPOINT: u32 = 610; +pub const ERROR_IP_ADDRESS_CONFLICT1: u32 = 611; +pub const ERROR_IP_ADDRESS_CONFLICT2: u32 = 612; +pub const ERROR_REGISTRY_QUOTA_LIMIT: u32 = 613; +pub const ERROR_NO_CALLBACK_ACTIVE: u32 = 614; +pub const ERROR_PWD_TOO_SHORT: u32 = 615; +pub const ERROR_PWD_TOO_RECENT: u32 = 616; +pub const ERROR_PWD_HISTORY_CONFLICT: u32 = 617; +pub const ERROR_UNSUPPORTED_COMPRESSION: u32 = 618; +pub const ERROR_INVALID_HW_PROFILE: u32 = 619; +pub const ERROR_INVALID_PLUGPLAY_DEVICE_PATH: u32 = 620; +pub const ERROR_QUOTA_LIST_INCONSISTENT: u32 = 621; +pub const ERROR_EVALUATION_EXPIRATION: u32 = 622; +pub const ERROR_ILLEGAL_DLL_RELOCATION: u32 = 623; +pub const ERROR_DLL_INIT_FAILED_LOGOFF: u32 = 624; +pub const ERROR_VALIDATE_CONTINUE: u32 = 625; +pub const ERROR_NO_MORE_MATCHES: u32 = 626; +pub const ERROR_RANGE_LIST_CONFLICT: u32 = 627; +pub const ERROR_SERVER_SID_MISMATCH: u32 = 628; +pub const ERROR_CANT_ENABLE_DENY_ONLY: u32 = 629; +pub const ERROR_FLOAT_MULTIPLE_FAULTS: u32 = 630; +pub const ERROR_FLOAT_MULTIPLE_TRAPS: u32 = 631; +pub const ERROR_NOINTERFACE: u32 = 632; +pub const ERROR_DRIVER_FAILED_SLEEP: u32 = 633; +pub const ERROR_CORRUPT_SYSTEM_FILE: u32 = 634; +pub const ERROR_COMMITMENT_MINIMUM: u32 = 635; +pub const ERROR_PNP_RESTART_ENUMERATION: u32 = 636; +pub const ERROR_SYSTEM_IMAGE_BAD_SIGNATURE: u32 = 637; +pub const ERROR_PNP_REBOOT_REQUIRED: u32 = 638; +pub const ERROR_INSUFFICIENT_POWER: u32 = 639; +pub const ERROR_MULTIPLE_FAULT_VIOLATION: u32 = 640; +pub const ERROR_SYSTEM_SHUTDOWN: u32 = 641; +pub const ERROR_PORT_NOT_SET: u32 = 642; +pub const ERROR_DS_VERSION_CHECK_FAILURE: u32 = 643; +pub const ERROR_RANGE_NOT_FOUND: u32 = 644; +pub const ERROR_NOT_SAFE_MODE_DRIVER: u32 = 646; +pub const ERROR_FAILED_DRIVER_ENTRY: u32 = 647; +pub const ERROR_DEVICE_ENUMERATION_ERROR: u32 = 648; +pub const ERROR_MOUNT_POINT_NOT_RESOLVED: u32 = 649; +pub const ERROR_INVALID_DEVICE_OBJECT_PARAMETER: u32 = 650; +pub const ERROR_MCA_OCCURED: u32 = 651; +pub const ERROR_DRIVER_DATABASE_ERROR: u32 = 652; +pub const ERROR_SYSTEM_HIVE_TOO_LARGE: u32 = 653; +pub const ERROR_DRIVER_FAILED_PRIOR_UNLOAD: u32 = 654; +pub const ERROR_VOLSNAP_PREPARE_HIBERNATE: u32 = 655; +pub const ERROR_HIBERNATION_FAILURE: u32 = 656; +pub const ERROR_PWD_TOO_LONG: u32 = 657; +pub const ERROR_FILE_SYSTEM_LIMITATION: u32 = 665; +pub const ERROR_ASSERTION_FAILURE: u32 = 668; +pub const ERROR_ACPI_ERROR: u32 = 669; +pub const ERROR_WOW_ASSERTION: u32 = 670; +pub const ERROR_PNP_BAD_MPS_TABLE: u32 = 671; +pub const ERROR_PNP_TRANSLATION_FAILED: u32 = 672; +pub const ERROR_PNP_IRQ_TRANSLATION_FAILED: u32 = 673; +pub const ERROR_PNP_INVALID_ID: u32 = 674; +pub const ERROR_WAKE_SYSTEM_DEBUGGER: u32 = 675; +pub const ERROR_HANDLES_CLOSED: u32 = 676; +pub const ERROR_EXTRANEOUS_INFORMATION: u32 = 677; +pub const ERROR_RXACT_COMMIT_NECESSARY: u32 = 678; +pub const ERROR_MEDIA_CHECK: u32 = 679; +pub const ERROR_GUID_SUBSTITUTION_MADE: u32 = 680; +pub const ERROR_STOPPED_ON_SYMLINK: u32 = 681; +pub const ERROR_LONGJUMP: u32 = 682; +pub const ERROR_PLUGPLAY_QUERY_VETOED: u32 = 683; +pub const ERROR_UNWIND_CONSOLIDATE: u32 = 684; +pub const ERROR_REGISTRY_HIVE_RECOVERED: u32 = 685; +pub const ERROR_DLL_MIGHT_BE_INSECURE: u32 = 686; +pub const ERROR_DLL_MIGHT_BE_INCOMPATIBLE: u32 = 687; +pub const ERROR_DBG_EXCEPTION_NOT_HANDLED: u32 = 688; +pub const ERROR_DBG_REPLY_LATER: u32 = 689; +pub const ERROR_DBG_UNABLE_TO_PROVIDE_HANDLE: u32 = 690; +pub const ERROR_DBG_TERMINATE_THREAD: u32 = 691; +pub const ERROR_DBG_TERMINATE_PROCESS: u32 = 692; +pub const ERROR_DBG_CONTROL_C: u32 = 693; +pub const ERROR_DBG_PRINTEXCEPTION_C: u32 = 694; +pub const ERROR_DBG_RIPEXCEPTION: u32 = 695; +pub const ERROR_DBG_CONTROL_BREAK: u32 = 696; +pub const ERROR_DBG_COMMAND_EXCEPTION: u32 = 697; +pub const ERROR_OBJECT_NAME_EXISTS: u32 = 698; +pub const ERROR_THREAD_WAS_SUSPENDED: u32 = 699; +pub const ERROR_IMAGE_NOT_AT_BASE: u32 = 700; +pub const ERROR_RXACT_STATE_CREATED: u32 = 701; +pub const ERROR_SEGMENT_NOTIFICATION: u32 = 702; +pub const ERROR_BAD_CURRENT_DIRECTORY: u32 = 703; +pub const ERROR_FT_READ_RECOVERY_FROM_BACKUP: u32 = 704; +pub const ERROR_FT_WRITE_RECOVERY: u32 = 705; +pub const ERROR_IMAGE_MACHINE_TYPE_MISMATCH: u32 = 706; +pub const ERROR_RECEIVE_PARTIAL: u32 = 707; +pub const ERROR_RECEIVE_EXPEDITED: u32 = 708; +pub const ERROR_RECEIVE_PARTIAL_EXPEDITED: u32 = 709; +pub const ERROR_EVENT_DONE: u32 = 710; +pub const ERROR_EVENT_PENDING: u32 = 711; +pub const ERROR_CHECKING_FILE_SYSTEM: u32 = 712; +pub const ERROR_FATAL_APP_EXIT: u32 = 713; +pub const ERROR_PREDEFINED_HANDLE: u32 = 714; +pub const ERROR_WAS_UNLOCKED: u32 = 715; +pub const ERROR_SERVICE_NOTIFICATION: u32 = 716; +pub const ERROR_WAS_LOCKED: u32 = 717; +pub const ERROR_LOG_HARD_ERROR: u32 = 718; +pub const ERROR_ALREADY_WIN32: u32 = 719; +pub const ERROR_IMAGE_MACHINE_TYPE_MISMATCH_EXE: u32 = 720; +pub const ERROR_NO_YIELD_PERFORMED: u32 = 721; +pub const ERROR_TIMER_RESUME_IGNORED: u32 = 722; +pub const ERROR_ARBITRATION_UNHANDLED: u32 = 723; +pub const ERROR_CARDBUS_NOT_SUPPORTED: u32 = 724; +pub const ERROR_MP_PROCESSOR_MISMATCH: u32 = 725; +pub const ERROR_HIBERNATED: u32 = 726; +pub const ERROR_RESUME_HIBERNATION: u32 = 727; +pub const ERROR_FIRMWARE_UPDATED: u32 = 728; +pub const ERROR_DRIVERS_LEAKING_LOCKED_PAGES: u32 = 729; +pub const ERROR_WAKE_SYSTEM: u32 = 730; +pub const ERROR_WAIT_1: u32 = 731; +pub const ERROR_WAIT_2: u32 = 732; +pub const ERROR_WAIT_3: u32 = 733; +pub const ERROR_WAIT_63: u32 = 734; +pub const ERROR_ABANDONED_WAIT_0: u32 = 735; +pub const ERROR_ABANDONED_WAIT_63: u32 = 736; +pub const ERROR_USER_APC: u32 = 737; +pub const ERROR_KERNEL_APC: u32 = 738; +pub const ERROR_ALERTED: u32 = 739; +pub const ERROR_ELEVATION_REQUIRED: u32 = 740; +pub const ERROR_REPARSE: u32 = 741; +pub const ERROR_OPLOCK_BREAK_IN_PROGRESS: u32 = 742; +pub const ERROR_VOLUME_MOUNTED: u32 = 743; +pub const ERROR_RXACT_COMMITTED: u32 = 744; +pub const ERROR_NOTIFY_CLEANUP: u32 = 745; +pub const ERROR_PRIMARY_TRANSPORT_CONNECT_FAILED: u32 = 746; +pub const ERROR_PAGE_FAULT_TRANSITION: u32 = 747; +pub const ERROR_PAGE_FAULT_DEMAND_ZERO: u32 = 748; +pub const ERROR_PAGE_FAULT_COPY_ON_WRITE: u32 = 749; +pub const ERROR_PAGE_FAULT_GUARD_PAGE: u32 = 750; +pub const ERROR_PAGE_FAULT_PAGING_FILE: u32 = 751; +pub const ERROR_CACHE_PAGE_LOCKED: u32 = 752; +pub const ERROR_CRASH_DUMP: u32 = 753; +pub const ERROR_BUFFER_ALL_ZEROS: u32 = 754; +pub const ERROR_REPARSE_OBJECT: u32 = 755; +pub const ERROR_RESOURCE_REQUIREMENTS_CHANGED: u32 = 756; +pub const ERROR_TRANSLATION_COMPLETE: u32 = 757; +pub const ERROR_NOTHING_TO_TERMINATE: u32 = 758; +pub const ERROR_PROCESS_NOT_IN_JOB: u32 = 759; +pub const ERROR_PROCESS_IN_JOB: u32 = 760; +pub const ERROR_VOLSNAP_HIBERNATE_READY: u32 = 761; +pub const ERROR_FSFILTER_OP_COMPLETED_SUCCESSFULLY: u32 = 762; +pub const ERROR_INTERRUPT_VECTOR_ALREADY_CONNECTED: u32 = 763; +pub const ERROR_INTERRUPT_STILL_CONNECTED: u32 = 764; +pub const ERROR_WAIT_FOR_OPLOCK: u32 = 765; +pub const ERROR_DBG_EXCEPTION_HANDLED: u32 = 766; +pub const ERROR_DBG_CONTINUE: u32 = 767; +pub const ERROR_CALLBACK_POP_STACK: u32 = 768; +pub const ERROR_COMPRESSION_DISABLED: u32 = 769; +pub const ERROR_CANTFETCHBACKWARDS: u32 = 770; +pub const ERROR_CANTSCROLLBACKWARDS: u32 = 771; +pub const ERROR_ROWSNOTRELEASED: u32 = 772; +pub const ERROR_BAD_ACCESSOR_FLAGS: u32 = 773; +pub const ERROR_ERRORS_ENCOUNTERED: u32 = 774; +pub const ERROR_NOT_CAPABLE: u32 = 775; +pub const ERROR_REQUEST_OUT_OF_SEQUENCE: u32 = 776; +pub const ERROR_VERSION_PARSE_ERROR: u32 = 777; +pub const ERROR_BADSTARTPOSITION: u32 = 778; +pub const ERROR_MEMORY_HARDWARE: u32 = 779; +pub const ERROR_DISK_REPAIR_DISABLED: u32 = 780; +pub const ERROR_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE: u32 = 781; +pub const ERROR_SYSTEM_POWERSTATE_TRANSITION: u32 = 782; +pub const ERROR_SYSTEM_POWERSTATE_COMPLEX_TRANSITION: u32 = 783; +pub const ERROR_MCA_EXCEPTION: u32 = 784; +pub const ERROR_ACCESS_AUDIT_BY_POLICY: u32 = 785; +pub const ERROR_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY: u32 = 786; +pub const ERROR_ABANDON_HIBERFILE: u32 = 787; +pub const ERROR_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED: u32 = 788; +pub const ERROR_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR: u32 = 789; +pub const ERROR_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR: u32 = 790; +pub const ERROR_BAD_MCFG_TABLE: u32 = 791; +pub const ERROR_DISK_REPAIR_REDIRECTED: u32 = 792; +pub const ERROR_DISK_REPAIR_UNSUCCESSFUL: u32 = 793; +pub const ERROR_CORRUPT_LOG_OVERFULL: u32 = 794; +pub const ERROR_CORRUPT_LOG_CORRUPTED: u32 = 795; +pub const ERROR_CORRUPT_LOG_UNAVAILABLE: u32 = 796; +pub const ERROR_CORRUPT_LOG_DELETED_FULL: u32 = 797; +pub const ERROR_CORRUPT_LOG_CLEARED: u32 = 798; +pub const ERROR_ORPHAN_NAME_EXHAUSTED: u32 = 799; +pub const ERROR_OPLOCK_SWITCHED_TO_NEW_HANDLE: u32 = 800; +pub const ERROR_CANNOT_GRANT_REQUESTED_OPLOCK: u32 = 801; +pub const ERROR_CANNOT_BREAK_OPLOCK: u32 = 802; +pub const ERROR_OPLOCK_HANDLE_CLOSED: u32 = 803; +pub const ERROR_NO_ACE_CONDITION: u32 = 804; +pub const ERROR_INVALID_ACE_CONDITION: u32 = 805; +pub const ERROR_FILE_HANDLE_REVOKED: u32 = 806; +pub const ERROR_IMAGE_AT_DIFFERENT_BASE: u32 = 807; +pub const ERROR_ENCRYPTED_IO_NOT_POSSIBLE: u32 = 808; +pub const ERROR_FILE_METADATA_OPTIMIZATION_IN_PROGRESS: u32 = 809; +pub const ERROR_QUOTA_ACTIVITY: u32 = 810; +pub const ERROR_HANDLE_REVOKED: u32 = 811; +pub const ERROR_CALLBACK_INVOKE_INLINE: u32 = 812; +pub const ERROR_CPU_SET_INVALID: u32 = 813; +pub const ERROR_ENCLAVE_NOT_TERMINATED: u32 = 814; +pub const ERROR_ENCLAVE_VIOLATION: u32 = 815; +pub const ERROR_EA_ACCESS_DENIED: u32 = 994; +pub const ERROR_OPERATION_ABORTED: u32 = 995; +pub const ERROR_IO_INCOMPLETE: u32 = 996; +pub const ERROR_IO_PENDING: u32 = 997; +pub const ERROR_NOACCESS: u32 = 998; +pub const ERROR_SWAPERROR: u32 = 999; +pub const ERROR_STACK_OVERFLOW: u32 = 1001; +pub const ERROR_INVALID_MESSAGE: u32 = 1002; +pub const ERROR_CAN_NOT_COMPLETE: u32 = 1003; +pub const ERROR_INVALID_FLAGS: u32 = 1004; +pub const ERROR_UNRECOGNIZED_VOLUME: u32 = 1005; +pub const ERROR_FILE_INVALID: u32 = 1006; +pub const ERROR_FULLSCREEN_MODE: u32 = 1007; +pub const ERROR_NO_TOKEN: u32 = 1008; +pub const ERROR_BADDB: u32 = 1009; +pub const ERROR_BADKEY: u32 = 1010; +pub const ERROR_CANTOPEN: u32 = 1011; +pub const ERROR_CANTREAD: u32 = 1012; +pub const ERROR_CANTWRITE: u32 = 1013; +pub const ERROR_REGISTRY_RECOVERED: u32 = 1014; +pub const ERROR_REGISTRY_CORRUPT: u32 = 1015; +pub const ERROR_REGISTRY_IO_FAILED: u32 = 1016; +pub const ERROR_NOT_REGISTRY_FILE: u32 = 1017; +pub const ERROR_KEY_DELETED: u32 = 1018; +pub const ERROR_NO_LOG_SPACE: u32 = 1019; +pub const ERROR_KEY_HAS_CHILDREN: u32 = 1020; +pub const ERROR_CHILD_MUST_BE_VOLATILE: u32 = 1021; +pub const ERROR_NOTIFY_ENUM_DIR: u32 = 1022; +pub const ERROR_DEPENDENT_SERVICES_RUNNING: u32 = 1051; +pub const ERROR_INVALID_SERVICE_CONTROL: u32 = 1052; +pub const ERROR_SERVICE_REQUEST_TIMEOUT: u32 = 1053; +pub const ERROR_SERVICE_NO_THREAD: u32 = 1054; +pub const ERROR_SERVICE_DATABASE_LOCKED: u32 = 1055; +pub const ERROR_SERVICE_ALREADY_RUNNING: u32 = 1056; +pub const ERROR_INVALID_SERVICE_ACCOUNT: u32 = 1057; +pub const ERROR_SERVICE_DISABLED: u32 = 1058; +pub const ERROR_CIRCULAR_DEPENDENCY: u32 = 1059; +pub const ERROR_SERVICE_DOES_NOT_EXIST: u32 = 1060; +pub const ERROR_SERVICE_CANNOT_ACCEPT_CTRL: u32 = 1061; +pub const ERROR_SERVICE_NOT_ACTIVE: u32 = 1062; +pub const ERROR_FAILED_SERVICE_CONTROLLER_CONNECT: u32 = 1063; +pub const ERROR_EXCEPTION_IN_SERVICE: u32 = 1064; +pub const ERROR_DATABASE_DOES_NOT_EXIST: u32 = 1065; +pub const ERROR_SERVICE_SPECIFIC_ERROR: u32 = 1066; +pub const ERROR_PROCESS_ABORTED: u32 = 1067; +pub const ERROR_SERVICE_DEPENDENCY_FAIL: u32 = 1068; +pub const ERROR_SERVICE_LOGON_FAILED: u32 = 1069; +pub const ERROR_SERVICE_START_HANG: u32 = 1070; +pub const ERROR_INVALID_SERVICE_LOCK: u32 = 1071; +pub const ERROR_SERVICE_MARKED_FOR_DELETE: u32 = 1072; +pub const ERROR_SERVICE_EXISTS: u32 = 1073; +pub const ERROR_ALREADY_RUNNING_LKG: u32 = 1074; +pub const ERROR_SERVICE_DEPENDENCY_DELETED: u32 = 1075; +pub const ERROR_BOOT_ALREADY_ACCEPTED: u32 = 1076; +pub const ERROR_SERVICE_NEVER_STARTED: u32 = 1077; +pub const ERROR_DUPLICATE_SERVICE_NAME: u32 = 1078; +pub const ERROR_DIFFERENT_SERVICE_ACCOUNT: u32 = 1079; +pub const ERROR_CANNOT_DETECT_DRIVER_FAILURE: u32 = 1080; +pub const ERROR_CANNOT_DETECT_PROCESS_ABORT: u32 = 1081; +pub const ERROR_NO_RECOVERY_PROGRAM: u32 = 1082; +pub const ERROR_SERVICE_NOT_IN_EXE: u32 = 1083; +pub const ERROR_NOT_SAFEBOOT_SERVICE: u32 = 1084; +pub const ERROR_END_OF_MEDIA: u32 = 1100; +pub const ERROR_FILEMARK_DETECTED: u32 = 1101; +pub const ERROR_BEGINNING_OF_MEDIA: u32 = 1102; +pub const ERROR_SETMARK_DETECTED: u32 = 1103; +pub const ERROR_NO_DATA_DETECTED: u32 = 1104; +pub const ERROR_PARTITION_FAILURE: u32 = 1105; +pub const ERROR_INVALID_BLOCK_LENGTH: u32 = 1106; +pub const ERROR_DEVICE_NOT_PARTITIONED: u32 = 1107; +pub const ERROR_UNABLE_TO_LOCK_MEDIA: u32 = 1108; +pub const ERROR_UNABLE_TO_UNLOAD_MEDIA: u32 = 1109; +pub const ERROR_MEDIA_CHANGED: u32 = 1110; +pub const ERROR_BUS_RESET: u32 = 1111; +pub const ERROR_NO_MEDIA_IN_DRIVE: u32 = 1112; +pub const ERROR_NO_UNICODE_TRANSLATION: u32 = 1113; +pub const ERROR_DLL_INIT_FAILED: u32 = 1114; +pub const ERROR_SHUTDOWN_IN_PROGRESS: u32 = 1115; +pub const ERROR_NO_SHUTDOWN_IN_PROGRESS: u32 = 1116; +pub const ERROR_IO_DEVICE: u32 = 1117; +pub const ERROR_SERIAL_NO_DEVICE: u32 = 1118; +pub const ERROR_IRQ_BUSY: u32 = 1119; +pub const ERROR_MORE_WRITES: u32 = 1120; +pub const ERROR_COUNTER_TIMEOUT: u32 = 1121; +pub const ERROR_FLOPPY_ID_MARK_NOT_FOUND: u32 = 1122; +pub const ERROR_FLOPPY_WRONG_CYLINDER: u32 = 1123; +pub const ERROR_FLOPPY_UNKNOWN_ERROR: u32 = 1124; +pub const ERROR_FLOPPY_BAD_REGISTERS: u32 = 1125; +pub const ERROR_DISK_RECALIBRATE_FAILED: u32 = 1126; +pub const ERROR_DISK_OPERATION_FAILED: u32 = 1127; +pub const ERROR_DISK_RESET_FAILED: u32 = 1128; +pub const ERROR_EOM_OVERFLOW: u32 = 1129; +pub const ERROR_NOT_ENOUGH_SERVER_MEMORY: u32 = 1130; +pub const ERROR_POSSIBLE_DEADLOCK: u32 = 1131; +pub const ERROR_MAPPED_ALIGNMENT: u32 = 1132; +pub const ERROR_SET_POWER_STATE_VETOED: u32 = 1140; +pub const ERROR_SET_POWER_STATE_FAILED: u32 = 1141; +pub const ERROR_TOO_MANY_LINKS: u32 = 1142; +pub const ERROR_OLD_WIN_VERSION: u32 = 1150; +pub const ERROR_APP_WRONG_OS: u32 = 1151; +pub const ERROR_SINGLE_INSTANCE_APP: u32 = 1152; +pub const ERROR_RMODE_APP: u32 = 1153; +pub const ERROR_INVALID_DLL: u32 = 1154; +pub const ERROR_NO_ASSOCIATION: u32 = 1155; +pub const ERROR_DDE_FAIL: u32 = 1156; +pub const ERROR_DLL_NOT_FOUND: u32 = 1157; +pub const ERROR_NO_MORE_USER_HANDLES: u32 = 1158; +pub const ERROR_MESSAGE_SYNC_ONLY: u32 = 1159; +pub const ERROR_SOURCE_ELEMENT_EMPTY: u32 = 1160; +pub const ERROR_DESTINATION_ELEMENT_FULL: u32 = 1161; +pub const ERROR_ILLEGAL_ELEMENT_ADDRESS: u32 = 1162; +pub const ERROR_MAGAZINE_NOT_PRESENT: u32 = 1163; +pub const ERROR_DEVICE_REINITIALIZATION_NEEDED: u32 = 1164; +pub const ERROR_DEVICE_REQUIRES_CLEANING: u32 = 1165; +pub const ERROR_DEVICE_DOOR_OPEN: u32 = 1166; +pub const ERROR_DEVICE_NOT_CONNECTED: u32 = 1167; +pub const ERROR_NOT_FOUND: u32 = 1168; +pub const ERROR_NO_MATCH: u32 = 1169; +pub const ERROR_SET_NOT_FOUND: u32 = 1170; +pub const ERROR_POINT_NOT_FOUND: u32 = 1171; +pub const ERROR_NO_TRACKING_SERVICE: u32 = 1172; +pub const ERROR_NO_VOLUME_ID: u32 = 1173; +pub const ERROR_UNABLE_TO_REMOVE_REPLACED: u32 = 1175; +pub const ERROR_UNABLE_TO_MOVE_REPLACEMENT: u32 = 1176; +pub const ERROR_UNABLE_TO_MOVE_REPLACEMENT_2: u32 = 1177; +pub const ERROR_JOURNAL_DELETE_IN_PROGRESS: u32 = 1178; +pub const ERROR_JOURNAL_NOT_ACTIVE: u32 = 1179; +pub const ERROR_POTENTIAL_FILE_FOUND: u32 = 1180; +pub const ERROR_JOURNAL_ENTRY_DELETED: u32 = 1181; +pub const ERROR_SHUTDOWN_IS_SCHEDULED: u32 = 1190; +pub const ERROR_SHUTDOWN_USERS_LOGGED_ON: u32 = 1191; +pub const ERROR_BAD_DEVICE: u32 = 1200; +pub const ERROR_CONNECTION_UNAVAIL: u32 = 1201; +pub const ERROR_DEVICE_ALREADY_REMEMBERED: u32 = 1202; +pub const ERROR_NO_NET_OR_BAD_PATH: u32 = 1203; +pub const ERROR_BAD_PROVIDER: u32 = 1204; +pub const ERROR_CANNOT_OPEN_PROFILE: u32 = 1205; +pub const ERROR_BAD_PROFILE: u32 = 1206; +pub const ERROR_NOT_CONTAINER: u32 = 1207; +pub const ERROR_EXTENDED_ERROR: u32 = 1208; +pub const ERROR_INVALID_GROUPNAME: u32 = 1209; +pub const ERROR_INVALID_COMPUTERNAME: u32 = 1210; +pub const ERROR_INVALID_EVENTNAME: u32 = 1211; +pub const ERROR_INVALID_DOMAINNAME: u32 = 1212; +pub const ERROR_INVALID_SERVICENAME: u32 = 1213; +pub const ERROR_INVALID_NETNAME: u32 = 1214; +pub const ERROR_INVALID_SHARENAME: u32 = 1215; +pub const ERROR_INVALID_PASSWORDNAME: u32 = 1216; +pub const ERROR_INVALID_MESSAGENAME: u32 = 1217; +pub const ERROR_INVALID_MESSAGEDEST: u32 = 1218; +pub const ERROR_SESSION_CREDENTIAL_CONFLICT: u32 = 1219; +pub const ERROR_REMOTE_SESSION_LIMIT_EXCEEDED: u32 = 1220; +pub const ERROR_DUP_DOMAINNAME: u32 = 1221; +pub const ERROR_NO_NETWORK: u32 = 1222; +pub const ERROR_CANCELLED: u32 = 1223; +pub const ERROR_USER_MAPPED_FILE: u32 = 1224; +pub const ERROR_CONNECTION_REFUSED: u32 = 1225; +pub const ERROR_GRACEFUL_DISCONNECT: u32 = 1226; +pub const ERROR_ADDRESS_ALREADY_ASSOCIATED: u32 = 1227; +pub const ERROR_ADDRESS_NOT_ASSOCIATED: u32 = 1228; +pub const ERROR_CONNECTION_INVALID: u32 = 1229; +pub const ERROR_CONNECTION_ACTIVE: u32 = 1230; +pub const ERROR_NETWORK_UNREACHABLE: u32 = 1231; +pub const ERROR_HOST_UNREACHABLE: u32 = 1232; +pub const ERROR_PROTOCOL_UNREACHABLE: u32 = 1233; +pub const ERROR_PORT_UNREACHABLE: u32 = 1234; +pub const ERROR_REQUEST_ABORTED: u32 = 1235; +pub const ERROR_CONNECTION_ABORTED: u32 = 1236; +pub const ERROR_RETRY: u32 = 1237; +pub const ERROR_CONNECTION_COUNT_LIMIT: u32 = 1238; +pub const ERROR_LOGIN_TIME_RESTRICTION: u32 = 1239; +pub const ERROR_LOGIN_WKSTA_RESTRICTION: u32 = 1240; +pub const ERROR_INCORRECT_ADDRESS: u32 = 1241; +pub const ERROR_ALREADY_REGISTERED: u32 = 1242; +pub const ERROR_SERVICE_NOT_FOUND: u32 = 1243; +pub const ERROR_NOT_AUTHENTICATED: u32 = 1244; +pub const ERROR_NOT_LOGGED_ON: u32 = 1245; +pub const ERROR_CONTINUE: u32 = 1246; +pub const ERROR_ALREADY_INITIALIZED: u32 = 1247; +pub const ERROR_NO_MORE_DEVICES: u32 = 1248; +pub const ERROR_NO_SUCH_SITE: u32 = 1249; +pub const ERROR_DOMAIN_CONTROLLER_EXISTS: u32 = 1250; +pub const ERROR_ONLY_IF_CONNECTED: u32 = 1251; +pub const ERROR_OVERRIDE_NOCHANGES: u32 = 1252; +pub const ERROR_BAD_USER_PROFILE: u32 = 1253; +pub const ERROR_NOT_SUPPORTED_ON_SBS: u32 = 1254; +pub const ERROR_SERVER_SHUTDOWN_IN_PROGRESS: u32 = 1255; +pub const ERROR_HOST_DOWN: u32 = 1256; +pub const ERROR_NON_ACCOUNT_SID: u32 = 1257; +pub const ERROR_NON_DOMAIN_SID: u32 = 1258; +pub const ERROR_APPHELP_BLOCK: u32 = 1259; +pub const ERROR_ACCESS_DISABLED_BY_POLICY: u32 = 1260; +pub const ERROR_REG_NAT_CONSUMPTION: u32 = 1261; +pub const ERROR_CSCSHARE_OFFLINE: u32 = 1262; +pub const ERROR_PKINIT_FAILURE: u32 = 1263; +pub const ERROR_SMARTCARD_SUBSYSTEM_FAILURE: u32 = 1264; +pub const ERROR_DOWNGRADE_DETECTED: u32 = 1265; +pub const ERROR_MACHINE_LOCKED: u32 = 1271; +pub const ERROR_SMB_GUEST_LOGON_BLOCKED: u32 = 1272; +pub const ERROR_CALLBACK_SUPPLIED_INVALID_DATA: u32 = 1273; +pub const ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED: u32 = 1274; +pub const ERROR_DRIVER_BLOCKED: u32 = 1275; +pub const ERROR_INVALID_IMPORT_OF_NON_DLL: u32 = 1276; +pub const ERROR_ACCESS_DISABLED_WEBBLADE: u32 = 1277; +pub const ERROR_ACCESS_DISABLED_WEBBLADE_TAMPER: u32 = 1278; +pub const ERROR_RECOVERY_FAILURE: u32 = 1279; +pub const ERROR_ALREADY_FIBER: u32 = 1280; +pub const ERROR_ALREADY_THREAD: u32 = 1281; +pub const ERROR_STACK_BUFFER_OVERRUN: u32 = 1282; +pub const ERROR_PARAMETER_QUOTA_EXCEEDED: u32 = 1283; +pub const ERROR_DEBUGGER_INACTIVE: u32 = 1284; +pub const ERROR_DELAY_LOAD_FAILED: u32 = 1285; +pub const ERROR_VDM_DISALLOWED: u32 = 1286; +pub const ERROR_UNIDENTIFIED_ERROR: u32 = 1287; +pub const ERROR_INVALID_CRUNTIME_PARAMETER: u32 = 1288; +pub const ERROR_BEYOND_VDL: u32 = 1289; +pub const ERROR_INCOMPATIBLE_SERVICE_SID_TYPE: u32 = 1290; +pub const ERROR_DRIVER_PROCESS_TERMINATED: u32 = 1291; +pub const ERROR_IMPLEMENTATION_LIMIT: u32 = 1292; +pub const ERROR_PROCESS_IS_PROTECTED: u32 = 1293; +pub const ERROR_SERVICE_NOTIFY_CLIENT_LAGGING: u32 = 1294; +pub const ERROR_DISK_QUOTA_EXCEEDED: u32 = 1295; +pub const ERROR_CONTENT_BLOCKED: u32 = 1296; +pub const ERROR_INCOMPATIBLE_SERVICE_PRIVILEGE: u32 = 1297; +pub const ERROR_APP_HANG: u32 = 1298; +pub const ERROR_INVALID_LABEL: u32 = 1299; +pub const ERROR_NOT_ALL_ASSIGNED: u32 = 1300; +pub const ERROR_SOME_NOT_MAPPED: u32 = 1301; +pub const ERROR_NO_QUOTAS_FOR_ACCOUNT: u32 = 1302; +pub const ERROR_LOCAL_USER_SESSION_KEY: u32 = 1303; +pub const ERROR_NULL_LM_PASSWORD: u32 = 1304; +pub const ERROR_UNKNOWN_REVISION: u32 = 1305; +pub const ERROR_REVISION_MISMATCH: u32 = 1306; +pub const ERROR_INVALID_OWNER: u32 = 1307; +pub const ERROR_INVALID_PRIMARY_GROUP: u32 = 1308; +pub const ERROR_NO_IMPERSONATION_TOKEN: u32 = 1309; +pub const ERROR_CANT_DISABLE_MANDATORY: u32 = 1310; +pub const ERROR_NO_LOGON_SERVERS: u32 = 1311; +pub const ERROR_NO_SUCH_LOGON_SESSION: u32 = 1312; +pub const ERROR_NO_SUCH_PRIVILEGE: u32 = 1313; +pub const ERROR_PRIVILEGE_NOT_HELD: u32 = 1314; +pub const ERROR_INVALID_ACCOUNT_NAME: u32 = 1315; +pub const ERROR_USER_EXISTS: u32 = 1316; +pub const ERROR_NO_SUCH_USER: u32 = 1317; +pub const ERROR_GROUP_EXISTS: u32 = 1318; +pub const ERROR_NO_SUCH_GROUP: u32 = 1319; +pub const ERROR_MEMBER_IN_GROUP: u32 = 1320; +pub const ERROR_MEMBER_NOT_IN_GROUP: u32 = 1321; +pub const ERROR_LAST_ADMIN: u32 = 1322; +pub const ERROR_WRONG_PASSWORD: u32 = 1323; +pub const ERROR_ILL_FORMED_PASSWORD: u32 = 1324; +pub const ERROR_PASSWORD_RESTRICTION: u32 = 1325; +pub const ERROR_LOGON_FAILURE: u32 = 1326; +pub const ERROR_ACCOUNT_RESTRICTION: u32 = 1327; +pub const ERROR_INVALID_LOGON_HOURS: u32 = 1328; +pub const ERROR_INVALID_WORKSTATION: u32 = 1329; +pub const ERROR_PASSWORD_EXPIRED: u32 = 1330; +pub const ERROR_ACCOUNT_DISABLED: u32 = 1331; +pub const ERROR_NONE_MAPPED: u32 = 1332; +pub const ERROR_TOO_MANY_LUIDS_REQUESTED: u32 = 1333; +pub const ERROR_LUIDS_EXHAUSTED: u32 = 1334; +pub const ERROR_INVALID_SUB_AUTHORITY: u32 = 1335; +pub const ERROR_INVALID_ACL: u32 = 1336; +pub const ERROR_INVALID_SID: u32 = 1337; +pub const ERROR_INVALID_SECURITY_DESCR: u32 = 1338; +pub const ERROR_BAD_INHERITANCE_ACL: u32 = 1340; +pub const ERROR_SERVER_DISABLED: u32 = 1341; +pub const ERROR_SERVER_NOT_DISABLED: u32 = 1342; +pub const ERROR_INVALID_ID_AUTHORITY: u32 = 1343; +pub const ERROR_ALLOTTED_SPACE_EXCEEDED: u32 = 1344; +pub const ERROR_INVALID_GROUP_ATTRIBUTES: u32 = 1345; +pub const ERROR_BAD_IMPERSONATION_LEVEL: u32 = 1346; +pub const ERROR_CANT_OPEN_ANONYMOUS: u32 = 1347; +pub const ERROR_BAD_VALIDATION_CLASS: u32 = 1348; +pub const ERROR_BAD_TOKEN_TYPE: u32 = 1349; +pub const ERROR_NO_SECURITY_ON_OBJECT: u32 = 1350; +pub const ERROR_CANT_ACCESS_DOMAIN_INFO: u32 = 1351; +pub const ERROR_INVALID_SERVER_STATE: u32 = 1352; +pub const ERROR_INVALID_DOMAIN_STATE: u32 = 1353; +pub const ERROR_INVALID_DOMAIN_ROLE: u32 = 1354; +pub const ERROR_NO_SUCH_DOMAIN: u32 = 1355; +pub const ERROR_DOMAIN_EXISTS: u32 = 1356; +pub const ERROR_DOMAIN_LIMIT_EXCEEDED: u32 = 1357; +pub const ERROR_INTERNAL_DB_CORRUPTION: u32 = 1358; +pub const ERROR_INTERNAL_ERROR: u32 = 1359; +pub const ERROR_GENERIC_NOT_MAPPED: u32 = 1360; +pub const ERROR_BAD_DESCRIPTOR_FORMAT: u32 = 1361; +pub const ERROR_NOT_LOGON_PROCESS: u32 = 1362; +pub const ERROR_LOGON_SESSION_EXISTS: u32 = 1363; +pub const ERROR_NO_SUCH_PACKAGE: u32 = 1364; +pub const ERROR_BAD_LOGON_SESSION_STATE: u32 = 1365; +pub const ERROR_LOGON_SESSION_COLLISION: u32 = 1366; +pub const ERROR_INVALID_LOGON_TYPE: u32 = 1367; +pub const ERROR_CANNOT_IMPERSONATE: u32 = 1368; +pub const ERROR_RXACT_INVALID_STATE: u32 = 1369; +pub const ERROR_RXACT_COMMIT_FAILURE: u32 = 1370; +pub const ERROR_SPECIAL_ACCOUNT: u32 = 1371; +pub const ERROR_SPECIAL_GROUP: u32 = 1372; +pub const ERROR_SPECIAL_USER: u32 = 1373; +pub const ERROR_MEMBERS_PRIMARY_GROUP: u32 = 1374; +pub const ERROR_TOKEN_ALREADY_IN_USE: u32 = 1375; +pub const ERROR_NO_SUCH_ALIAS: u32 = 1376; +pub const ERROR_MEMBER_NOT_IN_ALIAS: u32 = 1377; +pub const ERROR_MEMBER_IN_ALIAS: u32 = 1378; +pub const ERROR_ALIAS_EXISTS: u32 = 1379; +pub const ERROR_LOGON_NOT_GRANTED: u32 = 1380; +pub const ERROR_TOO_MANY_SECRETS: u32 = 1381; +pub const ERROR_SECRET_TOO_LONG: u32 = 1382; +pub const ERROR_INTERNAL_DB_ERROR: u32 = 1383; +pub const ERROR_TOO_MANY_CONTEXT_IDS: u32 = 1384; +pub const ERROR_LOGON_TYPE_NOT_GRANTED: u32 = 1385; +pub const ERROR_NT_CROSS_ENCRYPTION_REQUIRED: u32 = 1386; +pub const ERROR_NO_SUCH_MEMBER: u32 = 1387; +pub const ERROR_INVALID_MEMBER: u32 = 1388; +pub const ERROR_TOO_MANY_SIDS: u32 = 1389; +pub const ERROR_LM_CROSS_ENCRYPTION_REQUIRED: u32 = 1390; +pub const ERROR_NO_INHERITANCE: u32 = 1391; +pub const ERROR_FILE_CORRUPT: u32 = 1392; +pub const ERROR_DISK_CORRUPT: u32 = 1393; +pub const ERROR_NO_USER_SESSION_KEY: u32 = 1394; +pub const ERROR_LICENSE_QUOTA_EXCEEDED: u32 = 1395; +pub const ERROR_WRONG_TARGET_NAME: u32 = 1396; +pub const ERROR_MUTUAL_AUTH_FAILED: u32 = 1397; +pub const ERROR_TIME_SKEW: u32 = 1398; +pub const ERROR_CURRENT_DOMAIN_NOT_ALLOWED: u32 = 1399; +pub const ERROR_INVALID_WINDOW_HANDLE: u32 = 1400; +pub const ERROR_INVALID_MENU_HANDLE: u32 = 1401; +pub const ERROR_INVALID_CURSOR_HANDLE: u32 = 1402; +pub const ERROR_INVALID_ACCEL_HANDLE: u32 = 1403; +pub const ERROR_INVALID_HOOK_HANDLE: u32 = 1404; +pub const ERROR_INVALID_DWP_HANDLE: u32 = 1405; +pub const ERROR_TLW_WITH_WSCHILD: u32 = 1406; +pub const ERROR_CANNOT_FIND_WND_CLASS: u32 = 1407; +pub const ERROR_WINDOW_OF_OTHER_THREAD: u32 = 1408; +pub const ERROR_HOTKEY_ALREADY_REGISTERED: u32 = 1409; +pub const ERROR_CLASS_ALREADY_EXISTS: u32 = 1410; +pub const ERROR_CLASS_DOES_NOT_EXIST: u32 = 1411; +pub const ERROR_CLASS_HAS_WINDOWS: u32 = 1412; +pub const ERROR_INVALID_INDEX: u32 = 1413; +pub const ERROR_INVALID_ICON_HANDLE: u32 = 1414; +pub const ERROR_PRIVATE_DIALOG_INDEX: u32 = 1415; +pub const ERROR_LISTBOX_ID_NOT_FOUND: u32 = 1416; +pub const ERROR_NO_WILDCARD_CHARACTERS: u32 = 1417; +pub const ERROR_CLIPBOARD_NOT_OPEN: u32 = 1418; +pub const ERROR_HOTKEY_NOT_REGISTERED: u32 = 1419; +pub const ERROR_WINDOW_NOT_DIALOG: u32 = 1420; +pub const ERROR_CONTROL_ID_NOT_FOUND: u32 = 1421; +pub const ERROR_INVALID_COMBOBOX_MESSAGE: u32 = 1422; +pub const ERROR_WINDOW_NOT_COMBOBOX: u32 = 1423; +pub const ERROR_INVALID_EDIT_HEIGHT: u32 = 1424; +pub const ERROR_DC_NOT_FOUND: u32 = 1425; +pub const ERROR_INVALID_HOOK_FILTER: u32 = 1426; +pub const ERROR_INVALID_FILTER_PROC: u32 = 1427; +pub const ERROR_HOOK_NEEDS_HMOD: u32 = 1428; +pub const ERROR_GLOBAL_ONLY_HOOK: u32 = 1429; +pub const ERROR_JOURNAL_HOOK_SET: u32 = 1430; +pub const ERROR_HOOK_NOT_INSTALLED: u32 = 1431; +pub const ERROR_INVALID_LB_MESSAGE: u32 = 1432; +pub const ERROR_SETCOUNT_ON_BAD_LB: u32 = 1433; +pub const ERROR_LB_WITHOUT_TABSTOPS: u32 = 1434; +pub const ERROR_DESTROY_OBJECT_OF_OTHER_THREAD: u32 = 1435; +pub const ERROR_CHILD_WINDOW_MENU: u32 = 1436; +pub const ERROR_NO_SYSTEM_MENU: u32 = 1437; +pub const ERROR_INVALID_MSGBOX_STYLE: u32 = 1438; +pub const ERROR_INVALID_SPI_VALUE: u32 = 1439; +pub const ERROR_SCREEN_ALREADY_LOCKED: u32 = 1440; +pub const ERROR_HWNDS_HAVE_DIFF_PARENT: u32 = 1441; +pub const ERROR_NOT_CHILD_WINDOW: u32 = 1442; +pub const ERROR_INVALID_GW_COMMAND: u32 = 1443; +pub const ERROR_INVALID_THREAD_ID: u32 = 1444; +pub const ERROR_NON_MDICHILD_WINDOW: u32 = 1445; +pub const ERROR_POPUP_ALREADY_ACTIVE: u32 = 1446; +pub const ERROR_NO_SCROLLBARS: u32 = 1447; +pub const ERROR_INVALID_SCROLLBAR_RANGE: u32 = 1448; +pub const ERROR_INVALID_SHOWWIN_COMMAND: u32 = 1449; +pub const ERROR_NO_SYSTEM_RESOURCES: u32 = 1450; +pub const ERROR_NONPAGED_SYSTEM_RESOURCES: u32 = 1451; +pub const ERROR_PAGED_SYSTEM_RESOURCES: u32 = 1452; +pub const ERROR_WORKING_SET_QUOTA: u32 = 1453; +pub const ERROR_PAGEFILE_QUOTA: u32 = 1454; +pub const ERROR_COMMITMENT_LIMIT: u32 = 1455; +pub const ERROR_MENU_ITEM_NOT_FOUND: u32 = 1456; +pub const ERROR_INVALID_KEYBOARD_HANDLE: u32 = 1457; +pub const ERROR_HOOK_TYPE_NOT_ALLOWED: u32 = 1458; +pub const ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION: u32 = 1459; +pub const ERROR_TIMEOUT: u32 = 1460; +pub const ERROR_INVALID_MONITOR_HANDLE: u32 = 1461; +pub const ERROR_INCORRECT_SIZE: u32 = 1462; +pub const ERROR_SYMLINK_CLASS_DISABLED: u32 = 1463; +pub const ERROR_SYMLINK_NOT_SUPPORTED: u32 = 1464; +pub const ERROR_XML_PARSE_ERROR: u32 = 1465; +pub const ERROR_XMLDSIG_ERROR: u32 = 1466; +pub const ERROR_RESTART_APPLICATION: u32 = 1467; +pub const ERROR_WRONG_COMPARTMENT: u32 = 1468; +pub const ERROR_AUTHIP_FAILURE: u32 = 1469; +pub const ERROR_NO_NVRAM_RESOURCES: u32 = 1470; +pub const ERROR_NOT_GUI_PROCESS: u32 = 1471; +pub const ERROR_EVENTLOG_FILE_CORRUPT: u32 = 1500; +pub const ERROR_EVENTLOG_CANT_START: u32 = 1501; +pub const ERROR_LOG_FILE_FULL: u32 = 1502; +pub const ERROR_EVENTLOG_FILE_CHANGED: u32 = 1503; +pub const ERROR_CONTAINER_ASSIGNED: u32 = 1504; +pub const ERROR_JOB_NO_CONTAINER: u32 = 1505; +pub const ERROR_INVALID_TASK_NAME: u32 = 1550; +pub const ERROR_INVALID_TASK_INDEX: u32 = 1551; +pub const ERROR_THREAD_ALREADY_IN_TASK: u32 = 1552; +pub const ERROR_INSTALL_SERVICE_FAILURE: u32 = 1601; +pub const ERROR_INSTALL_USEREXIT: u32 = 1602; +pub const ERROR_INSTALL_FAILURE: u32 = 1603; +pub const ERROR_INSTALL_SUSPEND: u32 = 1604; +pub const ERROR_UNKNOWN_PRODUCT: u32 = 1605; +pub const ERROR_UNKNOWN_FEATURE: u32 = 1606; +pub const ERROR_UNKNOWN_COMPONENT: u32 = 1607; +pub const ERROR_UNKNOWN_PROPERTY: u32 = 1608; +pub const ERROR_INVALID_HANDLE_STATE: u32 = 1609; +pub const ERROR_BAD_CONFIGURATION: u32 = 1610; +pub const ERROR_INDEX_ABSENT: u32 = 1611; +pub const ERROR_INSTALL_SOURCE_ABSENT: u32 = 1612; +pub const ERROR_INSTALL_PACKAGE_VERSION: u32 = 1613; +pub const ERROR_PRODUCT_UNINSTALLED: u32 = 1614; +pub const ERROR_BAD_QUERY_SYNTAX: u32 = 1615; +pub const ERROR_INVALID_FIELD: u32 = 1616; +pub const ERROR_DEVICE_REMOVED: u32 = 1617; +pub const ERROR_INSTALL_ALREADY_RUNNING: u32 = 1618; +pub const ERROR_INSTALL_PACKAGE_OPEN_FAILED: u32 = 1619; +pub const ERROR_INSTALL_PACKAGE_INVALID: u32 = 1620; +pub const ERROR_INSTALL_UI_FAILURE: u32 = 1621; +pub const ERROR_INSTALL_LOG_FAILURE: u32 = 1622; +pub const ERROR_INSTALL_LANGUAGE_UNSUPPORTED: u32 = 1623; +pub const ERROR_INSTALL_TRANSFORM_FAILURE: u32 = 1624; +pub const ERROR_INSTALL_PACKAGE_REJECTED: u32 = 1625; +pub const ERROR_FUNCTION_NOT_CALLED: u32 = 1626; +pub const ERROR_FUNCTION_FAILED: u32 = 1627; +pub const ERROR_INVALID_TABLE: u32 = 1628; +pub const ERROR_DATATYPE_MISMATCH: u32 = 1629; +pub const ERROR_UNSUPPORTED_TYPE: u32 = 1630; +pub const ERROR_CREATE_FAILED: u32 = 1631; +pub const ERROR_INSTALL_TEMP_UNWRITABLE: u32 = 1632; +pub const ERROR_INSTALL_PLATFORM_UNSUPPORTED: u32 = 1633; +pub const ERROR_INSTALL_NOTUSED: u32 = 1634; +pub const ERROR_PATCH_PACKAGE_OPEN_FAILED: u32 = 1635; +pub const ERROR_PATCH_PACKAGE_INVALID: u32 = 1636; +pub const ERROR_PATCH_PACKAGE_UNSUPPORTED: u32 = 1637; +pub const ERROR_PRODUCT_VERSION: u32 = 1638; +pub const ERROR_INVALID_COMMAND_LINE: u32 = 1639; +pub const ERROR_INSTALL_REMOTE_DISALLOWED: u32 = 1640; +pub const ERROR_SUCCESS_REBOOT_INITIATED: u32 = 1641; +pub const ERROR_PATCH_TARGET_NOT_FOUND: u32 = 1642; +pub const ERROR_PATCH_PACKAGE_REJECTED: u32 = 1643; +pub const ERROR_INSTALL_TRANSFORM_REJECTED: u32 = 1644; +pub const ERROR_INSTALL_REMOTE_PROHIBITED: u32 = 1645; +pub const ERROR_PATCH_REMOVAL_UNSUPPORTED: u32 = 1646; +pub const ERROR_UNKNOWN_PATCH: u32 = 1647; +pub const ERROR_PATCH_NO_SEQUENCE: u32 = 1648; +pub const ERROR_PATCH_REMOVAL_DISALLOWED: u32 = 1649; +pub const ERROR_INVALID_PATCH_XML: u32 = 1650; +pub const ERROR_PATCH_MANAGED_ADVERTISED_PRODUCT: u32 = 1651; +pub const ERROR_INSTALL_SERVICE_SAFEBOOT: u32 = 1652; +pub const ERROR_FAIL_FAST_EXCEPTION: u32 = 1653; +pub const ERROR_INSTALL_REJECTED: u32 = 1654; +pub const ERROR_DYNAMIC_CODE_BLOCKED: u32 = 1655; +pub const ERROR_NOT_SAME_OBJECT: u32 = 1656; +pub const ERROR_STRICT_CFG_VIOLATION: u32 = 1657; +pub const ERROR_SET_CONTEXT_DENIED: u32 = 1660; +pub const ERROR_CROSS_PARTITION_VIOLATION: u32 = 1661; +pub const ERROR_INVALID_USER_BUFFER: u32 = 1784; +pub const ERROR_UNRECOGNIZED_MEDIA: u32 = 1785; +pub const ERROR_NO_TRUST_LSA_SECRET: u32 = 1786; +pub const ERROR_NO_TRUST_SAM_ACCOUNT: u32 = 1787; +pub const ERROR_TRUSTED_DOMAIN_FAILURE: u32 = 1788; +pub const ERROR_TRUSTED_RELATIONSHIP_FAILURE: u32 = 1789; +pub const ERROR_TRUST_FAILURE: u32 = 1790; +pub const ERROR_NETLOGON_NOT_STARTED: u32 = 1792; +pub const ERROR_ACCOUNT_EXPIRED: u32 = 1793; +pub const ERROR_REDIRECTOR_HAS_OPEN_HANDLES: u32 = 1794; +pub const ERROR_PRINTER_DRIVER_ALREADY_INSTALLED: u32 = 1795; +pub const ERROR_UNKNOWN_PORT: u32 = 1796; +pub const ERROR_UNKNOWN_PRINTER_DRIVER: u32 = 1797; +pub const ERROR_UNKNOWN_PRINTPROCESSOR: u32 = 1798; +pub const ERROR_INVALID_SEPARATOR_FILE: u32 = 1799; +pub const ERROR_INVALID_PRIORITY: u32 = 1800; +pub const ERROR_INVALID_PRINTER_NAME: u32 = 1801; +pub const ERROR_PRINTER_ALREADY_EXISTS: u32 = 1802; +pub const ERROR_INVALID_PRINTER_COMMAND: u32 = 1803; +pub const ERROR_INVALID_DATATYPE: u32 = 1804; +pub const ERROR_INVALID_ENVIRONMENT: u32 = 1805; +pub const ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT: u32 = 1807; +pub const ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT: u32 = 1808; +pub const ERROR_NOLOGON_SERVER_TRUST_ACCOUNT: u32 = 1809; +pub const ERROR_DOMAIN_TRUST_INCONSISTENT: u32 = 1810; +pub const ERROR_SERVER_HAS_OPEN_HANDLES: u32 = 1811; +pub const ERROR_RESOURCE_DATA_NOT_FOUND: u32 = 1812; +pub const ERROR_RESOURCE_TYPE_NOT_FOUND: u32 = 1813; +pub const ERROR_RESOURCE_NAME_NOT_FOUND: u32 = 1814; +pub const ERROR_RESOURCE_LANG_NOT_FOUND: u32 = 1815; +pub const ERROR_NOT_ENOUGH_QUOTA: u32 = 1816; +pub const ERROR_INVALID_TIME: u32 = 1901; +pub const ERROR_INVALID_FORM_NAME: u32 = 1902; +pub const ERROR_INVALID_FORM_SIZE: u32 = 1903; +pub const ERROR_ALREADY_WAITING: u32 = 1904; +pub const ERROR_PRINTER_DELETED: u32 = 1905; +pub const ERROR_INVALID_PRINTER_STATE: u32 = 1906; +pub const ERROR_PASSWORD_MUST_CHANGE: u32 = 1907; +pub const ERROR_DOMAIN_CONTROLLER_NOT_FOUND: u32 = 1908; +pub const ERROR_ACCOUNT_LOCKED_OUT: u32 = 1909; +pub const ERROR_NO_SITENAME: u32 = 1919; +pub const ERROR_CANT_ACCESS_FILE: u32 = 1920; +pub const ERROR_CANT_RESOLVE_FILENAME: u32 = 1921; +pub const ERROR_KM_DRIVER_BLOCKED: u32 = 1930; +pub const ERROR_CONTEXT_EXPIRED: u32 = 1931; +pub const ERROR_PER_USER_TRUST_QUOTA_EXCEEDED: u32 = 1932; +pub const ERROR_ALL_USER_TRUST_QUOTA_EXCEEDED: u32 = 1933; +pub const ERROR_USER_DELETE_TRUST_QUOTA_EXCEEDED: u32 = 1934; +pub const ERROR_AUTHENTICATION_FIREWALL_FAILED: u32 = 1935; +pub const ERROR_REMOTE_PRINT_CONNECTIONS_BLOCKED: u32 = 1936; +pub const ERROR_NTLM_BLOCKED: u32 = 1937; +pub const ERROR_PASSWORD_CHANGE_REQUIRED: u32 = 1938; +pub const ERROR_LOST_MODE_LOGON_RESTRICTION: u32 = 1939; +pub const ERROR_INVALID_PIXEL_FORMAT: u32 = 2000; +pub const ERROR_BAD_DRIVER: u32 = 2001; +pub const ERROR_INVALID_WINDOW_STYLE: u32 = 2002; +pub const ERROR_METAFILE_NOT_SUPPORTED: u32 = 2003; +pub const ERROR_TRANSFORM_NOT_SUPPORTED: u32 = 2004; +pub const ERROR_CLIPPING_NOT_SUPPORTED: u32 = 2005; +pub const ERROR_INVALID_CMM: u32 = 2010; +pub const ERROR_INVALID_PROFILE: u32 = 2011; +pub const ERROR_TAG_NOT_FOUND: u32 = 2012; +pub const ERROR_TAG_NOT_PRESENT: u32 = 2013; +pub const ERROR_DUPLICATE_TAG: u32 = 2014; +pub const ERROR_PROFILE_NOT_ASSOCIATED_WITH_DEVICE: u32 = 2015; +pub const ERROR_PROFILE_NOT_FOUND: u32 = 2016; +pub const ERROR_INVALID_COLORSPACE: u32 = 2017; +pub const ERROR_ICM_NOT_ENABLED: u32 = 2018; +pub const ERROR_DELETING_ICM_XFORM: u32 = 2019; +pub const ERROR_INVALID_TRANSFORM: u32 = 2020; +pub const ERROR_COLORSPACE_MISMATCH: u32 = 2021; +pub const ERROR_INVALID_COLORINDEX: u32 = 2022; +pub const ERROR_PROFILE_DOES_NOT_MATCH_DEVICE: u32 = 2023; +pub const ERROR_CONNECTED_OTHER_PASSWORD: u32 = 2108; +pub const ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT: u32 = 2109; +pub const ERROR_BAD_USERNAME: u32 = 2202; +pub const ERROR_NOT_CONNECTED: u32 = 2250; +pub const ERROR_OPEN_FILES: u32 = 2401; +pub const ERROR_ACTIVE_CONNECTIONS: u32 = 2402; +pub const ERROR_DEVICE_IN_USE: u32 = 2404; +pub const ERROR_UNKNOWN_PRINT_MONITOR: u32 = 3000; +pub const ERROR_PRINTER_DRIVER_IN_USE: u32 = 3001; +pub const ERROR_SPOOL_FILE_NOT_FOUND: u32 = 3002; +pub const ERROR_SPL_NO_STARTDOC: u32 = 3003; +pub const ERROR_SPL_NO_ADDJOB: u32 = 3004; +pub const ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED: u32 = 3005; +pub const ERROR_PRINT_MONITOR_ALREADY_INSTALLED: u32 = 3006; +pub const ERROR_INVALID_PRINT_MONITOR: u32 = 3007; +pub const ERROR_PRINT_MONITOR_IN_USE: u32 = 3008; +pub const ERROR_PRINTER_HAS_JOBS_QUEUED: u32 = 3009; +pub const ERROR_SUCCESS_REBOOT_REQUIRED: u32 = 3010; +pub const ERROR_SUCCESS_RESTART_REQUIRED: u32 = 3011; +pub const ERROR_PRINTER_NOT_FOUND: u32 = 3012; +pub const ERROR_PRINTER_DRIVER_WARNED: u32 = 3013; +pub const ERROR_PRINTER_DRIVER_BLOCKED: u32 = 3014; +pub const ERROR_PRINTER_DRIVER_PACKAGE_IN_USE: u32 = 3015; +pub const ERROR_CORE_DRIVER_PACKAGE_NOT_FOUND: u32 = 3016; +pub const ERROR_FAIL_REBOOT_REQUIRED: u32 = 3017; +pub const ERROR_FAIL_REBOOT_INITIATED: u32 = 3018; +pub const ERROR_PRINTER_DRIVER_DOWNLOAD_NEEDED: u32 = 3019; +pub const ERROR_PRINT_JOB_RESTART_REQUIRED: u32 = 3020; +pub const ERROR_INVALID_PRINTER_DRIVER_MANIFEST: u32 = 3021; +pub const ERROR_PRINTER_NOT_SHAREABLE: u32 = 3022; +pub const ERROR_REQUEST_PAUSED: u32 = 3050; +pub const ERROR_APPEXEC_CONDITION_NOT_SATISFIED: u32 = 3060; +pub const ERROR_APPEXEC_HANDLE_INVALIDATED: u32 = 3061; +pub const ERROR_APPEXEC_INVALID_HOST_GENERATION: u32 = 3062; +pub const ERROR_APPEXEC_UNEXPECTED_PROCESS_REGISTRATION: u32 = 3063; +pub const ERROR_APPEXEC_INVALID_HOST_STATE: u32 = 3064; +pub const ERROR_APPEXEC_NO_DONOR: u32 = 3065; +pub const ERROR_APPEXEC_HOST_ID_MISMATCH: u32 = 3066; +pub const ERROR_APPEXEC_UNKNOWN_USER: u32 = 3067; +pub const ERROR_IO_REISSUE_AS_CACHED: u32 = 3950; +pub const ERROR_WINS_INTERNAL: u32 = 4000; +pub const ERROR_CAN_NOT_DEL_LOCAL_WINS: u32 = 4001; +pub const ERROR_STATIC_INIT: u32 = 4002; +pub const ERROR_INC_BACKUP: u32 = 4003; +pub const ERROR_FULL_BACKUP: u32 = 4004; +pub const ERROR_REC_NON_EXISTENT: u32 = 4005; +pub const ERROR_RPL_NOT_ALLOWED: u32 = 4006; +pub const ERROR_DHCP_ADDRESS_CONFLICT: u32 = 4100; +pub const ERROR_WMI_GUID_NOT_FOUND: u32 = 4200; +pub const ERROR_WMI_INSTANCE_NOT_FOUND: u32 = 4201; +pub const ERROR_WMI_ITEMID_NOT_FOUND: u32 = 4202; +pub const ERROR_WMI_TRY_AGAIN: u32 = 4203; +pub const ERROR_WMI_DP_NOT_FOUND: u32 = 4204; +pub const ERROR_WMI_UNRESOLVED_INSTANCE_REF: u32 = 4205; +pub const ERROR_WMI_ALREADY_ENABLED: u32 = 4206; +pub const ERROR_WMI_GUID_DISCONNECTED: u32 = 4207; +pub const ERROR_WMI_SERVER_UNAVAILABLE: u32 = 4208; +pub const ERROR_WMI_DP_FAILED: u32 = 4209; +pub const ERROR_WMI_INVALID_MOF: u32 = 4210; +pub const ERROR_WMI_INVALID_REGINFO: u32 = 4211; +pub const ERROR_WMI_ALREADY_DISABLED: u32 = 4212; +pub const ERROR_WMI_READ_ONLY: u32 = 4213; +pub const ERROR_WMI_SET_FAILURE: u32 = 4214; +pub const ERROR_NOT_APPCONTAINER: u32 = 4250; +pub const ERROR_APPCONTAINER_REQUIRED: u32 = 4251; +pub const ERROR_NOT_SUPPORTED_IN_APPCONTAINER: u32 = 4252; +pub const ERROR_INVALID_PACKAGE_SID_LENGTH: u32 = 4253; +pub const ERROR_INVALID_MEDIA: u32 = 4300; +pub const ERROR_INVALID_LIBRARY: u32 = 4301; +pub const ERROR_INVALID_MEDIA_POOL: u32 = 4302; +pub const ERROR_DRIVE_MEDIA_MISMATCH: u32 = 4303; +pub const ERROR_MEDIA_OFFLINE: u32 = 4304; +pub const ERROR_LIBRARY_OFFLINE: u32 = 4305; +pub const ERROR_EMPTY: u32 = 4306; +pub const ERROR_NOT_EMPTY: u32 = 4307; +pub const ERROR_MEDIA_UNAVAILABLE: u32 = 4308; +pub const ERROR_RESOURCE_DISABLED: u32 = 4309; +pub const ERROR_INVALID_CLEANER: u32 = 4310; +pub const ERROR_UNABLE_TO_CLEAN: u32 = 4311; +pub const ERROR_OBJECT_NOT_FOUND: u32 = 4312; +pub const ERROR_DATABASE_FAILURE: u32 = 4313; +pub const ERROR_DATABASE_FULL: u32 = 4314; +pub const ERROR_MEDIA_INCOMPATIBLE: u32 = 4315; +pub const ERROR_RESOURCE_NOT_PRESENT: u32 = 4316; +pub const ERROR_INVALID_OPERATION: u32 = 4317; +pub const ERROR_MEDIA_NOT_AVAILABLE: u32 = 4318; +pub const ERROR_DEVICE_NOT_AVAILABLE: u32 = 4319; +pub const ERROR_REQUEST_REFUSED: u32 = 4320; +pub const ERROR_INVALID_DRIVE_OBJECT: u32 = 4321; +pub const ERROR_LIBRARY_FULL: u32 = 4322; +pub const ERROR_MEDIUM_NOT_ACCESSIBLE: u32 = 4323; +pub const ERROR_UNABLE_TO_LOAD_MEDIUM: u32 = 4324; +pub const ERROR_UNABLE_TO_INVENTORY_DRIVE: u32 = 4325; +pub const ERROR_UNABLE_TO_INVENTORY_SLOT: u32 = 4326; +pub const ERROR_UNABLE_TO_INVENTORY_TRANSPORT: u32 = 4327; +pub const ERROR_TRANSPORT_FULL: u32 = 4328; +pub const ERROR_CONTROLLING_IEPORT: u32 = 4329; +pub const ERROR_UNABLE_TO_EJECT_MOUNTED_MEDIA: u32 = 4330; +pub const ERROR_CLEANER_SLOT_SET: u32 = 4331; +pub const ERROR_CLEANER_SLOT_NOT_SET: u32 = 4332; +pub const ERROR_CLEANER_CARTRIDGE_SPENT: u32 = 4333; +pub const ERROR_UNEXPECTED_OMID: u32 = 4334; +pub const ERROR_CANT_DELETE_LAST_ITEM: u32 = 4335; +pub const ERROR_MESSAGE_EXCEEDS_MAX_SIZE: u32 = 4336; +pub const ERROR_VOLUME_CONTAINS_SYS_FILES: u32 = 4337; +pub const ERROR_INDIGENOUS_TYPE: u32 = 4338; +pub const ERROR_NO_SUPPORTING_DRIVES: u32 = 4339; +pub const ERROR_CLEANER_CARTRIDGE_INSTALLED: u32 = 4340; +pub const ERROR_IEPORT_FULL: u32 = 4341; +pub const ERROR_FILE_OFFLINE: u32 = 4350; +pub const ERROR_REMOTE_STORAGE_NOT_ACTIVE: u32 = 4351; +pub const ERROR_REMOTE_STORAGE_MEDIA_ERROR: u32 = 4352; +pub const ERROR_NOT_A_REPARSE_POINT: u32 = 4390; +pub const ERROR_REPARSE_ATTRIBUTE_CONFLICT: u32 = 4391; +pub const ERROR_INVALID_REPARSE_DATA: u32 = 4392; +pub const ERROR_REPARSE_TAG_INVALID: u32 = 4393; +pub const ERROR_REPARSE_TAG_MISMATCH: u32 = 4394; +pub const ERROR_REPARSE_POINT_ENCOUNTERED: u32 = 4395; +pub const ERROR_APP_DATA_NOT_FOUND: u32 = 4400; +pub const ERROR_APP_DATA_EXPIRED: u32 = 4401; +pub const ERROR_APP_DATA_CORRUPT: u32 = 4402; +pub const ERROR_APP_DATA_LIMIT_EXCEEDED: u32 = 4403; +pub const ERROR_APP_DATA_REBOOT_REQUIRED: u32 = 4404; +pub const ERROR_SECUREBOOT_ROLLBACK_DETECTED: u32 = 4420; +pub const ERROR_SECUREBOOT_POLICY_VIOLATION: u32 = 4421; +pub const ERROR_SECUREBOOT_INVALID_POLICY: u32 = 4422; +pub const ERROR_SECUREBOOT_POLICY_PUBLISHER_NOT_FOUND: u32 = 4423; +pub const ERROR_SECUREBOOT_POLICY_NOT_SIGNED: u32 = 4424; +pub const ERROR_SECUREBOOT_NOT_ENABLED: u32 = 4425; +pub const ERROR_SECUREBOOT_FILE_REPLACED: u32 = 4426; +pub const ERROR_SECUREBOOT_POLICY_NOT_AUTHORIZED: u32 = 4427; +pub const ERROR_SECUREBOOT_POLICY_UNKNOWN: u32 = 4428; +pub const ERROR_SECUREBOOT_POLICY_MISSING_ANTIROLLBACKVERSION: u32 = 4429; +pub const ERROR_SECUREBOOT_PLATFORM_ID_MISMATCH: u32 = 4430; +pub const ERROR_SECUREBOOT_POLICY_ROLLBACK_DETECTED: u32 = 4431; +pub const ERROR_SECUREBOOT_POLICY_UPGRADE_MISMATCH: u32 = 4432; +pub const ERROR_SECUREBOOT_REQUIRED_POLICY_FILE_MISSING: u32 = 4433; +pub const ERROR_SECUREBOOT_NOT_BASE_POLICY: u32 = 4434; +pub const ERROR_SECUREBOOT_NOT_SUPPLEMENTAL_POLICY: u32 = 4435; +pub const ERROR_OFFLOAD_READ_FLT_NOT_SUPPORTED: u32 = 4440; +pub const ERROR_OFFLOAD_WRITE_FLT_NOT_SUPPORTED: u32 = 4441; +pub const ERROR_OFFLOAD_READ_FILE_NOT_SUPPORTED: u32 = 4442; +pub const ERROR_OFFLOAD_WRITE_FILE_NOT_SUPPORTED: u32 = 4443; +pub const ERROR_ALREADY_HAS_STREAM_ID: u32 = 4444; +pub const ERROR_SMR_GARBAGE_COLLECTION_REQUIRED: u32 = 4445; +pub const ERROR_WOF_WIM_HEADER_CORRUPT: u32 = 4446; +pub const ERROR_WOF_WIM_RESOURCE_TABLE_CORRUPT: u32 = 4447; +pub const ERROR_WOF_FILE_RESOURCE_TABLE_CORRUPT: u32 = 4448; +pub const ERROR_VOLUME_NOT_SIS_ENABLED: u32 = 4500; +pub const ERROR_SYSTEM_INTEGRITY_ROLLBACK_DETECTED: u32 = 4550; +pub const ERROR_SYSTEM_INTEGRITY_POLICY_VIOLATION: u32 = 4551; +pub const ERROR_SYSTEM_INTEGRITY_INVALID_POLICY: u32 = 4552; +pub const ERROR_SYSTEM_INTEGRITY_POLICY_NOT_SIGNED: u32 = 4553; +pub const ERROR_SYSTEM_INTEGRITY_TOO_MANY_POLICIES: u32 = 4554; +pub const ERROR_SYSTEM_INTEGRITY_SUPPLEMENTAL_POLICY_NOT_AUTHORIZED: u32 = 4555; +pub const ERROR_VSM_NOT_INITIALIZED: u32 = 4560; +pub const ERROR_VSM_DMA_PROTECTION_NOT_IN_USE: u32 = 4561; +pub const ERROR_PLATFORM_MANIFEST_NOT_AUTHORIZED: u32 = 4570; +pub const ERROR_PLATFORM_MANIFEST_INVALID: u32 = 4571; +pub const ERROR_PLATFORM_MANIFEST_FILE_NOT_AUTHORIZED: u32 = 4572; +pub const ERROR_PLATFORM_MANIFEST_CATALOG_NOT_AUTHORIZED: u32 = 4573; +pub const ERROR_PLATFORM_MANIFEST_BINARY_ID_NOT_FOUND: u32 = 4574; +pub const ERROR_PLATFORM_MANIFEST_NOT_ACTIVE: u32 = 4575; +pub const ERROR_PLATFORM_MANIFEST_NOT_SIGNED: u32 = 4576; +pub const ERROR_DEPENDENT_RESOURCE_EXISTS: u32 = 5001; +pub const ERROR_DEPENDENCY_NOT_FOUND: u32 = 5002; +pub const ERROR_DEPENDENCY_ALREADY_EXISTS: u32 = 5003; +pub const ERROR_RESOURCE_NOT_ONLINE: u32 = 5004; +pub const ERROR_HOST_NODE_NOT_AVAILABLE: u32 = 5005; +pub const ERROR_RESOURCE_NOT_AVAILABLE: u32 = 5006; +pub const ERROR_RESOURCE_NOT_FOUND: u32 = 5007; +pub const ERROR_SHUTDOWN_CLUSTER: u32 = 5008; +pub const ERROR_CANT_EVICT_ACTIVE_NODE: u32 = 5009; +pub const ERROR_OBJECT_ALREADY_EXISTS: u32 = 5010; +pub const ERROR_OBJECT_IN_LIST: u32 = 5011; +pub const ERROR_GROUP_NOT_AVAILABLE: u32 = 5012; +pub const ERROR_GROUP_NOT_FOUND: u32 = 5013; +pub const ERROR_GROUP_NOT_ONLINE: u32 = 5014; +pub const ERROR_HOST_NODE_NOT_RESOURCE_OWNER: u32 = 5015; +pub const ERROR_HOST_NODE_NOT_GROUP_OWNER: u32 = 5016; +pub const ERROR_RESMON_CREATE_FAILED: u32 = 5017; +pub const ERROR_RESMON_ONLINE_FAILED: u32 = 5018; +pub const ERROR_RESOURCE_ONLINE: u32 = 5019; +pub const ERROR_QUORUM_RESOURCE: u32 = 5020; +pub const ERROR_NOT_QUORUM_CAPABLE: u32 = 5021; +pub const ERROR_CLUSTER_SHUTTING_DOWN: u32 = 5022; +pub const ERROR_INVALID_STATE: u32 = 5023; +pub const ERROR_RESOURCE_PROPERTIES_STORED: u32 = 5024; +pub const ERROR_NOT_QUORUM_CLASS: u32 = 5025; +pub const ERROR_CORE_RESOURCE: u32 = 5026; +pub const ERROR_QUORUM_RESOURCE_ONLINE_FAILED: u32 = 5027; +pub const ERROR_QUORUMLOG_OPEN_FAILED: u32 = 5028; +pub const ERROR_CLUSTERLOG_CORRUPT: u32 = 5029; +pub const ERROR_CLUSTERLOG_RECORD_EXCEEDS_MAXSIZE: u32 = 5030; +pub const ERROR_CLUSTERLOG_EXCEEDS_MAXSIZE: u32 = 5031; +pub const ERROR_CLUSTERLOG_CHKPOINT_NOT_FOUND: u32 = 5032; +pub const ERROR_CLUSTERLOG_NOT_ENOUGH_SPACE: u32 = 5033; +pub const ERROR_QUORUM_OWNER_ALIVE: u32 = 5034; +pub const ERROR_NETWORK_NOT_AVAILABLE: u32 = 5035; +pub const ERROR_NODE_NOT_AVAILABLE: u32 = 5036; +pub const ERROR_ALL_NODES_NOT_AVAILABLE: u32 = 5037; +pub const ERROR_RESOURCE_FAILED: u32 = 5038; +pub const ERROR_CLUSTER_INVALID_NODE: u32 = 5039; +pub const ERROR_CLUSTER_NODE_EXISTS: u32 = 5040; +pub const ERROR_CLUSTER_JOIN_IN_PROGRESS: u32 = 5041; +pub const ERROR_CLUSTER_NODE_NOT_FOUND: u32 = 5042; +pub const ERROR_CLUSTER_LOCAL_NODE_NOT_FOUND: u32 = 5043; +pub const ERROR_CLUSTER_NETWORK_EXISTS: u32 = 5044; +pub const ERROR_CLUSTER_NETWORK_NOT_FOUND: u32 = 5045; +pub const ERROR_CLUSTER_NETINTERFACE_EXISTS: u32 = 5046; +pub const ERROR_CLUSTER_NETINTERFACE_NOT_FOUND: u32 = 5047; +pub const ERROR_CLUSTER_INVALID_REQUEST: u32 = 5048; +pub const ERROR_CLUSTER_INVALID_NETWORK_PROVIDER: u32 = 5049; +pub const ERROR_CLUSTER_NODE_DOWN: u32 = 5050; +pub const ERROR_CLUSTER_NODE_UNREACHABLE: u32 = 5051; +pub const ERROR_CLUSTER_NODE_NOT_MEMBER: u32 = 5052; +pub const ERROR_CLUSTER_JOIN_NOT_IN_PROGRESS: u32 = 5053; +pub const ERROR_CLUSTER_INVALID_NETWORK: u32 = 5054; +pub const ERROR_CLUSTER_NODE_UP: u32 = 5056; +pub const ERROR_CLUSTER_IPADDR_IN_USE: u32 = 5057; +pub const ERROR_CLUSTER_NODE_NOT_PAUSED: u32 = 5058; +pub const ERROR_CLUSTER_NO_SECURITY_CONTEXT: u32 = 5059; +pub const ERROR_CLUSTER_NETWORK_NOT_INTERNAL: u32 = 5060; +pub const ERROR_CLUSTER_NODE_ALREADY_UP: u32 = 5061; +pub const ERROR_CLUSTER_NODE_ALREADY_DOWN: u32 = 5062; +pub const ERROR_CLUSTER_NETWORK_ALREADY_ONLINE: u32 = 5063; +pub const ERROR_CLUSTER_NETWORK_ALREADY_OFFLINE: u32 = 5064; +pub const ERROR_CLUSTER_NODE_ALREADY_MEMBER: u32 = 5065; +pub const ERROR_CLUSTER_LAST_INTERNAL_NETWORK: u32 = 5066; +pub const ERROR_CLUSTER_NETWORK_HAS_DEPENDENTS: u32 = 5067; +pub const ERROR_INVALID_OPERATION_ON_QUORUM: u32 = 5068; +pub const ERROR_DEPENDENCY_NOT_ALLOWED: u32 = 5069; +pub const ERROR_CLUSTER_NODE_PAUSED: u32 = 5070; +pub const ERROR_NODE_CANT_HOST_RESOURCE: u32 = 5071; +pub const ERROR_CLUSTER_NODE_NOT_READY: u32 = 5072; +pub const ERROR_CLUSTER_NODE_SHUTTING_DOWN: u32 = 5073; +pub const ERROR_CLUSTER_JOIN_ABORTED: u32 = 5074; +pub const ERROR_CLUSTER_INCOMPATIBLE_VERSIONS: u32 = 5075; +pub const ERROR_CLUSTER_MAXNUM_OF_RESOURCES_EXCEEDED: u32 = 5076; +pub const ERROR_CLUSTER_SYSTEM_CONFIG_CHANGED: u32 = 5077; +pub const ERROR_CLUSTER_RESOURCE_TYPE_NOT_FOUND: u32 = 5078; +pub const ERROR_CLUSTER_RESTYPE_NOT_SUPPORTED: u32 = 5079; +pub const ERROR_CLUSTER_RESNAME_NOT_FOUND: u32 = 5080; +pub const ERROR_CLUSTER_NO_RPC_PACKAGES_REGISTERED: u32 = 5081; +pub const ERROR_CLUSTER_OWNER_NOT_IN_PREFLIST: u32 = 5082; +pub const ERROR_CLUSTER_DATABASE_SEQMISMATCH: u32 = 5083; +pub const ERROR_RESMON_INVALID_STATE: u32 = 5084; +pub const ERROR_CLUSTER_GUM_NOT_LOCKER: u32 = 5085; +pub const ERROR_QUORUM_DISK_NOT_FOUND: u32 = 5086; +pub const ERROR_DATABASE_BACKUP_CORRUPT: u32 = 5087; +pub const ERROR_CLUSTER_NODE_ALREADY_HAS_DFS_ROOT: u32 = 5088; +pub const ERROR_RESOURCE_PROPERTY_UNCHANGEABLE: u32 = 5089; +pub const ERROR_NO_ADMIN_ACCESS_POINT: u32 = 5090; +pub const ERROR_CLUSTER_MEMBERSHIP_INVALID_STATE: u32 = 5890; +pub const ERROR_CLUSTER_QUORUMLOG_NOT_FOUND: u32 = 5891; +pub const ERROR_CLUSTER_MEMBERSHIP_HALT: u32 = 5892; +pub const ERROR_CLUSTER_INSTANCE_ID_MISMATCH: u32 = 5893; +pub const ERROR_CLUSTER_NETWORK_NOT_FOUND_FOR_IP: u32 = 5894; +pub const ERROR_CLUSTER_PROPERTY_DATA_TYPE_MISMATCH: u32 = 5895; +pub const ERROR_CLUSTER_EVICT_WITHOUT_CLEANUP: u32 = 5896; +pub const ERROR_CLUSTER_PARAMETER_MISMATCH: u32 = 5897; +pub const ERROR_NODE_CANNOT_BE_CLUSTERED: u32 = 5898; +pub const ERROR_CLUSTER_WRONG_OS_VERSION: u32 = 5899; +pub const ERROR_CLUSTER_CANT_CREATE_DUP_CLUSTER_NAME: u32 = 5900; +pub const ERROR_CLUSCFG_ALREADY_COMMITTED: u32 = 5901; +pub const ERROR_CLUSCFG_ROLLBACK_FAILED: u32 = 5902; +pub const ERROR_CLUSCFG_SYSTEM_DISK_DRIVE_LETTER_CONFLICT: u32 = 5903; +pub const ERROR_CLUSTER_OLD_VERSION: u32 = 5904; +pub const ERROR_CLUSTER_MISMATCHED_COMPUTER_ACCT_NAME: u32 = 5905; +pub const ERROR_CLUSTER_NO_NET_ADAPTERS: u32 = 5906; +pub const ERROR_CLUSTER_POISONED: u32 = 5907; +pub const ERROR_CLUSTER_GROUP_MOVING: u32 = 5908; +pub const ERROR_CLUSTER_RESOURCE_TYPE_BUSY: u32 = 5909; +pub const ERROR_RESOURCE_CALL_TIMED_OUT: u32 = 5910; +pub const ERROR_INVALID_CLUSTER_IPV6_ADDRESS: u32 = 5911; +pub const ERROR_CLUSTER_INTERNAL_INVALID_FUNCTION: u32 = 5912; +pub const ERROR_CLUSTER_PARAMETER_OUT_OF_BOUNDS: u32 = 5913; +pub const ERROR_CLUSTER_PARTIAL_SEND: u32 = 5914; +pub const ERROR_CLUSTER_REGISTRY_INVALID_FUNCTION: u32 = 5915; +pub const ERROR_CLUSTER_INVALID_STRING_TERMINATION: u32 = 5916; +pub const ERROR_CLUSTER_INVALID_STRING_FORMAT: u32 = 5917; +pub const ERROR_CLUSTER_DATABASE_TRANSACTION_IN_PROGRESS: u32 = 5918; +pub const ERROR_CLUSTER_DATABASE_TRANSACTION_NOT_IN_PROGRESS: u32 = 5919; +pub const ERROR_CLUSTER_NULL_DATA: u32 = 5920; +pub const ERROR_CLUSTER_PARTIAL_READ: u32 = 5921; +pub const ERROR_CLUSTER_PARTIAL_WRITE: u32 = 5922; +pub const ERROR_CLUSTER_CANT_DESERIALIZE_DATA: u32 = 5923; +pub const ERROR_DEPENDENT_RESOURCE_PROPERTY_CONFLICT: u32 = 5924; +pub const ERROR_CLUSTER_NO_QUORUM: u32 = 5925; +pub const ERROR_CLUSTER_INVALID_IPV6_NETWORK: u32 = 5926; +pub const ERROR_CLUSTER_INVALID_IPV6_TUNNEL_NETWORK: u32 = 5927; +pub const ERROR_QUORUM_NOT_ALLOWED_IN_THIS_GROUP: u32 = 5928; +pub const ERROR_DEPENDENCY_TREE_TOO_COMPLEX: u32 = 5929; +pub const ERROR_EXCEPTION_IN_RESOURCE_CALL: u32 = 5930; +pub const ERROR_CLUSTER_RHS_FAILED_INITIALIZATION: u32 = 5931; +pub const ERROR_CLUSTER_NOT_INSTALLED: u32 = 5932; +pub const ERROR_CLUSTER_RESOURCES_MUST_BE_ONLINE_ON_THE_SAME_NODE: u32 = 5933; +pub const ERROR_CLUSTER_MAX_NODES_IN_CLUSTER: u32 = 5934; +pub const ERROR_CLUSTER_TOO_MANY_NODES: u32 = 5935; +pub const ERROR_CLUSTER_OBJECT_ALREADY_USED: u32 = 5936; +pub const ERROR_NONCORE_GROUPS_FOUND: u32 = 5937; +pub const ERROR_FILE_SHARE_RESOURCE_CONFLICT: u32 = 5938; +pub const ERROR_CLUSTER_EVICT_INVALID_REQUEST: u32 = 5939; +pub const ERROR_CLUSTER_SINGLETON_RESOURCE: u32 = 5940; +pub const ERROR_CLUSTER_GROUP_SINGLETON_RESOURCE: u32 = 5941; +pub const ERROR_CLUSTER_RESOURCE_PROVIDER_FAILED: u32 = 5942; +pub const ERROR_CLUSTER_RESOURCE_CONFIGURATION_ERROR: u32 = 5943; +pub const ERROR_CLUSTER_GROUP_BUSY: u32 = 5944; +pub const ERROR_CLUSTER_NOT_SHARED_VOLUME: u32 = 5945; +pub const ERROR_CLUSTER_INVALID_SECURITY_DESCRIPTOR: u32 = 5946; +pub const ERROR_CLUSTER_SHARED_VOLUMES_IN_USE: u32 = 5947; +pub const ERROR_CLUSTER_USE_SHARED_VOLUMES_API: u32 = 5948; +pub const ERROR_CLUSTER_BACKUP_IN_PROGRESS: u32 = 5949; +pub const ERROR_NON_CSV_PATH: u32 = 5950; +pub const ERROR_CSV_VOLUME_NOT_LOCAL: u32 = 5951; +pub const ERROR_CLUSTER_WATCHDOG_TERMINATING: u32 = 5952; +pub const ERROR_CLUSTER_RESOURCE_VETOED_MOVE_INCOMPATIBLE_NODES: u32 = 5953; +pub const ERROR_CLUSTER_INVALID_NODE_WEIGHT: u32 = 5954; +pub const ERROR_CLUSTER_RESOURCE_VETOED_CALL: u32 = 5955; +pub const ERROR_RESMON_SYSTEM_RESOURCES_LACKING: u32 = 5956; +pub const ERROR_CLUSTER_RESOURCE_VETOED_MOVE_NOT_ENOUGH_RESOURCES_ON_DESTINATION: u32 = 5957; +pub const ERROR_CLUSTER_RESOURCE_VETOED_MOVE_NOT_ENOUGH_RESOURCES_ON_SOURCE: u32 = 5958; +pub const ERROR_CLUSTER_GROUP_QUEUED: u32 = 5959; +pub const ERROR_CLUSTER_RESOURCE_LOCKED_STATUS: u32 = 5960; +pub const ERROR_CLUSTER_SHARED_VOLUME_FAILOVER_NOT_ALLOWED: u32 = 5961; +pub const ERROR_CLUSTER_NODE_DRAIN_IN_PROGRESS: u32 = 5962; +pub const ERROR_CLUSTER_DISK_NOT_CONNECTED: u32 = 5963; +pub const ERROR_DISK_NOT_CSV_CAPABLE: u32 = 5964; +pub const ERROR_RESOURCE_NOT_IN_AVAILABLE_STORAGE: u32 = 5965; +pub const ERROR_CLUSTER_SHARED_VOLUME_REDIRECTED: u32 = 5966; +pub const ERROR_CLUSTER_SHARED_VOLUME_NOT_REDIRECTED: u32 = 5967; +pub const ERROR_CLUSTER_CANNOT_RETURN_PROPERTIES: u32 = 5968; +pub const ERROR_CLUSTER_RESOURCE_CONTAINS_UNSUPPORTED_DIFF_AREA_FOR_SHARED_VOLUMES: u32 = 5969; +pub const ERROR_CLUSTER_RESOURCE_IS_IN_MAINTENANCE_MODE: u32 = 5970; +pub const ERROR_CLUSTER_AFFINITY_CONFLICT: u32 = 5971; +pub const ERROR_CLUSTER_RESOURCE_IS_REPLICA_VIRTUAL_MACHINE: u32 = 5972; +pub const ERROR_CLUSTER_UPGRADE_INCOMPATIBLE_VERSIONS: u32 = 5973; +pub const ERROR_CLUSTER_UPGRADE_FIX_QUORUM_NOT_SUPPORTED: u32 = 5974; +pub const ERROR_CLUSTER_UPGRADE_RESTART_REQUIRED: u32 = 5975; +pub const ERROR_CLUSTER_UPGRADE_IN_PROGRESS: u32 = 5976; +pub const ERROR_CLUSTER_UPGRADE_INCOMPLETE: u32 = 5977; +pub const ERROR_CLUSTER_NODE_IN_GRACE_PERIOD: u32 = 5978; +pub const ERROR_CLUSTER_CSV_IO_PAUSE_TIMEOUT: u32 = 5979; +pub const ERROR_NODE_NOT_ACTIVE_CLUSTER_MEMBER: u32 = 5980; +pub const ERROR_CLUSTER_RESOURCE_NOT_MONITORED: u32 = 5981; +pub const ERROR_CLUSTER_RESOURCE_DOES_NOT_SUPPORT_UNMONITORED: u32 = 5982; +pub const ERROR_CLUSTER_RESOURCE_IS_REPLICATED: u32 = 5983; +pub const ERROR_CLUSTER_NODE_ISOLATED: u32 = 5984; +pub const ERROR_CLUSTER_NODE_QUARANTINED: u32 = 5985; +pub const ERROR_CLUSTER_DATABASE_UPDATE_CONDITION_FAILED: u32 = 5986; +pub const ERROR_CLUSTER_SPACE_DEGRADED: u32 = 5987; +pub const ERROR_CLUSTER_TOKEN_DELEGATION_NOT_SUPPORTED: u32 = 5988; +pub const ERROR_CLUSTER_CSV_INVALID_HANDLE: u32 = 5989; +pub const ERROR_CLUSTER_CSV_SUPPORTED_ONLY_ON_COORDINATOR: u32 = 5990; +pub const ERROR_GROUPSET_NOT_AVAILABLE: u32 = 5991; +pub const ERROR_GROUPSET_NOT_FOUND: u32 = 5992; +pub const ERROR_GROUPSET_CANT_PROVIDE: u32 = 5993; +pub const ERROR_CLUSTER_FAULT_DOMAIN_PARENT_NOT_FOUND: u32 = 5994; +pub const ERROR_CLUSTER_FAULT_DOMAIN_INVALID_HIERARCHY: u32 = 5995; +pub const ERROR_CLUSTER_FAULT_DOMAIN_FAILED_S2D_VALIDATION: u32 = 5996; +pub const ERROR_CLUSTER_FAULT_DOMAIN_S2D_CONNECTIVITY_LOSS: u32 = 5997; +pub const ERROR_CLUSTER_INVALID_INFRASTRUCTURE_FILESERVER_NAME: u32 = 5998; +pub const ERROR_CLUSTERSET_MANAGEMENT_CLUSTER_UNREACHABLE: u32 = 5999; +pub const ERROR_ENCRYPTION_FAILED: u32 = 6000; +pub const ERROR_DECRYPTION_FAILED: u32 = 6001; +pub const ERROR_FILE_ENCRYPTED: u32 = 6002; +pub const ERROR_NO_RECOVERY_POLICY: u32 = 6003; +pub const ERROR_NO_EFS: u32 = 6004; +pub const ERROR_WRONG_EFS: u32 = 6005; +pub const ERROR_NO_USER_KEYS: u32 = 6006; +pub const ERROR_FILE_NOT_ENCRYPTED: u32 = 6007; +pub const ERROR_NOT_EXPORT_FORMAT: u32 = 6008; +pub const ERROR_FILE_READ_ONLY: u32 = 6009; +pub const ERROR_DIR_EFS_DISALLOWED: u32 = 6010; +pub const ERROR_EFS_SERVER_NOT_TRUSTED: u32 = 6011; +pub const ERROR_BAD_RECOVERY_POLICY: u32 = 6012; +pub const ERROR_EFS_ALG_BLOB_TOO_BIG: u32 = 6013; +pub const ERROR_VOLUME_NOT_SUPPORT_EFS: u32 = 6014; +pub const ERROR_EFS_DISABLED: u32 = 6015; +pub const ERROR_EFS_VERSION_NOT_SUPPORT: u32 = 6016; +pub const ERROR_CS_ENCRYPTION_INVALID_SERVER_RESPONSE: u32 = 6017; +pub const ERROR_CS_ENCRYPTION_UNSUPPORTED_SERVER: u32 = 6018; +pub const ERROR_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE: u32 = 6019; +pub const ERROR_CS_ENCRYPTION_NEW_ENCRYPTED_FILE: u32 = 6020; +pub const ERROR_CS_ENCRYPTION_FILE_NOT_CSE: u32 = 6021; +pub const ERROR_ENCRYPTION_POLICY_DENIES_OPERATION: u32 = 6022; +pub const ERROR_WIP_ENCRYPTION_FAILED: u32 = 6023; +pub const ERROR_NO_BROWSER_SERVERS_FOUND: u32 = 6118; +pub const ERROR_LOG_SECTOR_INVALID: u32 = 6600; +pub const ERROR_LOG_SECTOR_PARITY_INVALID: u32 = 6601; +pub const ERROR_LOG_SECTOR_REMAPPED: u32 = 6602; +pub const ERROR_LOG_BLOCK_INCOMPLETE: u32 = 6603; +pub const ERROR_LOG_INVALID_RANGE: u32 = 6604; +pub const ERROR_LOG_BLOCKS_EXHAUSTED: u32 = 6605; +pub const ERROR_LOG_READ_CONTEXT_INVALID: u32 = 6606; +pub const ERROR_LOG_RESTART_INVALID: u32 = 6607; +pub const ERROR_LOG_BLOCK_VERSION: u32 = 6608; +pub const ERROR_LOG_BLOCK_INVALID: u32 = 6609; +pub const ERROR_LOG_READ_MODE_INVALID: u32 = 6610; +pub const ERROR_LOG_NO_RESTART: u32 = 6611; +pub const ERROR_LOG_METADATA_CORRUPT: u32 = 6612; +pub const ERROR_LOG_METADATA_INVALID: u32 = 6613; +pub const ERROR_LOG_METADATA_INCONSISTENT: u32 = 6614; +pub const ERROR_LOG_RESERVATION_INVALID: u32 = 6615; +pub const ERROR_LOG_CANT_DELETE: u32 = 6616; +pub const ERROR_LOG_CONTAINER_LIMIT_EXCEEDED: u32 = 6617; +pub const ERROR_LOG_START_OF_LOG: u32 = 6618; +pub const ERROR_LOG_POLICY_ALREADY_INSTALLED: u32 = 6619; +pub const ERROR_LOG_POLICY_NOT_INSTALLED: u32 = 6620; +pub const ERROR_LOG_POLICY_INVALID: u32 = 6621; +pub const ERROR_LOG_POLICY_CONFLICT: u32 = 6622; +pub const ERROR_LOG_PINNED_ARCHIVE_TAIL: u32 = 6623; +pub const ERROR_LOG_RECORD_NONEXISTENT: u32 = 6624; +pub const ERROR_LOG_RECORDS_RESERVED_INVALID: u32 = 6625; +pub const ERROR_LOG_SPACE_RESERVED_INVALID: u32 = 6626; +pub const ERROR_LOG_TAIL_INVALID: u32 = 6627; +pub const ERROR_LOG_FULL: u32 = 6628; +pub const ERROR_COULD_NOT_RESIZE_LOG: u32 = 6629; +pub const ERROR_LOG_MULTIPLEXED: u32 = 6630; +pub const ERROR_LOG_DEDICATED: u32 = 6631; +pub const ERROR_LOG_ARCHIVE_NOT_IN_PROGRESS: u32 = 6632; +pub const ERROR_LOG_ARCHIVE_IN_PROGRESS: u32 = 6633; +pub const ERROR_LOG_EPHEMERAL: u32 = 6634; +pub const ERROR_LOG_NOT_ENOUGH_CONTAINERS: u32 = 6635; +pub const ERROR_LOG_CLIENT_ALREADY_REGISTERED: u32 = 6636; +pub const ERROR_LOG_CLIENT_NOT_REGISTERED: u32 = 6637; +pub const ERROR_LOG_FULL_HANDLER_IN_PROGRESS: u32 = 6638; +pub const ERROR_LOG_CONTAINER_READ_FAILED: u32 = 6639; +pub const ERROR_LOG_CONTAINER_WRITE_FAILED: u32 = 6640; +pub const ERROR_LOG_CONTAINER_OPEN_FAILED: u32 = 6641; +pub const ERROR_LOG_CONTAINER_STATE_INVALID: u32 = 6642; +pub const ERROR_LOG_STATE_INVALID: u32 = 6643; +pub const ERROR_LOG_PINNED: u32 = 6644; +pub const ERROR_LOG_METADATA_FLUSH_FAILED: u32 = 6645; +pub const ERROR_LOG_INCONSISTENT_SECURITY: u32 = 6646; +pub const ERROR_LOG_APPENDED_FLUSH_FAILED: u32 = 6647; +pub const ERROR_LOG_PINNED_RESERVATION: u32 = 6648; +pub const ERROR_INVALID_TRANSACTION: u32 = 6700; +pub const ERROR_TRANSACTION_NOT_ACTIVE: u32 = 6701; +pub const ERROR_TRANSACTION_REQUEST_NOT_VALID: u32 = 6702; +pub const ERROR_TRANSACTION_NOT_REQUESTED: u32 = 6703; +pub const ERROR_TRANSACTION_ALREADY_ABORTED: u32 = 6704; +pub const ERROR_TRANSACTION_ALREADY_COMMITTED: u32 = 6705; +pub const ERROR_TM_INITIALIZATION_FAILED: u32 = 6706; +pub const ERROR_RESOURCEMANAGER_READ_ONLY: u32 = 6707; +pub const ERROR_TRANSACTION_NOT_JOINED: u32 = 6708; +pub const ERROR_TRANSACTION_SUPERIOR_EXISTS: u32 = 6709; +pub const ERROR_CRM_PROTOCOL_ALREADY_EXISTS: u32 = 6710; +pub const ERROR_TRANSACTION_PROPAGATION_FAILED: u32 = 6711; +pub const ERROR_CRM_PROTOCOL_NOT_FOUND: u32 = 6712; +pub const ERROR_TRANSACTION_INVALID_MARSHALL_BUFFER: u32 = 6713; +pub const ERROR_CURRENT_TRANSACTION_NOT_VALID: u32 = 6714; +pub const ERROR_TRANSACTION_NOT_FOUND: u32 = 6715; +pub const ERROR_RESOURCEMANAGER_NOT_FOUND: u32 = 6716; +pub const ERROR_ENLISTMENT_NOT_FOUND: u32 = 6717; +pub const ERROR_TRANSACTIONMANAGER_NOT_FOUND: u32 = 6718; +pub const ERROR_TRANSACTIONMANAGER_NOT_ONLINE: u32 = 6719; +pub const ERROR_TRANSACTIONMANAGER_RECOVERY_NAME_COLLISION: u32 = 6720; +pub const ERROR_TRANSACTION_NOT_ROOT: u32 = 6721; +pub const ERROR_TRANSACTION_OBJECT_EXPIRED: u32 = 6722; +pub const ERROR_TRANSACTION_RESPONSE_NOT_ENLISTED: u32 = 6723; +pub const ERROR_TRANSACTION_RECORD_TOO_LONG: u32 = 6724; +pub const ERROR_IMPLICIT_TRANSACTION_NOT_SUPPORTED: u32 = 6725; +pub const ERROR_TRANSACTION_INTEGRITY_VIOLATED: u32 = 6726; +pub const ERROR_TRANSACTIONMANAGER_IDENTITY_MISMATCH: u32 = 6727; +pub const ERROR_RM_CANNOT_BE_FROZEN_FOR_SNAPSHOT: u32 = 6728; +pub const ERROR_TRANSACTION_MUST_WRITETHROUGH: u32 = 6729; +pub const ERROR_TRANSACTION_NO_SUPERIOR: u32 = 6730; +pub const ERROR_HEURISTIC_DAMAGE_POSSIBLE: u32 = 6731; +pub const ERROR_TRANSACTIONAL_CONFLICT: u32 = 6800; +pub const ERROR_RM_NOT_ACTIVE: u32 = 6801; +pub const ERROR_RM_METADATA_CORRUPT: u32 = 6802; +pub const ERROR_DIRECTORY_NOT_RM: u32 = 6803; +pub const ERROR_TRANSACTIONS_UNSUPPORTED_REMOTE: u32 = 6805; +pub const ERROR_LOG_RESIZE_INVALID_SIZE: u32 = 6806; +pub const ERROR_OBJECT_NO_LONGER_EXISTS: u32 = 6807; +pub const ERROR_STREAM_MINIVERSION_NOT_FOUND: u32 = 6808; +pub const ERROR_STREAM_MINIVERSION_NOT_VALID: u32 = 6809; +pub const ERROR_MINIVERSION_INACCESSIBLE_FROM_SPECIFIED_TRANSACTION: u32 = 6810; +pub const ERROR_CANT_OPEN_MINIVERSION_WITH_MODIFY_INTENT: u32 = 6811; +pub const ERROR_CANT_CREATE_MORE_STREAM_MINIVERSIONS: u32 = 6812; +pub const ERROR_REMOTE_FILE_VERSION_MISMATCH: u32 = 6814; +pub const ERROR_HANDLE_NO_LONGER_VALID: u32 = 6815; +pub const ERROR_NO_TXF_METADATA: u32 = 6816; +pub const ERROR_LOG_CORRUPTION_DETECTED: u32 = 6817; +pub const ERROR_CANT_RECOVER_WITH_HANDLE_OPEN: u32 = 6818; +pub const ERROR_RM_DISCONNECTED: u32 = 6819; +pub const ERROR_ENLISTMENT_NOT_SUPERIOR: u32 = 6820; +pub const ERROR_RECOVERY_NOT_NEEDED: u32 = 6821; +pub const ERROR_RM_ALREADY_STARTED: u32 = 6822; +pub const ERROR_FILE_IDENTITY_NOT_PERSISTENT: u32 = 6823; +pub const ERROR_CANT_BREAK_TRANSACTIONAL_DEPENDENCY: u32 = 6824; +pub const ERROR_CANT_CROSS_RM_BOUNDARY: u32 = 6825; +pub const ERROR_TXF_DIR_NOT_EMPTY: u32 = 6826; +pub const ERROR_INDOUBT_TRANSACTIONS_EXIST: u32 = 6827; +pub const ERROR_TM_VOLATILE: u32 = 6828; +pub const ERROR_ROLLBACK_TIMER_EXPIRED: u32 = 6829; +pub const ERROR_TXF_ATTRIBUTE_CORRUPT: u32 = 6830; +pub const ERROR_EFS_NOT_ALLOWED_IN_TRANSACTION: u32 = 6831; +pub const ERROR_TRANSACTIONAL_OPEN_NOT_ALLOWED: u32 = 6832; +pub const ERROR_LOG_GROWTH_FAILED: u32 = 6833; +pub const ERROR_TRANSACTED_MAPPING_UNSUPPORTED_REMOTE: u32 = 6834; +pub const ERROR_TXF_METADATA_ALREADY_PRESENT: u32 = 6835; +pub const ERROR_TRANSACTION_SCOPE_CALLBACKS_NOT_SET: u32 = 6836; +pub const ERROR_TRANSACTION_REQUIRED_PROMOTION: u32 = 6837; +pub const ERROR_CANNOT_EXECUTE_FILE_IN_TRANSACTION: u32 = 6838; +pub const ERROR_TRANSACTIONS_NOT_FROZEN: u32 = 6839; +pub const ERROR_TRANSACTION_FREEZE_IN_PROGRESS: u32 = 6840; +pub const ERROR_NOT_SNAPSHOT_VOLUME: u32 = 6841; +pub const ERROR_NO_SAVEPOINT_WITH_OPEN_FILES: u32 = 6842; +pub const ERROR_DATA_LOST_REPAIR: u32 = 6843; +pub const ERROR_SPARSE_NOT_ALLOWED_IN_TRANSACTION: u32 = 6844; +pub const ERROR_TM_IDENTITY_MISMATCH: u32 = 6845; +pub const ERROR_FLOATED_SECTION: u32 = 6846; +pub const ERROR_CANNOT_ACCEPT_TRANSACTED_WORK: u32 = 6847; +pub const ERROR_CANNOT_ABORT_TRANSACTIONS: u32 = 6848; +pub const ERROR_BAD_CLUSTERS: u32 = 6849; +pub const ERROR_COMPRESSION_NOT_ALLOWED_IN_TRANSACTION: u32 = 6850; +pub const ERROR_VOLUME_DIRTY: u32 = 6851; +pub const ERROR_NO_LINK_TRACKING_IN_TRANSACTION: u32 = 6852; +pub const ERROR_OPERATION_NOT_SUPPORTED_IN_TRANSACTION: u32 = 6853; +pub const ERROR_EXPIRED_HANDLE: u32 = 6854; +pub const ERROR_TRANSACTION_NOT_ENLISTED: u32 = 6855; +pub const ERROR_CTX_WINSTATION_NAME_INVALID: u32 = 7001; +pub const ERROR_CTX_INVALID_PD: u32 = 7002; +pub const ERROR_CTX_PD_NOT_FOUND: u32 = 7003; +pub const ERROR_CTX_WD_NOT_FOUND: u32 = 7004; +pub const ERROR_CTX_CANNOT_MAKE_EVENTLOG_ENTRY: u32 = 7005; +pub const ERROR_CTX_SERVICE_NAME_COLLISION: u32 = 7006; +pub const ERROR_CTX_CLOSE_PENDING: u32 = 7007; +pub const ERROR_CTX_NO_OUTBUF: u32 = 7008; +pub const ERROR_CTX_MODEM_INF_NOT_FOUND: u32 = 7009; +pub const ERROR_CTX_INVALID_MODEMNAME: u32 = 7010; +pub const ERROR_CTX_MODEM_RESPONSE_ERROR: u32 = 7011; +pub const ERROR_CTX_MODEM_RESPONSE_TIMEOUT: u32 = 7012; +pub const ERROR_CTX_MODEM_RESPONSE_NO_CARRIER: u32 = 7013; +pub const ERROR_CTX_MODEM_RESPONSE_NO_DIALTONE: u32 = 7014; +pub const ERROR_CTX_MODEM_RESPONSE_BUSY: u32 = 7015; +pub const ERROR_CTX_MODEM_RESPONSE_VOICE: u32 = 7016; +pub const ERROR_CTX_TD_ERROR: u32 = 7017; +pub const ERROR_CTX_WINSTATION_NOT_FOUND: u32 = 7022; +pub const ERROR_CTX_WINSTATION_ALREADY_EXISTS: u32 = 7023; +pub const ERROR_CTX_WINSTATION_BUSY: u32 = 7024; +pub const ERROR_CTX_BAD_VIDEO_MODE: u32 = 7025; +pub const ERROR_CTX_GRAPHICS_INVALID: u32 = 7035; +pub const ERROR_CTX_LOGON_DISABLED: u32 = 7037; +pub const ERROR_CTX_NOT_CONSOLE: u32 = 7038; +pub const ERROR_CTX_CLIENT_QUERY_TIMEOUT: u32 = 7040; +pub const ERROR_CTX_CONSOLE_DISCONNECT: u32 = 7041; +pub const ERROR_CTX_CONSOLE_CONNECT: u32 = 7042; +pub const ERROR_CTX_SHADOW_DENIED: u32 = 7044; +pub const ERROR_CTX_WINSTATION_ACCESS_DENIED: u32 = 7045; +pub const ERROR_CTX_INVALID_WD: u32 = 7049; +pub const ERROR_CTX_SHADOW_INVALID: u32 = 7050; +pub const ERROR_CTX_SHADOW_DISABLED: u32 = 7051; +pub const ERROR_CTX_CLIENT_LICENSE_IN_USE: u32 = 7052; +pub const ERROR_CTX_CLIENT_LICENSE_NOT_SET: u32 = 7053; +pub const ERROR_CTX_LICENSE_NOT_AVAILABLE: u32 = 7054; +pub const ERROR_CTX_LICENSE_CLIENT_INVALID: u32 = 7055; +pub const ERROR_CTX_LICENSE_EXPIRED: u32 = 7056; +pub const ERROR_CTX_SHADOW_NOT_RUNNING: u32 = 7057; +pub const ERROR_CTX_SHADOW_ENDED_BY_MODE_CHANGE: u32 = 7058; +pub const ERROR_ACTIVATION_COUNT_EXCEEDED: u32 = 7059; +pub const ERROR_CTX_WINSTATIONS_DISABLED: u32 = 7060; +pub const ERROR_CTX_ENCRYPTION_LEVEL_REQUIRED: u32 = 7061; +pub const ERROR_CTX_SESSION_IN_USE: u32 = 7062; +pub const ERROR_CTX_NO_FORCE_LOGOFF: u32 = 7063; +pub const ERROR_CTX_ACCOUNT_RESTRICTION: u32 = 7064; +pub const ERROR_RDP_PROTOCOL_ERROR: u32 = 7065; +pub const ERROR_CTX_CDM_CONNECT: u32 = 7066; +pub const ERROR_CTX_CDM_DISCONNECT: u32 = 7067; +pub const ERROR_CTX_SECURITY_LAYER_ERROR: u32 = 7068; +pub const ERROR_TS_INCOMPATIBLE_SESSIONS: u32 = 7069; +pub const ERROR_TS_VIDEO_SUBSYSTEM_ERROR: u32 = 7070; +pub const ERROR_DS_NOT_INSTALLED: u32 = 8200; +pub const ERROR_DS_MEMBERSHIP_EVALUATED_LOCALLY: u32 = 8201; +pub const ERROR_DS_NO_ATTRIBUTE_OR_VALUE: u32 = 8202; +pub const ERROR_DS_INVALID_ATTRIBUTE_SYNTAX: u32 = 8203; +pub const ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED: u32 = 8204; +pub const ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS: u32 = 8205; +pub const ERROR_DS_BUSY: u32 = 8206; +pub const ERROR_DS_UNAVAILABLE: u32 = 8207; +pub const ERROR_DS_NO_RIDS_ALLOCATED: u32 = 8208; +pub const ERROR_DS_NO_MORE_RIDS: u32 = 8209; +pub const ERROR_DS_INCORRECT_ROLE_OWNER: u32 = 8210; +pub const ERROR_DS_RIDMGR_INIT_ERROR: u32 = 8211; +pub const ERROR_DS_OBJ_CLASS_VIOLATION: u32 = 8212; +pub const ERROR_DS_CANT_ON_NON_LEAF: u32 = 8213; +pub const ERROR_DS_CANT_ON_RDN: u32 = 8214; +pub const ERROR_DS_CANT_MOD_OBJ_CLASS: u32 = 8215; +pub const ERROR_DS_CROSS_DOM_MOVE_ERROR: u32 = 8216; +pub const ERROR_DS_GC_NOT_AVAILABLE: u32 = 8217; +pub const ERROR_SHARED_POLICY: u32 = 8218; +pub const ERROR_POLICY_OBJECT_NOT_FOUND: u32 = 8219; +pub const ERROR_POLICY_ONLY_IN_DS: u32 = 8220; +pub const ERROR_PROMOTION_ACTIVE: u32 = 8221; +pub const ERROR_NO_PROMOTION_ACTIVE: u32 = 8222; +pub const ERROR_DS_OPERATIONS_ERROR: u32 = 8224; +pub const ERROR_DS_PROTOCOL_ERROR: u32 = 8225; +pub const ERROR_DS_TIMELIMIT_EXCEEDED: u32 = 8226; +pub const ERROR_DS_SIZELIMIT_EXCEEDED: u32 = 8227; +pub const ERROR_DS_ADMIN_LIMIT_EXCEEDED: u32 = 8228; +pub const ERROR_DS_COMPARE_FALSE: u32 = 8229; +pub const ERROR_DS_COMPARE_TRUE: u32 = 8230; +pub const ERROR_DS_AUTH_METHOD_NOT_SUPPORTED: u32 = 8231; +pub const ERROR_DS_STRONG_AUTH_REQUIRED: u32 = 8232; +pub const ERROR_DS_INAPPROPRIATE_AUTH: u32 = 8233; +pub const ERROR_DS_AUTH_UNKNOWN: u32 = 8234; +pub const ERROR_DS_REFERRAL: u32 = 8235; +pub const ERROR_DS_UNAVAILABLE_CRIT_EXTENSION: u32 = 8236; +pub const ERROR_DS_CONFIDENTIALITY_REQUIRED: u32 = 8237; +pub const ERROR_DS_INAPPROPRIATE_MATCHING: u32 = 8238; +pub const ERROR_DS_CONSTRAINT_VIOLATION: u32 = 8239; +pub const ERROR_DS_NO_SUCH_OBJECT: u32 = 8240; +pub const ERROR_DS_ALIAS_PROBLEM: u32 = 8241; +pub const ERROR_DS_INVALID_DN_SYNTAX: u32 = 8242; +pub const ERROR_DS_IS_LEAF: u32 = 8243; +pub const ERROR_DS_ALIAS_DEREF_PROBLEM: u32 = 8244; +pub const ERROR_DS_UNWILLING_TO_PERFORM: u32 = 8245; +pub const ERROR_DS_LOOP_DETECT: u32 = 8246; +pub const ERROR_DS_NAMING_VIOLATION: u32 = 8247; +pub const ERROR_DS_OBJECT_RESULTS_TOO_LARGE: u32 = 8248; +pub const ERROR_DS_AFFECTS_MULTIPLE_DSAS: u32 = 8249; +pub const ERROR_DS_SERVER_DOWN: u32 = 8250; +pub const ERROR_DS_LOCAL_ERROR: u32 = 8251; +pub const ERROR_DS_ENCODING_ERROR: u32 = 8252; +pub const ERROR_DS_DECODING_ERROR: u32 = 8253; +pub const ERROR_DS_FILTER_UNKNOWN: u32 = 8254; +pub const ERROR_DS_PARAM_ERROR: u32 = 8255; +pub const ERROR_DS_NOT_SUPPORTED: u32 = 8256; +pub const ERROR_DS_NO_RESULTS_RETURNED: u32 = 8257; +pub const ERROR_DS_CONTROL_NOT_FOUND: u32 = 8258; +pub const ERROR_DS_CLIENT_LOOP: u32 = 8259; +pub const ERROR_DS_REFERRAL_LIMIT_EXCEEDED: u32 = 8260; +pub const ERROR_DS_SORT_CONTROL_MISSING: u32 = 8261; +pub const ERROR_DS_OFFSET_RANGE_ERROR: u32 = 8262; +pub const ERROR_DS_RIDMGR_DISABLED: u32 = 8263; +pub const ERROR_DS_ROOT_MUST_BE_NC: u32 = 8301; +pub const ERROR_DS_ADD_REPLICA_INHIBITED: u32 = 8302; +pub const ERROR_DS_ATT_NOT_DEF_IN_SCHEMA: u32 = 8303; +pub const ERROR_DS_MAX_OBJ_SIZE_EXCEEDED: u32 = 8304; +pub const ERROR_DS_OBJ_STRING_NAME_EXISTS: u32 = 8305; +pub const ERROR_DS_NO_RDN_DEFINED_IN_SCHEMA: u32 = 8306; +pub const ERROR_DS_RDN_DOESNT_MATCH_SCHEMA: u32 = 8307; +pub const ERROR_DS_NO_REQUESTED_ATTS_FOUND: u32 = 8308; +pub const ERROR_DS_USER_BUFFER_TO_SMALL: u32 = 8309; +pub const ERROR_DS_ATT_IS_NOT_ON_OBJ: u32 = 8310; +pub const ERROR_DS_ILLEGAL_MOD_OPERATION: u32 = 8311; +pub const ERROR_DS_OBJ_TOO_LARGE: u32 = 8312; +pub const ERROR_DS_BAD_INSTANCE_TYPE: u32 = 8313; +pub const ERROR_DS_MASTERDSA_REQUIRED: u32 = 8314; +pub const ERROR_DS_OBJECT_CLASS_REQUIRED: u32 = 8315; +pub const ERROR_DS_MISSING_REQUIRED_ATT: u32 = 8316; +pub const ERROR_DS_ATT_NOT_DEF_FOR_CLASS: u32 = 8317; +pub const ERROR_DS_ATT_ALREADY_EXISTS: u32 = 8318; +pub const ERROR_DS_CANT_ADD_ATT_VALUES: u32 = 8320; +pub const ERROR_DS_SINGLE_VALUE_CONSTRAINT: u32 = 8321; +pub const ERROR_DS_RANGE_CONSTRAINT: u32 = 8322; +pub const ERROR_DS_ATT_VAL_ALREADY_EXISTS: u32 = 8323; +pub const ERROR_DS_CANT_REM_MISSING_ATT: u32 = 8324; +pub const ERROR_DS_CANT_REM_MISSING_ATT_VAL: u32 = 8325; +pub const ERROR_DS_ROOT_CANT_BE_SUBREF: u32 = 8326; +pub const ERROR_DS_NO_CHAINING: u32 = 8327; +pub const ERROR_DS_NO_CHAINED_EVAL: u32 = 8328; +pub const ERROR_DS_NO_PARENT_OBJECT: u32 = 8329; +pub const ERROR_DS_PARENT_IS_AN_ALIAS: u32 = 8330; +pub const ERROR_DS_CANT_MIX_MASTER_AND_REPS: u32 = 8331; +pub const ERROR_DS_CHILDREN_EXIST: u32 = 8332; +pub const ERROR_DS_OBJ_NOT_FOUND: u32 = 8333; +pub const ERROR_DS_ALIASED_OBJ_MISSING: u32 = 8334; +pub const ERROR_DS_BAD_NAME_SYNTAX: u32 = 8335; +pub const ERROR_DS_ALIAS_POINTS_TO_ALIAS: u32 = 8336; +pub const ERROR_DS_CANT_DEREF_ALIAS: u32 = 8337; +pub const ERROR_DS_OUT_OF_SCOPE: u32 = 8338; +pub const ERROR_DS_OBJECT_BEING_REMOVED: u32 = 8339; +pub const ERROR_DS_CANT_DELETE_DSA_OBJ: u32 = 8340; +pub const ERROR_DS_GENERIC_ERROR: u32 = 8341; +pub const ERROR_DS_DSA_MUST_BE_INT_MASTER: u32 = 8342; +pub const ERROR_DS_CLASS_NOT_DSA: u32 = 8343; +pub const ERROR_DS_INSUFF_ACCESS_RIGHTS: u32 = 8344; +pub const ERROR_DS_ILLEGAL_SUPERIOR: u32 = 8345; +pub const ERROR_DS_ATTRIBUTE_OWNED_BY_SAM: u32 = 8346; +pub const ERROR_DS_NAME_TOO_MANY_PARTS: u32 = 8347; +pub const ERROR_DS_NAME_TOO_LONG: u32 = 8348; +pub const ERROR_DS_NAME_VALUE_TOO_LONG: u32 = 8349; +pub const ERROR_DS_NAME_UNPARSEABLE: u32 = 8350; +pub const ERROR_DS_NAME_TYPE_UNKNOWN: u32 = 8351; +pub const ERROR_DS_NOT_AN_OBJECT: u32 = 8352; +pub const ERROR_DS_SEC_DESC_TOO_SHORT: u32 = 8353; +pub const ERROR_DS_SEC_DESC_INVALID: u32 = 8354; +pub const ERROR_DS_NO_DELETED_NAME: u32 = 8355; +pub const ERROR_DS_SUBREF_MUST_HAVE_PARENT: u32 = 8356; +pub const ERROR_DS_NCNAME_MUST_BE_NC: u32 = 8357; +pub const ERROR_DS_CANT_ADD_SYSTEM_ONLY: u32 = 8358; +pub const ERROR_DS_CLASS_MUST_BE_CONCRETE: u32 = 8359; +pub const ERROR_DS_INVALID_DMD: u32 = 8360; +pub const ERROR_DS_OBJ_GUID_EXISTS: u32 = 8361; +pub const ERROR_DS_NOT_ON_BACKLINK: u32 = 8362; +pub const ERROR_DS_NO_CROSSREF_FOR_NC: u32 = 8363; +pub const ERROR_DS_SHUTTING_DOWN: u32 = 8364; +pub const ERROR_DS_UNKNOWN_OPERATION: u32 = 8365; +pub const ERROR_DS_INVALID_ROLE_OWNER: u32 = 8366; +pub const ERROR_DS_COULDNT_CONTACT_FSMO: u32 = 8367; +pub const ERROR_DS_CROSS_NC_DN_RENAME: u32 = 8368; +pub const ERROR_DS_CANT_MOD_SYSTEM_ONLY: u32 = 8369; +pub const ERROR_DS_REPLICATOR_ONLY: u32 = 8370; +pub const ERROR_DS_OBJ_CLASS_NOT_DEFINED: u32 = 8371; +pub const ERROR_DS_OBJ_CLASS_NOT_SUBCLASS: u32 = 8372; +pub const ERROR_DS_NAME_REFERENCE_INVALID: u32 = 8373; +pub const ERROR_DS_CROSS_REF_EXISTS: u32 = 8374; +pub const ERROR_DS_CANT_DEL_MASTER_CROSSREF: u32 = 8375; +pub const ERROR_DS_SUBTREE_NOTIFY_NOT_NC_HEAD: u32 = 8376; +pub const ERROR_DS_NOTIFY_FILTER_TOO_COMPLEX: u32 = 8377; +pub const ERROR_DS_DUP_RDN: u32 = 8378; +pub const ERROR_DS_DUP_OID: u32 = 8379; +pub const ERROR_DS_DUP_MAPI_ID: u32 = 8380; +pub const ERROR_DS_DUP_SCHEMA_ID_GUID: u32 = 8381; +pub const ERROR_DS_DUP_LDAP_DISPLAY_NAME: u32 = 8382; +pub const ERROR_DS_SEMANTIC_ATT_TEST: u32 = 8383; +pub const ERROR_DS_SYNTAX_MISMATCH: u32 = 8384; +pub const ERROR_DS_EXISTS_IN_MUST_HAVE: u32 = 8385; +pub const ERROR_DS_EXISTS_IN_MAY_HAVE: u32 = 8386; +pub const ERROR_DS_NONEXISTENT_MAY_HAVE: u32 = 8387; +pub const ERROR_DS_NONEXISTENT_MUST_HAVE: u32 = 8388; +pub const ERROR_DS_AUX_CLS_TEST_FAIL: u32 = 8389; +pub const ERROR_DS_NONEXISTENT_POSS_SUP: u32 = 8390; +pub const ERROR_DS_SUB_CLS_TEST_FAIL: u32 = 8391; +pub const ERROR_DS_BAD_RDN_ATT_ID_SYNTAX: u32 = 8392; +pub const ERROR_DS_EXISTS_IN_AUX_CLS: u32 = 8393; +pub const ERROR_DS_EXISTS_IN_SUB_CLS: u32 = 8394; +pub const ERROR_DS_EXISTS_IN_POSS_SUP: u32 = 8395; +pub const ERROR_DS_RECALCSCHEMA_FAILED: u32 = 8396; +pub const ERROR_DS_TREE_DELETE_NOT_FINISHED: u32 = 8397; +pub const ERROR_DS_CANT_DELETE: u32 = 8398; +pub const ERROR_DS_ATT_SCHEMA_REQ_ID: u32 = 8399; +pub const ERROR_DS_BAD_ATT_SCHEMA_SYNTAX: u32 = 8400; +pub const ERROR_DS_CANT_CACHE_ATT: u32 = 8401; +pub const ERROR_DS_CANT_CACHE_CLASS: u32 = 8402; +pub const ERROR_DS_CANT_REMOVE_ATT_CACHE: u32 = 8403; +pub const ERROR_DS_CANT_REMOVE_CLASS_CACHE: u32 = 8404; +pub const ERROR_DS_CANT_RETRIEVE_DN: u32 = 8405; +pub const ERROR_DS_MISSING_SUPREF: u32 = 8406; +pub const ERROR_DS_CANT_RETRIEVE_INSTANCE: u32 = 8407; +pub const ERROR_DS_CODE_INCONSISTENCY: u32 = 8408; +pub const ERROR_DS_DATABASE_ERROR: u32 = 8409; +pub const ERROR_DS_GOVERNSID_MISSING: u32 = 8410; +pub const ERROR_DS_MISSING_EXPECTED_ATT: u32 = 8411; +pub const ERROR_DS_NCNAME_MISSING_CR_REF: u32 = 8412; +pub const ERROR_DS_SECURITY_CHECKING_ERROR: u32 = 8413; +pub const ERROR_DS_SCHEMA_NOT_LOADED: u32 = 8414; +pub const ERROR_DS_SCHEMA_ALLOC_FAILED: u32 = 8415; +pub const ERROR_DS_ATT_SCHEMA_REQ_SYNTAX: u32 = 8416; +pub const ERROR_DS_GCVERIFY_ERROR: u32 = 8417; +pub const ERROR_DS_DRA_SCHEMA_MISMATCH: u32 = 8418; +pub const ERROR_DS_CANT_FIND_DSA_OBJ: u32 = 8419; +pub const ERROR_DS_CANT_FIND_EXPECTED_NC: u32 = 8420; +pub const ERROR_DS_CANT_FIND_NC_IN_CACHE: u32 = 8421; +pub const ERROR_DS_CANT_RETRIEVE_CHILD: u32 = 8422; +pub const ERROR_DS_SECURITY_ILLEGAL_MODIFY: u32 = 8423; +pub const ERROR_DS_CANT_REPLACE_HIDDEN_REC: u32 = 8424; +pub const ERROR_DS_BAD_HIERARCHY_FILE: u32 = 8425; +pub const ERROR_DS_BUILD_HIERARCHY_TABLE_FAILED: u32 = 8426; +pub const ERROR_DS_CONFIG_PARAM_MISSING: u32 = 8427; +pub const ERROR_DS_COUNTING_AB_INDICES_FAILED: u32 = 8428; +pub const ERROR_DS_HIERARCHY_TABLE_MALLOC_FAILED: u32 = 8429; +pub const ERROR_DS_INTERNAL_FAILURE: u32 = 8430; +pub const ERROR_DS_UNKNOWN_ERROR: u32 = 8431; +pub const ERROR_DS_ROOT_REQUIRES_CLASS_TOP: u32 = 8432; +pub const ERROR_DS_REFUSING_FSMO_ROLES: u32 = 8433; +pub const ERROR_DS_MISSING_FSMO_SETTINGS: u32 = 8434; +pub const ERROR_DS_UNABLE_TO_SURRENDER_ROLES: u32 = 8435; +pub const ERROR_DS_DRA_GENERIC: u32 = 8436; +pub const ERROR_DS_DRA_INVALID_PARAMETER: u32 = 8437; +pub const ERROR_DS_DRA_BUSY: u32 = 8438; +pub const ERROR_DS_DRA_BAD_DN: u32 = 8439; +pub const ERROR_DS_DRA_BAD_NC: u32 = 8440; +pub const ERROR_DS_DRA_DN_EXISTS: u32 = 8441; +pub const ERROR_DS_DRA_INTERNAL_ERROR: u32 = 8442; +pub const ERROR_DS_DRA_INCONSISTENT_DIT: u32 = 8443; +pub const ERROR_DS_DRA_CONNECTION_FAILED: u32 = 8444; +pub const ERROR_DS_DRA_BAD_INSTANCE_TYPE: u32 = 8445; +pub const ERROR_DS_DRA_OUT_OF_MEM: u32 = 8446; +pub const ERROR_DS_DRA_MAIL_PROBLEM: u32 = 8447; +pub const ERROR_DS_DRA_REF_ALREADY_EXISTS: u32 = 8448; +pub const ERROR_DS_DRA_REF_NOT_FOUND: u32 = 8449; +pub const ERROR_DS_DRA_OBJ_IS_REP_SOURCE: u32 = 8450; +pub const ERROR_DS_DRA_DB_ERROR: u32 = 8451; +pub const ERROR_DS_DRA_NO_REPLICA: u32 = 8452; +pub const ERROR_DS_DRA_ACCESS_DENIED: u32 = 8453; +pub const ERROR_DS_DRA_NOT_SUPPORTED: u32 = 8454; +pub const ERROR_DS_DRA_RPC_CANCELLED: u32 = 8455; +pub const ERROR_DS_DRA_SOURCE_DISABLED: u32 = 8456; +pub const ERROR_DS_DRA_SINK_DISABLED: u32 = 8457; +pub const ERROR_DS_DRA_NAME_COLLISION: u32 = 8458; +pub const ERROR_DS_DRA_SOURCE_REINSTALLED: u32 = 8459; +pub const ERROR_DS_DRA_MISSING_PARENT: u32 = 8460; +pub const ERROR_DS_DRA_PREEMPTED: u32 = 8461; +pub const ERROR_DS_DRA_ABANDON_SYNC: u32 = 8462; +pub const ERROR_DS_DRA_SHUTDOWN: u32 = 8463; +pub const ERROR_DS_DRA_INCOMPATIBLE_PARTIAL_SET: u32 = 8464; +pub const ERROR_DS_DRA_SOURCE_IS_PARTIAL_REPLICA: u32 = 8465; +pub const ERROR_DS_DRA_EXTN_CONNECTION_FAILED: u32 = 8466; +pub const ERROR_DS_INSTALL_SCHEMA_MISMATCH: u32 = 8467; +pub const ERROR_DS_DUP_LINK_ID: u32 = 8468; +pub const ERROR_DS_NAME_ERROR_RESOLVING: u32 = 8469; +pub const ERROR_DS_NAME_ERROR_NOT_FOUND: u32 = 8470; +pub const ERROR_DS_NAME_ERROR_NOT_UNIQUE: u32 = 8471; +pub const ERROR_DS_NAME_ERROR_NO_MAPPING: u32 = 8472; +pub const ERROR_DS_NAME_ERROR_DOMAIN_ONLY: u32 = 8473; +pub const ERROR_DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING: u32 = 8474; +pub const ERROR_DS_CONSTRUCTED_ATT_MOD: u32 = 8475; +pub const ERROR_DS_WRONG_OM_OBJ_CLASS: u32 = 8476; +pub const ERROR_DS_DRA_REPL_PENDING: u32 = 8477; +pub const ERROR_DS_DS_REQUIRED: u32 = 8478; +pub const ERROR_DS_INVALID_LDAP_DISPLAY_NAME: u32 = 8479; +pub const ERROR_DS_NON_BASE_SEARCH: u32 = 8480; +pub const ERROR_DS_CANT_RETRIEVE_ATTS: u32 = 8481; +pub const ERROR_DS_BACKLINK_WITHOUT_LINK: u32 = 8482; +pub const ERROR_DS_EPOCH_MISMATCH: u32 = 8483; +pub const ERROR_DS_SRC_NAME_MISMATCH: u32 = 8484; +pub const ERROR_DS_SRC_AND_DST_NC_IDENTICAL: u32 = 8485; +pub const ERROR_DS_DST_NC_MISMATCH: u32 = 8486; +pub const ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC: u32 = 8487; +pub const ERROR_DS_SRC_GUID_MISMATCH: u32 = 8488; +pub const ERROR_DS_CANT_MOVE_DELETED_OBJECT: u32 = 8489; +pub const ERROR_DS_PDC_OPERATION_IN_PROGRESS: u32 = 8490; +pub const ERROR_DS_CROSS_DOMAIN_CLEANUP_REQD: u32 = 8491; +pub const ERROR_DS_ILLEGAL_XDOM_MOVE_OPERATION: u32 = 8492; +pub const ERROR_DS_CANT_WITH_ACCT_GROUP_MEMBERSHPS: u32 = 8493; +pub const ERROR_DS_NC_MUST_HAVE_NC_PARENT: u32 = 8494; +pub const ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE: u32 = 8495; +pub const ERROR_DS_DST_DOMAIN_NOT_NATIVE: u32 = 8496; +pub const ERROR_DS_MISSING_INFRASTRUCTURE_CONTAINER: u32 = 8497; +pub const ERROR_DS_CANT_MOVE_ACCOUNT_GROUP: u32 = 8498; +pub const ERROR_DS_CANT_MOVE_RESOURCE_GROUP: u32 = 8499; +pub const ERROR_DS_INVALID_SEARCH_FLAG: u32 = 8500; +pub const ERROR_DS_NO_TREE_DELETE_ABOVE_NC: u32 = 8501; +pub const ERROR_DS_COULDNT_LOCK_TREE_FOR_DELETE: u32 = 8502; +pub const ERROR_DS_COULDNT_IDENTIFY_OBJECTS_FOR_TREE_DELETE: u32 = 8503; +pub const ERROR_DS_SAM_INIT_FAILURE: u32 = 8504; +pub const ERROR_DS_SENSITIVE_GROUP_VIOLATION: u32 = 8505; +pub const ERROR_DS_CANT_MOD_PRIMARYGROUPID: u32 = 8506; +pub const ERROR_DS_ILLEGAL_BASE_SCHEMA_MOD: u32 = 8507; +pub const ERROR_DS_NONSAFE_SCHEMA_CHANGE: u32 = 8508; +pub const ERROR_DS_SCHEMA_UPDATE_DISALLOWED: u32 = 8509; +pub const ERROR_DS_CANT_CREATE_UNDER_SCHEMA: u32 = 8510; +pub const ERROR_DS_INSTALL_NO_SRC_SCH_VERSION: u32 = 8511; +pub const ERROR_DS_INSTALL_NO_SCH_VERSION_IN_INIFILE: u32 = 8512; +pub const ERROR_DS_INVALID_GROUP_TYPE: u32 = 8513; +pub const ERROR_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN: u32 = 8514; +pub const ERROR_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN: u32 = 8515; +pub const ERROR_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER: u32 = 8516; +pub const ERROR_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER: u32 = 8517; +pub const ERROR_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER: u32 = 8518; +pub const ERROR_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER: u32 = 8519; +pub const ERROR_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER: u32 = 8520; +pub const ERROR_DS_HAVE_PRIMARY_MEMBERS: u32 = 8521; +pub const ERROR_DS_STRING_SD_CONVERSION_FAILED: u32 = 8522; +pub const ERROR_DS_NAMING_MASTER_GC: u32 = 8523; +pub const ERROR_DS_DNS_LOOKUP_FAILURE: u32 = 8524; +pub const ERROR_DS_COULDNT_UPDATE_SPNS: u32 = 8525; +pub const ERROR_DS_CANT_RETRIEVE_SD: u32 = 8526; +pub const ERROR_DS_KEY_NOT_UNIQUE: u32 = 8527; +pub const ERROR_DS_WRONG_LINKED_ATT_SYNTAX: u32 = 8528; +pub const ERROR_DS_SAM_NEED_BOOTKEY_PASSWORD: u32 = 8529; +pub const ERROR_DS_SAM_NEED_BOOTKEY_FLOPPY: u32 = 8530; +pub const ERROR_DS_CANT_START: u32 = 8531; +pub const ERROR_DS_INIT_FAILURE: u32 = 8532; +pub const ERROR_DS_NO_PKT_PRIVACY_ON_CONNECTION: u32 = 8533; +pub const ERROR_DS_SOURCE_DOMAIN_IN_FOREST: u32 = 8534; +pub const ERROR_DS_DESTINATION_DOMAIN_NOT_IN_FOREST: u32 = 8535; +pub const ERROR_DS_DESTINATION_AUDITING_NOT_ENABLED: u32 = 8536; +pub const ERROR_DS_CANT_FIND_DC_FOR_SRC_DOMAIN: u32 = 8537; +pub const ERROR_DS_SRC_OBJ_NOT_GROUP_OR_USER: u32 = 8538; +pub const ERROR_DS_SRC_SID_EXISTS_IN_FOREST: u32 = 8539; +pub const ERROR_DS_SRC_AND_DST_OBJECT_CLASS_MISMATCH: u32 = 8540; +pub const ERROR_SAM_INIT_FAILURE: u32 = 8541; +pub const ERROR_DS_DRA_SCHEMA_INFO_SHIP: u32 = 8542; +pub const ERROR_DS_DRA_SCHEMA_CONFLICT: u32 = 8543; +pub const ERROR_DS_DRA_EARLIER_SCHEMA_CONFLICT: u32 = 8544; +pub const ERROR_DS_DRA_OBJ_NC_MISMATCH: u32 = 8545; +pub const ERROR_DS_NC_STILL_HAS_DSAS: u32 = 8546; +pub const ERROR_DS_GC_REQUIRED: u32 = 8547; +pub const ERROR_DS_LOCAL_MEMBER_OF_LOCAL_ONLY: u32 = 8548; +pub const ERROR_DS_NO_FPO_IN_UNIVERSAL_GROUPS: u32 = 8549; +pub const ERROR_DS_CANT_ADD_TO_GC: u32 = 8550; +pub const ERROR_DS_NO_CHECKPOINT_WITH_PDC: u32 = 8551; +pub const ERROR_DS_SOURCE_AUDITING_NOT_ENABLED: u32 = 8552; +pub const ERROR_DS_CANT_CREATE_IN_NONDOMAIN_NC: u32 = 8553; +pub const ERROR_DS_INVALID_NAME_FOR_SPN: u32 = 8554; +pub const ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS: u32 = 8555; +pub const ERROR_DS_UNICODEPWD_NOT_IN_QUOTES: u32 = 8556; +pub const ERROR_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED: u32 = 8557; +pub const ERROR_DS_MUST_BE_RUN_ON_DST_DC: u32 = 8558; +pub const ERROR_DS_SRC_DC_MUST_BE_SP4_OR_GREATER: u32 = 8559; +pub const ERROR_DS_CANT_TREE_DELETE_CRITICAL_OBJ: u32 = 8560; +pub const ERROR_DS_INIT_FAILURE_CONSOLE: u32 = 8561; +pub const ERROR_DS_SAM_INIT_FAILURE_CONSOLE: u32 = 8562; +pub const ERROR_DS_FOREST_VERSION_TOO_HIGH: u32 = 8563; +pub const ERROR_DS_DOMAIN_VERSION_TOO_HIGH: u32 = 8564; +pub const ERROR_DS_FOREST_VERSION_TOO_LOW: u32 = 8565; +pub const ERROR_DS_DOMAIN_VERSION_TOO_LOW: u32 = 8566; +pub const ERROR_DS_INCOMPATIBLE_VERSION: u32 = 8567; +pub const ERROR_DS_LOW_DSA_VERSION: u32 = 8568; +pub const ERROR_DS_NO_BEHAVIOR_VERSION_IN_MIXEDDOMAIN: u32 = 8569; +pub const ERROR_DS_NOT_SUPPORTED_SORT_ORDER: u32 = 8570; +pub const ERROR_DS_NAME_NOT_UNIQUE: u32 = 8571; +pub const ERROR_DS_MACHINE_ACCOUNT_CREATED_PRENT4: u32 = 8572; +pub const ERROR_DS_OUT_OF_VERSION_STORE: u32 = 8573; +pub const ERROR_DS_INCOMPATIBLE_CONTROLS_USED: u32 = 8574; +pub const ERROR_DS_NO_REF_DOMAIN: u32 = 8575; +pub const ERROR_DS_RESERVED_LINK_ID: u32 = 8576; +pub const ERROR_DS_LINK_ID_NOT_AVAILABLE: u32 = 8577; +pub const ERROR_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER: u32 = 8578; +pub const ERROR_DS_MODIFYDN_DISALLOWED_BY_INSTANCE_TYPE: u32 = 8579; +pub const ERROR_DS_NO_OBJECT_MOVE_IN_SCHEMA_NC: u32 = 8580; +pub const ERROR_DS_MODIFYDN_DISALLOWED_BY_FLAG: u32 = 8581; +pub const ERROR_DS_MODIFYDN_WRONG_GRANDPARENT: u32 = 8582; +pub const ERROR_DS_NAME_ERROR_TRUST_REFERRAL: u32 = 8583; +pub const ERROR_NOT_SUPPORTED_ON_STANDARD_SERVER: u32 = 8584; +pub const ERROR_DS_CANT_ACCESS_REMOTE_PART_OF_AD: u32 = 8585; +pub const ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE_V2: u32 = 8586; +pub const ERROR_DS_THREAD_LIMIT_EXCEEDED: u32 = 8587; +pub const ERROR_DS_NOT_CLOSEST: u32 = 8588; +pub const ERROR_DS_CANT_DERIVE_SPN_WITHOUT_SERVER_REF: u32 = 8589; +pub const ERROR_DS_SINGLE_USER_MODE_FAILED: u32 = 8590; +pub const ERROR_DS_NTDSCRIPT_SYNTAX_ERROR: u32 = 8591; +pub const ERROR_DS_NTDSCRIPT_PROCESS_ERROR: u32 = 8592; +pub const ERROR_DS_DIFFERENT_REPL_EPOCHS: u32 = 8593; +pub const ERROR_DS_DRS_EXTENSIONS_CHANGED: u32 = 8594; +pub const ERROR_DS_REPLICA_SET_CHANGE_NOT_ALLOWED_ON_DISABLED_CR: u32 = 8595; +pub const ERROR_DS_NO_MSDS_INTID: u32 = 8596; +pub const ERROR_DS_DUP_MSDS_INTID: u32 = 8597; +pub const ERROR_DS_EXISTS_IN_RDNATTID: u32 = 8598; +pub const ERROR_DS_AUTHORIZATION_FAILED: u32 = 8599; +pub const ERROR_DS_INVALID_SCRIPT: u32 = 8600; +pub const ERROR_DS_REMOTE_CROSSREF_OP_FAILED: u32 = 8601; +pub const ERROR_DS_CROSS_REF_BUSY: u32 = 8602; +pub const ERROR_DS_CANT_DERIVE_SPN_FOR_DELETED_DOMAIN: u32 = 8603; +pub const ERROR_DS_CANT_DEMOTE_WITH_WRITEABLE_NC: u32 = 8604; +pub const ERROR_DS_DUPLICATE_ID_FOUND: u32 = 8605; +pub const ERROR_DS_INSUFFICIENT_ATTR_TO_CREATE_OBJECT: u32 = 8606; +pub const ERROR_DS_GROUP_CONVERSION_ERROR: u32 = 8607; +pub const ERROR_DS_CANT_MOVE_APP_BASIC_GROUP: u32 = 8608; +pub const ERROR_DS_CANT_MOVE_APP_QUERY_GROUP: u32 = 8609; +pub const ERROR_DS_ROLE_NOT_VERIFIED: u32 = 8610; +pub const ERROR_DS_WKO_CONTAINER_CANNOT_BE_SPECIAL: u32 = 8611; +pub const ERROR_DS_DOMAIN_RENAME_IN_PROGRESS: u32 = 8612; +pub const ERROR_DS_EXISTING_AD_CHILD_NC: u32 = 8613; +pub const ERROR_DS_REPL_LIFETIME_EXCEEDED: u32 = 8614; +pub const ERROR_DS_DISALLOWED_IN_SYSTEM_CONTAINER: u32 = 8615; +pub const ERROR_DS_LDAP_SEND_QUEUE_FULL: u32 = 8616; +pub const ERROR_DS_DRA_OUT_SCHEDULE_WINDOW: u32 = 8617; +pub const ERROR_DS_POLICY_NOT_KNOWN: u32 = 8618; +pub const ERROR_NO_SITE_SETTINGS_OBJECT: u32 = 8619; +pub const ERROR_NO_SECRETS: u32 = 8620; +pub const ERROR_NO_WRITABLE_DC_FOUND: u32 = 8621; +pub const ERROR_DS_NO_SERVER_OBJECT: u32 = 8622; +pub const ERROR_DS_NO_NTDSA_OBJECT: u32 = 8623; +pub const ERROR_DS_NON_ASQ_SEARCH: u32 = 8624; +pub const ERROR_DS_AUDIT_FAILURE: u32 = 8625; +pub const ERROR_DS_INVALID_SEARCH_FLAG_SUBTREE: u32 = 8626; +pub const ERROR_DS_INVALID_SEARCH_FLAG_TUPLE: u32 = 8627; +pub const ERROR_DS_HIERARCHY_TABLE_TOO_DEEP: u32 = 8628; +pub const ERROR_DS_DRA_CORRUPT_UTD_VECTOR: u32 = 8629; +pub const ERROR_DS_DRA_SECRETS_DENIED: u32 = 8630; +pub const ERROR_DS_RESERVED_MAPI_ID: u32 = 8631; +pub const ERROR_DS_MAPI_ID_NOT_AVAILABLE: u32 = 8632; +pub const ERROR_DS_DRA_MISSING_KRBTGT_SECRET: u32 = 8633; +pub const ERROR_DS_DOMAIN_NAME_EXISTS_IN_FOREST: u32 = 8634; +pub const ERROR_DS_FLAT_NAME_EXISTS_IN_FOREST: u32 = 8635; +pub const ERROR_INVALID_USER_PRINCIPAL_NAME: u32 = 8636; +pub const ERROR_DS_OID_MAPPED_GROUP_CANT_HAVE_MEMBERS: u32 = 8637; +pub const ERROR_DS_OID_NOT_FOUND: u32 = 8638; +pub const ERROR_DS_DRA_RECYCLED_TARGET: u32 = 8639; +pub const ERROR_DS_DISALLOWED_NC_REDIRECT: u32 = 8640; +pub const ERROR_DS_HIGH_ADLDS_FFL: u32 = 8641; +pub const ERROR_DS_HIGH_DSA_VERSION: u32 = 8642; +pub const ERROR_DS_LOW_ADLDS_FFL: u32 = 8643; +pub const ERROR_DOMAIN_SID_SAME_AS_LOCAL_WORKSTATION: u32 = 8644; +pub const ERROR_DS_UNDELETE_SAM_VALIDATION_FAILED: u32 = 8645; +pub const ERROR_INCORRECT_ACCOUNT_TYPE: u32 = 8646; +pub const ERROR_DS_SPN_VALUE_NOT_UNIQUE_IN_FOREST: u32 = 8647; +pub const ERROR_DS_UPN_VALUE_NOT_UNIQUE_IN_FOREST: u32 = 8648; +pub const ERROR_DS_MISSING_FOREST_TRUST: u32 = 8649; +pub const ERROR_DS_VALUE_KEY_NOT_UNIQUE: u32 = 8650; +pub const ERROR_IPSEC_QM_POLICY_EXISTS: u32 = 13000; +pub const ERROR_IPSEC_QM_POLICY_NOT_FOUND: u32 = 13001; +pub const ERROR_IPSEC_QM_POLICY_IN_USE: u32 = 13002; +pub const ERROR_IPSEC_MM_POLICY_EXISTS: u32 = 13003; +pub const ERROR_IPSEC_MM_POLICY_NOT_FOUND: u32 = 13004; +pub const ERROR_IPSEC_MM_POLICY_IN_USE: u32 = 13005; +pub const ERROR_IPSEC_MM_FILTER_EXISTS: u32 = 13006; +pub const ERROR_IPSEC_MM_FILTER_NOT_FOUND: u32 = 13007; +pub const ERROR_IPSEC_TRANSPORT_FILTER_EXISTS: u32 = 13008; +pub const ERROR_IPSEC_TRANSPORT_FILTER_NOT_FOUND: u32 = 13009; +pub const ERROR_IPSEC_MM_AUTH_EXISTS: u32 = 13010; +pub const ERROR_IPSEC_MM_AUTH_NOT_FOUND: u32 = 13011; +pub const ERROR_IPSEC_MM_AUTH_IN_USE: u32 = 13012; +pub const ERROR_IPSEC_DEFAULT_MM_POLICY_NOT_FOUND: u32 = 13013; +pub const ERROR_IPSEC_DEFAULT_MM_AUTH_NOT_FOUND: u32 = 13014; +pub const ERROR_IPSEC_DEFAULT_QM_POLICY_NOT_FOUND: u32 = 13015; +pub const ERROR_IPSEC_TUNNEL_FILTER_EXISTS: u32 = 13016; +pub const ERROR_IPSEC_TUNNEL_FILTER_NOT_FOUND: u32 = 13017; +pub const ERROR_IPSEC_MM_FILTER_PENDING_DELETION: u32 = 13018; +pub const ERROR_IPSEC_TRANSPORT_FILTER_PENDING_DELETION: u32 = 13019; +pub const ERROR_IPSEC_TUNNEL_FILTER_PENDING_DELETION: u32 = 13020; +pub const ERROR_IPSEC_MM_POLICY_PENDING_DELETION: u32 = 13021; +pub const ERROR_IPSEC_MM_AUTH_PENDING_DELETION: u32 = 13022; +pub const ERROR_IPSEC_QM_POLICY_PENDING_DELETION: u32 = 13023; +pub const ERROR_IPSEC_IKE_NEG_STATUS_BEGIN: u32 = 13800; +pub const ERROR_IPSEC_IKE_AUTH_FAIL: u32 = 13801; +pub const ERROR_IPSEC_IKE_ATTRIB_FAIL: u32 = 13802; +pub const ERROR_IPSEC_IKE_NEGOTIATION_PENDING: u32 = 13803; +pub const ERROR_IPSEC_IKE_GENERAL_PROCESSING_ERROR: u32 = 13804; +pub const ERROR_IPSEC_IKE_TIMED_OUT: u32 = 13805; +pub const ERROR_IPSEC_IKE_NO_CERT: u32 = 13806; +pub const ERROR_IPSEC_IKE_SA_DELETED: u32 = 13807; +pub const ERROR_IPSEC_IKE_SA_REAPED: u32 = 13808; +pub const ERROR_IPSEC_IKE_MM_ACQUIRE_DROP: u32 = 13809; +pub const ERROR_IPSEC_IKE_QM_ACQUIRE_DROP: u32 = 13810; +pub const ERROR_IPSEC_IKE_QUEUE_DROP_MM: u32 = 13811; +pub const ERROR_IPSEC_IKE_QUEUE_DROP_NO_MM: u32 = 13812; +pub const ERROR_IPSEC_IKE_DROP_NO_RESPONSE: u32 = 13813; +pub const ERROR_IPSEC_IKE_MM_DELAY_DROP: u32 = 13814; +pub const ERROR_IPSEC_IKE_QM_DELAY_DROP: u32 = 13815; +pub const ERROR_IPSEC_IKE_ERROR: u32 = 13816; +pub const ERROR_IPSEC_IKE_CRL_FAILED: u32 = 13817; +pub const ERROR_IPSEC_IKE_INVALID_KEY_USAGE: u32 = 13818; +pub const ERROR_IPSEC_IKE_INVALID_CERT_TYPE: u32 = 13819; +pub const ERROR_IPSEC_IKE_NO_PRIVATE_KEY: u32 = 13820; +pub const ERROR_IPSEC_IKE_SIMULTANEOUS_REKEY: u32 = 13821; +pub const ERROR_IPSEC_IKE_DH_FAIL: u32 = 13822; +pub const ERROR_IPSEC_IKE_CRITICAL_PAYLOAD_NOT_RECOGNIZED: u32 = 13823; +pub const ERROR_IPSEC_IKE_INVALID_HEADER: u32 = 13824; +pub const ERROR_IPSEC_IKE_NO_POLICY: u32 = 13825; +pub const ERROR_IPSEC_IKE_INVALID_SIGNATURE: u32 = 13826; +pub const ERROR_IPSEC_IKE_KERBEROS_ERROR: u32 = 13827; +pub const ERROR_IPSEC_IKE_NO_PUBLIC_KEY: u32 = 13828; +pub const ERROR_IPSEC_IKE_PROCESS_ERR: u32 = 13829; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_SA: u32 = 13830; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_PROP: u32 = 13831; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_TRANS: u32 = 13832; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_KE: u32 = 13833; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_ID: u32 = 13834; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_CERT: u32 = 13835; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_CERT_REQ: u32 = 13836; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_HASH: u32 = 13837; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_SIG: u32 = 13838; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_NONCE: u32 = 13839; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_NOTIFY: u32 = 13840; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_DELETE: u32 = 13841; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_VENDOR: u32 = 13842; +pub const ERROR_IPSEC_IKE_INVALID_PAYLOAD: u32 = 13843; +pub const ERROR_IPSEC_IKE_LOAD_SOFT_SA: u32 = 13844; +pub const ERROR_IPSEC_IKE_SOFT_SA_TORN_DOWN: u32 = 13845; +pub const ERROR_IPSEC_IKE_INVALID_COOKIE: u32 = 13846; +pub const ERROR_IPSEC_IKE_NO_PEER_CERT: u32 = 13847; +pub const ERROR_IPSEC_IKE_PEER_CRL_FAILED: u32 = 13848; +pub const ERROR_IPSEC_IKE_POLICY_CHANGE: u32 = 13849; +pub const ERROR_IPSEC_IKE_NO_MM_POLICY: u32 = 13850; +pub const ERROR_IPSEC_IKE_NOTCBPRIV: u32 = 13851; +pub const ERROR_IPSEC_IKE_SECLOADFAIL: u32 = 13852; +pub const ERROR_IPSEC_IKE_FAILSSPINIT: u32 = 13853; +pub const ERROR_IPSEC_IKE_FAILQUERYSSP: u32 = 13854; +pub const ERROR_IPSEC_IKE_SRVACQFAIL: u32 = 13855; +pub const ERROR_IPSEC_IKE_SRVQUERYCRED: u32 = 13856; +pub const ERROR_IPSEC_IKE_GETSPIFAIL: u32 = 13857; +pub const ERROR_IPSEC_IKE_INVALID_FILTER: u32 = 13858; +pub const ERROR_IPSEC_IKE_OUT_OF_MEMORY: u32 = 13859; +pub const ERROR_IPSEC_IKE_ADD_UPDATE_KEY_FAILED: u32 = 13860; +pub const ERROR_IPSEC_IKE_INVALID_POLICY: u32 = 13861; +pub const ERROR_IPSEC_IKE_UNKNOWN_DOI: u32 = 13862; +pub const ERROR_IPSEC_IKE_INVALID_SITUATION: u32 = 13863; +pub const ERROR_IPSEC_IKE_DH_FAILURE: u32 = 13864; +pub const ERROR_IPSEC_IKE_INVALID_GROUP: u32 = 13865; +pub const ERROR_IPSEC_IKE_ENCRYPT: u32 = 13866; +pub const ERROR_IPSEC_IKE_DECRYPT: u32 = 13867; +pub const ERROR_IPSEC_IKE_POLICY_MATCH: u32 = 13868; +pub const ERROR_IPSEC_IKE_UNSUPPORTED_ID: u32 = 13869; +pub const ERROR_IPSEC_IKE_INVALID_HASH: u32 = 13870; +pub const ERROR_IPSEC_IKE_INVALID_HASH_ALG: u32 = 13871; +pub const ERROR_IPSEC_IKE_INVALID_HASH_SIZE: u32 = 13872; +pub const ERROR_IPSEC_IKE_INVALID_ENCRYPT_ALG: u32 = 13873; +pub const ERROR_IPSEC_IKE_INVALID_AUTH_ALG: u32 = 13874; +pub const ERROR_IPSEC_IKE_INVALID_SIG: u32 = 13875; +pub const ERROR_IPSEC_IKE_LOAD_FAILED: u32 = 13876; +pub const ERROR_IPSEC_IKE_RPC_DELETE: u32 = 13877; +pub const ERROR_IPSEC_IKE_BENIGN_REINIT: u32 = 13878; +pub const ERROR_IPSEC_IKE_INVALID_RESPONDER_LIFETIME_NOTIFY: u32 = 13879; +pub const ERROR_IPSEC_IKE_INVALID_MAJOR_VERSION: u32 = 13880; +pub const ERROR_IPSEC_IKE_INVALID_CERT_KEYLEN: u32 = 13881; +pub const ERROR_IPSEC_IKE_MM_LIMIT: u32 = 13882; +pub const ERROR_IPSEC_IKE_NEGOTIATION_DISABLED: u32 = 13883; +pub const ERROR_IPSEC_IKE_QM_LIMIT: u32 = 13884; +pub const ERROR_IPSEC_IKE_MM_EXPIRED: u32 = 13885; +pub const ERROR_IPSEC_IKE_PEER_MM_ASSUMED_INVALID: u32 = 13886; +pub const ERROR_IPSEC_IKE_CERT_CHAIN_POLICY_MISMATCH: u32 = 13887; +pub const ERROR_IPSEC_IKE_UNEXPECTED_MESSAGE_ID: u32 = 13888; +pub const ERROR_IPSEC_IKE_INVALID_AUTH_PAYLOAD: u32 = 13889; +pub const ERROR_IPSEC_IKE_DOS_COOKIE_SENT: u32 = 13890; +pub const ERROR_IPSEC_IKE_SHUTTING_DOWN: u32 = 13891; +pub const ERROR_IPSEC_IKE_CGA_AUTH_FAILED: u32 = 13892; +pub const ERROR_IPSEC_IKE_PROCESS_ERR_NATOA: u32 = 13893; +pub const ERROR_IPSEC_IKE_INVALID_MM_FOR_QM: u32 = 13894; +pub const ERROR_IPSEC_IKE_QM_EXPIRED: u32 = 13895; +pub const ERROR_IPSEC_IKE_TOO_MANY_FILTERS: u32 = 13896; +pub const ERROR_IPSEC_IKE_NEG_STATUS_END: u32 = 13897; +pub const ERROR_IPSEC_IKE_KILL_DUMMY_NAP_TUNNEL: u32 = 13898; +pub const ERROR_IPSEC_IKE_INNER_IP_ASSIGNMENT_FAILURE: u32 = 13899; +pub const ERROR_IPSEC_IKE_REQUIRE_CP_PAYLOAD_MISSING: u32 = 13900; +pub const ERROR_IPSEC_KEY_MODULE_IMPERSONATION_NEGOTIATION_PENDING: u32 = 13901; +pub const ERROR_IPSEC_IKE_COEXISTENCE_SUPPRESS: u32 = 13902; +pub const ERROR_IPSEC_IKE_RATELIMIT_DROP: u32 = 13903; +pub const ERROR_IPSEC_IKE_PEER_DOESNT_SUPPORT_MOBIKE: u32 = 13904; +pub const ERROR_IPSEC_IKE_AUTHORIZATION_FAILURE: u32 = 13905; +pub const ERROR_IPSEC_IKE_STRONG_CRED_AUTHORIZATION_FAILURE: u32 = 13906; +pub const ERROR_IPSEC_IKE_AUTHORIZATION_FAILURE_WITH_OPTIONAL_RETRY: u32 = 13907; +pub const ERROR_IPSEC_IKE_STRONG_CRED_AUTHORIZATION_AND_CERTMAP_FAILURE: u32 = 13908; +pub const ERROR_IPSEC_IKE_NEG_STATUS_EXTENDED_END: u32 = 13909; +pub const ERROR_IPSEC_BAD_SPI: u32 = 13910; +pub const ERROR_IPSEC_SA_LIFETIME_EXPIRED: u32 = 13911; +pub const ERROR_IPSEC_WRONG_SA: u32 = 13912; +pub const ERROR_IPSEC_REPLAY_CHECK_FAILED: u32 = 13913; +pub const ERROR_IPSEC_INVALID_PACKET: u32 = 13914; +pub const ERROR_IPSEC_INTEGRITY_CHECK_FAILED: u32 = 13915; +pub const ERROR_IPSEC_CLEAR_TEXT_DROP: u32 = 13916; +pub const ERROR_IPSEC_AUTH_FIREWALL_DROP: u32 = 13917; +pub const ERROR_IPSEC_THROTTLE_DROP: u32 = 13918; +pub const ERROR_IPSEC_DOSP_BLOCK: u32 = 13925; +pub const ERROR_IPSEC_DOSP_RECEIVED_MULTICAST: u32 = 13926; +pub const ERROR_IPSEC_DOSP_INVALID_PACKET: u32 = 13927; +pub const ERROR_IPSEC_DOSP_STATE_LOOKUP_FAILED: u32 = 13928; +pub const ERROR_IPSEC_DOSP_MAX_ENTRIES: u32 = 13929; +pub const ERROR_IPSEC_DOSP_KEYMOD_NOT_ALLOWED: u32 = 13930; +pub const ERROR_IPSEC_DOSP_NOT_INSTALLED: u32 = 13931; +pub const ERROR_IPSEC_DOSP_MAX_PER_IP_RATELIMIT_QUEUES: u32 = 13932; +pub const ERROR_SXS_SECTION_NOT_FOUND: u32 = 14000; +pub const ERROR_SXS_CANT_GEN_ACTCTX: u32 = 14001; +pub const ERROR_SXS_INVALID_ACTCTXDATA_FORMAT: u32 = 14002; +pub const ERROR_SXS_ASSEMBLY_NOT_FOUND: u32 = 14003; +pub const ERROR_SXS_MANIFEST_FORMAT_ERROR: u32 = 14004; +pub const ERROR_SXS_MANIFEST_PARSE_ERROR: u32 = 14005; +pub const ERROR_SXS_ACTIVATION_CONTEXT_DISABLED: u32 = 14006; +pub const ERROR_SXS_KEY_NOT_FOUND: u32 = 14007; +pub const ERROR_SXS_VERSION_CONFLICT: u32 = 14008; +pub const ERROR_SXS_WRONG_SECTION_TYPE: u32 = 14009; +pub const ERROR_SXS_THREAD_QUERIES_DISABLED: u32 = 14010; +pub const ERROR_SXS_PROCESS_DEFAULT_ALREADY_SET: u32 = 14011; +pub const ERROR_SXS_UNKNOWN_ENCODING_GROUP: u32 = 14012; +pub const ERROR_SXS_UNKNOWN_ENCODING: u32 = 14013; +pub const ERROR_SXS_INVALID_XML_NAMESPACE_URI: u32 = 14014; +pub const ERROR_SXS_ROOT_MANIFEST_DEPENDENCY_NOT_INSTALLED: u32 = 14015; +pub const ERROR_SXS_LEAF_MANIFEST_DEPENDENCY_NOT_INSTALLED: u32 = 14016; +pub const ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE: u32 = 14017; +pub const ERROR_SXS_MANIFEST_MISSING_REQUIRED_DEFAULT_NAMESPACE: u32 = 14018; +pub const ERROR_SXS_MANIFEST_INVALID_REQUIRED_DEFAULT_NAMESPACE: u32 = 14019; +pub const ERROR_SXS_PRIVATE_MANIFEST_CROSS_PATH_WITH_REPARSE_POINT: u32 = 14020; +pub const ERROR_SXS_DUPLICATE_DLL_NAME: u32 = 14021; +pub const ERROR_SXS_DUPLICATE_WINDOWCLASS_NAME: u32 = 14022; +pub const ERROR_SXS_DUPLICATE_CLSID: u32 = 14023; +pub const ERROR_SXS_DUPLICATE_IID: u32 = 14024; +pub const ERROR_SXS_DUPLICATE_TLBID: u32 = 14025; +pub const ERROR_SXS_DUPLICATE_PROGID: u32 = 14026; +pub const ERROR_SXS_DUPLICATE_ASSEMBLY_NAME: u32 = 14027; +pub const ERROR_SXS_FILE_HASH_MISMATCH: u32 = 14028; +pub const ERROR_SXS_POLICY_PARSE_ERROR: u32 = 14029; +pub const ERROR_SXS_XML_E_MISSINGQUOTE: u32 = 14030; +pub const ERROR_SXS_XML_E_COMMENTSYNTAX: u32 = 14031; +pub const ERROR_SXS_XML_E_BADSTARTNAMECHAR: u32 = 14032; +pub const ERROR_SXS_XML_E_BADNAMECHAR: u32 = 14033; +pub const ERROR_SXS_XML_E_BADCHARINSTRING: u32 = 14034; +pub const ERROR_SXS_XML_E_XMLDECLSYNTAX: u32 = 14035; +pub const ERROR_SXS_XML_E_BADCHARDATA: u32 = 14036; +pub const ERROR_SXS_XML_E_MISSINGWHITESPACE: u32 = 14037; +pub const ERROR_SXS_XML_E_EXPECTINGTAGEND: u32 = 14038; +pub const ERROR_SXS_XML_E_MISSINGSEMICOLON: u32 = 14039; +pub const ERROR_SXS_XML_E_UNBALANCEDPAREN: u32 = 14040; +pub const ERROR_SXS_XML_E_INTERNALERROR: u32 = 14041; +pub const ERROR_SXS_XML_E_UNEXPECTED_WHITESPACE: u32 = 14042; +pub const ERROR_SXS_XML_E_INCOMPLETE_ENCODING: u32 = 14043; +pub const ERROR_SXS_XML_E_MISSING_PAREN: u32 = 14044; +pub const ERROR_SXS_XML_E_EXPECTINGCLOSEQUOTE: u32 = 14045; +pub const ERROR_SXS_XML_E_MULTIPLE_COLONS: u32 = 14046; +pub const ERROR_SXS_XML_E_INVALID_DECIMAL: u32 = 14047; +pub const ERROR_SXS_XML_E_INVALID_HEXIDECIMAL: u32 = 14048; +pub const ERROR_SXS_XML_E_INVALID_UNICODE: u32 = 14049; +pub const ERROR_SXS_XML_E_WHITESPACEORQUESTIONMARK: u32 = 14050; +pub const ERROR_SXS_XML_E_UNEXPECTEDENDTAG: u32 = 14051; +pub const ERROR_SXS_XML_E_UNCLOSEDTAG: u32 = 14052; +pub const ERROR_SXS_XML_E_DUPLICATEATTRIBUTE: u32 = 14053; +pub const ERROR_SXS_XML_E_MULTIPLEROOTS: u32 = 14054; +pub const ERROR_SXS_XML_E_INVALIDATROOTLEVEL: u32 = 14055; +pub const ERROR_SXS_XML_E_BADXMLDECL: u32 = 14056; +pub const ERROR_SXS_XML_E_MISSINGROOT: u32 = 14057; +pub const ERROR_SXS_XML_E_UNEXPECTEDEOF: u32 = 14058; +pub const ERROR_SXS_XML_E_BADPEREFINSUBSET: u32 = 14059; +pub const ERROR_SXS_XML_E_UNCLOSEDSTARTTAG: u32 = 14060; +pub const ERROR_SXS_XML_E_UNCLOSEDENDTAG: u32 = 14061; +pub const ERROR_SXS_XML_E_UNCLOSEDSTRING: u32 = 14062; +pub const ERROR_SXS_XML_E_UNCLOSEDCOMMENT: u32 = 14063; +pub const ERROR_SXS_XML_E_UNCLOSEDDECL: u32 = 14064; +pub const ERROR_SXS_XML_E_UNCLOSEDCDATA: u32 = 14065; +pub const ERROR_SXS_XML_E_RESERVEDNAMESPACE: u32 = 14066; +pub const ERROR_SXS_XML_E_INVALIDENCODING: u32 = 14067; +pub const ERROR_SXS_XML_E_INVALIDSWITCH: u32 = 14068; +pub const ERROR_SXS_XML_E_BADXMLCASE: u32 = 14069; +pub const ERROR_SXS_XML_E_INVALID_STANDALONE: u32 = 14070; +pub const ERROR_SXS_XML_E_UNEXPECTED_STANDALONE: u32 = 14071; +pub const ERROR_SXS_XML_E_INVALID_VERSION: u32 = 14072; +pub const ERROR_SXS_XML_E_MISSINGEQUALS: u32 = 14073; +pub const ERROR_SXS_PROTECTION_RECOVERY_FAILED: u32 = 14074; +pub const ERROR_SXS_PROTECTION_PUBLIC_KEY_TOO_SHORT: u32 = 14075; +pub const ERROR_SXS_PROTECTION_CATALOG_NOT_VALID: u32 = 14076; +pub const ERROR_SXS_UNTRANSLATABLE_HRESULT: u32 = 14077; +pub const ERROR_SXS_PROTECTION_CATALOG_FILE_MISSING: u32 = 14078; +pub const ERROR_SXS_MISSING_ASSEMBLY_IDENTITY_ATTRIBUTE: u32 = 14079; +pub const ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE_NAME: u32 = 14080; +pub const ERROR_SXS_ASSEMBLY_MISSING: u32 = 14081; +pub const ERROR_SXS_CORRUPT_ACTIVATION_STACK: u32 = 14082; +pub const ERROR_SXS_CORRUPTION: u32 = 14083; +pub const ERROR_SXS_EARLY_DEACTIVATION: u32 = 14084; +pub const ERROR_SXS_INVALID_DEACTIVATION: u32 = 14085; +pub const ERROR_SXS_MULTIPLE_DEACTIVATION: u32 = 14086; +pub const ERROR_SXS_PROCESS_TERMINATION_REQUESTED: u32 = 14087; +pub const ERROR_SXS_RELEASE_ACTIVATION_CONTEXT: u32 = 14088; +pub const ERROR_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT_EMPTY: u32 = 14089; +pub const ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_VALUE: u32 = 14090; +pub const ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_NAME: u32 = 14091; +pub const ERROR_SXS_IDENTITY_DUPLICATE_ATTRIBUTE: u32 = 14092; +pub const ERROR_SXS_IDENTITY_PARSE_ERROR: u32 = 14093; +pub const ERROR_MALFORMED_SUBSTITUTION_STRING: u32 = 14094; +pub const ERROR_SXS_INCORRECT_PUBLIC_KEY_TOKEN: u32 = 14095; +pub const ERROR_UNMAPPED_SUBSTITUTION_STRING: u32 = 14096; +pub const ERROR_SXS_ASSEMBLY_NOT_LOCKED: u32 = 14097; +pub const ERROR_SXS_COMPONENT_STORE_CORRUPT: u32 = 14098; +pub const ERROR_ADVANCED_INSTALLER_FAILED: u32 = 14099; +pub const ERROR_XML_ENCODING_MISMATCH: u32 = 14100; +pub const ERROR_SXS_MANIFEST_IDENTITY_SAME_BUT_CONTENTS_DIFFERENT: u32 = 14101; +pub const ERROR_SXS_IDENTITIES_DIFFERENT: u32 = 14102; +pub const ERROR_SXS_ASSEMBLY_IS_NOT_A_DEPLOYMENT: u32 = 14103; +pub const ERROR_SXS_FILE_NOT_PART_OF_ASSEMBLY: u32 = 14104; +pub const ERROR_SXS_MANIFEST_TOO_BIG: u32 = 14105; +pub const ERROR_SXS_SETTING_NOT_REGISTERED: u32 = 14106; +pub const ERROR_SXS_TRANSACTION_CLOSURE_INCOMPLETE: u32 = 14107; +pub const ERROR_SMI_PRIMITIVE_INSTALLER_FAILED: u32 = 14108; +pub const ERROR_GENERIC_COMMAND_FAILED: u32 = 14109; +pub const ERROR_SXS_FILE_HASH_MISSING: u32 = 14110; +pub const ERROR_SXS_DUPLICATE_ACTIVATABLE_CLASS: u32 = 14111; +pub const ERROR_EVT_INVALID_CHANNEL_PATH: u32 = 15000; +pub const ERROR_EVT_INVALID_QUERY: u32 = 15001; +pub const ERROR_EVT_PUBLISHER_METADATA_NOT_FOUND: u32 = 15002; +pub const ERROR_EVT_EVENT_TEMPLATE_NOT_FOUND: u32 = 15003; +pub const ERROR_EVT_INVALID_PUBLISHER_NAME: u32 = 15004; +pub const ERROR_EVT_INVALID_EVENT_DATA: u32 = 15005; +pub const ERROR_EVT_CHANNEL_NOT_FOUND: u32 = 15007; +pub const ERROR_EVT_MALFORMED_XML_TEXT: u32 = 15008; +pub const ERROR_EVT_SUBSCRIPTION_TO_DIRECT_CHANNEL: u32 = 15009; +pub const ERROR_EVT_CONFIGURATION_ERROR: u32 = 15010; +pub const ERROR_EVT_QUERY_RESULT_STALE: u32 = 15011; +pub const ERROR_EVT_QUERY_RESULT_INVALID_POSITION: u32 = 15012; +pub const ERROR_EVT_NON_VALIDATING_MSXML: u32 = 15013; +pub const ERROR_EVT_FILTER_ALREADYSCOPED: u32 = 15014; +pub const ERROR_EVT_FILTER_NOTELTSET: u32 = 15015; +pub const ERROR_EVT_FILTER_INVARG: u32 = 15016; +pub const ERROR_EVT_FILTER_INVTEST: u32 = 15017; +pub const ERROR_EVT_FILTER_INVTYPE: u32 = 15018; +pub const ERROR_EVT_FILTER_PARSEERR: u32 = 15019; +pub const ERROR_EVT_FILTER_UNSUPPORTEDOP: u32 = 15020; +pub const ERROR_EVT_FILTER_UNEXPECTEDTOKEN: u32 = 15021; +pub const ERROR_EVT_INVALID_OPERATION_OVER_ENABLED_DIRECT_CHANNEL: u32 = 15022; +pub const ERROR_EVT_INVALID_CHANNEL_PROPERTY_VALUE: u32 = 15023; +pub const ERROR_EVT_INVALID_PUBLISHER_PROPERTY_VALUE: u32 = 15024; +pub const ERROR_EVT_CHANNEL_CANNOT_ACTIVATE: u32 = 15025; +pub const ERROR_EVT_FILTER_TOO_COMPLEX: u32 = 15026; +pub const ERROR_EVT_MESSAGE_NOT_FOUND: u32 = 15027; +pub const ERROR_EVT_MESSAGE_ID_NOT_FOUND: u32 = 15028; +pub const ERROR_EVT_UNRESOLVED_VALUE_INSERT: u32 = 15029; +pub const ERROR_EVT_UNRESOLVED_PARAMETER_INSERT: u32 = 15030; +pub const ERROR_EVT_MAX_INSERTS_REACHED: u32 = 15031; +pub const ERROR_EVT_EVENT_DEFINITION_NOT_FOUND: u32 = 15032; +pub const ERROR_EVT_MESSAGE_LOCALE_NOT_FOUND: u32 = 15033; +pub const ERROR_EVT_VERSION_TOO_OLD: u32 = 15034; +pub const ERROR_EVT_VERSION_TOO_NEW: u32 = 15035; +pub const ERROR_EVT_CANNOT_OPEN_CHANNEL_OF_QUERY: u32 = 15036; +pub const ERROR_EVT_PUBLISHER_DISABLED: u32 = 15037; +pub const ERROR_EVT_FILTER_OUT_OF_RANGE: u32 = 15038; +pub const ERROR_EC_SUBSCRIPTION_CANNOT_ACTIVATE: u32 = 15080; +pub const ERROR_EC_LOG_DISABLED: u32 = 15081; +pub const ERROR_EC_CIRCULAR_FORWARDING: u32 = 15082; +pub const ERROR_EC_CREDSTORE_FULL: u32 = 15083; +pub const ERROR_EC_CRED_NOT_FOUND: u32 = 15084; +pub const ERROR_EC_NO_ACTIVE_CHANNEL: u32 = 15085; +pub const ERROR_MUI_FILE_NOT_FOUND: u32 = 15100; +pub const ERROR_MUI_INVALID_FILE: u32 = 15101; +pub const ERROR_MUI_INVALID_RC_CONFIG: u32 = 15102; +pub const ERROR_MUI_INVALID_LOCALE_NAME: u32 = 15103; +pub const ERROR_MUI_INVALID_ULTIMATEFALLBACK_NAME: u32 = 15104; +pub const ERROR_MUI_FILE_NOT_LOADED: u32 = 15105; +pub const ERROR_RESOURCE_ENUM_USER_STOP: u32 = 15106; +pub const ERROR_MUI_INTLSETTINGS_UILANG_NOT_INSTALLED: u32 = 15107; +pub const ERROR_MUI_INTLSETTINGS_INVALID_LOCALE_NAME: u32 = 15108; +pub const ERROR_MRM_RUNTIME_NO_DEFAULT_OR_NEUTRAL_RESOURCE: u32 = 15110; +pub const ERROR_MRM_INVALID_PRICONFIG: u32 = 15111; +pub const ERROR_MRM_INVALID_FILE_TYPE: u32 = 15112; +pub const ERROR_MRM_UNKNOWN_QUALIFIER: u32 = 15113; +pub const ERROR_MRM_INVALID_QUALIFIER_VALUE: u32 = 15114; +pub const ERROR_MRM_NO_CANDIDATE: u32 = 15115; +pub const ERROR_MRM_NO_MATCH_OR_DEFAULT_CANDIDATE: u32 = 15116; +pub const ERROR_MRM_RESOURCE_TYPE_MISMATCH: u32 = 15117; +pub const ERROR_MRM_DUPLICATE_MAP_NAME: u32 = 15118; +pub const ERROR_MRM_DUPLICATE_ENTRY: u32 = 15119; +pub const ERROR_MRM_INVALID_RESOURCE_IDENTIFIER: u32 = 15120; +pub const ERROR_MRM_FILEPATH_TOO_LONG: u32 = 15121; +pub const ERROR_MRM_UNSUPPORTED_DIRECTORY_TYPE: u32 = 15122; +pub const ERROR_MRM_INVALID_PRI_FILE: u32 = 15126; +pub const ERROR_MRM_NAMED_RESOURCE_NOT_FOUND: u32 = 15127; +pub const ERROR_MRM_MAP_NOT_FOUND: u32 = 15135; +pub const ERROR_MRM_UNSUPPORTED_PROFILE_TYPE: u32 = 15136; +pub const ERROR_MRM_INVALID_QUALIFIER_OPERATOR: u32 = 15137; +pub const ERROR_MRM_INDETERMINATE_QUALIFIER_VALUE: u32 = 15138; +pub const ERROR_MRM_AUTOMERGE_ENABLED: u32 = 15139; +pub const ERROR_MRM_TOO_MANY_RESOURCES: u32 = 15140; +pub const ERROR_MRM_UNSUPPORTED_FILE_TYPE_FOR_MERGE: u32 = 15141; +pub const ERROR_MRM_UNSUPPORTED_FILE_TYPE_FOR_LOAD_UNLOAD_PRI_FILE: u32 = 15142; +pub const ERROR_MRM_NO_CURRENT_VIEW_ON_THREAD: u32 = 15143; +pub const ERROR_DIFFERENT_PROFILE_RESOURCE_MANAGER_EXIST: u32 = 15144; +pub const ERROR_OPERATION_NOT_ALLOWED_FROM_SYSTEM_COMPONENT: u32 = 15145; +pub const ERROR_MRM_DIRECT_REF_TO_NON_DEFAULT_RESOURCE: u32 = 15146; +pub const ERROR_MRM_GENERATION_COUNT_MISMATCH: u32 = 15147; +pub const ERROR_PRI_MERGE_VERSION_MISMATCH: u32 = 15148; +pub const ERROR_PRI_MERGE_MISSING_SCHEMA: u32 = 15149; +pub const ERROR_PRI_MERGE_LOAD_FILE_FAILED: u32 = 15150; +pub const ERROR_PRI_MERGE_ADD_FILE_FAILED: u32 = 15151; +pub const ERROR_PRI_MERGE_WRITE_FILE_FAILED: u32 = 15152; +pub const ERROR_PRI_MERGE_MULTIPLE_PACKAGE_FAMILIES_NOT_ALLOWED: u32 = 15153; +pub const ERROR_PRI_MERGE_MULTIPLE_MAIN_PACKAGES_NOT_ALLOWED: u32 = 15154; +pub const ERROR_PRI_MERGE_BUNDLE_PACKAGES_NOT_ALLOWED: u32 = 15155; +pub const ERROR_PRI_MERGE_MAIN_PACKAGE_REQUIRED: u32 = 15156; +pub const ERROR_PRI_MERGE_RESOURCE_PACKAGE_REQUIRED: u32 = 15157; +pub const ERROR_PRI_MERGE_INVALID_FILE_NAME: u32 = 15158; +pub const ERROR_MRM_PACKAGE_NOT_FOUND: u32 = 15159; +pub const ERROR_MRM_MISSING_DEFAULT_LANGUAGE: u32 = 15160; +pub const ERROR_MCA_INVALID_CAPABILITIES_STRING: u32 = 15200; +pub const ERROR_MCA_INVALID_VCP_VERSION: u32 = 15201; +pub const ERROR_MCA_MONITOR_VIOLATES_MCCS_SPECIFICATION: u32 = 15202; +pub const ERROR_MCA_MCCS_VERSION_MISMATCH: u32 = 15203; +pub const ERROR_MCA_UNSUPPORTED_MCCS_VERSION: u32 = 15204; +pub const ERROR_MCA_INTERNAL_ERROR: u32 = 15205; +pub const ERROR_MCA_INVALID_TECHNOLOGY_TYPE_RETURNED: u32 = 15206; +pub const ERROR_MCA_UNSUPPORTED_COLOR_TEMPERATURE: u32 = 15207; +pub const ERROR_AMBIGUOUS_SYSTEM_DEVICE: u32 = 15250; +pub const ERROR_SYSTEM_DEVICE_NOT_FOUND: u32 = 15299; +pub const ERROR_HASH_NOT_SUPPORTED: u32 = 15300; +pub const ERROR_HASH_NOT_PRESENT: u32 = 15301; +pub const ERROR_SECONDARY_IC_PROVIDER_NOT_REGISTERED: u32 = 15321; +pub const ERROR_GPIO_CLIENT_INFORMATION_INVALID: u32 = 15322; +pub const ERROR_GPIO_VERSION_NOT_SUPPORTED: u32 = 15323; +pub const ERROR_GPIO_INVALID_REGISTRATION_PACKET: u32 = 15324; +pub const ERROR_GPIO_OPERATION_DENIED: u32 = 15325; +pub const ERROR_GPIO_INCOMPATIBLE_CONNECT_MODE: u32 = 15326; +pub const ERROR_GPIO_INTERRUPT_ALREADY_UNMASKED: u32 = 15327; +pub const ERROR_CANNOT_SWITCH_RUNLEVEL: u32 = 15400; +pub const ERROR_INVALID_RUNLEVEL_SETTING: u32 = 15401; +pub const ERROR_RUNLEVEL_SWITCH_TIMEOUT: u32 = 15402; +pub const ERROR_RUNLEVEL_SWITCH_AGENT_TIMEOUT: u32 = 15403; +pub const ERROR_RUNLEVEL_SWITCH_IN_PROGRESS: u32 = 15404; +pub const ERROR_SERVICES_FAILED_AUTOSTART: u32 = 15405; +pub const ERROR_COM_TASK_STOP_PENDING: u32 = 15501; +pub const ERROR_INSTALL_OPEN_PACKAGE_FAILED: u32 = 15600; +pub const ERROR_INSTALL_PACKAGE_NOT_FOUND: u32 = 15601; +pub const ERROR_INSTALL_INVALID_PACKAGE: u32 = 15602; +pub const ERROR_INSTALL_RESOLVE_DEPENDENCY_FAILED: u32 = 15603; +pub const ERROR_INSTALL_OUT_OF_DISK_SPACE: u32 = 15604; +pub const ERROR_INSTALL_NETWORK_FAILURE: u32 = 15605; +pub const ERROR_INSTALL_REGISTRATION_FAILURE: u32 = 15606; +pub const ERROR_INSTALL_DEREGISTRATION_FAILURE: u32 = 15607; +pub const ERROR_INSTALL_CANCEL: u32 = 15608; +pub const ERROR_INSTALL_FAILED: u32 = 15609; +pub const ERROR_REMOVE_FAILED: u32 = 15610; +pub const ERROR_PACKAGE_ALREADY_EXISTS: u32 = 15611; +pub const ERROR_NEEDS_REMEDIATION: u32 = 15612; +pub const ERROR_INSTALL_PREREQUISITE_FAILED: u32 = 15613; +pub const ERROR_PACKAGE_REPOSITORY_CORRUPTED: u32 = 15614; +pub const ERROR_INSTALL_POLICY_FAILURE: u32 = 15615; +pub const ERROR_PACKAGE_UPDATING: u32 = 15616; +pub const ERROR_DEPLOYMENT_BLOCKED_BY_POLICY: u32 = 15617; +pub const ERROR_PACKAGES_IN_USE: u32 = 15618; +pub const ERROR_RECOVERY_FILE_CORRUPT: u32 = 15619; +pub const ERROR_INVALID_STAGED_SIGNATURE: u32 = 15620; +pub const ERROR_DELETING_EXISTING_APPLICATIONDATA_STORE_FAILED: u32 = 15621; +pub const ERROR_INSTALL_PACKAGE_DOWNGRADE: u32 = 15622; +pub const ERROR_SYSTEM_NEEDS_REMEDIATION: u32 = 15623; +pub const ERROR_APPX_INTEGRITY_FAILURE_CLR_NGEN: u32 = 15624; +pub const ERROR_RESILIENCY_FILE_CORRUPT: u32 = 15625; +pub const ERROR_INSTALL_FIREWALL_SERVICE_NOT_RUNNING: u32 = 15626; +pub const ERROR_PACKAGE_MOVE_FAILED: u32 = 15627; +pub const ERROR_INSTALL_VOLUME_NOT_EMPTY: u32 = 15628; +pub const ERROR_INSTALL_VOLUME_OFFLINE: u32 = 15629; +pub const ERROR_INSTALL_VOLUME_CORRUPT: u32 = 15630; +pub const ERROR_NEEDS_REGISTRATION: u32 = 15631; +pub const ERROR_INSTALL_WRONG_PROCESSOR_ARCHITECTURE: u32 = 15632; +pub const ERROR_DEV_SIDELOAD_LIMIT_EXCEEDED: u32 = 15633; +pub const ERROR_INSTALL_OPTIONAL_PACKAGE_REQUIRES_MAIN_PACKAGE: u32 = 15634; +pub const ERROR_PACKAGE_NOT_SUPPORTED_ON_FILESYSTEM: u32 = 15635; +pub const ERROR_PACKAGE_MOVE_BLOCKED_BY_STREAMING: u32 = 15636; +pub const ERROR_INSTALL_OPTIONAL_PACKAGE_APPLICATIONID_NOT_UNIQUE: u32 = 15637; +pub const ERROR_PACKAGE_STAGING_ONHOLD: u32 = 15638; +pub const ERROR_INSTALL_INVALID_RELATED_SET_UPDATE: u32 = 15639; +pub const ERROR_INSTALL_OPTIONAL_PACKAGE_REQUIRES_MAIN_PACKAGE_FULLTRUST_CAPABILITY: u32 = 15640; +pub const ERROR_DEPLOYMENT_BLOCKED_BY_USER_LOG_OFF: u32 = 15641; +pub const ERROR_PROVISION_OPTIONAL_PACKAGE_REQUIRES_MAIN_PACKAGE_PROVISIONED: u32 = 15642; +pub const ERROR_PACKAGES_REPUTATION_CHECK_FAILED: u32 = 15643; +pub const ERROR_PACKAGES_REPUTATION_CHECK_TIMEDOUT: u32 = 15644; +pub const ERROR_DEPLOYMENT_OPTION_NOT_SUPPORTED: u32 = 15645; +pub const ERROR_APPINSTALLER_ACTIVATION_BLOCKED: u32 = 15646; +pub const ERROR_REGISTRATION_FROM_REMOTE_DRIVE_NOT_SUPPORTED: u32 = 15647; +pub const ERROR_APPX_RAW_DATA_WRITE_FAILED: u32 = 15648; +pub const ERROR_DEPLOYMENT_BLOCKED_BY_VOLUME_POLICY_PACKAGE: u32 = 15649; +pub const ERROR_DEPLOYMENT_BLOCKED_BY_VOLUME_POLICY_MACHINE: u32 = 15650; +pub const ERROR_DEPLOYMENT_BLOCKED_BY_PROFILE_POLICY: u32 = 15651; +pub const ERROR_DEPLOYMENT_FAILED_CONFLICTING_MUTABLE_PACKAGE_DIRECTORY: u32 = 15652; +pub const ERROR_SINGLETON_RESOURCE_INSTALLED_IN_ACTIVE_USER: u32 = 15653; +pub const ERROR_DIFFERENT_VERSION_OF_PACKAGED_SERVICE_INSTALLED: u32 = 15654; +pub const ERROR_SERVICE_EXISTS_AS_NON_PACKAGED_SERVICE: u32 = 15655; +pub const ERROR_PACKAGED_SERVICE_REQUIRES_ADMIN_PRIVILEGES: u32 = 15656; +pub const ERROR_STATE_LOAD_STORE_FAILED: u32 = 15800; +pub const ERROR_STATE_GET_VERSION_FAILED: u32 = 15801; +pub const ERROR_STATE_SET_VERSION_FAILED: u32 = 15802; +pub const ERROR_STATE_STRUCTURED_RESET_FAILED: u32 = 15803; +pub const ERROR_STATE_OPEN_CONTAINER_FAILED: u32 = 15804; +pub const ERROR_STATE_CREATE_CONTAINER_FAILED: u32 = 15805; +pub const ERROR_STATE_DELETE_CONTAINER_FAILED: u32 = 15806; +pub const ERROR_STATE_READ_SETTING_FAILED: u32 = 15807; +pub const ERROR_STATE_WRITE_SETTING_FAILED: u32 = 15808; +pub const ERROR_STATE_DELETE_SETTING_FAILED: u32 = 15809; +pub const ERROR_STATE_QUERY_SETTING_FAILED: u32 = 15810; +pub const ERROR_STATE_READ_COMPOSITE_SETTING_FAILED: u32 = 15811; +pub const ERROR_STATE_WRITE_COMPOSITE_SETTING_FAILED: u32 = 15812; +pub const ERROR_STATE_ENUMERATE_CONTAINER_FAILED: u32 = 15813; +pub const ERROR_STATE_ENUMERATE_SETTINGS_FAILED: u32 = 15814; +pub const ERROR_STATE_COMPOSITE_SETTING_VALUE_SIZE_LIMIT_EXCEEDED: u32 = 15815; +pub const ERROR_STATE_SETTING_VALUE_SIZE_LIMIT_EXCEEDED: u32 = 15816; +pub const ERROR_STATE_SETTING_NAME_SIZE_LIMIT_EXCEEDED: u32 = 15817; +pub const ERROR_STATE_CONTAINER_NAME_SIZE_LIMIT_EXCEEDED: u32 = 15818; +pub const ERROR_API_UNAVAILABLE: u32 = 15841; +pub const ERROR_LABEL_UNREADABLE: u32 = 1; +pub const ERROR_LABEL_QUESTIONABLE: u32 = 2; +pub const ERROR_SLOT_NOT_PRESENT: u32 = 4; +pub const ERROR_DRIVE_NOT_INSTALLED: u32 = 8; +pub const ERROR_TRAY_MALFUNCTION: u32 = 16; +pub const ERROR_INIT_STATUS_NEEDED: u32 = 17; +pub const ERROR_UNHANDLED_ERROR: u32 = 4294967295; +pub const ERROR_BIDI_STATUS_OK: u32 = 0; +pub const ERROR_BIDI_NOT_SUPPORTED: u32 = 50; +pub const ERROR_BIDI_ERROR_BASE: u32 = 13000; +pub const ERROR_BIDI_STATUS_WARNING: u32 = 13001; +pub const ERROR_BIDI_SCHEMA_READ_ONLY: u32 = 13002; +pub const ERROR_BIDI_SERVER_OFFLINE: u32 = 13003; +pub const ERROR_BIDI_DEVICE_OFFLINE: u32 = 13004; +pub const ERROR_BIDI_SCHEMA_NOT_SUPPORTED: u32 = 13005; +pub const ERROR_BIDI_SET_DIFFERENT_TYPE: u32 = 13006; +pub const ERROR_BIDI_SET_MULTIPLE_SCHEMAPATH: u32 = 13007; +pub const ERROR_BIDI_SET_INVALID_SCHEMAPATH: u32 = 13008; +pub const ERROR_BIDI_SET_UNKNOWN_FAILURE: u32 = 13009; +pub const ERROR_BIDI_SCHEMA_WRITE_ONLY: u32 = 13010; +pub const ERROR_BIDI_GET_REQUIRES_ARGUMENT: u32 = 13011; +pub const ERROR_BIDI_GET_ARGUMENT_NOT_SUPPORTED: u32 = 13012; +pub const ERROR_BIDI_GET_MISSING_ARGUMENT: u32 = 13013; +pub const ERROR_BIDI_DEVICE_CONFIG_UNCHANGED: u32 = 13014; +pub const ERROR_BIDI_NO_LOCALIZED_RESOURCES: u32 = 13015; +pub const ERROR_BIDI_NO_BIDI_SCHEMA_EXTENSIONS: u32 = 13016; +pub const ERROR_BIDI_UNSUPPORTED_CLIENT_LANGUAGE: u32 = 13017; +pub const ERROR_BIDI_UNSUPPORTED_RESOURCE_FORMAT: u32 = 13018; +pub const ERROR_INTERNET_OUT_OF_HANDLES: u32 = 12001; +pub const ERROR_INTERNET_TIMEOUT: u32 = 12002; +pub const ERROR_INTERNET_EXTENDED_ERROR: u32 = 12003; +pub const ERROR_INTERNET_INTERNAL_ERROR: u32 = 12004; +pub const ERROR_INTERNET_INVALID_URL: u32 = 12005; +pub const ERROR_INTERNET_UNRECOGNIZED_SCHEME: u32 = 12006; +pub const ERROR_INTERNET_NAME_NOT_RESOLVED: u32 = 12007; +pub const ERROR_INTERNET_PROTOCOL_NOT_FOUND: u32 = 12008; +pub const ERROR_INTERNET_INVALID_OPTION: u32 = 12009; +pub const ERROR_INTERNET_BAD_OPTION_LENGTH: u32 = 12010; +pub const ERROR_INTERNET_OPTION_NOT_SETTABLE: u32 = 12011; +pub const ERROR_INTERNET_SHUTDOWN: u32 = 12012; +pub const ERROR_INTERNET_INCORRECT_USER_NAME: u32 = 12013; +pub const ERROR_INTERNET_INCORRECT_PASSWORD: u32 = 12014; +pub const ERROR_INTERNET_LOGIN_FAILURE: u32 = 12015; +pub const ERROR_INTERNET_INVALID_OPERATION: u32 = 12016; +pub const ERROR_INTERNET_OPERATION_CANCELLED: u32 = 12017; +pub const ERROR_INTERNET_INCORRECT_HANDLE_TYPE: u32 = 12018; +pub const ERROR_INTERNET_INCORRECT_HANDLE_STATE: u32 = 12019; +pub const ERROR_INTERNET_NOT_PROXY_REQUEST: u32 = 12020; +pub const ERROR_INTERNET_REGISTRY_VALUE_NOT_FOUND: u32 = 12021; +pub const ERROR_INTERNET_BAD_REGISTRY_PARAMETER: u32 = 12022; +pub const ERROR_INTERNET_NO_DIRECT_ACCESS: u32 = 12023; +pub const ERROR_INTERNET_NO_CONTEXT: u32 = 12024; +pub const ERROR_INTERNET_NO_CALLBACK: u32 = 12025; +pub const ERROR_INTERNET_REQUEST_PENDING: u32 = 12026; +pub const ERROR_INTERNET_INCORRECT_FORMAT: u32 = 12027; +pub const ERROR_INTERNET_ITEM_NOT_FOUND: u32 = 12028; +pub const ERROR_INTERNET_CANNOT_CONNECT: u32 = 12029; +pub const ERROR_INTERNET_CONNECTION_ABORTED: u32 = 12030; +pub const ERROR_INTERNET_CONNECTION_RESET: u32 = 12031; +pub const ERROR_INTERNET_FORCE_RETRY: u32 = 12032; +pub const ERROR_INTERNET_INVALID_PROXY_REQUEST: u32 = 12033; +pub const ERROR_INTERNET_NEED_UI: u32 = 12034; +pub const ERROR_INTERNET_HANDLE_EXISTS: u32 = 12036; +pub const ERROR_INTERNET_SEC_CERT_DATE_INVALID: u32 = 12037; +pub const ERROR_INTERNET_SEC_CERT_CN_INVALID: u32 = 12038; +pub const ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR: u32 = 12039; +pub const ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR: u32 = 12040; +pub const ERROR_INTERNET_MIXED_SECURITY: u32 = 12041; +pub const ERROR_INTERNET_CHG_POST_IS_NON_SECURE: u32 = 12042; +pub const ERROR_INTERNET_POST_IS_NON_SECURE: u32 = 12043; +pub const ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED: u32 = 12044; +pub const ERROR_INTERNET_INVALID_CA: u32 = 12045; +pub const ERROR_INTERNET_CLIENT_AUTH_NOT_SETUP: u32 = 12046; +pub const ERROR_INTERNET_ASYNC_THREAD_FAILED: u32 = 12047; +pub const ERROR_INTERNET_REDIRECT_SCHEME_CHANGE: u32 = 12048; +pub const ERROR_INTERNET_DIALOG_PENDING: u32 = 12049; +pub const ERROR_INTERNET_RETRY_DIALOG: u32 = 12050; +pub const ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR: u32 = 12052; +pub const ERROR_INTERNET_INSERT_CDROM: u32 = 12053; +pub const ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED: u32 = 12054; +pub const ERROR_INTERNET_SEC_CERT_ERRORS: u32 = 12055; +pub const ERROR_INTERNET_SEC_CERT_NO_REV: u32 = 12056; +pub const ERROR_INTERNET_SEC_CERT_REV_FAILED: u32 = 12057; +pub const ERROR_HTTP_HSTS_REDIRECT_REQUIRED: u32 = 12060; +pub const ERROR_INTERNET_SEC_CERT_WEAK_SIGNATURE: u32 = 12062; +pub const ERROR_FTP_TRANSFER_IN_PROGRESS: u32 = 12110; +pub const ERROR_FTP_DROPPED: u32 = 12111; +pub const ERROR_FTP_NO_PASSIVE_MODE: u32 = 12112; +pub const ERROR_GOPHER_PROTOCOL_ERROR: u32 = 12130; +pub const ERROR_GOPHER_NOT_FILE: u32 = 12131; +pub const ERROR_GOPHER_DATA_ERROR: u32 = 12132; +pub const ERROR_GOPHER_END_OF_DATA: u32 = 12133; +pub const ERROR_GOPHER_INVALID_LOCATOR: u32 = 12134; +pub const ERROR_GOPHER_INCORRECT_LOCATOR_TYPE: u32 = 12135; +pub const ERROR_GOPHER_NOT_GOPHER_PLUS: u32 = 12136; +pub const ERROR_GOPHER_ATTRIBUTE_NOT_FOUND: u32 = 12137; +pub const ERROR_GOPHER_UNKNOWN_LOCATOR: u32 = 12138; +pub const ERROR_HTTP_HEADER_NOT_FOUND: u32 = 12150; +pub const ERROR_HTTP_DOWNLEVEL_SERVER: u32 = 12151; +pub const ERROR_HTTP_INVALID_SERVER_RESPONSE: u32 = 12152; +pub const ERROR_HTTP_INVALID_HEADER: u32 = 12153; +pub const ERROR_HTTP_INVALID_QUERY_REQUEST: u32 = 12154; +pub const ERROR_HTTP_HEADER_ALREADY_EXISTS: u32 = 12155; +pub const ERROR_HTTP_REDIRECT_FAILED: u32 = 12156; +pub const ERROR_HTTP_NOT_REDIRECTED: u32 = 12160; +pub const ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION: u32 = 12161; +pub const ERROR_HTTP_COOKIE_DECLINED: u32 = 12162; +pub const ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION: u32 = 12168; +pub const ERROR_INTERNET_SECURITY_CHANNEL_ERROR: u32 = 12157; +pub const ERROR_INTERNET_UNABLE_TO_CACHE_FILE: u32 = 12158; +pub const ERROR_INTERNET_TCPIP_NOT_INSTALLED: u32 = 12159; +pub const ERROR_INTERNET_DISCONNECTED: u32 = 12163; +pub const ERROR_INTERNET_SERVER_UNREACHABLE: u32 = 12164; +pub const ERROR_INTERNET_PROXY_SERVER_UNREACHABLE: u32 = 12165; +pub const ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT: u32 = 12166; +pub const ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT: u32 = 12167; +pub const ERROR_INTERNET_SEC_INVALID_CERT: u32 = 12169; +pub const ERROR_INTERNET_SEC_CERT_REVOKED: u32 = 12170; +pub const ERROR_INTERNET_FAILED_DUETOSECURITYCHECK: u32 = 12171; +pub const ERROR_INTERNET_NOT_INITIALIZED: u32 = 12172; +pub const ERROR_INTERNET_NEED_MSN_SSPI_PKG: u32 = 12173; +pub const ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY: u32 = 12174; +pub const ERROR_INTERNET_DECODING_FAILED: u32 = 12175; +pub const ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED_PROXY: u32 = 12187; +pub const ERROR_INTERNET_SECURE_FAILURE_PROXY: u32 = 12188; +pub const ERROR_INTERNET_HTTP_PROTOCOL_MISMATCH: u32 = 12190; +pub const STORMLIB_VERSION: u32 = 2326; +pub const STORMLIB_VERSION_STRING: &'static [u8; 5usize] = b"9.22\0"; +pub const ID_MPQ: u32 = 441536589; +pub const ID_MPQ_USERDATA: u32 = 458313805; +pub const ID_MPK: u32 = 441143373; +pub const ERROR_AVI_FILE: u32 = 10000; +pub const ERROR_UNKNOWN_FILE_KEY: u32 = 10001; +pub const ERROR_CHECKSUM_ERROR: u32 = 10002; +pub const ERROR_INTERNAL_FILE: u32 = 10003; +pub const ERROR_BASE_FILE_MISSING: u32 = 10004; +pub const ERROR_MARKED_FOR_DELETE: u32 = 10005; +pub const ERROR_FILE_INCOMPLETE: u32 = 10006; +pub const ERROR_UNKNOWN_FILE_NAMES: u32 = 10007; +pub const ERROR_CANT_FIND_PATCH_PREFIX: u32 = 10008; +pub const HASH_TABLE_SIZE_MIN: u32 = 4; +pub const HASH_TABLE_SIZE_DEFAULT: u32 = 4096; +pub const HASH_TABLE_SIZE_MAX: u32 = 524288; +pub const HASH_ENTRY_DELETED: u32 = 4294967294; +pub const HASH_ENTRY_FREE: u32 = 4294967295; +pub const HET_ENTRY_DELETED: u32 = 128; +pub const HET_ENTRY_FREE: u32 = 0; +pub const HASH_STATE_SIZE: u32 = 96; +pub const SFILE_OPEN_HARD_DISK_FILE: u32 = 2; +pub const SFILE_OPEN_CDROM_FILE: u32 = 3; +pub const SFILE_OPEN_FROM_MPQ: u32 = 0; +pub const SFILE_OPEN_CHECK_EXISTS: u32 = 4294967292; +pub const SFILE_OPEN_BASE_FILE: u32 = 4294967293; +pub const SFILE_OPEN_ANY_LOCALE: u32 = 4294967294; +pub const SFILE_OPEN_LOCAL_FILE: u32 = 4294967295; +pub const MPQ_FLAG_READ_ONLY: u32 = 1; +pub const MPQ_FLAG_CHANGED: u32 = 2; +pub const MPQ_FLAG_MALFORMED: u32 = 4; +pub const MPQ_FLAG_HASH_TABLE_CUT: u32 = 8; +pub const MPQ_FLAG_BLOCK_TABLE_CUT: u32 = 16; +pub const MPQ_FLAG_CHECK_SECTOR_CRC: u32 = 32; +pub const MPQ_FLAG_SAVING_TABLES: u32 = 64; +pub const MPQ_FLAG_PATCH: u32 = 128; +pub const MPQ_FLAG_WAR3_MAP: u32 = 256; +pub const MPQ_FLAG_LISTFILE_NONE: u32 = 512; +pub const MPQ_FLAG_LISTFILE_NEW: u32 = 1024; +pub const MPQ_FLAG_LISTFILE_FORCE: u32 = 2048; +pub const MPQ_FLAG_ATTRIBUTES_NONE: u32 = 4096; +pub const MPQ_FLAG_ATTRIBUTES_NEW: u32 = 8192; +pub const MPQ_FLAG_SIGNATURE_NONE: u32 = 16384; +pub const MPQ_FLAG_SIGNATURE_NEW: u32 = 32768; +pub const MPQ_SUBTYPE_MPQ: u32 = 0; +pub const MPQ_SUBTYPE_SQP: u32 = 1; +pub const MPQ_SUBTYPE_MPK: u32 = 2; +pub const SFILE_INVALID_SIZE: u32 = 4294967295; +pub const SFILE_INVALID_POS: u32 = 4294967295; +pub const SFILE_INVALID_ATTRIBUTES: u32 = 4294967295; +pub const MPQ_FILE_IMPLODE: u32 = 256; +pub const MPQ_FILE_COMPRESS: u32 = 512; +pub const MPQ_FILE_ENCRYPTED: u32 = 65536; +pub const MPQ_FILE_FIX_KEY: u32 = 131072; +pub const MPQ_FILE_PATCH_FILE: u32 = 1048576; +pub const MPQ_FILE_SINGLE_UNIT: u32 = 16777216; +pub const MPQ_FILE_DELETE_MARKER: u32 = 33554432; +pub const MPQ_FILE_SECTOR_CRC: u32 = 67108864; +pub const MPQ_FILE_SIGNATURE: u32 = 268435456; +pub const MPQ_FILE_EXISTS: u32 = 2147483648; +pub const MPQ_FILE_REPLACEEXISTING: u32 = 2147483648; +pub const MPQ_FILE_COMPRESS_MASK: u32 = 65280; +pub const MPQ_FILE_DEFAULT_INTERNAL: u32 = 4294967295; +pub const MPQ_FILE_VALID_FLAGS: u32 = 2534605568; +pub const MPQ_FILE_VALID_FLAGS_W3X: u32 = 2516779776; +pub const BLOCK_INDEX_MASK: u32 = 268435455; +pub const MPQ_COMPRESSION_HUFFMANN: u32 = 1; +pub const MPQ_COMPRESSION_ZLIB: u32 = 2; +pub const MPQ_COMPRESSION_PKWARE: u32 = 8; +pub const MPQ_COMPRESSION_BZIP2: u32 = 16; +pub const MPQ_COMPRESSION_SPARSE: u32 = 32; +pub const MPQ_COMPRESSION_ADPCM_MONO: u32 = 64; +pub const MPQ_COMPRESSION_ADPCM_STEREO: u32 = 128; +pub const MPQ_COMPRESSION_LZMA: u32 = 18; +pub const MPQ_COMPRESSION_NEXT_SAME: u32 = 4294967295; +pub const MPQ_WAVE_QUALITY_HIGH: u32 = 0; +pub const MPQ_WAVE_QUALITY_MEDIUM: u32 = 1; +pub const MPQ_WAVE_QUALITY_LOW: u32 = 2; +pub const HET_TABLE_SIGNATURE: u32 = 441730376; +pub const BET_TABLE_SIGNATURE: u32 = 441730370; +pub const MPQ_KEY_HASH_TABLE: u32 = 3283040112; +pub const MPQ_KEY_BLOCK_TABLE: u32 = 3968054179; +pub const LISTFILE_NAME: &'static [u8; 11usize] = b"(listfile)\0"; +pub const SIGNATURE_NAME: &'static [u8; 12usize] = b"(signature)\0"; +pub const ATTRIBUTES_NAME: &'static [u8; 13usize] = b"(attributes)\0"; +pub const PATCH_METADATA_NAME: &'static [u8; 17usize] = b"(patch_metadata)\0"; +pub const MPQ_FORMAT_VERSION_1: u32 = 0; +pub const MPQ_FORMAT_VERSION_2: u32 = 1; +pub const MPQ_FORMAT_VERSION_3: u32 = 2; +pub const MPQ_FORMAT_VERSION_4: u32 = 3; +pub const MPQ_ATTRIBUTE_CRC32: u32 = 1; +pub const MPQ_ATTRIBUTE_FILETIME: u32 = 2; +pub const MPQ_ATTRIBUTE_MD5: u32 = 4; +pub const MPQ_ATTRIBUTE_PATCH_BIT: u32 = 8; +pub const MPQ_ATTRIBUTE_ALL: u32 = 15; +pub const MPQ_ATTRIBUTES_V1: u32 = 100; +pub const BASE_PROVIDER_FILE: u32 = 0; +pub const BASE_PROVIDER_MAP: u32 = 1; +pub const BASE_PROVIDER_HTTP: u32 = 2; +pub const BASE_PROVIDER_MASK: u32 = 15; +pub const STREAM_PROVIDER_FLAT: u32 = 0; +pub const STREAM_PROVIDER_PARTIAL: u32 = 16; +pub const STREAM_PROVIDER_MPQE: u32 = 32; +pub const STREAM_PROVIDER_BLOCK4: u32 = 48; +pub const STREAM_PROVIDER_MASK: u32 = 240; +pub const STREAM_FLAG_READ_ONLY: u32 = 256; +pub const STREAM_FLAG_WRITE_SHARE: u32 = 512; +pub const STREAM_FLAG_USE_BITMAP: u32 = 1024; +pub const STREAM_OPTIONS_MASK: u32 = 65280; +pub const STREAM_PROVIDERS_MASK: u32 = 255; +pub const STREAM_FLAGS_MASK: u32 = 65535; +pub const MPQ_OPEN_NO_LISTFILE: u32 = 65536; +pub const MPQ_OPEN_NO_ATTRIBUTES: u32 = 131072; +pub const MPQ_OPEN_NO_HEADER_SEARCH: u32 = 262144; +pub const MPQ_OPEN_FORCE_MPQ_V1: u32 = 524288; +pub const MPQ_OPEN_CHECK_SECTOR_CRC: u32 = 1048576; +pub const MPQ_OPEN_PATCH: u32 = 2097152; +pub const MPQ_OPEN_FORCE_LISTFILE: u32 = 4194304; +pub const MPQ_OPEN_READ_ONLY: u32 = 256; +pub const MPQ_CREATE_LISTFILE: u32 = 1048576; +pub const MPQ_CREATE_ATTRIBUTES: u32 = 2097152; +pub const MPQ_CREATE_SIGNATURE: u32 = 4194304; +pub const MPQ_CREATE_ARCHIVE_V1: u32 = 0; +pub const MPQ_CREATE_ARCHIVE_V2: u32 = 16777216; +pub const MPQ_CREATE_ARCHIVE_V3: u32 = 33554432; +pub const MPQ_CREATE_ARCHIVE_V4: u32 = 50331648; +pub const MPQ_CREATE_ARCHIVE_VMASK: u32 = 251658240; +pub const FLAGS_TO_FORMAT_SHIFT: u32 = 24; +pub const SFILE_VERIFY_SECTOR_CRC: u32 = 1; +pub const SFILE_VERIFY_FILE_CRC: u32 = 2; +pub const SFILE_VERIFY_FILE_MD5: u32 = 4; +pub const SFILE_VERIFY_RAW_MD5: u32 = 8; +pub const SFILE_VERIFY_ALL: u32 = 15; +pub const VERIFY_OPEN_ERROR: u32 = 1; +pub const VERIFY_READ_ERROR: u32 = 2; +pub const VERIFY_FILE_HAS_SECTOR_CRC: u32 = 4; +pub const VERIFY_FILE_SECTOR_CRC_ERROR: u32 = 8; +pub const VERIFY_FILE_HAS_CHECKSUM: u32 = 16; +pub const VERIFY_FILE_CHECKSUM_ERROR: u32 = 32; +pub const VERIFY_FILE_HAS_MD5: u32 = 64; +pub const VERIFY_FILE_MD5_ERROR: u32 = 128; +pub const VERIFY_FILE_HAS_RAW_MD5: u32 = 256; +pub const VERIFY_FILE_RAW_MD5_ERROR: u32 = 512; +pub const VERIFY_FILE_ERROR_MASK: u32 = 683; +pub const SFILE_VERIFY_MPQ_HEADER: u32 = 1; +pub const SFILE_VERIFY_HET_TABLE: u32 = 2; +pub const SFILE_VERIFY_BET_TABLE: u32 = 3; +pub const SFILE_VERIFY_HASH_TABLE: u32 = 4; +pub const SFILE_VERIFY_BLOCK_TABLE: u32 = 5; +pub const SFILE_VERIFY_HIBLOCK_TABLE: u32 = 6; +pub const SFILE_VERIFY_FILE: u32 = 7; +pub const SIGNATURE_TYPE_NONE: u32 = 0; +pub const SIGNATURE_TYPE_WEAK: u32 = 1; +pub const SIGNATURE_TYPE_STRONG: u32 = 2; +pub const ERROR_NO_SIGNATURE: u32 = 0; +pub const ERROR_VERIFY_FAILED: u32 = 1; +pub const ERROR_WEAK_SIGNATURE_OK: u32 = 2; +pub const ERROR_WEAK_SIGNATURE_ERROR: u32 = 3; +pub const ERROR_STRONG_SIGNATURE_OK: u32 = 4; +pub const ERROR_STRONG_SIGNATURE_ERROR: u32 = 5; +pub const MD5_DIGEST_SIZE: u32 = 16; +pub const SHA1_DIGEST_SIZE: u32 = 20; +pub const CCB_CHECKING_FILES: u32 = 1; +pub const CCB_CHECKING_HASH_TABLE: u32 = 2; +pub const CCB_COPYING_NON_MPQ_DATA: u32 = 3; +pub const CCB_COMPACTING_FILES: u32 = 4; +pub const CCB_CLOSING_ARCHIVE: u32 = 5; +pub const MPQ_HEADER_SIZE_V1: u32 = 32; +pub const MPQ_HEADER_SIZE_V2: u32 = 44; +pub const MPQ_HEADER_SIZE_V3: u32 = 68; +pub const MPQ_HEADER_SIZE_V4: u32 = 208; +pub const MPQ_HEADER_DWORDS: u32 = 52; +pub type size_t = ::std::os::raw::c_ulonglong; +pub type TCHAR = u16; +pub type ULONG = ::std::os::raw::c_ulong; +pub type USHORT = ::std::os::raw::c_ushort; +pub type UCHAR = ::std::os::raw::c_uchar; +pub type DWORD = ::std::os::raw::c_ulong; +pub type BOOL = ::std::os::raw::c_int; +pub type BYTE = ::std::os::raw::c_uchar; +pub type WORD = ::std::os::raw::c_ushort; +pub type FLOAT = f32; +pub type PBYTE = *mut BYTE; +pub type LPBYTE = *mut BYTE; +pub type PDWORD = *mut DWORD; +pub type LPDWORD = *mut DWORD; +pub type LPVOID = *mut ::std::os::raw::c_void; +pub type LPCVOID = *const ::std::os::raw::c_void; +pub type INT = ::std::os::raw::c_int; +pub type UINT = ::std::os::raw::c_uint; +pub type INT_PTR = ::std::os::raw::c_longlong; +pub type UINT_PTR = ::std::os::raw::c_ulonglong; +pub type LONG_PTR = ::std::os::raw::c_longlong; +pub type ULONG_PTR = ::std::os::raw::c_ulonglong; +pub type SHANDLE_PTR = ::std::os::raw::c_longlong; +pub type SIZE_T = ULONG_PTR; +pub type SSIZE_T = LONG_PTR; +pub type DWORD_PTR = ULONG_PTR; +pub type DWORD64 = ::std::os::raw::c_ulonglong; +pub type KAFFINITY = ULONG_PTR; +pub type PVOID = *mut ::std::os::raw::c_void; +pub type CHAR = ::std::os::raw::c_char; +pub type SHORT = ::std::os::raw::c_short; +pub type LONG = ::std::os::raw::c_long; +pub type WCHAR = u16; +pub type LPWSTR = *mut WCHAR; +pub type PWSTR = *mut WCHAR; +pub type LPCWSTR = *const WCHAR; +pub type PCWSTR = *const WCHAR; +pub type PCZZWSTR = *const WCHAR; +pub type LPSTR = *mut CHAR; +pub type LPCSTR = *const CHAR; +pub type PCSTR = *const CHAR; +pub type PCZZSTR = *const CHAR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _GROUP_AFFINITY { + pub Mask: KAFFINITY, + pub Group: WORD, + pub Reserved: [WORD; 3usize], +} +#[test] +fn bindgen_test_layout__GROUP_AFFINITY() { + assert_eq!( + ::std::mem::size_of::<_GROUP_AFFINITY>(), + 16usize, + concat!("Size of: ", stringify!(_GROUP_AFFINITY)) + ); + assert_eq!( + ::std::mem::align_of::<_GROUP_AFFINITY>(), + 8usize, + concat!("Alignment of ", stringify!(_GROUP_AFFINITY)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_GROUP_AFFINITY>())).Mask as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_GROUP_AFFINITY), + "::", + stringify!(Mask) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_GROUP_AFFINITY>())).Group as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_GROUP_AFFINITY), + "::", + stringify!(Group) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_GROUP_AFFINITY>())).Reserved as *const _ as usize }, + 10usize, + concat!( + "Offset of field: ", + stringify!(_GROUP_AFFINITY), + "::", + stringify!(Reserved) + ) + ); +} +pub type GROUP_AFFINITY = _GROUP_AFFINITY; +pub type HANDLE = *mut ::std::os::raw::c_void; +pub type HRESULT = ::std::os::raw::c_long; +pub type LCID = DWORD; +pub type LONGLONG = ::std::os::raw::c_longlong; +pub type ULONGLONG = ::std::os::raw::c_ulonglong; +#[repr(C)] +#[derive(Copy, Clone)] +pub union _LARGE_INTEGER { + pub __bindgen_anon_1: _LARGE_INTEGER__bindgen_ty_1, + pub u: _LARGE_INTEGER__bindgen_ty_2, + pub QuadPart: LONGLONG, + _bindgen_union_align: u64, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _LARGE_INTEGER__bindgen_ty_1 { + pub LowPart: DWORD, + pub HighPart: LONG, +} +#[test] +fn bindgen_test_layout__LARGE_INTEGER__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_LARGE_INTEGER__bindgen_ty_1>(), + 8usize, + concat!("Size of: ", stringify!(_LARGE_INTEGER__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<_LARGE_INTEGER__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(_LARGE_INTEGER__bindgen_ty_1)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_LARGE_INTEGER__bindgen_ty_1>())).LowPart as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_LARGE_INTEGER__bindgen_ty_1), + "::", + stringify!(LowPart) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_LARGE_INTEGER__bindgen_ty_1>())).HighPart as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_LARGE_INTEGER__bindgen_ty_1), + "::", + stringify!(HighPart) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _LARGE_INTEGER__bindgen_ty_2 { + pub LowPart: DWORD, + pub HighPart: LONG, +} +#[test] +fn bindgen_test_layout__LARGE_INTEGER__bindgen_ty_2() { + assert_eq!( + ::std::mem::size_of::<_LARGE_INTEGER__bindgen_ty_2>(), + 8usize, + concat!("Size of: ", stringify!(_LARGE_INTEGER__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::<_LARGE_INTEGER__bindgen_ty_2>(), + 4usize, + concat!("Alignment of ", stringify!(_LARGE_INTEGER__bindgen_ty_2)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_LARGE_INTEGER__bindgen_ty_2>())).LowPart as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_LARGE_INTEGER__bindgen_ty_2), + "::", + stringify!(LowPart) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_LARGE_INTEGER__bindgen_ty_2>())).HighPart as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_LARGE_INTEGER__bindgen_ty_2), + "::", + stringify!(HighPart) + ) + ); +} +#[test] +fn bindgen_test_layout__LARGE_INTEGER() { + assert_eq!( + ::std::mem::size_of::<_LARGE_INTEGER>(), + 8usize, + concat!("Size of: ", stringify!(_LARGE_INTEGER)) + ); + assert_eq!( + ::std::mem::align_of::<_LARGE_INTEGER>(), + 8usize, + concat!("Alignment of ", stringify!(_LARGE_INTEGER)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_LARGE_INTEGER>())).u as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_LARGE_INTEGER), + "::", + stringify!(u) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_LARGE_INTEGER>())).QuadPart as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_LARGE_INTEGER), + "::", + stringify!(QuadPart) + ) + ); +} +pub type LARGE_INTEGER = _LARGE_INTEGER; +#[repr(C)] +#[derive(Copy, Clone)] +pub union _ULARGE_INTEGER { + pub __bindgen_anon_1: _ULARGE_INTEGER__bindgen_ty_1, + pub u: _ULARGE_INTEGER__bindgen_ty_2, + pub QuadPart: ULONGLONG, + _bindgen_union_align: u64, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _ULARGE_INTEGER__bindgen_ty_1 { + pub LowPart: DWORD, + pub HighPart: DWORD, +} +#[test] +fn bindgen_test_layout__ULARGE_INTEGER__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_ULARGE_INTEGER__bindgen_ty_1>(), + 8usize, + concat!("Size of: ", stringify!(_ULARGE_INTEGER__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<_ULARGE_INTEGER__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(_ULARGE_INTEGER__bindgen_ty_1)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_ULARGE_INTEGER__bindgen_ty_1>())).LowPart as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_ULARGE_INTEGER__bindgen_ty_1), + "::", + stringify!(LowPart) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_ULARGE_INTEGER__bindgen_ty_1>())).HighPart as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_ULARGE_INTEGER__bindgen_ty_1), + "::", + stringify!(HighPart) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _ULARGE_INTEGER__bindgen_ty_2 { + pub LowPart: DWORD, + pub HighPart: DWORD, +} +#[test] +fn bindgen_test_layout__ULARGE_INTEGER__bindgen_ty_2() { + assert_eq!( + ::std::mem::size_of::<_ULARGE_INTEGER__bindgen_ty_2>(), + 8usize, + concat!("Size of: ", stringify!(_ULARGE_INTEGER__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::<_ULARGE_INTEGER__bindgen_ty_2>(), + 4usize, + concat!("Alignment of ", stringify!(_ULARGE_INTEGER__bindgen_ty_2)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_ULARGE_INTEGER__bindgen_ty_2>())).LowPart as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_ULARGE_INTEGER__bindgen_ty_2), + "::", + stringify!(LowPart) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_ULARGE_INTEGER__bindgen_ty_2>())).HighPart as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_ULARGE_INTEGER__bindgen_ty_2), + "::", + stringify!(HighPart) + ) + ); +} +#[test] +fn bindgen_test_layout__ULARGE_INTEGER() { + assert_eq!( + ::std::mem::size_of::<_ULARGE_INTEGER>(), + 8usize, + concat!("Size of: ", stringify!(_ULARGE_INTEGER)) + ); + assert_eq!( + ::std::mem::align_of::<_ULARGE_INTEGER>(), + 8usize, + concat!("Alignment of ", stringify!(_ULARGE_INTEGER)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_ULARGE_INTEGER>())).u as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_ULARGE_INTEGER), + "::", + stringify!(u) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_ULARGE_INTEGER>())).QuadPart as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_ULARGE_INTEGER), + "::", + stringify!(QuadPart) + ) + ); +} +pub type ULARGE_INTEGER = _ULARGE_INTEGER; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _LUID { + pub LowPart: DWORD, + pub HighPart: LONG, +} +#[test] +fn bindgen_test_layout__LUID() { + assert_eq!( + ::std::mem::size_of::<_LUID>(), + 8usize, + concat!("Size of: ", stringify!(_LUID)) + ); + assert_eq!( + ::std::mem::align_of::<_LUID>(), + 4usize, + concat!("Alignment of ", stringify!(_LUID)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_LUID>())).LowPart as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_LUID), + "::", + stringify!(LowPart) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_LUID>())).HighPart as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_LUID), + "::", + stringify!(HighPart) + ) + ); +} +pub type LUID = _LUID; +pub type DWORDLONG = ULONGLONG; +pub type BOOLEAN = BYTE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SINGLE_LIST_ENTRY { + pub Next: *mut _SINGLE_LIST_ENTRY, +} +#[test] +fn bindgen_test_layout__SINGLE_LIST_ENTRY() { + assert_eq!( + ::std::mem::size_of::<_SINGLE_LIST_ENTRY>(), + 8usize, + concat!("Size of: ", stringify!(_SINGLE_LIST_ENTRY)) + ); + assert_eq!( + ::std::mem::align_of::<_SINGLE_LIST_ENTRY>(), + 8usize, + concat!("Alignment of ", stringify!(_SINGLE_LIST_ENTRY)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SINGLE_LIST_ENTRY>())).Next as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SINGLE_LIST_ENTRY), + "::", + stringify!(Next) + ) + ); +} +pub type SINGLE_LIST_ENTRY = _SINGLE_LIST_ENTRY; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _GUID { + pub Data1: ::std::os::raw::c_ulong, + pub Data2: ::std::os::raw::c_ushort, + pub Data3: ::std::os::raw::c_ushort, + pub Data4: [::std::os::raw::c_uchar; 8usize], +} +#[test] +fn bindgen_test_layout__GUID() { + assert_eq!( + ::std::mem::size_of::<_GUID>(), + 16usize, + concat!("Size of: ", stringify!(_GUID)) + ); + assert_eq!( + ::std::mem::align_of::<_GUID>(), + 4usize, + concat!("Alignment of ", stringify!(_GUID)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_GUID>())).Data1 as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_GUID), + "::", + stringify!(Data1) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_GUID>())).Data2 as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_GUID), + "::", + stringify!(Data2) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_GUID>())).Data3 as *const _ as usize }, + 6usize, + concat!( + "Offset of field: ", + stringify!(_GUID), + "::", + stringify!(Data3) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_GUID>())).Data4 as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_GUID), + "::", + stringify!(Data4) + ) + ); +} +pub type GUID = _GUID; +pub type LPGUID = *mut GUID; +pub type LPCGUID = *const GUID; +pub type IID = GUID; +pub type CLSID = GUID; +pub type FMTID = GUID; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCOPE_TABLE_AMD64 { + pub Count: DWORD, + pub ScopeRecord: [_SCOPE_TABLE_AMD64__bindgen_ty_1; 1usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCOPE_TABLE_AMD64__bindgen_ty_1 { + pub BeginAddress: DWORD, + pub EndAddress: DWORD, + pub HandlerAddress: DWORD, + pub JumpTarget: DWORD, +} +#[test] +fn bindgen_test_layout__SCOPE_TABLE_AMD64__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_SCOPE_TABLE_AMD64__bindgen_ty_1>(), + 16usize, + concat!("Size of: ", stringify!(_SCOPE_TABLE_AMD64__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<_SCOPE_TABLE_AMD64__bindgen_ty_1>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_SCOPE_TABLE_AMD64__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCOPE_TABLE_AMD64__bindgen_ty_1>())).BeginAddress as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCOPE_TABLE_AMD64__bindgen_ty_1), + "::", + stringify!(BeginAddress) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCOPE_TABLE_AMD64__bindgen_ty_1>())).EndAddress as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCOPE_TABLE_AMD64__bindgen_ty_1), + "::", + stringify!(EndAddress) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCOPE_TABLE_AMD64__bindgen_ty_1>())).HandlerAddress as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCOPE_TABLE_AMD64__bindgen_ty_1), + "::", + stringify!(HandlerAddress) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCOPE_TABLE_AMD64__bindgen_ty_1>())).JumpTarget as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SCOPE_TABLE_AMD64__bindgen_ty_1), + "::", + stringify!(JumpTarget) + ) + ); +} +#[test] +fn bindgen_test_layout__SCOPE_TABLE_AMD64() { + assert_eq!( + ::std::mem::size_of::<_SCOPE_TABLE_AMD64>(), + 20usize, + concat!("Size of: ", stringify!(_SCOPE_TABLE_AMD64)) + ); + assert_eq!( + ::std::mem::align_of::<_SCOPE_TABLE_AMD64>(), + 4usize, + concat!("Alignment of ", stringify!(_SCOPE_TABLE_AMD64)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCOPE_TABLE_AMD64>())).Count as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCOPE_TABLE_AMD64), + "::", + stringify!(Count) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCOPE_TABLE_AMD64>())).ScopeRecord as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCOPE_TABLE_AMD64), + "::", + stringify!(ScopeRecord) + ) + ); +} +pub type SCOPE_TABLE_AMD64 = _SCOPE_TABLE_AMD64; +pub type SCOPE_TABLE = SCOPE_TABLE_AMD64; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCOPE_TABLE_ARM { + pub Count: DWORD, + pub ScopeRecord: [_SCOPE_TABLE_ARM__bindgen_ty_1; 1usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCOPE_TABLE_ARM__bindgen_ty_1 { + pub BeginAddress: DWORD, + pub EndAddress: DWORD, + pub HandlerAddress: DWORD, + pub JumpTarget: DWORD, +} +#[test] +fn bindgen_test_layout__SCOPE_TABLE_ARM__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_SCOPE_TABLE_ARM__bindgen_ty_1>(), + 16usize, + concat!("Size of: ", stringify!(_SCOPE_TABLE_ARM__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<_SCOPE_TABLE_ARM__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(_SCOPE_TABLE_ARM__bindgen_ty_1)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCOPE_TABLE_ARM__bindgen_ty_1>())).BeginAddress as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCOPE_TABLE_ARM__bindgen_ty_1), + "::", + stringify!(BeginAddress) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCOPE_TABLE_ARM__bindgen_ty_1>())).EndAddress as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCOPE_TABLE_ARM__bindgen_ty_1), + "::", + stringify!(EndAddress) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCOPE_TABLE_ARM__bindgen_ty_1>())).HandlerAddress as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCOPE_TABLE_ARM__bindgen_ty_1), + "::", + stringify!(HandlerAddress) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCOPE_TABLE_ARM__bindgen_ty_1>())).JumpTarget as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SCOPE_TABLE_ARM__bindgen_ty_1), + "::", + stringify!(JumpTarget) + ) + ); +} +#[test] +fn bindgen_test_layout__SCOPE_TABLE_ARM() { + assert_eq!( + ::std::mem::size_of::<_SCOPE_TABLE_ARM>(), + 20usize, + concat!("Size of: ", stringify!(_SCOPE_TABLE_ARM)) + ); + assert_eq!( + ::std::mem::align_of::<_SCOPE_TABLE_ARM>(), + 4usize, + concat!("Alignment of ", stringify!(_SCOPE_TABLE_ARM)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCOPE_TABLE_ARM>())).Count as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCOPE_TABLE_ARM), + "::", + stringify!(Count) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCOPE_TABLE_ARM>())).ScopeRecord as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCOPE_TABLE_ARM), + "::", + stringify!(ScopeRecord) + ) + ); +} +pub type SCOPE_TABLE_ARM = _SCOPE_TABLE_ARM; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCOPE_TABLE_ARM64 { + pub Count: DWORD, + pub ScopeRecord: [_SCOPE_TABLE_ARM64__bindgen_ty_1; 1usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCOPE_TABLE_ARM64__bindgen_ty_1 { + pub BeginAddress: DWORD, + pub EndAddress: DWORD, + pub HandlerAddress: DWORD, + pub JumpTarget: DWORD, +} +#[test] +fn bindgen_test_layout__SCOPE_TABLE_ARM64__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_SCOPE_TABLE_ARM64__bindgen_ty_1>(), + 16usize, + concat!("Size of: ", stringify!(_SCOPE_TABLE_ARM64__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<_SCOPE_TABLE_ARM64__bindgen_ty_1>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_SCOPE_TABLE_ARM64__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCOPE_TABLE_ARM64__bindgen_ty_1>())).BeginAddress as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCOPE_TABLE_ARM64__bindgen_ty_1), + "::", + stringify!(BeginAddress) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCOPE_TABLE_ARM64__bindgen_ty_1>())).EndAddress as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCOPE_TABLE_ARM64__bindgen_ty_1), + "::", + stringify!(EndAddress) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCOPE_TABLE_ARM64__bindgen_ty_1>())).HandlerAddress as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCOPE_TABLE_ARM64__bindgen_ty_1), + "::", + stringify!(HandlerAddress) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCOPE_TABLE_ARM64__bindgen_ty_1>())).JumpTarget as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SCOPE_TABLE_ARM64__bindgen_ty_1), + "::", + stringify!(JumpTarget) + ) + ); +} +#[test] +fn bindgen_test_layout__SCOPE_TABLE_ARM64() { + assert_eq!( + ::std::mem::size_of::<_SCOPE_TABLE_ARM64>(), + 20usize, + concat!("Size of: ", stringify!(_SCOPE_TABLE_ARM64)) + ); + assert_eq!( + ::std::mem::align_of::<_SCOPE_TABLE_ARM64>(), + 4usize, + concat!("Alignment of ", stringify!(_SCOPE_TABLE_ARM64)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCOPE_TABLE_ARM64>())).Count as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCOPE_TABLE_ARM64), + "::", + stringify!(Count) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCOPE_TABLE_ARM64>())).ScopeRecord as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCOPE_TABLE_ARM64), + "::", + stringify!(ScopeRecord) + ) + ); +} +pub type SCOPE_TABLE_ARM64 = _SCOPE_TABLE_ARM64; +pub type PACCESS_TOKEN = PVOID; +pub type PSECURITY_DESCRIPTOR = PVOID; +pub type PSID = PVOID; +pub type ACCESS_MASK = DWORD; +pub type PACCESS_MASK = *mut ACCESS_MASK; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _GENERIC_MAPPING { + pub GenericRead: ACCESS_MASK, + pub GenericWrite: ACCESS_MASK, + pub GenericExecute: ACCESS_MASK, + pub GenericAll: ACCESS_MASK, +} +#[test] +fn bindgen_test_layout__GENERIC_MAPPING() { + assert_eq!( + ::std::mem::size_of::<_GENERIC_MAPPING>(), + 16usize, + concat!("Size of: ", stringify!(_GENERIC_MAPPING)) + ); + assert_eq!( + ::std::mem::align_of::<_GENERIC_MAPPING>(), + 4usize, + concat!("Alignment of ", stringify!(_GENERIC_MAPPING)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_GENERIC_MAPPING>())).GenericRead as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_GENERIC_MAPPING), + "::", + stringify!(GenericRead) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_GENERIC_MAPPING>())).GenericWrite as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_GENERIC_MAPPING), + "::", + stringify!(GenericWrite) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_GENERIC_MAPPING>())).GenericExecute as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_GENERIC_MAPPING), + "::", + stringify!(GenericExecute) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_GENERIC_MAPPING>())).GenericAll as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_GENERIC_MAPPING), + "::", + stringify!(GenericAll) + ) + ); +} +pub type GENERIC_MAPPING = _GENERIC_MAPPING; +pub type PGENERIC_MAPPING = *mut GENERIC_MAPPING; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _LUID_AND_ATTRIBUTES { + pub Luid: LUID, + pub Attributes: DWORD, +} +#[test] +fn bindgen_test_layout__LUID_AND_ATTRIBUTES() { + assert_eq!( + ::std::mem::size_of::<_LUID_AND_ATTRIBUTES>(), + 12usize, + concat!("Size of: ", stringify!(_LUID_AND_ATTRIBUTES)) + ); + assert_eq!( + ::std::mem::align_of::<_LUID_AND_ATTRIBUTES>(), + 4usize, + concat!("Alignment of ", stringify!(_LUID_AND_ATTRIBUTES)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_LUID_AND_ATTRIBUTES>())).Luid as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_LUID_AND_ATTRIBUTES), + "::", + stringify!(Luid) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_LUID_AND_ATTRIBUTES>())).Attributes as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_LUID_AND_ATTRIBUTES), + "::", + stringify!(Attributes) + ) + ); +} +pub type LUID_AND_ATTRIBUTES = _LUID_AND_ATTRIBUTES; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SID_IDENTIFIER_AUTHORITY { + pub Value: [BYTE; 6usize], +} +#[test] +fn bindgen_test_layout__SID_IDENTIFIER_AUTHORITY() { + assert_eq!( + ::std::mem::size_of::<_SID_IDENTIFIER_AUTHORITY>(), + 6usize, + concat!("Size of: ", stringify!(_SID_IDENTIFIER_AUTHORITY)) + ); + assert_eq!( + ::std::mem::align_of::<_SID_IDENTIFIER_AUTHORITY>(), + 1usize, + concat!("Alignment of ", stringify!(_SID_IDENTIFIER_AUTHORITY)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SID_IDENTIFIER_AUTHORITY>())).Value as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SID_IDENTIFIER_AUTHORITY), + "::", + stringify!(Value) + ) + ); +} +pub type SID_IDENTIFIER_AUTHORITY = _SID_IDENTIFIER_AUTHORITY; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SID { + pub Revision: BYTE, + pub SubAuthorityCount: BYTE, + pub IdentifierAuthority: SID_IDENTIFIER_AUTHORITY, + pub SubAuthority: [DWORD; 1usize], +} +#[test] +fn bindgen_test_layout__SID() { + assert_eq!( + ::std::mem::size_of::<_SID>(), + 12usize, + concat!("Size of: ", stringify!(_SID)) + ); + assert_eq!( + ::std::mem::align_of::<_SID>(), + 4usize, + concat!("Alignment of ", stringify!(_SID)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SID>())).Revision as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SID), + "::", + stringify!(Revision) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SID>())).SubAuthorityCount as *const _ as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(_SID), + "::", + stringify!(SubAuthorityCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SID>())).IdentifierAuthority as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_SID), + "::", + stringify!(IdentifierAuthority) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SID>())).SubAuthority as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SID), + "::", + stringify!(SubAuthority) + ) + ); +} +pub type SID = _SID; +#[repr(C)] +#[derive(Copy, Clone)] +pub union _SE_SID { + pub Sid: SID, + pub Buffer: [BYTE; 68usize], + _bindgen_union_align: [u32; 17usize], +} +#[test] +fn bindgen_test_layout__SE_SID() { + assert_eq!( + ::std::mem::size_of::<_SE_SID>(), + 68usize, + concat!("Size of: ", stringify!(_SE_SID)) + ); + assert_eq!( + ::std::mem::align_of::<_SE_SID>(), + 4usize, + concat!("Alignment of ", stringify!(_SE_SID)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SE_SID>())).Sid as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SE_SID), + "::", + stringify!(Sid) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SE_SID>())).Buffer as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SE_SID), + "::", + stringify!(Buffer) + ) + ); +} +pub type SE_SID = _SE_SID; +pub const _SID_NAME_USE_SidTypeUser: _SID_NAME_USE = 1; +pub const _SID_NAME_USE_SidTypeGroup: _SID_NAME_USE = 2; +pub const _SID_NAME_USE_SidTypeDomain: _SID_NAME_USE = 3; +pub const _SID_NAME_USE_SidTypeAlias: _SID_NAME_USE = 4; +pub const _SID_NAME_USE_SidTypeWellKnownGroup: _SID_NAME_USE = 5; +pub const _SID_NAME_USE_SidTypeDeletedAccount: _SID_NAME_USE = 6; +pub const _SID_NAME_USE_SidTypeInvalid: _SID_NAME_USE = 7; +pub const _SID_NAME_USE_SidTypeUnknown: _SID_NAME_USE = 8; +pub const _SID_NAME_USE_SidTypeComputer: _SID_NAME_USE = 9; +pub const _SID_NAME_USE_SidTypeLabel: _SID_NAME_USE = 10; +pub const _SID_NAME_USE_SidTypeLogonSession: _SID_NAME_USE = 11; +pub type _SID_NAME_USE = ::std::os::raw::c_int; +pub use self::_SID_NAME_USE as SID_NAME_USE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SID_AND_ATTRIBUTES { + pub Sid: PSID, + pub Attributes: DWORD, +} +#[test] +fn bindgen_test_layout__SID_AND_ATTRIBUTES() { + assert_eq!( + ::std::mem::size_of::<_SID_AND_ATTRIBUTES>(), + 16usize, + concat!("Size of: ", stringify!(_SID_AND_ATTRIBUTES)) + ); + assert_eq!( + ::std::mem::align_of::<_SID_AND_ATTRIBUTES>(), + 8usize, + concat!("Alignment of ", stringify!(_SID_AND_ATTRIBUTES)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SID_AND_ATTRIBUTES>())).Sid as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SID_AND_ATTRIBUTES), + "::", + stringify!(Sid) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SID_AND_ATTRIBUTES>())).Attributes as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SID_AND_ATTRIBUTES), + "::", + stringify!(Attributes) + ) + ); +} +pub type SID_AND_ATTRIBUTES = _SID_AND_ATTRIBUTES; +pub type PSID_AND_ATTRIBUTES = *mut _SID_AND_ATTRIBUTES; +pub type SID_AND_ATTRIBUTES_ARRAY = [SID_AND_ATTRIBUTES; 1usize]; +pub type SID_HASH_ENTRY = ULONG_PTR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SID_AND_ATTRIBUTES_HASH { + pub SidCount: DWORD, + pub SidAttr: PSID_AND_ATTRIBUTES, + pub Hash: [SID_HASH_ENTRY; 32usize], +} +#[test] +fn bindgen_test_layout__SID_AND_ATTRIBUTES_HASH() { + assert_eq!( + ::std::mem::size_of::<_SID_AND_ATTRIBUTES_HASH>(), + 272usize, + concat!("Size of: ", stringify!(_SID_AND_ATTRIBUTES_HASH)) + ); + assert_eq!( + ::std::mem::align_of::<_SID_AND_ATTRIBUTES_HASH>(), + 8usize, + concat!("Alignment of ", stringify!(_SID_AND_ATTRIBUTES_HASH)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SID_AND_ATTRIBUTES_HASH>())).SidCount as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SID_AND_ATTRIBUTES_HASH), + "::", + stringify!(SidCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SID_AND_ATTRIBUTES_HASH>())).SidAttr as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SID_AND_ATTRIBUTES_HASH), + "::", + stringify!(SidAttr) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SID_AND_ATTRIBUTES_HASH>())).Hash as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SID_AND_ATTRIBUTES_HASH), + "::", + stringify!(Hash) + ) + ); +} +pub type SID_AND_ATTRIBUTES_HASH = _SID_AND_ATTRIBUTES_HASH; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _ACL { + pub AclRevision: BYTE, + pub Sbz1: BYTE, + pub AclSize: WORD, + pub AceCount: WORD, + pub Sbz2: WORD, +} +#[test] +fn bindgen_test_layout__ACL() { + assert_eq!( + ::std::mem::size_of::<_ACL>(), + 8usize, + concat!("Size of: ", stringify!(_ACL)) + ); + assert_eq!( + ::std::mem::align_of::<_ACL>(), + 2usize, + concat!("Alignment of ", stringify!(_ACL)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_ACL>())).AclRevision as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_ACL), + "::", + stringify!(AclRevision) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_ACL>())).Sbz1 as *const _ as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(_ACL), + "::", + stringify!(Sbz1) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_ACL>())).AclSize as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_ACL), + "::", + stringify!(AclSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_ACL>())).AceCount as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_ACL), + "::", + stringify!(AceCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_ACL>())).Sbz2 as *const _ as usize }, + 6usize, + concat!( + "Offset of field: ", + stringify!(_ACL), + "::", + stringify!(Sbz2) + ) + ); +} +pub type ACL = _ACL; +pub type PACL = *mut ACL; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _ACE_HEADER { + pub AceType: BYTE, + pub AceFlags: BYTE, + pub AceSize: WORD, +} +#[test] +fn bindgen_test_layout__ACE_HEADER() { + assert_eq!( + ::std::mem::size_of::<_ACE_HEADER>(), + 4usize, + concat!("Size of: ", stringify!(_ACE_HEADER)) + ); + assert_eq!( + ::std::mem::align_of::<_ACE_HEADER>(), + 2usize, + concat!("Alignment of ", stringify!(_ACE_HEADER)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_ACE_HEADER>())).AceType as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_ACE_HEADER), + "::", + stringify!(AceType) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_ACE_HEADER>())).AceFlags as *const _ as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(_ACE_HEADER), + "::", + stringify!(AceFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_ACE_HEADER>())).AceSize as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_ACE_HEADER), + "::", + stringify!(AceSize) + ) + ); +} +pub type ACE_HEADER = _ACE_HEADER; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SYSTEM_AUDIT_ACE { + pub Header: ACE_HEADER, + pub Mask: ACCESS_MASK, + pub SidStart: DWORD, +} +#[test] +fn bindgen_test_layout__SYSTEM_AUDIT_ACE() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_AUDIT_ACE>(), + 12usize, + concat!("Size of: ", stringify!(_SYSTEM_AUDIT_ACE)) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_AUDIT_ACE>(), + 4usize, + concat!("Alignment of ", stringify!(_SYSTEM_AUDIT_ACE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_AUDIT_ACE>())).Header as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_AUDIT_ACE), + "::", + stringify!(Header) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_AUDIT_ACE>())).Mask as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_AUDIT_ACE), + "::", + stringify!(Mask) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_AUDIT_ACE>())).SidStart as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_AUDIT_ACE), + "::", + stringify!(SidStart) + ) + ); +} +pub type SYSTEM_AUDIT_ACE = _SYSTEM_AUDIT_ACE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SYSTEM_ALARM_ACE { + pub Header: ACE_HEADER, + pub Mask: ACCESS_MASK, + pub SidStart: DWORD, +} +#[test] +fn bindgen_test_layout__SYSTEM_ALARM_ACE() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_ALARM_ACE>(), + 12usize, + concat!("Size of: ", stringify!(_SYSTEM_ALARM_ACE)) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_ALARM_ACE>(), + 4usize, + concat!("Alignment of ", stringify!(_SYSTEM_ALARM_ACE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_ALARM_ACE>())).Header as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_ALARM_ACE), + "::", + stringify!(Header) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_ALARM_ACE>())).Mask as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_ALARM_ACE), + "::", + stringify!(Mask) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_ALARM_ACE>())).SidStart as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_ALARM_ACE), + "::", + stringify!(SidStart) + ) + ); +} +pub type SYSTEM_ALARM_ACE = _SYSTEM_ALARM_ACE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SYSTEM_RESOURCE_ATTRIBUTE_ACE { + pub Header: ACE_HEADER, + pub Mask: ACCESS_MASK, + pub SidStart: DWORD, +} +#[test] +fn bindgen_test_layout__SYSTEM_RESOURCE_ATTRIBUTE_ACE() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_RESOURCE_ATTRIBUTE_ACE>(), + 12usize, + concat!("Size of: ", stringify!(_SYSTEM_RESOURCE_ATTRIBUTE_ACE)) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_RESOURCE_ATTRIBUTE_ACE>(), + 4usize, + concat!("Alignment of ", stringify!(_SYSTEM_RESOURCE_ATTRIBUTE_ACE)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_RESOURCE_ATTRIBUTE_ACE>())).Header as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_RESOURCE_ATTRIBUTE_ACE), + "::", + stringify!(Header) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_RESOURCE_ATTRIBUTE_ACE>())).Mask as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_RESOURCE_ATTRIBUTE_ACE), + "::", + stringify!(Mask) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_RESOURCE_ATTRIBUTE_ACE>())).SidStart as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_RESOURCE_ATTRIBUTE_ACE), + "::", + stringify!(SidStart) + ) + ); +} +pub type SYSTEM_RESOURCE_ATTRIBUTE_ACE = _SYSTEM_RESOURCE_ATTRIBUTE_ACE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SYSTEM_SCOPED_POLICY_ID_ACE { + pub Header: ACE_HEADER, + pub Mask: ACCESS_MASK, + pub SidStart: DWORD, +} +#[test] +fn bindgen_test_layout__SYSTEM_SCOPED_POLICY_ID_ACE() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_SCOPED_POLICY_ID_ACE>(), + 12usize, + concat!("Size of: ", stringify!(_SYSTEM_SCOPED_POLICY_ID_ACE)) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_SCOPED_POLICY_ID_ACE>(), + 4usize, + concat!("Alignment of ", stringify!(_SYSTEM_SCOPED_POLICY_ID_ACE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_SCOPED_POLICY_ID_ACE>())).Header as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_SCOPED_POLICY_ID_ACE), + "::", + stringify!(Header) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_SCOPED_POLICY_ID_ACE>())).Mask as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_SCOPED_POLICY_ID_ACE), + "::", + stringify!(Mask) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_SCOPED_POLICY_ID_ACE>())).SidStart as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_SCOPED_POLICY_ID_ACE), + "::", + stringify!(SidStart) + ) + ); +} +pub type SYSTEM_SCOPED_POLICY_ID_ACE = _SYSTEM_SCOPED_POLICY_ID_ACE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SYSTEM_MANDATORY_LABEL_ACE { + pub Header: ACE_HEADER, + pub Mask: ACCESS_MASK, + pub SidStart: DWORD, +} +#[test] +fn bindgen_test_layout__SYSTEM_MANDATORY_LABEL_ACE() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_MANDATORY_LABEL_ACE>(), + 12usize, + concat!("Size of: ", stringify!(_SYSTEM_MANDATORY_LABEL_ACE)) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_MANDATORY_LABEL_ACE>(), + 4usize, + concat!("Alignment of ", stringify!(_SYSTEM_MANDATORY_LABEL_ACE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_MANDATORY_LABEL_ACE>())).Header as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_MANDATORY_LABEL_ACE), + "::", + stringify!(Header) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_MANDATORY_LABEL_ACE>())).Mask as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_MANDATORY_LABEL_ACE), + "::", + stringify!(Mask) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_MANDATORY_LABEL_ACE>())).SidStart as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_MANDATORY_LABEL_ACE), + "::", + stringify!(SidStart) + ) + ); +} +pub type SYSTEM_MANDATORY_LABEL_ACE = _SYSTEM_MANDATORY_LABEL_ACE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SYSTEM_PROCESS_TRUST_LABEL_ACE { + pub Header: ACE_HEADER, + pub Mask: ACCESS_MASK, + pub SidStart: DWORD, +} +#[test] +fn bindgen_test_layout__SYSTEM_PROCESS_TRUST_LABEL_ACE() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_PROCESS_TRUST_LABEL_ACE>(), + 12usize, + concat!("Size of: ", stringify!(_SYSTEM_PROCESS_TRUST_LABEL_ACE)) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_PROCESS_TRUST_LABEL_ACE>(), + 4usize, + concat!("Alignment of ", stringify!(_SYSTEM_PROCESS_TRUST_LABEL_ACE)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_PROCESS_TRUST_LABEL_ACE>())).Header as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_PROCESS_TRUST_LABEL_ACE), + "::", + stringify!(Header) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_PROCESS_TRUST_LABEL_ACE>())).Mask as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_PROCESS_TRUST_LABEL_ACE), + "::", + stringify!(Mask) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_PROCESS_TRUST_LABEL_ACE>())).SidStart as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_PROCESS_TRUST_LABEL_ACE), + "::", + stringify!(SidStart) + ) + ); +} +pub type SYSTEM_PROCESS_TRUST_LABEL_ACE = _SYSTEM_PROCESS_TRUST_LABEL_ACE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SYSTEM_ACCESS_FILTER_ACE { + pub Header: ACE_HEADER, + pub Mask: ACCESS_MASK, + pub SidStart: DWORD, +} +#[test] +fn bindgen_test_layout__SYSTEM_ACCESS_FILTER_ACE() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_ACCESS_FILTER_ACE>(), + 12usize, + concat!("Size of: ", stringify!(_SYSTEM_ACCESS_FILTER_ACE)) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_ACCESS_FILTER_ACE>(), + 4usize, + concat!("Alignment of ", stringify!(_SYSTEM_ACCESS_FILTER_ACE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_ACCESS_FILTER_ACE>())).Header as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_ACCESS_FILTER_ACE), + "::", + stringify!(Header) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_ACCESS_FILTER_ACE>())).Mask as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_ACCESS_FILTER_ACE), + "::", + stringify!(Mask) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_ACCESS_FILTER_ACE>())).SidStart as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_ACCESS_FILTER_ACE), + "::", + stringify!(SidStart) + ) + ); +} +pub type SYSTEM_ACCESS_FILTER_ACE = _SYSTEM_ACCESS_FILTER_ACE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SYSTEM_AUDIT_OBJECT_ACE { + pub Header: ACE_HEADER, + pub Mask: ACCESS_MASK, + pub Flags: DWORD, + pub ObjectType: GUID, + pub InheritedObjectType: GUID, + pub SidStart: DWORD, +} +#[test] +fn bindgen_test_layout__SYSTEM_AUDIT_OBJECT_ACE() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_AUDIT_OBJECT_ACE>(), + 48usize, + concat!("Size of: ", stringify!(_SYSTEM_AUDIT_OBJECT_ACE)) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_AUDIT_OBJECT_ACE>(), + 4usize, + concat!("Alignment of ", stringify!(_SYSTEM_AUDIT_OBJECT_ACE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_AUDIT_OBJECT_ACE>())).Header as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_AUDIT_OBJECT_ACE), + "::", + stringify!(Header) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_AUDIT_OBJECT_ACE>())).Mask as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_AUDIT_OBJECT_ACE), + "::", + stringify!(Mask) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_AUDIT_OBJECT_ACE>())).Flags as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_AUDIT_OBJECT_ACE), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_AUDIT_OBJECT_ACE>())).ObjectType as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_AUDIT_OBJECT_ACE), + "::", + stringify!(ObjectType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_AUDIT_OBJECT_ACE>())).InheritedObjectType as *const _ as usize + }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_AUDIT_OBJECT_ACE), + "::", + stringify!(InheritedObjectType) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_AUDIT_OBJECT_ACE>())).SidStart as *const _ as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_AUDIT_OBJECT_ACE), + "::", + stringify!(SidStart) + ) + ); +} +pub type SYSTEM_AUDIT_OBJECT_ACE = _SYSTEM_AUDIT_OBJECT_ACE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SYSTEM_ALARM_OBJECT_ACE { + pub Header: ACE_HEADER, + pub Mask: ACCESS_MASK, + pub Flags: DWORD, + pub ObjectType: GUID, + pub InheritedObjectType: GUID, + pub SidStart: DWORD, +} +#[test] +fn bindgen_test_layout__SYSTEM_ALARM_OBJECT_ACE() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_ALARM_OBJECT_ACE>(), + 48usize, + concat!("Size of: ", stringify!(_SYSTEM_ALARM_OBJECT_ACE)) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_ALARM_OBJECT_ACE>(), + 4usize, + concat!("Alignment of ", stringify!(_SYSTEM_ALARM_OBJECT_ACE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_ALARM_OBJECT_ACE>())).Header as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_ALARM_OBJECT_ACE), + "::", + stringify!(Header) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_ALARM_OBJECT_ACE>())).Mask as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_ALARM_OBJECT_ACE), + "::", + stringify!(Mask) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_ALARM_OBJECT_ACE>())).Flags as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_ALARM_OBJECT_ACE), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_ALARM_OBJECT_ACE>())).ObjectType as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_ALARM_OBJECT_ACE), + "::", + stringify!(ObjectType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_ALARM_OBJECT_ACE>())).InheritedObjectType as *const _ as usize + }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_ALARM_OBJECT_ACE), + "::", + stringify!(InheritedObjectType) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_ALARM_OBJECT_ACE>())).SidStart as *const _ as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_ALARM_OBJECT_ACE), + "::", + stringify!(SidStart) + ) + ); +} +pub type SYSTEM_ALARM_OBJECT_ACE = _SYSTEM_ALARM_OBJECT_ACE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SYSTEM_AUDIT_CALLBACK_ACE { + pub Header: ACE_HEADER, + pub Mask: ACCESS_MASK, + pub SidStart: DWORD, +} +#[test] +fn bindgen_test_layout__SYSTEM_AUDIT_CALLBACK_ACE() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_AUDIT_CALLBACK_ACE>(), + 12usize, + concat!("Size of: ", stringify!(_SYSTEM_AUDIT_CALLBACK_ACE)) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_AUDIT_CALLBACK_ACE>(), + 4usize, + concat!("Alignment of ", stringify!(_SYSTEM_AUDIT_CALLBACK_ACE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_AUDIT_CALLBACK_ACE>())).Header as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_AUDIT_CALLBACK_ACE), + "::", + stringify!(Header) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_AUDIT_CALLBACK_ACE>())).Mask as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_AUDIT_CALLBACK_ACE), + "::", + stringify!(Mask) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_AUDIT_CALLBACK_ACE>())).SidStart as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_AUDIT_CALLBACK_ACE), + "::", + stringify!(SidStart) + ) + ); +} +pub type SYSTEM_AUDIT_CALLBACK_ACE = _SYSTEM_AUDIT_CALLBACK_ACE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SYSTEM_ALARM_CALLBACK_ACE { + pub Header: ACE_HEADER, + pub Mask: ACCESS_MASK, + pub SidStart: DWORD, +} +#[test] +fn bindgen_test_layout__SYSTEM_ALARM_CALLBACK_ACE() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_ALARM_CALLBACK_ACE>(), + 12usize, + concat!("Size of: ", stringify!(_SYSTEM_ALARM_CALLBACK_ACE)) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_ALARM_CALLBACK_ACE>(), + 4usize, + concat!("Alignment of ", stringify!(_SYSTEM_ALARM_CALLBACK_ACE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_ALARM_CALLBACK_ACE>())).Header as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_ALARM_CALLBACK_ACE), + "::", + stringify!(Header) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_ALARM_CALLBACK_ACE>())).Mask as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_ALARM_CALLBACK_ACE), + "::", + stringify!(Mask) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_ALARM_CALLBACK_ACE>())).SidStart as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_ALARM_CALLBACK_ACE), + "::", + stringify!(SidStart) + ) + ); +} +pub type SYSTEM_ALARM_CALLBACK_ACE = _SYSTEM_ALARM_CALLBACK_ACE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SYSTEM_AUDIT_CALLBACK_OBJECT_ACE { + pub Header: ACE_HEADER, + pub Mask: ACCESS_MASK, + pub Flags: DWORD, + pub ObjectType: GUID, + pub InheritedObjectType: GUID, + pub SidStart: DWORD, +} +#[test] +fn bindgen_test_layout__SYSTEM_AUDIT_CALLBACK_OBJECT_ACE() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_AUDIT_CALLBACK_OBJECT_ACE>(), + 48usize, + concat!("Size of: ", stringify!(_SYSTEM_AUDIT_CALLBACK_OBJECT_ACE)) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_AUDIT_CALLBACK_OBJECT_ACE>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_SYSTEM_AUDIT_CALLBACK_OBJECT_ACE) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_AUDIT_CALLBACK_OBJECT_ACE>())).Header as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_AUDIT_CALLBACK_OBJECT_ACE), + "::", + stringify!(Header) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_AUDIT_CALLBACK_OBJECT_ACE>())).Mask as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_AUDIT_CALLBACK_OBJECT_ACE), + "::", + stringify!(Mask) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_AUDIT_CALLBACK_OBJECT_ACE>())).Flags as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_AUDIT_CALLBACK_OBJECT_ACE), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_AUDIT_CALLBACK_OBJECT_ACE>())).ObjectType as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_AUDIT_CALLBACK_OBJECT_ACE), + "::", + stringify!(ObjectType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_AUDIT_CALLBACK_OBJECT_ACE>())).InheritedObjectType as *const _ + as usize + }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_AUDIT_CALLBACK_OBJECT_ACE), + "::", + stringify!(InheritedObjectType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_AUDIT_CALLBACK_OBJECT_ACE>())).SidStart as *const _ as usize + }, + 44usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_AUDIT_CALLBACK_OBJECT_ACE), + "::", + stringify!(SidStart) + ) + ); +} +pub type SYSTEM_AUDIT_CALLBACK_OBJECT_ACE = _SYSTEM_AUDIT_CALLBACK_OBJECT_ACE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SYSTEM_ALARM_CALLBACK_OBJECT_ACE { + pub Header: ACE_HEADER, + pub Mask: ACCESS_MASK, + pub Flags: DWORD, + pub ObjectType: GUID, + pub InheritedObjectType: GUID, + pub SidStart: DWORD, +} +#[test] +fn bindgen_test_layout__SYSTEM_ALARM_CALLBACK_OBJECT_ACE() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_ALARM_CALLBACK_OBJECT_ACE>(), + 48usize, + concat!("Size of: ", stringify!(_SYSTEM_ALARM_CALLBACK_OBJECT_ACE)) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_ALARM_CALLBACK_OBJECT_ACE>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_SYSTEM_ALARM_CALLBACK_OBJECT_ACE) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_ALARM_CALLBACK_OBJECT_ACE>())).Header as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_ALARM_CALLBACK_OBJECT_ACE), + "::", + stringify!(Header) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_ALARM_CALLBACK_OBJECT_ACE>())).Mask as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_ALARM_CALLBACK_OBJECT_ACE), + "::", + stringify!(Mask) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_ALARM_CALLBACK_OBJECT_ACE>())).Flags as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_ALARM_CALLBACK_OBJECT_ACE), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_ALARM_CALLBACK_OBJECT_ACE>())).ObjectType as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_ALARM_CALLBACK_OBJECT_ACE), + "::", + stringify!(ObjectType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_ALARM_CALLBACK_OBJECT_ACE>())).InheritedObjectType as *const _ + as usize + }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_ALARM_CALLBACK_OBJECT_ACE), + "::", + stringify!(InheritedObjectType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_ALARM_CALLBACK_OBJECT_ACE>())).SidStart as *const _ as usize + }, + 44usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_ALARM_CALLBACK_OBJECT_ACE), + "::", + stringify!(SidStart) + ) + ); +} +pub type SYSTEM_ALARM_CALLBACK_OBJECT_ACE = _SYSTEM_ALARM_CALLBACK_OBJECT_ACE; +pub type SECURITY_DESCRIPTOR_CONTROL = WORD; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SECURITY_DESCRIPTOR_RELATIVE { + pub Revision: BYTE, + pub Sbz1: BYTE, + pub Control: SECURITY_DESCRIPTOR_CONTROL, + pub Owner: DWORD, + pub Group: DWORD, + pub Sacl: DWORD, + pub Dacl: DWORD, +} +#[test] +fn bindgen_test_layout__SECURITY_DESCRIPTOR_RELATIVE() { + assert_eq!( + ::std::mem::size_of::<_SECURITY_DESCRIPTOR_RELATIVE>(), + 20usize, + concat!("Size of: ", stringify!(_SECURITY_DESCRIPTOR_RELATIVE)) + ); + assert_eq!( + ::std::mem::align_of::<_SECURITY_DESCRIPTOR_RELATIVE>(), + 4usize, + concat!("Alignment of ", stringify!(_SECURITY_DESCRIPTOR_RELATIVE)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SECURITY_DESCRIPTOR_RELATIVE>())).Revision as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_DESCRIPTOR_RELATIVE), + "::", + stringify!(Revision) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SECURITY_DESCRIPTOR_RELATIVE>())).Sbz1 as *const _ as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_DESCRIPTOR_RELATIVE), + "::", + stringify!(Sbz1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SECURITY_DESCRIPTOR_RELATIVE>())).Control as *const _ as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_DESCRIPTOR_RELATIVE), + "::", + stringify!(Control) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SECURITY_DESCRIPTOR_RELATIVE>())).Owner as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_DESCRIPTOR_RELATIVE), + "::", + stringify!(Owner) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SECURITY_DESCRIPTOR_RELATIVE>())).Group as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_DESCRIPTOR_RELATIVE), + "::", + stringify!(Group) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SECURITY_DESCRIPTOR_RELATIVE>())).Sacl as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_DESCRIPTOR_RELATIVE), + "::", + stringify!(Sacl) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SECURITY_DESCRIPTOR_RELATIVE>())).Dacl as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_DESCRIPTOR_RELATIVE), + "::", + stringify!(Dacl) + ) + ); +} +pub type SECURITY_DESCRIPTOR_RELATIVE = _SECURITY_DESCRIPTOR_RELATIVE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SECURITY_DESCRIPTOR { + pub Revision: BYTE, + pub Sbz1: BYTE, + pub Control: SECURITY_DESCRIPTOR_CONTROL, + pub Owner: PSID, + pub Group: PSID, + pub Sacl: PACL, + pub Dacl: PACL, +} +#[test] +fn bindgen_test_layout__SECURITY_DESCRIPTOR() { + assert_eq!( + ::std::mem::size_of::<_SECURITY_DESCRIPTOR>(), + 40usize, + concat!("Size of: ", stringify!(_SECURITY_DESCRIPTOR)) + ); + assert_eq!( + ::std::mem::align_of::<_SECURITY_DESCRIPTOR>(), + 8usize, + concat!("Alignment of ", stringify!(_SECURITY_DESCRIPTOR)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SECURITY_DESCRIPTOR>())).Revision as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_DESCRIPTOR), + "::", + stringify!(Revision) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SECURITY_DESCRIPTOR>())).Sbz1 as *const _ as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_DESCRIPTOR), + "::", + stringify!(Sbz1) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SECURITY_DESCRIPTOR>())).Control as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_DESCRIPTOR), + "::", + stringify!(Control) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SECURITY_DESCRIPTOR>())).Owner as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_DESCRIPTOR), + "::", + stringify!(Owner) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SECURITY_DESCRIPTOR>())).Group as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_DESCRIPTOR), + "::", + stringify!(Group) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SECURITY_DESCRIPTOR>())).Sacl as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_DESCRIPTOR), + "::", + stringify!(Sacl) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SECURITY_DESCRIPTOR>())).Dacl as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_DESCRIPTOR), + "::", + stringify!(Dacl) + ) + ); +} +pub type SECURITY_DESCRIPTOR = _SECURITY_DESCRIPTOR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SECURITY_OBJECT_AI_PARAMS { + pub Size: DWORD, + pub ConstraintMask: DWORD, +} +#[test] +fn bindgen_test_layout__SECURITY_OBJECT_AI_PARAMS() { + assert_eq!( + ::std::mem::size_of::<_SECURITY_OBJECT_AI_PARAMS>(), + 8usize, + concat!("Size of: ", stringify!(_SECURITY_OBJECT_AI_PARAMS)) + ); + assert_eq!( + ::std::mem::align_of::<_SECURITY_OBJECT_AI_PARAMS>(), + 4usize, + concat!("Alignment of ", stringify!(_SECURITY_OBJECT_AI_PARAMS)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SECURITY_OBJECT_AI_PARAMS>())).Size as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_OBJECT_AI_PARAMS), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SECURITY_OBJECT_AI_PARAMS>())).ConstraintMask as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_OBJECT_AI_PARAMS), + "::", + stringify!(ConstraintMask) + ) + ); +} +pub type SECURITY_OBJECT_AI_PARAMS = _SECURITY_OBJECT_AI_PARAMS; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _OBJECT_TYPE_LIST { + pub Level: WORD, + pub Sbz: WORD, + pub ObjectType: *mut GUID, +} +#[test] +fn bindgen_test_layout__OBJECT_TYPE_LIST() { + assert_eq!( + ::std::mem::size_of::<_OBJECT_TYPE_LIST>(), + 16usize, + concat!("Size of: ", stringify!(_OBJECT_TYPE_LIST)) + ); + assert_eq!( + ::std::mem::align_of::<_OBJECT_TYPE_LIST>(), + 8usize, + concat!("Alignment of ", stringify!(_OBJECT_TYPE_LIST)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_OBJECT_TYPE_LIST>())).Level as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_OBJECT_TYPE_LIST), + "::", + stringify!(Level) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_OBJECT_TYPE_LIST>())).Sbz as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_OBJECT_TYPE_LIST), + "::", + stringify!(Sbz) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_OBJECT_TYPE_LIST>())).ObjectType as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_OBJECT_TYPE_LIST), + "::", + stringify!(ObjectType) + ) + ); +} +pub type POBJECT_TYPE_LIST = *mut _OBJECT_TYPE_LIST; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _PRIVILEGE_SET { + pub PrivilegeCount: DWORD, + pub Control: DWORD, + pub Privilege: [LUID_AND_ATTRIBUTES; 1usize], +} +#[test] +fn bindgen_test_layout__PRIVILEGE_SET() { + assert_eq!( + ::std::mem::size_of::<_PRIVILEGE_SET>(), + 20usize, + concat!("Size of: ", stringify!(_PRIVILEGE_SET)) + ); + assert_eq!( + ::std::mem::align_of::<_PRIVILEGE_SET>(), + 4usize, + concat!("Alignment of ", stringify!(_PRIVILEGE_SET)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_PRIVILEGE_SET>())).PrivilegeCount as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_PRIVILEGE_SET), + "::", + stringify!(PrivilegeCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_PRIVILEGE_SET>())).Control as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_PRIVILEGE_SET), + "::", + stringify!(Control) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_PRIVILEGE_SET>())).Privilege as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_PRIVILEGE_SET), + "::", + stringify!(Privilege) + ) + ); +} +pub type PPRIVILEGE_SET = *mut _PRIVILEGE_SET; +pub type ACCESS_REASON = DWORD; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _ACCESS_REASONS { + pub Data: [ACCESS_REASON; 32usize], +} +#[test] +fn bindgen_test_layout__ACCESS_REASONS() { + assert_eq!( + ::std::mem::size_of::<_ACCESS_REASONS>(), + 128usize, + concat!("Size of: ", stringify!(_ACCESS_REASONS)) + ); + assert_eq!( + ::std::mem::align_of::<_ACCESS_REASONS>(), + 4usize, + concat!("Alignment of ", stringify!(_ACCESS_REASONS)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_ACCESS_REASONS>())).Data as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_ACCESS_REASONS), + "::", + stringify!(Data) + ) + ); +} +pub type PACCESS_REASONS = *mut _ACCESS_REASONS; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SE_SECURITY_DESCRIPTOR { + pub Size: DWORD, + pub Flags: DWORD, + pub SecurityDescriptor: PSECURITY_DESCRIPTOR, +} +#[test] +fn bindgen_test_layout__SE_SECURITY_DESCRIPTOR() { + assert_eq!( + ::std::mem::size_of::<_SE_SECURITY_DESCRIPTOR>(), + 16usize, + concat!("Size of: ", stringify!(_SE_SECURITY_DESCRIPTOR)) + ); + assert_eq!( + ::std::mem::align_of::<_SE_SECURITY_DESCRIPTOR>(), + 8usize, + concat!("Alignment of ", stringify!(_SE_SECURITY_DESCRIPTOR)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SE_SECURITY_DESCRIPTOR>())).Size as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SE_SECURITY_DESCRIPTOR), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SE_SECURITY_DESCRIPTOR>())).Flags as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SE_SECURITY_DESCRIPTOR), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SE_SECURITY_DESCRIPTOR>())).SecurityDescriptor as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SE_SECURITY_DESCRIPTOR), + "::", + stringify!(SecurityDescriptor) + ) + ); +} +pub type SE_SECURITY_DESCRIPTOR = _SE_SECURITY_DESCRIPTOR; +pub type PSE_SECURITY_DESCRIPTOR = *mut _SE_SECURITY_DESCRIPTOR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SE_ACCESS_REQUEST { + pub Size: DWORD, + pub SeSecurityDescriptor: PSE_SECURITY_DESCRIPTOR, + pub DesiredAccess: ACCESS_MASK, + pub PreviouslyGrantedAccess: ACCESS_MASK, + pub PrincipalSelfSid: PSID, + pub GenericMapping: PGENERIC_MAPPING, + pub ObjectTypeListCount: DWORD, + pub ObjectTypeList: POBJECT_TYPE_LIST, +} +#[test] +fn bindgen_test_layout__SE_ACCESS_REQUEST() { + assert_eq!( + ::std::mem::size_of::<_SE_ACCESS_REQUEST>(), + 56usize, + concat!("Size of: ", stringify!(_SE_ACCESS_REQUEST)) + ); + assert_eq!( + ::std::mem::align_of::<_SE_ACCESS_REQUEST>(), + 8usize, + concat!("Alignment of ", stringify!(_SE_ACCESS_REQUEST)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SE_ACCESS_REQUEST>())).Size as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SE_ACCESS_REQUEST), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SE_ACCESS_REQUEST>())).SeSecurityDescriptor as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SE_ACCESS_REQUEST), + "::", + stringify!(SeSecurityDescriptor) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SE_ACCESS_REQUEST>())).DesiredAccess as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SE_ACCESS_REQUEST), + "::", + stringify!(DesiredAccess) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SE_ACCESS_REQUEST>())).PreviouslyGrantedAccess as *const _ as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_SE_ACCESS_REQUEST), + "::", + stringify!(PreviouslyGrantedAccess) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SE_ACCESS_REQUEST>())).PrincipalSelfSid as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SE_ACCESS_REQUEST), + "::", + stringify!(PrincipalSelfSid) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SE_ACCESS_REQUEST>())).GenericMapping as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_SE_ACCESS_REQUEST), + "::", + stringify!(GenericMapping) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SE_ACCESS_REQUEST>())).ObjectTypeListCount as *const _ as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_SE_ACCESS_REQUEST), + "::", + stringify!(ObjectTypeListCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SE_ACCESS_REQUEST>())).ObjectTypeList as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_SE_ACCESS_REQUEST), + "::", + stringify!(ObjectTypeList) + ) + ); +} +pub type SE_ACCESS_REQUEST = _SE_ACCESS_REQUEST; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SE_ACCESS_REPLY { + pub Size: DWORD, + pub ResultListCount: DWORD, + pub GrantedAccess: PACCESS_MASK, + pub AccessStatus: PDWORD, + pub AccessReason: PACCESS_REASONS, + pub Privileges: *mut PPRIVILEGE_SET, +} +#[test] +fn bindgen_test_layout__SE_ACCESS_REPLY() { + assert_eq!( + ::std::mem::size_of::<_SE_ACCESS_REPLY>(), + 40usize, + concat!("Size of: ", stringify!(_SE_ACCESS_REPLY)) + ); + assert_eq!( + ::std::mem::align_of::<_SE_ACCESS_REPLY>(), + 8usize, + concat!("Alignment of ", stringify!(_SE_ACCESS_REPLY)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SE_ACCESS_REPLY>())).Size as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SE_ACCESS_REPLY), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SE_ACCESS_REPLY>())).ResultListCount as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SE_ACCESS_REPLY), + "::", + stringify!(ResultListCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SE_ACCESS_REPLY>())).GrantedAccess as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SE_ACCESS_REPLY), + "::", + stringify!(GrantedAccess) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SE_ACCESS_REPLY>())).AccessStatus as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SE_ACCESS_REPLY), + "::", + stringify!(AccessStatus) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SE_ACCESS_REPLY>())).AccessReason as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SE_ACCESS_REPLY), + "::", + stringify!(AccessReason) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SE_ACCESS_REPLY>())).Privileges as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_SE_ACCESS_REPLY), + "::", + stringify!(Privileges) + ) + ); +} +pub type SE_ACCESS_REPLY = _SE_ACCESS_REPLY; +pub const _SECURITY_IMPERSONATION_LEVEL_SecurityAnonymous: _SECURITY_IMPERSONATION_LEVEL = 0; +pub const _SECURITY_IMPERSONATION_LEVEL_SecurityIdentification: _SECURITY_IMPERSONATION_LEVEL = 1; +pub const _SECURITY_IMPERSONATION_LEVEL_SecurityImpersonation: _SECURITY_IMPERSONATION_LEVEL = 2; +pub const _SECURITY_IMPERSONATION_LEVEL_SecurityDelegation: _SECURITY_IMPERSONATION_LEVEL = 3; +pub type _SECURITY_IMPERSONATION_LEVEL = ::std::os::raw::c_int; +pub use self::_SECURITY_IMPERSONATION_LEVEL as SECURITY_IMPERSONATION_LEVEL; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _TOKEN_USER { + pub User: SID_AND_ATTRIBUTES, +} +#[test] +fn bindgen_test_layout__TOKEN_USER() { + assert_eq!( + ::std::mem::size_of::<_TOKEN_USER>(), + 16usize, + concat!("Size of: ", stringify!(_TOKEN_USER)) + ); + assert_eq!( + ::std::mem::align_of::<_TOKEN_USER>(), + 8usize, + concat!("Alignment of ", stringify!(_TOKEN_USER)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_TOKEN_USER>())).User as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_TOKEN_USER), + "::", + stringify!(User) + ) + ); +} +pub type TOKEN_USER = _TOKEN_USER; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SE_TOKEN_USER { + pub __bindgen_anon_1: _SE_TOKEN_USER__bindgen_ty_1, + pub __bindgen_anon_2: _SE_TOKEN_USER__bindgen_ty_2, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _SE_TOKEN_USER__bindgen_ty_1 { + pub TokenUser: TOKEN_USER, + pub User: SID_AND_ATTRIBUTES, + _bindgen_union_align: [u64; 2usize], +} +#[test] +fn bindgen_test_layout__SE_TOKEN_USER__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_SE_TOKEN_USER__bindgen_ty_1>(), + 16usize, + concat!("Size of: ", stringify!(_SE_TOKEN_USER__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<_SE_TOKEN_USER__bindgen_ty_1>(), + 8usize, + concat!("Alignment of ", stringify!(_SE_TOKEN_USER__bindgen_ty_1)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SE_TOKEN_USER__bindgen_ty_1>())).TokenUser as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SE_TOKEN_USER__bindgen_ty_1), + "::", + stringify!(TokenUser) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SE_TOKEN_USER__bindgen_ty_1>())).User as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SE_TOKEN_USER__bindgen_ty_1), + "::", + stringify!(User) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _SE_TOKEN_USER__bindgen_ty_2 { + pub Sid: SID, + pub Buffer: [BYTE; 68usize], + _bindgen_union_align: [u32; 17usize], +} +#[test] +fn bindgen_test_layout__SE_TOKEN_USER__bindgen_ty_2() { + assert_eq!( + ::std::mem::size_of::<_SE_TOKEN_USER__bindgen_ty_2>(), + 68usize, + concat!("Size of: ", stringify!(_SE_TOKEN_USER__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::<_SE_TOKEN_USER__bindgen_ty_2>(), + 4usize, + concat!("Alignment of ", stringify!(_SE_TOKEN_USER__bindgen_ty_2)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SE_TOKEN_USER__bindgen_ty_2>())).Sid as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SE_TOKEN_USER__bindgen_ty_2), + "::", + stringify!(Sid) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SE_TOKEN_USER__bindgen_ty_2>())).Buffer as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SE_TOKEN_USER__bindgen_ty_2), + "::", + stringify!(Buffer) + ) + ); +} +#[test] +fn bindgen_test_layout__SE_TOKEN_USER() { + assert_eq!( + ::std::mem::size_of::<_SE_TOKEN_USER>(), + 88usize, + concat!("Size of: ", stringify!(_SE_TOKEN_USER)) + ); + assert_eq!( + ::std::mem::align_of::<_SE_TOKEN_USER>(), + 8usize, + concat!("Alignment of ", stringify!(_SE_TOKEN_USER)) + ); +} +pub type SE_TOKEN_USER = _SE_TOKEN_USER; +pub type SECURITY_CONTEXT_TRACKING_MODE = BOOLEAN; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SECURITY_QUALITY_OF_SERVICE { + pub Length: DWORD, + pub ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL, + pub ContextTrackingMode: SECURITY_CONTEXT_TRACKING_MODE, + pub EffectiveOnly: BOOLEAN, +} +#[test] +fn bindgen_test_layout__SECURITY_QUALITY_OF_SERVICE() { + assert_eq!( + ::std::mem::size_of::<_SECURITY_QUALITY_OF_SERVICE>(), + 12usize, + concat!("Size of: ", stringify!(_SECURITY_QUALITY_OF_SERVICE)) + ); + assert_eq!( + ::std::mem::align_of::<_SECURITY_QUALITY_OF_SERVICE>(), + 4usize, + concat!("Alignment of ", stringify!(_SECURITY_QUALITY_OF_SERVICE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SECURITY_QUALITY_OF_SERVICE>())).Length as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_QUALITY_OF_SERVICE), + "::", + stringify!(Length) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SECURITY_QUALITY_OF_SERVICE>())).ImpersonationLevel as *const _ + as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_QUALITY_OF_SERVICE), + "::", + stringify!(ImpersonationLevel) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SECURITY_QUALITY_OF_SERVICE>())).ContextTrackingMode as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_QUALITY_OF_SERVICE), + "::", + stringify!(ContextTrackingMode) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SECURITY_QUALITY_OF_SERVICE>())).EffectiveOnly as *const _ as usize + }, + 9usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_QUALITY_OF_SERVICE), + "::", + stringify!(EffectiveOnly) + ) + ); +} +pub type SECURITY_QUALITY_OF_SERVICE = _SECURITY_QUALITY_OF_SERVICE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SE_IMPERSONATION_STATE { + pub Token: PACCESS_TOKEN, + pub CopyOnOpen: BOOLEAN, + pub EffectiveOnly: BOOLEAN, + pub Level: SECURITY_IMPERSONATION_LEVEL, +} +#[test] +fn bindgen_test_layout__SE_IMPERSONATION_STATE() { + assert_eq!( + ::std::mem::size_of::<_SE_IMPERSONATION_STATE>(), + 16usize, + concat!("Size of: ", stringify!(_SE_IMPERSONATION_STATE)) + ); + assert_eq!( + ::std::mem::align_of::<_SE_IMPERSONATION_STATE>(), + 8usize, + concat!("Alignment of ", stringify!(_SE_IMPERSONATION_STATE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SE_IMPERSONATION_STATE>())).Token as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SE_IMPERSONATION_STATE), + "::", + stringify!(Token) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SE_IMPERSONATION_STATE>())).CopyOnOpen as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SE_IMPERSONATION_STATE), + "::", + stringify!(CopyOnOpen) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SE_IMPERSONATION_STATE>())).EffectiveOnly as *const _ as usize + }, + 9usize, + concat!( + "Offset of field: ", + stringify!(_SE_IMPERSONATION_STATE), + "::", + stringify!(EffectiveOnly) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SE_IMPERSONATION_STATE>())).Level as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SE_IMPERSONATION_STATE), + "::", + stringify!(Level) + ) + ); +} +pub type SE_IMPERSONATION_STATE = _SE_IMPERSONATION_STATE; +pub type SECURITY_INFORMATION = DWORD; +pub type SE_SIGNING_LEVEL = BYTE; +pub const _SE_IMAGE_SIGNATURE_TYPE_SeImageSignatureNone: _SE_IMAGE_SIGNATURE_TYPE = 0; +pub const _SE_IMAGE_SIGNATURE_TYPE_SeImageSignatureEmbedded: _SE_IMAGE_SIGNATURE_TYPE = 1; +pub const _SE_IMAGE_SIGNATURE_TYPE_SeImageSignatureCache: _SE_IMAGE_SIGNATURE_TYPE = 2; +pub const _SE_IMAGE_SIGNATURE_TYPE_SeImageSignatureCatalogCached: _SE_IMAGE_SIGNATURE_TYPE = 3; +pub const _SE_IMAGE_SIGNATURE_TYPE_SeImageSignatureCatalogNotCached: _SE_IMAGE_SIGNATURE_TYPE = 4; +pub const _SE_IMAGE_SIGNATURE_TYPE_SeImageSignatureCatalogHint: _SE_IMAGE_SIGNATURE_TYPE = 5; +pub const _SE_IMAGE_SIGNATURE_TYPE_SeImageSignaturePackageCatalog: _SE_IMAGE_SIGNATURE_TYPE = 6; +pub type _SE_IMAGE_SIGNATURE_TYPE = ::std::os::raw::c_int; +pub use self::_SE_IMAGE_SIGNATURE_TYPE as SE_IMAGE_SIGNATURE_TYPE; +pub const _SE_LEARNING_MODE_DATA_TYPE_SeLearningModeInvalidType: _SE_LEARNING_MODE_DATA_TYPE = 0; +pub const _SE_LEARNING_MODE_DATA_TYPE_SeLearningModeSettings: _SE_LEARNING_MODE_DATA_TYPE = 1; +pub const _SE_LEARNING_MODE_DATA_TYPE_SeLearningModeMax: _SE_LEARNING_MODE_DATA_TYPE = 2; +pub type _SE_LEARNING_MODE_DATA_TYPE = ::std::os::raw::c_int; +pub use self::_SE_LEARNING_MODE_DATA_TYPE as SE_LEARNING_MODE_DATA_TYPE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SECURITY_CAPABILITIES { + pub AppContainerSid: PSID, + pub Capabilities: PSID_AND_ATTRIBUTES, + pub CapabilityCount: DWORD, + pub Reserved: DWORD, +} +#[test] +fn bindgen_test_layout__SECURITY_CAPABILITIES() { + assert_eq!( + ::std::mem::size_of::<_SECURITY_CAPABILITIES>(), + 24usize, + concat!("Size of: ", stringify!(_SECURITY_CAPABILITIES)) + ); + assert_eq!( + ::std::mem::align_of::<_SECURITY_CAPABILITIES>(), + 8usize, + concat!("Alignment of ", stringify!(_SECURITY_CAPABILITIES)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SECURITY_CAPABILITIES>())).AppContainerSid as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_CAPABILITIES), + "::", + stringify!(AppContainerSid) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SECURITY_CAPABILITIES>())).Capabilities as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_CAPABILITIES), + "::", + stringify!(Capabilities) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SECURITY_CAPABILITIES>())).CapabilityCount as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_CAPABILITIES), + "::", + stringify!(CapabilityCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SECURITY_CAPABILITIES>())).Reserved as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_CAPABILITIES), + "::", + stringify!(Reserved) + ) + ); +} +pub type SECURITY_CAPABILITIES = _SECURITY_CAPABILITIES; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SILOOBJECT_BASIC_INFORMATION { + pub SiloId: DWORD, + pub SiloParentId: DWORD, + pub NumberOfProcesses: DWORD, + pub IsInServerSilo: BOOLEAN, + pub Reserved: [BYTE; 3usize], +} +#[test] +fn bindgen_test_layout__SILOOBJECT_BASIC_INFORMATION() { + assert_eq!( + ::std::mem::size_of::<_SILOOBJECT_BASIC_INFORMATION>(), + 16usize, + concat!("Size of: ", stringify!(_SILOOBJECT_BASIC_INFORMATION)) + ); + assert_eq!( + ::std::mem::align_of::<_SILOOBJECT_BASIC_INFORMATION>(), + 4usize, + concat!("Alignment of ", stringify!(_SILOOBJECT_BASIC_INFORMATION)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SILOOBJECT_BASIC_INFORMATION>())).SiloId as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SILOOBJECT_BASIC_INFORMATION), + "::", + stringify!(SiloId) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SILOOBJECT_BASIC_INFORMATION>())).SiloParentId as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SILOOBJECT_BASIC_INFORMATION), + "::", + stringify!(SiloParentId) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SILOOBJECT_BASIC_INFORMATION>())).NumberOfProcesses as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SILOOBJECT_BASIC_INFORMATION), + "::", + stringify!(NumberOfProcesses) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SILOOBJECT_BASIC_INFORMATION>())).IsInServerSilo as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SILOOBJECT_BASIC_INFORMATION), + "::", + stringify!(IsInServerSilo) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SILOOBJECT_BASIC_INFORMATION>())).Reserved as *const _ as usize + }, + 13usize, + concat!( + "Offset of field: ", + stringify!(_SILOOBJECT_BASIC_INFORMATION), + "::", + stringify!(Reserved) + ) + ); +} +pub type SILOOBJECT_BASIC_INFORMATION = _SILOOBJECT_BASIC_INFORMATION; +pub const _SERVERSILO_STATE_SERVERSILO_INITING: _SERVERSILO_STATE = 0; +pub const _SERVERSILO_STATE_SERVERSILO_STARTED: _SERVERSILO_STATE = 1; +pub const _SERVERSILO_STATE_SERVERSILO_SHUTTING_DOWN: _SERVERSILO_STATE = 2; +pub const _SERVERSILO_STATE_SERVERSILO_TERMINATING: _SERVERSILO_STATE = 3; +pub const _SERVERSILO_STATE_SERVERSILO_TERMINATED: _SERVERSILO_STATE = 4; +pub type _SERVERSILO_STATE = ::std::os::raw::c_int; +pub use self::_SERVERSILO_STATE as SERVERSILO_STATE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVERSILO_BASIC_INFORMATION { + pub ServiceSessionId: DWORD, + pub State: SERVERSILO_STATE, + pub ExitStatus: DWORD, +} +#[test] +fn bindgen_test_layout__SERVERSILO_BASIC_INFORMATION() { + assert_eq!( + ::std::mem::size_of::<_SERVERSILO_BASIC_INFORMATION>(), + 12usize, + concat!("Size of: ", stringify!(_SERVERSILO_BASIC_INFORMATION)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVERSILO_BASIC_INFORMATION>(), + 4usize, + concat!("Alignment of ", stringify!(_SERVERSILO_BASIC_INFORMATION)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVERSILO_BASIC_INFORMATION>())).ServiceSessionId as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVERSILO_BASIC_INFORMATION), + "::", + stringify!(ServiceSessionId) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVERSILO_BASIC_INFORMATION>())).State as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SERVERSILO_BASIC_INFORMATION), + "::", + stringify!(State) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVERSILO_BASIC_INFORMATION>())).ExitStatus as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SERVERSILO_BASIC_INFORMATION), + "::", + stringify!(ExitStatus) + ) + ); +} +pub type SERVERSILO_BASIC_INFORMATION = _SERVERSILO_BASIC_INFORMATION; +pub const _LOGICAL_PROCESSOR_RELATIONSHIP_RelationProcessorCore: _LOGICAL_PROCESSOR_RELATIONSHIP = + 0; +pub const _LOGICAL_PROCESSOR_RELATIONSHIP_RelationNumaNode: _LOGICAL_PROCESSOR_RELATIONSHIP = 1; +pub const _LOGICAL_PROCESSOR_RELATIONSHIP_RelationCache: _LOGICAL_PROCESSOR_RELATIONSHIP = 2; +pub const _LOGICAL_PROCESSOR_RELATIONSHIP_RelationProcessorPackage: + _LOGICAL_PROCESSOR_RELATIONSHIP = 3; +pub const _LOGICAL_PROCESSOR_RELATIONSHIP_RelationGroup: _LOGICAL_PROCESSOR_RELATIONSHIP = 4; +pub const _LOGICAL_PROCESSOR_RELATIONSHIP_RelationAll: _LOGICAL_PROCESSOR_RELATIONSHIP = 65535; +pub type _LOGICAL_PROCESSOR_RELATIONSHIP = ::std::os::raw::c_int; +pub use self::_LOGICAL_PROCESSOR_RELATIONSHIP as LOGICAL_PROCESSOR_RELATIONSHIP; +pub const _PROCESSOR_CACHE_TYPE_CacheUnified: _PROCESSOR_CACHE_TYPE = 0; +pub const _PROCESSOR_CACHE_TYPE_CacheInstruction: _PROCESSOR_CACHE_TYPE = 1; +pub const _PROCESSOR_CACHE_TYPE_CacheData: _PROCESSOR_CACHE_TYPE = 2; +pub const _PROCESSOR_CACHE_TYPE_CacheTrace: _PROCESSOR_CACHE_TYPE = 3; +pub type _PROCESSOR_CACHE_TYPE = ::std::os::raw::c_int; +pub use self::_PROCESSOR_CACHE_TYPE as PROCESSOR_CACHE_TYPE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _CACHE_DESCRIPTOR { + pub Level: BYTE, + pub Associativity: BYTE, + pub LineSize: WORD, + pub Size: DWORD, + pub Type: PROCESSOR_CACHE_TYPE, +} +#[test] +fn bindgen_test_layout__CACHE_DESCRIPTOR() { + assert_eq!( + ::std::mem::size_of::<_CACHE_DESCRIPTOR>(), + 12usize, + concat!("Size of: ", stringify!(_CACHE_DESCRIPTOR)) + ); + assert_eq!( + ::std::mem::align_of::<_CACHE_DESCRIPTOR>(), + 4usize, + concat!("Alignment of ", stringify!(_CACHE_DESCRIPTOR)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CACHE_DESCRIPTOR>())).Level as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_CACHE_DESCRIPTOR), + "::", + stringify!(Level) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CACHE_DESCRIPTOR>())).Associativity as *const _ as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(_CACHE_DESCRIPTOR), + "::", + stringify!(Associativity) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CACHE_DESCRIPTOR>())).LineSize as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_CACHE_DESCRIPTOR), + "::", + stringify!(LineSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CACHE_DESCRIPTOR>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_CACHE_DESCRIPTOR), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CACHE_DESCRIPTOR>())).Type as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_CACHE_DESCRIPTOR), + "::", + stringify!(Type) + ) + ); +} +pub type CACHE_DESCRIPTOR = _CACHE_DESCRIPTOR; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION { + pub ProcessorMask: ULONG_PTR, + pub Relationship: LOGICAL_PROCESSOR_RELATIONSHIP, + pub __bindgen_anon_1: _SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1 { + pub ProcessorCore: _SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1__bindgen_ty_1, + pub NumaNode: _SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1__bindgen_ty_2, + pub Cache: CACHE_DESCRIPTOR, + pub Reserved: [ULONGLONG; 2usize], + _bindgen_union_align: [u64; 2usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1__bindgen_ty_1 { + pub Flags: BYTE, +} +#[test] +fn bindgen_test_layout__SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1__bindgen_ty_1>(), + 1usize, + concat!( + "Size of: ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1__bindgen_ty_1>(), + 1usize, + concat!( + "Alignment of ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1__bindgen_ty_1>())) + .Flags as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(Flags) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1__bindgen_ty_2 { + pub NodeNumber: DWORD, +} +#[test] +fn bindgen_test_layout__SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1__bindgen_ty_2() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1__bindgen_ty_2>(), + 4usize, + concat!( + "Size of: ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1__bindgen_ty_2>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1__bindgen_ty_2>())) + .NodeNumber as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(NodeNumber) + ) + ); +} +#[test] +fn bindgen_test_layout__SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1>(), + 16usize, + concat!( + "Size of: ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1>())).ProcessorCore + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1), + "::", + stringify!(ProcessorCore) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1>())).NumaNode + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1), + "::", + stringify!(NumaNode) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1>())).Cache + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1), + "::", + stringify!(Cache) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1>())).Reserved + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION__bindgen_ty_1), + "::", + stringify!(Reserved) + ) + ); +} +#[test] +fn bindgen_test_layout__SYSTEM_LOGICAL_PROCESSOR_INFORMATION() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION>(), + 32usize, + concat!( + "Size of: ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION>())).ProcessorMask as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION), + "::", + stringify!(ProcessorMask) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION>())).Relationship as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION), + "::", + stringify!(Relationship) + ) + ); +} +pub type SYSTEM_LOGICAL_PROCESSOR_INFORMATION = _SYSTEM_LOGICAL_PROCESSOR_INFORMATION; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _PROCESSOR_RELATIONSHIP { + pub Flags: BYTE, + pub EfficiencyClass: BYTE, + pub Reserved: [BYTE; 20usize], + pub GroupCount: WORD, + pub GroupMask: [GROUP_AFFINITY; 1usize], +} +#[test] +fn bindgen_test_layout__PROCESSOR_RELATIONSHIP() { + assert_eq!( + ::std::mem::size_of::<_PROCESSOR_RELATIONSHIP>(), + 40usize, + concat!("Size of: ", stringify!(_PROCESSOR_RELATIONSHIP)) + ); + assert_eq!( + ::std::mem::align_of::<_PROCESSOR_RELATIONSHIP>(), + 8usize, + concat!("Alignment of ", stringify!(_PROCESSOR_RELATIONSHIP)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_PROCESSOR_RELATIONSHIP>())).Flags as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_PROCESSOR_RELATIONSHIP), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_PROCESSOR_RELATIONSHIP>())).EfficiencyClass as *const _ as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(_PROCESSOR_RELATIONSHIP), + "::", + stringify!(EfficiencyClass) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_PROCESSOR_RELATIONSHIP>())).Reserved as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_PROCESSOR_RELATIONSHIP), + "::", + stringify!(Reserved) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_PROCESSOR_RELATIONSHIP>())).GroupCount as *const _ as usize }, + 22usize, + concat!( + "Offset of field: ", + stringify!(_PROCESSOR_RELATIONSHIP), + "::", + stringify!(GroupCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_PROCESSOR_RELATIONSHIP>())).GroupMask as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_PROCESSOR_RELATIONSHIP), + "::", + stringify!(GroupMask) + ) + ); +} +pub type PROCESSOR_RELATIONSHIP = _PROCESSOR_RELATIONSHIP; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _NUMA_NODE_RELATIONSHIP { + pub NodeNumber: DWORD, + pub Reserved: [BYTE; 20usize], + pub GroupMask: GROUP_AFFINITY, +} +#[test] +fn bindgen_test_layout__NUMA_NODE_RELATIONSHIP() { + assert_eq!( + ::std::mem::size_of::<_NUMA_NODE_RELATIONSHIP>(), + 40usize, + concat!("Size of: ", stringify!(_NUMA_NODE_RELATIONSHIP)) + ); + assert_eq!( + ::std::mem::align_of::<_NUMA_NODE_RELATIONSHIP>(), + 8usize, + concat!("Alignment of ", stringify!(_NUMA_NODE_RELATIONSHIP)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_NUMA_NODE_RELATIONSHIP>())).NodeNumber as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_NUMA_NODE_RELATIONSHIP), + "::", + stringify!(NodeNumber) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_NUMA_NODE_RELATIONSHIP>())).Reserved as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_NUMA_NODE_RELATIONSHIP), + "::", + stringify!(Reserved) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_NUMA_NODE_RELATIONSHIP>())).GroupMask as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_NUMA_NODE_RELATIONSHIP), + "::", + stringify!(GroupMask) + ) + ); +} +pub type NUMA_NODE_RELATIONSHIP = _NUMA_NODE_RELATIONSHIP; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _CACHE_RELATIONSHIP { + pub Level: BYTE, + pub Associativity: BYTE, + pub LineSize: WORD, + pub CacheSize: DWORD, + pub Type: PROCESSOR_CACHE_TYPE, + pub Reserved: [BYTE; 20usize], + pub GroupMask: GROUP_AFFINITY, +} +#[test] +fn bindgen_test_layout__CACHE_RELATIONSHIP() { + assert_eq!( + ::std::mem::size_of::<_CACHE_RELATIONSHIP>(), + 48usize, + concat!("Size of: ", stringify!(_CACHE_RELATIONSHIP)) + ); + assert_eq!( + ::std::mem::align_of::<_CACHE_RELATIONSHIP>(), + 8usize, + concat!("Alignment of ", stringify!(_CACHE_RELATIONSHIP)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CACHE_RELATIONSHIP>())).Level as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_CACHE_RELATIONSHIP), + "::", + stringify!(Level) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CACHE_RELATIONSHIP>())).Associativity as *const _ as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(_CACHE_RELATIONSHIP), + "::", + stringify!(Associativity) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CACHE_RELATIONSHIP>())).LineSize as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_CACHE_RELATIONSHIP), + "::", + stringify!(LineSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CACHE_RELATIONSHIP>())).CacheSize as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_CACHE_RELATIONSHIP), + "::", + stringify!(CacheSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CACHE_RELATIONSHIP>())).Type as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_CACHE_RELATIONSHIP), + "::", + stringify!(Type) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CACHE_RELATIONSHIP>())).Reserved as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_CACHE_RELATIONSHIP), + "::", + stringify!(Reserved) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CACHE_RELATIONSHIP>())).GroupMask as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_CACHE_RELATIONSHIP), + "::", + stringify!(GroupMask) + ) + ); +} +pub type CACHE_RELATIONSHIP = _CACHE_RELATIONSHIP; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _PROCESSOR_GROUP_INFO { + pub MaximumProcessorCount: BYTE, + pub ActiveProcessorCount: BYTE, + pub Reserved: [BYTE; 38usize], + pub ActiveProcessorMask: KAFFINITY, +} +#[test] +fn bindgen_test_layout__PROCESSOR_GROUP_INFO() { + assert_eq!( + ::std::mem::size_of::<_PROCESSOR_GROUP_INFO>(), + 48usize, + concat!("Size of: ", stringify!(_PROCESSOR_GROUP_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_PROCESSOR_GROUP_INFO>(), + 8usize, + concat!("Alignment of ", stringify!(_PROCESSOR_GROUP_INFO)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_PROCESSOR_GROUP_INFO>())).MaximumProcessorCount as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_PROCESSOR_GROUP_INFO), + "::", + stringify!(MaximumProcessorCount) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_PROCESSOR_GROUP_INFO>())).ActiveProcessorCount as *const _ as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(_PROCESSOR_GROUP_INFO), + "::", + stringify!(ActiveProcessorCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_PROCESSOR_GROUP_INFO>())).Reserved as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_PROCESSOR_GROUP_INFO), + "::", + stringify!(Reserved) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_PROCESSOR_GROUP_INFO>())).ActiveProcessorMask as *const _ as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_PROCESSOR_GROUP_INFO), + "::", + stringify!(ActiveProcessorMask) + ) + ); +} +pub type PROCESSOR_GROUP_INFO = _PROCESSOR_GROUP_INFO; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _GROUP_RELATIONSHIP { + pub MaximumGroupCount: WORD, + pub ActiveGroupCount: WORD, + pub Reserved: [BYTE; 20usize], + pub GroupInfo: [PROCESSOR_GROUP_INFO; 1usize], +} +#[test] +fn bindgen_test_layout__GROUP_RELATIONSHIP() { + assert_eq!( + ::std::mem::size_of::<_GROUP_RELATIONSHIP>(), + 72usize, + concat!("Size of: ", stringify!(_GROUP_RELATIONSHIP)) + ); + assert_eq!( + ::std::mem::align_of::<_GROUP_RELATIONSHIP>(), + 8usize, + concat!("Alignment of ", stringify!(_GROUP_RELATIONSHIP)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_GROUP_RELATIONSHIP>())).MaximumGroupCount as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_GROUP_RELATIONSHIP), + "::", + stringify!(MaximumGroupCount) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_GROUP_RELATIONSHIP>())).ActiveGroupCount as *const _ as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_GROUP_RELATIONSHIP), + "::", + stringify!(ActiveGroupCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_GROUP_RELATIONSHIP>())).Reserved as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_GROUP_RELATIONSHIP), + "::", + stringify!(Reserved) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_GROUP_RELATIONSHIP>())).GroupInfo as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_GROUP_RELATIONSHIP), + "::", + stringify!(GroupInfo) + ) + ); +} +pub type GROUP_RELATIONSHIP = _GROUP_RELATIONSHIP; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX { + pub Relationship: LOGICAL_PROCESSOR_RELATIONSHIP, + pub Size: DWORD, + pub __bindgen_anon_1: _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX__bindgen_ty_1 { + pub Processor: PROCESSOR_RELATIONSHIP, + pub NumaNode: NUMA_NODE_RELATIONSHIP, + pub Cache: CACHE_RELATIONSHIP, + pub Group: GROUP_RELATIONSHIP, + _bindgen_union_align: [u64; 9usize], +} +#[test] +fn bindgen_test_layout__SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX__bindgen_ty_1>(), + 72usize, + concat!( + "Size of: ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX__bindgen_ty_1>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX__bindgen_ty_1>())).Processor + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX__bindgen_ty_1), + "::", + stringify!(Processor) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX__bindgen_ty_1>())).NumaNode + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX__bindgen_ty_1), + "::", + stringify!(NumaNode) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX__bindgen_ty_1>())).Cache + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX__bindgen_ty_1), + "::", + stringify!(Cache) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX__bindgen_ty_1>())).Group + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX__bindgen_ty_1), + "::", + stringify!(Group) + ) + ); +} +#[test] +fn bindgen_test_layout__SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX>(), + 80usize, + concat!( + "Size of: ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX>())).Relationship as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX), + "::", + stringify!(Relationship) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX>())).Size as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX), + "::", + stringify!(Size) + ) + ); +} +pub type SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX = _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX; +pub const _CPU_SET_INFORMATION_TYPE_CpuSetInformation: _CPU_SET_INFORMATION_TYPE = 0; +pub type _CPU_SET_INFORMATION_TYPE = ::std::os::raw::c_int; +pub use self::_CPU_SET_INFORMATION_TYPE as CPU_SET_INFORMATION_TYPE; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SYSTEM_CPU_SET_INFORMATION { + pub Size: DWORD, + pub Type: CPU_SET_INFORMATION_TYPE, + pub __bindgen_anon_1: _SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1 { + pub CpuSet: _SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1, + _bindgen_union_align: [u64; 3usize], +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1 { + pub Id: DWORD, + pub Group: WORD, + pub LogicalProcessorIndex: BYTE, + pub CoreIndex: BYTE, + pub LastLevelCacheIndex: BYTE, + pub NumaNodeIndex: BYTE, + pub EfficiencyClass: BYTE, + pub __bindgen_anon_1: _SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, + pub __bindgen_anon_2: _SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_2, + pub AllocationTag: DWORD64, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 { + pub AllFlags: BYTE, + pub __bindgen_anon_1: + _SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, + _bindgen_union_align: u8, +} +#[repr(C, packed)] +#[derive(Debug, Copy, Clone)] +pub struct _SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 { + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>, +} +#[test] +fn bindgen_test_layout__SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1( +) { + assert_eq!( + ::std::mem::size_of::< + _SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, + >(), + 1usize, + concat!( + "Size of: ", + stringify!( + _SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 + ) + ) + ); + assert_eq!( + ::std::mem::align_of::< + _SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, + >(), + 1usize, + concat!( + "Alignment of ", + stringify!( + _SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 + ) + ) + ); +} +impl _SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 { + #[inline] + pub fn Parked(&self) -> BYTE { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_Parked(&mut self, val: BYTE) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn Allocated(&self) -> BYTE { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_Allocated(&mut self, val: BYTE) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn AllocatedToTargetProcess(&self) -> BYTE { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_AllocatedToTargetProcess(&mut self, val: BYTE) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn RealTime(&self) -> BYTE { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_RealTime(&mut self, val: BYTE) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn ReservedFlags(&self) -> BYTE { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 4u8) as u8) } + } + #[inline] + pub fn set_ReservedFlags(&mut self, val: BYTE) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 4u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + Parked: BYTE, + Allocated: BYTE, + AllocatedToTargetProcess: BYTE, + RealTime: BYTE, + ReservedFlags: BYTE, + ) -> __BindgenBitfieldUnit<[u8; 1usize], u8> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize], u8> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let Parked: u8 = unsafe { ::std::mem::transmute(Parked) }; + Parked as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let Allocated: u8 = unsafe { ::std::mem::transmute(Allocated) }; + Allocated as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let AllocatedToTargetProcess: u8 = unsafe { ::std::mem::transmute(AllocatedToTargetProcess) }; + AllocatedToTargetProcess as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let RealTime: u8 = unsafe { ::std::mem::transmute(RealTime) }; + RealTime as u64 + }); + __bindgen_bitfield_unit.set(4usize, 4u8, { + let ReservedFlags: u8 = unsafe { ::std::mem::transmute(ReservedFlags) }; + ReservedFlags as u64 + }); + __bindgen_bitfield_unit + } +} +#[test] +fn bindgen_test_layout__SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1>(), + 1usize, + concat!( + "Size of: ", + stringify!(_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1>(), + 1usize, + concat!( + "Alignment of ", + stringify!(_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1>( + ))) + .AllFlags as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(AllFlags) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_2 { + pub Reserved: DWORD, + pub SchedulingClass: BYTE, + _bindgen_union_align: u32, +} +#[test] +fn bindgen_test_layout__SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_2() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_2>(), + 4usize, + concat!( + "Size of: ", + stringify!(_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_2>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_2>( + ))) + .Reserved as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(Reserved) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_2>( + ))) + .SchedulingClass as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(SchedulingClass) + ) + ); +} +#[test] +fn bindgen_test_layout__SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1>(), + 24usize, + concat!( + "Size of: ", + stringify!(_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1>())).Id + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(Id) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1>())).Group + as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(Group) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1>())) + .LogicalProcessorIndex as *const _ as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(LogicalProcessorIndex) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1>())).CoreIndex + as *const _ as usize + }, + 7usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(CoreIndex) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1>())) + .LastLevelCacheIndex as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(LastLevelCacheIndex) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1>())) + .NumaNodeIndex as *const _ as usize + }, + 9usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(NumaNodeIndex) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1>())) + .EfficiencyClass as *const _ as usize + }, + 10usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(EfficiencyClass) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1>())) + .AllocationTag as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(AllocationTag) + ) + ); +} +#[test] +fn bindgen_test_layout__SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1>(), + 24usize, + concat!( + "Size of: ", + stringify!(_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1>())).CpuSet as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_CPU_SET_INFORMATION__bindgen_ty_1), + "::", + stringify!(CpuSet) + ) + ); +} +#[test] +fn bindgen_test_layout__SYSTEM_CPU_SET_INFORMATION() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_CPU_SET_INFORMATION>(), + 32usize, + concat!("Size of: ", stringify!(_SYSTEM_CPU_SET_INFORMATION)) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_CPU_SET_INFORMATION>(), + 8usize, + concat!("Alignment of ", stringify!(_SYSTEM_CPU_SET_INFORMATION)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_CPU_SET_INFORMATION>())).Size as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_CPU_SET_INFORMATION), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_CPU_SET_INFORMATION>())).Type as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_CPU_SET_INFORMATION), + "::", + stringify!(Type) + ) + ); +} +pub type SYSTEM_CPU_SET_INFORMATION = _SYSTEM_CPU_SET_INFORMATION; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION { + pub CycleTime: DWORD64, +} +#[test] +fn bindgen_test_layout__SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION>(), + 8usize, + concat!( + "Size of: ", + stringify!(_SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION>())).CycleTime as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION), + "::", + stringify!(CycleTime) + ) + ); +} +pub type SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION = _SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SCRUB_DATA_INPUT { + pub Size: DWORD, + pub Flags: DWORD, + pub MaximumIos: DWORD, + pub ObjectId: [DWORD; 4usize], + pub Reserved: [DWORD; 25usize], + pub ResumeContext: [BYTE; 816usize], +} +#[test] +fn bindgen_test_layout__SCRUB_DATA_INPUT() { + assert_eq!( + ::std::mem::size_of::<_SCRUB_DATA_INPUT>(), + 944usize, + concat!("Size of: ", stringify!(_SCRUB_DATA_INPUT)) + ); + assert_eq!( + ::std::mem::align_of::<_SCRUB_DATA_INPUT>(), + 4usize, + concat!("Alignment of ", stringify!(_SCRUB_DATA_INPUT)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCRUB_DATA_INPUT>())).Size as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_DATA_INPUT), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCRUB_DATA_INPUT>())).Flags as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_DATA_INPUT), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCRUB_DATA_INPUT>())).MaximumIos as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_DATA_INPUT), + "::", + stringify!(MaximumIos) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCRUB_DATA_INPUT>())).ObjectId as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_DATA_INPUT), + "::", + stringify!(ObjectId) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCRUB_DATA_INPUT>())).Reserved as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_DATA_INPUT), + "::", + stringify!(Reserved) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCRUB_DATA_INPUT>())).ResumeContext as *const _ as usize }, + 128usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_DATA_INPUT), + "::", + stringify!(ResumeContext) + ) + ); +} +pub type SCRUB_DATA_INPUT = _SCRUB_DATA_INPUT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCRUB_PARITY_EXTENT { + pub Offset: LONGLONG, + pub Length: ULONGLONG, +} +#[test] +fn bindgen_test_layout__SCRUB_PARITY_EXTENT() { + assert_eq!( + ::std::mem::size_of::<_SCRUB_PARITY_EXTENT>(), + 16usize, + concat!("Size of: ", stringify!(_SCRUB_PARITY_EXTENT)) + ); + assert_eq!( + ::std::mem::align_of::<_SCRUB_PARITY_EXTENT>(), + 8usize, + concat!("Alignment of ", stringify!(_SCRUB_PARITY_EXTENT)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCRUB_PARITY_EXTENT>())).Offset as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_PARITY_EXTENT), + "::", + stringify!(Offset) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCRUB_PARITY_EXTENT>())).Length as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_PARITY_EXTENT), + "::", + stringify!(Length) + ) + ); +} +pub type SCRUB_PARITY_EXTENT = _SCRUB_PARITY_EXTENT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCRUB_PARITY_EXTENT_DATA { + pub Size: WORD, + pub Flags: WORD, + pub NumberOfParityExtents: WORD, + pub MaximumNumberOfParityExtents: WORD, + pub ParityExtents: [SCRUB_PARITY_EXTENT; 1usize], +} +#[test] +fn bindgen_test_layout__SCRUB_PARITY_EXTENT_DATA() { + assert_eq!( + ::std::mem::size_of::<_SCRUB_PARITY_EXTENT_DATA>(), + 24usize, + concat!("Size of: ", stringify!(_SCRUB_PARITY_EXTENT_DATA)) + ); + assert_eq!( + ::std::mem::align_of::<_SCRUB_PARITY_EXTENT_DATA>(), + 8usize, + concat!("Alignment of ", stringify!(_SCRUB_PARITY_EXTENT_DATA)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCRUB_PARITY_EXTENT_DATA>())).Size as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_PARITY_EXTENT_DATA), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCRUB_PARITY_EXTENT_DATA>())).Flags as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_PARITY_EXTENT_DATA), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCRUB_PARITY_EXTENT_DATA>())).NumberOfParityExtents as *const _ + as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_PARITY_EXTENT_DATA), + "::", + stringify!(NumberOfParityExtents) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCRUB_PARITY_EXTENT_DATA>())).MaximumNumberOfParityExtents as *const _ + as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_PARITY_EXTENT_DATA), + "::", + stringify!(MaximumNumberOfParityExtents) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCRUB_PARITY_EXTENT_DATA>())).ParityExtents as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_PARITY_EXTENT_DATA), + "::", + stringify!(ParityExtents) + ) + ); +} +pub type SCRUB_PARITY_EXTENT_DATA = _SCRUB_PARITY_EXTENT_DATA; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SCRUB_DATA_OUTPUT { + pub Size: DWORD, + pub Flags: DWORD, + pub Status: DWORD, + pub ErrorFileOffset: ULONGLONG, + pub ErrorLength: ULONGLONG, + pub NumberOfBytesRepaired: ULONGLONG, + pub NumberOfBytesFailed: ULONGLONG, + pub InternalFileReference: ULONGLONG, + pub ResumeContextLength: WORD, + pub ParityExtentDataOffset: WORD, + pub Reserved: [DWORD; 9usize], + pub NumberOfMetadataBytesProcessed: ULONGLONG, + pub NumberOfDataBytesProcessed: ULONGLONG, + pub TotalNumberOfMetadataBytesInUse: ULONGLONG, + pub TotalNumberOfDataBytesInUse: ULONGLONG, + pub ResumeContext: [BYTE; 816usize], +} +#[test] +fn bindgen_test_layout__SCRUB_DATA_OUTPUT() { + assert_eq!( + ::std::mem::size_of::<_SCRUB_DATA_OUTPUT>(), + 944usize, + concat!("Size of: ", stringify!(_SCRUB_DATA_OUTPUT)) + ); + assert_eq!( + ::std::mem::align_of::<_SCRUB_DATA_OUTPUT>(), + 8usize, + concat!("Alignment of ", stringify!(_SCRUB_DATA_OUTPUT)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCRUB_DATA_OUTPUT>())).Size as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_DATA_OUTPUT), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCRUB_DATA_OUTPUT>())).Flags as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_DATA_OUTPUT), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCRUB_DATA_OUTPUT>())).Status as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_DATA_OUTPUT), + "::", + stringify!(Status) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCRUB_DATA_OUTPUT>())).ErrorFileOffset as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_DATA_OUTPUT), + "::", + stringify!(ErrorFileOffset) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCRUB_DATA_OUTPUT>())).ErrorLength as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_DATA_OUTPUT), + "::", + stringify!(ErrorLength) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCRUB_DATA_OUTPUT>())).NumberOfBytesRepaired as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_DATA_OUTPUT), + "::", + stringify!(NumberOfBytesRepaired) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCRUB_DATA_OUTPUT>())).NumberOfBytesFailed as *const _ as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_DATA_OUTPUT), + "::", + stringify!(NumberOfBytesFailed) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCRUB_DATA_OUTPUT>())).InternalFileReference as *const _ as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_DATA_OUTPUT), + "::", + stringify!(InternalFileReference) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCRUB_DATA_OUTPUT>())).ResumeContextLength as *const _ as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_DATA_OUTPUT), + "::", + stringify!(ResumeContextLength) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCRUB_DATA_OUTPUT>())).ParityExtentDataOffset as *const _ as usize + }, + 58usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_DATA_OUTPUT), + "::", + stringify!(ParityExtentDataOffset) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCRUB_DATA_OUTPUT>())).Reserved as *const _ as usize }, + 60usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_DATA_OUTPUT), + "::", + stringify!(Reserved) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCRUB_DATA_OUTPUT>())).NumberOfMetadataBytesProcessed as *const _ + as usize + }, + 96usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_DATA_OUTPUT), + "::", + stringify!(NumberOfMetadataBytesProcessed) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCRUB_DATA_OUTPUT>())).NumberOfDataBytesProcessed as *const _ as usize + }, + 104usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_DATA_OUTPUT), + "::", + stringify!(NumberOfDataBytesProcessed) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCRUB_DATA_OUTPUT>())).TotalNumberOfMetadataBytesInUse as *const _ + as usize + }, + 112usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_DATA_OUTPUT), + "::", + stringify!(TotalNumberOfMetadataBytesInUse) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCRUB_DATA_OUTPUT>())).TotalNumberOfDataBytesInUse as *const _ + as usize + }, + 120usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_DATA_OUTPUT), + "::", + stringify!(TotalNumberOfDataBytesInUse) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCRUB_DATA_OUTPUT>())).ResumeContext as *const _ as usize }, + 128usize, + concat!( + "Offset of field: ", + stringify!(_SCRUB_DATA_OUTPUT), + "::", + stringify!(ResumeContext) + ) + ); +} +pub type SCRUB_DATA_OUTPUT = _SCRUB_DATA_OUTPUT; +pub const _SharedVirtualDiskSupportType_SharedVirtualDisksUnsupported: + _SharedVirtualDiskSupportType = 0; +pub const _SharedVirtualDiskSupportType_SharedVirtualDisksSupported: _SharedVirtualDiskSupportType = + 1; +pub const _SharedVirtualDiskSupportType_SharedVirtualDiskSnapshotsSupported: + _SharedVirtualDiskSupportType = 3; +pub const _SharedVirtualDiskSupportType_SharedVirtualDiskCDPSnapshotsSupported: + _SharedVirtualDiskSupportType = 7; +pub type _SharedVirtualDiskSupportType = ::std::os::raw::c_int; +pub use self::_SharedVirtualDiskSupportType as SharedVirtualDiskSupportType; +pub const _SharedVirtualDiskHandleState_SharedVirtualDiskHandleStateNone: + _SharedVirtualDiskHandleState = 0; +pub const _SharedVirtualDiskHandleState_SharedVirtualDiskHandleStateFileShared: + _SharedVirtualDiskHandleState = 1; +pub const _SharedVirtualDiskHandleState_SharedVirtualDiskHandleStateHandleShared: + _SharedVirtualDiskHandleState = 3; +pub type _SharedVirtualDiskHandleState = ::std::os::raw::c_int; +pub use self::_SharedVirtualDiskHandleState as SharedVirtualDiskHandleState; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SHARED_VIRTUAL_DISK_SUPPORT { + pub SharedVirtualDiskSupport: SharedVirtualDiskSupportType, + pub HandleState: SharedVirtualDiskHandleState, +} +#[test] +fn bindgen_test_layout__SHARED_VIRTUAL_DISK_SUPPORT() { + assert_eq!( + ::std::mem::size_of::<_SHARED_VIRTUAL_DISK_SUPPORT>(), + 8usize, + concat!("Size of: ", stringify!(_SHARED_VIRTUAL_DISK_SUPPORT)) + ); + assert_eq!( + ::std::mem::align_of::<_SHARED_VIRTUAL_DISK_SUPPORT>(), + 4usize, + concat!("Alignment of ", stringify!(_SHARED_VIRTUAL_DISK_SUPPORT)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SHARED_VIRTUAL_DISK_SUPPORT>())).SharedVirtualDiskSupport as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SHARED_VIRTUAL_DISK_SUPPORT), + "::", + stringify!(SharedVirtualDiskSupport) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SHARED_VIRTUAL_DISK_SUPPORT>())).HandleState as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SHARED_VIRTUAL_DISK_SUPPORT), + "::", + stringify!(HandleState) + ) + ); +} +pub type SHARED_VIRTUAL_DISK_SUPPORT = _SHARED_VIRTUAL_DISK_SUPPORT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SHUFFLE_FILE_DATA { + pub StartingOffset: LONGLONG, + pub Length: LONGLONG, + pub Flags: DWORD, +} +#[test] +fn bindgen_test_layout__SHUFFLE_FILE_DATA() { + assert_eq!( + ::std::mem::size_of::<_SHUFFLE_FILE_DATA>(), + 24usize, + concat!("Size of: ", stringify!(_SHUFFLE_FILE_DATA)) + ); + assert_eq!( + ::std::mem::align_of::<_SHUFFLE_FILE_DATA>(), + 8usize, + concat!("Alignment of ", stringify!(_SHUFFLE_FILE_DATA)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHUFFLE_FILE_DATA>())).StartingOffset as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SHUFFLE_FILE_DATA), + "::", + stringify!(StartingOffset) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHUFFLE_FILE_DATA>())).Length as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SHUFFLE_FILE_DATA), + "::", + stringify!(Length) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHUFFLE_FILE_DATA>())).Flags as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SHUFFLE_FILE_DATA), + "::", + stringify!(Flags) + ) + ); +} +pub type SHUFFLE_FILE_DATA = _SHUFFLE_FILE_DATA; +pub const _SYSTEM_POWER_STATE_PowerSystemUnspecified: _SYSTEM_POWER_STATE = 0; +pub const _SYSTEM_POWER_STATE_PowerSystemWorking: _SYSTEM_POWER_STATE = 1; +pub const _SYSTEM_POWER_STATE_PowerSystemSleeping1: _SYSTEM_POWER_STATE = 2; +pub const _SYSTEM_POWER_STATE_PowerSystemSleeping2: _SYSTEM_POWER_STATE = 3; +pub const _SYSTEM_POWER_STATE_PowerSystemSleeping3: _SYSTEM_POWER_STATE = 4; +pub const _SYSTEM_POWER_STATE_PowerSystemHibernate: _SYSTEM_POWER_STATE = 5; +pub const _SYSTEM_POWER_STATE_PowerSystemShutdown: _SYSTEM_POWER_STATE = 6; +pub const _SYSTEM_POWER_STATE_PowerSystemMaximum: _SYSTEM_POWER_STATE = 7; +pub type _SYSTEM_POWER_STATE = ::std::os::raw::c_int; +pub use self::_SYSTEM_POWER_STATE as SYSTEM_POWER_STATE; +pub const POWER_ACTION_PowerActionNone: POWER_ACTION = 0; +pub const POWER_ACTION_PowerActionReserved: POWER_ACTION = 1; +pub const POWER_ACTION_PowerActionSleep: POWER_ACTION = 2; +pub const POWER_ACTION_PowerActionHibernate: POWER_ACTION = 3; +pub const POWER_ACTION_PowerActionShutdown: POWER_ACTION = 4; +pub const POWER_ACTION_PowerActionShutdownReset: POWER_ACTION = 5; +pub const POWER_ACTION_PowerActionShutdownOff: POWER_ACTION = 6; +pub const POWER_ACTION_PowerActionWarmEject: POWER_ACTION = 7; +pub const POWER_ACTION_PowerActionDisplayOff: POWER_ACTION = 8; +pub type POWER_ACTION = ::std::os::raw::c_int; +pub const SYSTEM_POWER_CONDITION_PoAc: SYSTEM_POWER_CONDITION = 0; +pub const SYSTEM_POWER_CONDITION_PoDc: SYSTEM_POWER_CONDITION = 1; +pub const SYSTEM_POWER_CONDITION_PoHot: SYSTEM_POWER_CONDITION = 2; +pub const SYSTEM_POWER_CONDITION_PoConditionMaximum: SYSTEM_POWER_CONDITION = 3; +pub type SYSTEM_POWER_CONDITION = ::std::os::raw::c_int; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct SET_POWER_SETTING_VALUE { + pub Version: DWORD, + pub Guid: GUID, + pub PowerCondition: SYSTEM_POWER_CONDITION, + pub DataLength: DWORD, + pub Data: [BYTE; 1usize], +} +#[test] +fn bindgen_test_layout_SET_POWER_SETTING_VALUE() { + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(SET_POWER_SETTING_VALUE)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(SET_POWER_SETTING_VALUE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(SET_POWER_SETTING_VALUE), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).Guid as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(SET_POWER_SETTING_VALUE), + "::", + stringify!(Guid) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).PowerCondition as *const _ as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(SET_POWER_SETTING_VALUE), + "::", + stringify!(PowerCondition) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).DataLength as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(SET_POWER_SETTING_VALUE), + "::", + stringify!(DataLength) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).Data as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(SET_POWER_SETTING_VALUE), + "::", + stringify!(Data) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct BATTERY_REPORTING_SCALE { + pub Granularity: DWORD, + pub Capacity: DWORD, +} +#[test] +fn bindgen_test_layout_BATTERY_REPORTING_SCALE() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(BATTERY_REPORTING_SCALE)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(BATTERY_REPORTING_SCALE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).Granularity as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(BATTERY_REPORTING_SCALE), + "::", + stringify!(Granularity) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).Capacity as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(BATTERY_REPORTING_SCALE), + "::", + stringify!(Capacity) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct POWER_ACTION_POLICY { + pub Action: POWER_ACTION, + pub Flags: DWORD, + pub EventCode: DWORD, +} +#[test] +fn bindgen_test_layout_POWER_ACTION_POLICY() { + assert_eq!( + ::std::mem::size_of::(), + 12usize, + concat!("Size of: ", stringify!(POWER_ACTION_POLICY)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(POWER_ACTION_POLICY)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).Action as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(POWER_ACTION_POLICY), + "::", + stringify!(Action) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).Flags as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(POWER_ACTION_POLICY), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).EventCode as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(POWER_ACTION_POLICY), + "::", + stringify!(EventCode) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct SYSTEM_POWER_LEVEL { + pub Enable: BOOLEAN, + pub Spare: [BYTE; 3usize], + pub BatteryLevel: DWORD, + pub PowerPolicy: POWER_ACTION_POLICY, + pub MinSystemState: SYSTEM_POWER_STATE, +} +#[test] +fn bindgen_test_layout_SYSTEM_POWER_LEVEL() { + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(SYSTEM_POWER_LEVEL)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(SYSTEM_POWER_LEVEL)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).Enable as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_LEVEL), + "::", + stringify!(Enable) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).Spare as *const _ as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_LEVEL), + "::", + stringify!(Spare) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).BatteryLevel as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_LEVEL), + "::", + stringify!(BatteryLevel) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).PowerPolicy as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_LEVEL), + "::", + stringify!(PowerPolicy) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).MinSystemState as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_LEVEL), + "::", + stringify!(MinSystemState) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SYSTEM_POWER_POLICY { + pub Revision: DWORD, + pub PowerButton: POWER_ACTION_POLICY, + pub SleepButton: POWER_ACTION_POLICY, + pub LidClose: POWER_ACTION_POLICY, + pub LidOpenWake: SYSTEM_POWER_STATE, + pub Reserved: DWORD, + pub Idle: POWER_ACTION_POLICY, + pub IdleTimeout: DWORD, + pub IdleSensitivity: BYTE, + pub DynamicThrottle: BYTE, + pub Spare2: [BYTE; 2usize], + pub MinSleep: SYSTEM_POWER_STATE, + pub MaxSleep: SYSTEM_POWER_STATE, + pub ReducedLatencySleep: SYSTEM_POWER_STATE, + pub WinLogonFlags: DWORD, + pub Spare3: DWORD, + pub DozeS4Timeout: DWORD, + pub BroadcastCapacityResolution: DWORD, + pub DischargePolicy: [SYSTEM_POWER_LEVEL; 4usize], + pub VideoTimeout: DWORD, + pub VideoDimDisplay: BOOLEAN, + pub VideoReserved: [DWORD; 3usize], + pub SpindownTimeout: DWORD, + pub OptimizeForPower: BOOLEAN, + pub FanThrottleTolerance: BYTE, + pub ForcedThrottle: BYTE, + pub MinThrottle: BYTE, + pub OverThrottled: POWER_ACTION_POLICY, +} +#[test] +fn bindgen_test_layout__SYSTEM_POWER_POLICY() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_POWER_POLICY>(), + 232usize, + concat!("Size of: ", stringify!(_SYSTEM_POWER_POLICY)) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_POWER_POLICY>(), + 4usize, + concat!("Alignment of ", stringify!(_SYSTEM_POWER_POLICY)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).Revision as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(Revision) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).PowerButton as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(PowerButton) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).SleepButton as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(SleepButton) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).LidClose as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(LidClose) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).LidOpenWake as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(LidOpenWake) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).Reserved as *const _ as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(Reserved) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).Idle as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(Idle) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).IdleTimeout as *const _ as usize }, + 60usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(IdleTimeout) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).IdleSensitivity as *const _ as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(IdleSensitivity) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).DynamicThrottle as *const _ as usize + }, + 65usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(DynamicThrottle) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).Spare2 as *const _ as usize }, + 66usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(Spare2) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).MinSleep as *const _ as usize }, + 68usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(MinSleep) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).MaxSleep as *const _ as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(MaxSleep) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).ReducedLatencySleep as *const _ as usize + }, + 76usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(ReducedLatencySleep) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).WinLogonFlags as *const _ as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(WinLogonFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).Spare3 as *const _ as usize }, + 84usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(Spare3) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).DozeS4Timeout as *const _ as usize }, + 88usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(DozeS4Timeout) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).BroadcastCapacityResolution as *const _ + as usize + }, + 92usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(BroadcastCapacityResolution) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).DischargePolicy as *const _ as usize + }, + 96usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(DischargePolicy) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).VideoTimeout as *const _ as usize }, + 192usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(VideoTimeout) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).VideoDimDisplay as *const _ as usize + }, + 196usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(VideoDimDisplay) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).VideoReserved as *const _ as usize }, + 200usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(VideoReserved) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).SpindownTimeout as *const _ as usize + }, + 212usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(SpindownTimeout) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).OptimizeForPower as *const _ as usize + }, + 216usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(OptimizeForPower) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).FanThrottleTolerance as *const _ as usize + }, + 217usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(FanThrottleTolerance) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).ForcedThrottle as *const _ as usize }, + 218usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(ForcedThrottle) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).MinThrottle as *const _ as usize }, + 219usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(MinThrottle) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_POWER_POLICY>())).OverThrottled as *const _ as usize }, + 220usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_POLICY), + "::", + stringify!(OverThrottled) + ) + ); +} +pub type SYSTEM_POWER_POLICY = _SYSTEM_POWER_POLICY; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct SYSTEM_POWER_CAPABILITIES { + pub PowerButtonPresent: BOOLEAN, + pub SleepButtonPresent: BOOLEAN, + pub LidPresent: BOOLEAN, + pub SystemS1: BOOLEAN, + pub SystemS2: BOOLEAN, + pub SystemS3: BOOLEAN, + pub SystemS4: BOOLEAN, + pub SystemS5: BOOLEAN, + pub HiberFilePresent: BOOLEAN, + pub FullWake: BOOLEAN, + pub VideoDimPresent: BOOLEAN, + pub ApmPresent: BOOLEAN, + pub UpsPresent: BOOLEAN, + pub ThermalControl: BOOLEAN, + pub ProcessorThrottle: BOOLEAN, + pub ProcessorMinThrottle: BYTE, + pub ProcessorMaxThrottle: BYTE, + pub FastSystemS4: BOOLEAN, + pub Hiberboot: BOOLEAN, + pub WakeAlarmPresent: BOOLEAN, + pub AoAc: BOOLEAN, + pub DiskSpinDown: BOOLEAN, + pub HiberFileType: BYTE, + pub AoAcConnectivitySupported: BOOLEAN, + pub spare3: [BYTE; 6usize], + pub SystemBatteriesPresent: BOOLEAN, + pub BatteriesAreShortTerm: BOOLEAN, + pub BatteryScale: [BATTERY_REPORTING_SCALE; 3usize], + pub AcOnLineWake: SYSTEM_POWER_STATE, + pub SoftLidWake: SYSTEM_POWER_STATE, + pub RtcWake: SYSTEM_POWER_STATE, + pub MinDeviceWakeState: SYSTEM_POWER_STATE, + pub DefaultLowLatencyWake: SYSTEM_POWER_STATE, +} +#[test] +fn bindgen_test_layout_SYSTEM_POWER_CAPABILITIES() { + assert_eq!( + ::std::mem::size_of::(), + 76usize, + concat!("Size of: ", stringify!(SYSTEM_POWER_CAPABILITIES)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(SYSTEM_POWER_CAPABILITIES)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).PowerButtonPresent as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(PowerButtonPresent) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).SleepButtonPresent as *const _ as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(SleepButtonPresent) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).LidPresent as *const _ as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(LidPresent) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).SystemS1 as *const _ as usize }, + 3usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(SystemS1) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).SystemS2 as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(SystemS2) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).SystemS3 as *const _ as usize }, + 5usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(SystemS3) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).SystemS4 as *const _ as usize }, + 6usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(SystemS4) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).SystemS5 as *const _ as usize }, + 7usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(SystemS5) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).HiberFilePresent as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(HiberFilePresent) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).FullWake as *const _ as usize }, + 9usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(FullWake) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).VideoDimPresent as *const _ as usize + }, + 10usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(VideoDimPresent) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).ApmPresent as *const _ as usize + }, + 11usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(ApmPresent) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).UpsPresent as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(UpsPresent) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).ThermalControl as *const _ as usize + }, + 13usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(ThermalControl) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).ProcessorThrottle as *const _ as usize + }, + 14usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(ProcessorThrottle) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).ProcessorMinThrottle as *const _ + as usize + }, + 15usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(ProcessorMinThrottle) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).ProcessorMaxThrottle as *const _ + as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(ProcessorMaxThrottle) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).FastSystemS4 as *const _ as usize + }, + 17usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(FastSystemS4) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).Hiberboot as *const _ as usize }, + 18usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(Hiberboot) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).WakeAlarmPresent as *const _ as usize + }, + 19usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(WakeAlarmPresent) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).AoAc as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(AoAc) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).DiskSpinDown as *const _ as usize + }, + 21usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(DiskSpinDown) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).HiberFileType as *const _ as usize + }, + 22usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(HiberFileType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).AoAcConnectivitySupported as *const _ + as usize + }, + 23usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(AoAcConnectivitySupported) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).spare3 as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(spare3) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).SystemBatteriesPresent as *const _ + as usize + }, + 30usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(SystemBatteriesPresent) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).BatteriesAreShortTerm as *const _ + as usize + }, + 31usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(BatteriesAreShortTerm) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).BatteryScale as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(BatteryScale) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).AcOnLineWake as *const _ as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(AcOnLineWake) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).SoftLidWake as *const _ as usize + }, + 60usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(SoftLidWake) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).RtcWake as *const _ as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(RtcWake) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).MinDeviceWakeState as *const _ as usize + }, + 68usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(MinDeviceWakeState) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).DefaultLowLatencyWake as *const _ + as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_POWER_CAPABILITIES), + "::", + stringify!(DefaultLowLatencyWake) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct SYSTEM_BATTERY_STATE { + pub AcOnLine: BOOLEAN, + pub BatteryPresent: BOOLEAN, + pub Charging: BOOLEAN, + pub Discharging: BOOLEAN, + pub Spare1: [BOOLEAN; 3usize], + pub Tag: BYTE, + pub MaxCapacity: DWORD, + pub RemainingCapacity: DWORD, + pub Rate: DWORD, + pub EstimatedTime: DWORD, + pub DefaultAlert1: DWORD, + pub DefaultAlert2: DWORD, +} +#[test] +fn bindgen_test_layout_SYSTEM_BATTERY_STATE() { + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(SYSTEM_BATTERY_STATE)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(SYSTEM_BATTERY_STATE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).AcOnLine as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_BATTERY_STATE), + "::", + stringify!(AcOnLine) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).BatteryPresent as *const _ as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_BATTERY_STATE), + "::", + stringify!(BatteryPresent) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).Charging as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_BATTERY_STATE), + "::", + stringify!(Charging) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).Discharging as *const _ as usize }, + 3usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_BATTERY_STATE), + "::", + stringify!(Discharging) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).Spare1 as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_BATTERY_STATE), + "::", + stringify!(Spare1) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).Tag as *const _ as usize }, + 7usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_BATTERY_STATE), + "::", + stringify!(Tag) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).MaxCapacity as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_BATTERY_STATE), + "::", + stringify!(MaxCapacity) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).RemainingCapacity as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_BATTERY_STATE), + "::", + stringify!(RemainingCapacity) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).Rate as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_BATTERY_STATE), + "::", + stringify!(Rate) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).EstimatedTime as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_BATTERY_STATE), + "::", + stringify!(EstimatedTime) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).DefaultAlert1 as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_BATTERY_STATE), + "::", + stringify!(DefaultAlert1) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).DefaultAlert2 as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(SYSTEM_BATTERY_STATE), + "::", + stringify!(DefaultAlert2) + ) + ); +} +#[repr(C)] +#[repr(align(16))] +#[derive(Debug, Copy, Clone)] +pub struct _SLIST_ENTRY { + pub Next: *mut _SLIST_ENTRY, +} +#[test] +fn bindgen_test_layout__SLIST_ENTRY() { + assert_eq!( + ::std::mem::size_of::<_SLIST_ENTRY>(), + 16usize, + concat!("Size of: ", stringify!(_SLIST_ENTRY)) + ); + assert_eq!( + ::std::mem::align_of::<_SLIST_ENTRY>(), + 16usize, + concat!("Alignment of ", stringify!(_SLIST_ENTRY)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SLIST_ENTRY>())).Next as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SLIST_ENTRY), + "::", + stringify!(Next) + ) + ); +} +pub type SLIST_ENTRY = _SLIST_ENTRY; +#[repr(C)] +#[repr(align(16))] +#[derive(Copy, Clone)] +pub union _SLIST_HEADER { + pub __bindgen_anon_1: _SLIST_HEADER__bindgen_ty_1, + pub HeaderX64: _SLIST_HEADER__bindgen_ty_2, + _bindgen_union_align: u128, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SLIST_HEADER__bindgen_ty_1 { + pub Alignment: ULONGLONG, + pub Region: ULONGLONG, +} +#[test] +fn bindgen_test_layout__SLIST_HEADER__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_SLIST_HEADER__bindgen_ty_1>(), + 16usize, + concat!("Size of: ", stringify!(_SLIST_HEADER__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<_SLIST_HEADER__bindgen_ty_1>(), + 8usize, + concat!("Alignment of ", stringify!(_SLIST_HEADER__bindgen_ty_1)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SLIST_HEADER__bindgen_ty_1>())).Alignment as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SLIST_HEADER__bindgen_ty_1), + "::", + stringify!(Alignment) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SLIST_HEADER__bindgen_ty_1>())).Region as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SLIST_HEADER__bindgen_ty_1), + "::", + stringify!(Region) + ) + ); +} +#[repr(C)] +#[repr(align(8))] +#[derive(Debug, Copy, Clone)] +pub struct _SLIST_HEADER__bindgen_ty_2 { + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 16usize], u64>, +} +#[test] +fn bindgen_test_layout__SLIST_HEADER__bindgen_ty_2() { + assert_eq!( + ::std::mem::size_of::<_SLIST_HEADER__bindgen_ty_2>(), + 16usize, + concat!("Size of: ", stringify!(_SLIST_HEADER__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::<_SLIST_HEADER__bindgen_ty_2>(), + 8usize, + concat!("Alignment of ", stringify!(_SLIST_HEADER__bindgen_ty_2)) + ); +} +impl _SLIST_HEADER__bindgen_ty_2 { + #[inline] + pub fn Depth(&self) -> ULONGLONG { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 16u8) as u64) } + } + #[inline] + pub fn set_Depth(&mut self, val: ULONGLONG) { + unsafe { + let val: u64 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 16u8, val as u64) + } + } + #[inline] + pub fn Sequence(&self) -> ULONGLONG { + unsafe { ::std::mem::transmute(self._bitfield_1.get(16usize, 48u8) as u64) } + } + #[inline] + pub fn set_Sequence(&mut self, val: ULONGLONG) { + unsafe { + let val: u64 = ::std::mem::transmute(val); + self._bitfield_1.set(16usize, 48u8, val as u64) + } + } + #[inline] + pub fn Reserved(&self) -> ULONGLONG { + unsafe { ::std::mem::transmute(self._bitfield_1.get(64usize, 4u8) as u64) } + } + #[inline] + pub fn set_Reserved(&mut self, val: ULONGLONG) { + unsafe { + let val: u64 = ::std::mem::transmute(val); + self._bitfield_1.set(64usize, 4u8, val as u64) + } + } + #[inline] + pub fn NextEntry(&self) -> ULONGLONG { + unsafe { ::std::mem::transmute(self._bitfield_1.get(68usize, 60u8) as u64) } + } + #[inline] + pub fn set_NextEntry(&mut self, val: ULONGLONG) { + unsafe { + let val: u64 = ::std::mem::transmute(val); + self._bitfield_1.set(68usize, 60u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + Depth: ULONGLONG, + Sequence: ULONGLONG, + Reserved: ULONGLONG, + NextEntry: ULONGLONG, + ) -> __BindgenBitfieldUnit<[u8; 16usize], u64> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 16usize], u64> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 16u8, { + let Depth: u64 = unsafe { ::std::mem::transmute(Depth) }; + Depth as u64 + }); + __bindgen_bitfield_unit.set(16usize, 48u8, { + let Sequence: u64 = unsafe { ::std::mem::transmute(Sequence) }; + Sequence as u64 + }); + __bindgen_bitfield_unit.set(64usize, 4u8, { + let Reserved: u64 = unsafe { ::std::mem::transmute(Reserved) }; + Reserved as u64 + }); + __bindgen_bitfield_unit.set(68usize, 60u8, { + let NextEntry: u64 = unsafe { ::std::mem::transmute(NextEntry) }; + NextEntry as u64 + }); + __bindgen_bitfield_unit + } +} +#[test] +fn bindgen_test_layout__SLIST_HEADER() { + assert_eq!( + ::std::mem::size_of::<_SLIST_HEADER>(), + 16usize, + concat!("Size of: ", stringify!(_SLIST_HEADER)) + ); + assert_eq!( + ::std::mem::align_of::<_SLIST_HEADER>(), + 16usize, + concat!("Alignment of ", stringify!(_SLIST_HEADER)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SLIST_HEADER>())).HeaderX64 as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SLIST_HEADER), + "::", + stringify!(HeaderX64) + ) + ); +} +pub type SLIST_HEADER = _SLIST_HEADER; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _RTL_BARRIER { + pub Reserved1: DWORD, + pub Reserved2: DWORD, + pub Reserved3: [ULONG_PTR; 2usize], + pub Reserved4: DWORD, + pub Reserved5: DWORD, +} +#[test] +fn bindgen_test_layout__RTL_BARRIER() { + assert_eq!( + ::std::mem::size_of::<_RTL_BARRIER>(), + 32usize, + concat!("Size of: ", stringify!(_RTL_BARRIER)) + ); + assert_eq!( + ::std::mem::align_of::<_RTL_BARRIER>(), + 8usize, + concat!("Alignment of ", stringify!(_RTL_BARRIER)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_RTL_BARRIER>())).Reserved1 as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_RTL_BARRIER), + "::", + stringify!(Reserved1) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_RTL_BARRIER>())).Reserved2 as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_RTL_BARRIER), + "::", + stringify!(Reserved2) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_RTL_BARRIER>())).Reserved3 as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_RTL_BARRIER), + "::", + stringify!(Reserved3) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_RTL_BARRIER>())).Reserved4 as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_RTL_BARRIER), + "::", + stringify!(Reserved4) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_RTL_BARRIER>())).Reserved5 as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_RTL_BARRIER), + "::", + stringify!(Reserved5) + ) + ); +} +pub type RTL_BARRIER = _RTL_BARRIER; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _RTL_SRWLOCK { + pub Ptr: PVOID, +} +#[test] +fn bindgen_test_layout__RTL_SRWLOCK() { + assert_eq!( + ::std::mem::size_of::<_RTL_SRWLOCK>(), + 8usize, + concat!("Size of: ", stringify!(_RTL_SRWLOCK)) + ); + assert_eq!( + ::std::mem::align_of::<_RTL_SRWLOCK>(), + 8usize, + concat!("Alignment of ", stringify!(_RTL_SRWLOCK)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_RTL_SRWLOCK>())).Ptr as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_RTL_SRWLOCK), + "::", + stringify!(Ptr) + ) + ); +} +pub type RTL_SRWLOCK = _RTL_SRWLOCK; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SUPPORTED_OS_INFO { + pub MajorVersion: WORD, + pub MinorVersion: WORD, +} +#[test] +fn bindgen_test_layout__SUPPORTED_OS_INFO() { + assert_eq!( + ::std::mem::size_of::<_SUPPORTED_OS_INFO>(), + 4usize, + concat!("Size of: ", stringify!(_SUPPORTED_OS_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_SUPPORTED_OS_INFO>(), + 2usize, + concat!("Alignment of ", stringify!(_SUPPORTED_OS_INFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SUPPORTED_OS_INFO>())).MajorVersion as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SUPPORTED_OS_INFO), + "::", + stringify!(MajorVersion) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SUPPORTED_OS_INFO>())).MinorVersion as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_SUPPORTED_OS_INFO), + "::", + stringify!(MinorVersion) + ) + ); +} +pub type SUPPORTED_OS_INFO = _SUPPORTED_OS_INFO; +pub const _CM_SERVICE_NODE_TYPE_DriverType: _CM_SERVICE_NODE_TYPE = 1; +pub const _CM_SERVICE_NODE_TYPE_FileSystemType: _CM_SERVICE_NODE_TYPE = 2; +pub const _CM_SERVICE_NODE_TYPE_Win32ServiceOwnProcess: _CM_SERVICE_NODE_TYPE = 16; +pub const _CM_SERVICE_NODE_TYPE_Win32ServiceShareProcess: _CM_SERVICE_NODE_TYPE = 32; +pub const _CM_SERVICE_NODE_TYPE_AdapterType: _CM_SERVICE_NODE_TYPE = 4; +pub const _CM_SERVICE_NODE_TYPE_RecognizerType: _CM_SERVICE_NODE_TYPE = 8; +pub type _CM_SERVICE_NODE_TYPE = ::std::os::raw::c_int; +pub use self::_CM_SERVICE_NODE_TYPE as SERVICE_NODE_TYPE; +pub const _CM_SERVICE_LOAD_TYPE_BootLoad: _CM_SERVICE_LOAD_TYPE = 0; +pub const _CM_SERVICE_LOAD_TYPE_SystemLoad: _CM_SERVICE_LOAD_TYPE = 1; +pub const _CM_SERVICE_LOAD_TYPE_AutoLoad: _CM_SERVICE_LOAD_TYPE = 2; +pub const _CM_SERVICE_LOAD_TYPE_DemandLoad: _CM_SERVICE_LOAD_TYPE = 3; +pub const _CM_SERVICE_LOAD_TYPE_DisableLoad: _CM_SERVICE_LOAD_TYPE = 4; +pub type _CM_SERVICE_LOAD_TYPE = ::std::os::raw::c_int; +pub use self::_CM_SERVICE_LOAD_TYPE as SERVICE_LOAD_TYPE; +pub const _CM_ERROR_CONTROL_TYPE_IgnoreError: _CM_ERROR_CONTROL_TYPE = 0; +pub const _CM_ERROR_CONTROL_TYPE_NormalError: _CM_ERROR_CONTROL_TYPE = 1; +pub const _CM_ERROR_CONTROL_TYPE_SevereError: _CM_ERROR_CONTROL_TYPE = 2; +pub const _CM_ERROR_CONTROL_TYPE_CriticalError: _CM_ERROR_CONTROL_TYPE = 3; +pub type _CM_ERROR_CONTROL_TYPE = ::std::os::raw::c_int; +pub use self::_CM_ERROR_CONTROL_TYPE as SERVICE_ERROR_TYPE; +pub type SAVEPOINT_ID = ULONG; +pub type LPARAM = LONG_PTR; +pub type LRESULT = LONG_PTR; +pub type SPHANDLE = *mut HANDLE; +pub type HGLOBAL = HANDLE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct HKEY__ { + pub unused: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_HKEY__() { + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(HKEY__)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(HKEY__)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).unused as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(HKEY__), + "::", + stringify!(unused) + ) + ); +} +pub type HKEY = *mut HKEY__; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct HINSTANCE__ { + pub unused: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_HINSTANCE__() { + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(HINSTANCE__)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(HINSTANCE__)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).unused as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(HINSTANCE__), + "::", + stringify!(unused) + ) + ); +} +pub type HINSTANCE = *mut HINSTANCE__; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _FILETIME { + pub dwLowDateTime: DWORD, + pub dwHighDateTime: DWORD, +} +#[test] +fn bindgen_test_layout__FILETIME() { + assert_eq!( + ::std::mem::size_of::<_FILETIME>(), + 8usize, + concat!("Size of: ", stringify!(_FILETIME)) + ); + assert_eq!( + ::std::mem::align_of::<_FILETIME>(), + 4usize, + concat!("Alignment of ", stringify!(_FILETIME)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_FILETIME>())).dwLowDateTime as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_FILETIME), + "::", + stringify!(dwLowDateTime) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_FILETIME>())).dwHighDateTime as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_FILETIME), + "::", + stringify!(dwHighDateTime) + ) + ); +} +pub type FILETIME = _FILETIME; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct HWND__ { + pub unused: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_HWND__() { + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(HWND__)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(HWND__)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).unused as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(HWND__), + "::", + stringify!(unused) + ) + ); +} +pub type HWND = *mut HWND__; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct HBITMAP__ { + pub unused: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_HBITMAP__() { + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(HBITMAP__)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(HBITMAP__)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).unused as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(HBITMAP__), + "::", + stringify!(unused) + ) + ); +} +pub type HBITMAP = *mut HBITMAP__; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct HENHMETAFILE__ { + pub unused: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_HENHMETAFILE__() { + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(HENHMETAFILE__)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(HENHMETAFILE__)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).unused as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(HENHMETAFILE__), + "::", + stringify!(unused) + ) + ); +} +pub type HENHMETAFILE = *mut HENHMETAFILE__; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct HICON__ { + pub unused: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_HICON__() { + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(HICON__)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(HICON__)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).unused as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(HICON__), + "::", + stringify!(unused) + ) + ); +} +pub type HICON = *mut HICON__; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagRECT { + pub left: LONG, + pub top: LONG, + pub right: LONG, + pub bottom: LONG, +} +#[test] +fn bindgen_test_layout_tagRECT() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(tagRECT)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(tagRECT)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).left as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagRECT), + "::", + stringify!(left) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).top as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagRECT), + "::", + stringify!(top) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).right as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagRECT), + "::", + stringify!(right) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).bottom as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(tagRECT), + "::", + stringify!(bottom) + ) + ); +} +pub type RECT = tagRECT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagSIZE { + pub cx: LONG, + pub cy: LONG, +} +#[test] +fn bindgen_test_layout_tagSIZE() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(tagSIZE)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(tagSIZE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cx as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSIZE), + "::", + stringify!(cx) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cy as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagSIZE), + "::", + stringify!(cy) + ) + ); +} +pub type SIZE = tagSIZE; +pub type SIZEL = SIZE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SECURITY_ATTRIBUTES { + pub nLength: DWORD, + pub lpSecurityDescriptor: LPVOID, + pub bInheritHandle: BOOL, +} +#[test] +fn bindgen_test_layout__SECURITY_ATTRIBUTES() { + assert_eq!( + ::std::mem::size_of::<_SECURITY_ATTRIBUTES>(), + 24usize, + concat!("Size of: ", stringify!(_SECURITY_ATTRIBUTES)) + ); + assert_eq!( + ::std::mem::align_of::<_SECURITY_ATTRIBUTES>(), + 8usize, + concat!("Alignment of ", stringify!(_SECURITY_ATTRIBUTES)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SECURITY_ATTRIBUTES>())).nLength as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_ATTRIBUTES), + "::", + stringify!(nLength) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SECURITY_ATTRIBUTES>())).lpSecurityDescriptor as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_ATTRIBUTES), + "::", + stringify!(lpSecurityDescriptor) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SECURITY_ATTRIBUTES>())).bInheritHandle as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SECURITY_ATTRIBUTES), + "::", + stringify!(bInheritHandle) + ) + ); +} +pub type SECURITY_ATTRIBUTES = _SECURITY_ATTRIBUTES; +pub type LPSECURITY_ATTRIBUTES = *mut _SECURITY_ATTRIBUTES; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _OVERLAPPED { + pub Internal: ULONG_PTR, + pub InternalHigh: ULONG_PTR, + pub __bindgen_anon_1: _OVERLAPPED__bindgen_ty_1, + pub hEvent: HANDLE, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _OVERLAPPED__bindgen_ty_1 { + pub __bindgen_anon_1: _OVERLAPPED__bindgen_ty_1__bindgen_ty_1, + pub Pointer: PVOID, + _bindgen_union_align: u64, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _OVERLAPPED__bindgen_ty_1__bindgen_ty_1 { + pub Offset: DWORD, + pub OffsetHigh: DWORD, +} +#[test] +fn bindgen_test_layout__OVERLAPPED__bindgen_ty_1__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_OVERLAPPED__bindgen_ty_1__bindgen_ty_1>(), + 8usize, + concat!( + "Size of: ", + stringify!(_OVERLAPPED__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_OVERLAPPED__bindgen_ty_1__bindgen_ty_1>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_OVERLAPPED__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_OVERLAPPED__bindgen_ty_1__bindgen_ty_1>())).Offset as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_OVERLAPPED__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(Offset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_OVERLAPPED__bindgen_ty_1__bindgen_ty_1>())).OffsetHigh as *const _ + as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_OVERLAPPED__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(OffsetHigh) + ) + ); +} +#[test] +fn bindgen_test_layout__OVERLAPPED__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_OVERLAPPED__bindgen_ty_1>(), + 8usize, + concat!("Size of: ", stringify!(_OVERLAPPED__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<_OVERLAPPED__bindgen_ty_1>(), + 8usize, + concat!("Alignment of ", stringify!(_OVERLAPPED__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_OVERLAPPED__bindgen_ty_1>())).Pointer as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_OVERLAPPED__bindgen_ty_1), + "::", + stringify!(Pointer) + ) + ); +} +#[test] +fn bindgen_test_layout__OVERLAPPED() { + assert_eq!( + ::std::mem::size_of::<_OVERLAPPED>(), + 32usize, + concat!("Size of: ", stringify!(_OVERLAPPED)) + ); + assert_eq!( + ::std::mem::align_of::<_OVERLAPPED>(), + 8usize, + concat!("Alignment of ", stringify!(_OVERLAPPED)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_OVERLAPPED>())).Internal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_OVERLAPPED), + "::", + stringify!(Internal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_OVERLAPPED>())).InternalHigh as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_OVERLAPPED), + "::", + stringify!(InternalHigh) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_OVERLAPPED>())).hEvent as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_OVERLAPPED), + "::", + stringify!(hEvent) + ) + ); +} +pub type LPOVERLAPPED = *mut _OVERLAPPED; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SYSTEMTIME { + pub wYear: WORD, + pub wMonth: WORD, + pub wDayOfWeek: WORD, + pub wDay: WORD, + pub wHour: WORD, + pub wMinute: WORD, + pub wSecond: WORD, + pub wMilliseconds: WORD, +} +#[test] +fn bindgen_test_layout__SYSTEMTIME() { + assert_eq!( + ::std::mem::size_of::<_SYSTEMTIME>(), + 16usize, + concat!("Size of: ", stringify!(_SYSTEMTIME)) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEMTIME>(), + 2usize, + concat!("Alignment of ", stringify!(_SYSTEMTIME)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEMTIME>())).wYear as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEMTIME), + "::", + stringify!(wYear) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEMTIME>())).wMonth as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEMTIME), + "::", + stringify!(wMonth) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEMTIME>())).wDayOfWeek as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEMTIME), + "::", + stringify!(wDayOfWeek) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEMTIME>())).wDay as *const _ as usize }, + 6usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEMTIME), + "::", + stringify!(wDay) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEMTIME>())).wHour as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEMTIME), + "::", + stringify!(wHour) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEMTIME>())).wMinute as *const _ as usize }, + 10usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEMTIME), + "::", + stringify!(wMinute) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEMTIME>())).wSecond as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEMTIME), + "::", + stringify!(wSecond) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEMTIME>())).wMilliseconds as *const _ as usize }, + 14usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEMTIME), + "::", + stringify!(wMilliseconds) + ) + ); +} +pub type SYSTEMTIME = _SYSTEMTIME; +pub const _STREAM_INFO_LEVELS_FindStreamInfoStandard: _STREAM_INFO_LEVELS = 0; +pub const _STREAM_INFO_LEVELS_FindStreamInfoMaxInfoLevel: _STREAM_INFO_LEVELS = 1; +pub type _STREAM_INFO_LEVELS = ::std::os::raw::c_int; +pub use self::_STREAM_INFO_LEVELS as STREAM_INFO_LEVELS; +pub type SRWLOCK = RTL_SRWLOCK; +pub type SYNCHRONIZATION_BARRIER = RTL_BARRIER; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _PROCESS_INFORMATION { + pub hProcess: HANDLE, + pub hThread: HANDLE, + pub dwProcessId: DWORD, + pub dwThreadId: DWORD, +} +#[test] +fn bindgen_test_layout__PROCESS_INFORMATION() { + assert_eq!( + ::std::mem::size_of::<_PROCESS_INFORMATION>(), + 24usize, + concat!("Size of: ", stringify!(_PROCESS_INFORMATION)) + ); + assert_eq!( + ::std::mem::align_of::<_PROCESS_INFORMATION>(), + 8usize, + concat!("Alignment of ", stringify!(_PROCESS_INFORMATION)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_PROCESS_INFORMATION>())).hProcess as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_PROCESS_INFORMATION), + "::", + stringify!(hProcess) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_PROCESS_INFORMATION>())).hThread as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_PROCESS_INFORMATION), + "::", + stringify!(hThread) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_PROCESS_INFORMATION>())).dwProcessId as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_PROCESS_INFORMATION), + "::", + stringify!(dwProcessId) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_PROCESS_INFORMATION>())).dwThreadId as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_PROCESS_INFORMATION), + "::", + stringify!(dwThreadId) + ) + ); +} +pub type LPPROCESS_INFORMATION = *mut _PROCESS_INFORMATION; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STARTUPINFOA { + pub cb: DWORD, + pub lpReserved: LPSTR, + pub lpDesktop: LPSTR, + pub lpTitle: LPSTR, + pub dwX: DWORD, + pub dwY: DWORD, + pub dwXSize: DWORD, + pub dwYSize: DWORD, + pub dwXCountChars: DWORD, + pub dwYCountChars: DWORD, + pub dwFillAttribute: DWORD, + pub dwFlags: DWORD, + pub wShowWindow: WORD, + pub cbReserved2: WORD, + pub lpReserved2: LPBYTE, + pub hStdInput: HANDLE, + pub hStdOutput: HANDLE, + pub hStdError: HANDLE, +} +#[test] +fn bindgen_test_layout__STARTUPINFOA() { + assert_eq!( + ::std::mem::size_of::<_STARTUPINFOA>(), + 104usize, + concat!("Size of: ", stringify!(_STARTUPINFOA)) + ); + assert_eq!( + ::std::mem::align_of::<_STARTUPINFOA>(), + 8usize, + concat!("Alignment of ", stringify!(_STARTUPINFOA)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOA>())).cb as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOA), + "::", + stringify!(cb) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOA>())).lpReserved as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOA), + "::", + stringify!(lpReserved) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOA>())).lpDesktop as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOA), + "::", + stringify!(lpDesktop) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOA>())).lpTitle as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOA), + "::", + stringify!(lpTitle) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOA>())).dwX as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOA), + "::", + stringify!(dwX) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOA>())).dwY as *const _ as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOA), + "::", + stringify!(dwY) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOA>())).dwXSize as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOA), + "::", + stringify!(dwXSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOA>())).dwYSize as *const _ as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOA), + "::", + stringify!(dwYSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOA>())).dwXCountChars as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOA), + "::", + stringify!(dwXCountChars) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOA>())).dwYCountChars as *const _ as usize }, + 52usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOA), + "::", + stringify!(dwYCountChars) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOA>())).dwFillAttribute as *const _ as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOA), + "::", + stringify!(dwFillAttribute) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOA>())).dwFlags as *const _ as usize }, + 60usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOA), + "::", + stringify!(dwFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOA>())).wShowWindow as *const _ as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOA), + "::", + stringify!(wShowWindow) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOA>())).cbReserved2 as *const _ as usize }, + 66usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOA), + "::", + stringify!(cbReserved2) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOA>())).lpReserved2 as *const _ as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOA), + "::", + stringify!(lpReserved2) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOA>())).hStdInput as *const _ as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOA), + "::", + stringify!(hStdInput) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOA>())).hStdOutput as *const _ as usize }, + 88usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOA), + "::", + stringify!(hStdOutput) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOA>())).hStdError as *const _ as usize }, + 96usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOA), + "::", + stringify!(hStdError) + ) + ); +} +pub type STARTUPINFOA = _STARTUPINFOA; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STARTUPINFOW { + pub cb: DWORD, + pub lpReserved: LPWSTR, + pub lpDesktop: LPWSTR, + pub lpTitle: LPWSTR, + pub dwX: DWORD, + pub dwY: DWORD, + pub dwXSize: DWORD, + pub dwYSize: DWORD, + pub dwXCountChars: DWORD, + pub dwYCountChars: DWORD, + pub dwFillAttribute: DWORD, + pub dwFlags: DWORD, + pub wShowWindow: WORD, + pub cbReserved2: WORD, + pub lpReserved2: LPBYTE, + pub hStdInput: HANDLE, + pub hStdOutput: HANDLE, + pub hStdError: HANDLE, +} +#[test] +fn bindgen_test_layout__STARTUPINFOW() { + assert_eq!( + ::std::mem::size_of::<_STARTUPINFOW>(), + 104usize, + concat!("Size of: ", stringify!(_STARTUPINFOW)) + ); + assert_eq!( + ::std::mem::align_of::<_STARTUPINFOW>(), + 8usize, + concat!("Alignment of ", stringify!(_STARTUPINFOW)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOW>())).cb as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOW), + "::", + stringify!(cb) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOW>())).lpReserved as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOW), + "::", + stringify!(lpReserved) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOW>())).lpDesktop as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOW), + "::", + stringify!(lpDesktop) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOW>())).lpTitle as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOW), + "::", + stringify!(lpTitle) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOW>())).dwX as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOW), + "::", + stringify!(dwX) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOW>())).dwY as *const _ as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOW), + "::", + stringify!(dwY) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOW>())).dwXSize as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOW), + "::", + stringify!(dwXSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOW>())).dwYSize as *const _ as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOW), + "::", + stringify!(dwYSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOW>())).dwXCountChars as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOW), + "::", + stringify!(dwXCountChars) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOW>())).dwYCountChars as *const _ as usize }, + 52usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOW), + "::", + stringify!(dwYCountChars) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOW>())).dwFillAttribute as *const _ as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOW), + "::", + stringify!(dwFillAttribute) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOW>())).dwFlags as *const _ as usize }, + 60usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOW), + "::", + stringify!(dwFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOW>())).wShowWindow as *const _ as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOW), + "::", + stringify!(wShowWindow) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOW>())).cbReserved2 as *const _ as usize }, + 66usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOW), + "::", + stringify!(cbReserved2) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOW>())).lpReserved2 as *const _ as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOW), + "::", + stringify!(lpReserved2) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOW>())).hStdInput as *const _ as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOW), + "::", + stringify!(hStdInput) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOW>())).hStdOutput as *const _ as usize }, + 88usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOW), + "::", + stringify!(hStdOutput) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOW>())).hStdError as *const _ as usize }, + 96usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOW), + "::", + stringify!(hStdError) + ) + ); +} +pub type STARTUPINFOW = _STARTUPINFOW; +pub type LPSTARTUPINFOW = *mut _STARTUPINFOW; +pub type STARTUPINFO = STARTUPINFOW; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _PROC_THREAD_ATTRIBUTE_LIST { + _unused: [u8; 0], +} +pub type LPPROC_THREAD_ATTRIBUTE_LIST = *mut _PROC_THREAD_ATTRIBUTE_LIST; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SYSTEM_INFO { + pub __bindgen_anon_1: _SYSTEM_INFO__bindgen_ty_1, + pub dwPageSize: DWORD, + pub lpMinimumApplicationAddress: LPVOID, + pub lpMaximumApplicationAddress: LPVOID, + pub dwActiveProcessorMask: DWORD_PTR, + pub dwNumberOfProcessors: DWORD, + pub dwProcessorType: DWORD, + pub dwAllocationGranularity: DWORD, + pub wProcessorLevel: WORD, + pub wProcessorRevision: WORD, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _SYSTEM_INFO__bindgen_ty_1 { + pub dwOemId: DWORD, + pub __bindgen_anon_1: _SYSTEM_INFO__bindgen_ty_1__bindgen_ty_1, + _bindgen_union_align: u32, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SYSTEM_INFO__bindgen_ty_1__bindgen_ty_1 { + pub wProcessorArchitecture: WORD, + pub wReserved: WORD, +} +#[test] +fn bindgen_test_layout__SYSTEM_INFO__bindgen_ty_1__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_INFO__bindgen_ty_1__bindgen_ty_1>(), + 4usize, + concat!( + "Size of: ", + stringify!(_SYSTEM_INFO__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_INFO__bindgen_ty_1__bindgen_ty_1>(), + 2usize, + concat!( + "Alignment of ", + stringify!(_SYSTEM_INFO__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_INFO__bindgen_ty_1__bindgen_ty_1>())).wProcessorArchitecture + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_INFO__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(wProcessorArchitecture) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_INFO__bindgen_ty_1__bindgen_ty_1>())).wReserved as *const _ + as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_INFO__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(wReserved) + ) + ); +} +#[test] +fn bindgen_test_layout__SYSTEM_INFO__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_INFO__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(_SYSTEM_INFO__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_INFO__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(_SYSTEM_INFO__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_INFO__bindgen_ty_1>())).dwOemId as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_INFO__bindgen_ty_1), + "::", + stringify!(dwOemId) + ) + ); +} +#[test] +fn bindgen_test_layout__SYSTEM_INFO() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_INFO>(), + 48usize, + concat!("Size of: ", stringify!(_SYSTEM_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_INFO>(), + 8usize, + concat!("Alignment of ", stringify!(_SYSTEM_INFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_INFO>())).dwPageSize as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_INFO), + "::", + stringify!(dwPageSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_INFO>())).lpMinimumApplicationAddress as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_INFO), + "::", + stringify!(lpMinimumApplicationAddress) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_INFO>())).lpMaximumApplicationAddress as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_INFO), + "::", + stringify!(lpMaximumApplicationAddress) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_INFO>())).dwActiveProcessorMask as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_INFO), + "::", + stringify!(dwActiveProcessorMask) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_INFO>())).dwNumberOfProcessors as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_INFO), + "::", + stringify!(dwNumberOfProcessors) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_INFO>())).dwProcessorType as *const _ as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_INFO), + "::", + stringify!(dwProcessorType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_INFO>())).dwAllocationGranularity as *const _ as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_INFO), + "::", + stringify!(dwAllocationGranularity) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_INFO>())).wProcessorLevel as *const _ as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_INFO), + "::", + stringify!(wProcessorLevel) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_INFO>())).wProcessorRevision as *const _ as usize }, + 46usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_INFO), + "::", + stringify!(wProcessorRevision) + ) + ); +} +pub type SYSTEM_INFO = _SYSTEM_INFO; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STARTUPINFOEXA { + pub StartupInfo: STARTUPINFOA, + pub lpAttributeList: LPPROC_THREAD_ATTRIBUTE_LIST, +} +#[test] +fn bindgen_test_layout__STARTUPINFOEXA() { + assert_eq!( + ::std::mem::size_of::<_STARTUPINFOEXA>(), + 112usize, + concat!("Size of: ", stringify!(_STARTUPINFOEXA)) + ); + assert_eq!( + ::std::mem::align_of::<_STARTUPINFOEXA>(), + 8usize, + concat!("Alignment of ", stringify!(_STARTUPINFOEXA)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOEXA>())).StartupInfo as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOEXA), + "::", + stringify!(StartupInfo) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOEXA>())).lpAttributeList as *const _ as usize }, + 104usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOEXA), + "::", + stringify!(lpAttributeList) + ) + ); +} +pub type STARTUPINFOEXA = _STARTUPINFOEXA; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STARTUPINFOEXW { + pub StartupInfo: STARTUPINFOW, + pub lpAttributeList: LPPROC_THREAD_ATTRIBUTE_LIST, +} +#[test] +fn bindgen_test_layout__STARTUPINFOEXW() { + assert_eq!( + ::std::mem::size_of::<_STARTUPINFOEXW>(), + 112usize, + concat!("Size of: ", stringify!(_STARTUPINFOEXW)) + ); + assert_eq!( + ::std::mem::align_of::<_STARTUPINFOEXW>(), + 8usize, + concat!("Alignment of ", stringify!(_STARTUPINFOEXW)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOEXW>())).StartupInfo as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOEXW), + "::", + stringify!(StartupInfo) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STARTUPINFOEXW>())).lpAttributeList as *const _ as usize }, + 104usize, + concat!( + "Offset of field: ", + stringify!(_STARTUPINFOEXW), + "::", + stringify!(lpAttributeList) + ) + ); +} +pub type STARTUPINFOEXW = _STARTUPINFOEXW; +pub type STARTUPINFOEX = STARTUPINFOEXW; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SYSTEM_POWER_STATUS { + pub ACLineStatus: BYTE, + pub BatteryFlag: BYTE, + pub BatteryLifePercent: BYTE, + pub SystemStatusFlag: BYTE, + pub BatteryLifeTime: DWORD, + pub BatteryFullLifeTime: DWORD, +} +#[test] +fn bindgen_test_layout__SYSTEM_POWER_STATUS() { + assert_eq!( + ::std::mem::size_of::<_SYSTEM_POWER_STATUS>(), + 12usize, + concat!("Size of: ", stringify!(_SYSTEM_POWER_STATUS)) + ); + assert_eq!( + ::std::mem::align_of::<_SYSTEM_POWER_STATUS>(), + 4usize, + concat!("Alignment of ", stringify!(_SYSTEM_POWER_STATUS)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_POWER_STATUS>())).ACLineStatus as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_STATUS), + "::", + stringify!(ACLineStatus) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SYSTEM_POWER_STATUS>())).BatteryFlag as *const _ as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_STATUS), + "::", + stringify!(BatteryFlag) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_POWER_STATUS>())).BatteryLifePercent as *const _ as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_STATUS), + "::", + stringify!(BatteryLifePercent) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_POWER_STATUS>())).SystemStatusFlag as *const _ as usize + }, + 3usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_STATUS), + "::", + stringify!(SystemStatusFlag) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_POWER_STATUS>())).BatteryLifeTime as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_STATUS), + "::", + stringify!(BatteryLifeTime) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SYSTEM_POWER_STATUS>())).BatteryFullLifeTime as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SYSTEM_POWER_STATUS), + "::", + stringify!(BatteryFullLifeTime) + ) + ); +} +pub type SYSTEM_POWER_STATUS = _SYSTEM_POWER_STATUS; +pub type SENDASYNCPROC = ::std::option::Option< + unsafe extern "C" fn(arg1: HWND, arg2: UINT, arg3: ULONG_PTR, arg4: LRESULT), +>; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct SHELLHOOKINFO { + pub hwnd: HWND, + pub rc: RECT, +} +#[test] +fn bindgen_test_layout_SHELLHOOKINFO() { + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(SHELLHOOKINFO)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(SHELLHOOKINFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).hwnd as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(SHELLHOOKINFO), + "::", + stringify!(hwnd) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).rc as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(SHELLHOOKINFO), + "::", + stringify!(rc) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagSTYLESTRUCT { + pub styleOld: DWORD, + pub styleNew: DWORD, +} +#[test] +fn bindgen_test_layout_tagSTYLESTRUCT() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(tagSTYLESTRUCT)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(tagSTYLESTRUCT)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).styleOld as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSTYLESTRUCT), + "::", + stringify!(styleOld) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).styleNew as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagSTYLESTRUCT), + "::", + stringify!(styleNew) + ) + ); +} +pub type STYLESTRUCT = tagSTYLESTRUCT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagSCROLLINFO { + pub cbSize: UINT, + pub fMask: UINT, + pub nMin: ::std::os::raw::c_int, + pub nMax: ::std::os::raw::c_int, + pub nPage: UINT, + pub nPos: ::std::os::raw::c_int, + pub nTrackPos: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_tagSCROLLINFO() { + assert_eq!( + ::std::mem::size_of::(), + 28usize, + concat!("Size of: ", stringify!(tagSCROLLINFO)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(tagSCROLLINFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cbSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSCROLLINFO), + "::", + stringify!(cbSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).fMask as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagSCROLLINFO), + "::", + stringify!(fMask) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).nMin as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagSCROLLINFO), + "::", + stringify!(nMin) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).nMax as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(tagSCROLLINFO), + "::", + stringify!(nMax) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).nPage as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(tagSCROLLINFO), + "::", + stringify!(nPage) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).nPos as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(tagSCROLLINFO), + "::", + stringify!(nPos) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).nTrackPos as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(tagSCROLLINFO), + "::", + stringify!(nTrackPos) + ) + ); +} +pub type SCROLLINFO = tagSCROLLINFO; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagSERIALKEYSA { + pub cbSize: UINT, + pub dwFlags: DWORD, + pub lpszActivePort: LPSTR, + pub lpszPort: LPSTR, + pub iBaudRate: UINT, + pub iPortState: UINT, + pub iActive: UINT, +} +#[test] +fn bindgen_test_layout_tagSERIALKEYSA() { + assert_eq!( + ::std::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(tagSERIALKEYSA)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagSERIALKEYSA)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cbSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSERIALKEYSA), + "::", + stringify!(cbSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwFlags as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagSERIALKEYSA), + "::", + stringify!(dwFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lpszActivePort as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagSERIALKEYSA), + "::", + stringify!(lpszActivePort) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lpszPort as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(tagSERIALKEYSA), + "::", + stringify!(lpszPort) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).iBaudRate as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(tagSERIALKEYSA), + "::", + stringify!(iBaudRate) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).iPortState as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(tagSERIALKEYSA), + "::", + stringify!(iPortState) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).iActive as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(tagSERIALKEYSA), + "::", + stringify!(iActive) + ) + ); +} +pub type SERIALKEYSA = tagSERIALKEYSA; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagSERIALKEYSW { + pub cbSize: UINT, + pub dwFlags: DWORD, + pub lpszActivePort: LPWSTR, + pub lpszPort: LPWSTR, + pub iBaudRate: UINT, + pub iPortState: UINT, + pub iActive: UINT, +} +#[test] +fn bindgen_test_layout_tagSERIALKEYSW() { + assert_eq!( + ::std::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(tagSERIALKEYSW)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagSERIALKEYSW)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cbSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSERIALKEYSW), + "::", + stringify!(cbSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwFlags as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagSERIALKEYSW), + "::", + stringify!(dwFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lpszActivePort as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagSERIALKEYSW), + "::", + stringify!(lpszActivePort) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lpszPort as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(tagSERIALKEYSW), + "::", + stringify!(lpszPort) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).iBaudRate as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(tagSERIALKEYSW), + "::", + stringify!(iBaudRate) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).iPortState as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(tagSERIALKEYSW), + "::", + stringify!(iPortState) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).iActive as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(tagSERIALKEYSW), + "::", + stringify!(iActive) + ) + ); +} +pub type SERIALKEYSW = tagSERIALKEYSW; +pub type SERIALKEYS = SERIALKEYSW; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagSTICKYKEYS { + pub cbSize: UINT, + pub dwFlags: DWORD, +} +#[test] +fn bindgen_test_layout_tagSTICKYKEYS() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(tagSTICKYKEYS)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(tagSTICKYKEYS)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cbSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSTICKYKEYS), + "::", + stringify!(cbSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwFlags as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagSTICKYKEYS), + "::", + stringify!(dwFlags) + ) + ); +} +pub type STICKYKEYS = tagSTICKYKEYS; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagSOUNDSENTRYA { + pub cbSize: UINT, + pub dwFlags: DWORD, + pub iFSTextEffect: DWORD, + pub iFSTextEffectMSec: DWORD, + pub iFSTextEffectColorBits: DWORD, + pub iFSGrafEffect: DWORD, + pub iFSGrafEffectMSec: DWORD, + pub iFSGrafEffectColor: DWORD, + pub iWindowsEffect: DWORD, + pub iWindowsEffectMSec: DWORD, + pub lpszWindowsEffectDLL: LPSTR, + pub iWindowsEffectOrdinal: DWORD, +} +#[test] +fn bindgen_test_layout_tagSOUNDSENTRYA() { + assert_eq!( + ::std::mem::size_of::(), + 56usize, + concat!("Size of: ", stringify!(tagSOUNDSENTRYA)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagSOUNDSENTRYA)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cbSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYA), + "::", + stringify!(cbSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwFlags as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYA), + "::", + stringify!(dwFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).iFSTextEffect as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYA), + "::", + stringify!(iFSTextEffect) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).iFSTextEffectMSec as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYA), + "::", + stringify!(iFSTextEffectMSec) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).iFSTextEffectColorBits as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYA), + "::", + stringify!(iFSTextEffectColorBits) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).iFSGrafEffect as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYA), + "::", + stringify!(iFSGrafEffect) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).iFSGrafEffectMSec as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYA), + "::", + stringify!(iFSGrafEffectMSec) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).iFSGrafEffectColor as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYA), + "::", + stringify!(iFSGrafEffectColor) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).iWindowsEffect as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYA), + "::", + stringify!(iWindowsEffect) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).iWindowsEffectMSec as *const _ as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYA), + "::", + stringify!(iWindowsEffectMSec) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).lpszWindowsEffectDLL as *const _ as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYA), + "::", + stringify!(lpszWindowsEffectDLL) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).iWindowsEffectOrdinal as *const _ as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYA), + "::", + stringify!(iWindowsEffectOrdinal) + ) + ); +} +pub type SOUNDSENTRYA = tagSOUNDSENTRYA; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagSOUNDSENTRYW { + pub cbSize: UINT, + pub dwFlags: DWORD, + pub iFSTextEffect: DWORD, + pub iFSTextEffectMSec: DWORD, + pub iFSTextEffectColorBits: DWORD, + pub iFSGrafEffect: DWORD, + pub iFSGrafEffectMSec: DWORD, + pub iFSGrafEffectColor: DWORD, + pub iWindowsEffect: DWORD, + pub iWindowsEffectMSec: DWORD, + pub lpszWindowsEffectDLL: LPWSTR, + pub iWindowsEffectOrdinal: DWORD, +} +#[test] +fn bindgen_test_layout_tagSOUNDSENTRYW() { + assert_eq!( + ::std::mem::size_of::(), + 56usize, + concat!("Size of: ", stringify!(tagSOUNDSENTRYW)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagSOUNDSENTRYW)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cbSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYW), + "::", + stringify!(cbSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwFlags as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYW), + "::", + stringify!(dwFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).iFSTextEffect as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYW), + "::", + stringify!(iFSTextEffect) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).iFSTextEffectMSec as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYW), + "::", + stringify!(iFSTextEffectMSec) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).iFSTextEffectColorBits as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYW), + "::", + stringify!(iFSTextEffectColorBits) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).iFSGrafEffect as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYW), + "::", + stringify!(iFSGrafEffect) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).iFSGrafEffectMSec as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYW), + "::", + stringify!(iFSGrafEffectMSec) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).iFSGrafEffectColor as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYW), + "::", + stringify!(iFSGrafEffectColor) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).iWindowsEffect as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYW), + "::", + stringify!(iWindowsEffect) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).iWindowsEffectMSec as *const _ as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYW), + "::", + stringify!(iWindowsEffectMSec) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).lpszWindowsEffectDLL as *const _ as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYW), + "::", + stringify!(lpszWindowsEffectDLL) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).iWindowsEffectOrdinal as *const _ as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(tagSOUNDSENTRYW), + "::", + stringify!(iWindowsEffectOrdinal) + ) + ); +} +pub type SOUNDSENTRYW = tagSOUNDSENTRYW; +pub type SOUNDSENTRY = SOUNDSENTRYW; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagSCROLLBARINFO { + pub cbSize: DWORD, + pub rcScrollBar: RECT, + pub dxyLineButton: ::std::os::raw::c_int, + pub xyThumbTop: ::std::os::raw::c_int, + pub xyThumbBottom: ::std::os::raw::c_int, + pub reserved: ::std::os::raw::c_int, + pub rgstate: [DWORD; 6usize], +} +#[test] +fn bindgen_test_layout_tagSCROLLBARINFO() { + assert_eq!( + ::std::mem::size_of::(), + 60usize, + concat!("Size of: ", stringify!(tagSCROLLBARINFO)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(tagSCROLLBARINFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cbSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSCROLLBARINFO), + "::", + stringify!(cbSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).rcScrollBar as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagSCROLLBARINFO), + "::", + stringify!(rcScrollBar) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dxyLineButton as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(tagSCROLLBARINFO), + "::", + stringify!(dxyLineButton) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).xyThumbTop as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(tagSCROLLBARINFO), + "::", + stringify!(xyThumbTop) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).xyThumbBottom as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(tagSCROLLBARINFO), + "::", + stringify!(xyThumbBottom) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).reserved as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(tagSCROLLBARINFO), + "::", + stringify!(reserved) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).rgstate as *const _ as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(tagSCROLLBARINFO), + "::", + stringify!(rgstate) + ) + ); +} +pub type SCROLLBARINFO = tagSCROLLBARINFO; +pub const SYSNLS_FUNCTION_COMPARE_STRING: SYSNLS_FUNCTION = 1; +pub type SYSNLS_FUNCTION = ::std::os::raw::c_int; +pub const SYSGEOTYPE_GEO_NATION: SYSGEOTYPE = 1; +pub const SYSGEOTYPE_GEO_LATITUDE: SYSGEOTYPE = 2; +pub const SYSGEOTYPE_GEO_LONGITUDE: SYSGEOTYPE = 3; +pub const SYSGEOTYPE_GEO_ISO2: SYSGEOTYPE = 4; +pub const SYSGEOTYPE_GEO_ISO3: SYSGEOTYPE = 5; +pub const SYSGEOTYPE_GEO_RFC1766: SYSGEOTYPE = 6; +pub const SYSGEOTYPE_GEO_LCID: SYSGEOTYPE = 7; +pub const SYSGEOTYPE_GEO_FRIENDLYNAME: SYSGEOTYPE = 8; +pub const SYSGEOTYPE_GEO_OFFICIALNAME: SYSGEOTYPE = 9; +pub const SYSGEOTYPE_GEO_TIMEZONES: SYSGEOTYPE = 10; +pub const SYSGEOTYPE_GEO_OFFICIALLANGUAGES: SYSGEOTYPE = 11; +pub const SYSGEOTYPE_GEO_ISO_UN_NUMBER: SYSGEOTYPE = 12; +pub const SYSGEOTYPE_GEO_PARENT: SYSGEOTYPE = 13; +pub const SYSGEOTYPE_GEO_DIALINGCODE: SYSGEOTYPE = 14; +pub const SYSGEOTYPE_GEO_CURRENCYCODE: SYSGEOTYPE = 15; +pub const SYSGEOTYPE_GEO_CURRENCYSYMBOL: SYSGEOTYPE = 16; +pub const SYSGEOTYPE_GEO_NAME: SYSGEOTYPE = 17; +pub const SYSGEOTYPE_GEO_ID: SYSGEOTYPE = 18; +pub type SYSGEOTYPE = ::std::os::raw::c_int; +pub const SYSGEOCLASS_GEOCLASS_NATION: SYSGEOCLASS = 16; +pub const SYSGEOCLASS_GEOCLASS_REGION: SYSGEOCLASS = 14; +pub const SYSGEOCLASS_GEOCLASS_ALL: SYSGEOCLASS = 0; +pub type SYSGEOCLASS = ::std::os::raw::c_int; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SMALL_RECT { + pub Left: SHORT, + pub Top: SHORT, + pub Right: SHORT, + pub Bottom: SHORT, +} +#[test] +fn bindgen_test_layout__SMALL_RECT() { + assert_eq!( + ::std::mem::size_of::<_SMALL_RECT>(), + 8usize, + concat!("Size of: ", stringify!(_SMALL_RECT)) + ); + assert_eq!( + ::std::mem::align_of::<_SMALL_RECT>(), + 2usize, + concat!("Alignment of ", stringify!(_SMALL_RECT)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SMALL_RECT>())).Left as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SMALL_RECT), + "::", + stringify!(Left) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SMALL_RECT>())).Top as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_SMALL_RECT), + "::", + stringify!(Top) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SMALL_RECT>())).Right as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SMALL_RECT), + "::", + stringify!(Right) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SMALL_RECT>())).Bottom as *const _ as usize }, + 6usize, + concat!( + "Offset of field: ", + stringify!(_SMALL_RECT), + "::", + stringify!(Bottom) + ) + ); +} +pub type SMALL_RECT = _SMALL_RECT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SESSION_HEADER { + pub sess_name: UCHAR, + pub num_sess: UCHAR, + pub rcv_dg_outstanding: UCHAR, + pub rcv_any_outstanding: UCHAR, +} +#[test] +fn bindgen_test_layout__SESSION_HEADER() { + assert_eq!( + ::std::mem::size_of::<_SESSION_HEADER>(), + 4usize, + concat!("Size of: ", stringify!(_SESSION_HEADER)) + ); + assert_eq!( + ::std::mem::align_of::<_SESSION_HEADER>(), + 1usize, + concat!("Alignment of ", stringify!(_SESSION_HEADER)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SESSION_HEADER>())).sess_name as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SESSION_HEADER), + "::", + stringify!(sess_name) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SESSION_HEADER>())).num_sess as *const _ as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(_SESSION_HEADER), + "::", + stringify!(num_sess) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SESSION_HEADER>())).rcv_dg_outstanding as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_SESSION_HEADER), + "::", + stringify!(rcv_dg_outstanding) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SESSION_HEADER>())).rcv_any_outstanding as *const _ as usize }, + 3usize, + concat!( + "Offset of field: ", + stringify!(_SESSION_HEADER), + "::", + stringify!(rcv_any_outstanding) + ) + ); +} +pub type SESSION_HEADER = _SESSION_HEADER; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SESSION_BUFFER { + pub lsn: UCHAR, + pub state: UCHAR, + pub local_name: [UCHAR; 16usize], + pub remote_name: [UCHAR; 16usize], + pub rcvs_outstanding: UCHAR, + pub sends_outstanding: UCHAR, +} +#[test] +fn bindgen_test_layout__SESSION_BUFFER() { + assert_eq!( + ::std::mem::size_of::<_SESSION_BUFFER>(), + 36usize, + concat!("Size of: ", stringify!(_SESSION_BUFFER)) + ); + assert_eq!( + ::std::mem::align_of::<_SESSION_BUFFER>(), + 1usize, + concat!("Alignment of ", stringify!(_SESSION_BUFFER)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SESSION_BUFFER>())).lsn as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SESSION_BUFFER), + "::", + stringify!(lsn) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SESSION_BUFFER>())).state as *const _ as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(_SESSION_BUFFER), + "::", + stringify!(state) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SESSION_BUFFER>())).local_name as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_SESSION_BUFFER), + "::", + stringify!(local_name) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SESSION_BUFFER>())).remote_name as *const _ as usize }, + 18usize, + concat!( + "Offset of field: ", + stringify!(_SESSION_BUFFER), + "::", + stringify!(remote_name) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SESSION_BUFFER>())).rcvs_outstanding as *const _ as usize }, + 34usize, + concat!( + "Offset of field: ", + stringify!(_SESSION_BUFFER), + "::", + stringify!(rcvs_outstanding) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SESSION_BUFFER>())).sends_outstanding as *const _ as usize }, + 35usize, + concat!( + "Offset of field: ", + stringify!(_SESSION_BUFFER), + "::", + stringify!(sends_outstanding) + ) + ); +} +pub type SESSION_BUFFER = _SESSION_BUFFER; +pub type I_RPC_HANDLE = *mut ::std::os::raw::c_void; +pub type RPC_BINDING_HANDLE = I_RPC_HANDLE; +pub type handle_t = RPC_BINDING_HANDLE; +pub type UUID = GUID; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SEC_WINNT_AUTH_IDENTITY_W { + pub User: *mut ::std::os::raw::c_ushort, + pub UserLength: ::std::os::raw::c_ulong, + pub Domain: *mut ::std::os::raw::c_ushort, + pub DomainLength: ::std::os::raw::c_ulong, + pub Password: *mut ::std::os::raw::c_ushort, + pub PasswordLength: ::std::os::raw::c_ulong, + pub Flags: ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout__SEC_WINNT_AUTH_IDENTITY_W() { + assert_eq!( + ::std::mem::size_of::<_SEC_WINNT_AUTH_IDENTITY_W>(), + 48usize, + concat!("Size of: ", stringify!(_SEC_WINNT_AUTH_IDENTITY_W)) + ); + assert_eq!( + ::std::mem::align_of::<_SEC_WINNT_AUTH_IDENTITY_W>(), + 8usize, + concat!("Alignment of ", stringify!(_SEC_WINNT_AUTH_IDENTITY_W)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SEC_WINNT_AUTH_IDENTITY_W>())).User as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SEC_WINNT_AUTH_IDENTITY_W), + "::", + stringify!(User) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SEC_WINNT_AUTH_IDENTITY_W>())).UserLength as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SEC_WINNT_AUTH_IDENTITY_W), + "::", + stringify!(UserLength) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SEC_WINNT_AUTH_IDENTITY_W>())).Domain as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SEC_WINNT_AUTH_IDENTITY_W), + "::", + stringify!(Domain) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SEC_WINNT_AUTH_IDENTITY_W>())).DomainLength as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SEC_WINNT_AUTH_IDENTITY_W), + "::", + stringify!(DomainLength) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SEC_WINNT_AUTH_IDENTITY_W>())).Password as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_SEC_WINNT_AUTH_IDENTITY_W), + "::", + stringify!(Password) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SEC_WINNT_AUTH_IDENTITY_W>())).PasswordLength as *const _ as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_SEC_WINNT_AUTH_IDENTITY_W), + "::", + stringify!(PasswordLength) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SEC_WINNT_AUTH_IDENTITY_W>())).Flags as *const _ as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(_SEC_WINNT_AUTH_IDENTITY_W), + "::", + stringify!(Flags) + ) + ); +} +pub type SEC_WINNT_AUTH_IDENTITY_W = _SEC_WINNT_AUTH_IDENTITY_W; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SEC_WINNT_AUTH_IDENTITY_A { + pub User: *mut ::std::os::raw::c_uchar, + pub UserLength: ::std::os::raw::c_ulong, + pub Domain: *mut ::std::os::raw::c_uchar, + pub DomainLength: ::std::os::raw::c_ulong, + pub Password: *mut ::std::os::raw::c_uchar, + pub PasswordLength: ::std::os::raw::c_ulong, + pub Flags: ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout__SEC_WINNT_AUTH_IDENTITY_A() { + assert_eq!( + ::std::mem::size_of::<_SEC_WINNT_AUTH_IDENTITY_A>(), + 48usize, + concat!("Size of: ", stringify!(_SEC_WINNT_AUTH_IDENTITY_A)) + ); + assert_eq!( + ::std::mem::align_of::<_SEC_WINNT_AUTH_IDENTITY_A>(), + 8usize, + concat!("Alignment of ", stringify!(_SEC_WINNT_AUTH_IDENTITY_A)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SEC_WINNT_AUTH_IDENTITY_A>())).User as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SEC_WINNT_AUTH_IDENTITY_A), + "::", + stringify!(User) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SEC_WINNT_AUTH_IDENTITY_A>())).UserLength as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SEC_WINNT_AUTH_IDENTITY_A), + "::", + stringify!(UserLength) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SEC_WINNT_AUTH_IDENTITY_A>())).Domain as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SEC_WINNT_AUTH_IDENTITY_A), + "::", + stringify!(Domain) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SEC_WINNT_AUTH_IDENTITY_A>())).DomainLength as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SEC_WINNT_AUTH_IDENTITY_A), + "::", + stringify!(DomainLength) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SEC_WINNT_AUTH_IDENTITY_A>())).Password as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_SEC_WINNT_AUTH_IDENTITY_A), + "::", + stringify!(Password) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SEC_WINNT_AUTH_IDENTITY_A>())).PasswordLength as *const _ as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_SEC_WINNT_AUTH_IDENTITY_A), + "::", + stringify!(PasswordLength) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SEC_WINNT_AUTH_IDENTITY_A>())).Flags as *const _ as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(_SEC_WINNT_AUTH_IDENTITY_A), + "::", + stringify!(Flags) + ) + ); +} +pub type SEC_WINNT_AUTH_IDENTITY_A = _SEC_WINNT_AUTH_IDENTITY_A; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _RPC_VERSION { + pub MajorVersion: ::std::os::raw::c_ushort, + pub MinorVersion: ::std::os::raw::c_ushort, +} +#[test] +fn bindgen_test_layout__RPC_VERSION() { + assert_eq!( + ::std::mem::size_of::<_RPC_VERSION>(), + 4usize, + concat!("Size of: ", stringify!(_RPC_VERSION)) + ); + assert_eq!( + ::std::mem::align_of::<_RPC_VERSION>(), + 2usize, + concat!("Alignment of ", stringify!(_RPC_VERSION)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_RPC_VERSION>())).MajorVersion as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_RPC_VERSION), + "::", + stringify!(MajorVersion) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_RPC_VERSION>())).MinorVersion as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_RPC_VERSION), + "::", + stringify!(MinorVersion) + ) + ); +} +pub type RPC_VERSION = _RPC_VERSION; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _RPC_SYNTAX_IDENTIFIER { + pub SyntaxGUID: GUID, + pub SyntaxVersion: RPC_VERSION, +} +#[test] +fn bindgen_test_layout__RPC_SYNTAX_IDENTIFIER() { + assert_eq!( + ::std::mem::size_of::<_RPC_SYNTAX_IDENTIFIER>(), + 20usize, + concat!("Size of: ", stringify!(_RPC_SYNTAX_IDENTIFIER)) + ); + assert_eq!( + ::std::mem::align_of::<_RPC_SYNTAX_IDENTIFIER>(), + 4usize, + concat!("Alignment of ", stringify!(_RPC_SYNTAX_IDENTIFIER)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_RPC_SYNTAX_IDENTIFIER>())).SyntaxGUID as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_RPC_SYNTAX_IDENTIFIER), + "::", + stringify!(SyntaxGUID) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_RPC_SYNTAX_IDENTIFIER>())).SyntaxVersion as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_RPC_SYNTAX_IDENTIFIER), + "::", + stringify!(SyntaxVersion) + ) + ); +} +pub type PRPC_SYNTAX_IDENTIFIER = *mut _RPC_SYNTAX_IDENTIFIER; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _RPC_MESSAGE { + pub Handle: RPC_BINDING_HANDLE, + pub DataRepresentation: ::std::os::raw::c_ulong, + pub Buffer: *mut ::std::os::raw::c_void, + pub BufferLength: ::std::os::raw::c_uint, + pub ProcNum: ::std::os::raw::c_uint, + pub TransferSyntax: PRPC_SYNTAX_IDENTIFIER, + pub RpcInterfaceInformation: *mut ::std::os::raw::c_void, + pub ReservedForRuntime: *mut ::std::os::raw::c_void, + pub ManagerEpv: *mut ::std::os::raw::c_void, + pub ImportContext: *mut ::std::os::raw::c_void, + pub RpcFlags: ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout__RPC_MESSAGE() { + assert_eq!( + ::std::mem::size_of::<_RPC_MESSAGE>(), + 80usize, + concat!("Size of: ", stringify!(_RPC_MESSAGE)) + ); + assert_eq!( + ::std::mem::align_of::<_RPC_MESSAGE>(), + 8usize, + concat!("Alignment of ", stringify!(_RPC_MESSAGE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_RPC_MESSAGE>())).Handle as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_RPC_MESSAGE), + "::", + stringify!(Handle) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_RPC_MESSAGE>())).DataRepresentation as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_RPC_MESSAGE), + "::", + stringify!(DataRepresentation) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_RPC_MESSAGE>())).Buffer as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_RPC_MESSAGE), + "::", + stringify!(Buffer) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_RPC_MESSAGE>())).BufferLength as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_RPC_MESSAGE), + "::", + stringify!(BufferLength) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_RPC_MESSAGE>())).ProcNum as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_RPC_MESSAGE), + "::", + stringify!(ProcNum) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_RPC_MESSAGE>())).TransferSyntax as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_RPC_MESSAGE), + "::", + stringify!(TransferSyntax) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_RPC_MESSAGE>())).RpcInterfaceInformation as *const _ as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_RPC_MESSAGE), + "::", + stringify!(RpcInterfaceInformation) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_RPC_MESSAGE>())).ReservedForRuntime as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_RPC_MESSAGE), + "::", + stringify!(ReservedForRuntime) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_RPC_MESSAGE>())).ManagerEpv as *const _ as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(_RPC_MESSAGE), + "::", + stringify!(ManagerEpv) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_RPC_MESSAGE>())).ImportContext as *const _ as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(_RPC_MESSAGE), + "::", + stringify!(ImportContext) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_RPC_MESSAGE>())).RpcFlags as *const _ as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(_RPC_MESSAGE), + "::", + stringify!(RpcFlags) + ) + ); +} +pub type PRPC_MESSAGE = *mut _RPC_MESSAGE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _AppBarData { + pub cbSize: DWORD, + pub hWnd: HWND, + pub uCallbackMessage: UINT, + pub uEdge: UINT, + pub rc: RECT, + pub lParam: LPARAM, +} +#[test] +fn bindgen_test_layout__AppBarData() { + assert_eq!( + ::std::mem::size_of::<_AppBarData>(), + 48usize, + concat!("Size of: ", stringify!(_AppBarData)) + ); + assert_eq!( + ::std::mem::align_of::<_AppBarData>(), + 8usize, + concat!("Alignment of ", stringify!(_AppBarData)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_AppBarData>())).cbSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_AppBarData), + "::", + stringify!(cbSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_AppBarData>())).hWnd as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_AppBarData), + "::", + stringify!(hWnd) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_AppBarData>())).uCallbackMessage as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_AppBarData), + "::", + stringify!(uCallbackMessage) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_AppBarData>())).uEdge as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_AppBarData), + "::", + stringify!(uEdge) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_AppBarData>())).rc as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_AppBarData), + "::", + stringify!(rc) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_AppBarData>())).lParam as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_AppBarData), + "::", + stringify!(lParam) + ) + ); +} +pub type PAPPBARDATA = *mut _AppBarData; +extern "C" { + pub fn SHAppBarMessage(dwMessage: DWORD, pData: PAPPBARDATA) -> UINT_PTR; +} +pub type FILEOP_FLAGS = WORD; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SHFILEOPSTRUCTA { + pub hwnd: HWND, + pub wFunc: UINT, + pub pFrom: PCZZSTR, + pub pTo: PCZZSTR, + pub fFlags: FILEOP_FLAGS, + pub fAnyOperationsAborted: BOOL, + pub hNameMappings: LPVOID, + pub lpszProgressTitle: PCSTR, +} +#[test] +fn bindgen_test_layout__SHFILEOPSTRUCTA() { + assert_eq!( + ::std::mem::size_of::<_SHFILEOPSTRUCTA>(), + 56usize, + concat!("Size of: ", stringify!(_SHFILEOPSTRUCTA)) + ); + assert_eq!( + ::std::mem::align_of::<_SHFILEOPSTRUCTA>(), + 8usize, + concat!("Alignment of ", stringify!(_SHFILEOPSTRUCTA)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEOPSTRUCTA>())).hwnd as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEOPSTRUCTA), + "::", + stringify!(hwnd) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEOPSTRUCTA>())).wFunc as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEOPSTRUCTA), + "::", + stringify!(wFunc) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEOPSTRUCTA>())).pFrom as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEOPSTRUCTA), + "::", + stringify!(pFrom) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEOPSTRUCTA>())).pTo as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEOPSTRUCTA), + "::", + stringify!(pTo) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEOPSTRUCTA>())).fFlags as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEOPSTRUCTA), + "::", + stringify!(fFlags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SHFILEOPSTRUCTA>())).fAnyOperationsAborted as *const _ as usize + }, + 36usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEOPSTRUCTA), + "::", + stringify!(fAnyOperationsAborted) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEOPSTRUCTA>())).hNameMappings as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEOPSTRUCTA), + "::", + stringify!(hNameMappings) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEOPSTRUCTA>())).lpszProgressTitle as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEOPSTRUCTA), + "::", + stringify!(lpszProgressTitle) + ) + ); +} +pub type SHFILEOPSTRUCTA = _SHFILEOPSTRUCTA; +pub type LPSHFILEOPSTRUCTA = *mut _SHFILEOPSTRUCTA; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SHFILEOPSTRUCTW { + pub hwnd: HWND, + pub wFunc: UINT, + pub pFrom: PCZZWSTR, + pub pTo: PCZZWSTR, + pub fFlags: FILEOP_FLAGS, + pub fAnyOperationsAborted: BOOL, + pub hNameMappings: LPVOID, + pub lpszProgressTitle: PCWSTR, +} +#[test] +fn bindgen_test_layout__SHFILEOPSTRUCTW() { + assert_eq!( + ::std::mem::size_of::<_SHFILEOPSTRUCTW>(), + 56usize, + concat!("Size of: ", stringify!(_SHFILEOPSTRUCTW)) + ); + assert_eq!( + ::std::mem::align_of::<_SHFILEOPSTRUCTW>(), + 8usize, + concat!("Alignment of ", stringify!(_SHFILEOPSTRUCTW)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEOPSTRUCTW>())).hwnd as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEOPSTRUCTW), + "::", + stringify!(hwnd) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEOPSTRUCTW>())).wFunc as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEOPSTRUCTW), + "::", + stringify!(wFunc) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEOPSTRUCTW>())).pFrom as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEOPSTRUCTW), + "::", + stringify!(pFrom) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEOPSTRUCTW>())).pTo as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEOPSTRUCTW), + "::", + stringify!(pTo) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEOPSTRUCTW>())).fFlags as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEOPSTRUCTW), + "::", + stringify!(fFlags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SHFILEOPSTRUCTW>())).fAnyOperationsAborted as *const _ as usize + }, + 36usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEOPSTRUCTW), + "::", + stringify!(fAnyOperationsAborted) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEOPSTRUCTW>())).hNameMappings as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEOPSTRUCTW), + "::", + stringify!(hNameMappings) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEOPSTRUCTW>())).lpszProgressTitle as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEOPSTRUCTW), + "::", + stringify!(lpszProgressTitle) + ) + ); +} +pub type SHFILEOPSTRUCTW = _SHFILEOPSTRUCTW; +pub type LPSHFILEOPSTRUCTW = *mut _SHFILEOPSTRUCTW; +pub type SHFILEOPSTRUCT = SHFILEOPSTRUCTW; +extern "C" { + pub fn SHFileOperationA(lpFileOp: LPSHFILEOPSTRUCTA) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn SHFileOperationW(lpFileOp: LPSHFILEOPSTRUCTW) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn SHFreeNameMappings(hNameMappings: HANDLE); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SHNAMEMAPPINGA { + pub pszOldPath: LPSTR, + pub pszNewPath: LPSTR, + pub cchOldPath: ::std::os::raw::c_int, + pub cchNewPath: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout__SHNAMEMAPPINGA() { + assert_eq!( + ::std::mem::size_of::<_SHNAMEMAPPINGA>(), + 24usize, + concat!("Size of: ", stringify!(_SHNAMEMAPPINGA)) + ); + assert_eq!( + ::std::mem::align_of::<_SHNAMEMAPPINGA>(), + 8usize, + concat!("Alignment of ", stringify!(_SHNAMEMAPPINGA)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHNAMEMAPPINGA>())).pszOldPath as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SHNAMEMAPPINGA), + "::", + stringify!(pszOldPath) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHNAMEMAPPINGA>())).pszNewPath as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SHNAMEMAPPINGA), + "::", + stringify!(pszNewPath) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHNAMEMAPPINGA>())).cchOldPath as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SHNAMEMAPPINGA), + "::", + stringify!(cchOldPath) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHNAMEMAPPINGA>())).cchNewPath as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_SHNAMEMAPPINGA), + "::", + stringify!(cchNewPath) + ) + ); +} +pub type SHNAMEMAPPINGA = _SHNAMEMAPPINGA; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SHNAMEMAPPINGW { + pub pszOldPath: LPWSTR, + pub pszNewPath: LPWSTR, + pub cchOldPath: ::std::os::raw::c_int, + pub cchNewPath: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout__SHNAMEMAPPINGW() { + assert_eq!( + ::std::mem::size_of::<_SHNAMEMAPPINGW>(), + 24usize, + concat!("Size of: ", stringify!(_SHNAMEMAPPINGW)) + ); + assert_eq!( + ::std::mem::align_of::<_SHNAMEMAPPINGW>(), + 8usize, + concat!("Alignment of ", stringify!(_SHNAMEMAPPINGW)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHNAMEMAPPINGW>())).pszOldPath as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SHNAMEMAPPINGW), + "::", + stringify!(pszOldPath) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHNAMEMAPPINGW>())).pszNewPath as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SHNAMEMAPPINGW), + "::", + stringify!(pszNewPath) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHNAMEMAPPINGW>())).cchOldPath as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SHNAMEMAPPINGW), + "::", + stringify!(cchOldPath) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHNAMEMAPPINGW>())).cchNewPath as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_SHNAMEMAPPINGW), + "::", + stringify!(cchNewPath) + ) + ); +} +pub type SHNAMEMAPPINGW = _SHNAMEMAPPINGW; +pub type SHNAMEMAPPING = SHNAMEMAPPINGW; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SHELLEXECUTEINFOA { + pub cbSize: DWORD, + pub fMask: ULONG, + pub hwnd: HWND, + pub lpVerb: LPCSTR, + pub lpFile: LPCSTR, + pub lpParameters: LPCSTR, + pub lpDirectory: LPCSTR, + pub nShow: ::std::os::raw::c_int, + pub hInstApp: HINSTANCE, + pub lpIDList: *mut ::std::os::raw::c_void, + pub lpClass: LPCSTR, + pub hkeyClass: HKEY, + pub dwHotKey: DWORD, + pub __bindgen_anon_1: _SHELLEXECUTEINFOA__bindgen_ty_1, + pub hProcess: HANDLE, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _SHELLEXECUTEINFOA__bindgen_ty_1 { + pub hIcon: HANDLE, + pub hMonitor: HANDLE, + _bindgen_union_align: u64, +} +#[test] +fn bindgen_test_layout__SHELLEXECUTEINFOA__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_SHELLEXECUTEINFOA__bindgen_ty_1>(), + 8usize, + concat!("Size of: ", stringify!(_SHELLEXECUTEINFOA__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<_SHELLEXECUTEINFOA__bindgen_ty_1>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_SHELLEXECUTEINFOA__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SHELLEXECUTEINFOA__bindgen_ty_1>())).hIcon as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOA__bindgen_ty_1), + "::", + stringify!(hIcon) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SHELLEXECUTEINFOA__bindgen_ty_1>())).hMonitor as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOA__bindgen_ty_1), + "::", + stringify!(hMonitor) + ) + ); +} +#[test] +fn bindgen_test_layout__SHELLEXECUTEINFOA() { + assert_eq!( + ::std::mem::size_of::<_SHELLEXECUTEINFOA>(), + 112usize, + concat!("Size of: ", stringify!(_SHELLEXECUTEINFOA)) + ); + assert_eq!( + ::std::mem::align_of::<_SHELLEXECUTEINFOA>(), + 8usize, + concat!("Alignment of ", stringify!(_SHELLEXECUTEINFOA)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOA>())).cbSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOA), + "::", + stringify!(cbSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOA>())).fMask as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOA), + "::", + stringify!(fMask) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOA>())).hwnd as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOA), + "::", + stringify!(hwnd) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOA>())).lpVerb as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOA), + "::", + stringify!(lpVerb) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOA>())).lpFile as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOA), + "::", + stringify!(lpFile) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOA>())).lpParameters as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOA), + "::", + stringify!(lpParameters) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOA>())).lpDirectory as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOA), + "::", + stringify!(lpDirectory) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOA>())).nShow as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOA), + "::", + stringify!(nShow) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOA>())).hInstApp as *const _ as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOA), + "::", + stringify!(hInstApp) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOA>())).lpIDList as *const _ as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOA), + "::", + stringify!(lpIDList) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOA>())).lpClass as *const _ as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOA), + "::", + stringify!(lpClass) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOA>())).hkeyClass as *const _ as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOA), + "::", + stringify!(hkeyClass) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOA>())).dwHotKey as *const _ as usize }, + 88usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOA), + "::", + stringify!(dwHotKey) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOA>())).hProcess as *const _ as usize }, + 104usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOA), + "::", + stringify!(hProcess) + ) + ); +} +pub type SHELLEXECUTEINFOA = _SHELLEXECUTEINFOA; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SHELLEXECUTEINFOW { + pub cbSize: DWORD, + pub fMask: ULONG, + pub hwnd: HWND, + pub lpVerb: LPCWSTR, + pub lpFile: LPCWSTR, + pub lpParameters: LPCWSTR, + pub lpDirectory: LPCWSTR, + pub nShow: ::std::os::raw::c_int, + pub hInstApp: HINSTANCE, + pub lpIDList: *mut ::std::os::raw::c_void, + pub lpClass: LPCWSTR, + pub hkeyClass: HKEY, + pub dwHotKey: DWORD, + pub __bindgen_anon_1: _SHELLEXECUTEINFOW__bindgen_ty_1, + pub hProcess: HANDLE, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _SHELLEXECUTEINFOW__bindgen_ty_1 { + pub hIcon: HANDLE, + pub hMonitor: HANDLE, + _bindgen_union_align: u64, +} +#[test] +fn bindgen_test_layout__SHELLEXECUTEINFOW__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_SHELLEXECUTEINFOW__bindgen_ty_1>(), + 8usize, + concat!("Size of: ", stringify!(_SHELLEXECUTEINFOW__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<_SHELLEXECUTEINFOW__bindgen_ty_1>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_SHELLEXECUTEINFOW__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SHELLEXECUTEINFOW__bindgen_ty_1>())).hIcon as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOW__bindgen_ty_1), + "::", + stringify!(hIcon) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SHELLEXECUTEINFOW__bindgen_ty_1>())).hMonitor as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOW__bindgen_ty_1), + "::", + stringify!(hMonitor) + ) + ); +} +#[test] +fn bindgen_test_layout__SHELLEXECUTEINFOW() { + assert_eq!( + ::std::mem::size_of::<_SHELLEXECUTEINFOW>(), + 112usize, + concat!("Size of: ", stringify!(_SHELLEXECUTEINFOW)) + ); + assert_eq!( + ::std::mem::align_of::<_SHELLEXECUTEINFOW>(), + 8usize, + concat!("Alignment of ", stringify!(_SHELLEXECUTEINFOW)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOW>())).cbSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOW), + "::", + stringify!(cbSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOW>())).fMask as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOW), + "::", + stringify!(fMask) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOW>())).hwnd as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOW), + "::", + stringify!(hwnd) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOW>())).lpVerb as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOW), + "::", + stringify!(lpVerb) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOW>())).lpFile as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOW), + "::", + stringify!(lpFile) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOW>())).lpParameters as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOW), + "::", + stringify!(lpParameters) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOW>())).lpDirectory as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOW), + "::", + stringify!(lpDirectory) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOW>())).nShow as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOW), + "::", + stringify!(nShow) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOW>())).hInstApp as *const _ as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOW), + "::", + stringify!(hInstApp) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOW>())).lpIDList as *const _ as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOW), + "::", + stringify!(lpIDList) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOW>())).lpClass as *const _ as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOW), + "::", + stringify!(lpClass) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOW>())).hkeyClass as *const _ as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOW), + "::", + stringify!(hkeyClass) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOW>())).dwHotKey as *const _ as usize }, + 88usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOW), + "::", + stringify!(dwHotKey) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHELLEXECUTEINFOW>())).hProcess as *const _ as usize }, + 104usize, + concat!( + "Offset of field: ", + stringify!(_SHELLEXECUTEINFOW), + "::", + stringify!(hProcess) + ) + ); +} +pub type SHELLEXECUTEINFOW = _SHELLEXECUTEINFOW; +pub type SHELLEXECUTEINFO = SHELLEXECUTEINFOW; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SHCREATEPROCESSINFOW { + pub cbSize: DWORD, + pub fMask: ULONG, + pub hwnd: HWND, + pub pszFile: LPCWSTR, + pub pszParameters: LPCWSTR, + pub pszCurrentDirectory: LPCWSTR, + pub hUserToken: HANDLE, + pub lpProcessAttributes: LPSECURITY_ATTRIBUTES, + pub lpThreadAttributes: LPSECURITY_ATTRIBUTES, + pub bInheritHandles: BOOL, + pub dwCreationFlags: DWORD, + pub lpStartupInfo: LPSTARTUPINFOW, + pub lpProcessInformation: LPPROCESS_INFORMATION, +} +#[test] +fn bindgen_test_layout__SHCREATEPROCESSINFOW() { + assert_eq!( + ::std::mem::size_of::<_SHCREATEPROCESSINFOW>(), + 88usize, + concat!("Size of: ", stringify!(_SHCREATEPROCESSINFOW)) + ); + assert_eq!( + ::std::mem::align_of::<_SHCREATEPROCESSINFOW>(), + 8usize, + concat!("Alignment of ", stringify!(_SHCREATEPROCESSINFOW)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHCREATEPROCESSINFOW>())).cbSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SHCREATEPROCESSINFOW), + "::", + stringify!(cbSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHCREATEPROCESSINFOW>())).fMask as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SHCREATEPROCESSINFOW), + "::", + stringify!(fMask) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHCREATEPROCESSINFOW>())).hwnd as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SHCREATEPROCESSINFOW), + "::", + stringify!(hwnd) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHCREATEPROCESSINFOW>())).pszFile as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SHCREATEPROCESSINFOW), + "::", + stringify!(pszFile) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHCREATEPROCESSINFOW>())).pszParameters as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SHCREATEPROCESSINFOW), + "::", + stringify!(pszParameters) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SHCREATEPROCESSINFOW>())).pszCurrentDirectory as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_SHCREATEPROCESSINFOW), + "::", + stringify!(pszCurrentDirectory) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHCREATEPROCESSINFOW>())).hUserToken as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_SHCREATEPROCESSINFOW), + "::", + stringify!(hUserToken) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SHCREATEPROCESSINFOW>())).lpProcessAttributes as *const _ as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_SHCREATEPROCESSINFOW), + "::", + stringify!(lpProcessAttributes) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SHCREATEPROCESSINFOW>())).lpThreadAttributes as *const _ as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(_SHCREATEPROCESSINFOW), + "::", + stringify!(lpThreadAttributes) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SHCREATEPROCESSINFOW>())).bInheritHandles as *const _ as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(_SHCREATEPROCESSINFOW), + "::", + stringify!(bInheritHandles) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SHCREATEPROCESSINFOW>())).dwCreationFlags as *const _ as usize + }, + 68usize, + concat!( + "Offset of field: ", + stringify!(_SHCREATEPROCESSINFOW), + "::", + stringify!(dwCreationFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHCREATEPROCESSINFOW>())).lpStartupInfo as *const _ as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(_SHCREATEPROCESSINFOW), + "::", + stringify!(lpStartupInfo) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SHCREATEPROCESSINFOW>())).lpProcessInformation as *const _ as usize + }, + 80usize, + concat!( + "Offset of field: ", + stringify!(_SHCREATEPROCESSINFOW), + "::", + stringify!(lpProcessInformation) + ) + ); +} +pub type SHCREATEPROCESSINFOW = _SHCREATEPROCESSINFOW; +pub type PSHCREATEPROCESSINFOW = *mut _SHCREATEPROCESSINFOW; +extern "C" { + pub fn SHCreateProcessAsUserW(pscpi: PSHCREATEPROCESSINFOW) -> BOOL; +} +extern "C" { + pub fn SHEvaluateSystemCommandTemplate( + pszCmdTemplate: PCWSTR, + ppszApplication: *mut PWSTR, + ppszCommandLine: *mut PWSTR, + ppszParameters: *mut PWSTR, + ) -> HRESULT; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SHQUERYRBINFO { + pub cbSize: DWORD, + pub i64Size: ::std::os::raw::c_longlong, + pub i64NumItems: ::std::os::raw::c_longlong, +} +#[test] +fn bindgen_test_layout__SHQUERYRBINFO() { + assert_eq!( + ::std::mem::size_of::<_SHQUERYRBINFO>(), + 24usize, + concat!("Size of: ", stringify!(_SHQUERYRBINFO)) + ); + assert_eq!( + ::std::mem::align_of::<_SHQUERYRBINFO>(), + 8usize, + concat!("Alignment of ", stringify!(_SHQUERYRBINFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHQUERYRBINFO>())).cbSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SHQUERYRBINFO), + "::", + stringify!(cbSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHQUERYRBINFO>())).i64Size as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SHQUERYRBINFO), + "::", + stringify!(i64Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHQUERYRBINFO>())).i64NumItems as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SHQUERYRBINFO), + "::", + stringify!(i64NumItems) + ) + ); +} +pub type SHQUERYRBINFO = _SHQUERYRBINFO; +pub type LPSHQUERYRBINFO = *mut _SHQUERYRBINFO; +extern "C" { + pub fn SHQueryRecycleBinA(pszRootPath: LPCSTR, pSHQueryRBInfo: LPSHQUERYRBINFO) -> HRESULT; +} +extern "C" { + pub fn SHQueryRecycleBinW(pszRootPath: LPCWSTR, pSHQueryRBInfo: LPSHQUERYRBINFO) -> HRESULT; +} +extern "C" { + pub fn SHEmptyRecycleBinA(hwnd: HWND, pszRootPath: LPCSTR, dwFlags: DWORD) -> HRESULT; +} +extern "C" { + pub fn SHEmptyRecycleBinW(hwnd: HWND, pszRootPath: LPCWSTR, dwFlags: DWORD) -> HRESULT; +} +pub const QUERY_USER_NOTIFICATION_STATE_QUNS_NOT_PRESENT: QUERY_USER_NOTIFICATION_STATE = 1; +pub const QUERY_USER_NOTIFICATION_STATE_QUNS_BUSY: QUERY_USER_NOTIFICATION_STATE = 2; +pub const QUERY_USER_NOTIFICATION_STATE_QUNS_RUNNING_D3D_FULL_SCREEN: + QUERY_USER_NOTIFICATION_STATE = 3; +pub const QUERY_USER_NOTIFICATION_STATE_QUNS_PRESENTATION_MODE: QUERY_USER_NOTIFICATION_STATE = 4; +pub const QUERY_USER_NOTIFICATION_STATE_QUNS_ACCEPTS_NOTIFICATIONS: QUERY_USER_NOTIFICATION_STATE = + 5; +pub const QUERY_USER_NOTIFICATION_STATE_QUNS_QUIET_TIME: QUERY_USER_NOTIFICATION_STATE = 6; +pub const QUERY_USER_NOTIFICATION_STATE_QUNS_APP: QUERY_USER_NOTIFICATION_STATE = 7; +pub type QUERY_USER_NOTIFICATION_STATE = ::std::os::raw::c_int; +extern "C" { + pub fn SHQueryUserNotificationState(pquns: *mut QUERY_USER_NOTIFICATION_STATE) -> HRESULT; +} +extern "C" { + pub fn SHGetPropertyStoreForWindow( + hwnd: HWND, + riid: *const IID, + ppv: *mut *mut ::std::os::raw::c_void, + ) -> HRESULT; +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SHFILEINFOA { + pub hIcon: HICON, + pub iIcon: ::std::os::raw::c_int, + pub dwAttributes: DWORD, + pub szDisplayName: [CHAR; 260usize], + pub szTypeName: [CHAR; 80usize], +} +#[test] +fn bindgen_test_layout__SHFILEINFOA() { + assert_eq!( + ::std::mem::size_of::<_SHFILEINFOA>(), + 360usize, + concat!("Size of: ", stringify!(_SHFILEINFOA)) + ); + assert_eq!( + ::std::mem::align_of::<_SHFILEINFOA>(), + 8usize, + concat!("Alignment of ", stringify!(_SHFILEINFOA)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEINFOA>())).hIcon as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEINFOA), + "::", + stringify!(hIcon) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEINFOA>())).iIcon as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEINFOA), + "::", + stringify!(iIcon) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEINFOA>())).dwAttributes as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEINFOA), + "::", + stringify!(dwAttributes) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEINFOA>())).szDisplayName as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEINFOA), + "::", + stringify!(szDisplayName) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEINFOA>())).szTypeName as *const _ as usize }, + 276usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEINFOA), + "::", + stringify!(szTypeName) + ) + ); +} +pub type SHFILEINFOA = _SHFILEINFOA; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SHFILEINFOW { + pub hIcon: HICON, + pub iIcon: ::std::os::raw::c_int, + pub dwAttributes: DWORD, + pub szDisplayName: [WCHAR; 260usize], + pub szTypeName: [WCHAR; 80usize], +} +#[test] +fn bindgen_test_layout__SHFILEINFOW() { + assert_eq!( + ::std::mem::size_of::<_SHFILEINFOW>(), + 696usize, + concat!("Size of: ", stringify!(_SHFILEINFOW)) + ); + assert_eq!( + ::std::mem::align_of::<_SHFILEINFOW>(), + 8usize, + concat!("Alignment of ", stringify!(_SHFILEINFOW)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEINFOW>())).hIcon as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEINFOW), + "::", + stringify!(hIcon) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEINFOW>())).iIcon as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEINFOW), + "::", + stringify!(iIcon) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEINFOW>())).dwAttributes as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEINFOW), + "::", + stringify!(dwAttributes) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEINFOW>())).szDisplayName as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEINFOW), + "::", + stringify!(szDisplayName) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHFILEINFOW>())).szTypeName as *const _ as usize }, + 536usize, + concat!( + "Offset of field: ", + stringify!(_SHFILEINFOW), + "::", + stringify!(szTypeName) + ) + ); +} +pub type SHFILEINFOW = _SHFILEINFOW; +pub type SHFILEINFO = SHFILEINFOW; +extern "C" { + pub fn SHGetFileInfoA( + pszPath: LPCSTR, + dwFileAttributes: DWORD, + psfi: *mut SHFILEINFOA, + cbFileInfo: UINT, + uFlags: UINT, + ) -> DWORD_PTR; +} +extern "C" { + pub fn SHGetFileInfoW( + pszPath: LPCWSTR, + dwFileAttributes: DWORD, + psfi: *mut SHFILEINFOW, + cbFileInfo: UINT, + uFlags: UINT, + ) -> DWORD_PTR; +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SHSTOCKICONINFO { + pub cbSize: DWORD, + pub hIcon: HICON, + pub iSysImageIndex: ::std::os::raw::c_int, + pub iIcon: ::std::os::raw::c_int, + pub szPath: [WCHAR; 260usize], +} +#[test] +fn bindgen_test_layout__SHSTOCKICONINFO() { + assert_eq!( + ::std::mem::size_of::<_SHSTOCKICONINFO>(), + 544usize, + concat!("Size of: ", stringify!(_SHSTOCKICONINFO)) + ); + assert_eq!( + ::std::mem::align_of::<_SHSTOCKICONINFO>(), + 8usize, + concat!("Alignment of ", stringify!(_SHSTOCKICONINFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHSTOCKICONINFO>())).cbSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SHSTOCKICONINFO), + "::", + stringify!(cbSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHSTOCKICONINFO>())).hIcon as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SHSTOCKICONINFO), + "::", + stringify!(hIcon) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHSTOCKICONINFO>())).iSysImageIndex as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SHSTOCKICONINFO), + "::", + stringify!(iSysImageIndex) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHSTOCKICONINFO>())).iIcon as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_SHSTOCKICONINFO), + "::", + stringify!(iIcon) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHSTOCKICONINFO>())).szPath as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SHSTOCKICONINFO), + "::", + stringify!(szPath) + ) + ); +} +pub type SHSTOCKICONINFO = _SHSTOCKICONINFO; +pub const SHSTOCKICONID_SIID_DOCNOASSOC: SHSTOCKICONID = 0; +pub const SHSTOCKICONID_SIID_DOCASSOC: SHSTOCKICONID = 1; +pub const SHSTOCKICONID_SIID_APPLICATION: SHSTOCKICONID = 2; +pub const SHSTOCKICONID_SIID_FOLDER: SHSTOCKICONID = 3; +pub const SHSTOCKICONID_SIID_FOLDEROPEN: SHSTOCKICONID = 4; +pub const SHSTOCKICONID_SIID_DRIVE525: SHSTOCKICONID = 5; +pub const SHSTOCKICONID_SIID_DRIVE35: SHSTOCKICONID = 6; +pub const SHSTOCKICONID_SIID_DRIVEREMOVE: SHSTOCKICONID = 7; +pub const SHSTOCKICONID_SIID_DRIVEFIXED: SHSTOCKICONID = 8; +pub const SHSTOCKICONID_SIID_DRIVENET: SHSTOCKICONID = 9; +pub const SHSTOCKICONID_SIID_DRIVENETDISABLED: SHSTOCKICONID = 10; +pub const SHSTOCKICONID_SIID_DRIVECD: SHSTOCKICONID = 11; +pub const SHSTOCKICONID_SIID_DRIVERAM: SHSTOCKICONID = 12; +pub const SHSTOCKICONID_SIID_WORLD: SHSTOCKICONID = 13; +pub const SHSTOCKICONID_SIID_SERVER: SHSTOCKICONID = 15; +pub const SHSTOCKICONID_SIID_PRINTER: SHSTOCKICONID = 16; +pub const SHSTOCKICONID_SIID_MYNETWORK: SHSTOCKICONID = 17; +pub const SHSTOCKICONID_SIID_FIND: SHSTOCKICONID = 22; +pub const SHSTOCKICONID_SIID_HELP: SHSTOCKICONID = 23; +pub const SHSTOCKICONID_SIID_SHARE: SHSTOCKICONID = 28; +pub const SHSTOCKICONID_SIID_LINK: SHSTOCKICONID = 29; +pub const SHSTOCKICONID_SIID_SLOWFILE: SHSTOCKICONID = 30; +pub const SHSTOCKICONID_SIID_RECYCLER: SHSTOCKICONID = 31; +pub const SHSTOCKICONID_SIID_RECYCLERFULL: SHSTOCKICONID = 32; +pub const SHSTOCKICONID_SIID_MEDIACDAUDIO: SHSTOCKICONID = 40; +pub const SHSTOCKICONID_SIID_LOCK: SHSTOCKICONID = 47; +pub const SHSTOCKICONID_SIID_AUTOLIST: SHSTOCKICONID = 49; +pub const SHSTOCKICONID_SIID_PRINTERNET: SHSTOCKICONID = 50; +pub const SHSTOCKICONID_SIID_SERVERSHARE: SHSTOCKICONID = 51; +pub const SHSTOCKICONID_SIID_PRINTERFAX: SHSTOCKICONID = 52; +pub const SHSTOCKICONID_SIID_PRINTERFAXNET: SHSTOCKICONID = 53; +pub const SHSTOCKICONID_SIID_PRINTERFILE: SHSTOCKICONID = 54; +pub const SHSTOCKICONID_SIID_STACK: SHSTOCKICONID = 55; +pub const SHSTOCKICONID_SIID_MEDIASVCD: SHSTOCKICONID = 56; +pub const SHSTOCKICONID_SIID_STUFFEDFOLDER: SHSTOCKICONID = 57; +pub const SHSTOCKICONID_SIID_DRIVEUNKNOWN: SHSTOCKICONID = 58; +pub const SHSTOCKICONID_SIID_DRIVEDVD: SHSTOCKICONID = 59; +pub const SHSTOCKICONID_SIID_MEDIADVD: SHSTOCKICONID = 60; +pub const SHSTOCKICONID_SIID_MEDIADVDRAM: SHSTOCKICONID = 61; +pub const SHSTOCKICONID_SIID_MEDIADVDRW: SHSTOCKICONID = 62; +pub const SHSTOCKICONID_SIID_MEDIADVDR: SHSTOCKICONID = 63; +pub const SHSTOCKICONID_SIID_MEDIADVDROM: SHSTOCKICONID = 64; +pub const SHSTOCKICONID_SIID_MEDIACDAUDIOPLUS: SHSTOCKICONID = 65; +pub const SHSTOCKICONID_SIID_MEDIACDRW: SHSTOCKICONID = 66; +pub const SHSTOCKICONID_SIID_MEDIACDR: SHSTOCKICONID = 67; +pub const SHSTOCKICONID_SIID_MEDIACDBURN: SHSTOCKICONID = 68; +pub const SHSTOCKICONID_SIID_MEDIABLANKCD: SHSTOCKICONID = 69; +pub const SHSTOCKICONID_SIID_MEDIACDROM: SHSTOCKICONID = 70; +pub const SHSTOCKICONID_SIID_AUDIOFILES: SHSTOCKICONID = 71; +pub const SHSTOCKICONID_SIID_IMAGEFILES: SHSTOCKICONID = 72; +pub const SHSTOCKICONID_SIID_VIDEOFILES: SHSTOCKICONID = 73; +pub const SHSTOCKICONID_SIID_MIXEDFILES: SHSTOCKICONID = 74; +pub const SHSTOCKICONID_SIID_FOLDERBACK: SHSTOCKICONID = 75; +pub const SHSTOCKICONID_SIID_FOLDERFRONT: SHSTOCKICONID = 76; +pub const SHSTOCKICONID_SIID_SHIELD: SHSTOCKICONID = 77; +pub const SHSTOCKICONID_SIID_WARNING: SHSTOCKICONID = 78; +pub const SHSTOCKICONID_SIID_INFO: SHSTOCKICONID = 79; +pub const SHSTOCKICONID_SIID_ERROR: SHSTOCKICONID = 80; +pub const SHSTOCKICONID_SIID_KEY: SHSTOCKICONID = 81; +pub const SHSTOCKICONID_SIID_SOFTWARE: SHSTOCKICONID = 82; +pub const SHSTOCKICONID_SIID_RENAME: SHSTOCKICONID = 83; +pub const SHSTOCKICONID_SIID_DELETE: SHSTOCKICONID = 84; +pub const SHSTOCKICONID_SIID_MEDIAAUDIODVD: SHSTOCKICONID = 85; +pub const SHSTOCKICONID_SIID_MEDIAMOVIEDVD: SHSTOCKICONID = 86; +pub const SHSTOCKICONID_SIID_MEDIAENHANCEDCD: SHSTOCKICONID = 87; +pub const SHSTOCKICONID_SIID_MEDIAENHANCEDDVD: SHSTOCKICONID = 88; +pub const SHSTOCKICONID_SIID_MEDIAHDDVD: SHSTOCKICONID = 89; +pub const SHSTOCKICONID_SIID_MEDIABLURAY: SHSTOCKICONID = 90; +pub const SHSTOCKICONID_SIID_MEDIAVCD: SHSTOCKICONID = 91; +pub const SHSTOCKICONID_SIID_MEDIADVDPLUSR: SHSTOCKICONID = 92; +pub const SHSTOCKICONID_SIID_MEDIADVDPLUSRW: SHSTOCKICONID = 93; +pub const SHSTOCKICONID_SIID_DESKTOPPC: SHSTOCKICONID = 94; +pub const SHSTOCKICONID_SIID_MOBILEPC: SHSTOCKICONID = 95; +pub const SHSTOCKICONID_SIID_USERS: SHSTOCKICONID = 96; +pub const SHSTOCKICONID_SIID_MEDIASMARTMEDIA: SHSTOCKICONID = 97; +pub const SHSTOCKICONID_SIID_MEDIACOMPACTFLASH: SHSTOCKICONID = 98; +pub const SHSTOCKICONID_SIID_DEVICECELLPHONE: SHSTOCKICONID = 99; +pub const SHSTOCKICONID_SIID_DEVICECAMERA: SHSTOCKICONID = 100; +pub const SHSTOCKICONID_SIID_DEVICEVIDEOCAMERA: SHSTOCKICONID = 101; +pub const SHSTOCKICONID_SIID_DEVICEAUDIOPLAYER: SHSTOCKICONID = 102; +pub const SHSTOCKICONID_SIID_NETWORKCONNECT: SHSTOCKICONID = 103; +pub const SHSTOCKICONID_SIID_INTERNET: SHSTOCKICONID = 104; +pub const SHSTOCKICONID_SIID_ZIPFILE: SHSTOCKICONID = 105; +pub const SHSTOCKICONID_SIID_SETTINGS: SHSTOCKICONID = 106; +pub const SHSTOCKICONID_SIID_DRIVEHDDVD: SHSTOCKICONID = 132; +pub const SHSTOCKICONID_SIID_DRIVEBD: SHSTOCKICONID = 133; +pub const SHSTOCKICONID_SIID_MEDIAHDDVDROM: SHSTOCKICONID = 134; +pub const SHSTOCKICONID_SIID_MEDIAHDDVDR: SHSTOCKICONID = 135; +pub const SHSTOCKICONID_SIID_MEDIAHDDVDRAM: SHSTOCKICONID = 136; +pub const SHSTOCKICONID_SIID_MEDIABDROM: SHSTOCKICONID = 137; +pub const SHSTOCKICONID_SIID_MEDIABDR: SHSTOCKICONID = 138; +pub const SHSTOCKICONID_SIID_MEDIABDRE: SHSTOCKICONID = 139; +pub const SHSTOCKICONID_SIID_CLUSTEREDDRIVE: SHSTOCKICONID = 140; +pub const SHSTOCKICONID_SIID_MAX_ICONS: SHSTOCKICONID = 181; +pub type SHSTOCKICONID = ::std::os::raw::c_int; +extern "C" { + pub fn SHGetStockIconInfo( + siid: SHSTOCKICONID, + uFlags: UINT, + psii: *mut SHSTOCKICONINFO, + ) -> HRESULT; +} +extern "C" { + pub fn SHGetDiskFreeSpaceExA( + pszDirectoryName: LPCSTR, + pulFreeBytesAvailableToCaller: *mut ULARGE_INTEGER, + pulTotalNumberOfBytes: *mut ULARGE_INTEGER, + pulTotalNumberOfFreeBytes: *mut ULARGE_INTEGER, + ) -> BOOL; +} +extern "C" { + pub fn SHGetDiskFreeSpaceExW( + pszDirectoryName: LPCWSTR, + pulFreeBytesAvailableToCaller: *mut ULARGE_INTEGER, + pulTotalNumberOfBytes: *mut ULARGE_INTEGER, + pulTotalNumberOfFreeBytes: *mut ULARGE_INTEGER, + ) -> BOOL; +} +extern "C" { + pub fn SHGetNewLinkInfoA( + pszLinkTo: LPCSTR, + pszDir: LPCSTR, + pszName: LPSTR, + pfMustCopy: *mut BOOL, + uFlags: UINT, + ) -> BOOL; +} +extern "C" { + pub fn SHGetNewLinkInfoW( + pszLinkTo: LPCWSTR, + pszDir: LPCWSTR, + pszName: LPWSTR, + pfMustCopy: *mut BOOL, + uFlags: UINT, + ) -> BOOL; +} +extern "C" { + pub fn SHInvokePrinterCommandA( + hwnd: HWND, + uAction: UINT, + lpBuf1: LPCSTR, + lpBuf2: LPCSTR, + fModal: BOOL, + ) -> BOOL; +} +extern "C" { + pub fn SHInvokePrinterCommandW( + hwnd: HWND, + uAction: UINT, + lpBuf1: LPCWSTR, + lpBuf2: LPCWSTR, + fModal: BOOL, + ) -> BOOL; +} +extern "C" { + pub fn SHLoadNonloadedIconOverlayIdentifiers() -> HRESULT; +} +extern "C" { + pub fn SHIsFileAvailableOffline(pwszPath: PCWSTR, pdwStatus: *mut DWORD) -> HRESULT; +} +extern "C" { + pub fn SHSetLocalizedName( + pszPath: PCWSTR, + pszResModule: PCWSTR, + idsRes: ::std::os::raw::c_int, + ) -> HRESULT; +} +extern "C" { + pub fn SHRemoveLocalizedName(pszPath: PCWSTR) -> HRESULT; +} +extern "C" { + pub fn SHGetLocalizedName( + pszPath: PCWSTR, + pszResModule: PWSTR, + cch: UINT, + pidsRes: *mut ::std::os::raw::c_int, + ) -> HRESULT; +} +extern "C" { + pub fn SHEnumerateUnreadMailAccountsA( + hKeyUser: HKEY, + dwIndex: DWORD, + pszMailAddress: LPSTR, + cchMailAddress: ::std::os::raw::c_int, + ) -> HRESULT; +} +extern "C" { + pub fn SHEnumerateUnreadMailAccountsW( + hKeyUser: HKEY, + dwIndex: DWORD, + pszMailAddress: LPWSTR, + cchMailAddress: ::std::os::raw::c_int, + ) -> HRESULT; +} +extern "C" { + pub fn SHGetUnreadMailCountA( + hKeyUser: HKEY, + pszMailAddress: LPCSTR, + pdwCount: *mut DWORD, + pFileTime: *mut FILETIME, + pszShellExecuteCommand: LPSTR, + cchShellExecuteCommand: ::std::os::raw::c_int, + ) -> HRESULT; +} +extern "C" { + pub fn SHGetUnreadMailCountW( + hKeyUser: HKEY, + pszMailAddress: LPCWSTR, + pdwCount: *mut DWORD, + pFileTime: *mut FILETIME, + pszShellExecuteCommand: LPWSTR, + cchShellExecuteCommand: ::std::os::raw::c_int, + ) -> HRESULT; +} +extern "C" { + pub fn SHSetUnreadMailCountA( + pszMailAddress: LPCSTR, + dwCount: DWORD, + pszShellExecuteCommand: LPCSTR, + ) -> HRESULT; +} +extern "C" { + pub fn SHSetUnreadMailCountW( + pszMailAddress: LPCWSTR, + dwCount: DWORD, + pszShellExecuteCommand: LPCWSTR, + ) -> HRESULT; +} +extern "C" { + pub fn SHTestTokenMembership(hToken: HANDLE, ulRID: ULONG) -> BOOL; +} +extern "C" { + pub fn SHGetImageList( + iImageList: ::std::os::raw::c_int, + riid: *const IID, + ppvObj: *mut *mut ::std::os::raw::c_void, + ) -> HRESULT; +} +extern "C" { + pub fn SHGetDriveMedia(pszDrive: PCWSTR, pdwMediaContent: *mut DWORD) -> HRESULT; +} +pub type u_short = ::std::os::raw::c_ushort; +pub type SOCKET = UINT_PTR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct servent { + pub s_name: *mut ::std::os::raw::c_char, + pub s_aliases: *mut *mut ::std::os::raw::c_char, + pub s_proto: *mut ::std::os::raw::c_char, + pub s_port: ::std::os::raw::c_short, +} +#[test] +fn bindgen_test_layout_servent() { + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(servent)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(servent)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).s_name as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(servent), + "::", + stringify!(s_name) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).s_aliases as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(servent), + "::", + stringify!(s_aliases) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).s_proto as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(servent), + "::", + stringify!(s_proto) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).s_port as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(servent), + "::", + stringify!(s_port) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct in_addr { + pub S_un: in_addr__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union in_addr__bindgen_ty_1 { + pub S_un_b: in_addr__bindgen_ty_1__bindgen_ty_1, + pub S_un_w: in_addr__bindgen_ty_1__bindgen_ty_2, + pub S_addr: ULONG, + _bindgen_union_align: u32, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct in_addr__bindgen_ty_1__bindgen_ty_1 { + pub s_b1: UCHAR, + pub s_b2: UCHAR, + pub s_b3: UCHAR, + pub s_b4: UCHAR, +} +#[test] +fn bindgen_test_layout_in_addr__bindgen_ty_1__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(in_addr__bindgen_ty_1__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!( + "Alignment of ", + stringify!(in_addr__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).s_b1 as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(in_addr__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(s_b1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).s_b2 as *const _ as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(in_addr__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(s_b2) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).s_b3 as *const _ as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(in_addr__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(s_b3) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).s_b4 as *const _ as usize + }, + 3usize, + concat!( + "Offset of field: ", + stringify!(in_addr__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(s_b4) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct in_addr__bindgen_ty_1__bindgen_ty_2 { + pub s_w1: USHORT, + pub s_w2: USHORT, +} +#[test] +fn bindgen_test_layout_in_addr__bindgen_ty_1__bindgen_ty_2() { + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(in_addr__bindgen_ty_1__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 2usize, + concat!( + "Alignment of ", + stringify!(in_addr__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).s_w1 as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(in_addr__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(s_w1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).s_w2 as *const _ as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(in_addr__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(s_w2) + ) + ); +} +#[test] +fn bindgen_test_layout_in_addr__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(in_addr__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(in_addr__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).S_un_b as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(in_addr__bindgen_ty_1), + "::", + stringify!(S_un_b) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).S_un_w as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(in_addr__bindgen_ty_1), + "::", + stringify!(S_un_w) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).S_addr as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(in_addr__bindgen_ty_1), + "::", + stringify!(S_addr) + ) + ); +} +#[test] +fn bindgen_test_layout_in_addr() { + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(in_addr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(in_addr)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).S_un as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(in_addr), + "::", + stringify!(S_un) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sockaddr_in { + pub sin_family: ::std::os::raw::c_short, + pub sin_port: u_short, + pub sin_addr: in_addr, + pub sin_zero: [::std::os::raw::c_char; 8usize], +} +#[test] +fn bindgen_test_layout_sockaddr_in() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(sockaddr_in)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(sockaddr_in)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).sin_family as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in), + "::", + stringify!(sin_family) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).sin_port as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in), + "::", + stringify!(sin_port) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).sin_addr as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in), + "::", + stringify!(sin_addr) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).sin_zero as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in), + "::", + stringify!(sin_zero) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sockaddr { + pub sa_family: u_short, + pub sa_data: [::std::os::raw::c_char; 14usize], +} +#[test] +fn bindgen_test_layout_sockaddr() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(sockaddr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 2usize, + concat!("Alignment of ", stringify!(sockaddr)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).sa_family as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(sockaddr), + "::", + stringify!(sa_family) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).sa_data as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(sockaddr), + "::", + stringify!(sa_data) + ) + ); +} +pub type SOCKADDR = sockaddr; +pub type SOCKADDR_IN = sockaddr_in; +pub type SERVENT = servent; +pub type ALG_ID = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCHANNEL_ALG { + pub dwUse: DWORD, + pub Algid: ALG_ID, + pub cBits: DWORD, + pub dwFlags: DWORD, + pub dwReserved: DWORD, +} +#[test] +fn bindgen_test_layout__SCHANNEL_ALG() { + assert_eq!( + ::std::mem::size_of::<_SCHANNEL_ALG>(), + 20usize, + concat!("Size of: ", stringify!(_SCHANNEL_ALG)) + ); + assert_eq!( + ::std::mem::align_of::<_SCHANNEL_ALG>(), + 4usize, + concat!("Alignment of ", stringify!(_SCHANNEL_ALG)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCHANNEL_ALG>())).dwUse as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCHANNEL_ALG), + "::", + stringify!(dwUse) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCHANNEL_ALG>())).Algid as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCHANNEL_ALG), + "::", + stringify!(Algid) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCHANNEL_ALG>())).cBits as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCHANNEL_ALG), + "::", + stringify!(cBits) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCHANNEL_ALG>())).dwFlags as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SCHANNEL_ALG), + "::", + stringify!(dwFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCHANNEL_ALG>())).dwReserved as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SCHANNEL_ALG), + "::", + stringify!(dwReserved) + ) + ); +} +pub type SCHANNEL_ALG = _SCHANNEL_ALG; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SSL_ECCKEY_BLOB { + pub dwCurveType: ULONG, + pub cbKey: ULONG, +} +#[test] +fn bindgen_test_layout__SSL_ECCKEY_BLOB() { + assert_eq!( + ::std::mem::size_of::<_SSL_ECCKEY_BLOB>(), + 8usize, + concat!("Size of: ", stringify!(_SSL_ECCKEY_BLOB)) + ); + assert_eq!( + ::std::mem::align_of::<_SSL_ECCKEY_BLOB>(), + 4usize, + concat!("Alignment of ", stringify!(_SSL_ECCKEY_BLOB)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SSL_ECCKEY_BLOB>())).dwCurveType as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SSL_ECCKEY_BLOB), + "::", + stringify!(dwCurveType) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SSL_ECCKEY_BLOB>())).cbKey as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SSL_ECCKEY_BLOB), + "::", + stringify!(cbKey) + ) + ); +} +pub type SSL_ECCKEY_BLOB = _SSL_ECCKEY_BLOB; +pub type SECURITY_STATUS = LONG; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _HTTPSPolicyCallbackData { + pub __bindgen_anon_1: _HTTPSPolicyCallbackData__bindgen_ty_1, + pub dwAuthType: DWORD, + pub fdwChecks: DWORD, + pub pwszServerName: *mut WCHAR, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _HTTPSPolicyCallbackData__bindgen_ty_1 { + pub cbStruct: DWORD, + pub cbSize: DWORD, + _bindgen_union_align: u32, +} +#[test] +fn bindgen_test_layout__HTTPSPolicyCallbackData__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_HTTPSPolicyCallbackData__bindgen_ty_1>(), + 4usize, + concat!( + "Size of: ", + stringify!(_HTTPSPolicyCallbackData__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_HTTPSPolicyCallbackData__bindgen_ty_1>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_HTTPSPolicyCallbackData__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_HTTPSPolicyCallbackData__bindgen_ty_1>())).cbStruct as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_HTTPSPolicyCallbackData__bindgen_ty_1), + "::", + stringify!(cbStruct) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_HTTPSPolicyCallbackData__bindgen_ty_1>())).cbSize as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_HTTPSPolicyCallbackData__bindgen_ty_1), + "::", + stringify!(cbSize) + ) + ); +} +#[test] +fn bindgen_test_layout__HTTPSPolicyCallbackData() { + assert_eq!( + ::std::mem::size_of::<_HTTPSPolicyCallbackData>(), + 24usize, + concat!("Size of: ", stringify!(_HTTPSPolicyCallbackData)) + ); + assert_eq!( + ::std::mem::align_of::<_HTTPSPolicyCallbackData>(), + 8usize, + concat!("Alignment of ", stringify!(_HTTPSPolicyCallbackData)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_HTTPSPolicyCallbackData>())).dwAuthType as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_HTTPSPolicyCallbackData), + "::", + stringify!(dwAuthType) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_HTTPSPolicyCallbackData>())).fdwChecks as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_HTTPSPolicyCallbackData), + "::", + stringify!(fdwChecks) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_HTTPSPolicyCallbackData>())).pwszServerName as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_HTTPSPolicyCallbackData), + "::", + stringify!(pwszServerName) + ) + ); +} +pub type SSL_EXTRA_CERT_CHAIN_POLICY_PARA = _HTTPSPolicyCallbackData; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SSL_F12_EXTRA_CERT_CHAIN_POLICY_STATUS { + pub cbSize: DWORD, + pub dwErrorLevel: DWORD, + pub dwErrorCategory: DWORD, + pub dwReserved: DWORD, + pub wszErrorText: [WCHAR; 256usize], +} +#[test] +fn bindgen_test_layout__SSL_F12_EXTRA_CERT_CHAIN_POLICY_STATUS() { + assert_eq!( + ::std::mem::size_of::<_SSL_F12_EXTRA_CERT_CHAIN_POLICY_STATUS>(), + 528usize, + concat!( + "Size of: ", + stringify!(_SSL_F12_EXTRA_CERT_CHAIN_POLICY_STATUS) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SSL_F12_EXTRA_CERT_CHAIN_POLICY_STATUS>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_SSL_F12_EXTRA_CERT_CHAIN_POLICY_STATUS) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SSL_F12_EXTRA_CERT_CHAIN_POLICY_STATUS>())).cbSize as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SSL_F12_EXTRA_CERT_CHAIN_POLICY_STATUS), + "::", + stringify!(cbSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SSL_F12_EXTRA_CERT_CHAIN_POLICY_STATUS>())).dwErrorLevel as *const _ + as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SSL_F12_EXTRA_CERT_CHAIN_POLICY_STATUS), + "::", + stringify!(dwErrorLevel) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SSL_F12_EXTRA_CERT_CHAIN_POLICY_STATUS>())).dwErrorCategory + as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SSL_F12_EXTRA_CERT_CHAIN_POLICY_STATUS), + "::", + stringify!(dwErrorCategory) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SSL_F12_EXTRA_CERT_CHAIN_POLICY_STATUS>())).dwReserved as *const _ + as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SSL_F12_EXTRA_CERT_CHAIN_POLICY_STATUS), + "::", + stringify!(dwReserved) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SSL_F12_EXTRA_CERT_CHAIN_POLICY_STATUS>())).wszErrorText as *const _ + as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SSL_F12_EXTRA_CERT_CHAIN_POLICY_STATUS), + "::", + stringify!(wszErrorText) + ) + ); +} +pub type SSL_F12_EXTRA_CERT_CHAIN_POLICY_STATUS = _SSL_F12_EXTRA_CERT_CHAIN_POLICY_STATUS; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SSL_HPKP_HEADER_EXTRA_CERT_CHAIN_POLICY_PARA { + pub cbSize: DWORD, + pub dwReserved: DWORD, + pub pwszServerName: LPWSTR, + pub rgpszHpkpValue: [LPSTR; 2usize], +} +#[test] +fn bindgen_test_layout__SSL_HPKP_HEADER_EXTRA_CERT_CHAIN_POLICY_PARA() { + assert_eq!( + ::std::mem::size_of::<_SSL_HPKP_HEADER_EXTRA_CERT_CHAIN_POLICY_PARA>(), + 32usize, + concat!( + "Size of: ", + stringify!(_SSL_HPKP_HEADER_EXTRA_CERT_CHAIN_POLICY_PARA) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SSL_HPKP_HEADER_EXTRA_CERT_CHAIN_POLICY_PARA>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_SSL_HPKP_HEADER_EXTRA_CERT_CHAIN_POLICY_PARA) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SSL_HPKP_HEADER_EXTRA_CERT_CHAIN_POLICY_PARA>())).cbSize as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SSL_HPKP_HEADER_EXTRA_CERT_CHAIN_POLICY_PARA), + "::", + stringify!(cbSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SSL_HPKP_HEADER_EXTRA_CERT_CHAIN_POLICY_PARA>())).dwReserved + as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SSL_HPKP_HEADER_EXTRA_CERT_CHAIN_POLICY_PARA), + "::", + stringify!(dwReserved) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SSL_HPKP_HEADER_EXTRA_CERT_CHAIN_POLICY_PARA>())).pwszServerName + as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SSL_HPKP_HEADER_EXTRA_CERT_CHAIN_POLICY_PARA), + "::", + stringify!(pwszServerName) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SSL_HPKP_HEADER_EXTRA_CERT_CHAIN_POLICY_PARA>())).rgpszHpkpValue + as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SSL_HPKP_HEADER_EXTRA_CERT_CHAIN_POLICY_PARA), + "::", + stringify!(rgpszHpkpValue) + ) + ); +} +pub type SSL_HPKP_HEADER_EXTRA_CERT_CHAIN_POLICY_PARA = + _SSL_HPKP_HEADER_EXTRA_CERT_CHAIN_POLICY_PARA; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_PARA { + pub cbSize: DWORD, + pub dwReserved: DWORD, + pub pwszServerName: PCWSTR, +} +#[test] +fn bindgen_test_layout__SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_PARA() { + assert_eq!( + ::std::mem::size_of::<_SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_PARA>(), + 16usize, + concat!( + "Size of: ", + stringify!(_SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_PARA) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_PARA>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_PARA) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_PARA>())).cbSize as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_PARA), + "::", + stringify!(cbSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_PARA>())).dwReserved as *const _ + as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_PARA), + "::", + stringify!(dwReserved) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_PARA>())).pwszServerName + as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_PARA), + "::", + stringify!(pwszServerName) + ) + ); +} +pub type SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_PARA = _SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_PARA; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_STATUS { + pub cbSize: DWORD, + pub lError: LONG, + pub wszErrorText: [WCHAR; 512usize], +} +#[test] +fn bindgen_test_layout__SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_STATUS() { + assert_eq!( + ::std::mem::size_of::<_SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_STATUS>(), + 1032usize, + concat!( + "Size of: ", + stringify!(_SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_STATUS) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_STATUS>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_STATUS) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_STATUS>())).cbSize as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_STATUS), + "::", + stringify!(cbSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_STATUS>())).lError as *const _ + as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_STATUS), + "::", + stringify!(lError) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_STATUS>())).wszErrorText + as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_STATUS), + "::", + stringify!(wszErrorText) + ) + ); +} +pub type SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_STATUS = _SSL_KEY_PIN_EXTRA_CERT_CHAIN_POLICY_STATUS; +pub type byte = ::std::os::raw::c_uchar; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _bindgen_ty_1 { + pub pad: [*mut ::std::os::raw::c_void; 2usize], + pub userContext: *mut ::std::os::raw::c_void, +} +#[test] +fn bindgen_test_layout__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_bindgen_ty_1>(), + 24usize, + concat!("Size of: ", stringify!(_bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<_bindgen_ty_1>(), + 8usize, + concat!("Alignment of ", stringify!(_bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_bindgen_ty_1>())).pad as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_bindgen_ty_1), + "::", + stringify!(pad) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_bindgen_ty_1>())).userContext as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_bindgen_ty_1), + "::", + stringify!(userContext) + ) + ); +} +pub type NDR_SCONTEXT = *mut _bindgen_ty_1; +pub type NDR_RUNDOWN = + ::std::option::Option; +pub type NDR_NOTIFY_ROUTINE = ::std::option::Option; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCONTEXT_QUEUE { + pub NumberOfObjects: ::std::os::raw::c_ulong, + pub ArrayOfObjects: *mut NDR_SCONTEXT, +} +#[test] +fn bindgen_test_layout__SCONTEXT_QUEUE() { + assert_eq!( + ::std::mem::size_of::<_SCONTEXT_QUEUE>(), + 16usize, + concat!("Size of: ", stringify!(_SCONTEXT_QUEUE)) + ); + assert_eq!( + ::std::mem::align_of::<_SCONTEXT_QUEUE>(), + 8usize, + concat!("Alignment of ", stringify!(_SCONTEXT_QUEUE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCONTEXT_QUEUE>())).NumberOfObjects as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCONTEXT_QUEUE), + "::", + stringify!(NumberOfObjects) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCONTEXT_QUEUE>())).ArrayOfObjects as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCONTEXT_QUEUE), + "::", + stringify!(ArrayOfObjects) + ) + ); +} +pub type SCONTEXT_QUEUE = _SCONTEXT_QUEUE; +pub type error_status_t = ::std::os::raw::c_ulong; +pub type EXPR_EVAL = ::std::option::Option; +pub type PFORMAT_STRING = *const ::std::os::raw::c_uchar; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ARRAY_INFO { + pub Dimension: ::std::os::raw::c_long, + pub BufferConformanceMark: *mut ::std::os::raw::c_ulong, + pub BufferVarianceMark: *mut ::std::os::raw::c_ulong, + pub MaxCountArray: *mut ::std::os::raw::c_ulong, + pub OffsetArray: *mut ::std::os::raw::c_ulong, + pub ActualCountArray: *mut ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout_ARRAY_INFO() { + assert_eq!( + ::std::mem::size_of::(), + 48usize, + concat!("Size of: ", stringify!(ARRAY_INFO)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(ARRAY_INFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).Dimension as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ARRAY_INFO), + "::", + stringify!(Dimension) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).BufferConformanceMark as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(ARRAY_INFO), + "::", + stringify!(BufferConformanceMark) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).BufferVarianceMark as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(ARRAY_INFO), + "::", + stringify!(BufferVarianceMark) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).MaxCountArray as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(ARRAY_INFO), + "::", + stringify!(MaxCountArray) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).OffsetArray as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(ARRAY_INFO), + "::", + stringify!(OffsetArray) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).ActualCountArray as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(ARRAY_INFO), + "::", + stringify!(ActualCountArray) + ) + ); +} +pub type PARRAY_INFO = *mut ARRAY_INFO; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _NDR_ASYNC_MESSAGE { + _unused: [u8; 0], +} +pub type PNDR_ASYNC_MESSAGE = *mut _NDR_ASYNC_MESSAGE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _NDR_CORRELATION_INFO { + _unused: [u8; 0], +} +pub type PNDR_CORRELATION_INFO = *mut _NDR_CORRELATION_INFO; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct NDR_ALLOC_ALL_NODES_CONTEXT { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct NDR_POINTER_QUEUE_STATE { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _NDR_PROC_CONTEXT { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _MIDL_STUB_MESSAGE { + pub RpcMsg: PRPC_MESSAGE, + pub Buffer: *mut ::std::os::raw::c_uchar, + pub BufferStart: *mut ::std::os::raw::c_uchar, + pub BufferEnd: *mut ::std::os::raw::c_uchar, + pub BufferMark: *mut ::std::os::raw::c_uchar, + pub BufferLength: ::std::os::raw::c_ulong, + pub MemorySize: ::std::os::raw::c_ulong, + pub Memory: *mut ::std::os::raw::c_uchar, + pub IsClient: ::std::os::raw::c_uchar, + pub Pad: ::std::os::raw::c_uchar, + pub uFlags2: ::std::os::raw::c_ushort, + pub ReuseBuffer: ::std::os::raw::c_int, + pub pAllocAllNodesContext: *mut NDR_ALLOC_ALL_NODES_CONTEXT, + pub pPointerQueueState: *mut NDR_POINTER_QUEUE_STATE, + pub IgnoreEmbeddedPointers: ::std::os::raw::c_int, + pub PointerBufferMark: *mut ::std::os::raw::c_uchar, + pub CorrDespIncrement: ::std::os::raw::c_uchar, + pub uFlags: ::std::os::raw::c_uchar, + pub UniquePtrCount: ::std::os::raw::c_ushort, + pub MaxCount: ULONG_PTR, + pub Offset: ::std::os::raw::c_ulong, + pub ActualCount: ::std::os::raw::c_ulong, + pub pfnAllocate: + ::std::option::Option *mut ::std::os::raw::c_void>, + pub pfnFree: ::std::option::Option, + pub StackTop: *mut ::std::os::raw::c_uchar, + pub pPresentedType: *mut ::std::os::raw::c_uchar, + pub pTransmitType: *mut ::std::os::raw::c_uchar, + pub SavedHandle: handle_t, + pub StubDesc: *const _MIDL_STUB_DESC, + pub FullPtrXlatTables: *mut _FULL_PTR_XLAT_TABLES, + pub FullPtrRefId: ::std::os::raw::c_ulong, + pub PointerLength: ::std::os::raw::c_ulong, + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize], u16>, + pub dwDestContext: ::std::os::raw::c_ulong, + pub pvDestContext: *mut ::std::os::raw::c_void, + pub SavedContextHandles: *mut NDR_SCONTEXT, + pub ParamNumber: ::std::os::raw::c_long, + pub pRpcChannelBuffer: *mut IRpcChannelBuffer, + pub pArrayInfo: PARRAY_INFO, + pub SizePtrCountArray: *mut ::std::os::raw::c_ulong, + pub SizePtrOffsetArray: *mut ::std::os::raw::c_ulong, + pub SizePtrLengthArray: *mut ::std::os::raw::c_ulong, + pub pArgQueue: *mut ::std::os::raw::c_void, + pub dwStubPhase: ::std::os::raw::c_ulong, + pub LowStackMark: *mut ::std::os::raw::c_void, + pub pAsyncMsg: PNDR_ASYNC_MESSAGE, + pub pCorrInfo: PNDR_CORRELATION_INFO, + pub pCorrMemory: *mut ::std::os::raw::c_uchar, + pub pMemoryList: *mut ::std::os::raw::c_void, + pub pCSInfo: INT_PTR, + pub ConformanceMark: *mut ::std::os::raw::c_uchar, + pub VarianceMark: *mut ::std::os::raw::c_uchar, + pub Unused: INT_PTR, + pub pContext: *mut _NDR_PROC_CONTEXT, + pub ContextHandleHash: *mut ::std::os::raw::c_void, + pub pUserMarshalList: *mut ::std::os::raw::c_void, + pub Reserved51_3: INT_PTR, + pub Reserved51_4: INT_PTR, + pub Reserved51_5: INT_PTR, +} +#[test] +fn bindgen_test_layout__MIDL_STUB_MESSAGE() { + assert_eq!( + ::std::mem::size_of::<_MIDL_STUB_MESSAGE>(), + 400usize, + concat!("Size of: ", stringify!(_MIDL_STUB_MESSAGE)) + ); + assert_eq!( + ::std::mem::align_of::<_MIDL_STUB_MESSAGE>(), + 8usize, + concat!("Alignment of ", stringify!(_MIDL_STUB_MESSAGE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).RpcMsg as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(RpcMsg) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).Buffer as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(Buffer) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).BufferStart as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(BufferStart) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).BufferEnd as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(BufferEnd) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).BufferMark as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(BufferMark) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).BufferLength as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(BufferLength) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).MemorySize as *const _ as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(MemorySize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).Memory as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(Memory) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).IsClient as *const _ as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(IsClient) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).Pad as *const _ as usize }, + 57usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(Pad) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).uFlags2 as *const _ as usize }, + 58usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(uFlags2) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).ReuseBuffer as *const _ as usize }, + 60usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(ReuseBuffer) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).pAllocAllNodesContext as *const _ as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(pAllocAllNodesContext) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).pPointerQueueState as *const _ as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(pPointerQueueState) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).IgnoreEmbeddedPointers as *const _ as usize + }, + 80usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(IgnoreEmbeddedPointers) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).PointerBufferMark as *const _ as usize + }, + 88usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(PointerBufferMark) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).CorrDespIncrement as *const _ as usize + }, + 96usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(CorrDespIncrement) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).uFlags as *const _ as usize }, + 97usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(uFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).UniquePtrCount as *const _ as usize }, + 98usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(UniquePtrCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).MaxCount as *const _ as usize }, + 104usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(MaxCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).Offset as *const _ as usize }, + 112usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(Offset) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).ActualCount as *const _ as usize }, + 116usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(ActualCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).pfnAllocate as *const _ as usize }, + 120usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(pfnAllocate) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).pfnFree as *const _ as usize }, + 128usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(pfnFree) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).StackTop as *const _ as usize }, + 136usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(StackTop) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).pPresentedType as *const _ as usize }, + 144usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(pPresentedType) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).pTransmitType as *const _ as usize }, + 152usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(pTransmitType) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).SavedHandle as *const _ as usize }, + 160usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(SavedHandle) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).StubDesc as *const _ as usize }, + 168usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(StubDesc) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).FullPtrXlatTables as *const _ as usize + }, + 176usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(FullPtrXlatTables) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).FullPtrRefId as *const _ as usize }, + 184usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(FullPtrRefId) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).PointerLength as *const _ as usize }, + 188usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(PointerLength) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).dwDestContext as *const _ as usize }, + 196usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(dwDestContext) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).pvDestContext as *const _ as usize }, + 200usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(pvDestContext) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).SavedContextHandles as *const _ as usize + }, + 208usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(SavedContextHandles) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).ParamNumber as *const _ as usize }, + 216usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(ParamNumber) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).pRpcChannelBuffer as *const _ as usize + }, + 224usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(pRpcChannelBuffer) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).pArrayInfo as *const _ as usize }, + 232usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(pArrayInfo) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).SizePtrCountArray as *const _ as usize + }, + 240usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(SizePtrCountArray) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).SizePtrOffsetArray as *const _ as usize + }, + 248usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(SizePtrOffsetArray) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).SizePtrLengthArray as *const _ as usize + }, + 256usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(SizePtrLengthArray) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).pArgQueue as *const _ as usize }, + 264usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(pArgQueue) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).dwStubPhase as *const _ as usize }, + 272usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(dwStubPhase) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).LowStackMark as *const _ as usize }, + 280usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(LowStackMark) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).pAsyncMsg as *const _ as usize }, + 288usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(pAsyncMsg) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).pCorrInfo as *const _ as usize }, + 296usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(pCorrInfo) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).pCorrMemory as *const _ as usize }, + 304usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(pCorrMemory) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).pMemoryList as *const _ as usize }, + 312usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(pMemoryList) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).pCSInfo as *const _ as usize }, + 320usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(pCSInfo) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).ConformanceMark as *const _ as usize }, + 328usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(ConformanceMark) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).VarianceMark as *const _ as usize }, + 336usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(VarianceMark) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).Unused as *const _ as usize }, + 344usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(Unused) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).pContext as *const _ as usize }, + 352usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(pContext) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).ContextHandleHash as *const _ as usize + }, + 360usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(ContextHandleHash) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).pUserMarshalList as *const _ as usize }, + 368usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(pUserMarshalList) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).Reserved51_3 as *const _ as usize }, + 376usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(Reserved51_3) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).Reserved51_4 as *const _ as usize }, + 384usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(Reserved51_4) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_MESSAGE>())).Reserved51_5 as *const _ as usize }, + 392usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_MESSAGE), + "::", + stringify!(Reserved51_5) + ) + ); +} +impl _MIDL_STUB_MESSAGE { + #[inline] + pub fn fInDontFree(&self) -> ::std::os::raw::c_int { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } + } + #[inline] + pub fn set_fInDontFree(&mut self, val: ::std::os::raw::c_int) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn fDontCallFreeInst(&self) -> ::std::os::raw::c_int { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u32) } + } + #[inline] + pub fn set_fDontCallFreeInst(&mut self, val: ::std::os::raw::c_int) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn fUnused1(&self) -> ::std::os::raw::c_int { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u32) } + } + #[inline] + pub fn set_fUnused1(&mut self, val: ::std::os::raw::c_int) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn fHasReturn(&self) -> ::std::os::raw::c_int { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u32) } + } + #[inline] + pub fn set_fHasReturn(&mut self, val: ::std::os::raw::c_int) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn fHasExtensions(&self) -> ::std::os::raw::c_int { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u32) } + } + #[inline] + pub fn set_fHasExtensions(&mut self, val: ::std::os::raw::c_int) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub fn fHasNewCorrDesc(&self) -> ::std::os::raw::c_int { + unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u32) } + } + #[inline] + pub fn set_fHasNewCorrDesc(&mut self, val: ::std::os::raw::c_int) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub fn fIsIn(&self) -> ::std::os::raw::c_int { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u32) } + } + #[inline] + pub fn set_fIsIn(&mut self, val: ::std::os::raw::c_int) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 1u8, val as u64) + } + } + #[inline] + pub fn fIsOut(&self) -> ::std::os::raw::c_int { + unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u32) } + } + #[inline] + pub fn set_fIsOut(&mut self, val: ::std::os::raw::c_int) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(7usize, 1u8, val as u64) + } + } + #[inline] + pub fn fIsOicf(&self) -> ::std::os::raw::c_int { + unsafe { ::std::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u32) } + } + #[inline] + pub fn set_fIsOicf(&mut self, val: ::std::os::raw::c_int) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(8usize, 1u8, val as u64) + } + } + #[inline] + pub fn fBufferValid(&self) -> ::std::os::raw::c_int { + unsafe { ::std::mem::transmute(self._bitfield_1.get(9usize, 1u8) as u32) } + } + #[inline] + pub fn set_fBufferValid(&mut self, val: ::std::os::raw::c_int) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(9usize, 1u8, val as u64) + } + } + #[inline] + pub fn fHasMemoryValidateCallback(&self) -> ::std::os::raw::c_int { + unsafe { ::std::mem::transmute(self._bitfield_1.get(10usize, 1u8) as u32) } + } + #[inline] + pub fn set_fHasMemoryValidateCallback(&mut self, val: ::std::os::raw::c_int) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(10usize, 1u8, val as u64) + } + } + #[inline] + pub fn fInFree(&self) -> ::std::os::raw::c_int { + unsafe { ::std::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u32) } + } + #[inline] + pub fn set_fInFree(&mut self, val: ::std::os::raw::c_int) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(11usize, 1u8, val as u64) + } + } + #[inline] + pub fn fNeedMCCP(&self) -> ::std::os::raw::c_int { + unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u32) } + } + #[inline] + pub fn set_fNeedMCCP(&mut self, val: ::std::os::raw::c_int) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(12usize, 1u8, val as u64) + } + } + #[inline] + pub fn fUnused2(&self) -> ::std::os::raw::c_int { + unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 3u8) as u32) } + } + #[inline] + pub fn set_fUnused2(&mut self, val: ::std::os::raw::c_int) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(13usize, 3u8, val as u64) + } + } + #[inline] + pub fn fUnused3(&self) -> ::std::os::raw::c_int { + unsafe { ::std::mem::transmute(self._bitfield_1.get(16usize, 16u8) as u32) } + } + #[inline] + pub fn set_fUnused3(&mut self, val: ::std::os::raw::c_int) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(16usize, 16u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + fInDontFree: ::std::os::raw::c_int, + fDontCallFreeInst: ::std::os::raw::c_int, + fUnused1: ::std::os::raw::c_int, + fHasReturn: ::std::os::raw::c_int, + fHasExtensions: ::std::os::raw::c_int, + fHasNewCorrDesc: ::std::os::raw::c_int, + fIsIn: ::std::os::raw::c_int, + fIsOut: ::std::os::raw::c_int, + fIsOicf: ::std::os::raw::c_int, + fBufferValid: ::std::os::raw::c_int, + fHasMemoryValidateCallback: ::std::os::raw::c_int, + fInFree: ::std::os::raw::c_int, + fNeedMCCP: ::std::os::raw::c_int, + fUnused2: ::std::os::raw::c_int, + fUnused3: ::std::os::raw::c_int, + ) -> __BindgenBitfieldUnit<[u8; 4usize], u16> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize], u16> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let fInDontFree: u32 = unsafe { ::std::mem::transmute(fInDontFree) }; + fInDontFree as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let fDontCallFreeInst: u32 = unsafe { ::std::mem::transmute(fDontCallFreeInst) }; + fDontCallFreeInst as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let fUnused1: u32 = unsafe { ::std::mem::transmute(fUnused1) }; + fUnused1 as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let fHasReturn: u32 = unsafe { ::std::mem::transmute(fHasReturn) }; + fHasReturn as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let fHasExtensions: u32 = unsafe { ::std::mem::transmute(fHasExtensions) }; + fHasExtensions as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let fHasNewCorrDesc: u32 = unsafe { ::std::mem::transmute(fHasNewCorrDesc) }; + fHasNewCorrDesc as u64 + }); + __bindgen_bitfield_unit.set(6usize, 1u8, { + let fIsIn: u32 = unsafe { ::std::mem::transmute(fIsIn) }; + fIsIn as u64 + }); + __bindgen_bitfield_unit.set(7usize, 1u8, { + let fIsOut: u32 = unsafe { ::std::mem::transmute(fIsOut) }; + fIsOut as u64 + }); + __bindgen_bitfield_unit.set(8usize, 1u8, { + let fIsOicf: u32 = unsafe { ::std::mem::transmute(fIsOicf) }; + fIsOicf as u64 + }); + __bindgen_bitfield_unit.set(9usize, 1u8, { + let fBufferValid: u32 = unsafe { ::std::mem::transmute(fBufferValid) }; + fBufferValid as u64 + }); + __bindgen_bitfield_unit.set(10usize, 1u8, { + let fHasMemoryValidateCallback: u32 = + unsafe { ::std::mem::transmute(fHasMemoryValidateCallback) }; + fHasMemoryValidateCallback as u64 + }); + __bindgen_bitfield_unit.set(11usize, 1u8, { + let fInFree: u32 = unsafe { ::std::mem::transmute(fInFree) }; + fInFree as u64 + }); + __bindgen_bitfield_unit.set(12usize, 1u8, { + let fNeedMCCP: u32 = unsafe { ::std::mem::transmute(fNeedMCCP) }; + fNeedMCCP as u64 + }); + __bindgen_bitfield_unit.set(13usize, 3u8, { + let fUnused2: u32 = unsafe { ::std::mem::transmute(fUnused2) }; + fUnused2 as u64 + }); + __bindgen_bitfield_unit.set(16usize, 16u8, { + let fUnused3: u32 = unsafe { ::std::mem::transmute(fUnused3) }; + fUnused3 as u64 + }); + __bindgen_bitfield_unit + } +} +pub type PMIDL_STUB_MESSAGE = *mut _MIDL_STUB_MESSAGE; +pub type GENERIC_BINDING_ROUTINE = ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> *mut ::std::os::raw::c_void, +>; +pub type GENERIC_UNBIND_ROUTINE = ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void, arg2: *mut ::std::os::raw::c_uchar), +>; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _GENERIC_BINDING_ROUTINE_PAIR { + pub pfnBind: GENERIC_BINDING_ROUTINE, + pub pfnUnbind: GENERIC_UNBIND_ROUTINE, +} +#[test] +fn bindgen_test_layout__GENERIC_BINDING_ROUTINE_PAIR() { + assert_eq!( + ::std::mem::size_of::<_GENERIC_BINDING_ROUTINE_PAIR>(), + 16usize, + concat!("Size of: ", stringify!(_GENERIC_BINDING_ROUTINE_PAIR)) + ); + assert_eq!( + ::std::mem::align_of::<_GENERIC_BINDING_ROUTINE_PAIR>(), + 8usize, + concat!("Alignment of ", stringify!(_GENERIC_BINDING_ROUTINE_PAIR)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_GENERIC_BINDING_ROUTINE_PAIR>())).pfnBind as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_GENERIC_BINDING_ROUTINE_PAIR), + "::", + stringify!(pfnBind) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_GENERIC_BINDING_ROUTINE_PAIR>())).pfnUnbind as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_GENERIC_BINDING_ROUTINE_PAIR), + "::", + stringify!(pfnUnbind) + ) + ); +} +pub type GENERIC_BINDING_ROUTINE_PAIR = _GENERIC_BINDING_ROUTINE_PAIR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __GENERIC_BINDING_INFO { + pub pObj: *mut ::std::os::raw::c_void, + pub Size: ::std::os::raw::c_uint, + pub pfnBind: GENERIC_BINDING_ROUTINE, + pub pfnUnbind: GENERIC_UNBIND_ROUTINE, +} +#[test] +fn bindgen_test_layout___GENERIC_BINDING_INFO() { + assert_eq!( + ::std::mem::size_of::<__GENERIC_BINDING_INFO>(), + 32usize, + concat!("Size of: ", stringify!(__GENERIC_BINDING_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<__GENERIC_BINDING_INFO>(), + 8usize, + concat!("Alignment of ", stringify!(__GENERIC_BINDING_INFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<__GENERIC_BINDING_INFO>())).pObj as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__GENERIC_BINDING_INFO), + "::", + stringify!(pObj) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<__GENERIC_BINDING_INFO>())).Size as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(__GENERIC_BINDING_INFO), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<__GENERIC_BINDING_INFO>())).pfnBind as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(__GENERIC_BINDING_INFO), + "::", + stringify!(pfnBind) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<__GENERIC_BINDING_INFO>())).pfnUnbind as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(__GENERIC_BINDING_INFO), + "::", + stringify!(pfnUnbind) + ) + ); +} +pub type PGENERIC_BINDING_INFO = *mut __GENERIC_BINDING_INFO; +pub type XMIT_HELPER_ROUTINE = + ::std::option::Option; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _XMIT_ROUTINE_QUINTUPLE { + pub pfnTranslateToXmit: XMIT_HELPER_ROUTINE, + pub pfnTranslateFromXmit: XMIT_HELPER_ROUTINE, + pub pfnFreeXmit: XMIT_HELPER_ROUTINE, + pub pfnFreeInst: XMIT_HELPER_ROUTINE, +} +#[test] +fn bindgen_test_layout__XMIT_ROUTINE_QUINTUPLE() { + assert_eq!( + ::std::mem::size_of::<_XMIT_ROUTINE_QUINTUPLE>(), + 32usize, + concat!("Size of: ", stringify!(_XMIT_ROUTINE_QUINTUPLE)) + ); + assert_eq!( + ::std::mem::align_of::<_XMIT_ROUTINE_QUINTUPLE>(), + 8usize, + concat!("Alignment of ", stringify!(_XMIT_ROUTINE_QUINTUPLE)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_XMIT_ROUTINE_QUINTUPLE>())).pfnTranslateToXmit as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_XMIT_ROUTINE_QUINTUPLE), + "::", + stringify!(pfnTranslateToXmit) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_XMIT_ROUTINE_QUINTUPLE>())).pfnTranslateFromXmit as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_XMIT_ROUTINE_QUINTUPLE), + "::", + stringify!(pfnTranslateFromXmit) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_XMIT_ROUTINE_QUINTUPLE>())).pfnFreeXmit as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_XMIT_ROUTINE_QUINTUPLE), + "::", + stringify!(pfnFreeXmit) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_XMIT_ROUTINE_QUINTUPLE>())).pfnFreeInst as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_XMIT_ROUTINE_QUINTUPLE), + "::", + stringify!(pfnFreeInst) + ) + ); +} +pub type XMIT_ROUTINE_QUINTUPLE = _XMIT_ROUTINE_QUINTUPLE; +pub type USER_MARSHAL_SIZING_ROUTINE = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_ulong, + arg2: ::std::os::raw::c_ulong, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_ulong, +>; +pub type USER_MARSHAL_MARSHALLING_ROUTINE = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_ulong, + arg2: *mut ::std::os::raw::c_uchar, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_uchar, +>; +pub type USER_MARSHAL_UNMARSHALLING_ROUTINE = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_ulong, + arg2: *mut ::std::os::raw::c_uchar, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_uchar, +>; +pub type USER_MARSHAL_FREEING_ROUTINE = ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_ulong, arg2: *mut ::std::os::raw::c_void), +>; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _USER_MARSHAL_ROUTINE_QUADRUPLE { + pub pfnBufferSize: USER_MARSHAL_SIZING_ROUTINE, + pub pfnMarshall: USER_MARSHAL_MARSHALLING_ROUTINE, + pub pfnUnmarshall: USER_MARSHAL_UNMARSHALLING_ROUTINE, + pub pfnFree: USER_MARSHAL_FREEING_ROUTINE, +} +#[test] +fn bindgen_test_layout__USER_MARSHAL_ROUTINE_QUADRUPLE() { + assert_eq!( + ::std::mem::size_of::<_USER_MARSHAL_ROUTINE_QUADRUPLE>(), + 32usize, + concat!("Size of: ", stringify!(_USER_MARSHAL_ROUTINE_QUADRUPLE)) + ); + assert_eq!( + ::std::mem::align_of::<_USER_MARSHAL_ROUTINE_QUADRUPLE>(), + 8usize, + concat!("Alignment of ", stringify!(_USER_MARSHAL_ROUTINE_QUADRUPLE)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_USER_MARSHAL_ROUTINE_QUADRUPLE>())).pfnBufferSize as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_USER_MARSHAL_ROUTINE_QUADRUPLE), + "::", + stringify!(pfnBufferSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_USER_MARSHAL_ROUTINE_QUADRUPLE>())).pfnMarshall as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_USER_MARSHAL_ROUTINE_QUADRUPLE), + "::", + stringify!(pfnMarshall) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_USER_MARSHAL_ROUTINE_QUADRUPLE>())).pfnUnmarshall as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_USER_MARSHAL_ROUTINE_QUADRUPLE), + "::", + stringify!(pfnUnmarshall) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_USER_MARSHAL_ROUTINE_QUADRUPLE>())).pfnFree as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_USER_MARSHAL_ROUTINE_QUADRUPLE), + "::", + stringify!(pfnFree) + ) + ); +} +pub type USER_MARSHAL_ROUTINE_QUADRUPLE = _USER_MARSHAL_ROUTINE_QUADRUPLE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _MALLOC_FREE_STRUCT { + pub pfnAllocate: + ::std::option::Option *mut ::std::os::raw::c_void>, + pub pfnFree: ::std::option::Option, +} +#[test] +fn bindgen_test_layout__MALLOC_FREE_STRUCT() { + assert_eq!( + ::std::mem::size_of::<_MALLOC_FREE_STRUCT>(), + 16usize, + concat!("Size of: ", stringify!(_MALLOC_FREE_STRUCT)) + ); + assert_eq!( + ::std::mem::align_of::<_MALLOC_FREE_STRUCT>(), + 8usize, + concat!("Alignment of ", stringify!(_MALLOC_FREE_STRUCT)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MALLOC_FREE_STRUCT>())).pfnAllocate as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_MALLOC_FREE_STRUCT), + "::", + stringify!(pfnAllocate) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MALLOC_FREE_STRUCT>())).pfnFree as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_MALLOC_FREE_STRUCT), + "::", + stringify!(pfnFree) + ) + ); +} +pub type MALLOC_FREE_STRUCT = _MALLOC_FREE_STRUCT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _COMM_FAULT_OFFSETS { + pub CommOffset: ::std::os::raw::c_short, + pub FaultOffset: ::std::os::raw::c_short, +} +#[test] +fn bindgen_test_layout__COMM_FAULT_OFFSETS() { + assert_eq!( + ::std::mem::size_of::<_COMM_FAULT_OFFSETS>(), + 4usize, + concat!("Size of: ", stringify!(_COMM_FAULT_OFFSETS)) + ); + assert_eq!( + ::std::mem::align_of::<_COMM_FAULT_OFFSETS>(), + 2usize, + concat!("Alignment of ", stringify!(_COMM_FAULT_OFFSETS)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_COMM_FAULT_OFFSETS>())).CommOffset as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_COMM_FAULT_OFFSETS), + "::", + stringify!(CommOffset) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_COMM_FAULT_OFFSETS>())).FaultOffset as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_COMM_FAULT_OFFSETS), + "::", + stringify!(FaultOffset) + ) + ); +} +pub type COMM_FAULT_OFFSETS = _COMM_FAULT_OFFSETS; +pub const _IDL_CS_CONVERT_IDL_CS_NO_CONVERT: _IDL_CS_CONVERT = 0; +pub const _IDL_CS_CONVERT_IDL_CS_IN_PLACE_CONVERT: _IDL_CS_CONVERT = 1; +pub const _IDL_CS_CONVERT_IDL_CS_NEW_BUFFER_CONVERT: _IDL_CS_CONVERT = 2; +pub type _IDL_CS_CONVERT = ::std::os::raw::c_int; +pub use self::_IDL_CS_CONVERT as IDL_CS_CONVERT; +pub type CS_TYPE_NET_SIZE_ROUTINE = ::std::option::Option< + unsafe extern "C" fn( + hBinding: RPC_BINDING_HANDLE, + ulNetworkCodeSet: ::std::os::raw::c_ulong, + ulLocalBufferSize: ::std::os::raw::c_ulong, + conversionType: *mut IDL_CS_CONVERT, + pulNetworkBufferSize: *mut ::std::os::raw::c_ulong, + pStatus: *mut error_status_t, + ), +>; +pub type CS_TYPE_LOCAL_SIZE_ROUTINE = ::std::option::Option< + unsafe extern "C" fn( + hBinding: RPC_BINDING_HANDLE, + ulNetworkCodeSet: ::std::os::raw::c_ulong, + ulNetworkBufferSize: ::std::os::raw::c_ulong, + conversionType: *mut IDL_CS_CONVERT, + pulLocalBufferSize: *mut ::std::os::raw::c_ulong, + pStatus: *mut error_status_t, + ), +>; +pub type CS_TYPE_TO_NETCS_ROUTINE = ::std::option::Option< + unsafe extern "C" fn( + hBinding: RPC_BINDING_HANDLE, + ulNetworkCodeSet: ::std::os::raw::c_ulong, + pLocalData: *mut ::std::os::raw::c_void, + ulLocalDataLength: ::std::os::raw::c_ulong, + pNetworkData: *mut byte, + pulNetworkDataLength: *mut ::std::os::raw::c_ulong, + pStatus: *mut error_status_t, + ), +>; +pub type CS_TYPE_FROM_NETCS_ROUTINE = ::std::option::Option< + unsafe extern "C" fn( + hBinding: RPC_BINDING_HANDLE, + ulNetworkCodeSet: ::std::os::raw::c_ulong, + pNetworkData: *mut byte, + ulNetworkDataLength: ::std::os::raw::c_ulong, + ulLocalBufferSize: ::std::os::raw::c_ulong, + pLocalData: *mut ::std::os::raw::c_void, + pulLocalDataLength: *mut ::std::os::raw::c_ulong, + pStatus: *mut error_status_t, + ), +>; +pub type CS_TAG_GETTING_ROUTINE = ::std::option::Option< + unsafe extern "C" fn( + hBinding: RPC_BINDING_HANDLE, + fServerSide: ::std::os::raw::c_int, + pulSendingTag: *mut ::std::os::raw::c_ulong, + pulDesiredReceivingTag: *mut ::std::os::raw::c_ulong, + pulReceivingTag: *mut ::std::os::raw::c_ulong, + pStatus: *mut error_status_t, + ), +>; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _NDR_CS_SIZE_CONVERT_ROUTINES { + pub pfnNetSize: CS_TYPE_NET_SIZE_ROUTINE, + pub pfnToNetCs: CS_TYPE_TO_NETCS_ROUTINE, + pub pfnLocalSize: CS_TYPE_LOCAL_SIZE_ROUTINE, + pub pfnFromNetCs: CS_TYPE_FROM_NETCS_ROUTINE, +} +#[test] +fn bindgen_test_layout__NDR_CS_SIZE_CONVERT_ROUTINES() { + assert_eq!( + ::std::mem::size_of::<_NDR_CS_SIZE_CONVERT_ROUTINES>(), + 32usize, + concat!("Size of: ", stringify!(_NDR_CS_SIZE_CONVERT_ROUTINES)) + ); + assert_eq!( + ::std::mem::align_of::<_NDR_CS_SIZE_CONVERT_ROUTINES>(), + 8usize, + concat!("Alignment of ", stringify!(_NDR_CS_SIZE_CONVERT_ROUTINES)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_NDR_CS_SIZE_CONVERT_ROUTINES>())).pfnNetSize as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_NDR_CS_SIZE_CONVERT_ROUTINES), + "::", + stringify!(pfnNetSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_NDR_CS_SIZE_CONVERT_ROUTINES>())).pfnToNetCs as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_NDR_CS_SIZE_CONVERT_ROUTINES), + "::", + stringify!(pfnToNetCs) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_NDR_CS_SIZE_CONVERT_ROUTINES>())).pfnLocalSize as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_NDR_CS_SIZE_CONVERT_ROUTINES), + "::", + stringify!(pfnLocalSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_NDR_CS_SIZE_CONVERT_ROUTINES>())).pfnFromNetCs as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_NDR_CS_SIZE_CONVERT_ROUTINES), + "::", + stringify!(pfnFromNetCs) + ) + ); +} +pub type NDR_CS_SIZE_CONVERT_ROUTINES = _NDR_CS_SIZE_CONVERT_ROUTINES; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _NDR_CS_ROUTINES { + pub pSizeConvertRoutines: *mut NDR_CS_SIZE_CONVERT_ROUTINES, + pub pTagGettingRoutines: *mut CS_TAG_GETTING_ROUTINE, +} +#[test] +fn bindgen_test_layout__NDR_CS_ROUTINES() { + assert_eq!( + ::std::mem::size_of::<_NDR_CS_ROUTINES>(), + 16usize, + concat!("Size of: ", stringify!(_NDR_CS_ROUTINES)) + ); + assert_eq!( + ::std::mem::align_of::<_NDR_CS_ROUTINES>(), + 8usize, + concat!("Alignment of ", stringify!(_NDR_CS_ROUTINES)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_NDR_CS_ROUTINES>())).pSizeConvertRoutines as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_NDR_CS_ROUTINES), + "::", + stringify!(pSizeConvertRoutines) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_NDR_CS_ROUTINES>())).pTagGettingRoutines as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_NDR_CS_ROUTINES), + "::", + stringify!(pTagGettingRoutines) + ) + ); +} +pub type NDR_CS_ROUTINES = _NDR_CS_ROUTINES; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _NDR_EXPR_DESC { + pub pOffset: *const ::std::os::raw::c_ushort, + pub pFormatExpr: PFORMAT_STRING, +} +#[test] +fn bindgen_test_layout__NDR_EXPR_DESC() { + assert_eq!( + ::std::mem::size_of::<_NDR_EXPR_DESC>(), + 16usize, + concat!("Size of: ", stringify!(_NDR_EXPR_DESC)) + ); + assert_eq!( + ::std::mem::align_of::<_NDR_EXPR_DESC>(), + 8usize, + concat!("Alignment of ", stringify!(_NDR_EXPR_DESC)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_NDR_EXPR_DESC>())).pOffset as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_NDR_EXPR_DESC), + "::", + stringify!(pOffset) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_NDR_EXPR_DESC>())).pFormatExpr as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_NDR_EXPR_DESC), + "::", + stringify!(pFormatExpr) + ) + ); +} +pub type NDR_EXPR_DESC = _NDR_EXPR_DESC; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _MIDL_STUB_DESC { + pub RpcInterfaceInformation: *mut ::std::os::raw::c_void, + pub pfnAllocate: + ::std::option::Option *mut ::std::os::raw::c_void>, + pub pfnFree: ::std::option::Option, + pub IMPLICIT_HANDLE_INFO: _MIDL_STUB_DESC__bindgen_ty_1, + pub apfnNdrRundownRoutines: *const NDR_RUNDOWN, + pub aGenericBindingRoutinePairs: *const GENERIC_BINDING_ROUTINE_PAIR, + pub apfnExprEval: *const EXPR_EVAL, + pub aXmitQuintuple: *const XMIT_ROUTINE_QUINTUPLE, + pub pFormatTypes: *const ::std::os::raw::c_uchar, + pub fCheckBounds: ::std::os::raw::c_int, + pub Version: ::std::os::raw::c_ulong, + pub pMallocFreeStruct: *mut MALLOC_FREE_STRUCT, + pub MIDLVersion: ::std::os::raw::c_long, + pub CommFaultOffsets: *const COMM_FAULT_OFFSETS, + pub aUserMarshalQuadruple: *const USER_MARSHAL_ROUTINE_QUADRUPLE, + pub NotifyRoutineTable: *const NDR_NOTIFY_ROUTINE, + pub mFlags: ULONG_PTR, + pub CsRoutineTables: *const NDR_CS_ROUTINES, + pub ProxyServerInfo: *mut ::std::os::raw::c_void, + pub pExprInfo: *const NDR_EXPR_DESC, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _MIDL_STUB_DESC__bindgen_ty_1 { + pub pAutoHandle: *mut handle_t, + pub pPrimitiveHandle: *mut handle_t, + pub pGenericBindingInfo: PGENERIC_BINDING_INFO, + _bindgen_union_align: u64, +} +#[test] +fn bindgen_test_layout__MIDL_STUB_DESC__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_MIDL_STUB_DESC__bindgen_ty_1>(), + 8usize, + concat!("Size of: ", stringify!(_MIDL_STUB_DESC__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<_MIDL_STUB_DESC__bindgen_ty_1>(), + 8usize, + concat!("Alignment of ", stringify!(_MIDL_STUB_DESC__bindgen_ty_1)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_MIDL_STUB_DESC__bindgen_ty_1>())).pAutoHandle as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_DESC__bindgen_ty_1), + "::", + stringify!(pAutoHandle) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_MIDL_STUB_DESC__bindgen_ty_1>())).pPrimitiveHandle as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_DESC__bindgen_ty_1), + "::", + stringify!(pPrimitiveHandle) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_MIDL_STUB_DESC__bindgen_ty_1>())).pGenericBindingInfo as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_DESC__bindgen_ty_1), + "::", + stringify!(pGenericBindingInfo) + ) + ); +} +#[test] +fn bindgen_test_layout__MIDL_STUB_DESC() { + assert_eq!( + ::std::mem::size_of::<_MIDL_STUB_DESC>(), + 152usize, + concat!("Size of: ", stringify!(_MIDL_STUB_DESC)) + ); + assert_eq!( + ::std::mem::align_of::<_MIDL_STUB_DESC>(), + 8usize, + concat!("Alignment of ", stringify!(_MIDL_STUB_DESC)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_MIDL_STUB_DESC>())).RpcInterfaceInformation as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_DESC), + "::", + stringify!(RpcInterfaceInformation) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_DESC>())).pfnAllocate as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_DESC), + "::", + stringify!(pfnAllocate) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_DESC>())).pfnFree as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_DESC), + "::", + stringify!(pfnFree) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_MIDL_STUB_DESC>())).IMPLICIT_HANDLE_INFO as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_DESC), + "::", + stringify!(IMPLICIT_HANDLE_INFO) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_MIDL_STUB_DESC>())).apfnNdrRundownRoutines as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_DESC), + "::", + stringify!(apfnNdrRundownRoutines) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_MIDL_STUB_DESC>())).aGenericBindingRoutinePairs as *const _ as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_DESC), + "::", + stringify!(aGenericBindingRoutinePairs) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_DESC>())).apfnExprEval as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_DESC), + "::", + stringify!(apfnExprEval) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_DESC>())).aXmitQuintuple as *const _ as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_DESC), + "::", + stringify!(aXmitQuintuple) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_DESC>())).pFormatTypes as *const _ as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_DESC), + "::", + stringify!(pFormatTypes) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_DESC>())).fCheckBounds as *const _ as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_DESC), + "::", + stringify!(fCheckBounds) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_DESC>())).Version as *const _ as usize }, + 76usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_DESC), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_DESC>())).pMallocFreeStruct as *const _ as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_DESC), + "::", + stringify!(pMallocFreeStruct) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_DESC>())).MIDLVersion as *const _ as usize }, + 88usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_DESC), + "::", + stringify!(MIDLVersion) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_DESC>())).CommFaultOffsets as *const _ as usize }, + 96usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_DESC), + "::", + stringify!(CommFaultOffsets) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_MIDL_STUB_DESC>())).aUserMarshalQuadruple as *const _ as usize + }, + 104usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_DESC), + "::", + stringify!(aUserMarshalQuadruple) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_DESC>())).NotifyRoutineTable as *const _ as usize }, + 112usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_DESC), + "::", + stringify!(NotifyRoutineTable) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_DESC>())).mFlags as *const _ as usize }, + 120usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_DESC), + "::", + stringify!(mFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_DESC>())).CsRoutineTables as *const _ as usize }, + 128usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_DESC), + "::", + stringify!(CsRoutineTables) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_DESC>())).ProxyServerInfo as *const _ as usize }, + 136usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_DESC), + "::", + stringify!(ProxyServerInfo) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_MIDL_STUB_DESC>())).pExprInfo as *const _ as usize }, + 144usize, + concat!( + "Offset of field: ", + stringify!(_MIDL_STUB_DESC), + "::", + stringify!(pExprInfo) + ) + ); +} +pub type STUB_THUNK = ::std::option::Option; +pub type SERVER_ROUTINE = ::std::option::Option ::std::os::raw::c_long>; +pub const XLAT_SIDE_XLAT_SERVER: XLAT_SIDE = 1; +pub const XLAT_SIDE_XLAT_CLIENT: XLAT_SIDE = 2; +pub type XLAT_SIDE = ::std::os::raw::c_int; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _FULL_PTR_XLAT_TABLES { + pub RefIdToPointer: *mut ::std::os::raw::c_void, + pub PointerToRefId: *mut ::std::os::raw::c_void, + pub NextRefId: ::std::os::raw::c_ulong, + pub XlatSide: XLAT_SIDE, +} +#[test] +fn bindgen_test_layout__FULL_PTR_XLAT_TABLES() { + assert_eq!( + ::std::mem::size_of::<_FULL_PTR_XLAT_TABLES>(), + 24usize, + concat!("Size of: ", stringify!(_FULL_PTR_XLAT_TABLES)) + ); + assert_eq!( + ::std::mem::align_of::<_FULL_PTR_XLAT_TABLES>(), + 8usize, + concat!("Alignment of ", stringify!(_FULL_PTR_XLAT_TABLES)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_FULL_PTR_XLAT_TABLES>())).RefIdToPointer as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_FULL_PTR_XLAT_TABLES), + "::", + stringify!(RefIdToPointer) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_FULL_PTR_XLAT_TABLES>())).PointerToRefId as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_FULL_PTR_XLAT_TABLES), + "::", + stringify!(PointerToRefId) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_FULL_PTR_XLAT_TABLES>())).NextRefId as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_FULL_PTR_XLAT_TABLES), + "::", + stringify!(NextRefId) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_FULL_PTR_XLAT_TABLES>())).XlatSide as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_FULL_PTR_XLAT_TABLES), + "::", + stringify!(XlatSide) + ) + ); +} +pub const STUB_PHASE_STUB_UNMARSHAL: STUB_PHASE = 0; +pub const STUB_PHASE_STUB_CALL_SERVER: STUB_PHASE = 1; +pub const STUB_PHASE_STUB_MARSHAL: STUB_PHASE = 2; +pub const STUB_PHASE_STUB_CALL_SERVER_NO_HRESULT: STUB_PHASE = 3; +pub type STUB_PHASE = ::std::os::raw::c_int; +pub type OLECHAR = WCHAR; +pub type LPOLESTR = *mut OLECHAR; +pub type LPCOLESTR = *const OLECHAR; +pub type DOUBLE = f64; +pub type SCODE = LONG; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _FLAGGED_WORD_BLOB { + pub fFlags: ULONG, + pub clSize: ULONG, + pub asData: [::std::os::raw::c_ushort; 1usize], +} +#[test] +fn bindgen_test_layout__FLAGGED_WORD_BLOB() { + assert_eq!( + ::std::mem::size_of::<_FLAGGED_WORD_BLOB>(), + 12usize, + concat!("Size of: ", stringify!(_FLAGGED_WORD_BLOB)) + ); + assert_eq!( + ::std::mem::align_of::<_FLAGGED_WORD_BLOB>(), + 4usize, + concat!("Alignment of ", stringify!(_FLAGGED_WORD_BLOB)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_FLAGGED_WORD_BLOB>())).fFlags as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_FLAGGED_WORD_BLOB), + "::", + stringify!(fFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_FLAGGED_WORD_BLOB>())).clSize as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_FLAGGED_WORD_BLOB), + "::", + stringify!(clSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_FLAGGED_WORD_BLOB>())).asData as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_FLAGGED_WORD_BLOB), + "::", + stringify!(asData) + ) + ); +} +pub type FLAGGED_WORD_BLOB = _FLAGGED_WORD_BLOB; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _BYTE_SIZEDARR { + pub clSize: ULONG, + pub pData: *mut byte, +} +#[test] +fn bindgen_test_layout__BYTE_SIZEDARR() { + assert_eq!( + ::std::mem::size_of::<_BYTE_SIZEDARR>(), + 16usize, + concat!("Size of: ", stringify!(_BYTE_SIZEDARR)) + ); + assert_eq!( + ::std::mem::align_of::<_BYTE_SIZEDARR>(), + 8usize, + concat!("Alignment of ", stringify!(_BYTE_SIZEDARR)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_BYTE_SIZEDARR>())).clSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_BYTE_SIZEDARR), + "::", + stringify!(clSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_BYTE_SIZEDARR>())).pData as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_BYTE_SIZEDARR), + "::", + stringify!(pData) + ) + ); +} +pub type BYTE_SIZEDARR = _BYTE_SIZEDARR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SHORT_SIZEDARR { + pub clSize: ULONG, + pub pData: *mut ::std::os::raw::c_ushort, +} +#[test] +fn bindgen_test_layout__SHORT_SIZEDARR() { + assert_eq!( + ::std::mem::size_of::<_SHORT_SIZEDARR>(), + 16usize, + concat!("Size of: ", stringify!(_SHORT_SIZEDARR)) + ); + assert_eq!( + ::std::mem::align_of::<_SHORT_SIZEDARR>(), + 8usize, + concat!("Alignment of ", stringify!(_SHORT_SIZEDARR)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHORT_SIZEDARR>())).clSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SHORT_SIZEDARR), + "::", + stringify!(clSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHORT_SIZEDARR>())).pData as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SHORT_SIZEDARR), + "::", + stringify!(pData) + ) + ); +} +pub type WORD_SIZEDARR = _SHORT_SIZEDARR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _LONG_SIZEDARR { + pub clSize: ULONG, + pub pData: *mut ULONG, +} +#[test] +fn bindgen_test_layout__LONG_SIZEDARR() { + assert_eq!( + ::std::mem::size_of::<_LONG_SIZEDARR>(), + 16usize, + concat!("Size of: ", stringify!(_LONG_SIZEDARR)) + ); + assert_eq!( + ::std::mem::align_of::<_LONG_SIZEDARR>(), + 8usize, + concat!("Alignment of ", stringify!(_LONG_SIZEDARR)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_LONG_SIZEDARR>())).clSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_LONG_SIZEDARR), + "::", + stringify!(clSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_LONG_SIZEDARR>())).pData as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_LONG_SIZEDARR), + "::", + stringify!(pData) + ) + ); +} +pub type DWORD_SIZEDARR = _LONG_SIZEDARR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _HYPER_SIZEDARR { + pub clSize: ULONG, + pub pData: *mut ::std::os::raw::c_longlong, +} +#[test] +fn bindgen_test_layout__HYPER_SIZEDARR() { + assert_eq!( + ::std::mem::size_of::<_HYPER_SIZEDARR>(), + 16usize, + concat!("Size of: ", stringify!(_HYPER_SIZEDARR)) + ); + assert_eq!( + ::std::mem::align_of::<_HYPER_SIZEDARR>(), + 8usize, + concat!("Alignment of ", stringify!(_HYPER_SIZEDARR)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_HYPER_SIZEDARR>())).clSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_HYPER_SIZEDARR), + "::", + stringify!(clSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_HYPER_SIZEDARR>())).pData as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_HYPER_SIZEDARR), + "::", + stringify!(pData) + ) + ); +} +pub type HYPER_SIZEDARR = _HYPER_SIZEDARR; +pub const tagSTGC_STGC_DEFAULT: tagSTGC = 0; +pub const tagSTGC_STGC_OVERWRITE: tagSTGC = 1; +pub const tagSTGC_STGC_ONLYIFCURRENT: tagSTGC = 2; +pub const tagSTGC_STGC_DANGEROUSLYCOMMITMERELYTODISKCACHE: tagSTGC = 4; +pub const tagSTGC_STGC_CONSOLIDATE: tagSTGC = 8; +pub type tagSTGC = ::std::os::raw::c_int; +pub use self::tagSTGC as STGC; +pub const tagSTGMOVE_STGMOVE_MOVE: tagSTGMOVE = 0; +pub const tagSTGMOVE_STGMOVE_COPY: tagSTGMOVE = 1; +pub const tagSTGMOVE_STGMOVE_SHALLOWCOPY: tagSTGMOVE = 2; +pub type tagSTGMOVE = ::std::os::raw::c_int; +pub use self::tagSTGMOVE as STGMOVE; +pub const tagSTATFLAG_STATFLAG_DEFAULT: tagSTATFLAG = 0; +pub const tagSTATFLAG_STATFLAG_NONAME: tagSTATFLAG = 1; +pub const tagSTATFLAG_STATFLAG_NOOPEN: tagSTATFLAG = 2; +pub type tagSTATFLAG = ::std::os::raw::c_int; +pub use self::tagSTATFLAG as STATFLAG; +pub type CLIPFORMAT = WORD; +pub type HMETAFILEPICT = *mut ::std::os::raw::c_void; +pub type DATE = f64; +#[repr(C)] +#[derive(Copy, Clone)] +pub union tagCY { + pub __bindgen_anon_1: tagCY__bindgen_ty_1, + pub int64: LONGLONG, + _bindgen_union_align: u64, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagCY__bindgen_ty_1 { + pub Lo: ULONG, + pub Hi: LONG, +} +#[test] +fn bindgen_test_layout_tagCY__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(tagCY__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(tagCY__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).Lo as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagCY__bindgen_ty_1), + "::", + stringify!(Lo) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).Hi as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagCY__bindgen_ty_1), + "::", + stringify!(Hi) + ) + ); +} +#[test] +fn bindgen_test_layout_tagCY() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(tagCY)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagCY)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).int64 as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagCY), + "::", + stringify!(int64) + ) + ); +} +pub type CY = tagCY; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct tagDEC { + pub wReserved: USHORT, + pub __bindgen_anon_1: tagDEC__bindgen_ty_1, + pub Hi32: ULONG, + pub __bindgen_anon_2: tagDEC__bindgen_ty_2, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union tagDEC__bindgen_ty_1 { + pub __bindgen_anon_1: tagDEC__bindgen_ty_1__bindgen_ty_1, + pub signscale: USHORT, + _bindgen_union_align: u16, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagDEC__bindgen_ty_1__bindgen_ty_1 { + pub scale: BYTE, + pub sign: BYTE, +} +#[test] +fn bindgen_test_layout_tagDEC__bindgen_ty_1__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::(), + 2usize, + concat!("Size of: ", stringify!(tagDEC__bindgen_ty_1__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!( + "Alignment of ", + stringify!(tagDEC__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).scale as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagDEC__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(scale) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).sign as *const _ as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(tagDEC__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(sign) + ) + ); +} +#[test] +fn bindgen_test_layout_tagDEC__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::(), + 2usize, + concat!("Size of: ", stringify!(tagDEC__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 2usize, + concat!("Alignment of ", stringify!(tagDEC__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).signscale as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagDEC__bindgen_ty_1), + "::", + stringify!(signscale) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union tagDEC__bindgen_ty_2 { + pub __bindgen_anon_1: tagDEC__bindgen_ty_2__bindgen_ty_1, + pub Lo64: ULONGLONG, + _bindgen_union_align: u64, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagDEC__bindgen_ty_2__bindgen_ty_1 { + pub Lo32: ULONG, + pub Mid32: ULONG, +} +#[test] +fn bindgen_test_layout_tagDEC__bindgen_ty_2__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(tagDEC__bindgen_ty_2__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!( + "Alignment of ", + stringify!(tagDEC__bindgen_ty_2__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).Lo32 as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagDEC__bindgen_ty_2__bindgen_ty_1), + "::", + stringify!(Lo32) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).Mid32 as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagDEC__bindgen_ty_2__bindgen_ty_1), + "::", + stringify!(Mid32) + ) + ); +} +#[test] +fn bindgen_test_layout_tagDEC__bindgen_ty_2() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(tagDEC__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagDEC__bindgen_ty_2)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).Lo64 as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagDEC__bindgen_ty_2), + "::", + stringify!(Lo64) + ) + ); +} +#[test] +fn bindgen_test_layout_tagDEC() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(tagDEC)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagDEC)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).wReserved as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagDEC), + "::", + stringify!(wReserved) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).Hi32 as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagDEC), + "::", + stringify!(Hi32) + ) + ); +} +pub type DECIMAL = tagDEC; +pub type wireBSTR = *mut FLAGGED_WORD_BLOB; +pub type BSTR = *mut OLECHAR; +pub type VARIANT_BOOL = ::std::os::raw::c_short; +pub type VARTYPE = ::std::os::raw::c_ushort; +pub type PROPID = ULONG; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_HOTPLUG_INFO { + pub Size: DWORD, + pub MediaRemovable: BOOLEAN, + pub MediaHotplug: BOOLEAN, + pub DeviceHotplug: BOOLEAN, + pub WriteCacheEnableOverride: BOOLEAN, +} +#[test] +fn bindgen_test_layout__STORAGE_HOTPLUG_INFO() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_HOTPLUG_INFO>(), + 8usize, + concat!("Size of: ", stringify!(_STORAGE_HOTPLUG_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_HOTPLUG_INFO>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_HOTPLUG_INFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_HOTPLUG_INFO>())).Size as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HOTPLUG_INFO), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HOTPLUG_INFO>())).MediaRemovable as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HOTPLUG_INFO), + "::", + stringify!(MediaRemovable) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_HOTPLUG_INFO>())).MediaHotplug as *const _ as usize }, + 5usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HOTPLUG_INFO), + "::", + stringify!(MediaHotplug) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_HOTPLUG_INFO>())).DeviceHotplug as *const _ as usize }, + 6usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HOTPLUG_INFO), + "::", + stringify!(DeviceHotplug) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HOTPLUG_INFO>())).WriteCacheEnableOverride as *const _ + as usize + }, + 7usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HOTPLUG_INFO), + "::", + stringify!(WriteCacheEnableOverride) + ) + ); +} +pub type STORAGE_HOTPLUG_INFO = _STORAGE_HOTPLUG_INFO; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_DEVICE_NUMBER { + pub DeviceType: DWORD, + pub DeviceNumber: DWORD, + pub PartitionNumber: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_DEVICE_NUMBER() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_DEVICE_NUMBER>(), + 12usize, + concat!("Size of: ", stringify!(_STORAGE_DEVICE_NUMBER)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_DEVICE_NUMBER>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_DEVICE_NUMBER)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DEVICE_NUMBER>())).DeviceType as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_NUMBER), + "::", + stringify!(DeviceType) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DEVICE_NUMBER>())).DeviceNumber as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_NUMBER), + "::", + stringify!(DeviceNumber) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_NUMBER>())).PartitionNumber as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_NUMBER), + "::", + stringify!(PartitionNumber) + ) + ); +} +pub type STORAGE_DEVICE_NUMBER = _STORAGE_DEVICE_NUMBER; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_DEVICE_NUMBERS { + pub Version: DWORD, + pub Size: DWORD, + pub NumberOfDevices: DWORD, + pub Devices: [STORAGE_DEVICE_NUMBER; 1usize], +} +#[test] +fn bindgen_test_layout__STORAGE_DEVICE_NUMBERS() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_DEVICE_NUMBERS>(), + 24usize, + concat!("Size of: ", stringify!(_STORAGE_DEVICE_NUMBERS)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_DEVICE_NUMBERS>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_DEVICE_NUMBERS)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DEVICE_NUMBERS>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_NUMBERS), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DEVICE_NUMBERS>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_NUMBERS), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_NUMBERS>())).NumberOfDevices as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_NUMBERS), + "::", + stringify!(NumberOfDevices) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DEVICE_NUMBERS>())).Devices as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_NUMBERS), + "::", + stringify!(Devices) + ) + ); +} +pub type STORAGE_DEVICE_NUMBERS = _STORAGE_DEVICE_NUMBERS; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_DEVICE_NUMBER_EX { + pub Version: DWORD, + pub Size: DWORD, + pub Flags: DWORD, + pub DeviceType: DWORD, + pub DeviceNumber: DWORD, + pub DeviceGuid: GUID, + pub PartitionNumber: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_DEVICE_NUMBER_EX() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_DEVICE_NUMBER_EX>(), + 40usize, + concat!("Size of: ", stringify!(_STORAGE_DEVICE_NUMBER_EX)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_DEVICE_NUMBER_EX>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_DEVICE_NUMBER_EX)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DEVICE_NUMBER_EX>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_NUMBER_EX), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DEVICE_NUMBER_EX>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_NUMBER_EX), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DEVICE_NUMBER_EX>())).Flags as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_NUMBER_EX), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_NUMBER_EX>())).DeviceType as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_NUMBER_EX), + "::", + stringify!(DeviceType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_NUMBER_EX>())).DeviceNumber as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_NUMBER_EX), + "::", + stringify!(DeviceNumber) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_NUMBER_EX>())).DeviceGuid as *const _ as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_NUMBER_EX), + "::", + stringify!(DeviceGuid) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_NUMBER_EX>())).PartitionNumber as *const _ as usize + }, + 36usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_NUMBER_EX), + "::", + stringify!(PartitionNumber) + ) + ); +} +pub type STORAGE_DEVICE_NUMBER_EX = _STORAGE_DEVICE_NUMBER_EX; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_BUS_RESET_REQUEST { + pub PathId: BYTE, +} +#[test] +fn bindgen_test_layout__STORAGE_BUS_RESET_REQUEST() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_BUS_RESET_REQUEST>(), + 1usize, + concat!("Size of: ", stringify!(_STORAGE_BUS_RESET_REQUEST)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_BUS_RESET_REQUEST>(), + 1usize, + concat!("Alignment of ", stringify!(_STORAGE_BUS_RESET_REQUEST)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_BUS_RESET_REQUEST>())).PathId as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_BUS_RESET_REQUEST), + "::", + stringify!(PathId) + ) + ); +} +pub type STORAGE_BUS_RESET_REQUEST = _STORAGE_BUS_RESET_REQUEST; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct STORAGE_BREAK_RESERVATION_REQUEST { + pub Length: DWORD, + pub _unused: BYTE, + pub PathId: BYTE, + pub TargetId: BYTE, + pub Lun: BYTE, +} +#[test] +fn bindgen_test_layout_STORAGE_BREAK_RESERVATION_REQUEST() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(STORAGE_BREAK_RESERVATION_REQUEST)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!( + "Alignment of ", + stringify!(STORAGE_BREAK_RESERVATION_REQUEST) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).Length as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(STORAGE_BREAK_RESERVATION_REQUEST), + "::", + stringify!(Length) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::()))._unused as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(STORAGE_BREAK_RESERVATION_REQUEST), + "::", + stringify!(_unused) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).PathId as *const _ as usize + }, + 5usize, + concat!( + "Offset of field: ", + stringify!(STORAGE_BREAK_RESERVATION_REQUEST), + "::", + stringify!(PathId) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).TargetId as *const _ as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(STORAGE_BREAK_RESERVATION_REQUEST), + "::", + stringify!(TargetId) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).Lun as *const _ as usize + }, + 7usize, + concat!( + "Offset of field: ", + stringify!(STORAGE_BREAK_RESERVATION_REQUEST), + "::", + stringify!(Lun) + ) + ); +} +pub const _STORAGE_MEDIA_TYPE_DDS_4mm: _STORAGE_MEDIA_TYPE = 32; +pub const _STORAGE_MEDIA_TYPE_MiniQic: _STORAGE_MEDIA_TYPE = 33; +pub const _STORAGE_MEDIA_TYPE_Travan: _STORAGE_MEDIA_TYPE = 34; +pub const _STORAGE_MEDIA_TYPE_QIC: _STORAGE_MEDIA_TYPE = 35; +pub const _STORAGE_MEDIA_TYPE_MP_8mm: _STORAGE_MEDIA_TYPE = 36; +pub const _STORAGE_MEDIA_TYPE_AME_8mm: _STORAGE_MEDIA_TYPE = 37; +pub const _STORAGE_MEDIA_TYPE_AIT1_8mm: _STORAGE_MEDIA_TYPE = 38; +pub const _STORAGE_MEDIA_TYPE_DLT: _STORAGE_MEDIA_TYPE = 39; +pub const _STORAGE_MEDIA_TYPE_NCTP: _STORAGE_MEDIA_TYPE = 40; +pub const _STORAGE_MEDIA_TYPE_IBM_3480: _STORAGE_MEDIA_TYPE = 41; +pub const _STORAGE_MEDIA_TYPE_IBM_3490E: _STORAGE_MEDIA_TYPE = 42; +pub const _STORAGE_MEDIA_TYPE_IBM_Magstar_3590: _STORAGE_MEDIA_TYPE = 43; +pub const _STORAGE_MEDIA_TYPE_IBM_Magstar_MP: _STORAGE_MEDIA_TYPE = 44; +pub const _STORAGE_MEDIA_TYPE_STK_DATA_D3: _STORAGE_MEDIA_TYPE = 45; +pub const _STORAGE_MEDIA_TYPE_SONY_DTF: _STORAGE_MEDIA_TYPE = 46; +pub const _STORAGE_MEDIA_TYPE_DV_6mm: _STORAGE_MEDIA_TYPE = 47; +pub const _STORAGE_MEDIA_TYPE_DMI: _STORAGE_MEDIA_TYPE = 48; +pub const _STORAGE_MEDIA_TYPE_SONY_D2: _STORAGE_MEDIA_TYPE = 49; +pub const _STORAGE_MEDIA_TYPE_CLEANER_CARTRIDGE: _STORAGE_MEDIA_TYPE = 50; +pub const _STORAGE_MEDIA_TYPE_CD_ROM: _STORAGE_MEDIA_TYPE = 51; +pub const _STORAGE_MEDIA_TYPE_CD_R: _STORAGE_MEDIA_TYPE = 52; +pub const _STORAGE_MEDIA_TYPE_CD_RW: _STORAGE_MEDIA_TYPE = 53; +pub const _STORAGE_MEDIA_TYPE_DVD_ROM: _STORAGE_MEDIA_TYPE = 54; +pub const _STORAGE_MEDIA_TYPE_DVD_R: _STORAGE_MEDIA_TYPE = 55; +pub const _STORAGE_MEDIA_TYPE_DVD_RW: _STORAGE_MEDIA_TYPE = 56; +pub const _STORAGE_MEDIA_TYPE_MO_3_RW: _STORAGE_MEDIA_TYPE = 57; +pub const _STORAGE_MEDIA_TYPE_MO_5_WO: _STORAGE_MEDIA_TYPE = 58; +pub const _STORAGE_MEDIA_TYPE_MO_5_RW: _STORAGE_MEDIA_TYPE = 59; +pub const _STORAGE_MEDIA_TYPE_MO_5_LIMDOW: _STORAGE_MEDIA_TYPE = 60; +pub const _STORAGE_MEDIA_TYPE_PC_5_WO: _STORAGE_MEDIA_TYPE = 61; +pub const _STORAGE_MEDIA_TYPE_PC_5_RW: _STORAGE_MEDIA_TYPE = 62; +pub const _STORAGE_MEDIA_TYPE_PD_5_RW: _STORAGE_MEDIA_TYPE = 63; +pub const _STORAGE_MEDIA_TYPE_ABL_5_WO: _STORAGE_MEDIA_TYPE = 64; +pub const _STORAGE_MEDIA_TYPE_PINNACLE_APEX_5_RW: _STORAGE_MEDIA_TYPE = 65; +pub const _STORAGE_MEDIA_TYPE_SONY_12_WO: _STORAGE_MEDIA_TYPE = 66; +pub const _STORAGE_MEDIA_TYPE_PHILIPS_12_WO: _STORAGE_MEDIA_TYPE = 67; +pub const _STORAGE_MEDIA_TYPE_HITACHI_12_WO: _STORAGE_MEDIA_TYPE = 68; +pub const _STORAGE_MEDIA_TYPE_CYGNET_12_WO: _STORAGE_MEDIA_TYPE = 69; +pub const _STORAGE_MEDIA_TYPE_KODAK_14_WO: _STORAGE_MEDIA_TYPE = 70; +pub const _STORAGE_MEDIA_TYPE_MO_NFR_525: _STORAGE_MEDIA_TYPE = 71; +pub const _STORAGE_MEDIA_TYPE_NIKON_12_RW: _STORAGE_MEDIA_TYPE = 72; +pub const _STORAGE_MEDIA_TYPE_IOMEGA_ZIP: _STORAGE_MEDIA_TYPE = 73; +pub const _STORAGE_MEDIA_TYPE_IOMEGA_JAZ: _STORAGE_MEDIA_TYPE = 74; +pub const _STORAGE_MEDIA_TYPE_SYQUEST_EZ135: _STORAGE_MEDIA_TYPE = 75; +pub const _STORAGE_MEDIA_TYPE_SYQUEST_EZFLYER: _STORAGE_MEDIA_TYPE = 76; +pub const _STORAGE_MEDIA_TYPE_SYQUEST_SYJET: _STORAGE_MEDIA_TYPE = 77; +pub const _STORAGE_MEDIA_TYPE_AVATAR_F2: _STORAGE_MEDIA_TYPE = 78; +pub const _STORAGE_MEDIA_TYPE_MP2_8mm: _STORAGE_MEDIA_TYPE = 79; +pub const _STORAGE_MEDIA_TYPE_DST_S: _STORAGE_MEDIA_TYPE = 80; +pub const _STORAGE_MEDIA_TYPE_DST_M: _STORAGE_MEDIA_TYPE = 81; +pub const _STORAGE_MEDIA_TYPE_DST_L: _STORAGE_MEDIA_TYPE = 82; +pub const _STORAGE_MEDIA_TYPE_VXATape_1: _STORAGE_MEDIA_TYPE = 83; +pub const _STORAGE_MEDIA_TYPE_VXATape_2: _STORAGE_MEDIA_TYPE = 84; +pub const _STORAGE_MEDIA_TYPE_STK_9840: _STORAGE_MEDIA_TYPE = 85; +pub const _STORAGE_MEDIA_TYPE_LTO_Ultrium: _STORAGE_MEDIA_TYPE = 86; +pub const _STORAGE_MEDIA_TYPE_LTO_Accelis: _STORAGE_MEDIA_TYPE = 87; +pub const _STORAGE_MEDIA_TYPE_DVD_RAM: _STORAGE_MEDIA_TYPE = 88; +pub const _STORAGE_MEDIA_TYPE_AIT_8mm: _STORAGE_MEDIA_TYPE = 89; +pub const _STORAGE_MEDIA_TYPE_ADR_1: _STORAGE_MEDIA_TYPE = 90; +pub const _STORAGE_MEDIA_TYPE_ADR_2: _STORAGE_MEDIA_TYPE = 91; +pub const _STORAGE_MEDIA_TYPE_STK_9940: _STORAGE_MEDIA_TYPE = 92; +pub const _STORAGE_MEDIA_TYPE_SAIT: _STORAGE_MEDIA_TYPE = 93; +pub const _STORAGE_MEDIA_TYPE_VXATape: _STORAGE_MEDIA_TYPE = 94; +pub type _STORAGE_MEDIA_TYPE = ::std::os::raw::c_int; +pub use self::_STORAGE_MEDIA_TYPE as STORAGE_MEDIA_TYPE; +pub const _STORAGE_BUS_TYPE_BusTypeUnknown: _STORAGE_BUS_TYPE = 0; +pub const _STORAGE_BUS_TYPE_BusTypeScsi: _STORAGE_BUS_TYPE = 1; +pub const _STORAGE_BUS_TYPE_BusTypeAtapi: _STORAGE_BUS_TYPE = 2; +pub const _STORAGE_BUS_TYPE_BusTypeAta: _STORAGE_BUS_TYPE = 3; +pub const _STORAGE_BUS_TYPE_BusType1394: _STORAGE_BUS_TYPE = 4; +pub const _STORAGE_BUS_TYPE_BusTypeSsa: _STORAGE_BUS_TYPE = 5; +pub const _STORAGE_BUS_TYPE_BusTypeFibre: _STORAGE_BUS_TYPE = 6; +pub const _STORAGE_BUS_TYPE_BusTypeUsb: _STORAGE_BUS_TYPE = 7; +pub const _STORAGE_BUS_TYPE_BusTypeRAID: _STORAGE_BUS_TYPE = 8; +pub const _STORAGE_BUS_TYPE_BusTypeiScsi: _STORAGE_BUS_TYPE = 9; +pub const _STORAGE_BUS_TYPE_BusTypeSas: _STORAGE_BUS_TYPE = 10; +pub const _STORAGE_BUS_TYPE_BusTypeSata: _STORAGE_BUS_TYPE = 11; +pub const _STORAGE_BUS_TYPE_BusTypeSd: _STORAGE_BUS_TYPE = 12; +pub const _STORAGE_BUS_TYPE_BusTypeMmc: _STORAGE_BUS_TYPE = 13; +pub const _STORAGE_BUS_TYPE_BusTypeVirtual: _STORAGE_BUS_TYPE = 14; +pub const _STORAGE_BUS_TYPE_BusTypeFileBackedVirtual: _STORAGE_BUS_TYPE = 15; +pub const _STORAGE_BUS_TYPE_BusTypeSpaces: _STORAGE_BUS_TYPE = 16; +pub const _STORAGE_BUS_TYPE_BusTypeNvme: _STORAGE_BUS_TYPE = 17; +pub const _STORAGE_BUS_TYPE_BusTypeSCM: _STORAGE_BUS_TYPE = 18; +pub const _STORAGE_BUS_TYPE_BusTypeUfs: _STORAGE_BUS_TYPE = 19; +pub const _STORAGE_BUS_TYPE_BusTypeMax: _STORAGE_BUS_TYPE = 20; +pub const _STORAGE_BUS_TYPE_BusTypeMaxReserved: _STORAGE_BUS_TYPE = 127; +pub type _STORAGE_BUS_TYPE = ::std::os::raw::c_int; +pub use self::_STORAGE_BUS_TYPE as STORAGE_BUS_TYPE; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _STORAGE_PREDICT_FAILURE { + pub PredictFailure: DWORD, + pub VendorSpecific: [BYTE; 512usize], +} +#[test] +fn bindgen_test_layout__STORAGE_PREDICT_FAILURE() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_PREDICT_FAILURE>(), + 516usize, + concat!("Size of: ", stringify!(_STORAGE_PREDICT_FAILURE)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_PREDICT_FAILURE>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_PREDICT_FAILURE)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PREDICT_FAILURE>())).PredictFailure as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PREDICT_FAILURE), + "::", + stringify!(PredictFailure) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PREDICT_FAILURE>())).VendorSpecific as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PREDICT_FAILURE), + "::", + stringify!(VendorSpecific) + ) + ); +} +pub type STORAGE_PREDICT_FAILURE = _STORAGE_PREDICT_FAILURE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_FAILURE_PREDICTION_CONFIG { + pub Version: DWORD, + pub Size: DWORD, + pub Set: BOOLEAN, + pub Enabled: BOOLEAN, + pub Reserved: WORD, +} +#[test] +fn bindgen_test_layout__STORAGE_FAILURE_PREDICTION_CONFIG() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_FAILURE_PREDICTION_CONFIG>(), + 12usize, + concat!("Size of: ", stringify!(_STORAGE_FAILURE_PREDICTION_CONFIG)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_FAILURE_PREDICTION_CONFIG>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_FAILURE_PREDICTION_CONFIG) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_FAILURE_PREDICTION_CONFIG>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_FAILURE_PREDICTION_CONFIG), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_FAILURE_PREDICTION_CONFIG>())).Size as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_FAILURE_PREDICTION_CONFIG), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_FAILURE_PREDICTION_CONFIG>())).Set as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_FAILURE_PREDICTION_CONFIG), + "::", + stringify!(Set) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_FAILURE_PREDICTION_CONFIG>())).Enabled as *const _ as usize + }, + 9usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_FAILURE_PREDICTION_CONFIG), + "::", + stringify!(Enabled) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_FAILURE_PREDICTION_CONFIG>())).Reserved as *const _ as usize + }, + 10usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_FAILURE_PREDICTION_CONFIG), + "::", + stringify!(Reserved) + ) + ); +} +pub type STORAGE_FAILURE_PREDICTION_CONFIG = _STORAGE_FAILURE_PREDICTION_CONFIG; +pub const _STORAGE_QUERY_TYPE_PropertyStandardQuery: _STORAGE_QUERY_TYPE = 0; +pub const _STORAGE_QUERY_TYPE_PropertyExistsQuery: _STORAGE_QUERY_TYPE = 1; +pub const _STORAGE_QUERY_TYPE_PropertyMaskQuery: _STORAGE_QUERY_TYPE = 2; +pub const _STORAGE_QUERY_TYPE_PropertyQueryMaxDefined: _STORAGE_QUERY_TYPE = 3; +pub type _STORAGE_QUERY_TYPE = ::std::os::raw::c_int; +pub use self::_STORAGE_QUERY_TYPE as STORAGE_QUERY_TYPE; +pub const _STORAGE_SET_TYPE_PropertyStandardSet: _STORAGE_SET_TYPE = 0; +pub const _STORAGE_SET_TYPE_PropertyExistsSet: _STORAGE_SET_TYPE = 1; +pub const _STORAGE_SET_TYPE_PropertySetMaxDefined: _STORAGE_SET_TYPE = 2; +pub type _STORAGE_SET_TYPE = ::std::os::raw::c_int; +pub use self::_STORAGE_SET_TYPE as STORAGE_SET_TYPE; +pub const _STORAGE_PROPERTY_ID_StorageDeviceProperty: _STORAGE_PROPERTY_ID = 0; +pub const _STORAGE_PROPERTY_ID_StorageAdapterProperty: _STORAGE_PROPERTY_ID = 1; +pub const _STORAGE_PROPERTY_ID_StorageDeviceIdProperty: _STORAGE_PROPERTY_ID = 2; +pub const _STORAGE_PROPERTY_ID_StorageDeviceUniqueIdProperty: _STORAGE_PROPERTY_ID = 3; +pub const _STORAGE_PROPERTY_ID_StorageDeviceWriteCacheProperty: _STORAGE_PROPERTY_ID = 4; +pub const _STORAGE_PROPERTY_ID_StorageMiniportProperty: _STORAGE_PROPERTY_ID = 5; +pub const _STORAGE_PROPERTY_ID_StorageAccessAlignmentProperty: _STORAGE_PROPERTY_ID = 6; +pub const _STORAGE_PROPERTY_ID_StorageDeviceSeekPenaltyProperty: _STORAGE_PROPERTY_ID = 7; +pub const _STORAGE_PROPERTY_ID_StorageDeviceTrimProperty: _STORAGE_PROPERTY_ID = 8; +pub const _STORAGE_PROPERTY_ID_StorageDeviceWriteAggregationProperty: _STORAGE_PROPERTY_ID = 9; +pub const _STORAGE_PROPERTY_ID_StorageDeviceDeviceTelemetryProperty: _STORAGE_PROPERTY_ID = 10; +pub const _STORAGE_PROPERTY_ID_StorageDeviceLBProvisioningProperty: _STORAGE_PROPERTY_ID = 11; +pub const _STORAGE_PROPERTY_ID_StorageDevicePowerProperty: _STORAGE_PROPERTY_ID = 12; +pub const _STORAGE_PROPERTY_ID_StorageDeviceCopyOffloadProperty: _STORAGE_PROPERTY_ID = 13; +pub const _STORAGE_PROPERTY_ID_StorageDeviceResiliencyProperty: _STORAGE_PROPERTY_ID = 14; +pub const _STORAGE_PROPERTY_ID_StorageDeviceMediumProductType: _STORAGE_PROPERTY_ID = 15; +pub const _STORAGE_PROPERTY_ID_StorageAdapterRpmbProperty: _STORAGE_PROPERTY_ID = 16; +pub const _STORAGE_PROPERTY_ID_StorageAdapterCryptoProperty: _STORAGE_PROPERTY_ID = 17; +pub const _STORAGE_PROPERTY_ID_StorageDeviceIoCapabilityProperty: _STORAGE_PROPERTY_ID = 48; +pub const _STORAGE_PROPERTY_ID_StorageAdapterProtocolSpecificProperty: _STORAGE_PROPERTY_ID = 49; +pub const _STORAGE_PROPERTY_ID_StorageDeviceProtocolSpecificProperty: _STORAGE_PROPERTY_ID = 50; +pub const _STORAGE_PROPERTY_ID_StorageAdapterTemperatureProperty: _STORAGE_PROPERTY_ID = 51; +pub const _STORAGE_PROPERTY_ID_StorageDeviceTemperatureProperty: _STORAGE_PROPERTY_ID = 52; +pub const _STORAGE_PROPERTY_ID_StorageAdapterPhysicalTopologyProperty: _STORAGE_PROPERTY_ID = 53; +pub const _STORAGE_PROPERTY_ID_StorageDevicePhysicalTopologyProperty: _STORAGE_PROPERTY_ID = 54; +pub const _STORAGE_PROPERTY_ID_StorageDeviceAttributesProperty: _STORAGE_PROPERTY_ID = 55; +pub const _STORAGE_PROPERTY_ID_StorageDeviceManagementStatus: _STORAGE_PROPERTY_ID = 56; +pub const _STORAGE_PROPERTY_ID_StorageAdapterSerialNumberProperty: _STORAGE_PROPERTY_ID = 57; +pub const _STORAGE_PROPERTY_ID_StorageDeviceLocationProperty: _STORAGE_PROPERTY_ID = 58; +pub const _STORAGE_PROPERTY_ID_StorageDeviceNumaProperty: _STORAGE_PROPERTY_ID = 59; +pub const _STORAGE_PROPERTY_ID_StorageDeviceZonedDeviceProperty: _STORAGE_PROPERTY_ID = 60; +pub const _STORAGE_PROPERTY_ID_StorageDeviceUnsafeShutdownCount: _STORAGE_PROPERTY_ID = 61; +pub const _STORAGE_PROPERTY_ID_StorageDeviceEnduranceProperty: _STORAGE_PROPERTY_ID = 62; +pub type _STORAGE_PROPERTY_ID = ::std::os::raw::c_int; +pub use self::_STORAGE_PROPERTY_ID as STORAGE_PROPERTY_ID; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_PROPERTY_QUERY { + pub PropertyId: STORAGE_PROPERTY_ID, + pub QueryType: STORAGE_QUERY_TYPE, + pub AdditionalParameters: [BYTE; 1usize], +} +#[test] +fn bindgen_test_layout__STORAGE_PROPERTY_QUERY() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_PROPERTY_QUERY>(), + 12usize, + concat!("Size of: ", stringify!(_STORAGE_PROPERTY_QUERY)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_PROPERTY_QUERY>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_PROPERTY_QUERY)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_PROPERTY_QUERY>())).PropertyId as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROPERTY_QUERY), + "::", + stringify!(PropertyId) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_PROPERTY_QUERY>())).QueryType as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROPERTY_QUERY), + "::", + stringify!(QueryType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROPERTY_QUERY>())).AdditionalParameters as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROPERTY_QUERY), + "::", + stringify!(AdditionalParameters) + ) + ); +} +pub type STORAGE_PROPERTY_QUERY = _STORAGE_PROPERTY_QUERY; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_PROPERTY_SET { + pub PropertyId: STORAGE_PROPERTY_ID, + pub SetType: STORAGE_SET_TYPE, + pub AdditionalParameters: [BYTE; 1usize], +} +#[test] +fn bindgen_test_layout__STORAGE_PROPERTY_SET() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_PROPERTY_SET>(), + 12usize, + concat!("Size of: ", stringify!(_STORAGE_PROPERTY_SET)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_PROPERTY_SET>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_PROPERTY_SET)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_PROPERTY_SET>())).PropertyId as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROPERTY_SET), + "::", + stringify!(PropertyId) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_PROPERTY_SET>())).SetType as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROPERTY_SET), + "::", + stringify!(SetType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROPERTY_SET>())).AdditionalParameters as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROPERTY_SET), + "::", + stringify!(AdditionalParameters) + ) + ); +} +pub type STORAGE_PROPERTY_SET = _STORAGE_PROPERTY_SET; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_DESCRIPTOR_HEADER { + pub Version: DWORD, + pub Size: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_DESCRIPTOR_HEADER() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_DESCRIPTOR_HEADER>(), + 8usize, + concat!("Size of: ", stringify!(_STORAGE_DESCRIPTOR_HEADER)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_DESCRIPTOR_HEADER>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_DESCRIPTOR_HEADER)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DESCRIPTOR_HEADER>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DESCRIPTOR_HEADER), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DESCRIPTOR_HEADER>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DESCRIPTOR_HEADER), + "::", + stringify!(Size) + ) + ); +} +pub type STORAGE_DESCRIPTOR_HEADER = _STORAGE_DESCRIPTOR_HEADER; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_DEVICE_DESCRIPTOR { + pub Version: DWORD, + pub Size: DWORD, + pub DeviceType: BYTE, + pub DeviceTypeModifier: BYTE, + pub RemovableMedia: BOOLEAN, + pub CommandQueueing: BOOLEAN, + pub VendorIdOffset: DWORD, + pub ProductIdOffset: DWORD, + pub ProductRevisionOffset: DWORD, + pub SerialNumberOffset: DWORD, + pub BusType: STORAGE_BUS_TYPE, + pub RawPropertiesLength: DWORD, + pub RawDeviceProperties: [BYTE; 1usize], +} +#[test] +fn bindgen_test_layout__STORAGE_DEVICE_DESCRIPTOR() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_DEVICE_DESCRIPTOR>(), + 40usize, + concat!("Size of: ", stringify!(_STORAGE_DEVICE_DESCRIPTOR)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_DEVICE_DESCRIPTOR>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_DEVICE_DESCRIPTOR)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DEVICE_DESCRIPTOR>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_DESCRIPTOR), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DEVICE_DESCRIPTOR>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_DESCRIPTOR), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_DESCRIPTOR>())).DeviceType as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_DESCRIPTOR), + "::", + stringify!(DeviceType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_DESCRIPTOR>())).DeviceTypeModifier as *const _ as usize + }, + 9usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_DESCRIPTOR), + "::", + stringify!(DeviceTypeModifier) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_DESCRIPTOR>())).RemovableMedia as *const _ as usize + }, + 10usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_DESCRIPTOR), + "::", + stringify!(RemovableMedia) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_DESCRIPTOR>())).CommandQueueing as *const _ as usize + }, + 11usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_DESCRIPTOR), + "::", + stringify!(CommandQueueing) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_DESCRIPTOR>())).VendorIdOffset as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_DESCRIPTOR), + "::", + stringify!(VendorIdOffset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_DESCRIPTOR>())).ProductIdOffset as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_DESCRIPTOR), + "::", + stringify!(ProductIdOffset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_DESCRIPTOR>())).ProductRevisionOffset as *const _ + as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_DESCRIPTOR), + "::", + stringify!(ProductRevisionOffset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_DESCRIPTOR>())).SerialNumberOffset as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_DESCRIPTOR), + "::", + stringify!(SerialNumberOffset) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DEVICE_DESCRIPTOR>())).BusType as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_DESCRIPTOR), + "::", + stringify!(BusType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_DESCRIPTOR>())).RawPropertiesLength as *const _ + as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_DESCRIPTOR), + "::", + stringify!(RawPropertiesLength) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_DESCRIPTOR>())).RawDeviceProperties as *const _ + as usize + }, + 36usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_DESCRIPTOR), + "::", + stringify!(RawDeviceProperties) + ) + ); +} +pub type STORAGE_DEVICE_DESCRIPTOR = _STORAGE_DEVICE_DESCRIPTOR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_ADAPTER_DESCRIPTOR { + pub Version: DWORD, + pub Size: DWORD, + pub MaximumTransferLength: DWORD, + pub MaximumPhysicalPages: DWORD, + pub AlignmentMask: DWORD, + pub AdapterUsesPio: BOOLEAN, + pub AdapterScansDown: BOOLEAN, + pub CommandQueueing: BOOLEAN, + pub AcceleratedTransfer: BOOLEAN, + pub BusType: BYTE, + pub BusMajorVersion: WORD, + pub BusMinorVersion: WORD, + pub SrbType: BYTE, + pub AddressType: BYTE, +} +#[test] +fn bindgen_test_layout__STORAGE_ADAPTER_DESCRIPTOR() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_ADAPTER_DESCRIPTOR>(), + 32usize, + concat!("Size of: ", stringify!(_STORAGE_ADAPTER_DESCRIPTOR)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_ADAPTER_DESCRIPTOR>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_ADAPTER_DESCRIPTOR)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_ADAPTER_DESCRIPTOR>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ADAPTER_DESCRIPTOR), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_ADAPTER_DESCRIPTOR>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ADAPTER_DESCRIPTOR), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ADAPTER_DESCRIPTOR>())).MaximumTransferLength as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ADAPTER_DESCRIPTOR), + "::", + stringify!(MaximumTransferLength) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ADAPTER_DESCRIPTOR>())).MaximumPhysicalPages as *const _ + as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ADAPTER_DESCRIPTOR), + "::", + stringify!(MaximumPhysicalPages) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ADAPTER_DESCRIPTOR>())).AlignmentMask as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ADAPTER_DESCRIPTOR), + "::", + stringify!(AlignmentMask) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ADAPTER_DESCRIPTOR>())).AdapterUsesPio as *const _ as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ADAPTER_DESCRIPTOR), + "::", + stringify!(AdapterUsesPio) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ADAPTER_DESCRIPTOR>())).AdapterScansDown as *const _ as usize + }, + 21usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ADAPTER_DESCRIPTOR), + "::", + stringify!(AdapterScansDown) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ADAPTER_DESCRIPTOR>())).CommandQueueing as *const _ as usize + }, + 22usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ADAPTER_DESCRIPTOR), + "::", + stringify!(CommandQueueing) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ADAPTER_DESCRIPTOR>())).AcceleratedTransfer as *const _ + as usize + }, + 23usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ADAPTER_DESCRIPTOR), + "::", + stringify!(AcceleratedTransfer) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_ADAPTER_DESCRIPTOR>())).BusType as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ADAPTER_DESCRIPTOR), + "::", + stringify!(BusType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ADAPTER_DESCRIPTOR>())).BusMajorVersion as *const _ as usize + }, + 26usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ADAPTER_DESCRIPTOR), + "::", + stringify!(BusMajorVersion) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ADAPTER_DESCRIPTOR>())).BusMinorVersion as *const _ as usize + }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ADAPTER_DESCRIPTOR), + "::", + stringify!(BusMinorVersion) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_ADAPTER_DESCRIPTOR>())).SrbType as *const _ as usize }, + 30usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ADAPTER_DESCRIPTOR), + "::", + stringify!(SrbType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ADAPTER_DESCRIPTOR>())).AddressType as *const _ as usize + }, + 31usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ADAPTER_DESCRIPTOR), + "::", + stringify!(AddressType) + ) + ); +} +pub type STORAGE_ADAPTER_DESCRIPTOR = _STORAGE_ADAPTER_DESCRIPTOR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR { + pub Version: DWORD, + pub Size: DWORD, + pub BytesPerCacheLine: DWORD, + pub BytesOffsetForCacheAlignment: DWORD, + pub BytesPerLogicalSector: DWORD, + pub BytesPerPhysicalSector: DWORD, + pub BytesOffsetForSectorAlignment: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR>(), + 28usize, + concat!( + "Size of: ", + stringify!(_STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR>())).Size as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR>())).BytesPerCacheLine as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR), + "::", + stringify!(BytesPerCacheLine) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR>())).BytesOffsetForCacheAlignment + as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR), + "::", + stringify!(BytesOffsetForCacheAlignment) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR>())).BytesPerLogicalSector + as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR), + "::", + stringify!(BytesPerLogicalSector) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR>())).BytesPerPhysicalSector + as *const _ as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR), + "::", + stringify!(BytesPerPhysicalSector) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR>())).BytesOffsetForSectorAlignment + as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR), + "::", + stringify!(BytesOffsetForSectorAlignment) + ) + ); +} +pub type STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR = _STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_MEDIUM_PRODUCT_TYPE_DESCRIPTOR { + pub Version: DWORD, + pub Size: DWORD, + pub MediumProductType: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_MEDIUM_PRODUCT_TYPE_DESCRIPTOR() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_MEDIUM_PRODUCT_TYPE_DESCRIPTOR>(), + 12usize, + concat!( + "Size of: ", + stringify!(_STORAGE_MEDIUM_PRODUCT_TYPE_DESCRIPTOR) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_MEDIUM_PRODUCT_TYPE_DESCRIPTOR>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_MEDIUM_PRODUCT_TYPE_DESCRIPTOR) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_MEDIUM_PRODUCT_TYPE_DESCRIPTOR>())).Version as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_MEDIUM_PRODUCT_TYPE_DESCRIPTOR), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_MEDIUM_PRODUCT_TYPE_DESCRIPTOR>())).Size as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_MEDIUM_PRODUCT_TYPE_DESCRIPTOR), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_MEDIUM_PRODUCT_TYPE_DESCRIPTOR>())).MediumProductType + as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_MEDIUM_PRODUCT_TYPE_DESCRIPTOR), + "::", + stringify!(MediumProductType) + ) + ); +} +pub type STORAGE_MEDIUM_PRODUCT_TYPE_DESCRIPTOR = _STORAGE_MEDIUM_PRODUCT_TYPE_DESCRIPTOR; +pub const _STORAGE_PORT_CODE_SET_StoragePortCodeSetReserved: _STORAGE_PORT_CODE_SET = 0; +pub const _STORAGE_PORT_CODE_SET_StoragePortCodeSetStorport: _STORAGE_PORT_CODE_SET = 1; +pub const _STORAGE_PORT_CODE_SET_StoragePortCodeSetSCSIport: _STORAGE_PORT_CODE_SET = 2; +pub const _STORAGE_PORT_CODE_SET_StoragePortCodeSetSpaceport: _STORAGE_PORT_CODE_SET = 3; +pub const _STORAGE_PORT_CODE_SET_StoragePortCodeSetATAport: _STORAGE_PORT_CODE_SET = 4; +pub const _STORAGE_PORT_CODE_SET_StoragePortCodeSetUSBport: _STORAGE_PORT_CODE_SET = 5; +pub const _STORAGE_PORT_CODE_SET_StoragePortCodeSetSBP2port: _STORAGE_PORT_CODE_SET = 6; +pub const _STORAGE_PORT_CODE_SET_StoragePortCodeSetSDport: _STORAGE_PORT_CODE_SET = 7; +pub type _STORAGE_PORT_CODE_SET = ::std::os::raw::c_int; +pub use self::_STORAGE_PORT_CODE_SET as STORAGE_PORT_CODE_SET; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_MINIPORT_DESCRIPTOR { + pub Version: DWORD, + pub Size: DWORD, + pub Portdriver: STORAGE_PORT_CODE_SET, + pub LUNResetSupported: BOOLEAN, + pub TargetResetSupported: BOOLEAN, + pub IoTimeoutValue: WORD, + pub ExtraIoInfoSupported: BOOLEAN, + pub Reserved0: [BYTE; 3usize], + pub Reserved1: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_MINIPORT_DESCRIPTOR() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_MINIPORT_DESCRIPTOR>(), + 24usize, + concat!("Size of: ", stringify!(_STORAGE_MINIPORT_DESCRIPTOR)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_MINIPORT_DESCRIPTOR>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_MINIPORT_DESCRIPTOR)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_MINIPORT_DESCRIPTOR>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_MINIPORT_DESCRIPTOR), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_MINIPORT_DESCRIPTOR>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_MINIPORT_DESCRIPTOR), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_MINIPORT_DESCRIPTOR>())).Portdriver as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_MINIPORT_DESCRIPTOR), + "::", + stringify!(Portdriver) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_MINIPORT_DESCRIPTOR>())).LUNResetSupported as *const _ + as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_MINIPORT_DESCRIPTOR), + "::", + stringify!(LUNResetSupported) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_MINIPORT_DESCRIPTOR>())).TargetResetSupported as *const _ + as usize + }, + 13usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_MINIPORT_DESCRIPTOR), + "::", + stringify!(TargetResetSupported) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_MINIPORT_DESCRIPTOR>())).IoTimeoutValue as *const _ as usize + }, + 14usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_MINIPORT_DESCRIPTOR), + "::", + stringify!(IoTimeoutValue) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_MINIPORT_DESCRIPTOR>())).ExtraIoInfoSupported as *const _ + as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_MINIPORT_DESCRIPTOR), + "::", + stringify!(ExtraIoInfoSupported) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_MINIPORT_DESCRIPTOR>())).Reserved0 as *const _ as usize + }, + 17usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_MINIPORT_DESCRIPTOR), + "::", + stringify!(Reserved0) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_MINIPORT_DESCRIPTOR>())).Reserved1 as *const _ as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_MINIPORT_DESCRIPTOR), + "::", + stringify!(Reserved1) + ) + ); +} +pub type STORAGE_MINIPORT_DESCRIPTOR = _STORAGE_MINIPORT_DESCRIPTOR; +pub const _STORAGE_IDENTIFIER_CODE_SET_StorageIdCodeSetReserved: _STORAGE_IDENTIFIER_CODE_SET = 0; +pub const _STORAGE_IDENTIFIER_CODE_SET_StorageIdCodeSetBinary: _STORAGE_IDENTIFIER_CODE_SET = 1; +pub const _STORAGE_IDENTIFIER_CODE_SET_StorageIdCodeSetAscii: _STORAGE_IDENTIFIER_CODE_SET = 2; +pub const _STORAGE_IDENTIFIER_CODE_SET_StorageIdCodeSetUtf8: _STORAGE_IDENTIFIER_CODE_SET = 3; +pub type _STORAGE_IDENTIFIER_CODE_SET = ::std::os::raw::c_int; +pub use self::_STORAGE_IDENTIFIER_CODE_SET as STORAGE_IDENTIFIER_CODE_SET; +pub const _STORAGE_IDENTIFIER_TYPE_StorageIdTypeVendorSpecific: _STORAGE_IDENTIFIER_TYPE = 0; +pub const _STORAGE_IDENTIFIER_TYPE_StorageIdTypeVendorId: _STORAGE_IDENTIFIER_TYPE = 1; +pub const _STORAGE_IDENTIFIER_TYPE_StorageIdTypeEUI64: _STORAGE_IDENTIFIER_TYPE = 2; +pub const _STORAGE_IDENTIFIER_TYPE_StorageIdTypeFCPHName: _STORAGE_IDENTIFIER_TYPE = 3; +pub const _STORAGE_IDENTIFIER_TYPE_StorageIdTypePortRelative: _STORAGE_IDENTIFIER_TYPE = 4; +pub const _STORAGE_IDENTIFIER_TYPE_StorageIdTypeTargetPortGroup: _STORAGE_IDENTIFIER_TYPE = 5; +pub const _STORAGE_IDENTIFIER_TYPE_StorageIdTypeLogicalUnitGroup: _STORAGE_IDENTIFIER_TYPE = 6; +pub const _STORAGE_IDENTIFIER_TYPE_StorageIdTypeMD5LogicalUnitIdentifier: _STORAGE_IDENTIFIER_TYPE = + 7; +pub const _STORAGE_IDENTIFIER_TYPE_StorageIdTypeScsiNameString: _STORAGE_IDENTIFIER_TYPE = 8; +pub type _STORAGE_IDENTIFIER_TYPE = ::std::os::raw::c_int; +pub use self::_STORAGE_IDENTIFIER_TYPE as STORAGE_IDENTIFIER_TYPE; +pub const _STORAGE_ID_NAA_FORMAT_StorageIdNAAFormatIEEEExtended: _STORAGE_ID_NAA_FORMAT = 2; +pub const _STORAGE_ID_NAA_FORMAT_StorageIdNAAFormatIEEERegistered: _STORAGE_ID_NAA_FORMAT = 3; +pub const _STORAGE_ID_NAA_FORMAT_StorageIdNAAFormatIEEEERegisteredExtended: _STORAGE_ID_NAA_FORMAT = + 5; +pub type _STORAGE_ID_NAA_FORMAT = ::std::os::raw::c_int; +pub use self::_STORAGE_ID_NAA_FORMAT as STORAGE_ID_NAA_FORMAT; +pub const _STORAGE_ASSOCIATION_TYPE_StorageIdAssocDevice: _STORAGE_ASSOCIATION_TYPE = 0; +pub const _STORAGE_ASSOCIATION_TYPE_StorageIdAssocPort: _STORAGE_ASSOCIATION_TYPE = 1; +pub const _STORAGE_ASSOCIATION_TYPE_StorageIdAssocTarget: _STORAGE_ASSOCIATION_TYPE = 2; +pub type _STORAGE_ASSOCIATION_TYPE = ::std::os::raw::c_int; +pub use self::_STORAGE_ASSOCIATION_TYPE as STORAGE_ASSOCIATION_TYPE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_IDENTIFIER { + pub CodeSet: STORAGE_IDENTIFIER_CODE_SET, + pub Type: STORAGE_IDENTIFIER_TYPE, + pub IdentifierSize: WORD, + pub NextOffset: WORD, + pub Association: STORAGE_ASSOCIATION_TYPE, + pub Identifier: [BYTE; 1usize], +} +#[test] +fn bindgen_test_layout__STORAGE_IDENTIFIER() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_IDENTIFIER>(), + 20usize, + concat!("Size of: ", stringify!(_STORAGE_IDENTIFIER)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_IDENTIFIER>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_IDENTIFIER)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_IDENTIFIER>())).CodeSet as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_IDENTIFIER), + "::", + stringify!(CodeSet) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_IDENTIFIER>())).Type as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_IDENTIFIER), + "::", + stringify!(Type) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_IDENTIFIER>())).IdentifierSize as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_IDENTIFIER), + "::", + stringify!(IdentifierSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_IDENTIFIER>())).NextOffset as *const _ as usize }, + 10usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_IDENTIFIER), + "::", + stringify!(NextOffset) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_IDENTIFIER>())).Association as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_IDENTIFIER), + "::", + stringify!(Association) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_IDENTIFIER>())).Identifier as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_IDENTIFIER), + "::", + stringify!(Identifier) + ) + ); +} +pub type STORAGE_IDENTIFIER = _STORAGE_IDENTIFIER; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_DEVICE_ID_DESCRIPTOR { + pub Version: DWORD, + pub Size: DWORD, + pub NumberOfIdentifiers: DWORD, + pub Identifiers: [BYTE; 1usize], +} +#[test] +fn bindgen_test_layout__STORAGE_DEVICE_ID_DESCRIPTOR() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_DEVICE_ID_DESCRIPTOR>(), + 16usize, + concat!("Size of: ", stringify!(_STORAGE_DEVICE_ID_DESCRIPTOR)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_DEVICE_ID_DESCRIPTOR>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_DEVICE_ID_DESCRIPTOR)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_ID_DESCRIPTOR>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_ID_DESCRIPTOR), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DEVICE_ID_DESCRIPTOR>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_ID_DESCRIPTOR), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_ID_DESCRIPTOR>())).NumberOfIdentifiers as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_ID_DESCRIPTOR), + "::", + stringify!(NumberOfIdentifiers) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_ID_DESCRIPTOR>())).Identifiers as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_ID_DESCRIPTOR), + "::", + stringify!(Identifiers) + ) + ); +} +pub type STORAGE_DEVICE_ID_DESCRIPTOR = _STORAGE_DEVICE_ID_DESCRIPTOR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_LB_PROVISIONING_MAP_RESOURCES { + pub Size: DWORD, + pub Version: DWORD, + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>, + pub Reserved1: [BYTE; 3usize], + pub _bitfield_2: __BindgenBitfieldUnit<[u8; 1usize], u8>, + pub Reserved3: [BYTE; 3usize], + pub AvailableMappingResources: DWORDLONG, + pub UsedMappingResources: DWORDLONG, +} +#[test] +fn bindgen_test_layout__STORAGE_LB_PROVISIONING_MAP_RESOURCES() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_LB_PROVISIONING_MAP_RESOURCES>(), + 32usize, + concat!( + "Size of: ", + stringify!(_STORAGE_LB_PROVISIONING_MAP_RESOURCES) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_LB_PROVISIONING_MAP_RESOURCES>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_LB_PROVISIONING_MAP_RESOURCES) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_LB_PROVISIONING_MAP_RESOURCES>())).Size as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_LB_PROVISIONING_MAP_RESOURCES), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_LB_PROVISIONING_MAP_RESOURCES>())).Version as *const _ + as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_LB_PROVISIONING_MAP_RESOURCES), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_LB_PROVISIONING_MAP_RESOURCES>())).Reserved1 as *const _ + as usize + }, + 9usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_LB_PROVISIONING_MAP_RESOURCES), + "::", + stringify!(Reserved1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_LB_PROVISIONING_MAP_RESOURCES>())).Reserved3 as *const _ + as usize + }, + 13usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_LB_PROVISIONING_MAP_RESOURCES), + "::", + stringify!(Reserved3) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_LB_PROVISIONING_MAP_RESOURCES>())).AvailableMappingResources + as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_LB_PROVISIONING_MAP_RESOURCES), + "::", + stringify!(AvailableMappingResources) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_LB_PROVISIONING_MAP_RESOURCES>())).UsedMappingResources + as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_LB_PROVISIONING_MAP_RESOURCES), + "::", + stringify!(UsedMappingResources) + ) + ); +} +impl _STORAGE_LB_PROVISIONING_MAP_RESOURCES { + #[inline] + pub fn AvailableMappingResourcesValid(&self) -> BYTE { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_AvailableMappingResourcesValid(&mut self, val: BYTE) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn UsedMappingResourcesValid(&self) -> BYTE { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_UsedMappingResourcesValid(&mut self, val: BYTE) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn Reserved0(&self) -> BYTE { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 6u8) as u8) } + } + #[inline] + pub fn set_Reserved0(&mut self, val: BYTE) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 6u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + AvailableMappingResourcesValid: BYTE, + UsedMappingResourcesValid: BYTE, + Reserved0: BYTE, + ) -> __BindgenBitfieldUnit<[u8; 1usize], u8> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize], u8> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let AvailableMappingResourcesValid: u8 = + unsafe { ::std::mem::transmute(AvailableMappingResourcesValid) }; + AvailableMappingResourcesValid as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let UsedMappingResourcesValid: u8 = + unsafe { ::std::mem::transmute(UsedMappingResourcesValid) }; + UsedMappingResourcesValid as u64 + }); + __bindgen_bitfield_unit.set(2usize, 6u8, { + let Reserved0: u8 = unsafe { ::std::mem::transmute(Reserved0) }; + Reserved0 as u64 + }); + __bindgen_bitfield_unit + } + #[inline] + pub fn AvailableMappingResourcesScope(&self) -> BYTE { + unsafe { ::std::mem::transmute(self._bitfield_2.get(0usize, 2u8) as u8) } + } + #[inline] + pub fn set_AvailableMappingResourcesScope(&mut self, val: BYTE) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_2.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn UsedMappingResourcesScope(&self) -> BYTE { + unsafe { ::std::mem::transmute(self._bitfield_2.get(2usize, 2u8) as u8) } + } + #[inline] + pub fn set_UsedMappingResourcesScope(&mut self, val: BYTE) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_2.set(2usize, 2u8, val as u64) + } + } + #[inline] + pub fn Reserved2(&self) -> BYTE { + unsafe { ::std::mem::transmute(self._bitfield_2.get(4usize, 4u8) as u8) } + } + #[inline] + pub fn set_Reserved2(&mut self, val: BYTE) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_2.set(4usize, 4u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_2( + AvailableMappingResourcesScope: BYTE, + UsedMappingResourcesScope: BYTE, + Reserved2: BYTE, + ) -> __BindgenBitfieldUnit<[u8; 1usize], u8> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize], u8> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let AvailableMappingResourcesScope: u8 = + unsafe { ::std::mem::transmute(AvailableMappingResourcesScope) }; + AvailableMappingResourcesScope as u64 + }); + __bindgen_bitfield_unit.set(2usize, 2u8, { + let UsedMappingResourcesScope: u8 = + unsafe { ::std::mem::transmute(UsedMappingResourcesScope) }; + UsedMappingResourcesScope as u64 + }); + __bindgen_bitfield_unit.set(4usize, 4u8, { + let Reserved2: u8 = unsafe { ::std::mem::transmute(Reserved2) }; + Reserved2 as u64 + }); + __bindgen_bitfield_unit + } +} +pub type STORAGE_LB_PROVISIONING_MAP_RESOURCES = _STORAGE_LB_PROVISIONING_MAP_RESOURCES; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_DEVICE_RESILIENCY_DESCRIPTOR { + pub Version: DWORD, + pub Size: DWORD, + pub NameOffset: DWORD, + pub NumberOfLogicalCopies: DWORD, + pub NumberOfPhysicalCopies: DWORD, + pub PhysicalDiskRedundancy: DWORD, + pub NumberOfColumns: DWORD, + pub Interleave: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_DEVICE_RESILIENCY_DESCRIPTOR() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_DEVICE_RESILIENCY_DESCRIPTOR>(), + 32usize, + concat!( + "Size of: ", + stringify!(_STORAGE_DEVICE_RESILIENCY_DESCRIPTOR) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_DEVICE_RESILIENCY_DESCRIPTOR>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_DEVICE_RESILIENCY_DESCRIPTOR) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_RESILIENCY_DESCRIPTOR>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_RESILIENCY_DESCRIPTOR), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_RESILIENCY_DESCRIPTOR>())).Size as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_RESILIENCY_DESCRIPTOR), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_RESILIENCY_DESCRIPTOR>())).NameOffset as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_RESILIENCY_DESCRIPTOR), + "::", + stringify!(NameOffset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_RESILIENCY_DESCRIPTOR>())).NumberOfLogicalCopies + as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_RESILIENCY_DESCRIPTOR), + "::", + stringify!(NumberOfLogicalCopies) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_RESILIENCY_DESCRIPTOR>())).NumberOfPhysicalCopies + as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_RESILIENCY_DESCRIPTOR), + "::", + stringify!(NumberOfPhysicalCopies) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_RESILIENCY_DESCRIPTOR>())).PhysicalDiskRedundancy + as *const _ as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_RESILIENCY_DESCRIPTOR), + "::", + stringify!(PhysicalDiskRedundancy) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_RESILIENCY_DESCRIPTOR>())).NumberOfColumns as *const _ + as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_RESILIENCY_DESCRIPTOR), + "::", + stringify!(NumberOfColumns) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_RESILIENCY_DESCRIPTOR>())).Interleave as *const _ + as usize + }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_RESILIENCY_DESCRIPTOR), + "::", + stringify!(Interleave) + ) + ); +} +pub type STORAGE_DEVICE_RESILIENCY_DESCRIPTOR = _STORAGE_DEVICE_RESILIENCY_DESCRIPTOR; +pub const _STORAGE_RPMB_FRAME_TYPE_StorageRpmbFrameTypeUnknown: _STORAGE_RPMB_FRAME_TYPE = 0; +pub const _STORAGE_RPMB_FRAME_TYPE_StorageRpmbFrameTypeStandard: _STORAGE_RPMB_FRAME_TYPE = 1; +pub const _STORAGE_RPMB_FRAME_TYPE_StorageRpmbFrameTypeMax: _STORAGE_RPMB_FRAME_TYPE = 2; +pub type _STORAGE_RPMB_FRAME_TYPE = ::std::os::raw::c_int; +pub use self::_STORAGE_RPMB_FRAME_TYPE as STORAGE_RPMB_FRAME_TYPE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_RPMB_DESCRIPTOR { + pub Version: DWORD, + pub Size: DWORD, + pub SizeInBytes: DWORD, + pub MaxReliableWriteSizeInBytes: DWORD, + pub FrameFormat: STORAGE_RPMB_FRAME_TYPE, +} +#[test] +fn bindgen_test_layout__STORAGE_RPMB_DESCRIPTOR() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_RPMB_DESCRIPTOR>(), + 20usize, + concat!("Size of: ", stringify!(_STORAGE_RPMB_DESCRIPTOR)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_RPMB_DESCRIPTOR>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_RPMB_DESCRIPTOR)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_RPMB_DESCRIPTOR>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_RPMB_DESCRIPTOR), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_RPMB_DESCRIPTOR>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_RPMB_DESCRIPTOR), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_RPMB_DESCRIPTOR>())).SizeInBytes as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_RPMB_DESCRIPTOR), + "::", + stringify!(SizeInBytes) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_RPMB_DESCRIPTOR>())).MaxReliableWriteSizeInBytes as *const _ + as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_RPMB_DESCRIPTOR), + "::", + stringify!(MaxReliableWriteSizeInBytes) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_RPMB_DESCRIPTOR>())).FrameFormat as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_RPMB_DESCRIPTOR), + "::", + stringify!(FrameFormat) + ) + ); +} +pub type STORAGE_RPMB_DESCRIPTOR = _STORAGE_RPMB_DESCRIPTOR; +pub const _STORAGE_CRYPTO_ALGORITHM_ID_StorageCryptoAlgorithmUnknown: _STORAGE_CRYPTO_ALGORITHM_ID = + 0; +pub const _STORAGE_CRYPTO_ALGORITHM_ID_StorageCryptoAlgorithmXTSAES: _STORAGE_CRYPTO_ALGORITHM_ID = + 1; +pub const _STORAGE_CRYPTO_ALGORITHM_ID_StorageCryptoAlgorithmBitlockerAESCBC: + _STORAGE_CRYPTO_ALGORITHM_ID = 2; +pub const _STORAGE_CRYPTO_ALGORITHM_ID_StorageCryptoAlgorithmAESECB: _STORAGE_CRYPTO_ALGORITHM_ID = + 3; +pub const _STORAGE_CRYPTO_ALGORITHM_ID_StorageCryptoAlgorithmESSIVAESCBC: + _STORAGE_CRYPTO_ALGORITHM_ID = 4; +pub const _STORAGE_CRYPTO_ALGORITHM_ID_StorageCryptoAlgorithmMax: _STORAGE_CRYPTO_ALGORITHM_ID = 5; +pub type _STORAGE_CRYPTO_ALGORITHM_ID = ::std::os::raw::c_int; +pub use self::_STORAGE_CRYPTO_ALGORITHM_ID as STORAGE_CRYPTO_ALGORITHM_ID; +pub const _STORAGE_CRYPTO_KEY_SIZE_StorageCryptoKeySizeUnknown: _STORAGE_CRYPTO_KEY_SIZE = 0; +pub const _STORAGE_CRYPTO_KEY_SIZE_StorageCryptoKeySize128Bits: _STORAGE_CRYPTO_KEY_SIZE = 1; +pub const _STORAGE_CRYPTO_KEY_SIZE_StorageCryptoKeySize192Bits: _STORAGE_CRYPTO_KEY_SIZE = 2; +pub const _STORAGE_CRYPTO_KEY_SIZE_StorageCryptoKeySize256Bits: _STORAGE_CRYPTO_KEY_SIZE = 3; +pub const _STORAGE_CRYPTO_KEY_SIZE_StorageCryptoKeySize512Bits: _STORAGE_CRYPTO_KEY_SIZE = 4; +pub type _STORAGE_CRYPTO_KEY_SIZE = ::std::os::raw::c_int; +pub use self::_STORAGE_CRYPTO_KEY_SIZE as STORAGE_CRYPTO_KEY_SIZE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_CRYPTO_CAPABILITY { + pub Version: DWORD, + pub Size: DWORD, + pub CryptoCapabilityIndex: DWORD, + pub AlgorithmId: STORAGE_CRYPTO_ALGORITHM_ID, + pub KeySize: STORAGE_CRYPTO_KEY_SIZE, + pub DataUnitSizeBitmask: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_CRYPTO_CAPABILITY() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_CRYPTO_CAPABILITY>(), + 24usize, + concat!("Size of: ", stringify!(_STORAGE_CRYPTO_CAPABILITY)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_CRYPTO_CAPABILITY>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_CRYPTO_CAPABILITY)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_CRYPTO_CAPABILITY>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_CRYPTO_CAPABILITY), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_CRYPTO_CAPABILITY>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_CRYPTO_CAPABILITY), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_CRYPTO_CAPABILITY>())).CryptoCapabilityIndex as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_CRYPTO_CAPABILITY), + "::", + stringify!(CryptoCapabilityIndex) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_CRYPTO_CAPABILITY>())).AlgorithmId as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_CRYPTO_CAPABILITY), + "::", + stringify!(AlgorithmId) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_CRYPTO_CAPABILITY>())).KeySize as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_CRYPTO_CAPABILITY), + "::", + stringify!(KeySize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_CRYPTO_CAPABILITY>())).DataUnitSizeBitmask as *const _ + as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_CRYPTO_CAPABILITY), + "::", + stringify!(DataUnitSizeBitmask) + ) + ); +} +pub type STORAGE_CRYPTO_CAPABILITY = _STORAGE_CRYPTO_CAPABILITY; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_CRYPTO_DESCRIPTOR { + pub Version: DWORD, + pub Size: DWORD, + pub NumKeysSupported: DWORD, + pub NumCryptoCapabilities: DWORD, + pub CryptoCapabilities: [STORAGE_CRYPTO_CAPABILITY; 1usize], +} +#[test] +fn bindgen_test_layout__STORAGE_CRYPTO_DESCRIPTOR() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_CRYPTO_DESCRIPTOR>(), + 40usize, + concat!("Size of: ", stringify!(_STORAGE_CRYPTO_DESCRIPTOR)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_CRYPTO_DESCRIPTOR>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_CRYPTO_DESCRIPTOR)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_CRYPTO_DESCRIPTOR>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_CRYPTO_DESCRIPTOR), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_CRYPTO_DESCRIPTOR>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_CRYPTO_DESCRIPTOR), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_CRYPTO_DESCRIPTOR>())).NumKeysSupported as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_CRYPTO_DESCRIPTOR), + "::", + stringify!(NumKeysSupported) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_CRYPTO_DESCRIPTOR>())).NumCryptoCapabilities as *const _ + as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_CRYPTO_DESCRIPTOR), + "::", + stringify!(NumCryptoCapabilities) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_CRYPTO_DESCRIPTOR>())).CryptoCapabilities as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_CRYPTO_DESCRIPTOR), + "::", + stringify!(CryptoCapabilities) + ) + ); +} +pub type STORAGE_CRYPTO_DESCRIPTOR = _STORAGE_CRYPTO_DESCRIPTOR; +pub const _STORAGE_TIER_MEDIA_TYPE_StorageTierMediaTypeUnspecified: _STORAGE_TIER_MEDIA_TYPE = 0; +pub const _STORAGE_TIER_MEDIA_TYPE_StorageTierMediaTypeDisk: _STORAGE_TIER_MEDIA_TYPE = 1; +pub const _STORAGE_TIER_MEDIA_TYPE_StorageTierMediaTypeSsd: _STORAGE_TIER_MEDIA_TYPE = 2; +pub const _STORAGE_TIER_MEDIA_TYPE_StorageTierMediaTypeScm: _STORAGE_TIER_MEDIA_TYPE = 4; +pub const _STORAGE_TIER_MEDIA_TYPE_StorageTierMediaTypeMax: _STORAGE_TIER_MEDIA_TYPE = 5; +pub type _STORAGE_TIER_MEDIA_TYPE = ::std::os::raw::c_int; +pub use self::_STORAGE_TIER_MEDIA_TYPE as STORAGE_TIER_MEDIA_TYPE; +pub const _STORAGE_TIER_CLASS_StorageTierClassUnspecified: _STORAGE_TIER_CLASS = 0; +pub const _STORAGE_TIER_CLASS_StorageTierClassCapacity: _STORAGE_TIER_CLASS = 1; +pub const _STORAGE_TIER_CLASS_StorageTierClassPerformance: _STORAGE_TIER_CLASS = 2; +pub const _STORAGE_TIER_CLASS_StorageTierClassMax: _STORAGE_TIER_CLASS = 3; +pub type _STORAGE_TIER_CLASS = ::std::os::raw::c_int; +pub use self::_STORAGE_TIER_CLASS as STORAGE_TIER_CLASS; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _STORAGE_TIER { + pub Id: GUID, + pub Name: [WCHAR; 256usize], + pub Description: [WCHAR; 256usize], + pub Flags: DWORDLONG, + pub ProvisionedCapacity: DWORDLONG, + pub MediaType: STORAGE_TIER_MEDIA_TYPE, + pub Class: STORAGE_TIER_CLASS, +} +#[test] +fn bindgen_test_layout__STORAGE_TIER() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_TIER>(), + 1064usize, + concat!("Size of: ", stringify!(_STORAGE_TIER)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_TIER>(), + 8usize, + concat!("Alignment of ", stringify!(_STORAGE_TIER)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_TIER>())).Id as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TIER), + "::", + stringify!(Id) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_TIER>())).Name as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TIER), + "::", + stringify!(Name) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_TIER>())).Description as *const _ as usize }, + 528usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TIER), + "::", + stringify!(Description) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_TIER>())).Flags as *const _ as usize }, + 1040usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TIER), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_TIER>())).ProvisionedCapacity as *const _ as usize }, + 1048usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TIER), + "::", + stringify!(ProvisionedCapacity) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_TIER>())).MediaType as *const _ as usize }, + 1056usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TIER), + "::", + stringify!(MediaType) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_TIER>())).Class as *const _ as usize }, + 1060usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TIER), + "::", + stringify!(Class) + ) + ); +} +pub type STORAGE_TIER = _STORAGE_TIER; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _STORAGE_DEVICE_TIERING_DESCRIPTOR { + pub Version: DWORD, + pub Size: DWORD, + pub Flags: DWORD, + pub TotalNumberOfTiers: DWORD, + pub NumberOfTiersReturned: DWORD, + pub Tiers: [STORAGE_TIER; 1usize], +} +#[test] +fn bindgen_test_layout__STORAGE_DEVICE_TIERING_DESCRIPTOR() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_DEVICE_TIERING_DESCRIPTOR>(), + 1088usize, + concat!("Size of: ", stringify!(_STORAGE_DEVICE_TIERING_DESCRIPTOR)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_DEVICE_TIERING_DESCRIPTOR>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_DEVICE_TIERING_DESCRIPTOR) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_TIERING_DESCRIPTOR>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_TIERING_DESCRIPTOR), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_TIERING_DESCRIPTOR>())).Size as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_TIERING_DESCRIPTOR), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_TIERING_DESCRIPTOR>())).Flags as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_TIERING_DESCRIPTOR), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_TIERING_DESCRIPTOR>())).TotalNumberOfTiers as *const _ + as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_TIERING_DESCRIPTOR), + "::", + stringify!(TotalNumberOfTiers) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_TIERING_DESCRIPTOR>())).NumberOfTiersReturned + as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_TIERING_DESCRIPTOR), + "::", + stringify!(NumberOfTiersReturned) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_TIERING_DESCRIPTOR>())).Tiers as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_TIERING_DESCRIPTOR), + "::", + stringify!(Tiers) + ) + ); +} +pub type STORAGE_DEVICE_TIERING_DESCRIPTOR = _STORAGE_DEVICE_TIERING_DESCRIPTOR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_DEVICE_FAULT_DOMAIN_DESCRIPTOR { + pub Version: DWORD, + pub Size: DWORD, + pub NumberOfFaultDomains: DWORD, + pub FaultDomainIds: [GUID; 1usize], +} +#[test] +fn bindgen_test_layout__STORAGE_DEVICE_FAULT_DOMAIN_DESCRIPTOR() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_DEVICE_FAULT_DOMAIN_DESCRIPTOR>(), + 28usize, + concat!( + "Size of: ", + stringify!(_STORAGE_DEVICE_FAULT_DOMAIN_DESCRIPTOR) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_DEVICE_FAULT_DOMAIN_DESCRIPTOR>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_DEVICE_FAULT_DOMAIN_DESCRIPTOR) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_FAULT_DOMAIN_DESCRIPTOR>())).Version as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_FAULT_DOMAIN_DESCRIPTOR), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_FAULT_DOMAIN_DESCRIPTOR>())).Size as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_FAULT_DOMAIN_DESCRIPTOR), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_FAULT_DOMAIN_DESCRIPTOR>())).NumberOfFaultDomains + as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_FAULT_DOMAIN_DESCRIPTOR), + "::", + stringify!(NumberOfFaultDomains) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_FAULT_DOMAIN_DESCRIPTOR>())).FaultDomainIds as *const _ + as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_FAULT_DOMAIN_DESCRIPTOR), + "::", + stringify!(FaultDomainIds) + ) + ); +} +pub type STORAGE_DEVICE_FAULT_DOMAIN_DESCRIPTOR = _STORAGE_DEVICE_FAULT_DOMAIN_DESCRIPTOR; +pub const _STORAGE_PROTOCOL_TYPE_ProtocolTypeUnknown: _STORAGE_PROTOCOL_TYPE = 0; +pub const _STORAGE_PROTOCOL_TYPE_ProtocolTypeScsi: _STORAGE_PROTOCOL_TYPE = 1; +pub const _STORAGE_PROTOCOL_TYPE_ProtocolTypeAta: _STORAGE_PROTOCOL_TYPE = 2; +pub const _STORAGE_PROTOCOL_TYPE_ProtocolTypeNvme: _STORAGE_PROTOCOL_TYPE = 3; +pub const _STORAGE_PROTOCOL_TYPE_ProtocolTypeSd: _STORAGE_PROTOCOL_TYPE = 4; +pub const _STORAGE_PROTOCOL_TYPE_ProtocolTypeUfs: _STORAGE_PROTOCOL_TYPE = 5; +pub const _STORAGE_PROTOCOL_TYPE_ProtocolTypeProprietary: _STORAGE_PROTOCOL_TYPE = 126; +pub const _STORAGE_PROTOCOL_TYPE_ProtocolTypeMaxReserved: _STORAGE_PROTOCOL_TYPE = 127; +pub type _STORAGE_PROTOCOL_TYPE = ::std::os::raw::c_int; +pub use self::_STORAGE_PROTOCOL_TYPE as STORAGE_PROTOCOL_TYPE; +pub const _STORAGE_PROTOCOL_NVME_DATA_TYPE_NVMeDataTypeUnknown: _STORAGE_PROTOCOL_NVME_DATA_TYPE = + 0; +pub const _STORAGE_PROTOCOL_NVME_DATA_TYPE_NVMeDataTypeIdentify: _STORAGE_PROTOCOL_NVME_DATA_TYPE = + 1; +pub const _STORAGE_PROTOCOL_NVME_DATA_TYPE_NVMeDataTypeLogPage: _STORAGE_PROTOCOL_NVME_DATA_TYPE = + 2; +pub const _STORAGE_PROTOCOL_NVME_DATA_TYPE_NVMeDataTypeFeature: _STORAGE_PROTOCOL_NVME_DATA_TYPE = + 3; +pub type _STORAGE_PROTOCOL_NVME_DATA_TYPE = ::std::os::raw::c_int; +pub use self::_STORAGE_PROTOCOL_NVME_DATA_TYPE as STORAGE_PROTOCOL_NVME_DATA_TYPE; +pub const _STORAGE_PROTOCOL_ATA_DATA_TYPE_AtaDataTypeUnknown: _STORAGE_PROTOCOL_ATA_DATA_TYPE = 0; +pub const _STORAGE_PROTOCOL_ATA_DATA_TYPE_AtaDataTypeIdentify: _STORAGE_PROTOCOL_ATA_DATA_TYPE = 1; +pub const _STORAGE_PROTOCOL_ATA_DATA_TYPE_AtaDataTypeLogPage: _STORAGE_PROTOCOL_ATA_DATA_TYPE = 2; +pub type _STORAGE_PROTOCOL_ATA_DATA_TYPE = ::std::os::raw::c_int; +pub use self::_STORAGE_PROTOCOL_ATA_DATA_TYPE as STORAGE_PROTOCOL_ATA_DATA_TYPE; +pub const _STORAGE_PROTOCOL_UFS_DATA_TYPE_UfsDataTypeUnknown: _STORAGE_PROTOCOL_UFS_DATA_TYPE = 0; +pub const _STORAGE_PROTOCOL_UFS_DATA_TYPE_UfsDataTypeQueryDescriptor: + _STORAGE_PROTOCOL_UFS_DATA_TYPE = 1; +pub const _STORAGE_PROTOCOL_UFS_DATA_TYPE_UfsDataTypeMax: _STORAGE_PROTOCOL_UFS_DATA_TYPE = 2; +pub type _STORAGE_PROTOCOL_UFS_DATA_TYPE = ::std::os::raw::c_int; +pub use self::_STORAGE_PROTOCOL_UFS_DATA_TYPE as STORAGE_PROTOCOL_UFS_DATA_TYPE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_PROTOCOL_SPECIFIC_DATA { + pub ProtocolType: STORAGE_PROTOCOL_TYPE, + pub DataType: DWORD, + pub ProtocolDataRequestValue: DWORD, + pub ProtocolDataRequestSubValue: DWORD, + pub ProtocolDataOffset: DWORD, + pub ProtocolDataLength: DWORD, + pub FixedProtocolReturnData: DWORD, + pub ProtocolDataRequestSubValue2: DWORD, + pub ProtocolDataRequestSubValue3: DWORD, + pub Reserved: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_PROTOCOL_SPECIFIC_DATA() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_PROTOCOL_SPECIFIC_DATA>(), + 40usize, + concat!("Size of: ", stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_PROTOCOL_SPECIFIC_DATA>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_SPECIFIC_DATA>())).ProtocolType as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA), + "::", + stringify!(ProtocolType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_SPECIFIC_DATA>())).DataType as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA), + "::", + stringify!(DataType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_SPECIFIC_DATA>())).ProtocolDataRequestValue + as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA), + "::", + stringify!(ProtocolDataRequestValue) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_SPECIFIC_DATA>())).ProtocolDataRequestSubValue + as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA), + "::", + stringify!(ProtocolDataRequestSubValue) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_SPECIFIC_DATA>())).ProtocolDataOffset as *const _ + as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA), + "::", + stringify!(ProtocolDataOffset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_SPECIFIC_DATA>())).ProtocolDataLength as *const _ + as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA), + "::", + stringify!(ProtocolDataLength) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_SPECIFIC_DATA>())).FixedProtocolReturnData + as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA), + "::", + stringify!(FixedProtocolReturnData) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_SPECIFIC_DATA>())).ProtocolDataRequestSubValue2 + as *const _ as usize + }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA), + "::", + stringify!(ProtocolDataRequestSubValue2) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_SPECIFIC_DATA>())).ProtocolDataRequestSubValue3 + as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA), + "::", + stringify!(ProtocolDataRequestSubValue3) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_SPECIFIC_DATA>())).Reserved as *const _ as usize + }, + 36usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA), + "::", + stringify!(Reserved) + ) + ); +} +pub type STORAGE_PROTOCOL_SPECIFIC_DATA = _STORAGE_PROTOCOL_SPECIFIC_DATA; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_PROTOCOL_SPECIFIC_DATA_EXT { + pub ProtocolType: STORAGE_PROTOCOL_TYPE, + pub DataType: DWORD, + pub ProtocolDataValue: DWORD, + pub ProtocolDataSubValue: DWORD, + pub ProtocolDataOffset: DWORD, + pub ProtocolDataLength: DWORD, + pub FixedProtocolReturnData: DWORD, + pub ProtocolDataSubValue2: DWORD, + pub ProtocolDataSubValue3: DWORD, + pub ProtocolDataSubValue4: DWORD, + pub ProtocolDataSubValue5: DWORD, + pub Reserved: [DWORD; 5usize], +} +#[test] +fn bindgen_test_layout__STORAGE_PROTOCOL_SPECIFIC_DATA_EXT() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT>(), + 64usize, + concat!("Size of: ", stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT>())).ProtocolType as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT), + "::", + stringify!(ProtocolType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT>())).DataType as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT), + "::", + stringify!(DataType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT>())).ProtocolDataValue as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT), + "::", + stringify!(ProtocolDataValue) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT>())).ProtocolDataSubValue + as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT), + "::", + stringify!(ProtocolDataSubValue) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT>())).ProtocolDataOffset as *const _ + as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT), + "::", + stringify!(ProtocolDataOffset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT>())).ProtocolDataLength as *const _ + as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT), + "::", + stringify!(ProtocolDataLength) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT>())).FixedProtocolReturnData + as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT), + "::", + stringify!(FixedProtocolReturnData) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT>())).ProtocolDataSubValue2 + as *const _ as usize + }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT), + "::", + stringify!(ProtocolDataSubValue2) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT>())).ProtocolDataSubValue3 + as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT), + "::", + stringify!(ProtocolDataSubValue3) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT>())).ProtocolDataSubValue4 + as *const _ as usize + }, + 36usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT), + "::", + stringify!(ProtocolDataSubValue4) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT>())).ProtocolDataSubValue5 + as *const _ as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT), + "::", + stringify!(ProtocolDataSubValue5) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT>())).Reserved as *const _ as usize + }, + 44usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_SPECIFIC_DATA_EXT), + "::", + stringify!(Reserved) + ) + ); +} +pub type STORAGE_PROTOCOL_SPECIFIC_DATA_EXT = _STORAGE_PROTOCOL_SPECIFIC_DATA_EXT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_PROTOCOL_DATA_DESCRIPTOR { + pub Version: DWORD, + pub Size: DWORD, + pub ProtocolSpecificData: STORAGE_PROTOCOL_SPECIFIC_DATA, +} +#[test] +fn bindgen_test_layout__STORAGE_PROTOCOL_DATA_DESCRIPTOR() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_PROTOCOL_DATA_DESCRIPTOR>(), + 48usize, + concat!("Size of: ", stringify!(_STORAGE_PROTOCOL_DATA_DESCRIPTOR)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_PROTOCOL_DATA_DESCRIPTOR>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_PROTOCOL_DATA_DESCRIPTOR) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_DATA_DESCRIPTOR>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_DATA_DESCRIPTOR), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_DATA_DESCRIPTOR>())).Size as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_DATA_DESCRIPTOR), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_DATA_DESCRIPTOR>())).ProtocolSpecificData as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_DATA_DESCRIPTOR), + "::", + stringify!(ProtocolSpecificData) + ) + ); +} +pub type STORAGE_PROTOCOL_DATA_DESCRIPTOR = _STORAGE_PROTOCOL_DATA_DESCRIPTOR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_PROTOCOL_DATA_DESCRIPTOR_EXT { + pub Version: DWORD, + pub Size: DWORD, + pub ProtocolSpecificData: STORAGE_PROTOCOL_SPECIFIC_DATA_EXT, +} +#[test] +fn bindgen_test_layout__STORAGE_PROTOCOL_DATA_DESCRIPTOR_EXT() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_PROTOCOL_DATA_DESCRIPTOR_EXT>(), + 72usize, + concat!( + "Size of: ", + stringify!(_STORAGE_PROTOCOL_DATA_DESCRIPTOR_EXT) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_PROTOCOL_DATA_DESCRIPTOR_EXT>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_PROTOCOL_DATA_DESCRIPTOR_EXT) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_DATA_DESCRIPTOR_EXT>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_DATA_DESCRIPTOR_EXT), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_DATA_DESCRIPTOR_EXT>())).Size as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_DATA_DESCRIPTOR_EXT), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_DATA_DESCRIPTOR_EXT>())).ProtocolSpecificData + as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_DATA_DESCRIPTOR_EXT), + "::", + stringify!(ProtocolSpecificData) + ) + ); +} +pub type STORAGE_PROTOCOL_DATA_DESCRIPTOR_EXT = _STORAGE_PROTOCOL_DATA_DESCRIPTOR_EXT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_TEMPERATURE_INFO { + pub Index: WORD, + pub Temperature: SHORT, + pub OverThreshold: SHORT, + pub UnderThreshold: SHORT, + pub OverThresholdChangable: BOOLEAN, + pub UnderThresholdChangable: BOOLEAN, + pub EventGenerated: BOOLEAN, + pub Reserved0: BYTE, + pub Reserved1: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_TEMPERATURE_INFO() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_TEMPERATURE_INFO>(), + 16usize, + concat!("Size of: ", stringify!(_STORAGE_TEMPERATURE_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_TEMPERATURE_INFO>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_TEMPERATURE_INFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_INFO>())).Index as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_INFO), + "::", + stringify!(Index) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_INFO>())).Temperature as *const _ as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_INFO), + "::", + stringify!(Temperature) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_INFO>())).OverThreshold as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_INFO), + "::", + stringify!(OverThreshold) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_INFO>())).UnderThreshold as *const _ as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_INFO), + "::", + stringify!(UnderThreshold) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_INFO>())).OverThresholdChangable as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_INFO), + "::", + stringify!(OverThresholdChangable) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_INFO>())).UnderThresholdChangable as *const _ + as usize + }, + 9usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_INFO), + "::", + stringify!(UnderThresholdChangable) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_INFO>())).EventGenerated as *const _ as usize + }, + 10usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_INFO), + "::", + stringify!(EventGenerated) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_INFO>())).Reserved0 as *const _ as usize }, + 11usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_INFO), + "::", + stringify!(Reserved0) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_INFO>())).Reserved1 as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_INFO), + "::", + stringify!(Reserved1) + ) + ); +} +pub type STORAGE_TEMPERATURE_INFO = _STORAGE_TEMPERATURE_INFO; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_TEMPERATURE_DATA_DESCRIPTOR { + pub Version: DWORD, + pub Size: DWORD, + pub CriticalTemperature: SHORT, + pub WarningTemperature: SHORT, + pub InfoCount: WORD, + pub Reserved0: [BYTE; 2usize], + pub Reserved1: [DWORD; 2usize], + pub TemperatureInfo: [STORAGE_TEMPERATURE_INFO; 1usize], +} +#[test] +fn bindgen_test_layout__STORAGE_TEMPERATURE_DATA_DESCRIPTOR() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_TEMPERATURE_DATA_DESCRIPTOR>(), + 40usize, + concat!( + "Size of: ", + stringify!(_STORAGE_TEMPERATURE_DATA_DESCRIPTOR) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_TEMPERATURE_DATA_DESCRIPTOR>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_TEMPERATURE_DATA_DESCRIPTOR) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_DATA_DESCRIPTOR>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_DATA_DESCRIPTOR), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_DATA_DESCRIPTOR>())).Size as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_DATA_DESCRIPTOR), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_DATA_DESCRIPTOR>())).CriticalTemperature + as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_DATA_DESCRIPTOR), + "::", + stringify!(CriticalTemperature) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_DATA_DESCRIPTOR>())).WarningTemperature + as *const _ as usize + }, + 10usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_DATA_DESCRIPTOR), + "::", + stringify!(WarningTemperature) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_DATA_DESCRIPTOR>())).InfoCount as *const _ + as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_DATA_DESCRIPTOR), + "::", + stringify!(InfoCount) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_DATA_DESCRIPTOR>())).Reserved0 as *const _ + as usize + }, + 14usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_DATA_DESCRIPTOR), + "::", + stringify!(Reserved0) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_DATA_DESCRIPTOR>())).Reserved1 as *const _ + as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_DATA_DESCRIPTOR), + "::", + stringify!(Reserved1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_DATA_DESCRIPTOR>())).TemperatureInfo as *const _ + as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_DATA_DESCRIPTOR), + "::", + stringify!(TemperatureInfo) + ) + ); +} +pub type STORAGE_TEMPERATURE_DATA_DESCRIPTOR = _STORAGE_TEMPERATURE_DATA_DESCRIPTOR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_TEMPERATURE_THRESHOLD { + pub Version: DWORD, + pub Size: DWORD, + pub Flags: WORD, + pub Index: WORD, + pub Threshold: SHORT, + pub OverThreshold: BOOLEAN, + pub Reserved: BYTE, +} +#[test] +fn bindgen_test_layout__STORAGE_TEMPERATURE_THRESHOLD() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_TEMPERATURE_THRESHOLD>(), + 16usize, + concat!("Size of: ", stringify!(_STORAGE_TEMPERATURE_THRESHOLD)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_TEMPERATURE_THRESHOLD>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_TEMPERATURE_THRESHOLD)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_THRESHOLD>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_THRESHOLD), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_THRESHOLD>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_THRESHOLD), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_THRESHOLD>())).Flags as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_THRESHOLD), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_THRESHOLD>())).Index as *const _ as usize + }, + 10usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_THRESHOLD), + "::", + stringify!(Index) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_THRESHOLD>())).Threshold as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_THRESHOLD), + "::", + stringify!(Threshold) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_THRESHOLD>())).OverThreshold as *const _ as usize + }, + 14usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_THRESHOLD), + "::", + stringify!(OverThreshold) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_TEMPERATURE_THRESHOLD>())).Reserved as *const _ as usize + }, + 15usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TEMPERATURE_THRESHOLD), + "::", + stringify!(Reserved) + ) + ); +} +pub type STORAGE_TEMPERATURE_THRESHOLD = _STORAGE_TEMPERATURE_THRESHOLD; +pub const _STORAGE_DEVICE_FORM_FACTOR_FormFactorUnknown: _STORAGE_DEVICE_FORM_FACTOR = 0; +pub const _STORAGE_DEVICE_FORM_FACTOR_FormFactor3_5: _STORAGE_DEVICE_FORM_FACTOR = 1; +pub const _STORAGE_DEVICE_FORM_FACTOR_FormFactor2_5: _STORAGE_DEVICE_FORM_FACTOR = 2; +pub const _STORAGE_DEVICE_FORM_FACTOR_FormFactor1_8: _STORAGE_DEVICE_FORM_FACTOR = 3; +pub const _STORAGE_DEVICE_FORM_FACTOR_FormFactor1_8Less: _STORAGE_DEVICE_FORM_FACTOR = 4; +pub const _STORAGE_DEVICE_FORM_FACTOR_FormFactorEmbedded: _STORAGE_DEVICE_FORM_FACTOR = 5; +pub const _STORAGE_DEVICE_FORM_FACTOR_FormFactorMemoryCard: _STORAGE_DEVICE_FORM_FACTOR = 6; +pub const _STORAGE_DEVICE_FORM_FACTOR_FormFactormSata: _STORAGE_DEVICE_FORM_FACTOR = 7; +pub const _STORAGE_DEVICE_FORM_FACTOR_FormFactorM_2: _STORAGE_DEVICE_FORM_FACTOR = 8; +pub const _STORAGE_DEVICE_FORM_FACTOR_FormFactorPCIeBoard: _STORAGE_DEVICE_FORM_FACTOR = 9; +pub const _STORAGE_DEVICE_FORM_FACTOR_FormFactorDimm: _STORAGE_DEVICE_FORM_FACTOR = 10; +pub type _STORAGE_DEVICE_FORM_FACTOR = ::std::os::raw::c_int; +pub use self::_STORAGE_DEVICE_FORM_FACTOR as STORAGE_DEVICE_FORM_FACTOR; +pub const _STORAGE_COMPONENT_HEALTH_STATUS_HealthStatusUnknown: _STORAGE_COMPONENT_HEALTH_STATUS = + 0; +pub const _STORAGE_COMPONENT_HEALTH_STATUS_HealthStatusNormal: _STORAGE_COMPONENT_HEALTH_STATUS = 1; +pub const _STORAGE_COMPONENT_HEALTH_STATUS_HealthStatusThrottled: _STORAGE_COMPONENT_HEALTH_STATUS = + 2; +pub const _STORAGE_COMPONENT_HEALTH_STATUS_HealthStatusWarning: _STORAGE_COMPONENT_HEALTH_STATUS = + 3; +pub const _STORAGE_COMPONENT_HEALTH_STATUS_HealthStatusDisabled: _STORAGE_COMPONENT_HEALTH_STATUS = + 4; +pub const _STORAGE_COMPONENT_HEALTH_STATUS_HealthStatusFailed: _STORAGE_COMPONENT_HEALTH_STATUS = 5; +pub type _STORAGE_COMPONENT_HEALTH_STATUS = ::std::os::raw::c_int; +pub use self::_STORAGE_COMPONENT_HEALTH_STATUS as STORAGE_COMPONENT_HEALTH_STATUS; +#[repr(C)] +#[derive(Copy, Clone)] +pub union _STORAGE_SPEC_VERSION { + pub __bindgen_anon_1: _STORAGE_SPEC_VERSION__bindgen_ty_1, + pub AsUlong: DWORD, + _bindgen_union_align: u32, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _STORAGE_SPEC_VERSION__bindgen_ty_1 { + pub MinorVersion: _STORAGE_SPEC_VERSION__bindgen_ty_1__bindgen_ty_1, + pub MajorVersion: WORD, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _STORAGE_SPEC_VERSION__bindgen_ty_1__bindgen_ty_1 { + pub __bindgen_anon_1: _STORAGE_SPEC_VERSION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, + pub AsUshort: WORD, + _bindgen_union_align: u16, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_SPEC_VERSION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 { + pub SubMinor: BYTE, + pub Minor: BYTE, +} +#[test] +fn bindgen_test_layout__STORAGE_SPEC_VERSION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_SPEC_VERSION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1>(), + 2usize, + concat!( + "Size of: ", + stringify!(_STORAGE_SPEC_VERSION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_SPEC_VERSION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1>(), + 1usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_SPEC_VERSION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_SPEC_VERSION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1>())) + .SubMinor as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_SPEC_VERSION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(SubMinor) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_SPEC_VERSION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1>())) + .Minor as *const _ as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_SPEC_VERSION__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(Minor) + ) + ); +} +#[test] +fn bindgen_test_layout__STORAGE_SPEC_VERSION__bindgen_ty_1__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_SPEC_VERSION__bindgen_ty_1__bindgen_ty_1>(), + 2usize, + concat!( + "Size of: ", + stringify!(_STORAGE_SPEC_VERSION__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_SPEC_VERSION__bindgen_ty_1__bindgen_ty_1>(), + 2usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_SPEC_VERSION__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_SPEC_VERSION__bindgen_ty_1__bindgen_ty_1>())).AsUshort + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_SPEC_VERSION__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(AsUshort) + ) + ); +} +#[test] +fn bindgen_test_layout__STORAGE_SPEC_VERSION__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_SPEC_VERSION__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(_STORAGE_SPEC_VERSION__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_SPEC_VERSION__bindgen_ty_1>(), + 2usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_SPEC_VERSION__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_SPEC_VERSION__bindgen_ty_1>())).MinorVersion as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_SPEC_VERSION__bindgen_ty_1), + "::", + stringify!(MinorVersion) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_SPEC_VERSION__bindgen_ty_1>())).MajorVersion as *const _ + as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_SPEC_VERSION__bindgen_ty_1), + "::", + stringify!(MajorVersion) + ) + ); +} +#[test] +fn bindgen_test_layout__STORAGE_SPEC_VERSION() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_SPEC_VERSION>(), + 4usize, + concat!("Size of: ", stringify!(_STORAGE_SPEC_VERSION)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_SPEC_VERSION>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_SPEC_VERSION)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_SPEC_VERSION>())).AsUlong as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_SPEC_VERSION), + "::", + stringify!(AsUlong) + ) + ); +} +pub type STORAGE_SPEC_VERSION = _STORAGE_SPEC_VERSION; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _STORAGE_PHYSICAL_DEVICE_DATA { + pub DeviceId: DWORD, + pub Role: DWORD, + pub HealthStatus: STORAGE_COMPONENT_HEALTH_STATUS, + pub CommandProtocol: STORAGE_PROTOCOL_TYPE, + pub SpecVersion: STORAGE_SPEC_VERSION, + pub FormFactor: STORAGE_DEVICE_FORM_FACTOR, + pub Vendor: [BYTE; 8usize], + pub Model: [BYTE; 40usize], + pub FirmwareRevision: [BYTE; 16usize], + pub Capacity: DWORDLONG, + pub PhysicalLocation: [BYTE; 32usize], + pub Reserved: [DWORD; 2usize], +} +#[test] +fn bindgen_test_layout__STORAGE_PHYSICAL_DEVICE_DATA() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_PHYSICAL_DEVICE_DATA>(), + 136usize, + concat!("Size of: ", stringify!(_STORAGE_PHYSICAL_DEVICE_DATA)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_PHYSICAL_DEVICE_DATA>(), + 8usize, + concat!("Alignment of ", stringify!(_STORAGE_PHYSICAL_DEVICE_DATA)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_DEVICE_DATA>())).DeviceId as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_DEVICE_DATA), + "::", + stringify!(DeviceId) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_PHYSICAL_DEVICE_DATA>())).Role as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_DEVICE_DATA), + "::", + stringify!(Role) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_DEVICE_DATA>())).HealthStatus as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_DEVICE_DATA), + "::", + stringify!(HealthStatus) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_DEVICE_DATA>())).CommandProtocol as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_DEVICE_DATA), + "::", + stringify!(CommandProtocol) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_DEVICE_DATA>())).SpecVersion as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_DEVICE_DATA), + "::", + stringify!(SpecVersion) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_DEVICE_DATA>())).FormFactor as *const _ as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_DEVICE_DATA), + "::", + stringify!(FormFactor) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_DEVICE_DATA>())).Vendor as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_DEVICE_DATA), + "::", + stringify!(Vendor) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_PHYSICAL_DEVICE_DATA>())).Model as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_DEVICE_DATA), + "::", + stringify!(Model) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_DEVICE_DATA>())).FirmwareRevision as *const _ + as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_DEVICE_DATA), + "::", + stringify!(FirmwareRevision) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_DEVICE_DATA>())).Capacity as *const _ as usize + }, + 88usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_DEVICE_DATA), + "::", + stringify!(Capacity) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_DEVICE_DATA>())).PhysicalLocation as *const _ + as usize + }, + 96usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_DEVICE_DATA), + "::", + stringify!(PhysicalLocation) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_DEVICE_DATA>())).Reserved as *const _ as usize + }, + 128usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_DEVICE_DATA), + "::", + stringify!(Reserved) + ) + ); +} +pub type STORAGE_PHYSICAL_DEVICE_DATA = _STORAGE_PHYSICAL_DEVICE_DATA; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _STORAGE_PHYSICAL_ADAPTER_DATA { + pub AdapterId: DWORD, + pub HealthStatus: STORAGE_COMPONENT_HEALTH_STATUS, + pub CommandProtocol: STORAGE_PROTOCOL_TYPE, + pub SpecVersion: STORAGE_SPEC_VERSION, + pub Vendor: [BYTE; 8usize], + pub Model: [BYTE; 40usize], + pub FirmwareRevision: [BYTE; 16usize], + pub PhysicalLocation: [BYTE; 32usize], + pub ExpanderConnected: BOOLEAN, + pub Reserved0: [BYTE; 3usize], + pub Reserved1: [DWORD; 3usize], +} +#[test] +fn bindgen_test_layout__STORAGE_PHYSICAL_ADAPTER_DATA() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_PHYSICAL_ADAPTER_DATA>(), + 128usize, + concat!("Size of: ", stringify!(_STORAGE_PHYSICAL_ADAPTER_DATA)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_PHYSICAL_ADAPTER_DATA>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_PHYSICAL_ADAPTER_DATA)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_ADAPTER_DATA>())).AdapterId as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_ADAPTER_DATA), + "::", + stringify!(AdapterId) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_ADAPTER_DATA>())).HealthStatus as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_ADAPTER_DATA), + "::", + stringify!(HealthStatus) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_ADAPTER_DATA>())).CommandProtocol as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_ADAPTER_DATA), + "::", + stringify!(CommandProtocol) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_ADAPTER_DATA>())).SpecVersion as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_ADAPTER_DATA), + "::", + stringify!(SpecVersion) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_ADAPTER_DATA>())).Vendor as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_ADAPTER_DATA), + "::", + stringify!(Vendor) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_ADAPTER_DATA>())).Model as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_ADAPTER_DATA), + "::", + stringify!(Model) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_ADAPTER_DATA>())).FirmwareRevision as *const _ + as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_ADAPTER_DATA), + "::", + stringify!(FirmwareRevision) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_ADAPTER_DATA>())).PhysicalLocation as *const _ + as usize + }, + 80usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_ADAPTER_DATA), + "::", + stringify!(PhysicalLocation) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_ADAPTER_DATA>())).ExpanderConnected as *const _ + as usize + }, + 112usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_ADAPTER_DATA), + "::", + stringify!(ExpanderConnected) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_ADAPTER_DATA>())).Reserved0 as *const _ as usize + }, + 113usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_ADAPTER_DATA), + "::", + stringify!(Reserved0) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_ADAPTER_DATA>())).Reserved1 as *const _ as usize + }, + 116usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_ADAPTER_DATA), + "::", + stringify!(Reserved1) + ) + ); +} +pub type STORAGE_PHYSICAL_ADAPTER_DATA = _STORAGE_PHYSICAL_ADAPTER_DATA; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_PHYSICAL_NODE_DATA { + pub NodeId: DWORD, + pub AdapterCount: DWORD, + pub AdapterDataLength: DWORD, + pub AdapterDataOffset: DWORD, + pub DeviceCount: DWORD, + pub DeviceDataLength: DWORD, + pub DeviceDataOffset: DWORD, + pub Reserved: [DWORD; 3usize], +} +#[test] +fn bindgen_test_layout__STORAGE_PHYSICAL_NODE_DATA() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_PHYSICAL_NODE_DATA>(), + 40usize, + concat!("Size of: ", stringify!(_STORAGE_PHYSICAL_NODE_DATA)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_PHYSICAL_NODE_DATA>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_PHYSICAL_NODE_DATA)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_PHYSICAL_NODE_DATA>())).NodeId as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_NODE_DATA), + "::", + stringify!(NodeId) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_NODE_DATA>())).AdapterCount as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_NODE_DATA), + "::", + stringify!(AdapterCount) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_NODE_DATA>())).AdapterDataLength as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_NODE_DATA), + "::", + stringify!(AdapterDataLength) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_NODE_DATA>())).AdapterDataOffset as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_NODE_DATA), + "::", + stringify!(AdapterDataOffset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_NODE_DATA>())).DeviceCount as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_NODE_DATA), + "::", + stringify!(DeviceCount) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_NODE_DATA>())).DeviceDataLength as *const _ as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_NODE_DATA), + "::", + stringify!(DeviceDataLength) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_NODE_DATA>())).DeviceDataOffset as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_NODE_DATA), + "::", + stringify!(DeviceDataOffset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_NODE_DATA>())).Reserved as *const _ as usize + }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_NODE_DATA), + "::", + stringify!(Reserved) + ) + ); +} +pub type STORAGE_PHYSICAL_NODE_DATA = _STORAGE_PHYSICAL_NODE_DATA; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR { + pub Version: DWORD, + pub Size: DWORD, + pub NodeCount: DWORD, + pub Reserved: DWORD, + pub Node: [STORAGE_PHYSICAL_NODE_DATA; 1usize], +} +#[test] +fn bindgen_test_layout__STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR>(), + 56usize, + concat!( + "Size of: ", + stringify!(_STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR>())).Size as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR>())).NodeCount as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR), + "::", + stringify!(NodeCount) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR>())).Reserved as *const _ + as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR), + "::", + stringify!(Reserved) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR>())).Node as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR), + "::", + stringify!(Node) + ) + ); +} +pub type STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR = _STORAGE_PHYSICAL_TOPOLOGY_DESCRIPTOR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_DEVICE_IO_CAPABILITY_DESCRIPTOR { + pub Version: DWORD, + pub Size: DWORD, + pub LunMaxIoCount: DWORD, + pub AdapterMaxIoCount: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_DEVICE_IO_CAPABILITY_DESCRIPTOR() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_DEVICE_IO_CAPABILITY_DESCRIPTOR>(), + 16usize, + concat!( + "Size of: ", + stringify!(_STORAGE_DEVICE_IO_CAPABILITY_DESCRIPTOR) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_DEVICE_IO_CAPABILITY_DESCRIPTOR>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_DEVICE_IO_CAPABILITY_DESCRIPTOR) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_IO_CAPABILITY_DESCRIPTOR>())).Version as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_IO_CAPABILITY_DESCRIPTOR), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_IO_CAPABILITY_DESCRIPTOR>())).Size as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_IO_CAPABILITY_DESCRIPTOR), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_IO_CAPABILITY_DESCRIPTOR>())).LunMaxIoCount as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_IO_CAPABILITY_DESCRIPTOR), + "::", + stringify!(LunMaxIoCount) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_IO_CAPABILITY_DESCRIPTOR>())).AdapterMaxIoCount + as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_IO_CAPABILITY_DESCRIPTOR), + "::", + stringify!(AdapterMaxIoCount) + ) + ); +} +pub type STORAGE_DEVICE_IO_CAPABILITY_DESCRIPTOR = _STORAGE_DEVICE_IO_CAPABILITY_DESCRIPTOR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_DEVICE_ATTRIBUTES_DESCRIPTOR { + pub Version: DWORD, + pub Size: DWORD, + pub Attributes: DWORD64, +} +#[test] +fn bindgen_test_layout__STORAGE_DEVICE_ATTRIBUTES_DESCRIPTOR() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_DEVICE_ATTRIBUTES_DESCRIPTOR>(), + 16usize, + concat!( + "Size of: ", + stringify!(_STORAGE_DEVICE_ATTRIBUTES_DESCRIPTOR) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_DEVICE_ATTRIBUTES_DESCRIPTOR>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_DEVICE_ATTRIBUTES_DESCRIPTOR) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_ATTRIBUTES_DESCRIPTOR>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_ATTRIBUTES_DESCRIPTOR), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_ATTRIBUTES_DESCRIPTOR>())).Size as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_ATTRIBUTES_DESCRIPTOR), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_ATTRIBUTES_DESCRIPTOR>())).Attributes as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_ATTRIBUTES_DESCRIPTOR), + "::", + stringify!(Attributes) + ) + ); +} +pub type STORAGE_DEVICE_ATTRIBUTES_DESCRIPTOR = _STORAGE_DEVICE_ATTRIBUTES_DESCRIPTOR; +pub const _STORAGE_DISK_HEALTH_STATUS_DiskHealthUnknown: _STORAGE_DISK_HEALTH_STATUS = 0; +pub const _STORAGE_DISK_HEALTH_STATUS_DiskHealthUnhealthy: _STORAGE_DISK_HEALTH_STATUS = 1; +pub const _STORAGE_DISK_HEALTH_STATUS_DiskHealthWarning: _STORAGE_DISK_HEALTH_STATUS = 2; +pub const _STORAGE_DISK_HEALTH_STATUS_DiskHealthHealthy: _STORAGE_DISK_HEALTH_STATUS = 3; +pub const _STORAGE_DISK_HEALTH_STATUS_DiskHealthMax: _STORAGE_DISK_HEALTH_STATUS = 4; +pub type _STORAGE_DISK_HEALTH_STATUS = ::std::os::raw::c_int; +pub use self::_STORAGE_DISK_HEALTH_STATUS as STORAGE_DISK_HEALTH_STATUS; +pub const _STORAGE_DISK_OPERATIONAL_STATUS_DiskOpStatusNone: _STORAGE_DISK_OPERATIONAL_STATUS = 0; +pub const _STORAGE_DISK_OPERATIONAL_STATUS_DiskOpStatusUnknown: _STORAGE_DISK_OPERATIONAL_STATUS = + 1; +pub const _STORAGE_DISK_OPERATIONAL_STATUS_DiskOpStatusOk: _STORAGE_DISK_OPERATIONAL_STATUS = 2; +pub const _STORAGE_DISK_OPERATIONAL_STATUS_DiskOpStatusPredictingFailure: + _STORAGE_DISK_OPERATIONAL_STATUS = 3; +pub const _STORAGE_DISK_OPERATIONAL_STATUS_DiskOpStatusInService: _STORAGE_DISK_OPERATIONAL_STATUS = + 4; +pub const _STORAGE_DISK_OPERATIONAL_STATUS_DiskOpStatusHardwareError: + _STORAGE_DISK_OPERATIONAL_STATUS = 5; +pub const _STORAGE_DISK_OPERATIONAL_STATUS_DiskOpStatusNotUsable: _STORAGE_DISK_OPERATIONAL_STATUS = + 6; +pub const _STORAGE_DISK_OPERATIONAL_STATUS_DiskOpStatusTransientError: + _STORAGE_DISK_OPERATIONAL_STATUS = 7; +pub const _STORAGE_DISK_OPERATIONAL_STATUS_DiskOpStatusMissing: _STORAGE_DISK_OPERATIONAL_STATUS = + 8; +pub type _STORAGE_DISK_OPERATIONAL_STATUS = ::std::os::raw::c_int; +pub use self::_STORAGE_DISK_OPERATIONAL_STATUS as STORAGE_DISK_OPERATIONAL_STATUS; +pub const _STORAGE_OPERATIONAL_STATUS_REASON_DiskOpReasonUnknown: + _STORAGE_OPERATIONAL_STATUS_REASON = 0; +pub const _STORAGE_OPERATIONAL_STATUS_REASON_DiskOpReasonScsiSenseCode: + _STORAGE_OPERATIONAL_STATUS_REASON = 1; +pub const _STORAGE_OPERATIONAL_STATUS_REASON_DiskOpReasonMedia: _STORAGE_OPERATIONAL_STATUS_REASON = + 2; +pub const _STORAGE_OPERATIONAL_STATUS_REASON_DiskOpReasonIo: _STORAGE_OPERATIONAL_STATUS_REASON = 3; +pub const _STORAGE_OPERATIONAL_STATUS_REASON_DiskOpReasonThresholdExceeded: + _STORAGE_OPERATIONAL_STATUS_REASON = 4; +pub const _STORAGE_OPERATIONAL_STATUS_REASON_DiskOpReasonLostData: + _STORAGE_OPERATIONAL_STATUS_REASON = 5; +pub const _STORAGE_OPERATIONAL_STATUS_REASON_DiskOpReasonEnergySource: + _STORAGE_OPERATIONAL_STATUS_REASON = 6; +pub const _STORAGE_OPERATIONAL_STATUS_REASON_DiskOpReasonConfiguration: + _STORAGE_OPERATIONAL_STATUS_REASON = 7; +pub const _STORAGE_OPERATIONAL_STATUS_REASON_DiskOpReasonDeviceController: + _STORAGE_OPERATIONAL_STATUS_REASON = 8; +pub const _STORAGE_OPERATIONAL_STATUS_REASON_DiskOpReasonMediaController: + _STORAGE_OPERATIONAL_STATUS_REASON = 9; +pub const _STORAGE_OPERATIONAL_STATUS_REASON_DiskOpReasonComponent: + _STORAGE_OPERATIONAL_STATUS_REASON = 10; +pub const _STORAGE_OPERATIONAL_STATUS_REASON_DiskOpReasonNVDIMM_N: + _STORAGE_OPERATIONAL_STATUS_REASON = 11; +pub const _STORAGE_OPERATIONAL_STATUS_REASON_DiskOpReasonBackgroundOperation: + _STORAGE_OPERATIONAL_STATUS_REASON = 12; +pub const _STORAGE_OPERATIONAL_STATUS_REASON_DiskOpReasonInvalidFirmware: + _STORAGE_OPERATIONAL_STATUS_REASON = 13; +pub const _STORAGE_OPERATIONAL_STATUS_REASON_DiskOpReasonHealthCheck: + _STORAGE_OPERATIONAL_STATUS_REASON = 14; +pub const _STORAGE_OPERATIONAL_STATUS_REASON_DiskOpReasonLostDataPersistence: + _STORAGE_OPERATIONAL_STATUS_REASON = 15; +pub const _STORAGE_OPERATIONAL_STATUS_REASON_DiskOpReasonDisabledByPlatform: + _STORAGE_OPERATIONAL_STATUS_REASON = 16; +pub const _STORAGE_OPERATIONAL_STATUS_REASON_DiskOpReasonLostWritePersistence: + _STORAGE_OPERATIONAL_STATUS_REASON = 17; +pub const _STORAGE_OPERATIONAL_STATUS_REASON_DiskOpReasonDataPersistenceLossImminent: + _STORAGE_OPERATIONAL_STATUS_REASON = 18; +pub const _STORAGE_OPERATIONAL_STATUS_REASON_DiskOpReasonWritePersistenceLossImminent: + _STORAGE_OPERATIONAL_STATUS_REASON = 19; +pub const _STORAGE_OPERATIONAL_STATUS_REASON_DiskOpReasonMax: _STORAGE_OPERATIONAL_STATUS_REASON = + 20; +pub type _STORAGE_OPERATIONAL_STATUS_REASON = ::std::os::raw::c_int; +pub use self::_STORAGE_OPERATIONAL_STATUS_REASON as STORAGE_OPERATIONAL_STATUS_REASON; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _STORAGE_OPERATIONAL_REASON { + pub Version: DWORD, + pub Size: DWORD, + pub Reason: STORAGE_OPERATIONAL_STATUS_REASON, + pub RawBytes: _STORAGE_OPERATIONAL_REASON__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _STORAGE_OPERATIONAL_REASON__bindgen_ty_1 { + pub ScsiSenseKey: _STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_1, + pub NVDIMM_N: _STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_2, + pub AsUlong: DWORD, + _bindgen_union_align: u32, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_1 { + pub SenseKey: BYTE, + pub ASC: BYTE, + pub ASCQ: BYTE, + pub Reserved: BYTE, +} +#[test] +fn bindgen_test_layout__STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_1>(), + 4usize, + concat!( + "Size of: ", + stringify!(_STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_1>(), + 1usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_1>())).SenseKey + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(SenseKey) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_1>())).ASC + as *const _ as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(ASC) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_1>())).ASCQ + as *const _ as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(ASCQ) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_1>())).Reserved + as *const _ as usize + }, + 3usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(Reserved) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_2 { + pub CriticalHealth: BYTE, + pub ModuleHealth: [BYTE; 2usize], + pub ErrorThresholdStatus: BYTE, +} +#[test] +fn bindgen_test_layout__STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_2() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_2>(), + 4usize, + concat!( + "Size of: ", + stringify!(_STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_2>(), + 1usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_2>())) + .CriticalHealth as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(CriticalHealth) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_2>())) + .ModuleHealth as *const _ as usize + }, + 1usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(ModuleHealth) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_2>())) + .ErrorThresholdStatus as *const _ as usize + }, + 3usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OPERATIONAL_REASON__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(ErrorThresholdStatus) + ) + ); +} +#[test] +fn bindgen_test_layout__STORAGE_OPERATIONAL_REASON__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_OPERATIONAL_REASON__bindgen_ty_1>(), + 4usize, + concat!( + "Size of: ", + stringify!(_STORAGE_OPERATIONAL_REASON__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_OPERATIONAL_REASON__bindgen_ty_1>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_OPERATIONAL_REASON__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_OPERATIONAL_REASON__bindgen_ty_1>())).ScsiSenseKey as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OPERATIONAL_REASON__bindgen_ty_1), + "::", + stringify!(ScsiSenseKey) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_OPERATIONAL_REASON__bindgen_ty_1>())).NVDIMM_N as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OPERATIONAL_REASON__bindgen_ty_1), + "::", + stringify!(NVDIMM_N) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_OPERATIONAL_REASON__bindgen_ty_1>())).AsUlong as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OPERATIONAL_REASON__bindgen_ty_1), + "::", + stringify!(AsUlong) + ) + ); +} +#[test] +fn bindgen_test_layout__STORAGE_OPERATIONAL_REASON() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_OPERATIONAL_REASON>(), + 16usize, + concat!("Size of: ", stringify!(_STORAGE_OPERATIONAL_REASON)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_OPERATIONAL_REASON>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_OPERATIONAL_REASON)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_OPERATIONAL_REASON>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OPERATIONAL_REASON), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_OPERATIONAL_REASON>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OPERATIONAL_REASON), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_OPERATIONAL_REASON>())).Reason as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OPERATIONAL_REASON), + "::", + stringify!(Reason) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_OPERATIONAL_REASON>())).RawBytes as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OPERATIONAL_REASON), + "::", + stringify!(RawBytes) + ) + ); +} +pub type STORAGE_OPERATIONAL_REASON = _STORAGE_OPERATIONAL_REASON; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _STORAGE_DEVICE_MANAGEMENT_STATUS { + pub Version: DWORD, + pub Size: DWORD, + pub Health: STORAGE_DISK_HEALTH_STATUS, + pub NumberOfOperationalStatus: DWORD, + pub NumberOfAdditionalReasons: DWORD, + pub OperationalStatus: [STORAGE_DISK_OPERATIONAL_STATUS; 16usize], + pub AdditionalReasons: [STORAGE_OPERATIONAL_REASON; 1usize], +} +#[test] +fn bindgen_test_layout__STORAGE_DEVICE_MANAGEMENT_STATUS() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_DEVICE_MANAGEMENT_STATUS>(), + 100usize, + concat!("Size of: ", stringify!(_STORAGE_DEVICE_MANAGEMENT_STATUS)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_DEVICE_MANAGEMENT_STATUS>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_DEVICE_MANAGEMENT_STATUS) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_MANAGEMENT_STATUS>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_MANAGEMENT_STATUS), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_MANAGEMENT_STATUS>())).Size as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_MANAGEMENT_STATUS), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_MANAGEMENT_STATUS>())).Health as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_MANAGEMENT_STATUS), + "::", + stringify!(Health) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_MANAGEMENT_STATUS>())).NumberOfOperationalStatus + as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_MANAGEMENT_STATUS), + "::", + stringify!(NumberOfOperationalStatus) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_MANAGEMENT_STATUS>())).NumberOfAdditionalReasons + as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_MANAGEMENT_STATUS), + "::", + stringify!(NumberOfAdditionalReasons) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_MANAGEMENT_STATUS>())).OperationalStatus as *const _ + as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_MANAGEMENT_STATUS), + "::", + stringify!(OperationalStatus) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_MANAGEMENT_STATUS>())).AdditionalReasons as *const _ + as usize + }, + 84usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_MANAGEMENT_STATUS), + "::", + stringify!(AdditionalReasons) + ) + ); +} +pub type STORAGE_DEVICE_MANAGEMENT_STATUS = _STORAGE_DEVICE_MANAGEMENT_STATUS; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _STORAGE_ADAPTER_SERIAL_NUMBER { + pub Version: DWORD, + pub Size: DWORD, + pub SerialNumber: [WCHAR; 128usize], +} +#[test] +fn bindgen_test_layout__STORAGE_ADAPTER_SERIAL_NUMBER() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_ADAPTER_SERIAL_NUMBER>(), + 264usize, + concat!("Size of: ", stringify!(_STORAGE_ADAPTER_SERIAL_NUMBER)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_ADAPTER_SERIAL_NUMBER>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_ADAPTER_SERIAL_NUMBER)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ADAPTER_SERIAL_NUMBER>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ADAPTER_SERIAL_NUMBER), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_ADAPTER_SERIAL_NUMBER>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ADAPTER_SERIAL_NUMBER), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ADAPTER_SERIAL_NUMBER>())).SerialNumber as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ADAPTER_SERIAL_NUMBER), + "::", + stringify!(SerialNumber) + ) + ); +} +pub type STORAGE_ADAPTER_SERIAL_NUMBER = _STORAGE_ADAPTER_SERIAL_NUMBER; +pub const _STORAGE_ZONED_DEVICE_TYPES_ZonedDeviceTypeUnknown: _STORAGE_ZONED_DEVICE_TYPES = 0; +pub const _STORAGE_ZONED_DEVICE_TYPES_ZonedDeviceTypeHostManaged: _STORAGE_ZONED_DEVICE_TYPES = 1; +pub const _STORAGE_ZONED_DEVICE_TYPES_ZonedDeviceTypeHostAware: _STORAGE_ZONED_DEVICE_TYPES = 2; +pub const _STORAGE_ZONED_DEVICE_TYPES_ZonedDeviceTypeDeviceManaged: _STORAGE_ZONED_DEVICE_TYPES = 3; +pub type _STORAGE_ZONED_DEVICE_TYPES = ::std::os::raw::c_int; +pub use self::_STORAGE_ZONED_DEVICE_TYPES as STORAGE_ZONED_DEVICE_TYPES; +pub const _STORAGE_ZONE_TYPES_ZoneTypeUnknown: _STORAGE_ZONE_TYPES = 0; +pub const _STORAGE_ZONE_TYPES_ZoneTypeConventional: _STORAGE_ZONE_TYPES = 1; +pub const _STORAGE_ZONE_TYPES_ZoneTypeSequentialWriteRequired: _STORAGE_ZONE_TYPES = 2; +pub const _STORAGE_ZONE_TYPES_ZoneTypeSequentialWritePreferred: _STORAGE_ZONE_TYPES = 3; +pub const _STORAGE_ZONE_TYPES_ZoneTypeMax: _STORAGE_ZONE_TYPES = 4; +pub type _STORAGE_ZONE_TYPES = ::std::os::raw::c_int; +pub use self::_STORAGE_ZONE_TYPES as STORAGE_ZONE_TYPES; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_ZONE_GROUP { + pub ZoneCount: DWORD, + pub ZoneType: STORAGE_ZONE_TYPES, + pub ZoneSize: DWORDLONG, +} +#[test] +fn bindgen_test_layout__STORAGE_ZONE_GROUP() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_ZONE_GROUP>(), + 16usize, + concat!("Size of: ", stringify!(_STORAGE_ZONE_GROUP)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_ZONE_GROUP>(), + 8usize, + concat!("Alignment of ", stringify!(_STORAGE_ZONE_GROUP)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_ZONE_GROUP>())).ZoneCount as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONE_GROUP), + "::", + stringify!(ZoneCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_ZONE_GROUP>())).ZoneType as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONE_GROUP), + "::", + stringify!(ZoneType) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_ZONE_GROUP>())).ZoneSize as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONE_GROUP), + "::", + stringify!(ZoneSize) + ) + ); +} +pub type STORAGE_ZONE_GROUP = _STORAGE_ZONE_GROUP; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _STORAGE_ZONED_DEVICE_DESCRIPTOR { + pub Version: DWORD, + pub Size: DWORD, + pub DeviceType: STORAGE_ZONED_DEVICE_TYPES, + pub ZoneCount: DWORD, + pub ZoneAttributes: _STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1, + pub ZoneGroupCount: DWORD, + pub ZoneGroup: [STORAGE_ZONE_GROUP; 1usize], +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1 { + pub SequentialRequiredZone: _STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_1, + pub SequentialPreferredZone: _STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_2, + _bindgen_union_align: [u32; 2usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_1 { + pub MaxOpenZoneCount: DWORD, + pub UnrestrictedRead: BOOLEAN, + pub Reserved: [BYTE; 3usize], +} +#[test] +fn bindgen_test_layout__STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_1>(), + 8usize, + concat!( + "Size of: ", + stringify!(_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_1>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_1>())) + .MaxOpenZoneCount as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(MaxOpenZoneCount) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_1>())) + .UnrestrictedRead as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(UnrestrictedRead) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_1>())) + .Reserved as *const _ as usize + }, + 5usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(Reserved) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_2 { + pub OptimalOpenZoneCount: DWORD, + pub Reserved: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_2() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_2>(), + 8usize, + concat!( + "Size of: ", + stringify!(_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_2>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_2>())) + .OptimalOpenZoneCount as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(OptimalOpenZoneCount) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_2>())) + .Reserved as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(Reserved) + ) + ); +} +#[test] +fn bindgen_test_layout__STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1>(), + 8usize, + concat!( + "Size of: ", + stringify!(_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1>())) + .SequentialRequiredZone as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1), + "::", + stringify!(SequentialRequiredZone) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1>())) + .SequentialPreferredZone as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONED_DEVICE_DESCRIPTOR__bindgen_ty_1), + "::", + stringify!(SequentialPreferredZone) + ) + ); +} +#[test] +fn bindgen_test_layout__STORAGE_ZONED_DEVICE_DESCRIPTOR() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_ZONED_DEVICE_DESCRIPTOR>(), + 48usize, + concat!("Size of: ", stringify!(_STORAGE_ZONED_DEVICE_DESCRIPTOR)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_ZONED_DEVICE_DESCRIPTOR>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_ZONED_DEVICE_DESCRIPTOR) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ZONED_DEVICE_DESCRIPTOR>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONED_DEVICE_DESCRIPTOR), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ZONED_DEVICE_DESCRIPTOR>())).Size as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONED_DEVICE_DESCRIPTOR), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ZONED_DEVICE_DESCRIPTOR>())).DeviceType as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONED_DEVICE_DESCRIPTOR), + "::", + stringify!(DeviceType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ZONED_DEVICE_DESCRIPTOR>())).ZoneCount as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONED_DEVICE_DESCRIPTOR), + "::", + stringify!(ZoneCount) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ZONED_DEVICE_DESCRIPTOR>())).ZoneAttributes as *const _ + as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONED_DEVICE_DESCRIPTOR), + "::", + stringify!(ZoneAttributes) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ZONED_DEVICE_DESCRIPTOR>())).ZoneGroupCount as *const _ + as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONED_DEVICE_DESCRIPTOR), + "::", + stringify!(ZoneGroupCount) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ZONED_DEVICE_DESCRIPTOR>())).ZoneGroup as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONED_DEVICE_DESCRIPTOR), + "::", + stringify!(ZoneGroup) + ) + ); +} +pub type STORAGE_ZONED_DEVICE_DESCRIPTOR = _STORAGE_ZONED_DEVICE_DESCRIPTOR; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _DEVICE_LOCATION { + pub Socket: DWORD, + pub Slot: DWORD, + pub Adapter: DWORD, + pub Port: DWORD, + pub __bindgen_anon_1: _DEVICE_LOCATION__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _DEVICE_LOCATION__bindgen_ty_1 { + pub __bindgen_anon_1: _DEVICE_LOCATION__bindgen_ty_1__bindgen_ty_1, + pub __bindgen_anon_2: _DEVICE_LOCATION__bindgen_ty_1__bindgen_ty_2, + _bindgen_union_align: [u32; 2usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _DEVICE_LOCATION__bindgen_ty_1__bindgen_ty_1 { + pub Channel: DWORD, + pub Device: DWORD, +} +#[test] +fn bindgen_test_layout__DEVICE_LOCATION__bindgen_ty_1__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_DEVICE_LOCATION__bindgen_ty_1__bindgen_ty_1>(), + 8usize, + concat!( + "Size of: ", + stringify!(_DEVICE_LOCATION__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_DEVICE_LOCATION__bindgen_ty_1__bindgen_ty_1>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_DEVICE_LOCATION__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_DEVICE_LOCATION__bindgen_ty_1__bindgen_ty_1>())).Channel as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_DEVICE_LOCATION__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(Channel) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_DEVICE_LOCATION__bindgen_ty_1__bindgen_ty_1>())).Device as *const _ + as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_DEVICE_LOCATION__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(Device) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _DEVICE_LOCATION__bindgen_ty_1__bindgen_ty_2 { + pub Target: DWORD, + pub Lun: DWORD, +} +#[test] +fn bindgen_test_layout__DEVICE_LOCATION__bindgen_ty_1__bindgen_ty_2() { + assert_eq!( + ::std::mem::size_of::<_DEVICE_LOCATION__bindgen_ty_1__bindgen_ty_2>(), + 8usize, + concat!( + "Size of: ", + stringify!(_DEVICE_LOCATION__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + ::std::mem::align_of::<_DEVICE_LOCATION__bindgen_ty_1__bindgen_ty_2>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_DEVICE_LOCATION__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_DEVICE_LOCATION__bindgen_ty_1__bindgen_ty_2>())).Target as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_DEVICE_LOCATION__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(Target) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_DEVICE_LOCATION__bindgen_ty_1__bindgen_ty_2>())).Lun as *const _ + as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_DEVICE_LOCATION__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(Lun) + ) + ); +} +#[test] +fn bindgen_test_layout__DEVICE_LOCATION__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_DEVICE_LOCATION__bindgen_ty_1>(), + 8usize, + concat!("Size of: ", stringify!(_DEVICE_LOCATION__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<_DEVICE_LOCATION__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(_DEVICE_LOCATION__bindgen_ty_1)) + ); +} +#[test] +fn bindgen_test_layout__DEVICE_LOCATION() { + assert_eq!( + ::std::mem::size_of::<_DEVICE_LOCATION>(), + 24usize, + concat!("Size of: ", stringify!(_DEVICE_LOCATION)) + ); + assert_eq!( + ::std::mem::align_of::<_DEVICE_LOCATION>(), + 4usize, + concat!("Alignment of ", stringify!(_DEVICE_LOCATION)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_DEVICE_LOCATION>())).Socket as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_DEVICE_LOCATION), + "::", + stringify!(Socket) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_DEVICE_LOCATION>())).Slot as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_DEVICE_LOCATION), + "::", + stringify!(Slot) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_DEVICE_LOCATION>())).Adapter as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_DEVICE_LOCATION), + "::", + stringify!(Adapter) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_DEVICE_LOCATION>())).Port as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_DEVICE_LOCATION), + "::", + stringify!(Port) + ) + ); +} +pub type DEVICE_LOCATION = _DEVICE_LOCATION; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _STORAGE_DEVICE_LOCATION_DESCRIPTOR { + pub Version: DWORD, + pub Size: DWORD, + pub Location: DEVICE_LOCATION, + pub StringOffset: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_DEVICE_LOCATION_DESCRIPTOR() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_DEVICE_LOCATION_DESCRIPTOR>(), + 36usize, + concat!("Size of: ", stringify!(_STORAGE_DEVICE_LOCATION_DESCRIPTOR)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_DEVICE_LOCATION_DESCRIPTOR>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_DEVICE_LOCATION_DESCRIPTOR) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_LOCATION_DESCRIPTOR>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_LOCATION_DESCRIPTOR), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_LOCATION_DESCRIPTOR>())).Size as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_LOCATION_DESCRIPTOR), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_LOCATION_DESCRIPTOR>())).Location as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_LOCATION_DESCRIPTOR), + "::", + stringify!(Location) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_LOCATION_DESCRIPTOR>())).StringOffset as *const _ + as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_LOCATION_DESCRIPTOR), + "::", + stringify!(StringOffset) + ) + ); +} +pub type STORAGE_DEVICE_LOCATION_DESCRIPTOR = _STORAGE_DEVICE_LOCATION_DESCRIPTOR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_DEVICE_NUMA_PROPERTY { + pub Version: DWORD, + pub Size: DWORD, + pub NumaNode: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_DEVICE_NUMA_PROPERTY() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_DEVICE_NUMA_PROPERTY>(), + 12usize, + concat!("Size of: ", stringify!(_STORAGE_DEVICE_NUMA_PROPERTY)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_DEVICE_NUMA_PROPERTY>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_DEVICE_NUMA_PROPERTY)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_NUMA_PROPERTY>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_NUMA_PROPERTY), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DEVICE_NUMA_PROPERTY>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_NUMA_PROPERTY), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_NUMA_PROPERTY>())).NumaNode as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_NUMA_PROPERTY), + "::", + stringify!(NumaNode) + ) + ); +} +pub type STORAGE_DEVICE_NUMA_PROPERTY = _STORAGE_DEVICE_NUMA_PROPERTY; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_DEVICE_UNSAFE_SHUTDOWN_COUNT { + pub Version: DWORD, + pub Size: DWORD, + pub UnsafeShutdownCount: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_DEVICE_UNSAFE_SHUTDOWN_COUNT() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_DEVICE_UNSAFE_SHUTDOWN_COUNT>(), + 12usize, + concat!( + "Size of: ", + stringify!(_STORAGE_DEVICE_UNSAFE_SHUTDOWN_COUNT) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_DEVICE_UNSAFE_SHUTDOWN_COUNT>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_DEVICE_UNSAFE_SHUTDOWN_COUNT) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_UNSAFE_SHUTDOWN_COUNT>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_UNSAFE_SHUTDOWN_COUNT), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_UNSAFE_SHUTDOWN_COUNT>())).Size as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_UNSAFE_SHUTDOWN_COUNT), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DEVICE_UNSAFE_SHUTDOWN_COUNT>())).UnsafeShutdownCount + as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_UNSAFE_SHUTDOWN_COUNT), + "::", + stringify!(UnsafeShutdownCount) + ) + ); +} +pub type STORAGE_DEVICE_UNSAFE_SHUTDOWN_COUNT = _STORAGE_DEVICE_UNSAFE_SHUTDOWN_COUNT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_HW_ENDURANCE_INFO { + pub ValidFields: DWORD, + pub GroupId: DWORD, + pub Flags: _STORAGE_HW_ENDURANCE_INFO__bindgen_ty_1, + pub LifePercentage: DWORD, + pub BytesReadCount: [BYTE; 16usize], + pub ByteWriteCount: [BYTE; 16usize], +} +#[repr(C)] +#[repr(align(4))] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_HW_ENDURANCE_INFO__bindgen_ty_1 { + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize], u32>, +} +#[test] +fn bindgen_test_layout__STORAGE_HW_ENDURANCE_INFO__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_HW_ENDURANCE_INFO__bindgen_ty_1>(), + 4usize, + concat!( + "Size of: ", + stringify!(_STORAGE_HW_ENDURANCE_INFO__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_HW_ENDURANCE_INFO__bindgen_ty_1>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_HW_ENDURANCE_INFO__bindgen_ty_1) + ) + ); +} +impl _STORAGE_HW_ENDURANCE_INFO__bindgen_ty_1 { + #[inline] + pub fn Shared(&self) -> DWORD { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } + } + #[inline] + pub fn set_Shared(&mut self, val: DWORD) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn Reserved(&self) -> DWORD { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 31u8) as u32) } + } + #[inline] + pub fn set_Reserved(&mut self, val: DWORD) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 31u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + Shared: DWORD, + Reserved: DWORD, + ) -> __BindgenBitfieldUnit<[u8; 4usize], u32> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize], u32> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let Shared: u32 = unsafe { ::std::mem::transmute(Shared) }; + Shared as u64 + }); + __bindgen_bitfield_unit.set(1usize, 31u8, { + let Reserved: u32 = unsafe { ::std::mem::transmute(Reserved) }; + Reserved as u64 + }); + __bindgen_bitfield_unit + } +} +#[test] +fn bindgen_test_layout__STORAGE_HW_ENDURANCE_INFO() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_HW_ENDURANCE_INFO>(), + 48usize, + concat!("Size of: ", stringify!(_STORAGE_HW_ENDURANCE_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_HW_ENDURANCE_INFO>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_HW_ENDURANCE_INFO)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_ENDURANCE_INFO>())).ValidFields as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_ENDURANCE_INFO), + "::", + stringify!(ValidFields) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_HW_ENDURANCE_INFO>())).GroupId as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_ENDURANCE_INFO), + "::", + stringify!(GroupId) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_HW_ENDURANCE_INFO>())).Flags as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_ENDURANCE_INFO), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_ENDURANCE_INFO>())).LifePercentage as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_ENDURANCE_INFO), + "::", + stringify!(LifePercentage) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_ENDURANCE_INFO>())).BytesReadCount as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_ENDURANCE_INFO), + "::", + stringify!(BytesReadCount) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_ENDURANCE_INFO>())).ByteWriteCount as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_ENDURANCE_INFO), + "::", + stringify!(ByteWriteCount) + ) + ); +} +pub type STORAGE_HW_ENDURANCE_INFO = _STORAGE_HW_ENDURANCE_INFO; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_HW_ENDURANCE_DATA_DESCRIPTOR { + pub Version: DWORD, + pub Size: DWORD, + pub EnduranceInfo: STORAGE_HW_ENDURANCE_INFO, +} +#[test] +fn bindgen_test_layout__STORAGE_HW_ENDURANCE_DATA_DESCRIPTOR() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_HW_ENDURANCE_DATA_DESCRIPTOR>(), + 56usize, + concat!( + "Size of: ", + stringify!(_STORAGE_HW_ENDURANCE_DATA_DESCRIPTOR) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_HW_ENDURANCE_DATA_DESCRIPTOR>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_HW_ENDURANCE_DATA_DESCRIPTOR) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_ENDURANCE_DATA_DESCRIPTOR>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_ENDURANCE_DATA_DESCRIPTOR), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_ENDURANCE_DATA_DESCRIPTOR>())).Size as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_ENDURANCE_DATA_DESCRIPTOR), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_ENDURANCE_DATA_DESCRIPTOR>())).EnduranceInfo as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_ENDURANCE_DATA_DESCRIPTOR), + "::", + stringify!(EnduranceInfo) + ) + ); +} +pub type STORAGE_HW_ENDURANCE_DATA_DESCRIPTOR = _STORAGE_HW_ENDURANCE_DATA_DESCRIPTOR; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _STORAGE_OFFLOAD_TOKEN { + pub TokenType: [BYTE; 4usize], + pub Reserved: [BYTE; 2usize], + pub TokenIdLength: [BYTE; 2usize], + pub __bindgen_anon_1: _STORAGE_OFFLOAD_TOKEN__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _STORAGE_OFFLOAD_TOKEN__bindgen_ty_1 { + pub StorageOffloadZeroDataToken: _STORAGE_OFFLOAD_TOKEN__bindgen_ty_1__bindgen_ty_1, + pub Token: [BYTE; 504usize], + _bindgen_union_align: [u8; 504usize], +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _STORAGE_OFFLOAD_TOKEN__bindgen_ty_1__bindgen_ty_1 { + pub Reserved2: [BYTE; 504usize], +} +#[test] +fn bindgen_test_layout__STORAGE_OFFLOAD_TOKEN__bindgen_ty_1__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_OFFLOAD_TOKEN__bindgen_ty_1__bindgen_ty_1>(), + 504usize, + concat!( + "Size of: ", + stringify!(_STORAGE_OFFLOAD_TOKEN__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_OFFLOAD_TOKEN__bindgen_ty_1__bindgen_ty_1>(), + 1usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_OFFLOAD_TOKEN__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_OFFLOAD_TOKEN__bindgen_ty_1__bindgen_ty_1>())).Reserved2 + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OFFLOAD_TOKEN__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(Reserved2) + ) + ); +} +#[test] +fn bindgen_test_layout__STORAGE_OFFLOAD_TOKEN__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_OFFLOAD_TOKEN__bindgen_ty_1>(), + 504usize, + concat!( + "Size of: ", + stringify!(_STORAGE_OFFLOAD_TOKEN__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_OFFLOAD_TOKEN__bindgen_ty_1>(), + 1usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_OFFLOAD_TOKEN__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_OFFLOAD_TOKEN__bindgen_ty_1>())).StorageOffloadZeroDataToken + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OFFLOAD_TOKEN__bindgen_ty_1), + "::", + stringify!(StorageOffloadZeroDataToken) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_OFFLOAD_TOKEN__bindgen_ty_1>())).Token as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OFFLOAD_TOKEN__bindgen_ty_1), + "::", + stringify!(Token) + ) + ); +} +#[test] +fn bindgen_test_layout__STORAGE_OFFLOAD_TOKEN() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_OFFLOAD_TOKEN>(), + 512usize, + concat!("Size of: ", stringify!(_STORAGE_OFFLOAD_TOKEN)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_OFFLOAD_TOKEN>(), + 1usize, + concat!("Alignment of ", stringify!(_STORAGE_OFFLOAD_TOKEN)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_OFFLOAD_TOKEN>())).TokenType as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OFFLOAD_TOKEN), + "::", + stringify!(TokenType) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_OFFLOAD_TOKEN>())).Reserved as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OFFLOAD_TOKEN), + "::", + stringify!(Reserved) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_OFFLOAD_TOKEN>())).TokenIdLength as *const _ as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OFFLOAD_TOKEN), + "::", + stringify!(TokenIdLength) + ) + ); +} +pub type STORAGE_OFFLOAD_TOKEN = _STORAGE_OFFLOAD_TOKEN; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _STORAGE_OFFLOAD_READ_OUTPUT { + pub OffloadReadFlags: DWORD, + pub Reserved: DWORD, + pub LengthProtected: DWORDLONG, + pub TokenLength: DWORD, + pub Token: STORAGE_OFFLOAD_TOKEN, +} +#[test] +fn bindgen_test_layout__STORAGE_OFFLOAD_READ_OUTPUT() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_OFFLOAD_READ_OUTPUT>(), + 536usize, + concat!("Size of: ", stringify!(_STORAGE_OFFLOAD_READ_OUTPUT)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_OFFLOAD_READ_OUTPUT>(), + 8usize, + concat!("Alignment of ", stringify!(_STORAGE_OFFLOAD_READ_OUTPUT)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_OFFLOAD_READ_OUTPUT>())).OffloadReadFlags as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OFFLOAD_READ_OUTPUT), + "::", + stringify!(OffloadReadFlags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_OFFLOAD_READ_OUTPUT>())).Reserved as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OFFLOAD_READ_OUTPUT), + "::", + stringify!(Reserved) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_OFFLOAD_READ_OUTPUT>())).LengthProtected as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OFFLOAD_READ_OUTPUT), + "::", + stringify!(LengthProtected) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_OFFLOAD_READ_OUTPUT>())).TokenLength as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OFFLOAD_READ_OUTPUT), + "::", + stringify!(TokenLength) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_OFFLOAD_READ_OUTPUT>())).Token as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OFFLOAD_READ_OUTPUT), + "::", + stringify!(Token) + ) + ); +} +pub type STORAGE_OFFLOAD_READ_OUTPUT = _STORAGE_OFFLOAD_READ_OUTPUT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_OFFLOAD_WRITE_OUTPUT { + pub OffloadWriteFlags: DWORD, + pub Reserved: DWORD, + pub LengthCopied: DWORDLONG, +} +#[test] +fn bindgen_test_layout__STORAGE_OFFLOAD_WRITE_OUTPUT() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_OFFLOAD_WRITE_OUTPUT>(), + 16usize, + concat!("Size of: ", stringify!(_STORAGE_OFFLOAD_WRITE_OUTPUT)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_OFFLOAD_WRITE_OUTPUT>(), + 8usize, + concat!("Alignment of ", stringify!(_STORAGE_OFFLOAD_WRITE_OUTPUT)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_OFFLOAD_WRITE_OUTPUT>())).OffloadWriteFlags as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OFFLOAD_WRITE_OUTPUT), + "::", + stringify!(OffloadWriteFlags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_OFFLOAD_WRITE_OUTPUT>())).Reserved as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OFFLOAD_WRITE_OUTPUT), + "::", + stringify!(Reserved) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_OFFLOAD_WRITE_OUTPUT>())).LengthCopied as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_OFFLOAD_WRITE_OUTPUT), + "::", + stringify!(LengthCopied) + ) + ); +} +pub type STORAGE_OFFLOAD_WRITE_OUTPUT = _STORAGE_OFFLOAD_WRITE_OUTPUT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_TIER_REGION { + pub TierId: GUID, + pub Offset: DWORDLONG, + pub Length: DWORDLONG, +} +#[test] +fn bindgen_test_layout__STORAGE_TIER_REGION() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_TIER_REGION>(), + 32usize, + concat!("Size of: ", stringify!(_STORAGE_TIER_REGION)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_TIER_REGION>(), + 8usize, + concat!("Alignment of ", stringify!(_STORAGE_TIER_REGION)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_TIER_REGION>())).TierId as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TIER_REGION), + "::", + stringify!(TierId) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_TIER_REGION>())).Offset as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TIER_REGION), + "::", + stringify!(Offset) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_TIER_REGION>())).Length as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_TIER_REGION), + "::", + stringify!(Length) + ) + ); +} +pub type STORAGE_TIER_REGION = _STORAGE_TIER_REGION; +pub const _STORAGE_ZONES_ATTRIBUTES_ZonesAttributeTypeAndLengthMayDifferent: + _STORAGE_ZONES_ATTRIBUTES = 0; +pub const _STORAGE_ZONES_ATTRIBUTES_ZonesAttributeTypeSameLengthSame: _STORAGE_ZONES_ATTRIBUTES = 1; +pub const _STORAGE_ZONES_ATTRIBUTES_ZonesAttributeTypeSameLastZoneLengthDifferent: + _STORAGE_ZONES_ATTRIBUTES = 2; +pub const _STORAGE_ZONES_ATTRIBUTES_ZonesAttributeTypeMayDifferentLengthSame: + _STORAGE_ZONES_ATTRIBUTES = 3; +pub type _STORAGE_ZONES_ATTRIBUTES = ::std::os::raw::c_int; +pub use self::_STORAGE_ZONES_ATTRIBUTES as STORAGE_ZONES_ATTRIBUTES; +pub const _STORAGE_ZONE_CONDITION_ZoneConditionConventional: _STORAGE_ZONE_CONDITION = 0; +pub const _STORAGE_ZONE_CONDITION_ZoneConditionEmpty: _STORAGE_ZONE_CONDITION = 1; +pub const _STORAGE_ZONE_CONDITION_ZoneConditionImplicitlyOpened: _STORAGE_ZONE_CONDITION = 2; +pub const _STORAGE_ZONE_CONDITION_ZoneConditionExplicitlyOpened: _STORAGE_ZONE_CONDITION = 3; +pub const _STORAGE_ZONE_CONDITION_ZoneConditionClosed: _STORAGE_ZONE_CONDITION = 4; +pub const _STORAGE_ZONE_CONDITION_ZoneConditionReadOnly: _STORAGE_ZONE_CONDITION = 13; +pub const _STORAGE_ZONE_CONDITION_ZoneConditionFull: _STORAGE_ZONE_CONDITION = 14; +pub const _STORAGE_ZONE_CONDITION_ZoneConditionOffline: _STORAGE_ZONE_CONDITION = 15; +pub type _STORAGE_ZONE_CONDITION = ::std::os::raw::c_int; +pub use self::_STORAGE_ZONE_CONDITION as STORAGE_ZONE_CONDITION; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_ZONE_DESCRIPTOR { + pub Size: DWORD, + pub ZoneType: STORAGE_ZONE_TYPES, + pub ZoneCondition: STORAGE_ZONE_CONDITION, + pub ResetWritePointerRecommend: BOOLEAN, + pub Reserved0: [BYTE; 3usize], + pub ZoneSize: DWORDLONG, + pub WritePointerOffset: DWORDLONG, +} +#[test] +fn bindgen_test_layout__STORAGE_ZONE_DESCRIPTOR() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_ZONE_DESCRIPTOR>(), + 32usize, + concat!("Size of: ", stringify!(_STORAGE_ZONE_DESCRIPTOR)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_ZONE_DESCRIPTOR>(), + 8usize, + concat!("Alignment of ", stringify!(_STORAGE_ZONE_DESCRIPTOR)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_ZONE_DESCRIPTOR>())).Size as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONE_DESCRIPTOR), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_ZONE_DESCRIPTOR>())).ZoneType as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONE_DESCRIPTOR), + "::", + stringify!(ZoneType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ZONE_DESCRIPTOR>())).ZoneCondition as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONE_DESCRIPTOR), + "::", + stringify!(ZoneCondition) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ZONE_DESCRIPTOR>())).ResetWritePointerRecommend as *const _ + as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONE_DESCRIPTOR), + "::", + stringify!(ResetWritePointerRecommend) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_ZONE_DESCRIPTOR>())).Reserved0 as *const _ as usize }, + 13usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONE_DESCRIPTOR), + "::", + stringify!(Reserved0) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_ZONE_DESCRIPTOR>())).ZoneSize as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONE_DESCRIPTOR), + "::", + stringify!(ZoneSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ZONE_DESCRIPTOR>())).WritePointerOffset as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ZONE_DESCRIPTOR), + "::", + stringify!(WritePointerOffset) + ) + ); +} +pub type STORAGE_ZONE_DESCRIPTOR = _STORAGE_ZONE_DESCRIPTOR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_GET_BC_PROPERTIES_OUTPUT { + pub MaximumRequestsPerPeriod: DWORD, + pub MinimumPeriod: DWORD, + pub MaximumRequestSize: DWORDLONG, + pub EstimatedTimePerRequest: DWORD, + pub NumOutStandingRequests: DWORD, + pub RequestSize: DWORDLONG, +} +#[test] +fn bindgen_test_layout__STORAGE_GET_BC_PROPERTIES_OUTPUT() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_GET_BC_PROPERTIES_OUTPUT>(), + 32usize, + concat!("Size of: ", stringify!(_STORAGE_GET_BC_PROPERTIES_OUTPUT)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_GET_BC_PROPERTIES_OUTPUT>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_GET_BC_PROPERTIES_OUTPUT) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_GET_BC_PROPERTIES_OUTPUT>())).MaximumRequestsPerPeriod + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_GET_BC_PROPERTIES_OUTPUT), + "::", + stringify!(MaximumRequestsPerPeriod) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_GET_BC_PROPERTIES_OUTPUT>())).MinimumPeriod as *const _ + as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_GET_BC_PROPERTIES_OUTPUT), + "::", + stringify!(MinimumPeriod) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_GET_BC_PROPERTIES_OUTPUT>())).MaximumRequestSize as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_GET_BC_PROPERTIES_OUTPUT), + "::", + stringify!(MaximumRequestSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_GET_BC_PROPERTIES_OUTPUT>())).EstimatedTimePerRequest + as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_GET_BC_PROPERTIES_OUTPUT), + "::", + stringify!(EstimatedTimePerRequest) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_GET_BC_PROPERTIES_OUTPUT>())).NumOutStandingRequests + as *const _ as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_GET_BC_PROPERTIES_OUTPUT), + "::", + stringify!(NumOutStandingRequests) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_GET_BC_PROPERTIES_OUTPUT>())).RequestSize as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_GET_BC_PROPERTIES_OUTPUT), + "::", + stringify!(RequestSize) + ) + ); +} +pub type STORAGE_GET_BC_PROPERTIES_OUTPUT = _STORAGE_GET_BC_PROPERTIES_OUTPUT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_ALLOCATE_BC_STREAM_INPUT { + pub Version: DWORD, + pub RequestsPerPeriod: DWORD, + pub Period: DWORD, + pub RetryFailures: BOOLEAN, + pub Discardable: BOOLEAN, + pub Reserved1: [BOOLEAN; 2usize], + pub AccessType: DWORD, + pub AccessMode: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_ALLOCATE_BC_STREAM_INPUT() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_ALLOCATE_BC_STREAM_INPUT>(), + 24usize, + concat!("Size of: ", stringify!(_STORAGE_ALLOCATE_BC_STREAM_INPUT)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_ALLOCATE_BC_STREAM_INPUT>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_ALLOCATE_BC_STREAM_INPUT) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ALLOCATE_BC_STREAM_INPUT>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ALLOCATE_BC_STREAM_INPUT), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ALLOCATE_BC_STREAM_INPUT>())).RequestsPerPeriod as *const _ + as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ALLOCATE_BC_STREAM_INPUT), + "::", + stringify!(RequestsPerPeriod) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ALLOCATE_BC_STREAM_INPUT>())).Period as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ALLOCATE_BC_STREAM_INPUT), + "::", + stringify!(Period) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ALLOCATE_BC_STREAM_INPUT>())).RetryFailures as *const _ + as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ALLOCATE_BC_STREAM_INPUT), + "::", + stringify!(RetryFailures) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ALLOCATE_BC_STREAM_INPUT>())).Discardable as *const _ as usize + }, + 13usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ALLOCATE_BC_STREAM_INPUT), + "::", + stringify!(Discardable) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ALLOCATE_BC_STREAM_INPUT>())).Reserved1 as *const _ as usize + }, + 14usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ALLOCATE_BC_STREAM_INPUT), + "::", + stringify!(Reserved1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ALLOCATE_BC_STREAM_INPUT>())).AccessType as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ALLOCATE_BC_STREAM_INPUT), + "::", + stringify!(AccessType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ALLOCATE_BC_STREAM_INPUT>())).AccessMode as *const _ as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ALLOCATE_BC_STREAM_INPUT), + "::", + stringify!(AccessMode) + ) + ); +} +pub type STORAGE_ALLOCATE_BC_STREAM_INPUT = _STORAGE_ALLOCATE_BC_STREAM_INPUT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_ALLOCATE_BC_STREAM_OUTPUT { + pub RequestSize: DWORDLONG, + pub NumOutStandingRequests: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_ALLOCATE_BC_STREAM_OUTPUT() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_ALLOCATE_BC_STREAM_OUTPUT>(), + 16usize, + concat!("Size of: ", stringify!(_STORAGE_ALLOCATE_BC_STREAM_OUTPUT)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_ALLOCATE_BC_STREAM_OUTPUT>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_ALLOCATE_BC_STREAM_OUTPUT) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ALLOCATE_BC_STREAM_OUTPUT>())).RequestSize as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ALLOCATE_BC_STREAM_OUTPUT), + "::", + stringify!(RequestSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_ALLOCATE_BC_STREAM_OUTPUT>())).NumOutStandingRequests + as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ALLOCATE_BC_STREAM_OUTPUT), + "::", + stringify!(NumOutStandingRequests) + ) + ); +} +pub type STORAGE_ALLOCATE_BC_STREAM_OUTPUT = _STORAGE_ALLOCATE_BC_STREAM_OUTPUT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_PRIORITY_HINT_SUPPORT { + pub SupportFlags: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_PRIORITY_HINT_SUPPORT() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_PRIORITY_HINT_SUPPORT>(), + 4usize, + concat!("Size of: ", stringify!(_STORAGE_PRIORITY_HINT_SUPPORT)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_PRIORITY_HINT_SUPPORT>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_PRIORITY_HINT_SUPPORT)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PRIORITY_HINT_SUPPORT>())).SupportFlags as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PRIORITY_HINT_SUPPORT), + "::", + stringify!(SupportFlags) + ) + ); +} +pub type STORAGE_PRIORITY_HINT_SUPPORT = _STORAGE_PRIORITY_HINT_SUPPORT; +pub const _STORAGE_DIAGNOSTIC_LEVEL_StorageDiagnosticLevelDefault: _STORAGE_DIAGNOSTIC_LEVEL = 0; +pub const _STORAGE_DIAGNOSTIC_LEVEL_StorageDiagnosticLevelMax: _STORAGE_DIAGNOSTIC_LEVEL = 1; +pub type _STORAGE_DIAGNOSTIC_LEVEL = ::std::os::raw::c_int; +pub use self::_STORAGE_DIAGNOSTIC_LEVEL as STORAGE_DIAGNOSTIC_LEVEL; +pub const _STORAGE_DIAGNOSTIC_TARGET_TYPE_StorageDiagnosticTargetTypeUndefined: + _STORAGE_DIAGNOSTIC_TARGET_TYPE = 0; +pub const _STORAGE_DIAGNOSTIC_TARGET_TYPE_StorageDiagnosticTargetTypePort: + _STORAGE_DIAGNOSTIC_TARGET_TYPE = 1; +pub const _STORAGE_DIAGNOSTIC_TARGET_TYPE_StorageDiagnosticTargetTypeMiniport: + _STORAGE_DIAGNOSTIC_TARGET_TYPE = 2; +pub const _STORAGE_DIAGNOSTIC_TARGET_TYPE_StorageDiagnosticTargetTypeHbaFirmware: + _STORAGE_DIAGNOSTIC_TARGET_TYPE = 3; +pub const _STORAGE_DIAGNOSTIC_TARGET_TYPE_StorageDiagnosticTargetTypeMax: + _STORAGE_DIAGNOSTIC_TARGET_TYPE = 4; +pub type _STORAGE_DIAGNOSTIC_TARGET_TYPE = ::std::os::raw::c_int; +pub use self::_STORAGE_DIAGNOSTIC_TARGET_TYPE as STORAGE_DIAGNOSTIC_TARGET_TYPE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_DIAGNOSTIC_REQUEST { + pub Version: DWORD, + pub Size: DWORD, + pub Reserved: DWORD, + pub TargetType: STORAGE_DIAGNOSTIC_TARGET_TYPE, + pub Level: STORAGE_DIAGNOSTIC_LEVEL, +} +#[test] +fn bindgen_test_layout__STORAGE_DIAGNOSTIC_REQUEST() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_DIAGNOSTIC_REQUEST>(), + 20usize, + concat!("Size of: ", stringify!(_STORAGE_DIAGNOSTIC_REQUEST)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_DIAGNOSTIC_REQUEST>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_DIAGNOSTIC_REQUEST)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DIAGNOSTIC_REQUEST>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DIAGNOSTIC_REQUEST), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DIAGNOSTIC_REQUEST>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DIAGNOSTIC_REQUEST), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DIAGNOSTIC_REQUEST>())).Reserved as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DIAGNOSTIC_REQUEST), + "::", + stringify!(Reserved) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DIAGNOSTIC_REQUEST>())).TargetType as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DIAGNOSTIC_REQUEST), + "::", + stringify!(TargetType) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DIAGNOSTIC_REQUEST>())).Level as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DIAGNOSTIC_REQUEST), + "::", + stringify!(Level) + ) + ); +} +pub type STORAGE_DIAGNOSTIC_REQUEST = _STORAGE_DIAGNOSTIC_REQUEST; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_DIAGNOSTIC_DATA { + pub Version: DWORD, + pub Size: DWORD, + pub ProviderId: GUID, + pub BufferSize: DWORD, + pub Reserved: DWORD, + pub DiagnosticDataBuffer: [BYTE; 1usize], +} +#[test] +fn bindgen_test_layout__STORAGE_DIAGNOSTIC_DATA() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_DIAGNOSTIC_DATA>(), + 36usize, + concat!("Size of: ", stringify!(_STORAGE_DIAGNOSTIC_DATA)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_DIAGNOSTIC_DATA>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_DIAGNOSTIC_DATA)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DIAGNOSTIC_DATA>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DIAGNOSTIC_DATA), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DIAGNOSTIC_DATA>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DIAGNOSTIC_DATA), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DIAGNOSTIC_DATA>())).ProviderId as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DIAGNOSTIC_DATA), + "::", + stringify!(ProviderId) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DIAGNOSTIC_DATA>())).BufferSize as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DIAGNOSTIC_DATA), + "::", + stringify!(BufferSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DIAGNOSTIC_DATA>())).Reserved as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DIAGNOSTIC_DATA), + "::", + stringify!(Reserved) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_DIAGNOSTIC_DATA>())).DiagnosticDataBuffer as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DIAGNOSTIC_DATA), + "::", + stringify!(DiagnosticDataBuffer) + ) + ); +} +pub type STORAGE_DIAGNOSTIC_DATA = _STORAGE_DIAGNOSTIC_DATA; +#[repr(C)] +#[derive(Debug)] +pub struct _STORAGE_MEDIA_SERIAL_NUMBER_DATA { + pub Reserved: WORD, + pub SerialNumberLength: WORD, + pub SerialNumber: __IncompleteArrayField, +} +#[test] +fn bindgen_test_layout__STORAGE_MEDIA_SERIAL_NUMBER_DATA() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_MEDIA_SERIAL_NUMBER_DATA>(), + 4usize, + concat!("Size of: ", stringify!(_STORAGE_MEDIA_SERIAL_NUMBER_DATA)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_MEDIA_SERIAL_NUMBER_DATA>(), + 2usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_MEDIA_SERIAL_NUMBER_DATA) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_MEDIA_SERIAL_NUMBER_DATA>())).Reserved as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_MEDIA_SERIAL_NUMBER_DATA), + "::", + stringify!(Reserved) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_MEDIA_SERIAL_NUMBER_DATA>())).SerialNumberLength as *const _ + as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_MEDIA_SERIAL_NUMBER_DATA), + "::", + stringify!(SerialNumberLength) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_MEDIA_SERIAL_NUMBER_DATA>())).SerialNumber as *const _ + as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_MEDIA_SERIAL_NUMBER_DATA), + "::", + stringify!(SerialNumber) + ) + ); +} +pub type STORAGE_MEDIA_SERIAL_NUMBER_DATA = _STORAGE_MEDIA_SERIAL_NUMBER_DATA; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _STORAGE_READ_CAPACITY { + pub Version: DWORD, + pub Size: DWORD, + pub BlockLength: DWORD, + pub NumberOfBlocks: LARGE_INTEGER, + pub DiskLength: LARGE_INTEGER, +} +#[test] +fn bindgen_test_layout__STORAGE_READ_CAPACITY() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_READ_CAPACITY>(), + 32usize, + concat!("Size of: ", stringify!(_STORAGE_READ_CAPACITY)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_READ_CAPACITY>(), + 8usize, + concat!("Alignment of ", stringify!(_STORAGE_READ_CAPACITY)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_READ_CAPACITY>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_READ_CAPACITY), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_READ_CAPACITY>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_READ_CAPACITY), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_READ_CAPACITY>())).BlockLength as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_READ_CAPACITY), + "::", + stringify!(BlockLength) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_READ_CAPACITY>())).NumberOfBlocks as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_READ_CAPACITY), + "::", + stringify!(NumberOfBlocks) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_READ_CAPACITY>())).DiskLength as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_READ_CAPACITY), + "::", + stringify!(DiskLength) + ) + ); +} +pub type STORAGE_READ_CAPACITY = _STORAGE_READ_CAPACITY; +pub const _WRITE_CACHE_TYPE_WriteCacheTypeUnknown: _WRITE_CACHE_TYPE = 0; +pub const _WRITE_CACHE_TYPE_WriteCacheTypeNone: _WRITE_CACHE_TYPE = 1; +pub const _WRITE_CACHE_TYPE_WriteCacheTypeWriteBack: _WRITE_CACHE_TYPE = 2; +pub const _WRITE_CACHE_TYPE_WriteCacheTypeWriteThrough: _WRITE_CACHE_TYPE = 3; +pub type _WRITE_CACHE_TYPE = ::std::os::raw::c_int; +pub use self::_WRITE_CACHE_TYPE as WRITE_CACHE_TYPE; +pub const _WRITE_CACHE_ENABLE_WriteCacheEnableUnknown: _WRITE_CACHE_ENABLE = 0; +pub const _WRITE_CACHE_ENABLE_WriteCacheDisabled: _WRITE_CACHE_ENABLE = 1; +pub const _WRITE_CACHE_ENABLE_WriteCacheEnabled: _WRITE_CACHE_ENABLE = 2; +pub type _WRITE_CACHE_ENABLE = ::std::os::raw::c_int; +pub use self::_WRITE_CACHE_ENABLE as WRITE_CACHE_ENABLE; +pub const _WRITE_CACHE_CHANGE_WriteCacheChangeUnknown: _WRITE_CACHE_CHANGE = 0; +pub const _WRITE_CACHE_CHANGE_WriteCacheNotChangeable: _WRITE_CACHE_CHANGE = 1; +pub const _WRITE_CACHE_CHANGE_WriteCacheChangeable: _WRITE_CACHE_CHANGE = 2; +pub type _WRITE_CACHE_CHANGE = ::std::os::raw::c_int; +pub use self::_WRITE_CACHE_CHANGE as WRITE_CACHE_CHANGE; +pub const _WRITE_THROUGH_WriteThroughUnknown: _WRITE_THROUGH = 0; +pub const _WRITE_THROUGH_WriteThroughNotSupported: _WRITE_THROUGH = 1; +pub const _WRITE_THROUGH_WriteThroughSupported: _WRITE_THROUGH = 2; +pub type _WRITE_THROUGH = ::std::os::raw::c_int; +pub use self::_WRITE_THROUGH as WRITE_THROUGH; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_WRITE_CACHE_PROPERTY { + pub Version: DWORD, + pub Size: DWORD, + pub WriteCacheType: WRITE_CACHE_TYPE, + pub WriteCacheEnabled: WRITE_CACHE_ENABLE, + pub WriteCacheChangeable: WRITE_CACHE_CHANGE, + pub WriteThroughSupported: WRITE_THROUGH, + pub FlushCacheSupported: BOOLEAN, + pub UserDefinedPowerProtection: BOOLEAN, + pub NVCacheEnabled: BOOLEAN, +} +#[test] +fn bindgen_test_layout__STORAGE_WRITE_CACHE_PROPERTY() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_WRITE_CACHE_PROPERTY>(), + 28usize, + concat!("Size of: ", stringify!(_STORAGE_WRITE_CACHE_PROPERTY)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_WRITE_CACHE_PROPERTY>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_WRITE_CACHE_PROPERTY)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_WRITE_CACHE_PROPERTY>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_WRITE_CACHE_PROPERTY), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_WRITE_CACHE_PROPERTY>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_WRITE_CACHE_PROPERTY), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_WRITE_CACHE_PROPERTY>())).WriteCacheType as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_WRITE_CACHE_PROPERTY), + "::", + stringify!(WriteCacheType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_WRITE_CACHE_PROPERTY>())).WriteCacheEnabled as *const _ + as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_WRITE_CACHE_PROPERTY), + "::", + stringify!(WriteCacheEnabled) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_WRITE_CACHE_PROPERTY>())).WriteCacheChangeable as *const _ + as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_WRITE_CACHE_PROPERTY), + "::", + stringify!(WriteCacheChangeable) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_WRITE_CACHE_PROPERTY>())).WriteThroughSupported as *const _ + as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_WRITE_CACHE_PROPERTY), + "::", + stringify!(WriteThroughSupported) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_WRITE_CACHE_PROPERTY>())).FlushCacheSupported as *const _ + as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_WRITE_CACHE_PROPERTY), + "::", + stringify!(FlushCacheSupported) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_WRITE_CACHE_PROPERTY>())).UserDefinedPowerProtection + as *const _ as usize + }, + 25usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_WRITE_CACHE_PROPERTY), + "::", + stringify!(UserDefinedPowerProtection) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_WRITE_CACHE_PROPERTY>())).NVCacheEnabled as *const _ as usize + }, + 26usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_WRITE_CACHE_PROPERTY), + "::", + stringify!(NVCacheEnabled) + ) + ); +} +pub type STORAGE_WRITE_CACHE_PROPERTY = _STORAGE_WRITE_CACHE_PROPERTY; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_IDLE_POWER { + pub Version: DWORD, + pub Size: DWORD, + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize], u32>, + pub D3IdleTimeout: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_IDLE_POWER() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_IDLE_POWER>(), + 16usize, + concat!("Size of: ", stringify!(_STORAGE_IDLE_POWER)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_IDLE_POWER>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_IDLE_POWER)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_IDLE_POWER>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_IDLE_POWER), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_IDLE_POWER>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_IDLE_POWER), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_IDLE_POWER>())).D3IdleTimeout as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_IDLE_POWER), + "::", + stringify!(D3IdleTimeout) + ) + ); +} +impl _STORAGE_IDLE_POWER { + #[inline] + pub fn WakeCapableHint(&self) -> DWORD { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } + } + #[inline] + pub fn set_WakeCapableHint(&mut self, val: DWORD) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn D3ColdSupported(&self) -> DWORD { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u32) } + } + #[inline] + pub fn set_D3ColdSupported(&mut self, val: DWORD) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn Reserved(&self) -> DWORD { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 30u8) as u32) } + } + #[inline] + pub fn set_Reserved(&mut self, val: DWORD) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 30u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + WakeCapableHint: DWORD, + D3ColdSupported: DWORD, + Reserved: DWORD, + ) -> __BindgenBitfieldUnit<[u8; 4usize], u32> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize], u32> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let WakeCapableHint: u32 = unsafe { ::std::mem::transmute(WakeCapableHint) }; + WakeCapableHint as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let D3ColdSupported: u32 = unsafe { ::std::mem::transmute(D3ColdSupported) }; + D3ColdSupported as u64 + }); + __bindgen_bitfield_unit.set(2usize, 30u8, { + let Reserved: u32 = unsafe { ::std::mem::transmute(Reserved) }; + Reserved as u64 + }); + __bindgen_bitfield_unit + } +} +pub type STORAGE_IDLE_POWER = _STORAGE_IDLE_POWER; +pub const _STORAGE_POWERUP_REASON_TYPE_StoragePowerupUnknown: _STORAGE_POWERUP_REASON_TYPE = 0; +pub const _STORAGE_POWERUP_REASON_TYPE_StoragePowerupIO: _STORAGE_POWERUP_REASON_TYPE = 1; +pub const _STORAGE_POWERUP_REASON_TYPE_StoragePowerupDeviceAttention: _STORAGE_POWERUP_REASON_TYPE = + 2; +pub type _STORAGE_POWERUP_REASON_TYPE = ::std::os::raw::c_int; +pub use self::_STORAGE_POWERUP_REASON_TYPE as STORAGE_POWERUP_REASON_TYPE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_IDLE_POWERUP_REASON { + pub Version: DWORD, + pub Size: DWORD, + pub PowerupReason: STORAGE_POWERUP_REASON_TYPE, +} +#[test] +fn bindgen_test_layout__STORAGE_IDLE_POWERUP_REASON() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_IDLE_POWERUP_REASON>(), + 12usize, + concat!("Size of: ", stringify!(_STORAGE_IDLE_POWERUP_REASON)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_IDLE_POWERUP_REASON>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_IDLE_POWERUP_REASON)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_IDLE_POWERUP_REASON>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_IDLE_POWERUP_REASON), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_IDLE_POWERUP_REASON>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_IDLE_POWERUP_REASON), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_IDLE_POWERUP_REASON>())).PowerupReason as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_IDLE_POWERUP_REASON), + "::", + stringify!(PowerupReason) + ) + ); +} +pub type STORAGE_IDLE_POWERUP_REASON = _STORAGE_IDLE_POWERUP_REASON; +pub const _STORAGE_DEVICE_POWER_CAP_UNITS_StorageDevicePowerCapUnitsPercent: + _STORAGE_DEVICE_POWER_CAP_UNITS = 0; +pub const _STORAGE_DEVICE_POWER_CAP_UNITS_StorageDevicePowerCapUnitsMilliwatts: + _STORAGE_DEVICE_POWER_CAP_UNITS = 1; +pub type _STORAGE_DEVICE_POWER_CAP_UNITS = ::std::os::raw::c_int; +pub use self::_STORAGE_DEVICE_POWER_CAP_UNITS as STORAGE_DEVICE_POWER_CAP_UNITS; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_DEVICE_POWER_CAP { + pub Version: DWORD, + pub Size: DWORD, + pub Units: STORAGE_DEVICE_POWER_CAP_UNITS, + pub MaxPower: DWORDLONG, +} +#[test] +fn bindgen_test_layout__STORAGE_DEVICE_POWER_CAP() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_DEVICE_POWER_CAP>(), + 24usize, + concat!("Size of: ", stringify!(_STORAGE_DEVICE_POWER_CAP)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_DEVICE_POWER_CAP>(), + 8usize, + concat!("Alignment of ", stringify!(_STORAGE_DEVICE_POWER_CAP)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DEVICE_POWER_CAP>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_POWER_CAP), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DEVICE_POWER_CAP>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_POWER_CAP), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DEVICE_POWER_CAP>())).Units as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_POWER_CAP), + "::", + stringify!(Units) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_DEVICE_POWER_CAP>())).MaxPower as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_DEVICE_POWER_CAP), + "::", + stringify!(MaxPower) + ) + ); +} +pub type STORAGE_DEVICE_POWER_CAP = _STORAGE_DEVICE_POWER_CAP; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _STORAGE_RPMB_DATA_FRAME { + pub Stuff: [BYTE; 196usize], + pub KeyOrMAC: [BYTE; 32usize], + pub Data: [BYTE; 256usize], + pub Nonce: [BYTE; 16usize], + pub WriteCounter: [BYTE; 4usize], + pub Address: [BYTE; 2usize], + pub BlockCount: [BYTE; 2usize], + pub OperationResult: [BYTE; 2usize], + pub RequestOrResponseType: [BYTE; 2usize], +} +#[test] +fn bindgen_test_layout__STORAGE_RPMB_DATA_FRAME() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_RPMB_DATA_FRAME>(), + 512usize, + concat!("Size of: ", stringify!(_STORAGE_RPMB_DATA_FRAME)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_RPMB_DATA_FRAME>(), + 1usize, + concat!("Alignment of ", stringify!(_STORAGE_RPMB_DATA_FRAME)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_RPMB_DATA_FRAME>())).Stuff as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_RPMB_DATA_FRAME), + "::", + stringify!(Stuff) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_RPMB_DATA_FRAME>())).KeyOrMAC as *const _ as usize }, + 196usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_RPMB_DATA_FRAME), + "::", + stringify!(KeyOrMAC) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_RPMB_DATA_FRAME>())).Data as *const _ as usize }, + 228usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_RPMB_DATA_FRAME), + "::", + stringify!(Data) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_RPMB_DATA_FRAME>())).Nonce as *const _ as usize }, + 484usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_RPMB_DATA_FRAME), + "::", + stringify!(Nonce) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_RPMB_DATA_FRAME>())).WriteCounter as *const _ as usize + }, + 500usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_RPMB_DATA_FRAME), + "::", + stringify!(WriteCounter) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_RPMB_DATA_FRAME>())).Address as *const _ as usize }, + 504usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_RPMB_DATA_FRAME), + "::", + stringify!(Address) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_RPMB_DATA_FRAME>())).BlockCount as *const _ as usize }, + 506usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_RPMB_DATA_FRAME), + "::", + stringify!(BlockCount) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_RPMB_DATA_FRAME>())).OperationResult as *const _ as usize + }, + 508usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_RPMB_DATA_FRAME), + "::", + stringify!(OperationResult) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_RPMB_DATA_FRAME>())).RequestOrResponseType as *const _ + as usize + }, + 510usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_RPMB_DATA_FRAME), + "::", + stringify!(RequestOrResponseType) + ) + ); +} +pub type STORAGE_RPMB_DATA_FRAME = _STORAGE_RPMB_DATA_FRAME; +pub const _STORAGE_RPMB_COMMAND_TYPE_StorRpmbProgramAuthKey: _STORAGE_RPMB_COMMAND_TYPE = 1; +pub const _STORAGE_RPMB_COMMAND_TYPE_StorRpmbQueryWriteCounter: _STORAGE_RPMB_COMMAND_TYPE = 2; +pub const _STORAGE_RPMB_COMMAND_TYPE_StorRpmbAuthenticatedWrite: _STORAGE_RPMB_COMMAND_TYPE = 3; +pub const _STORAGE_RPMB_COMMAND_TYPE_StorRpmbAuthenticatedRead: _STORAGE_RPMB_COMMAND_TYPE = 4; +pub const _STORAGE_RPMB_COMMAND_TYPE_StorRpmbReadResultRequest: _STORAGE_RPMB_COMMAND_TYPE = 5; +pub const _STORAGE_RPMB_COMMAND_TYPE_StorRpmbAuthenticatedDeviceConfigWrite: + _STORAGE_RPMB_COMMAND_TYPE = 6; +pub const _STORAGE_RPMB_COMMAND_TYPE_StorRpmbAuthenticatedDeviceConfigRead: + _STORAGE_RPMB_COMMAND_TYPE = 7; +pub type _STORAGE_RPMB_COMMAND_TYPE = ::std::os::raw::c_int; +pub use self::_STORAGE_RPMB_COMMAND_TYPE as STORAGE_RPMB_COMMAND_TYPE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_EVENT_NOTIFICATION { + pub Version: DWORD, + pub Size: DWORD, + pub Events: DWORDLONG, +} +#[test] +fn bindgen_test_layout__STORAGE_EVENT_NOTIFICATION() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_EVENT_NOTIFICATION>(), + 16usize, + concat!("Size of: ", stringify!(_STORAGE_EVENT_NOTIFICATION)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_EVENT_NOTIFICATION>(), + 8usize, + concat!("Alignment of ", stringify!(_STORAGE_EVENT_NOTIFICATION)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_EVENT_NOTIFICATION>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_EVENT_NOTIFICATION), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_EVENT_NOTIFICATION>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_EVENT_NOTIFICATION), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_EVENT_NOTIFICATION>())).Events as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_EVENT_NOTIFICATION), + "::", + stringify!(Events) + ) + ); +} +pub type STORAGE_EVENT_NOTIFICATION = _STORAGE_EVENT_NOTIFICATION; +pub const _STORAGE_COUNTER_TYPE_StorageCounterTypeUnknown: _STORAGE_COUNTER_TYPE = 0; +pub const _STORAGE_COUNTER_TYPE_StorageCounterTypeTemperatureCelsius: _STORAGE_COUNTER_TYPE = 1; +pub const _STORAGE_COUNTER_TYPE_StorageCounterTypeTemperatureCelsiusMax: _STORAGE_COUNTER_TYPE = 2; +pub const _STORAGE_COUNTER_TYPE_StorageCounterTypeReadErrorsTotal: _STORAGE_COUNTER_TYPE = 3; +pub const _STORAGE_COUNTER_TYPE_StorageCounterTypeReadErrorsCorrected: _STORAGE_COUNTER_TYPE = 4; +pub const _STORAGE_COUNTER_TYPE_StorageCounterTypeReadErrorsUncorrected: _STORAGE_COUNTER_TYPE = 5; +pub const _STORAGE_COUNTER_TYPE_StorageCounterTypeWriteErrorsTotal: _STORAGE_COUNTER_TYPE = 6; +pub const _STORAGE_COUNTER_TYPE_StorageCounterTypeWriteErrorsCorrected: _STORAGE_COUNTER_TYPE = 7; +pub const _STORAGE_COUNTER_TYPE_StorageCounterTypeWriteErrorsUncorrected: _STORAGE_COUNTER_TYPE = 8; +pub const _STORAGE_COUNTER_TYPE_StorageCounterTypeManufactureDate: _STORAGE_COUNTER_TYPE = 9; +pub const _STORAGE_COUNTER_TYPE_StorageCounterTypeStartStopCycleCount: _STORAGE_COUNTER_TYPE = 10; +pub const _STORAGE_COUNTER_TYPE_StorageCounterTypeStartStopCycleCountMax: _STORAGE_COUNTER_TYPE = + 11; +pub const _STORAGE_COUNTER_TYPE_StorageCounterTypeLoadUnloadCycleCount: _STORAGE_COUNTER_TYPE = 12; +pub const _STORAGE_COUNTER_TYPE_StorageCounterTypeLoadUnloadCycleCountMax: _STORAGE_COUNTER_TYPE = + 13; +pub const _STORAGE_COUNTER_TYPE_StorageCounterTypeWearPercentage: _STORAGE_COUNTER_TYPE = 14; +pub const _STORAGE_COUNTER_TYPE_StorageCounterTypeWearPercentageWarning: _STORAGE_COUNTER_TYPE = 15; +pub const _STORAGE_COUNTER_TYPE_StorageCounterTypeWearPercentageMax: _STORAGE_COUNTER_TYPE = 16; +pub const _STORAGE_COUNTER_TYPE_StorageCounterTypePowerOnHours: _STORAGE_COUNTER_TYPE = 17; +pub const _STORAGE_COUNTER_TYPE_StorageCounterTypeReadLatency100NSMax: _STORAGE_COUNTER_TYPE = 18; +pub const _STORAGE_COUNTER_TYPE_StorageCounterTypeWriteLatency100NSMax: _STORAGE_COUNTER_TYPE = 19; +pub const _STORAGE_COUNTER_TYPE_StorageCounterTypeFlushLatency100NSMax: _STORAGE_COUNTER_TYPE = 20; +pub const _STORAGE_COUNTER_TYPE_StorageCounterTypeMax: _STORAGE_COUNTER_TYPE = 21; +pub type _STORAGE_COUNTER_TYPE = ::std::os::raw::c_int; +pub use self::_STORAGE_COUNTER_TYPE as STORAGE_COUNTER_TYPE; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _STORAGE_COUNTER { + pub Type: STORAGE_COUNTER_TYPE, + pub Value: _STORAGE_COUNTER__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _STORAGE_COUNTER__bindgen_ty_1 { + pub ManufactureDate: _STORAGE_COUNTER__bindgen_ty_1__bindgen_ty_1, + pub AsUlonglong: DWORDLONG, + _bindgen_union_align: u64, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_COUNTER__bindgen_ty_1__bindgen_ty_1 { + pub Week: DWORD, + pub Year: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_COUNTER__bindgen_ty_1__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_COUNTER__bindgen_ty_1__bindgen_ty_1>(), + 8usize, + concat!( + "Size of: ", + stringify!(_STORAGE_COUNTER__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_COUNTER__bindgen_ty_1__bindgen_ty_1>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_COUNTER__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_COUNTER__bindgen_ty_1__bindgen_ty_1>())).Week as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_COUNTER__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(Week) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_COUNTER__bindgen_ty_1__bindgen_ty_1>())).Year as *const _ + as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_COUNTER__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(Year) + ) + ); +} +#[test] +fn bindgen_test_layout__STORAGE_COUNTER__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_COUNTER__bindgen_ty_1>(), + 8usize, + concat!("Size of: ", stringify!(_STORAGE_COUNTER__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_COUNTER__bindgen_ty_1>(), + 8usize, + concat!("Alignment of ", stringify!(_STORAGE_COUNTER__bindgen_ty_1)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_COUNTER__bindgen_ty_1>())).ManufactureDate as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_COUNTER__bindgen_ty_1), + "::", + stringify!(ManufactureDate) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_COUNTER__bindgen_ty_1>())).AsUlonglong as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_COUNTER__bindgen_ty_1), + "::", + stringify!(AsUlonglong) + ) + ); +} +#[test] +fn bindgen_test_layout__STORAGE_COUNTER() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_COUNTER>(), + 16usize, + concat!("Size of: ", stringify!(_STORAGE_COUNTER)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_COUNTER>(), + 8usize, + concat!("Alignment of ", stringify!(_STORAGE_COUNTER)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_COUNTER>())).Type as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_COUNTER), + "::", + stringify!(Type) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_COUNTER>())).Value as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_COUNTER), + "::", + stringify!(Value) + ) + ); +} +pub type STORAGE_COUNTER = _STORAGE_COUNTER; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _STORAGE_COUNTERS { + pub Version: DWORD, + pub Size: DWORD, + pub NumberOfCounters: DWORD, + pub Counters: [STORAGE_COUNTER; 1usize], +} +#[test] +fn bindgen_test_layout__STORAGE_COUNTERS() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_COUNTERS>(), + 32usize, + concat!("Size of: ", stringify!(_STORAGE_COUNTERS)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_COUNTERS>(), + 8usize, + concat!("Alignment of ", stringify!(_STORAGE_COUNTERS)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_COUNTERS>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_COUNTERS), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_COUNTERS>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_COUNTERS), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_COUNTERS>())).NumberOfCounters as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_COUNTERS), + "::", + stringify!(NumberOfCounters) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_COUNTERS>())).Counters as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_COUNTERS), + "::", + stringify!(Counters) + ) + ); +} +pub type STORAGE_COUNTERS = _STORAGE_COUNTERS; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_HW_FIRMWARE_INFO_QUERY { + pub Version: DWORD, + pub Size: DWORD, + pub Flags: DWORD, + pub Reserved: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_HW_FIRMWARE_INFO_QUERY() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_HW_FIRMWARE_INFO_QUERY>(), + 16usize, + concat!("Size of: ", stringify!(_STORAGE_HW_FIRMWARE_INFO_QUERY)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_HW_FIRMWARE_INFO_QUERY>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_HW_FIRMWARE_INFO_QUERY)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_INFO_QUERY>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_INFO_QUERY), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_INFO_QUERY>())).Size as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_INFO_QUERY), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_INFO_QUERY>())).Flags as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_INFO_QUERY), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_INFO_QUERY>())).Reserved as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_INFO_QUERY), + "::", + stringify!(Reserved) + ) + ); +} +pub type STORAGE_HW_FIRMWARE_INFO_QUERY = _STORAGE_HW_FIRMWARE_INFO_QUERY; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_HW_FIRMWARE_SLOT_INFO { + pub Version: DWORD, + pub Size: DWORD, + pub SlotNumber: BYTE, + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>, + pub Reserved1: [BYTE; 6usize], + pub Revision: [BYTE; 16usize], +} +#[test] +fn bindgen_test_layout__STORAGE_HW_FIRMWARE_SLOT_INFO() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_HW_FIRMWARE_SLOT_INFO>(), + 32usize, + concat!("Size of: ", stringify!(_STORAGE_HW_FIRMWARE_SLOT_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_HW_FIRMWARE_SLOT_INFO>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_HW_FIRMWARE_SLOT_INFO)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_SLOT_INFO>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_SLOT_INFO), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_SLOT_INFO>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_SLOT_INFO), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_SLOT_INFO>())).SlotNumber as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_SLOT_INFO), + "::", + stringify!(SlotNumber) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_SLOT_INFO>())).Reserved1 as *const _ as usize + }, + 10usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_SLOT_INFO), + "::", + stringify!(Reserved1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_SLOT_INFO>())).Revision as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_SLOT_INFO), + "::", + stringify!(Revision) + ) + ); +} +impl _STORAGE_HW_FIRMWARE_SLOT_INFO { + #[inline] + pub fn ReadOnly(&self) -> BYTE { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_ReadOnly(&mut self, val: BYTE) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn Reserved0(&self) -> BYTE { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 7u8) as u8) } + } + #[inline] + pub fn set_Reserved0(&mut self, val: BYTE) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 7u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + ReadOnly: BYTE, + Reserved0: BYTE, + ) -> __BindgenBitfieldUnit<[u8; 1usize], u8> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize], u8> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let ReadOnly: u8 = unsafe { ::std::mem::transmute(ReadOnly) }; + ReadOnly as u64 + }); + __bindgen_bitfield_unit.set(1usize, 7u8, { + let Reserved0: u8 = unsafe { ::std::mem::transmute(Reserved0) }; + Reserved0 as u64 + }); + __bindgen_bitfield_unit + } +} +pub type STORAGE_HW_FIRMWARE_SLOT_INFO = _STORAGE_HW_FIRMWARE_SLOT_INFO; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_HW_FIRMWARE_INFO { + pub Version: DWORD, + pub Size: DWORD, + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>, + pub SlotCount: BYTE, + pub ActiveSlot: BYTE, + pub PendingActivateSlot: BYTE, + pub FirmwareShared: BOOLEAN, + pub Reserved: [BYTE; 3usize], + pub ImagePayloadAlignment: DWORD, + pub ImagePayloadMaxSize: DWORD, + pub Slot: [STORAGE_HW_FIRMWARE_SLOT_INFO; 1usize], +} +#[test] +fn bindgen_test_layout__STORAGE_HW_FIRMWARE_INFO() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_HW_FIRMWARE_INFO>(), + 56usize, + concat!("Size of: ", stringify!(_STORAGE_HW_FIRMWARE_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_HW_FIRMWARE_INFO>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_HW_FIRMWARE_INFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_INFO>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_INFO), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_INFO>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_INFO), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_INFO>())).SlotCount as *const _ as usize }, + 9usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_INFO), + "::", + stringify!(SlotCount) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_INFO>())).ActiveSlot as *const _ as usize + }, + 10usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_INFO), + "::", + stringify!(ActiveSlot) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_INFO>())).PendingActivateSlot as *const _ as usize + }, + 11usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_INFO), + "::", + stringify!(PendingActivateSlot) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_INFO>())).FirmwareShared as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_INFO), + "::", + stringify!(FirmwareShared) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_INFO>())).Reserved as *const _ as usize }, + 13usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_INFO), + "::", + stringify!(Reserved) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_INFO>())).ImagePayloadAlignment as *const _ + as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_INFO), + "::", + stringify!(ImagePayloadAlignment) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_INFO>())).ImagePayloadMaxSize as *const _ as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_INFO), + "::", + stringify!(ImagePayloadMaxSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_INFO>())).Slot as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_INFO), + "::", + stringify!(Slot) + ) + ); +} +impl _STORAGE_HW_FIRMWARE_INFO { + #[inline] + pub fn SupportUpgrade(&self) -> BYTE { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_SupportUpgrade(&mut self, val: BYTE) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn Reserved0(&self) -> BYTE { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 7u8) as u8) } + } + #[inline] + pub fn set_Reserved0(&mut self, val: BYTE) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 7u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + SupportUpgrade: BYTE, + Reserved0: BYTE, + ) -> __BindgenBitfieldUnit<[u8; 1usize], u8> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize], u8> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let SupportUpgrade: u8 = unsafe { ::std::mem::transmute(SupportUpgrade) }; + SupportUpgrade as u64 + }); + __bindgen_bitfield_unit.set(1usize, 7u8, { + let Reserved0: u8 = unsafe { ::std::mem::transmute(Reserved0) }; + Reserved0 as u64 + }); + __bindgen_bitfield_unit + } +} +pub type STORAGE_HW_FIRMWARE_INFO = _STORAGE_HW_FIRMWARE_INFO; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_HW_FIRMWARE_DOWNLOAD { + pub Version: DWORD, + pub Size: DWORD, + pub Flags: DWORD, + pub Slot: BYTE, + pub Reserved: [BYTE; 3usize], + pub Offset: DWORDLONG, + pub BufferSize: DWORDLONG, + pub ImageBuffer: [BYTE; 1usize], +} +#[test] +fn bindgen_test_layout__STORAGE_HW_FIRMWARE_DOWNLOAD() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_HW_FIRMWARE_DOWNLOAD>(), + 40usize, + concat!("Size of: ", stringify!(_STORAGE_HW_FIRMWARE_DOWNLOAD)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_HW_FIRMWARE_DOWNLOAD>(), + 8usize, + concat!("Alignment of ", stringify!(_STORAGE_HW_FIRMWARE_DOWNLOAD)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_DOWNLOAD>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_DOWNLOAD), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_DOWNLOAD>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_DOWNLOAD), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_DOWNLOAD>())).Flags as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_DOWNLOAD), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_DOWNLOAD>())).Slot as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_DOWNLOAD), + "::", + stringify!(Slot) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_DOWNLOAD>())).Reserved as *const _ as usize + }, + 13usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_DOWNLOAD), + "::", + stringify!(Reserved) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_DOWNLOAD>())).Offset as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_DOWNLOAD), + "::", + stringify!(Offset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_DOWNLOAD>())).BufferSize as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_DOWNLOAD), + "::", + stringify!(BufferSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_DOWNLOAD>())).ImageBuffer as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_DOWNLOAD), + "::", + stringify!(ImageBuffer) + ) + ); +} +pub type STORAGE_HW_FIRMWARE_DOWNLOAD = _STORAGE_HW_FIRMWARE_DOWNLOAD; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_HW_FIRMWARE_DOWNLOAD_V2 { + pub Version: DWORD, + pub Size: DWORD, + pub Flags: DWORD, + pub Slot: BYTE, + pub Reserved: [BYTE; 3usize], + pub Offset: DWORDLONG, + pub BufferSize: DWORDLONG, + pub ImageSize: DWORD, + pub Reserved2: DWORD, + pub ImageBuffer: [BYTE; 1usize], +} +#[test] +fn bindgen_test_layout__STORAGE_HW_FIRMWARE_DOWNLOAD_V2() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_HW_FIRMWARE_DOWNLOAD_V2>(), + 48usize, + concat!("Size of: ", stringify!(_STORAGE_HW_FIRMWARE_DOWNLOAD_V2)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_HW_FIRMWARE_DOWNLOAD_V2>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_HW_FIRMWARE_DOWNLOAD_V2) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_DOWNLOAD_V2>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_DOWNLOAD_V2), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_DOWNLOAD_V2>())).Size as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_DOWNLOAD_V2), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_DOWNLOAD_V2>())).Flags as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_DOWNLOAD_V2), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_DOWNLOAD_V2>())).Slot as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_DOWNLOAD_V2), + "::", + stringify!(Slot) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_DOWNLOAD_V2>())).Reserved as *const _ as usize + }, + 13usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_DOWNLOAD_V2), + "::", + stringify!(Reserved) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_DOWNLOAD_V2>())).Offset as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_DOWNLOAD_V2), + "::", + stringify!(Offset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_DOWNLOAD_V2>())).BufferSize as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_DOWNLOAD_V2), + "::", + stringify!(BufferSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_DOWNLOAD_V2>())).ImageSize as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_DOWNLOAD_V2), + "::", + stringify!(ImageSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_DOWNLOAD_V2>())).Reserved2 as *const _ as usize + }, + 36usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_DOWNLOAD_V2), + "::", + stringify!(Reserved2) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_DOWNLOAD_V2>())).ImageBuffer as *const _ as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_DOWNLOAD_V2), + "::", + stringify!(ImageBuffer) + ) + ); +} +pub type STORAGE_HW_FIRMWARE_DOWNLOAD_V2 = _STORAGE_HW_FIRMWARE_DOWNLOAD_V2; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_HW_FIRMWARE_ACTIVATE { + pub Version: DWORD, + pub Size: DWORD, + pub Flags: DWORD, + pub Slot: BYTE, + pub Reserved0: [BYTE; 3usize], +} +#[test] +fn bindgen_test_layout__STORAGE_HW_FIRMWARE_ACTIVATE() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_HW_FIRMWARE_ACTIVATE>(), + 16usize, + concat!("Size of: ", stringify!(_STORAGE_HW_FIRMWARE_ACTIVATE)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_HW_FIRMWARE_ACTIVATE>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_HW_FIRMWARE_ACTIVATE)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_ACTIVATE>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_ACTIVATE), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_ACTIVATE>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_ACTIVATE), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_ACTIVATE>())).Flags as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_ACTIVATE), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_ACTIVATE>())).Slot as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_ACTIVATE), + "::", + stringify!(Slot) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_HW_FIRMWARE_ACTIVATE>())).Reserved0 as *const _ as usize + }, + 13usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_HW_FIRMWARE_ACTIVATE), + "::", + stringify!(Reserved0) + ) + ); +} +pub type STORAGE_HW_FIRMWARE_ACTIVATE = _STORAGE_HW_FIRMWARE_ACTIVATE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_PROTOCOL_COMMAND { + pub Version: DWORD, + pub Length: DWORD, + pub ProtocolType: STORAGE_PROTOCOL_TYPE, + pub Flags: DWORD, + pub ReturnStatus: DWORD, + pub ErrorCode: DWORD, + pub CommandLength: DWORD, + pub ErrorInfoLength: DWORD, + pub DataToDeviceTransferLength: DWORD, + pub DataFromDeviceTransferLength: DWORD, + pub TimeOutValue: DWORD, + pub ErrorInfoOffset: DWORD, + pub DataToDeviceBufferOffset: DWORD, + pub DataFromDeviceBufferOffset: DWORD, + pub CommandSpecific: DWORD, + pub Reserved0: DWORD, + pub FixedProtocolReturnData: DWORD, + pub Reserved1: [DWORD; 3usize], + pub Command: [BYTE; 1usize], +} +#[test] +fn bindgen_test_layout__STORAGE_PROTOCOL_COMMAND() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_PROTOCOL_COMMAND>(), + 84usize, + concat!("Size of: ", stringify!(_STORAGE_PROTOCOL_COMMAND)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_PROTOCOL_COMMAND>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_PROTOCOL_COMMAND)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_PROTOCOL_COMMAND>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_COMMAND), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_PROTOCOL_COMMAND>())).Length as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_COMMAND), + "::", + stringify!(Length) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_COMMAND>())).ProtocolType as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_COMMAND), + "::", + stringify!(ProtocolType) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_PROTOCOL_COMMAND>())).Flags as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_COMMAND), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_COMMAND>())).ReturnStatus as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_COMMAND), + "::", + stringify!(ReturnStatus) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_PROTOCOL_COMMAND>())).ErrorCode as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_COMMAND), + "::", + stringify!(ErrorCode) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_COMMAND>())).CommandLength as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_COMMAND), + "::", + stringify!(CommandLength) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_COMMAND>())).ErrorInfoLength as *const _ as usize + }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_COMMAND), + "::", + stringify!(ErrorInfoLength) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_COMMAND>())).DataToDeviceTransferLength as *const _ + as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_COMMAND), + "::", + stringify!(DataToDeviceTransferLength) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_COMMAND>())).DataFromDeviceTransferLength as *const _ + as usize + }, + 36usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_COMMAND), + "::", + stringify!(DataFromDeviceTransferLength) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_COMMAND>())).TimeOutValue as *const _ as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_COMMAND), + "::", + stringify!(TimeOutValue) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_COMMAND>())).ErrorInfoOffset as *const _ as usize + }, + 44usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_COMMAND), + "::", + stringify!(ErrorInfoOffset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_COMMAND>())).DataToDeviceBufferOffset as *const _ + as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_COMMAND), + "::", + stringify!(DataToDeviceBufferOffset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_COMMAND>())).DataFromDeviceBufferOffset as *const _ + as usize + }, + 52usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_COMMAND), + "::", + stringify!(DataFromDeviceBufferOffset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_COMMAND>())).CommandSpecific as *const _ as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_COMMAND), + "::", + stringify!(CommandSpecific) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_PROTOCOL_COMMAND>())).Reserved0 as *const _ as usize }, + 60usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_COMMAND), + "::", + stringify!(Reserved0) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_PROTOCOL_COMMAND>())).FixedProtocolReturnData as *const _ + as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_COMMAND), + "::", + stringify!(FixedProtocolReturnData) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_PROTOCOL_COMMAND>())).Reserved1 as *const _ as usize }, + 68usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_COMMAND), + "::", + stringify!(Reserved1) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_PROTOCOL_COMMAND>())).Command as *const _ as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_PROTOCOL_COMMAND), + "::", + stringify!(Command) + ) + ); +} +pub type STORAGE_PROTOCOL_COMMAND = _STORAGE_PROTOCOL_COMMAND; +pub const _STORAGE_ATTRIBUTE_MGMT_ACTION_StorAttributeMgmt_ClearAttribute: + _STORAGE_ATTRIBUTE_MGMT_ACTION = 0; +pub const _STORAGE_ATTRIBUTE_MGMT_ACTION_StorAttributeMgmt_SetAttribute: + _STORAGE_ATTRIBUTE_MGMT_ACTION = 1; +pub const _STORAGE_ATTRIBUTE_MGMT_ACTION_StorAttributeMgmt_ResetAttribute: + _STORAGE_ATTRIBUTE_MGMT_ACTION = 2; +pub type _STORAGE_ATTRIBUTE_MGMT_ACTION = ::std::os::raw::c_int; +pub use self::_STORAGE_ATTRIBUTE_MGMT_ACTION as STORAGE_ATTRIBUTE_MGMT_ACTION; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_ATTRIBUTE_MGMT { + pub Version: DWORD, + pub Size: DWORD, + pub Action: STORAGE_ATTRIBUTE_MGMT_ACTION, + pub Attribute: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_ATTRIBUTE_MGMT() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_ATTRIBUTE_MGMT>(), + 16usize, + concat!("Size of: ", stringify!(_STORAGE_ATTRIBUTE_MGMT)) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_ATTRIBUTE_MGMT>(), + 4usize, + concat!("Alignment of ", stringify!(_STORAGE_ATTRIBUTE_MGMT)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_ATTRIBUTE_MGMT>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ATTRIBUTE_MGMT), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_ATTRIBUTE_MGMT>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ATTRIBUTE_MGMT), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_ATTRIBUTE_MGMT>())).Action as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ATTRIBUTE_MGMT), + "::", + stringify!(Action) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STORAGE_ATTRIBUTE_MGMT>())).Attribute as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_ATTRIBUTE_MGMT), + "::", + stringify!(Attribute) + ) + ); +} +pub type STORAGE_ATTRIBUTE_MGMT = _STORAGE_ATTRIBUTE_MGMT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCM_PD_HEALTH_NOTIFICATION_DATA { + pub DeviceGuid: GUID, +} +#[test] +fn bindgen_test_layout__SCM_PD_HEALTH_NOTIFICATION_DATA() { + assert_eq!( + ::std::mem::size_of::<_SCM_PD_HEALTH_NOTIFICATION_DATA>(), + 16usize, + concat!("Size of: ", stringify!(_SCM_PD_HEALTH_NOTIFICATION_DATA)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_PD_HEALTH_NOTIFICATION_DATA>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_SCM_PD_HEALTH_NOTIFICATION_DATA) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_HEALTH_NOTIFICATION_DATA>())).DeviceGuid as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_HEALTH_NOTIFICATION_DATA), + "::", + stringify!(DeviceGuid) + ) + ); +} +pub type SCM_PD_HEALTH_NOTIFICATION_DATA = _SCM_PD_HEALTH_NOTIFICATION_DATA; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SCM_LOGICAL_DEVICE_INSTANCE { + pub Version: DWORD, + pub Size: DWORD, + pub DeviceGuid: GUID, + pub SymbolicLink: [WCHAR; 256usize], +} +#[test] +fn bindgen_test_layout__SCM_LOGICAL_DEVICE_INSTANCE() { + assert_eq!( + ::std::mem::size_of::<_SCM_LOGICAL_DEVICE_INSTANCE>(), + 536usize, + concat!("Size of: ", stringify!(_SCM_LOGICAL_DEVICE_INSTANCE)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_LOGICAL_DEVICE_INSTANCE>(), + 4usize, + concat!("Alignment of ", stringify!(_SCM_LOGICAL_DEVICE_INSTANCE)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_LOGICAL_DEVICE_INSTANCE>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_LOGICAL_DEVICE_INSTANCE), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_LOGICAL_DEVICE_INSTANCE>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_LOGICAL_DEVICE_INSTANCE), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_LOGICAL_DEVICE_INSTANCE>())).DeviceGuid as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCM_LOGICAL_DEVICE_INSTANCE), + "::", + stringify!(DeviceGuid) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_LOGICAL_DEVICE_INSTANCE>())).SymbolicLink as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SCM_LOGICAL_DEVICE_INSTANCE), + "::", + stringify!(SymbolicLink) + ) + ); +} +pub type SCM_LOGICAL_DEVICE_INSTANCE = _SCM_LOGICAL_DEVICE_INSTANCE; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SCM_LOGICAL_DEVICES { + pub Version: DWORD, + pub Size: DWORD, + pub DeviceCount: DWORD, + pub Devices: [SCM_LOGICAL_DEVICE_INSTANCE; 1usize], +} +#[test] +fn bindgen_test_layout__SCM_LOGICAL_DEVICES() { + assert_eq!( + ::std::mem::size_of::<_SCM_LOGICAL_DEVICES>(), + 548usize, + concat!("Size of: ", stringify!(_SCM_LOGICAL_DEVICES)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_LOGICAL_DEVICES>(), + 4usize, + concat!("Alignment of ", stringify!(_SCM_LOGICAL_DEVICES)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_LOGICAL_DEVICES>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_LOGICAL_DEVICES), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_LOGICAL_DEVICES>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_LOGICAL_DEVICES), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_LOGICAL_DEVICES>())).DeviceCount as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCM_LOGICAL_DEVICES), + "::", + stringify!(DeviceCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_LOGICAL_DEVICES>())).Devices as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SCM_LOGICAL_DEVICES), + "::", + stringify!(Devices) + ) + ); +} +pub type SCM_LOGICAL_DEVICES = _SCM_LOGICAL_DEVICES; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SCM_PHYSICAL_DEVICE_INSTANCE { + pub Version: DWORD, + pub Size: DWORD, + pub NfitHandle: DWORD, + pub SymbolicLink: [WCHAR; 256usize], +} +#[test] +fn bindgen_test_layout__SCM_PHYSICAL_DEVICE_INSTANCE() { + assert_eq!( + ::std::mem::size_of::<_SCM_PHYSICAL_DEVICE_INSTANCE>(), + 524usize, + concat!("Size of: ", stringify!(_SCM_PHYSICAL_DEVICE_INSTANCE)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_PHYSICAL_DEVICE_INSTANCE>(), + 4usize, + concat!("Alignment of ", stringify!(_SCM_PHYSICAL_DEVICE_INSTANCE)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PHYSICAL_DEVICE_INSTANCE>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PHYSICAL_DEVICE_INSTANCE), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PHYSICAL_DEVICE_INSTANCE>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PHYSICAL_DEVICE_INSTANCE), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PHYSICAL_DEVICE_INSTANCE>())).NfitHandle as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PHYSICAL_DEVICE_INSTANCE), + "::", + stringify!(NfitHandle) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PHYSICAL_DEVICE_INSTANCE>())).SymbolicLink as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PHYSICAL_DEVICE_INSTANCE), + "::", + stringify!(SymbolicLink) + ) + ); +} +pub type SCM_PHYSICAL_DEVICE_INSTANCE = _SCM_PHYSICAL_DEVICE_INSTANCE; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SCM_PHYSICAL_DEVICES { + pub Version: DWORD, + pub Size: DWORD, + pub DeviceCount: DWORD, + pub Devices: [SCM_PHYSICAL_DEVICE_INSTANCE; 1usize], +} +#[test] +fn bindgen_test_layout__SCM_PHYSICAL_DEVICES() { + assert_eq!( + ::std::mem::size_of::<_SCM_PHYSICAL_DEVICES>(), + 536usize, + concat!("Size of: ", stringify!(_SCM_PHYSICAL_DEVICES)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_PHYSICAL_DEVICES>(), + 4usize, + concat!("Alignment of ", stringify!(_SCM_PHYSICAL_DEVICES)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PHYSICAL_DEVICES>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PHYSICAL_DEVICES), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PHYSICAL_DEVICES>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PHYSICAL_DEVICES), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PHYSICAL_DEVICES>())).DeviceCount as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PHYSICAL_DEVICES), + "::", + stringify!(DeviceCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PHYSICAL_DEVICES>())).Devices as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PHYSICAL_DEVICES), + "::", + stringify!(Devices) + ) + ); +} +pub type SCM_PHYSICAL_DEVICES = _SCM_PHYSICAL_DEVICES; +pub const _SCM_REGION_FLAG_ScmRegionFlagNone: _SCM_REGION_FLAG = 0; +pub const _SCM_REGION_FLAG_ScmRegionFlagLabel: _SCM_REGION_FLAG = 1; +pub type _SCM_REGION_FLAG = ::std::os::raw::c_int; +pub use self::_SCM_REGION_FLAG as SCM_REGION_FLAG; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCM_REGION { + pub Version: DWORD, + pub Size: DWORD, + pub Flags: DWORD, + pub NfitHandle: DWORD, + pub LogicalDeviceGuid: GUID, + pub AddressRangeType: GUID, + pub AssociatedId: DWORD, + pub Length: DWORD64, + pub StartingDPA: DWORD64, + pub BaseSPA: DWORD64, + pub SPAOffset: DWORD64, + pub RegionOffset: DWORD64, +} +#[test] +fn bindgen_test_layout__SCM_REGION() { + assert_eq!( + ::std::mem::size_of::<_SCM_REGION>(), + 96usize, + concat!("Size of: ", stringify!(_SCM_REGION)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_REGION>(), + 8usize, + concat!("Alignment of ", stringify!(_SCM_REGION)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_REGION>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_REGION), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_REGION>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_REGION), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_REGION>())).Flags as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCM_REGION), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_REGION>())).NfitHandle as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SCM_REGION), + "::", + stringify!(NfitHandle) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_REGION>())).LogicalDeviceGuid as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SCM_REGION), + "::", + stringify!(LogicalDeviceGuid) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_REGION>())).AddressRangeType as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_SCM_REGION), + "::", + stringify!(AddressRangeType) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_REGION>())).AssociatedId as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_SCM_REGION), + "::", + stringify!(AssociatedId) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_REGION>())).Length as *const _ as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(_SCM_REGION), + "::", + stringify!(Length) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_REGION>())).StartingDPA as *const _ as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(_SCM_REGION), + "::", + stringify!(StartingDPA) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_REGION>())).BaseSPA as *const _ as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(_SCM_REGION), + "::", + stringify!(BaseSPA) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_REGION>())).SPAOffset as *const _ as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(_SCM_REGION), + "::", + stringify!(SPAOffset) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_REGION>())).RegionOffset as *const _ as usize }, + 88usize, + concat!( + "Offset of field: ", + stringify!(_SCM_REGION), + "::", + stringify!(RegionOffset) + ) + ); +} +pub type SCM_REGION = _SCM_REGION; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCM_REGIONS { + pub Version: DWORD, + pub Size: DWORD, + pub RegionCount: DWORD, + pub Regions: [SCM_REGION; 1usize], +} +#[test] +fn bindgen_test_layout__SCM_REGIONS() { + assert_eq!( + ::std::mem::size_of::<_SCM_REGIONS>(), + 112usize, + concat!("Size of: ", stringify!(_SCM_REGIONS)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_REGIONS>(), + 8usize, + concat!("Alignment of ", stringify!(_SCM_REGIONS)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_REGIONS>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_REGIONS), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_REGIONS>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_REGIONS), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_REGIONS>())).RegionCount as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCM_REGIONS), + "::", + stringify!(RegionCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_REGIONS>())).Regions as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SCM_REGIONS), + "::", + stringify!(Regions) + ) + ); +} +pub type SCM_REGIONS = _SCM_REGIONS; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCM_INTERLEAVED_PD_INFO { + pub DeviceHandle: DWORD, + pub DeviceGuid: GUID, +} +#[test] +fn bindgen_test_layout__SCM_INTERLEAVED_PD_INFO() { + assert_eq!( + ::std::mem::size_of::<_SCM_INTERLEAVED_PD_INFO>(), + 20usize, + concat!("Size of: ", stringify!(_SCM_INTERLEAVED_PD_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_INTERLEAVED_PD_INFO>(), + 4usize, + concat!("Alignment of ", stringify!(_SCM_INTERLEAVED_PD_INFO)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_INTERLEAVED_PD_INFO>())).DeviceHandle as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_INTERLEAVED_PD_INFO), + "::", + stringify!(DeviceHandle) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_INTERLEAVED_PD_INFO>())).DeviceGuid as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_INTERLEAVED_PD_INFO), + "::", + stringify!(DeviceGuid) + ) + ); +} +pub type SCM_INTERLEAVED_PD_INFO = _SCM_INTERLEAVED_PD_INFO; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCM_LD_INTERLEAVE_SET_INFO { + pub Version: DWORD, + pub Size: DWORD, + pub InterleaveSetSize: DWORD, + pub InterleaveSet: [SCM_INTERLEAVED_PD_INFO; 1usize], +} +#[test] +fn bindgen_test_layout__SCM_LD_INTERLEAVE_SET_INFO() { + assert_eq!( + ::std::mem::size_of::<_SCM_LD_INTERLEAVE_SET_INFO>(), + 32usize, + concat!("Size of: ", stringify!(_SCM_LD_INTERLEAVE_SET_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_LD_INTERLEAVE_SET_INFO>(), + 4usize, + concat!("Alignment of ", stringify!(_SCM_LD_INTERLEAVE_SET_INFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_LD_INTERLEAVE_SET_INFO>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_LD_INTERLEAVE_SET_INFO), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_LD_INTERLEAVE_SET_INFO>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_LD_INTERLEAVE_SET_INFO), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_LD_INTERLEAVE_SET_INFO>())).InterleaveSetSize as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCM_LD_INTERLEAVE_SET_INFO), + "::", + stringify!(InterleaveSetSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_LD_INTERLEAVE_SET_INFO>())).InterleaveSet as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SCM_LD_INTERLEAVE_SET_INFO), + "::", + stringify!(InterleaveSet) + ) + ); +} +pub type SCM_LD_INTERLEAVE_SET_INFO = _SCM_LD_INTERLEAVE_SET_INFO; +pub const _SCM_PD_QUERY_TYPE_ScmPhysicalDeviceQuery_Descriptor: _SCM_PD_QUERY_TYPE = 0; +pub const _SCM_PD_QUERY_TYPE_ScmPhysicalDeviceQuery_IsSupported: _SCM_PD_QUERY_TYPE = 1; +pub const _SCM_PD_QUERY_TYPE_ScmPhysicalDeviceQuery_Max: _SCM_PD_QUERY_TYPE = 2; +pub type _SCM_PD_QUERY_TYPE = ::std::os::raw::c_int; +pub use self::_SCM_PD_QUERY_TYPE as SCM_PD_QUERY_TYPE; +pub const _SCM_PD_PROPERTY_ID_ScmPhysicalDeviceProperty_DeviceInfo: _SCM_PD_PROPERTY_ID = 0; +pub const _SCM_PD_PROPERTY_ID_ScmPhysicalDeviceProperty_ManagementStatus: _SCM_PD_PROPERTY_ID = 1; +pub const _SCM_PD_PROPERTY_ID_ScmPhysicalDeviceProperty_FirmwareInfo: _SCM_PD_PROPERTY_ID = 2; +pub const _SCM_PD_PROPERTY_ID_ScmPhysicalDeviceProperty_LocationString: _SCM_PD_PROPERTY_ID = 3; +pub const _SCM_PD_PROPERTY_ID_ScmPhysicalDeviceProperty_DeviceSpecificInfo: _SCM_PD_PROPERTY_ID = 4; +pub const _SCM_PD_PROPERTY_ID_ScmPhysicalDeviceProperty_DeviceHandle: _SCM_PD_PROPERTY_ID = 5; +pub const _SCM_PD_PROPERTY_ID_ScmPhysicalDeviceProperty_Max: _SCM_PD_PROPERTY_ID = 6; +pub type _SCM_PD_PROPERTY_ID = ::std::os::raw::c_int; +pub use self::_SCM_PD_PROPERTY_ID as SCM_PD_PROPERTY_ID; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCM_PD_PROPERTY_QUERY { + pub Version: DWORD, + pub Size: DWORD, + pub PropertyId: SCM_PD_PROPERTY_ID, + pub QueryType: SCM_PD_QUERY_TYPE, + pub AdditionalParameters: [BYTE; 1usize], +} +#[test] +fn bindgen_test_layout__SCM_PD_PROPERTY_QUERY() { + assert_eq!( + ::std::mem::size_of::<_SCM_PD_PROPERTY_QUERY>(), + 20usize, + concat!("Size of: ", stringify!(_SCM_PD_PROPERTY_QUERY)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_PD_PROPERTY_QUERY>(), + 4usize, + concat!("Alignment of ", stringify!(_SCM_PD_PROPERTY_QUERY)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_PROPERTY_QUERY>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_PROPERTY_QUERY), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_PROPERTY_QUERY>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_PROPERTY_QUERY), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_PROPERTY_QUERY>())).PropertyId as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_PROPERTY_QUERY), + "::", + stringify!(PropertyId) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_PROPERTY_QUERY>())).QueryType as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_PROPERTY_QUERY), + "::", + stringify!(QueryType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_PROPERTY_QUERY>())).AdditionalParameters as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_PROPERTY_QUERY), + "::", + stringify!(AdditionalParameters) + ) + ); +} +pub type SCM_PD_PROPERTY_QUERY = _SCM_PD_PROPERTY_QUERY; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCM_PD_DESCRIPTOR_HEADER { + pub Version: DWORD, + pub Size: DWORD, +} +#[test] +fn bindgen_test_layout__SCM_PD_DESCRIPTOR_HEADER() { + assert_eq!( + ::std::mem::size_of::<_SCM_PD_DESCRIPTOR_HEADER>(), + 8usize, + concat!("Size of: ", stringify!(_SCM_PD_DESCRIPTOR_HEADER)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_PD_DESCRIPTOR_HEADER>(), + 4usize, + concat!("Alignment of ", stringify!(_SCM_PD_DESCRIPTOR_HEADER)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_DESCRIPTOR_HEADER>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DESCRIPTOR_HEADER), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_DESCRIPTOR_HEADER>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DESCRIPTOR_HEADER), + "::", + stringify!(Size) + ) + ); +} +pub type SCM_PD_DESCRIPTOR_HEADER = _SCM_PD_DESCRIPTOR_HEADER; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCM_PD_DEVICE_HANDLE { + pub Version: DWORD, + pub Size: DWORD, + pub DeviceGuid: GUID, + pub DeviceHandle: DWORD, +} +#[test] +fn bindgen_test_layout__SCM_PD_DEVICE_HANDLE() { + assert_eq!( + ::std::mem::size_of::<_SCM_PD_DEVICE_HANDLE>(), + 28usize, + concat!("Size of: ", stringify!(_SCM_PD_DEVICE_HANDLE)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_PD_DEVICE_HANDLE>(), + 4usize, + concat!("Alignment of ", stringify!(_SCM_PD_DEVICE_HANDLE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_DEVICE_HANDLE>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_HANDLE), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_DEVICE_HANDLE>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_HANDLE), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_DEVICE_HANDLE>())).DeviceGuid as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_HANDLE), + "::", + stringify!(DeviceGuid) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_DEVICE_HANDLE>())).DeviceHandle as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_HANDLE), + "::", + stringify!(DeviceHandle) + ) + ); +} +pub type SCM_PD_DEVICE_HANDLE = _SCM_PD_DEVICE_HANDLE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCM_PD_DEVICE_INFO { + pub Version: DWORD, + pub Size: DWORD, + pub DeviceGuid: GUID, + pub UnsafeShutdownCount: DWORD, + pub PersistentMemorySizeInBytes: DWORD64, + pub VolatileMemorySizeInBytes: DWORD64, + pub TotalMemorySizeInBytes: DWORD64, + pub SlotNumber: DWORD, + pub DeviceHandle: DWORD, + pub PhysicalId: WORD, + pub NumberOfFormatInterfaceCodes: BYTE, + pub FormatInterfaceCodes: [WORD; 8usize], + pub VendorId: DWORD, + pub ProductId: DWORD, + pub SubsystemDeviceId: DWORD, + pub SubsystemVendorId: DWORD, + pub ManufacturingLocation: BYTE, + pub ManufacturingWeek: BYTE, + pub ManufacturingYear: BYTE, + pub SerialNumber4Byte: DWORD, + pub SerialNumberLengthInChars: DWORD, + pub SerialNumber: [CHAR; 1usize], +} +#[test] +fn bindgen_test_layout__SCM_PD_DEVICE_INFO() { + assert_eq!( + ::std::mem::size_of::<_SCM_PD_DEVICE_INFO>(), + 120usize, + concat!("Size of: ", stringify!(_SCM_PD_DEVICE_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_PD_DEVICE_INFO>(), + 8usize, + concat!("Alignment of ", stringify!(_SCM_PD_DEVICE_INFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_DEVICE_INFO>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_INFO), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_DEVICE_INFO>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_INFO), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_DEVICE_INFO>())).DeviceGuid as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_INFO), + "::", + stringify!(DeviceGuid) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_DEVICE_INFO>())).UnsafeShutdownCount as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_INFO), + "::", + stringify!(UnsafeShutdownCount) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_DEVICE_INFO>())).PersistentMemorySizeInBytes as *const _ + as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_INFO), + "::", + stringify!(PersistentMemorySizeInBytes) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_DEVICE_INFO>())).VolatileMemorySizeInBytes as *const _ as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_INFO), + "::", + stringify!(VolatileMemorySizeInBytes) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_DEVICE_INFO>())).TotalMemorySizeInBytes as *const _ as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_INFO), + "::", + stringify!(TotalMemorySizeInBytes) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_DEVICE_INFO>())).SlotNumber as *const _ as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_INFO), + "::", + stringify!(SlotNumber) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_DEVICE_INFO>())).DeviceHandle as *const _ as usize }, + 60usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_INFO), + "::", + stringify!(DeviceHandle) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_DEVICE_INFO>())).PhysicalId as *const _ as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_INFO), + "::", + stringify!(PhysicalId) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_DEVICE_INFO>())).NumberOfFormatInterfaceCodes as *const _ + as usize + }, + 66usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_INFO), + "::", + stringify!(NumberOfFormatInterfaceCodes) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_DEVICE_INFO>())).FormatInterfaceCodes as *const _ as usize + }, + 68usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_INFO), + "::", + stringify!(FormatInterfaceCodes) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_DEVICE_INFO>())).VendorId as *const _ as usize }, + 84usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_INFO), + "::", + stringify!(VendorId) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_DEVICE_INFO>())).ProductId as *const _ as usize }, + 88usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_INFO), + "::", + stringify!(ProductId) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_DEVICE_INFO>())).SubsystemDeviceId as *const _ as usize + }, + 92usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_INFO), + "::", + stringify!(SubsystemDeviceId) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_DEVICE_INFO>())).SubsystemVendorId as *const _ as usize + }, + 96usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_INFO), + "::", + stringify!(SubsystemVendorId) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_DEVICE_INFO>())).ManufacturingLocation as *const _ as usize + }, + 100usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_INFO), + "::", + stringify!(ManufacturingLocation) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_DEVICE_INFO>())).ManufacturingWeek as *const _ as usize + }, + 101usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_INFO), + "::", + stringify!(ManufacturingWeek) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_DEVICE_INFO>())).ManufacturingYear as *const _ as usize + }, + 102usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_INFO), + "::", + stringify!(ManufacturingYear) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_DEVICE_INFO>())).SerialNumber4Byte as *const _ as usize + }, + 104usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_INFO), + "::", + stringify!(SerialNumber4Byte) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_DEVICE_INFO>())).SerialNumberLengthInChars as *const _ as usize + }, + 108usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_INFO), + "::", + stringify!(SerialNumberLengthInChars) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_DEVICE_INFO>())).SerialNumber as *const _ as usize }, + 112usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_INFO), + "::", + stringify!(SerialNumber) + ) + ); +} +pub type SCM_PD_DEVICE_INFO = _SCM_PD_DEVICE_INFO; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SCM_PD_DEVICE_SPECIFIC_PROPERTY { + pub Name: [WCHAR; 128usize], + pub Value: LONGLONG, +} +#[test] +fn bindgen_test_layout__SCM_PD_DEVICE_SPECIFIC_PROPERTY() { + assert_eq!( + ::std::mem::size_of::<_SCM_PD_DEVICE_SPECIFIC_PROPERTY>(), + 264usize, + concat!("Size of: ", stringify!(_SCM_PD_DEVICE_SPECIFIC_PROPERTY)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_PD_DEVICE_SPECIFIC_PROPERTY>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_SCM_PD_DEVICE_SPECIFIC_PROPERTY) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_DEVICE_SPECIFIC_PROPERTY>())).Name as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_SPECIFIC_PROPERTY), + "::", + stringify!(Name) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_DEVICE_SPECIFIC_PROPERTY>())).Value as *const _ as usize + }, + 256usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_SPECIFIC_PROPERTY), + "::", + stringify!(Value) + ) + ); +} +pub type SCM_PD_DEVICE_SPECIFIC_PROPERTY = _SCM_PD_DEVICE_SPECIFIC_PROPERTY; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SCM_PD_DEVICE_SPECIFIC_INFO { + pub Version: DWORD, + pub Size: DWORD, + pub NumberOfProperties: DWORD, + pub DeviceSpecificProperties: [SCM_PD_DEVICE_SPECIFIC_PROPERTY; 1usize], +} +#[test] +fn bindgen_test_layout__SCM_PD_DEVICE_SPECIFIC_INFO() { + assert_eq!( + ::std::mem::size_of::<_SCM_PD_DEVICE_SPECIFIC_INFO>(), + 280usize, + concat!("Size of: ", stringify!(_SCM_PD_DEVICE_SPECIFIC_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_PD_DEVICE_SPECIFIC_INFO>(), + 8usize, + concat!("Alignment of ", stringify!(_SCM_PD_DEVICE_SPECIFIC_INFO)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_DEVICE_SPECIFIC_INFO>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_SPECIFIC_INFO), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_DEVICE_SPECIFIC_INFO>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_SPECIFIC_INFO), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_DEVICE_SPECIFIC_INFO>())).NumberOfProperties as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_SPECIFIC_INFO), + "::", + stringify!(NumberOfProperties) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_DEVICE_SPECIFIC_INFO>())).DeviceSpecificProperties as *const _ + as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_DEVICE_SPECIFIC_INFO), + "::", + stringify!(DeviceSpecificProperties) + ) + ); +} +pub type SCM_PD_DEVICE_SPECIFIC_INFO = _SCM_PD_DEVICE_SPECIFIC_INFO; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCM_PD_FIRMWARE_SLOT_INFO { + pub Version: DWORD, + pub Size: DWORD, + pub SlotNumber: BYTE, + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>, + pub Reserved1: [BYTE; 6usize], + pub Revision: [BYTE; 32usize], +} +#[test] +fn bindgen_test_layout__SCM_PD_FIRMWARE_SLOT_INFO() { + assert_eq!( + ::std::mem::size_of::<_SCM_PD_FIRMWARE_SLOT_INFO>(), + 48usize, + concat!("Size of: ", stringify!(_SCM_PD_FIRMWARE_SLOT_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_PD_FIRMWARE_SLOT_INFO>(), + 4usize, + concat!("Alignment of ", stringify!(_SCM_PD_FIRMWARE_SLOT_INFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_FIRMWARE_SLOT_INFO>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_FIRMWARE_SLOT_INFO), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_FIRMWARE_SLOT_INFO>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_FIRMWARE_SLOT_INFO), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_FIRMWARE_SLOT_INFO>())).SlotNumber as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_FIRMWARE_SLOT_INFO), + "::", + stringify!(SlotNumber) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_FIRMWARE_SLOT_INFO>())).Reserved1 as *const _ as usize + }, + 10usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_FIRMWARE_SLOT_INFO), + "::", + stringify!(Reserved1) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_FIRMWARE_SLOT_INFO>())).Revision as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_FIRMWARE_SLOT_INFO), + "::", + stringify!(Revision) + ) + ); +} +impl _SCM_PD_FIRMWARE_SLOT_INFO { + #[inline] + pub fn ReadOnly(&self) -> BYTE { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_ReadOnly(&mut self, val: BYTE) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn Reserved0(&self) -> BYTE { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 7u8) as u8) } + } + #[inline] + pub fn set_Reserved0(&mut self, val: BYTE) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 7u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + ReadOnly: BYTE, + Reserved0: BYTE, + ) -> __BindgenBitfieldUnit<[u8; 1usize], u8> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize], u8> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let ReadOnly: u8 = unsafe { ::std::mem::transmute(ReadOnly) }; + ReadOnly as u64 + }); + __bindgen_bitfield_unit.set(1usize, 7u8, { + let Reserved0: u8 = unsafe { ::std::mem::transmute(Reserved0) }; + Reserved0 as u64 + }); + __bindgen_bitfield_unit + } +} +pub type SCM_PD_FIRMWARE_SLOT_INFO = _SCM_PD_FIRMWARE_SLOT_INFO; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCM_PD_FIRMWARE_INFO { + pub Version: DWORD, + pub Size: DWORD, + pub ActiveSlot: BYTE, + pub NextActiveSlot: BYTE, + pub SlotCount: BYTE, + pub Slots: [SCM_PD_FIRMWARE_SLOT_INFO; 1usize], +} +#[test] +fn bindgen_test_layout__SCM_PD_FIRMWARE_INFO() { + assert_eq!( + ::std::mem::size_of::<_SCM_PD_FIRMWARE_INFO>(), + 60usize, + concat!("Size of: ", stringify!(_SCM_PD_FIRMWARE_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_PD_FIRMWARE_INFO>(), + 4usize, + concat!("Alignment of ", stringify!(_SCM_PD_FIRMWARE_INFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_FIRMWARE_INFO>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_FIRMWARE_INFO), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_FIRMWARE_INFO>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_FIRMWARE_INFO), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_FIRMWARE_INFO>())).ActiveSlot as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_FIRMWARE_INFO), + "::", + stringify!(ActiveSlot) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_FIRMWARE_INFO>())).NextActiveSlot as *const _ as usize + }, + 9usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_FIRMWARE_INFO), + "::", + stringify!(NextActiveSlot) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_FIRMWARE_INFO>())).SlotCount as *const _ as usize }, + 10usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_FIRMWARE_INFO), + "::", + stringify!(SlotCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_FIRMWARE_INFO>())).Slots as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_FIRMWARE_INFO), + "::", + stringify!(Slots) + ) + ); +} +pub type SCM_PD_FIRMWARE_INFO = _SCM_PD_FIRMWARE_INFO; +pub const _SCM_PD_HEALTH_STATUS_ScmPhysicalDeviceHealth_Unknown: _SCM_PD_HEALTH_STATUS = 0; +pub const _SCM_PD_HEALTH_STATUS_ScmPhysicalDeviceHealth_Unhealthy: _SCM_PD_HEALTH_STATUS = 1; +pub const _SCM_PD_HEALTH_STATUS_ScmPhysicalDeviceHealth_Warning: _SCM_PD_HEALTH_STATUS = 2; +pub const _SCM_PD_HEALTH_STATUS_ScmPhysicalDeviceHealth_Healthy: _SCM_PD_HEALTH_STATUS = 3; +pub const _SCM_PD_HEALTH_STATUS_ScmPhysicalDeviceHealth_Max: _SCM_PD_HEALTH_STATUS = 4; +pub type _SCM_PD_HEALTH_STATUS = ::std::os::raw::c_int; +pub use self::_SCM_PD_HEALTH_STATUS as SCM_PD_HEALTH_STATUS; +pub const _SCM_PD_OPERATIONAL_STATUS_ScmPhysicalDeviceOpStatus_Unknown: _SCM_PD_OPERATIONAL_STATUS = + 0; +pub const _SCM_PD_OPERATIONAL_STATUS_ScmPhysicalDeviceOpStatus_Ok: _SCM_PD_OPERATIONAL_STATUS = 1; +pub const _SCM_PD_OPERATIONAL_STATUS_ScmPhysicalDeviceOpStatus_PredictingFailure: + _SCM_PD_OPERATIONAL_STATUS = 2; +pub const _SCM_PD_OPERATIONAL_STATUS_ScmPhysicalDeviceOpStatus_InService: + _SCM_PD_OPERATIONAL_STATUS = 3; +pub const _SCM_PD_OPERATIONAL_STATUS_ScmPhysicalDeviceOpStatus_HardwareError: + _SCM_PD_OPERATIONAL_STATUS = 4; +pub const _SCM_PD_OPERATIONAL_STATUS_ScmPhysicalDeviceOpStatus_NotUsable: + _SCM_PD_OPERATIONAL_STATUS = 5; +pub const _SCM_PD_OPERATIONAL_STATUS_ScmPhysicalDeviceOpStatus_TransientError: + _SCM_PD_OPERATIONAL_STATUS = 6; +pub const _SCM_PD_OPERATIONAL_STATUS_ScmPhysicalDeviceOpStatus_Missing: _SCM_PD_OPERATIONAL_STATUS = + 7; +pub const _SCM_PD_OPERATIONAL_STATUS_ScmPhysicalDeviceOpStatus_Max: _SCM_PD_OPERATIONAL_STATUS = 8; +pub type _SCM_PD_OPERATIONAL_STATUS = ::std::os::raw::c_int; +pub use self::_SCM_PD_OPERATIONAL_STATUS as SCM_PD_OPERATIONAL_STATUS; +pub const _SCM_PD_OPERATIONAL_STATUS_REASON_ScmPhysicalDeviceOpReason_Unknown: + _SCM_PD_OPERATIONAL_STATUS_REASON = 0; +pub const _SCM_PD_OPERATIONAL_STATUS_REASON_ScmPhysicalDeviceOpReason_Media: + _SCM_PD_OPERATIONAL_STATUS_REASON = 1; +pub const _SCM_PD_OPERATIONAL_STATUS_REASON_ScmPhysicalDeviceOpReason_ThresholdExceeded: + _SCM_PD_OPERATIONAL_STATUS_REASON = 2; +pub const _SCM_PD_OPERATIONAL_STATUS_REASON_ScmPhysicalDeviceOpReason_LostData: + _SCM_PD_OPERATIONAL_STATUS_REASON = 3; +pub const _SCM_PD_OPERATIONAL_STATUS_REASON_ScmPhysicalDeviceOpReason_EnergySource: + _SCM_PD_OPERATIONAL_STATUS_REASON = 4; +pub const _SCM_PD_OPERATIONAL_STATUS_REASON_ScmPhysicalDeviceOpReason_Configuration: + _SCM_PD_OPERATIONAL_STATUS_REASON = 5; +pub const _SCM_PD_OPERATIONAL_STATUS_REASON_ScmPhysicalDeviceOpReason_DeviceController: + _SCM_PD_OPERATIONAL_STATUS_REASON = 6; +pub const _SCM_PD_OPERATIONAL_STATUS_REASON_ScmPhysicalDeviceOpReason_MediaController: + _SCM_PD_OPERATIONAL_STATUS_REASON = 7; +pub const _SCM_PD_OPERATIONAL_STATUS_REASON_ScmPhysicalDeviceOpReason_Component: + _SCM_PD_OPERATIONAL_STATUS_REASON = 8; +pub const _SCM_PD_OPERATIONAL_STATUS_REASON_ScmPhysicalDeviceOpReason_BackgroundOperation: + _SCM_PD_OPERATIONAL_STATUS_REASON = 9; +pub const _SCM_PD_OPERATIONAL_STATUS_REASON_ScmPhysicalDeviceOpReason_InvalidFirmware: + _SCM_PD_OPERATIONAL_STATUS_REASON = 10; +pub const _SCM_PD_OPERATIONAL_STATUS_REASON_ScmPhysicalDeviceOpReason_HealthCheck: + _SCM_PD_OPERATIONAL_STATUS_REASON = 11; +pub const _SCM_PD_OPERATIONAL_STATUS_REASON_ScmPhysicalDeviceOpReason_LostDataPersistence: + _SCM_PD_OPERATIONAL_STATUS_REASON = 12; +pub const _SCM_PD_OPERATIONAL_STATUS_REASON_ScmPhysicalDeviceOpReason_DisabledByPlatform: + _SCM_PD_OPERATIONAL_STATUS_REASON = 13; +pub const _SCM_PD_OPERATIONAL_STATUS_REASON_ScmPhysicalDeviceOpReason_PermanentError: + _SCM_PD_OPERATIONAL_STATUS_REASON = 14; +pub const _SCM_PD_OPERATIONAL_STATUS_REASON_ScmPhysicalDeviceOpReason_LostWritePersistence: + _SCM_PD_OPERATIONAL_STATUS_REASON = 15; +pub const _SCM_PD_OPERATIONAL_STATUS_REASON_ScmPhysicalDeviceOpReason_FatalError: + _SCM_PD_OPERATIONAL_STATUS_REASON = 16; +pub const _SCM_PD_OPERATIONAL_STATUS_REASON_ScmPhysicalDeviceOpReason_DataPersistenceLossImminent : _SCM_PD_OPERATIONAL_STATUS_REASON = 17 ; +pub const _SCM_PD_OPERATIONAL_STATUS_REASON_ScmPhysicalDeviceOpReason_WritePersistenceLossImminent : _SCM_PD_OPERATIONAL_STATUS_REASON = 18 ; +pub const _SCM_PD_OPERATIONAL_STATUS_REASON_ScmPhysicalDeviceOpReason_MediaRemainingSpareBlock: + _SCM_PD_OPERATIONAL_STATUS_REASON = 19; +pub const _SCM_PD_OPERATIONAL_STATUS_REASON_ScmPhysicalDeviceOpReason_PerformanceDegradation: + _SCM_PD_OPERATIONAL_STATUS_REASON = 20; +pub const _SCM_PD_OPERATIONAL_STATUS_REASON_ScmPhysicalDeviceOpReason_ExcessiveTemperature: + _SCM_PD_OPERATIONAL_STATUS_REASON = 21; +pub const _SCM_PD_OPERATIONAL_STATUS_REASON_ScmPhysicalDeviceOpReason_Max: + _SCM_PD_OPERATIONAL_STATUS_REASON = 22; +pub type _SCM_PD_OPERATIONAL_STATUS_REASON = ::std::os::raw::c_int; +pub use self::_SCM_PD_OPERATIONAL_STATUS_REASON as SCM_PD_OPERATIONAL_STATUS_REASON; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCM_PD_MANAGEMENT_STATUS { + pub Version: DWORD, + pub Size: DWORD, + pub Health: SCM_PD_HEALTH_STATUS, + pub NumberOfOperationalStatus: DWORD, + pub NumberOfAdditionalReasons: DWORD, + pub OperationalStatus: [SCM_PD_OPERATIONAL_STATUS; 16usize], + pub AdditionalReasons: [SCM_PD_OPERATIONAL_STATUS_REASON; 1usize], +} +#[test] +fn bindgen_test_layout__SCM_PD_MANAGEMENT_STATUS() { + assert_eq!( + ::std::mem::size_of::<_SCM_PD_MANAGEMENT_STATUS>(), + 88usize, + concat!("Size of: ", stringify!(_SCM_PD_MANAGEMENT_STATUS)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_PD_MANAGEMENT_STATUS>(), + 4usize, + concat!("Alignment of ", stringify!(_SCM_PD_MANAGEMENT_STATUS)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_MANAGEMENT_STATUS>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_MANAGEMENT_STATUS), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_MANAGEMENT_STATUS>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_MANAGEMENT_STATUS), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_MANAGEMENT_STATUS>())).Health as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_MANAGEMENT_STATUS), + "::", + stringify!(Health) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_MANAGEMENT_STATUS>())).NumberOfOperationalStatus as *const _ + as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_MANAGEMENT_STATUS), + "::", + stringify!(NumberOfOperationalStatus) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_MANAGEMENT_STATUS>())).NumberOfAdditionalReasons as *const _ + as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_MANAGEMENT_STATUS), + "::", + stringify!(NumberOfAdditionalReasons) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_MANAGEMENT_STATUS>())).OperationalStatus as *const _ as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_MANAGEMENT_STATUS), + "::", + stringify!(OperationalStatus) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_MANAGEMENT_STATUS>())).AdditionalReasons as *const _ as usize + }, + 84usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_MANAGEMENT_STATUS), + "::", + stringify!(AdditionalReasons) + ) + ); +} +pub type SCM_PD_MANAGEMENT_STATUS = _SCM_PD_MANAGEMENT_STATUS; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCM_PD_LOCATION_STRING { + pub Version: DWORD, + pub Size: DWORD, + pub Location: [WCHAR; 1usize], +} +#[test] +fn bindgen_test_layout__SCM_PD_LOCATION_STRING() { + assert_eq!( + ::std::mem::size_of::<_SCM_PD_LOCATION_STRING>(), + 12usize, + concat!("Size of: ", stringify!(_SCM_PD_LOCATION_STRING)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_PD_LOCATION_STRING>(), + 4usize, + concat!("Alignment of ", stringify!(_SCM_PD_LOCATION_STRING)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_LOCATION_STRING>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_LOCATION_STRING), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_LOCATION_STRING>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_LOCATION_STRING), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_LOCATION_STRING>())).Location as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_LOCATION_STRING), + "::", + stringify!(Location) + ) + ); +} +pub type SCM_PD_LOCATION_STRING = _SCM_PD_LOCATION_STRING; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCM_PD_FIRMWARE_DOWNLOAD { + pub Version: DWORD, + pub Size: DWORD, + pub Flags: DWORD, + pub Slot: BYTE, + pub Reserved: [BYTE; 3usize], + pub Offset: DWORD64, + pub FirmwareImageSizeInBytes: DWORD, + pub FirmwareImage: [BYTE; 1usize], +} +#[test] +fn bindgen_test_layout__SCM_PD_FIRMWARE_DOWNLOAD() { + assert_eq!( + ::std::mem::size_of::<_SCM_PD_FIRMWARE_DOWNLOAD>(), + 32usize, + concat!("Size of: ", stringify!(_SCM_PD_FIRMWARE_DOWNLOAD)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_PD_FIRMWARE_DOWNLOAD>(), + 8usize, + concat!("Alignment of ", stringify!(_SCM_PD_FIRMWARE_DOWNLOAD)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_FIRMWARE_DOWNLOAD>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_FIRMWARE_DOWNLOAD), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_FIRMWARE_DOWNLOAD>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_FIRMWARE_DOWNLOAD), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_FIRMWARE_DOWNLOAD>())).Flags as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_FIRMWARE_DOWNLOAD), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_FIRMWARE_DOWNLOAD>())).Slot as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_FIRMWARE_DOWNLOAD), + "::", + stringify!(Slot) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_FIRMWARE_DOWNLOAD>())).Reserved as *const _ as usize }, + 13usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_FIRMWARE_DOWNLOAD), + "::", + stringify!(Reserved) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_FIRMWARE_DOWNLOAD>())).Offset as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_FIRMWARE_DOWNLOAD), + "::", + stringify!(Offset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_FIRMWARE_DOWNLOAD>())).FirmwareImageSizeInBytes as *const _ + as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_FIRMWARE_DOWNLOAD), + "::", + stringify!(FirmwareImageSizeInBytes) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_FIRMWARE_DOWNLOAD>())).FirmwareImage as *const _ as usize + }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_FIRMWARE_DOWNLOAD), + "::", + stringify!(FirmwareImage) + ) + ); +} +pub type SCM_PD_FIRMWARE_DOWNLOAD = _SCM_PD_FIRMWARE_DOWNLOAD; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCM_PD_FIRMWARE_ACTIVATE { + pub Version: DWORD, + pub Size: DWORD, + pub Flags: DWORD, + pub Slot: BYTE, +} +#[test] +fn bindgen_test_layout__SCM_PD_FIRMWARE_ACTIVATE() { + assert_eq!( + ::std::mem::size_of::<_SCM_PD_FIRMWARE_ACTIVATE>(), + 16usize, + concat!("Size of: ", stringify!(_SCM_PD_FIRMWARE_ACTIVATE)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_PD_FIRMWARE_ACTIVATE>(), + 4usize, + concat!("Alignment of ", stringify!(_SCM_PD_FIRMWARE_ACTIVATE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_FIRMWARE_ACTIVATE>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_FIRMWARE_ACTIVATE), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_FIRMWARE_ACTIVATE>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_FIRMWARE_ACTIVATE), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_FIRMWARE_ACTIVATE>())).Flags as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_FIRMWARE_ACTIVATE), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_FIRMWARE_ACTIVATE>())).Slot as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_FIRMWARE_ACTIVATE), + "::", + stringify!(Slot) + ) + ); +} +pub type SCM_PD_FIRMWARE_ACTIVATE = _SCM_PD_FIRMWARE_ACTIVATE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCM_PD_PASSTHROUGH_INPUT { + pub Version: DWORD, + pub Size: DWORD, + pub ProtocolGuid: GUID, + pub DataSize: DWORD, + pub Data: [BYTE; 1usize], +} +#[test] +fn bindgen_test_layout__SCM_PD_PASSTHROUGH_INPUT() { + assert_eq!( + ::std::mem::size_of::<_SCM_PD_PASSTHROUGH_INPUT>(), + 32usize, + concat!("Size of: ", stringify!(_SCM_PD_PASSTHROUGH_INPUT)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_PD_PASSTHROUGH_INPUT>(), + 4usize, + concat!("Alignment of ", stringify!(_SCM_PD_PASSTHROUGH_INPUT)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_PASSTHROUGH_INPUT>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_PASSTHROUGH_INPUT), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_PASSTHROUGH_INPUT>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_PASSTHROUGH_INPUT), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_PASSTHROUGH_INPUT>())).ProtocolGuid as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_PASSTHROUGH_INPUT), + "::", + stringify!(ProtocolGuid) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_PASSTHROUGH_INPUT>())).DataSize as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_PASSTHROUGH_INPUT), + "::", + stringify!(DataSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_PASSTHROUGH_INPUT>())).Data as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_PASSTHROUGH_INPUT), + "::", + stringify!(Data) + ) + ); +} +pub type SCM_PD_PASSTHROUGH_INPUT = _SCM_PD_PASSTHROUGH_INPUT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCM_PD_PASSTHROUGH_OUTPUT { + pub Version: DWORD, + pub Size: DWORD, + pub ProtocolGuid: GUID, + pub DataSize: DWORD, + pub Data: [BYTE; 1usize], +} +#[test] +fn bindgen_test_layout__SCM_PD_PASSTHROUGH_OUTPUT() { + assert_eq!( + ::std::mem::size_of::<_SCM_PD_PASSTHROUGH_OUTPUT>(), + 32usize, + concat!("Size of: ", stringify!(_SCM_PD_PASSTHROUGH_OUTPUT)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_PD_PASSTHROUGH_OUTPUT>(), + 4usize, + concat!("Alignment of ", stringify!(_SCM_PD_PASSTHROUGH_OUTPUT)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_PASSTHROUGH_OUTPUT>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_PASSTHROUGH_OUTPUT), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_PASSTHROUGH_OUTPUT>())).Size as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_PASSTHROUGH_OUTPUT), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_PASSTHROUGH_OUTPUT>())).ProtocolGuid as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_PASSTHROUGH_OUTPUT), + "::", + stringify!(ProtocolGuid) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_PASSTHROUGH_OUTPUT>())).DataSize as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_PASSTHROUGH_OUTPUT), + "::", + stringify!(DataSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCM_PD_PASSTHROUGH_OUTPUT>())).Data as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_PASSTHROUGH_OUTPUT), + "::", + stringify!(Data) + ) + ); +} +pub type SCM_PD_PASSTHROUGH_OUTPUT = _SCM_PD_PASSTHROUGH_OUTPUT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCM_PD_PASSTHROUGH_INVDIMM_INPUT { + pub Opcode: DWORD, + pub OpcodeParametersLength: DWORD, + pub OpcodeParameters: [BYTE; 1usize], +} +#[test] +fn bindgen_test_layout__SCM_PD_PASSTHROUGH_INVDIMM_INPUT() { + assert_eq!( + ::std::mem::size_of::<_SCM_PD_PASSTHROUGH_INVDIMM_INPUT>(), + 12usize, + concat!("Size of: ", stringify!(_SCM_PD_PASSTHROUGH_INVDIMM_INPUT)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_PD_PASSTHROUGH_INVDIMM_INPUT>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_SCM_PD_PASSTHROUGH_INVDIMM_INPUT) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_PASSTHROUGH_INVDIMM_INPUT>())).Opcode as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_PASSTHROUGH_INVDIMM_INPUT), + "::", + stringify!(Opcode) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_PASSTHROUGH_INVDIMM_INPUT>())).OpcodeParametersLength + as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_PASSTHROUGH_INVDIMM_INPUT), + "::", + stringify!(OpcodeParametersLength) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_PASSTHROUGH_INVDIMM_INPUT>())).OpcodeParameters as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_PASSTHROUGH_INVDIMM_INPUT), + "::", + stringify!(OpcodeParameters) + ) + ); +} +pub type SCM_PD_PASSTHROUGH_INVDIMM_INPUT = _SCM_PD_PASSTHROUGH_INVDIMM_INPUT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCM_PD_PASSTHROUGH_INVDIMM_OUTPUT { + pub GeneralStatus: WORD, + pub ExtendedStatus: WORD, + pub OutputDataLength: DWORD, + pub OutputData: [BYTE; 1usize], +} +#[test] +fn bindgen_test_layout__SCM_PD_PASSTHROUGH_INVDIMM_OUTPUT() { + assert_eq!( + ::std::mem::size_of::<_SCM_PD_PASSTHROUGH_INVDIMM_OUTPUT>(), + 12usize, + concat!("Size of: ", stringify!(_SCM_PD_PASSTHROUGH_INVDIMM_OUTPUT)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_PD_PASSTHROUGH_INVDIMM_OUTPUT>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_SCM_PD_PASSTHROUGH_INVDIMM_OUTPUT) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_PASSTHROUGH_INVDIMM_OUTPUT>())).GeneralStatus as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_PASSTHROUGH_INVDIMM_OUTPUT), + "::", + stringify!(GeneralStatus) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_PASSTHROUGH_INVDIMM_OUTPUT>())).ExtendedStatus as *const _ + as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_PASSTHROUGH_INVDIMM_OUTPUT), + "::", + stringify!(ExtendedStatus) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_PASSTHROUGH_INVDIMM_OUTPUT>())).OutputDataLength as *const _ + as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_PASSTHROUGH_INVDIMM_OUTPUT), + "::", + stringify!(OutputDataLength) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_PASSTHROUGH_INVDIMM_OUTPUT>())).OutputData as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_PASSTHROUGH_INVDIMM_OUTPUT), + "::", + stringify!(OutputData) + ) + ); +} +pub type SCM_PD_PASSTHROUGH_INVDIMM_OUTPUT = _SCM_PD_PASSTHROUGH_INVDIMM_OUTPUT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCM_PD_REINITIALIZE_MEDIA_INPUT { + pub Version: DWORD, + pub Size: DWORD, + pub Options: _SCM_PD_REINITIALIZE_MEDIA_INPUT__bindgen_ty_1, +} +#[repr(C)] +#[repr(align(4))] +#[derive(Debug, Copy, Clone)] +pub struct _SCM_PD_REINITIALIZE_MEDIA_INPUT__bindgen_ty_1 { + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>, + pub __bindgen_padding_0: [u8; 3usize], +} +#[test] +fn bindgen_test_layout__SCM_PD_REINITIALIZE_MEDIA_INPUT__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_SCM_PD_REINITIALIZE_MEDIA_INPUT__bindgen_ty_1>(), + 4usize, + concat!( + "Size of: ", + stringify!(_SCM_PD_REINITIALIZE_MEDIA_INPUT__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_PD_REINITIALIZE_MEDIA_INPUT__bindgen_ty_1>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_SCM_PD_REINITIALIZE_MEDIA_INPUT__bindgen_ty_1) + ) + ); +} +impl _SCM_PD_REINITIALIZE_MEDIA_INPUT__bindgen_ty_1 { + #[inline] + pub fn Overwrite(&self) -> DWORD { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } + } + #[inline] + pub fn set_Overwrite(&mut self, val: DWORD) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(Overwrite: DWORD) -> __BindgenBitfieldUnit<[u8; 1usize], u8> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize], u8> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let Overwrite: u32 = unsafe { ::std::mem::transmute(Overwrite) }; + Overwrite as u64 + }); + __bindgen_bitfield_unit + } +} +#[test] +fn bindgen_test_layout__SCM_PD_REINITIALIZE_MEDIA_INPUT() { + assert_eq!( + ::std::mem::size_of::<_SCM_PD_REINITIALIZE_MEDIA_INPUT>(), + 12usize, + concat!("Size of: ", stringify!(_SCM_PD_REINITIALIZE_MEDIA_INPUT)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_PD_REINITIALIZE_MEDIA_INPUT>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_SCM_PD_REINITIALIZE_MEDIA_INPUT) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_REINITIALIZE_MEDIA_INPUT>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_REINITIALIZE_MEDIA_INPUT), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_REINITIALIZE_MEDIA_INPUT>())).Size as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_REINITIALIZE_MEDIA_INPUT), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_REINITIALIZE_MEDIA_INPUT>())).Options as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_REINITIALIZE_MEDIA_INPUT), + "::", + stringify!(Options) + ) + ); +} +pub type SCM_PD_REINITIALIZE_MEDIA_INPUT = _SCM_PD_REINITIALIZE_MEDIA_INPUT; +pub const _SCM_PD_MEDIA_REINITIALIZATION_STATUS_ScmPhysicalDeviceReinit_Success: + _SCM_PD_MEDIA_REINITIALIZATION_STATUS = 0; +pub const _SCM_PD_MEDIA_REINITIALIZATION_STATUS_ScmPhysicalDeviceReinit_RebootNeeded: + _SCM_PD_MEDIA_REINITIALIZATION_STATUS = 1; +pub const _SCM_PD_MEDIA_REINITIALIZATION_STATUS_ScmPhysicalDeviceReinit_ColdBootNeeded: + _SCM_PD_MEDIA_REINITIALIZATION_STATUS = 2; +pub const _SCM_PD_MEDIA_REINITIALIZATION_STATUS_ScmPhysicalDeviceReinit_Max: + _SCM_PD_MEDIA_REINITIALIZATION_STATUS = 3; +pub type _SCM_PD_MEDIA_REINITIALIZATION_STATUS = ::std::os::raw::c_int; +pub use self::_SCM_PD_MEDIA_REINITIALIZATION_STATUS as SCM_PD_MEDIA_REINITIALIZATION_STATUS; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCM_PD_REINITIALIZE_MEDIA_OUTPUT { + pub Version: DWORD, + pub Size: DWORD, + pub Status: SCM_PD_MEDIA_REINITIALIZATION_STATUS, +} +#[test] +fn bindgen_test_layout__SCM_PD_REINITIALIZE_MEDIA_OUTPUT() { + assert_eq!( + ::std::mem::size_of::<_SCM_PD_REINITIALIZE_MEDIA_OUTPUT>(), + 12usize, + concat!("Size of: ", stringify!(_SCM_PD_REINITIALIZE_MEDIA_OUTPUT)) + ); + assert_eq!( + ::std::mem::align_of::<_SCM_PD_REINITIALIZE_MEDIA_OUTPUT>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_SCM_PD_REINITIALIZE_MEDIA_OUTPUT) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_REINITIALIZE_MEDIA_OUTPUT>())).Version as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_REINITIALIZE_MEDIA_OUTPUT), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_REINITIALIZE_MEDIA_OUTPUT>())).Size as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_REINITIALIZE_MEDIA_OUTPUT), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCM_PD_REINITIALIZE_MEDIA_OUTPUT>())).Status as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCM_PD_REINITIALIZE_MEDIA_OUTPUT), + "::", + stringify!(Status) + ) + ); +} +pub type SCM_PD_REINITIALIZE_MEDIA_OUTPUT = _SCM_PD_REINITIALIZE_MEDIA_OUTPUT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SET_PARTITION_INFORMATION { + pub PartitionType: BYTE, +} +#[test] +fn bindgen_test_layout__SET_PARTITION_INFORMATION() { + assert_eq!( + ::std::mem::size_of::<_SET_PARTITION_INFORMATION>(), + 1usize, + concat!("Size of: ", stringify!(_SET_PARTITION_INFORMATION)) + ); + assert_eq!( + ::std::mem::align_of::<_SET_PARTITION_INFORMATION>(), + 1usize, + concat!("Alignment of ", stringify!(_SET_PARTITION_INFORMATION)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SET_PARTITION_INFORMATION>())).PartitionType as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SET_PARTITION_INFORMATION), + "::", + stringify!(PartitionType) + ) + ); +} +pub type SET_PARTITION_INFORMATION = _SET_PARTITION_INFORMATION; +pub const _PARTITION_STYLE_PARTITION_STYLE_MBR: _PARTITION_STYLE = 0; +pub const _PARTITION_STYLE_PARTITION_STYLE_GPT: _PARTITION_STYLE = 1; +pub const _PARTITION_STYLE_PARTITION_STYLE_RAW: _PARTITION_STYLE = 2; +pub type _PARTITION_STYLE = ::std::os::raw::c_int; +pub use self::_PARTITION_STYLE as PARTITION_STYLE; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _PARTITION_INFORMATION_GPT { + pub PartitionType: GUID, + pub PartitionId: GUID, + pub Attributes: DWORD64, + pub Name: [WCHAR; 36usize], +} +#[test] +fn bindgen_test_layout__PARTITION_INFORMATION_GPT() { + assert_eq!( + ::std::mem::size_of::<_PARTITION_INFORMATION_GPT>(), + 112usize, + concat!("Size of: ", stringify!(_PARTITION_INFORMATION_GPT)) + ); + assert_eq!( + ::std::mem::align_of::<_PARTITION_INFORMATION_GPT>(), + 8usize, + concat!("Alignment of ", stringify!(_PARTITION_INFORMATION_GPT)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_PARTITION_INFORMATION_GPT>())).PartitionType as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_PARTITION_INFORMATION_GPT), + "::", + stringify!(PartitionType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_PARTITION_INFORMATION_GPT>())).PartitionId as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_PARTITION_INFORMATION_GPT), + "::", + stringify!(PartitionId) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_PARTITION_INFORMATION_GPT>())).Attributes as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_PARTITION_INFORMATION_GPT), + "::", + stringify!(Attributes) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_PARTITION_INFORMATION_GPT>())).Name as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_PARTITION_INFORMATION_GPT), + "::", + stringify!(Name) + ) + ); +} +pub type PARTITION_INFORMATION_GPT = _PARTITION_INFORMATION_GPT; +pub type SET_PARTITION_INFORMATION_MBR = SET_PARTITION_INFORMATION; +pub type SET_PARTITION_INFORMATION_GPT = PARTITION_INFORMATION_GPT; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SET_PARTITION_INFORMATION_EX { + pub PartitionStyle: PARTITION_STYLE, + pub __bindgen_anon_1: _SET_PARTITION_INFORMATION_EX__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _SET_PARTITION_INFORMATION_EX__bindgen_ty_1 { + pub Mbr: SET_PARTITION_INFORMATION_MBR, + pub Gpt: SET_PARTITION_INFORMATION_GPT, + _bindgen_union_align: [u64; 14usize], +} +#[test] +fn bindgen_test_layout__SET_PARTITION_INFORMATION_EX__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_SET_PARTITION_INFORMATION_EX__bindgen_ty_1>(), + 112usize, + concat!( + "Size of: ", + stringify!(_SET_PARTITION_INFORMATION_EX__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SET_PARTITION_INFORMATION_EX__bindgen_ty_1>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_SET_PARTITION_INFORMATION_EX__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SET_PARTITION_INFORMATION_EX__bindgen_ty_1>())).Mbr as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SET_PARTITION_INFORMATION_EX__bindgen_ty_1), + "::", + stringify!(Mbr) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SET_PARTITION_INFORMATION_EX__bindgen_ty_1>())).Gpt as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SET_PARTITION_INFORMATION_EX__bindgen_ty_1), + "::", + stringify!(Gpt) + ) + ); +} +#[test] +fn bindgen_test_layout__SET_PARTITION_INFORMATION_EX() { + assert_eq!( + ::std::mem::size_of::<_SET_PARTITION_INFORMATION_EX>(), + 120usize, + concat!("Size of: ", stringify!(_SET_PARTITION_INFORMATION_EX)) + ); + assert_eq!( + ::std::mem::align_of::<_SET_PARTITION_INFORMATION_EX>(), + 8usize, + concat!("Alignment of ", stringify!(_SET_PARTITION_INFORMATION_EX)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SET_PARTITION_INFORMATION_EX>())).PartitionStyle as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SET_PARTITION_INFORMATION_EX), + "::", + stringify!(PartitionStyle) + ) + ); +} +pub type SET_PARTITION_INFORMATION_EX = _SET_PARTITION_INFORMATION_EX; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _IDEREGS { + pub bFeaturesReg: BYTE, + pub bSectorCountReg: BYTE, + pub bSectorNumberReg: BYTE, + pub bCylLowReg: BYTE, + pub bCylHighReg: BYTE, + pub bDriveHeadReg: BYTE, + pub bCommandReg: BYTE, + pub bReserved: BYTE, +} +#[test] +fn bindgen_test_layout__IDEREGS() { + assert_eq!( + ::std::mem::size_of::<_IDEREGS>(), + 8usize, + concat!("Size of: ", stringify!(_IDEREGS)) + ); + assert_eq!( + ::std::mem::align_of::<_IDEREGS>(), + 1usize, + concat!("Alignment of ", stringify!(_IDEREGS)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_IDEREGS>())).bFeaturesReg as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_IDEREGS), + "::", + stringify!(bFeaturesReg) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_IDEREGS>())).bSectorCountReg as *const _ as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(_IDEREGS), + "::", + stringify!(bSectorCountReg) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_IDEREGS>())).bSectorNumberReg as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_IDEREGS), + "::", + stringify!(bSectorNumberReg) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_IDEREGS>())).bCylLowReg as *const _ as usize }, + 3usize, + concat!( + "Offset of field: ", + stringify!(_IDEREGS), + "::", + stringify!(bCylLowReg) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_IDEREGS>())).bCylHighReg as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_IDEREGS), + "::", + stringify!(bCylHighReg) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_IDEREGS>())).bDriveHeadReg as *const _ as usize }, + 5usize, + concat!( + "Offset of field: ", + stringify!(_IDEREGS), + "::", + stringify!(bDriveHeadReg) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_IDEREGS>())).bCommandReg as *const _ as usize }, + 6usize, + concat!( + "Offset of field: ", + stringify!(_IDEREGS), + "::", + stringify!(bCommandReg) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_IDEREGS>())).bReserved as *const _ as usize }, + 7usize, + concat!( + "Offset of field: ", + stringify!(_IDEREGS), + "::", + stringify!(bReserved) + ) + ); +} +pub type IDEREGS = _IDEREGS; +#[repr(C, packed)] +#[derive(Debug, Copy, Clone)] +pub struct _SENDCMDINPARAMS { + pub cBufferSize: DWORD, + pub irDriveRegs: IDEREGS, + pub bDriveNumber: BYTE, + pub bReserved: [BYTE; 3usize], + pub dwReserved: [DWORD; 4usize], + pub bBuffer: [BYTE; 1usize], +} +#[test] +fn bindgen_test_layout__SENDCMDINPARAMS() { + assert_eq!( + ::std::mem::size_of::<_SENDCMDINPARAMS>(), + 33usize, + concat!("Size of: ", stringify!(_SENDCMDINPARAMS)) + ); + assert_eq!( + ::std::mem::align_of::<_SENDCMDINPARAMS>(), + 1usize, + concat!("Alignment of ", stringify!(_SENDCMDINPARAMS)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SENDCMDINPARAMS>())).cBufferSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SENDCMDINPARAMS), + "::", + stringify!(cBufferSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SENDCMDINPARAMS>())).irDriveRegs as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SENDCMDINPARAMS), + "::", + stringify!(irDriveRegs) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SENDCMDINPARAMS>())).bDriveNumber as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SENDCMDINPARAMS), + "::", + stringify!(bDriveNumber) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SENDCMDINPARAMS>())).bReserved as *const _ as usize }, + 13usize, + concat!( + "Offset of field: ", + stringify!(_SENDCMDINPARAMS), + "::", + stringify!(bReserved) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SENDCMDINPARAMS>())).dwReserved as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SENDCMDINPARAMS), + "::", + stringify!(dwReserved) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SENDCMDINPARAMS>())).bBuffer as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_SENDCMDINPARAMS), + "::", + stringify!(bBuffer) + ) + ); +} +pub type SENDCMDINPARAMS = _SENDCMDINPARAMS; +#[repr(C, packed)] +#[derive(Debug, Copy, Clone)] +pub struct _DRIVERSTATUS { + pub bDriverError: BYTE, + pub bIDEError: BYTE, + pub bReserved: [BYTE; 2usize], + pub dwReserved: [DWORD; 2usize], +} +#[test] +fn bindgen_test_layout__DRIVERSTATUS() { + assert_eq!( + ::std::mem::size_of::<_DRIVERSTATUS>(), + 12usize, + concat!("Size of: ", stringify!(_DRIVERSTATUS)) + ); + assert_eq!( + ::std::mem::align_of::<_DRIVERSTATUS>(), + 1usize, + concat!("Alignment of ", stringify!(_DRIVERSTATUS)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_DRIVERSTATUS>())).bDriverError as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_DRIVERSTATUS), + "::", + stringify!(bDriverError) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_DRIVERSTATUS>())).bIDEError as *const _ as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(_DRIVERSTATUS), + "::", + stringify!(bIDEError) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_DRIVERSTATUS>())).bReserved as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_DRIVERSTATUS), + "::", + stringify!(bReserved) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_DRIVERSTATUS>())).dwReserved as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_DRIVERSTATUS), + "::", + stringify!(dwReserved) + ) + ); +} +pub type DRIVERSTATUS = _DRIVERSTATUS; +#[repr(C, packed)] +#[derive(Debug, Copy, Clone)] +pub struct _SENDCMDOUTPARAMS { + pub cBufferSize: DWORD, + pub DriverStatus: DRIVERSTATUS, + pub bBuffer: [BYTE; 1usize], +} +#[test] +fn bindgen_test_layout__SENDCMDOUTPARAMS() { + assert_eq!( + ::std::mem::size_of::<_SENDCMDOUTPARAMS>(), + 17usize, + concat!("Size of: ", stringify!(_SENDCMDOUTPARAMS)) + ); + assert_eq!( + ::std::mem::align_of::<_SENDCMDOUTPARAMS>(), + 1usize, + concat!("Alignment of ", stringify!(_SENDCMDOUTPARAMS)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SENDCMDOUTPARAMS>())).cBufferSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SENDCMDOUTPARAMS), + "::", + stringify!(cBufferSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SENDCMDOUTPARAMS>())).DriverStatus as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SENDCMDOUTPARAMS), + "::", + stringify!(DriverStatus) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SENDCMDOUTPARAMS>())).bBuffer as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SENDCMDOUTPARAMS), + "::", + stringify!(bBuffer) + ) + ); +} +pub type SENDCMDOUTPARAMS = _SENDCMDOUTPARAMS; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SET_DISK_ATTRIBUTES { + pub Version: DWORD, + pub Persist: BOOLEAN, + pub Reserved1: [BYTE; 3usize], + pub Attributes: DWORDLONG, + pub AttributesMask: DWORDLONG, + pub Reserved2: [DWORD; 4usize], +} +#[test] +fn bindgen_test_layout__SET_DISK_ATTRIBUTES() { + assert_eq!( + ::std::mem::size_of::<_SET_DISK_ATTRIBUTES>(), + 40usize, + concat!("Size of: ", stringify!(_SET_DISK_ATTRIBUTES)) + ); + assert_eq!( + ::std::mem::align_of::<_SET_DISK_ATTRIBUTES>(), + 8usize, + concat!("Alignment of ", stringify!(_SET_DISK_ATTRIBUTES)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SET_DISK_ATTRIBUTES>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SET_DISK_ATTRIBUTES), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SET_DISK_ATTRIBUTES>())).Persist as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SET_DISK_ATTRIBUTES), + "::", + stringify!(Persist) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SET_DISK_ATTRIBUTES>())).Reserved1 as *const _ as usize }, + 5usize, + concat!( + "Offset of field: ", + stringify!(_SET_DISK_ATTRIBUTES), + "::", + stringify!(Reserved1) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SET_DISK_ATTRIBUTES>())).Attributes as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SET_DISK_ATTRIBUTES), + "::", + stringify!(Attributes) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SET_DISK_ATTRIBUTES>())).AttributesMask as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SET_DISK_ATTRIBUTES), + "::", + stringify!(AttributesMask) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SET_DISK_ATTRIBUTES>())).Reserved2 as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SET_DISK_ATTRIBUTES), + "::", + stringify!(Reserved2) + ) + ); +} +pub type SET_DISK_ATTRIBUTES = _SET_DISK_ATTRIBUTES; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct STARTING_LCN_INPUT_BUFFER { + pub StartingLcn: LARGE_INTEGER, +} +#[test] +fn bindgen_test_layout_STARTING_LCN_INPUT_BUFFER() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(STARTING_LCN_INPUT_BUFFER)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(STARTING_LCN_INPUT_BUFFER)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).StartingLcn as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(STARTING_LCN_INPUT_BUFFER), + "::", + stringify!(StartingLcn) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct STARTING_LCN_INPUT_BUFFER_EX { + pub StartingLcn: LARGE_INTEGER, + pub Flags: DWORD, +} +#[test] +fn bindgen_test_layout_STARTING_LCN_INPUT_BUFFER_EX() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(STARTING_LCN_INPUT_BUFFER_EX)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(STARTING_LCN_INPUT_BUFFER_EX)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).StartingLcn as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(STARTING_LCN_INPUT_BUFFER_EX), + "::", + stringify!(StartingLcn) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).Flags as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(STARTING_LCN_INPUT_BUFFER_EX), + "::", + stringify!(Flags) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct STARTING_VCN_INPUT_BUFFER { + pub StartingVcn: LARGE_INTEGER, +} +#[test] +fn bindgen_test_layout_STARTING_VCN_INPUT_BUFFER() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(STARTING_VCN_INPUT_BUFFER)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(STARTING_VCN_INPUT_BUFFER)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).StartingVcn as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(STARTING_VCN_INPUT_BUFFER), + "::", + stringify!(StartingVcn) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct RETRIEVAL_POINTERS_BUFFER { + pub ExtentCount: DWORD, + pub StartingVcn: LARGE_INTEGER, + pub Extents: [RETRIEVAL_POINTERS_BUFFER__bindgen_ty_1; 1usize], +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct RETRIEVAL_POINTERS_BUFFER__bindgen_ty_1 { + pub NextVcn: LARGE_INTEGER, + pub Lcn: LARGE_INTEGER, +} +#[test] +fn bindgen_test_layout_RETRIEVAL_POINTERS_BUFFER__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!( + "Size of: ", + stringify!(RETRIEVAL_POINTERS_BUFFER__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(RETRIEVAL_POINTERS_BUFFER__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).NextVcn as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(RETRIEVAL_POINTERS_BUFFER__bindgen_ty_1), + "::", + stringify!(NextVcn) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).Lcn as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(RETRIEVAL_POINTERS_BUFFER__bindgen_ty_1), + "::", + stringify!(Lcn) + ) + ); +} +#[test] +fn bindgen_test_layout_RETRIEVAL_POINTERS_BUFFER() { + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(RETRIEVAL_POINTERS_BUFFER)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(RETRIEVAL_POINTERS_BUFFER)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).ExtentCount as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(RETRIEVAL_POINTERS_BUFFER), + "::", + stringify!(ExtentCount) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).StartingVcn as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(RETRIEVAL_POINTERS_BUFFER), + "::", + stringify!(StartingVcn) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).Extents as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(RETRIEVAL_POINTERS_BUFFER), + "::", + stringify!(Extents) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SI_COPYFILE { + pub SourceFileNameLength: DWORD, + pub DestinationFileNameLength: DWORD, + pub Flags: DWORD, + pub FileNameBuffer: [WCHAR; 1usize], +} +#[test] +fn bindgen_test_layout__SI_COPYFILE() { + assert_eq!( + ::std::mem::size_of::<_SI_COPYFILE>(), + 16usize, + concat!("Size of: ", stringify!(_SI_COPYFILE)) + ); + assert_eq!( + ::std::mem::align_of::<_SI_COPYFILE>(), + 4usize, + concat!("Alignment of ", stringify!(_SI_COPYFILE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SI_COPYFILE>())).SourceFileNameLength as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SI_COPYFILE), + "::", + stringify!(SourceFileNameLength) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SI_COPYFILE>())).DestinationFileNameLength as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SI_COPYFILE), + "::", + stringify!(DestinationFileNameLength) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SI_COPYFILE>())).Flags as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SI_COPYFILE), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SI_COPYFILE>())).FileNameBuffer as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SI_COPYFILE), + "::", + stringify!(FileNameBuffer) + ) + ); +} +pub type SI_COPYFILE = _SI_COPYFILE; +pub const _SHRINK_VOLUME_REQUEST_TYPES_ShrinkPrepare: _SHRINK_VOLUME_REQUEST_TYPES = 1; +pub const _SHRINK_VOLUME_REQUEST_TYPES_ShrinkCommit: _SHRINK_VOLUME_REQUEST_TYPES = 2; +pub const _SHRINK_VOLUME_REQUEST_TYPES_ShrinkAbort: _SHRINK_VOLUME_REQUEST_TYPES = 3; +pub type _SHRINK_VOLUME_REQUEST_TYPES = ::std::os::raw::c_int; +pub use self::_SHRINK_VOLUME_REQUEST_TYPES as SHRINK_VOLUME_REQUEST_TYPES; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SHRINK_VOLUME_INFORMATION { + pub ShrinkRequestType: SHRINK_VOLUME_REQUEST_TYPES, + pub Flags: DWORDLONG, + pub NewNumberOfSectors: LONGLONG, +} +#[test] +fn bindgen_test_layout__SHRINK_VOLUME_INFORMATION() { + assert_eq!( + ::std::mem::size_of::<_SHRINK_VOLUME_INFORMATION>(), + 24usize, + concat!("Size of: ", stringify!(_SHRINK_VOLUME_INFORMATION)) + ); + assert_eq!( + ::std::mem::align_of::<_SHRINK_VOLUME_INFORMATION>(), + 8usize, + concat!("Alignment of ", stringify!(_SHRINK_VOLUME_INFORMATION)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SHRINK_VOLUME_INFORMATION>())).ShrinkRequestType as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SHRINK_VOLUME_INFORMATION), + "::", + stringify!(ShrinkRequestType) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SHRINK_VOLUME_INFORMATION>())).Flags as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SHRINK_VOLUME_INFORMATION), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SHRINK_VOLUME_INFORMATION>())).NewNumberOfSectors as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SHRINK_VOLUME_INFORMATION), + "::", + stringify!(NewNumberOfSectors) + ) + ); +} +pub type SHRINK_VOLUME_INFORMATION = _SHRINK_VOLUME_INFORMATION; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _VIRTUAL_STORAGE_TYPE { + pub DeviceId: DWORD, + pub VendorId: GUID, +} +#[test] +fn bindgen_test_layout__VIRTUAL_STORAGE_TYPE() { + assert_eq!( + ::std::mem::size_of::<_VIRTUAL_STORAGE_TYPE>(), + 20usize, + concat!("Size of: ", stringify!(_VIRTUAL_STORAGE_TYPE)) + ); + assert_eq!( + ::std::mem::align_of::<_VIRTUAL_STORAGE_TYPE>(), + 4usize, + concat!("Alignment of ", stringify!(_VIRTUAL_STORAGE_TYPE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_VIRTUAL_STORAGE_TYPE>())).DeviceId as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_VIRTUAL_STORAGE_TYPE), + "::", + stringify!(DeviceId) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_VIRTUAL_STORAGE_TYPE>())).VendorId as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_VIRTUAL_STORAGE_TYPE), + "::", + stringify!(VendorId) + ) + ); +} +pub type VIRTUAL_STORAGE_TYPE = _VIRTUAL_STORAGE_TYPE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_QUERY_DEPENDENT_VOLUME_REQUEST { + pub RequestLevel: DWORD, + pub RequestFlags: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_QUERY_DEPENDENT_VOLUME_REQUEST() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_QUERY_DEPENDENT_VOLUME_REQUEST>(), + 8usize, + concat!( + "Size of: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_REQUEST) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_QUERY_DEPENDENT_VOLUME_REQUEST>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_REQUEST) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_QUERY_DEPENDENT_VOLUME_REQUEST>())).RequestLevel as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_REQUEST), + "::", + stringify!(RequestLevel) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_QUERY_DEPENDENT_VOLUME_REQUEST>())).RequestFlags as *const _ + as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_REQUEST), + "::", + stringify!(RequestFlags) + ) + ); +} +pub type STORAGE_QUERY_DEPENDENT_VOLUME_REQUEST = _STORAGE_QUERY_DEPENDENT_VOLUME_REQUEST; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY { + pub EntryLength: DWORD, + pub DependencyTypeFlags: DWORD, + pub ProviderSpecificFlags: DWORD, + pub VirtualStorageType: VIRTUAL_STORAGE_TYPE, +} +#[test] +fn bindgen_test_layout__STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY>(), + 32usize, + concat!( + "Size of: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY>())).EntryLength as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY), + "::", + stringify!(EntryLength) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY>())).DependencyTypeFlags + as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY), + "::", + stringify!(DependencyTypeFlags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY>())).ProviderSpecificFlags + as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY), + "::", + stringify!(ProviderSpecificFlags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY>())).VirtualStorageType + as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY), + "::", + stringify!(VirtualStorageType) + ) + ); +} +pub type STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY = _STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY { + pub EntryLength: DWORD, + pub DependencyTypeFlags: DWORD, + pub ProviderSpecificFlags: DWORD, + pub VirtualStorageType: VIRTUAL_STORAGE_TYPE, + pub AncestorLevel: DWORD, + pub HostVolumeNameOffset: DWORD, + pub HostVolumeNameSize: DWORD, + pub DependentVolumeNameOffset: DWORD, + pub DependentVolumeNameSize: DWORD, + pub RelativePathOffset: DWORD, + pub RelativePathSize: DWORD, + pub DependentDeviceNameOffset: DWORD, + pub DependentDeviceNameSize: DWORD, +} +#[test] +fn bindgen_test_layout__STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY>(), + 68usize, + concat!( + "Size of: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY>())).EntryLength as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY), + "::", + stringify!(EntryLength) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY>())).DependencyTypeFlags + as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY), + "::", + stringify!(DependencyTypeFlags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY>())).ProviderSpecificFlags + as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY), + "::", + stringify!(ProviderSpecificFlags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY>())).VirtualStorageType + as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY), + "::", + stringify!(VirtualStorageType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY>())).AncestorLevel + as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY), + "::", + stringify!(AncestorLevel) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY>())).HostVolumeNameOffset + as *const _ as usize + }, + 36usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY), + "::", + stringify!(HostVolumeNameOffset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY>())).HostVolumeNameSize + as *const _ as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY), + "::", + stringify!(HostVolumeNameSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY>())) + .DependentVolumeNameOffset as *const _ as usize + }, + 44usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY), + "::", + stringify!(DependentVolumeNameOffset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY>())).DependentVolumeNameSize + as *const _ as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY), + "::", + stringify!(DependentVolumeNameSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY>())).RelativePathOffset + as *const _ as usize + }, + 52usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY), + "::", + stringify!(RelativePathOffset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY>())).RelativePathSize + as *const _ as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY), + "::", + stringify!(RelativePathSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY>())) + .DependentDeviceNameOffset as *const _ as usize + }, + 60usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY), + "::", + stringify!(DependentDeviceNameOffset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY>())).DependentDeviceNameSize + as *const _ as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY), + "::", + stringify!(DependentDeviceNameSize) + ) + ); +} +pub type STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY = _STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY; +#[repr(C)] +pub struct _STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE { + pub ResponseLevel: DWORD, + pub NumberEntries: DWORD, + pub __bindgen_anon_1: _STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE__bindgen_ty_1, +} +#[repr(C)] +pub struct _STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE__bindgen_ty_1 { + pub Lev1Depends: __BindgenUnionField<[STORAGE_QUERY_DEPENDENT_VOLUME_LEV1_ENTRY; 0usize]>, + pub Lev2Depends: __BindgenUnionField<[STORAGE_QUERY_DEPENDENT_VOLUME_LEV2_ENTRY; 0usize]>, + pub bindgen_union_field: u32, +} +#[test] +fn bindgen_test_layout__STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE__bindgen_ty_1>(), + 4usize, + concat!( + "Size of: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE__bindgen_ty_1>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE__bindgen_ty_1>())).Lev1Depends + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE__bindgen_ty_1), + "::", + stringify!(Lev1Depends) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE__bindgen_ty_1>())).Lev2Depends + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE__bindgen_ty_1), + "::", + stringify!(Lev2Depends) + ) + ); +} +#[test] +fn bindgen_test_layout__STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE() { + assert_eq!( + ::std::mem::size_of::<_STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE>(), + 12usize, + concat!( + "Size of: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE>())).ResponseLevel as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE), + "::", + stringify!(ResponseLevel) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE>())).NumberEntries as *const _ + as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE), + "::", + stringify!(NumberEntries) + ) + ); +} +pub type STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE = _STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SD_CHANGE_MACHINE_SID_INPUT { + pub CurrentMachineSIDOffset: WORD, + pub CurrentMachineSIDLength: WORD, + pub NewMachineSIDOffset: WORD, + pub NewMachineSIDLength: WORD, +} +#[test] +fn bindgen_test_layout__SD_CHANGE_MACHINE_SID_INPUT() { + assert_eq!( + ::std::mem::size_of::<_SD_CHANGE_MACHINE_SID_INPUT>(), + 8usize, + concat!("Size of: ", stringify!(_SD_CHANGE_MACHINE_SID_INPUT)) + ); + assert_eq!( + ::std::mem::align_of::<_SD_CHANGE_MACHINE_SID_INPUT>(), + 2usize, + concat!("Alignment of ", stringify!(_SD_CHANGE_MACHINE_SID_INPUT)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_CHANGE_MACHINE_SID_INPUT>())).CurrentMachineSIDOffset as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SD_CHANGE_MACHINE_SID_INPUT), + "::", + stringify!(CurrentMachineSIDOffset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_CHANGE_MACHINE_SID_INPUT>())).CurrentMachineSIDLength as *const _ + as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_SD_CHANGE_MACHINE_SID_INPUT), + "::", + stringify!(CurrentMachineSIDLength) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_CHANGE_MACHINE_SID_INPUT>())).NewMachineSIDOffset as *const _ + as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SD_CHANGE_MACHINE_SID_INPUT), + "::", + stringify!(NewMachineSIDOffset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_CHANGE_MACHINE_SID_INPUT>())).NewMachineSIDLength as *const _ + as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(_SD_CHANGE_MACHINE_SID_INPUT), + "::", + stringify!(NewMachineSIDLength) + ) + ); +} +pub type SD_CHANGE_MACHINE_SID_INPUT = _SD_CHANGE_MACHINE_SID_INPUT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SD_CHANGE_MACHINE_SID_OUTPUT { + pub NumSDChangedSuccess: DWORDLONG, + pub NumSDChangedFail: DWORDLONG, + pub NumSDUnused: DWORDLONG, + pub NumSDTotal: DWORDLONG, + pub NumMftSDChangedSuccess: DWORDLONG, + pub NumMftSDChangedFail: DWORDLONG, + pub NumMftSDTotal: DWORDLONG, +} +#[test] +fn bindgen_test_layout__SD_CHANGE_MACHINE_SID_OUTPUT() { + assert_eq!( + ::std::mem::size_of::<_SD_CHANGE_MACHINE_SID_OUTPUT>(), + 56usize, + concat!("Size of: ", stringify!(_SD_CHANGE_MACHINE_SID_OUTPUT)) + ); + assert_eq!( + ::std::mem::align_of::<_SD_CHANGE_MACHINE_SID_OUTPUT>(), + 8usize, + concat!("Alignment of ", stringify!(_SD_CHANGE_MACHINE_SID_OUTPUT)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_CHANGE_MACHINE_SID_OUTPUT>())).NumSDChangedSuccess as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SD_CHANGE_MACHINE_SID_OUTPUT), + "::", + stringify!(NumSDChangedSuccess) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_CHANGE_MACHINE_SID_OUTPUT>())).NumSDChangedFail as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SD_CHANGE_MACHINE_SID_OUTPUT), + "::", + stringify!(NumSDChangedFail) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_CHANGE_MACHINE_SID_OUTPUT>())).NumSDUnused as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SD_CHANGE_MACHINE_SID_OUTPUT), + "::", + stringify!(NumSDUnused) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_CHANGE_MACHINE_SID_OUTPUT>())).NumSDTotal as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SD_CHANGE_MACHINE_SID_OUTPUT), + "::", + stringify!(NumSDTotal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_CHANGE_MACHINE_SID_OUTPUT>())).NumMftSDChangedSuccess as *const _ + as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_SD_CHANGE_MACHINE_SID_OUTPUT), + "::", + stringify!(NumMftSDChangedSuccess) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_CHANGE_MACHINE_SID_OUTPUT>())).NumMftSDChangedFail as *const _ + as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_SD_CHANGE_MACHINE_SID_OUTPUT), + "::", + stringify!(NumMftSDChangedFail) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_CHANGE_MACHINE_SID_OUTPUT>())).NumMftSDTotal as *const _ as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_SD_CHANGE_MACHINE_SID_OUTPUT), + "::", + stringify!(NumMftSDTotal) + ) + ); +} +pub type SD_CHANGE_MACHINE_SID_OUTPUT = _SD_CHANGE_MACHINE_SID_OUTPUT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SD_QUERY_STATS_INPUT { + pub Reserved: DWORD, +} +#[test] +fn bindgen_test_layout__SD_QUERY_STATS_INPUT() { + assert_eq!( + ::std::mem::size_of::<_SD_QUERY_STATS_INPUT>(), + 4usize, + concat!("Size of: ", stringify!(_SD_QUERY_STATS_INPUT)) + ); + assert_eq!( + ::std::mem::align_of::<_SD_QUERY_STATS_INPUT>(), + 4usize, + concat!("Alignment of ", stringify!(_SD_QUERY_STATS_INPUT)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SD_QUERY_STATS_INPUT>())).Reserved as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SD_QUERY_STATS_INPUT), + "::", + stringify!(Reserved) + ) + ); +} +pub type SD_QUERY_STATS_INPUT = _SD_QUERY_STATS_INPUT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SD_QUERY_STATS_OUTPUT { + pub SdsStreamSize: DWORDLONG, + pub SdsAllocationSize: DWORDLONG, + pub SiiStreamSize: DWORDLONG, + pub SiiAllocationSize: DWORDLONG, + pub SdhStreamSize: DWORDLONG, + pub SdhAllocationSize: DWORDLONG, + pub NumSDTotal: DWORDLONG, + pub NumSDUnused: DWORDLONG, +} +#[test] +fn bindgen_test_layout__SD_QUERY_STATS_OUTPUT() { + assert_eq!( + ::std::mem::size_of::<_SD_QUERY_STATS_OUTPUT>(), + 64usize, + concat!("Size of: ", stringify!(_SD_QUERY_STATS_OUTPUT)) + ); + assert_eq!( + ::std::mem::align_of::<_SD_QUERY_STATS_OUTPUT>(), + 8usize, + concat!("Alignment of ", stringify!(_SD_QUERY_STATS_OUTPUT)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_QUERY_STATS_OUTPUT>())).SdsStreamSize as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SD_QUERY_STATS_OUTPUT), + "::", + stringify!(SdsStreamSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_QUERY_STATS_OUTPUT>())).SdsAllocationSize as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SD_QUERY_STATS_OUTPUT), + "::", + stringify!(SdsAllocationSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_QUERY_STATS_OUTPUT>())).SiiStreamSize as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SD_QUERY_STATS_OUTPUT), + "::", + stringify!(SiiStreamSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_QUERY_STATS_OUTPUT>())).SiiAllocationSize as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SD_QUERY_STATS_OUTPUT), + "::", + stringify!(SiiAllocationSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_QUERY_STATS_OUTPUT>())).SdhStreamSize as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_SD_QUERY_STATS_OUTPUT), + "::", + stringify!(SdhStreamSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_QUERY_STATS_OUTPUT>())).SdhAllocationSize as *const _ as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_SD_QUERY_STATS_OUTPUT), + "::", + stringify!(SdhAllocationSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SD_QUERY_STATS_OUTPUT>())).NumSDTotal as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_SD_QUERY_STATS_OUTPUT), + "::", + stringify!(NumSDTotal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SD_QUERY_STATS_OUTPUT>())).NumSDUnused as *const _ as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(_SD_QUERY_STATS_OUTPUT), + "::", + stringify!(NumSDUnused) + ) + ); +} +pub type SD_QUERY_STATS_OUTPUT = _SD_QUERY_STATS_OUTPUT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SD_ENUM_SDS_INPUT { + pub StartingOffset: DWORDLONG, + pub MaxSDEntriesToReturn: DWORDLONG, +} +#[test] +fn bindgen_test_layout__SD_ENUM_SDS_INPUT() { + assert_eq!( + ::std::mem::size_of::<_SD_ENUM_SDS_INPUT>(), + 16usize, + concat!("Size of: ", stringify!(_SD_ENUM_SDS_INPUT)) + ); + assert_eq!( + ::std::mem::align_of::<_SD_ENUM_SDS_INPUT>(), + 8usize, + concat!("Alignment of ", stringify!(_SD_ENUM_SDS_INPUT)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SD_ENUM_SDS_INPUT>())).StartingOffset as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SD_ENUM_SDS_INPUT), + "::", + stringify!(StartingOffset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_ENUM_SDS_INPUT>())).MaxSDEntriesToReturn as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SD_ENUM_SDS_INPUT), + "::", + stringify!(MaxSDEntriesToReturn) + ) + ); +} +pub type SD_ENUM_SDS_INPUT = _SD_ENUM_SDS_INPUT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SD_ENUM_SDS_ENTRY { + pub Hash: DWORD, + pub SecurityId: DWORD, + pub Offset: DWORDLONG, + pub Length: DWORD, + pub Descriptor: [BYTE; 1usize], +} +#[test] +fn bindgen_test_layout__SD_ENUM_SDS_ENTRY() { + assert_eq!( + ::std::mem::size_of::<_SD_ENUM_SDS_ENTRY>(), + 24usize, + concat!("Size of: ", stringify!(_SD_ENUM_SDS_ENTRY)) + ); + assert_eq!( + ::std::mem::align_of::<_SD_ENUM_SDS_ENTRY>(), + 8usize, + concat!("Alignment of ", stringify!(_SD_ENUM_SDS_ENTRY)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SD_ENUM_SDS_ENTRY>())).Hash as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SD_ENUM_SDS_ENTRY), + "::", + stringify!(Hash) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SD_ENUM_SDS_ENTRY>())).SecurityId as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SD_ENUM_SDS_ENTRY), + "::", + stringify!(SecurityId) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SD_ENUM_SDS_ENTRY>())).Offset as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SD_ENUM_SDS_ENTRY), + "::", + stringify!(Offset) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SD_ENUM_SDS_ENTRY>())).Length as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SD_ENUM_SDS_ENTRY), + "::", + stringify!(Length) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SD_ENUM_SDS_ENTRY>())).Descriptor as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_SD_ENUM_SDS_ENTRY), + "::", + stringify!(Descriptor) + ) + ); +} +pub type SD_ENUM_SDS_ENTRY = _SD_ENUM_SDS_ENTRY; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SD_ENUM_SDS_OUTPUT { + pub NextOffset: DWORDLONG, + pub NumSDEntriesReturned: DWORDLONG, + pub NumSDBytesReturned: DWORDLONG, + pub SDEntry: [SD_ENUM_SDS_ENTRY; 1usize], +} +#[test] +fn bindgen_test_layout__SD_ENUM_SDS_OUTPUT() { + assert_eq!( + ::std::mem::size_of::<_SD_ENUM_SDS_OUTPUT>(), + 48usize, + concat!("Size of: ", stringify!(_SD_ENUM_SDS_OUTPUT)) + ); + assert_eq!( + ::std::mem::align_of::<_SD_ENUM_SDS_OUTPUT>(), + 8usize, + concat!("Alignment of ", stringify!(_SD_ENUM_SDS_OUTPUT)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SD_ENUM_SDS_OUTPUT>())).NextOffset as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SD_ENUM_SDS_OUTPUT), + "::", + stringify!(NextOffset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_ENUM_SDS_OUTPUT>())).NumSDEntriesReturned as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SD_ENUM_SDS_OUTPUT), + "::", + stringify!(NumSDEntriesReturned) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_ENUM_SDS_OUTPUT>())).NumSDBytesReturned as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SD_ENUM_SDS_OUTPUT), + "::", + stringify!(NumSDBytesReturned) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SD_ENUM_SDS_OUTPUT>())).SDEntry as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SD_ENUM_SDS_OUTPUT), + "::", + stringify!(SDEntry) + ) + ); +} +pub type SD_ENUM_SDS_OUTPUT = _SD_ENUM_SDS_OUTPUT; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SD_GLOBAL_CHANGE_INPUT { + pub Flags: DWORD, + pub ChangeType: DWORD, + pub __bindgen_anon_1: _SD_GLOBAL_CHANGE_INPUT__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _SD_GLOBAL_CHANGE_INPUT__bindgen_ty_1 { + pub SdChange: SD_CHANGE_MACHINE_SID_INPUT, + pub SdQueryStats: SD_QUERY_STATS_INPUT, + pub SdEnumSds: SD_ENUM_SDS_INPUT, + _bindgen_union_align: [u64; 2usize], +} +#[test] +fn bindgen_test_layout__SD_GLOBAL_CHANGE_INPUT__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_SD_GLOBAL_CHANGE_INPUT__bindgen_ty_1>(), + 16usize, + concat!( + "Size of: ", + stringify!(_SD_GLOBAL_CHANGE_INPUT__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SD_GLOBAL_CHANGE_INPUT__bindgen_ty_1>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_SD_GLOBAL_CHANGE_INPUT__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_GLOBAL_CHANGE_INPUT__bindgen_ty_1>())).SdChange as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SD_GLOBAL_CHANGE_INPUT__bindgen_ty_1), + "::", + stringify!(SdChange) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_GLOBAL_CHANGE_INPUT__bindgen_ty_1>())).SdQueryStats as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SD_GLOBAL_CHANGE_INPUT__bindgen_ty_1), + "::", + stringify!(SdQueryStats) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_GLOBAL_CHANGE_INPUT__bindgen_ty_1>())).SdEnumSds as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SD_GLOBAL_CHANGE_INPUT__bindgen_ty_1), + "::", + stringify!(SdEnumSds) + ) + ); +} +#[test] +fn bindgen_test_layout__SD_GLOBAL_CHANGE_INPUT() { + assert_eq!( + ::std::mem::size_of::<_SD_GLOBAL_CHANGE_INPUT>(), + 24usize, + concat!("Size of: ", stringify!(_SD_GLOBAL_CHANGE_INPUT)) + ); + assert_eq!( + ::std::mem::align_of::<_SD_GLOBAL_CHANGE_INPUT>(), + 8usize, + concat!("Alignment of ", stringify!(_SD_GLOBAL_CHANGE_INPUT)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SD_GLOBAL_CHANGE_INPUT>())).Flags as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SD_GLOBAL_CHANGE_INPUT), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SD_GLOBAL_CHANGE_INPUT>())).ChangeType as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SD_GLOBAL_CHANGE_INPUT), + "::", + stringify!(ChangeType) + ) + ); +} +pub type SD_GLOBAL_CHANGE_INPUT = _SD_GLOBAL_CHANGE_INPUT; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SD_GLOBAL_CHANGE_OUTPUT { + pub Flags: DWORD, + pub ChangeType: DWORD, + pub __bindgen_anon_1: _SD_GLOBAL_CHANGE_OUTPUT__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _SD_GLOBAL_CHANGE_OUTPUT__bindgen_ty_1 { + pub SdChange: SD_CHANGE_MACHINE_SID_OUTPUT, + pub SdQueryStats: SD_QUERY_STATS_OUTPUT, + pub SdEnumSds: SD_ENUM_SDS_OUTPUT, + _bindgen_union_align: [u64; 8usize], +} +#[test] +fn bindgen_test_layout__SD_GLOBAL_CHANGE_OUTPUT__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_SD_GLOBAL_CHANGE_OUTPUT__bindgen_ty_1>(), + 64usize, + concat!( + "Size of: ", + stringify!(_SD_GLOBAL_CHANGE_OUTPUT__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SD_GLOBAL_CHANGE_OUTPUT__bindgen_ty_1>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_SD_GLOBAL_CHANGE_OUTPUT__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_GLOBAL_CHANGE_OUTPUT__bindgen_ty_1>())).SdChange as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SD_GLOBAL_CHANGE_OUTPUT__bindgen_ty_1), + "::", + stringify!(SdChange) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_GLOBAL_CHANGE_OUTPUT__bindgen_ty_1>())).SdQueryStats as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SD_GLOBAL_CHANGE_OUTPUT__bindgen_ty_1), + "::", + stringify!(SdQueryStats) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SD_GLOBAL_CHANGE_OUTPUT__bindgen_ty_1>())).SdEnumSds as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SD_GLOBAL_CHANGE_OUTPUT__bindgen_ty_1), + "::", + stringify!(SdEnumSds) + ) + ); +} +#[test] +fn bindgen_test_layout__SD_GLOBAL_CHANGE_OUTPUT() { + assert_eq!( + ::std::mem::size_of::<_SD_GLOBAL_CHANGE_OUTPUT>(), + 72usize, + concat!("Size of: ", stringify!(_SD_GLOBAL_CHANGE_OUTPUT)) + ); + assert_eq!( + ::std::mem::align_of::<_SD_GLOBAL_CHANGE_OUTPUT>(), + 8usize, + concat!("Alignment of ", stringify!(_SD_GLOBAL_CHANGE_OUTPUT)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SD_GLOBAL_CHANGE_OUTPUT>())).Flags as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SD_GLOBAL_CHANGE_OUTPUT), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SD_GLOBAL_CHANGE_OUTPUT>())).ChangeType as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SD_GLOBAL_CHANGE_OUTPUT), + "::", + stringify!(ChangeType) + ) + ); +} +pub type SD_GLOBAL_CHANGE_OUTPUT = _SD_GLOBAL_CHANGE_OUTPUT; +pub const _STORAGE_RESERVE_ID_StorageReserveIdNone: _STORAGE_RESERVE_ID = 0; +pub const _STORAGE_RESERVE_ID_StorageReserveIdHard: _STORAGE_RESERVE_ID = 1; +pub const _STORAGE_RESERVE_ID_StorageReserveIdSoft: _STORAGE_RESERVE_ID = 2; +pub const _STORAGE_RESERVE_ID_StorageReserveIdUpdateScratch: _STORAGE_RESERVE_ID = 3; +pub const _STORAGE_RESERVE_ID_StorageReserveIdMax: _STORAGE_RESERVE_ID = 4; +pub type _STORAGE_RESERVE_ID = ::std::os::raw::c_int; +pub use self::_STORAGE_RESERVE_ID as STORAGE_RESERVE_ID; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _STREAM_LAYOUT_ENTRY { + pub Version: DWORD, + pub NextStreamOffset: DWORD, + pub Flags: DWORD, + pub ExtentInformationOffset: DWORD, + pub AllocationSize: LARGE_INTEGER, + pub EndOfFile: LARGE_INTEGER, + pub StreamInformationOffset: DWORD, + pub AttributeTypeCode: DWORD, + pub AttributeFlags: DWORD, + pub StreamIdentifierLength: DWORD, + pub StreamIdentifier: [WCHAR; 1usize], +} +#[test] +fn bindgen_test_layout__STREAM_LAYOUT_ENTRY() { + assert_eq!( + ::std::mem::size_of::<_STREAM_LAYOUT_ENTRY>(), + 56usize, + concat!("Size of: ", stringify!(_STREAM_LAYOUT_ENTRY)) + ); + assert_eq!( + ::std::mem::align_of::<_STREAM_LAYOUT_ENTRY>(), + 8usize, + concat!("Alignment of ", stringify!(_STREAM_LAYOUT_ENTRY)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STREAM_LAYOUT_ENTRY>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STREAM_LAYOUT_ENTRY), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STREAM_LAYOUT_ENTRY>())).NextStreamOffset as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STREAM_LAYOUT_ENTRY), + "::", + stringify!(NextStreamOffset) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STREAM_LAYOUT_ENTRY>())).Flags as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STREAM_LAYOUT_ENTRY), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STREAM_LAYOUT_ENTRY>())).ExtentInformationOffset as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STREAM_LAYOUT_ENTRY), + "::", + stringify!(ExtentInformationOffset) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STREAM_LAYOUT_ENTRY>())).AllocationSize as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_STREAM_LAYOUT_ENTRY), + "::", + stringify!(AllocationSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STREAM_LAYOUT_ENTRY>())).EndOfFile as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_STREAM_LAYOUT_ENTRY), + "::", + stringify!(EndOfFile) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STREAM_LAYOUT_ENTRY>())).StreamInformationOffset as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_STREAM_LAYOUT_ENTRY), + "::", + stringify!(StreamInformationOffset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STREAM_LAYOUT_ENTRY>())).AttributeTypeCode as *const _ as usize + }, + 36usize, + concat!( + "Offset of field: ", + stringify!(_STREAM_LAYOUT_ENTRY), + "::", + stringify!(AttributeTypeCode) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STREAM_LAYOUT_ENTRY>())).AttributeFlags as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_STREAM_LAYOUT_ENTRY), + "::", + stringify!(AttributeFlags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STREAM_LAYOUT_ENTRY>())).StreamIdentifierLength as *const _ as usize + }, + 44usize, + concat!( + "Offset of field: ", + stringify!(_STREAM_LAYOUT_ENTRY), + "::", + stringify!(StreamIdentifierLength) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STREAM_LAYOUT_ENTRY>())).StreamIdentifier as *const _ as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_STREAM_LAYOUT_ENTRY), + "::", + stringify!(StreamIdentifier) + ) + ); +} +pub type STREAM_LAYOUT_ENTRY = _STREAM_LAYOUT_ENTRY; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _STREAM_EXTENT_ENTRY { + pub Flags: DWORD, + pub ExtentInformation: _STREAM_EXTENT_ENTRY__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _STREAM_EXTENT_ENTRY__bindgen_ty_1 { + pub RetrievalPointers: RETRIEVAL_POINTERS_BUFFER, + _bindgen_union_align: [u64; 4usize], +} +#[test] +fn bindgen_test_layout__STREAM_EXTENT_ENTRY__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_STREAM_EXTENT_ENTRY__bindgen_ty_1>(), + 32usize, + concat!("Size of: ", stringify!(_STREAM_EXTENT_ENTRY__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<_STREAM_EXTENT_ENTRY__bindgen_ty_1>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_STREAM_EXTENT_ENTRY__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STREAM_EXTENT_ENTRY__bindgen_ty_1>())).RetrievalPointers as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STREAM_EXTENT_ENTRY__bindgen_ty_1), + "::", + stringify!(RetrievalPointers) + ) + ); +} +#[test] +fn bindgen_test_layout__STREAM_EXTENT_ENTRY() { + assert_eq!( + ::std::mem::size_of::<_STREAM_EXTENT_ENTRY>(), + 40usize, + concat!("Size of: ", stringify!(_STREAM_EXTENT_ENTRY)) + ); + assert_eq!( + ::std::mem::align_of::<_STREAM_EXTENT_ENTRY>(), + 8usize, + concat!("Alignment of ", stringify!(_STREAM_EXTENT_ENTRY)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STREAM_EXTENT_ENTRY>())).Flags as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STREAM_EXTENT_ENTRY), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STREAM_EXTENT_ENTRY>())).ExtentInformation as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STREAM_EXTENT_ENTRY), + "::", + stringify!(ExtentInformation) + ) + ); +} +pub type STREAM_EXTENT_ENTRY = _STREAM_EXTENT_ENTRY; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SET_PURGE_FAILURE_MODE_INPUT { + pub Flags: DWORD, +} +#[test] +fn bindgen_test_layout__SET_PURGE_FAILURE_MODE_INPUT() { + assert_eq!( + ::std::mem::size_of::<_SET_PURGE_FAILURE_MODE_INPUT>(), + 4usize, + concat!("Size of: ", stringify!(_SET_PURGE_FAILURE_MODE_INPUT)) + ); + assert_eq!( + ::std::mem::align_of::<_SET_PURGE_FAILURE_MODE_INPUT>(), + 4usize, + concat!("Alignment of ", stringify!(_SET_PURGE_FAILURE_MODE_INPUT)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SET_PURGE_FAILURE_MODE_INPUT>())).Flags as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SET_PURGE_FAILURE_MODE_INPUT), + "::", + stringify!(Flags) + ) + ); +} +pub type SET_PURGE_FAILURE_MODE_INPUT = _SET_PURGE_FAILURE_MODE_INPUT; +pub const _FILE_STORAGE_TIER_CLASS_FileStorageTierClassUnspecified: _FILE_STORAGE_TIER_CLASS = 0; +pub const _FILE_STORAGE_TIER_CLASS_FileStorageTierClassCapacity: _FILE_STORAGE_TIER_CLASS = 1; +pub const _FILE_STORAGE_TIER_CLASS_FileStorageTierClassPerformance: _FILE_STORAGE_TIER_CLASS = 2; +pub const _FILE_STORAGE_TIER_CLASS_FileStorageTierClassMax: _FILE_STORAGE_TIER_CLASS = 3; +pub type _FILE_STORAGE_TIER_CLASS = ::std::os::raw::c_int; +pub use self::_FILE_STORAGE_TIER_CLASS as FILE_STORAGE_TIER_CLASS; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _STREAM_INFORMATION_ENTRY { + pub Version: DWORD, + pub Flags: DWORD, + pub StreamInformation: _STREAM_INFORMATION_ENTRY__StreamInformation, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _STREAM_INFORMATION_ENTRY__StreamInformation { + pub DesiredStorageClass: _STREAM_INFORMATION_ENTRY__StreamInformation__DesiredStorageClass, + _bindgen_union_align: [u32; 2usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STREAM_INFORMATION_ENTRY__StreamInformation__DesiredStorageClass { + pub Class: FILE_STORAGE_TIER_CLASS, + pub Flags: DWORD, +} +#[test] +fn bindgen_test_layout__STREAM_INFORMATION_ENTRY__StreamInformation__DesiredStorageClass() { + assert_eq!( + ::std::mem::size_of::<_STREAM_INFORMATION_ENTRY__StreamInformation__DesiredStorageClass>(), + 8usize, + concat!( + "Size of: ", + stringify!(_STREAM_INFORMATION_ENTRY__StreamInformation__DesiredStorageClass) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STREAM_INFORMATION_ENTRY__StreamInformation__DesiredStorageClass>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STREAM_INFORMATION_ENTRY__StreamInformation__DesiredStorageClass) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STREAM_INFORMATION_ENTRY__StreamInformation__DesiredStorageClass>())) + .Class as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STREAM_INFORMATION_ENTRY__StreamInformation__DesiredStorageClass), + "::", + stringify!(Class) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STREAM_INFORMATION_ENTRY__StreamInformation__DesiredStorageClass>())) + .Flags as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STREAM_INFORMATION_ENTRY__StreamInformation__DesiredStorageClass), + "::", + stringify!(Flags) + ) + ); +} +#[test] +fn bindgen_test_layout__STREAM_INFORMATION_ENTRY__StreamInformation() { + assert_eq!( + ::std::mem::size_of::<_STREAM_INFORMATION_ENTRY__StreamInformation>(), + 8usize, + concat!( + "Size of: ", + stringify!(_STREAM_INFORMATION_ENTRY__StreamInformation) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STREAM_INFORMATION_ENTRY__StreamInformation>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STREAM_INFORMATION_ENTRY__StreamInformation) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STREAM_INFORMATION_ENTRY__StreamInformation>())).DesiredStorageClass + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STREAM_INFORMATION_ENTRY__StreamInformation), + "::", + stringify!(DesiredStorageClass) + ) + ); +} +#[test] +fn bindgen_test_layout__STREAM_INFORMATION_ENTRY() { + assert_eq!( + ::std::mem::size_of::<_STREAM_INFORMATION_ENTRY>(), + 16usize, + concat!("Size of: ", stringify!(_STREAM_INFORMATION_ENTRY)) + ); + assert_eq!( + ::std::mem::align_of::<_STREAM_INFORMATION_ENTRY>(), + 4usize, + concat!("Alignment of ", stringify!(_STREAM_INFORMATION_ENTRY)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STREAM_INFORMATION_ENTRY>())).Version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STREAM_INFORMATION_ENTRY), + "::", + stringify!(Version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_STREAM_INFORMATION_ENTRY>())).Flags as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STREAM_INFORMATION_ENTRY), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STREAM_INFORMATION_ENTRY>())).StreamInformation as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STREAM_INFORMATION_ENTRY), + "::", + stringify!(StreamInformation) + ) + ); +} +pub type STREAM_INFORMATION_ENTRY = _STREAM_INFORMATION_ENTRY; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STREAMS_QUERY_PARAMETERS_OUTPUT_BUFFER { + pub OptimalWriteSize: DWORD, + pub StreamGranularitySize: DWORD, + pub StreamIdMin: DWORD, + pub StreamIdMax: DWORD, +} +#[test] +fn bindgen_test_layout__STREAMS_QUERY_PARAMETERS_OUTPUT_BUFFER() { + assert_eq!( + ::std::mem::size_of::<_STREAMS_QUERY_PARAMETERS_OUTPUT_BUFFER>(), + 16usize, + concat!( + "Size of: ", + stringify!(_STREAMS_QUERY_PARAMETERS_OUTPUT_BUFFER) + ) + ); + assert_eq!( + ::std::mem::align_of::<_STREAMS_QUERY_PARAMETERS_OUTPUT_BUFFER>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STREAMS_QUERY_PARAMETERS_OUTPUT_BUFFER) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STREAMS_QUERY_PARAMETERS_OUTPUT_BUFFER>())).OptimalWriteSize + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STREAMS_QUERY_PARAMETERS_OUTPUT_BUFFER), + "::", + stringify!(OptimalWriteSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STREAMS_QUERY_PARAMETERS_OUTPUT_BUFFER>())).StreamGranularitySize + as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STREAMS_QUERY_PARAMETERS_OUTPUT_BUFFER), + "::", + stringify!(StreamGranularitySize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STREAMS_QUERY_PARAMETERS_OUTPUT_BUFFER>())).StreamIdMin as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_STREAMS_QUERY_PARAMETERS_OUTPUT_BUFFER), + "::", + stringify!(StreamIdMin) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STREAMS_QUERY_PARAMETERS_OUTPUT_BUFFER>())).StreamIdMax as *const _ + as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_STREAMS_QUERY_PARAMETERS_OUTPUT_BUFFER), + "::", + stringify!(StreamIdMax) + ) + ); +} +pub type STREAMS_QUERY_PARAMETERS_OUTPUT_BUFFER = _STREAMS_QUERY_PARAMETERS_OUTPUT_BUFFER; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STREAMS_ASSOCIATE_ID_INPUT_BUFFER { + pub Flags: DWORD, + pub StreamId: DWORD, +} +#[test] +fn bindgen_test_layout__STREAMS_ASSOCIATE_ID_INPUT_BUFFER() { + assert_eq!( + ::std::mem::size_of::<_STREAMS_ASSOCIATE_ID_INPUT_BUFFER>(), + 8usize, + concat!("Size of: ", stringify!(_STREAMS_ASSOCIATE_ID_INPUT_BUFFER)) + ); + assert_eq!( + ::std::mem::align_of::<_STREAMS_ASSOCIATE_ID_INPUT_BUFFER>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_STREAMS_ASSOCIATE_ID_INPUT_BUFFER) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STREAMS_ASSOCIATE_ID_INPUT_BUFFER>())).Flags as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STREAMS_ASSOCIATE_ID_INPUT_BUFFER), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STREAMS_ASSOCIATE_ID_INPUT_BUFFER>())).StreamId as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_STREAMS_ASSOCIATE_ID_INPUT_BUFFER), + "::", + stringify!(StreamId) + ) + ); +} +pub type STREAMS_ASSOCIATE_ID_INPUT_BUFFER = _STREAMS_ASSOCIATE_ID_INPUT_BUFFER; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _STREAMS_QUERY_ID_OUTPUT_BUFFER { + pub StreamId: DWORD, +} +#[test] +fn bindgen_test_layout__STREAMS_QUERY_ID_OUTPUT_BUFFER() { + assert_eq!( + ::std::mem::size_of::<_STREAMS_QUERY_ID_OUTPUT_BUFFER>(), + 4usize, + concat!("Size of: ", stringify!(_STREAMS_QUERY_ID_OUTPUT_BUFFER)) + ); + assert_eq!( + ::std::mem::align_of::<_STREAMS_QUERY_ID_OUTPUT_BUFFER>(), + 4usize, + concat!("Alignment of ", stringify!(_STREAMS_QUERY_ID_OUTPUT_BUFFER)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_STREAMS_QUERY_ID_OUTPUT_BUFFER>())).StreamId as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_STREAMS_QUERY_ID_OUTPUT_BUFFER), + "::", + stringify!(StreamId) + ) + ); +} +pub type STREAMS_QUERY_ID_OUTPUT_BUFFER = _STREAMS_QUERY_ID_OUTPUT_BUFFER; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SET_DAX_ALLOC_ALIGNMENT_HINT_INPUT { + pub Flags: DWORD, + pub AlignmentShift: DWORD, + pub FileOffsetToAlign: DWORDLONG, + pub FallbackAlignmentShift: DWORD, +} +#[test] +fn bindgen_test_layout__SET_DAX_ALLOC_ALIGNMENT_HINT_INPUT() { + assert_eq!( + ::std::mem::size_of::<_SET_DAX_ALLOC_ALIGNMENT_HINT_INPUT>(), + 24usize, + concat!("Size of: ", stringify!(_SET_DAX_ALLOC_ALIGNMENT_HINT_INPUT)) + ); + assert_eq!( + ::std::mem::align_of::<_SET_DAX_ALLOC_ALIGNMENT_HINT_INPUT>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_SET_DAX_ALLOC_ALIGNMENT_HINT_INPUT) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SET_DAX_ALLOC_ALIGNMENT_HINT_INPUT>())).Flags as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SET_DAX_ALLOC_ALIGNMENT_HINT_INPUT), + "::", + stringify!(Flags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SET_DAX_ALLOC_ALIGNMENT_HINT_INPUT>())).AlignmentShift as *const _ + as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SET_DAX_ALLOC_ALIGNMENT_HINT_INPUT), + "::", + stringify!(AlignmentShift) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SET_DAX_ALLOC_ALIGNMENT_HINT_INPUT>())).FileOffsetToAlign as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SET_DAX_ALLOC_ALIGNMENT_HINT_INPUT), + "::", + stringify!(FileOffsetToAlign) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SET_DAX_ALLOC_ALIGNMENT_HINT_INPUT>())).FallbackAlignmentShift + as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SET_DAX_ALLOC_ALIGNMENT_HINT_INPUT), + "::", + stringify!(FallbackAlignmentShift) + ) + ); +} +pub type SET_DAX_ALLOC_ALIGNMENT_HINT_INPUT = _SET_DAX_ALLOC_ALIGNMENT_HINT_INPUT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCARD_IO_REQUEST { + pub dwProtocol: DWORD, + pub cbPciLength: DWORD, +} +#[test] +fn bindgen_test_layout__SCARD_IO_REQUEST() { + assert_eq!( + ::std::mem::size_of::<_SCARD_IO_REQUEST>(), + 8usize, + concat!("Size of: ", stringify!(_SCARD_IO_REQUEST)) + ); + assert_eq!( + ::std::mem::align_of::<_SCARD_IO_REQUEST>(), + 4usize, + concat!("Alignment of ", stringify!(_SCARD_IO_REQUEST)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCARD_IO_REQUEST>())).dwProtocol as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCARD_IO_REQUEST), + "::", + stringify!(dwProtocol) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCARD_IO_REQUEST>())).cbPciLength as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCARD_IO_REQUEST), + "::", + stringify!(cbPciLength) + ) + ); +} +pub type SCARD_IO_REQUEST = _SCARD_IO_REQUEST; +pub type LPSCARD_IO_REQUEST = *mut _SCARD_IO_REQUEST; +pub type LPCSCARD_IO_REQUEST = *const SCARD_IO_REQUEST; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCARD_T0_COMMAND { + pub bCla: BYTE, + pub bIns: BYTE, + pub bP1: BYTE, + pub bP2: BYTE, + pub bP3: BYTE, +} +#[test] +fn bindgen_test_layout__SCARD_T0_COMMAND() { + assert_eq!( + ::std::mem::size_of::<_SCARD_T0_COMMAND>(), + 5usize, + concat!("Size of: ", stringify!(_SCARD_T0_COMMAND)) + ); + assert_eq!( + ::std::mem::align_of::<_SCARD_T0_COMMAND>(), + 1usize, + concat!("Alignment of ", stringify!(_SCARD_T0_COMMAND)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCARD_T0_COMMAND>())).bCla as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCARD_T0_COMMAND), + "::", + stringify!(bCla) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCARD_T0_COMMAND>())).bIns as *const _ as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(_SCARD_T0_COMMAND), + "::", + stringify!(bIns) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCARD_T0_COMMAND>())).bP1 as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_SCARD_T0_COMMAND), + "::", + stringify!(bP1) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCARD_T0_COMMAND>())).bP2 as *const _ as usize }, + 3usize, + concat!( + "Offset of field: ", + stringify!(_SCARD_T0_COMMAND), + "::", + stringify!(bP2) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCARD_T0_COMMAND>())).bP3 as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCARD_T0_COMMAND), + "::", + stringify!(bP3) + ) + ); +} +pub type SCARD_T0_COMMAND = _SCARD_T0_COMMAND; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SCARD_T0_REQUEST { + pub ioRequest: SCARD_IO_REQUEST, + pub bSw1: BYTE, + pub bSw2: BYTE, + pub __bindgen_anon_1: _SCARD_T0_REQUEST__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _SCARD_T0_REQUEST__bindgen_ty_1 { + pub CmdBytes: SCARD_T0_COMMAND, + pub rgbHeader: [BYTE; 5usize], + _bindgen_union_align: [u8; 5usize], +} +#[test] +fn bindgen_test_layout__SCARD_T0_REQUEST__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_SCARD_T0_REQUEST__bindgen_ty_1>(), + 5usize, + concat!("Size of: ", stringify!(_SCARD_T0_REQUEST__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<_SCARD_T0_REQUEST__bindgen_ty_1>(), + 1usize, + concat!("Alignment of ", stringify!(_SCARD_T0_REQUEST__bindgen_ty_1)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCARD_T0_REQUEST__bindgen_ty_1>())).CmdBytes as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCARD_T0_REQUEST__bindgen_ty_1), + "::", + stringify!(CmdBytes) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SCARD_T0_REQUEST__bindgen_ty_1>())).rgbHeader as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCARD_T0_REQUEST__bindgen_ty_1), + "::", + stringify!(rgbHeader) + ) + ); +} +#[test] +fn bindgen_test_layout__SCARD_T0_REQUEST() { + assert_eq!( + ::std::mem::size_of::<_SCARD_T0_REQUEST>(), + 16usize, + concat!("Size of: ", stringify!(_SCARD_T0_REQUEST)) + ); + assert_eq!( + ::std::mem::align_of::<_SCARD_T0_REQUEST>(), + 4usize, + concat!("Alignment of ", stringify!(_SCARD_T0_REQUEST)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCARD_T0_REQUEST>())).ioRequest as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCARD_T0_REQUEST), + "::", + stringify!(ioRequest) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCARD_T0_REQUEST>())).bSw1 as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SCARD_T0_REQUEST), + "::", + stringify!(bSw1) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCARD_T0_REQUEST>())).bSw2 as *const _ as usize }, + 9usize, + concat!( + "Offset of field: ", + stringify!(_SCARD_T0_REQUEST), + "::", + stringify!(bSw2) + ) + ); +} +pub type SCARD_T0_REQUEST = _SCARD_T0_REQUEST; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SCARD_T1_REQUEST { + pub ioRequest: SCARD_IO_REQUEST, +} +#[test] +fn bindgen_test_layout__SCARD_T1_REQUEST() { + assert_eq!( + ::std::mem::size_of::<_SCARD_T1_REQUEST>(), + 8usize, + concat!("Size of: ", stringify!(_SCARD_T1_REQUEST)) + ); + assert_eq!( + ::std::mem::align_of::<_SCARD_T1_REQUEST>(), + 4usize, + concat!("Alignment of ", stringify!(_SCARD_T1_REQUEST)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCARD_T1_REQUEST>())).ioRequest as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCARD_T1_REQUEST), + "::", + stringify!(ioRequest) + ) + ); +} +pub type SCARD_T1_REQUEST = _SCARD_T1_REQUEST; +pub type LPCBYTE = *const BYTE; +pub type SCARDCONTEXT = ULONG_PTR; +pub type LPSCARDCONTEXT = *mut SCARDCONTEXT; +pub type SCARDHANDLE = ULONG_PTR; +pub type LPSCARDHANDLE = *mut SCARDHANDLE; +extern "C" { + pub fn SCardEstablishContext( + dwScope: DWORD, + pvReserved1: LPCVOID, + pvReserved2: LPCVOID, + phContext: LPSCARDCONTEXT, + ) -> LONG; +} +extern "C" { + pub fn SCardReleaseContext(hContext: SCARDCONTEXT) -> LONG; +} +extern "C" { + pub fn SCardIsValidContext(hContext: SCARDCONTEXT) -> LONG; +} +extern "C" { + pub fn SCardListReaderGroupsA( + hContext: SCARDCONTEXT, + mszGroups: LPSTR, + pcchGroups: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardListReaderGroupsW( + hContext: SCARDCONTEXT, + mszGroups: LPWSTR, + pcchGroups: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardListReadersA( + hContext: SCARDCONTEXT, + mszGroups: LPCSTR, + mszReaders: LPSTR, + pcchReaders: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardListReadersW( + hContext: SCARDCONTEXT, + mszGroups: LPCWSTR, + mszReaders: LPWSTR, + pcchReaders: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardListCardsA( + hContext: SCARDCONTEXT, + pbAtr: LPCBYTE, + rgquidInterfaces: LPCGUID, + cguidInterfaceCount: DWORD, + mszCards: *mut CHAR, + pcchCards: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardListCardsW( + hContext: SCARDCONTEXT, + pbAtr: LPCBYTE, + rgquidInterfaces: LPCGUID, + cguidInterfaceCount: DWORD, + mszCards: *mut WCHAR, + pcchCards: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardListInterfacesA( + hContext: SCARDCONTEXT, + szCard: LPCSTR, + pguidInterfaces: LPGUID, + pcguidInterfaces: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardListInterfacesW( + hContext: SCARDCONTEXT, + szCard: LPCWSTR, + pguidInterfaces: LPGUID, + pcguidInterfaces: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardGetProviderIdA( + hContext: SCARDCONTEXT, + szCard: LPCSTR, + pguidProviderId: LPGUID, + ) -> LONG; +} +extern "C" { + pub fn SCardGetProviderIdW( + hContext: SCARDCONTEXT, + szCard: LPCWSTR, + pguidProviderId: LPGUID, + ) -> LONG; +} +extern "C" { + pub fn SCardGetCardTypeProviderNameA( + hContext: SCARDCONTEXT, + szCardName: LPCSTR, + dwProviderId: DWORD, + szProvider: *mut CHAR, + pcchProvider: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardGetCardTypeProviderNameW( + hContext: SCARDCONTEXT, + szCardName: LPCWSTR, + dwProviderId: DWORD, + szProvider: *mut WCHAR, + pcchProvider: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardIntroduceReaderGroupA(hContext: SCARDCONTEXT, szGroupName: LPCSTR) -> LONG; +} +extern "C" { + pub fn SCardIntroduceReaderGroupW(hContext: SCARDCONTEXT, szGroupName: LPCWSTR) -> LONG; +} +extern "C" { + pub fn SCardForgetReaderGroupA(hContext: SCARDCONTEXT, szGroupName: LPCSTR) -> LONG; +} +extern "C" { + pub fn SCardForgetReaderGroupW(hContext: SCARDCONTEXT, szGroupName: LPCWSTR) -> LONG; +} +extern "C" { + pub fn SCardIntroduceReaderA( + hContext: SCARDCONTEXT, + szReaderName: LPCSTR, + szDeviceName: LPCSTR, + ) -> LONG; +} +extern "C" { + pub fn SCardIntroduceReaderW( + hContext: SCARDCONTEXT, + szReaderName: LPCWSTR, + szDeviceName: LPCWSTR, + ) -> LONG; +} +extern "C" { + pub fn SCardForgetReaderA(hContext: SCARDCONTEXT, szReaderName: LPCSTR) -> LONG; +} +extern "C" { + pub fn SCardForgetReaderW(hContext: SCARDCONTEXT, szReaderName: LPCWSTR) -> LONG; +} +extern "C" { + pub fn SCardAddReaderToGroupA( + hContext: SCARDCONTEXT, + szReaderName: LPCSTR, + szGroupName: LPCSTR, + ) -> LONG; +} +extern "C" { + pub fn SCardAddReaderToGroupW( + hContext: SCARDCONTEXT, + szReaderName: LPCWSTR, + szGroupName: LPCWSTR, + ) -> LONG; +} +extern "C" { + pub fn SCardRemoveReaderFromGroupA( + hContext: SCARDCONTEXT, + szReaderName: LPCSTR, + szGroupName: LPCSTR, + ) -> LONG; +} +extern "C" { + pub fn SCardRemoveReaderFromGroupW( + hContext: SCARDCONTEXT, + szReaderName: LPCWSTR, + szGroupName: LPCWSTR, + ) -> LONG; +} +extern "C" { + pub fn SCardIntroduceCardTypeA( + hContext: SCARDCONTEXT, + szCardName: LPCSTR, + pguidPrimaryProvider: LPCGUID, + rgguidInterfaces: LPCGUID, + dwInterfaceCount: DWORD, + pbAtr: LPCBYTE, + pbAtrMask: LPCBYTE, + cbAtrLen: DWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardIntroduceCardTypeW( + hContext: SCARDCONTEXT, + szCardName: LPCWSTR, + pguidPrimaryProvider: LPCGUID, + rgguidInterfaces: LPCGUID, + dwInterfaceCount: DWORD, + pbAtr: LPCBYTE, + pbAtrMask: LPCBYTE, + cbAtrLen: DWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardSetCardTypeProviderNameA( + hContext: SCARDCONTEXT, + szCardName: LPCSTR, + dwProviderId: DWORD, + szProvider: LPCSTR, + ) -> LONG; +} +extern "C" { + pub fn SCardSetCardTypeProviderNameW( + hContext: SCARDCONTEXT, + szCardName: LPCWSTR, + dwProviderId: DWORD, + szProvider: LPCWSTR, + ) -> LONG; +} +extern "C" { + pub fn SCardForgetCardTypeA(hContext: SCARDCONTEXT, szCardName: LPCSTR) -> LONG; +} +extern "C" { + pub fn SCardForgetCardTypeW(hContext: SCARDCONTEXT, szCardName: LPCWSTR) -> LONG; +} +extern "C" { + pub fn SCardFreeMemory(hContext: SCARDCONTEXT, pvMem: LPCVOID) -> LONG; +} +extern "C" { + pub fn SCardAccessStartedEvent() -> HANDLE; +} +extern "C" { + pub fn SCardReleaseStartedEvent(); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct SCARD_READERSTATEA { + pub szReader: LPCSTR, + pub pvUserData: LPVOID, + pub dwCurrentState: DWORD, + pub dwEventState: DWORD, + pub cbAtr: DWORD, + pub rgbAtr: [BYTE; 36usize], +} +#[test] +fn bindgen_test_layout_SCARD_READERSTATEA() { + assert_eq!( + ::std::mem::size_of::(), + 64usize, + concat!("Size of: ", stringify!(SCARD_READERSTATEA)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(SCARD_READERSTATEA)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).szReader as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(SCARD_READERSTATEA), + "::", + stringify!(szReader) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).pvUserData as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(SCARD_READERSTATEA), + "::", + stringify!(pvUserData) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwCurrentState as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(SCARD_READERSTATEA), + "::", + stringify!(dwCurrentState) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwEventState as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(SCARD_READERSTATEA), + "::", + stringify!(dwEventState) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cbAtr as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(SCARD_READERSTATEA), + "::", + stringify!(cbAtr) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).rgbAtr as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(SCARD_READERSTATEA), + "::", + stringify!(rgbAtr) + ) + ); +} +pub type LPSCARD_READERSTATEA = *mut SCARD_READERSTATEA; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct SCARD_READERSTATEW { + pub szReader: LPCWSTR, + pub pvUserData: LPVOID, + pub dwCurrentState: DWORD, + pub dwEventState: DWORD, + pub cbAtr: DWORD, + pub rgbAtr: [BYTE; 36usize], +} +#[test] +fn bindgen_test_layout_SCARD_READERSTATEW() { + assert_eq!( + ::std::mem::size_of::(), + 64usize, + concat!("Size of: ", stringify!(SCARD_READERSTATEW)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(SCARD_READERSTATEW)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).szReader as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(SCARD_READERSTATEW), + "::", + stringify!(szReader) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).pvUserData as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(SCARD_READERSTATEW), + "::", + stringify!(pvUserData) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwCurrentState as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(SCARD_READERSTATEW), + "::", + stringify!(dwCurrentState) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwEventState as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(SCARD_READERSTATEW), + "::", + stringify!(dwEventState) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cbAtr as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(SCARD_READERSTATEW), + "::", + stringify!(cbAtr) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).rgbAtr as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(SCARD_READERSTATEW), + "::", + stringify!(rgbAtr) + ) + ); +} +pub type LPSCARD_READERSTATEW = *mut SCARD_READERSTATEW; +pub type SCARD_READERSTATE = SCARD_READERSTATEW; +extern "C" { + pub fn SCardLocateCardsA( + hContext: SCARDCONTEXT, + mszCards: LPCSTR, + rgReaderStates: LPSCARD_READERSTATEA, + cReaders: DWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardLocateCardsW( + hContext: SCARDCONTEXT, + mszCards: LPCWSTR, + rgReaderStates: LPSCARD_READERSTATEW, + cReaders: DWORD, + ) -> LONG; +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SCARD_ATRMASK { + pub cbAtr: DWORD, + pub rgbAtr: [BYTE; 36usize], + pub rgbMask: [BYTE; 36usize], +} +#[test] +fn bindgen_test_layout__SCARD_ATRMASK() { + assert_eq!( + ::std::mem::size_of::<_SCARD_ATRMASK>(), + 76usize, + concat!("Size of: ", stringify!(_SCARD_ATRMASK)) + ); + assert_eq!( + ::std::mem::align_of::<_SCARD_ATRMASK>(), + 4usize, + concat!("Alignment of ", stringify!(_SCARD_ATRMASK)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCARD_ATRMASK>())).cbAtr as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SCARD_ATRMASK), + "::", + stringify!(cbAtr) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCARD_ATRMASK>())).rgbAtr as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SCARD_ATRMASK), + "::", + stringify!(rgbAtr) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SCARD_ATRMASK>())).rgbMask as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_SCARD_ATRMASK), + "::", + stringify!(rgbMask) + ) + ); +} +pub type SCARD_ATRMASK = _SCARD_ATRMASK; +pub type LPSCARD_ATRMASK = *mut _SCARD_ATRMASK; +extern "C" { + pub fn SCardLocateCardsByATRA( + hContext: SCARDCONTEXT, + rgAtrMasks: LPSCARD_ATRMASK, + cAtrs: DWORD, + rgReaderStates: LPSCARD_READERSTATEA, + cReaders: DWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardLocateCardsByATRW( + hContext: SCARDCONTEXT, + rgAtrMasks: LPSCARD_ATRMASK, + cAtrs: DWORD, + rgReaderStates: LPSCARD_READERSTATEW, + cReaders: DWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardGetStatusChangeA( + hContext: SCARDCONTEXT, + dwTimeout: DWORD, + rgReaderStates: LPSCARD_READERSTATEA, + cReaders: DWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardGetStatusChangeW( + hContext: SCARDCONTEXT, + dwTimeout: DWORD, + rgReaderStates: LPSCARD_READERSTATEW, + cReaders: DWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardCancel(hContext: SCARDCONTEXT) -> LONG; +} +extern "C" { + pub fn SCardConnectA( + hContext: SCARDCONTEXT, + szReader: LPCSTR, + dwShareMode: DWORD, + dwPreferredProtocols: DWORD, + phCard: LPSCARDHANDLE, + pdwActiveProtocol: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardConnectW( + hContext: SCARDCONTEXT, + szReader: LPCWSTR, + dwShareMode: DWORD, + dwPreferredProtocols: DWORD, + phCard: LPSCARDHANDLE, + pdwActiveProtocol: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardReconnect( + hCard: SCARDHANDLE, + dwShareMode: DWORD, + dwPreferredProtocols: DWORD, + dwInitialization: DWORD, + pdwActiveProtocol: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardDisconnect(hCard: SCARDHANDLE, dwDisposition: DWORD) -> LONG; +} +extern "C" { + pub fn SCardBeginTransaction(hCard: SCARDHANDLE) -> LONG; +} +extern "C" { + pub fn SCardEndTransaction(hCard: SCARDHANDLE, dwDisposition: DWORD) -> LONG; +} +extern "C" { + pub fn SCardCancelTransaction(hCard: SCARDHANDLE) -> LONG; +} +extern "C" { + pub fn SCardState( + hCard: SCARDHANDLE, + pdwState: LPDWORD, + pdwProtocol: LPDWORD, + pbAtr: LPBYTE, + pcbAtrLen: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardStatusA( + hCard: SCARDHANDLE, + mszReaderNames: LPSTR, + pcchReaderLen: LPDWORD, + pdwState: LPDWORD, + pdwProtocol: LPDWORD, + pbAtr: LPBYTE, + pcbAtrLen: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardStatusW( + hCard: SCARDHANDLE, + mszReaderNames: LPWSTR, + pcchReaderLen: LPDWORD, + pdwState: LPDWORD, + pdwProtocol: LPDWORD, + pbAtr: LPBYTE, + pcbAtrLen: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardTransmit( + hCard: SCARDHANDLE, + pioSendPci: LPCSCARD_IO_REQUEST, + pbSendBuffer: LPCBYTE, + cbSendLength: DWORD, + pioRecvPci: LPSCARD_IO_REQUEST, + pbRecvBuffer: LPBYTE, + pcbRecvLength: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardGetTransmitCount(hCard: SCARDHANDLE, pcTransmitCount: LPDWORD) -> LONG; +} +extern "C" { + pub fn SCardControl( + hCard: SCARDHANDLE, + dwControlCode: DWORD, + lpInBuffer: LPCVOID, + cbInBufferSize: DWORD, + lpOutBuffer: LPVOID, + cbOutBufferSize: DWORD, + lpBytesReturned: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardGetAttrib( + hCard: SCARDHANDLE, + dwAttrId: DWORD, + pbAttr: LPBYTE, + pcbAttrLen: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardSetAttrib( + hCard: SCARDHANDLE, + dwAttrId: DWORD, + pbAttr: LPCBYTE, + cbAttrLen: DWORD, + ) -> LONG; +} +pub type LPOCNCONNPROCA = ::std::option::Option< + unsafe extern "C" fn(arg1: SCARDCONTEXT, arg2: LPSTR, arg3: LPSTR, arg4: PVOID) -> SCARDHANDLE, +>; +pub type LPOCNCONNPROCW = ::std::option::Option< + unsafe extern "C" fn(arg1: SCARDCONTEXT, arg2: LPWSTR, arg3: LPWSTR, arg4: PVOID) -> SCARDHANDLE, +>; +pub type LPOCNCHKPROC = ::std::option::Option< + unsafe extern "C" fn(arg1: SCARDCONTEXT, arg2: SCARDHANDLE, arg3: PVOID) -> BOOL, +>; +pub type LPOCNDSCPROC = + ::std::option::Option; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct OPENCARD_SEARCH_CRITERIAA { + pub dwStructSize: DWORD, + pub lpstrGroupNames: LPSTR, + pub nMaxGroupNames: DWORD, + pub rgguidInterfaces: LPCGUID, + pub cguidInterfaces: DWORD, + pub lpstrCardNames: LPSTR, + pub nMaxCardNames: DWORD, + pub lpfnCheck: LPOCNCHKPROC, + pub lpfnConnect: LPOCNCONNPROCA, + pub lpfnDisconnect: LPOCNDSCPROC, + pub pvUserData: LPVOID, + pub dwShareMode: DWORD, + pub dwPreferredProtocols: DWORD, +} +#[test] +fn bindgen_test_layout_OPENCARD_SEARCH_CRITERIAA() { + assert_eq!( + ::std::mem::size_of::(), + 96usize, + concat!("Size of: ", stringify!(OPENCARD_SEARCH_CRITERIAA)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(OPENCARD_SEARCH_CRITERIAA)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).dwStructSize as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAA), + "::", + stringify!(dwStructSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).lpstrGroupNames as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAA), + "::", + stringify!(lpstrGroupNames) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).nMaxGroupNames as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAA), + "::", + stringify!(nMaxGroupNames) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).rgguidInterfaces as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAA), + "::", + stringify!(rgguidInterfaces) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).cguidInterfaces as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAA), + "::", + stringify!(cguidInterfaces) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).lpstrCardNames as *const _ as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAA), + "::", + stringify!(lpstrCardNames) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).nMaxCardNames as *const _ as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAA), + "::", + stringify!(nMaxCardNames) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lpfnCheck as *const _ as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAA), + "::", + stringify!(lpfnCheck) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).lpfnConnect as *const _ as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAA), + "::", + stringify!(lpfnConnect) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).lpfnDisconnect as *const _ as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAA), + "::", + stringify!(lpfnDisconnect) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pvUserData as *const _ as usize + }, + 80usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAA), + "::", + stringify!(pvUserData) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).dwShareMode as *const _ as usize + }, + 88usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAA), + "::", + stringify!(dwShareMode) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).dwPreferredProtocols as *const _ + as usize + }, + 92usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAA), + "::", + stringify!(dwPreferredProtocols) + ) + ); +} +pub type POPENCARD_SEARCH_CRITERIAA = *mut OPENCARD_SEARCH_CRITERIAA; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct OPENCARD_SEARCH_CRITERIAW { + pub dwStructSize: DWORD, + pub lpstrGroupNames: LPWSTR, + pub nMaxGroupNames: DWORD, + pub rgguidInterfaces: LPCGUID, + pub cguidInterfaces: DWORD, + pub lpstrCardNames: LPWSTR, + pub nMaxCardNames: DWORD, + pub lpfnCheck: LPOCNCHKPROC, + pub lpfnConnect: LPOCNCONNPROCW, + pub lpfnDisconnect: LPOCNDSCPROC, + pub pvUserData: LPVOID, + pub dwShareMode: DWORD, + pub dwPreferredProtocols: DWORD, +} +#[test] +fn bindgen_test_layout_OPENCARD_SEARCH_CRITERIAW() { + assert_eq!( + ::std::mem::size_of::(), + 96usize, + concat!("Size of: ", stringify!(OPENCARD_SEARCH_CRITERIAW)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(OPENCARD_SEARCH_CRITERIAW)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).dwStructSize as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAW), + "::", + stringify!(dwStructSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).lpstrGroupNames as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAW), + "::", + stringify!(lpstrGroupNames) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).nMaxGroupNames as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAW), + "::", + stringify!(nMaxGroupNames) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).rgguidInterfaces as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAW), + "::", + stringify!(rgguidInterfaces) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).cguidInterfaces as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAW), + "::", + stringify!(cguidInterfaces) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).lpstrCardNames as *const _ as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAW), + "::", + stringify!(lpstrCardNames) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).nMaxCardNames as *const _ as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAW), + "::", + stringify!(nMaxCardNames) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lpfnCheck as *const _ as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAW), + "::", + stringify!(lpfnCheck) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).lpfnConnect as *const _ as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAW), + "::", + stringify!(lpfnConnect) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).lpfnDisconnect as *const _ as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAW), + "::", + stringify!(lpfnDisconnect) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pvUserData as *const _ as usize + }, + 80usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAW), + "::", + stringify!(pvUserData) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).dwShareMode as *const _ as usize + }, + 88usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAW), + "::", + stringify!(dwShareMode) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).dwPreferredProtocols as *const _ + as usize + }, + 92usize, + concat!( + "Offset of field: ", + stringify!(OPENCARD_SEARCH_CRITERIAW), + "::", + stringify!(dwPreferredProtocols) + ) + ); +} +pub type POPENCARD_SEARCH_CRITERIAW = *mut OPENCARD_SEARCH_CRITERIAW; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct OPENCARDNAME_EXA { + pub dwStructSize: DWORD, + pub hSCardContext: SCARDCONTEXT, + pub hwndOwner: HWND, + pub dwFlags: DWORD, + pub lpstrTitle: LPCSTR, + pub lpstrSearchDesc: LPCSTR, + pub hIcon: HICON, + pub pOpenCardSearchCriteria: POPENCARD_SEARCH_CRITERIAA, + pub lpfnConnect: LPOCNCONNPROCA, + pub pvUserData: LPVOID, + pub dwShareMode: DWORD, + pub dwPreferredProtocols: DWORD, + pub lpstrRdr: LPSTR, + pub nMaxRdr: DWORD, + pub lpstrCard: LPSTR, + pub nMaxCard: DWORD, + pub dwActiveProtocol: DWORD, + pub hCardHandle: SCARDHANDLE, +} +#[test] +fn bindgen_test_layout_OPENCARDNAME_EXA() { + assert_eq!( + ::std::mem::size_of::(), + 128usize, + concat!("Size of: ", stringify!(OPENCARDNAME_EXA)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(OPENCARDNAME_EXA)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwStructSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXA), + "::", + stringify!(dwStructSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).hSCardContext as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXA), + "::", + stringify!(hSCardContext) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).hwndOwner as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXA), + "::", + stringify!(hwndOwner) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwFlags as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXA), + "::", + stringify!(dwFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lpstrTitle as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXA), + "::", + stringify!(lpstrTitle) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lpstrSearchDesc as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXA), + "::", + stringify!(lpstrSearchDesc) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).hIcon as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXA), + "::", + stringify!(hIcon) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pOpenCardSearchCriteria as *const _ as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXA), + "::", + stringify!(pOpenCardSearchCriteria) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lpfnConnect as *const _ as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXA), + "::", + stringify!(lpfnConnect) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).pvUserData as *const _ as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXA), + "::", + stringify!(pvUserData) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwShareMode as *const _ as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXA), + "::", + stringify!(dwShareMode) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).dwPreferredProtocols as *const _ as usize + }, + 84usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXA), + "::", + stringify!(dwPreferredProtocols) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lpstrRdr as *const _ as usize }, + 88usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXA), + "::", + stringify!(lpstrRdr) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).nMaxRdr as *const _ as usize }, + 96usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXA), + "::", + stringify!(nMaxRdr) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lpstrCard as *const _ as usize }, + 104usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXA), + "::", + stringify!(lpstrCard) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).nMaxCard as *const _ as usize }, + 112usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXA), + "::", + stringify!(nMaxCard) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwActiveProtocol as *const _ as usize }, + 116usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXA), + "::", + stringify!(dwActiveProtocol) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).hCardHandle as *const _ as usize }, + 120usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXA), + "::", + stringify!(hCardHandle) + ) + ); +} +pub type LPOPENCARDNAME_EXA = *mut OPENCARDNAME_EXA; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct OPENCARDNAME_EXW { + pub dwStructSize: DWORD, + pub hSCardContext: SCARDCONTEXT, + pub hwndOwner: HWND, + pub dwFlags: DWORD, + pub lpstrTitle: LPCWSTR, + pub lpstrSearchDesc: LPCWSTR, + pub hIcon: HICON, + pub pOpenCardSearchCriteria: POPENCARD_SEARCH_CRITERIAW, + pub lpfnConnect: LPOCNCONNPROCW, + pub pvUserData: LPVOID, + pub dwShareMode: DWORD, + pub dwPreferredProtocols: DWORD, + pub lpstrRdr: LPWSTR, + pub nMaxRdr: DWORD, + pub lpstrCard: LPWSTR, + pub nMaxCard: DWORD, + pub dwActiveProtocol: DWORD, + pub hCardHandle: SCARDHANDLE, +} +#[test] +fn bindgen_test_layout_OPENCARDNAME_EXW() { + assert_eq!( + ::std::mem::size_of::(), + 128usize, + concat!("Size of: ", stringify!(OPENCARDNAME_EXW)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(OPENCARDNAME_EXW)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwStructSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXW), + "::", + stringify!(dwStructSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).hSCardContext as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXW), + "::", + stringify!(hSCardContext) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).hwndOwner as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXW), + "::", + stringify!(hwndOwner) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwFlags as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXW), + "::", + stringify!(dwFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lpstrTitle as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXW), + "::", + stringify!(lpstrTitle) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lpstrSearchDesc as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXW), + "::", + stringify!(lpstrSearchDesc) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).hIcon as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXW), + "::", + stringify!(hIcon) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pOpenCardSearchCriteria as *const _ as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXW), + "::", + stringify!(pOpenCardSearchCriteria) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lpfnConnect as *const _ as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXW), + "::", + stringify!(lpfnConnect) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).pvUserData as *const _ as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXW), + "::", + stringify!(pvUserData) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwShareMode as *const _ as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXW), + "::", + stringify!(dwShareMode) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).dwPreferredProtocols as *const _ as usize + }, + 84usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXW), + "::", + stringify!(dwPreferredProtocols) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lpstrRdr as *const _ as usize }, + 88usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXW), + "::", + stringify!(lpstrRdr) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).nMaxRdr as *const _ as usize }, + 96usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXW), + "::", + stringify!(nMaxRdr) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lpstrCard as *const _ as usize }, + 104usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXW), + "::", + stringify!(lpstrCard) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).nMaxCard as *const _ as usize }, + 112usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXW), + "::", + stringify!(nMaxCard) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwActiveProtocol as *const _ as usize }, + 116usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXW), + "::", + stringify!(dwActiveProtocol) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).hCardHandle as *const _ as usize }, + 120usize, + concat!( + "Offset of field: ", + stringify!(OPENCARDNAME_EXW), + "::", + stringify!(hCardHandle) + ) + ); +} +pub type LPOPENCARDNAME_EXW = *mut OPENCARDNAME_EXW; +extern "C" { + pub fn SCardUIDlgSelectCardA(arg1: LPOPENCARDNAME_EXA) -> LONG; +} +extern "C" { + pub fn SCardUIDlgSelectCardW(arg1: LPOPENCARDNAME_EXW) -> LONG; +} +extern "C" { + pub fn SCardDlgExtendedError() -> LONG; +} +extern "C" { + pub fn SCardReadCacheA( + hContext: SCARDCONTEXT, + CardIdentifier: *mut UUID, + FreshnessCounter: DWORD, + LookupName: LPSTR, + Data: PBYTE, + DataLen: *mut DWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardReadCacheW( + hContext: SCARDCONTEXT, + CardIdentifier: *mut UUID, + FreshnessCounter: DWORD, + LookupName: LPWSTR, + Data: PBYTE, + DataLen: *mut DWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardWriteCacheA( + hContext: SCARDCONTEXT, + CardIdentifier: *mut UUID, + FreshnessCounter: DWORD, + LookupName: LPSTR, + Data: PBYTE, + DataLen: DWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardWriteCacheW( + hContext: SCARDCONTEXT, + CardIdentifier: *mut UUID, + FreshnessCounter: DWORD, + LookupName: LPWSTR, + Data: PBYTE, + DataLen: DWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardGetReaderIconA( + hContext: SCARDCONTEXT, + szReaderName: LPCSTR, + pbIcon: LPBYTE, + pcbIcon: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardGetReaderIconW( + hContext: SCARDCONTEXT, + szReaderName: LPCWSTR, + pbIcon: LPBYTE, + pcbIcon: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardGetDeviceTypeIdA( + hContext: SCARDCONTEXT, + szReaderName: LPCSTR, + pdwDeviceTypeId: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardGetDeviceTypeIdW( + hContext: SCARDCONTEXT, + szReaderName: LPCWSTR, + pdwDeviceTypeId: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardGetReaderDeviceInstanceIdA( + hContext: SCARDCONTEXT, + szReaderName: LPCSTR, + szDeviceInstanceId: LPSTR, + pcchDeviceInstanceId: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardGetReaderDeviceInstanceIdW( + hContext: SCARDCONTEXT, + szReaderName: LPCWSTR, + szDeviceInstanceId: LPWSTR, + pcchDeviceInstanceId: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardListReadersWithDeviceInstanceIdA( + hContext: SCARDCONTEXT, + szDeviceInstanceId: LPCSTR, + mszReaders: LPSTR, + pcchReaders: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardListReadersWithDeviceInstanceIdW( + hContext: SCARDCONTEXT, + szDeviceInstanceId: LPCWSTR, + mszReaders: LPWSTR, + pcchReaders: LPDWORD, + ) -> LONG; +} +extern "C" { + pub fn SCardAudit(hContext: SCARDCONTEXT, dwEvent: DWORD) -> LONG; +} +#[repr(C)] +pub struct IUnknown__bindgen_vtable(::std::os::raw::c_void); +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct IUnknown { + pub vtable_: *const IUnknown__bindgen_vtable, +} +#[test] +fn bindgen_test_layout_IUnknown() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(IUnknown)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(IUnknown)) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct IEnumString { + pub _base: IUnknown, +} +#[test] +fn bindgen_test_layout_IEnumString() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(IEnumString)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(IEnumString)) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ISequentialStream { + pub _base: IUnknown, +} +#[test] +fn bindgen_test_layout_ISequentialStream() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(ISequentialStream)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(ISequentialStream)) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct tagSTATSTG { + pub pwcsName: LPOLESTR, + pub type_: DWORD, + pub cbSize: ULARGE_INTEGER, + pub mtime: FILETIME, + pub ctime: FILETIME, + pub atime: FILETIME, + pub grfMode: DWORD, + pub grfLocksSupported: DWORD, + pub clsid: CLSID, + pub grfStateBits: DWORD, + pub reserved: DWORD, +} +#[test] +fn bindgen_test_layout_tagSTATSTG() { + assert_eq!( + ::std::mem::size_of::(), + 80usize, + concat!("Size of: ", stringify!(tagSTATSTG)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagSTATSTG)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).pwcsName as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSTATSTG), + "::", + stringify!(pwcsName) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagSTATSTG), + "::", + stringify!(type_) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cbSize as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(tagSTATSTG), + "::", + stringify!(cbSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).mtime as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(tagSTATSTG), + "::", + stringify!(mtime) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).ctime as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(tagSTATSTG), + "::", + stringify!(ctime) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).atime as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(tagSTATSTG), + "::", + stringify!(atime) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).grfMode as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(tagSTATSTG), + "::", + stringify!(grfMode) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).grfLocksSupported as *const _ as usize }, + 52usize, + concat!( + "Offset of field: ", + stringify!(tagSTATSTG), + "::", + stringify!(grfLocksSupported) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).clsid as *const _ as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(tagSTATSTG), + "::", + stringify!(clsid) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).grfStateBits as *const _ as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(tagSTATSTG), + "::", + stringify!(grfStateBits) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).reserved as *const _ as usize }, + 76usize, + concat!( + "Offset of field: ", + stringify!(tagSTATSTG), + "::", + stringify!(reserved) + ) + ); +} +pub type STATSTG = tagSTATSTG; +pub const tagSTGTY_STGTY_STORAGE: tagSTGTY = 1; +pub const tagSTGTY_STGTY_STREAM: tagSTGTY = 2; +pub const tagSTGTY_STGTY_LOCKBYTES: tagSTGTY = 3; +pub const tagSTGTY_STGTY_PROPERTY: tagSTGTY = 4; +pub type tagSTGTY = ::std::os::raw::c_int; +pub use self::tagSTGTY as STGTY; +pub const tagSTREAM_SEEK_STREAM_SEEK_SET: tagSTREAM_SEEK = 0; +pub const tagSTREAM_SEEK_STREAM_SEEK_CUR: tagSTREAM_SEEK = 1; +pub const tagSTREAM_SEEK_STREAM_SEEK_END: tagSTREAM_SEEK = 2; +pub type tagSTREAM_SEEK = ::std::os::raw::c_int; +pub use self::tagSTREAM_SEEK as STREAM_SEEK; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct IStream { + pub _base: ISequentialStream, +} +#[test] +fn bindgen_test_layout_IStream() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(IStream)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(IStream)) + ); +} +pub type RPCOLEDATAREP = ULONG; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagRPCOLEMESSAGE { + pub reserved1: *mut ::std::os::raw::c_void, + pub dataRepresentation: RPCOLEDATAREP, + pub Buffer: *mut ::std::os::raw::c_void, + pub cbBuffer: ULONG, + pub iMethod: ULONG, + pub reserved2: [*mut ::std::os::raw::c_void; 5usize], + pub rpcFlags: ULONG, +} +#[test] +fn bindgen_test_layout_tagRPCOLEMESSAGE() { + assert_eq!( + ::std::mem::size_of::(), + 80usize, + concat!("Size of: ", stringify!(tagRPCOLEMESSAGE)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagRPCOLEMESSAGE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).reserved1 as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagRPCOLEMESSAGE), + "::", + stringify!(reserved1) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dataRepresentation as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagRPCOLEMESSAGE), + "::", + stringify!(dataRepresentation) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).Buffer as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(tagRPCOLEMESSAGE), + "::", + stringify!(Buffer) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cbBuffer as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(tagRPCOLEMESSAGE), + "::", + stringify!(cbBuffer) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).iMethod as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(tagRPCOLEMESSAGE), + "::", + stringify!(iMethod) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).reserved2 as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(tagRPCOLEMESSAGE), + "::", + stringify!(reserved2) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).rpcFlags as *const _ as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(tagRPCOLEMESSAGE), + "::", + stringify!(rpcFlags) + ) + ); +} +pub type RPCOLEMESSAGE = tagRPCOLEMESSAGE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct IRpcChannelBuffer { + pub _base: IUnknown, +} +#[test] +fn bindgen_test_layout_IRpcChannelBuffer() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(IRpcChannelBuffer)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(IRpcChannelBuffer)) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct SChannelHookCallInfo { + pub iid: IID, + pub cbSize: DWORD, + pub uCausality: GUID, + pub dwServerPid: DWORD, + pub iMethod: DWORD, + pub pObject: *mut ::std::os::raw::c_void, +} +#[test] +fn bindgen_test_layout_SChannelHookCallInfo() { + assert_eq!( + ::std::mem::size_of::(), + 56usize, + concat!("Size of: ", stringify!(SChannelHookCallInfo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(SChannelHookCallInfo)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).iid as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(SChannelHookCallInfo), + "::", + stringify!(iid) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cbSize as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(SChannelHookCallInfo), + "::", + stringify!(cbSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).uCausality as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(SChannelHookCallInfo), + "::", + stringify!(uCausality) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwServerPid as *const _ as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(SChannelHookCallInfo), + "::", + stringify!(dwServerPid) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).iMethod as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(SChannelHookCallInfo), + "::", + stringify!(iMethod) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).pObject as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(SChannelHookCallInfo), + "::", + stringify!(pObject) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagSOLE_AUTHENTICATION_SERVICE { + pub dwAuthnSvc: DWORD, + pub dwAuthzSvc: DWORD, + pub pPrincipalName: *mut OLECHAR, + pub hr: HRESULT, +} +#[test] +fn bindgen_test_layout_tagSOLE_AUTHENTICATION_SERVICE() { + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(tagSOLE_AUTHENTICATION_SERVICE)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagSOLE_AUTHENTICATION_SERVICE)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).dwAuthnSvc as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSOLE_AUTHENTICATION_SERVICE), + "::", + stringify!(dwAuthnSvc) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).dwAuthzSvc as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagSOLE_AUTHENTICATION_SERVICE), + "::", + stringify!(dwAuthzSvc) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pPrincipalName as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagSOLE_AUTHENTICATION_SERVICE), + "::", + stringify!(pPrincipalName) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).hr as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(tagSOLE_AUTHENTICATION_SERVICE), + "::", + stringify!(hr) + ) + ); +} +pub type SOLE_AUTHENTICATION_SERVICE = tagSOLE_AUTHENTICATION_SERVICE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagSOLE_AUTHENTICATION_INFO { + pub dwAuthnSvc: DWORD, + pub dwAuthzSvc: DWORD, + pub pAuthInfo: *mut ::std::os::raw::c_void, +} +#[test] +fn bindgen_test_layout_tagSOLE_AUTHENTICATION_INFO() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(tagSOLE_AUTHENTICATION_INFO)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagSOLE_AUTHENTICATION_INFO)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).dwAuthnSvc as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSOLE_AUTHENTICATION_INFO), + "::", + stringify!(dwAuthnSvc) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).dwAuthzSvc as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagSOLE_AUTHENTICATION_INFO), + "::", + stringify!(dwAuthzSvc) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pAuthInfo as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagSOLE_AUTHENTICATION_INFO), + "::", + stringify!(pAuthInfo) + ) + ); +} +pub type SOLE_AUTHENTICATION_INFO = tagSOLE_AUTHENTICATION_INFO; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagSOLE_AUTHENTICATION_LIST { + pub cAuthInfo: DWORD, + pub aAuthInfo: *mut SOLE_AUTHENTICATION_INFO, +} +#[test] +fn bindgen_test_layout_tagSOLE_AUTHENTICATION_LIST() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(tagSOLE_AUTHENTICATION_LIST)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagSOLE_AUTHENTICATION_LIST)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).cAuthInfo as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSOLE_AUTHENTICATION_LIST), + "::", + stringify!(cAuthInfo) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).aAuthInfo as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagSOLE_AUTHENTICATION_LIST), + "::", + stringify!(aAuthInfo) + ) + ); +} +pub type SOLE_AUTHENTICATION_LIST = tagSOLE_AUTHENTICATION_LIST; +pub const tagSTDMSHLFLAGS_SMEXF_SERVER: tagSTDMSHLFLAGS = 1; +pub const tagSTDMSHLFLAGS_SMEXF_HANDLER: tagSTDMSHLFLAGS = 2; +pub type tagSTDMSHLFLAGS = ::std::os::raw::c_int; +pub use self::tagSTDMSHLFLAGS as STDMSHLFLAGS; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagBIND_OPTS { + pub cbStruct: DWORD, + pub grfFlags: DWORD, + pub grfMode: DWORD, + pub dwTickCountDeadline: DWORD, +} +#[test] +fn bindgen_test_layout_tagBIND_OPTS() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(tagBIND_OPTS)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(tagBIND_OPTS)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cbStruct as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagBIND_OPTS), + "::", + stringify!(cbStruct) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).grfFlags as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagBIND_OPTS), + "::", + stringify!(grfFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).grfMode as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagBIND_OPTS), + "::", + stringify!(grfMode) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwTickCountDeadline as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(tagBIND_OPTS), + "::", + stringify!(dwTickCountDeadline) + ) + ); +} +pub type BIND_OPTS = tagBIND_OPTS; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct IBindCtx { + pub _base: IUnknown, +} +#[test] +fn bindgen_test_layout_IBindCtx() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(IBindCtx)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(IBindCtx)) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct IEnumMoniker { + pub _base: IUnknown, +} +#[test] +fn bindgen_test_layout_IEnumMoniker() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(IEnumMoniker)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(IEnumMoniker)) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct IRunningObjectTable { + pub _base: IUnknown, +} +#[test] +fn bindgen_test_layout_IRunningObjectTable() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(IRunningObjectTable)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(IRunningObjectTable)) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct IPersist { + pub _base: IUnknown, +} +#[test] +fn bindgen_test_layout_IPersist() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(IPersist)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(IPersist)) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct IPersistStream { + pub _base: IPersist, +} +#[test] +fn bindgen_test_layout_IPersistStream() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(IPersistStream)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(IPersistStream)) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct IMoniker { + pub _base: IPersistStream, +} +#[test] +fn bindgen_test_layout_IMoniker() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(IMoniker)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(IMoniker)) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct IEnumSTATSTG { + pub _base: IUnknown, +} +#[test] +fn bindgen_test_layout_IEnumSTATSTG() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(IEnumSTATSTG)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(IEnumSTATSTG)) + ); +} +pub type SNB = *mut LPOLESTR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct IStorage { + pub _base: IUnknown, +} +#[test] +fn bindgen_test_layout_IStorage() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(IStorage)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(IStorage)) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagDVTARGETDEVICE { + pub tdSize: DWORD, + pub tdDriverNameOffset: WORD, + pub tdDeviceNameOffset: WORD, + pub tdPortNameOffset: WORD, + pub tdExtDevmodeOffset: WORD, + pub tdData: [BYTE; 1usize], +} +#[test] +fn bindgen_test_layout_tagDVTARGETDEVICE() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(tagDVTARGETDEVICE)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(tagDVTARGETDEVICE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).tdSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagDVTARGETDEVICE), + "::", + stringify!(tdSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).tdDriverNameOffset as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagDVTARGETDEVICE), + "::", + stringify!(tdDriverNameOffset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).tdDeviceNameOffset as *const _ as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(tagDVTARGETDEVICE), + "::", + stringify!(tdDeviceNameOffset) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).tdPortNameOffset as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagDVTARGETDEVICE), + "::", + stringify!(tdPortNameOffset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).tdExtDevmodeOffset as *const _ as usize + }, + 10usize, + concat!( + "Offset of field: ", + stringify!(tagDVTARGETDEVICE), + "::", + stringify!(tdExtDevmodeOffset) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).tdData as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(tagDVTARGETDEVICE), + "::", + stringify!(tdData) + ) + ); +} +pub type DVTARGETDEVICE = tagDVTARGETDEVICE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagFORMATETC { + pub cfFormat: CLIPFORMAT, + pub ptd: *mut DVTARGETDEVICE, + pub dwAspect: DWORD, + pub lindex: LONG, + pub tymed: DWORD, +} +#[test] +fn bindgen_test_layout_tagFORMATETC() { + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(tagFORMATETC)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagFORMATETC)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cfFormat as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagFORMATETC), + "::", + stringify!(cfFormat) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).ptd as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagFORMATETC), + "::", + stringify!(ptd) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwAspect as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(tagFORMATETC), + "::", + stringify!(dwAspect) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lindex as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(tagFORMATETC), + "::", + stringify!(lindex) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).tymed as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(tagFORMATETC), + "::", + stringify!(tymed) + ) + ); +} +pub type FORMATETC = tagFORMATETC; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagSTATDATA { + pub formatetc: FORMATETC, + pub advf: DWORD, + pub pAdvSink: *mut IAdviseSink, + pub dwConnection: DWORD, +} +#[test] +fn bindgen_test_layout_tagSTATDATA() { + assert_eq!( + ::std::mem::size_of::(), + 56usize, + concat!("Size of: ", stringify!(tagSTATDATA)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagSTATDATA)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).formatetc as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSTATDATA), + "::", + stringify!(formatetc) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).advf as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(tagSTATDATA), + "::", + stringify!(advf) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).pAdvSink as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(tagSTATDATA), + "::", + stringify!(pAdvSink) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwConnection as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(tagSTATDATA), + "::", + stringify!(dwConnection) + ) + ); +} +pub type STATDATA = tagSTATDATA; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct tagSTGMEDIUM { + pub tymed: DWORD, + pub __bindgen_anon_1: tagSTGMEDIUM__bindgen_ty_1, + pub pUnkForRelease: *mut IUnknown, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union tagSTGMEDIUM__bindgen_ty_1 { + pub hBitmap: HBITMAP, + pub hMetaFilePict: HMETAFILEPICT, + pub hEnhMetaFile: HENHMETAFILE, + pub hGlobal: HGLOBAL, + pub lpszFileName: LPOLESTR, + pub pstm: *mut IStream, + pub pstg: *mut IStorage, + _bindgen_union_align: u64, +} +#[test] +fn bindgen_test_layout_tagSTGMEDIUM__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(tagSTGMEDIUM__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagSTGMEDIUM__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).hBitmap as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSTGMEDIUM__bindgen_ty_1), + "::", + stringify!(hBitmap) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).hMetaFilePict as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSTGMEDIUM__bindgen_ty_1), + "::", + stringify!(hMetaFilePict) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).hEnhMetaFile as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSTGMEDIUM__bindgen_ty_1), + "::", + stringify!(hEnhMetaFile) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).hGlobal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSTGMEDIUM__bindgen_ty_1), + "::", + stringify!(hGlobal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).lpszFileName as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSTGMEDIUM__bindgen_ty_1), + "::", + stringify!(lpszFileName) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).pstm as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSTGMEDIUM__bindgen_ty_1), + "::", + stringify!(pstm) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).pstg as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSTGMEDIUM__bindgen_ty_1), + "::", + stringify!(pstg) + ) + ); +} +#[test] +fn bindgen_test_layout_tagSTGMEDIUM() { + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(tagSTGMEDIUM)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagSTGMEDIUM)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).tymed as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSTGMEDIUM), + "::", + stringify!(tymed) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).pUnkForRelease as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(tagSTGMEDIUM), + "::", + stringify!(pUnkForRelease) + ) + ); +} +pub type uSTGMEDIUM = tagSTGMEDIUM; +pub type STGMEDIUM = uSTGMEDIUM; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct IAdviseSink { + pub _base: IUnknown, +} +#[test] +fn bindgen_test_layout_IAdviseSink() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(IAdviseSink)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(IAdviseSink)) + ); +} +pub const tagSERVERCALL_SERVERCALL_ISHANDLED: tagSERVERCALL = 0; +pub const tagSERVERCALL_SERVERCALL_REJECTED: tagSERVERCALL = 1; +pub const tagSERVERCALL_SERVERCALL_RETRYLATER: tagSERVERCALL = 2; +pub type tagSERVERCALL = ::std::os::raw::c_int; +pub use self::tagSERVERCALL as SERVERCALL; +extern "C" { + pub fn SNB_UserSize( + arg1: *mut ::std::os::raw::c_ulong, + arg2: ::std::os::raw::c_ulong, + arg3: *mut SNB, + ) -> ::std::os::raw::c_ulong; +} +extern "C" { + pub fn SNB_UserMarshal( + arg1: *mut ::std::os::raw::c_ulong, + arg2: *mut ::std::os::raw::c_uchar, + arg3: *mut SNB, + ) -> *mut ::std::os::raw::c_uchar; +} +extern "C" { + pub fn SNB_UserUnmarshal( + arg1: *mut ::std::os::raw::c_ulong, + arg2: *mut ::std::os::raw::c_uchar, + arg3: *mut SNB, + ) -> *mut ::std::os::raw::c_uchar; +} +extern "C" { + pub fn SNB_UserFree(arg1: *mut ::std::os::raw::c_ulong, arg2: *mut SNB); +} +extern "C" { + pub fn STGMEDIUM_UserSize( + arg1: *mut ::std::os::raw::c_ulong, + arg2: ::std::os::raw::c_ulong, + arg3: *mut STGMEDIUM, + ) -> ::std::os::raw::c_ulong; +} +extern "C" { + pub fn STGMEDIUM_UserMarshal( + arg1: *mut ::std::os::raw::c_ulong, + arg2: *mut ::std::os::raw::c_uchar, + arg3: *mut STGMEDIUM, + ) -> *mut ::std::os::raw::c_uchar; +} +extern "C" { + pub fn STGMEDIUM_UserUnmarshal( + arg1: *mut ::std::os::raw::c_ulong, + arg2: *mut ::std::os::raw::c_uchar, + arg3: *mut STGMEDIUM, + ) -> *mut ::std::os::raw::c_uchar; +} +extern "C" { + pub fn STGMEDIUM_UserFree(arg1: *mut ::std::os::raw::c_ulong, arg2: *mut STGMEDIUM); +} +extern "C" { + pub fn SNB_UserSize64( + arg1: *mut ::std::os::raw::c_ulong, + arg2: ::std::os::raw::c_ulong, + arg3: *mut SNB, + ) -> ::std::os::raw::c_ulong; +} +extern "C" { + pub fn SNB_UserMarshal64( + arg1: *mut ::std::os::raw::c_ulong, + arg2: *mut ::std::os::raw::c_uchar, + arg3: *mut SNB, + ) -> *mut ::std::os::raw::c_uchar; +} +extern "C" { + pub fn SNB_UserUnmarshal64( + arg1: *mut ::std::os::raw::c_ulong, + arg2: *mut ::std::os::raw::c_uchar, + arg3: *mut SNB, + ) -> *mut ::std::os::raw::c_uchar; +} +extern "C" { + pub fn SNB_UserFree64(arg1: *mut ::std::os::raw::c_ulong, arg2: *mut SNB); +} +extern "C" { + pub fn STGMEDIUM_UserSize64( + arg1: *mut ::std::os::raw::c_ulong, + arg2: ::std::os::raw::c_ulong, + arg3: *mut STGMEDIUM, + ) -> ::std::os::raw::c_ulong; +} +extern "C" { + pub fn STGMEDIUM_UserMarshal64( + arg1: *mut ::std::os::raw::c_ulong, + arg2: *mut ::std::os::raw::c_uchar, + arg3: *mut STGMEDIUM, + ) -> *mut ::std::os::raw::c_uchar; +} +extern "C" { + pub fn STGMEDIUM_UserUnmarshal64( + arg1: *mut ::std::os::raw::c_ulong, + arg2: *mut ::std::os::raw::c_uchar, + arg3: *mut STGMEDIUM, + ) -> *mut ::std::os::raw::c_uchar; +} +extern "C" { + pub fn STGMEDIUM_UserFree64(arg1: *mut ::std::os::raw::c_ulong, arg2: *mut STGMEDIUM); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagSAFEARRAYBOUND { + pub cElements: ULONG, + pub lLbound: LONG, +} +#[test] +fn bindgen_test_layout_tagSAFEARRAYBOUND() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(tagSAFEARRAYBOUND)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(tagSAFEARRAYBOUND)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cElements as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSAFEARRAYBOUND), + "::", + stringify!(cElements) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lLbound as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagSAFEARRAYBOUND), + "::", + stringify!(lLbound) + ) + ); +} +pub type SAFEARRAYBOUND = tagSAFEARRAYBOUND; +pub type wireVARIANT = *mut _wireVARIANT; +pub type wireBRECORD = *mut _wireBRECORD; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _wireSAFEARR_BSTR { + pub Size: ULONG, + pub aBstr: *mut wireBSTR, +} +#[test] +fn bindgen_test_layout__wireSAFEARR_BSTR() { + assert_eq!( + ::std::mem::size_of::<_wireSAFEARR_BSTR>(), + 16usize, + concat!("Size of: ", stringify!(_wireSAFEARR_BSTR)) + ); + assert_eq!( + ::std::mem::align_of::<_wireSAFEARR_BSTR>(), + 8usize, + concat!("Alignment of ", stringify!(_wireSAFEARR_BSTR)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireSAFEARR_BSTR>())).Size as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARR_BSTR), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireSAFEARR_BSTR>())).aBstr as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARR_BSTR), + "::", + stringify!(aBstr) + ) + ); +} +pub type SAFEARR_BSTR = _wireSAFEARR_BSTR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _wireSAFEARR_UNKNOWN { + pub Size: ULONG, + pub apUnknown: *mut *mut IUnknown, +} +#[test] +fn bindgen_test_layout__wireSAFEARR_UNKNOWN() { + assert_eq!( + ::std::mem::size_of::<_wireSAFEARR_UNKNOWN>(), + 16usize, + concat!("Size of: ", stringify!(_wireSAFEARR_UNKNOWN)) + ); + assert_eq!( + ::std::mem::align_of::<_wireSAFEARR_UNKNOWN>(), + 8usize, + concat!("Alignment of ", stringify!(_wireSAFEARR_UNKNOWN)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireSAFEARR_UNKNOWN>())).Size as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARR_UNKNOWN), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireSAFEARR_UNKNOWN>())).apUnknown as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARR_UNKNOWN), + "::", + stringify!(apUnknown) + ) + ); +} +pub type SAFEARR_UNKNOWN = _wireSAFEARR_UNKNOWN; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _wireSAFEARR_DISPATCH { + pub Size: ULONG, + pub apDispatch: *mut *mut IDispatch, +} +#[test] +fn bindgen_test_layout__wireSAFEARR_DISPATCH() { + assert_eq!( + ::std::mem::size_of::<_wireSAFEARR_DISPATCH>(), + 16usize, + concat!("Size of: ", stringify!(_wireSAFEARR_DISPATCH)) + ); + assert_eq!( + ::std::mem::align_of::<_wireSAFEARR_DISPATCH>(), + 8usize, + concat!("Alignment of ", stringify!(_wireSAFEARR_DISPATCH)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireSAFEARR_DISPATCH>())).Size as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARR_DISPATCH), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireSAFEARR_DISPATCH>())).apDispatch as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARR_DISPATCH), + "::", + stringify!(apDispatch) + ) + ); +} +pub type SAFEARR_DISPATCH = _wireSAFEARR_DISPATCH; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _wireSAFEARR_VARIANT { + pub Size: ULONG, + pub aVariant: *mut wireVARIANT, +} +#[test] +fn bindgen_test_layout__wireSAFEARR_VARIANT() { + assert_eq!( + ::std::mem::size_of::<_wireSAFEARR_VARIANT>(), + 16usize, + concat!("Size of: ", stringify!(_wireSAFEARR_VARIANT)) + ); + assert_eq!( + ::std::mem::align_of::<_wireSAFEARR_VARIANT>(), + 8usize, + concat!("Alignment of ", stringify!(_wireSAFEARR_VARIANT)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireSAFEARR_VARIANT>())).Size as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARR_VARIANT), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireSAFEARR_VARIANT>())).aVariant as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARR_VARIANT), + "::", + stringify!(aVariant) + ) + ); +} +pub type SAFEARR_VARIANT = _wireSAFEARR_VARIANT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _wireSAFEARR_BRECORD { + pub Size: ULONG, + pub aRecord: *mut wireBRECORD, +} +#[test] +fn bindgen_test_layout__wireSAFEARR_BRECORD() { + assert_eq!( + ::std::mem::size_of::<_wireSAFEARR_BRECORD>(), + 16usize, + concat!("Size of: ", stringify!(_wireSAFEARR_BRECORD)) + ); + assert_eq!( + ::std::mem::align_of::<_wireSAFEARR_BRECORD>(), + 8usize, + concat!("Alignment of ", stringify!(_wireSAFEARR_BRECORD)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireSAFEARR_BRECORD>())).Size as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARR_BRECORD), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireSAFEARR_BRECORD>())).aRecord as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARR_BRECORD), + "::", + stringify!(aRecord) + ) + ); +} +pub type SAFEARR_BRECORD = _wireSAFEARR_BRECORD; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _wireSAFEARR_HAVEIID { + pub Size: ULONG, + pub apUnknown: *mut *mut IUnknown, + pub iid: IID, +} +#[test] +fn bindgen_test_layout__wireSAFEARR_HAVEIID() { + assert_eq!( + ::std::mem::size_of::<_wireSAFEARR_HAVEIID>(), + 32usize, + concat!("Size of: ", stringify!(_wireSAFEARR_HAVEIID)) + ); + assert_eq!( + ::std::mem::align_of::<_wireSAFEARR_HAVEIID>(), + 8usize, + concat!("Alignment of ", stringify!(_wireSAFEARR_HAVEIID)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireSAFEARR_HAVEIID>())).Size as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARR_HAVEIID), + "::", + stringify!(Size) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireSAFEARR_HAVEIID>())).apUnknown as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARR_HAVEIID), + "::", + stringify!(apUnknown) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireSAFEARR_HAVEIID>())).iid as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARR_HAVEIID), + "::", + stringify!(iid) + ) + ); +} +pub type SAFEARR_HAVEIID = _wireSAFEARR_HAVEIID; +pub const tagSF_TYPE_SF_ERROR: tagSF_TYPE = 10; +pub const tagSF_TYPE_SF_I1: tagSF_TYPE = 16; +pub const tagSF_TYPE_SF_I2: tagSF_TYPE = 2; +pub const tagSF_TYPE_SF_I4: tagSF_TYPE = 3; +pub const tagSF_TYPE_SF_I8: tagSF_TYPE = 20; +pub const tagSF_TYPE_SF_BSTR: tagSF_TYPE = 8; +pub const tagSF_TYPE_SF_UNKNOWN: tagSF_TYPE = 13; +pub const tagSF_TYPE_SF_DISPATCH: tagSF_TYPE = 9; +pub const tagSF_TYPE_SF_VARIANT: tagSF_TYPE = 12; +pub const tagSF_TYPE_SF_RECORD: tagSF_TYPE = 36; +pub const tagSF_TYPE_SF_HAVEIID: tagSF_TYPE = 32781; +pub type tagSF_TYPE = ::std::os::raw::c_int; +pub use self::tagSF_TYPE as SF_TYPE; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _wireSAFEARRAY_UNION { + pub sfType: ULONG, + pub u: _wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001 { + pub BstrStr: SAFEARR_BSTR, + pub UnknownStr: SAFEARR_UNKNOWN, + pub DispatchStr: SAFEARR_DISPATCH, + pub VariantStr: SAFEARR_VARIANT, + pub RecordStr: SAFEARR_BRECORD, + pub HaveIidStr: SAFEARR_HAVEIID, + pub ByteStr: BYTE_SIZEDARR, + pub WordStr: WORD_SIZEDARR, + pub LongStr: DWORD_SIZEDARR, + pub HyperStr: HYPER_SIZEDARR, + _bindgen_union_align: [u64; 4usize], +} +#[test] +fn bindgen_test_layout__wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001() { + assert_eq!( + ::std::mem::size_of::<_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001>(), + 32usize, + concat!( + "Size of: ", + stringify!(_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001) + ) + ); + assert_eq!( + ::std::mem::align_of::<_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001>())).BstrStr + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001), + "::", + stringify!(BstrStr) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001>())).UnknownStr + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001), + "::", + stringify!(UnknownStr) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001>())).DispatchStr + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001), + "::", + stringify!(DispatchStr) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001>())).VariantStr + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001), + "::", + stringify!(VariantStr) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001>())).RecordStr + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001), + "::", + stringify!(RecordStr) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001>())).HaveIidStr + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001), + "::", + stringify!(HaveIidStr) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001>())).ByteStr + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001), + "::", + stringify!(ByteStr) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001>())).WordStr + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001), + "::", + stringify!(WordStr) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001>())).LongStr + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001), + "::", + stringify!(LongStr) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001>())).HyperStr + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARRAY_UNION___MIDL_IOleAutomationTypes_0001), + "::", + stringify!(HyperStr) + ) + ); +} +#[test] +fn bindgen_test_layout__wireSAFEARRAY_UNION() { + assert_eq!( + ::std::mem::size_of::<_wireSAFEARRAY_UNION>(), + 40usize, + concat!("Size of: ", stringify!(_wireSAFEARRAY_UNION)) + ); + assert_eq!( + ::std::mem::align_of::<_wireSAFEARRAY_UNION>(), + 8usize, + concat!("Alignment of ", stringify!(_wireSAFEARRAY_UNION)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireSAFEARRAY_UNION>())).sfType as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARRAY_UNION), + "::", + stringify!(sfType) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireSAFEARRAY_UNION>())).u as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARRAY_UNION), + "::", + stringify!(u) + ) + ); +} +pub type SAFEARRAYUNION = _wireSAFEARRAY_UNION; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _wireSAFEARRAY { + pub cDims: USHORT, + pub fFeatures: USHORT, + pub cbElements: ULONG, + pub cLocks: ULONG, + pub uArrayStructs: SAFEARRAYUNION, + pub rgsabound: [SAFEARRAYBOUND; 1usize], +} +#[test] +fn bindgen_test_layout__wireSAFEARRAY() { + assert_eq!( + ::std::mem::size_of::<_wireSAFEARRAY>(), + 64usize, + concat!("Size of: ", stringify!(_wireSAFEARRAY)) + ); + assert_eq!( + ::std::mem::align_of::<_wireSAFEARRAY>(), + 8usize, + concat!("Alignment of ", stringify!(_wireSAFEARRAY)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireSAFEARRAY>())).cDims as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARRAY), + "::", + stringify!(cDims) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireSAFEARRAY>())).fFeatures as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARRAY), + "::", + stringify!(fFeatures) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireSAFEARRAY>())).cbElements as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARRAY), + "::", + stringify!(cbElements) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireSAFEARRAY>())).cLocks as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARRAY), + "::", + stringify!(cLocks) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireSAFEARRAY>())).uArrayStructs as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARRAY), + "::", + stringify!(uArrayStructs) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireSAFEARRAY>())).rgsabound as *const _ as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(_wireSAFEARRAY), + "::", + stringify!(rgsabound) + ) + ); +} +pub type wireSAFEARRAY = *mut _wireSAFEARRAY; +pub type wirePSAFEARRAY = *mut wireSAFEARRAY; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagSAFEARRAY { + pub cDims: USHORT, + pub fFeatures: USHORT, + pub cbElements: ULONG, + pub cLocks: ULONG, + pub pvData: PVOID, + pub rgsabound: [SAFEARRAYBOUND; 1usize], +} +#[test] +fn bindgen_test_layout_tagSAFEARRAY() { + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(tagSAFEARRAY)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagSAFEARRAY)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cDims as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSAFEARRAY), + "::", + stringify!(cDims) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).fFeatures as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(tagSAFEARRAY), + "::", + stringify!(fFeatures) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cbElements as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagSAFEARRAY), + "::", + stringify!(cbElements) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cLocks as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagSAFEARRAY), + "::", + stringify!(cLocks) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).pvData as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(tagSAFEARRAY), + "::", + stringify!(pvData) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).rgsabound as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(tagSAFEARRAY), + "::", + stringify!(rgsabound) + ) + ); +} +pub type SAFEARRAY = tagSAFEARRAY; +pub type VARIANT = tagVARIANT; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct tagVARIANT { + pub __bindgen_anon_1: tagVARIANT__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union tagVARIANT__bindgen_ty_1 { + pub __bindgen_anon_1: tagVARIANT__bindgen_ty_1__bindgen_ty_1, + pub decVal: DECIMAL, + _bindgen_union_align: [u64; 3usize], +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct tagVARIANT__bindgen_ty_1__bindgen_ty_1 { + pub vt: VARTYPE, + pub wReserved1: WORD, + pub wReserved2: WORD, + pub wReserved3: WORD, + pub __bindgen_anon_1: tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 { + pub llVal: LONGLONG, + pub lVal: LONG, + pub bVal: BYTE, + pub iVal: SHORT, + pub fltVal: FLOAT, + pub dblVal: DOUBLE, + pub boolVal: VARIANT_BOOL, + pub __OBSOLETE__VARIANT_BOOL: VARIANT_BOOL, + pub scode: SCODE, + pub cyVal: CY, + pub date: DATE, + pub bstrVal: BSTR, + pub punkVal: *mut IUnknown, + pub pdispVal: *mut IDispatch, + pub parray: *mut SAFEARRAY, + pub pbVal: *mut BYTE, + pub piVal: *mut SHORT, + pub plVal: *mut LONG, + pub pllVal: *mut LONGLONG, + pub pfltVal: *mut FLOAT, + pub pdblVal: *mut DOUBLE, + pub pboolVal: *mut VARIANT_BOOL, + pub __OBSOLETE__VARIANT_PBOOL: *mut VARIANT_BOOL, + pub pscode: *mut SCODE, + pub pcyVal: *mut CY, + pub pdate: *mut DATE, + pub pbstrVal: *mut BSTR, + pub ppunkVal: *mut *mut IUnknown, + pub ppdispVal: *mut *mut IDispatch, + pub pparray: *mut *mut SAFEARRAY, + pub pvarVal: *mut VARIANT, + pub byref: PVOID, + pub cVal: CHAR, + pub uiVal: USHORT, + pub ulVal: ULONG, + pub ullVal: ULONGLONG, + pub intVal: INT, + pub uintVal: UINT, + pub pdecVal: *mut DECIMAL, + pub pcVal: *mut CHAR, + pub puiVal: *mut USHORT, + pub pulVal: *mut ULONG, + pub pullVal: *mut ULONGLONG, + pub pintVal: *mut INT, + pub puintVal: *mut UINT, + pub __bindgen_anon_1: tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1, + _bindgen_union_align: [u64; 2usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 { + pub pvRecord: PVOID, + pub pRecInfo: *mut IRecordInfo, +} +#[test] +fn bindgen_test_layout_tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!( + "Size of: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())) + .pvRecord as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(pvRecord) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())) + .pRecInfo as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(pRecInfo) + ) + ); +} +#[test] +fn bindgen_test_layout_tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!( + "Size of: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).llVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(llVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).lVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(lVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).bVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(bVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).iVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(iVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).fltVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(fltVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).dblVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(dblVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).boolVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(boolVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())) + .__OBSOLETE__VARIANT_BOOL as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(__OBSOLETE__VARIANT_BOOL) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).scode + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(scode) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).cyVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(cyVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).date + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(date) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).bstrVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(bstrVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).punkVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(punkVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pdispVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(pdispVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).parray + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(parray) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pbVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(pbVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).piVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(piVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).plVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(plVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pllVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(pllVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pfltVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(pfltVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pdblVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(pdblVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pboolVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(pboolVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())) + .__OBSOLETE__VARIANT_PBOOL as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(__OBSOLETE__VARIANT_PBOOL) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pscode + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(pscode) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pcyVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(pcyVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pdate + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(pdate) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pbstrVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(pbstrVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).ppunkVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(ppunkVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).ppdispVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(ppdispVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pparray + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(pparray) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pvarVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(pvarVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).byref + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(byref) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).cVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(cVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).uiVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(uiVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).ulVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(ulVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).ullVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(ullVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).intVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(intVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).uintVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(uintVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pdecVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(pdecVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pcVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(pcVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).puiVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(puiVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pulVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(pulVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pullVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(pullVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pintVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(pintVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).puintVal + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(puintVal) + ) + ); +} +#[test] +fn bindgen_test_layout_tagVARIANT__bindgen_ty_1__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!( + "Size of: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).vt as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(vt) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).wReserved1 as *const _ + as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(wReserved1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).wReserved2 as *const _ + as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(wReserved2) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).wReserved3 as *const _ + as usize + }, + 6usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(wReserved3) + ) + ); +} +#[test] +fn bindgen_test_layout_tagVARIANT__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(tagVARIANT__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagVARIANT__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).decVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARIANT__bindgen_ty_1), + "::", + stringify!(decVal) + ) + ); +} +#[test] +fn bindgen_test_layout_tagVARIANT() { + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(tagVARIANT)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagVARIANT)) + ); +} +pub type VARIANTARG = VARIANT; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _wireBRECORD { + pub fFlags: ULONG, + pub clSize: ULONG, + pub pRecInfo: *mut IRecordInfo, + pub pRecord: *mut byte, +} +#[test] +fn bindgen_test_layout__wireBRECORD() { + assert_eq!( + ::std::mem::size_of::<_wireBRECORD>(), + 24usize, + concat!("Size of: ", stringify!(_wireBRECORD)) + ); + assert_eq!( + ::std::mem::align_of::<_wireBRECORD>(), + 8usize, + concat!("Alignment of ", stringify!(_wireBRECORD)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireBRECORD>())).fFlags as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireBRECORD), + "::", + stringify!(fFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireBRECORD>())).clSize as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_wireBRECORD), + "::", + stringify!(clSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireBRECORD>())).pRecInfo as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_wireBRECORD), + "::", + stringify!(pRecInfo) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireBRECORD>())).pRecord as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_wireBRECORD), + "::", + stringify!(pRecord) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _wireVARIANT { + pub clSize: DWORD, + pub rpcReserved: DWORD, + pub vt: USHORT, + pub wReserved1: USHORT, + pub wReserved2: USHORT, + pub wReserved3: USHORT, + pub __bindgen_anon_1: _wireVARIANT__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _wireVARIANT__bindgen_ty_1 { + pub llVal: LONGLONG, + pub lVal: LONG, + pub bVal: BYTE, + pub iVal: SHORT, + pub fltVal: FLOAT, + pub dblVal: DOUBLE, + pub boolVal: VARIANT_BOOL, + pub scode: SCODE, + pub cyVal: CY, + pub date: DATE, + pub bstrVal: wireBSTR, + pub punkVal: *mut IUnknown, + pub pdispVal: *mut IDispatch, + pub parray: wirePSAFEARRAY, + pub brecVal: wireBRECORD, + pub pbVal: *mut BYTE, + pub piVal: *mut SHORT, + pub plVal: *mut LONG, + pub pllVal: *mut LONGLONG, + pub pfltVal: *mut FLOAT, + pub pdblVal: *mut DOUBLE, + pub pboolVal: *mut VARIANT_BOOL, + pub pscode: *mut SCODE, + pub pcyVal: *mut CY, + pub pdate: *mut DATE, + pub pbstrVal: *mut wireBSTR, + pub ppunkVal: *mut *mut IUnknown, + pub ppdispVal: *mut *mut IDispatch, + pub pparray: *mut wirePSAFEARRAY, + pub pvarVal: *mut wireVARIANT, + pub cVal: CHAR, + pub uiVal: USHORT, + pub ulVal: ULONG, + pub ullVal: ULONGLONG, + pub intVal: INT, + pub uintVal: UINT, + pub decVal: DECIMAL, + pub pdecVal: *mut DECIMAL, + pub pcVal: *mut CHAR, + pub puiVal: *mut USHORT, + pub pulVal: *mut ULONG, + pub pullVal: *mut ULONGLONG, + pub pintVal: *mut INT, + pub puintVal: *mut UINT, + _bindgen_union_align: [u64; 2usize], +} +#[test] +fn bindgen_test_layout__wireVARIANT__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_wireVARIANT__bindgen_ty_1>(), + 16usize, + concat!("Size of: ", stringify!(_wireVARIANT__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<_wireVARIANT__bindgen_ty_1>(), + 8usize, + concat!("Alignment of ", stringify!(_wireVARIANT__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).llVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(llVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).lVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(lVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).bVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(bVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).iVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(iVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).fltVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(fltVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).dblVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(dblVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).boolVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(boolVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).scode as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(scode) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).cyVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(cyVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).date as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(date) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).bstrVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(bstrVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).punkVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(punkVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).pdispVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(pdispVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).parray as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(parray) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).brecVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(brecVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).pbVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(pbVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).piVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(piVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).plVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(plVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).pllVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(pllVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).pfltVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(pfltVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).pdblVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(pdblVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).pboolVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(pboolVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).pscode as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(pscode) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).pcyVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(pcyVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).pdate as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(pdate) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).pbstrVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(pbstrVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).ppunkVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(ppunkVal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).ppdispVal as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(ppdispVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).pparray as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(pparray) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).pvarVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(pvarVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).cVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(cVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).uiVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(uiVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).ulVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(ulVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).ullVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(ullVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).intVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(intVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).uintVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(uintVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).decVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(decVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).pdecVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(pdecVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).pcVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(pcVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).puiVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(puiVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).pulVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(pulVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).pullVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(pullVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).pintVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(pintVal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT__bindgen_ty_1>())).puintVal as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT__bindgen_ty_1), + "::", + stringify!(puintVal) + ) + ); +} +#[test] +fn bindgen_test_layout__wireVARIANT() { + assert_eq!( + ::std::mem::size_of::<_wireVARIANT>(), + 32usize, + concat!("Size of: ", stringify!(_wireVARIANT)) + ); + assert_eq!( + ::std::mem::align_of::<_wireVARIANT>(), + 8usize, + concat!("Alignment of ", stringify!(_wireVARIANT)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT>())).clSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT), + "::", + stringify!(clSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT>())).rpcReserved as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT), + "::", + stringify!(rpcReserved) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT>())).vt as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT), + "::", + stringify!(vt) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT>())).wReserved1 as *const _ as usize }, + 10usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT), + "::", + stringify!(wReserved1) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT>())).wReserved2 as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT), + "::", + stringify!(wReserved2) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_wireVARIANT>())).wReserved3 as *const _ as usize }, + 14usize, + concat!( + "Offset of field: ", + stringify!(_wireVARIANT), + "::", + stringify!(wReserved3) + ) + ); +} +pub type DISPID = LONG; +pub type MEMBERID = DISPID; +pub type HREFTYPE = DWORD; +pub const tagTYPEKIND_TKIND_ENUM: tagTYPEKIND = 0; +pub const tagTYPEKIND_TKIND_RECORD: tagTYPEKIND = 1; +pub const tagTYPEKIND_TKIND_MODULE: tagTYPEKIND = 2; +pub const tagTYPEKIND_TKIND_INTERFACE: tagTYPEKIND = 3; +pub const tagTYPEKIND_TKIND_DISPATCH: tagTYPEKIND = 4; +pub const tagTYPEKIND_TKIND_COCLASS: tagTYPEKIND = 5; +pub const tagTYPEKIND_TKIND_ALIAS: tagTYPEKIND = 6; +pub const tagTYPEKIND_TKIND_UNION: tagTYPEKIND = 7; +pub const tagTYPEKIND_TKIND_MAX: tagTYPEKIND = 8; +pub type tagTYPEKIND = ::std::os::raw::c_int; +pub use self::tagTYPEKIND as TYPEKIND; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct tagTYPEDESC { + pub __bindgen_anon_1: tagTYPEDESC__bindgen_ty_1, + pub vt: VARTYPE, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union tagTYPEDESC__bindgen_ty_1 { + pub lptdesc: *mut tagTYPEDESC, + pub lpadesc: *mut tagARRAYDESC, + pub hreftype: HREFTYPE, + _bindgen_union_align: u64, +} +#[test] +fn bindgen_test_layout_tagTYPEDESC__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(tagTYPEDESC__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagTYPEDESC__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lptdesc as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagTYPEDESC__bindgen_ty_1), + "::", + stringify!(lptdesc) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lpadesc as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagTYPEDESC__bindgen_ty_1), + "::", + stringify!(lpadesc) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).hreftype as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagTYPEDESC__bindgen_ty_1), + "::", + stringify!(hreftype) + ) + ); +} +#[test] +fn bindgen_test_layout_tagTYPEDESC() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(tagTYPEDESC)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagTYPEDESC)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).vt as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagTYPEDESC), + "::", + stringify!(vt) + ) + ); +} +pub type TYPEDESC = tagTYPEDESC; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct tagARRAYDESC { + pub tdescElem: TYPEDESC, + pub cDims: USHORT, + pub rgbounds: [SAFEARRAYBOUND; 1usize], +} +#[test] +fn bindgen_test_layout_tagARRAYDESC() { + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(tagARRAYDESC)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagARRAYDESC)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).tdescElem as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagARRAYDESC), + "::", + stringify!(tdescElem) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cDims as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(tagARRAYDESC), + "::", + stringify!(cDims) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).rgbounds as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(tagARRAYDESC), + "::", + stringify!(rgbounds) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct tagPARAMDESCEX { + pub cBytes: ULONG, + pub varDefaultValue: VARIANTARG, +} +#[test] +fn bindgen_test_layout_tagPARAMDESCEX() { + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(tagPARAMDESCEX)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagPARAMDESCEX)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cBytes as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagPARAMDESCEX), + "::", + stringify!(cBytes) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).varDefaultValue as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagPARAMDESCEX), + "::", + stringify!(varDefaultValue) + ) + ); +} +pub type LPPARAMDESCEX = *mut tagPARAMDESCEX; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagPARAMDESC { + pub pparamdescex: LPPARAMDESCEX, + pub wParamFlags: USHORT, +} +#[test] +fn bindgen_test_layout_tagPARAMDESC() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(tagPARAMDESC)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagPARAMDESC)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).pparamdescex as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagPARAMDESC), + "::", + stringify!(pparamdescex) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).wParamFlags as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagPARAMDESC), + "::", + stringify!(wParamFlags) + ) + ); +} +pub type PARAMDESC = tagPARAMDESC; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagIDLDESC { + pub dwReserved: ULONG_PTR, + pub wIDLFlags: USHORT, +} +#[test] +fn bindgen_test_layout_tagIDLDESC() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(tagIDLDESC)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagIDLDESC)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwReserved as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagIDLDESC), + "::", + stringify!(dwReserved) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).wIDLFlags as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagIDLDESC), + "::", + stringify!(wIDLFlags) + ) + ); +} +pub type IDLDESC = tagIDLDESC; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct tagELEMDESC { + pub tdesc: TYPEDESC, + pub __bindgen_anon_1: tagELEMDESC__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union tagELEMDESC__bindgen_ty_1 { + pub idldesc: IDLDESC, + pub paramdesc: PARAMDESC, + _bindgen_union_align: [u64; 2usize], +} +#[test] +fn bindgen_test_layout_tagELEMDESC__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(tagELEMDESC__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagELEMDESC__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).idldesc as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagELEMDESC__bindgen_ty_1), + "::", + stringify!(idldesc) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).paramdesc as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagELEMDESC__bindgen_ty_1), + "::", + stringify!(paramdesc) + ) + ); +} +#[test] +fn bindgen_test_layout_tagELEMDESC() { + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(tagELEMDESC)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagELEMDESC)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).tdesc as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagELEMDESC), + "::", + stringify!(tdesc) + ) + ); +} +pub type ELEMDESC = tagELEMDESC; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct tagTYPEATTR { + pub guid: GUID, + pub lcid: LCID, + pub dwReserved: DWORD, + pub memidConstructor: MEMBERID, + pub memidDestructor: MEMBERID, + pub lpstrSchema: LPOLESTR, + pub cbSizeInstance: ULONG, + pub typekind: TYPEKIND, + pub cFuncs: WORD, + pub cVars: WORD, + pub cImplTypes: WORD, + pub cbSizeVft: WORD, + pub cbAlignment: WORD, + pub wTypeFlags: WORD, + pub wMajorVerNum: WORD, + pub wMinorVerNum: WORD, + pub tdescAlias: TYPEDESC, + pub idldescType: IDLDESC, +} +#[test] +fn bindgen_test_layout_tagTYPEATTR() { + assert_eq!( + ::std::mem::size_of::(), + 96usize, + concat!("Size of: ", stringify!(tagTYPEATTR)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagTYPEATTR)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).guid as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagTYPEATTR), + "::", + stringify!(guid) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lcid as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(tagTYPEATTR), + "::", + stringify!(lcid) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwReserved as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(tagTYPEATTR), + "::", + stringify!(dwReserved) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).memidConstructor as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(tagTYPEATTR), + "::", + stringify!(memidConstructor) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).memidDestructor as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(tagTYPEATTR), + "::", + stringify!(memidDestructor) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lpstrSchema as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(tagTYPEATTR), + "::", + stringify!(lpstrSchema) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cbSizeInstance as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(tagTYPEATTR), + "::", + stringify!(cbSizeInstance) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).typekind as *const _ as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(tagTYPEATTR), + "::", + stringify!(typekind) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cFuncs as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(tagTYPEATTR), + "::", + stringify!(cFuncs) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cVars as *const _ as usize }, + 50usize, + concat!( + "Offset of field: ", + stringify!(tagTYPEATTR), + "::", + stringify!(cVars) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cImplTypes as *const _ as usize }, + 52usize, + concat!( + "Offset of field: ", + stringify!(tagTYPEATTR), + "::", + stringify!(cImplTypes) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cbSizeVft as *const _ as usize }, + 54usize, + concat!( + "Offset of field: ", + stringify!(tagTYPEATTR), + "::", + stringify!(cbSizeVft) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cbAlignment as *const _ as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(tagTYPEATTR), + "::", + stringify!(cbAlignment) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).wTypeFlags as *const _ as usize }, + 58usize, + concat!( + "Offset of field: ", + stringify!(tagTYPEATTR), + "::", + stringify!(wTypeFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).wMajorVerNum as *const _ as usize }, + 60usize, + concat!( + "Offset of field: ", + stringify!(tagTYPEATTR), + "::", + stringify!(wMajorVerNum) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).wMinorVerNum as *const _ as usize }, + 62usize, + concat!( + "Offset of field: ", + stringify!(tagTYPEATTR), + "::", + stringify!(wMinorVerNum) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).tdescAlias as *const _ as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(tagTYPEATTR), + "::", + stringify!(tdescAlias) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).idldescType as *const _ as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(tagTYPEATTR), + "::", + stringify!(idldescType) + ) + ); +} +pub type TYPEATTR = tagTYPEATTR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagDISPPARAMS { + pub rgvarg: *mut VARIANTARG, + pub rgdispidNamedArgs: *mut DISPID, + pub cArgs: UINT, + pub cNamedArgs: UINT, +} +#[test] +fn bindgen_test_layout_tagDISPPARAMS() { + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(tagDISPPARAMS)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagDISPPARAMS)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).rgvarg as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagDISPPARAMS), + "::", + stringify!(rgvarg) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).rgdispidNamedArgs as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagDISPPARAMS), + "::", + stringify!(rgdispidNamedArgs) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cArgs as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(tagDISPPARAMS), + "::", + stringify!(cArgs) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cNamedArgs as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(tagDISPPARAMS), + "::", + stringify!(cNamedArgs) + ) + ); +} +pub type DISPPARAMS = tagDISPPARAMS; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagEXCEPINFO { + pub wCode: WORD, + pub wReserved: WORD, + pub bstrSource: BSTR, + pub bstrDescription: BSTR, + pub bstrHelpFile: BSTR, + pub dwHelpContext: DWORD, + pub pvReserved: PVOID, + pub pfnDeferredFillIn: + ::std::option::Option HRESULT>, + pub scode: SCODE, +} +#[test] +fn bindgen_test_layout_tagEXCEPINFO() { + assert_eq!( + ::std::mem::size_of::(), + 64usize, + concat!("Size of: ", stringify!(tagEXCEPINFO)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagEXCEPINFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).wCode as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagEXCEPINFO), + "::", + stringify!(wCode) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).wReserved as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(tagEXCEPINFO), + "::", + stringify!(wReserved) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).bstrSource as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagEXCEPINFO), + "::", + stringify!(bstrSource) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).bstrDescription as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(tagEXCEPINFO), + "::", + stringify!(bstrDescription) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).bstrHelpFile as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(tagEXCEPINFO), + "::", + stringify!(bstrHelpFile) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwHelpContext as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(tagEXCEPINFO), + "::", + stringify!(dwHelpContext) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).pvReserved as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(tagEXCEPINFO), + "::", + stringify!(pvReserved) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).pfnDeferredFillIn as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(tagEXCEPINFO), + "::", + stringify!(pfnDeferredFillIn) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).scode as *const _ as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(tagEXCEPINFO), + "::", + stringify!(scode) + ) + ); +} +pub type EXCEPINFO = tagEXCEPINFO; +pub const tagCALLCONV_CC_FASTCALL: tagCALLCONV = 0; +pub const tagCALLCONV_CC_CDECL: tagCALLCONV = 1; +pub const tagCALLCONV_CC_MSCPASCAL: tagCALLCONV = 2; +pub const tagCALLCONV_CC_PASCAL: tagCALLCONV = 2; +pub const tagCALLCONV_CC_MACPASCAL: tagCALLCONV = 3; +pub const tagCALLCONV_CC_STDCALL: tagCALLCONV = 4; +pub const tagCALLCONV_CC_FPFASTCALL: tagCALLCONV = 5; +pub const tagCALLCONV_CC_SYSCALL: tagCALLCONV = 6; +pub const tagCALLCONV_CC_MPWCDECL: tagCALLCONV = 7; +pub const tagCALLCONV_CC_MPWPASCAL: tagCALLCONV = 8; +pub const tagCALLCONV_CC_MAX: tagCALLCONV = 9; +pub type tagCALLCONV = ::std::os::raw::c_int; +pub use self::tagCALLCONV as CALLCONV; +pub const tagFUNCKIND_FUNC_VIRTUAL: tagFUNCKIND = 0; +pub const tagFUNCKIND_FUNC_PUREVIRTUAL: tagFUNCKIND = 1; +pub const tagFUNCKIND_FUNC_NONVIRTUAL: tagFUNCKIND = 2; +pub const tagFUNCKIND_FUNC_STATIC: tagFUNCKIND = 3; +pub const tagFUNCKIND_FUNC_DISPATCH: tagFUNCKIND = 4; +pub type tagFUNCKIND = ::std::os::raw::c_int; +pub use self::tagFUNCKIND as FUNCKIND; +pub const tagINVOKEKIND_INVOKE_FUNC: tagINVOKEKIND = 1; +pub const tagINVOKEKIND_INVOKE_PROPERTYGET: tagINVOKEKIND = 2; +pub const tagINVOKEKIND_INVOKE_PROPERTYPUT: tagINVOKEKIND = 4; +pub const tagINVOKEKIND_INVOKE_PROPERTYPUTREF: tagINVOKEKIND = 8; +pub type tagINVOKEKIND = ::std::os::raw::c_int; +pub use self::tagINVOKEKIND as INVOKEKIND; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct tagFUNCDESC { + pub memid: MEMBERID, + pub lprgscode: *mut SCODE, + pub lprgelemdescParam: *mut ELEMDESC, + pub funckind: FUNCKIND, + pub invkind: INVOKEKIND, + pub callconv: CALLCONV, + pub cParams: SHORT, + pub cParamsOpt: SHORT, + pub oVft: SHORT, + pub cScodes: SHORT, + pub elemdescFunc: ELEMDESC, + pub wFuncFlags: WORD, +} +#[test] +fn bindgen_test_layout_tagFUNCDESC() { + assert_eq!( + ::std::mem::size_of::(), + 88usize, + concat!("Size of: ", stringify!(tagFUNCDESC)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagFUNCDESC)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).memid as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagFUNCDESC), + "::", + stringify!(memid) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lprgscode as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagFUNCDESC), + "::", + stringify!(lprgscode) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lprgelemdescParam as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(tagFUNCDESC), + "::", + stringify!(lprgelemdescParam) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).funckind as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(tagFUNCDESC), + "::", + stringify!(funckind) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).invkind as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(tagFUNCDESC), + "::", + stringify!(invkind) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).callconv as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(tagFUNCDESC), + "::", + stringify!(callconv) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cParams as *const _ as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(tagFUNCDESC), + "::", + stringify!(cParams) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cParamsOpt as *const _ as usize }, + 38usize, + concat!( + "Offset of field: ", + stringify!(tagFUNCDESC), + "::", + stringify!(cParamsOpt) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).oVft as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(tagFUNCDESC), + "::", + stringify!(oVft) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cScodes as *const _ as usize }, + 42usize, + concat!( + "Offset of field: ", + stringify!(tagFUNCDESC), + "::", + stringify!(cScodes) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).elemdescFunc as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(tagFUNCDESC), + "::", + stringify!(elemdescFunc) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).wFuncFlags as *const _ as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(tagFUNCDESC), + "::", + stringify!(wFuncFlags) + ) + ); +} +pub type FUNCDESC = tagFUNCDESC; +pub const tagVARKIND_VAR_PERINSTANCE: tagVARKIND = 0; +pub const tagVARKIND_VAR_STATIC: tagVARKIND = 1; +pub const tagVARKIND_VAR_CONST: tagVARKIND = 2; +pub const tagVARKIND_VAR_DISPATCH: tagVARKIND = 3; +pub type tagVARKIND = ::std::os::raw::c_int; +pub use self::tagVARKIND as VARKIND; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct tagVARDESC { + pub memid: MEMBERID, + pub lpstrSchema: LPOLESTR, + pub __bindgen_anon_1: tagVARDESC__bindgen_ty_1, + pub elemdescVar: ELEMDESC, + pub wVarFlags: WORD, + pub varkind: VARKIND, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union tagVARDESC__bindgen_ty_1 { + pub oInst: ULONG, + pub lpvarValue: *mut VARIANT, + _bindgen_union_align: u64, +} +#[test] +fn bindgen_test_layout_tagVARDESC__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(tagVARDESC__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagVARDESC__bindgen_ty_1)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).oInst as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARDESC__bindgen_ty_1), + "::", + stringify!(oInst) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lpvarValue as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARDESC__bindgen_ty_1), + "::", + stringify!(lpvarValue) + ) + ); +} +#[test] +fn bindgen_test_layout_tagVARDESC() { + assert_eq!( + ::std::mem::size_of::(), + 64usize, + concat!("Size of: ", stringify!(tagVARDESC)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagVARDESC)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).memid as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagVARDESC), + "::", + stringify!(memid) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lpstrSchema as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagVARDESC), + "::", + stringify!(lpstrSchema) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).elemdescVar as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(tagVARDESC), + "::", + stringify!(elemdescVar) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).wVarFlags as *const _ as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(tagVARDESC), + "::", + stringify!(wVarFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).varkind as *const _ as usize }, + 60usize, + concat!( + "Offset of field: ", + stringify!(tagVARDESC), + "::", + stringify!(varkind) + ) + ); +} +pub type VARDESC = tagVARDESC; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct IDispatch { + pub _base: IUnknown, +} +#[test] +fn bindgen_test_layout_IDispatch() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(IDispatch)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(IDispatch)) + ); +} +pub const tagDESCKIND_DESCKIND_NONE: tagDESCKIND = 0; +pub const tagDESCKIND_DESCKIND_FUNCDESC: tagDESCKIND = 1; +pub const tagDESCKIND_DESCKIND_VARDESC: tagDESCKIND = 2; +pub const tagDESCKIND_DESCKIND_TYPECOMP: tagDESCKIND = 3; +pub const tagDESCKIND_DESCKIND_IMPLICITAPPOBJ: tagDESCKIND = 4; +pub const tagDESCKIND_DESCKIND_MAX: tagDESCKIND = 5; +pub type tagDESCKIND = ::std::os::raw::c_int; +pub use self::tagDESCKIND as DESCKIND; +#[repr(C)] +#[derive(Copy, Clone)] +pub union tagBINDPTR { + pub lpfuncdesc: *mut FUNCDESC, + pub lpvardesc: *mut VARDESC, + pub lptcomp: *mut ITypeComp, + _bindgen_union_align: u64, +} +#[test] +fn bindgen_test_layout_tagBINDPTR() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(tagBINDPTR)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagBINDPTR)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lpfuncdesc as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagBINDPTR), + "::", + stringify!(lpfuncdesc) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lpvardesc as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagBINDPTR), + "::", + stringify!(lpvardesc) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lptcomp as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagBINDPTR), + "::", + stringify!(lptcomp) + ) + ); +} +pub type BINDPTR = tagBINDPTR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ITypeComp { + pub _base: IUnknown, +} +#[test] +fn bindgen_test_layout_ITypeComp() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(ITypeComp)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(ITypeComp)) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ITypeInfo { + pub _base: IUnknown, +} +#[test] +fn bindgen_test_layout_ITypeInfo() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(ITypeInfo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(ITypeInfo)) + ); +} +pub const tagSYSKIND_SYS_WIN16: tagSYSKIND = 0; +pub const tagSYSKIND_SYS_WIN32: tagSYSKIND = 1; +pub const tagSYSKIND_SYS_MAC: tagSYSKIND = 2; +pub const tagSYSKIND_SYS_WIN64: tagSYSKIND = 3; +pub type tagSYSKIND = ::std::os::raw::c_int; +pub use self::tagSYSKIND as SYSKIND; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagTLIBATTR { + pub guid: GUID, + pub lcid: LCID, + pub syskind: SYSKIND, + pub wMajorVerNum: WORD, + pub wMinorVerNum: WORD, + pub wLibFlags: WORD, +} +#[test] +fn bindgen_test_layout_tagTLIBATTR() { + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(tagTLIBATTR)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(tagTLIBATTR)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).guid as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagTLIBATTR), + "::", + stringify!(guid) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lcid as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(tagTLIBATTR), + "::", + stringify!(lcid) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).syskind as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(tagTLIBATTR), + "::", + stringify!(syskind) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).wMajorVerNum as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(tagTLIBATTR), + "::", + stringify!(wMajorVerNum) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).wMinorVerNum as *const _ as usize }, + 26usize, + concat!( + "Offset of field: ", + stringify!(tagTLIBATTR), + "::", + stringify!(wMinorVerNum) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).wLibFlags as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(tagTLIBATTR), + "::", + stringify!(wLibFlags) + ) + ); +} +pub type TLIBATTR = tagTLIBATTR; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ITypeLib { + pub _base: IUnknown, +} +#[test] +fn bindgen_test_layout_ITypeLib() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(ITypeLib)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(ITypeLib)) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct IRecordInfo { + pub _base: IUnknown, +} +#[test] +fn bindgen_test_layout_IRecordInfo() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(IRecordInfo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(IRecordInfo)) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagSTATPROPSTG { + pub lpwstrName: LPOLESTR, + pub propid: PROPID, + pub vt: VARTYPE, +} +#[test] +fn bindgen_test_layout_tagSTATPROPSTG() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(tagSTATPROPSTG)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagSTATPROPSTG)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).lpwstrName as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSTATPROPSTG), + "::", + stringify!(lpwstrName) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).propid as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagSTATPROPSTG), + "::", + stringify!(propid) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).vt as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(tagSTATPROPSTG), + "::", + stringify!(vt) + ) + ); +} +pub type STATPROPSTG = tagSTATPROPSTG; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagSTATPROPSETSTG { + pub fmtid: FMTID, + pub clsid: CLSID, + pub grfFlags: DWORD, + pub mtime: FILETIME, + pub ctime: FILETIME, + pub atime: FILETIME, + pub dwOSVersion: DWORD, +} +#[test] +fn bindgen_test_layout_tagSTATPROPSETSTG() { + assert_eq!( + ::std::mem::size_of::(), + 64usize, + concat!("Size of: ", stringify!(tagSTATPROPSETSTG)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(tagSTATPROPSETSTG)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).fmtid as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSTATPROPSETSTG), + "::", + stringify!(fmtid) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).clsid as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(tagSTATPROPSETSTG), + "::", + stringify!(clsid) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).grfFlags as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(tagSTATPROPSETSTG), + "::", + stringify!(grfFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).mtime as *const _ as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(tagSTATPROPSETSTG), + "::", + stringify!(mtime) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).ctime as *const _ as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(tagSTATPROPSETSTG), + "::", + stringify!(ctime) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).atime as *const _ as usize }, + 52usize, + concat!( + "Offset of field: ", + stringify!(tagSTATPROPSETSTG), + "::", + stringify!(atime) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwOSVersion as *const _ as usize }, + 60usize, + concat!( + "Offset of field: ", + stringify!(tagSTATPROPSETSTG), + "::", + stringify!(dwOSVersion) + ) + ); +} +pub type STATPROPSETSTG = tagSTATPROPSETSTG; +pub type STGFMT = DWORD; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagSTGOPTIONS { + pub usVersion: USHORT, + pub reserved: USHORT, + pub ulSectorSize: ULONG, + pub pwcsTemplateFile: *const WCHAR, +} +#[test] +fn bindgen_test_layout_tagSTGOPTIONS() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(tagSTGOPTIONS)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tagSTGOPTIONS)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).usVersion as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSTGOPTIONS), + "::", + stringify!(usVersion) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).reserved as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(tagSTGOPTIONS), + "::", + stringify!(reserved) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).ulSectorSize as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagSTGOPTIONS), + "::", + stringify!(ulSectorSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).pwcsTemplateFile as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tagSTGOPTIONS), + "::", + stringify!(pwcsTemplateFile) + ) + ); +} +pub type STGOPTIONS = tagSTGOPTIONS; +pub const __MIDL_IInternetSecurityManager_0003_SZM_CREATE: __MIDL_IInternetSecurityManager_0003 = 0; +pub const __MIDL_IInternetSecurityManager_0003_SZM_DELETE: __MIDL_IInternetSecurityManager_0003 = 1; +pub type __MIDL_IInternetSecurityManager_0003 = ::std::os::raw::c_int; +pub use self::__MIDL_IInternetSecurityManager_0003 as SZM_FLAGS; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _tagSOFTDISTINFO { + pub cbSize: ULONG, + pub dwFlags: DWORD, + pub dwAdState: DWORD, + pub szTitle: LPWSTR, + pub szAbstract: LPWSTR, + pub szHREF: LPWSTR, + pub dwInstalledVersionMS: DWORD, + pub dwInstalledVersionLS: DWORD, + pub dwUpdateVersionMS: DWORD, + pub dwUpdateVersionLS: DWORD, + pub dwAdvertisedVersionMS: DWORD, + pub dwAdvertisedVersionLS: DWORD, + pub dwReserved: DWORD, +} +#[test] +fn bindgen_test_layout__tagSOFTDISTINFO() { + assert_eq!( + ::std::mem::size_of::<_tagSOFTDISTINFO>(), + 72usize, + concat!("Size of: ", stringify!(_tagSOFTDISTINFO)) + ); + assert_eq!( + ::std::mem::align_of::<_tagSOFTDISTINFO>(), + 8usize, + concat!("Alignment of ", stringify!(_tagSOFTDISTINFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_tagSOFTDISTINFO>())).cbSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_tagSOFTDISTINFO), + "::", + stringify!(cbSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_tagSOFTDISTINFO>())).dwFlags as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_tagSOFTDISTINFO), + "::", + stringify!(dwFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_tagSOFTDISTINFO>())).dwAdState as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_tagSOFTDISTINFO), + "::", + stringify!(dwAdState) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_tagSOFTDISTINFO>())).szTitle as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_tagSOFTDISTINFO), + "::", + stringify!(szTitle) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_tagSOFTDISTINFO>())).szAbstract as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_tagSOFTDISTINFO), + "::", + stringify!(szAbstract) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_tagSOFTDISTINFO>())).szHREF as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_tagSOFTDISTINFO), + "::", + stringify!(szHREF) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_tagSOFTDISTINFO>())).dwInstalledVersionMS as *const _ as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_tagSOFTDISTINFO), + "::", + stringify!(dwInstalledVersionMS) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_tagSOFTDISTINFO>())).dwInstalledVersionLS as *const _ as usize + }, + 44usize, + concat!( + "Offset of field: ", + stringify!(_tagSOFTDISTINFO), + "::", + stringify!(dwInstalledVersionLS) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_tagSOFTDISTINFO>())).dwUpdateVersionMS as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_tagSOFTDISTINFO), + "::", + stringify!(dwUpdateVersionMS) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_tagSOFTDISTINFO>())).dwUpdateVersionLS as *const _ as usize }, + 52usize, + concat!( + "Offset of field: ", + stringify!(_tagSOFTDISTINFO), + "::", + stringify!(dwUpdateVersionLS) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_tagSOFTDISTINFO>())).dwAdvertisedVersionMS as *const _ as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(_tagSOFTDISTINFO), + "::", + stringify!(dwAdvertisedVersionMS) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_tagSOFTDISTINFO>())).dwAdvertisedVersionLS as *const _ as usize + }, + 60usize, + concat!( + "Offset of field: ", + stringify!(_tagSOFTDISTINFO), + "::", + stringify!(dwAdvertisedVersionLS) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_tagSOFTDISTINFO>())).dwReserved as *const _ as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(_tagSOFTDISTINFO), + "::", + stringify!(dwReserved) + ) + ); +} +pub type SOFTDISTINFO = _tagSOFTDISTINFO; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagSERIALIZEDPROPERTYVALUE { + pub dwType: DWORD, + pub rgb: [BYTE; 1usize], +} +#[test] +fn bindgen_test_layout_tagSERIALIZEDPROPERTYVALUE() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(tagSERIALIZEDPROPERTYVALUE)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(tagSERIALIZEDPROPERTYVALUE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwType as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSERIALIZEDPROPERTYVALUE), + "::", + stringify!(dwType) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).rgb as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagSERIALIZEDPROPERTYVALUE), + "::", + stringify!(rgb) + ) + ); +} +pub type SERIALIZEDPROPERTYVALUE = tagSERIALIZEDPROPERTYVALUE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct SERVICE_TRIGGER_CUSTOM_STATE_ID { + pub Data: [DWORD; 2usize], +} +#[test] +fn bindgen_test_layout_SERVICE_TRIGGER_CUSTOM_STATE_ID() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(SERVICE_TRIGGER_CUSTOM_STATE_ID)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(SERVICE_TRIGGER_CUSTOM_STATE_ID)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).Data as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(SERVICE_TRIGGER_CUSTOM_STATE_ID), + "::", + stringify!(Data) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM { + pub u: _SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM__bindgen_ty_1 { + pub CustomStateId: SERVICE_TRIGGER_CUSTOM_STATE_ID, + pub s: _SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM__bindgen_ty_1__bindgen_ty_1, + _bindgen_union_align: [u32; 2usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM__bindgen_ty_1__bindgen_ty_1 { + pub DataOffset: DWORD, + pub Data: [BYTE; 1usize], +} +#[test] +fn bindgen_test_layout__SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM__bindgen_ty_1__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM__bindgen_ty_1__bindgen_ty_1>( + ), + 8usize, + concat!( + "Size of: ", + stringify!(_SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM__bindgen_ty_1__bindgen_ty_1>( + ), + 4usize, + concat!( + "Alignment of ", + stringify!(_SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::< + _SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM__bindgen_ty_1__bindgen_ty_1, + >())) + .DataOffset as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(DataOffset) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::< + _SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM__bindgen_ty_1__bindgen_ty_1, + >())) + .Data as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(Data) + ) + ); +} +#[test] +fn bindgen_test_layout__SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM__bindgen_ty_1>(), + 8usize, + concat!( + "Size of: ", + stringify!(_SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM__bindgen_ty_1>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM__bindgen_ty_1>())) + .CustomStateId as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM__bindgen_ty_1), + "::", + stringify!(CustomStateId) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM__bindgen_ty_1>())).s + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM__bindgen_ty_1), + "::", + stringify!(s) + ) + ); +} +#[test] +fn bindgen_test_layout__SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM>(), + 8usize, + concat!( + "Size of: ", + stringify!(_SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM>())).u as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM), + "::", + stringify!(u) + ) + ); +} +pub type SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM = + _SERVICE_CUSTOM_SYSTEM_STATE_CHANGE_DATA_ITEM; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_DESCRIPTIONA { + pub lpDescription: LPSTR, +} +#[test] +fn bindgen_test_layout__SERVICE_DESCRIPTIONA() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_DESCRIPTIONA>(), + 8usize, + concat!("Size of: ", stringify!(_SERVICE_DESCRIPTIONA)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_DESCRIPTIONA>(), + 8usize, + concat!("Alignment of ", stringify!(_SERVICE_DESCRIPTIONA)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_DESCRIPTIONA>())).lpDescription as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_DESCRIPTIONA), + "::", + stringify!(lpDescription) + ) + ); +} +pub type SERVICE_DESCRIPTIONA = _SERVICE_DESCRIPTIONA; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_DESCRIPTIONW { + pub lpDescription: LPWSTR, +} +#[test] +fn bindgen_test_layout__SERVICE_DESCRIPTIONW() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_DESCRIPTIONW>(), + 8usize, + concat!("Size of: ", stringify!(_SERVICE_DESCRIPTIONW)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_DESCRIPTIONW>(), + 8usize, + concat!("Alignment of ", stringify!(_SERVICE_DESCRIPTIONW)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_DESCRIPTIONW>())).lpDescription as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_DESCRIPTIONW), + "::", + stringify!(lpDescription) + ) + ); +} +pub type SERVICE_DESCRIPTIONW = _SERVICE_DESCRIPTIONW; +pub type SERVICE_DESCRIPTION = SERVICE_DESCRIPTIONW; +pub const _SC_ACTION_TYPE_SC_ACTION_NONE: _SC_ACTION_TYPE = 0; +pub const _SC_ACTION_TYPE_SC_ACTION_RESTART: _SC_ACTION_TYPE = 1; +pub const _SC_ACTION_TYPE_SC_ACTION_REBOOT: _SC_ACTION_TYPE = 2; +pub const _SC_ACTION_TYPE_SC_ACTION_RUN_COMMAND: _SC_ACTION_TYPE = 3; +pub const _SC_ACTION_TYPE_SC_ACTION_OWN_RESTART: _SC_ACTION_TYPE = 4; +pub type _SC_ACTION_TYPE = ::std::os::raw::c_int; +pub use self::_SC_ACTION_TYPE as SC_ACTION_TYPE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SC_ACTION { + pub Type: SC_ACTION_TYPE, + pub Delay: DWORD, +} +#[test] +fn bindgen_test_layout__SC_ACTION() { + assert_eq!( + ::std::mem::size_of::<_SC_ACTION>(), + 8usize, + concat!("Size of: ", stringify!(_SC_ACTION)) + ); + assert_eq!( + ::std::mem::align_of::<_SC_ACTION>(), + 4usize, + concat!("Alignment of ", stringify!(_SC_ACTION)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SC_ACTION>())).Type as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SC_ACTION), + "::", + stringify!(Type) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SC_ACTION>())).Delay as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SC_ACTION), + "::", + stringify!(Delay) + ) + ); +} +pub type SC_ACTION = _SC_ACTION; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_FAILURE_ACTIONSA { + pub dwResetPeriod: DWORD, + pub lpRebootMsg: LPSTR, + pub lpCommand: LPSTR, + pub cActions: DWORD, + pub lpsaActions: *mut SC_ACTION, +} +#[test] +fn bindgen_test_layout__SERVICE_FAILURE_ACTIONSA() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_FAILURE_ACTIONSA>(), + 40usize, + concat!("Size of: ", stringify!(_SERVICE_FAILURE_ACTIONSA)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_FAILURE_ACTIONSA>(), + 8usize, + concat!("Alignment of ", stringify!(_SERVICE_FAILURE_ACTIONSA)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_FAILURE_ACTIONSA>())).dwResetPeriod as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_FAILURE_ACTIONSA), + "::", + stringify!(dwResetPeriod) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_FAILURE_ACTIONSA>())).lpRebootMsg as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_FAILURE_ACTIONSA), + "::", + stringify!(lpRebootMsg) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_FAILURE_ACTIONSA>())).lpCommand as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_FAILURE_ACTIONSA), + "::", + stringify!(lpCommand) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_FAILURE_ACTIONSA>())).cActions as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_FAILURE_ACTIONSA), + "::", + stringify!(cActions) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_FAILURE_ACTIONSA>())).lpsaActions as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_FAILURE_ACTIONSA), + "::", + stringify!(lpsaActions) + ) + ); +} +pub type SERVICE_FAILURE_ACTIONSA = _SERVICE_FAILURE_ACTIONSA; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_FAILURE_ACTIONSW { + pub dwResetPeriod: DWORD, + pub lpRebootMsg: LPWSTR, + pub lpCommand: LPWSTR, + pub cActions: DWORD, + pub lpsaActions: *mut SC_ACTION, +} +#[test] +fn bindgen_test_layout__SERVICE_FAILURE_ACTIONSW() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_FAILURE_ACTIONSW>(), + 40usize, + concat!("Size of: ", stringify!(_SERVICE_FAILURE_ACTIONSW)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_FAILURE_ACTIONSW>(), + 8usize, + concat!("Alignment of ", stringify!(_SERVICE_FAILURE_ACTIONSW)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_FAILURE_ACTIONSW>())).dwResetPeriod as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_FAILURE_ACTIONSW), + "::", + stringify!(dwResetPeriod) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_FAILURE_ACTIONSW>())).lpRebootMsg as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_FAILURE_ACTIONSW), + "::", + stringify!(lpRebootMsg) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_FAILURE_ACTIONSW>())).lpCommand as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_FAILURE_ACTIONSW), + "::", + stringify!(lpCommand) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_FAILURE_ACTIONSW>())).cActions as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_FAILURE_ACTIONSW), + "::", + stringify!(cActions) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_FAILURE_ACTIONSW>())).lpsaActions as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_FAILURE_ACTIONSW), + "::", + stringify!(lpsaActions) + ) + ); +} +pub type SERVICE_FAILURE_ACTIONSW = _SERVICE_FAILURE_ACTIONSW; +pub type SERVICE_FAILURE_ACTIONS = SERVICE_FAILURE_ACTIONSW; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_DELAYED_AUTO_START_INFO { + pub fDelayedAutostart: BOOL, +} +#[test] +fn bindgen_test_layout__SERVICE_DELAYED_AUTO_START_INFO() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_DELAYED_AUTO_START_INFO>(), + 4usize, + concat!("Size of: ", stringify!(_SERVICE_DELAYED_AUTO_START_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_DELAYED_AUTO_START_INFO>(), + 4usize, + concat!( + "Alignment of ", + stringify!(_SERVICE_DELAYED_AUTO_START_INFO) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_DELAYED_AUTO_START_INFO>())).fDelayedAutostart as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_DELAYED_AUTO_START_INFO), + "::", + stringify!(fDelayedAutostart) + ) + ); +} +pub type SERVICE_DELAYED_AUTO_START_INFO = _SERVICE_DELAYED_AUTO_START_INFO; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_FAILURE_ACTIONS_FLAG { + pub fFailureActionsOnNonCrashFailures: BOOL, +} +#[test] +fn bindgen_test_layout__SERVICE_FAILURE_ACTIONS_FLAG() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_FAILURE_ACTIONS_FLAG>(), + 4usize, + concat!("Size of: ", stringify!(_SERVICE_FAILURE_ACTIONS_FLAG)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_FAILURE_ACTIONS_FLAG>(), + 4usize, + concat!("Alignment of ", stringify!(_SERVICE_FAILURE_ACTIONS_FLAG)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_FAILURE_ACTIONS_FLAG>())).fFailureActionsOnNonCrashFailures + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_FAILURE_ACTIONS_FLAG), + "::", + stringify!(fFailureActionsOnNonCrashFailures) + ) + ); +} +pub type SERVICE_FAILURE_ACTIONS_FLAG = _SERVICE_FAILURE_ACTIONS_FLAG; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_SID_INFO { + pub dwServiceSidType: DWORD, +} +#[test] +fn bindgen_test_layout__SERVICE_SID_INFO() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_SID_INFO>(), + 4usize, + concat!("Size of: ", stringify!(_SERVICE_SID_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_SID_INFO>(), + 4usize, + concat!("Alignment of ", stringify!(_SERVICE_SID_INFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_SID_INFO>())).dwServiceSidType as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_SID_INFO), + "::", + stringify!(dwServiceSidType) + ) + ); +} +pub type SERVICE_SID_INFO = _SERVICE_SID_INFO; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_REQUIRED_PRIVILEGES_INFOA { + pub pmszRequiredPrivileges: LPSTR, +} +#[test] +fn bindgen_test_layout__SERVICE_REQUIRED_PRIVILEGES_INFOA() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_REQUIRED_PRIVILEGES_INFOA>(), + 8usize, + concat!("Size of: ", stringify!(_SERVICE_REQUIRED_PRIVILEGES_INFOA)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_REQUIRED_PRIVILEGES_INFOA>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_SERVICE_REQUIRED_PRIVILEGES_INFOA) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_REQUIRED_PRIVILEGES_INFOA>())).pmszRequiredPrivileges + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_REQUIRED_PRIVILEGES_INFOA), + "::", + stringify!(pmszRequiredPrivileges) + ) + ); +} +pub type SERVICE_REQUIRED_PRIVILEGES_INFOA = _SERVICE_REQUIRED_PRIVILEGES_INFOA; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_REQUIRED_PRIVILEGES_INFOW { + pub pmszRequiredPrivileges: LPWSTR, +} +#[test] +fn bindgen_test_layout__SERVICE_REQUIRED_PRIVILEGES_INFOW() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_REQUIRED_PRIVILEGES_INFOW>(), + 8usize, + concat!("Size of: ", stringify!(_SERVICE_REQUIRED_PRIVILEGES_INFOW)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_REQUIRED_PRIVILEGES_INFOW>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_SERVICE_REQUIRED_PRIVILEGES_INFOW) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_REQUIRED_PRIVILEGES_INFOW>())).pmszRequiredPrivileges + as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_REQUIRED_PRIVILEGES_INFOW), + "::", + stringify!(pmszRequiredPrivileges) + ) + ); +} +pub type SERVICE_REQUIRED_PRIVILEGES_INFOW = _SERVICE_REQUIRED_PRIVILEGES_INFOW; +pub type SERVICE_REQUIRED_PRIVILEGES_INFO = SERVICE_REQUIRED_PRIVILEGES_INFOW; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_PRESHUTDOWN_INFO { + pub dwPreshutdownTimeout: DWORD, +} +#[test] +fn bindgen_test_layout__SERVICE_PRESHUTDOWN_INFO() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_PRESHUTDOWN_INFO>(), + 4usize, + concat!("Size of: ", stringify!(_SERVICE_PRESHUTDOWN_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_PRESHUTDOWN_INFO>(), + 4usize, + concat!("Alignment of ", stringify!(_SERVICE_PRESHUTDOWN_INFO)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_PRESHUTDOWN_INFO>())).dwPreshutdownTimeout as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_PRESHUTDOWN_INFO), + "::", + stringify!(dwPreshutdownTimeout) + ) + ); +} +pub type SERVICE_PRESHUTDOWN_INFO = _SERVICE_PRESHUTDOWN_INFO; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_TRIGGER_SPECIFIC_DATA_ITEM { + pub dwDataType: DWORD, + pub cbData: DWORD, + pub pData: PBYTE, +} +#[test] +fn bindgen_test_layout__SERVICE_TRIGGER_SPECIFIC_DATA_ITEM() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_TRIGGER_SPECIFIC_DATA_ITEM>(), + 16usize, + concat!("Size of: ", stringify!(_SERVICE_TRIGGER_SPECIFIC_DATA_ITEM)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_TRIGGER_SPECIFIC_DATA_ITEM>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_SERVICE_TRIGGER_SPECIFIC_DATA_ITEM) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_TRIGGER_SPECIFIC_DATA_ITEM>())).dwDataType as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_TRIGGER_SPECIFIC_DATA_ITEM), + "::", + stringify!(dwDataType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_TRIGGER_SPECIFIC_DATA_ITEM>())).cbData as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_TRIGGER_SPECIFIC_DATA_ITEM), + "::", + stringify!(cbData) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_TRIGGER_SPECIFIC_DATA_ITEM>())).pData as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_TRIGGER_SPECIFIC_DATA_ITEM), + "::", + stringify!(pData) + ) + ); +} +pub type SERVICE_TRIGGER_SPECIFIC_DATA_ITEM = _SERVICE_TRIGGER_SPECIFIC_DATA_ITEM; +pub type PSERVICE_TRIGGER_SPECIFIC_DATA_ITEM = *mut _SERVICE_TRIGGER_SPECIFIC_DATA_ITEM; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_TRIGGER { + pub dwTriggerType: DWORD, + pub dwAction: DWORD, + pub pTriggerSubtype: *mut GUID, + pub cDataItems: DWORD, + pub pDataItems: PSERVICE_TRIGGER_SPECIFIC_DATA_ITEM, +} +#[test] +fn bindgen_test_layout__SERVICE_TRIGGER() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_TRIGGER>(), + 32usize, + concat!("Size of: ", stringify!(_SERVICE_TRIGGER)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_TRIGGER>(), + 8usize, + concat!("Alignment of ", stringify!(_SERVICE_TRIGGER)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_TRIGGER>())).dwTriggerType as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_TRIGGER), + "::", + stringify!(dwTriggerType) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_TRIGGER>())).dwAction as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_TRIGGER), + "::", + stringify!(dwAction) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_TRIGGER>())).pTriggerSubtype as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_TRIGGER), + "::", + stringify!(pTriggerSubtype) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_TRIGGER>())).cDataItems as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_TRIGGER), + "::", + stringify!(cDataItems) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_TRIGGER>())).pDataItems as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_TRIGGER), + "::", + stringify!(pDataItems) + ) + ); +} +pub type SERVICE_TRIGGER = _SERVICE_TRIGGER; +pub type PSERVICE_TRIGGER = *mut _SERVICE_TRIGGER; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_TRIGGER_INFO { + pub cTriggers: DWORD, + pub pTriggers: PSERVICE_TRIGGER, + pub pReserved: PBYTE, +} +#[test] +fn bindgen_test_layout__SERVICE_TRIGGER_INFO() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_TRIGGER_INFO>(), + 24usize, + concat!("Size of: ", stringify!(_SERVICE_TRIGGER_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_TRIGGER_INFO>(), + 8usize, + concat!("Alignment of ", stringify!(_SERVICE_TRIGGER_INFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_TRIGGER_INFO>())).cTriggers as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_TRIGGER_INFO), + "::", + stringify!(cTriggers) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_TRIGGER_INFO>())).pTriggers as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_TRIGGER_INFO), + "::", + stringify!(pTriggers) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_TRIGGER_INFO>())).pReserved as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_TRIGGER_INFO), + "::", + stringify!(pReserved) + ) + ); +} +pub type SERVICE_TRIGGER_INFO = _SERVICE_TRIGGER_INFO; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_PREFERRED_NODE_INFO { + pub usPreferredNode: USHORT, + pub fDelete: BOOLEAN, +} +#[test] +fn bindgen_test_layout__SERVICE_PREFERRED_NODE_INFO() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_PREFERRED_NODE_INFO>(), + 4usize, + concat!("Size of: ", stringify!(_SERVICE_PREFERRED_NODE_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_PREFERRED_NODE_INFO>(), + 2usize, + concat!("Alignment of ", stringify!(_SERVICE_PREFERRED_NODE_INFO)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_PREFERRED_NODE_INFO>())).usPreferredNode as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_PREFERRED_NODE_INFO), + "::", + stringify!(usPreferredNode) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_PREFERRED_NODE_INFO>())).fDelete as *const _ as usize + }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_PREFERRED_NODE_INFO), + "::", + stringify!(fDelete) + ) + ); +} +pub type SERVICE_PREFERRED_NODE_INFO = _SERVICE_PREFERRED_NODE_INFO; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SERVICE_TIMECHANGE_INFO { + pub liNewTime: LARGE_INTEGER, + pub liOldTime: LARGE_INTEGER, +} +#[test] +fn bindgen_test_layout__SERVICE_TIMECHANGE_INFO() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_TIMECHANGE_INFO>(), + 16usize, + concat!("Size of: ", stringify!(_SERVICE_TIMECHANGE_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_TIMECHANGE_INFO>(), + 8usize, + concat!("Alignment of ", stringify!(_SERVICE_TIMECHANGE_INFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_TIMECHANGE_INFO>())).liNewTime as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_TIMECHANGE_INFO), + "::", + stringify!(liNewTime) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_TIMECHANGE_INFO>())).liOldTime as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_TIMECHANGE_INFO), + "::", + stringify!(liOldTime) + ) + ); +} +pub type SERVICE_TIMECHANGE_INFO = _SERVICE_TIMECHANGE_INFO; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_LAUNCH_PROTECTED_INFO { + pub dwLaunchProtected: DWORD, +} +#[test] +fn bindgen_test_layout__SERVICE_LAUNCH_PROTECTED_INFO() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_LAUNCH_PROTECTED_INFO>(), + 4usize, + concat!("Size of: ", stringify!(_SERVICE_LAUNCH_PROTECTED_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_LAUNCH_PROTECTED_INFO>(), + 4usize, + concat!("Alignment of ", stringify!(_SERVICE_LAUNCH_PROTECTED_INFO)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_LAUNCH_PROTECTED_INFO>())).dwLaunchProtected as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_LAUNCH_PROTECTED_INFO), + "::", + stringify!(dwLaunchProtected) + ) + ); +} +pub type SERVICE_LAUNCH_PROTECTED_INFO = _SERVICE_LAUNCH_PROTECTED_INFO; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct SC_HANDLE__ { + pub unused: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_SC_HANDLE__() { + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(SC_HANDLE__)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(SC_HANDLE__)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).unused as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(SC_HANDLE__), + "::", + stringify!(unused) + ) + ); +} +pub type SC_HANDLE = *mut SC_HANDLE__; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct SERVICE_STATUS_HANDLE__ { + pub unused: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_SERVICE_STATUS_HANDLE__() { + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(SERVICE_STATUS_HANDLE__)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(SERVICE_STATUS_HANDLE__)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).unused as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(SERVICE_STATUS_HANDLE__), + "::", + stringify!(unused) + ) + ); +} +pub type SERVICE_STATUS_HANDLE = *mut SERVICE_STATUS_HANDLE__; +pub const _SC_STATUS_TYPE_SC_STATUS_PROCESS_INFO: _SC_STATUS_TYPE = 0; +pub type _SC_STATUS_TYPE = ::std::os::raw::c_int; +pub use self::_SC_STATUS_TYPE as SC_STATUS_TYPE; +pub const _SC_ENUM_TYPE_SC_ENUM_PROCESS_INFO: _SC_ENUM_TYPE = 0; +pub type _SC_ENUM_TYPE = ::std::os::raw::c_int; +pub use self::_SC_ENUM_TYPE as SC_ENUM_TYPE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_STATUS { + pub dwServiceType: DWORD, + pub dwCurrentState: DWORD, + pub dwControlsAccepted: DWORD, + pub dwWin32ExitCode: DWORD, + pub dwServiceSpecificExitCode: DWORD, + pub dwCheckPoint: DWORD, + pub dwWaitHint: DWORD, +} +#[test] +fn bindgen_test_layout__SERVICE_STATUS() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_STATUS>(), + 28usize, + concat!("Size of: ", stringify!(_SERVICE_STATUS)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_STATUS>(), + 4usize, + concat!("Alignment of ", stringify!(_SERVICE_STATUS)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_STATUS>())).dwServiceType as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_STATUS), + "::", + stringify!(dwServiceType) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_STATUS>())).dwCurrentState as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_STATUS), + "::", + stringify!(dwCurrentState) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_STATUS>())).dwControlsAccepted as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_STATUS), + "::", + stringify!(dwControlsAccepted) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_STATUS>())).dwWin32ExitCode as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_STATUS), + "::", + stringify!(dwWin32ExitCode) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_STATUS>())).dwServiceSpecificExitCode as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_STATUS), + "::", + stringify!(dwServiceSpecificExitCode) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_STATUS>())).dwCheckPoint as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_STATUS), + "::", + stringify!(dwCheckPoint) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_STATUS>())).dwWaitHint as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_STATUS), + "::", + stringify!(dwWaitHint) + ) + ); +} +pub type SERVICE_STATUS = _SERVICE_STATUS; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_STATUS_PROCESS { + pub dwServiceType: DWORD, + pub dwCurrentState: DWORD, + pub dwControlsAccepted: DWORD, + pub dwWin32ExitCode: DWORD, + pub dwServiceSpecificExitCode: DWORD, + pub dwCheckPoint: DWORD, + pub dwWaitHint: DWORD, + pub dwProcessId: DWORD, + pub dwServiceFlags: DWORD, +} +#[test] +fn bindgen_test_layout__SERVICE_STATUS_PROCESS() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_STATUS_PROCESS>(), + 36usize, + concat!("Size of: ", stringify!(_SERVICE_STATUS_PROCESS)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_STATUS_PROCESS>(), + 4usize, + concat!("Alignment of ", stringify!(_SERVICE_STATUS_PROCESS)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_STATUS_PROCESS>())).dwServiceType as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_STATUS_PROCESS), + "::", + stringify!(dwServiceType) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_STATUS_PROCESS>())).dwCurrentState as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_STATUS_PROCESS), + "::", + stringify!(dwCurrentState) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_STATUS_PROCESS>())).dwControlsAccepted as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_STATUS_PROCESS), + "::", + stringify!(dwControlsAccepted) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_STATUS_PROCESS>())).dwWin32ExitCode as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_STATUS_PROCESS), + "::", + stringify!(dwWin32ExitCode) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_STATUS_PROCESS>())).dwServiceSpecificExitCode as *const _ + as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_STATUS_PROCESS), + "::", + stringify!(dwServiceSpecificExitCode) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_STATUS_PROCESS>())).dwCheckPoint as *const _ as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_STATUS_PROCESS), + "::", + stringify!(dwCheckPoint) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_STATUS_PROCESS>())).dwWaitHint as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_STATUS_PROCESS), + "::", + stringify!(dwWaitHint) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_STATUS_PROCESS>())).dwProcessId as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_STATUS_PROCESS), + "::", + stringify!(dwProcessId) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_STATUS_PROCESS>())).dwServiceFlags as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_STATUS_PROCESS), + "::", + stringify!(dwServiceFlags) + ) + ); +} +pub type SERVICE_STATUS_PROCESS = _SERVICE_STATUS_PROCESS; +pub type SC_LOCK = LPVOID; +pub type LPSERVICE_MAIN_FUNCTIONW = ::std::option::Option< + unsafe extern "C" fn(dwNumServicesArgs: DWORD, lpServiceArgVectors: *mut LPWSTR), +>; +pub type LPSERVICE_MAIN_FUNCTIONA = ::std::option::Option< + unsafe extern "C" fn(dwNumServicesArgs: DWORD, lpServiceArgVectors: *mut LPSTR), +>; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_TABLE_ENTRYA { + pub lpServiceName: LPSTR, + pub lpServiceProc: LPSERVICE_MAIN_FUNCTIONA, +} +#[test] +fn bindgen_test_layout__SERVICE_TABLE_ENTRYA() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_TABLE_ENTRYA>(), + 16usize, + concat!("Size of: ", stringify!(_SERVICE_TABLE_ENTRYA)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_TABLE_ENTRYA>(), + 8usize, + concat!("Alignment of ", stringify!(_SERVICE_TABLE_ENTRYA)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_TABLE_ENTRYA>())).lpServiceName as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_TABLE_ENTRYA), + "::", + stringify!(lpServiceName) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_TABLE_ENTRYA>())).lpServiceProc as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_TABLE_ENTRYA), + "::", + stringify!(lpServiceProc) + ) + ); +} +pub type SERVICE_TABLE_ENTRYA = _SERVICE_TABLE_ENTRYA; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_TABLE_ENTRYW { + pub lpServiceName: LPWSTR, + pub lpServiceProc: LPSERVICE_MAIN_FUNCTIONW, +} +#[test] +fn bindgen_test_layout__SERVICE_TABLE_ENTRYW() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_TABLE_ENTRYW>(), + 16usize, + concat!("Size of: ", stringify!(_SERVICE_TABLE_ENTRYW)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_TABLE_ENTRYW>(), + 8usize, + concat!("Alignment of ", stringify!(_SERVICE_TABLE_ENTRYW)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_TABLE_ENTRYW>())).lpServiceName as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_TABLE_ENTRYW), + "::", + stringify!(lpServiceName) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_TABLE_ENTRYW>())).lpServiceProc as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_TABLE_ENTRYW), + "::", + stringify!(lpServiceProc) + ) + ); +} +pub type SERVICE_TABLE_ENTRYW = _SERVICE_TABLE_ENTRYW; +pub type SERVICE_TABLE_ENTRY = SERVICE_TABLE_ENTRYW; +pub type PFN_SC_NOTIFY_CALLBACK = ::std::option::Option; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_NOTIFY_1 { + pub dwVersion: DWORD, + pub pfnNotifyCallback: PFN_SC_NOTIFY_CALLBACK, + pub pContext: PVOID, + pub dwNotificationStatus: DWORD, + pub ServiceStatus: SERVICE_STATUS_PROCESS, +} +#[test] +fn bindgen_test_layout__SERVICE_NOTIFY_1() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_NOTIFY_1>(), + 64usize, + concat!("Size of: ", stringify!(_SERVICE_NOTIFY_1)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_NOTIFY_1>(), + 8usize, + concat!("Alignment of ", stringify!(_SERVICE_NOTIFY_1)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_NOTIFY_1>())).dwVersion as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_NOTIFY_1), + "::", + stringify!(dwVersion) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_NOTIFY_1>())).pfnNotifyCallback as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_NOTIFY_1), + "::", + stringify!(pfnNotifyCallback) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_NOTIFY_1>())).pContext as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_NOTIFY_1), + "::", + stringify!(pContext) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_NOTIFY_1>())).dwNotificationStatus as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_NOTIFY_1), + "::", + stringify!(dwNotificationStatus) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_NOTIFY_1>())).ServiceStatus as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_NOTIFY_1), + "::", + stringify!(ServiceStatus) + ) + ); +} +pub type SERVICE_NOTIFY_1 = _SERVICE_NOTIFY_1; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_NOTIFY_2A { + pub dwVersion: DWORD, + pub pfnNotifyCallback: PFN_SC_NOTIFY_CALLBACK, + pub pContext: PVOID, + pub dwNotificationStatus: DWORD, + pub ServiceStatus: SERVICE_STATUS_PROCESS, + pub dwNotificationTriggered: DWORD, + pub pszServiceNames: LPSTR, +} +#[test] +fn bindgen_test_layout__SERVICE_NOTIFY_2A() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_NOTIFY_2A>(), + 80usize, + concat!("Size of: ", stringify!(_SERVICE_NOTIFY_2A)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_NOTIFY_2A>(), + 8usize, + concat!("Alignment of ", stringify!(_SERVICE_NOTIFY_2A)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_NOTIFY_2A>())).dwVersion as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_NOTIFY_2A), + "::", + stringify!(dwVersion) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_NOTIFY_2A>())).pfnNotifyCallback as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_NOTIFY_2A), + "::", + stringify!(pfnNotifyCallback) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_NOTIFY_2A>())).pContext as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_NOTIFY_2A), + "::", + stringify!(pContext) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_NOTIFY_2A>())).dwNotificationStatus as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_NOTIFY_2A), + "::", + stringify!(dwNotificationStatus) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_NOTIFY_2A>())).ServiceStatus as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_NOTIFY_2A), + "::", + stringify!(ServiceStatus) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_NOTIFY_2A>())).dwNotificationTriggered as *const _ as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_NOTIFY_2A), + "::", + stringify!(dwNotificationTriggered) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_NOTIFY_2A>())).pszServiceNames as *const _ as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_NOTIFY_2A), + "::", + stringify!(pszServiceNames) + ) + ); +} +pub type SERVICE_NOTIFY_2A = _SERVICE_NOTIFY_2A; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_NOTIFY_2W { + pub dwVersion: DWORD, + pub pfnNotifyCallback: PFN_SC_NOTIFY_CALLBACK, + pub pContext: PVOID, + pub dwNotificationStatus: DWORD, + pub ServiceStatus: SERVICE_STATUS_PROCESS, + pub dwNotificationTriggered: DWORD, + pub pszServiceNames: LPWSTR, +} +#[test] +fn bindgen_test_layout__SERVICE_NOTIFY_2W() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_NOTIFY_2W>(), + 80usize, + concat!("Size of: ", stringify!(_SERVICE_NOTIFY_2W)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_NOTIFY_2W>(), + 8usize, + concat!("Alignment of ", stringify!(_SERVICE_NOTIFY_2W)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_NOTIFY_2W>())).dwVersion as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_NOTIFY_2W), + "::", + stringify!(dwVersion) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_NOTIFY_2W>())).pfnNotifyCallback as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_NOTIFY_2W), + "::", + stringify!(pfnNotifyCallback) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_NOTIFY_2W>())).pContext as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_NOTIFY_2W), + "::", + stringify!(pContext) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_NOTIFY_2W>())).dwNotificationStatus as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_NOTIFY_2W), + "::", + stringify!(dwNotificationStatus) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_NOTIFY_2W>())).ServiceStatus as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_NOTIFY_2W), + "::", + stringify!(ServiceStatus) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_NOTIFY_2W>())).dwNotificationTriggered as *const _ as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_NOTIFY_2W), + "::", + stringify!(dwNotificationTriggered) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_NOTIFY_2W>())).pszServiceNames as *const _ as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_NOTIFY_2W), + "::", + stringify!(pszServiceNames) + ) + ); +} +pub type SERVICE_NOTIFY_2W = _SERVICE_NOTIFY_2W; +pub type SERVICE_NOTIFY_2 = SERVICE_NOTIFY_2W; +pub type SERVICE_NOTIFYA = SERVICE_NOTIFY_2A; +pub type SERVICE_NOTIFYW = SERVICE_NOTIFY_2W; +pub type SERVICE_NOTIFY = SERVICE_NOTIFYW; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_CONTROL_STATUS_REASON_PARAMSA { + pub dwReason: DWORD, + pub pszComment: LPSTR, + pub ServiceStatus: SERVICE_STATUS_PROCESS, +} +#[test] +fn bindgen_test_layout__SERVICE_CONTROL_STATUS_REASON_PARAMSA() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_CONTROL_STATUS_REASON_PARAMSA>(), + 56usize, + concat!( + "Size of: ", + stringify!(_SERVICE_CONTROL_STATUS_REASON_PARAMSA) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_CONTROL_STATUS_REASON_PARAMSA>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_SERVICE_CONTROL_STATUS_REASON_PARAMSA) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_CONTROL_STATUS_REASON_PARAMSA>())).dwReason as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_CONTROL_STATUS_REASON_PARAMSA), + "::", + stringify!(dwReason) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_CONTROL_STATUS_REASON_PARAMSA>())).pszComment as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_CONTROL_STATUS_REASON_PARAMSA), + "::", + stringify!(pszComment) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_CONTROL_STATUS_REASON_PARAMSA>())).ServiceStatus as *const _ + as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_CONTROL_STATUS_REASON_PARAMSA), + "::", + stringify!(ServiceStatus) + ) + ); +} +pub type SERVICE_CONTROL_STATUS_REASON_PARAMSA = _SERVICE_CONTROL_STATUS_REASON_PARAMSA; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_CONTROL_STATUS_REASON_PARAMSW { + pub dwReason: DWORD, + pub pszComment: LPWSTR, + pub ServiceStatus: SERVICE_STATUS_PROCESS, +} +#[test] +fn bindgen_test_layout__SERVICE_CONTROL_STATUS_REASON_PARAMSW() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_CONTROL_STATUS_REASON_PARAMSW>(), + 56usize, + concat!( + "Size of: ", + stringify!(_SERVICE_CONTROL_STATUS_REASON_PARAMSW) + ) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_CONTROL_STATUS_REASON_PARAMSW>(), + 8usize, + concat!( + "Alignment of ", + stringify!(_SERVICE_CONTROL_STATUS_REASON_PARAMSW) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_CONTROL_STATUS_REASON_PARAMSW>())).dwReason as *const _ + as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_CONTROL_STATUS_REASON_PARAMSW), + "::", + stringify!(dwReason) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_CONTROL_STATUS_REASON_PARAMSW>())).pszComment as *const _ + as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_CONTROL_STATUS_REASON_PARAMSW), + "::", + stringify!(pszComment) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_SERVICE_CONTROL_STATUS_REASON_PARAMSW>())).ServiceStatus as *const _ + as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_CONTROL_STATUS_REASON_PARAMSW), + "::", + stringify!(ServiceStatus) + ) + ); +} +pub type SERVICE_CONTROL_STATUS_REASON_PARAMSW = _SERVICE_CONTROL_STATUS_REASON_PARAMSW; +pub type SERVICE_CONTROL_STATUS_REASON_PARAMS = SERVICE_CONTROL_STATUS_REASON_PARAMSW; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SERVICE_START_REASON { + pub dwReason: DWORD, +} +#[test] +fn bindgen_test_layout__SERVICE_START_REASON() { + assert_eq!( + ::std::mem::size_of::<_SERVICE_START_REASON>(), + 4usize, + concat!("Size of: ", stringify!(_SERVICE_START_REASON)) + ); + assert_eq!( + ::std::mem::align_of::<_SERVICE_START_REASON>(), + 4usize, + concat!("Alignment of ", stringify!(_SERVICE_START_REASON)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SERVICE_START_REASON>())).dwReason as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SERVICE_START_REASON), + "::", + stringify!(dwReason) + ) + ); +} +pub type SERVICE_START_REASON = _SERVICE_START_REASON; +pub const _SC_EVENT_TYPE_SC_EVENT_DATABASE_CHANGE: _SC_EVENT_TYPE = 0; +pub const _SC_EVENT_TYPE_SC_EVENT_PROPERTY_CHANGE: _SC_EVENT_TYPE = 1; +pub const _SC_EVENT_TYPE_SC_EVENT_STATUS_CHANGE: _SC_EVENT_TYPE = 2; +pub type _SC_EVENT_TYPE = ::std::os::raw::c_int; +pub use self::_SC_EVENT_TYPE as SC_EVENT_TYPE; +pub const SERVICE_REGISTRY_STATE_TYPE_ServiceRegistryStateParameters: SERVICE_REGISTRY_STATE_TYPE = + 0; +pub const SERVICE_REGISTRY_STATE_TYPE_ServiceRegistryStatePersistent: SERVICE_REGISTRY_STATE_TYPE = + 1; +pub const SERVICE_REGISTRY_STATE_TYPE_MaxServiceRegistryStateType: SERVICE_REGISTRY_STATE_TYPE = 2; +pub type SERVICE_REGISTRY_STATE_TYPE = ::std::os::raw::c_int; +pub const SERVICE_DIRECTORY_TYPE_ServiceDirectoryPersistentState: SERVICE_DIRECTORY_TYPE = 0; +pub const SERVICE_DIRECTORY_TYPE_ServiceDirectoryTypeMax: SERVICE_DIRECTORY_TYPE = 1; +pub type SERVICE_DIRECTORY_TYPE = ::std::os::raw::c_int; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagSTYLEBUFA { + pub dwStyle: DWORD, + pub szDescription: [CHAR; 32usize], +} +#[test] +fn bindgen_test_layout_tagSTYLEBUFA() { + assert_eq!( + ::std::mem::size_of::(), + 36usize, + concat!("Size of: ", stringify!(tagSTYLEBUFA)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(tagSTYLEBUFA)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwStyle as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSTYLEBUFA), + "::", + stringify!(dwStyle) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).szDescription as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagSTYLEBUFA), + "::", + stringify!(szDescription) + ) + ); +} +pub type STYLEBUFA = tagSTYLEBUFA; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tagSTYLEBUFW { + pub dwStyle: DWORD, + pub szDescription: [WCHAR; 32usize], +} +#[test] +fn bindgen_test_layout_tagSTYLEBUFW() { + assert_eq!( + ::std::mem::size_of::(), + 68usize, + concat!("Size of: ", stringify!(tagSTYLEBUFW)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(tagSTYLEBUFW)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).dwStyle as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tagSTYLEBUFW), + "::", + stringify!(dwStyle) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).szDescription as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tagSTYLEBUFW), + "::", + stringify!(szDescription) + ) + ); +} +pub type STYLEBUFW = tagSTYLEBUFW; +pub type STYLEBUF = STYLEBUFW; +pub const _SFileInfoClass_SFileMpqFileName: _SFileInfoClass = 0; +pub const _SFileInfoClass_SFileMpqStreamBitmap: _SFileInfoClass = 1; +pub const _SFileInfoClass_SFileMpqUserDataOffset: _SFileInfoClass = 2; +pub const _SFileInfoClass_SFileMpqUserDataHeader: _SFileInfoClass = 3; +pub const _SFileInfoClass_SFileMpqUserData: _SFileInfoClass = 4; +pub const _SFileInfoClass_SFileMpqHeaderOffset: _SFileInfoClass = 5; +pub const _SFileInfoClass_SFileMpqHeaderSize: _SFileInfoClass = 6; +pub const _SFileInfoClass_SFileMpqHeader: _SFileInfoClass = 7; +pub const _SFileInfoClass_SFileMpqHetTableOffset: _SFileInfoClass = 8; +pub const _SFileInfoClass_SFileMpqHetTableSize: _SFileInfoClass = 9; +pub const _SFileInfoClass_SFileMpqHetHeader: _SFileInfoClass = 10; +pub const _SFileInfoClass_SFileMpqHetTable: _SFileInfoClass = 11; +pub const _SFileInfoClass_SFileMpqBetTableOffset: _SFileInfoClass = 12; +pub const _SFileInfoClass_SFileMpqBetTableSize: _SFileInfoClass = 13; +pub const _SFileInfoClass_SFileMpqBetHeader: _SFileInfoClass = 14; +pub const _SFileInfoClass_SFileMpqBetTable: _SFileInfoClass = 15; +pub const _SFileInfoClass_SFileMpqHashTableOffset: _SFileInfoClass = 16; +pub const _SFileInfoClass_SFileMpqHashTableSize64: _SFileInfoClass = 17; +pub const _SFileInfoClass_SFileMpqHashTableSize: _SFileInfoClass = 18; +pub const _SFileInfoClass_SFileMpqHashTable: _SFileInfoClass = 19; +pub const _SFileInfoClass_SFileMpqBlockTableOffset: _SFileInfoClass = 20; +pub const _SFileInfoClass_SFileMpqBlockTableSize64: _SFileInfoClass = 21; +pub const _SFileInfoClass_SFileMpqBlockTableSize: _SFileInfoClass = 22; +pub const _SFileInfoClass_SFileMpqBlockTable: _SFileInfoClass = 23; +pub const _SFileInfoClass_SFileMpqHiBlockTableOffset: _SFileInfoClass = 24; +pub const _SFileInfoClass_SFileMpqHiBlockTableSize64: _SFileInfoClass = 25; +pub const _SFileInfoClass_SFileMpqHiBlockTable: _SFileInfoClass = 26; +pub const _SFileInfoClass_SFileMpqSignatures: _SFileInfoClass = 27; +pub const _SFileInfoClass_SFileMpqStrongSignatureOffset: _SFileInfoClass = 28; +pub const _SFileInfoClass_SFileMpqStrongSignatureSize: _SFileInfoClass = 29; +pub const _SFileInfoClass_SFileMpqStrongSignature: _SFileInfoClass = 30; +pub const _SFileInfoClass_SFileMpqArchiveSize64: _SFileInfoClass = 31; +pub const _SFileInfoClass_SFileMpqArchiveSize: _SFileInfoClass = 32; +pub const _SFileInfoClass_SFileMpqMaxFileCount: _SFileInfoClass = 33; +pub const _SFileInfoClass_SFileMpqFileTableSize: _SFileInfoClass = 34; +pub const _SFileInfoClass_SFileMpqSectorSize: _SFileInfoClass = 35; +pub const _SFileInfoClass_SFileMpqNumberOfFiles: _SFileInfoClass = 36; +pub const _SFileInfoClass_SFileMpqRawChunkSize: _SFileInfoClass = 37; +pub const _SFileInfoClass_SFileMpqStreamFlags: _SFileInfoClass = 38; +pub const _SFileInfoClass_SFileMpqFlags: _SFileInfoClass = 39; +pub const _SFileInfoClass_SFileInfoPatchChain: _SFileInfoClass = 40; +pub const _SFileInfoClass_SFileInfoFileEntry: _SFileInfoClass = 41; +pub const _SFileInfoClass_SFileInfoHashEntry: _SFileInfoClass = 42; +pub const _SFileInfoClass_SFileInfoHashIndex: _SFileInfoClass = 43; +pub const _SFileInfoClass_SFileInfoNameHash1: _SFileInfoClass = 44; +pub const _SFileInfoClass_SFileInfoNameHash2: _SFileInfoClass = 45; +pub const _SFileInfoClass_SFileInfoNameHash3: _SFileInfoClass = 46; +pub const _SFileInfoClass_SFileInfoLocale: _SFileInfoClass = 47; +pub const _SFileInfoClass_SFileInfoFileIndex: _SFileInfoClass = 48; +pub const _SFileInfoClass_SFileInfoByteOffset: _SFileInfoClass = 49; +pub const _SFileInfoClass_SFileInfoFileTime: _SFileInfoClass = 50; +pub const _SFileInfoClass_SFileInfoFileSize: _SFileInfoClass = 51; +pub const _SFileInfoClass_SFileInfoCompressedSize: _SFileInfoClass = 52; +pub const _SFileInfoClass_SFileInfoFlags: _SFileInfoClass = 53; +pub const _SFileInfoClass_SFileInfoEncryptionKey: _SFileInfoClass = 54; +pub const _SFileInfoClass_SFileInfoEncryptionKeyRaw: _SFileInfoClass = 55; +pub const _SFileInfoClass_SFileInfoCRC32: _SFileInfoClass = 56; +pub type _SFileInfoClass = ::std::os::raw::c_int; +pub use self::_SFileInfoClass as SFileInfoClass; +pub type SFILE_DOWNLOAD_CALLBACK = ::std::option::Option< + unsafe extern "C" fn( + pvUserData: *mut ::std::os::raw::c_void, + ByteOffset: ULONGLONG, + dwTotalBytes: DWORD, + ), +>; +pub type SFILE_ADDFILE_CALLBACK = ::std::option::Option< + unsafe extern "C" fn( + pvUserData: *mut ::std::os::raw::c_void, + dwBytesWritten: DWORD, + dwTotalBytes: DWORD, + bFinalCall: bool, + ), +>; +pub type SFILE_COMPACT_CALLBACK = ::std::option::Option< + unsafe extern "C" fn( + pvUserData: *mut ::std::os::raw::c_void, + dwWorkType: DWORD, + BytesProcessed: ULONGLONG, + TotalBytes: ULONGLONG, + ), +>; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _SFILE_FIND_DATA { + pub cFileName: [::std::os::raw::c_char; 260usize], + pub szPlainName: *mut ::std::os::raw::c_char, + pub dwHashIndex: DWORD, + pub dwBlockIndex: DWORD, + pub dwFileSize: DWORD, + pub dwFileFlags: DWORD, + pub dwCompSize: DWORD, + pub dwFileTimeLo: DWORD, + pub dwFileTimeHi: DWORD, + pub lcLocale: LCID, +} +#[test] +fn bindgen_test_layout__SFILE_FIND_DATA() { + assert_eq!( + ::std::mem::size_of::<_SFILE_FIND_DATA>(), + 304usize, + concat!("Size of: ", stringify!(_SFILE_FIND_DATA)) + ); + assert_eq!( + ::std::mem::align_of::<_SFILE_FIND_DATA>(), + 8usize, + concat!("Alignment of ", stringify!(_SFILE_FIND_DATA)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).cFileName as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(cFileName) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).szPlainName as *const _ as usize }, + 264usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(szPlainName) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwHashIndex as *const _ as usize }, + 272usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(dwHashIndex) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwBlockIndex as *const _ as usize }, + 276usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(dwBlockIndex) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwFileSize as *const _ as usize }, + 280usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(dwFileSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwFileFlags as *const _ as usize }, + 284usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(dwFileFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwCompSize as *const _ as usize }, + 288usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(dwCompSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwFileTimeLo as *const _ as usize }, + 292usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(dwFileTimeLo) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwFileTimeHi as *const _ as usize }, + 296usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(dwFileTimeHi) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).lcLocale as *const _ as usize }, + 300usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_FIND_DATA), + "::", + stringify!(lcLocale) + ) + ); +} +pub type SFILE_FIND_DATA = _SFILE_FIND_DATA; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _SFILE_CREATE_MPQ { + pub cbSize: DWORD, + pub dwMpqVersion: DWORD, + pub pvUserData: *mut ::std::os::raw::c_void, + pub cbUserData: DWORD, + pub dwStreamFlags: DWORD, + pub dwFileFlags1: DWORD, + pub dwFileFlags2: DWORD, + pub dwFileFlags3: DWORD, + pub dwAttrFlags: DWORD, + pub dwSectorSize: DWORD, + pub dwRawChunkSize: DWORD, + pub dwMaxFileCount: DWORD, +} +#[test] +fn bindgen_test_layout__SFILE_CREATE_MPQ() { + assert_eq!( + ::std::mem::size_of::<_SFILE_CREATE_MPQ>(), + 56usize, + concat!("Size of: ", stringify!(_SFILE_CREATE_MPQ)) + ); + assert_eq!( + ::std::mem::align_of::<_SFILE_CREATE_MPQ>(), + 8usize, + concat!("Alignment of ", stringify!(_SFILE_CREATE_MPQ)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).cbSize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(cbSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwMpqVersion as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwMpqVersion) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).pvUserData as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(pvUserData) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).cbUserData as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(cbUserData) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwStreamFlags as *const _ as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwStreamFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwFileFlags1 as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwFileFlags1) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwFileFlags2 as *const _ as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwFileFlags2) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwFileFlags3 as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwFileFlags3) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwAttrFlags as *const _ as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwAttrFlags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwSectorSize as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwSectorSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwRawChunkSize as *const _ as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwRawChunkSize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwMaxFileCount as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_SFILE_CREATE_MPQ), + "::", + stringify!(dwMaxFileCount) + ) + ); +} +pub type SFILE_CREATE_MPQ = _SFILE_CREATE_MPQ; +pub type PSFILE_CREATE_MPQ = *mut _SFILE_CREATE_MPQ; +pub type SFILESETLOCALE = ::std::option::Option LCID>; +pub type SFILEOPENARCHIVE = ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: DWORD, + arg3: DWORD, + arg4: *mut HANDLE, + ) -> bool, +>; +pub type SFILECLOSEARCHIVE = ::std::option::Option bool>; +pub type SFILEOPENFILEEX = ::std::option::Option< + unsafe extern "C" fn( + arg1: HANDLE, + arg2: *const ::std::os::raw::c_char, + arg3: DWORD, + arg4: *mut HANDLE, + ) -> bool, +>; +pub type SFILECLOSEFILE = ::std::option::Option bool>; +pub type SFILEGETFILESIZE = + ::std::option::Option DWORD>; +pub type SFILESETFILEPOINTER = ::std::option::Option< + unsafe extern "C" fn(arg1: HANDLE, arg2: LONG, arg3: *mut LONG, arg4: DWORD) -> DWORD, +>; +pub type SFILEREADFILE = ::std::option::Option< + unsafe extern "C" fn( + arg1: HANDLE, + arg2: *mut ::std::os::raw::c_void, + arg3: DWORD, + arg4: LPDWORD, + arg5: LPOVERLAPPED, + ) -> bool, +>; +extern "C" { + pub fn SFileGetLocale() -> LCID; +} +extern "C" { + pub fn SFileSetLocale(lcNewLocale: LCID) -> LCID; +} +extern "C" { + pub fn SFileOpenArchive( + szMpqName: *const TCHAR, + dwPriority: DWORD, + dwFlags: DWORD, + phMpq: *mut HANDLE, + ) -> bool; +} +extern "C" { + pub fn SFileCreateArchive( + szMpqName: *const TCHAR, + dwCreateFlags: DWORD, + dwMaxFileCount: DWORD, + phMpq: *mut HANDLE, + ) -> bool; +} +extern "C" { + pub fn SFileCreateArchive2( + szMpqName: *const TCHAR, + pCreateInfo: PSFILE_CREATE_MPQ, + phMpq: *mut HANDLE, + ) -> bool; +} +extern "C" { + pub fn SFileSetDownloadCallback( + hMpq: HANDLE, + DownloadCB: SFILE_DOWNLOAD_CALLBACK, + pvUserData: *mut ::std::os::raw::c_void, + ) -> bool; +} +extern "C" { + pub fn SFileFlushArchive(hMpq: HANDLE) -> bool; +} +extern "C" { + pub fn SFileCloseArchive(hMpq: HANDLE) -> bool; +} +extern "C" { + pub fn SFileAddListFile(hMpq: HANDLE, szListFile: *const TCHAR) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn SFileSetCompactCallback( + hMpq: HANDLE, + CompactCB: SFILE_COMPACT_CALLBACK, + pvUserData: *mut ::std::os::raw::c_void, + ) -> bool; +} +extern "C" { + pub fn SFileCompactArchive(hMpq: HANDLE, szListFile: *const TCHAR, bReserved: bool) -> bool; +} +extern "C" { + pub fn SFileGetMaxFileCount(hMpq: HANDLE) -> DWORD; +} +extern "C" { + pub fn SFileSetMaxFileCount(hMpq: HANDLE, dwMaxFileCount: DWORD) -> bool; +} +extern "C" { + pub fn SFileGetAttributes(hMpq: HANDLE) -> DWORD; +} +extern "C" { + pub fn SFileSetAttributes(hMpq: HANDLE, dwFlags: DWORD) -> bool; +} +extern "C" { + pub fn SFileUpdateFileAttributes(hMpq: HANDLE, szFileName: *const ::std::os::raw::c_char) + -> bool; +} +extern "C" { + pub fn SFileOpenPatchArchive( + hMpq: HANDLE, + szPatchMpqName: *const TCHAR, + szPatchPathPrefix: *const ::std::os::raw::c_char, + dwFlags: DWORD, + ) -> bool; +} +extern "C" { + pub fn SFileIsPatchedArchive(hMpq: HANDLE) -> bool; +} +extern "C" { + pub fn SFileHasFile(hMpq: HANDLE, szFileName: *const ::std::os::raw::c_char) -> bool; +} +extern "C" { + pub fn SFileOpenFileEx( + hMpq: HANDLE, + szFileName: *const ::std::os::raw::c_char, + dwSearchScope: DWORD, + phFile: *mut HANDLE, + ) -> bool; +} +extern "C" { + pub fn SFileGetFileSize(hFile: HANDLE, pdwFileSizeHigh: LPDWORD) -> DWORD; +} +extern "C" { + pub fn SFileSetFilePointer( + hFile: HANDLE, + lFilePos: LONG, + plFilePosHigh: *mut LONG, + dwMoveMethod: DWORD, + ) -> DWORD; +} +extern "C" { + pub fn SFileReadFile( + hFile: HANDLE, + lpBuffer: *mut ::std::os::raw::c_void, + dwToRead: DWORD, + pdwRead: LPDWORD, + lpOverlapped: LPOVERLAPPED, + ) -> bool; +} +extern "C" { + pub fn SFileCloseFile(hFile: HANDLE) -> bool; +} +extern "C" { + pub fn SFileGetFileInfo( + hMpqOrFile: HANDLE, + InfoClass: SFileInfoClass, + pvFileInfo: *mut ::std::os::raw::c_void, + cbFileInfo: DWORD, + pcbLengthNeeded: LPDWORD, + ) -> bool; +} +extern "C" { + pub fn SFileGetFileName(hFile: HANDLE, szFileName: *mut ::std::os::raw::c_char) -> bool; +} +extern "C" { + pub fn SFileFreeFileInfo( + pvFileInfo: *mut ::std::os::raw::c_void, + InfoClass: SFileInfoClass, + ) -> bool; +} +extern "C" { + pub fn SFileExtractFile( + hMpq: HANDLE, + szToExtract: *const ::std::os::raw::c_char, + szExtracted: *const TCHAR, + dwSearchScope: DWORD, + ) -> bool; +} +extern "C" { + pub fn SFileGetFileChecksums( + hMpq: HANDLE, + szFileName: *const ::std::os::raw::c_char, + pdwCrc32: LPDWORD, + pMD5: *mut ::std::os::raw::c_char, + ) -> bool; +} +extern "C" { + pub fn SFileVerifyFile( + hMpq: HANDLE, + szFileName: *const ::std::os::raw::c_char, + dwFlags: DWORD, + ) -> DWORD; +} +extern "C" { + pub fn SFileVerifyRawData( + hMpq: HANDLE, + dwWhatToVerify: DWORD, + szFileName: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn SFileSignArchive(hMpq: HANDLE, dwSignatureType: DWORD) -> bool; +} +extern "C" { + pub fn SFileVerifyArchive(hMpq: HANDLE) -> DWORD; +} +extern "C" { + pub fn SFileFindFirstFile( + hMpq: HANDLE, + szMask: *const ::std::os::raw::c_char, + lpFindFileData: *mut SFILE_FIND_DATA, + szListFile: *const TCHAR, + ) -> HANDLE; +} +extern "C" { + pub fn SFileFindNextFile(hFind: HANDLE, lpFindFileData: *mut SFILE_FIND_DATA) -> bool; +} +extern "C" { + pub fn SFileFindClose(hFind: HANDLE) -> bool; +} +extern "C" { + pub fn SListFileFindFirstFile( + hMpq: HANDLE, + szListFile: *const TCHAR, + szMask: *const ::std::os::raw::c_char, + lpFindFileData: *mut SFILE_FIND_DATA, + ) -> HANDLE; +} +extern "C" { + pub fn SListFileFindNextFile(hFind: HANDLE, lpFindFileData: *mut SFILE_FIND_DATA) -> bool; +} +extern "C" { + pub fn SListFileFindClose(hFind: HANDLE) -> bool; +} +extern "C" { + pub fn SFileEnumLocales( + hMpq: HANDLE, + szFileName: *const ::std::os::raw::c_char, + plcLocales: *mut LCID, + pdwMaxLocales: LPDWORD, + dwSearchScope: DWORD, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn SFileCreateFile( + hMpq: HANDLE, + szArchivedName: *const ::std::os::raw::c_char, + FileTime: ULONGLONG, + dwFileSize: DWORD, + lcLocale: LCID, + dwFlags: DWORD, + phFile: *mut HANDLE, + ) -> bool; +} +extern "C" { + pub fn SFileWriteFile( + hFile: HANDLE, + pvData: *const ::std::os::raw::c_void, + dwSize: DWORD, + dwCompression: DWORD, + ) -> bool; +} +extern "C" { + pub fn SFileFinishFile(hFile: HANDLE) -> bool; +} +extern "C" { + pub fn SFileAddFileEx( + hMpq: HANDLE, + szFileName: *const TCHAR, + szArchivedName: *const ::std::os::raw::c_char, + dwFlags: DWORD, + dwCompression: DWORD, + dwCompressionNext: DWORD, + ) -> bool; +} +extern "C" { + pub fn SFileAddFile( + hMpq: HANDLE, + szFileName: *const TCHAR, + szArchivedName: *const ::std::os::raw::c_char, + dwFlags: DWORD, + ) -> bool; +} +extern "C" { + pub fn SFileAddWave( + hMpq: HANDLE, + szFileName: *const TCHAR, + szArchivedName: *const ::std::os::raw::c_char, + dwFlags: DWORD, + dwQuality: DWORD, + ) -> bool; +} +extern "C" { + pub fn SFileRemoveFile( + hMpq: HANDLE, + szFileName: *const ::std::os::raw::c_char, + dwSearchScope: DWORD, + ) -> bool; +} +extern "C" { + pub fn SFileRenameFile( + hMpq: HANDLE, + szOldFileName: *const ::std::os::raw::c_char, + szNewFileName: *const ::std::os::raw::c_char, + ) -> bool; +} +extern "C" { + pub fn SFileSetFileLocale(hFile: HANDLE, lcNewLocale: LCID) -> bool; +} +extern "C" { + pub fn SFileSetDataCompression(DataCompression: DWORD) -> bool; +} +extern "C" { + pub fn SFileSetAddFileCallback( + hMpq: HANDLE, + AddFileCB: SFILE_ADDFILE_CALLBACK, + pvUserData: *mut ::std::os::raw::c_void, + ) -> bool; +} +extern "C" { + pub fn SCompImplode( + pvOutBuffer: *mut ::std::os::raw::c_void, + pcbOutBuffer: *mut ::std::os::raw::c_int, + pvInBuffer: *mut ::std::os::raw::c_void, + cbInBuffer: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn SCompExplode( + pvOutBuffer: *mut ::std::os::raw::c_void, + pcbOutBuffer: *mut ::std::os::raw::c_int, + pvInBuffer: *mut ::std::os::raw::c_void, + cbInBuffer: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn SCompCompress( + pvOutBuffer: *mut ::std::os::raw::c_void, + pcbOutBuffer: *mut ::std::os::raw::c_int, + pvInBuffer: *mut ::std::os::raw::c_void, + cbInBuffer: ::std::os::raw::c_int, + uCompressionMask: ::std::os::raw::c_uint, + nCmpType: ::std::os::raw::c_int, + nCmpLevel: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn SCompDecompress( + pvOutBuffer: *mut ::std::os::raw::c_void, + pcbOutBuffer: *mut ::std::os::raw::c_int, + pvInBuffer: *mut ::std::os::raw::c_void, + cbInBuffer: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn SCompDecompress2( + pvOutBuffer: *mut ::std::os::raw::c_void, + pcbOutBuffer: *mut ::std::os::raw::c_int, + pvInBuffer: *mut ::std::os::raw::c_void, + cbInBuffer: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} diff --git a/crates/stormlib-sys/src/lib.rs b/crates/stormlib-sys/src/lib.rs new file mode 100644 index 0000000..f296019 --- /dev/null +++ b/crates/stormlib-sys/src/lib.rs @@ -0,0 +1,78 @@ +#![allow(non_camel_case_types, non_snake_case, non_upper_case_globals)] + +#[cfg(target_os = "windows")] +include!("./bindings_windows.rs"); +#[cfg(target_os = "linux")] +include!("./bindings_linux.rs"); +#[cfg(target_os = "macos")] +include!("./bindings_macos.rs"); + +extern "C" { + pub fn SetLastError(dwErrCode: u32); +} +extern "C" { + pub fn GetLastError() -> u32; +} + +#[test] +fn test_w3x() { + use std::ffi::*; + use std::ptr; + + #[cfg(not(target_os = "windows"))] + let path = CString::new("../../samples/test_tft.w3x").unwrap(); + #[cfg(target_os = "windows")] + let path: Vec<_> = { + "../../samples/test_tft.w3x" + .as_bytes() + .iter() + .cloned() + .map(u16::from) + .chain(std::iter::once(0)) + .collect() + }; + + let file = CString::new("war3map.j").unwrap(); + unsafe { + let mut handle: HANDLE = ptr::null_mut(); + let ok = SFileOpenArchive( + path.as_ptr(), + 0, + MPQ_OPEN_NO_LISTFILE | MPQ_OPEN_NO_ATTRIBUTES, + &mut handle as *mut HANDLE, + ); + + assert!(ok); + + let mut file_handle: HANDLE = ptr::null_mut(); + let ok = SFileOpenFileEx(handle, file.as_ptr(), 0, &mut file_handle as *mut HANDLE); + assert!(ok); + + let mut size_high: DWORD = 0; + let size = SFileGetFileSize(file_handle, &mut size_high as *mut DWORD); + assert!(ok); + + println!("file size = {}", size); + + let mut buf = Vec::::with_capacity(size as usize); + buf.resize(buf.capacity(), 0); + + let mut read: DWORD = 0; + let ok = SFileReadFile( + file_handle, + std::mem::transmute(buf.as_mut_ptr()), + size, + &mut read as *mut DWORD, + ptr::null_mut(), + ); + assert!(ok); + + println!("read size = {}", read); + + assert_eq!(buf, std::fs::read("../../samples/war3map.j").unwrap()); + + assert!(SFileCloseFile(file_handle)); + + assert!(SFileCloseArchive(handle)); + } +} diff --git a/crates/stormlib/Cargo.toml b/crates/stormlib/Cargo.toml new file mode 100644 index 0000000..7e48a02 --- /dev/null +++ b/crates/stormlib/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "stormlib" +version = "0.1.1" +authors = ["Flux Xu "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +stormlib-sys = {path = "../stormlib-sys"} +bitflags = "1.2" +libc = "0.2" +thiserror = "1" + +[target.'cfg(windows)'.dependencies] +widestring = "0.4" diff --git a/crates/stormlib/src/constants.rs b/crates/stormlib/src/constants.rs new file mode 100644 index 0000000..39c376d --- /dev/null +++ b/crates/stormlib/src/constants.rs @@ -0,0 +1,27 @@ +use bitflags::bitflags; +use stormlib_sys; + +bitflags! { + pub struct OpenArchiveFlags: u32 { + const STREAM_PROVIDER_PARTIAL = stormlib_sys::STREAM_PROVIDER_PARTIAL; + const STREAM_PROVIDER_MPQE = stormlib_sys::STREAM_PROVIDER_MPQE; + const STREAM_PROVIDER_BLOCK4 = stormlib_sys::STREAM_PROVIDER_BLOCK4; + const STREAM_PROVIDER_MASK = stormlib_sys::STREAM_PROVIDER_MASK; + + const BASE_PROVIDER_FILE = stormlib_sys::BASE_PROVIDER_FILE; + const BASE_PROVIDER_MAP = stormlib_sys::BASE_PROVIDER_MAP ; + const BASE_PROVIDER_HTTP = stormlib_sys::BASE_PROVIDER_HTTP; + const BASE_PROVIDER_MASK = stormlib_sys::BASE_PROVIDER_MASK; + + const STREAM_FLAG_READ_ONLY = stormlib_sys::STREAM_FLAG_READ_ONLY; + const STREAM_FLAG_WRITE_SHARE = stormlib_sys::STREAM_FLAG_WRITE_SHARE; + + const MPQ_OPEN_NO_FLAG = 0; + const MPQ_OPEN_NO_LISTFILE = stormlib_sys::MPQ_OPEN_NO_LISTFILE; + const MPQ_OPEN_NO_ATTRIBUTES = stormlib_sys::MPQ_OPEN_NO_ATTRIBUTES; + const MPQ_OPEN_NO_HEADER_SEARCH = stormlib_sys::MPQ_OPEN_NO_HEADER_SEARCH; + const MPQ_OPEN_FORCE_MPQ_V1 = stormlib_sys::MPQ_OPEN_FORCE_MPQ_V1; + const MPQ_OPEN_CHECK_SECTOR_CRC = stormlib_sys::MPQ_OPEN_CHECK_SECTOR_CRC; + const MPQ_OPEN_READ_ONLY = stormlib_sys::MPQ_OPEN_READ_ONLY; + } +} diff --git a/crates/stormlib/src/error.rs b/crates/stormlib/src/error.rs new file mode 100644 index 0000000..889fcd1 --- /dev/null +++ b/crates/stormlib/src/error.rs @@ -0,0 +1,80 @@ +use thiserror::Error; +use std::ffi::NulError; + +#[derive(Debug)] +pub struct ErrorCode(pub u32); + +#[derive(Error, Debug)] +pub enum StormError { + #[error("FileNotFound")] + FileNotFound, + #[error("AccessDenied")] + AccessDenied, + #[error("InvalidHandle")] + InvalidHandle, + #[error("NotEnoughMemory")] + NotEnoughMemory, + #[error("NotSupported")] + NotSupported, + #[error("InvalidParameter")] + InvalidParameter, + #[cfg(target_os = "windows")] + #[error("NegativeSeek")] + NegativeSeek, + #[error("DiskFull")] + DiskFull, + #[error("AlreadyExists")] + AlreadyExists, + #[error("InsufficientBuffer")] + InsufficientBuffer, + #[error("BadFormat")] + BadFormat, + #[error("NoMoreFiles")] + NoMoreFiles, + #[error("HandleEof")] + HandleEof, + #[error("CanNotComplete")] + CanNotComplete, + #[error("FileCorrupt")] + FileCorrupt, + #[error("UnknownCode({0:?})")] + UnknownCode(ErrorCode), + #[cfg(not(target_os = "windows"))] + #[error("non-utf-8 encoding is not supported")] + NonUtf8, + #[error("an interior nul byte was found")] + InteriorNul, +} + +pub type Result = std::result::Result; + +impl From for StormError { + fn from(ErrorCode(code): ErrorCode) -> Self { + use StormError::*; + match code { + stormlib_sys::ERROR_FILE_NOT_FOUND => FileNotFound, + stormlib_sys::ERROR_ACCESS_DENIED => AccessDenied, + stormlib_sys::ERROR_INVALID_HANDLE => InvalidHandle, + stormlib_sys::ERROR_NOT_ENOUGH_MEMORY => NotEnoughMemory, + stormlib_sys::ERROR_NOT_SUPPORTED => NotSupported, + stormlib_sys::ERROR_INVALID_PARAMETER => InvalidParameter, + #[cfg(target_os = "windows")] + stormlib_sys::ERROR_NEGATIVE_SEEK => NegativeSeek, + stormlib_sys::ERROR_DISK_FULL => DiskFull, + stormlib_sys::ERROR_ALREADY_EXISTS => AlreadyExists, + stormlib_sys::ERROR_INSUFFICIENT_BUFFER => InsufficientBuffer, + stormlib_sys::ERROR_BAD_FORMAT => BadFormat, + stormlib_sys::ERROR_NO_MORE_FILES => NoMoreFiles, + stormlib_sys::ERROR_HANDLE_EOF => HandleEof, + stormlib_sys::ERROR_CAN_NOT_COMPLETE => CanNotComplete, + stormlib_sys::ERROR_FILE_CORRUPT => FileCorrupt, + other => UnknownCode(ErrorCode(other)), + } + } +} + +impl From for StormError { + fn from(_: NulError) -> Self { + StormError::InteriorNul + } +} \ No newline at end of file diff --git a/crates/stormlib/src/lib.rs b/crates/stormlib/src/lib.rs new file mode 100644 index 0000000..4ede574 --- /dev/null +++ b/crates/stormlib/src/lib.rs @@ -0,0 +1,354 @@ +use std::ffi::*; +use std::path::Path; +use std::ptr; +use stormlib_sys::*; + +#[macro_use] +mod util; + +mod constants; +pub use constants::*; + +pub mod error; +use error::*; + +/// MPQ archive +#[derive(Debug)] +pub struct Archive { + handle: HANDLE, +} + +impl Archive { + /// Opens a MPQ archive + pub fn open>(path: P, flags: OpenArchiveFlags) -> Result { + #[cfg(not(target_os = "windows"))] + let cpath = { + let pathstr = path.as_ref().to_str().ok_or_else(|| StormError::NonUtf8)?; + CString::new(pathstr)? + }; + #[cfg(target_os = "windows")] + let cpath = { + use widestring::U16CString; + U16CString::from_os_str(path.as_ref()) + .map_err(|_| StormError::InteriorNul)? + .into_vec() + }; + let mut handle: HANDLE = ptr::null_mut(); + unsafe_try_call!(SFileOpenArchive( + cpath.as_ptr(), + 0, + flags.bits(), + &mut handle as *mut HANDLE, + )); + Ok(Archive { handle }) + } + + pub fn create>(path: P, filecount: usize, use_filelist: bool) -> Result { + #[cfg(not(target_os = "windows"))] + let cpath = { + let pathstr = path.as_ref().to_str().ok_or_else(|| StormError::NonUtf8)?; + CString::new(pathstr)? + }; + #[cfg(target_os = "windows")] + let cpath = { + use widestring::U16CString; + U16CString::from_os_str(path.as_ref()) + .map_err(|_| StormError::InteriorNul)? + .into_vec() + }; + let mut handle: HANDLE = ptr::null_mut(); + let flags = 0; + let dwMpqVersion = (flags & MPQ_CREATE_ARCHIVE_VMASK) >> 24; + let dwStreamFlags = 0; + let mut dwFileFlags1 = if flags & MPQ_CREATE_LISTFILE != 0 { + MPQ_FILE_DEFAULT_INTERNAL + } else { + 0 + }; + let dwFileFlags2 = if flags & MPQ_CREATE_ATTRIBUTES != 0 { + MPQ_FILE_DEFAULT_INTERNAL + } else { + 0 + }; + let dwFileFlags3 = if flags & MPQ_CREATE_SIGNATURE != 0 { + MPQ_FILE_DEFAULT_INTERNAL + } else { + 0 + }; + let mut dwAttrFlags = if flags & MPQ_CREATE_ATTRIBUTES != 0 { + MPQ_ATTRIBUTE_CRC32 | MPQ_ATTRIBUTE_FILETIME | MPQ_ATTRIBUTE_MD5 + } else { + 0 + }; + let dwSectorSize: u32 = if dwMpqVersion >= MPQ_FORMAT_VERSION_3 { + 0x4000 + } else { + 0x1000 + }; + let dwRawChunkSize = if dwMpqVersion >= MPQ_FORMAT_VERSION_4 { + 0x4000 + } else { + 0 + }; + let dwMaxFileCount = filecount; + + if dwMpqVersion >= MPQ_FORMAT_VERSION_3 && flags & MPQ_CREATE_ATTRIBUTES != 0 { + dwAttrFlags |= MPQ_ATTRIBUTE_PATCH_BIT; + } + + if use_filelist { + dwFileFlags1 = MPQ_FILE_DEFAULT_INTERNAL; + } + + let cbSize = ::std::mem::size_of::<_SFILE_CREATE_MPQ>() as u32; + let mut ci = Box::new(_SFILE_CREATE_MPQ { + cbSize, + dwMpqVersion, + pvUserData: ptr::null_mut(), + cbUserData: 0, + dwStreamFlags, + dwFileFlags1, + dwFileFlags2, + dwFileFlags3, + dwAttrFlags, + dwSectorSize, + dwRawChunkSize, + dwMaxFileCount: dwMaxFileCount as u32, + }); + + unsafe_try_call!(SFileCreateArchive2( + cpath.as_ptr(), + &mut *ci, + &mut handle as *mut HANDLE + )); + + Ok(Archive { handle }) + } + + /// Quick check if the file exists within MPQ archive, without opening it + pub fn has_file(&mut self, path: &str) -> Result { + let cpath = CString::new(path)?; + unsafe { + let r = SFileHasFile(self.handle, cpath.as_ptr()); + let err = GetLastError(); + if !r && err != ERROR_FILE_NOT_FOUND { + return Err(From::from(ErrorCode(err))); + } + Ok(r) + } + } + + /// Opens a file from MPQ archive + pub fn open_file<'a>(&'a mut self, path: &str) -> Result> { + let mut file_handle: HANDLE = ptr::null_mut(); + let cpath = CString::new(path)?; + unsafe_try_call!(SFileOpenFileEx( + self.handle, + cpath.as_ptr(), + 0, + &mut file_handle as *mut HANDLE + )); + Ok(File { + archive: self, + file_handle, + size: None, + need_reset: false, + }) + } + + pub fn write_file(&self, file_name: &str, data: &[u8]) -> Result { + let cpath = CString::new(file_name)?; + let mut handle = ptr::null_mut(); + unsafe_try_call!(SFileCreateFile( + self.handle, + cpath.as_ptr(), + 0, + data.len() as u32, + 0, + MPQ_FILE_REPLACEEXISTING, + &mut handle, + )); + unsafe_try_call!(SFileWriteFile( + handle, + data.as_ptr() as *const c_void, + data.len() as u32, + 0 + )); + unsafe_try_call!(SFileFinishFile(handle)); + Ok(true) + } + + pub fn add_file(&mut self, path: &str, local_path: &str) -> Result<()> { + #[cfg(not(target_os = "windows"))] + let clocal_path = { + let pathstr = local_path + .as_ref() + .to_str() + .ok_or_else(|| StormError::NonUtf8)?; + CString::new(pathstr)? + }; + #[cfg(target_os = "windows")] + let clocal_path = { + use widestring::U16CString; + U16CString::from_os_str(local_path) + .map_err(|_| StormError::InteriorNul)? + .into_vec() + }; + let _ = self.remove_file(path); + let cpath = CString::new(path)?; + unsafe_try_call!(SFileAddFileEx( + self.handle, + clocal_path.as_ptr(), + cpath.as_ptr(), + MPQ_FILE_COMPRESS | MPQ_FILE_ENCRYPTED, + MPQ_COMPRESSION_ZLIB, + MPQ_COMPRESSION_NEXT_SAME, + )); + Ok(()) + } + + pub fn remove_file(&mut self, path: &str) -> Result { + let cpath = CString::new(path)?; + unsafe { + let r = SFileRemoveFile(self.handle, cpath.as_ptr(), 0); + let err = GetLastError(); + if !r && err != ERROR_FILE_NOT_FOUND { + return Err(From::from(ErrorCode(err))); + } + Ok(r) + } + } + + pub fn compact(&mut self) -> Result<()> { + unsafe_try_call!(SFileCompactArchive(self.handle, ptr::null_mut(), false)); + Ok(()) + } +} + +impl std::ops::Drop for Archive { + fn drop(&mut self) { + unsafe { + SFileCloseArchive(self.handle); + } + } +} + +/// Opened file +#[derive(Debug)] +pub struct File<'a> { + archive: &'a Archive, + file_handle: HANDLE, + size: Option, + need_reset: bool, +} + +impl<'a> File<'a> { + /// Retrieves a size of the file within archive + pub fn get_size(&mut self) -> Result { + if let Some(size) = self.size.clone() { + Ok(size) + } else { + let mut high: DWORD = 0; + let low = unsafe { SFileGetFileSize(self.file_handle, &mut high as *mut DWORD) }; + if low == SFILE_INVALID_SIZE { + return Err(From::from(ErrorCode(unsafe { GetLastError() }))); + } + let high = (high as u64) << 32; + let size = high | (low as u64); + self.size = Some(size); + return Ok(size); + } + } + + /// Reads all data from the file + pub fn read_all(&mut self) -> Result> { + if self.need_reset { + unsafe { + if SFileSetFilePointer(self.file_handle, 0, ptr::null_mut(), 0) + == SFILE_INVALID_SIZE + { + return Err(From::from(ErrorCode(GetLastError()))); + } + } + } + + let size = self.get_size()?; + let mut buf = Vec::::with_capacity(size as usize); + buf.resize(buf.capacity(), 0); + let mut read: DWORD = 0; + self.need_reset = true; + unsafe_try_call!(SFileReadFile( + self.file_handle, + std::mem::transmute(buf.as_mut_ptr()), + size as u32, + &mut read as *mut DWORD, + ptr::null_mut(), + )); + if (read as u64) < size { + buf.truncate(read as usize); + } + Ok(buf) + } +} + +impl<'a> std::ops::Drop for File<'a> { + fn drop(&mut self) { + unsafe { + SFileCloseFile(self.file_handle); + } + } +} + +#[test] +fn test_read() { + let mut archive = Archive::open( + "../../samples/test_tft.w3x", + OpenArchiveFlags::MPQ_OPEN_NO_LISTFILE | OpenArchiveFlags::MPQ_OPEN_NO_ATTRIBUTES, + ) + .unwrap(); + + assert_eq!(archive.has_file("invalid").unwrap(), false); + assert_eq!(archive.has_file("war3map.j").unwrap(), true); + let mut f = archive.open_file("war3map.j").unwrap(); + assert_eq!(f.get_size().unwrap(), 14115); + assert_eq!( + f.read_all().unwrap(), + std::fs::read("../../samples/war3map.j").unwrap() + ); +} + +#[cfg(target_os = "windows")] +#[test] +fn test_read_unicode() { + use widestring::U16CString; + use std::os::windows::ffi::OsStringExt; + let mut archive = Archive::open( + OsString::from_wide( + &U16CString::from_str("../../samples/中文.w3x") + .unwrap() + .into_vec(), + ), + OpenArchiveFlags::MPQ_OPEN_NO_LISTFILE | OpenArchiveFlags::MPQ_OPEN_NO_ATTRIBUTES, + ) + .unwrap(); + let mut f = archive.open_file("war3map.j").unwrap(); + assert_eq!( + f.read_all().unwrap(), + std::fs::read("../../samples/war3map.j").unwrap() + ); +} + +#[cfg(target_os = "macos")] +#[test] +fn test_read_utf8() { + let mut archive = Archive::open( + "../../samples/中文.w3x", + OpenArchiveFlags::MPQ_OPEN_NO_LISTFILE | OpenArchiveFlags::MPQ_OPEN_NO_ATTRIBUTES, + ) + .unwrap(); + let mut f = archive.open_file("war3map.j").unwrap(); + assert_eq!( + f.read_all().unwrap(), + std::fs::read("../../samples/war3map.j").unwrap() + ); +} diff --git a/crates/stormlib/src/util.rs b/crates/stormlib/src/util.rs new file mode 100644 index 0000000..eb7dc8a --- /dev/null +++ b/crates/stormlib/src/util.rs @@ -0,0 +1,11 @@ +/// Check ffi function call result, propagates the error +macro_rules! unsafe_try_call { + ($r:expr) => { + #[allow(unused_unsafe)] + unsafe { + if !$r { + return Err($crate::error::ErrorCode(stormlib_sys::GetLastError()).into()); + } + } + }; +} diff --git a/libs/ceres-mpq/Cargo.toml b/libs/ceres-mpq/Cargo.toml deleted file mode 100644 index 4cb8fc8..0000000 --- a/libs/ceres-mpq/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "ceres-mpq" -version = "0.1.0" -authors = ["mori"] -edition = "2018" - -[dependencies] -num-derive = "0.2.5" -num-traits = "0.2.6" -storm-sys = {path = "../storm-sys"} -failure = "0.1.5" diff --git a/libs/ceres-mpq/src/lib.rs b/libs/ceres-mpq/src/lib.rs deleted file mode 100644 index 62e0a0e..0000000 --- a/libs/ceres-mpq/src/lib.rs +++ /dev/null @@ -1,356 +0,0 @@ -use std::ffi::{c_void, CString}; -use std::ptr; - -use num_derive::FromPrimitive; -use num_traits::FromPrimitive; - -use failure::Fail; - -use storm_sys as storm; - -#[derive(FromPrimitive, Clone, Copy, Debug)] -pub enum GenericErrorCode { - NoError = 0, - FileNotFound = 2, - AccessDenied = 1, - InvalidHandle = 9, - NotEnoughMemory = 12, - NotSupported = 95, - InvalidParameter = 22, - DiskFull = 28, - AlreadyExists = 17, - InsufficientBuffer = 105, - BadFormat = 1000, - NoMoreFiles = 1001, - HandleEof = 1002, - CanNotComplete = 1003, - FileCorrupt = 1004, - AviFile = 10000, - UnknownFileKey = 10001, - ChecksumError = 10002, - InternalFile = 10003, - BaseFileMissing = 10004, - MarkedForDelete = 10005, - FileIncomplete = 10006, - UnknownFileNames = 10007, - CantFindPatchPrefix = 10008, -} - -#[derive(Debug, Fail)] -pub enum GenericError { - #[fail(display = "Success")] - Success, - #[fail(display = "Error code {:?}", _0)] - ErrorCode(GenericErrorCode), - #[fail(display = "Unknown error code {:?}", _0)] - Unknown(u32), -} - -fn get_last_generic_error() -> GenericError { - let error_code_id = unsafe { storm::GetLastError() }; - - let error_code: Option = FromPrimitive::from_u32(error_code_id); - - if let Some(error_code) = error_code { - match error_code { - GenericErrorCode::NoError => GenericError::Success, - error_code => GenericError::ErrorCode(error_code), - } - } else { - GenericError::Unknown(error_code_id) - } -} - -fn test_for_generic_error() -> Result<(), GenericError> { - let error = get_last_generic_error(); - - if let GenericError::Success = error { - Ok(()) - } else { - Err(error) - } -} - -impl std::string::ToString for GenericErrorCode { - fn to_string(&self) -> String { - match self { - GenericErrorCode::NoError => "No error".into(), - GenericErrorCode::FileNotFound => "File not found".into(), - GenericErrorCode::AccessDenied => "Access denied".into(), - _ => format!("Error Code: {}", *self as u32), - } - } -} - -#[derive(FromPrimitive)] -pub enum SignatureErrorKind { - NoSignature = 0, - VerifyFailed = 1, - WeakSignatureOk = 2, - WeakSignatureError = 3, - StrongSignatureOk = 4, - StrongSignatureError = 5, -} - -pub struct MPQArchive { - handle: storm::HANDLE, -} - -pub struct MPQFile { - handle: storm::HANDLE, -} - -impl MPQArchive { - pub fn open(path: &str, flag: u32) -> Result { - let path = CString::new("flat-file://".to_string() + path).unwrap(); - let path_ptr = path.as_ptr(); - let mut handle = ptr::null_mut(); - - unsafe { - storm::SFileOpenArchive(path_ptr, 0, flag, &mut handle); - } - - test_for_generic_error()?; - - Ok(MPQArchive { handle }) - } - - pub fn create( - path: &str, - filecount: usize, - use_filelist: bool, - ) -> Result { - let path = CString::new(path).unwrap(); - let path_ptr = path.as_ptr(); - let mut handle = ptr::null_mut(); - - let mut flags = 0; - let dwMpqVersion = (flags & storm::MPQ_CREATE_ARCHIVE_VMASK) >> 24; - let dwStreamFlags = 0; - let mut dwFileFlags1 = if flags & storm::MPQ_CREATE_LISTFILE != 0 { - storm::MPQ_FILE_DEFAULT_INTERNAL - } else { - 0 - }; - let dwFileFlags2 = if flags & storm::MPQ_CREATE_ATTRIBUTES != 0 { - storm::MPQ_FILE_DEFAULT_INTERNAL - } else { - 0 - }; - let dwFileFlags3 = if flags & storm::MPQ_CREATE_SIGNATURE != 0 { - storm::MPQ_FILE_DEFAULT_INTERNAL - } else { - 0 - }; - let mut dwAttrFlags = if flags & storm::MPQ_CREATE_ATTRIBUTES != 0 { - storm::MPQ_ATTRIBUTE_CRC32 | storm::MPQ_ATTRIBUTE_FILETIME | storm::MPQ_ATTRIBUTE_MD5 - } else { - 0 - }; - let dwSectorSize = if dwMpqVersion >= storm::MPQ_FORMAT_VERSION_3 { - 0x4000 - } else { - 0x1000 - }; - let dwRawChunkSize = if dwMpqVersion >= storm::MPQ_FORMAT_VERSION_4 { - 0x4000 - } else { - 0 - }; - let dwMaxFileCount = filecount; - - if (dwMpqVersion >= storm::MPQ_FORMAT_VERSION_3 - && flags & storm::MPQ_CREATE_ATTRIBUTES != 0) - { - dwAttrFlags |= storm::MPQ_ATTRIBUTE_PATCH_BIT; - } - - if (use_filelist) { - dwFileFlags1 = storm::MPQ_FILE_DEFAULT_INTERNAL; - } - - unsafe { - let cbSize = ::std::mem::size_of::() as u32; - - let mut ci = Box::new(storm::_SFILE_CREATE_MPQ { - cbSize, - dwMpqVersion, - pvUserData: ptr::null_mut(), - cbUserData: 0, - dwStreamFlags, - dwFileFlags1, - dwFileFlags2, - dwFileFlags3, - dwAttrFlags, - dwSectorSize, - dwRawChunkSize, - dwMaxFileCount: dwMaxFileCount as u32, - }); - - storm::SFileCreateArchive2(path_ptr, &mut *ci, &mut handle); - } - - test_for_generic_error()?; - - Ok(MPQArchive { handle }) - } - - pub fn open_file(&self, file_name: &str) -> Result { - let file_name = CString::new(file_name).unwrap(); - let file_name_ptr = file_name.as_ptr(); - let mut handle = ptr::null_mut(); - - unsafe { - storm::SFileOpenFileEx(self.handle, file_name_ptr, 0, &mut handle); - } - - test_for_generic_error()?; - - Ok(MPQFile { handle }) - } - - pub fn has_file(&self, file_name: &str) -> bool { - let file_name = CString::new(file_name).unwrap(); - let file_name_ptr = file_name.as_ptr(); - - unsafe { - return storm::SFileHasFile(self.handle, file_name_ptr); - } - } - - pub fn get_max_files(&self) -> usize { - unsafe { - let count = storm::SFileGetMaxFileCount(self.handle); - return count as usize; - } - } - - pub fn set_max_files(&self, count: usize) -> bool { - unsafe { - return storm::SFileSetMaxFileCount(self.handle, count as u32); - } - } - - pub fn write_file(&self, file_name: &str, data: &[u8]) -> Result<(), GenericError> { - let file_name = CString::new(file_name).unwrap(); - let file_name_ptr = file_name.as_ptr(); - let mut handle = ptr::null_mut(); - - unsafe { - if !storm::SFileCreateFile( - self.handle, - file_name_ptr, - 0, - data.len() as u32, - 0, - storm::MPQ_FILE_REPLACEEXISTING, - &mut handle, - ) { - test_for_generic_error()?; - } - } - - unsafe { - if !storm::SFileWriteFile(handle, data.as_ptr() as *const c_void, data.len() as u32, 0) - { - test_for_generic_error()?; - } - } - - unsafe { - if !storm::SFileFinishFile(handle) { - test_for_generic_error()?; - } - } - - Ok(()) - } - - pub fn add_file(&self, file_name: &str, file_path:&str) -> Result<(), GenericError> { - - self.remove_file(file_name); - - let file_name = CString::new(file_name).unwrap(); - let file_name_ptr = file_name.as_ptr(); - let file_path = CString::new(file_path).unwrap(); - let file_path_ptr = file_path.as_ptr(); - - unsafe { - if !storm::SFileAddFileEx(self.handle, file_path_ptr, file_name_ptr, storm::MPQ_FILE_COMPRESS |storm::MPQ_FILE_ENCRYPTED, storm::MPQ_COMPRESSION_ZLIB, storm::MPQ_COMPRESSION_NEXT_SAME) - { - test_for_generic_error()?; - } - } - - Ok(()) - } - - pub fn remove_file(&self, file_name: &str) -> bool { - let cfile_name = CString::new(file_name).unwrap(); - let file_name_ptr = cfile_name.as_ptr(); - unsafe { - if self.has_file(file_name){ - return storm::SFileRemoveFile(self.handle, file_name_ptr, 0); - }else{ - return false; - } - } - } - - pub fn compact(&self) -> bool { - unsafe { - return storm::SFileCompactArchive(self.handle, ptr::null_mut(), false); - } - } -} - -impl Drop for MPQArchive { - fn drop(&mut self) { - unsafe { - storm::SFileCloseArchive(self.handle); - } - } -} - -impl MPQFile { - pub fn get_size(&self) -> Result { - let mut file_size_high = 0; - - let file_size_low = unsafe { storm::SFileGetFileSize(self.handle, &mut file_size_high) }; - - test_for_generic_error()?; - - Ok(file_size_low) - } - - pub fn read_contents(&self) -> Result, GenericError> { - let size = self.get_size()?; - let mut buffer: Vec = Vec::new(); - buffer.resize_with(size as usize, || 0); - - let buffer_ptr = buffer.as_mut_ptr() as *mut c_void; - let mut bytes_read: u32 = 0; - - unsafe { - if !storm::SFileReadFile( - self.handle, - buffer_ptr, - size, - &mut bytes_read, - ptr::null_mut(), - ) { - test_for_generic_error()?; - } - } - - Ok(buffer) - } -} - -impl Drop for MPQFile { - fn drop(&mut self) { - unsafe { - storm::SFileCloseFile(self.handle); - } - } -} diff --git a/libs/storm-sys/Cargo.toml b/libs/storm-sys/Cargo.toml deleted file mode 100644 index 159c86e..0000000 --- a/libs/storm-sys/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "storm-sys" -version = "0.1.0" -authors = ["mori"] -edition = "2018" -build = "build.rs" - -[dependencies] - -[build-dependencies] -bindgen = "0.49.0" -cc = { version = "1.0.36", features = ["parallel"] } \ No newline at end of file diff --git a/libs/storm-sys/StormCommon.h b/libs/storm-sys/StormCommon.h deleted file mode 100644 index 9d9f43c..0000000 --- a/libs/storm-sys/StormCommon.h +++ /dev/null @@ -1,385 +0,0 @@ -/*****************************************************************************/ -/* SCommon.h Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Common functions for encryption/decryption from Storm.dll. Included by */ -/* SFile*** functions, do not include and do not use this file directly */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 24.03.03 1.00 Lad The first version of SFileCommon.h */ -/* 12.06.04 1.00 Lad Renamed to SCommon.h */ -/* 06.09.10 1.00 Lad Renamed to StormCommon.h */ -/*****************************************************************************/ - -#ifndef __STORMCOMMON_H__ -#define __STORMCOMMON_H__ - -//----------------------------------------------------------------------------- -// Compression support - -// Include functions from Pkware Data Compression Library -#include "pklib/pklib.h" - -// Include functions from Huffmann compression -#include "huffman/huff.h" - -// Include functions from IMA ADPCM compression -#include "adpcm/adpcm.h" - -// Include functions from SPARSE compression -#include "sparse/sparse.h" - -// Include functions from LZMA compression -#include "lzma/C/LzmaEnc.h" -#include "lzma/C/LzmaDec.h" - -// Include functions from zlib -#ifndef __SYS_ZLIB - #include "zlib/zlib.h" -#else - #include -#endif - -// Include functions from bzlib -#ifndef __SYS_BZLIB - #include "bzip2/bzlib.h" -#else - #include -#endif - -//----------------------------------------------------------------------------- -// Cryptography support - -// Headers from LibTomCrypt -#include "libtomcrypt/src/headers/tomcrypt.h" - -// For HashStringJenkins -#include "jenkins/lookup.h" - -//----------------------------------------------------------------------------- -// StormLib private defines - -#define ID_MPQ_FILE 0x46494c45 // Used internally for checking TMPQFile ('FILE') - -// Prevent problems with CRT "min" and "max" functions, -// as they are not defined on all platforms -#define STORMLIB_MIN(a, b) ((a < b) ? a : b) -#define STORMLIB_MAX(a, b) ((a > b) ? a : b) -#define STORMLIB_UNUSED(p) ((void)(p)) - -// Macro for building 64-bit file offset from two 32-bit -#define MAKE_OFFSET64(hi, lo) (((ULONGLONG)hi << 32) | (ULONGLONG)lo) - -//----------------------------------------------------------------------------- -// MPQ signature information - -// Size of each signature type -#define MPQ_WEAK_SIGNATURE_SIZE 64 -#define MPQ_STRONG_SIGNATURE_SIZE 256 -#define MPQ_STRONG_SIGNATURE_ID 0x5349474E // ID of the strong signature ("NGIS") -#define MPQ_SIGNATURE_FILE_SIZE (MPQ_WEAK_SIGNATURE_SIZE + 8) - -// MPQ signature info -typedef struct _MPQ_SIGNATURE_INFO -{ - ULONGLONG BeginMpqData; // File offset where the hashing starts - ULONGLONG BeginExclude; // Begin of the excluded area (used for (signature) file) - ULONGLONG EndExclude; // End of the excluded area (used for (signature) file) - ULONGLONG EndMpqData; // File offset where the hashing ends - ULONGLONG EndOfFile; // Size of the entire file - BYTE Signature[MPQ_STRONG_SIGNATURE_SIZE + 0x10]; - DWORD cbSignatureSize; // Length of the signature - DWORD SignatureTypes; // See SIGNATURE_TYPE_XXX - -} MPQ_SIGNATURE_INFO, *PMPQ_SIGNATURE_INFO; - -//----------------------------------------------------------------------------- -// Memory management -// -// We use our own macros for allocating/freeing memory. If you want -// to redefine them, please keep the following rules: -// -// - The memory allocation must return NULL if not enough memory -// (i.e not to throw exception) -// - The allocating function does not need to fill the allocated buffer with zeros -// - Memory freeing function doesn't have to test the pointer to NULL -// - -//#if defined(_MSC_VER) && defined(_DEBUG) -// -//#define STORM_ALLOC(type, nitems) (type *)HeapAlloc(GetProcessHeap(), 0, ((nitems) * sizeof(type))) -//#define STORM_REALLOC(type, ptr, nitems) (type *)HeapReAlloc(GetProcessHeap(), 0, ptr, ((nitems) * sizeof(type))) -//#define STORM_FREE(ptr) HeapFree(GetProcessHeap(), 0, ptr) -// -//#else - -#define STORM_ALLOC(type, nitems) (type *)malloc((nitems) * sizeof(type)) -#define STORM_REALLOC(type, ptr, nitems) (type *)realloc(ptr, ((nitems) * sizeof(type))) -#define STORM_FREE(ptr) free(ptr) - -//#endif - -//----------------------------------------------------------------------------- -// StormLib internal global variables - -extern LCID lcFileLocale; // Preferred file locale - -//----------------------------------------------------------------------------- -// Conversion to uppercase/lowercase (and "/" to "\") - -extern unsigned char AsciiToLowerTable[256]; -extern unsigned char AsciiToUpperTable[256]; - -//----------------------------------------------------------------------------- -// Safe string functions - -void StringCopy(char * szTarget, size_t cchTarget, const char * szSource); -void StringCat(char * szTarget, size_t cchTargetMax, const char * szSource); - -#ifdef _UNICODE -void StringCopy(TCHAR * szTarget, size_t cchTarget, const char * szSource); -void StringCopy(char * szTarget, size_t cchTarget, const TCHAR * szSource); -void StringCopy(TCHAR * szTarget, size_t cchTarget, const TCHAR * szSource); -void StringCat(TCHAR * szTarget, size_t cchTargetMax, const TCHAR * szSource); -#endif - -//----------------------------------------------------------------------------- -// Encryption and decryption functions - -#define MPQ_HASH_TABLE_INDEX 0x000 -#define MPQ_HASH_NAME_A 0x100 -#define MPQ_HASH_NAME_B 0x200 -#define MPQ_HASH_FILE_KEY 0x300 -#define MPQ_HASH_KEY2_MIX 0x400 - -DWORD HashString(const char * szFileName, DWORD dwHashType); -DWORD HashStringSlash(const char * szFileName, DWORD dwHashType); -DWORD HashStringLower(const char * szFileName, DWORD dwHashType); - -void InitializeMpqCryptography(); - -DWORD GetNearestPowerOfTwo(DWORD dwFileCount); - -bool IsPseudoFileName(const char * szFileName, LPDWORD pdwFileIndex); -ULONGLONG HashStringJenkins(const char * szFileName); - -DWORD GetDefaultSpecialFileFlags(DWORD dwFileSize, USHORT wFormatVersion); - -void EncryptMpqBlock(void * pvDataBlock, DWORD dwLength, DWORD dwKey); -void DecryptMpqBlock(void * pvDataBlock, DWORD dwLength, DWORD dwKey); - -DWORD DetectFileKeyBySectorSize(LPDWORD EncryptedData, DWORD dwSectorSize, DWORD dwSectorOffsLen); -DWORD DetectFileKeyByContent(void * pvEncryptedData, DWORD dwSectorSize, DWORD dwFileSize); -DWORD DecryptFileKey(const char * szFileName, ULONGLONG MpqPos, DWORD dwFileSize, DWORD dwFlags); - -bool IsValidMD5(LPBYTE pbMd5); -bool IsValidSignature(LPBYTE pbSignature); -bool VerifyDataBlockHash(void * pvDataBlock, DWORD cbDataBlock, LPBYTE expected_md5); -void CalculateDataBlockHash(void * pvDataBlock, DWORD cbDataBlock, LPBYTE md5_hash); - -//----------------------------------------------------------------------------- -// Handle validation functions - -TMPQArchive * IsValidMpqHandle(HANDLE hMpq); -TMPQFile * IsValidFileHandle(HANDLE hFile); - -//----------------------------------------------------------------------------- -// Support for MPQ file tables - -ULONGLONG FileOffsetFromMpqOffset(TMPQArchive * ha, ULONGLONG MpqOffset); -ULONGLONG CalculateRawSectorOffset(TMPQFile * hf, DWORD dwSectorOffset); - -int ConvertMpqHeaderToFormat4(TMPQArchive * ha, ULONGLONG MpqOffset, ULONGLONG FileSize, DWORD dwFlags, bool bIsWarcraft3Map); - -bool IsValidHashEntry(TMPQArchive * ha, TMPQHash * pHash); - -TMPQHash * FindFreeHashEntry(TMPQArchive * ha, DWORD dwStartIndex, DWORD dwName1, DWORD dwName2, LCID lcLocale); -TMPQHash * GetFirstHashEntry(TMPQArchive * ha, const char * szFileName); -TMPQHash * GetNextHashEntry(TMPQArchive * ha, TMPQHash * pFirstHash, TMPQHash * pPrevHash); -TMPQHash * AllocateHashEntry(TMPQArchive * ha, TFileEntry * pFileEntry, LCID lcLocale); - -TMPQExtHeader * LoadExtTable(TMPQArchive * ha, ULONGLONG ByteOffset, size_t Size, DWORD dwSignature, DWORD dwKey); -TMPQHetTable * LoadHetTable(TMPQArchive * ha); -TMPQBetTable * LoadBetTable(TMPQArchive * ha); - -TMPQBlock * LoadBlockTable(TMPQArchive * ha, bool bDontFixEntries = false); -TMPQBlock * TranslateBlockTable(TMPQArchive * ha, ULONGLONG * pcbTableSize, bool * pbNeedHiBlockTable); - -ULONGLONG FindFreeMpqSpace(TMPQArchive * ha); - -// Functions that load the HET and BET tables -int CreateHashTable(TMPQArchive * ha, DWORD dwHashTableSize); -int LoadAnyHashTable(TMPQArchive * ha); -int BuildFileTable(TMPQArchive * ha); -int DefragmentFileTable(TMPQArchive * ha); - -int CreateFileTable(TMPQArchive * ha, DWORD dwFileTableSize); -int RebuildHetTable(TMPQArchive * ha); -int RebuildFileTable(TMPQArchive * ha, DWORD dwNewHashTableSize); -int SaveMPQTables(TMPQArchive * ha); - -TMPQHetTable * CreateHetTable(DWORD dwEntryCount, DWORD dwTotalCount, DWORD dwHashBitSize, LPBYTE pbSrcData); -void FreeHetTable(TMPQHetTable * pHetTable); - -TMPQBetTable * CreateBetTable(DWORD dwMaxFileCount); -void FreeBetTable(TMPQBetTable * pBetTable); - -// Functions for finding files in the file table -TFileEntry * GetFileEntryLocale2(TMPQArchive * ha, const char * szFileName, LCID lcLocale, LPDWORD PtrHashIndex); -TFileEntry * GetFileEntryLocale(TMPQArchive * ha, const char * szFileName, LCID lcLocale); -TFileEntry * GetFileEntryExact(TMPQArchive * ha, const char * szFileName, LCID lcLocale, LPDWORD PtrHashIndex); - -// Allocates file name in the file entry -void AllocateFileName(TMPQArchive * ha, TFileEntry * pFileEntry, const char * szFileName); - -// Allocates new file entry in the MPQ tables. Reuses existing, if possible -TFileEntry * AllocateFileEntry(TMPQArchive * ha, const char * szFileName, LCID lcLocale, LPDWORD PtrHashIndex); -int RenameFileEntry(TMPQArchive * ha, TMPQFile * hf, const char * szNewFileName); -int DeleteFileEntry(TMPQArchive * ha, TMPQFile * hf); - -// Invalidates entries for (listfile) and (attributes) -void InvalidateInternalFiles(TMPQArchive * ha); - -// Retrieves information about the strong signature -bool QueryMpqSignatureInfo(TMPQArchive * ha, PMPQ_SIGNATURE_INFO pSignatureInfo); - -//----------------------------------------------------------------------------- -// Support for alternate file formats (SBaseSubTypes.cpp) - -int ConvertSqpHeaderToFormat4(TMPQArchive * ha, ULONGLONG FileSize, DWORD dwFlags); -TMPQHash * LoadSqpHashTable(TMPQArchive * ha); -TMPQBlock * LoadSqpBlockTable(TMPQArchive * ha); - -int ConvertMpkHeaderToFormat4(TMPQArchive * ha, ULONGLONG FileSize, DWORD dwFlags); -void DecryptMpkTable(void * pvMpkTable, size_t cbSize); -TMPQHash * LoadMpkHashTable(TMPQArchive * ha); -TMPQBlock * LoadMpkBlockTable(TMPQArchive * ha); -int SCompDecompressMpk(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer); - -//----------------------------------------------------------------------------- -// Common functions - MPQ File - -TMPQFile * CreateFileHandle(TMPQArchive * ha, TFileEntry * pFileEntry); -TMPQFile * CreateWritableHandle(TMPQArchive * ha, DWORD dwFileSize); -void * LoadMpqTable(TMPQArchive * ha, ULONGLONG ByteOffset, DWORD dwCompressedSize, DWORD dwRealSize, DWORD dwKey, bool * pbTableIsCut); -int AllocateSectorBuffer(TMPQFile * hf); -int AllocatePatchInfo(TMPQFile * hf, bool bLoadFromFile); -int AllocateSectorOffsets(TMPQFile * hf, bool bLoadFromFile); -int AllocateSectorChecksums(TMPQFile * hf, bool bLoadFromFile); -int WritePatchInfo(TMPQFile * hf); -int WriteSectorOffsets(TMPQFile * hf); -int WriteSectorChecksums(TMPQFile * hf); -int WriteMemDataMD5(TFileStream * pStream, ULONGLONG RawDataOffs, void * pvRawData, DWORD dwRawDataSize, DWORD dwChunkSize, LPDWORD pcbTotalSize); -int WriteMpqDataMD5(TFileStream * pStream, ULONGLONG RawDataOffs, DWORD dwRawDataSize, DWORD dwChunkSize); -void FreeFileHandle(TMPQFile *& hf); -void FreeArchiveHandle(TMPQArchive *& ha); - -//----------------------------------------------------------------------------- -// Patch functions - -// Structure used for the patching process -typedef struct _TMPQPatcher -{ - BYTE this_md5[MD5_DIGEST_SIZE]; // MD5 of the current file state - LPBYTE pbFileData1; // Primary working buffer - LPBYTE pbFileData2; // Secondary working buffer - DWORD cbMaxFileData; // Maximum allowed size of the patch data - DWORD cbFileData; // Current size of the result data - DWORD nCounter; // Counter of the patch process - -} TMPQPatcher; - -bool IsIncrementalPatchFile(const void * pvData, DWORD cbData, LPDWORD pdwPatchedFileSize); -int Patch_InitPatcher(TMPQPatcher * pPatcher, TMPQFile * hf); -int Patch_Process(TMPQPatcher * pPatcher, TMPQFile * hf); -void Patch_Finalize(TMPQPatcher * pPatcher); - -//----------------------------------------------------------------------------- -// Utility functions - -bool CheckWildCard(const char * szString, const char * szWildCard); -bool IsInternalMpqFileName(const char * szFileName); - -template -const XCHAR * GetPlainFileName(const XCHAR * szFileName) -{ - const XCHAR * szPlainName = szFileName; - - while(*szFileName != 0) - { - if(*szFileName == '\\' || *szFileName == '/') - szPlainName = szFileName + 1; - szFileName++; - } - - return szPlainName; -} - -//----------------------------------------------------------------------------- -// Internal support for MPQ modifications - -int SFileAddFile_Init( - TMPQArchive * ha, - const char * szArchivedName, - ULONGLONG ft, - DWORD dwFileSize, - LCID lcLocale, - DWORD dwFlags, - TMPQFile ** phf - ); - -int SFileAddFile_Init( - TMPQArchive * ha, - TMPQFile * hfSrc, - TMPQFile ** phf - ); - -int SFileAddFile_Write( - TMPQFile * hf, - const void * pvData, - DWORD dwSize, - DWORD dwCompression - ); - -int SFileAddFile_Finish( - TMPQFile * hf - ); - -//----------------------------------------------------------------------------- -// Attributes support - -int SAttrLoadAttributes(TMPQArchive * ha); -int SAttrFileSaveToMpq(TMPQArchive * ha); - -//----------------------------------------------------------------------------- -// Listfile functions - -int SListFileSaveToMpq(TMPQArchive * ha); - -//----------------------------------------------------------------------------- -// Weak signature support - -int SSignFileCreate(TMPQArchive * ha); -int SSignFileFinish(TMPQArchive * ha); - -//----------------------------------------------------------------------------- -// Dump data support - -#ifdef __STORMLIB_DUMP_DATA__ - -void DumpMpqHeader(TMPQHeader * pHeader); -void DumpHashTable(TMPQHash * pHashTable, DWORD dwHashTableSize); -void DumpHetAndBetTable(TMPQHetTable * pHetTable, TMPQBetTable * pBetTable); -void DumpFileTable(TFileEntry * pFileTable, DWORD dwFileTableSize); - -#else - -#define DumpMpqHeader(h) /* */ -#define DumpHashTable(t, s) /* */ -#define DumpHetAndBetTable(t, s) /* */ -#define DumpFileTable(t, s) /* */ - -#endif - -#endif // __STORMCOMMON_H__ - diff --git a/libs/storm-sys/StormLib.h b/libs/storm-sys/StormLib.h deleted file mode 100644 index 31f6eda..0000000 --- a/libs/storm-sys/StormLib.h +++ /dev/null @@ -1,1124 +0,0 @@ -/*****************************************************************************/ -/* StormLib.h Copyright (c) Ladislav Zezula 1999-2017 */ -/*---------------------------------------------------------------------------*/ -/* StormLib library v 9.22 */ -/* */ -/* Author : Ladislav Zezula */ -/* E-mail : ladik@zezula.net */ -/* WWW : http://www.zezula.net */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* xx.xx.99 1.00 Lad Created */ -/* 24.03.03 2.50 Lad Version 2.50 */ -/* 02.04.03 3.00 Lad Version 3.00 with compression */ -/* 11.04.03 3.01 Lad Renamed to StormLib.h for compatibility with */ -/* original headers for Storm.dll */ -/* 10.05.03 3.02 Lad Added Pkware DCL compression */ -/* 26.05.03 4.00 Lad Completed all compressions */ -/* 18.06.03 4.01 Lad Added SFileSetFileLocale */ -/* Added SFileExtractFile */ -/* 26.07.03 4.02 Lad Implemented nameless rename and delete */ -/* 26.07.03 4.03 Lad Added support for protected MPQs */ -/* 28.08.03 4.10 Lad Fixed bugs that caused StormLib incorrectly work */ -/* with Diablo I savegames and with files having full */ -/* hash table */ -/* 08.12.03 4.11 DCH Fixed bug in reading file sector larger than 0x1000 */ -/* on certain files. */ -/* Fixed bug in AddFile with MPQ_FILE_REPLACE_EXISTING */ -/* (Thanx Daniel Chiamarello, dchiamarello@madvawes.com)*/ -/* 21.12.03 4.50 Lad Completed port for Mac */ -/* Fixed bug in compacting (if fsize is mul of 0x1000) */ -/* Fixed bug in SCompCompress */ -/* 27.05.04 4.51 Lad Changed memory management from new/delete to our */ -/* own macros */ -/* 22.06.04 4.60 Lad Optimized search. Support for multiple listfiles. */ -/* 30.09.04 4.61 Lad Fixed some bugs (Aaargh !!!) */ -/* Correctly works if HashTableSize > BlockTableSize */ -/* 29.12.04 4.70 Lad Fixed compatibility problem with MPQs from WoW */ -/* 14.07.05 5.00 Lad Added the BZLIB compression support */ -/* Added suport of files stored as single unit */ -/* 17.04.06 5.01 Lad Converted to MS Visual Studio 8.0 */ -/* Fixed issue with protected Warcraft 3 protected maps */ -/* 15.05.06 5.02 Lad Fixed issue with WoW 1.10+ */ -/* 07.09.06 5.10 Lad Fixed processing files longer than 2GB */ -/* 22.11.06 6.00 Lad Support for MPQ archives V2 */ -/* 12.06.07 6.10 Lad Support for (attributes) file */ -/* 10.09.07 6.12 Lad Support for MPQs protected by corrupting hash table */ -/* 03.12.07 6.13 Lad Support for MPQs with hash tbl size > block tbl size */ -/* 07.04.08 6.20 Lad Added SFileFlushArchive */ -/* 09.04.08 Lad Removed FilePointer variable from MPQ handle */ -/* structure, as it caused more problems than benefits */ -/* 12.05.08 6.22 Lad Support for w3xMaster map protector */ -/* 05.10.08 6.23 Lad Support for protectors who set negative values in */ -/* the table of file blocks */ -/* 26.05.09 6.24 Lad Fixed search for multiple lang files with deleted */ -/* entries */ -/* 03.09.09 6.25 Lad Fixed decompression bug in huffmann decompression */ -/* 22.03.10 6.50 Lad New compressions in Starcraft II (LZMA, sparse) */ -/* Fixed compacting MPQs that contain single unit files */ -/* 26.04.10 7.00 Lad Major rewrite */ -/* 08.06.10 7.10 Lad Support for partial MPQs */ -/* 08.07.10 7.11 Lad Support for MPQs v 3.0 */ -/* 20.08.10 7.20 Lad Support for opening multiple MPQs in patch mode */ -/* 20.09.10 8.00 Lad MPQs v 4, HET and BET tables */ -/* 07.01.11 8.01 Lad Write support for MPQs v 3 and 4 */ -/* 15.09.11 8.04 Lad Bug fixes, testing for Diablo III MPQs */ -/* 26.04.12 8.10 Lad Support for data map, added SFileGetArchiveBitmap */ -/* 29.05.12 8.20 Lad C-only interface */ -/* 14.01.13 8.21 Lad ADPCM and Huffmann (de)compression refactored */ -/* 04.12.13 9.00 Lad Unit tests, bug fixes */ -/* 27.08.14 9.10 Lad Signing archives with weak digital signature */ -/* 25.11.14 9.11 Lad Fixed bug reading & creating HET table */ -/* 18.09.15 9.20 Lad Release 9.20 */ -/* 12.12.16 9.21 Lad Release 9.21 */ -/* 10.11.17 9.22 Lad Release 9.22 */ -/*****************************************************************************/ - -#ifndef __STORMLIB_H__ -#define __STORMLIB_H__ - -#ifdef _MSC_VER -#pragma warning(disable:4668) // 'XXX' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' -#pragma warning(disable:4820) // 'XXX' : '2' bytes padding added after data member 'XXX::yyy' -#endif - -#include "StormPort.h" - -#ifdef __cplusplus -extern "C" { -#endif - -//----------------------------------------------------------------------------- -// Use the apropriate library -// -// The library type is encoded in the library name as the following -// StormLibXYZ.lib -// -// X - D for Debug version, R for Release version -// Y - A for ANSI version, U for Unicode version -// Z - S for static-linked CRT library, D for multithreaded DLL CRT library -// - -#if defined(__STORMLIB_SELF__) && !defined(STORMLIB_NO_AUTO_LINK) -#define STORMLIB_NO_AUTO_LINK // Define this if you don't want to link using pragmas when using msvc -#endif - -#if defined(_MSC_VER) && !defined(STORMLIB_NO_AUTO_LINK) - #ifdef _DEBUG // DEBUG VERSIONS - #ifndef _UNICODE - #ifdef _DLL - #pragma comment(lib, "StormLibDAD.lib") // Debug Ansi CRT-DLL version - #else - #pragma comment(lib, "StormLibDAS.lib") // Debug Ansi CRT-LIB version - #endif - #else - #ifdef _DLL - #pragma comment(lib, "StormLibDUD.lib") // Debug Unicode CRT-DLL version - #else - #pragma comment(lib, "StormLibDUS.lib") // Debug Unicode CRT-LIB version - #endif - #endif - #else // RELEASE VERSIONS - #ifndef _UNICODE - #ifdef _DLL - #pragma comment(lib, "StormLibRAD.lib") // Release Ansi CRT-DLL version - #else - #pragma comment(lib, "StormLibRAS.lib") // Release Ansi CRT-LIB version - #endif - #else - #ifdef _DLL - #pragma comment(lib, "StormLibRUD.lib") // Release Unicode CRT-DLL version - #else - #pragma comment(lib, "StormLibRUS.lib") // Release Unicode CRT-LIB version - #endif - #endif - #endif - -#endif - -//----------------------------------------------------------------------------- -// Defines - -#define STORMLIB_VERSION 0x0916 // Current version of StormLib (9.21) -#define STORMLIB_VERSION_STRING "9.22" // String version of StormLib version - -#define ID_MPQ 0x1A51504D // MPQ archive header ID ('MPQ\x1A') -#define ID_MPQ_USERDATA 0x1B51504D // MPQ userdata entry ('MPQ\x1B') -#define ID_MPK 0x1A4B504D // MPK archive header ID ('MPK\x1A') - -#define ERROR_AVI_FILE 10000 // Not a MPQ file, but an AVI file. -#define ERROR_UNKNOWN_FILE_KEY 10001 // Returned by SFileReadFile when can't find file key -#define ERROR_CHECKSUM_ERROR 10002 // Returned by SFileReadFile when sector CRC doesn't match -#define ERROR_INTERNAL_FILE 10003 // The given operation is not allowed on internal file -#define ERROR_BASE_FILE_MISSING 10004 // The file is present as incremental patch file, but base file is missing -#define ERROR_MARKED_FOR_DELETE 10005 // The file was marked as "deleted" in the MPQ -#define ERROR_FILE_INCOMPLETE 10006 // The required file part is missing -#define ERROR_UNKNOWN_FILE_NAMES 10007 // A name of at least one file is unknown -#define ERROR_CANT_FIND_PATCH_PREFIX 10008 // StormLib was unable to find patch prefix for the patches - -// Values for SFileCreateArchive -#define HASH_TABLE_SIZE_MIN 0x00000004 // Verified: If there is 1 file, hash table size is 4 -#define HASH_TABLE_SIZE_DEFAULT 0x00001000 // Default hash table size for empty MPQs -#define HASH_TABLE_SIZE_MAX 0x00080000 // Maximum acceptable hash table size - -#define HASH_ENTRY_DELETED 0xFFFFFFFE // Block index for deleted entry in the hash table -#define HASH_ENTRY_FREE 0xFFFFFFFF // Block index for free entry in the hash table - -#define HET_ENTRY_DELETED 0x80 // NameHash1 value for a deleted entry -#define HET_ENTRY_FREE 0x00 // NameHash1 value for free entry - -#define HASH_STATE_SIZE 0x60 // Size of LibTomCrypt's hash_state structure - -// Values for SFileOpenArchive -#define SFILE_OPEN_HARD_DISK_FILE 2 // Open the archive on HDD -#define SFILE_OPEN_CDROM_FILE 3 // Open the archive only if it is on CDROM - -// Values for SFileOpenFile -#define SFILE_OPEN_FROM_MPQ 0x00000000 // Open the file from the MPQ archive -#define SFILE_OPEN_CHECK_EXISTS 0xFFFFFFFC // Only check whether the file exists -#define SFILE_OPEN_BASE_FILE 0xFFFFFFFD // Reserved for StormLib internal use -#define SFILE_OPEN_ANY_LOCALE 0xFFFFFFFE // Reserved for StormLib internal use -#define SFILE_OPEN_LOCAL_FILE 0xFFFFFFFF // Open a local file - -// Flags for TMPQArchive::dwFlags. Used internally -#define MPQ_FLAG_READ_ONLY 0x00000001 // If set, the MPQ has been open for read-only access -#define MPQ_FLAG_CHANGED 0x00000002 // If set, the MPQ tables have been changed -#define MPQ_FLAG_MALFORMED 0x00000004 // Malformed data structure detected (W3M map protectors) -#define MPQ_FLAG_HASH_TABLE_CUT 0x00000008 // The hash table goes beyond EOF -#define MPQ_FLAG_BLOCK_TABLE_CUT 0x00000010 // The hash table goes beyond EOF -#define MPQ_FLAG_CHECK_SECTOR_CRC 0x00000020 // Checking sector CRC when reading files -#define MPQ_FLAG_SAVING_TABLES 0x00000040 // If set, we are saving MPQ internal files and MPQ tables -#define MPQ_FLAG_PATCH 0x00000080 // If set, this MPQ is a patch archive -#define MPQ_FLAG_WAR3_MAP 0x00000100 // If set, this MPQ is a map for Warcraft III -#define MPQ_FLAG_LISTFILE_NONE 0x00000200 // Set when no (listfile) was found in InvalidateInternalFiles -#define MPQ_FLAG_LISTFILE_NEW 0x00000400 // Set when (listfile) invalidated by InvalidateInternalFiles -#define MPQ_FLAG_LISTFILE_FORCE 0x00000800 // Save updated listfile on exit -#define MPQ_FLAG_ATTRIBUTES_NONE 0x00001000 // Set when no (attributes) was found in InvalidateInternalFiles -#define MPQ_FLAG_ATTRIBUTES_NEW 0x00002000 // Set when (attributes) invalidated by InvalidateInternalFiles -#define MPQ_FLAG_SIGNATURE_NONE 0x00004000 // Set when no (signature) was found in InvalidateInternalFiles -#define MPQ_FLAG_SIGNATURE_NEW 0x00008000 // Set when (signature) invalidated by InvalidateInternalFiles - -// Values for TMPQArchive::dwSubType -#define MPQ_SUBTYPE_MPQ 0x00000000 // The file is a MPQ file (Blizzard games) -#define MPQ_SUBTYPE_SQP 0x00000001 // The file is a SQP file (War of the Immortals) -#define MPQ_SUBTYPE_MPK 0x00000002 // The file is a MPK file (Longwu Online) - -// Return value for SFileGetFileSize and SFileSetFilePointer -#define SFILE_INVALID_SIZE 0xFFFFFFFF -#define SFILE_INVALID_POS 0xFFFFFFFF -#define SFILE_INVALID_ATTRIBUTES 0xFFFFFFFF - -// Flags for SFileAddFile -#define MPQ_FILE_IMPLODE 0x00000100 // Implode method (By PKWARE Data Compression Library) -#define MPQ_FILE_COMPRESS 0x00000200 // Compress methods (By multiple methods) -#define MPQ_FILE_ENCRYPTED 0x00010000 // Indicates whether file is encrypted -#define MPQ_FILE_FIX_KEY 0x00020000 // File decryption key has to be fixed -#define MPQ_FILE_PATCH_FILE 0x00100000 // The file is a patch file. Raw file data begin with TPatchInfo structure -#define MPQ_FILE_SINGLE_UNIT 0x01000000 // File is stored as a single unit, rather than split into sectors (Thx, Quantam) -#define MPQ_FILE_DELETE_MARKER 0x02000000 // File is a deletion marker. Used in MPQ patches, indicating that the file no longer exists. -#define MPQ_FILE_SECTOR_CRC 0x04000000 // File has checksums for each sector. - // Ignored if file is not compressed or imploded. -#define MPQ_FILE_SIGNATURE 0x10000000 // Present on STANDARD.SNP\(signature). The only occurence ever observed -#define MPQ_FILE_EXISTS 0x80000000 // Set if file exists, reset when the file was deleted -#define MPQ_FILE_REPLACEEXISTING 0x80000000 // Replace when the file exist (SFileAddFile) - -#define MPQ_FILE_COMPRESS_MASK 0x0000FF00 // Mask for a file being compressed - -#define MPQ_FILE_DEFAULT_INTERNAL 0xFFFFFFFF // Use default flags for internal files - -#define MPQ_FILE_VALID_FLAGS (MPQ_FILE_IMPLODE | \ - MPQ_FILE_COMPRESS | \ - MPQ_FILE_ENCRYPTED | \ - MPQ_FILE_FIX_KEY | \ - MPQ_FILE_PATCH_FILE | \ - MPQ_FILE_SINGLE_UNIT | \ - MPQ_FILE_DELETE_MARKER | \ - MPQ_FILE_SECTOR_CRC | \ - MPQ_FILE_SIGNATURE | \ - MPQ_FILE_EXISTS) - -#define MPQ_FILE_VALID_FLAGS_W3X (MPQ_FILE_IMPLODE | \ - MPQ_FILE_COMPRESS | \ - MPQ_FILE_ENCRYPTED | \ - MPQ_FILE_FIX_KEY | \ - MPQ_FILE_DELETE_MARKER | \ - MPQ_FILE_SECTOR_CRC | \ - MPQ_FILE_SIGNATURE | \ - MPQ_FILE_EXISTS) - -// We need to mask out the upper 4 bits of the block table index. -// This is because it gets shifted out when calculating block table offset -// BlockTableOffset = pHash->dwBlockIndex << 0x04 -// Malformed MPQ maps may contain block indexes like 0x40000001 or 0xF0000023 -#define BLOCK_INDEX_MASK 0x0FFFFFFF -#define MPQ_BLOCK_INDEX(pHash) (pHash->dwBlockIndex & BLOCK_INDEX_MASK) - -// Compression types for multiple compressions -#define MPQ_COMPRESSION_HUFFMANN 0x01 // Huffmann compression (used on WAVE files only) -#define MPQ_COMPRESSION_ZLIB 0x02 // ZLIB compression -#define MPQ_COMPRESSION_PKWARE 0x08 // PKWARE DCL compression -#define MPQ_COMPRESSION_BZIP2 0x10 // BZIP2 compression (added in Warcraft III) -#define MPQ_COMPRESSION_SPARSE 0x20 // Sparse compression (added in Starcraft 2) -#define MPQ_COMPRESSION_ADPCM_MONO 0x40 // IMA ADPCM compression (mono) -#define MPQ_COMPRESSION_ADPCM_STEREO 0x80 // IMA ADPCM compression (stereo) -#define MPQ_COMPRESSION_LZMA 0x12 // LZMA compression. Added in Starcraft 2. This value is NOT a combination of flags. -#define MPQ_COMPRESSION_NEXT_SAME 0xFFFFFFFF // Same compression - -// Constants for SFileAddWave -#define MPQ_WAVE_QUALITY_HIGH 0 // Best quality, the worst compression -#define MPQ_WAVE_QUALITY_MEDIUM 1 // Medium quality, medium compression -#define MPQ_WAVE_QUALITY_LOW 2 // Low quality, the best compression - -// Signatures for HET and BET table -#define HET_TABLE_SIGNATURE 0x1A544548 // 'HET\x1a' -#define BET_TABLE_SIGNATURE 0x1A544542 // 'BET\x1a' - -// Decryption keys for MPQ tables -#define MPQ_KEY_HASH_TABLE 0xC3AF3770 // Obtained by HashString("(hash table)", MPQ_HASH_FILE_KEY) -#define MPQ_KEY_BLOCK_TABLE 0xEC83B3A3 // Obtained by HashString("(block table)", MPQ_HASH_FILE_KEY) - -#define LISTFILE_NAME "(listfile)" // Name of internal listfile -#define SIGNATURE_NAME "(signature)" // Name of internal signature -#define ATTRIBUTES_NAME "(attributes)" // Name of internal attributes file -#define PATCH_METADATA_NAME "(patch_metadata)" - -#define MPQ_FORMAT_VERSION_1 0 // Up to The Burning Crusade -#define MPQ_FORMAT_VERSION_2 1 // The Burning Crusade and newer -#define MPQ_FORMAT_VERSION_3 2 // WoW Cataclysm Beta -#define MPQ_FORMAT_VERSION_4 3 // WoW Cataclysm and newer - -// Flags for MPQ attributes -#define MPQ_ATTRIBUTE_CRC32 0x00000001 // The "(attributes)" contains CRC32 for each file -#define MPQ_ATTRIBUTE_FILETIME 0x00000002 // The "(attributes)" contains file time for each file -#define MPQ_ATTRIBUTE_MD5 0x00000004 // The "(attributes)" contains MD5 for each file -#define MPQ_ATTRIBUTE_PATCH_BIT 0x00000008 // The "(attributes)" contains a patch bit for each file -#define MPQ_ATTRIBUTE_ALL 0x0000000F // Summary mask - -#define MPQ_ATTRIBUTES_V1 100 // (attributes) format version 1.00 - -// Flags for SFileOpenArchive -#define BASE_PROVIDER_FILE 0x00000000 // Base data source is a file -#define BASE_PROVIDER_MAP 0x00000001 // Base data source is memory-mapped file -#define BASE_PROVIDER_HTTP 0x00000002 // Base data source is a file on web server -#define BASE_PROVIDER_MASK 0x0000000F // Mask for base provider value - -#define STREAM_PROVIDER_FLAT 0x00000000 // Stream is linear with no offset mapping -#define STREAM_PROVIDER_PARTIAL 0x00000010 // Stream is partial file (.part) -#define STREAM_PROVIDER_MPQE 0x00000020 // Stream is an encrypted MPQ -#define STREAM_PROVIDER_BLOCK4 0x00000030 // 0x4000 per block, text MD5 after each block, max 0x2000 blocks per file -#define STREAM_PROVIDER_MASK 0x000000F0 // Mask for stream provider value - -#define STREAM_FLAG_READ_ONLY 0x00000100 // Stream is read only -#define STREAM_FLAG_WRITE_SHARE 0x00000200 // Allow write sharing when open for write -#define STREAM_FLAG_USE_BITMAP 0x00000400 // If the file has a file bitmap, load it and use it -#define STREAM_OPTIONS_MASK 0x0000FF00 // Mask for stream options - -#define STREAM_PROVIDERS_MASK 0x000000FF // Mask to get stream providers -#define STREAM_FLAGS_MASK 0x0000FFFF // Mask for all stream flags (providers+options) - -#define MPQ_OPEN_NO_LISTFILE 0x00010000 // Don't load the internal listfile -#define MPQ_OPEN_NO_ATTRIBUTES 0x00020000 // Don't open the attributes -#define MPQ_OPEN_NO_HEADER_SEARCH 0x00040000 // Don't search for the MPQ header past the begin of the file -#define MPQ_OPEN_FORCE_MPQ_V1 0x00080000 // Always open the archive as MPQ v 1.00, ignore the "wFormatVersion" variable in the header -#define MPQ_OPEN_CHECK_SECTOR_CRC 0x00100000 // On files with MPQ_FILE_SECTOR_CRC, the CRC will be checked when reading file -#define MPQ_OPEN_PATCH 0x00200000 // This archive is a patch MPQ. Used internally. -#define MPQ_OPEN_FORCE_LISTFILE 0x00400000 // Force add listfile even if there is none at the moment of opening -#define MPQ_OPEN_READ_ONLY STREAM_FLAG_READ_ONLY - -// Flags for SFileCreateArchive -#define MPQ_CREATE_LISTFILE 0x00100000 // Also add the (listfile) file -#define MPQ_CREATE_ATTRIBUTES 0x00200000 // Also add the (attributes) file -#define MPQ_CREATE_SIGNATURE 0x00400000 // Also add the (signature) file -#define MPQ_CREATE_ARCHIVE_V1 0x00000000 // Creates archive of version 1 (size up to 4GB) -#define MPQ_CREATE_ARCHIVE_V2 0x01000000 // Creates archive of version 2 (larger than 4 GB) -#define MPQ_CREATE_ARCHIVE_V3 0x02000000 // Creates archive of version 3 -#define MPQ_CREATE_ARCHIVE_V4 0x03000000 // Creates archive of version 4 -#define MPQ_CREATE_ARCHIVE_VMASK 0x0F000000 // Mask for archive version - -#define FLAGS_TO_FORMAT_SHIFT 24 // (MPQ_CREATE_ARCHIVE_V4 >> FLAGS_TO_FORMAT_SHIFT) => MPQ_FORMAT_VERSION_4 - -// Flags for SFileVerifyFile -#define SFILE_VERIFY_SECTOR_CRC 0x00000001 // Verify sector checksum for the file, if available -#define SFILE_VERIFY_FILE_CRC 0x00000002 // Verify file CRC, if available -#define SFILE_VERIFY_FILE_MD5 0x00000004 // Verify file MD5, if available -#define SFILE_VERIFY_RAW_MD5 0x00000008 // Verify raw file MD5, if available -#define SFILE_VERIFY_ALL 0x0000000F // Verify every checksum possible - -// Return values for SFileVerifyFile -#define VERIFY_OPEN_ERROR 0x0001 // Failed to open the file -#define VERIFY_READ_ERROR 0x0002 // Failed to read all data from the file -#define VERIFY_FILE_HAS_SECTOR_CRC 0x0004 // File has sector CRC -#define VERIFY_FILE_SECTOR_CRC_ERROR 0x0008 // Sector CRC check failed -#define VERIFY_FILE_HAS_CHECKSUM 0x0010 // File has CRC32 -#define VERIFY_FILE_CHECKSUM_ERROR 0x0020 // CRC32 check failed -#define VERIFY_FILE_HAS_MD5 0x0040 // File has data MD5 -#define VERIFY_FILE_MD5_ERROR 0x0080 // MD5 check failed -#define VERIFY_FILE_HAS_RAW_MD5 0x0100 // File has raw data MD5 -#define VERIFY_FILE_RAW_MD5_ERROR 0x0200 // Raw MD5 check failed -#define VERIFY_FILE_ERROR_MASK (VERIFY_OPEN_ERROR | VERIFY_READ_ERROR | VERIFY_FILE_SECTOR_CRC_ERROR | VERIFY_FILE_CHECKSUM_ERROR | VERIFY_FILE_MD5_ERROR | VERIFY_FILE_RAW_MD5_ERROR) - -// Flags for SFileVerifyRawData (for MPQs version 4.0 or higher) -#define SFILE_VERIFY_MPQ_HEADER 0x0001 // Verify raw MPQ header -#define SFILE_VERIFY_HET_TABLE 0x0002 // Verify raw data of the HET table -#define SFILE_VERIFY_BET_TABLE 0x0003 // Verify raw data of the BET table -#define SFILE_VERIFY_HASH_TABLE 0x0004 // Verify raw data of the hash table -#define SFILE_VERIFY_BLOCK_TABLE 0x0005 // Verify raw data of the block table -#define SFILE_VERIFY_HIBLOCK_TABLE 0x0006 // Verify raw data of the hi-block table -#define SFILE_VERIFY_FILE 0x0007 // Verify raw data of a file - -// Signature types -#define SIGNATURE_TYPE_NONE 0x0000 // The archive has no signature in it -#define SIGNATURE_TYPE_WEAK 0x0001 // The archive has weak signature -#define SIGNATURE_TYPE_STRONG 0x0002 // The archive has strong signature - -// Return values for SFileVerifyArchive -#define ERROR_NO_SIGNATURE 0 // There is no signature in the MPQ -#define ERROR_VERIFY_FAILED 1 // There was an error during verifying signature (like no memory) -#define ERROR_WEAK_SIGNATURE_OK 2 // There is a weak signature and sign check passed -#define ERROR_WEAK_SIGNATURE_ERROR 3 // There is a weak signature but sign check failed -#define ERROR_STRONG_SIGNATURE_OK 4 // There is a strong signature and sign check passed -#define ERROR_STRONG_SIGNATURE_ERROR 5 // There is a strong signature but sign check failed - -#ifndef MD5_DIGEST_SIZE -#define MD5_DIGEST_SIZE 0x10 -#endif - -#ifndef SHA1_DIGEST_SIZE -#define SHA1_DIGEST_SIZE 0x14 // 160 bits -#endif - -#ifndef LANG_NEUTRAL -#define LANG_NEUTRAL 0x00 // Neutral locale -#endif - -// Pointer to hashing function -typedef DWORD (*HASH_STRING)(const char * szFileName, DWORD dwHashType); - -//----------------------------------------------------------------------------- -// File information classes for SFileGetFileInfo and SFileFreeFileInfo - -typedef enum _SFileInfoClass -{ - // Info classes for archives - SFileMpqFileName, // Name of the archive file (TCHAR []) - SFileMpqStreamBitmap, // Array of bits, each bit means availability of one block (BYTE []) - SFileMpqUserDataOffset, // Offset of the user data header (ULONGLONG) - SFileMpqUserDataHeader, // Raw (unfixed) user data header (TMPQUserData) - SFileMpqUserData, // MPQ USer data, without the header (BYTE []) - SFileMpqHeaderOffset, // Offset of the MPQ header (ULONGLONG) - SFileMpqHeaderSize, // Fixed size of the MPQ header - SFileMpqHeader, // Raw (unfixed) archive header (TMPQHeader) - SFileMpqHetTableOffset, // Offset of the HET table, relative to MPQ header (ULONGLONG) - SFileMpqHetTableSize, // Compressed size of the HET table (ULONGLONG) - SFileMpqHetHeader, // HET table header (TMPQHetHeader) - SFileMpqHetTable, // HET table as pointer. Must be freed using SFileFreeFileInfo - SFileMpqBetTableOffset, // Offset of the BET table, relative to MPQ header (ULONGLONG) - SFileMpqBetTableSize, // Compressed size of the BET table (ULONGLONG) - SFileMpqBetHeader, // BET table header, followed by the flags (TMPQBetHeader + DWORD[]) - SFileMpqBetTable, // BET table as pointer. Must be freed using SFileFreeFileInfo - SFileMpqHashTableOffset, // Hash table offset, relative to MPQ header (ULONGLONG) - SFileMpqHashTableSize64, // Compressed size of the hash table (ULONGLONG) - SFileMpqHashTableSize, // Size of the hash table, in entries (DWORD) - SFileMpqHashTable, // Raw (unfixed) hash table (TMPQBlock []) - SFileMpqBlockTableOffset, // Block table offset, relative to MPQ header (ULONGLONG) - SFileMpqBlockTableSize64, // Compressed size of the block table (ULONGLONG) - SFileMpqBlockTableSize, // Size of the block table, in entries (DWORD) - SFileMpqBlockTable, // Raw (unfixed) block table (TMPQBlock []) - SFileMpqHiBlockTableOffset, // Hi-block table offset, relative to MPQ header (ULONGLONG) - SFileMpqHiBlockTableSize64, // Compressed size of the hi-block table (ULONGLONG) - SFileMpqHiBlockTable, // The hi-block table (USHORT []) - SFileMpqSignatures, // Signatures present in the MPQ (DWORD) - SFileMpqStrongSignatureOffset, // Byte offset of the strong signature, relative to begin of the file (ULONGLONG) - SFileMpqStrongSignatureSize, // Size of the strong signature (DWORD) - SFileMpqStrongSignature, // The strong signature (BYTE []) - SFileMpqArchiveSize64, // Archive size from the header (ULONGLONG) - SFileMpqArchiveSize, // Archive size from the header (DWORD) - SFileMpqMaxFileCount, // Max number of files in the archive (DWORD) - SFileMpqFileTableSize, // Number of entries in the file table (DWORD) - SFileMpqSectorSize, // Sector size (DWORD) - SFileMpqNumberOfFiles, // Number of files (DWORD) - SFileMpqRawChunkSize, // Size of the raw data chunk for MD5 - SFileMpqStreamFlags, // Stream flags (DWORD) - SFileMpqFlags, // Nonzero if the MPQ is read only (DWORD) - - // Info classes for files - SFileInfoPatchChain, // Chain of patches where the file is (TCHAR []) - SFileInfoFileEntry, // The file entry for the file (TFileEntry) - SFileInfoHashEntry, // Hash table entry for the file (TMPQHash) - SFileInfoHashIndex, // Index of the hash table entry (DWORD) - SFileInfoNameHash1, // The first name hash in the hash table (DWORD) - SFileInfoNameHash2, // The second name hash in the hash table (DWORD) - SFileInfoNameHash3, // 64-bit file name hash for the HET/BET tables (ULONGLONG) - SFileInfoLocale, // File locale (DWORD) - SFileInfoFileIndex, // Block index (DWORD) - SFileInfoByteOffset, // File position in the archive (ULONGLONG) - SFileInfoFileTime, // File time (ULONGLONG) - SFileInfoFileSize, // Size of the file (DWORD) - SFileInfoCompressedSize, // Compressed file size (DWORD) - SFileInfoFlags, // File flags from (DWORD) - SFileInfoEncryptionKey, // File encryption key - SFileInfoEncryptionKeyRaw, // Unfixed value of the file key - SFileInfoCRC32, // CRC32 of the file -} SFileInfoClass; - -//----------------------------------------------------------------------------- -// Callback functions - -// Values for compact callback -#define CCB_CHECKING_FILES 1 // Checking archive (dwParam1 = current, dwParam2 = total) -#define CCB_CHECKING_HASH_TABLE 2 // Checking hash table (dwParam1 = current, dwParam2 = total) -#define CCB_COPYING_NON_MPQ_DATA 3 // Copying non-MPQ data: No params used -#define CCB_COMPACTING_FILES 4 // Compacting archive (dwParam1 = current, dwParam2 = total) -#define CCB_CLOSING_ARCHIVE 5 // Closing archive: No params used - -typedef void (WINAPI * SFILE_DOWNLOAD_CALLBACK)(void * pvUserData, ULONGLONG ByteOffset, DWORD dwTotalBytes); -typedef void (WINAPI * SFILE_ADDFILE_CALLBACK)(void * pvUserData, DWORD dwBytesWritten, DWORD dwTotalBytes, bool bFinalCall); -typedef void (WINAPI * SFILE_COMPACT_CALLBACK)(void * pvUserData, DWORD dwWorkType, ULONGLONG BytesProcessed, ULONGLONG TotalBytes); - -typedef struct TFileStream TFileStream; - -//----------------------------------------------------------------------------- -// Structure for bit arrays used for HET and BET tables - -typedef struct _TBitArray -{ - DWORD NumberOfBytes; // Total number of bytes in "Elements" - DWORD NumberOfBits; // Total number of bits that are available - BYTE Elements[1]; // Array of elements (variable length) -} TBitArray; - -void GetBits(TBitArray * array, unsigned int nBitPosition, unsigned int nBitLength, void * pvBuffer, int nResultSize); -void SetBits(TBitArray * array, unsigned int nBitPosition, unsigned int nBitLength, void * pvBuffer, int nResultSize); - -//----------------------------------------------------------------------------- -// Structures related to MPQ format -// -// Note: All structures in this header file are supposed to remain private -// to StormLib. The structures may (and will) change over time, as the MPQ -// file format evolves. Programmers directly using these structures need to -// be aware of this. And the last, but not least, NEVER do any modifications -// to those structures directly, always use SFile* functions. -// - -#define MPQ_HEADER_SIZE_V1 0x20 -#define MPQ_HEADER_SIZE_V2 0x2C -#define MPQ_HEADER_SIZE_V3 0x44 -#define MPQ_HEADER_SIZE_V4 0xD0 -#define MPQ_HEADER_DWORDS (MPQ_HEADER_SIZE_V4 / 0x04) - -typedef struct _TMPQUserData -{ - // The ID_MPQ_USERDATA ('MPQ\x1B') signature - DWORD dwID; - - // Maximum size of the user data - DWORD cbUserDataSize; - - // Offset of the MPQ header, relative to the begin of this header - DWORD dwHeaderOffs; - - // Appears to be size of user data header (Starcraft II maps) - DWORD cbUserDataHeader; -} TMPQUserData; - -// MPQ file header -// -// We have to make sure that the header is packed OK. -// Reason: A 64-bit integer at the beginning of 3.0 part, -// which is offset 0x2C -#pragma pack(push, 1) -typedef struct _TMPQHeader -{ - // The ID_MPQ ('MPQ\x1A') signature - DWORD dwID; - - // Size of the archive header - DWORD dwHeaderSize; - - // 32-bit size of MPQ archive - // This field is deprecated in the Burning Crusade MoPaQ format, and the size of the archive - // is calculated as the size from the beginning of the archive to the end of the hash table, - // block table, or hi-block table (whichever is largest). - DWORD dwArchiveSize; - - // 0 = Format 1 (up to The Burning Crusade) - // 1 = Format 2 (The Burning Crusade and newer) - // 2 = Format 3 (WoW - Cataclysm beta or newer) - // 3 = Format 4 (WoW - Cataclysm beta or newer) - USHORT wFormatVersion; - - // Power of two exponent specifying the number of 512-byte disk sectors in each file sector - // in the archive. The size of each file sector in the archive is 512 * 2 ^ wSectorSize. - USHORT wSectorSize; - - // Offset to the beginning of the hash table, relative to the beginning of the archive. - DWORD dwHashTablePos; - - // Offset to the beginning of the block table, relative to the beginning of the archive. - DWORD dwBlockTablePos; - - // Number of entries in the hash table. Must be a power of two, and must be less than 2^16 for - // the original MoPaQ format, or less than 2^20 for the Burning Crusade format. - DWORD dwHashTableSize; - - // Number of entries in the block table - DWORD dwBlockTableSize; - - //-- MPQ HEADER v 2 ------------------------------------------- - - // Offset to the beginning of array of 16-bit high parts of file offsets. - ULONGLONG HiBlockTablePos64; - - // High 16 bits of the hash table offset for large archives. - USHORT wHashTablePosHi; - - // High 16 bits of the block table offset for large archives. - USHORT wBlockTablePosHi; - - //-- MPQ HEADER v 3 ------------------------------------------- - - // 64-bit version of the archive size - ULONGLONG ArchiveSize64; - - // 64-bit position of the BET table - ULONGLONG BetTablePos64; - - // 64-bit position of the HET table - ULONGLONG HetTablePos64; - - //-- MPQ HEADER v 4 ------------------------------------------- - - // Compressed size of the hash table - ULONGLONG HashTableSize64; - - // Compressed size of the block table - ULONGLONG BlockTableSize64; - - // Compressed size of the hi-block table - ULONGLONG HiBlockTableSize64; - - // Compressed size of the HET block - ULONGLONG HetTableSize64; - - // Compressed size of the BET block - ULONGLONG BetTableSize64; - - // Size of raw data chunk to calculate MD5. - // MD5 of each data chunk follows the raw file data. - DWORD dwRawChunkSize; - - // MD5 of MPQ tables - unsigned char MD5_BlockTable[MD5_DIGEST_SIZE]; // MD5 of the block table before decryption - unsigned char MD5_HashTable[MD5_DIGEST_SIZE]; // MD5 of the hash table before decryption - unsigned char MD5_HiBlockTable[MD5_DIGEST_SIZE]; // MD5 of the hi-block table - unsigned char MD5_BetTable[MD5_DIGEST_SIZE]; // MD5 of the BET table before decryption - unsigned char MD5_HetTable[MD5_DIGEST_SIZE]; // MD5 of the HET table before decryption - unsigned char MD5_MpqHeader[MD5_DIGEST_SIZE]; // MD5 of the MPQ header from signature to (including) MD5_HetTable -} TMPQHeader; -#pragma pack(pop) - -// Hash table entry. All files in the archive are searched by their hashes. -typedef struct _TMPQHash -{ - // The hash of the file path, using method A. - DWORD dwName1; - - // The hash of the file path, using method B. - DWORD dwName2; - -#ifdef PLATFORM_LITTLE_ENDIAN - - // The language of the file. This is a Windows LANGID data type, and uses the same values. - // 0 indicates the default language (American English), or that the file is language-neutral. - USHORT lcLocale; - - // The platform the file is used for. 0 indicates the default platform. - // No other values have been observed. - BYTE Platform; - BYTE Reserved; - -#else - - BYTE Platform; - BYTE Reserved; - USHORT lcLocale; - -#endif - - // If the hash table entry is valid, this is the index into the block table of the file. - // Otherwise, one of the following two values: - // - FFFFFFFFh: Hash table entry is empty, and has always been empty. - // Terminates searches for a given file. - // - FFFFFFFEh: Hash table entry is empty, but was valid at some point (a deleted file). - // Does not terminate searches for a given file. - DWORD dwBlockIndex; -} TMPQHash; - -// File description block contains informations about the file -typedef struct _TMPQBlock -{ - // Offset of the beginning of the file, relative to the beginning of the archive. - DWORD dwFilePos; - - // Compressed file size - DWORD dwCSize; - - // Only valid if the block is a file; otherwise meaningless, and should be 0. - // If the file is compressed, this is the size of the uncompressed file data. - DWORD dwFSize; - - // Flags for the file. See MPQ_FILE_XXXX constants - DWORD dwFlags; -} TMPQBlock; - -// Patch file information, preceding the sector offset table -typedef struct _TPatchInfo -{ - DWORD dwLength; // Length of patch info header, in bytes - DWORD dwFlags; // Flags. 0x80000000 = MD5 (?) - DWORD dwDataSize; // Uncompressed size of the patch file - BYTE md5[0x10]; // MD5 of the entire patch file after decompression - - // Followed by the sector table (variable length) -} TPatchInfo; - -// This is the combined file entry for maintaining file list in the MPQ. -// This structure is combined from block table, hi-block table, -// (attributes) file and from (listfile). -typedef struct _TFileEntry -{ - ULONGLONG FileNameHash; // Jenkins hash of the file name. Only used when the MPQ has BET table. - ULONGLONG ByteOffset; // Position of the file content in the MPQ, relative to the MPQ header - ULONGLONG FileTime; // FileTime from the (attributes) file. 0 if not present. - DWORD dwFileSize; // Decompressed size of the file - DWORD dwCmpSize; // Compressed size of the file (i.e., size of the file data in the MPQ) - DWORD dwFlags; // File flags (from block table) - DWORD dwCrc32; // CRC32 from (attributes) file. 0 if not present. - BYTE md5[MD5_DIGEST_SIZE]; // File MD5 from the (attributes) file. 0 if not present. - char * szFileName; // File name. NULL if not known. -} TFileEntry; - -// Common header for HET and BET tables -typedef struct _TMPQExtHeader -{ - DWORD dwSignature; // 'HET\x1A' or 'BET\x1A' - DWORD dwVersion; // Version. Seems to be always 1 - DWORD dwDataSize; // Size of the contained table - - // Followed by the table header - // Followed by the table data - -} TMPQExtHeader; - -// Structure for HET table header -typedef struct _TMPQHetHeader -{ - TMPQExtHeader ExtHdr; - - DWORD dwTableSize; // Size of the entire HET table, including HET_TABLE_HEADER (in bytes) - DWORD dwEntryCount; // Number of occupied entries in the HET table - DWORD dwTotalCount; // Total number of entries in the HET table - DWORD dwNameHashBitSize; // Size of the name hash entry (in bits) - DWORD dwIndexSizeTotal; // Total size of file index (in bits) - DWORD dwIndexSizeExtra; // Extra bits in the file index - DWORD dwIndexSize; // Effective size of the file index (in bits) - DWORD dwIndexTableSize; // Size of the block index subtable (in bytes) - -} TMPQHetHeader; - -// Structure for BET table header -typedef struct _TMPQBetHeader -{ - TMPQExtHeader ExtHdr; - - DWORD dwTableSize; // Size of the entire BET table, including the header (in bytes) - DWORD dwEntryCount; // Number of entries in the BET table. Must match HET_TABLE_HEADER::dwEntryCount - DWORD dwUnknown08; - DWORD dwTableEntrySize; // Size of one table entry (in bits) - DWORD dwBitIndex_FilePos; // Bit index of the file position (within the entry record) - DWORD dwBitIndex_FileSize; // Bit index of the file size (within the entry record) - DWORD dwBitIndex_CmpSize; // Bit index of the compressed size (within the entry record) - DWORD dwBitIndex_FlagIndex; // Bit index of the flag index (within the entry record) - DWORD dwBitIndex_Unknown; // Bit index of the ??? (within the entry record) - DWORD dwBitCount_FilePos; // Bit size of file position (in the entry record) - DWORD dwBitCount_FileSize; // Bit size of file size (in the entry record) - DWORD dwBitCount_CmpSize; // Bit size of compressed file size (in the entry record) - DWORD dwBitCount_FlagIndex; // Bit size of flags index (in the entry record) - DWORD dwBitCount_Unknown; // Bit size of ??? (in the entry record) - DWORD dwBitTotal_NameHash2; // Total bit size of the NameHash2 - DWORD dwBitExtra_NameHash2; // Extra bits in the NameHash2 - DWORD dwBitCount_NameHash2; // Effective size of NameHash2 (in bits) - DWORD dwNameHashArraySize; // Size of NameHash2 table, in bytes - DWORD dwFlagCount; // Number of flags in the following array - -} TMPQBetHeader; - -// Structure for parsed HET table -typedef struct _TMPQHetTable -{ - TBitArray * pBetIndexes; // Bit array of FileIndex values - LPBYTE pNameHashes; // Array of NameHash1 values (NameHash1 = upper 8 bits of FileName hashe) - ULONGLONG AndMask64; // AND mask used for calculating file name hash - ULONGLONG OrMask64; // OR mask used for setting the highest bit of the file name hash - - DWORD dwEntryCount; // Number of occupied entries in the HET table - DWORD dwTotalCount; // Number of entries in both NameHash and FileIndex table - DWORD dwNameHashBitSize; // Size of the name hash entry (in bits) - DWORD dwIndexSizeTotal; // Total size of one entry in pBetIndexes (in bits) - DWORD dwIndexSizeExtra; // Extra bits in the entry in pBetIndexes - DWORD dwIndexSize; // Effective size of one entry in pBetIndexes (in bits) -} TMPQHetTable; - -// Structure for parsed BET table -typedef struct _TMPQBetTable -{ - TBitArray * pNameHashes; // Array of NameHash2 entries (lower 24 bits of FileName hash) - TBitArray * pFileTable; // Bit-based file table - LPDWORD pFileFlags; // Array of file flags - - DWORD dwTableEntrySize; // Size of one table entry, in bits - DWORD dwBitIndex_FilePos; // Bit index of the file position in the table entry - DWORD dwBitIndex_FileSize; // Bit index of the file size in the table entry - DWORD dwBitIndex_CmpSize; // Bit index of the compressed size in the table entry - DWORD dwBitIndex_FlagIndex; // Bit index of the flag index in the table entry - DWORD dwBitIndex_Unknown; // Bit index of ??? in the table entry - DWORD dwBitCount_FilePos; // Size of file offset (in bits) within table entry - DWORD dwBitCount_FileSize; // Size of file size (in bits) within table entry - DWORD dwBitCount_CmpSize; // Size of compressed file size (in bits) within table entry - DWORD dwBitCount_FlagIndex; // Size of flag index (in bits) within table entry - DWORD dwBitCount_Unknown; // Size of ??? (in bits) within table entry - DWORD dwBitTotal_NameHash2; // Total size of the NameHash2 - DWORD dwBitExtra_NameHash2; // Extra bits in the NameHash2 - DWORD dwBitCount_NameHash2; // Effective size of the NameHash2 - DWORD dwEntryCount; // Number of entries - DWORD dwFlagCount; // Number of file flags in pFileFlags -} TMPQBetTable; - -// Structure for patch prefix -typedef struct _TMPQNamePrefix -{ - size_t nLength; // Length of this patch prefix. Can be 0 - char szPatchPrefix[1]; // Patch name prefix (variable length). If not empty, it always starts with backslash. -} TMPQNamePrefix; - -// Structure for name cache -typedef struct _TMPQNameCache -{ - DWORD FirstNameOffset; // Offset of the first name in the name list (in bytes) - DWORD FreeSpaceOffset; // Offset of the first free byte in the name cache (in bytes) - DWORD TotalCacheSize; // Size, in bytes, of the cache. Includes wildcard - DWORD SearchOffset; // Used by SListFileFindFirstFile - - // Followed by search mask (ASCIIZ, '\0' if none) - // Followed by name cache (ANSI multistring) - -} TMPQNameCache; - -// Archive handle structure -typedef struct _TMPQArchive -{ - TFileStream * pStream; // Open stream for the MPQ - - ULONGLONG UserDataPos; // Position of user data (relative to the begin of the file) - ULONGLONG MpqPos; // MPQ header offset (relative to the begin of the file) - ULONGLONG FileSize; // Size of the file at the moment of file open - - struct _TMPQArchive * haPatch; // Pointer to patch archive, if any - struct _TMPQArchive * haBase; // Pointer to base ("previous version") archive, if any - TMPQNamePrefix * pPatchPrefix; // Patch prefix to precede names of patch files - - TMPQUserData * pUserData; // MPQ user data (NULL if not present in the file) - TMPQHeader * pHeader; // MPQ file header - TMPQHash * pHashTable; // Hash table - TMPQHetTable * pHetTable; // HET table - TFileEntry * pFileTable; // File table - HASH_STRING pfnHashString; // Hashing function that will convert the file name into hash - - TMPQUserData UserData; // MPQ user data. Valid only when ID_MPQ_USERDATA has been found - DWORD HeaderData[MPQ_HEADER_DWORDS]; // Storage for MPQ header - - DWORD dwHETBlockSize; - DWORD dwBETBlockSize; - DWORD dwMaxFileCount; // Maximum number of files in the MPQ. Also total size of the file table. - DWORD dwFileTableSize; // Current size of the file table, e.g. index of the entry past the last occupied one - DWORD dwReservedFiles; // Number of entries reserved for internal MPQ files (listfile, attributes) - DWORD dwSectorSize; // Default size of one file sector - DWORD dwFileFlags1; // Flags for (listfile) - DWORD dwFileFlags2; // Flags for (attributes) - DWORD dwFileFlags3; // Flags for (signature) - DWORD dwAttrFlags; // Flags for the (attributes) file, see MPQ_ATTRIBUTE_XXX - DWORD dwFlags; // See MPQ_FLAG_XXXXX - DWORD dwSubType; // See MPQ_SUBTYPE_XXX - - SFILE_ADDFILE_CALLBACK pfnAddFileCB; // Callback function for adding files - void * pvAddFileUserData; // User data thats passed to the callback - - SFILE_COMPACT_CALLBACK pfnCompactCB; // Callback function for compacting the archive - ULONGLONG CompactBytesProcessed; // Amount of bytes that have been processed during a particular compact call - ULONGLONG CompactTotalBytes; // Total amount of bytes to be compacted - void * pvCompactUserData; // User data thats passed to the callback -} TMPQArchive; - -// File handle structure -typedef struct _TMPQFile -{ - TFileStream * pStream; // File stream. Only used on local files - TMPQArchive * ha; // Archive handle - TMPQHash * pHashEntry; // Pointer to hash table entry, if the file was open using hash table - TFileEntry * pFileEntry; // File entry for the file - ULONGLONG RawFilePos; // Offset in MPQ archive (relative to file begin) - ULONGLONG MpqFilePos; // Offset in MPQ archive (relative to MPQ header) - DWORD dwHashIndex; // Hash table index (0xFFFFFFFF if not used) - DWORD dwFileKey; // Decryption key - DWORD dwFilePos; // Current file position - DWORD dwMagic; // 'FILE' - - struct _TMPQFile * hfPatch; // Pointer to opened patch file - - TPatchInfo * pPatchInfo; // Patch info block, preceding the sector table - LPDWORD SectorOffsets; // Position of each file sector, relative to the begin of the file. Only for compressed files. - LPDWORD SectorChksums; // Array of sector checksums (either ADLER32 or MD5) values for each file sector - LPBYTE pbFileData; // Data of the file (single unit files, patched files) - DWORD cbFileData; // Size of file data - DWORD dwCompression0; // Compression that will be used on the first file sector - DWORD dwSectorCount; // Number of sectors in the file - DWORD dwPatchedFileSize; // Size of patched file. Used when saving patch file to the MPQ - DWORD dwDataSize; // Size of data in the file (on patch files, this differs from file size in block table entry) - - LPBYTE pbFileSector; // Last loaded file sector. For single unit files, entire file content - DWORD dwSectorOffs; // File position of currently loaded file sector - DWORD dwSectorSize; // Size of the file sector. For single unit files, this is equal to the file size - - unsigned char hctx[HASH_STATE_SIZE]; // Hash state for MD5. Used when saving file to MPQ - DWORD dwCrc32; // CRC32 value, used when saving file to MPQ - - int nAddFileError; // Result of the "Add File" operations - - bool bLoadedSectorCRCs; // If true, we already tried to load sector CRCs - bool bCheckSectorCRCs; // If true, then SFileReadFile will check sector CRCs when reading the file - bool bIsWriteHandle; // If true, this handle has been created by SFileCreateFile -} TMPQFile; - -// Structure for SFileFindFirstFile and SFileFindNextFile -typedef struct _SFILE_FIND_DATA -{ - char cFileName[MAX_PATH]; // Full name of the found file - char * szPlainName; // Plain name of the found file - DWORD dwHashIndex; // Hash table index for the file (HAH_ENTRY_FREE if no hash table) - DWORD dwBlockIndex; // Block table index for the file - DWORD dwFileSize; // File size in bytes - DWORD dwFileFlags; // MPQ file flags - DWORD dwCompSize; // Compressed file size - DWORD dwFileTimeLo; // Low 32-bits of the file time (0 if not present) - DWORD dwFileTimeHi; // High 32-bits of the file time (0 if not present) - LCID lcLocale; // Locale version - -} SFILE_FIND_DATA, *PSFILE_FIND_DATA; - -typedef struct _SFILE_CREATE_MPQ -{ - DWORD cbSize; // Size of this structure, in bytes - DWORD dwMpqVersion; // Version of the MPQ to be created - void *pvUserData; // Reserved, must be NULL - DWORD cbUserData; // Reserved, must be 0 - DWORD dwStreamFlags; // Stream flags for creating the MPQ - DWORD dwFileFlags1; // File flags for (listfile). Use MPQ_FILE_DEFAULT_INTERNAL to set default flags - DWORD dwFileFlags2; // File flags for (attributes). Use MPQ_FILE_DEFAULT_INTERNAL to set default flags - DWORD dwFileFlags3; // File flags for (signature). Use MPQ_FILE_DEFAULT_INTERNAL to set default flags - DWORD dwAttrFlags; // Flags for the (attributes) file. If 0, no attributes will be created - DWORD dwSectorSize; // Sector size for compressed files - DWORD dwRawChunkSize; // Size of raw data chunk - DWORD dwMaxFileCount; // File limit for the MPQ - -} SFILE_CREATE_MPQ, *PSFILE_CREATE_MPQ; - -//----------------------------------------------------------------------------- -// Stream support - functions - -// Structure used by FileStream_GetBitmap -typedef struct _TStreamBitmap -{ - ULONGLONG StreamSize; // Size of the stream, in bytes - DWORD BitmapSize; // Size of the block map, in bytes - DWORD BlockCount; // Number of blocks in the stream - DWORD BlockSize; // Size of one block - DWORD IsComplete; // Nonzero if the file is complete - - // Followed by the BYTE array, each bit means availability of one block - -} TStreamBitmap; - -// UNICODE versions of the file access functions -TFileStream * FileStream_CreateFile(const TCHAR * szFileName, DWORD dwStreamFlags); -TFileStream * FileStream_OpenFile(const TCHAR * szFileName, DWORD dwStreamFlags); -const TCHAR * FileStream_GetFileName(TFileStream * pStream); -size_t FileStream_Prefix(const TCHAR * szFileName, DWORD * pdwProvider); - -bool FileStream_SetCallback(TFileStream * pStream, SFILE_DOWNLOAD_CALLBACK pfnCallback, void * pvUserData); - -bool FileStream_GetBitmap(TFileStream * pStream, void * pvBitmap, DWORD cbBitmap, LPDWORD pcbLengthNeeded); -bool FileStream_Read(TFileStream * pStream, ULONGLONG * pByteOffset, void * pvBuffer, DWORD dwBytesToRead); -bool FileStream_Write(TFileStream * pStream, ULONGLONG * pByteOffset, const void * pvBuffer, DWORD dwBytesToWrite); -bool FileStream_SetSize(TFileStream * pStream, ULONGLONG NewFileSize); -bool FileStream_GetSize(TFileStream * pStream, ULONGLONG * pFileSize); -bool FileStream_GetPos(TFileStream * pStream, ULONGLONG * pByteOffset); -bool FileStream_GetTime(TFileStream * pStream, ULONGLONG * pFT); -bool FileStream_GetFlags(TFileStream * pStream, LPDWORD pdwStreamFlags); -bool FileStream_Replace(TFileStream * pStream, TFileStream * pNewStream); -void FileStream_Close(TFileStream * pStream); - -//----------------------------------------------------------------------------- -// Functions prototypes for Storm.dll - -// Typedefs for functions exported by Storm.dll -typedef LCID (WINAPI * SFILESETLOCALE)(LCID); -typedef bool (WINAPI * SFILEOPENARCHIVE)(const char *, DWORD, DWORD, HANDLE *); -typedef bool (WINAPI * SFILECLOSEARCHIVE)(HANDLE); -typedef bool (WINAPI * SFILEOPENFILEEX)(HANDLE, const char *, DWORD, HANDLE *); -typedef bool (WINAPI * SFILECLOSEFILE)(HANDLE); -typedef DWORD (WINAPI * SFILEGETFILESIZE)(HANDLE, LPDWORD); -typedef DWORD (WINAPI * SFILESETFILEPOINTER)(HANDLE, LONG, LONG *, DWORD); -typedef bool (WINAPI * SFILEREADFILE)(HANDLE, void *, DWORD, LPDWORD, LPOVERLAPPED); - -//----------------------------------------------------------------------------- -// Functions for manipulation with StormLib global flags - -LCID WINAPI SFileGetLocale(); -LCID WINAPI SFileSetLocale(LCID lcNewLocale); - -//----------------------------------------------------------------------------- -// Functions for archive manipulation - -bool WINAPI SFileOpenArchive(const TCHAR * szMpqName, DWORD dwPriority, DWORD dwFlags, HANDLE * phMpq); -bool WINAPI SFileCreateArchive(const TCHAR * szMpqName, DWORD dwCreateFlags, DWORD dwMaxFileCount, HANDLE * phMpq); -bool WINAPI SFileCreateArchive2(const TCHAR * szMpqName, PSFILE_CREATE_MPQ pCreateInfo, HANDLE * phMpq); - -bool WINAPI SFileSetDownloadCallback(HANDLE hMpq, SFILE_DOWNLOAD_CALLBACK DownloadCB, void * pvUserData); -bool WINAPI SFileFlushArchive(HANDLE hMpq); -bool WINAPI SFileCloseArchive(HANDLE hMpq); - -// Adds another listfile into MPQ. The currently added listfile(s) remain, -// so you can use this API to combining more listfiles. -// Note that this function is internally called by SFileFindFirstFile -int WINAPI SFileAddListFile(HANDLE hMpq, const TCHAR * szListFile); - -// Archive compacting -bool WINAPI SFileSetCompactCallback(HANDLE hMpq, SFILE_COMPACT_CALLBACK CompactCB, void * pvUserData); -bool WINAPI SFileCompactArchive(HANDLE hMpq, const TCHAR * szListFile, bool bReserved); - -// Changing the maximum file count -DWORD WINAPI SFileGetMaxFileCount(HANDLE hMpq); -bool WINAPI SFileSetMaxFileCount(HANDLE hMpq, DWORD dwMaxFileCount); - -// Changing (attributes) file -DWORD WINAPI SFileGetAttributes(HANDLE hMpq); -bool WINAPI SFileSetAttributes(HANDLE hMpq, DWORD dwFlags); -bool WINAPI SFileUpdateFileAttributes(HANDLE hMpq, const char * szFileName); - -//----------------------------------------------------------------------------- -// Functions for manipulation with patch archives - -bool WINAPI SFileOpenPatchArchive(HANDLE hMpq, const TCHAR * szPatchMpqName, const char * szPatchPathPrefix, DWORD dwFlags); -bool WINAPI SFileIsPatchedArchive(HANDLE hMpq); - -//----------------------------------------------------------------------------- -// Functions for file manipulation - -// Reading from MPQ file -bool WINAPI SFileHasFile(HANDLE hMpq, const char * szFileName); -bool WINAPI SFileOpenFileEx(HANDLE hMpq, const char * szFileName, DWORD dwSearchScope, HANDLE * phFile); -DWORD WINAPI SFileGetFileSize(HANDLE hFile, LPDWORD pdwFileSizeHigh); -DWORD WINAPI SFileSetFilePointer(HANDLE hFile, LONG lFilePos, LONG * plFilePosHigh, DWORD dwMoveMethod); -bool WINAPI SFileReadFile(HANDLE hFile, void * lpBuffer, DWORD dwToRead, LPDWORD pdwRead, LPOVERLAPPED lpOverlapped); -bool WINAPI SFileCloseFile(HANDLE hFile); - -// Retrieving info about a file in the archive -bool WINAPI SFileGetFileInfo(HANDLE hMpqOrFile, SFileInfoClass InfoClass, void * pvFileInfo, DWORD cbFileInfo, LPDWORD pcbLengthNeeded); -bool WINAPI SFileGetFileName(HANDLE hFile, char * szFileName); -bool WINAPI SFileFreeFileInfo(void * pvFileInfo, SFileInfoClass InfoClass); - -// High-level extract function -bool WINAPI SFileExtractFile(HANDLE hMpq, const char * szToExtract, const TCHAR * szExtracted, DWORD dwSearchScope); - -//----------------------------------------------------------------------------- -// Functions for file and archive verification - -// Generates file CRC32 -bool WINAPI SFileGetFileChecksums(HANDLE hMpq, const char * szFileName, LPDWORD pdwCrc32, char * pMD5); - -// Verifies file against its checksums stored in (attributes) attributes (depending on dwFlags). -// For dwFlags, use one or more of MPQ_ATTRIBUTE_MD5 -DWORD WINAPI SFileVerifyFile(HANDLE hMpq, const char * szFileName, DWORD dwFlags); - -// Verifies raw data of the archive. Only works for MPQs version 4 or newer -int WINAPI SFileVerifyRawData(HANDLE hMpq, DWORD dwWhatToVerify, const char * szFileName); - -// Verifies the signature, if present -bool WINAPI SFileSignArchive(HANDLE hMpq, DWORD dwSignatureType); -DWORD WINAPI SFileVerifyArchive(HANDLE hMpq); - -//----------------------------------------------------------------------------- -// Functions for file searching - -HANDLE WINAPI SFileFindFirstFile(HANDLE hMpq, const char * szMask, SFILE_FIND_DATA * lpFindFileData, const TCHAR * szListFile); -bool WINAPI SFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData); -bool WINAPI SFileFindClose(HANDLE hFind); - -HANDLE WINAPI SListFileFindFirstFile(HANDLE hMpq, const TCHAR * szListFile, const char * szMask, SFILE_FIND_DATA * lpFindFileData); -bool WINAPI SListFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData); -bool WINAPI SListFileFindClose(HANDLE hFind); - -// Locale support -int WINAPI SFileEnumLocales(HANDLE hMpq, const char * szFileName, LCID * plcLocales, LPDWORD pdwMaxLocales, DWORD dwSearchScope); - -//----------------------------------------------------------------------------- -// Support for adding files to the MPQ - -bool WINAPI SFileCreateFile(HANDLE hMpq, const char * szArchivedName, ULONGLONG FileTime, DWORD dwFileSize, LCID lcLocale, DWORD dwFlags, HANDLE * phFile); -bool WINAPI SFileWriteFile(HANDLE hFile, const void * pvData, DWORD dwSize, DWORD dwCompression); -bool WINAPI SFileFinishFile(HANDLE hFile); - -bool WINAPI SFileAddFileEx(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwCompression, DWORD dwCompressionNext = MPQ_COMPRESSION_NEXT_SAME); -bool WINAPI SFileAddFile(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags); -bool WINAPI SFileAddWave(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality); -bool WINAPI SFileRemoveFile(HANDLE hMpq, const char * szFileName, DWORD dwSearchScope); -bool WINAPI SFileRenameFile(HANDLE hMpq, const char * szOldFileName, const char * szNewFileName); -bool WINAPI SFileSetFileLocale(HANDLE hFile, LCID lcNewLocale); -bool WINAPI SFileSetDataCompression(DWORD DataCompression); - -bool WINAPI SFileSetAddFileCallback(HANDLE hMpq, SFILE_ADDFILE_CALLBACK AddFileCB, void * pvUserData); - -//----------------------------------------------------------------------------- -// Compression and decompression - -int WINAPI SCompImplode (void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer); -int WINAPI SCompExplode (void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer); -int WINAPI SCompCompress (void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, unsigned uCompressionMask, int nCmpType, int nCmpLevel); -int WINAPI SCompDecompress (void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer); -int WINAPI SCompDecompress2(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer); - -//----------------------------------------------------------------------------- -// Non-Windows support for SetLastError/GetLastError - -#ifndef PLATFORM_WINDOWS - -void SetLastError(DWORD dwErrCode); -DWORD GetLastError(); - -#endif - -//----------------------------------------------------------------------------- -// Functions from Storm.dll. They use slightly different names for keeping -// possibility to use them together with StormLib (StormXXX instead of SFileXXX) - -#ifdef __LINK_STORM_DLL__ - #define STORM_ALTERNATE_NAMES // Force storm_dll.h to use alternate fnc names - #include "..\storm_dll\storm_dll.h" -#endif // __LINK_STORM_DLL__ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // __STORMLIB_H__ diff --git a/libs/storm-sys/StormLib/LICENSE b/libs/storm-sys/StormLib/LICENSE deleted file mode 100644 index 136cae4..0000000 --- a/libs/storm-sys/StormLib/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 1999-2013 Ladislav Zezula - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/libs/storm-sys/StormLib/src/FileStream.cpp b/libs/storm-sys/StormLib/src/FileStream.cpp deleted file mode 100644 index a01aa7d..0000000 --- a/libs/storm-sys/StormLib/src/FileStream.cpp +++ /dev/null @@ -1,2668 +0,0 @@ -/*****************************************************************************/ -/* FileStream.cpp Copyright (c) Ladislav Zezula 2010 */ -/*---------------------------------------------------------------------------*/ -/* File stream support for StormLib */ -/* */ -/* Windows support: Written by Ladislav Zezula */ -/* Mac support: Written by Sam Wilkins */ -/* Linux support: Written by Sam Wilkins and Ivan Komissarov */ -/* Big-endian: Written & debugged by Sam Wilkins */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 11.06.10 1.00 Lad Derived from StormPortMac.cpp and StormPortLinux.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "StormCommon.h" -#include "FileStream.h" - -#ifdef _MSC_VER -#pragma warning(disable: 4800) // 'BOOL' : forcing value to bool 'true' or 'false' (performance warning) -#endif - -//----------------------------------------------------------------------------- -// Local defines - -#ifndef INVALID_HANDLE_VALUE -#define INVALID_HANDLE_VALUE ((HANDLE)-1) -#endif - -//----------------------------------------------------------------------------- -// Local functions - platform-specific functions - -#ifndef PLATFORM_WINDOWS -static DWORD nLastError = ERROR_SUCCESS; - -DWORD GetLastError() -{ - return nLastError; -} - -void SetLastError(DWORD dwErrCode) -{ - nLastError = dwErrCode; -} -#endif - -static DWORD StringToInt(const char * szString) -{ - DWORD dwValue = 0; - - while('0' <= szString[0] && szString[0] <= '9') - { - dwValue = (dwValue * 10) + (szString[0] - '9'); - szString++; - } - - return dwValue; -} - -//----------------------------------------------------------------------------- -// Dummy init function - -static void BaseNone_Init(TFileStream *) -{ - // Nothing here -} - -//----------------------------------------------------------------------------- -// Local functions - base file support - -static bool BaseFile_Create(TFileStream * pStream) -{ -#ifdef PLATFORM_WINDOWS - { - DWORD dwWriteShare = (pStream->dwFlags & STREAM_FLAG_WRITE_SHARE) ? FILE_SHARE_WRITE : 0; - - pStream->Base.File.hFile = CreateFile(pStream->szFileName, - GENERIC_READ | GENERIC_WRITE, - dwWriteShare | FILE_SHARE_READ, - NULL, - CREATE_ALWAYS, - 0, - NULL); - if(pStream->Base.File.hFile == INVALID_HANDLE_VALUE) - return false; - } -#endif - -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) - { - intptr_t handle; - - handle = open(pStream->szFileName, O_RDWR | O_CREAT | O_TRUNC | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); - if(handle == -1) - { - nLastError = errno; - return false; - } - - pStream->Base.File.hFile = (HANDLE)handle; - } -#endif - - // Reset the file size and position - pStream->Base.File.FileSize = 0; - pStream->Base.File.FilePos = 0; - return true; -} - -static bool BaseFile_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD dwStreamFlags) -{ -#ifdef PLATFORM_WINDOWS - { - ULARGE_INTEGER FileSize; - DWORD dwWriteAccess = (dwStreamFlags & STREAM_FLAG_READ_ONLY) ? 0 : FILE_WRITE_DATA | FILE_APPEND_DATA | FILE_WRITE_ATTRIBUTES; - DWORD dwWriteShare = (dwStreamFlags & STREAM_FLAG_WRITE_SHARE) ? FILE_SHARE_WRITE : 0; - - // Open the file - pStream->Base.File.hFile = CreateFile(szFileName, - FILE_READ_DATA | FILE_READ_ATTRIBUTES | dwWriteAccess, - FILE_SHARE_READ | dwWriteShare, - NULL, - OPEN_EXISTING, - 0, - NULL); - if(pStream->Base.File.hFile == INVALID_HANDLE_VALUE) - return false; - - // Query the file size - FileSize.LowPart = GetFileSize(pStream->Base.File.hFile, &FileSize.HighPart); - pStream->Base.File.FileSize = FileSize.QuadPart; - - // Query last write time - GetFileTime(pStream->Base.File.hFile, NULL, NULL, (LPFILETIME)&pStream->Base.File.FileTime); - } -#endif - -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) - { - struct stat64 fileinfo; - int oflag = (dwStreamFlags & STREAM_FLAG_READ_ONLY) ? O_RDONLY : O_RDWR; - intptr_t handle; - - // Open the file - handle = open(szFileName, oflag | O_LARGEFILE); - if(handle == -1) - { - nLastError = errno; - return false; - } - - // Get the file size - if(fstat64(handle, &fileinfo) == -1) - { - nLastError = errno; - close(handle); - return false; - } - - // time_t is number of seconds since 1.1.1970, UTC. - // 1 second = 10000000 (decimal) in FILETIME - // Set the start to 1.1.1970 00:00:00 - pStream->Base.File.FileTime = 0x019DB1DED53E8000ULL + (10000000 * fileinfo.st_mtime); - pStream->Base.File.FileSize = (ULONGLONG)fileinfo.st_size; - pStream->Base.File.hFile = (HANDLE)handle; - } -#endif - - // Reset the file position - pStream->Base.File.FilePos = 0; - return true; -} - -static bool BaseFile_Read( - TFileStream * pStream, // Pointer to an open stream - ULONGLONG * pByteOffset, // Pointer to file byte offset. If NULL, it reads from the current position - void * pvBuffer, // Pointer to data to be read - DWORD dwBytesToRead) // Number of bytes to read from the file -{ - ULONGLONG ByteOffset = (pByteOffset != NULL) ? *pByteOffset : pStream->Base.File.FilePos; - DWORD dwBytesRead = 0; // Must be set by platform-specific code - -#ifdef PLATFORM_WINDOWS - { - // Note: StormLib no longer supports Windows 9x. - // Thus, we can use the OVERLAPPED structure to specify - // file offset to read from file. This allows us to skip - // one system call to SetFilePointer - - // Update the byte offset - pStream->Base.File.FilePos = ByteOffset; - - // Read the data - if(dwBytesToRead != 0) - { - OVERLAPPED Overlapped; - - Overlapped.OffsetHigh = (DWORD)(ByteOffset >> 32); - Overlapped.Offset = (DWORD)ByteOffset; - Overlapped.hEvent = NULL; - if(!ReadFile(pStream->Base.File.hFile, pvBuffer, dwBytesToRead, &dwBytesRead, &Overlapped)) - return false; - } - } -#endif - -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) - { - ssize_t bytes_read; - - // If the byte offset is different from the current file position, - // we have to update the file position xxx - if(ByteOffset != pStream->Base.File.FilePos) - { - lseek64((intptr_t)pStream->Base.File.hFile, (off64_t)(ByteOffset), SEEK_SET); - pStream->Base.File.FilePos = ByteOffset; - } - - // Perform the read operation - if(dwBytesToRead != 0) - { - bytes_read = read((intptr_t)pStream->Base.File.hFile, pvBuffer, (size_t)dwBytesToRead); - if(bytes_read == -1) - { - nLastError = errno; - return false; - } - - dwBytesRead = (DWORD)(size_t)bytes_read; - } - } -#endif - - // Increment the current file position by number of bytes read - // If the number of bytes read doesn't match to required amount, return false - pStream->Base.File.FilePos = ByteOffset + dwBytesRead; - if(dwBytesRead != dwBytesToRead) - SetLastError(ERROR_HANDLE_EOF); - return (dwBytesRead == dwBytesToRead); -} - -/** - * \a pStream Pointer to an open stream - * \a pByteOffset Pointer to file byte offset. If NULL, writes to current position - * \a pvBuffer Pointer to data to be written - * \a dwBytesToWrite Number of bytes to write to the file - */ - -static bool BaseFile_Write(TFileStream * pStream, ULONGLONG * pByteOffset, const void * pvBuffer, DWORD dwBytesToWrite) -{ - ULONGLONG ByteOffset = (pByteOffset != NULL) ? *pByteOffset : pStream->Base.File.FilePos; - DWORD dwBytesWritten = 0; // Must be set by platform-specific code - -#ifdef PLATFORM_WINDOWS - { - // Note: StormLib no longer supports Windows 9x. - // Thus, we can use the OVERLAPPED structure to specify - // file offset to read from file. This allows us to skip - // one system call to SetFilePointer - - // Update the byte offset - pStream->Base.File.FilePos = ByteOffset; - - // Read the data - if(dwBytesToWrite != 0) - { - OVERLAPPED Overlapped; - - Overlapped.OffsetHigh = (DWORD)(ByteOffset >> 32); - Overlapped.Offset = (DWORD)ByteOffset; - Overlapped.hEvent = NULL; - if(!WriteFile(pStream->Base.File.hFile, pvBuffer, dwBytesToWrite, &dwBytesWritten, &Overlapped)) - return false; - } - } -#endif - -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) - { - ssize_t bytes_written; - - // If the byte offset is different from the current file position, - // we have to update the file position - if(ByteOffset != pStream->Base.File.FilePos) - { - lseek64((intptr_t)pStream->Base.File.hFile, (off64_t)(ByteOffset), SEEK_SET); - pStream->Base.File.FilePos = ByteOffset; - } - - // Perform the read operation - bytes_written = write((intptr_t)pStream->Base.File.hFile, pvBuffer, (size_t)dwBytesToWrite); - if(bytes_written == -1) - { - nLastError = errno; - return false; - } - - dwBytesWritten = (DWORD)(size_t)bytes_written; - } -#endif - - // Increment the current file position by number of bytes read - pStream->Base.File.FilePos = ByteOffset + dwBytesWritten; - - // Also modify the file size, if needed - if(pStream->Base.File.FilePos > pStream->Base.File.FileSize) - pStream->Base.File.FileSize = pStream->Base.File.FilePos; - - if(dwBytesWritten != dwBytesToWrite) - SetLastError(ERROR_DISK_FULL); - return (dwBytesWritten == dwBytesToWrite); -} - -/** - * \a pStream Pointer to an open stream - * \a NewFileSize New size of the file - */ -static bool BaseFile_Resize(TFileStream * pStream, ULONGLONG NewFileSize) -{ -#ifdef PLATFORM_WINDOWS - { - LONG FileSizeHi = (LONG)(NewFileSize >> 32); - LONG FileSizeLo; - DWORD dwNewPos; - bool bResult; - - // Set the position at the new file size - dwNewPos = SetFilePointer(pStream->Base.File.hFile, (LONG)NewFileSize, &FileSizeHi, FILE_BEGIN); - if(dwNewPos == INVALID_SET_FILE_POINTER && GetLastError() != ERROR_SUCCESS) - return false; - - // Set the current file pointer as the end of the file - bResult = (bool)SetEndOfFile(pStream->Base.File.hFile); - if(bResult) - pStream->Base.File.FileSize = NewFileSize; - - // Restore the file position - FileSizeHi = (LONG)(pStream->Base.File.FilePos >> 32); - FileSizeLo = (LONG)(pStream->Base.File.FilePos); - SetFilePointer(pStream->Base.File.hFile, FileSizeLo, &FileSizeHi, FILE_BEGIN); - return bResult; - } -#endif - -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) - { - if(ftruncate64((intptr_t)pStream->Base.File.hFile, (off64_t)NewFileSize) == -1) - { - nLastError = errno; - return false; - } - - pStream->Base.File.FileSize = NewFileSize; - return true; - } -#endif -} - -// Gives the current file size -static bool BaseFile_GetSize(TFileStream * pStream, ULONGLONG * pFileSize) -{ - // Note: Used by all thre base providers. - // Requires the TBaseData union to have the same layout for all three base providers - *pFileSize = pStream->Base.File.FileSize; - return true; -} - -// Gives the current file position -static bool BaseFile_GetPos(TFileStream * pStream, ULONGLONG * pByteOffset) -{ - // Note: Used by all thre base providers. - // Requires the TBaseData union to have the same layout for all three base providers - *pByteOffset = pStream->Base.File.FilePos; - return true; -} - -// Renames the file pointed by pStream so that it contains data from pNewStream -static bool BaseFile_Replace(TFileStream * pStream, TFileStream * pNewStream) -{ -#ifdef PLATFORM_WINDOWS - // Delete the original stream file. Don't check the result value, - // because if the file doesn't exist, it would fail - DeleteFile(pStream->szFileName); - - // Rename the new file to the old stream's file - return (bool)MoveFile(pNewStream->szFileName, pStream->szFileName); -#endif - -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) - // "rename" on Linux also works if the target file exists - if(rename(pNewStream->szFileName, pStream->szFileName) == -1) - { - nLastError = errno; - return false; - } - - return true; -#endif -} - -static void BaseFile_Close(TFileStream * pStream) -{ - if(pStream->Base.File.hFile != INVALID_HANDLE_VALUE) - { -#ifdef PLATFORM_WINDOWS - CloseHandle(pStream->Base.File.hFile); -#endif - -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) - close((intptr_t)pStream->Base.File.hFile); -#endif - } - - // Also invalidate the handle - pStream->Base.File.hFile = INVALID_HANDLE_VALUE; -} - -// Initializes base functions for the disk file -static void BaseFile_Init(TFileStream * pStream) -{ - pStream->BaseCreate = BaseFile_Create; - pStream->BaseOpen = BaseFile_Open; - pStream->BaseRead = BaseFile_Read; - pStream->BaseWrite = BaseFile_Write; - pStream->BaseResize = BaseFile_Resize; - pStream->BaseGetSize = BaseFile_GetSize; - pStream->BaseGetPos = BaseFile_GetPos; - pStream->BaseClose = BaseFile_Close; -} - -//----------------------------------------------------------------------------- -// Local functions - base memory-mapped file support - -static bool BaseMap_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD dwStreamFlags) -{ -#ifdef PLATFORM_WINDOWS - - ULARGE_INTEGER FileSize; - HANDLE hFile; - HANDLE hMap; - bool bResult = false; - - // Keep compiler happy - dwStreamFlags = dwStreamFlags; - - // Open the file for read access - hFile = CreateFile(szFileName, FILE_READ_DATA, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - if(hFile != INVALID_HANDLE_VALUE) - { - // Retrieve file size. Don't allow mapping file of a zero size. - FileSize.LowPart = GetFileSize(hFile, &FileSize.HighPart); - if(FileSize.QuadPart != 0) - { - // Now create mapping object - hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); - if(hMap != NULL) - { - // Map the entire view into memory - // Note that this operation will fail if the file can't fit - // into usermode address space - pStream->Base.Map.pbFile = (LPBYTE)MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0); - if(pStream->Base.Map.pbFile != NULL) - { - // Retrieve file time - GetFileTime(hFile, NULL, NULL, (LPFILETIME)&pStream->Base.Map.FileTime); - - // Retrieve file size and position - pStream->Base.Map.FileSize = FileSize.QuadPart; - pStream->Base.Map.FilePos = 0; - bResult = true; - } - - // Close the map handle - CloseHandle(hMap); - } - } - - // Close the file handle - CloseHandle(hFile); - } - - // If the file is not there and is not available for random access, - // report error - if(bResult == false) - return false; -#endif - -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) - struct stat64 fileinfo; - intptr_t handle; - bool bResult = false; - - // Open the file - handle = open(szFileName, O_RDONLY); - if(handle != -1) - { - // Get the file size - if(fstat64(handle, &fileinfo) != -1) - { - pStream->Base.Map.pbFile = (LPBYTE)mmap(NULL, (size_t)fileinfo.st_size, PROT_READ, MAP_PRIVATE, handle, 0); - if(pStream->Base.Map.pbFile != NULL) - { - // time_t is number of seconds since 1.1.1970, UTC. - // 1 second = 10000000 (decimal) in FILETIME - // Set the start to 1.1.1970 00:00:00 - pStream->Base.Map.FileTime = 0x019DB1DED53E8000ULL + (10000000 * fileinfo.st_mtime); - pStream->Base.Map.FileSize = (ULONGLONG)fileinfo.st_size; - pStream->Base.Map.FilePos = 0; - bResult = true; - } - } - close(handle); - } - - // Did the mapping fail? - if(bResult == false) - { - nLastError = errno; - return false; - } -#endif - - return true; -} - -static bool BaseMap_Read( - TFileStream * pStream, // Pointer to an open stream - ULONGLONG * pByteOffset, // Pointer to file byte offset. If NULL, it reads from the current position - void * pvBuffer, // Pointer to data to be read - DWORD dwBytesToRead) // Number of bytes to read from the file -{ - ULONGLONG ByteOffset = (pByteOffset != NULL) ? *pByteOffset : pStream->Base.Map.FilePos; - - // Do we have to read anything at all? - if(dwBytesToRead != 0) - { - // Don't allow reading past file size - if((ByteOffset + dwBytesToRead) > pStream->Base.Map.FileSize) - return false; - - // Copy the required data - memcpy(pvBuffer, pStream->Base.Map.pbFile + (size_t)ByteOffset, dwBytesToRead); - } - - // Move the current file position - pStream->Base.Map.FilePos += dwBytesToRead; - return true; -} - -static void BaseMap_Close(TFileStream * pStream) -{ -#ifdef PLATFORM_WINDOWS - if(pStream->Base.Map.pbFile != NULL) - UnmapViewOfFile(pStream->Base.Map.pbFile); -#endif - -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) - if(pStream->Base.Map.pbFile != NULL) - munmap(pStream->Base.Map.pbFile, (size_t )pStream->Base.Map.FileSize); -#endif - - pStream->Base.Map.pbFile = NULL; -} - -// Initializes base functions for the mapped file -static void BaseMap_Init(TFileStream * pStream) -{ - // Supply the file stream functions - pStream->BaseOpen = BaseMap_Open; - pStream->BaseRead = BaseMap_Read; - pStream->BaseGetSize = BaseFile_GetSize; // Reuse BaseFile function - pStream->BaseGetPos = BaseFile_GetPos; // Reuse BaseFile function - pStream->BaseClose = BaseMap_Close; - - // Mapped files are read-only - pStream->dwFlags |= STREAM_FLAG_READ_ONLY; -} - -//----------------------------------------------------------------------------- -// Local functions - base HTTP file support - -static const TCHAR * BaseHttp_ExtractServerName(const TCHAR * szFileName, TCHAR * szServerName) -{ - // Check for HTTP - if(!_tcsnicmp(szFileName, _T("http://"), 7)) - szFileName += 7; - - // Cut off the server name - if(szServerName != NULL) - { - while(szFileName[0] != 0 && szFileName[0] != _T('/')) - *szServerName++ = *szFileName++; - *szServerName = 0; - } - else - { - while(szFileName[0] != 0 && szFileName[0] != _T('/')) - szFileName++; - } - - // Return the remainder - return szFileName; -} - -static bool BaseHttp_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD dwStreamFlags) -{ - // Not supported - SetLastError(ERROR_NOT_SUPPORTED); - pStream = pStream; - return false; -} - -static bool BaseHttp_Read( - TFileStream * pStream, // Pointer to an open stream - ULONGLONG * pByteOffset, // Pointer to file byte offset. If NULL, it reads from the current position - void * pvBuffer, // Pointer to data to be read - DWORD dwBytesToRead) // Number of bytes to read from the file -{ - // Not supported - pStream = pStream; - pByteOffset = pByteOffset; - pvBuffer = pvBuffer; - dwBytesToRead = dwBytesToRead; - SetLastError(ERROR_NOT_SUPPORTED); - return false; -} - -static void BaseHttp_Close(TFileStream * pStream) -{ - pStream = pStream; -} - -// Initializes base functions for the mapped file -static void BaseHttp_Init(TFileStream * pStream) -{ - // Supply the stream functions - pStream->BaseOpen = BaseHttp_Open; - pStream->BaseRead = BaseHttp_Read; - pStream->BaseGetSize = BaseFile_GetSize; // Reuse BaseFile function - pStream->BaseGetPos = BaseFile_GetPos; // Reuse BaseFile function - pStream->BaseClose = BaseHttp_Close; - - // HTTP files are read-only - pStream->dwFlags |= STREAM_FLAG_READ_ONLY; -} - -//----------------------------------------------------------------------------- -// Local functions - base block-based support - -// Generic function that loads blocks from the file -// The function groups the block with the same availability, -// so the called BlockRead can finish the request in a single system call -static bool BlockStream_Read( - TBlockStream * pStream, // Pointer to an open stream - ULONGLONG * pByteOffset, // Pointer to file byte offset. If NULL, it reads from the current position - void * pvBuffer, // Pointer to data to be read - DWORD dwBytesToRead) // Number of bytes to read from the file -{ - ULONGLONG BlockOffset0; - ULONGLONG BlockOffset; - ULONGLONG ByteOffset; - ULONGLONG EndOffset; - LPBYTE TransferBuffer; - LPBYTE BlockBuffer; - DWORD BlockBufferOffset; // Offset of the desired data in the block buffer - DWORD BytesNeeded; // Number of bytes that really need to be read - DWORD BlockSize = pStream->BlockSize; - DWORD BlockCount; - bool bPrevBlockAvailable; - bool bCallbackCalled = false; - bool bBlockAvailable; - bool bResult = true; - - // The base block read function must be present - assert(pStream->BlockRead != NULL); - - // NOP reading of zero bytes - if(dwBytesToRead == 0) - return true; - - // Get the current position in the stream - ByteOffset = (pByteOffset != NULL) ? pByteOffset[0] : pStream->StreamPos; - EndOffset = ByteOffset + dwBytesToRead; - if(EndOffset > pStream->StreamSize) - { - SetLastError(ERROR_HANDLE_EOF); - return false; - } - - // Calculate the block parameters - BlockOffset0 = BlockOffset = ByteOffset & ~((ULONGLONG)BlockSize - 1); - BlockCount = (DWORD)(((EndOffset - BlockOffset) + (BlockSize - 1)) / BlockSize); - BytesNeeded = (DWORD)(EndOffset - BlockOffset); - - // Remember where we have our data - assert((BlockSize & (BlockSize - 1)) == 0); - BlockBufferOffset = (DWORD)(ByteOffset & (BlockSize - 1)); - - // Allocate buffer for reading blocks - TransferBuffer = BlockBuffer = STORM_ALLOC(BYTE, (BlockCount * BlockSize)); - if(TransferBuffer == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return false; - } - - // If all blocks are available, just read all blocks at once - if(pStream->IsComplete == 0) - { - // Now parse the blocks and send the block read request - // to all blocks with the same availability - assert(pStream->BlockCheck != NULL); - bPrevBlockAvailable = pStream->BlockCheck(pStream, BlockOffset); - - // Loop as long as we have something to read - while(BlockOffset < EndOffset) - { - // Determine availability of the next block - bBlockAvailable = pStream->BlockCheck(pStream, BlockOffset); - - // If the availability has changed, read all blocks up to this one - if(bBlockAvailable != bPrevBlockAvailable) - { - // Call the file stream callback, if the block is not available - if(pStream->pMaster && pStream->pfnCallback && bPrevBlockAvailable == false) - { - pStream->pfnCallback(pStream->UserData, BlockOffset0, (DWORD)(BlockOffset - BlockOffset0)); - bCallbackCalled = true; - } - - // Load the continuous blocks with the same availability - assert(BlockOffset > BlockOffset0); - bResult = pStream->BlockRead(pStream, BlockOffset0, BlockOffset, BlockBuffer, BytesNeeded, bPrevBlockAvailable); - if(!bResult) - break; - - // Move the block offset - BlockBuffer += (DWORD)(BlockOffset - BlockOffset0); - BytesNeeded -= (DWORD)(BlockOffset - BlockOffset0); - bPrevBlockAvailable = bBlockAvailable; - BlockOffset0 = BlockOffset; - } - - // Move to the block offset in the stream - BlockOffset += BlockSize; - } - - // If there is a block(s) remaining to be read, do it - if(BlockOffset > BlockOffset0) - { - // Call the file stream callback, if the block is not available - if(pStream->pMaster && pStream->pfnCallback && bPrevBlockAvailable == false) - { - pStream->pfnCallback(pStream->UserData, BlockOffset0, (DWORD)(BlockOffset - BlockOffset0)); - bCallbackCalled = true; - } - - // Read the complete blocks from the file - if(BlockOffset > pStream->StreamSize) - BlockOffset = pStream->StreamSize; - bResult = pStream->BlockRead(pStream, BlockOffset0, BlockOffset, BlockBuffer, BytesNeeded, bPrevBlockAvailable); - } - } - else - { - // Read the complete blocks from the file - if(EndOffset > pStream->StreamSize) - EndOffset = pStream->StreamSize; - bResult = pStream->BlockRead(pStream, BlockOffset, EndOffset, BlockBuffer, BytesNeeded, true); - } - - // Now copy the data to the user buffer - if(bResult) - { - memcpy(pvBuffer, TransferBuffer + BlockBufferOffset, dwBytesToRead); - pStream->StreamPos = ByteOffset + dwBytesToRead; - } - else - { - // If the block read failed, set the last error - SetLastError(ERROR_FILE_INCOMPLETE); - } - - // Call the callback to indicate we are done - if(bCallbackCalled) - pStream->pfnCallback(pStream->UserData, 0, 0); - - // Free the block buffer and return - STORM_FREE(TransferBuffer); - return bResult; -} - -static bool BlockStream_GetSize(TFileStream * pStream, ULONGLONG * pFileSize) -{ - *pFileSize = pStream->StreamSize; - return true; -} - -static bool BlockStream_GetPos(TFileStream * pStream, ULONGLONG * pByteOffset) -{ - *pByteOffset = pStream->StreamPos; - return true; -} - -static void BlockStream_Close(TBlockStream * pStream) -{ - // Free the data map, if any - if(pStream->FileBitmap != NULL) - STORM_FREE(pStream->FileBitmap); - pStream->FileBitmap = NULL; - - // Call the base class for closing the stream - pStream->BaseClose(pStream); -} - -//----------------------------------------------------------------------------- -// File stream allocation function - -static STREAM_INIT StreamBaseInit[4] = -{ - BaseFile_Init, - BaseMap_Init, - BaseHttp_Init, - BaseNone_Init -}; - -// This function allocates an empty structure for the file stream -// The stream structure is created as flat block, variable length -// The file name is placed after the end of the stream structure data -static TFileStream * AllocateFileStream( - const TCHAR * szFileName, - size_t StreamSize, - DWORD dwStreamFlags) -{ - TFileStream * pMaster = NULL; - TFileStream * pStream; - const TCHAR * szNextFile = szFileName; - size_t FileNameSize; - - // Sanity check - assert(StreamSize != 0); - - // The caller can specify chain of files in the following form: - // C:\archive.MPQ*http://www.server.com/MPQs/archive-server.MPQ - // In that case, we use the part after "*" as master file name - while(szNextFile[0] != 0 && szNextFile[0] != _T('*')) - szNextFile++; - FileNameSize = (size_t)((szNextFile - szFileName) * sizeof(TCHAR)); - - // If we have a next file, we need to open it as master stream - // Note that we don't care if the master stream exists or not, - // If it doesn't, later attempts to read missing file block will fail - if(szNextFile[0] == _T('*')) - { - // Don't allow another master file in the string - if(_tcschr(szNextFile + 1, _T('*')) != NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return NULL; - } - - // Open the master file - pMaster = FileStream_OpenFile(szNextFile + 1, STREAM_FLAG_READ_ONLY); - } - - // Allocate the stream structure for the given stream type - pStream = (TFileStream *)STORM_ALLOC(BYTE, StreamSize + FileNameSize + sizeof(TCHAR)); - if(pStream != NULL) - { - // Zero the entire structure - memset(pStream, 0, StreamSize); - pStream->pMaster = pMaster; - pStream->dwFlags = dwStreamFlags; - - // Initialize the file name - pStream->szFileName = (TCHAR *)((BYTE *)pStream + StreamSize); - memcpy(pStream->szFileName, szFileName, FileNameSize); - pStream->szFileName[FileNameSize / sizeof(TCHAR)] = 0; - - // Initialize the stream functions - StreamBaseInit[dwStreamFlags & 0x03](pStream); - } - - return pStream; -} - -//----------------------------------------------------------------------------- -// Local functions - flat stream support - -static DWORD FlatStream_CheckFile(TBlockStream * pStream) -{ - LPBYTE FileBitmap = (LPBYTE)pStream->FileBitmap; - DWORD WholeByteCount = (pStream->BlockCount / 8); - DWORD ExtraBitsCount = (pStream->BlockCount & 7); - BYTE ExpectedValue; - - // Verify the whole bytes - their value must be 0xFF - for(DWORD i = 0; i < WholeByteCount; i++) - { - if(FileBitmap[i] != 0xFF) - return 0; - } - - // If there are extra bits, calculate the mask - if(ExtraBitsCount != 0) - { - ExpectedValue = (BYTE)((1 << ExtraBitsCount) - 1); - if(FileBitmap[WholeByteCount] != ExpectedValue) - return 0; - } - - // Yes, the file is complete - return 1; -} - -static bool FlatStream_LoadBitmap(TBlockStream * pStream) -{ - FILE_BITMAP_FOOTER Footer; - ULONGLONG ByteOffset; - LPBYTE FileBitmap; - DWORD BlockCount; - DWORD BitmapSize; - - // Do not load the bitmap if we should not have to - if(!(pStream->dwFlags & STREAM_FLAG_USE_BITMAP)) - return false; - - // Only if the size is greater than size of bitmap footer - if(pStream->Base.File.FileSize > sizeof(FILE_BITMAP_FOOTER)) - { - // Load the bitmap footer - ByteOffset = pStream->Base.File.FileSize - sizeof(FILE_BITMAP_FOOTER); - if(pStream->BaseRead(pStream, &ByteOffset, &Footer, sizeof(FILE_BITMAP_FOOTER))) - { - // Make sure that the array is properly BSWAP-ed - BSWAP_ARRAY32_UNSIGNED((LPDWORD)(&Footer), sizeof(FILE_BITMAP_FOOTER)); - - // Verify if there is actually a footer - if(Footer.Signature == ID_FILE_BITMAP_FOOTER && Footer.Version == 0x03) - { - // Get the offset of the bitmap, number of blocks and size of the bitmap - ByteOffset = MAKE_OFFSET64(Footer.MapOffsetHi, Footer.MapOffsetLo); - BlockCount = (DWORD)(((ByteOffset - 1) / Footer.BlockSize) + 1); - BitmapSize = ((BlockCount + 7) / 8); - - // Check if the sizes match - if(ByteOffset + BitmapSize + sizeof(FILE_BITMAP_FOOTER) == pStream->Base.File.FileSize) - { - // Allocate space for the bitmap - FileBitmap = STORM_ALLOC(BYTE, BitmapSize); - if(FileBitmap != NULL) - { - // Load the bitmap bits - if(!pStream->BaseRead(pStream, &ByteOffset, FileBitmap, BitmapSize)) - { - STORM_FREE(FileBitmap); - return false; - } - - // Update the stream size - pStream->BuildNumber = Footer.BuildNumber; - pStream->StreamSize = ByteOffset; - - // Fill the bitmap information - pStream->FileBitmap = FileBitmap; - pStream->BitmapSize = BitmapSize; - pStream->BlockSize = Footer.BlockSize; - pStream->BlockCount = BlockCount; - pStream->IsComplete = FlatStream_CheckFile(pStream); - return true; - } - } - } - } - } - - return false; -} - -static void FlatStream_UpdateBitmap( - TBlockStream * pStream, // Pointer to an open stream - ULONGLONG StartOffset, - ULONGLONG EndOffset) -{ - LPBYTE FileBitmap = (LPBYTE)pStream->FileBitmap; - DWORD BlockIndex; - DWORD BlockSize = pStream->BlockSize; - DWORD ByteIndex; - BYTE BitMask; - - // Sanity checks - assert((StartOffset & (BlockSize - 1)) == 0); - assert(FileBitmap != NULL); - - // Calculate the index of the block - BlockIndex = (DWORD)(StartOffset / BlockSize); - ByteIndex = (BlockIndex / 0x08); - BitMask = (BYTE)(1 << (BlockIndex & 0x07)); - - // Set all bits for the specified range - while(StartOffset < EndOffset) - { - // Set the bit - FileBitmap[ByteIndex] |= BitMask; - - // Move all - StartOffset += BlockSize; - ByteIndex += (BitMask >> 0x07); - BitMask = (BitMask >> 0x07) | (BitMask << 0x01); - } - - // Increment the bitmap update count - pStream->IsModified = 1; -} - -static bool FlatStream_BlockCheck( - TBlockStream * pStream, // Pointer to an open stream - ULONGLONG BlockOffset) -{ - LPBYTE FileBitmap = (LPBYTE)pStream->FileBitmap; - DWORD BlockIndex; - BYTE BitMask; - - // Sanity checks - assert((BlockOffset & (pStream->BlockSize - 1)) == 0); - assert(FileBitmap != NULL); - - // Calculate the index of the block - BlockIndex = (DWORD)(BlockOffset / pStream->BlockSize); - BitMask = (BYTE)(1 << (BlockIndex & 0x07)); - - // Check if the bit is present - return (FileBitmap[BlockIndex / 0x08] & BitMask) ? true : false; -} - -static bool FlatStream_BlockRead( - TBlockStream * pStream, // Pointer to an open stream - ULONGLONG StartOffset, - ULONGLONG EndOffset, - LPBYTE BlockBuffer, - DWORD BytesNeeded, - bool bAvailable) -{ - DWORD BytesToRead = (DWORD)(EndOffset - StartOffset); - - // The starting offset must be aligned to size of the block - assert(pStream->FileBitmap != NULL); - assert((StartOffset & (pStream->BlockSize - 1)) == 0); - assert(StartOffset < EndOffset); - - // If the blocks are not available, we need to load them from the master - // and then save to the mirror - if(bAvailable == false) - { - // If we have no master, we cannot satisfy read request - if(pStream->pMaster == NULL) - return false; - - // Load the blocks from the master stream - // Note that we always have to read complete blocks - // so they get properly stored to the mirror stream - if(!FileStream_Read(pStream->pMaster, &StartOffset, BlockBuffer, BytesToRead)) - return false; - - // Store the loaded blocks to the mirror file. - // Note that this operation is not required to succeed - if(pStream->BaseWrite(pStream, &StartOffset, BlockBuffer, BytesToRead)) - FlatStream_UpdateBitmap(pStream, StartOffset, EndOffset); - - return true; - } - else - { - if(BytesToRead > BytesNeeded) - BytesToRead = BytesNeeded; - return pStream->BaseRead(pStream, &StartOffset, BlockBuffer, BytesToRead); - } -} - -static void FlatStream_Close(TBlockStream * pStream) -{ - FILE_BITMAP_FOOTER Footer; - - if(pStream->FileBitmap && pStream->IsModified) - { - // Write the file bitmap - pStream->BaseWrite(pStream, &pStream->StreamSize, pStream->FileBitmap, pStream->BitmapSize); - - // Prepare and write the file footer - Footer.Signature = ID_FILE_BITMAP_FOOTER; - Footer.Version = 3; - Footer.BuildNumber = pStream->BuildNumber; - Footer.MapOffsetLo = (DWORD)(pStream->StreamSize & 0xFFFFFFFF); - Footer.MapOffsetHi = (DWORD)(pStream->StreamSize >> 0x20); - Footer.BlockSize = pStream->BlockSize; - BSWAP_ARRAY32_UNSIGNED(&Footer, sizeof(FILE_BITMAP_FOOTER)); - pStream->BaseWrite(pStream, NULL, &Footer, sizeof(FILE_BITMAP_FOOTER)); - } - - // Close the base class - BlockStream_Close(pStream); -} - -static bool FlatStream_CreateMirror(TBlockStream * pStream) -{ - ULONGLONG MasterSize = 0; - ULONGLONG MirrorSize = 0; - LPBYTE FileBitmap = NULL; - DWORD dwBitmapSize; - DWORD dwBlockCount; - bool bNeedCreateMirrorStream = true; - bool bNeedResizeMirrorStream = true; - - // Do we have master function and base creation function? - if(pStream->pMaster == NULL || pStream->BaseCreate == NULL) - return false; - - // Retrieve the master file size, block count and bitmap size - FileStream_GetSize(pStream->pMaster, &MasterSize); - dwBlockCount = (DWORD)((MasterSize + DEFAULT_BLOCK_SIZE - 1) / DEFAULT_BLOCK_SIZE); - dwBitmapSize = (DWORD)((dwBlockCount + 7) / 8); - - // Setup stream size and position - pStream->BuildNumber = DEFAULT_BUILD_NUMBER; // BUGBUG: Really??? - pStream->StreamSize = MasterSize; - pStream->StreamPos = 0; - - // Open the base stream for write access - if(pStream->BaseOpen(pStream, pStream->szFileName, 0)) - { - // If the file open succeeded, check if the file size matches required size - pStream->BaseGetSize(pStream, &MirrorSize); - if(MirrorSize == MasterSize + dwBitmapSize + sizeof(FILE_BITMAP_FOOTER)) - { - // Attempt to load an existing file bitmap - if(FlatStream_LoadBitmap(pStream)) - return true; - - // We need to create new file bitmap - bNeedResizeMirrorStream = false; - } - - // We need to create mirror stream - bNeedCreateMirrorStream = false; - } - - // Create a new stream, if needed - if(bNeedCreateMirrorStream) - { - if(!pStream->BaseCreate(pStream)) - return false; - } - - // If we need to, then resize the mirror stream - if(bNeedResizeMirrorStream) - { - if(!pStream->BaseResize(pStream, MasterSize + dwBitmapSize + sizeof(FILE_BITMAP_FOOTER))) - return false; - } - - // Allocate the bitmap array - FileBitmap = STORM_ALLOC(BYTE, dwBitmapSize); - if(FileBitmap == NULL) - return false; - - // Initialize the bitmap - memset(FileBitmap, 0, dwBitmapSize); - pStream->FileBitmap = FileBitmap; - pStream->BitmapSize = dwBitmapSize; - pStream->BlockSize = DEFAULT_BLOCK_SIZE; - pStream->BlockCount = dwBlockCount; - pStream->IsComplete = 0; - pStream->IsModified = 1; - - // Note: Don't write the stream bitmap right away. - // Doing so would cause sparse file resize on NTFS, - // which would take long time on larger files. - return true; -} - -static TFileStream * FlatStream_Open(const TCHAR * szFileName, DWORD dwStreamFlags) -{ - TBlockStream * pStream; - ULONGLONG ByteOffset = 0; - - // Create new empty stream - pStream = (TBlockStream *)AllocateFileStream(szFileName, sizeof(TBlockStream), dwStreamFlags); - if(pStream == NULL) - return NULL; - - // Do we have a master stream? - if(pStream->pMaster != NULL) - { - if(!FlatStream_CreateMirror(pStream)) - { - FileStream_Close(pStream); - SetLastError(ERROR_FILE_NOT_FOUND); - return NULL; - } - } - else - { - // Attempt to open the base stream - if(!pStream->BaseOpen(pStream, pStream->szFileName, dwStreamFlags)) - { - FileStream_Close(pStream); - return NULL; - } - - // Load the bitmap, if required to - if(dwStreamFlags & STREAM_FLAG_USE_BITMAP) - FlatStream_LoadBitmap(pStream); - } - - // If we have a stream bitmap, set the reading functions - // which check presence of each file block - if(pStream->FileBitmap != NULL) - { - // Set the stream position to zero. Stream size is already set - assert(pStream->StreamSize != 0); - pStream->StreamPos = 0; - pStream->dwFlags |= STREAM_FLAG_READ_ONLY; - - // Supply the stream functions - pStream->StreamRead = (STREAM_READ)BlockStream_Read; - pStream->StreamGetSize = BlockStream_GetSize; - pStream->StreamGetPos = BlockStream_GetPos; - pStream->StreamClose = (STREAM_CLOSE)FlatStream_Close; - - // Supply the block functions - pStream->BlockCheck = (BLOCK_CHECK)FlatStream_BlockCheck; - pStream->BlockRead = (BLOCK_READ)FlatStream_BlockRead; - } - else - { - // Reset the base position to zero - pStream->BaseRead(pStream, &ByteOffset, NULL, 0); - - // Setup stream size and position - pStream->StreamSize = pStream->Base.File.FileSize; - pStream->StreamPos = 0; - - // Set the base functions - pStream->StreamRead = pStream->BaseRead; - pStream->StreamWrite = pStream->BaseWrite; - pStream->StreamResize = pStream->BaseResize; - pStream->StreamGetSize = pStream->BaseGetSize; - pStream->StreamGetPos = pStream->BaseGetPos; - pStream->StreamClose = pStream->BaseClose; - } - - return pStream; -} - -//----------------------------------------------------------------------------- -// Local functions - partial stream support - -static bool IsPartHeader(PPART_FILE_HEADER pPartHdr) -{ - // Version number must be 2 - if(pPartHdr->PartialVersion == 2) - { - // GameBuildNumber must be an ASCII number - if(isdigit(pPartHdr->GameBuildNumber[0]) && isdigit(pPartHdr->GameBuildNumber[1]) && isdigit(pPartHdr->GameBuildNumber[2])) - { - // Block size must be power of 2 - if((pPartHdr->BlockSize & (pPartHdr->BlockSize - 1)) == 0) - return true; - } - } - - return false; -} - -static DWORD PartStream_CheckFile(TBlockStream * pStream) -{ - PPART_FILE_MAP_ENTRY FileBitmap = (PPART_FILE_MAP_ENTRY)pStream->FileBitmap; - DWORD dwBlockCount; - - // Get the number of blocks - dwBlockCount = (DWORD)((pStream->StreamSize + pStream->BlockSize - 1) / pStream->BlockSize); - - // Check all blocks - for(DWORD i = 0; i < dwBlockCount; i++, FileBitmap++) - { - // Few sanity checks - assert(FileBitmap->LargeValueHi == 0); - assert(FileBitmap->LargeValueLo == 0); - assert(FileBitmap->Flags == 0 || FileBitmap->Flags == 3); - - // Check if this block is present - if(FileBitmap->Flags != 3) - return 0; - } - - // Yes, the file is complete - return 1; -} - -static bool PartStream_LoadBitmap(TBlockStream * pStream) -{ - PPART_FILE_MAP_ENTRY FileBitmap; - PART_FILE_HEADER PartHdr; - ULONGLONG ByteOffset = 0; - ULONGLONG StreamSize = 0; - DWORD BlockCount; - DWORD BitmapSize; - - // Only if the size is greater than size of the bitmap header - if(pStream->Base.File.FileSize > sizeof(PART_FILE_HEADER)) - { - // Attempt to read PART file header - if(pStream->BaseRead(pStream, &ByteOffset, &PartHdr, sizeof(PART_FILE_HEADER))) - { - // We need to swap PART file header on big-endian platforms - BSWAP_ARRAY32_UNSIGNED(&PartHdr, sizeof(PART_FILE_HEADER)); - - // Verify the PART file header - if(IsPartHeader(&PartHdr)) - { - // Get the number of blocks and size of one block - StreamSize = MAKE_OFFSET64(PartHdr.FileSizeHi, PartHdr.FileSizeLo); - ByteOffset = sizeof(PART_FILE_HEADER); - BlockCount = (DWORD)((StreamSize + PartHdr.BlockSize - 1) / PartHdr.BlockSize); - BitmapSize = BlockCount * sizeof(PART_FILE_MAP_ENTRY); - - // Check if sizes match - if((ByteOffset + BitmapSize) < pStream->Base.File.FileSize) - { - // Allocate space for the array of PART_FILE_MAP_ENTRY - FileBitmap = STORM_ALLOC(PART_FILE_MAP_ENTRY, BlockCount); - if(FileBitmap != NULL) - { - // Load the block map - if(!pStream->BaseRead(pStream, &ByteOffset, FileBitmap, BitmapSize)) - { - STORM_FREE(FileBitmap); - return false; - } - - // Make sure that the byte order is correct - BSWAP_ARRAY32_UNSIGNED(FileBitmap, BitmapSize); - - // Update the stream size - pStream->BuildNumber = StringToInt(PartHdr.GameBuildNumber); - pStream->StreamSize = StreamSize; - - // Fill the bitmap information - pStream->FileBitmap = FileBitmap; - pStream->BitmapSize = BitmapSize; - pStream->BlockSize = PartHdr.BlockSize; - pStream->BlockCount = BlockCount; - pStream->IsComplete = PartStream_CheckFile(pStream); - return true; - } - } - } - } - } - - return false; -} - -static void PartStream_UpdateBitmap( - TBlockStream * pStream, // Pointer to an open stream - ULONGLONG StartOffset, - ULONGLONG EndOffset, - ULONGLONG RealOffset) -{ - PPART_FILE_MAP_ENTRY FileBitmap; - DWORD BlockSize = pStream->BlockSize; - - // Sanity checks - assert((StartOffset & (BlockSize - 1)) == 0); - assert(pStream->FileBitmap != NULL); - - // Calculate the first entry in the block map - FileBitmap = (PPART_FILE_MAP_ENTRY)pStream->FileBitmap + (StartOffset / BlockSize); - - // Set all bits for the specified range - while(StartOffset < EndOffset) - { - // Set the bit - FileBitmap->BlockOffsHi = (DWORD)(RealOffset >> 0x20); - FileBitmap->BlockOffsLo = (DWORD)(RealOffset & 0xFFFFFFFF); - FileBitmap->Flags = 3; - - // Move all - StartOffset += BlockSize; - RealOffset += BlockSize; - FileBitmap++; - } - - // Increment the bitmap update count - pStream->IsModified = 1; -} - -static bool PartStream_BlockCheck( - TBlockStream * pStream, // Pointer to an open stream - ULONGLONG BlockOffset) -{ - PPART_FILE_MAP_ENTRY FileBitmap; - - // Sanity checks - assert((BlockOffset & (pStream->BlockSize - 1)) == 0); - assert(pStream->FileBitmap != NULL); - - // Calculate the block map entry - FileBitmap = (PPART_FILE_MAP_ENTRY)pStream->FileBitmap + (BlockOffset / pStream->BlockSize); - - // Check if the flags are present - return (FileBitmap->Flags & 0x03) ? true : false; -} - -static bool PartStream_BlockRead( - TBlockStream * pStream, - ULONGLONG StartOffset, - ULONGLONG EndOffset, - LPBYTE BlockBuffer, - DWORD BytesNeeded, - bool bAvailable) -{ - PPART_FILE_MAP_ENTRY FileBitmap; - ULONGLONG ByteOffset; - DWORD BytesToRead; - DWORD BlockIndex = (DWORD)(StartOffset / pStream->BlockSize); - - // The starting offset must be aligned to size of the block - assert(pStream->FileBitmap != NULL); - assert((StartOffset & (pStream->BlockSize - 1)) == 0); - assert(StartOffset < EndOffset); - - // If the blocks are not available, we need to load them from the master - // and then save to the mirror - if(bAvailable == false) - { - // If we have no master, we cannot satisfy read request - if(pStream->pMaster == NULL) - return false; - - // Load the blocks from the master stream - // Note that we always have to read complete blocks - // so they get properly stored to the mirror stream - BytesToRead = (DWORD)(EndOffset - StartOffset); - if(!FileStream_Read(pStream->pMaster, &StartOffset, BlockBuffer, BytesToRead)) - return false; - - // The loaded blocks are going to be stored to the end of the file - // Note that this operation is not required to succeed - if(pStream->BaseGetSize(pStream, &ByteOffset)) - { - // Store the loaded blocks to the mirror file. - if(pStream->BaseWrite(pStream, &ByteOffset, BlockBuffer, BytesToRead)) - { - PartStream_UpdateBitmap(pStream, StartOffset, EndOffset, ByteOffset); - } - } - } - else - { - // Get the file map entry - FileBitmap = (PPART_FILE_MAP_ENTRY)pStream->FileBitmap + BlockIndex; - - // Read all blocks - while(StartOffset < EndOffset) - { - // Get the number of bytes to be read - BytesToRead = (DWORD)(EndOffset - StartOffset); - if(BytesToRead > pStream->BlockSize) - BytesToRead = pStream->BlockSize; - if(BytesToRead > BytesNeeded) - BytesToRead = BytesNeeded; - - // Read the block - ByteOffset = MAKE_OFFSET64(FileBitmap->BlockOffsHi, FileBitmap->BlockOffsLo); - if(!pStream->BaseRead(pStream, &ByteOffset, BlockBuffer, BytesToRead)) - return false; - - // Move the pointers - StartOffset += pStream->BlockSize; - BlockBuffer += pStream->BlockSize; - BytesNeeded -= pStream->BlockSize; - FileBitmap++; - } - } - - return true; -} - -static void PartStream_Close(TBlockStream * pStream) -{ - PART_FILE_HEADER PartHeader; - ULONGLONG ByteOffset = 0; - - if(pStream->FileBitmap && pStream->IsModified) - { - // Prepare the part file header - memset(&PartHeader, 0, sizeof(PART_FILE_HEADER)); - PartHeader.PartialVersion = 2; - PartHeader.FileSizeHi = (DWORD)(pStream->StreamSize >> 0x20); - PartHeader.FileSizeLo = (DWORD)(pStream->StreamSize & 0xFFFFFFFF); - PartHeader.BlockSize = pStream->BlockSize; - - // Make sure that the header is properly BSWAPed - BSWAP_ARRAY32_UNSIGNED(&PartHeader, sizeof(PART_FILE_HEADER)); - sprintf(PartHeader.GameBuildNumber, "%u", (unsigned int)pStream->BuildNumber); - - // Write the part header - pStream->BaseWrite(pStream, &ByteOffset, &PartHeader, sizeof(PART_FILE_HEADER)); - - // Write the block bitmap - BSWAP_ARRAY32_UNSIGNED(pStream->FileBitmap, pStream->BitmapSize); - pStream->BaseWrite(pStream, NULL, pStream->FileBitmap, pStream->BitmapSize); - } - - // Close the base class - BlockStream_Close(pStream); -} - -static bool PartStream_CreateMirror(TBlockStream * pStream) -{ - ULONGLONG RemainingSize; - ULONGLONG MasterSize = 0; - ULONGLONG MirrorSize = 0; - LPBYTE FileBitmap = NULL; - DWORD dwBitmapSize; - DWORD dwBlockCount; - bool bNeedCreateMirrorStream = true; - bool bNeedResizeMirrorStream = true; - - // Do we have master function and base creation function? - if(pStream->pMaster == NULL || pStream->BaseCreate == NULL) - return false; - - // Retrieve the master file size, block count and bitmap size - FileStream_GetSize(pStream->pMaster, &MasterSize); - dwBlockCount = (DWORD)((MasterSize + DEFAULT_BLOCK_SIZE - 1) / DEFAULT_BLOCK_SIZE); - dwBitmapSize = (DWORD)(dwBlockCount * sizeof(PART_FILE_MAP_ENTRY)); - - // Setup stream size and position - pStream->BuildNumber = DEFAULT_BUILD_NUMBER; // BUGBUG: Really??? - pStream->StreamSize = MasterSize; - pStream->StreamPos = 0; - - // Open the base stream for write access - if(pStream->BaseOpen(pStream, pStream->szFileName, 0)) - { - // If the file open succeeded, check if the file size matches required size - pStream->BaseGetSize(pStream, &MirrorSize); - if(MirrorSize >= sizeof(PART_FILE_HEADER) + dwBitmapSize) - { - // Check if the remaining size is aligned to block - RemainingSize = MirrorSize - sizeof(PART_FILE_HEADER) - dwBitmapSize; - if((RemainingSize & (DEFAULT_BLOCK_SIZE - 1)) == 0 || RemainingSize == MasterSize) - { - // Attempt to load an existing file bitmap - if(PartStream_LoadBitmap(pStream)) - return true; - } - } - - // We need to create mirror stream - bNeedCreateMirrorStream = false; - } - - // Create a new stream, if needed - if(bNeedCreateMirrorStream) - { - if(!pStream->BaseCreate(pStream)) - return false; - } - - // If we need to, then resize the mirror stream - if(bNeedResizeMirrorStream) - { - if(!pStream->BaseResize(pStream, sizeof(PART_FILE_HEADER) + dwBitmapSize)) - return false; - } - - // Allocate the bitmap array - FileBitmap = STORM_ALLOC(BYTE, dwBitmapSize); - if(FileBitmap == NULL) - return false; - - // Initialize the bitmap - memset(FileBitmap, 0, dwBitmapSize); - pStream->FileBitmap = FileBitmap; - pStream->BitmapSize = dwBitmapSize; - pStream->BlockSize = DEFAULT_BLOCK_SIZE; - pStream->BlockCount = dwBlockCount; - pStream->IsComplete = 0; - pStream->IsModified = 1; - - // Note: Don't write the stream bitmap right away. - // Doing so would cause sparse file resize on NTFS, - // which would take long time on larger files. - return true; -} - - -static TFileStream * PartStream_Open(const TCHAR * szFileName, DWORD dwStreamFlags) -{ - TBlockStream * pStream; - - // Create new empty stream - pStream = (TBlockStream *)AllocateFileStream(szFileName, sizeof(TBlockStream), dwStreamFlags); - if(pStream == NULL) - return NULL; - - // Do we have a master stream? - if(pStream->pMaster != NULL) - { - if(!PartStream_CreateMirror(pStream)) - { - FileStream_Close(pStream); - SetLastError(ERROR_FILE_NOT_FOUND); - return NULL; - } - } - else - { - // Attempt to open the base stream - if(!pStream->BaseOpen(pStream, pStream->szFileName, dwStreamFlags)) - { - FileStream_Close(pStream); - return NULL; - } - - // Load the part stream block map - if(!PartStream_LoadBitmap(pStream)) - { - FileStream_Close(pStream); - SetLastError(ERROR_BAD_FORMAT); - return NULL; - } - } - - // Set the stream position to zero. Stream size is already set - assert(pStream->StreamSize != 0); - pStream->StreamPos = 0; - pStream->dwFlags |= STREAM_FLAG_READ_ONLY; - - // Set new function pointers - pStream->StreamRead = (STREAM_READ)BlockStream_Read; - pStream->StreamGetPos = BlockStream_GetPos; - pStream->StreamGetSize = BlockStream_GetSize; - pStream->StreamClose = (STREAM_CLOSE)PartStream_Close; - - // Supply the block functions - pStream->BlockCheck = (BLOCK_CHECK)PartStream_BlockCheck; - pStream->BlockRead = (BLOCK_READ)PartStream_BlockRead; - return pStream; -} - -//----------------------------------------------------------------------------- -// Local functions - MPQE stream support - -static const char * szKeyTemplate = "expand 32-byte k000000000000000000000000000000000000000000000000"; - -static const char * AuthCodeArray[] = -{ - // Starcraft II (Heart of the Swarm) - // Authentication code URL: http://dist.blizzard.com/mediakey/hots-authenticationcode-bgdl.txt - // -0C- -1C--08- -18--04- -14--00- -10- - "S48B6CDTN5XEQAKQDJNDLJBJ73FDFM3U", // SC2 Heart of the Swarm-all : "expand 32-byte kQAKQ0000FM3UN5XE000073FD6CDT0000LJBJS48B0000DJND" - - // Diablo III: Agent.exe (1.0.0.954) - // Address of decryption routine: 00502b00 - // Pointer to decryptor object: ECX - // Pointer to key: ECX+0x5C - // Authentication code URL: http://dist.blizzard.com/mediakey/d3-authenticationcode-enGB.txt - // -0C- -1C--08- -18--04- -14--00- -10- - "UCMXF6EJY352EFH4XFRXCFH2XC9MQRZK", // Diablo III Installer (deDE): "expand 32-byte kEFH40000QRZKY3520000XC9MF6EJ0000CFH2UCMX0000XFRX" - "MMKVHY48RP7WXP4GHYBQ7SL9J9UNPHBP", // Diablo III Installer (enGB): "expand 32-byte kXP4G0000PHBPRP7W0000J9UNHY4800007SL9MMKV0000HYBQ" - "8MXLWHQ7VGGLTZ9MQZQSFDCLJYET3CPP", // Diablo III Installer (enSG): "expand 32-byte kTZ9M00003CPPVGGL0000JYETWHQ70000FDCL8MXL0000QZQS" - "EJ2R5TM6XFE2GUNG5QDGHKQ9UAKPWZSZ", // Diablo III Installer (enUS): "expand 32-byte kGUNG0000WZSZXFE20000UAKP5TM60000HKQ9EJ2R00005QDG" - "PBGFBE42Z6LNK65UGJQ3WZVMCLP4HQQT", // Diablo III Installer (esES): "expand 32-byte kK65U0000HQQTZ6LN0000CLP4BE420000WZVMPBGF0000GJQ3" - "X7SEJJS9TSGCW5P28EBSC47AJPEY8VU2", // Diablo III Installer (esMX): "expand 32-byte kW5P200008VU2TSGC0000JPEYJJS90000C47AX7SE00008EBS" - "5KVBQA8VYE6XRY3DLGC5ZDE4XS4P7YA2", // Diablo III Installer (frFR): "expand 32-byte kRY3D00007YA2YE6X0000XS4PQA8V0000ZDE45KVB0000LGC5" - "478JD2K56EVNVVY4XX8TDWYT5B8KB254", // Diablo III Installer (itIT): "expand 32-byte kVVY40000B2546EVN00005B8KD2K50000DWYT478J0000XX8T" - "8TS4VNFQRZTN6YWHE9CHVDH9NVWD474A", // Diablo III Installer (koKR): "expand 32-byte k6YWH0000474ARZTN0000NVWDVNFQ0000VDH98TS40000E9CH" - "LJ52Z32DF4LZ4ZJJXVKK3AZQA6GABLJB", // Diablo III Installer (plPL): "expand 32-byte k4ZJJ0000BLJBF4LZ0000A6GAZ32D00003AZQLJ520000XVKK" - "K6BDHY2ECUE2545YKNLBJPVYWHE7XYAG", // Diablo III Installer (ptBR): "expand 32-byte k545Y0000XYAGCUE20000WHE7HY2E0000JPVYK6BD0000KNLB" - "NDVW8GWLAYCRPGRNY8RT7ZZUQU63VLPR", // Diablo III Installer (ruRU): "expand 32-byte kXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" - "6VWCQTN8V3ZZMRUCZXV8A8CGUX2TAA8H", // Diablo III Installer (zhTW): "expand 32-byte kMRUC0000AA8HV3ZZ0000UX2TQTN80000A8CG6VWC0000ZXV8" -// "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", // Diablo III Installer (zhCN): "expand 32-byte kXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" - - // Starcraft II (Wings of Liberty): Installer.exe (4.1.1.4219) - // Address of decryption routine: 0053A3D0 - // Pointer to decryptor object: ECX - // Pointer to key: ECX+0x5C - // Authentication code URL: http://dist.blizzard.com/mediakey/sc2-authenticationcode-enUS.txt - // -0C- -1C--08- -18--04- -14--00- -10- - "Y45MD3CAK4KXSSXHYD9VY64Z8EKJ4XFX", // SC2 Wings of Liberty (deDE): "expand 32-byte kSSXH00004XFXK4KX00008EKJD3CA0000Y64ZY45M0000YD9V" - "G8MN8UDG6NA2ANGY6A3DNY82HRGF29ZH", // SC2 Wings of Liberty (enGB): "expand 32-byte kANGY000029ZH6NA20000HRGF8UDG0000NY82G8MN00006A3D" - "W9RRHLB2FDU9WW5B3ECEBLRSFWZSF7HW", // SC2 Wings of Liberty (enSG): "expand 32-byte kWW5B0000F7HWFDU90000FWZSHLB20000BLRSW9RR00003ECE" - "3DH5RE5NVM5GTFD85LXGWT6FK859ETR5", // SC2 Wings of Liberty (enUS): "expand 32-byte kTFD80000ETR5VM5G0000K859RE5N0000WT6F3DH500005LXG" - "8WLKUAXE94PFQU4Y249PAZ24N4R4XKTQ", // SC2 Wings of Liberty (esES): "expand 32-byte kQU4Y0000XKTQ94PF0000N4R4UAXE0000AZ248WLK0000249P" - "A34DXX3VHGGXSQBRFE5UFFDXMF9G4G54", // SC2 Wings of Liberty (esMX): "expand 32-byte kSQBR00004G54HGGX0000MF9GXX3V0000FFDXA34D0000FE5U" - "ZG7J9K938HJEFWPQUA768MA2PFER6EAJ", // SC2 Wings of Liberty (frFR): "expand 32-byte kFWPQ00006EAJ8HJE0000PFER9K9300008MA2ZG7J0000UA76" - "NE7CUNNNTVAPXV7E3G2BSVBWGVMW8BL2", // SC2 Wings of Liberty (itIT): "expand 32-byte kXV7E00008BL2TVAP0000GVMWUNNN0000SVBWNE7C00003G2B" - "3V9E2FTMBM9QQWK7U6MAMWAZWQDB838F", // SC2 Wings of Liberty (koKR): "expand 32-byte kQWK70000838FBM9Q0000WQDB2FTM0000MWAZ3V9E0000U6MA" - "2NSFB8MELULJ83U6YHA3UP6K4MQD48L6", // SC2 Wings of Liberty (plPL): "expand 32-byte k83U6000048L6LULJ00004MQDB8ME0000UP6K2NSF0000YHA3" - "QA2TZ9EWZ4CUU8BMB5WXCTY65F9CSW4E", // SC2 Wings of Liberty (ptBR): "expand 32-byte kU8BM0000SW4EZ4CU00005F9CZ9EW0000CTY6QA2T0000B5WX" - "VHB378W64BAT9SH7D68VV9NLQDK9YEGT", // SC2 Wings of Liberty (ruRU): "expand 32-byte k9SH70000YEGT4BAT0000QDK978W60000V9NLVHB30000D68V" - "U3NFQJV4M6GC7KBN9XQJ3BRDN3PLD9NE", // SC2 Wings of Liberty (zhTW): "expand 32-byte k7KBN0000D9NEM6GC0000N3PLQJV400003BRDU3NF00009XQJ" - - NULL -}; - -static DWORD Rol32(DWORD dwValue, DWORD dwRolCount) -{ - DWORD dwShiftRight = 32 - dwRolCount; - - return (dwValue << dwRolCount) | (dwValue >> dwShiftRight); -} - -static void CreateKeyFromAuthCode( - LPBYTE pbKeyBuffer, - const char * szAuthCode) -{ - LPDWORD KeyPosition = (LPDWORD)(pbKeyBuffer + 0x10); - LPDWORD AuthCode32 = (LPDWORD)szAuthCode; - - memcpy(pbKeyBuffer, szKeyTemplate, MPQE_CHUNK_SIZE); - KeyPosition[0x00] = AuthCode32[0x03]; - KeyPosition[0x02] = AuthCode32[0x07]; - KeyPosition[0x03] = AuthCode32[0x02]; - KeyPosition[0x05] = AuthCode32[0x06]; - KeyPosition[0x06] = AuthCode32[0x01]; - KeyPosition[0x08] = AuthCode32[0x05]; - KeyPosition[0x09] = AuthCode32[0x00]; - KeyPosition[0x0B] = AuthCode32[0x04]; - BSWAP_ARRAY32_UNSIGNED(pbKeyBuffer, MPQE_CHUNK_SIZE); -} - -static void DecryptFileChunk( - DWORD * MpqData, - LPBYTE pbKey, - ULONGLONG ByteOffset, - DWORD dwLength) -{ - ULONGLONG ChunkOffset; - DWORD KeyShuffled[0x10]; - DWORD KeyMirror[0x10]; - DWORD RoundCount = 0x14; - - // Prepare the key - ChunkOffset = ByteOffset / MPQE_CHUNK_SIZE; - memcpy(KeyMirror, pbKey, MPQE_CHUNK_SIZE); - BSWAP_ARRAY32_UNSIGNED(KeyMirror, MPQE_CHUNK_SIZE); - KeyMirror[0x05] = (DWORD)(ChunkOffset >> 32); - KeyMirror[0x08] = (DWORD)(ChunkOffset); - - while(dwLength >= MPQE_CHUNK_SIZE) - { - // Shuffle the key - part 1 - KeyShuffled[0x0E] = KeyMirror[0x00]; - KeyShuffled[0x0C] = KeyMirror[0x01]; - KeyShuffled[0x05] = KeyMirror[0x02]; - KeyShuffled[0x0F] = KeyMirror[0x03]; - KeyShuffled[0x0A] = KeyMirror[0x04]; - KeyShuffled[0x07] = KeyMirror[0x05]; - KeyShuffled[0x0B] = KeyMirror[0x06]; - KeyShuffled[0x09] = KeyMirror[0x07]; - KeyShuffled[0x03] = KeyMirror[0x08]; - KeyShuffled[0x06] = KeyMirror[0x09]; - KeyShuffled[0x08] = KeyMirror[0x0A]; - KeyShuffled[0x0D] = KeyMirror[0x0B]; - KeyShuffled[0x02] = KeyMirror[0x0C]; - KeyShuffled[0x04] = KeyMirror[0x0D]; - KeyShuffled[0x01] = KeyMirror[0x0E]; - KeyShuffled[0x00] = KeyMirror[0x0F]; - - // Shuffle the key - part 2 - for(DWORD i = 0; i < RoundCount; i += 2) - { - KeyShuffled[0x0A] = KeyShuffled[0x0A] ^ Rol32((KeyShuffled[0x0E] + KeyShuffled[0x02]), 0x07); - KeyShuffled[0x03] = KeyShuffled[0x03] ^ Rol32((KeyShuffled[0x0A] + KeyShuffled[0x0E]), 0x09); - KeyShuffled[0x02] = KeyShuffled[0x02] ^ Rol32((KeyShuffled[0x03] + KeyShuffled[0x0A]), 0x0D); - KeyShuffled[0x0E] = KeyShuffled[0x0E] ^ Rol32((KeyShuffled[0x02] + KeyShuffled[0x03]), 0x12); - - KeyShuffled[0x07] = KeyShuffled[0x07] ^ Rol32((KeyShuffled[0x0C] + KeyShuffled[0x04]), 0x07); - KeyShuffled[0x06] = KeyShuffled[0x06] ^ Rol32((KeyShuffled[0x07] + KeyShuffled[0x0C]), 0x09); - KeyShuffled[0x04] = KeyShuffled[0x04] ^ Rol32((KeyShuffled[0x06] + KeyShuffled[0x07]), 0x0D); - KeyShuffled[0x0C] = KeyShuffled[0x0C] ^ Rol32((KeyShuffled[0x04] + KeyShuffled[0x06]), 0x12); - - KeyShuffled[0x0B] = KeyShuffled[0x0B] ^ Rol32((KeyShuffled[0x05] + KeyShuffled[0x01]), 0x07); - KeyShuffled[0x08] = KeyShuffled[0x08] ^ Rol32((KeyShuffled[0x0B] + KeyShuffled[0x05]), 0x09); - KeyShuffled[0x01] = KeyShuffled[0x01] ^ Rol32((KeyShuffled[0x08] + KeyShuffled[0x0B]), 0x0D); - KeyShuffled[0x05] = KeyShuffled[0x05] ^ Rol32((KeyShuffled[0x01] + KeyShuffled[0x08]), 0x12); - - KeyShuffled[0x09] = KeyShuffled[0x09] ^ Rol32((KeyShuffled[0x0F] + KeyShuffled[0x00]), 0x07); - KeyShuffled[0x0D] = KeyShuffled[0x0D] ^ Rol32((KeyShuffled[0x09] + KeyShuffled[0x0F]), 0x09); - KeyShuffled[0x00] = KeyShuffled[0x00] ^ Rol32((KeyShuffled[0x0D] + KeyShuffled[0x09]), 0x0D); - KeyShuffled[0x0F] = KeyShuffled[0x0F] ^ Rol32((KeyShuffled[0x00] + KeyShuffled[0x0D]), 0x12); - - KeyShuffled[0x04] = KeyShuffled[0x04] ^ Rol32((KeyShuffled[0x0E] + KeyShuffled[0x09]), 0x07); - KeyShuffled[0x08] = KeyShuffled[0x08] ^ Rol32((KeyShuffled[0x04] + KeyShuffled[0x0E]), 0x09); - KeyShuffled[0x09] = KeyShuffled[0x09] ^ Rol32((KeyShuffled[0x08] + KeyShuffled[0x04]), 0x0D); - KeyShuffled[0x0E] = KeyShuffled[0x0E] ^ Rol32((KeyShuffled[0x09] + KeyShuffled[0x08]), 0x12); - - KeyShuffled[0x01] = KeyShuffled[0x01] ^ Rol32((KeyShuffled[0x0C] + KeyShuffled[0x0A]), 0x07); - KeyShuffled[0x0D] = KeyShuffled[0x0D] ^ Rol32((KeyShuffled[0x01] + KeyShuffled[0x0C]), 0x09); - KeyShuffled[0x0A] = KeyShuffled[0x0A] ^ Rol32((KeyShuffled[0x0D] + KeyShuffled[0x01]), 0x0D); - KeyShuffled[0x0C] = KeyShuffled[0x0C] ^ Rol32((KeyShuffled[0x0A] + KeyShuffled[0x0D]), 0x12); - - KeyShuffled[0x00] = KeyShuffled[0x00] ^ Rol32((KeyShuffled[0x05] + KeyShuffled[0x07]), 0x07); - KeyShuffled[0x03] = KeyShuffled[0x03] ^ Rol32((KeyShuffled[0x00] + KeyShuffled[0x05]), 0x09); - KeyShuffled[0x07] = KeyShuffled[0x07] ^ Rol32((KeyShuffled[0x03] + KeyShuffled[0x00]), 0x0D); - KeyShuffled[0x05] = KeyShuffled[0x05] ^ Rol32((KeyShuffled[0x07] + KeyShuffled[0x03]), 0x12); - - KeyShuffled[0x02] = KeyShuffled[0x02] ^ Rol32((KeyShuffled[0x0F] + KeyShuffled[0x0B]), 0x07); - KeyShuffled[0x06] = KeyShuffled[0x06] ^ Rol32((KeyShuffled[0x02] + KeyShuffled[0x0F]), 0x09); - KeyShuffled[0x0B] = KeyShuffled[0x0B] ^ Rol32((KeyShuffled[0x06] + KeyShuffled[0x02]), 0x0D); - KeyShuffled[0x0F] = KeyShuffled[0x0F] ^ Rol32((KeyShuffled[0x0B] + KeyShuffled[0x06]), 0x12); - } - - // Decrypt one data chunk - BSWAP_ARRAY32_UNSIGNED(MpqData, MPQE_CHUNK_SIZE); - MpqData[0x00] = MpqData[0x00] ^ (KeyShuffled[0x0E] + KeyMirror[0x00]); - MpqData[0x01] = MpqData[0x01] ^ (KeyShuffled[0x04] + KeyMirror[0x0D]); - MpqData[0x02] = MpqData[0x02] ^ (KeyShuffled[0x08] + KeyMirror[0x0A]); - MpqData[0x03] = MpqData[0x03] ^ (KeyShuffled[0x09] + KeyMirror[0x07]); - MpqData[0x04] = MpqData[0x04] ^ (KeyShuffled[0x0A] + KeyMirror[0x04]); - MpqData[0x05] = MpqData[0x05] ^ (KeyShuffled[0x0C] + KeyMirror[0x01]); - MpqData[0x06] = MpqData[0x06] ^ (KeyShuffled[0x01] + KeyMirror[0x0E]); - MpqData[0x07] = MpqData[0x07] ^ (KeyShuffled[0x0D] + KeyMirror[0x0B]); - MpqData[0x08] = MpqData[0x08] ^ (KeyShuffled[0x03] + KeyMirror[0x08]); - MpqData[0x09] = MpqData[0x09] ^ (KeyShuffled[0x07] + KeyMirror[0x05]); - MpqData[0x0A] = MpqData[0x0A] ^ (KeyShuffled[0x05] + KeyMirror[0x02]); - MpqData[0x0B] = MpqData[0x0B] ^ (KeyShuffled[0x00] + KeyMirror[0x0F]); - MpqData[0x0C] = MpqData[0x0C] ^ (KeyShuffled[0x02] + KeyMirror[0x0C]); - MpqData[0x0D] = MpqData[0x0D] ^ (KeyShuffled[0x06] + KeyMirror[0x09]); - MpqData[0x0E] = MpqData[0x0E] ^ (KeyShuffled[0x0B] + KeyMirror[0x06]); - MpqData[0x0F] = MpqData[0x0F] ^ (KeyShuffled[0x0F] + KeyMirror[0x03]); - BSWAP_ARRAY32_UNSIGNED(MpqData, MPQE_CHUNK_SIZE); - - // Update byte offset in the key - KeyMirror[0x08]++; - if(KeyMirror[0x08] == 0) - KeyMirror[0x05]++; - - // Move pointers and decrease number of bytes to decrypt - MpqData += (MPQE_CHUNK_SIZE / sizeof(DWORD)); - dwLength -= MPQE_CHUNK_SIZE; - } -} - -static bool MpqeStream_DetectFileKey(TEncryptedStream * pStream) -{ - ULONGLONG ByteOffset = 0; - BYTE EncryptedHeader[MPQE_CHUNK_SIZE]; - BYTE FileHeader[MPQE_CHUNK_SIZE]; - - // Read the first file chunk - if(pStream->BaseRead(pStream, &ByteOffset, EncryptedHeader, sizeof(EncryptedHeader))) - { - // We just try all known keys one by one - for(int i = 0; AuthCodeArray[i] != NULL; i++) - { - // Prepare they decryption key from game serial number - CreateKeyFromAuthCode(pStream->Key, AuthCodeArray[i]); - - // Try to decrypt with the given key - memcpy(FileHeader, EncryptedHeader, MPQE_CHUNK_SIZE); - DecryptFileChunk((LPDWORD)FileHeader, pStream->Key, ByteOffset, MPQE_CHUNK_SIZE); - - // We check the decrypted data - // All known encrypted MPQs have header at the begin of the file, - // so we check for MPQ signature there. - if(FileHeader[0] == 'M' && FileHeader[1] == 'P' && FileHeader[2] == 'Q') - { - // Update the stream size - pStream->StreamSize = pStream->Base.File.FileSize; - - // Fill the block information - pStream->BlockSize = MPQE_CHUNK_SIZE; - pStream->BlockCount = (DWORD)(pStream->Base.File.FileSize + MPQE_CHUNK_SIZE - 1) / MPQE_CHUNK_SIZE; - pStream->IsComplete = 1; - return true; - } - } - } - - // Key not found, sorry - return false; -} - -static bool MpqeStream_BlockRead( - TEncryptedStream * pStream, - ULONGLONG StartOffset, - ULONGLONG EndOffset, - LPBYTE BlockBuffer, - DWORD BytesNeeded, - bool bAvailable) -{ - DWORD dwBytesToRead; - - assert((StartOffset & (pStream->BlockSize - 1)) == 0); - assert(StartOffset < EndOffset); - assert(bAvailable != false); - BytesNeeded = BytesNeeded; - bAvailable = bAvailable; - - // Read the file from the stream as-is - // Limit the reading to number of blocks really needed - dwBytesToRead = (DWORD)(EndOffset - StartOffset); - if(!pStream->BaseRead(pStream, &StartOffset, BlockBuffer, dwBytesToRead)) - return false; - - // Decrypt the data - dwBytesToRead = (dwBytesToRead + MPQE_CHUNK_SIZE - 1) & ~(MPQE_CHUNK_SIZE - 1); - DecryptFileChunk((LPDWORD)BlockBuffer, pStream->Key, StartOffset, dwBytesToRead); - return true; -} - -static TFileStream * MpqeStream_Open(const TCHAR * szFileName, DWORD dwStreamFlags) -{ - TEncryptedStream * pStream; - - // Create new empty stream - pStream = (TEncryptedStream *)AllocateFileStream(szFileName, sizeof(TEncryptedStream), dwStreamFlags); - if(pStream == NULL) - return NULL; - - // Attempt to open the base stream - assert(pStream->BaseOpen != NULL); - if(!pStream->BaseOpen(pStream, pStream->szFileName, dwStreamFlags)) - return NULL; - - // Determine the encryption key for the MPQ - if(MpqeStream_DetectFileKey(pStream)) - { - // Set the stream position and size - assert(pStream->StreamSize != 0); - pStream->StreamPos = 0; - pStream->dwFlags |= STREAM_FLAG_READ_ONLY; - - // Set new function pointers - pStream->StreamRead = (STREAM_READ)BlockStream_Read; - pStream->StreamGetPos = BlockStream_GetPos; - pStream->StreamGetSize = BlockStream_GetSize; - pStream->StreamClose = pStream->BaseClose; - - // Supply the block functions - pStream->BlockRead = (BLOCK_READ)MpqeStream_BlockRead; - return pStream; - } - - // Cleanup the stream and return - FileStream_Close(pStream); - SetLastError(ERROR_UNKNOWN_FILE_KEY); - return NULL; -} - -//----------------------------------------------------------------------------- -// Local functions - Block4 stream support - -#define BLOCK4_BLOCK_SIZE 0x4000 // Size of one block -#define BLOCK4_HASH_SIZE 0x20 // Size of MD5 hash that is after each block -#define BLOCK4_MAX_BLOCKS 0x00002000 // Maximum amount of blocks per file -#define BLOCK4_MAX_FSIZE 0x08040000 // Max size of one file - -static bool Block4Stream_BlockRead( - TBlockStream * pStream, // Pointer to an open stream - ULONGLONG StartOffset, - ULONGLONG EndOffset, - LPBYTE BlockBuffer, - DWORD BytesNeeded, - bool bAvailable) -{ - TBaseProviderData * BaseArray = (TBaseProviderData *)pStream->FileBitmap; - ULONGLONG ByteOffset; - DWORD BytesToRead; - DWORD StreamIndex; - DWORD BlockIndex; - bool bResult; - - // The starting offset must be aligned to size of the block - assert(pStream->FileBitmap != NULL); - assert((StartOffset & (pStream->BlockSize - 1)) == 0); - assert(StartOffset < EndOffset); - assert(bAvailable == true); - - // Keep compiler happy - bAvailable = bAvailable; - EndOffset = EndOffset; - - while(BytesNeeded != 0) - { - // Calculate the block index and the file index - StreamIndex = (DWORD)((StartOffset / pStream->BlockSize) / BLOCK4_MAX_BLOCKS); - BlockIndex = (DWORD)((StartOffset / pStream->BlockSize) % BLOCK4_MAX_BLOCKS); - if(StreamIndex > pStream->BitmapSize) - return false; - - // Calculate the block offset - ByteOffset = ((ULONGLONG)BlockIndex * (BLOCK4_BLOCK_SIZE + BLOCK4_HASH_SIZE)); - BytesToRead = STORMLIB_MIN(BytesNeeded, BLOCK4_BLOCK_SIZE); - - // Read from the base stream - pStream->Base = BaseArray[StreamIndex]; - bResult = pStream->BaseRead(pStream, &ByteOffset, BlockBuffer, BytesToRead); - BaseArray[StreamIndex] = pStream->Base; - - // Did the result succeed? - if(bResult == false) - return false; - - // Move pointers - StartOffset += BytesToRead; - BlockBuffer += BytesToRead; - BytesNeeded -= BytesToRead; - } - - return true; -} - - -static void Block4Stream_Close(TBlockStream * pStream) -{ - TBaseProviderData * BaseArray = (TBaseProviderData *)pStream->FileBitmap; - - // If we have a non-zero count of base streams, - // we have to close them all - if(BaseArray != NULL) - { - // Close all base streams - for(DWORD i = 0; i < pStream->BitmapSize; i++) - { - memcpy(&pStream->Base, BaseArray + i, sizeof(TBaseProviderData)); - pStream->BaseClose(pStream); - } - } - - // Free the data map, if any - if(pStream->FileBitmap != NULL) - STORM_FREE(pStream->FileBitmap); - pStream->FileBitmap = NULL; - - // Do not call the BaseClose function, - // we closed all handles already - return; -} - -static TFileStream * Block4Stream_Open(const TCHAR * szFileName, DWORD dwStreamFlags) -{ - TBaseProviderData * NewBaseArray = NULL; - ULONGLONG RemainderBlock; - ULONGLONG BlockCount; - ULONGLONG FileSize; - TBlockStream * pStream; - TCHAR * szNameBuff; - size_t nNameLength; - DWORD dwBaseFiles = 0; - DWORD dwBaseFlags; - - // Create new empty stream - pStream = (TBlockStream *)AllocateFileStream(szFileName, sizeof(TBlockStream), dwStreamFlags); - if(pStream == NULL) - return NULL; - - // Sanity check - assert(pStream->BaseOpen != NULL); - - // Get the length of the file name without numeric suffix - nNameLength = _tcslen(pStream->szFileName); - if(pStream->szFileName[nNameLength - 2] == '.' && pStream->szFileName[nNameLength - 1] == '0') - nNameLength -= 2; - pStream->szFileName[nNameLength] = 0; - - // Supply the stream functions - pStream->StreamRead = (STREAM_READ)BlockStream_Read; - pStream->StreamGetSize = BlockStream_GetSize; - pStream->StreamGetPos = BlockStream_GetPos; - pStream->StreamClose = (STREAM_CLOSE)Block4Stream_Close; - pStream->BlockRead = (BLOCK_READ)Block4Stream_BlockRead; - - // Allocate work space for numeric names - szNameBuff = STORM_ALLOC(TCHAR, nNameLength + 4); - if(szNameBuff != NULL) - { - // Set the base flags - dwBaseFlags = (dwStreamFlags & STREAM_PROVIDERS_MASK) | STREAM_FLAG_READ_ONLY; - - // Go all suffixes from 0 to 30 - for(int nSuffix = 0; nSuffix < 30; nSuffix++) - { - // Open the n-th file - _stprintf(szNameBuff, _T("%s.%u"), pStream->szFileName, nSuffix); - if(!pStream->BaseOpen(pStream, szNameBuff, dwBaseFlags)) - break; - - // If the open succeeded, we re-allocate the base provider array - NewBaseArray = STORM_ALLOC(TBaseProviderData, dwBaseFiles + 1); - if(NewBaseArray == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return NULL; - } - - // Copy the old base data array to the new base data array - if(pStream->FileBitmap != NULL) - { - memcpy(NewBaseArray, pStream->FileBitmap, sizeof(TBaseProviderData) * dwBaseFiles); - STORM_FREE(pStream->FileBitmap); - } - - // Also copy the opened base array - memcpy(NewBaseArray + dwBaseFiles, &pStream->Base, sizeof(TBaseProviderData)); - pStream->FileBitmap = NewBaseArray; - dwBaseFiles++; - - // Get the size of the base stream - pStream->BaseGetSize(pStream, &FileSize); - assert(FileSize <= BLOCK4_MAX_FSIZE); - RemainderBlock = FileSize % (BLOCK4_BLOCK_SIZE + BLOCK4_HASH_SIZE); - BlockCount = FileSize / (BLOCK4_BLOCK_SIZE + BLOCK4_HASH_SIZE); - - // Increment the stream size and number of blocks - pStream->StreamSize += (BlockCount * BLOCK4_BLOCK_SIZE); - pStream->BlockCount += (DWORD)BlockCount; - - // Is this the last file? - if(FileSize < BLOCK4_MAX_FSIZE) - { - if(RemainderBlock) - { - pStream->StreamSize += (RemainderBlock - BLOCK4_HASH_SIZE); - pStream->BlockCount++; - } - break; - } - } - - // Fill the remainining block stream variables - pStream->BitmapSize = dwBaseFiles; - pStream->BlockSize = BLOCK4_BLOCK_SIZE; - pStream->IsComplete = 1; - pStream->IsModified = 0; - - // Fill the remaining stream variables - pStream->StreamPos = 0; - pStream->dwFlags |= STREAM_FLAG_READ_ONLY; - - STORM_FREE(szNameBuff); - } - - // If we opened something, return success - if(dwBaseFiles == 0) - { - FileStream_Close(pStream); - SetLastError(ERROR_FILE_NOT_FOUND); - pStream = NULL; - } - - return pStream; -} - -//----------------------------------------------------------------------------- -// Public functions - -/** - * This function creates a new file for read-write access - * - * - If the current platform supports file sharing, - * the file must be created for read sharing (i.e. another application - * can open the file for read, but not for write) - * - If the file does not exist, the function must create new one - * - If the file exists, the function must rewrite it and set to zero size - * - The parameters of the function must be validate by the caller - * - The function must initialize all stream function pointers in TFileStream - * - If the function fails from any reason, it must close all handles - * and free all memory that has been allocated in the process of stream creation, - * including the TFileStream structure itself - * - * \a szFileName Name of the file to create - */ - -TFileStream * FileStream_CreateFile( - const TCHAR * szFileName, - DWORD dwStreamFlags) -{ - TFileStream * pStream; - - // We only support creation of flat, local file - if((dwStreamFlags & (STREAM_PROVIDERS_MASK)) != (STREAM_PROVIDER_FLAT | BASE_PROVIDER_FILE)) - { - SetLastError(ERROR_NOT_SUPPORTED); - return NULL; - } - - // Allocate file stream structure for flat stream - pStream = AllocateFileStream(szFileName, sizeof(TBlockStream), dwStreamFlags); - if(pStream != NULL) - { - // Attempt to create the disk file - if(BaseFile_Create(pStream)) - { - // Fill the stream provider functions - pStream->StreamRead = pStream->BaseRead; - pStream->StreamWrite = pStream->BaseWrite; - pStream->StreamResize = pStream->BaseResize; - pStream->StreamGetSize = pStream->BaseGetSize; - pStream->StreamGetPos = pStream->BaseGetPos; - pStream->StreamClose = pStream->BaseClose; - return pStream; - } - - // File create failed, delete the stream - STORM_FREE(pStream); - pStream = NULL; - } - - // Return the stream - return pStream; -} - -/** - * This function opens an existing file for read or read-write access - * - If the current platform supports file sharing, - * the file must be open for read sharing (i.e. another application - * can open the file for read, but not for write) - * - If the file does not exist, the function must return NULL - * - If the file exists but cannot be open, then function must return NULL - * - The parameters of the function must be validate by the caller - * - The function must initialize all stream function pointers in TFileStream - * - If the function fails from any reason, it must close all handles - * and free all memory that has been allocated in the process of stream creation, - * including the TFileStream structure itself - * - * \a szFileName Name of the file to open - * \a dwStreamFlags specifies the provider and base storage type - */ - -TFileStream * FileStream_OpenFile( - const TCHAR * szFileName, - DWORD dwStreamFlags) -{ - DWORD dwProvider = dwStreamFlags & STREAM_PROVIDERS_MASK; - size_t nPrefixLength = FileStream_Prefix(szFileName, &dwProvider); - - // Re-assemble the stream flags - dwStreamFlags = (dwStreamFlags & STREAM_OPTIONS_MASK) | dwProvider; - szFileName += nPrefixLength; - - // Perform provider-specific open - switch(dwStreamFlags & STREAM_PROVIDER_MASK) - { - case STREAM_PROVIDER_FLAT: - return FlatStream_Open(szFileName, dwStreamFlags); - - case STREAM_PROVIDER_PARTIAL: - return PartStream_Open(szFileName, dwStreamFlags); - - case STREAM_PROVIDER_MPQE: - return MpqeStream_Open(szFileName, dwStreamFlags); - - case STREAM_PROVIDER_BLOCK4: - return Block4Stream_Open(szFileName, dwStreamFlags); - - default: - SetLastError(ERROR_INVALID_PARAMETER); - return NULL; - } -} - -/** - * Returns the file name of the stream - * - * \a pStream Pointer to an open stream - */ -const TCHAR * FileStream_GetFileName(TFileStream * pStream) -{ - assert(pStream != NULL); - return pStream->szFileName; -} - -/** - * Returns the length of the provider prefix. Returns zero if no prefix - * - * \a szFileName Pointer to a stream name (file, mapped file, URL) - * \a pdwStreamProvider Pointer to a DWORD variable that receives stream provider (STREAM_PROVIDER_XXX) - */ - -size_t FileStream_Prefix(const TCHAR * szFileName, DWORD * pdwProvider) -{ - size_t nPrefixLength1 = 0; - size_t nPrefixLength2 = 0; - DWORD dwProvider = 0; - - if(szFileName != NULL) - { - // - // Determine the stream provider - // - - if(!_tcsnicmp(szFileName, _T("flat-"), 5)) - { - dwProvider |= STREAM_PROVIDER_FLAT; - nPrefixLength1 = 5; - } - - else if(!_tcsnicmp(szFileName, _T("part-"), 5)) - { - dwProvider |= STREAM_PROVIDER_PARTIAL; - nPrefixLength1 = 5; - } - - else if(!_tcsnicmp(szFileName, _T("mpqe-"), 5)) - { - dwProvider |= STREAM_PROVIDER_MPQE; - nPrefixLength1 = 5; - } - - else if(!_tcsnicmp(szFileName, _T("blk4-"), 5)) - { - dwProvider |= STREAM_PROVIDER_BLOCK4; - nPrefixLength1 = 5; - } - - // - // Determine the base provider - // - - if(!_tcsnicmp(szFileName+nPrefixLength1, _T("file:"), 5)) - { - dwProvider |= BASE_PROVIDER_FILE; - nPrefixLength2 = 5; - } - - else if(!_tcsnicmp(szFileName+nPrefixLength1, _T("map:"), 4)) - { - dwProvider |= BASE_PROVIDER_MAP; - nPrefixLength2 = 4; - } - - else if(!_tcsnicmp(szFileName+nPrefixLength1, _T("http:"), 5)) - { - dwProvider |= BASE_PROVIDER_HTTP; - nPrefixLength2 = 5; - } - - // Only accept stream provider if we recognized the base provider - if(nPrefixLength2 != 0) - { - // It is also allowed to put "//" after the base provider, e.g. "file://", "http://" - if(szFileName[nPrefixLength1+nPrefixLength2] == '/' && szFileName[nPrefixLength1+nPrefixLength2+1] == '/') - nPrefixLength2 += 2; - - if(pdwProvider != NULL) - *pdwProvider = dwProvider; - return nPrefixLength1 + nPrefixLength2; - } - } - - return 0; -} - -/** - * Sets a download callback. Whenever the stream needs to download one or more blocks - * from the server, the callback is called - * - * \a pStream Pointer to an open stream - * \a pfnCallback Pointer to callback function - * \a pvUserData Arbitrary user pointer passed to the download callback - */ - -bool FileStream_SetCallback(TFileStream * pStream, SFILE_DOWNLOAD_CALLBACK pfnCallback, void * pvUserData) -{ - TBlockStream * pBlockStream = (TBlockStream *)pStream; - - if(pStream->BlockRead == NULL) - { - SetLastError(ERROR_NOT_SUPPORTED); - return false; - } - - pBlockStream->pfnCallback = pfnCallback; - pBlockStream->UserData = pvUserData; - return true; -} - -/** - * This function gives the block map. The 'pvBitmap' pointer must point to a buffer - * of at least sizeof(STREAM_BLOCK_MAP) size. It can also have size of the complete - * block map (i.e. sizeof(STREAM_BLOCK_MAP) + BitmapSize). In that case, the function - * also copies the bit-based block map. - * - * \a pStream Pointer to an open stream - * \a pvBitmap Pointer to buffer where the block map will be stored - * \a cbBitmap Length of the buffer, of the block map - * \a cbLengthNeeded Length of the bitmap, in bytes - */ - -bool FileStream_GetBitmap(TFileStream * pStream, void * pvBitmap, DWORD cbBitmap, DWORD * pcbLengthNeeded) -{ - TStreamBitmap * pBitmap = (TStreamBitmap *)pvBitmap; - TBlockStream * pBlockStream = (TBlockStream *)pStream; - ULONGLONG BlockOffset; - LPBYTE Bitmap = (LPBYTE)(pBitmap + 1); - DWORD BitmapSize; - DWORD BlockCount; - DWORD BlockSize; - bool bResult = false; - - // Retrieve the size of one block - if(pStream->BlockCheck != NULL) - { - BlockCount = pBlockStream->BlockCount; - BlockSize = pBlockStream->BlockSize; - } - else - { - BlockCount = (DWORD)((pStream->StreamSize + DEFAULT_BLOCK_SIZE - 1) / DEFAULT_BLOCK_SIZE); - BlockSize = DEFAULT_BLOCK_SIZE; - } - - // Fill-in the variables - BitmapSize = (BlockCount + 7) / 8; - - // Give the number of blocks - if(pcbLengthNeeded != NULL) - pcbLengthNeeded[0] = sizeof(TStreamBitmap) + BitmapSize; - - // If the length of the buffer is not enough - if(pvBitmap != NULL && cbBitmap != 0) - { - // Give the STREAM_BLOCK_MAP structure - if(cbBitmap >= sizeof(TStreamBitmap)) - { - pBitmap->StreamSize = pStream->StreamSize; - pBitmap->BitmapSize = BitmapSize; - pBitmap->BlockCount = BlockCount; - pBitmap->BlockSize = BlockSize; - pBitmap->IsComplete = (pStream->BlockCheck != NULL) ? pBlockStream->IsComplete : 1; - bResult = true; - } - - // Give the block bitmap, if enough space - if(cbBitmap >= sizeof(TStreamBitmap) + BitmapSize) - { - // Version with bitmap present - if(pStream->BlockCheck != NULL) - { - DWORD ByteIndex = 0; - BYTE BitMask = 0x01; - - // Initialize the map with zeros - memset(Bitmap, 0, BitmapSize); - - // Fill the map - for(BlockOffset = 0; BlockOffset < pStream->StreamSize; BlockOffset += BlockSize) - { - // Set the bit if the block is present - if(pBlockStream->BlockCheck(pStream, BlockOffset)) - Bitmap[ByteIndex] |= BitMask; - - // Move bit position - ByteIndex += (BitMask >> 0x07); - BitMask = (BitMask >> 0x07) | (BitMask << 0x01); - } - } - else - { - memset(Bitmap, 0xFF, BitmapSize); - } - } - } - - // Set last error value and return - if(bResult == false) - SetLastError(ERROR_INSUFFICIENT_BUFFER); - return bResult; -} - -/** - * Reads data from the stream - * - * - Returns true if the read operation succeeded and all bytes have been read - * - Returns false if either read failed or not all bytes have been read - * - If the pByteOffset is NULL, the function must read the data from the current file position - * - The function can be called with dwBytesToRead = 0. In that case, pvBuffer is ignored - * and the function just adjusts file pointer. - * - * \a pStream Pointer to an open stream - * \a pByteOffset Pointer to file byte offset. If NULL, it reads from the current position - * \a pvBuffer Pointer to data to be read - * \a dwBytesToRead Number of bytes to read from the file - * - * \returns - * - If the function reads the required amount of bytes, it returns true. - * - If the function reads less than required bytes, it returns false and GetLastError() returns ERROR_HANDLE_EOF - * - If the function fails, it reads false and GetLastError() returns an error code different from ERROR_HANDLE_EOF - */ -bool FileStream_Read(TFileStream * pStream, ULONGLONG * pByteOffset, void * pvBuffer, DWORD dwBytesToRead) -{ - assert(pStream->StreamRead != NULL); - return pStream->StreamRead(pStream, pByteOffset, pvBuffer, dwBytesToRead); -} - -/** - * This function writes data to the stream - * - * - Returns true if the write operation succeeded and all bytes have been written - * - Returns false if either write failed or not all bytes have been written - * - If the pByteOffset is NULL, the function must write the data to the current file position - * - * \a pStream Pointer to an open stream - * \a pByteOffset Pointer to file byte offset. If NULL, it reads from the current position - * \a pvBuffer Pointer to data to be written - * \a dwBytesToWrite Number of bytes to write to the file - */ -bool FileStream_Write(TFileStream * pStream, ULONGLONG * pByteOffset, const void * pvBuffer, DWORD dwBytesToWrite) -{ - if(pStream->dwFlags & STREAM_FLAG_READ_ONLY) - { - SetLastError(ERROR_ACCESS_DENIED); - return false; - } - - assert(pStream->StreamWrite != NULL); - return pStream->StreamWrite(pStream, pByteOffset, pvBuffer, dwBytesToWrite); -} - -/** - * Returns the size of a file - * - * \a pStream Pointer to an open stream - * \a FileSize Pointer where to store the file size - */ -bool FileStream_GetSize(TFileStream * pStream, ULONGLONG * pFileSize) -{ - assert(pStream->StreamGetSize != NULL); - return pStream->StreamGetSize(pStream, pFileSize); -} - -/** - * Sets the size of a file - * - * \a pStream Pointer to an open stream - * \a NewFileSize File size to set - */ -bool FileStream_SetSize(TFileStream * pStream, ULONGLONG NewFileSize) -{ - if(pStream->dwFlags & STREAM_FLAG_READ_ONLY) - { - SetLastError(ERROR_ACCESS_DENIED); - return false; - } - - assert(pStream->StreamResize != NULL); - return pStream->StreamResize(pStream, NewFileSize); -} - -/** - * This function returns the current file position - * \a pStream - * \a pByteOffset - */ -bool FileStream_GetPos(TFileStream * pStream, ULONGLONG * pByteOffset) -{ - assert(pStream->StreamGetPos != NULL); - return pStream->StreamGetPos(pStream, pByteOffset); -} - -/** - * Returns the last write time of a file - * - * \a pStream Pointer to an open stream - * \a pFileType Pointer where to store the file last write time - */ -bool FileStream_GetTime(TFileStream * pStream, ULONGLONG * pFileTime) -{ - // Just use the saved filetime value - *pFileTime = pStream->Base.File.FileTime; - return true; -} - -/** - * Returns the stream flags - * - * \a pStream Pointer to an open stream - * \a pdwStreamFlags Pointer where to store the stream flags - */ -bool FileStream_GetFlags(TFileStream * pStream, LPDWORD pdwStreamFlags) -{ - *pdwStreamFlags = pStream->dwFlags; - return true; -} - -/** - * Switches a stream with another. Used for final phase of archive compacting. - * Performs these steps: - * - * 1) Closes the handle to the existing MPQ - * 2) Renames the temporary MPQ to the original MPQ, overwrites existing one - * 3) Opens the MPQ stores the handle and stream position to the new stream structure - * - * \a pStream Pointer to an open stream - * \a pNewStream Temporary ("working") stream (created during archive compacting) - */ -bool FileStream_Replace(TFileStream * pStream, TFileStream * pNewStream) -{ - // Only supported on flat files - if((pStream->dwFlags & STREAM_PROVIDERS_MASK) != (STREAM_PROVIDER_FLAT | BASE_PROVIDER_FILE)) - { - SetLastError(ERROR_NOT_SUPPORTED); - return false; - } - - // Not supported on read-only streams - if(pStream->dwFlags & STREAM_FLAG_READ_ONLY) - { - SetLastError(ERROR_ACCESS_DENIED); - return false; - } - - // Close both stream's base providers - pNewStream->BaseClose(pNewStream); - pStream->BaseClose(pStream); - - // Now we have to delete the (now closed) old file and rename the new file - if(!BaseFile_Replace(pStream, pNewStream)) - return false; - - // Now open the base file again - if(!BaseFile_Open(pStream, pStream->szFileName, pStream->dwFlags)) - return false; - - // Cleanup the new stream - FileStream_Close(pNewStream); - return true; -} - -/** - * This function closes an archive file and frees any data buffers - * that have been allocated for stream management. The function must also - * support partially allocated structure, i.e. one or more buffers - * can be NULL, if there was an allocation failure during the process - * - * \a pStream Pointer to an open stream - */ -void FileStream_Close(TFileStream * pStream) -{ - // Check if the stream structure is allocated at all - if(pStream != NULL) - { - // Free the master stream, if any - if(pStream->pMaster != NULL) - FileStream_Close(pStream->pMaster); - pStream->pMaster = NULL; - - // Close the stream provider ... - if(pStream->StreamClose != NULL) - pStream->StreamClose(pStream); - - // ... or close base stream, if any - else if(pStream->BaseClose != NULL) - pStream->BaseClose(pStream); - - // Free the stream itself - STORM_FREE(pStream); - } -} diff --git a/libs/storm-sys/StormLib/src/FileStream.h b/libs/storm-sys/StormLib/src/FileStream.h deleted file mode 100644 index 44beeed..0000000 --- a/libs/storm-sys/StormLib/src/FileStream.h +++ /dev/null @@ -1,217 +0,0 @@ -/*****************************************************************************/ -/* FileStream.h Copyright (c) Ladislav Zezula 2012 */ -/*---------------------------------------------------------------------------*/ -/* Description: Definitions for FileStream object */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 14.04.12 1.00 Lad The first version of FileStream.h */ -/*****************************************************************************/ - -#ifndef __FILESTREAM_H__ -#define __FILESTREAM_H__ - -//----------------------------------------------------------------------------- -// Function prototypes - -typedef void (*STREAM_INIT)( - struct TFileStream * pStream // Pointer to an unopened stream -); - -typedef bool (*STREAM_CREATE)( - struct TFileStream * pStream // Pointer to an unopened stream - ); - -typedef bool (*STREAM_OPEN)( - struct TFileStream * pStream, // Pointer to an unopened stream - const TCHAR * szFileName, // Pointer to file name to be open - DWORD dwStreamFlags // Stream flags - ); - -typedef bool (*STREAM_READ)( - struct TFileStream * pStream, // Pointer to an open stream - ULONGLONG * pByteOffset, // Pointer to file byte offset. If NULL, it reads from the current position - void * pvBuffer, // Pointer to data to be read - DWORD dwBytesToRead // Number of bytes to read from the file - ); - -typedef bool (*STREAM_WRITE)( - struct TFileStream * pStream, // Pointer to an open stream - ULONGLONG * pByteOffset, // Pointer to file byte offset. If NULL, it writes to the current position - const void * pvBuffer, // Pointer to data to be written - DWORD dwBytesToWrite // Number of bytes to read from the file - ); - -typedef bool (*STREAM_RESIZE)( - struct TFileStream * pStream, // Pointer to an open stream - ULONGLONG FileSize // New size for the file, in bytes - ); - -typedef bool (*STREAM_GETSIZE)( - struct TFileStream * pStream, // Pointer to an open stream - ULONGLONG * pFileSize // Receives the file size, in bytes - ); - -typedef bool (*STREAM_GETPOS)( - struct TFileStream * pStream, // Pointer to an open stream - ULONGLONG * pByteOffset // Pointer to store current file position - ); - -typedef void (*STREAM_CLOSE)( - struct TFileStream * pStream // Pointer to an open stream - ); - -typedef bool (*BLOCK_READ)( - struct TFileStream * pStream, // Pointer to a block-oriented stream - ULONGLONG StartOffset, // Byte offset of start of the block array - ULONGLONG EndOffset, // End offset (either end of the block or end of the file) - LPBYTE BlockBuffer, // Pointer to block-aligned buffer - DWORD BytesNeeded, // Number of bytes that are really needed - bool bAvailable // true if the block is available - ); - -typedef bool (*BLOCK_CHECK)( - struct TFileStream * pStream, // Pointer to a block-oriented stream - ULONGLONG BlockOffset // Offset of the file to check - ); - -typedef void (*BLOCK_SAVEMAP)( - struct TFileStream * pStream // Pointer to a block-oriented stream - ); - -//----------------------------------------------------------------------------- -// Local structures - partial file structure and bitmap footer - -#define ID_FILE_BITMAP_FOOTER 0x33767470 // Signature of the file bitmap footer ('ptv3') -#define DEFAULT_BLOCK_SIZE 0x00004000 // Default size of the stream block -#define DEFAULT_BUILD_NUMBER 10958 // Build number for newly created partial MPQs - -typedef struct _PART_FILE_HEADER -{ - DWORD PartialVersion; // Always set to 2 - char GameBuildNumber[0x20]; // Minimum build number of the game that can use this MPQ - DWORD Flags; // Flags (details unknown) - DWORD FileSizeLo; // Low 32 bits of the contained file size - DWORD FileSizeHi; // High 32 bits of the contained file size - DWORD BlockSize; // Size of one file block, in bytes - -} PART_FILE_HEADER, *PPART_FILE_HEADER; - -// Structure describing the block-to-file map entry -typedef struct _PART_FILE_MAP_ENTRY -{ - DWORD Flags; // 3 = the block is present in the file - DWORD BlockOffsLo; // Low 32 bits of the block position in the file - DWORD BlockOffsHi; // High 32 bits of the block position in the file - DWORD LargeValueLo; // 64-bit value, meaning is unknown - DWORD LargeValueHi; - -} PART_FILE_MAP_ENTRY, *PPART_FILE_MAP_ENTRY; - -typedef struct _FILE_BITMAP_FOOTER -{ - DWORD Signature; // 'ptv3' (ID_FILE_BITMAP_FOOTER) - DWORD Version; // Unknown, seems to always have value of 3 (version?) - DWORD BuildNumber; // Game build number for that MPQ - DWORD MapOffsetLo; // Low 32-bits of the offset of the bit map - DWORD MapOffsetHi; // High 32-bits of the offset of the bit map - DWORD BlockSize; // Size of one block (usually 0x4000 bytes) - -} FILE_BITMAP_FOOTER, *PFILE_BITMAP_FOOTER; - -//----------------------------------------------------------------------------- -// Structure for file stream - -union TBaseProviderData -{ - struct - { - ULONGLONG FileSize; // Size of the file - ULONGLONG FilePos; // Current file position - ULONGLONG FileTime; // Last write time - HANDLE hFile; // File handle - } File; - - struct - { - ULONGLONG FileSize; // Size of the file - ULONGLONG FilePos; // Current file position - ULONGLONG FileTime; // Last write time - LPBYTE pbFile; // Pointer to mapped view - } Map; - - struct - { - ULONGLONG FileSize; // Size of the file - ULONGLONG FilePos; // Current file position - ULONGLONG FileTime; // Last write time - HANDLE hInternet; // Internet handle - HANDLE hConnect; // Connection to the internet server - } Http; -}; - -struct TFileStream -{ - // Stream provider functions - STREAM_READ StreamRead; // Pointer to stream read function for this archive. Do not use directly. - STREAM_WRITE StreamWrite; // Pointer to stream write function for this archive. Do not use directly. - STREAM_RESIZE StreamResize; // Pointer to function changing file size - STREAM_GETSIZE StreamGetSize; // Pointer to function returning file size - STREAM_GETPOS StreamGetPos; // Pointer to function that returns current file position - STREAM_CLOSE StreamClose; // Pointer to function closing the stream - - // Block-oriented functions - BLOCK_READ BlockRead; // Pointer to function reading one or more blocks - BLOCK_CHECK BlockCheck; // Pointer to function checking whether the block is present - - // Base provider functions - STREAM_CREATE BaseCreate; // Pointer to base create function - STREAM_OPEN BaseOpen; // Pointer to base open function - STREAM_READ BaseRead; // Read from the stream - STREAM_WRITE BaseWrite; // Write to the stream - STREAM_RESIZE BaseResize; // Pointer to function changing file size - STREAM_GETSIZE BaseGetSize; // Pointer to function returning file size - STREAM_GETPOS BaseGetPos; // Pointer to function that returns current file position - STREAM_CLOSE BaseClose; // Pointer to function closing the stream - - // Base provider data (file size, file position) - TBaseProviderData Base; - - // Stream provider data - TFileStream * pMaster; // Master stream (e.g. MPQ on a web server) - TCHAR * szFileName; // File name (self-relative pointer) - - ULONGLONG StreamSize; // Stream size (can be less than file size) - ULONGLONG StreamPos; // Stream position - DWORD BuildNumber; // Game build number - DWORD dwFlags; // Stream flags - - // Followed by stream provider data, with variable length -}; - -//----------------------------------------------------------------------------- -// Structures for block-oriented stream - -struct TBlockStream : public TFileStream -{ - SFILE_DOWNLOAD_CALLBACK pfnCallback; // Callback for downloading - void * FileBitmap; // Array of bits for file blocks - void * UserData; // User data to be passed to the download callback - DWORD BitmapSize; // Size of the file bitmap (in bytes) - DWORD BlockSize; // Size of one block, in bytes - DWORD BlockCount; // Number of data blocks in the file - DWORD IsComplete; // If nonzero, no blocks are missing - DWORD IsModified; // nonzero if the bitmap has been modified -}; - -//----------------------------------------------------------------------------- -// Structure for encrypted stream - -#define MPQE_CHUNK_SIZE 0x40 // Size of one chunk to be decrypted - -struct TEncryptedStream : public TBlockStream -{ - BYTE Key[MPQE_CHUNK_SIZE]; // File key -}; - -#endif // __FILESTREAM_H__ diff --git a/libs/storm-sys/StormLib/src/SBaseCommon.cpp b/libs/storm-sys/StormLib/src/SBaseCommon.cpp deleted file mode 100644 index 782e154..0000000 --- a/libs/storm-sys/StormLib/src/SBaseCommon.cpp +++ /dev/null @@ -1,1842 +0,0 @@ -/*****************************************************************************/ -/* SBaseCommon.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Common functions for StormLib, used by all SFile*** modules */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 24.03.03 1.00 Lad The first version of SFileCommon.cpp */ -/* 19.11.03 1.01 Dan Big endian handling */ -/* 12.06.04 1.01 Lad Renamed to SCommon.cpp */ -/* 06.09.10 1.01 Lad Renamed to SBaseCommon.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "StormCommon.h" - -char StormLibCopyright[] = "StormLib v " STORMLIB_VERSION_STRING " Copyright Ladislav Zezula 1998-2014"; - -//----------------------------------------------------------------------------- -// Local variables - -LCID lcFileLocale = LANG_NEUTRAL; // File locale -USHORT wPlatform = 0; // File platform - -//----------------------------------------------------------------------------- -// Conversion to uppercase/lowercase - -// Converts ASCII characters to lowercase -// Converts slash (0x2F) to backslash (0x5C) -unsigned char AsciiToLowerTable[256] = -{ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x5C, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF -}; - -// Converts ASCII characters to uppercase -// Converts slash (0x2F) to backslash (0x5C) -unsigned char AsciiToUpperTable[256] = -{ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x5C, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF -}; - -// Converts ASCII characters to uppercase -// Does NOT convert slash (0x2F) to backslash (0x5C) -unsigned char AsciiToUpperTable_Slash[256] = -{ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF -}; - -//----------------------------------------------------------------------------- -// Safe string functions (for ANSI builds) - -void StringCopy(char * szTarget, size_t cchTarget, const char * szSource) -{ - if(cchTarget > 0) - { - size_t cchSource = strlen(szSource); - - if(cchSource >= cchTarget) - cchSource = cchTarget - 1; - - memcpy(szTarget, szSource, cchSource); - szTarget[cchSource] = 0; - } -} - -void StringCat(char * szTarget, size_t cchTargetMax, const char * szSource) -{ - // Get the current length of the target - size_t cchTarget = strlen(szTarget); - - // Copy the string to the target - if(cchTarget < cchTargetMax) - { - StringCopy(szTarget + cchTarget, (cchTargetMax - cchTarget), szSource); - } -} - -//----------------------------------------------------------------------------- -// Utility functions (UNICODE) only exist in the ANSI version of the library -// In ANSI builds, TCHAR = char, so we don't need these functions implemented - -#ifdef _UNICODE -void StringCopy(TCHAR * szTarget, size_t cchTarget, const char * szSource) -{ - if(cchTarget > 0) - { - size_t cchSource = strlen(szSource); - - if(cchSource >= cchTarget) - cchSource = cchTarget - 1; - - mbstowcs(szTarget, szSource, cchSource); - szTarget[cchSource] = 0; - } -} - -void StringCopy(char * szTarget, size_t cchTarget, const TCHAR * szSource) -{ - if(cchTarget > 0) - { - size_t cchSource = _tcslen(szSource); - - if(cchSource >= cchTarget) - cchSource = cchTarget - 1; - - wcstombs(szTarget, szSource, cchSource); - szTarget[cchSource] = 0; - } -} - -void StringCopy(TCHAR * szTarget, size_t cchTarget, const TCHAR * szSource) -{ - if(cchTarget > 0) - { - size_t cchSource = _tcslen(szSource); - - if(cchSource >= cchTarget) - cchSource = cchTarget - 1; - - memcpy(szTarget, szSource, cchSource * sizeof(TCHAR)); - szTarget[cchSource] = 0; - } -} - -void StringCat(TCHAR * szTarget, size_t cchTargetMax, const TCHAR * szSource) -{ - // Get the current length of the target - size_t cchTarget = _tcslen(szTarget); - - // Copy the string to the target - if(cchTarget < cchTargetMax) - { - StringCopy(szTarget + cchTarget, (cchTargetMax - cchTarget), szSource); - } -} -#endif - -//----------------------------------------------------------------------------- -// Storm hashing functions - -#define STORM_BUFFER_SIZE 0x500 -#define HASH_INDEX_MASK(ha) (ha->pHeader->dwHashTableSize ? (ha->pHeader->dwHashTableSize - 1) : 0) - -static DWORD StormBuffer[STORM_BUFFER_SIZE]; // Buffer for the decryption engine -static bool bMpqCryptographyInitialized = false; - -void InitializeMpqCryptography() -{ - DWORD dwSeed = 0x00100001; - DWORD index1 = 0; - DWORD index2 = 0; - int i; - - // Initialize the decryption buffer. - // Do nothing if already done. - if(bMpqCryptographyInitialized == false) - { - for(index1 = 0; index1 < 0x100; index1++) - { - for(index2 = index1, i = 0; i < 5; i++, index2 += 0x100) - { - DWORD temp1, temp2; - - dwSeed = (dwSeed * 125 + 3) % 0x2AAAAB; - temp1 = (dwSeed & 0xFFFF) << 0x10; - - dwSeed = (dwSeed * 125 + 3) % 0x2AAAAB; - temp2 = (dwSeed & 0xFFFF); - - StormBuffer[index2] = (temp1 | temp2); - } - } - - // Also register both MD5 and SHA1 hash algorithms - register_hash(&md5_desc); - register_hash(&sha1_desc); - - // Use LibTomMath as support math library for LibTomCrypt - ltc_mp = ltm_desc; - - // Don't do that again - bMpqCryptographyInitialized = true; - } -} - -// -// Note: Implementation of this function in WorldEdit.exe and storm.dll -// incorrectly treats the character as signed, which leads to the -// a buffer underflow if the character in the file name >= 0x80: -// The following steps happen when *pbKey == 0xBF and dwHashType == 0x0000 -// (calculating hash index) -// -// 1) Result of AsciiToUpperTable_Slash[*pbKey++] is sign-extended to 0xffffffbf -// 2) The "ch" is added to dwHashType (0xffffffbf + 0x0000 => 0xffffffbf) -// 3) The result is used as index to the StormBuffer table, -// thus dereferences a random value BEFORE the begin of StormBuffer. -// -// As result, MPQs containing files with non-ANSI characters will not work between -// various game versions and localizations. Even WorldEdit, after importing a file -// with Korean characters in the name, cannot open the file back. -// -DWORD HashString(const char * szFileName, DWORD dwHashType) -{ - LPBYTE pbKey = (BYTE *)szFileName; - DWORD dwSeed1 = 0x7FED7FED; - DWORD dwSeed2 = 0xEEEEEEEE; - DWORD ch; - - while(*pbKey != 0) - { - // Convert the input character to uppercase - // Convert slash (0x2F) to backslash (0x5C) - ch = AsciiToUpperTable[*pbKey++]; - - dwSeed1 = StormBuffer[dwHashType + ch] ^ (dwSeed1 + dwSeed2); - dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; - } - - return dwSeed1; -} - -DWORD HashStringSlash(const char * szFileName, DWORD dwHashType) -{ - LPBYTE pbKey = (BYTE *)szFileName; - DWORD dwSeed1 = 0x7FED7FED; - DWORD dwSeed2 = 0xEEEEEEEE; - DWORD ch; - - while(*pbKey != 0) - { - // Convert the input character to uppercase - // DON'T convert slash (0x2F) to backslash (0x5C) - ch = AsciiToUpperTable_Slash[*pbKey++]; - - dwSeed1 = StormBuffer[dwHashType + ch] ^ (dwSeed1 + dwSeed2); - dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; - } - - return dwSeed1; -} - -DWORD HashStringLower(const char * szFileName, DWORD dwHashType) -{ - LPBYTE pbKey = (BYTE *)szFileName; - DWORD dwSeed1 = 0x7FED7FED; - DWORD dwSeed2 = 0xEEEEEEEE; - DWORD ch; - - while(*pbKey != 0) - { - // Convert the input character to lower - // DON'T convert slash (0x2F) to backslash (0x5C) - ch = AsciiToLowerTable[*pbKey++]; - - dwSeed1 = StormBuffer[dwHashType + ch] ^ (dwSeed1 + dwSeed2); - dwSeed2 = ch + dwSeed1 + dwSeed2 + (dwSeed2 << 5) + 3; - } - - return dwSeed1; -} - -//----------------------------------------------------------------------------- -// Calculates the hash table size for a given amount of files - -// Returns the nearest higher power of two. -// If the value is already a power of two, returns the same value -DWORD GetNearestPowerOfTwo(DWORD dwFileCount) -{ - dwFileCount --; - - dwFileCount |= dwFileCount >> 1; - dwFileCount |= dwFileCount >> 2; - dwFileCount |= dwFileCount >> 4; - dwFileCount |= dwFileCount >> 8; - dwFileCount |= dwFileCount >> 16; - - return dwFileCount + 1; -} -/* -DWORD GetNearestPowerOfTwo(DWORD dwFileCount) -{ - DWORD dwPowerOfTwo = HASH_TABLE_SIZE_MIN; - - // For zero files, there is no hash table needed - if(dwFileCount == 0) - return 0; - - // Round the hash table size up to the nearest power of two - // Don't allow the hash table size go over allowed maximum - while(dwPowerOfTwo < HASH_TABLE_SIZE_MAX && dwPowerOfTwo < dwFileCount) - dwPowerOfTwo <<= 1; - return dwPowerOfTwo; -} -*/ -//----------------------------------------------------------------------------- -// Calculates a Jenkin's Encrypting and decrypting MPQ file data - -ULONGLONG HashStringJenkins(const char * szFileName) -{ - LPBYTE pbFileName = (LPBYTE)szFileName; - char szNameBuff[0x108]; - size_t nLength = 0; - unsigned int primary_hash = 1; - unsigned int secondary_hash = 2; - - // Normalize the file name - convert to uppercase, and convert "/" to "\\". - if(pbFileName != NULL) - { - char * szNamePtr = szNameBuff; - char * szNameEnd = szNamePtr + sizeof(szNameBuff); - - // Normalize the file name. Doesn't have to be zero terminated for hashing - while(szNamePtr < szNameEnd && pbFileName[0] != 0) - *szNamePtr++ = (char)AsciiToLowerTable[*pbFileName++]; - nLength = szNamePtr - szNameBuff; - } - - // Thanks Quantam for finding out what the algorithm is. - // I am really getting old for reversing large chunks of assembly - // that does hashing :-) - hashlittle2(szNameBuff, nLength, &secondary_hash, &primary_hash); - - // Combine those 2 together - return ((ULONGLONG)primary_hash << 0x20) | (ULONGLONG)secondary_hash; -} - -//----------------------------------------------------------------------------- -// Default flags for (attributes) and (listfile) - -DWORD GetDefaultSpecialFileFlags(DWORD dwFileSize, USHORT wFormatVersion) -{ - // Fixed for format 1.0 - if(wFormatVersion == MPQ_FORMAT_VERSION_1) - return MPQ_FILE_COMPRESS | MPQ_FILE_ENCRYPTED | MPQ_FILE_FIX_KEY; - - // Size-dependent for formats 2.0-4.0 - return (dwFileSize > 0x4000) ? (MPQ_FILE_COMPRESS | MPQ_FILE_SECTOR_CRC) : (MPQ_FILE_COMPRESS | MPQ_FILE_SINGLE_UNIT); -} - - -//----------------------------------------------------------------------------- -// Encrypting/Decrypting MPQ data block - -void EncryptMpqBlock(void * pvDataBlock, DWORD dwLength, DWORD dwKey1) -{ - LPDWORD DataBlock = (LPDWORD)pvDataBlock; - DWORD dwValue32; - DWORD dwKey2 = 0xEEEEEEEE; - - // Round to DWORDs - dwLength >>= 2; - - // Encrypt the data block at array of DWORDs - for(DWORD i = 0; i < dwLength; i++) - { - // Modify the second key - dwKey2 += StormBuffer[MPQ_HASH_KEY2_MIX + (dwKey1 & 0xFF)]; - - dwValue32 = DataBlock[i]; - DataBlock[i] = DataBlock[i] ^ (dwKey1 + dwKey2); - - dwKey1 = ((~dwKey1 << 0x15) + 0x11111111) | (dwKey1 >> 0x0B); - dwKey2 = dwValue32 + dwKey2 + (dwKey2 << 5) + 3; - } -} - -void DecryptMpqBlock(void * pvDataBlock, DWORD dwLength, DWORD dwKey1) -{ - LPDWORD DataBlock = (LPDWORD)pvDataBlock; - DWORD dwValue32; - DWORD dwKey2 = 0xEEEEEEEE; - - // Round to DWORDs - dwLength >>= 2; - - // Decrypt the data block at array of DWORDs - for(DWORD i = 0; i < dwLength; i++) - { - // Modify the second key - dwKey2 += StormBuffer[MPQ_HASH_KEY2_MIX + (dwKey1 & 0xFF)]; - - DataBlock[i] = DataBlock[i] ^ (dwKey1 + dwKey2); - dwValue32 = DataBlock[i]; - - dwKey1 = ((~dwKey1 << 0x15) + 0x11111111) | (dwKey1 >> 0x0B); - dwKey2 = dwValue32 + dwKey2 + (dwKey2 << 5) + 3; - } -} - -/** - * Functions tries to get file decryption key. This comes from these facts - * - * - We know the decrypted value of the first DWORD in the encrypted data - * - We know the decrypted value of the second DWORD (at least aproximately) - * - There is only 256 variants of how the second key is modified - * - * The first iteration of dwKey1 and dwKey2 is this: - * - * dwKey2 = 0xEEEEEEEE + StormBuffer[MPQ_HASH_KEY2_MIX + (dwKey1 & 0xFF)] - * dwDecrypted0 = DataBlock[0] ^ (dwKey1 + dwKey2); - * - * This means: - * - * (dwKey1 + dwKey2) = DataBlock[0] ^ dwDecrypted0; - * - */ - -DWORD DetectFileKeyBySectorSize(LPDWORD EncryptedData, DWORD dwSectorSize, DWORD dwDecrypted0) -{ - DWORD dwDecrypted1Max = dwSectorSize + dwDecrypted0; - DWORD dwKey1PlusKey2; - DWORD DataBlock[2]; - - // We must have at least 2 DWORDs there to be able to decrypt something - if(dwSectorSize < 0x08) - return 0; - - // Get the value of the combined encryption key - dwKey1PlusKey2 = (EncryptedData[0] ^ dwDecrypted0) - 0xEEEEEEEE; - - // Try all 256 combinations of dwKey1 - for(DWORD i = 0; i < 0x100; i++) - { - DWORD dwSaveKey1; - DWORD dwKey1 = dwKey1PlusKey2 - StormBuffer[MPQ_HASH_KEY2_MIX + i]; - DWORD dwKey2 = 0xEEEEEEEE; - - // Modify the second key and decrypt the first DWORD - dwKey2 += StormBuffer[MPQ_HASH_KEY2_MIX + (dwKey1 & 0xFF)]; - DataBlock[0] = EncryptedData[0] ^ (dwKey1 + dwKey2); - - // Did we obtain the same value like dwDecrypted0? - if(DataBlock[0] == dwDecrypted0) - { - // Save this key value. Increment by one because - // we are decrypting sector offset table - dwSaveKey1 = dwKey1 + 1; - - // Rotate both keys - dwKey1 = ((~dwKey1 << 0x15) + 0x11111111) | (dwKey1 >> 0x0B); - dwKey2 = DataBlock[0] + dwKey2 + (dwKey2 << 5) + 3; - - // Modify the second key again and decrypt the second DWORD - dwKey2 += StormBuffer[MPQ_HASH_KEY2_MIX + (dwKey1 & 0xFF)]; - DataBlock[1] = EncryptedData[1] ^ (dwKey1 + dwKey2); - - // Now compare the results - if(DataBlock[1] <= dwDecrypted1Max) - return dwSaveKey1; - } - } - - // Key not found - return 0; -} - -// Function tries to detect file encryption key based on expected file content -// It is the same function like before, except that we know the value of the second DWORD -DWORD DetectFileKeyByKnownContent(void * pvEncryptedData, DWORD dwDecrypted0, DWORD dwDecrypted1) -{ - LPDWORD EncryptedData = (LPDWORD)pvEncryptedData; - DWORD dwKey1PlusKey2; - DWORD DataBlock[2]; - - // Get the value of the combined encryption key - dwKey1PlusKey2 = (EncryptedData[0] ^ dwDecrypted0) - 0xEEEEEEEE; - - // Try all 256 combinations of dwKey1 - for(DWORD i = 0; i < 0x100; i++) - { - DWORD dwSaveKey1; - DWORD dwKey1 = dwKey1PlusKey2 - StormBuffer[MPQ_HASH_KEY2_MIX + i]; - DWORD dwKey2 = 0xEEEEEEEE; - - // Modify the second key and decrypt the first DWORD - dwKey2 += StormBuffer[MPQ_HASH_KEY2_MIX + (dwKey1 & 0xFF)]; - DataBlock[0] = EncryptedData[0] ^ (dwKey1 + dwKey2); - - // Did we obtain the same value like dwDecrypted0? - if(DataBlock[0] == dwDecrypted0) - { - // Save this key value - dwSaveKey1 = dwKey1; - - // Rotate both keys - dwKey1 = ((~dwKey1 << 0x15) + 0x11111111) | (dwKey1 >> 0x0B); - dwKey2 = DataBlock[0] + dwKey2 + (dwKey2 << 5) + 3; - - // Modify the second key again and decrypt the second DWORD - dwKey2 += StormBuffer[MPQ_HASH_KEY2_MIX + (dwKey1 & 0xFF)]; - DataBlock[1] = EncryptedData[1] ^ (dwKey1 + dwKey2); - - // Now compare the results - if(DataBlock[1] == dwDecrypted1) - return dwSaveKey1; - } - } - - // Key not found - return 0; -} - -DWORD DetectFileKeyByContent(void * pvEncryptedData, DWORD dwSectorSize, DWORD dwFileSize) -{ - DWORD dwFileKey; - - // Try to break the file encryption key as if it was a WAVE file - if(dwSectorSize >= 0x0C) - { - dwFileKey = DetectFileKeyByKnownContent(pvEncryptedData, 0x46464952, dwFileSize - 8); - if(dwFileKey != 0) - return dwFileKey; - } - - // Try to break the encryption key as if it was an EXE file - if(dwSectorSize > 0x40) - { - dwFileKey = DetectFileKeyByKnownContent(pvEncryptedData, 0x00905A4D, 0x00000003); - if(dwFileKey != 0) - return dwFileKey; - } - - // Try to break the encryption key as if it was a XML file - if(dwSectorSize > 0x04) - { - dwFileKey = DetectFileKeyByKnownContent(pvEncryptedData, 0x6D783F3C, 0x6576206C); - if(dwFileKey != 0) - return dwFileKey; - } - - // Not detected, sorry - return 0; -} - -DWORD DecryptFileKey( - const char * szFileName, - ULONGLONG MpqPos, - DWORD dwFileSize, - DWORD dwFlags) -{ - DWORD dwFileKey; - DWORD dwMpqPos = (DWORD)MpqPos; - - // File key is calculated from plain name - szFileName = GetPlainFileName(szFileName); - dwFileKey = HashString(szFileName, MPQ_HASH_FILE_KEY); - - // Fix the key, if needed - if(dwFlags & MPQ_FILE_FIX_KEY) - dwFileKey = (dwFileKey + dwMpqPos) ^ dwFileSize; - - // Return the key - return dwFileKey; -} - -//----------------------------------------------------------------------------- -// Handle validation functions - -TMPQArchive * IsValidMpqHandle(HANDLE hMpq) -{ - TMPQArchive * ha = (TMPQArchive *)hMpq; - - return (ha != NULL && ha->pHeader != NULL && ha->pHeader->dwID == ID_MPQ) ? ha : NULL; -} - -TMPQFile * IsValidFileHandle(HANDLE hFile) -{ - TMPQFile * hf = (TMPQFile *)hFile; - - // Must not be NULL - if(hf != NULL && hf->dwMagic == ID_MPQ_FILE) - { - // Local file handle? - if(hf->pStream != NULL) - return hf; - - // Also verify the MPQ handle within the file handle - if(IsValidMpqHandle(hf->ha)) - return hf; - } - - return NULL; -} - -//----------------------------------------------------------------------------- -// Hash table and block table manipulation - -// Attempts to search a free hash entry, or an entry whose names and locale matches -TMPQHash * FindFreeHashEntry(TMPQArchive * ha, DWORD dwStartIndex, DWORD dwName1, DWORD dwName2, LCID lcLocale) -{ - TMPQHash * pDeletedEntry = NULL; // If a deleted entry was found in the continuous hash range - TMPQHash * pFreeEntry = NULL; // If a free entry was found in the continuous hash range - DWORD dwHashIndexMask = HASH_INDEX_MASK(ha); - DWORD dwIndex; - - // Set the initial index - dwStartIndex = dwIndex = (dwStartIndex & dwHashIndexMask); - - // Search the hash table and return the found entries in the following priority: - // 1) - // 2) - // 3) - // 4) NULL - for(;;) - { - TMPQHash * pHash = ha->pHashTable + dwIndex; - - // If we found a matching entry, return that one - if(pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2 && pHash->lcLocale == lcLocale) - return pHash; - - // If we found a deleted entry, remember it but keep searching - if(pHash->dwBlockIndex == HASH_ENTRY_DELETED && pDeletedEntry == NULL) - pDeletedEntry = pHash; - - // If we found a free entry, we need to stop searching - if(pHash->dwBlockIndex == HASH_ENTRY_FREE) - { - pFreeEntry = pHash; - break; - } - - // Move to the next hash entry. - // If we reached the starting entry, it's failure. - dwIndex = (dwIndex + 1) & dwHashIndexMask; - if(dwIndex == dwStartIndex) - break; - } - - // If we found a deleted entry, return that one preferentially - return (pDeletedEntry != NULL) ? pDeletedEntry : pFreeEntry; -} - -// Retrieves the first hash entry for the given file. -// Every locale version of a file has its own hash entry -TMPQHash * GetFirstHashEntry(TMPQArchive * ha, const char * szFileName) -{ - DWORD dwHashIndexMask = HASH_INDEX_MASK(ha); - DWORD dwStartIndex = ha->pfnHashString(szFileName, MPQ_HASH_TABLE_INDEX); - DWORD dwName1 = ha->pfnHashString(szFileName, MPQ_HASH_NAME_A); - DWORD dwName2 = ha->pfnHashString(szFileName, MPQ_HASH_NAME_B); - DWORD dwIndex; - - // Set the initial index - dwStartIndex = dwIndex = (dwStartIndex & dwHashIndexMask); - - // Search the hash table - for(;;) - { - TMPQHash * pHash = ha->pHashTable + dwIndex; - - // If the entry matches, we found it. - if(pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2 && MPQ_BLOCK_INDEX(pHash) < ha->dwFileTableSize) - return pHash; - - // If that hash entry is a free entry, it means we haven't found the file - if(pHash->dwBlockIndex == HASH_ENTRY_FREE) - return NULL; - - // Move to the next hash entry. Stop searching - // if we got reached the original hash entry - dwIndex = (dwIndex + 1) & dwHashIndexMask; - if(dwIndex == dwStartIndex) - return NULL; - } -} - -TMPQHash * GetNextHashEntry(TMPQArchive * ha, TMPQHash * pFirstHash, TMPQHash * pHash) -{ - DWORD dwHashIndexMask = HASH_INDEX_MASK(ha); - DWORD dwStartIndex = (DWORD)(pFirstHash - ha->pHashTable); - DWORD dwName1 = pHash->dwName1; - DWORD dwName2 = pHash->dwName2; - DWORD dwIndex = (DWORD)(pHash - ha->pHashTable); - - // Now go for any next entry that follows the pHash, - // until either free hash entry was found, or the start entry was reached - for(;;) - { - // Move to the next hash entry. Stop searching - // if we got reached the original hash entry - dwIndex = (dwIndex + 1) & dwHashIndexMask; - if(dwIndex == dwStartIndex) - return NULL; - pHash = ha->pHashTable + dwIndex; - - // If the entry matches, we found it. - if(pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2 && MPQ_BLOCK_INDEX(pHash) < ha->dwFileTableSize) - return pHash; - - // If that hash entry is a free entry, it means we haven't found the file - if(pHash->dwBlockIndex == HASH_ENTRY_FREE) - return NULL; - } -} - -// Allocates an entry in the hash table -TMPQHash * AllocateHashEntry( - TMPQArchive * ha, - TFileEntry * pFileEntry, - LCID lcLocale) -{ - TMPQHash * pHash; - DWORD dwStartIndex = ha->pfnHashString(pFileEntry->szFileName, MPQ_HASH_TABLE_INDEX); - DWORD dwName1 = ha->pfnHashString(pFileEntry->szFileName, MPQ_HASH_NAME_A); - DWORD dwName2 = ha->pfnHashString(pFileEntry->szFileName, MPQ_HASH_NAME_B); - - // Attempt to find a free hash entry - pHash = FindFreeHashEntry(ha, dwStartIndex, dwName1, dwName2, lcLocale); - if(pHash != NULL) - { - // Fill the free hash entry - pHash->dwName1 = dwName1; - pHash->dwName2 = dwName2; - pHash->lcLocale = (USHORT)lcLocale; - pHash->Platform = 0; - pHash->dwBlockIndex = (DWORD)(pFileEntry - ha->pFileTable); - } - - return pHash; -} - -// Finds a free space in the MPQ where to store next data -// The free space begins beyond the file that is stored at the fuhrtest -// position in the MPQ. (listfile), (attributes) and (signature) are ignored, -// unless the MPQ is being flushed. -ULONGLONG FindFreeMpqSpace(TMPQArchive * ha) -{ - TMPQHeader * pHeader = ha->pHeader; - TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; - TFileEntry * pFileEntry; - ULONGLONG FreeSpacePos = ha->pHeader->dwHeaderSize; - DWORD dwChunkCount; - - // Parse the entire block table - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - { - // Only take existing files with nonzero size - if((pFileEntry->dwFlags & MPQ_FILE_EXISTS) && (pFileEntry->dwCmpSize != 0)) - { - // If we are not saving MPQ tables, ignore internal MPQ files - if((ha->dwFlags & MPQ_FLAG_SAVING_TABLES) == 0 && IsInternalMpqFileName(pFileEntry->szFileName)) - continue; - - // If the end of the file is bigger than current MPQ table pos, update it - if((pFileEntry->ByteOffset + pFileEntry->dwCmpSize) > FreeSpacePos) - { - // Get the end of the file data - FreeSpacePos = pFileEntry->ByteOffset + pFileEntry->dwCmpSize; - - // Add the MD5 chunks, if present - if(pHeader->dwRawChunkSize != 0 && pFileEntry->dwCmpSize != 0) - { - dwChunkCount = ((pFileEntry->dwCmpSize - 1) / pHeader->dwRawChunkSize) + 1; - FreeSpacePos += dwChunkCount * MD5_DIGEST_SIZE; - } - } - } - } - - // Give the free space position to the caller - return FreeSpacePos; -} - -//----------------------------------------------------------------------------- -// Common functions - MPQ File - -TMPQFile * CreateFileHandle(TMPQArchive * ha, TFileEntry * pFileEntry) -{ - TMPQFile * hf; - - // Allocate space for TMPQFile - hf = STORM_ALLOC(TMPQFile, 1); - if(hf != NULL) - { - // Fill the file structure - memset(hf, 0, sizeof(TMPQFile)); - hf->dwMagic = ID_MPQ_FILE; - hf->pStream = NULL; - hf->ha = ha; - - // If the called entered a file entry, we also copy informations from the file entry - if(ha != NULL && pFileEntry != NULL) - { - // Set the raw position and MPQ position - hf->RawFilePos = FileOffsetFromMpqOffset(ha, pFileEntry->ByteOffset); - hf->MpqFilePos = pFileEntry->ByteOffset; - - // Set the data size - hf->dwDataSize = pFileEntry->dwFileSize; - hf->pFileEntry = pFileEntry; - } - } - - return hf; -} - -TMPQFile * CreateWritableHandle(TMPQArchive * ha, DWORD dwFileSize) -{ - ULONGLONG FreeMpqSpace; - ULONGLONG TempPos; - TMPQFile * hf; - - // We need to find the position in the MPQ where we save the file data - FreeMpqSpace = FindFreeMpqSpace(ha); - - // When format V1, the size of the archive cannot exceed 4 GB - if(ha->pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1) - { - TempPos = FreeMpqSpace + - dwFileSize + - (ha->pHeader->dwHashTableSize * sizeof(TMPQHash)) + - (ha->dwFileTableSize * sizeof(TMPQBlock)); - if((TempPos >> 32) != 0) - { - SetLastError(ERROR_DISK_FULL); - return NULL; - } - } - - // Allocate the file handle - hf = CreateFileHandle(ha, NULL); - if(hf == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return NULL; - } - - // We need to find the position in the MPQ where we save the file data - hf->MpqFilePos = FreeMpqSpace; - hf->bIsWriteHandle = true; - return hf; -} - -// Loads a table from MPQ. -// Can be used for hash table, block table, sector offset table or sector checksum table -void * LoadMpqTable( - TMPQArchive * ha, - ULONGLONG ByteOffset, - DWORD dwCompressedSize, - DWORD dwTableSize, - DWORD dwKey, - bool * pbTableIsCut) -{ - ULONGLONG FileSize = 0; - LPBYTE pbCompressed = NULL; - LPBYTE pbMpqTable; - LPBYTE pbToRead; - DWORD dwBytesToRead = dwCompressedSize; - int nError = ERROR_SUCCESS; - - // Allocate the MPQ table - pbMpqTable = pbToRead = STORM_ALLOC(BYTE, dwTableSize); - if(pbMpqTable != NULL) - { - // Check if the MPQ table is encrypted - if(dwCompressedSize < dwTableSize) - { - // Allocate temporary buffer for holding compressed data - pbCompressed = pbToRead = STORM_ALLOC(BYTE, dwCompressedSize); - if(pbCompressed == NULL) - { - STORM_FREE(pbMpqTable); - return NULL; - } - } - - // Get the file offset from which we will read the table - // Note: According to Storm.dll from Warcraft III (version 2002), - // if the hash table position is 0xFFFFFFFF, no SetFilePointer call is done - // and the table is loaded from the current file offset - if(ByteOffset == SFILE_INVALID_POS) - FileStream_GetPos(ha->pStream, &ByteOffset); - - // On archives v 1.0, hash table and block table can go beyond EOF. - // Storm.dll reads as much as possible, then fills the missing part with zeros. - // Abused by Spazzler map protector which sets hash table size to 0x00100000 - if(ha->pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1) - { - // Cut the table size - FileStream_GetSize(ha->pStream, &FileSize); - if((ByteOffset + dwBytesToRead) > FileSize) - { - // Fill the extra data with zeros - dwBytesToRead = (DWORD)(FileSize - ByteOffset); - memset(pbMpqTable + dwBytesToRead, 0, (dwTableSize - dwBytesToRead)); - - // Give the caller information that the table was cut - if(pbTableIsCut != NULL) - pbTableIsCut[0] = true; - } - } - - // If everything succeeded, read the raw table form the MPQ - if(FileStream_Read(ha->pStream, &ByteOffset, pbToRead, dwBytesToRead)) - { - // First of all, decrypt the table - if(dwKey != 0) - { - BSWAP_ARRAY32_UNSIGNED(pbToRead, dwCompressedSize); - DecryptMpqBlock(pbToRead, dwCompressedSize, dwKey); - BSWAP_ARRAY32_UNSIGNED(pbToRead, dwCompressedSize); - } - - // If the table is compressed, decompress it - if(dwCompressedSize < dwTableSize) - { - int cbOutBuffer = (int)dwTableSize; - int cbInBuffer = (int)dwCompressedSize; - - if(!SCompDecompress2(pbMpqTable, &cbOutBuffer, pbCompressed, cbInBuffer)) - nError = GetLastError(); - } - - // Make sure that the table is properly byte-swapped - BSWAP_ARRAY32_UNSIGNED(pbMpqTable, dwTableSize); - } - else - { - nError = GetLastError(); - } - - // If read failed, free the table and return - if(nError != ERROR_SUCCESS) - { - STORM_FREE(pbMpqTable); - pbMpqTable = NULL; - } - - // Free the compression buffer, if any - if(pbCompressed != NULL) - STORM_FREE(pbCompressed); - } - - // Return the MPQ table - return pbMpqTable; -} - -unsigned char * AllocateMd5Buffer( - DWORD dwRawDataSize, - DWORD dwChunkSize, - LPDWORD pcbMd5Size) -{ - unsigned char * md5_array; - DWORD cbMd5Size; - - // Sanity check - assert(dwRawDataSize != 0); - assert(dwChunkSize != 0); - - // Calculate how many MD5's we will calculate - cbMd5Size = (((dwRawDataSize - 1) / dwChunkSize) + 1) * MD5_DIGEST_SIZE; - - // Allocate space for array or MD5s - md5_array = STORM_ALLOC(BYTE, cbMd5Size); - - // Give the size of the MD5 array - if(pcbMd5Size != NULL) - *pcbMd5Size = cbMd5Size; - return md5_array; -} - -// Allocates sector buffer and sector offset table -int AllocateSectorBuffer(TMPQFile * hf) -{ - TMPQArchive * ha = hf->ha; - - // Caller of AllocateSectorBuffer must ensure these - assert(hf->pbFileSector == NULL); - assert(hf->pFileEntry != NULL); - assert(hf->ha != NULL); - - // Don't allocate anything if the file has zero size - if(hf->pFileEntry->dwFileSize == 0 || hf->dwDataSize == 0) - return ERROR_SUCCESS; - - // Determine the file sector size and allocate buffer for it - hf->dwSectorSize = (hf->pFileEntry->dwFlags & MPQ_FILE_SINGLE_UNIT) ? hf->dwDataSize : ha->dwSectorSize; - hf->pbFileSector = STORM_ALLOC(BYTE, hf->dwSectorSize); - hf->dwSectorOffs = SFILE_INVALID_POS; - - // Return result - return (hf->pbFileSector != NULL) ? (int)ERROR_SUCCESS : (int)ERROR_NOT_ENOUGH_MEMORY; -} - -// Allocates sector offset table -int AllocatePatchInfo(TMPQFile * hf, bool bLoadFromFile) -{ - TMPQArchive * ha = hf->ha; - DWORD dwLength = sizeof(TPatchInfo); - - // The following conditions must be true - assert(hf->pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE); - assert(hf->pPatchInfo == NULL); - -__AllocateAndLoadPatchInfo: - - // Allocate space for patch header. Start with default size, - // and if its size if bigger, then we reload them - hf->pPatchInfo = STORM_ALLOC(TPatchInfo, 1); - if(hf->pPatchInfo == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - // Do we have to load the patch header from the file ? - if(bLoadFromFile) - { - // Load the patch header - if(!FileStream_Read(ha->pStream, &hf->RawFilePos, hf->pPatchInfo, dwLength)) - { - // Free the patch info - STORM_FREE(hf->pPatchInfo); - hf->pPatchInfo = NULL; - return GetLastError(); - } - - // Perform necessary swapping - hf->pPatchInfo->dwLength = BSWAP_INT32_UNSIGNED(hf->pPatchInfo->dwLength); - hf->pPatchInfo->dwFlags = BSWAP_INT32_UNSIGNED(hf->pPatchInfo->dwFlags); - hf->pPatchInfo->dwDataSize = BSWAP_INT32_UNSIGNED(hf->pPatchInfo->dwDataSize); - - // Verify the size of the patch header - // If it's not default size, we have to reload them - if(hf->pPatchInfo->dwLength > dwLength) - { - // Free the patch info - dwLength = hf->pPatchInfo->dwLength; - STORM_FREE(hf->pPatchInfo); - hf->pPatchInfo = NULL; - - // If the length is out of all possible ranges, fail the operation - if(dwLength > 0x400) - return ERROR_FILE_CORRUPT; - goto __AllocateAndLoadPatchInfo; - } - - // Patch file data size according to the patch header - hf->dwDataSize = hf->pPatchInfo->dwDataSize; - } - else - { - memset(hf->pPatchInfo, 0, dwLength); - } - - // Save the final length to the patch header - hf->pPatchInfo->dwLength = dwLength; - hf->pPatchInfo->dwFlags = 0x80000000; - return ERROR_SUCCESS; -} - -// Allocates sector offset table -int AllocateSectorOffsets(TMPQFile * hf, bool bLoadFromFile) -{ - TMPQArchive * ha = hf->ha; - TFileEntry * pFileEntry = hf->pFileEntry; - DWORD dwSectorOffsLen; - bool bSectorOffsetTableCorrupt = false; - - // Caller of AllocateSectorOffsets must ensure these - assert(hf->SectorOffsets == NULL); - assert(hf->pFileEntry != NULL); - assert(hf->dwDataSize != 0); - assert(hf->ha != NULL); - - // If the file is stored as single unit, just set number of sectors to 1 - if(pFileEntry->dwFlags & MPQ_FILE_SINGLE_UNIT) - { - hf->dwSectorCount = 1; - return ERROR_SUCCESS; - } - - // Calculate the number of data sectors - // Note that this doesn't work if the file size is zero - hf->dwSectorCount = ((hf->dwDataSize - 1) / hf->dwSectorSize) + 1; - - // Calculate the number of file sectors - dwSectorOffsLen = (hf->dwSectorCount + 1) * sizeof(DWORD); - - // If MPQ_FILE_SECTOR_CRC flag is set, there will either be extra DWORD - // or an array of MD5's. Either way, we read at least 4 bytes more - // in order to save additional read from the file. - if(pFileEntry->dwFlags & MPQ_FILE_SECTOR_CRC) - dwSectorOffsLen += sizeof(DWORD); - - // Only allocate and load the table if the file is compressed - if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK) - { - __LoadSectorOffsets: - - // Allocate the sector offset table - hf->SectorOffsets = STORM_ALLOC(DWORD, (dwSectorOffsLen / sizeof(DWORD))); - if(hf->SectorOffsets == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - // Only read from the file if we are supposed to do so - if(bLoadFromFile) - { - ULONGLONG RawFilePos = hf->RawFilePos; - - // Append the length of the patch info, if any - if(hf->pPatchInfo != NULL) - { - if((RawFilePos + hf->pPatchInfo->dwLength) < RawFilePos) - return ERROR_FILE_CORRUPT; - RawFilePos += hf->pPatchInfo->dwLength; - } - - // Load the sector offsets from the file - if(!FileStream_Read(ha->pStream, &RawFilePos, hf->SectorOffsets, dwSectorOffsLen)) - { - // Free the sector offsets - STORM_FREE(hf->SectorOffsets); - hf->SectorOffsets = NULL; - return GetLastError(); - } - - // Swap the sector positions - BSWAP_ARRAY32_UNSIGNED(hf->SectorOffsets, dwSectorOffsLen); - - // Decrypt loaded sector positions if necessary - if(pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED) - { - // If we don't know the file key, try to find it. - if(hf->dwFileKey == 0) - { - hf->dwFileKey = DetectFileKeyBySectorSize(hf->SectorOffsets, ha->dwSectorSize, dwSectorOffsLen); - if(hf->dwFileKey == 0) - { - STORM_FREE(hf->SectorOffsets); - hf->SectorOffsets = NULL; - return ERROR_UNKNOWN_FILE_KEY; - } - } - - // Decrypt sector positions - DecryptMpqBlock(hf->SectorOffsets, dwSectorOffsLen, hf->dwFileKey - 1); - } - - // - // Validate the sector offset table - // - // Note: Some MPQ protectors put the actual file data before the sector offset table. - // In this case, the sector offsets are negative (> 0x80000000). - // - - for(DWORD i = 0; i < hf->dwSectorCount; i++) - { - DWORD dwSectorOffset1 = hf->SectorOffsets[i+1]; - DWORD dwSectorOffset0 = hf->SectorOffsets[i]; - - // Every following sector offset must be bigger than the previous one - if(dwSectorOffset1 <= dwSectorOffset0) - { - bSectorOffsetTableCorrupt = true; - break; - } - - // The sector size must not be bigger than compressed file size - // Edit: Yes, but apparently, in original Storm.dll, the compressed - // size is not checked anywhere. However, we need to do this check - // in order to sector offset table malformed by MPQ protectors - if((dwSectorOffset1 - dwSectorOffset0) > ha->dwSectorSize) - { - bSectorOffsetTableCorrupt = true; - break; - } - } - - // If data corruption detected, free the sector offset table - if(bSectorOffsetTableCorrupt) - { - STORM_FREE(hf->SectorOffsets); - hf->SectorOffsets = NULL; - return ERROR_FILE_CORRUPT; - } - - // - // There may be various extra DWORDs loaded after the sector offset table. - // They are mostly empty on WoW release MPQs, but on MPQs from PTR, - // they contain random non-zero data. Their meaning is unknown. - // - // These extra values are, however, include in the dwCmpSize in the file - // table. We cannot ignore them, because compacting archive would fail - // - - if(hf->SectorOffsets[0] > dwSectorOffsLen) - { - // MPQ protectors put some ridiculous values there. We must limit the extra bytes - if(hf->SectorOffsets[0] > (dwSectorOffsLen + 0x400)) - return ERROR_FILE_CORRUPT; - - // Free the old sector offset table - dwSectorOffsLen = hf->SectorOffsets[0]; - STORM_FREE(hf->SectorOffsets); - goto __LoadSectorOffsets; - } - } - else - { - memset(hf->SectorOffsets, 0, dwSectorOffsLen); - hf->SectorOffsets[0] = dwSectorOffsLen; - } - } - - return ERROR_SUCCESS; -} - -int AllocateSectorChecksums(TMPQFile * hf, bool bLoadFromFile) -{ - TMPQArchive * ha = hf->ha; - TFileEntry * pFileEntry = hf->pFileEntry; - ULONGLONG RawFilePos; - DWORD dwCompressedSize = 0; - DWORD dwExpectedSize; - DWORD dwCrcOffset; // Offset of the CRC table, relative to file offset in the MPQ - DWORD dwCrcSize; - - // Caller of AllocateSectorChecksums must ensure these - assert(hf->SectorChksums == NULL); - assert(hf->SectorOffsets != NULL); - assert(hf->pFileEntry != NULL); - assert(hf->ha != NULL); - - // Single unit files don't have sector checksums - if(pFileEntry->dwFlags & MPQ_FILE_SINGLE_UNIT) - return ERROR_SUCCESS; - - // Caller must ensure that we are only called when we have sector checksums - assert(pFileEntry->dwFlags & MPQ_FILE_SECTOR_CRC); - - // - // Older MPQs store an array of CRC32's after - // the raw file data in the MPQ. - // - // In newer MPQs, the (since Cataclysm BETA) the (attributes) file - // contains additional 32-bit values beyond the sector table. - // Their number depends on size of the (attributes), but their - // meaning is unknown. They are usually zeroed in retail game files, - // but contain some sort of checksum in BETA MPQs - // - - // Does the size of the file table match with the CRC32-based checksums? - dwExpectedSize = (hf->dwSectorCount + 2) * sizeof(DWORD); - if(hf->SectorOffsets[0] != 0 && hf->SectorOffsets[0] == dwExpectedSize) - { - // If we are not loading from the MPQ file, we just allocate the sector table - // In that case, do not check any sizes - if(bLoadFromFile == false) - { - hf->SectorChksums = STORM_ALLOC(DWORD, hf->dwSectorCount); - if(hf->SectorChksums == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - // Fill the checksum table with zeros - memset(hf->SectorChksums, 0, hf->dwSectorCount * sizeof(DWORD)); - return ERROR_SUCCESS; - } - else - { - // Is there valid size of the sector checksums? - if(hf->SectorOffsets[hf->dwSectorCount + 1] >= hf->SectorOffsets[hf->dwSectorCount]) - dwCompressedSize = hf->SectorOffsets[hf->dwSectorCount + 1] - hf->SectorOffsets[hf->dwSectorCount]; - - // Ignore cases when the length is too small or too big. - if(dwCompressedSize < sizeof(DWORD) || dwCompressedSize > hf->dwSectorSize) - return ERROR_SUCCESS; - - // Calculate offset of the CRC table - dwCrcSize = hf->dwSectorCount * sizeof(DWORD); - dwCrcOffset = hf->SectorOffsets[hf->dwSectorCount]; - RawFilePos = CalculateRawSectorOffset(hf, dwCrcOffset); - - // Now read the table from the MPQ - hf->SectorChksums = (DWORD *)LoadMpqTable(ha, RawFilePos, dwCompressedSize, dwCrcSize, 0, NULL); - if(hf->SectorChksums == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - } - } - - // If the size doesn't match, we ignore sector checksums -// assert(false); - return ERROR_SUCCESS; -} - -int WritePatchInfo(TMPQFile * hf) -{ - TMPQArchive * ha = hf->ha; - TPatchInfo * pPatchInfo = hf->pPatchInfo; - - // The caller must make sure that this function is only called - // when the following is true. - assert(hf->pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE); - assert(pPatchInfo != NULL); - - BSWAP_ARRAY32_UNSIGNED(pPatchInfo, 3 * sizeof(DWORD)); - if(!FileStream_Write(ha->pStream, &hf->RawFilePos, pPatchInfo, sizeof(TPatchInfo))) - return GetLastError(); - - return ERROR_SUCCESS; -} - -int WriteSectorOffsets(TMPQFile * hf) -{ - TMPQArchive * ha = hf->ha; - TFileEntry * pFileEntry = hf->pFileEntry; - ULONGLONG RawFilePos = hf->RawFilePos; - DWORD dwSectorOffsLen; - - // The caller must make sure that this function is only called - // when the following is true. - assert(hf->pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK); - assert(hf->SectorOffsets != NULL); - dwSectorOffsLen = hf->SectorOffsets[0]; - - // If file is encrypted, sector positions are also encrypted - if(pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED) - EncryptMpqBlock(hf->SectorOffsets, dwSectorOffsLen, hf->dwFileKey - 1); - BSWAP_ARRAY32_UNSIGNED(hf->SectorOffsets, dwSectorOffsLen); - - // Adjust sector offset table position, if we also have patch info - if(hf->pPatchInfo != NULL) - RawFilePos += hf->pPatchInfo->dwLength; - - // Write sector offsets to the archive - if(!FileStream_Write(ha->pStream, &RawFilePos, hf->SectorOffsets, dwSectorOffsLen)) - return GetLastError(); - - // Not necessary, as the sector checksums - // are going to be freed when this is done. -// BSWAP_ARRAY32_UNSIGNED(hf->SectorOffsets, dwSectorOffsLen); - return ERROR_SUCCESS; -} - - -int WriteSectorChecksums(TMPQFile * hf) -{ - TMPQArchive * ha = hf->ha; - ULONGLONG RawFilePos; - TFileEntry * pFileEntry = hf->pFileEntry; - LPBYTE pbCompressed; - DWORD dwCompressedSize = 0; - DWORD dwCrcSize; - int nOutSize; - int nError = ERROR_SUCCESS; - - // The caller must make sure that this function is only called - // when the following is true. - assert(hf->pFileEntry->dwFlags & MPQ_FILE_SECTOR_CRC); - assert(hf->SectorOffsets != NULL); - assert(hf->SectorChksums != NULL); - - // If the MPQ has MD5 of each raw data chunk, - // we leave sector offsets empty - if(ha->pHeader->dwRawChunkSize != 0) - { - hf->SectorOffsets[hf->dwSectorCount + 1] = hf->SectorOffsets[hf->dwSectorCount]; - return ERROR_SUCCESS; - } - - // Calculate size of the checksum array - dwCrcSize = hf->dwSectorCount * sizeof(DWORD); - - // Allocate buffer for compressed sector CRCs. - pbCompressed = STORM_ALLOC(BYTE, dwCrcSize); - if(pbCompressed == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - // Perform the compression - BSWAP_ARRAY32_UNSIGNED(hf->SectorChksums, dwCrcSize); - - nOutSize = (int)dwCrcSize; - SCompCompress(pbCompressed, &nOutSize, hf->SectorChksums, (int)dwCrcSize, MPQ_COMPRESSION_ZLIB, 0, 0); - dwCompressedSize = (DWORD)nOutSize; - - // Write the sector CRCs to the archive - RawFilePos = hf->RawFilePos + hf->SectorOffsets[hf->dwSectorCount]; - if(hf->pPatchInfo != NULL) - RawFilePos += hf->pPatchInfo->dwLength; - if(!FileStream_Write(ha->pStream, &RawFilePos, pbCompressed, dwCompressedSize)) - nError = GetLastError(); - - // Not necessary, as the sector checksums - // are going to be freed when this is done. -// BSWAP_ARRAY32_UNSIGNED(hf->SectorChksums, dwCrcSize); - - // Store the sector CRCs - hf->SectorOffsets[hf->dwSectorCount + 1] = hf->SectorOffsets[hf->dwSectorCount] + dwCompressedSize; - pFileEntry->dwCmpSize += dwCompressedSize; - STORM_FREE(pbCompressed); - return nError; -} - -int WriteMemDataMD5( - TFileStream * pStream, - ULONGLONG RawDataOffs, - void * pvRawData, - DWORD dwRawDataSize, - DWORD dwChunkSize, - LPDWORD pcbTotalSize) -{ - unsigned char * md5_array; - unsigned char * md5; - LPBYTE pbRawData = (LPBYTE)pvRawData; - DWORD dwBytesRemaining = dwRawDataSize; - DWORD dwMd5ArraySize = 0; - int nError = ERROR_SUCCESS; - - // Allocate buffer for array of MD5 - md5_array = md5 = AllocateMd5Buffer(dwRawDataSize, dwChunkSize, &dwMd5ArraySize); - if(md5_array == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - // For every file chunk, calculate MD5 - while(dwBytesRemaining != 0) - { - // Get the remaining number of bytes to read - dwChunkSize = STORMLIB_MIN(dwBytesRemaining, dwChunkSize); - - // Calculate MD5 - CalculateDataBlockHash(pbRawData, dwChunkSize, md5); - md5 += MD5_DIGEST_SIZE; - - // Move offset and size - dwBytesRemaining -= dwChunkSize; - pbRawData += dwChunkSize; - } - - // Write the array od MD5's to the file - RawDataOffs += dwRawDataSize; - if(!FileStream_Write(pStream, &RawDataOffs, md5_array, dwMd5ArraySize)) - nError = GetLastError(); - - // Give the caller the size of the MD5 array - if(pcbTotalSize != NULL) - *pcbTotalSize = dwRawDataSize + dwMd5ArraySize; - - // Free buffers and exit - STORM_FREE(md5_array); - return nError; -} - - -// Writes the MD5 for each chunk of the raw file data -int WriteMpqDataMD5( - TFileStream * pStream, - ULONGLONG RawDataOffs, - DWORD dwRawDataSize, - DWORD dwChunkSize) -{ - unsigned char * md5_array; - unsigned char * md5; - LPBYTE pbFileChunk; - DWORD dwMd5ArraySize = 0; - DWORD dwToRead = dwRawDataSize; - int nError = ERROR_SUCCESS; - - // Allocate buffer for array of MD5 - md5_array = md5 = AllocateMd5Buffer(dwRawDataSize, dwChunkSize, &dwMd5ArraySize); - if(md5_array == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - // Allocate space for file chunk - pbFileChunk = STORM_ALLOC(BYTE, dwChunkSize); - if(pbFileChunk == NULL) - { - STORM_FREE(md5_array); - return ERROR_NOT_ENOUGH_MEMORY; - } - - // For every file chunk, calculate MD5 - while(dwRawDataSize != 0) - { - // Get the remaining number of bytes to read - dwToRead = STORMLIB_MIN(dwRawDataSize, dwChunkSize); - - // Read the chunk - if(!FileStream_Read(pStream, &RawDataOffs, pbFileChunk, dwToRead)) - { - nError = GetLastError(); - break; - } - - // Calculate MD5 - CalculateDataBlockHash(pbFileChunk, dwToRead, md5); - md5 += MD5_DIGEST_SIZE; - - // Move offset and size - RawDataOffs += dwToRead; - dwRawDataSize -= dwToRead; - } - - // Write the array od MD5's to the file - if(nError == ERROR_SUCCESS) - { - if(!FileStream_Write(pStream, NULL, md5_array, dwMd5ArraySize)) - nError = GetLastError(); - } - - // Free buffers and exit - STORM_FREE(pbFileChunk); - STORM_FREE(md5_array); - return nError; -} - -// Frees the structure for MPQ file -void FreeFileHandle(TMPQFile *& hf) -{ - if(hf != NULL) - { - // If we have patch file attached to this one, free it first - if(hf->hfPatch != NULL) - FreeFileHandle(hf->hfPatch); - - // Then free all buffers allocated in the file structure - if(hf->pbFileData != NULL) - STORM_FREE(hf->pbFileData); - if(hf->pPatchInfo != NULL) - STORM_FREE(hf->pPatchInfo); - if(hf->SectorOffsets != NULL) - STORM_FREE(hf->SectorOffsets); - if(hf->SectorChksums != NULL) - STORM_FREE(hf->SectorChksums); - if(hf->pbFileSector != NULL) - STORM_FREE(hf->pbFileSector); - if(hf->pStream != NULL) - FileStream_Close(hf->pStream); - STORM_FREE(hf); - hf = NULL; - } -} - -// Frees the MPQ archive -void FreeArchiveHandle(TMPQArchive *& ha) -{ - if(ha != NULL) - { - // First of all, free the patch archive, if any - if(ha->haPatch != NULL) - FreeArchiveHandle(ha->haPatch); - - // Free the patch prefix, if any - if(ha->pPatchPrefix != NULL) - STORM_FREE(ha->pPatchPrefix); - - // Close the file stream - FileStream_Close(ha->pStream); - ha->pStream = NULL; - - // Free the file names from the file table - if(ha->pFileTable != NULL) - { - for(DWORD i = 0; i < ha->dwFileTableSize; i++) - { - if(ha->pFileTable[i].szFileName != NULL) - STORM_FREE(ha->pFileTable[i].szFileName); - ha->pFileTable[i].szFileName = NULL; - } - - // Then free all buffers allocated in the archive structure - STORM_FREE(ha->pFileTable); - } - - if(ha->pHashTable != NULL) - STORM_FREE(ha->pHashTable); - if(ha->pHetTable != NULL) - FreeHetTable(ha->pHetTable); - STORM_FREE(ha); - ha = NULL; - } -} - -bool IsInternalMpqFileName(const char * szFileName) -{ - if(szFileName != NULL && szFileName[0] == '(') - { - if(!_stricmp(szFileName, LISTFILE_NAME) || - !_stricmp(szFileName, ATTRIBUTES_NAME) || - !_stricmp(szFileName, SIGNATURE_NAME)) - { - return true; - } - } - - return false; -} - -// Verifies if the file name is a pseudo-name -bool IsPseudoFileName(const char * szFileName, DWORD * pdwFileIndex) -{ - DWORD dwFileIndex = 0; - - if(szFileName != NULL) - { - // Must be "File########.ext" - if(!_strnicmp(szFileName, "File", 4)) - { - // Check 8 digits - for(int i = 4; i < 4+8; i++) - { - if(szFileName[i] < '0' || szFileName[i] > '9') - return false; - dwFileIndex = (dwFileIndex * 10) + (szFileName[i] - '0'); - } - - // An extension must follow - if(szFileName[12] == '.') - { - if(pdwFileIndex != NULL) - *pdwFileIndex = dwFileIndex; - return true; - } - } - } - - // Not a pseudo-name - return false; -} - -//----------------------------------------------------------------------------- -// Functions calculating and verifying the MD5 signature - -bool IsValidMD5(LPBYTE pbMd5) -{ - LPDWORD Md5 = (LPDWORD)pbMd5; - - return (Md5[0] | Md5[1] | Md5[2] | Md5[3]) ? true : false; -} - -bool IsValidSignature(LPBYTE pbSignature) -{ - LPDWORD Signature = (LPDWORD)pbSignature; - DWORD SigValid = 0; - - for(int i = 0; i < MPQ_WEAK_SIGNATURE_SIZE / sizeof(DWORD); i++) - SigValid |= Signature[i]; - - return (SigValid != 0) ? true : false; -} - - -bool VerifyDataBlockHash(void * pvDataBlock, DWORD cbDataBlock, LPBYTE expected_md5) -{ - hash_state md5_state; - BYTE md5_digest[MD5_DIGEST_SIZE]; - - // Don't verify the block if the MD5 is not valid. - if(!IsValidMD5(expected_md5)) - return true; - - // Calculate the MD5 of the data block - md5_init(&md5_state); - md5_process(&md5_state, (unsigned char *)pvDataBlock, cbDataBlock); - md5_done(&md5_state, md5_digest); - - // Does the MD5's match? - return (memcmp(md5_digest, expected_md5, MD5_DIGEST_SIZE) == 0); -} - -void CalculateDataBlockHash(void * pvDataBlock, DWORD cbDataBlock, LPBYTE md5_hash) -{ - hash_state md5_state; - - md5_init(&md5_state); - md5_process(&md5_state, (unsigned char *)pvDataBlock, cbDataBlock); - md5_done(&md5_state, md5_hash); -} - - -//----------------------------------------------------------------------------- -// Swapping functions - -#ifndef PLATFORM_LITTLE_ENDIAN - -// -// Note that those functions are implemented for Mac operating system, -// as this is the only supported platform that uses big endian. -// - -// Swaps a signed 16-bit integer -int16_t SwapInt16(uint16_t data) -{ - return (int16_t)CFSwapInt16(data); -} - -// Swaps an unsigned 16-bit integer -uint16_t SwapUInt16(uint16_t data) -{ - return CFSwapInt16(data); -} - -// Swaps signed 32-bit integer -int32_t SwapInt32(uint32_t data) -{ - return (int32_t)CFSwapInt32(data); -} - -// Swaps an unsigned 32-bit integer -uint32_t SwapUInt32(uint32_t data) -{ - return CFSwapInt32(data); -} - -// Swaps signed 64-bit integer -int64_t SwapInt64(int64_t data) -{ - return (int64_t)CFSwapInt64(data); -} - -// Swaps an unsigned 64-bit integer -uint64_t SwapUInt64(uint64_t data) -{ - return CFSwapInt64(data); -} - -// Swaps array of unsigned 16-bit integers -void ConvertUInt16Buffer(void * ptr, size_t length) -{ - uint16_t * buffer = (uint16_t *)ptr; - uint32_t nElements = (uint32_t)(length / sizeof(uint16_t)); - - while(nElements-- > 0) - { - *buffer = SwapUInt16(*buffer); - buffer++; - } -} - -// Swaps array of unsigned 32-bit integers -void ConvertUInt32Buffer(void * ptr, size_t length) -{ - uint32_t * buffer = (uint32_t *)ptr; - uint32_t nElements = (uint32_t)(length / sizeof(uint32_t)); - - while(nElements-- > 0) - { - *buffer = SwapUInt32(*buffer); - buffer++; - } -} - -// Swaps array of unsigned 64-bit integers -void ConvertUInt64Buffer(void * ptr, size_t length) -{ - uint64_t * buffer = (uint64_t *)ptr; - uint32_t nElements = (uint32_t)(length / sizeof(uint64_t)); - - while(nElements-- > 0) - { - *buffer = SwapUInt64(*buffer); - buffer++; - } -} - -// Swaps the TMPQHeader structure -void ConvertTMPQHeader(void *header, uint16_t version) -{ - TMPQHeader * theHeader = (TMPQHeader *)header; - - // Swap header part version 1 - if(version == MPQ_FORMAT_VERSION_1) - { - theHeader->dwID = SwapUInt32(theHeader->dwID); - theHeader->dwHeaderSize = SwapUInt32(theHeader->dwHeaderSize); - theHeader->dwArchiveSize = SwapUInt32(theHeader->dwArchiveSize); - theHeader->wFormatVersion = SwapUInt16(theHeader->wFormatVersion); - theHeader->wSectorSize = SwapUInt16(theHeader->wSectorSize); - theHeader->dwHashTablePos = SwapUInt32(theHeader->dwHashTablePos); - theHeader->dwBlockTablePos = SwapUInt32(theHeader->dwBlockTablePos); - theHeader->dwHashTableSize = SwapUInt32(theHeader->dwHashTableSize); - theHeader->dwBlockTableSize = SwapUInt32(theHeader->dwBlockTableSize); - } - - if(version == MPQ_FORMAT_VERSION_2) - { - theHeader->HiBlockTablePos64 = SwapUInt64(theHeader->HiBlockTablePos64); - theHeader->wHashTablePosHi = SwapUInt16(theHeader->wHashTablePosHi); - theHeader->wBlockTablePosHi = SwapUInt16(theHeader->wBlockTablePosHi); - } - - if(version == MPQ_FORMAT_VERSION_3) - { - theHeader->ArchiveSize64 = SwapUInt64(theHeader->ArchiveSize64); - theHeader->BetTablePos64 = SwapUInt64(theHeader->BetTablePos64); - theHeader->HetTablePos64 = SwapUInt64(theHeader->HetTablePos64); - } - - if(version == MPQ_FORMAT_VERSION_4) - { - theHeader->HashTableSize64 = SwapUInt64(theHeader->HashTableSize64); - theHeader->BlockTableSize64 = SwapUInt64(theHeader->BlockTableSize64); - theHeader->HiBlockTableSize64 = SwapUInt64(theHeader->HiBlockTableSize64); - theHeader->HetTableSize64 = SwapUInt64(theHeader->HetTableSize64); - theHeader->BetTableSize64 = SwapUInt64(theHeader->BetTableSize64); - } -} - -#endif // PLATFORM_LITTLE_ENDIAN diff --git a/libs/storm-sys/StormLib/src/SBaseDumpData.cpp b/libs/storm-sys/StormLib/src/SBaseDumpData.cpp deleted file mode 100644 index 334561b..0000000 --- a/libs/storm-sys/StormLib/src/SBaseDumpData.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/*****************************************************************************/ -/* SBaseDumpData.cpp Copyright (c) Ladislav Zezula 2011 */ -/*---------------------------------------------------------------------------*/ -/* Description : */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 26.01.11 1.00 Lad The first version of SBaseDumpData.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "StormCommon.h" - -#ifdef __STORMLIB_DUMP_DATA__ - -void DumpMpqHeader(TMPQHeader * pHeader) -{ - printf("== MPQ Header =================================\n"); - printf("DWORD dwID = %08X\n", pHeader->dwID); - printf("DWORD dwHeaderSize = %08X\n", pHeader->dwHeaderSize); - printf("DWORD dwArchiveSize = %08X\n", pHeader->dwArchiveSize); - printf("USHORT wFormatVersion = %04X\n", pHeader->wFormatVersion); - printf("USHORT wSectorSize = %04X\n", pHeader->wSectorSize); - printf("DWORD dwHashTablePos = %08X\n", pHeader->dwHashTablePos); - printf("DWORD dwBlockTablePos = %08X\n", pHeader->dwBlockTablePos); - printf("DWORD dwHashTableSize = %08X\n", pHeader->dwHashTableSize); - printf("DWORD dwBlockTableSize = %08X\n", pHeader->dwBlockTableSize); - printf("ULONGLONG HiBlockTablePos64 = %016llX\n", pHeader->HiBlockTablePos64); - printf("USHORT wHashTablePosHi = %04X\n", pHeader->wHashTablePosHi); - printf("USHORT wBlockTablePosHi = %04X\n", pHeader->wBlockTablePosHi); - printf("ULONGLONG ArchiveSize64 = %016llX\n", pHeader->ArchiveSize64); - printf("ULONGLONG BetTablePos64 = %016llX\n", pHeader->BetTablePos64); - printf("ULONGLONG HetTablePos64 = %016llX\n", pHeader->HetTablePos64); - printf("ULONGLONG HashTableSize64 = %016llX\n", pHeader->HashTableSize64); - printf("ULONGLONG BlockTableSize64 = %016llX\n", pHeader->BlockTableSize64); - printf("ULONGLONG HiBlockTableSize64 = %016llX\n", pHeader->HiBlockTableSize64); - printf("ULONGLONG HetTableSize64 = %016llX\n", pHeader->HetTableSize64); - printf("ULONGLONG BetTableSize64 = %016llX\n", pHeader->BetTableSize64); - printf("DWORD dwRawChunkSize = %08X\n", pHeader->dwRawChunkSize); - printf("-----------------------------------------------\n\n"); -} - -void DumpHashTable(TMPQHash * pHashTable, DWORD dwHashTableSize) -{ - DWORD i; - - if(pHashTable == NULL || dwHashTableSize == 0) - return; - - printf("== Hash Table =================================\n"); - for(i = 0; i < dwHashTableSize; i++) - { - printf("[%08x] %08X %08X %04X %02X %08X\n", i, - pHashTable[i].dwName1, - pHashTable[i].dwName2, - pHashTable[i].lcLocale, - pHashTable[i].Platform, - pHashTable[i].dwBlockIndex); - } - printf("-----------------------------------------------\n\n"); -} - -void DumpHetAndBetTable(TMPQHetTable * pHetTable, TMPQBetTable * pBetTable) -{ - DWORD i; - - if(pHetTable == NULL || pBetTable == NULL) - return; - - printf("== HET Header =================================\n"); - printf("ULONGLONG AndMask64 = %016llX\n", pHetTable->AndMask64); - printf("ULONGLONG OrMask64 = %016llX\n", pHetTable->OrMask64); - printf("DWORD dwEntryCount = %08X\n", pHetTable->dwEntryCount); - printf("DWORD dwTotalCount = %08X\n", pHetTable->dwTotalCount); - printf("DWORD dwNameHashBitSize = %08X\n", pHetTable->dwNameHashBitSize); - printf("DWORD dwIndexSizeTotal = %08X\n", pHetTable->dwIndexSizeTotal); - printf("DWORD dwIndexSizeExtra = %08X\n", pHetTable->dwIndexSizeExtra); - printf("DWORD dwIndexSize = %08X\n", pHetTable->dwIndexSize); - printf("-----------------------------------------------\n\n"); - - printf("== BET Header =================================\n"); - printf("DWORD dwTableEntrySize = %08X\n", pBetTable->dwTableEntrySize); - printf("DWORD dwBitIndex_FilePos = %08X\n", pBetTable->dwBitIndex_FilePos); - printf("DWORD dwBitIndex_FileSize = %08X\n", pBetTable->dwBitIndex_FileSize); - printf("DWORD dwBitIndex_CmpSize = %08X\n", pBetTable->dwBitIndex_CmpSize); - printf("DWORD dwBitIndex_FlagIndex = %08X\n", pBetTable->dwBitIndex_FlagIndex); - printf("DWORD dwBitIndex_Unknown = %08X\n", pBetTable->dwBitIndex_Unknown); - printf("DWORD dwBitCount_FilePos = %08X\n", pBetTable->dwBitCount_FilePos); - printf("DWORD dwBitCount_FileSize = %08X\n", pBetTable->dwBitCount_FileSize); - printf("DWORD dwBitCount_CmpSize = %08X\n", pBetTable->dwBitCount_CmpSize); - printf("DWORD dwBitCount_FlagIndex = %08X\n", pBetTable->dwBitCount_FlagIndex); - printf("DWORD dwBitCount_Unknown = %08X\n", pBetTable->dwBitCount_Unknown); - printf("DWORD dwBitTotal_NameHash2 = %08X\n", pBetTable->dwBitTotal_NameHash2); - printf("DWORD dwBitExtra_NameHash2 = %08X\n", pBetTable->dwBitExtra_NameHash2); - printf("DWORD dwBitCount_NameHash2 = %08X\n", pBetTable->dwBitCount_NameHash2); - printf("DWORD dwEntryCount = %08X\n", pBetTable->dwEntryCount); - printf("DWORD dwFlagCount = %08X\n", pBetTable->dwFlagCount); - printf("-----------------------------------------------\n\n"); - - printf("== HET & Bet Table ======================================================================\n\n"); - printf("HetIdx HetHash BetIdx BetHash ByteOffset FileSize CmpSize FlgIdx Flags \n"); - printf("------ ------- ------ ---------------- ---------------- -------- -------- ------ --------\n"); - for(i = 0; i < pHetTable->dwTotalCount; i++) - { - ULONGLONG ByteOffset = 0; - ULONGLONG BetHash = 0; - DWORD dwFileSize = 0; - DWORD dwCmpSize = 0; - DWORD dwFlagIndex = 0; - DWORD dwFlags = 0; - DWORD dwBetIndex = 0; - - GetBits(pHetTable->pBetIndexes, i * pHetTable->dwIndexSizeTotal, - pHetTable->dwIndexSize, - &dwBetIndex, - 4); - - if(dwBetIndex < pHetTable->dwTotalCount) - { - DWORD dwEntryIndex = pBetTable->dwTableEntrySize * dwBetIndex; - - GetBits(pBetTable->pNameHashes, dwBetIndex * pBetTable->dwBitTotal_NameHash2, - pBetTable->dwBitCount_NameHash2, - &BetHash, - 8); - - GetBits(pBetTable->pFileTable, dwEntryIndex + pBetTable->dwBitIndex_FilePos, - pBetTable->dwBitCount_FilePos, - &ByteOffset, - 8); - - GetBits(pBetTable->pFileTable, dwEntryIndex + pBetTable->dwBitIndex_FileSize, - pBetTable->dwBitCount_FileSize, - &dwFileSize, - 4); - - GetBits(pBetTable->pFileTable, dwEntryIndex + pBetTable->dwBitIndex_CmpSize, - pBetTable->dwBitCount_CmpSize, - &dwCmpSize, - 4); - - GetBits(pBetTable->pFileTable, dwEntryIndex + pBetTable->dwBitIndex_FlagIndex, - pBetTable->dwBitCount_FlagIndex, - &dwFlagIndex, - 4); - - dwFlags = pBetTable->pFileFlags[dwFlagIndex]; - } - - printf(" %04X %02lX %04X %016llX %016llX %08X %08X %04X %08X\n", i, - pHetTable->pNameHashes[i], - dwBetIndex, - BetHash, - ByteOffset, - dwFileSize, - dwCmpSize, - dwFlagIndex, - dwFlags); - } - printf("-----------------------------------------------------------------------------------------\n"); -} - -void DumpFileTable(TFileEntry * pFileTable, DWORD dwFileTableSize) -{ - DWORD i; - - if(pFileTable == NULL || dwFileTableSize == 0) - return; - - printf("== File Table =================================\n"); - for(i = 0; i < dwFileTableSize; i++, pFileTable++) - { - printf("[%04u] %08X-%08X %08X-%08X %08X-%08X 0x%08X 0x%08X 0x%08X %s\n", i, - (DWORD)(pFileTable->FileNameHash >> 0x20), - (DWORD)(pFileTable->FileNameHash & 0xFFFFFFFF), - (DWORD)(pFileTable->ByteOffset >> 0x20), - (DWORD)(pFileTable->ByteOffset & 0xFFFFFFFF), - (DWORD)(pFileTable->FileTime >> 0x20), - (DWORD)(pFileTable->FileTime & 0xFFFFFFFF), - pFileTable->dwFileSize, - pFileTable->dwCmpSize, - pFileTable->dwFlags, - pFileTable->szFileName != NULL ? pFileTable->szFileName : ""); - } - printf("-----------------------------------------------\n\n"); -} - -#endif // __STORMLIB_DUMP_DATA__ diff --git a/libs/storm-sys/StormLib/src/SBaseFileTable.cpp b/libs/storm-sys/StormLib/src/SBaseFileTable.cpp deleted file mode 100644 index e66536d..0000000 --- a/libs/storm-sys/StormLib/src/SBaseFileTable.cpp +++ /dev/null @@ -1,2958 +0,0 @@ -/*****************************************************************************/ -/* SBaseFileTable.cpp Copyright (c) Ladislav Zezula 2010 */ -/*---------------------------------------------------------------------------*/ -/* Description: Common handler for classic and new hash&block tables */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 06.09.10 1.00 Lad The first version of SBaseFileTable.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "StormCommon.h" - -//----------------------------------------------------------------------------- -// Local defines - -#define INVALID_FLAG_VALUE 0xCCCCCCCC -#define MAX_FLAG_INDEX 512 - -//----------------------------------------------------------------------------- -// Support for calculating bit sizes - -static void InitFileFlagArray(LPDWORD FlagArray) -{ - memset(FlagArray, 0xCC, MAX_FLAG_INDEX * sizeof(DWORD)); -} - -static DWORD GetFileFlagIndex(LPDWORD FlagArray, DWORD dwFlags) -{ - // Find free or equal entry in the flag array - for(DWORD dwFlagIndex = 0; dwFlagIndex < MAX_FLAG_INDEX; dwFlagIndex++) - { - if(FlagArray[dwFlagIndex] == INVALID_FLAG_VALUE || FlagArray[dwFlagIndex] == dwFlags) - { - FlagArray[dwFlagIndex] = dwFlags; - return dwFlagIndex; - } - } - - // This should never happen - assert(false); - return 0xFFFFFFFF; -} - -static DWORD GetNecessaryBitCount(ULONGLONG MaxValue) -{ - DWORD dwBitCount = 0; - - while(MaxValue > 0) - { - MaxValue >>= 1; - dwBitCount++; - } - - return dwBitCount; -} - -//----------------------------------------------------------------------------- -// Support functions for BIT_ARRAY - -static USHORT SetBitsMask[] = {0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF}; - -static TBitArray * CreateBitArray( - DWORD NumberOfBits, - BYTE FillValue) -{ - TBitArray * pBitArray; - size_t nSize = sizeof(TBitArray) + (NumberOfBits + 7) / 8; - - // Allocate the bit array - pBitArray = (TBitArray *)STORM_ALLOC(BYTE, nSize); - if(pBitArray != NULL) - { - memset(pBitArray, FillValue, nSize); - pBitArray->NumberOfBytes = (NumberOfBits + 7) / 8; - pBitArray->NumberOfBits = NumberOfBits; - } - - return pBitArray; -} - -void GetBits( - TBitArray * pArray, - unsigned int nBitPosition, - unsigned int nBitLength, - void * pvBuffer, - int nResultByteSize) -{ - unsigned char * pbBuffer = (unsigned char *)pvBuffer; - unsigned int nBytePosition0 = (nBitPosition / 8); - unsigned int nBytePosition1 = nBytePosition0 + 1; - unsigned int nByteLength = (nBitLength / 8); - unsigned int nBitOffset = (nBitPosition & 0x07); - unsigned char BitBuffer; - - // Keep compiler happy for platforms where nResultByteSize is not used - nResultByteSize = nResultByteSize; - -#ifdef _DEBUG - // Check if the target is properly zeroed - for(int i = 0; i < nResultByteSize; i++) - assert(pbBuffer[i] == 0); -#endif - -#ifndef PLATFORM_LITTLE_ENDIAN - // Adjust the buffer pointer for big endian platforms - pbBuffer += (nResultByteSize - 1); -#endif - - // Copy whole bytes, if any - while(nByteLength > 0) - { - // Is the current position in the Elements byte-aligned? - if(nBitOffset != 0) - { - BitBuffer = (unsigned char)((pArray->Elements[nBytePosition0] >> nBitOffset) | (pArray->Elements[nBytePosition1] << (0x08 - nBitOffset))); - } - else - { - BitBuffer = pArray->Elements[nBytePosition0]; - } - -#ifdef PLATFORM_LITTLE_ENDIAN - *pbBuffer++ = BitBuffer; -#else - *pbBuffer-- = BitBuffer; -#endif - - // Move byte positions and lengths - nBytePosition1++; - nBytePosition0++; - nByteLength--; - } - - // Get the rest of the bits - nBitLength = (nBitLength & 0x07); - if(nBitLength != 0) - { - *pbBuffer = (unsigned char)(pArray->Elements[nBytePosition0] >> nBitOffset); - - if(nBitLength > (8 - nBitOffset)) - *pbBuffer = (unsigned char)((pArray->Elements[nBytePosition1] << (8 - nBitOffset)) | (pArray->Elements[nBytePosition0] >> nBitOffset)); - - *pbBuffer &= (0x01 << nBitLength) - 1; - } -} - -void SetBits( - TBitArray * pArray, - unsigned int nBitPosition, - unsigned int nBitLength, - void * pvBuffer, - int nResultByteSize) -{ - unsigned char * pbBuffer = (unsigned char *)pvBuffer; - unsigned int nBytePosition = (nBitPosition / 8); - unsigned int nBitOffset = (nBitPosition & 0x07); - unsigned short BitBuffer = 0; - unsigned short AndMask = 0; - unsigned short OneByte = 0; - - // Keep compiler happy for platforms where nResultByteSize is not used - nResultByteSize = nResultByteSize; - -#ifndef PLATFORM_LITTLE_ENDIAN - // Adjust the buffer pointer for big endian platforms - pbBuffer += (nResultByteSize - 1); -#endif - - // Copy whole bytes, if any - while(nBitLength > 8) - { - // Reload the bit buffer -#ifdef PLATFORM_LITTLE_ENDIAN - OneByte = *pbBuffer++; -#else - OneByte = *pbBuffer--; -#endif - // Update the BitBuffer and AndMask for the bit array - BitBuffer = (BitBuffer >> 0x08) | (OneByte << nBitOffset); - AndMask = (AndMask >> 0x08) | (0x00FF << nBitOffset); - - // Update the byte in the array - pArray->Elements[nBytePosition] = (BYTE)((pArray->Elements[nBytePosition] & ~AndMask) | BitBuffer); - - // Move byte positions and lengths - nBytePosition++; - nBitLength -= 0x08; - } - - if(nBitLength != 0) - { - // Reload the bit buffer - OneByte = *pbBuffer; - - // Update the AND mask for the last bit - BitBuffer = (BitBuffer >> 0x08) | (OneByte << nBitOffset); - AndMask = (AndMask >> 0x08) | (SetBitsMask[nBitLength] << nBitOffset); - - // Update the byte in the array - pArray->Elements[nBytePosition] = (BYTE)((pArray->Elements[nBytePosition] & ~AndMask) | BitBuffer); - - // Update the next byte, if needed - if(AndMask & 0xFF00) - { - nBytePosition++; - BitBuffer >>= 0x08; - AndMask >>= 0x08; - - pArray->Elements[nBytePosition] = (BYTE)((pArray->Elements[nBytePosition] & ~AndMask) | BitBuffer); - } - } -} - -//----------------------------------------------------------------------------- -// Support for MPQ header - -static ULONGLONG DetermineArchiveSize_V1( - TMPQArchive * ha, - TMPQHeader * pHeader, - ULONGLONG MpqOffset, - ULONGLONG FileSize) -{ - ULONGLONG ByteOffset; - ULONGLONG EndOfMpq = FileSize; - DWORD SignatureHeader = 0; - DWORD dwArchiveSize32; - - // This could only be called for MPQs version 1.0 - assert(pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1); - - // Check if we can rely on the archive size in the header - if(pHeader->dwBlockTablePos < pHeader->dwArchiveSize) - { - // The block table cannot be compressed, so the sizes must match - if((pHeader->dwArchiveSize - pHeader->dwBlockTablePos) == (pHeader->dwBlockTableSize * sizeof(TMPQBlock))) - return pHeader->dwArchiveSize; - - // If the archive size in the header is less than real file size - dwArchiveSize32 = (DWORD)(FileSize - MpqOffset); - if(pHeader->dwArchiveSize == dwArchiveSize32) - return pHeader->dwArchiveSize; - } - - // Check if there is a signature header - if((EndOfMpq - MpqOffset) > (MPQ_STRONG_SIGNATURE_SIZE + 4)) - { - ByteOffset = EndOfMpq - MPQ_STRONG_SIGNATURE_SIZE - 4; - if(FileStream_Read(ha->pStream, &ByteOffset, &SignatureHeader, sizeof(DWORD))) - { - if(BSWAP_INT32_UNSIGNED(SignatureHeader) == MPQ_STRONG_SIGNATURE_ID) - EndOfMpq = EndOfMpq - MPQ_STRONG_SIGNATURE_SIZE - 4; - } - } - - // Return the returned archive size - return (EndOfMpq - MpqOffset); -} - -static ULONGLONG DetermineArchiveSize_V2( - TMPQHeader * pHeader, - ULONGLONG MpqOffset, - ULONGLONG FileSize) -{ - ULONGLONG EndOfMpq = FileSize; - DWORD dwArchiveSize32; - - // This could only be called for MPQs version 2.0 - assert(pHeader->wFormatVersion == MPQ_FORMAT_VERSION_2); - - // Check if we can rely on the archive size in the header - if((FileSize >> 0x20) == 0) - { - if(pHeader->dwBlockTablePos < pHeader->dwArchiveSize) - { - if((pHeader->dwArchiveSize - pHeader->dwBlockTablePos) <= (pHeader->dwBlockTableSize * sizeof(TMPQBlock))) - return pHeader->dwArchiveSize; - - // If the archive size in the header is less than real file size - dwArchiveSize32 = (DWORD)(FileSize - MpqOffset); - if(pHeader->dwArchiveSize <= dwArchiveSize32) - return pHeader->dwArchiveSize; - } - } - - // Return the calculated archive size - return (EndOfMpq - MpqOffset); -} - -ULONGLONG FileOffsetFromMpqOffset(TMPQArchive * ha, ULONGLONG MpqOffset) -{ - if(ha->pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1) - { - // For MPQ archive v1, any file offset is only 32-bit - return (ULONGLONG)((DWORD)ha->MpqPos + (DWORD)MpqOffset); - } - else - { - // For MPQ archive v2+, file offsets are full 64-bit - return ha->MpqPos + MpqOffset; - } -} - -ULONGLONG CalculateRawSectorOffset( - TMPQFile * hf, - DWORD dwSectorOffset) -{ - ULONGLONG RawFilePos; - - // Must be used for files within a MPQ - assert(hf->ha != NULL); - assert(hf->ha->pHeader != NULL); - - // - // Some MPQ protectors place the sector offset table after the actual file data. - // Sector offsets in the sector offset table are negative. When added - // to MPQ file offset from the block table entry, the result is a correct - // position of the file data in the MPQ. - // - // For MPQs version 1.0, the offset is purely 32-bit - // - - RawFilePos = hf->RawFilePos + dwSectorOffset; - if(hf->ha->pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1) - RawFilePos = (DWORD)hf->ha->MpqPos + (DWORD)hf->pFileEntry->ByteOffset + dwSectorOffset; - - // We also have to add patch header size, if patch header is present - if(hf->pPatchInfo != NULL) - RawFilePos += hf->pPatchInfo->dwLength; - - // Return the result offset - return RawFilePos; -} - -// This function converts the MPQ header so it always looks like version 4 -int ConvertMpqHeaderToFormat4( - TMPQArchive * ha, - ULONGLONG MpqOffset, - ULONGLONG FileSize, - DWORD dwFlags, - bool bIsWarcraft3Map) -{ - TMPQHeader * pHeader = (TMPQHeader *)ha->HeaderData; - ULONGLONG BlockTablePos64 = 0; - ULONGLONG HashTablePos64 = 0; - ULONGLONG BlockTableMask = (ULONGLONG)-1; - ULONGLONG ByteOffset; - USHORT wFormatVersion = BSWAP_INT16_UNSIGNED(pHeader->wFormatVersion); - int nError = ERROR_SUCCESS; - - // If version 1.0 is forced, then the format version is forced to be 1.0 - // Reason: Storm.dll in Warcraft III ignores format version value - if((dwFlags & MPQ_OPEN_FORCE_MPQ_V1) || bIsWarcraft3Map) - wFormatVersion = MPQ_FORMAT_VERSION_1; - - // Format-specific fixes - switch(wFormatVersion) - { - case MPQ_FORMAT_VERSION_1: - - // Check for malformed MPQ header version 1.0 - BSWAP_TMPQHEADER(pHeader, MPQ_FORMAT_VERSION_1); - if(pHeader->wFormatVersion != MPQ_FORMAT_VERSION_1 || pHeader->dwHeaderSize != MPQ_HEADER_SIZE_V1) - { - pHeader->wFormatVersion = MPQ_FORMAT_VERSION_1; - pHeader->dwHeaderSize = MPQ_HEADER_SIZE_V1; - ha->dwFlags |= MPQ_FLAG_MALFORMED; - } - - // - // Note: The value of "dwArchiveSize" member in the MPQ header - // is ignored by Storm.dll and can contain garbage value - // ("w3xmaster" protector). - // - - Label_ArchiveVersion1: - if(pHeader->dwBlockTableSize > 1) // Prevent empty MPQs being marked as malformed - { - if(pHeader->dwHashTablePos <= pHeader->dwHeaderSize || (pHeader->dwHashTablePos & 0x80000000)) - ha->dwFlags |= MPQ_FLAG_MALFORMED; - if(pHeader->dwBlockTablePos <= pHeader->dwHeaderSize || (pHeader->dwBlockTablePos & 0x80000000)) - ha->dwFlags |= MPQ_FLAG_MALFORMED; - } - - // Only low byte of sector size is really used - if(pHeader->wSectorSize & 0xFF00) - ha->dwFlags |= MPQ_FLAG_MALFORMED; - pHeader->wSectorSize = pHeader->wSectorSize & 0xFF; - - // Fill the rest of the header - memset((LPBYTE)pHeader + MPQ_HEADER_SIZE_V1, 0, sizeof(TMPQHeader) - MPQ_HEADER_SIZE_V1); - pHeader->BlockTableSize64 = pHeader->dwBlockTableSize * sizeof(TMPQBlock); - pHeader->HashTableSize64 = pHeader->dwHashTableSize * sizeof(TMPQHash); - pHeader->ArchiveSize64 = pHeader->dwArchiveSize; - - // Block table position must be calculated as 32-bit value - // Note: BOBA protector puts block table before the MPQ header, so it is negative - BlockTablePos64 = (ULONGLONG)((DWORD)MpqOffset + pHeader->dwBlockTablePos); - BlockTableMask = 0xFFFFFFF0; - - // Determine the archive size on malformed MPQs - if(ha->dwFlags & MPQ_FLAG_MALFORMED) - { - // Calculate the archive size - pHeader->ArchiveSize64 = DetermineArchiveSize_V1(ha, pHeader, MpqOffset, FileSize); - pHeader->dwArchiveSize = (DWORD)pHeader->ArchiveSize64; - } - - // EWIX_v8_7.w3x: TMPQHeader::dwBlockTableSize = 0x00319601 - // Size of TFileTable goes to ~200MB, so we artificially cut it - if(BlockTablePos64 + (pHeader->dwBlockTableSize * sizeof(TMPQBlock)) > FileSize) - { - pHeader->dwBlockTableSize = (DWORD)((FileSize - BlockTablePos64) / sizeof(TMPQBlock)); - pHeader->BlockTableSize64 = pHeader->dwBlockTableSize * sizeof(TMPQBlock); - } - break; - - case MPQ_FORMAT_VERSION_2: - - // Check for malformed MPQ header version 1.0 - BSWAP_TMPQHEADER(pHeader, MPQ_FORMAT_VERSION_2); - if(pHeader->wFormatVersion != MPQ_FORMAT_VERSION_2 || pHeader->dwHeaderSize != MPQ_HEADER_SIZE_V2) - { - pHeader->wFormatVersion = MPQ_FORMAT_VERSION_1; - pHeader->dwHeaderSize = MPQ_HEADER_SIZE_V1; - ha->dwFlags |= MPQ_FLAG_MALFORMED; - goto Label_ArchiveVersion1; - } - - // Fill the rest of the header with zeros - memset((LPBYTE)pHeader + MPQ_HEADER_SIZE_V2, 0, sizeof(TMPQHeader) - MPQ_HEADER_SIZE_V2); - - // Calculate the expected hash table size - pHeader->HashTableSize64 = (pHeader->dwHashTableSize * sizeof(TMPQHash)); - HashTablePos64 = MAKE_OFFSET64(pHeader->wHashTablePosHi, pHeader->dwHashTablePos); - - // Calculate the expected block table size - pHeader->BlockTableSize64 = (pHeader->dwBlockTableSize * sizeof(TMPQBlock)); - BlockTablePos64 = MAKE_OFFSET64(pHeader->wBlockTablePosHi, pHeader->dwBlockTablePos); - - // We require the block table to follow hash table - if(BlockTablePos64 >= HashTablePos64) - { - // HashTableSize64 may be less than TblSize * sizeof(TMPQHash). - // That means that the hash table is compressed. - pHeader->HashTableSize64 = BlockTablePos64 - HashTablePos64; - - // Calculate the compressed block table size - if(pHeader->HiBlockTablePos64 != 0) - { - // BlockTableSize64 may be less than TblSize * sizeof(TMPQBlock). - // That means that the block table is compressed. - pHeader->BlockTableSize64 = pHeader->HiBlockTablePos64 - BlockTablePos64; - assert(pHeader->BlockTableSize64 <= (pHeader->dwBlockTableSize * sizeof(TMPQBlock))); - - // Determine real archive size - pHeader->ArchiveSize64 = DetermineArchiveSize_V2(pHeader, MpqOffset, FileSize); - - // Calculate the size of the hi-block table - pHeader->HiBlockTableSize64 = pHeader->ArchiveSize64 - pHeader->HiBlockTablePos64; - assert(pHeader->HiBlockTableSize64 == (pHeader->dwBlockTableSize * sizeof(USHORT))); - } - else - { - // Determine real archive size - pHeader->ArchiveSize64 = DetermineArchiveSize_V2(pHeader, MpqOffset, FileSize); - - // Calculate size of the block table - pHeader->BlockTableSize64 = pHeader->ArchiveSize64 - BlockTablePos64; - assert(pHeader->BlockTableSize64 <= (pHeader->dwBlockTableSize * sizeof(TMPQBlock))); - } - } - else - { - pHeader->ArchiveSize64 = pHeader->dwArchiveSize; - ha->dwFlags |= MPQ_FLAG_MALFORMED; - } - - // Add the MPQ Offset - BlockTablePos64 += MpqOffset; - break; - - case MPQ_FORMAT_VERSION_3: - - // In MPQ format 3.0, the entire header is optional - // and the size of the header can actually be identical - // to size of header 2.0 - BSWAP_TMPQHEADER(pHeader, MPQ_FORMAT_VERSION_3); - if(pHeader->dwHeaderSize < MPQ_HEADER_SIZE_V3) - { - pHeader->ArchiveSize64 = pHeader->dwArchiveSize; - pHeader->HetTablePos64 = 0; - pHeader->BetTablePos64 = 0; - } - - // - // We need to calculate the compressed size of each table. We assume the following order: - // 1) HET table - // 2) BET table - // 3) Classic hash table - // 4) Classic block table - // 5) Hi-block table - // - - // Fill the rest of the header with zeros - memset((LPBYTE)pHeader + MPQ_HEADER_SIZE_V3, 0, sizeof(TMPQHeader) - MPQ_HEADER_SIZE_V3); - BlockTablePos64 = MAKE_OFFSET64(pHeader->wBlockTablePosHi, pHeader->dwBlockTablePos); - HashTablePos64 = MAKE_OFFSET64(pHeader->wHashTablePosHi, pHeader->dwHashTablePos); - ByteOffset = pHeader->ArchiveSize64; - - // Size of the hi-block table - if(pHeader->HiBlockTablePos64) - { - pHeader->HiBlockTableSize64 = ByteOffset - pHeader->HiBlockTablePos64; - ByteOffset = pHeader->HiBlockTablePos64; - } - - // Size of the block table - if(BlockTablePos64) - { - pHeader->BlockTableSize64 = ByteOffset - BlockTablePos64; - ByteOffset = BlockTablePos64; - } - - // Size of the hash table - if(HashTablePos64) - { - pHeader->HashTableSize64 = ByteOffset - HashTablePos64; - ByteOffset = HashTablePos64; - } - - // Size of the BET table - if(pHeader->BetTablePos64) - { - pHeader->BetTableSize64 = ByteOffset - pHeader->BetTablePos64; - ByteOffset = pHeader->BetTablePos64; - } - - // Size of the HET table - if(pHeader->HetTablePos64) - { - pHeader->HetTableSize64 = ByteOffset - pHeader->HetTablePos64; -// ByteOffset = pHeader->HetTablePos64; - } - - // Add the MPQ Offset - BlockTablePos64 += MpqOffset; - break; - - case MPQ_FORMAT_VERSION_4: - - // Verify header MD5. Header MD5 is calculated from the MPQ header since the 'MPQ\x1A' - // signature until the position of header MD5 at offset 0xC0 - BSWAP_TMPQHEADER(pHeader, MPQ_FORMAT_VERSION_4); - if(!VerifyDataBlockHash(pHeader, MPQ_HEADER_SIZE_V4 - MD5_DIGEST_SIZE, pHeader->MD5_MpqHeader)) - nError = ERROR_FILE_CORRUPT; - - // Calculate the block table position - BlockTablePos64 = MpqOffset + MAKE_OFFSET64(pHeader->wBlockTablePosHi, pHeader->dwBlockTablePos); - break; - - default: - - // Check if it's a War of the Immortal data file (SQP) - // If not, we treat it as malformed MPQ version 1.0 - if(ConvertSqpHeaderToFormat4(ha, FileSize, dwFlags) != ERROR_SUCCESS) - { - pHeader->wFormatVersion = MPQ_FORMAT_VERSION_1; - pHeader->dwHeaderSize = MPQ_HEADER_SIZE_V1; - ha->dwFlags |= MPQ_FLAG_MALFORMED; - goto Label_ArchiveVersion1; - } - - // Calculate the block table position - BlockTablePos64 = MpqOffset + MAKE_OFFSET64(pHeader->wBlockTablePosHi, pHeader->dwBlockTablePos); - break; - } - - // Handle case when block table is placed before the MPQ header - // Used by BOBA protector - if(BlockTablePos64 < MpqOffset) - ha->dwFlags |= MPQ_FLAG_MALFORMED; - return nError; -} - -//----------------------------------------------------------------------------- -// Support for hash table - -// Hash entry verification when the file table does not exist yet -bool IsValidHashEntry(TMPQArchive * ha, TMPQHash * pHash) -{ - TFileEntry * pFileEntry = ha->pFileTable + MPQ_BLOCK_INDEX(pHash); - - return ((MPQ_BLOCK_INDEX(pHash) < ha->dwFileTableSize) && (pFileEntry->dwFlags & MPQ_FILE_EXISTS)) ? true : false; -} - -// Hash entry verification when the file table does not exist yet -static bool IsValidHashEntry1(TMPQArchive * ha, TMPQHash * pHash, TMPQBlock * pBlockTable) -{ - ULONGLONG ByteOffset; - TMPQBlock * pBlock; - - // The block index is considered valid if it's less than block table size - if(MPQ_BLOCK_INDEX(pHash) < ha->pHeader->dwBlockTableSize) - { - // Calculate the block table position - pBlock = pBlockTable + MPQ_BLOCK_INDEX(pHash); - - // Check whether this is an existing file - // Also we do not allow to be file size greater than 2GB - if((pBlock->dwFlags & MPQ_FILE_EXISTS) && (pBlock->dwFSize & 0x80000000) == 0) - { - // The begin of the file must be within the archive - ByteOffset = FileOffsetFromMpqOffset(ha, pBlock->dwFilePos); - return (ByteOffset < ha->FileSize); - } - } - - return false; -} - -// Returns a hash table entry in the following order: -// 1) A hash table entry with the preferred locale and platform -// 2) A hash table entry with the neutral|matching locale and neutral|matching platform -// 3) NULL -// Storm_2016.dll: 15020940 -static TMPQHash * GetHashEntryLocale(TMPQArchive * ha, const char * szFileName, LCID lcLocale, BYTE Platform) -{ - TMPQHash * pFirstHash = GetFirstHashEntry(ha, szFileName); - TMPQHash * pBestEntry = NULL; - TMPQHash * pHash = pFirstHash; - - // Parse the found hashes - while(pHash != NULL) - { - // Storm_2016.dll: 150209CB - // If the hash entry matches both locale and platform, return it immediately - // Note: We only succeed this check if the locale is non-neutral, because - // some Warcraft III maps have several items with neutral locale&platform, which leads - // to wrong item being returned - if((lcLocale || Platform) && pHash->lcLocale == lcLocale && pHash->Platform == Platform) - return pHash; - - // Storm_2016.dll: 150209D9 - // If (locale matches or is neutral) OR (platform matches or is neutral) - // remember this as the best entry - if(pHash->lcLocale == 0 || pHash->lcLocale == lcLocale) - { - if(pHash->Platform == 0 || pHash->Platform == Platform) - pBestEntry = pHash; - } - - // Get the next hash entry for that file - pHash = GetNextHashEntry(ha, pFirstHash, pHash); - } - - // At the end, return neutral hash (if found), otherwise NULL - return pBestEntry; -} - -// Returns a hash table entry in the following order: -// 1) A hash table entry with the preferred locale -// 2) NULL -static TMPQHash * GetHashEntryExact(TMPQArchive * ha, const char * szFileName, LCID lcLocale) -{ - TMPQHash * pFirstHash = GetFirstHashEntry(ha, szFileName); - TMPQHash * pHash = pFirstHash; - - // Parse the found hashes - while(pHash != NULL) - { - // If the locales match, return it - if(pHash->lcLocale == lcLocale) - return pHash; - - // Get the next hash entry for that file - pHash = GetNextHashEntry(ha, pFirstHash, pHash); - } - - // Not found - return NULL; -} - -// Defragment the file table so it does not contain any gaps -// Note: As long as all values of all TMPQHash::dwBlockIndex -// are not HASH_ENTRY_FREE, the startup search index does not matter. -// Hash table is circular, so as long as there is no terminator, -// all entries will be found. -static TMPQHash * DefragmentHashTable( - TMPQArchive * ha, - TMPQHash * pHashTable, - TMPQBlock * pBlockTable) -{ - TMPQHeader * pHeader = ha->pHeader; - TMPQHash * pHashTableEnd = pHashTable + pHeader->dwHashTableSize; - TMPQHash * pSource = pHashTable; - TMPQHash * pTarget = pHashTable; - DWORD dwFirstFreeEntry; - DWORD dwNewTableSize; - - // Sanity checks - assert(pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1); - assert(pHeader->HiBlockTablePos64 == 0); - - // Parse the hash table and move the entries to the begin of it - for(pSource = pHashTable; pSource < pHashTableEnd; pSource++) - { - // Check whether this is a valid hash table entry - if(IsValidHashEntry1(ha, pSource, pBlockTable)) - { - // Copy the hash table entry back - if(pSource > pTarget) - pTarget[0] = pSource[0]; - - // Move the target - pTarget++; - } - } - - // Calculate how many entries in the hash table we really need - dwFirstFreeEntry = (DWORD)(pTarget - pHashTable); - dwNewTableSize = GetNearestPowerOfTwo(dwFirstFreeEntry); - - // Fill the rest with entries that look like deleted - pHashTableEnd = pHashTable + dwNewTableSize; - pSource = pHashTable + dwFirstFreeEntry; - memset(pSource, 0xFF, (dwNewTableSize - dwFirstFreeEntry) * sizeof(TMPQHash)); - - // Mark the block indexes as deleted - for(; pSource < pHashTableEnd; pSource++) - pSource->dwBlockIndex = HASH_ENTRY_DELETED; - - // Free some of the space occupied by the hash table - if(dwNewTableSize < pHeader->dwHashTableSize) - { - pHashTable = STORM_REALLOC(TMPQHash, pHashTable, dwNewTableSize); - ha->pHeader->BlockTableSize64 = dwNewTableSize * sizeof(TMPQHash); - ha->pHeader->dwHashTableSize = dwNewTableSize; - } - - return pHashTable; -} - -static int BuildFileTableFromBlockTable( - TMPQArchive * ha, - TMPQBlock * pBlockTable) -{ - TFileEntry * pFileEntry; - TMPQHeader * pHeader = ha->pHeader; - TMPQBlock * pBlock; - TMPQHash * pHashTableEnd; - TMPQHash * pHash; - LPDWORD DefragmentTable = NULL; - DWORD dwItemCount = 0; - DWORD dwFlagMask; - - // Sanity checks - assert(ha->pFileTable != NULL); - assert(ha->dwFileTableSize >= ha->dwMaxFileCount); - - // MPQs for Warcraft III doesn't know some flags, namely MPQ_FILE_SINGLE_UNIT and MPQ_FILE_PATCH_FILE - dwFlagMask = (ha->dwFlags & MPQ_FLAG_WAR3_MAP) ? MPQ_FILE_VALID_FLAGS_W3X : MPQ_FILE_VALID_FLAGS; - - // Defragment the hash table, if needed - if(ha->dwFlags & MPQ_FLAG_HASH_TABLE_CUT) - { - ha->pHashTable = DefragmentHashTable(ha, ha->pHashTable, pBlockTable); - ha->dwMaxFileCount = pHeader->dwHashTableSize; - } - - // If the hash table or block table is cut, - // we will defragment the block table - if(ha->dwFlags & (MPQ_FLAG_HASH_TABLE_CUT | MPQ_FLAG_BLOCK_TABLE_CUT)) - { - // Sanity checks - assert(pHeader->wFormatVersion == MPQ_FORMAT_VERSION_1); - assert(pHeader->HiBlockTablePos64 == 0); - - // Allocate the translation table - DefragmentTable = STORM_ALLOC(DWORD, pHeader->dwBlockTableSize); - if(DefragmentTable == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - // Fill the translation table - memset(DefragmentTable, 0xFF, pHeader->dwBlockTableSize * sizeof(DWORD)); - } - - // Parse the entire hash table - pHashTableEnd = ha->pHashTable + pHeader->dwHashTableSize; - for(pHash = ha->pHashTable; pHash < pHashTableEnd; pHash++) - { - // - // We need to properly handle these cases: - // - Multiple hash entries (same file name) point to the same block entry - // - Multiple hash entries (different file name) point to the same block entry - // - // Ignore all hash table entries where: - // - Block Index >= BlockTableSize - // - Flags of the appropriate block table entry - // - - if(IsValidHashEntry1(ha, pHash, pBlockTable)) - { - DWORD dwOldIndex = MPQ_BLOCK_INDEX(pHash); - DWORD dwNewIndex = MPQ_BLOCK_INDEX(pHash); - - // Determine the new block index - if(DefragmentTable != NULL) - { - // Need to handle case when multiple hash - // entries point to the same block entry - if(DefragmentTable[dwOldIndex] == HASH_ENTRY_FREE) - { - DefragmentTable[dwOldIndex] = dwItemCount; - dwNewIndex = dwItemCount++; - } - else - { - dwNewIndex = DefragmentTable[dwOldIndex]; - } - - // Fix the pointer in the hash entry - pHash->dwBlockIndex = dwNewIndex; - - // Dump the relocation entry -// printf("Relocating hash entry %08X-%08X: %08X -> %08X\n", pHash->dwName1, pHash->dwName2, dwBlockIndex, dwNewIndex); - } - - // Get the pointer to the file entry and the block entry - pFileEntry = ha->pFileTable + dwNewIndex; - pBlock = pBlockTable + dwOldIndex; - - // ByteOffset is only valid if file size is not zero - pFileEntry->ByteOffset = pBlock->dwFilePos; - if(pFileEntry->ByteOffset == 0 && pBlock->dwFSize == 0) - pFileEntry->ByteOffset = ha->pHeader->dwHeaderSize; - - // Fill the rest of the file entry - pFileEntry->dwFileSize = pBlock->dwFSize; - pFileEntry->dwCmpSize = pBlock->dwCSize; - pFileEntry->dwFlags = pBlock->dwFlags & dwFlagMask; - } - } - - // Free the translation table - if(DefragmentTable != NULL) - { - // If we defragmented the block table in the process, - // free some memory by shrinking the file table - if(ha->dwFileTableSize > ha->dwMaxFileCount) - { - ha->pFileTable = STORM_REALLOC(TFileEntry, ha->pFileTable, ha->dwMaxFileCount); - ha->pHeader->BlockTableSize64 = ha->dwMaxFileCount * sizeof(TMPQBlock); - ha->pHeader->dwBlockTableSize = ha->dwMaxFileCount; - ha->dwFileTableSize = ha->dwMaxFileCount; - } - -// DumpFileTable(ha->pFileTable, ha->dwFileTableSize); - - // Free the translation table - STORM_FREE(DefragmentTable); - } - - return ERROR_SUCCESS; -} - -static TMPQHash * TranslateHashTable( - TMPQArchive * ha, - ULONGLONG * pcbTableSize) -{ - TMPQHash * pHashTable; - size_t HashTableSize; - - // Allocate copy of the hash table - pHashTable = STORM_ALLOC(TMPQHash, ha->pHeader->dwHashTableSize); - if(pHashTable != NULL) - { - // Copy the hash table - HashTableSize = sizeof(TMPQHash) * ha->pHeader->dwHashTableSize; - memcpy(pHashTable, ha->pHashTable, HashTableSize); - - // Give the size to the caller - if(pcbTableSize != NULL) - { - *pcbTableSize = (ULONGLONG)HashTableSize; - } - } - - return pHashTable; -} - -// Also used in SFileGetFileInfo -TMPQBlock * TranslateBlockTable( - TMPQArchive * ha, - ULONGLONG * pcbTableSize, - bool * pbNeedHiBlockTable) -{ - TFileEntry * pFileEntry = ha->pFileTable; - TMPQBlock * pBlockTable; - TMPQBlock * pBlock; - DWORD NeedHiBlockTable = 0; - DWORD dwBlockTableSize = ha->pHeader->dwBlockTableSize; - - // Allocate copy of the hash table - pBlockTable = pBlock = STORM_ALLOC(TMPQBlock, dwBlockTableSize); - if(pBlockTable != NULL) - { - // Convert the block table - for(DWORD i = 0; i < dwBlockTableSize; i++) - { - NeedHiBlockTable |= (DWORD)(pFileEntry->ByteOffset >> 32); - pBlock->dwFilePos = (DWORD)pFileEntry->ByteOffset; - pBlock->dwFSize = pFileEntry->dwFileSize; - pBlock->dwCSize = pFileEntry->dwCmpSize; - pBlock->dwFlags = pFileEntry->dwFlags; - - pFileEntry++; - pBlock++; - } - - // Give the size to the caller - if(pcbTableSize != NULL) - *pcbTableSize = (ULONGLONG)dwBlockTableSize * sizeof(TMPQBlock); - - if(pbNeedHiBlockTable != NULL) - *pbNeedHiBlockTable = NeedHiBlockTable ? true : false; - } - - return pBlockTable; -} - -static USHORT * TranslateHiBlockTable( - TMPQArchive * ha, - ULONGLONG * pcbTableSize) -{ - TFileEntry * pFileEntry = ha->pFileTable; - USHORT * pHiBlockTable; - USHORT * pHiBlock; - DWORD dwBlockTableSize = ha->pHeader->dwBlockTableSize; - - // Allocate copy of the hash table - pHiBlockTable = pHiBlock = STORM_ALLOC(USHORT, dwBlockTableSize); - if(pHiBlockTable != NULL) - { - // Copy the block table - for(DWORD i = 0; i < dwBlockTableSize; i++) - pHiBlock[i] = (USHORT)(pFileEntry[i].ByteOffset >> 0x20); - - // Give the size to the caller - if(pcbTableSize != NULL) - *pcbTableSize = (ULONGLONG)dwBlockTableSize * sizeof(USHORT); - } - - return pHiBlockTable; -} - -//----------------------------------------------------------------------------- -// General EXT table functions - -TMPQExtHeader * LoadExtTable( - TMPQArchive * ha, - ULONGLONG ByteOffset, - size_t Size, - DWORD dwSignature, - DWORD dwKey) -{ - TMPQExtHeader * pCompressed = NULL; // Compressed table - TMPQExtHeader * pExtTable = NULL; // Uncompressed table - - // Do nothing if the size is zero - if(ByteOffset != 0 && Size != 0) - { - // Allocate size for the compressed table - pExtTable = (TMPQExtHeader *)STORM_ALLOC(BYTE, Size); - if(pExtTable != NULL) - { - // Load the table from the MPQ - ByteOffset += ha->MpqPos; - if(!FileStream_Read(ha->pStream, &ByteOffset, pExtTable, (DWORD)Size)) - { - STORM_FREE(pExtTable); - return NULL; - } - - // Swap the ext table header - BSWAP_ARRAY32_UNSIGNED(pExtTable, sizeof(TMPQExtHeader)); - if(pExtTable->dwSignature != dwSignature) - { - STORM_FREE(pExtTable); - return NULL; - } - - // Decrypt the block - BSWAP_ARRAY32_UNSIGNED(pExtTable + 1, pExtTable->dwDataSize); - DecryptMpqBlock(pExtTable + 1, (DWORD)(Size - sizeof(TMPQExtHeader)), dwKey); - BSWAP_ARRAY32_UNSIGNED(pExtTable + 1, pExtTable->dwDataSize); - - // If the table is compressed, decompress it - if((pExtTable->dwDataSize + sizeof(TMPQExtHeader)) > Size) - { - pCompressed = pExtTable; - pExtTable = (TMPQExtHeader *)STORM_ALLOC(BYTE, sizeof(TMPQExtHeader) + pCompressed->dwDataSize); - if(pExtTable != NULL) - { - int cbOutBuffer = (int)pCompressed->dwDataSize; - int cbInBuffer = (int)Size; - - // Decompress the extended table - pExtTable->dwSignature = pCompressed->dwSignature; - pExtTable->dwVersion = pCompressed->dwVersion; - pExtTable->dwDataSize = pCompressed->dwDataSize; - if(!SCompDecompress2(pExtTable + 1, &cbOutBuffer, pCompressed + 1, cbInBuffer)) - { - STORM_FREE(pExtTable); - pExtTable = NULL; - } - } - - // Free the compressed block - STORM_FREE(pCompressed); - } - } - } - - // Return the decompressed table to the caller - return pExtTable; -} - -static int SaveMpqTable( - TMPQArchive * ha, - void * pMpqTable, - ULONGLONG ByteOffset, - size_t Size, - unsigned char * md5, - DWORD dwKey, - bool bCompress) -{ - ULONGLONG FileOffset; - void * pCompressed = NULL; - int nError = ERROR_SUCCESS; - - // Do we have to compress the table? - if(bCompress) - { - int cbOutBuffer = (int)Size; - int cbInBuffer = (int)Size; - - // Allocate extra space for compressed table - pCompressed = STORM_ALLOC(BYTE, Size); - if(pCompressed == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - // Compress the table - SCompCompress(pCompressed, &cbOutBuffer, pMpqTable, cbInBuffer, MPQ_COMPRESSION_ZLIB, 0, 0); - - // If the compression failed, revert it. Otherwise, swap the tables - if(cbOutBuffer >= cbInBuffer) - { - STORM_FREE(pCompressed); - pCompressed = NULL; - } - else - { - pMpqTable = pCompressed; - } - } - - // Encrypt the table - if(dwKey != 0) - { - BSWAP_ARRAY32_UNSIGNED(pMpqTable, Size); - EncryptMpqBlock(pMpqTable, (DWORD)Size, dwKey); - BSWAP_ARRAY32_UNSIGNED(pMpqTable, Size); - } - - // Calculate the MD5 - if(md5 != NULL) - { - CalculateDataBlockHash(pMpqTable, (DWORD)Size, md5); - } - - // Save the table to the MPQ - BSWAP_ARRAY32_UNSIGNED(pMpqTable, Size); - FileOffset = ha->MpqPos + ByteOffset; - if(!FileStream_Write(ha->pStream, &FileOffset, pMpqTable, (DWORD)Size)) - nError = GetLastError(); - - // Free the compressed table, if any - if(pCompressed != NULL) - STORM_FREE(pCompressed); - return nError; -} - -static int SaveExtTable( - TMPQArchive * ha, - TMPQExtHeader * pExtTable, - ULONGLONG ByteOffset, - DWORD dwTableSize, - unsigned char * md5, - DWORD dwKey, - bool bCompress, - LPDWORD pcbTotalSize) -{ - ULONGLONG FileOffset; - TMPQExtHeader * pCompressed = NULL; - DWORD cbTotalSize = 0; - int nError = ERROR_SUCCESS; - - // Do we have to compress the table? - if(bCompress) - { - int cbOutBuffer = (int)dwTableSize; - int cbInBuffer = (int)dwTableSize; - - // Allocate extra space for compressed table - pCompressed = (TMPQExtHeader *)STORM_ALLOC(BYTE, dwTableSize); - if(pCompressed == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - // Compress the table - pCompressed->dwSignature = pExtTable->dwSignature; - pCompressed->dwVersion = pExtTable->dwVersion; - pCompressed->dwDataSize = pExtTable->dwDataSize; - SCompCompress((pCompressed + 1), &cbOutBuffer, (pExtTable + 1), cbInBuffer, MPQ_COMPRESSION_ZLIB, 0, 0); - - // If the compression failed, revert it. Otherwise, swap the tables - if(cbOutBuffer >= cbInBuffer) - { - STORM_FREE(pCompressed); - pCompressed = NULL; - } - else - { - pExtTable = pCompressed; - } - } - - // Encrypt the table - if(dwKey != 0) - { - BSWAP_ARRAY32_UNSIGNED(pExtTable + 1, pExtTable->dwDataSize); - EncryptMpqBlock(pExtTable + 1, (DWORD)(dwTableSize - sizeof(TMPQExtHeader)), dwKey); - BSWAP_ARRAY32_UNSIGNED(pExtTable + 1, pExtTable->dwDataSize); - } - - // Calculate the MD5 of the table after - if(md5 != NULL) - { - CalculateDataBlockHash(pExtTable, dwTableSize, md5); - } - - // Save the table to the MPQ - FileOffset = ha->MpqPos + ByteOffset; - if(FileStream_Write(ha->pStream, &FileOffset, pExtTable, dwTableSize)) - cbTotalSize += dwTableSize; - else - nError = GetLastError(); - - // We have to write raw data MD5 - if(nError == ERROR_SUCCESS && ha->pHeader->dwRawChunkSize != 0) - { - nError = WriteMemDataMD5(ha->pStream, - FileOffset, - pExtTable, - dwTableSize, - ha->pHeader->dwRawChunkSize, - &cbTotalSize); - } - - // Give the total written size, if needed - if(pcbTotalSize != NULL) - *pcbTotalSize = cbTotalSize; - - // Free the compressed table, if any - if(pCompressed != NULL) - STORM_FREE(pCompressed); - return nError; -} - -//----------------------------------------------------------------------------- -// Support for HET table - -static void CreateHetHeader( - TMPQHetTable * pHetTable, - TMPQHetHeader * pHetHeader) -{ - // Fill the common header - pHetHeader->ExtHdr.dwSignature = HET_TABLE_SIGNATURE; - pHetHeader->ExtHdr.dwVersion = 1; - pHetHeader->ExtHdr.dwDataSize = 0; - - // Fill the HET header - pHetHeader->dwEntryCount = pHetTable->dwEntryCount; - pHetHeader->dwTotalCount = pHetTable->dwTotalCount; - pHetHeader->dwNameHashBitSize = pHetTable->dwNameHashBitSize; - pHetHeader->dwIndexSizeTotal = pHetTable->dwIndexSizeTotal; - pHetHeader->dwIndexSizeExtra = pHetTable->dwIndexSizeExtra; - pHetHeader->dwIndexSize = pHetTable->dwIndexSize; - pHetHeader->dwIndexTableSize = ((pHetHeader->dwIndexSizeTotal * pHetTable->dwTotalCount) + 7) / 8; - - // Calculate the total size needed for holding HET table - pHetHeader->ExtHdr.dwDataSize = - pHetHeader->dwTableSize = sizeof(TMPQHetHeader) - sizeof(TMPQExtHeader) + - pHetHeader->dwTotalCount + - pHetHeader->dwIndexTableSize; -} - -TMPQHetTable * CreateHetTable(DWORD dwEntryCount, DWORD dwTotalCount, DWORD dwNameHashBitSize, LPBYTE pbSrcData) -{ - TMPQHetTable * pHetTable; - - pHetTable = STORM_ALLOC(TMPQHetTable, 1); - if(pHetTable != NULL) - { - // Zero the HET table - memset(pHetTable, 0, sizeof(TMPQHetTable)); - - // Hash sizes less than 0x40 bits are not tested - assert(dwNameHashBitSize == 0x40); - - // Calculate masks - pHetTable->AndMask64 = ((dwNameHashBitSize != 0x40) ? ((ULONGLONG)1 << dwNameHashBitSize) : 0) - 1; - pHetTable->OrMask64 = (ULONGLONG)1 << (dwNameHashBitSize - 1); - - // If the total count is not entered, use default - if(dwTotalCount == 0) - dwTotalCount = (dwEntryCount * 4) / 3; - - // Store the HET table parameters - pHetTable->dwEntryCount = dwEntryCount; - pHetTable->dwTotalCount = dwTotalCount; - pHetTable->dwNameHashBitSize = dwNameHashBitSize; - pHetTable->dwIndexSizeTotal = GetNecessaryBitCount(dwEntryCount); - pHetTable->dwIndexSizeExtra = 0; - pHetTable->dwIndexSize = pHetTable->dwIndexSizeTotal; - - // Allocate array of hashes - pHetTable->pNameHashes = STORM_ALLOC(BYTE, dwTotalCount); - if(pHetTable->pNameHashes != NULL) - { - // Make sure the data are initialized - memset(pHetTable->pNameHashes, 0, dwTotalCount); - - // Allocate the bit array for file indexes - pHetTable->pBetIndexes = CreateBitArray(dwTotalCount * pHetTable->dwIndexSizeTotal, 0xFF); - if(pHetTable->pBetIndexes != NULL) - { - // Initialize the HET table from the source data (if given) - if(pbSrcData != NULL) - { - // Copy the name hashes - memcpy(pHetTable->pNameHashes, pbSrcData, dwTotalCount); - - // Copy the file indexes - memcpy(pHetTable->pBetIndexes->Elements, pbSrcData + dwTotalCount, pHetTable->pBetIndexes->NumberOfBytes); - } - - // Return the result HET table - return pHetTable; - } - - // Free the name hashes - STORM_FREE(pHetTable->pNameHashes); - } - - STORM_FREE(pHetTable); - } - - // Failed - return NULL; -} - -static int InsertHetEntry(TMPQHetTable * pHetTable, ULONGLONG FileNameHash, DWORD dwFileIndex) -{ - DWORD StartIndex; - DWORD Index; - BYTE NameHash1; - - // Get the start index and the high 8 bits of the name hash - StartIndex = Index = (DWORD)(FileNameHash % pHetTable->dwTotalCount); - NameHash1 = (BYTE)(FileNameHash >> (pHetTable->dwNameHashBitSize - 8)); - - // Find a place where to put it - for(;;) - { - // Did we find a free HET entry? - if(pHetTable->pNameHashes[Index] == HET_ENTRY_FREE) - { - // Set the entry in the name hash table - pHetTable->pNameHashes[Index] = NameHash1; - - // Set the entry in the file index table - SetBits(pHetTable->pBetIndexes, pHetTable->dwIndexSizeTotal * Index, - pHetTable->dwIndexSize, - &dwFileIndex, - 4); - return ERROR_SUCCESS; - } - - // Move to the next entry in the HET table - // If we came to the start index again, we are done - Index = (Index + 1) % pHetTable->dwTotalCount; - if(Index == StartIndex) - break; - } - - // No space in the HET table. Should never happen, - // because the HET table is created according to the number of files - assert(false); - return ERROR_DISK_FULL; -} - -static TMPQHetTable * TranslateHetTable(TMPQHetHeader * pHetHeader) -{ - TMPQHetTable * pHetTable = NULL; - LPBYTE pbSrcData = (LPBYTE)(pHetHeader + 1); - - // Sanity check - assert(pHetHeader->ExtHdr.dwSignature == HET_TABLE_SIGNATURE); - assert(pHetHeader->ExtHdr.dwVersion == 1); - - // Verify size of the HET table - if(pHetHeader->ExtHdr.dwDataSize >= (sizeof(TMPQHetHeader) - sizeof(TMPQExtHeader))) - { - // Verify the size of the table in the header - if(pHetHeader->dwTableSize == pHetHeader->ExtHdr.dwDataSize) - { - // The size of the HET table must be sum of header, hash and index table size - assert((sizeof(TMPQHetHeader) - sizeof(TMPQExtHeader) + pHetHeader->dwTotalCount + pHetHeader->dwIndexTableSize) == pHetHeader->dwTableSize); - - // So far, all MPQs with HET Table have had total number of entries equal to 4/3 of file count - // Exception: "2010 - Starcraft II\!maps\Tya's Zerg Defense (unprotected).SC2Map" -// assert(((pHetHeader->dwEntryCount * 4) / 3) == pHetHeader->dwTotalCount); - - // The size of one index is predictable as well - assert(GetNecessaryBitCount(pHetHeader->dwEntryCount) == pHetHeader->dwIndexSizeTotal); - - // The size of index table (in entries) is expected - // to be the same like the hash table size (in bytes) - assert(((pHetHeader->dwTotalCount * pHetHeader->dwIndexSizeTotal) + 7) / 8 == pHetHeader->dwIndexTableSize); - - // Create translated table - pHetTable = CreateHetTable(pHetHeader->dwEntryCount, pHetHeader->dwTotalCount, pHetHeader->dwNameHashBitSize, pbSrcData); - if(pHetTable != NULL) - { - // Now the sizes in the hash table should be already set - assert(pHetTable->dwEntryCount == pHetHeader->dwEntryCount); - assert(pHetTable->dwTotalCount == pHetHeader->dwTotalCount); - assert(pHetTable->dwIndexSizeTotal == pHetHeader->dwIndexSizeTotal); - - // Copy the missing variables - pHetTable->dwIndexSizeExtra = pHetHeader->dwIndexSizeExtra; - pHetTable->dwIndexSize = pHetHeader->dwIndexSize; - } - } - } - - return pHetTable; -} - -static TMPQExtHeader * TranslateHetTable(TMPQHetTable * pHetTable, ULONGLONG * pcbHetTable) -{ - TMPQHetHeader * pHetHeader = NULL; - TMPQHetHeader HetHeader; - LPBYTE pbLinearTable = NULL; - LPBYTE pbTrgData; - - // Prepare header of the HET table - CreateHetHeader(pHetTable, &HetHeader); - - // Allocate space for the linear table - pbLinearTable = STORM_ALLOC(BYTE, sizeof(TMPQExtHeader) + HetHeader.dwTableSize); - if(pbLinearTable != NULL) - { - // Copy the table header - pHetHeader = (TMPQHetHeader *)pbLinearTable; - memcpy(pHetHeader, &HetHeader, sizeof(TMPQHetHeader)); - pbTrgData = (LPBYTE)(pHetHeader + 1); - - // Copy the array of name hashes - memcpy(pbTrgData, pHetTable->pNameHashes, pHetTable->dwTotalCount); - pbTrgData += pHetTable->dwTotalCount; - - // Copy the bit array of BET indexes - memcpy(pbTrgData, pHetTable->pBetIndexes->Elements, HetHeader.dwIndexTableSize); - - // Calculate the total size of the table, including the TMPQExtHeader - if(pcbHetTable != NULL) - { - *pcbHetTable = (ULONGLONG)(sizeof(TMPQExtHeader) + HetHeader.dwTableSize); - } - } - - // Keep Coverity happy - assert((TMPQExtHeader *)&pHetHeader->ExtHdr == (TMPQExtHeader *)pbLinearTable); - return (TMPQExtHeader *)pbLinearTable; -} - -static DWORD GetFileIndex_Het(TMPQArchive * ha, const char * szFileName) -{ - TMPQHetTable * pHetTable = ha->pHetTable; - ULONGLONG FileNameHash; - DWORD StartIndex; - DWORD Index; - BYTE NameHash1; // Upper 8 bits of the masked file name hash - - // If there are no entries in the HET table, do nothing - if(pHetTable->dwEntryCount == 0) - return HASH_ENTRY_FREE; - - // Do nothing if the MPQ has no HET table - assert(ha->pHetTable != NULL); - - // Calculate 64-bit hash of the file name - FileNameHash = (HashStringJenkins(szFileName) & pHetTable->AndMask64) | pHetTable->OrMask64; - - // Split the file name hash into two parts: - // NameHash1: The highest 8 bits of the name hash - // NameHash2: File name hash limited to hash size - // Note: Our file table contains full name hash, no need to cut the high 8 bits before comparison - NameHash1 = (BYTE)(FileNameHash >> (pHetTable->dwNameHashBitSize - 8)); - - // Calculate the starting index to the hash table - StartIndex = Index = (DWORD)(FileNameHash % pHetTable->dwTotalCount); - - // Go through HET table until we find a terminator - while(pHetTable->pNameHashes[Index] != HET_ENTRY_FREE) - { - // Did we find a match ? - if(pHetTable->pNameHashes[Index] == NameHash1) - { - DWORD dwFileIndex = 0; - - // Get the file index - GetBits(pHetTable->pBetIndexes, pHetTable->dwIndexSizeTotal * Index, - pHetTable->dwIndexSize, - &dwFileIndex, - sizeof(DWORD)); - - // Verify the FileNameHash against the entry in the table of name hashes - if(dwFileIndex <= ha->dwFileTableSize && ha->pFileTable[dwFileIndex].FileNameHash == FileNameHash) - { - return dwFileIndex; - } - } - - // Move to the next entry in the HET table - // If we came to the start index again, we are done - Index = (Index + 1) % pHetTable->dwTotalCount; - if(Index == StartIndex) - break; - } - - // File not found - return HASH_ENTRY_FREE; -} - -void FreeHetTable(TMPQHetTable * pHetTable) -{ - if(pHetTable != NULL) - { - if(pHetTable->pNameHashes != NULL) - STORM_FREE(pHetTable->pNameHashes); - if(pHetTable->pBetIndexes != NULL) - STORM_FREE(pHetTable->pBetIndexes); - - STORM_FREE(pHetTable); - } -} - -//----------------------------------------------------------------------------- -// Support for BET table - -static void CreateBetHeader( - TMPQArchive * ha, - TMPQBetHeader * pBetHeader) -{ - TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; - TFileEntry * pFileEntry; - ULONGLONG MaxByteOffset = 0; - DWORD FlagArray[MAX_FLAG_INDEX]; - DWORD dwMaxFlagIndex = 0; - DWORD dwMaxFileSize = 0; - DWORD dwMaxCmpSize = 0; - DWORD dwFlagIndex; - - // Initialize array of flag combinations - InitFileFlagArray(FlagArray); - - // Fill the common header - pBetHeader->ExtHdr.dwSignature = BET_TABLE_SIGNATURE; - pBetHeader->ExtHdr.dwVersion = 1; - pBetHeader->ExtHdr.dwDataSize = 0; - - // Get the maximum values for the BET table - pFileTableEnd = ha->pFileTable + ha->pHeader->dwBlockTableSize; - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - { - // - // Note: Deleted files must be counted as well - // - - // Highest file position in the MPQ - if(pFileEntry->ByteOffset > MaxByteOffset) - MaxByteOffset = pFileEntry->ByteOffset; - - // Biggest file size - if(pFileEntry->dwFileSize > dwMaxFileSize) - dwMaxFileSize = pFileEntry->dwFileSize; - - // Biggest compressed size - if(pFileEntry->dwCmpSize > dwMaxCmpSize) - dwMaxCmpSize = pFileEntry->dwCmpSize; - - // Check if this flag was there before - dwFlagIndex = GetFileFlagIndex(FlagArray, pFileEntry->dwFlags); - if(dwFlagIndex > dwMaxFlagIndex) - dwMaxFlagIndex = dwFlagIndex; - } - - // Now save bit count for every piece of file information - pBetHeader->dwBitIndex_FilePos = 0; - pBetHeader->dwBitCount_FilePos = GetNecessaryBitCount(MaxByteOffset); - - pBetHeader->dwBitIndex_FileSize = pBetHeader->dwBitIndex_FilePos + pBetHeader->dwBitCount_FilePos; - pBetHeader->dwBitCount_FileSize = GetNecessaryBitCount(dwMaxFileSize); - - pBetHeader->dwBitIndex_CmpSize = pBetHeader->dwBitIndex_FileSize + pBetHeader->dwBitCount_FileSize; - pBetHeader->dwBitCount_CmpSize = GetNecessaryBitCount(dwMaxCmpSize); - - pBetHeader->dwBitIndex_FlagIndex = pBetHeader->dwBitIndex_CmpSize + pBetHeader->dwBitCount_CmpSize; - pBetHeader->dwBitCount_FlagIndex = GetNecessaryBitCount(dwMaxFlagIndex + 1); - - pBetHeader->dwBitIndex_Unknown = pBetHeader->dwBitIndex_FlagIndex + pBetHeader->dwBitCount_FlagIndex; - pBetHeader->dwBitCount_Unknown = 0; - - // Calculate the total size of one entry - pBetHeader->dwTableEntrySize = pBetHeader->dwBitCount_FilePos + - pBetHeader->dwBitCount_FileSize + - pBetHeader->dwBitCount_CmpSize + - pBetHeader->dwBitCount_FlagIndex + - pBetHeader->dwBitCount_Unknown; - - // Save the file count and flag count - pBetHeader->dwEntryCount = ha->pHeader->dwBlockTableSize; - pBetHeader->dwFlagCount = dwMaxFlagIndex + 1; - pBetHeader->dwUnknown08 = 0x10; - - // Save the total size of the BET hash - pBetHeader->dwBitTotal_NameHash2 = ha->pHetTable->dwNameHashBitSize - 0x08; - pBetHeader->dwBitExtra_NameHash2 = 0; - pBetHeader->dwBitCount_NameHash2 = pBetHeader->dwBitTotal_NameHash2; - pBetHeader->dwNameHashArraySize = ((pBetHeader->dwBitTotal_NameHash2 * pBetHeader->dwEntryCount) + 7) / 8; - - // Save the total table size - pBetHeader->ExtHdr.dwDataSize = - pBetHeader->dwTableSize = sizeof(TMPQBetHeader) - sizeof(TMPQExtHeader) + - pBetHeader->dwFlagCount * sizeof(DWORD) + - ((pBetHeader->dwTableEntrySize * pBetHeader->dwEntryCount) + 7) / 8 + - pBetHeader->dwNameHashArraySize; -} - -TMPQBetTable * CreateBetTable(DWORD dwEntryCount) -{ - TMPQBetTable * pBetTable; - - // Allocate BET table - pBetTable = STORM_ALLOC(TMPQBetTable, 1); - if(pBetTable != NULL) - { - memset(pBetTable, 0, sizeof(TMPQBetTable)); - pBetTable->dwEntryCount = dwEntryCount; - } - - return pBetTable; -} - -static TMPQBetTable * TranslateBetTable( - TMPQArchive * ha, - TMPQBetHeader * pBetHeader) -{ - TMPQBetTable * pBetTable = NULL; - LPBYTE pbSrcData = (LPBYTE)(pBetHeader + 1); - DWORD LengthInBytes = 0; - - // Sanity check - assert(pBetHeader->ExtHdr.dwSignature == BET_TABLE_SIGNATURE); - assert(pBetHeader->ExtHdr.dwVersion == 1); - assert(ha->pHetTable != NULL); - ha = ha; - - // Verify size of the HET table - if(pBetHeader->ExtHdr.dwDataSize >= (sizeof(TMPQBetHeader) - sizeof(TMPQExtHeader))) - { - // Verify the size of the table in the header - if(pBetHeader->dwTableSize == pBetHeader->ExtHdr.dwDataSize) - { - // The number of entries in the BET table must be the same like number of entries in the block table - assert(pBetHeader->dwEntryCount == ha->pHeader->dwBlockTableSize); - assert(pBetHeader->dwEntryCount <= ha->dwMaxFileCount); - - // The number of entries in the BET table must be the same like number of entries in the HET table - // Note that if it's not, it is not a problem - //assert(pBetHeader->dwEntryCount == ha->pHetTable->dwEntryCount); - - // Create translated table - pBetTable = CreateBetTable(pBetHeader->dwEntryCount); - if(pBetTable != NULL) - { - // Copy the variables from the header to the BetTable - pBetTable->dwTableEntrySize = pBetHeader->dwTableEntrySize; - pBetTable->dwBitIndex_FilePos = pBetHeader->dwBitIndex_FilePos; - pBetTable->dwBitIndex_FileSize = pBetHeader->dwBitIndex_FileSize; - pBetTable->dwBitIndex_CmpSize = pBetHeader->dwBitIndex_CmpSize; - pBetTable->dwBitIndex_FlagIndex = pBetHeader->dwBitIndex_FlagIndex; - pBetTable->dwBitIndex_Unknown = pBetHeader->dwBitIndex_Unknown; - pBetTable->dwBitCount_FilePos = pBetHeader->dwBitCount_FilePos; - pBetTable->dwBitCount_FileSize = pBetHeader->dwBitCount_FileSize; - pBetTable->dwBitCount_CmpSize = pBetHeader->dwBitCount_CmpSize; - pBetTable->dwBitCount_FlagIndex = pBetHeader->dwBitCount_FlagIndex; - pBetTable->dwBitCount_Unknown = pBetHeader->dwBitCount_Unknown; - - // Since we don't know what the "unknown" is, we'll assert when it's zero - assert(pBetTable->dwBitCount_Unknown == 0); - - // Allocate array for flags - if(pBetHeader->dwFlagCount != 0) - { - // Allocate array for file flags and load it - pBetTable->pFileFlags = STORM_ALLOC(DWORD, pBetHeader->dwFlagCount); - if(pBetTable->pFileFlags != NULL) - { - LengthInBytes = pBetHeader->dwFlagCount * sizeof(DWORD); - memcpy(pBetTable->pFileFlags, pbSrcData, LengthInBytes); - BSWAP_ARRAY32_UNSIGNED(pBetTable->pFileFlags, LengthInBytes); - pbSrcData += LengthInBytes; - } - - // Save the number of flags - pBetTable->dwFlagCount = pBetHeader->dwFlagCount; - } - - // Load the bit-based file table - pBetTable->pFileTable = CreateBitArray(pBetTable->dwTableEntrySize * pBetHeader->dwEntryCount, 0); - if(pBetTable->pFileTable != NULL) - { - LengthInBytes = (pBetTable->pFileTable->NumberOfBits + 7) / 8; - memcpy(pBetTable->pFileTable->Elements, pbSrcData, LengthInBytes); - pbSrcData += LengthInBytes; - } - - // Fill the sizes of BET hash - pBetTable->dwBitTotal_NameHash2 = pBetHeader->dwBitTotal_NameHash2; - pBetTable->dwBitExtra_NameHash2 = pBetHeader->dwBitExtra_NameHash2; - pBetTable->dwBitCount_NameHash2 = pBetHeader->dwBitCount_NameHash2; - - // Create and load the array of BET hashes - pBetTable->pNameHashes = CreateBitArray(pBetTable->dwBitTotal_NameHash2 * pBetHeader->dwEntryCount, 0); - if(pBetTable->pNameHashes != NULL) - { - LengthInBytes = (pBetTable->pNameHashes->NumberOfBits + 7) / 8; - memcpy(pBetTable->pNameHashes->Elements, pbSrcData, LengthInBytes); -// pbSrcData += LengthInBytes; - } - - // Dump both tables -// DumpHetAndBetTable(ha->pHetTable, pBetTable); - } - } - } - - return pBetTable; -} - -TMPQExtHeader * TranslateBetTable( - TMPQArchive * ha, - ULONGLONG * pcbBetTable) -{ - TMPQBetHeader * pBetHeader = NULL; - TMPQBetHeader BetHeader; - TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; - TFileEntry * pFileEntry; - TBitArray * pBitArray = NULL; - LPBYTE pbLinearTable = NULL; - LPBYTE pbTrgData; - DWORD LengthInBytes; - DWORD FlagArray[MAX_FLAG_INDEX]; - - // Calculate the bit sizes of various entries - InitFileFlagArray(FlagArray); - CreateBetHeader(ha, &BetHeader); - - // Allocate space - pbLinearTable = STORM_ALLOC(BYTE, sizeof(TMPQExtHeader) + BetHeader.dwTableSize); - if(pbLinearTable != NULL) - { - // Copy the BET header to the linear buffer - pBetHeader = (TMPQBetHeader *)pbLinearTable; - memcpy(pBetHeader, &BetHeader, sizeof(TMPQBetHeader)); - pbTrgData = (LPBYTE)(pBetHeader + 1); - - // Save the bit-based block table - pBitArray = CreateBitArray(BetHeader.dwEntryCount * BetHeader.dwTableEntrySize, 0); - if(pBitArray != NULL) - { - DWORD dwFlagIndex = 0; - DWORD nBitOffset = 0; - - // Construct the bit-based file table - pFileTableEnd = ha->pFileTable + BetHeader.dwEntryCount; - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - { - // - // Note: Missing files must be included as well - // - - // Save the byte offset - SetBits(pBitArray, nBitOffset + BetHeader.dwBitIndex_FilePos, - BetHeader.dwBitCount_FilePos, - &pFileEntry->ByteOffset, - 8); - SetBits(pBitArray, nBitOffset + BetHeader.dwBitIndex_FileSize, - BetHeader.dwBitCount_FileSize, - &pFileEntry->dwFileSize, - 4); - SetBits(pBitArray, nBitOffset + BetHeader.dwBitIndex_CmpSize, - BetHeader.dwBitCount_CmpSize, - &pFileEntry->dwCmpSize, - 4); - - // Save the flag index - dwFlagIndex = GetFileFlagIndex(FlagArray, pFileEntry->dwFlags); - SetBits(pBitArray, nBitOffset + BetHeader.dwBitIndex_FlagIndex, - BetHeader.dwBitCount_FlagIndex, - &dwFlagIndex, - 4); - - // Move the bit offset - nBitOffset += BetHeader.dwTableEntrySize; - } - - // Write the array of flags - LengthInBytes = BetHeader.dwFlagCount * sizeof(DWORD); - memcpy(pbTrgData, FlagArray, LengthInBytes); - BSWAP_ARRAY32_UNSIGNED(pbTrgData, LengthInBytes); - pbTrgData += LengthInBytes; - - // Write the bit-based block table - LengthInBytes = (pBitArray->NumberOfBits + 7) / 8; - memcpy(pbTrgData, pBitArray->Elements, LengthInBytes); - pbTrgData += LengthInBytes; - - // Free the bit array - STORM_FREE(pBitArray); - } - - // Create bit array for name hashes - pBitArray = CreateBitArray(BetHeader.dwBitTotal_NameHash2 * BetHeader.dwEntryCount, 0); - if(pBitArray != NULL) - { - DWORD dwFileIndex = 0; - - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - { - // Insert the name hash to the bit array - SetBits(pBitArray, BetHeader.dwBitTotal_NameHash2 * dwFileIndex, - BetHeader.dwBitCount_NameHash2, - &pFileEntry->FileNameHash, - 8); - - assert(dwFileIndex < BetHeader.dwEntryCount); - dwFileIndex++; - } - - // Write the array of BET hashes - LengthInBytes = (pBitArray->NumberOfBits + 7) / 8; - memcpy(pbTrgData, pBitArray->Elements, LengthInBytes); -// pbTrgData += LengthInBytes; - - // Free the bit array - STORM_FREE(pBitArray); - } - - // Write the size of the BET table in the MPQ - if(pcbBetTable != NULL) - { - *pcbBetTable = (ULONGLONG)(sizeof(TMPQExtHeader) + BetHeader.dwTableSize); - } - } - - // Keep Coverity happy - assert((TMPQExtHeader *)&pBetHeader->ExtHdr == (TMPQExtHeader *)pbLinearTable); - return (TMPQExtHeader *)pbLinearTable; -} - -void FreeBetTable(TMPQBetTable * pBetTable) -{ - if(pBetTable != NULL) - { - if(pBetTable->pFileTable != NULL) - STORM_FREE(pBetTable->pFileTable); - if(pBetTable->pFileFlags != NULL) - STORM_FREE(pBetTable->pFileFlags); - if(pBetTable->pNameHashes != NULL) - STORM_FREE(pBetTable->pNameHashes); - - STORM_FREE(pBetTable); - } -} - -//----------------------------------------------------------------------------- -// Support for file table - -TFileEntry * GetFileEntryLocale2(TMPQArchive * ha, const char * szFileName, LCID lcLocale, LPDWORD PtrHashIndex) -{ - TMPQHash * pHash; - DWORD dwFileIndex; - - // First, we have to search the classic hash table - // This is because on renaming, deleting, or changing locale, - // we will need the pointer to hash table entry - if(ha->pHashTable != NULL) - { - pHash = GetHashEntryLocale(ha, szFileName, lcLocale, 0); - if(pHash != NULL && MPQ_BLOCK_INDEX(pHash) < ha->dwFileTableSize) - { - if(PtrHashIndex != NULL) - PtrHashIndex[0] = (DWORD)(pHash - ha->pHashTable); - return ha->pFileTable + MPQ_BLOCK_INDEX(pHash); - } - } - - // If we have HET table in the MPQ, try to find the file in HET table - if(ha->pHetTable != NULL) - { - dwFileIndex = GetFileIndex_Het(ha, szFileName); - if(dwFileIndex != HASH_ENTRY_FREE) - return ha->pFileTable + dwFileIndex; - } - - // Not found - return NULL; -} - -TFileEntry * GetFileEntryLocale(TMPQArchive * ha, const char * szFileName, LCID lcLocale) -{ - return GetFileEntryLocale2(ha, szFileName, lcLocale, NULL); -} - -TFileEntry * GetFileEntryExact(TMPQArchive * ha, const char * szFileName, LCID lcLocale, LPDWORD PtrHashIndex) -{ - TMPQHash * pHash; - DWORD dwFileIndex; - - // If the hash table is present, find the entry from hash table - if(ha->pHashTable != NULL) - { - pHash = GetHashEntryExact(ha, szFileName, lcLocale); - if(pHash != NULL && MPQ_BLOCK_INDEX(pHash) < ha->dwFileTableSize) - { - if(PtrHashIndex != NULL) - PtrHashIndex[0] = (DWORD)(pHash - ha->pHashTable); - return ha->pFileTable + MPQ_BLOCK_INDEX(pHash); - } - } - - // If we have HET table in the MPQ, try to find the file in HET table - if(ha->pHetTable != NULL) - { - dwFileIndex = GetFileIndex_Het(ha, szFileName); - if(dwFileIndex != HASH_ENTRY_FREE) - { - if(PtrHashIndex != NULL) - PtrHashIndex[0] = HASH_ENTRY_FREE; - return ha->pFileTable + dwFileIndex; - } - } - - // Not found - return NULL; -} - -void AllocateFileName(TMPQArchive * ha, TFileEntry * pFileEntry, const char * szFileName) -{ - // Sanity check - assert(pFileEntry != NULL); - - // If the file name is pseudo file name, free it at this point - if(IsPseudoFileName(pFileEntry->szFileName, NULL)) - { - if(pFileEntry->szFileName != NULL) - STORM_FREE(pFileEntry->szFileName); - pFileEntry->szFileName = NULL; - } - - // Only allocate new file name if it's not there yet - if(pFileEntry->szFileName == NULL) - { - pFileEntry->szFileName = STORM_ALLOC(char, strlen(szFileName) + 1); - if(pFileEntry->szFileName != NULL) - strcpy(pFileEntry->szFileName, szFileName); - } - - // We also need to create the file name hash - if(ha->pHetTable != NULL) - { - ULONGLONG AndMask64 = ha->pHetTable->AndMask64; - ULONGLONG OrMask64 = ha->pHetTable->OrMask64; - - pFileEntry->FileNameHash = (HashStringJenkins(szFileName) & AndMask64) | OrMask64; - } -} - -TFileEntry * AllocateFileEntry(TMPQArchive * ha, const char * szFileName, LCID lcLocale, LPDWORD PtrHashIndex) -{ - TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; - TFileEntry * pFreeEntry = NULL; - TFileEntry * pFileEntry; - TMPQHash * pHash = NULL; - DWORD dwReservedFiles = ha->dwReservedFiles; - DWORD dwFreeCount = 0; - - // Sanity check: File table size must be greater or equal to max file count - assert(ha->dwFileTableSize >= ha->dwMaxFileCount); - - // If we are saving MPQ tables, we don't tale number of reserved files into account - dwReservedFiles = (ha->dwFlags & MPQ_FLAG_SAVING_TABLES) ? 0 : ha->dwReservedFiles; - - // Now find a free entry in the file table. - // Note that in the case when free entries are in the middle, - // we need to use these - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - { - if((pFileEntry->dwFlags & MPQ_FILE_EXISTS) == 0) - { - // Remember the first free entry - if(pFreeEntry == NULL) - pFreeEntry = pFileEntry; - dwFreeCount++; - - // If the number of free items is greater than number - // of reserved items, We can add the file - if(dwFreeCount > dwReservedFiles) - break; - } - } - - // If the total number of free entries is less than number of reserved files, - // we cannot add the file to the archive - if(pFreeEntry == NULL || dwFreeCount <= dwReservedFiles) - return NULL; - - // Initialize the file entry and set its file name - memset(pFreeEntry, 0, sizeof(TFileEntry)); - AllocateFileName(ha, pFreeEntry, szFileName); - - // If the archive has a hash table, we need to first free entry there - if(ha->pHashTable != NULL) - { - // Make sure that the entry is not there yet - assert(GetHashEntryExact(ha, szFileName, lcLocale) == NULL); - - // Find a free hash table entry for the name - pHash = AllocateHashEntry(ha, pFreeEntry, lcLocale); - if(pHash == NULL) - return NULL; - - // Set the file index to the hash table - pHash->dwBlockIndex = (DWORD)(pFreeEntry - ha->pFileTable); - PtrHashIndex[0] = (DWORD)(pHash - ha->pHashTable); - } - - // If the archive has a HET table, just do some checks - // Note: Don't bother modifying the HET table. It will be rebuilt from scratch after, anyway - if(ha->pHetTable != NULL) - { - assert(GetFileIndex_Het(ha, szFileName) == HASH_ENTRY_FREE); - } - - // Return the free table entry - return pFreeEntry; -} - -int RenameFileEntry( - TMPQArchive * ha, - TMPQFile * hf, - const char * szNewFileName) -{ - TFileEntry * pFileEntry = hf->pFileEntry; - TMPQHash * pHashEntry = hf->pHashEntry; - LCID lcLocale = 0; - - // If the archive hash hash table, we need to free the hash table entry - if(ha->pHashTable != NULL) - { - // The file must have hash table entry assigned - // Will exit if there are multiple HASH entries pointing to the same file entry - if(pHashEntry == NULL) - return ERROR_NOT_SUPPORTED; - - // Save the locale - lcLocale = pHashEntry->lcLocale; - - // Mark the hash table entry as deleted - pHashEntry->dwName1 = 0xFFFFFFFF; - pHashEntry->dwName2 = 0xFFFFFFFF; - pHashEntry->lcLocale = 0xFFFF; - pHashEntry->Platform = 0xFF; - pHashEntry->Reserved = 0xFF; - pHashEntry->dwBlockIndex = HASH_ENTRY_DELETED; - } - - // Free the old file name - if(pFileEntry->szFileName != NULL) - STORM_FREE(pFileEntry->szFileName); - pFileEntry->szFileName = NULL; - - // Allocate new file name - AllocateFileName(ha, pFileEntry, szNewFileName); - - // Allocate new hash entry - if(ha->pHashTable != NULL) - { - // Since we freed one hash entry before, this must succeed - hf->pHashEntry = AllocateHashEntry(ha, pFileEntry, lcLocale); - assert(hf->pHashEntry != NULL); - } - - return ERROR_SUCCESS; -} - -int DeleteFileEntry(TMPQArchive * ha, TMPQFile * hf) -{ - TFileEntry * pFileEntry = hf->pFileEntry; - TMPQHash * pHashEntry = hf->pHashEntry; - - // If the archive hash hash table, we need to free the hash table entry - if(ha->pHashTable != NULL) - { - // The file must have hash table entry assigned - // Will exit if there are multiple HASH entries pointing to the same file entry - if(pHashEntry == NULL) - return ERROR_NOT_SUPPORTED; - - // Mark the hash table entry as deleted - pHashEntry->dwName1 = 0xFFFFFFFF; - pHashEntry->dwName2 = 0xFFFFFFFF; - pHashEntry->lcLocale = 0xFFFF; - pHashEntry->Platform = 0xFF; - pHashEntry->Reserved = 0xFF; - pHashEntry->dwBlockIndex = HASH_ENTRY_DELETED; - } - - // Free the file name, and set the file entry as deleted - if(pFileEntry->szFileName != NULL) - STORM_FREE(pFileEntry->szFileName); - pFileEntry->szFileName = NULL; - - // - // Don't modify the HET table, because it gets recreated by the caller - // Don't decrement the number of entries in the file table - // Keep Byte Offset, file size, compressed size, CRC32 and MD5 - // Clear the file name hash and the MPQ_FILE_EXISTS bit - // - - pFileEntry->dwFlags &= ~MPQ_FILE_EXISTS; - pFileEntry->FileNameHash = 0; - return ERROR_SUCCESS; -} - -DWORD InvalidateInternalFile(TMPQArchive * ha, const char * szFileName, DWORD dwFlagNone, DWORD dwFlagNew, DWORD dwForceAddTheFile = 0) -{ - TMPQFile * hf = NULL; - DWORD dwFileFlags = MPQ_FILE_DEFAULT_INTERNAL; - int nError = ERROR_FILE_NOT_FOUND; - - // Open the file from the MPQ - if(SFileOpenFileEx((HANDLE)ha, szFileName, SFILE_OPEN_BASE_FILE, (HANDLE *)&hf)) - { - // Remember the file flags - dwFileFlags = hf->pFileEntry->dwFlags; - - // Delete the file entry - nError = DeleteFileEntry(ha, hf); - if(nError == ERROR_SUCCESS) - dwForceAddTheFile = 1; - - // Close the file - FreeFileHandle(hf); - } - - // Are we going to add the file? - if(dwForceAddTheFile) - { - ha->dwFlags |= dwFlagNew; - ha->dwReservedFiles++; - } - else - { - ha->dwFlags |= dwFlagNone; - dwFileFlags = 0; - } - - // Return the intended file flags - return dwFileFlags; -} - -void InvalidateInternalFiles(TMPQArchive * ha) -{ - // Do nothing if we are in the middle of saving internal files - if(!(ha->dwFlags & MPQ_FLAG_SAVING_TABLES)) - { - // - // We clear the file entries for (listfile), (attributes) and (signature) - // For each internal file cleared, we increment the number - // of reserved entries in the file table. - // - - // Invalidate the (listfile), if not done yet - if((ha->dwFlags & (MPQ_FLAG_LISTFILE_NONE | MPQ_FLAG_LISTFILE_NEW)) == 0) - { - ha->dwFileFlags1 = InvalidateInternalFile(ha, LISTFILE_NAME, MPQ_FLAG_LISTFILE_NONE, MPQ_FLAG_LISTFILE_NEW, (ha->dwFlags & MPQ_FLAG_LISTFILE_FORCE)); - } - - // Invalidate the (attributes), if not done yet - if((ha->dwFlags & (MPQ_FLAG_ATTRIBUTES_NONE | MPQ_FLAG_ATTRIBUTES_NEW)) == 0) - { - ha->dwFileFlags2 = InvalidateInternalFile(ha, ATTRIBUTES_NAME, MPQ_FLAG_ATTRIBUTES_NONE, MPQ_FLAG_ATTRIBUTES_NEW); - } - - // Invalidate the (signature), if not done yet - if((ha->dwFlags & (MPQ_FLAG_SIGNATURE_NONE | MPQ_FLAG_SIGNATURE_NEW)) == 0) - { - ha->dwFileFlags3 = InvalidateInternalFile(ha, SIGNATURE_NAME, MPQ_FLAG_SIGNATURE_NONE, MPQ_FLAG_SIGNATURE_NEW); - } - - // Remember that the MPQ has been changed - ha->dwFlags |= MPQ_FLAG_CHANGED; - } -} - -//----------------------------------------------------------------------------- -// Support for file tables - hash table, block table, hi-block table - -int CreateHashTable(TMPQArchive * ha, DWORD dwHashTableSize) -{ - TMPQHash * pHashTable; - - // Sanity checks - assert((dwHashTableSize & (dwHashTableSize - 1)) == 0); - assert(ha->pHashTable == NULL); - - // If the required hash table size is zero, don't create anything - if(dwHashTableSize == 0) - dwHashTableSize = HASH_TABLE_SIZE_DEFAULT; - - // Create the hash table - pHashTable = STORM_ALLOC(TMPQHash, dwHashTableSize); - if(pHashTable == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - // Fill it - memset(pHashTable, 0xFF, dwHashTableSize * sizeof(TMPQHash)); - ha->pHeader->dwHashTableSize = dwHashTableSize; - ha->dwMaxFileCount = dwHashTableSize; - ha->pHashTable = pHashTable; - return ERROR_SUCCESS; -} - -static TMPQHash * LoadHashTable(TMPQArchive * ha) -{ - TMPQHeader * pHeader = ha->pHeader; - ULONGLONG ByteOffset; - TMPQHash * pHashTable = NULL; - DWORD dwTableSize; - DWORD dwCmpSize; - bool bHashTableIsCut = false; - - // Note: It is allowed to load hash table if it is at offset 0. - // Example: MPQ_2016_v1_ProtectedMap_HashOffsIsZero.w3x -// if(pHeader->dwHashTablePos == 0 && pHeader->wHashTablePosHi == 0) -// return NULL; - - // If the hash table size is zero, do nothing - if(pHeader->dwHashTableSize == 0) - return NULL; - - // Load the hash table for MPQ variations - switch(ha->dwSubType) - { - case MPQ_SUBTYPE_MPQ: - - // Calculate the position and size of the hash table - ByteOffset = FileOffsetFromMpqOffset(ha, MAKE_OFFSET64(pHeader->wHashTablePosHi, pHeader->dwHashTablePos)); - dwTableSize = pHeader->dwHashTableSize * sizeof(TMPQHash); - dwCmpSize = (DWORD)pHeader->HashTableSize64; - - // Read, decrypt and uncompress the hash table - pHashTable = (TMPQHash *)LoadMpqTable(ha, ByteOffset, dwCmpSize, dwTableSize, MPQ_KEY_HASH_TABLE, &bHashTableIsCut); -// DumpHashTable(pHashTable, pHeader->dwHashTableSize); - - // If the hash table was cut, we can/have to defragment it - if(pHashTable != NULL && bHashTableIsCut) - ha->dwFlags |= (MPQ_FLAG_MALFORMED | MPQ_FLAG_HASH_TABLE_CUT); - break; - - case MPQ_SUBTYPE_SQP: - pHashTable = LoadSqpHashTable(ha); - break; - - case MPQ_SUBTYPE_MPK: - pHashTable = LoadMpkHashTable(ha); - break; - } - - // Remember the size of the hash table - return pHashTable; -} - -int CreateFileTable(TMPQArchive * ha, DWORD dwFileTableSize) -{ - ha->pFileTable = STORM_ALLOC(TFileEntry, dwFileTableSize); - if(ha->pFileTable == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - memset(ha->pFileTable, 0x00, sizeof(TFileEntry) * dwFileTableSize); - ha->dwFileTableSize = dwFileTableSize; - return ERROR_SUCCESS; -} - -TMPQBlock * LoadBlockTable(TMPQArchive * ha, bool /* bDontFixEntries */) -{ - TMPQHeader * pHeader = ha->pHeader; - TMPQBlock * pBlockTable = NULL; - ULONGLONG ByteOffset; - DWORD dwTableSize; - DWORD dwCmpSize; - bool bBlockTableIsCut = false; - - // Note: It is possible that the block table starts at offset 0 - // Example: MPQ_2016_v1_ProtectedMap_HashOffsIsZero.w3x -// if(pHeader->dwBlockTablePos == 0 && pHeader->wBlockTablePosHi == 0) -// return NULL; - - // Do nothing if the block table size is zero - if(pHeader->dwBlockTableSize == 0) - return NULL; - - // Load the block table for MPQ variations - switch(ha->dwSubType) - { - case MPQ_SUBTYPE_MPQ: - - // Calculate byte position of the block table - ByteOffset = FileOffsetFromMpqOffset(ha, MAKE_OFFSET64(pHeader->wBlockTablePosHi, pHeader->dwBlockTablePos)); - dwTableSize = pHeader->dwBlockTableSize * sizeof(TMPQBlock); - dwCmpSize = (DWORD)pHeader->BlockTableSize64; - - // Read, decrypt and uncompress the block table - pBlockTable = (TMPQBlock * )LoadMpqTable(ha, ByteOffset, dwCmpSize, dwTableSize, MPQ_KEY_BLOCK_TABLE, &bBlockTableIsCut); - - // If the block table was cut, we need to remember it - if(pBlockTable != NULL && bBlockTableIsCut) - ha->dwFlags |= (MPQ_FLAG_MALFORMED | MPQ_FLAG_BLOCK_TABLE_CUT); - break; - - case MPQ_SUBTYPE_SQP: - - pBlockTable = LoadSqpBlockTable(ha); - break; - - case MPQ_SUBTYPE_MPK: - - pBlockTable = LoadMpkBlockTable(ha); - break; - } - - return pBlockTable; -} - -TMPQHetTable * LoadHetTable(TMPQArchive * ha) -{ - TMPQExtHeader * pExtTable; - TMPQHetTable * pHetTable = NULL; - TMPQHeader * pHeader = ha->pHeader; - - // If the HET table position is not 0, we expect the table to be present - if(pHeader->HetTablePos64 != 0 && pHeader->HetTableSize64 != 0) - { - // Attempt to load the HET table (Hash Extended Table) - pExtTable = LoadExtTable(ha, pHeader->HetTablePos64, (size_t)pHeader->HetTableSize64, HET_TABLE_SIGNATURE, MPQ_KEY_HASH_TABLE); - if(pExtTable != NULL) - { - // If loading HET table fails, we ignore the result. - pHetTable = TranslateHetTable((TMPQHetHeader *)pExtTable); - STORM_FREE(pExtTable); - } - } - - return pHetTable; -} - -TMPQBetTable * LoadBetTable(TMPQArchive * ha) -{ - TMPQExtHeader * pExtTable; - TMPQBetTable * pBetTable = NULL; - TMPQHeader * pHeader = ha->pHeader; - - // If the BET table position is not 0, we expect the table to be present - if(pHeader->BetTablePos64 != 0 && pHeader->BetTableSize64 != 0) - { - // Attempt to load the HET table (Hash Extended Table) - pExtTable = LoadExtTable(ha, pHeader->BetTablePos64, (size_t)pHeader->BetTableSize64, BET_TABLE_SIGNATURE, MPQ_KEY_BLOCK_TABLE); - if(pExtTable != NULL) - { - // If succeeded, we translate the BET table - // to more readable form - pBetTable = TranslateBetTable(ha, (TMPQBetHeader *)pExtTable); - STORM_FREE(pExtTable); - } - } - - return pBetTable; -} - -int LoadAnyHashTable(TMPQArchive * ha) -{ - TMPQHeader * pHeader = ha->pHeader; - - // If the MPQ archive is empty, don't bother trying to load anything - if(pHeader->dwHashTableSize == 0 && pHeader->HetTableSize64 == 0) - return CreateHashTable(ha, HASH_TABLE_SIZE_DEFAULT); - - // Try to load HET table - if(pHeader->HetTablePos64 != 0) - ha->pHetTable = LoadHetTable(ha); - - // Try to load classic hash table - if(pHeader->dwHashTableSize) - ha->pHashTable = LoadHashTable(ha); - - // At least one of the tables must be present - if(ha->pHetTable == NULL && ha->pHashTable == NULL) - return ERROR_FILE_CORRUPT; - - // Set the maximum file count to the size of the hash table. - // Note: We don't care about HET table limits, because HET table is rebuilt - // after each file add/rename/delete. - ha->dwMaxFileCount = (ha->pHashTable != NULL) ? pHeader->dwHashTableSize : HASH_TABLE_SIZE_MAX; - return ERROR_SUCCESS; -} - -static int BuildFileTable_Classic(TMPQArchive * ha) -{ - TMPQHeader * pHeader = ha->pHeader; - TMPQBlock * pBlockTable; - int nError = ERROR_SUCCESS; - - // Sanity checks - assert(ha->pHashTable != NULL); - assert(ha->pFileTable != NULL); - - // If the MPQ has no block table, do nothing - if(pHeader->dwBlockTableSize == 0) - return ERROR_SUCCESS; - assert(ha->dwFileTableSize >= pHeader->dwBlockTableSize); - - // Load the block table - // WARNING! ha->pFileTable can change in the process!! - pBlockTable = (TMPQBlock *)LoadBlockTable(ha); - if(pBlockTable != NULL) - { - nError = BuildFileTableFromBlockTable(ha, pBlockTable); - STORM_FREE(pBlockTable); - } - else - { - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Load the hi-block table - if(nError == ERROR_SUCCESS && pHeader->HiBlockTablePos64 != 0) - { - ULONGLONG ByteOffset; - USHORT * pHiBlockTable = NULL; - DWORD dwTableSize = pHeader->dwBlockTableSize * sizeof(USHORT); - - // Allocate space for the hi-block table - // Note: pHeader->dwBlockTableSize can be zero !!! - pHiBlockTable = STORM_ALLOC(USHORT, pHeader->dwBlockTableSize + 1); - if(pHiBlockTable != NULL) - { - // Load the hi-block table. It is not encrypted, nor compressed - ByteOffset = ha->MpqPos + pHeader->HiBlockTablePos64; - if(!FileStream_Read(ha->pStream, &ByteOffset, pHiBlockTable, dwTableSize)) - nError = GetLastError(); - - // Now merge the hi-block table to the file table - if(nError == ERROR_SUCCESS) - { - TFileEntry * pFileEntry = ha->pFileTable; - - // Swap the hi-block table - BSWAP_ARRAY16_UNSIGNED(pHiBlockTable, dwTableSize); - - // Add the high file offset to the base file offset. - for(DWORD i = 0; i < pHeader->dwBlockTableSize; i++, pFileEntry++) - pFileEntry->ByteOffset = MAKE_OFFSET64(pHiBlockTable[i], pFileEntry->ByteOffset); - } - - // Free the hi-block table - STORM_FREE(pHiBlockTable); - } - else - { - nError = ERROR_NOT_ENOUGH_MEMORY; - } - } - - return nError; -} - -static int BuildFileTable_HetBet(TMPQArchive * ha) -{ - TMPQHetTable * pHetTable = ha->pHetTable; - TMPQBetTable * pBetTable; - TFileEntry * pFileEntry = ha->pFileTable; - TBitArray * pBitArray; - DWORD dwBitPosition = 0; - DWORD i; - int nError = ERROR_FILE_CORRUPT; - - // Load the BET table from the MPQ - pBetTable = LoadBetTable(ha); - if(pBetTable != NULL) - { - // Verify the size of NameHash2 in the BET table. - // It has to be 8 bits less than the information in HET table - if((pBetTable->dwBitCount_NameHash2 + 8) != pHetTable->dwNameHashBitSize) - { - FreeBetTable(pBetTable); - return ERROR_FILE_CORRUPT; - } - - // Step one: Fill the name indexes - for(i = 0; i < pHetTable->dwTotalCount; i++) - { - DWORD dwFileIndex = 0; - - // Is the entry in the HET table occupied? - if(pHetTable->pNameHashes[i] != HET_ENTRY_FREE) - { - // Load the index to the BET table - GetBits(pHetTable->pBetIndexes, pHetTable->dwIndexSizeTotal * i, - pHetTable->dwIndexSize, - &dwFileIndex, - 4); - // Overflow test - if(dwFileIndex < pBetTable->dwEntryCount) - { - ULONGLONG NameHash1 = pHetTable->pNameHashes[i]; - ULONGLONG NameHash2 = 0; - - // Load the BET hash - GetBits(pBetTable->pNameHashes, pBetTable->dwBitTotal_NameHash2 * dwFileIndex, - pBetTable->dwBitCount_NameHash2, - &NameHash2, - 8); - - // Combine both part of the name hash and put it to the file table - pFileEntry = ha->pFileTable + dwFileIndex; - pFileEntry->FileNameHash = (NameHash1 << pBetTable->dwBitCount_NameHash2) | NameHash2; - } - } - } - - // Go through the entire BET table and convert it to the file table. - pFileEntry = ha->pFileTable; - pBitArray = pBetTable->pFileTable; - for(i = 0; i < pBetTable->dwEntryCount; i++) - { - DWORD dwFlagIndex = 0; - - // Read the file position - GetBits(pBitArray, dwBitPosition + pBetTable->dwBitIndex_FilePos, - pBetTable->dwBitCount_FilePos, - &pFileEntry->ByteOffset, - 8); - - // Read the file size - GetBits(pBitArray, dwBitPosition + pBetTable->dwBitIndex_FileSize, - pBetTable->dwBitCount_FileSize, - &pFileEntry->dwFileSize, - 4); - - // Read the compressed size - GetBits(pBitArray, dwBitPosition + pBetTable->dwBitIndex_CmpSize, - pBetTable->dwBitCount_CmpSize, - &pFileEntry->dwCmpSize, - 4); - - - // Read the flag index - if(pBetTable->dwFlagCount != 0) - { - GetBits(pBitArray, dwBitPosition + pBetTable->dwBitIndex_FlagIndex, - pBetTable->dwBitCount_FlagIndex, - &dwFlagIndex, - 4); - pFileEntry->dwFlags = pBetTable->pFileFlags[dwFlagIndex]; - } - - // - // TODO: Locale (?) - // - - // Move the current bit position - dwBitPosition += pBetTable->dwTableEntrySize; - pFileEntry++; - } - - // Set the current size of the file table - FreeBetTable(pBetTable); - nError = ERROR_SUCCESS; - } - else - { - nError = ERROR_FILE_CORRUPT; - } - - return nError; -} - -int BuildFileTable(TMPQArchive * ha) -{ - DWORD dwFileTableSize; - bool bFileTableCreated = false; - - // Sanity checks - assert(ha->pFileTable == NULL); - assert(ha->dwFileTableSize == 0); - assert(ha->dwMaxFileCount != 0); - - // Determine the allocation size for the file table - dwFileTableSize = STORMLIB_MAX(ha->pHeader->dwBlockTableSize, ha->dwMaxFileCount); - - // Allocate the file table with size determined before - ha->pFileTable = STORM_ALLOC(TFileEntry, dwFileTableSize); - if(ha->pFileTable == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - // Fill the table with zeros - memset(ha->pFileTable, 0, dwFileTableSize * sizeof(TFileEntry)); - ha->dwFileTableSize = dwFileTableSize; - - // If we have HET table, we load file table from the BET table - // Note: If BET table is corrupt or missing, we set the archive as read only - if(ha->pHetTable != NULL) - { - if(BuildFileTable_HetBet(ha) != ERROR_SUCCESS) - ha->dwFlags |= MPQ_FLAG_READ_ONLY; - else - bFileTableCreated = true; - } - - // If we have hash table, we load the file table from the block table - // Note: If block table is corrupt or missing, we set the archive as read only - if(ha->pHashTable != NULL) - { - if(BuildFileTable_Classic(ha) != ERROR_SUCCESS) - ha->dwFlags |= MPQ_FLAG_READ_ONLY; - else - bFileTableCreated = true; - } - - // Return result - return bFileTableCreated ? ERROR_SUCCESS : ERROR_FILE_CORRUPT; -} - -/* -void UpdateBlockTableSize(TMPQArchive * ha) -{ - TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; - TFileEntry * pFileEntry; - DWORD dwBlockTableSize = 0; - - // Calculate the number of files - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - { - // If the source table entry is valid, - if(pFileEntry->dwFlags & MPQ_FILE_EXISTS) - dwBlockTableSize = (DWORD)(pFileEntry - ha->pFileTable) + 1; - } - - // Save the block table size to the MPQ header - ha->pHeader->dwBlockTableSize = ha->dwReservedFiles + dwBlockTableSize; -} -*/ - -// Defragment the file table so it does not contain any gaps -int DefragmentFileTable(TMPQArchive * ha) -{ - TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; - TFileEntry * pSource = ha->pFileTable; - TFileEntry * pTarget = ha->pFileTable; - LPDWORD DefragmentTable; - DWORD dwBlockTableSize = 0; - DWORD dwSrcIndex; - DWORD dwTrgIndex; - - // Allocate brand new file table - DefragmentTable = STORM_ALLOC(DWORD, ha->dwFileTableSize); - if(DefragmentTable != NULL) - { - // Clear the file table - memset(DefragmentTable, 0xFF, sizeof(DWORD) * ha->dwFileTableSize); - - // Parse the entire file table and defragment it - for(; pSource < pFileTableEnd; pSource++) - { - // If the source table entry is valid, - if(pSource->dwFlags & MPQ_FILE_EXISTS) - { - // Remember the index conversion - dwSrcIndex = (DWORD)(pSource - ha->pFileTable); - dwTrgIndex = (DWORD)(pTarget - ha->pFileTable); - DefragmentTable[dwSrcIndex] = dwTrgIndex; - - // Move the entry, if needed - if(pTarget != pSource) - pTarget[0] = pSource[0]; - pTarget++; - - // Update the block table size - dwBlockTableSize = (DWORD)(pTarget - ha->pFileTable); - } - else - { - // If there is file name left, free it - if(pSource->szFileName != NULL) - STORM_FREE(pSource->szFileName); - pSource->szFileName = NULL; - } - } - - // Did we defragment something? - if(pTarget < pFileTableEnd) - { - // Clear the remaining file entries - memset(pTarget, 0, (pFileTableEnd - pTarget) * sizeof(TFileEntry)); - - // Go through the hash table and relocate the block indexes - if(ha->pHashTable != NULL) - { - TMPQHash * pHashTableEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - TMPQHash * pHash; - DWORD dwNewBlockIndex; - - for(pHash = ha->pHashTable; pHash < pHashTableEnd; pHash++) - { - if(MPQ_BLOCK_INDEX(pHash) < ha->dwFileTableSize) - { - // If that block entry is there, set it to the hash entry - // If not, set it as DELETED - dwNewBlockIndex = DefragmentTable[MPQ_BLOCK_INDEX(pHash)]; - pHash->dwBlockIndex = (dwNewBlockIndex != HASH_ENTRY_FREE) ? dwNewBlockIndex : HASH_ENTRY_DELETED; - } - } - } - } - - // Save the block table size - ha->pHeader->dwBlockTableSize = ha->dwReservedFiles + dwBlockTableSize; - - // Free the defragment table - STORM_FREE(DefragmentTable); - } - - return ERROR_SUCCESS; -} - -// Rebuilds the HET table from scratch based on the file table -// Used after a modifying operation (add, rename, delete) -int RebuildHetTable(TMPQArchive * ha) -{ - TMPQHetTable * pOldHetTable = ha->pHetTable; - TFileEntry * pFileTableEnd; - TFileEntry * pFileEntry; - DWORD dwBlockTableSize = ha->dwFileTableSize; - int nError = ERROR_SUCCESS; - - // If we are in the state of saving MPQ tables, the real size of block table - // must already have been calculated. Use that value instead - if(ha->dwFlags & MPQ_FLAG_SAVING_TABLES) - { - assert(ha->pHeader->dwBlockTableSize != 0); - dwBlockTableSize = ha->pHeader->dwBlockTableSize; - } - - // Create new HET table based on the total number of entries in the file table - // Note that if we fail to create it, we just stop using HET table - ha->pHetTable = CreateHetTable(dwBlockTableSize, 0, 0x40, NULL); - if(ha->pHetTable != NULL) - { - // Go through the file table again and insert all existing files - pFileTableEnd = ha->pFileTable + dwBlockTableSize; - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - { - if(pFileEntry->dwFlags & MPQ_FILE_EXISTS) - { - // Get the high - nError = InsertHetEntry(ha->pHetTable, pFileEntry->FileNameHash, (DWORD)(pFileEntry - ha->pFileTable)); - if(nError != ERROR_SUCCESS) - break; - } - } - } - - // Free the old HET table - FreeHetTable(pOldHetTable); - return nError; -} - -// Rebuilds the file table, removing all deleted file entries. -// Used when compacting the archive -int RebuildFileTable(TMPQArchive * ha, DWORD dwNewHashTableSize) -{ - TFileEntry * pFileEntry; - TMPQHash * pHashTableEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - TMPQHash * pOldHashTable = ha->pHashTable; - TMPQHash * pHashTable = NULL; - TMPQHash * pHash; - int nError = ERROR_SUCCESS; - - // The new hash table size must be greater or equal to the current hash table size - assert(dwNewHashTableSize >= ha->pHeader->dwHashTableSize); - assert(dwNewHashTableSize >= ha->dwMaxFileCount); - assert((dwNewHashTableSize & (dwNewHashTableSize - 1)) == 0); - assert(ha->pHashTable != NULL); - - // Reallocate the new file table, if needed - if(dwNewHashTableSize > ha->dwFileTableSize) - { - ha->pFileTable = STORM_REALLOC(TFileEntry, ha->pFileTable, dwNewHashTableSize); - if(ha->pFileTable == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - memset(ha->pFileTable + ha->dwFileTableSize, 0, (dwNewHashTableSize - ha->dwFileTableSize) * sizeof(TFileEntry)); - } - - // Allocate new hash table - if(nError == ERROR_SUCCESS) - { - pHashTable = STORM_ALLOC(TMPQHash, dwNewHashTableSize); - if(pHashTable == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // If both succeeded, we need to rebuild the file table - if(nError == ERROR_SUCCESS) - { - // Make sure that the hash table is properly filled - memset(pHashTable, 0xFF, sizeof(TMPQHash) * dwNewHashTableSize); - ha->pHashTable = pHashTable; - - // Set the new limits to the MPQ archive - ha->pHeader->dwHashTableSize = dwNewHashTableSize; - - // Parse the old hash table and copy all entries to the new table - for(pHash = pOldHashTable; pHash < pHashTableEnd; pHash++) - { - if(IsValidHashEntry(ha, pHash)) - { - pFileEntry = ha->pFileTable + MPQ_BLOCK_INDEX(pHash); - AllocateHashEntry(ha, pFileEntry, pHash->lcLocale); - } - } - - // Increment the max file count for the file - ha->dwFileTableSize = dwNewHashTableSize; - ha->dwMaxFileCount = dwNewHashTableSize; - ha->dwFlags |= MPQ_FLAG_CHANGED; - } - - // Now free the remaining entries - if(pOldHashTable != NULL) - STORM_FREE(pOldHashTable); - return nError; -} - -// Saves MPQ header, hash table, block table and hi-block table. -int SaveMPQTables(TMPQArchive * ha) -{ - TMPQExtHeader * pHetTable = NULL; - TMPQExtHeader * pBetTable = NULL; - TMPQHeader * pHeader = ha->pHeader; - TMPQBlock * pBlockTable = NULL; - TMPQHash * pHashTable = NULL; - ULONGLONG HetTableSize64 = 0; - ULONGLONG BetTableSize64 = 0; - ULONGLONG HashTableSize64 = 0; - ULONGLONG BlockTableSize64 = 0; - ULONGLONG HiBlockTableSize64 = 0; - ULONGLONG TablePos = 0; // A table position, relative to the begin of the MPQ - USHORT * pHiBlockTable = NULL; - DWORD cbTotalSize; - bool bNeedHiBlockTable = false; - int nError = ERROR_SUCCESS; - - // We expect this function to be called only when tables have been changed - assert(ha->dwFlags & MPQ_FLAG_CHANGED); - - // Find the space where the MPQ tables will be saved - TablePos = FindFreeMpqSpace(ha); - - // If the MPQ has HET table, we prepare a ready-to-save version - if(nError == ERROR_SUCCESS && ha->pHetTable != NULL) - { - pHetTable = TranslateHetTable(ha->pHetTable, &HetTableSize64); - if(pHetTable == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // If the MPQ has HET table, we also must create BET table to be saved - if(nError == ERROR_SUCCESS && ha->pHetTable != NULL) - { - pBetTable = TranslateBetTable(ha, &BetTableSize64); - if(pBetTable == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Now create hash table - if(nError == ERROR_SUCCESS && ha->pHashTable != NULL) - { - pHashTable = TranslateHashTable(ha, &HashTableSize64); - if(pHashTable == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Create block table - if(nError == ERROR_SUCCESS && ha->pFileTable != NULL) - { - pBlockTable = TranslateBlockTable(ha, &BlockTableSize64, &bNeedHiBlockTable); - if(pBlockTable == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Create hi-block table, if needed - if(nError == ERROR_SUCCESS && bNeedHiBlockTable) - { - pHiBlockTable = TranslateHiBlockTable(ha, &HiBlockTableSize64); - if(pHiBlockTable == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Write the HET table, if any - if(nError == ERROR_SUCCESS && pHetTable != NULL) - { - pHeader->HetTableSize64 = HetTableSize64; - pHeader->HetTablePos64 = TablePos; - nError = SaveExtTable(ha, pHetTable, TablePos, (DWORD)HetTableSize64, pHeader->MD5_HetTable, MPQ_KEY_HASH_TABLE, false, &cbTotalSize); - TablePos += cbTotalSize; - } - - // Write the BET table, if any - if(nError == ERROR_SUCCESS && pBetTable != NULL) - { - pHeader->BetTableSize64 = BetTableSize64; - pHeader->BetTablePos64 = TablePos; - nError = SaveExtTable(ha, pBetTable, TablePos, (DWORD)BetTableSize64, pHeader->MD5_BetTable, MPQ_KEY_BLOCK_TABLE, false, &cbTotalSize); - TablePos += cbTotalSize; - } - - // Write the hash table, if we have any - if(nError == ERROR_SUCCESS && pHashTable != NULL) - { - pHeader->HashTableSize64 = HashTableSize64; - pHeader->wHashTablePosHi = (USHORT)(TablePos >> 32); - pHeader->dwHashTableSize = (DWORD)(HashTableSize64 / sizeof(TMPQHash)); - pHeader->dwHashTablePos = (DWORD)TablePos; - nError = SaveMpqTable(ha, pHashTable, TablePos, (size_t)HashTableSize64, pHeader->MD5_HashTable, MPQ_KEY_HASH_TABLE, false); - TablePos += HashTableSize64; - } - - // Write the block table, if we have any - if(nError == ERROR_SUCCESS && pBlockTable != NULL) - { - pHeader->BlockTableSize64 = BlockTableSize64; - pHeader->wBlockTablePosHi = (USHORT)(TablePos >> 32); - pHeader->dwBlockTableSize = (DWORD)(BlockTableSize64 / sizeof(TMPQBlock)); - pHeader->dwBlockTablePos = (DWORD)TablePos; - nError = SaveMpqTable(ha, pBlockTable, TablePos, (size_t)BlockTableSize64, pHeader->MD5_BlockTable, MPQ_KEY_BLOCK_TABLE, false); - TablePos += BlockTableSize64; - } - - // Write the hi-block table, if we have any - if(nError == ERROR_SUCCESS && pHiBlockTable != NULL) - { - ULONGLONG ByteOffset = ha->MpqPos + TablePos; - - pHeader->HiBlockTableSize64 = HiBlockTableSize64; - pHeader->HiBlockTablePos64 = TablePos; - BSWAP_ARRAY16_UNSIGNED(pHiBlockTable, HiBlockTableSize64); - - if(!FileStream_Write(ha->pStream, &ByteOffset, pHiBlockTable, (DWORD)HiBlockTableSize64)) - nError = GetLastError(); - TablePos += HiBlockTableSize64; - } - - // Cut the MPQ - if(nError == ERROR_SUCCESS) - { - ULONGLONG FileSize = ha->MpqPos + TablePos; - - if(!FileStream_SetSize(ha->pStream, FileSize)) - nError = GetLastError(); - } - - // Write the MPQ header - if(nError == ERROR_SUCCESS) - { - TMPQHeader SaveMpqHeader; - - // Update the size of the archive - pHeader->ArchiveSize64 = TablePos; - pHeader->dwArchiveSize = (DWORD)TablePos; - - // Update the MD5 of the archive header - CalculateDataBlockHash(pHeader, MPQ_HEADER_SIZE_V4 - MD5_DIGEST_SIZE, pHeader->MD5_MpqHeader); - - // Write the MPQ header to the file - memcpy(&SaveMpqHeader, pHeader, pHeader->dwHeaderSize); - BSWAP_TMPQHEADER(&SaveMpqHeader, MPQ_FORMAT_VERSION_1); - BSWAP_TMPQHEADER(&SaveMpqHeader, MPQ_FORMAT_VERSION_2); - BSWAP_TMPQHEADER(&SaveMpqHeader, MPQ_FORMAT_VERSION_3); - BSWAP_TMPQHEADER(&SaveMpqHeader, MPQ_FORMAT_VERSION_4); - if(!FileStream_Write(ha->pStream, &ha->MpqPos, &SaveMpqHeader, pHeader->dwHeaderSize)) - nError = GetLastError(); - } - - // Clear the changed flag - if(nError == ERROR_SUCCESS) - ha->dwFlags &= ~MPQ_FLAG_CHANGED; - - // Cleanup and exit - if(pHetTable != NULL) - STORM_FREE(pHetTable); - if(pBetTable != NULL) - STORM_FREE(pBetTable); - if(pHashTable != NULL) - STORM_FREE(pHashTable); - if(pBlockTable != NULL) - STORM_FREE(pBlockTable); - if(pHiBlockTable != NULL) - STORM_FREE(pHiBlockTable); - return nError; -} diff --git a/libs/storm-sys/StormLib/src/SBaseSubTypes.cpp b/libs/storm-sys/StormLib/src/SBaseSubTypes.cpp deleted file mode 100644 index 47c205e..0000000 --- a/libs/storm-sys/StormLib/src/SBaseSubTypes.cpp +++ /dev/null @@ -1,618 +0,0 @@ -/*****************************************************************************/ -/* SBaseSubTypes.cpp Copyright (c) Ladislav Zezula 2013 */ -/*---------------------------------------------------------------------------*/ -/* Conversion routines for archive formats that are similar to MPQ format */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 02.11.11 1.00 Lad The first version of SBaseSubTypes.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "StormCommon.h" - -/*****************************************************************************/ -/* */ -/* Support for SQP file format (War of the Immortals) */ -/* */ -/*****************************************************************************/ - -typedef struct _TSQPHeader -{ - // The ID_MPQ ('MPQ\x1A') signature - DWORD dwID; - - // Size of the archive header - DWORD dwHeaderSize; - - // 32-bit size of MPQ archive - DWORD dwArchiveSize; - - // Offset to the beginning of the hash table, relative to the beginning of the archive. - DWORD dwHashTablePos; - - // Offset to the beginning of the block table, relative to the beginning of the archive. - DWORD dwBlockTablePos; - - // Number of entries in the hash table. Must be a power of two, and must be less than 2^16 for - // the original MoPaQ format, or less than 2^20 for the Burning Crusade format. - DWORD dwHashTableSize; - - // Number of entries in the block table - DWORD dwBlockTableSize; - - // Must be zero for SQP files - USHORT wFormatVersion; - - // Power of two exponent specifying the number of 512-byte disk sectors in each file sector - // in the archive. The size of each file sector in the archive is 512 * 2 ^ wSectorSize. - USHORT wSectorSize; - -} TSQPHeader; - -typedef struct _TSQPHash -{ - // Most likely the lcLocale+wPlatform. - DWORD dwAlwaysZero; - - // If the hash table entry is valid, this is the index into the block table of the file. - // Otherwise, one of the following two values: - // - FFFFFFFFh: Hash table entry is empty, and has always been empty. - // Terminates searches for a given file. - // - FFFFFFFEh: Hash table entry is empty, but was valid at some point (a deleted file). - // Does not terminate searches for a given file. - DWORD dwBlockIndex; - - // The hash of the file path, using method A. - DWORD dwName1; - - // The hash of the file path, using method B. - DWORD dwName2; - -} TSQPHash; - -typedef struct _TSQPBlock -{ - // Offset of the beginning of the file, relative to the beginning of the archive. - DWORD dwFilePos; - - // Flags for the file. See MPQ_FILE_XXXX constants - DWORD dwFlags; - - // Compressed file size - DWORD dwCSize; - - // Uncompressed file size - DWORD dwFSize; - -} TSQPBlock; - -//----------------------------------------------------------------------------- -// Functions - SQP file format - -// This function converts SQP file header into MPQ file header -int ConvertSqpHeaderToFormat4( - TMPQArchive * ha, - ULONGLONG FileSize, - DWORD dwFlags) -{ - TSQPHeader * pSqpHeader = (TSQPHeader *)ha->HeaderData; - TMPQHeader Header; - - // SQP files from War of the Immortal use MPQ file format with slightly - // modified structure. These fields have different position: - // - // Offset TMPQHeader TSQPHeader - // ------ ---------- ----------- - // 000C wFormatVersion dwHashTablePos (lo) - // 000E wSectorSize dwHashTablePos (hi) - // 001C dwBlockTableSize (lo) wBlockSize - // 001E dwHashTableSize (hi) wFormatVersion - - // Can't open the archive with certain flags - if(dwFlags & MPQ_OPEN_FORCE_MPQ_V1) - return ERROR_FILE_CORRUPT; - - // The file must not be greater than 4 GB - if((FileSize >> 0x20) != 0) - return ERROR_FILE_CORRUPT; - - // Translate the SQP header into a MPQ header - memset(&Header, 0, sizeof(TMPQHeader)); - Header.dwID = BSWAP_INT32_UNSIGNED(pSqpHeader->dwID); - Header.dwHeaderSize = BSWAP_INT32_UNSIGNED(pSqpHeader->dwHeaderSize); - Header.dwArchiveSize = BSWAP_INT32_UNSIGNED(pSqpHeader->dwArchiveSize); - Header.dwHashTablePos = BSWAP_INT32_UNSIGNED(pSqpHeader->dwHashTablePos); - Header.dwBlockTablePos = BSWAP_INT32_UNSIGNED(pSqpHeader->dwBlockTablePos); - Header.dwHashTableSize = BSWAP_INT32_UNSIGNED(pSqpHeader->dwHashTableSize); - Header.dwBlockTableSize = BSWAP_INT32_UNSIGNED(pSqpHeader->dwBlockTableSize); - Header.wFormatVersion = BSWAP_INT16_UNSIGNED(pSqpHeader->wFormatVersion); - Header.wSectorSize = BSWAP_INT16_UNSIGNED(pSqpHeader->wSectorSize); - - // Verify the SQP header - if(Header.dwID == ID_MPQ && Header.dwHeaderSize == sizeof(TSQPHeader) && Header.dwArchiveSize == FileSize) - { - // Check for fixed values of version and sector size - if(Header.wFormatVersion == MPQ_FORMAT_VERSION_1 && Header.wSectorSize == 3) - { - // Initialize the fields of 3.0 header - Header.ArchiveSize64 = Header.dwArchiveSize; - Header.HashTableSize64 = Header.dwHashTableSize * sizeof(TMPQHash); - Header.BlockTableSize64 = Header.dwBlockTableSize * sizeof(TMPQBlock); - - // Copy the converted MPQ header back - memcpy(ha->HeaderData, &Header, sizeof(TMPQHeader)); - - // Mark this file as SQP file - ha->pfnHashString = HashStringSlash; - ha->dwFlags |= MPQ_FLAG_READ_ONLY; - ha->dwSubType = MPQ_SUBTYPE_SQP; - return ERROR_SUCCESS; - } - } - - return ERROR_FILE_CORRUPT; -} - -void * LoadSqpTable(TMPQArchive * ha, DWORD dwByteOffset, DWORD cbTableSize, DWORD dwKey) -{ - ULONGLONG ByteOffset; - LPBYTE pbSqpTable; - - // Allocate buffer for the table - pbSqpTable = STORM_ALLOC(BYTE, cbTableSize); - if(pbSqpTable != NULL) - { - // Load the table - ByteOffset = ha->MpqPos + dwByteOffset; - if(FileStream_Read(ha->pStream, &ByteOffset, pbSqpTable, cbTableSize)) - { - // Decrypt the SQP table - DecryptMpqBlock(pbSqpTable, cbTableSize, dwKey); - return pbSqpTable; - } - - // Free the table - STORM_FREE(pbSqpTable); - } - - return NULL; -} - -TMPQHash * LoadSqpHashTable(TMPQArchive * ha) -{ - TMPQHeader * pHeader = ha->pHeader; - TSQPHash * pSqpHashTable; - TSQPHash * pSqpHashEnd; - TSQPHash * pSqpHash; - TMPQHash * pMpqHash; - int nError = ERROR_SUCCESS; - - // Load the hash table - pSqpHashTable = (TSQPHash *)LoadSqpTable(ha, pHeader->dwHashTablePos, pHeader->dwHashTableSize * sizeof(TSQPHash), MPQ_KEY_HASH_TABLE); - if(pSqpHashTable != NULL) - { - // Parse the entire hash table and convert it to MPQ hash table - pSqpHashEnd = pSqpHashTable + pHeader->dwHashTableSize; - pMpqHash = (TMPQHash *)pSqpHashTable; - for(pSqpHash = pSqpHashTable; pSqpHash < pSqpHashEnd; pSqpHash++, pMpqHash++) - { - // Ignore free entries - if(pSqpHash->dwBlockIndex != HASH_ENTRY_FREE) - { - // Check block index against the size of the block table - if(pHeader->dwBlockTableSize <= MPQ_BLOCK_INDEX(pSqpHash) && pSqpHash->dwBlockIndex < HASH_ENTRY_DELETED) - nError = ERROR_FILE_CORRUPT; - - // We do not support nonzero locale and platform ID - if(pSqpHash->dwAlwaysZero != 0 && pSqpHash->dwAlwaysZero != HASH_ENTRY_FREE) - nError = ERROR_FILE_CORRUPT; - - // Store the file name hash - pMpqHash->dwName1 = pSqpHash->dwName1; - pMpqHash->dwName2 = pSqpHash->dwName2; - - // Store the rest. Note that this must be done last, - // because block index corresponds to pMpqHash->dwName2 - pMpqHash->dwBlockIndex = MPQ_BLOCK_INDEX(pSqpHash); - pMpqHash->Platform = 0; - pMpqHash->lcLocale = 0; - } - } - - // If an error occured, we need to free the hash table - if(nError != ERROR_SUCCESS) - { - STORM_FREE(pSqpHashTable); - pSqpHashTable = NULL; - } - } - - // Return the converted hash table (or NULL on failure) - return (TMPQHash *)pSqpHashTable; -} - -// Loads the SQP Block table and converts it to a MPQ block table -TMPQBlock * LoadSqpBlockTable(TMPQArchive * ha) -{ - TMPQHeader * pHeader = ha->pHeader; - TSQPBlock * pSqpBlockTable; - TSQPBlock * pSqpBlockEnd; - TSQPBlock * pSqpBlock; - TMPQBlock * pMpqBlock; - DWORD dwFlags; - int nError = ERROR_SUCCESS; - - // Load the hash table - pSqpBlockTable = (TSQPBlock *)LoadSqpTable(ha, pHeader->dwBlockTablePos, pHeader->dwBlockTableSize * sizeof(TSQPBlock), MPQ_KEY_BLOCK_TABLE); - if(pSqpBlockTable != NULL) - { - // Parse the entire hash table and convert it to MPQ hash table - pSqpBlockEnd = pSqpBlockTable + pHeader->dwBlockTableSize; - pMpqBlock = (TMPQBlock *)pSqpBlockTable; - for(pSqpBlock = pSqpBlockTable; pSqpBlock < pSqpBlockEnd; pSqpBlock++, pMpqBlock++) - { - // Check for valid flags - if(pSqpBlock->dwFlags & ~MPQ_FILE_VALID_FLAGS) - nError = ERROR_FILE_CORRUPT; - - // Convert SQP block table entry to MPQ block table entry - dwFlags = pSqpBlock->dwFlags; - pMpqBlock->dwCSize = pSqpBlock->dwCSize; - pMpqBlock->dwFSize = pSqpBlock->dwFSize; - pMpqBlock->dwFlags = dwFlags; - } - - // If an error occured, we need to free the hash table - if(nError != ERROR_SUCCESS) - { - STORM_FREE(pSqpBlockTable); - pSqpBlockTable = NULL; - } - } - - // Return the converted hash table (or NULL on failure) - return (TMPQBlock *)pSqpBlockTable; -} - -/*****************************************************************************/ -/* */ -/* Support for MPK file format (Longwu Online) */ -/* */ -/*****************************************************************************/ - -#define MPK_FILE_UNKNOWN_0001 0x00000001 // Seems to be always present -#define MPK_FILE_UNKNOWN_0010 0x00000010 // Seems to be always present -#define MPK_FILE_COMPRESSED 0x00000100 // Indicates a compressed file -#define MPK_FILE_UNKNOWN_2000 0x00002000 // Seems to be always present -#define MPK_FILE_EXISTS 0x01000000 // Seems to be always present - -typedef struct _TMPKHeader -{ - // The ID_MPK ('MPK\x1A') signature - DWORD dwID; - - // Contains '2000' - DWORD dwVersion; - - // 32-bit size of the archive - DWORD dwArchiveSize; - - // Size of the archive header - DWORD dwHeaderSize; - - DWORD dwHashTablePos; - DWORD dwHashTableSize; - DWORD dwBlockTablePos; - DWORD dwBlockTableSize; - DWORD dwUnknownPos; - DWORD dwUnknownSize; -} TMPKHeader; - - -typedef struct _TMPKHash -{ - // The hash of the file path, using method A. - DWORD dwName1; - - // The hash of the file path, using method B. - DWORD dwName2; - - // The hash of the file path, using method C. - DWORD dwName3; - - // If the hash table entry is valid, this is the index into the block table of the file. - // Otherwise, one of the following two values: - // - FFFFFFFFh: Hash table entry is empty, and has always been empty. - // Terminates searches for a given file. - // - FFFFFFFEh: Hash table entry is empty, but was valid at some point (a deleted file). - // Does not terminate searches for a given file. - DWORD dwBlockIndex; - -} TMPKHash; - -typedef struct _TMPKBlock -{ - DWORD dwFlags; // 0x1121 - Compressed , 0x1120 - Not compressed - DWORD dwFilePos; // Offset of the beginning of the file, relative to the beginning of the archive. - DWORD dwFSize; // Uncompressed file size - DWORD dwCSize; // Compressed file size - DWORD dwUnknown; // 0x86364E6D -} TMPKBlock; - -//----------------------------------------------------------------------------- -// Local variables - MPK file format - -static const unsigned char MpkDecryptionKey[512] = -{ - 0x60, 0x20, 0x29, 0xE1, 0x01, 0xCE, 0xAA, 0xFE, 0xA3, 0xAB, 0x8E, 0x30, 0xAF, 0x02, 0xD1, 0x7D, - 0x41, 0x24, 0x06, 0xBD, 0xAE, 0xBE, 0x43, 0xC3, 0xBA, 0xB7, 0x08, 0x13, 0x51, 0xCF, 0xF8, 0xF7, - 0x25, 0x42, 0xA5, 0x4A, 0xDA, 0x0F, 0x52, 0x1C, 0x90, 0x3B, 0x63, 0x49, 0x36, 0xF6, 0xDD, 0x1B, - 0xEA, 0x58, 0xD4, 0x40, 0x70, 0x61, 0x55, 0x09, 0xCD, 0x0B, 0xA2, 0x4B, 0x68, 0x2C, 0x8A, 0xF1, - 0x3C, 0x3A, 0x65, 0xBB, 0xA1, 0xA8, 0x23, 0x97, 0xFD, 0x15, 0x00, 0x94, 0x88, 0x33, 0x59, 0xE9, - 0xFB, 0x69, 0x21, 0xEF, 0x85, 0x5B, 0x57, 0x6C, 0xFA, 0xB5, 0xEE, 0xB8, 0x71, 0xDC, 0xB1, 0x38, - 0x0C, 0x0A, 0x5C, 0x56, 0xC9, 0xB4, 0x84, 0x17, 0x1E, 0xE5, 0xD3, 0x5A, 0xCC, 0xFC, 0x11, 0x86, - 0x7F, 0x45, 0x4F, 0x54, 0xC8, 0x8D, 0x73, 0x89, 0x79, 0x5D, 0xB3, 0xBF, 0xB9, 0xE3, 0x93, 0xE4, - 0x6F, 0x35, 0x2D, 0x46, 0xF2, 0x76, 0xC5, 0x7E, 0xE2, 0xA4, 0xE6, 0xD9, 0x6E, 0x48, 0x34, 0x2B, - 0xC6, 0x5F, 0xBC, 0xA0, 0x6D, 0x0D, 0x47, 0x6B, 0x95, 0x96, 0x92, 0x91, 0xB2, 0x27, 0xEB, 0x9E, - 0xEC, 0x8F, 0xDF, 0x9C, 0x74, 0x99, 0x64, 0xF5, 0xFF, 0x28, 0xB6, 0x37, 0xF3, 0x7C, 0x81, 0x03, - 0x44, 0x62, 0x1F, 0xDB, 0x04, 0x7B, 0xB0, 0x9B, 0x31, 0xA7, 0xDE, 0x78, 0x9F, 0xAD, 0x0E, 0x3F, - 0x3E, 0x4D, 0xC7, 0xD7, 0x39, 0x19, 0x5E, 0xC2, 0xD0, 0xAC, 0xE8, 0x1A, 0x87, 0x8B, 0x07, 0x05, - 0x22, 0xED, 0x72, 0x2E, 0x1D, 0xC1, 0xA9, 0xD6, 0xE0, 0x83, 0xD5, 0xD8, 0xCB, 0x80, 0xF0, 0x66, - 0x7A, 0x9D, 0x50, 0xF9, 0x10, 0x4E, 0x16, 0x14, 0x77, 0x75, 0x6A, 0x67, 0xD2, 0xC0, 0xA6, 0xC4, - 0x53, 0x8C, 0x32, 0xCA, 0x82, 0x2A, 0x18, 0x9A, 0xF4, 0x4C, 0x3D, 0x26, 0x12, 0xE7, 0x98, 0x2F, - 0x4A, 0x04, 0x0D, 0xAF, 0xB4, 0xCF, 0x12, 0xCE, 0x1A, 0x37, 0x61, 0x39, 0x60, 0x95, 0xBE, 0x25, - 0xE4, 0x6E, 0xFC, 0x1B, 0xE7, 0x49, 0xE6, 0x67, 0xF6, 0xC5, 0xCB, 0x2F, 0x27, 0xD4, 0x68, 0xB2, - 0x01, 0x52, 0xD0, 0x46, 0x11, 0x20, 0xFB, 0x9D, 0xA9, 0x02, 0xF5, 0x8F, 0x3D, 0x82, 0xD3, 0xFF, - 0x0B, 0xB8, 0xF2, 0x4D, 0x8E, 0x81, 0x2C, 0xAB, 0x5F, 0xC4, 0x41, 0x29, 0x40, 0xFA, 0xC0, 0xBF, - 0x33, 0x10, 0x21, 0x16, 0xB0, 0x71, 0x83, 0x96, 0x8D, 0x2B, 0x23, 0x3B, 0xF9, 0xC1, 0xE5, 0x72, - 0xE2, 0x1C, 0x26, 0xF0, 0x73, 0x36, 0x63, 0x56, 0x31, 0x4E, 0x6B, 0x55, 0x62, 0x79, 0xC6, 0x91, - 0x00, 0x35, 0xB1, 0x2A, 0xA6, 0x42, 0xDF, 0xEB, 0x3C, 0x51, 0xEA, 0x97, 0x57, 0x94, 0x8C, 0x80, - 0x34, 0x5C, 0xD2, 0x76, 0xA4, 0xE9, 0x85, 0xE8, 0xBB, 0x78, 0xE0, 0xB5, 0xAD, 0x0F, 0x87, 0x70, - 0xDD, 0xAE, 0xF4, 0xD9, 0x66, 0x54, 0x6F, 0xCC, 0x4C, 0x77, 0x3E, 0xCD, 0xF1, 0x75, 0x0A, 0xA1, - 0x28, 0x9B, 0x9A, 0x7E, 0x4B, 0x98, 0x99, 0x47, 0xFE, 0xA5, 0xF7, 0xB7, 0xA3, 0xE1, 0x9F, 0xBC, - 0x93, 0x44, 0x3A, 0x08, 0x89, 0x22, 0xEE, 0xB9, 0x45, 0xD6, 0x06, 0x09, 0xC9, 0xBD, 0x14, 0x0C, - 0xB6, 0x5E, 0x9C, 0x7A, 0x65, 0x59, 0xAA, 0x19, 0x5B, 0x7C, 0x18, 0x43, 0x92, 0x13, 0x15, 0x7B, - 0xED, 0xD5, 0xC7, 0x17, 0xEF, 0x86, 0x90, 0xC2, 0x74, 0x64, 0xF3, 0xDC, 0x6C, 0x38, 0x05, 0x1D, - 0xC8, 0x0E, 0xEC, 0x6A, 0x32, 0xDA, 0xD7, 0xC3, 0xDB, 0x8B, 0x24, 0xB3, 0x5D, 0x2E, 0xBA, 0xA2, - 0xD8, 0x03, 0x88, 0x7D, 0x7F, 0x69, 0x8A, 0xFD, 0xCA, 0x4F, 0x30, 0x9E, 0xA0, 0xD1, 0x5A, 0x53, - 0xDE, 0x3F, 0x84, 0xAC, 0xF8, 0xA7, 0x2D, 0x1F, 0x1E, 0xE3, 0x58, 0x50, 0x6D, 0x48, 0x07, 0xA8 -}; - -//----------------------------------------------------------------------------- -// Functions - MPK file format - -// This function converts MPK file header into MPQ file header -int ConvertMpkHeaderToFormat4( - TMPQArchive * ha, - ULONGLONG FileSize, - DWORD dwFlags) -{ - TMPKHeader * pMpkHeader = (TMPKHeader *)ha->HeaderData; - TMPQHeader Header; - - // Can't open the archive with certain flags - if(dwFlags & MPQ_OPEN_FORCE_MPQ_V1) - return ERROR_FILE_CORRUPT; - - // Translate the MPK header into a MPQ header - // Note: Hash table size and block table size are in bytes, not in entries - memset(&Header, 0, sizeof(TMPQHeader)); - Header.dwID = BSWAP_INT32_UNSIGNED(pMpkHeader->dwID); - Header.dwArchiveSize = BSWAP_INT32_UNSIGNED(pMpkHeader->dwArchiveSize); - Header.dwHeaderSize = BSWAP_INT32_UNSIGNED(pMpkHeader->dwHeaderSize); - Header.dwHashTablePos = BSWAP_INT32_UNSIGNED(pMpkHeader->dwHashTablePos); - Header.dwHashTableSize = BSWAP_INT32_UNSIGNED(pMpkHeader->dwHashTableSize) / sizeof(TMPKHash); - Header.dwBlockTablePos = BSWAP_INT32_UNSIGNED(pMpkHeader->dwBlockTablePos); - Header.dwBlockTableSize = BSWAP_INT32_UNSIGNED(pMpkHeader->dwBlockTableSize) / sizeof(TMPKBlock); -// Header.dwUnknownPos = BSWAP_INT32_UNSIGNED(pMpkHeader->dwUnknownPos); -// Header.dwUnknownSize = BSWAP_INT32_UNSIGNED(pMpkHeader->dwUnknownSize); - assert(Header.dwHeaderSize == sizeof(TMPKHeader)); - - // Verify the MPK header - if(Header.dwID == ID_MPK && Header.dwHeaderSize == sizeof(TMPKHeader) && Header.dwArchiveSize == (DWORD)FileSize) - { - // The header ID must be ID_MPQ - Header.dwID = ID_MPQ; - Header.wFormatVersion = MPQ_FORMAT_VERSION_1; - Header.wSectorSize = 3; - - // Initialize the fields of 3.0 header - Header.ArchiveSize64 = Header.dwArchiveSize; - Header.HashTableSize64 = Header.dwHashTableSize * sizeof(TMPQHash); - Header.BlockTableSize64 = Header.dwBlockTableSize * sizeof(TMPQBlock); - - // Copy the converted MPQ header back - memcpy(ha->HeaderData, &Header, sizeof(TMPQHeader)); - - // Mark this file as MPK file - ha->pfnHashString = HashStringLower; - ha->dwFlags |= MPQ_FLAG_READ_ONLY; - ha->dwSubType = MPQ_SUBTYPE_MPK; - return ERROR_SUCCESS; - } - return ERROR_FILE_CORRUPT; -} - -// Attempts to search a free hash entry in the hash table being converted. -// The created hash table must always be of nonzero size, -// should have no duplicated items and no deleted entries -TMPQHash * FindFreeHashEntry(TMPQHash * pHashTable, DWORD dwHashTableSize, DWORD dwStartIndex) -{ - TMPQHash * pHash; - DWORD dwIndex; - - // Set the initial index - dwStartIndex = dwIndex = (dwStartIndex & (dwHashTableSize - 1)); - assert(dwHashTableSize != 0); - - // Search the hash table and return the found entries in the following priority: - for(;;) - { - // We are not expecting to find matching entry in the hash table being built - // We are not expecting to find deleted entry either - pHash = pHashTable + dwIndex; - - // If we found a free entry, we need to stop searching - if(pHash->dwBlockIndex == HASH_ENTRY_FREE) - return pHash; - - // Move to the next hash entry. - // If we reached the starting entry, it's failure. - dwIndex = (dwIndex + 1) & (dwHashTableSize - 1); - if(dwIndex == dwStartIndex) - break; - } - - // We haven't found anything - assert(false); - return NULL; -} - -void DecryptMpkTable(void * pvMpkTable, size_t cbSize) -{ - LPBYTE pbMpkTable = (LPBYTE)pvMpkTable; - - for(size_t i = 0; i < cbSize; i++) - pbMpkTable[i] = MpkDecryptionKey[pbMpkTable[i]]; -} - -void * LoadMpkTable(TMPQArchive * ha, DWORD dwByteOffset, DWORD cbTableSize) -{ - ULONGLONG ByteOffset; - LPBYTE pbMpkTable = NULL; - - // Allocate space for the table - pbMpkTable = STORM_ALLOC(BYTE, cbTableSize); - if(pbMpkTable != NULL) - { - // Load and the MPK hash table - ByteOffset = ha->MpqPos + dwByteOffset; - if(FileStream_Read(ha->pStream, &ByteOffset, pbMpkTable, cbTableSize)) - { - // Decrypt the table - DecryptMpkTable(pbMpkTable, cbTableSize); - return pbMpkTable; - } - - // Free the MPK table - STORM_FREE(pbMpkTable); - pbMpkTable = NULL; - } - - // Return the table - return pbMpkTable; -} - -TMPQHash * LoadMpkHashTable(TMPQArchive * ha) -{ - TMPQHeader * pHeader = ha->pHeader; - TMPQHash * pHashTable = NULL; - TMPKHash * pMpkHash; - TMPQHash * pHash = NULL; - DWORD dwHashTableSize = pHeader->dwHashTableSize; - - // MPKs use different hash table searching. - // Instead of using MPQ_HASH_TABLE_INDEX hash as index, - // they store the value directly in the hash table. - // Also for faster searching, the hash table is sorted ascending by the value - - // Load and decrypt the MPK hash table. - pMpkHash = (TMPKHash *)LoadMpkTable(ha, pHeader->dwHashTablePos, pHeader->dwHashTableSize * sizeof(TMPKHash)); - if(pMpkHash != NULL) - { - // Calculate the hash table size as if it was real MPQ hash table - pHeader->dwHashTableSize = GetNearestPowerOfTwo(pHeader->dwHashTableSize); - pHeader->HashTableSize64 = pHeader->dwHashTableSize * sizeof(TMPQHash); - - // Now allocate table that will serve like a true MPQ hash table, - // so we translate the MPK hash table to MPQ hash table - pHashTable = STORM_ALLOC(TMPQHash, pHeader->dwHashTableSize); - if(pHashTable != NULL) - { - // Set the entire hash table to free - memset(pHashTable, 0xFF, (size_t)pHeader->HashTableSize64); - - // Copy the MPK hash table into MPQ hash table - for(DWORD i = 0; i < dwHashTableSize; i++) - { - // Finds the free hash entry in the hash table - // We don't expect any errors here, because we are putting files to empty hash table - pHash = FindFreeHashEntry(pHashTable, pHeader->dwHashTableSize, pMpkHash[i].dwName1); - assert(pHash->dwBlockIndex == HASH_ENTRY_FREE); - - // Copy the MPK hash entry to the hash table - pHash->dwBlockIndex = pMpkHash[i].dwBlockIndex; - pHash->Platform = 0; - pHash->lcLocale = 0; - pHash->dwName1 = pMpkHash[i].dwName2; - pHash->dwName2 = pMpkHash[i].dwName3; - } - } - - // Free the temporary hash table - STORM_FREE(pMpkHash); - } - - return pHashTable; -} - -static DWORD ConvertMpkFlagsToMpqFlags(DWORD dwMpkFlags) -{ - DWORD dwMpqFlags = MPQ_FILE_EXISTS; - - // Check for flags that are always present - assert((dwMpkFlags & MPK_FILE_UNKNOWN_0001) != 0); - assert((dwMpkFlags & MPK_FILE_UNKNOWN_0010) != 0); - assert((dwMpkFlags & MPK_FILE_UNKNOWN_2000) != 0); - assert((dwMpkFlags & MPK_FILE_EXISTS) != 0); - - // Append the compressed flag - dwMpqFlags |= (dwMpkFlags & MPK_FILE_COMPRESSED) ? MPQ_FILE_COMPRESS : 0; - - // All files in the MPQ seem to be single unit files - dwMpqFlags |= MPQ_FILE_ENCRYPTED | MPQ_FILE_SINGLE_UNIT; - - return dwMpqFlags; -} - -TMPQBlock * LoadMpkBlockTable(TMPQArchive * ha) -{ - TMPQHeader * pHeader = ha->pHeader; - TMPKBlock * pMpkBlockTable; - TMPKBlock * pMpkBlockEnd; - TMPQBlock * pBlockTable = NULL; - TMPKBlock * pMpkBlock; - TMPQBlock * pMpqBlock; - - // Load and decrypt the MPK block table - pMpkBlockTable = pMpkBlock = (TMPKBlock *)LoadMpkTable(ha, pHeader->dwBlockTablePos, pHeader->dwBlockTableSize * sizeof(TMPKBlock)); - if(pMpkBlockTable != NULL) - { - // Allocate buffer for MPQ-like block table - pBlockTable = pMpqBlock = STORM_ALLOC(TMPQBlock, pHeader->dwBlockTableSize); - if(pBlockTable != NULL) - { - // Convert the MPK block table to MPQ block table - pMpkBlockEnd = pMpkBlockTable + pHeader->dwBlockTableSize; - while(pMpkBlock < pMpkBlockEnd) - { - // Translate the MPK block table entry to MPQ block table entry - pMpqBlock->dwFilePos = pMpkBlock->dwFilePos; - pMpqBlock->dwCSize = pMpkBlock->dwCSize; - pMpqBlock->dwFSize = pMpkBlock->dwFSize; - pMpqBlock->dwFlags = ConvertMpkFlagsToMpqFlags(pMpkBlock->dwFlags); - - // Move both - pMpkBlock++; - pMpqBlock++; - } - } - - // Free the MPK block table - STORM_FREE(pMpkBlockTable); - } - - return pBlockTable; -} diff --git a/libs/storm-sys/StormLib/src/SCompression.cpp b/libs/storm-sys/StormLib/src/SCompression.cpp deleted file mode 100644 index d706a6f..0000000 --- a/libs/storm-sys/StormLib/src/SCompression.cpp +++ /dev/null @@ -1,1145 +0,0 @@ -/*****************************************************************************/ -/* SCompression.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* This module serves as a bridge between StormLib code and (de)compression */ -/* functions. All (de)compression calls go (and should only go) through this */ -/* module. No system headers should be included in this module to prevent */ -/* compile-time problems. */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 01.04.03 1.00 Lad The first version of SCompression.cpp */ -/* 19.11.03 1.01 Dan Big endian handling */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "StormCommon.h" - -//----------------------------------------------------------------------------- -// Local structures - -// Information about the input and output buffers for pklib -typedef struct -{ - unsigned char * pbInBuff; // Pointer to input data buffer - unsigned char * pbInBuffEnd; // End of the input buffer - unsigned char * pbOutBuff; // Pointer to output data buffer - unsigned char * pbOutBuffEnd; // Pointer to output data buffer -} TDataInfo; - -// Prototype of the compression function -// Function doesn't return an error. A success means that the size of compressed buffer -// is lower than size of uncompressed buffer. -typedef void (*COMPRESS)( - void * pvOutBuffer, // [out] Pointer to the buffer where the compressed data will be stored - int * pcbOutBuffer, // [in] Pointer to length of the buffer pointed by pvOutBuffer - void * pvInBuffer, // [in] Pointer to the buffer with data to compress - int cbInBuffer, // [in] Length of the buffer pointer by pvInBuffer - int * pCmpType, // [in] Compression-method specific value. ADPCM Setups this for the following Huffman compression - int nCmpLevel); // [in] Compression specific value. ADPCM uses this. Should be set to zero. - -// Prototype of the decompression function -// Returns 1 if success, 0 if failure -typedef int (*DECOMPRESS)( - void * pvOutBuffer, // [out] Pointer to the buffer where to store decompressed data - int * pcbOutBuffer, // [in] Pointer to total size of the buffer pointed by pvOutBuffer - // [out] Contains length of the decompressed data - void * pvInBuffer, // [in] Pointer to data to be decompressed - int cbInBuffer); // [in] Length of the data to be decompressed - -// Table of compression functions -typedef struct -{ - unsigned long uMask; // Compression mask - COMPRESS Compress; // Compression function -} TCompressTable; - -// Table of decompression functions -typedef struct -{ - unsigned long uMask; // Decompression bit - DECOMPRESS Decompress; // Decompression function -} TDecompressTable; - - -/*****************************************************************************/ -/* */ -/* Support for Huffman compression (0x01) */ -/* */ -/*****************************************************************************/ - -void Compress_huff(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, int * pCmpType, int nCmpLevel) -{ - THuffmannTree ht(true); - TOutputStream os(pvOutBuffer, *pcbOutBuffer); - - STORMLIB_UNUSED(nCmpLevel); - *pcbOutBuffer = ht.Compress(&os, pvInBuffer, cbInBuffer, *pCmpType); -} - -int Decompress_huff(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) -{ - THuffmannTree ht(false); - TInputStream is(pvInBuffer, cbInBuffer); - - *pcbOutBuffer = ht.Decompress(pvOutBuffer, *pcbOutBuffer, &is); - return (*pcbOutBuffer == 0) ? 0 : 1; -} - -/******************************************************************************/ -/* */ -/* Support for ZLIB compression (0x02) */ -/* */ -/******************************************************************************/ - -void Compress_ZLIB(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, int * pCmpType, int nCmpLevel) -{ - z_stream z; // Stream information for zlib - int windowBits; - int nResult; - - // Keep compilers happy - STORMLIB_UNUSED(pCmpType); - STORMLIB_UNUSED(nCmpLevel); - - // Fill the stream structure for zlib - z.next_in = (Bytef *)pvInBuffer; - z.avail_in = (uInt)cbInBuffer; - z.total_in = cbInBuffer; - z.next_out = (Bytef *)pvOutBuffer; - z.avail_out = *pcbOutBuffer; - z.total_out = 0; - z.zalloc = NULL; - z.zfree = NULL; - - // Determine the proper window bits (WoW.exe build 12694) - if(cbInBuffer <= 0x100) - windowBits = 8; - else if(cbInBuffer <= 0x200) - windowBits = 9; - else if(cbInBuffer <= 0x400) - windowBits = 10; - else if(cbInBuffer <= 0x800) - windowBits = 11; - else if(cbInBuffer <= 0x1000) - windowBits = 12; - else if(cbInBuffer <= 0x2000) - windowBits = 13; - else if(cbInBuffer <= 0x4000) - windowBits = 14; - else - windowBits = 15; - - // Initialize the compression. - // Storm.dll uses zlib version 1.1.3 - // Wow.exe uses zlib version 1.2.3 - nResult = deflateInit2(&z, - 6, // Compression level used by WoW MPQs - Z_DEFLATED, - windowBits, - 8, - Z_DEFAULT_STRATEGY); - if(nResult == Z_OK) - { - // Call zlib to compress the data - nResult = deflate(&z, Z_FINISH); - - if(nResult == Z_OK || nResult == Z_STREAM_END) - *pcbOutBuffer = z.total_out; - - deflateEnd(&z); - } -} - -int Decompress_ZLIB(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) -{ - z_stream z; // Stream information for zlib - int nResult; - - // Fill the stream structure for zlib - z.next_in = (Bytef *)pvInBuffer; - z.avail_in = (uInt)cbInBuffer; - z.total_in = cbInBuffer; - z.next_out = (Bytef *)pvOutBuffer; - z.avail_out = *pcbOutBuffer; - z.total_out = 0; - z.zalloc = NULL; - z.zfree = NULL; - - // Initialize the decompression structure. Storm.dll uses zlib version 1.1.3 - if((nResult = inflateInit(&z)) == 0) - { - // Call zlib to decompress the data - nResult = inflate(&z, Z_FINISH); - *pcbOutBuffer = z.total_out; - inflateEnd(&z); - } - return nResult; -} - -/******************************************************************************/ -/* */ -/* Support functions for PKWARE Data Compression Library compression (0x08) */ -/* */ -/******************************************************************************/ - -// Function loads data from the input buffer. Used by Pklib's "implode" -// and "explode" function as user-defined callback -// Returns number of bytes loaded -// -// char * buf - Pointer to a buffer where to store loaded data -// unsigned int * size - Max. number of bytes to read -// void * param - Custom pointer, parameter of implode/explode - -static unsigned int ReadInputData(char * buf, unsigned int * size, void * param) -{ - TDataInfo * pInfo = (TDataInfo *)param; - unsigned int nMaxAvail = (unsigned int)(pInfo->pbInBuffEnd - pInfo->pbInBuff); - unsigned int nToRead = *size; - - // Check the case when not enough data available - if(nToRead > nMaxAvail) - nToRead = nMaxAvail; - - // Load data and increment offsets - memcpy(buf, pInfo->pbInBuff, nToRead); - pInfo->pbInBuff += nToRead; - assert(pInfo->pbInBuff <= pInfo->pbInBuffEnd); - return nToRead; -} - -// Function for store output data. Used by Pklib's "implode" and "explode" -// as user-defined callback -// -// char * buf - Pointer to data to be written -// unsigned int * size - Number of bytes to write -// void * param - Custom pointer, parameter of implode/explode - -static void WriteOutputData(char * buf, unsigned int * size, void * param) -{ - TDataInfo * pInfo = (TDataInfo *)param; - unsigned int nMaxWrite = (unsigned int)(pInfo->pbOutBuffEnd - pInfo->pbOutBuff); - unsigned int nToWrite = *size; - - // Check the case when not enough space in the output buffer - if(nToWrite > nMaxWrite) - nToWrite = nMaxWrite; - - // Write output data and increments offsets - memcpy(pInfo->pbOutBuff, buf, nToWrite); - pInfo->pbOutBuff += nToWrite; - assert(pInfo->pbOutBuff <= pInfo->pbOutBuffEnd); -} - -static void Compress_PKLIB(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, int * pCmpType, int nCmpLevel) -{ - TDataInfo Info; // Data information - char * work_buf = STORM_ALLOC(char, CMP_BUFFER_SIZE);// Pklib's work buffer - unsigned int dict_size; // Dictionary size - unsigned int ctype = CMP_BINARY; // Compression type - - // Keep compilers happy - STORMLIB_UNUSED(pCmpType); - STORMLIB_UNUSED(nCmpLevel); - - // Handle no-memory condition - if(work_buf != NULL) - { - // Fill data information structure - memset(work_buf, 0, CMP_BUFFER_SIZE); - Info.pbInBuff = (unsigned char *)pvInBuffer; - Info.pbInBuffEnd = (unsigned char *)pvInBuffer + cbInBuffer; - Info.pbOutBuff = (unsigned char *)pvOutBuffer; - Info.pbOutBuffEnd = (unsigned char *)pvOutBuffer + *pcbOutBuffer; - - // - // Set the dictionary size - // - // Diablo I uses fixed dictionary size of CMP_IMPLODE_DICT_SIZE3 - // Starcraft I uses the variable dictionary size based on algorithm below - // - - if (cbInBuffer < 0x600) - dict_size = CMP_IMPLODE_DICT_SIZE1; - else if(0x600 <= cbInBuffer && cbInBuffer < 0xC00) - dict_size = CMP_IMPLODE_DICT_SIZE2; - else - dict_size = CMP_IMPLODE_DICT_SIZE3; - - // Do the compression - if(implode(ReadInputData, WriteOutputData, work_buf, &Info, &ctype, &dict_size) == CMP_NO_ERROR) - *pcbOutBuffer = (int)(Info.pbOutBuff - (unsigned char *)pvOutBuffer); - - STORM_FREE(work_buf); - } -} - -static int Decompress_PKLIB(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) -{ - TDataInfo Info; // Data information - char * work_buf = STORM_ALLOC(char, EXP_BUFFER_SIZE);// Pklib's work buffer - - // Handle no-memory condition - if(work_buf == NULL) - return 0; - - // Fill data information structure - memset(work_buf, 0, EXP_BUFFER_SIZE); - Info.pbInBuff = (unsigned char *)pvInBuffer; - Info.pbInBuffEnd = (unsigned char *)pvInBuffer + cbInBuffer; - Info.pbOutBuff = (unsigned char *)pvOutBuffer; - Info.pbOutBuffEnd = (unsigned char *)pvOutBuffer + *pcbOutBuffer; - - // Do the decompression - explode(ReadInputData, WriteOutputData, work_buf, &Info); - - // If PKLIB is unable to decompress the data, return 0; - if(Info.pbOutBuff == pvOutBuffer) - { - STORM_FREE(work_buf); - return 0; - } - - // Give away the number of decompressed bytes - *pcbOutBuffer = (int)(Info.pbOutBuff - (unsigned char *)pvOutBuffer); - STORM_FREE(work_buf); - return 1; -} - -/******************************************************************************/ -/* */ -/* Support for Bzip2 compression (0x10) */ -/* */ -/******************************************************************************/ - -static void Compress_BZIP2(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, int * pCmpType, int nCmpLevel) -{ - bz_stream strm; - int blockSize100k = 9; - int workFactor = 30; - int bzError; - - // Keep compilers happy - STORMLIB_UNUSED(pCmpType); - STORMLIB_UNUSED(nCmpLevel); - - // Initialize the BZIP2 compression - strm.bzalloc = NULL; - strm.bzfree = NULL; - strm.opaque = NULL; - - // Blizzard uses 9 as blockSize100k, (0x30 as workFactor) - // Last checked on Starcraft II - if(BZ2_bzCompressInit(&strm, blockSize100k, 0, workFactor) == BZ_OK) - { - strm.next_in = (char *)pvInBuffer; - strm.avail_in = cbInBuffer; - strm.next_out = (char *)pvOutBuffer; - strm.avail_out = *pcbOutBuffer; - - // Perform the compression - for(;;) - { - bzError = BZ2_bzCompress(&strm, (strm.avail_in != 0) ? BZ_RUN : BZ_FINISH); - if(bzError == BZ_STREAM_END || bzError < 0) - break; - } - - // Put the stream into idle state - BZ2_bzCompressEnd(&strm); - - if(bzError > 0) - *pcbOutBuffer = strm.total_out_lo32; - } -} - -static int Decompress_BZIP2(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) -{ - bz_stream strm; - int nResult = BZ_OK; - - // Initialize the BZIP2 decompression - strm.bzalloc = NULL; - strm.bzfree = NULL; - strm.opaque = NULL; - - // Initialize decompression - if(BZ2_bzDecompressInit(&strm, 0, 0) == BZ_OK) - { - strm.next_in = (char *)pvInBuffer; - strm.avail_in = cbInBuffer; - strm.next_out = (char *)pvOutBuffer; - strm.avail_out = *pcbOutBuffer; - - // Perform the decompression - while(nResult != BZ_STREAM_END) - { - nResult = BZ2_bzDecompress(&strm); - - // If any error there, break the loop - if(nResult < BZ_OK) - break; - } - - // Put the stream into idle state - BZ2_bzDecompressEnd(&strm); - - // If all succeeded, set the number of output bytes - if(nResult >= BZ_OK) - { - *pcbOutBuffer = strm.total_out_lo32; - return 1; - } - } - - // Something failed, so set number of output bytes to zero - *pcbOutBuffer = 0; - return 1; -} - -/******************************************************************************/ -/* */ -/* Support functions for LZMA compression (0x12) */ -/* */ -/******************************************************************************/ - -#define LZMA_HEADER_SIZE (1 + LZMA_PROPS_SIZE + 8) - -static SRes LZMA_Callback_Progress(void * /* p */, UInt64 /* inSize */, UInt64 /* outSize */) -{ - return SZ_OK; -} - -static void * LZMA_Callback_Alloc(void *p, size_t size) -{ - p = p; - return STORM_ALLOC(BYTE, size); -} - -/* address can be 0 */ -static void LZMA_Callback_Free(void *p, void *address) -{ - p = p; - if(address != NULL) - STORM_FREE(address); -} - -// -// Note: So far, I haven't seen any files compressed by LZMA. -// This code haven't been verified against code ripped from Starcraft II Beta, -// but we know that Starcraft LZMA decompression code is able to decompress -// the data compressed by StormLib. -// - -static void Compress_LZMA(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, int * pCmpType, int nCmpLevel) -{ - ICompressProgress Progress; - CLzmaEncProps props; - ISzAlloc SzAlloc; - Byte * pbOutBuffer = (Byte *)pvOutBuffer; - Byte * destBuffer; - SizeT destLen = *pcbOutBuffer; - SizeT srcLen = cbInBuffer; - Byte encodedProps[LZMA_PROPS_SIZE]; - size_t encodedPropsSize = LZMA_PROPS_SIZE; - SRes nResult; - - // Keep compilers happy - STORMLIB_UNUSED(pCmpType); - STORMLIB_UNUSED(nCmpLevel); - - // Fill the callbacks in structures - Progress.Progress = LZMA_Callback_Progress; - SzAlloc.Alloc = LZMA_Callback_Alloc; - SzAlloc.Free = LZMA_Callback_Free; - - // Initialize properties - LzmaEncProps_Init(&props); - - // Perform compression - destBuffer = (Byte *)pvOutBuffer + LZMA_HEADER_SIZE; - destLen = *pcbOutBuffer - LZMA_HEADER_SIZE; - nResult = LzmaEncode(destBuffer, - &destLen, - (Byte *)pvInBuffer, - srcLen, - &props, - encodedProps, - &encodedPropsSize, - 0, - &Progress, - &SzAlloc, - &SzAlloc); - if(nResult != SZ_OK) - return; - - // If we failed to compress the data - if(destLen >= (SizeT)(*pcbOutBuffer - LZMA_HEADER_SIZE)) - return; - - // Write "useFilter" variable. Blizzard MPQ must not use filter. - *pbOutBuffer++ = 0; - - // Copy the encoded properties to the output buffer - memcpy(pvOutBuffer, encodedProps, encodedPropsSize); - pbOutBuffer += encodedPropsSize; - - // Copy the size of the data - *pbOutBuffer++ = (unsigned char)(srcLen >> 0x00); - *pbOutBuffer++ = (unsigned char)(srcLen >> 0x08); - *pbOutBuffer++ = (unsigned char)(srcLen >> 0x10); - *pbOutBuffer++ = (unsigned char)(srcLen >> 0x18); - *pbOutBuffer++ = 0; - *pbOutBuffer++ = 0; - *pbOutBuffer++ = 0; - *pbOutBuffer++ = 0; - - // Give the size of the data to the caller - *pcbOutBuffer = (unsigned int)(destLen + LZMA_HEADER_SIZE); -} - -static int Decompress_LZMA(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) -{ - ELzmaStatus LzmaStatus; - ISzAlloc SzAlloc; - Byte * destBuffer = (Byte *)pvOutBuffer; - Byte * srcBuffer = (Byte *)pvInBuffer; - SizeT destLen = *pcbOutBuffer; - SizeT srcLen = cbInBuffer; - SRes nResult; - - // There must be at least 0x0E bytes in the buffer - if(srcLen <= LZMA_HEADER_SIZE) - return 0; - - // We only accept blocks that have no filter used - if(*srcBuffer != 0) - return 0; - - // Fill the callbacks in structures - SzAlloc.Alloc = LZMA_Callback_Alloc; - SzAlloc.Free = LZMA_Callback_Free; - - // Perform compression - srcLen = cbInBuffer - LZMA_HEADER_SIZE; - nResult = LzmaDecode(destBuffer, - &destLen, - srcBuffer + LZMA_HEADER_SIZE, - &srcLen, - srcBuffer + 1, - LZMA_PROPS_SIZE, - LZMA_FINISH_END, - &LzmaStatus, - &SzAlloc); - if(nResult != SZ_OK) - return 0; - - *pcbOutBuffer = (unsigned int)destLen; - return 1; -} - -static int Decompress_LZMA_MPK(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) -{ - ELzmaStatus LzmaStatus; - ISzAlloc SzAlloc; - Byte * destBuffer = (Byte *)pvOutBuffer; - Byte * srcBuffer = (Byte *)pvInBuffer; - SizeT destLen = *pcbOutBuffer; - SizeT srcLen = cbInBuffer; - SRes nResult; - BYTE LZMA_Props[] = {0x5D, 0x00, 0x00, 0x00, 0x01}; - - // There must be at least 0x0E bytes in the buffer - if(srcLen <= sizeof(LZMA_Props)) - return 0; - - // Verify the props header - if(memcmp(pvInBuffer, LZMA_Props, sizeof(LZMA_Props))) - return 0; - - // Fill the callbacks in structures - SzAlloc.Alloc = LZMA_Callback_Alloc; - SzAlloc.Free = LZMA_Callback_Free; - - // Perform compression - srcLen = cbInBuffer - sizeof(LZMA_Props); - nResult = LzmaDecode(destBuffer, - &destLen, - srcBuffer + sizeof(LZMA_Props), - &srcLen, - srcBuffer, - sizeof(LZMA_Props), - LZMA_FINISH_END, - &LzmaStatus, - &SzAlloc); - if(nResult != SZ_OK) - return 0; - - *pcbOutBuffer = (unsigned int)destLen; - return 1; -} - -/******************************************************************************/ -/* */ -/* Support functions for SPARSE compression (0x20) */ -/* */ -/******************************************************************************/ - -void Compress_SPARSE(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, int * pCmpType, int nCmpLevel) -{ - // Keep compilers happy - STORMLIB_UNUSED(pCmpType); - STORMLIB_UNUSED(nCmpLevel); - - CompressSparse(pvOutBuffer, pcbOutBuffer, pvInBuffer, cbInBuffer); -} - -int Decompress_SPARSE(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) -{ - return DecompressSparse(pvOutBuffer, pcbOutBuffer, pvInBuffer, cbInBuffer); -} - -/******************************************************************************/ -/* */ -/* Support for ADPCM mono compression (0x40) */ -/* */ -/******************************************************************************/ - -static void Compress_ADPCM_mono(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, int * pCmpType, int nCmpLevel) -{ - // Prepare the compression level for Huffmann compression, - // which will be called as next step - if(0 < nCmpLevel && nCmpLevel <= 2) - { - nCmpLevel = 4; - *pCmpType = 6; - } - else if(nCmpLevel == 3) - { - nCmpLevel = 6; - *pCmpType = 8; - } - else - { - nCmpLevel = 5; - *pCmpType = 7; - } - *pcbOutBuffer = CompressADPCM(pvOutBuffer, *pcbOutBuffer, pvInBuffer, cbInBuffer, 1, nCmpLevel); -} - -static int Decompress_ADPCM_mono(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) -{ - *pcbOutBuffer = DecompressADPCM(pvOutBuffer, *pcbOutBuffer, pvInBuffer, cbInBuffer, 1); - return 1; -} - -/******************************************************************************/ -/* */ -/* Support for ADPCM stereo compression (0x80) */ -/* */ -/******************************************************************************/ - -static void Compress_ADPCM_stereo(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, int * pCmpType, int nCmpLevel) -{ - // Prepare the compression level for Huffmann compression, - // which will be called as next step - if(0 < nCmpLevel && nCmpLevel <= 2) - { - nCmpLevel = 4; - *pCmpType = 6; - } - else if(nCmpLevel == 3) - { - nCmpLevel = 6; - *pCmpType = 8; - } - else - { - nCmpLevel = 5; - *pCmpType = 7; - } - *pcbOutBuffer = CompressADPCM(pvOutBuffer, *pcbOutBuffer, pvInBuffer, cbInBuffer, 2, nCmpLevel); -} - -static int Decompress_ADPCM_stereo(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) -{ - *pcbOutBuffer = DecompressADPCM(pvOutBuffer, *pcbOutBuffer, pvInBuffer, cbInBuffer, 2); - return 1; -} - -/*****************************************************************************/ -/* */ -/* SCompImplode */ -/* */ -/*****************************************************************************/ - -int WINAPI SCompImplode(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) -{ - int cbOutBuffer; - - // Check for valid parameters - if(!pcbOutBuffer || *pcbOutBuffer < cbInBuffer || !pvOutBuffer || !pvInBuffer) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - - // Perform the compression - cbOutBuffer = *pcbOutBuffer; - Compress_PKLIB(pvOutBuffer, &cbOutBuffer, pvInBuffer, cbInBuffer, NULL, 0); - - // If the compression was unsuccessful, copy the data as-is - if(cbOutBuffer >= *pcbOutBuffer) - { - memcpy(pvOutBuffer, pvInBuffer, cbInBuffer); - cbOutBuffer = *pcbOutBuffer; - } - - *pcbOutBuffer = cbOutBuffer; - return 1; -} - -/*****************************************************************************/ -/* */ -/* SCompExplode */ -/* */ -/*****************************************************************************/ - -int WINAPI SCompExplode(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) -{ - int cbOutBuffer; - - // Check for valid parameters - if(!pcbOutBuffer || *pcbOutBuffer < cbInBuffer || !pvOutBuffer || !pvInBuffer) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - - // If the input length is the same as output length, do nothing. - cbOutBuffer = *pcbOutBuffer; - if(cbInBuffer == cbOutBuffer) - { - // If the buffers are equal, don't copy anything. - if(pvInBuffer == pvOutBuffer) - return 1; - - memcpy(pvOutBuffer, pvInBuffer, cbInBuffer); - return 1; - } - - // Perform decompression - if(!Decompress_PKLIB(pvOutBuffer, &cbOutBuffer, pvInBuffer, cbInBuffer)) - { - SetLastError(ERROR_FILE_CORRUPT); - return 0; - } - - *pcbOutBuffer = cbOutBuffer; - return 1; -} - -/*****************************************************************************/ -/* */ -/* SCompCompress */ -/* */ -/*****************************************************************************/ - -// This table contains compress functions which can be applied to -// uncompressed data. Each bit means the corresponding -// compression method/function must be applied. -// -// WAVes compression Data compression -// ------------------ ------------------- -// 1st sector - 0x08 0x08 (D, HF, W2, SC, D2) -// Next sectors - 0x81 0x02 (W3) - -static TCompressTable cmp_table[] = -{ - {MPQ_COMPRESSION_SPARSE, Compress_SPARSE}, // Sparse compression - {MPQ_COMPRESSION_ADPCM_MONO, Compress_ADPCM_mono}, // IMA ADPCM mono compression - {MPQ_COMPRESSION_ADPCM_STEREO, Compress_ADPCM_stereo}, // IMA ADPCM stereo compression - {MPQ_COMPRESSION_HUFFMANN, Compress_huff}, // Huffmann compression - {MPQ_COMPRESSION_ZLIB, Compress_ZLIB}, // Compression with the "zlib" library - {MPQ_COMPRESSION_PKWARE, Compress_PKLIB}, // Compression with Pkware DCL - {MPQ_COMPRESSION_BZIP2, Compress_BZIP2} // Compression Bzip2 library -}; - -int WINAPI SCompCompress(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, unsigned uCompressionMask, int nCmpType, int nCmpLevel) -{ - COMPRESS CompressFuncArray[0x10]; // Array of compression functions, applied sequentially - unsigned char CompressByte[0x10]; // CompressByte for each method in the CompressFuncArray array - unsigned char * pbWorkBuffer = NULL; // Temporary storage for decompressed data - unsigned char * pbOutBuffer = (unsigned char *)pvOutBuffer; - unsigned char * pbOutput = (unsigned char *)pvOutBuffer;// Current output buffer - unsigned char * pbInput = (unsigned char *)pvInBuffer; // Current input buffer - int nCompressCount = 0; - int nCompressIndex = 0; - int nAtLeastOneCompressionDone = 0; - int cbOutBuffer = 0; - int cbInLength = cbInBuffer; - int nResult = 1; - - // Check for valid parameters - if(!pcbOutBuffer || *pcbOutBuffer < cbInBuffer || !pvOutBuffer || !pvInBuffer) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - - // Zero input length brings zero output length - if(cbInBuffer == 0) - { - *pcbOutBuffer = 0; - return true; - } - - // Setup the compression function array - if(uCompressionMask == MPQ_COMPRESSION_LZMA) - { - CompressFuncArray[0] = Compress_LZMA; - CompressByte[0] = (char)uCompressionMask; - nCompressCount = 1; - } - else - { - // Fill the compressions array - for(size_t i = 0; i < (sizeof(cmp_table) / sizeof(TCompressTable)); i++) - { - // If the mask agrees, insert the compression function to the array - if(uCompressionMask & cmp_table[i].uMask) - { - CompressFuncArray[nCompressCount] = cmp_table[i].Compress; - CompressByte[nCompressCount] = (unsigned char)cmp_table[i].uMask; - uCompressionMask &= ~cmp_table[i].uMask; - nCompressCount++; - } - } - - // If at least one of the compressions remaing unknown, return an error - if(uCompressionMask != 0) - { - SetLastError(ERROR_NOT_SUPPORTED); - return 0; - } - } - - // If there is at least one compression, do it - if(nCompressCount > 0) - { - // If we need to do more than 1 compression, allocate intermediate buffer - if(nCompressCount > 1) - { - pbWorkBuffer = STORM_ALLOC(unsigned char, *pcbOutBuffer); - if(pbWorkBuffer == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - } - - // Get the current compression index - nCompressIndex = nCompressCount - 1; - - // Perform all compressions in the array - for(int i = 0; i < nCompressCount; i++) - { - // Choose the proper output buffer - pbOutput = (nCompressIndex & 1) ? pbWorkBuffer : pbOutBuffer; - nCompressIndex--; - - // Perform the (next) compression - // Note that if the compression method is unable to compress the input data block - // by at least 2 bytes, we consider it as failure and will use source data instead - cbOutBuffer = *pcbOutBuffer - 1; - CompressFuncArray[i](pbOutput + 1, &cbOutBuffer, pbInput, cbInLength, &nCmpType, nCmpLevel); - - // If the compression failed, we copy the input buffer as-is. - // Note that there is one extra byte at the end of the intermediate buffer, so it should be OK - if(cbOutBuffer > (cbInLength - 2)) - { - memcpy(pbOutput + nAtLeastOneCompressionDone, pbInput, cbInLength); - cbOutBuffer = cbInLength; - } - else - { - // Remember that we have done at least one compression - nAtLeastOneCompressionDone = 1; - uCompressionMask |= CompressByte[i]; - } - - // Now point input buffer to the output buffer - pbInput = pbOutput + nAtLeastOneCompressionDone; - cbInLength = cbOutBuffer; - } - - // If at least one compression succeeded, put the compression - // mask to the begin of the output buffer - if(nAtLeastOneCompressionDone) - *pbOutBuffer = (unsigned char)uCompressionMask; - *pcbOutBuffer = cbOutBuffer + nAtLeastOneCompressionDone; - } - else - { - memcpy(pvOutBuffer, pvInBuffer, cbInBuffer); - *pcbOutBuffer = cbInBuffer; - } - - // Cleanup and return - if(pbWorkBuffer != NULL) - STORM_FREE(pbWorkBuffer); - return nResult; -} - -/*****************************************************************************/ -/* */ -/* SCompDecompress */ -/* */ -/*****************************************************************************/ - -// This table contains decompress functions which can be applied to -// uncompressed data. The compression mask is stored in the first byte -// of compressed data -static TDecompressTable dcmp_table[] = -{ - {MPQ_COMPRESSION_BZIP2, Decompress_BZIP2}, // Decompression with Bzip2 library - {MPQ_COMPRESSION_PKWARE, Decompress_PKLIB}, // Decompression with Pkware Data Compression Library - {MPQ_COMPRESSION_ZLIB, Decompress_ZLIB}, // Decompression with the "zlib" library - {MPQ_COMPRESSION_HUFFMANN, Decompress_huff}, // Huffmann decompression - {MPQ_COMPRESSION_ADPCM_STEREO, Decompress_ADPCM_stereo}, // IMA ADPCM stereo decompression - {MPQ_COMPRESSION_ADPCM_MONO, Decompress_ADPCM_mono}, // IMA ADPCM mono decompression - {MPQ_COMPRESSION_SPARSE, Decompress_SPARSE} // Sparse decompression -}; - -int WINAPI SCompDecompress(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) -{ - unsigned char * pbWorkBuffer = NULL; - unsigned char * pbOutBuffer = (unsigned char *)pvOutBuffer; - unsigned char * pbInBuffer = (unsigned char *)pvInBuffer; - unsigned char * pbOutput = (unsigned char *)pvOutBuffer; - unsigned char * pbInput; - unsigned uCompressionMask; // Decompressions applied to the data - unsigned uCompressionCopy; // Decompressions applied to the data - int cbOutBuffer = *pcbOutBuffer; // Current size of the output buffer - int cbInLength; // Current size of the input buffer - int nCompressCount = 0; // Number of compressions to be applied - int nCompressIndex = 0; - int nResult = 1; - - // Verify buffer sizes - if(cbOutBuffer < cbInBuffer || cbInBuffer < 1) - return 0; - - // If the input length is the same as output length, do nothing. - if(cbOutBuffer == cbInBuffer) - { - // If the buffers are equal, don't copy anything. - if(pvInBuffer != pvOutBuffer) - memcpy(pvOutBuffer, pvInBuffer, cbInBuffer); - return 1; - } - - // Get applied compression types and decrement data length - uCompressionMask = uCompressionCopy = (unsigned char)*pbInBuffer++; - cbInBuffer--; - - // Get current compressed data and length of it - pbInput = pbInBuffer; - cbInLength = cbInBuffer; - - // This compression function doesn't support LZMA - assert(uCompressionMask != MPQ_COMPRESSION_LZMA); - - // Parse the compression mask - for(size_t i = 0; i < (sizeof(dcmp_table) / sizeof(TDecompressTable)); i++) - { - // If the mask agrees, insert the compression function to the array - if(uCompressionMask & dcmp_table[i].uMask) - { - uCompressionCopy &= ~dcmp_table[i].uMask; - nCompressCount++; - } - } - - // If at least one of the compressions remaing unknown, return an error - if(nCompressCount == 0 || uCompressionCopy != 0) - { - SetLastError(ERROR_NOT_SUPPORTED); - return 0; - } - - // If there is more than one compression, we have to allocate extra buffer - if(nCompressCount > 1) - { - pbWorkBuffer = STORM_ALLOC(unsigned char, cbOutBuffer); - if(pbWorkBuffer == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - } - - // Get the current compression index - nCompressIndex = nCompressCount - 1; - - // Apply all decompressions - for(size_t i = 0; i < (sizeof(dcmp_table) / sizeof(TDecompressTable)); i++) - { - // Perform the (next) decompression - if(uCompressionMask & dcmp_table[i].uMask) - { - // Get the correct output buffer - pbOutput = (nCompressIndex & 1) ? pbWorkBuffer : pbOutBuffer; - nCompressIndex--; - - // Perform the decompression - cbOutBuffer = *pcbOutBuffer; - nResult = dcmp_table[i].Decompress(pbOutput, &cbOutBuffer, pbInput, cbInLength); - if(nResult == 0 || cbOutBuffer == 0) - { - SetLastError(ERROR_FILE_CORRUPT); - nResult = 0; - break; - } - - // Switch buffers - cbInLength = cbOutBuffer; - pbInput = pbOutput; - } - } - - // Put the length of the decompressed data to the output buffer - *pcbOutBuffer = cbOutBuffer; - - // Cleanup and return - if(pbWorkBuffer != NULL) - STORM_FREE(pbWorkBuffer); - return nResult; -} - -int WINAPI SCompDecompress2(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) -{ - DECOMPRESS pfnDecompress1 = NULL; - DECOMPRESS pfnDecompress2 = NULL; - unsigned char * pbWorkBuffer = (unsigned char *)pvOutBuffer; - unsigned char * pbInBuffer = (unsigned char *)pvInBuffer; - int cbWorkBuffer = *pcbOutBuffer; - int nResult; - char CompressionMethod; - - // Verify buffer sizes - if(*pcbOutBuffer < cbInBuffer || cbInBuffer < 1) - return 0; - - // If the outputbuffer is as big as input buffer, just copy the block - if(*pcbOutBuffer == cbInBuffer) - { - if(pvOutBuffer != pvInBuffer) - memcpy(pvOutBuffer, pvInBuffer, cbInBuffer); - return 1; - } - - // Get the compression methods - CompressionMethod = *pbInBuffer++; - cbInBuffer--; - - // We only recognize a fixed set of compression methods - switch((unsigned char)CompressionMethod) - { - case MPQ_COMPRESSION_ZLIB: - pfnDecompress1 = Decompress_ZLIB; - break; - - case MPQ_COMPRESSION_PKWARE: - pfnDecompress1 = Decompress_PKLIB; - break; - - case MPQ_COMPRESSION_BZIP2: - pfnDecompress1 = Decompress_BZIP2; - break; - - case MPQ_COMPRESSION_LZMA: - pfnDecompress1 = Decompress_LZMA; - break; - - case MPQ_COMPRESSION_SPARSE: - pfnDecompress1 = Decompress_SPARSE; - break; - - case (MPQ_COMPRESSION_SPARSE | MPQ_COMPRESSION_ZLIB): - pfnDecompress1 = Decompress_ZLIB; - pfnDecompress2 = Decompress_SPARSE; - break; - - case (MPQ_COMPRESSION_SPARSE | MPQ_COMPRESSION_BZIP2): - pfnDecompress1 = Decompress_BZIP2; - pfnDecompress2 = Decompress_SPARSE; - break; - - // - // Note: Any combination including MPQ_COMPRESSION_ADPCM_MONO, - // MPQ_COMPRESSION_ADPCM_STEREO or MPQ_COMPRESSION_HUFFMANN - // is not supported by newer MPQs. - // - - case (MPQ_COMPRESSION_ADPCM_MONO | MPQ_COMPRESSION_HUFFMANN): - pfnDecompress1 = Decompress_huff; - pfnDecompress2 = Decompress_ADPCM_mono; - break; - - case (MPQ_COMPRESSION_ADPCM_STEREO | MPQ_COMPRESSION_HUFFMANN): - pfnDecompress1 = Decompress_huff; - pfnDecompress2 = Decompress_ADPCM_stereo; - break; - - default: - SetLastError(ERROR_FILE_CORRUPT); - return 0; - } - - // If we have to use two decompressions, allocate temporary buffer - if(pfnDecompress2 != NULL) - { - pbWorkBuffer = STORM_ALLOC(unsigned char, *pcbOutBuffer); - if(pbWorkBuffer == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - } - - // Apply the first decompression method - nResult = pfnDecompress1(pbWorkBuffer, &cbWorkBuffer, pbInBuffer, cbInBuffer); - - // Apply the second decompression method, if any - if(pfnDecompress2 != NULL && nResult != 0) - { - cbInBuffer = cbWorkBuffer; - cbWorkBuffer = *pcbOutBuffer; - nResult = pfnDecompress2(pvOutBuffer, &cbWorkBuffer, pbWorkBuffer, cbInBuffer); - } - - // Supply the output buffer size - *pcbOutBuffer = cbWorkBuffer; - - // Free temporary buffer - if(pbWorkBuffer != pvOutBuffer) - STORM_FREE(pbWorkBuffer); - - if(nResult == 0) - SetLastError(ERROR_FILE_CORRUPT); - return nResult; -} - -/*****************************************************************************/ -/* */ -/* File decompression for MPK archives */ -/* */ -/*****************************************************************************/ - -int SCompDecompressMpk(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) -{ - return Decompress_LZMA_MPK(pvOutBuffer, pcbOutBuffer, pvInBuffer, cbInBuffer); -} - diff --git a/libs/storm-sys/StormLib/src/SFileAddFile.cpp b/libs/storm-sys/StormLib/src/SFileAddFile.cpp deleted file mode 100644 index 4572d89..0000000 --- a/libs/storm-sys/StormLib/src/SFileAddFile.cpp +++ /dev/null @@ -1,1312 +0,0 @@ -/*****************************************************************************/ -/* SFileAddFile.cpp Copyright (c) Ladislav Zezula 2010 */ -/*---------------------------------------------------------------------------*/ -/* MPQ Editing functions */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 27.03.10 1.00 Lad Splitted from SFileCreateArchiveEx.cpp */ -/* 21.04.13 1.01 Dea AddFile callback now part of TMPQArchive */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "StormCommon.h" - -//----------------------------------------------------------------------------- -// Local variables - -// Mask for lossy compressions -#define MPQ_LOSSY_COMPRESSION_MASK (MPQ_COMPRESSION_ADPCM_MONO | MPQ_COMPRESSION_ADPCM_STEREO | MPQ_COMPRESSION_HUFFMANN) - -// Data compression for SFileAddFile -// Kept here for compatibility with code that was created with StormLib version < 6.50 -static DWORD DefaultDataCompression = MPQ_COMPRESSION_PKWARE; - -//----------------------------------------------------------------------------- -// WAVE verification - -#define FILE_SIGNATURE_RIFF 0x46464952 -#define FILE_SIGNATURE_WAVE 0x45564157 -#define FILE_SIGNATURE_FMT 0x20746D66 -#define AUDIO_FORMAT_PCM 1 - -typedef struct _WAVE_FILE_HEADER -{ - DWORD dwChunkId; // 0x52494646 ("RIFF") - DWORD dwChunkSize; // Size of that chunk, in bytes - DWORD dwFormat; // Must be 0x57415645 ("WAVE") - - // Format sub-chunk - DWORD dwSubChunk1Id; // 0x666d7420 ("fmt ") - DWORD dwSubChunk1Size; // 0x16 for PCM - USHORT wAudioFormat; // 1 = PCM. Other value means some sort of compression - USHORT wChannels; // Number of channels - DWORD dwSampleRate; // 8000, 44100, etc. - DWORD dwBytesRate; // SampleRate * NumChannels * BitsPerSample/8 - USHORT wBlockAlign; // NumChannels * BitsPerSample/8 - USHORT wBitsPerSample; // 8 bits = 8, 16 bits = 16, etc. - - // Followed by "data" sub-chunk (we don't care) -} WAVE_FILE_HEADER, *PWAVE_FILE_HEADER; - -static bool IsWaveFile_16BitsPerAdpcmSample( - LPBYTE pbFileData, - DWORD cbFileData, - LPDWORD pdwChannels) -{ - PWAVE_FILE_HEADER pWaveHdr = (PWAVE_FILE_HEADER)pbFileData; - - // The amount of file data must be at least size of WAVE header - if(cbFileData > sizeof(WAVE_FILE_HEADER)) - { - // Check for the RIFF header - if(pWaveHdr->dwChunkId == FILE_SIGNATURE_RIFF && pWaveHdr->dwFormat == FILE_SIGNATURE_WAVE) - { - // Check for ADPCM format - if(pWaveHdr->dwSubChunk1Id == FILE_SIGNATURE_FMT && pWaveHdr->wAudioFormat == AUDIO_FORMAT_PCM) - { - // Now the number of bits per sample must be at least 16. - // If not, the WAVE file gets corrupted by the ADPCM compression - if(pWaveHdr->wBitsPerSample >= 0x10) - { - *pdwChannels = pWaveHdr->wChannels; - return true; - } - } - } - } - - return false; -} - -static int FillWritableHandle( - TMPQArchive * ha, - TMPQFile * hf, - ULONGLONG FileTime, - DWORD dwFileSize, - DWORD dwFlags) -{ - TFileEntry * pFileEntry = hf->pFileEntry; - - // Initialize the hash entry for the file - hf->RawFilePos = ha->MpqPos + hf->MpqFilePos; - hf->dwDataSize = dwFileSize; - - // Initialize the block table entry for the file - pFileEntry->ByteOffset = hf->MpqFilePos; - pFileEntry->dwFileSize = dwFileSize; - pFileEntry->dwCmpSize = 0; - pFileEntry->dwFlags = dwFlags | MPQ_FILE_EXISTS; - - // Initialize the file time, CRC32 and MD5 - assert(sizeof(hf->hctx) >= sizeof(hash_state)); - memset(pFileEntry->md5, 0, MD5_DIGEST_SIZE); - md5_init((hash_state *)hf->hctx); - pFileEntry->dwCrc32 = crc32(0, Z_NULL, 0); - - // If the caller gave us a file time, use it. - pFileEntry->FileTime = FileTime; - - // Mark the archive as modified - ha->dwFlags |= MPQ_FLAG_CHANGED; - - // Call the callback, if needed - if(ha->pfnAddFileCB != NULL) - ha->pfnAddFileCB(ha->pvAddFileUserData, 0, hf->dwDataSize, false); - hf->nAddFileError = ERROR_SUCCESS; - - return ERROR_SUCCESS; -} - -//----------------------------------------------------------------------------- -// MPQ write data functions - -static int WriteDataToMpqFile( - TMPQArchive * ha, - TMPQFile * hf, - LPBYTE pbFileData, - DWORD dwDataSize, - DWORD dwCompression) -{ - TFileEntry * pFileEntry = hf->pFileEntry; - ULONGLONG ByteOffset; - LPBYTE pbCompressed = NULL; // Compressed (target) data - LPBYTE pbToWrite = hf->pbFileSector; // Data to write to the file - int nCompressionLevel; // ADPCM compression level (only used for wave files) - int nError = ERROR_SUCCESS; - - // Make sure that the caller won't overrun the previously initiated file size - assert(hf->dwFilePos + dwDataSize <= pFileEntry->dwFileSize); - assert(hf->dwSectorCount != 0); - assert(hf->pbFileSector != NULL); - if((hf->dwFilePos + dwDataSize) > pFileEntry->dwFileSize) - return ERROR_DISK_FULL; - - // Now write all data to the file sector buffer - if(nError == ERROR_SUCCESS) - { - DWORD dwBytesInSector = hf->dwFilePos % hf->dwSectorSize; - DWORD dwSectorIndex = hf->dwFilePos / hf->dwSectorSize; - DWORD dwBytesToCopy; - - // Process all data. - while(dwDataSize != 0) - { - dwBytesToCopy = dwDataSize; - - // Check for sector overflow - if(dwBytesToCopy > (hf->dwSectorSize - dwBytesInSector)) - dwBytesToCopy = (hf->dwSectorSize - dwBytesInSector); - - // Copy the data to the file sector - memcpy(hf->pbFileSector + dwBytesInSector, pbFileData, dwBytesToCopy); - dwBytesInSector += dwBytesToCopy; - pbFileData += dwBytesToCopy; - dwDataSize -= dwBytesToCopy; - - // Update the file position - hf->dwFilePos += dwBytesToCopy; - - // If the current sector is full, or if the file is already full, - // then write the data to the MPQ - if(dwBytesInSector >= hf->dwSectorSize || hf->dwFilePos >= pFileEntry->dwFileSize) - { - // Set the position in the file - ByteOffset = hf->RawFilePos + pFileEntry->dwCmpSize; - - // Update CRC32 and MD5 of the file - md5_process((hash_state *)hf->hctx, hf->pbFileSector, dwBytesInSector); - hf->dwCrc32 = crc32(hf->dwCrc32, hf->pbFileSector, dwBytesInSector); - - // Compress the file sector, if needed - if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK) - { - int nOutBuffer = (int)dwBytesInSector; - int nInBuffer = (int)dwBytesInSector; - - // If the file is compressed, allocate buffer for the compressed data. - // Note that we allocate buffer that is a bit longer than sector size, - // for case if the compression method performs a buffer overrun - if(pbCompressed == NULL) - { - pbToWrite = pbCompressed = STORM_ALLOC(BYTE, hf->dwSectorSize + 0x100); - if(pbCompressed == NULL) - { - nError = ERROR_NOT_ENOUGH_MEMORY; - break; - } - } - - // - // Note that both SCompImplode and SCompCompress copy data as-is, - // if they are unable to compress the data. - // - - if(pFileEntry->dwFlags & MPQ_FILE_IMPLODE) - { - SCompImplode(pbCompressed, &nOutBuffer, hf->pbFileSector, nInBuffer); - } - - if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS) - { - // If this is the first sector, we need to override the given compression - // by the first sector compression. This is because the entire sector must - // be compressed by the same compression. - // - // Test case: - // - // WRITE_FILE(hFile, pvBuffer, 0x10, MPQ_COMPRESSION_PKWARE) // Write 0x10 bytes (sector 0) - // WRITE_FILE(hFile, pvBuffer, 0x10, MPQ_COMPRESSION_ADPCM_MONO) // Write 0x10 bytes (still sector 0) - // WRITE_FILE(hFile, pvBuffer, 0x10, MPQ_COMPRESSION_ADPCM_MONO) // Write 0x10 bytes (still sector 0) - // WRITE_FILE(hFile, pvBuffer, 0x10, MPQ_COMPRESSION_ADPCM_MONO) // Write 0x10 bytes (still sector 0) - dwCompression = (dwSectorIndex == 0) ? hf->dwCompression0 : dwCompression; - - // If the caller wants ADPCM compression, we will set wave compression level to 4, - // which corresponds to medium quality - nCompressionLevel = (dwCompression & MPQ_LOSSY_COMPRESSION_MASK) ? 4 : -1; - SCompCompress(pbCompressed, &nOutBuffer, hf->pbFileSector, nInBuffer, (unsigned)dwCompression, 0, nCompressionLevel); - } - - // Update sector positions - dwBytesInSector = nOutBuffer; - if(hf->SectorOffsets != NULL) - hf->SectorOffsets[dwSectorIndex+1] = hf->SectorOffsets[dwSectorIndex] + dwBytesInSector; - - // We have to calculate sector CRC, if enabled - if(hf->SectorChksums != NULL) - hf->SectorChksums[dwSectorIndex] = adler32(0, pbCompressed, nOutBuffer); - } - - // Encrypt the sector, if necessary - if(pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED) - { - BSWAP_ARRAY32_UNSIGNED(pbToWrite, dwBytesInSector); - EncryptMpqBlock(pbToWrite, dwBytesInSector, hf->dwFileKey + dwSectorIndex); - BSWAP_ARRAY32_UNSIGNED(pbToWrite, dwBytesInSector); - } - - // Write the file sector - if(!FileStream_Write(ha->pStream, &ByteOffset, pbToWrite, dwBytesInSector)) - { - nError = GetLastError(); - break; - } - - // Call the compact callback, if any - if(ha->pfnAddFileCB != NULL) - ha->pfnAddFileCB(ha->pvAddFileUserData, hf->dwFilePos, hf->dwDataSize, false); - - // Update the compressed file size - pFileEntry->dwCmpSize += dwBytesInSector; - dwBytesInSector = 0; - dwSectorIndex++; - } - } - } - - // Cleanup - if(pbCompressed != NULL) - STORM_FREE(pbCompressed); - return nError; -} - -//----------------------------------------------------------------------------- -// Recrypts file data for file renaming - -static int RecryptFileData( - TMPQArchive * ha, - TMPQFile * hf, - const char * szFileName, - const char * szNewFileName) -{ - ULONGLONG RawFilePos; - TFileEntry * pFileEntry = hf->pFileEntry; - DWORD dwBytesToRecrypt = pFileEntry->dwCmpSize; - DWORD dwOldKey; - DWORD dwNewKey; - int nError = ERROR_SUCCESS; - - // The file must be encrypted - assert(pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED); - - // File decryption key is calculated from the plain name - szNewFileName = GetPlainFileName(szNewFileName); - szFileName = GetPlainFileName(szFileName); - - // Calculate both file keys - dwOldKey = DecryptFileKey(szFileName, pFileEntry->ByteOffset, pFileEntry->dwFileSize, pFileEntry->dwFlags); - dwNewKey = DecryptFileKey(szNewFileName, pFileEntry->ByteOffset, pFileEntry->dwFileSize, pFileEntry->dwFlags); - - // Incase the keys are equal, don't recrypt the file - if(dwNewKey == dwOldKey) - return ERROR_SUCCESS; - hf->dwFileKey = dwOldKey; - - // Calculate the raw position of the file in the archive - hf->MpqFilePos = pFileEntry->ByteOffset; - hf->RawFilePos = ha->MpqPos + hf->MpqFilePos; - - // Allocate buffer for file transfer - nError = AllocateSectorBuffer(hf); - if(nError != ERROR_SUCCESS) - return nError; - - // Also allocate buffer for sector offsets - // Note: Don't load sector checksums, we don't need to recrypt them - nError = AllocateSectorOffsets(hf, true); - if(nError != ERROR_SUCCESS) - return nError; - - // If we have sector offsets, recrypt these as well - if(hf->SectorOffsets != NULL) - { - // Allocate secondary buffer for sectors copy - DWORD * SectorOffsetsCopy = STORM_ALLOC(DWORD, hf->SectorOffsets[0] / sizeof(DWORD)); - DWORD dwSectorOffsLen = hf->SectorOffsets[0]; - - if(SectorOffsetsCopy == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - // Recrypt the array of sector offsets - memcpy(SectorOffsetsCopy, hf->SectorOffsets, dwSectorOffsLen); - EncryptMpqBlock(SectorOffsetsCopy, dwSectorOffsLen, dwNewKey - 1); - BSWAP_ARRAY32_UNSIGNED(SectorOffsetsCopy, dwSectorOffsLen); - - // Write the recrypted array back - if(!FileStream_Write(ha->pStream, &hf->RawFilePos, SectorOffsetsCopy, dwSectorOffsLen)) - nError = GetLastError(); - STORM_FREE(SectorOffsetsCopy); - } - - // Now we have to recrypt all file sectors. We do it without - // recompression, because recompression is not necessary in this case - if(nError == ERROR_SUCCESS) - { - for(DWORD dwSector = 0; dwSector < hf->dwSectorCount; dwSector++) - { - DWORD dwRawDataInSector = hf->dwSectorSize; - DWORD dwRawByteOffset = dwSector * hf->dwSectorSize; - - // Last sector: If there is not enough bytes remaining in the file, cut the raw size - if(dwRawDataInSector > dwBytesToRecrypt) - dwRawDataInSector = dwBytesToRecrypt; - - // Fix the raw data length if the file is compressed - if(hf->SectorOffsets != NULL) - { - dwRawDataInSector = hf->SectorOffsets[dwSector+1] - hf->SectorOffsets[dwSector]; - dwRawByteOffset = hf->SectorOffsets[dwSector]; - } - - // Calculate the raw file offset of the file sector - RawFilePos = CalculateRawSectorOffset(hf, dwRawByteOffset); - - // Read the file sector - if(!FileStream_Read(ha->pStream, &RawFilePos, hf->pbFileSector, dwRawDataInSector)) - { - nError = GetLastError(); - break; - } - - // If necessary, re-encrypt the sector - // Note: Recompression is not necessary here. Unlike encryption, - // the compression does not depend on the position of the file in MPQ. - BSWAP_ARRAY32_UNSIGNED(hf->pbFileSector, dwRawDataInSector); - DecryptMpqBlock(hf->pbFileSector, dwRawDataInSector, dwOldKey + dwSector); - EncryptMpqBlock(hf->pbFileSector, dwRawDataInSector, dwNewKey + dwSector); - BSWAP_ARRAY32_UNSIGNED(hf->pbFileSector, dwRawDataInSector); - - // Write the sector back - if(!FileStream_Write(ha->pStream, &RawFilePos, hf->pbFileSector, dwRawDataInSector)) - { - nError = GetLastError(); - break; - } - - // Decrement number of bytes remaining - dwBytesToRecrypt -= hf->dwSectorSize; - } - } - - return nError; -} - -//----------------------------------------------------------------------------- -// Internal support for MPQ modifications - -int SFileAddFile_Init( - TMPQArchive * ha, - const char * szFileName, - ULONGLONG FileTime, - DWORD dwFileSize, - LCID lcLocale, - DWORD dwFlags, - TMPQFile ** phf) -{ - TFileEntry * pFileEntry = NULL; - TMPQFile * hf = NULL; // File structure for newly added file - DWORD dwHashIndex = HASH_ENTRY_FREE; - int nError = ERROR_SUCCESS; - - // - // Note: This is an internal function so no validity checks are done. - // It is the caller's responsibility to make sure that no invalid - // flags get to this point - // - - // Sestor CRC is not allowed with single unit files - if(dwFlags & MPQ_FILE_SINGLE_UNIT) - dwFlags &= ~MPQ_FILE_SECTOR_CRC; - - // Sector CRC is not allowed if the file is not compressed - if(!(dwFlags & MPQ_FILE_COMPRESS_MASK)) - dwFlags &= ~MPQ_FILE_SECTOR_CRC; - - // Fix Key is not allowed if the file is not enrypted - if(!(dwFlags & MPQ_FILE_ENCRYPTED)) - dwFlags &= ~MPQ_FILE_FIX_KEY; - - // If the MPQ is of version 3.0 or higher, we ignore file locale. - // This is because HET and BET tables have no known support for it - if(ha->pHeader->wFormatVersion >= MPQ_FORMAT_VERSION_3) - lcLocale = 0; - - // Allocate the TMPQFile entry for newly added file - hf = CreateWritableHandle(ha, dwFileSize); - if(hf == NULL) - return false; - - // Allocate file entry in the MPQ - if(nError == ERROR_SUCCESS) - { - // Check if the file already exists in the archive - pFileEntry = GetFileEntryExact(ha, szFileName, lcLocale, &dwHashIndex); - if(pFileEntry != NULL) - { - if(dwFlags & MPQ_FILE_REPLACEEXISTING) - InvalidateInternalFiles(ha); - else - nError = ERROR_ALREADY_EXISTS; - } - else - { - // Attempt to allocate new file entry - pFileEntry = AllocateFileEntry(ha, szFileName, lcLocale, &dwHashIndex); - if(pFileEntry != NULL) - InvalidateInternalFiles(ha); - else - nError = ERROR_DISK_FULL; - } - - // Set the file entry to the file structure - hf->pFileEntry = pFileEntry; - } - - // Prepare the pointer to hash table entry - if(nError == ERROR_SUCCESS && ha->pHashTable != NULL && dwHashIndex < ha->pHeader->dwHashTableSize) - { - hf->pHashEntry = ha->pHashTable + dwHashIndex; - hf->pHashEntry->lcLocale = (USHORT)lcLocale; - } - - // Prepare the file key - if(nError == ERROR_SUCCESS && (dwFlags & MPQ_FILE_ENCRYPTED)) - { - hf->dwFileKey = DecryptFileKey(szFileName, hf->MpqFilePos, dwFileSize, dwFlags); - if(hf->dwFileKey == 0) - nError = ERROR_UNKNOWN_FILE_KEY; - } - - // Fill the file entry and TMPQFile structure - if(nError == ERROR_SUCCESS) - { - // At this point, the file name in the file entry must be set - assert(pFileEntry->szFileName != NULL); - assert(_stricmp(pFileEntry->szFileName, szFileName) == 0); - - nError = FillWritableHandle(ha, hf, FileTime, dwFileSize, dwFlags); - } - - // Free the file handle if failed - if(nError != ERROR_SUCCESS && hf != NULL) - FreeFileHandle(hf); - - // Give the handle to the caller - *phf = hf; - return nError; -} - -int SFileAddFile_Init( - TMPQArchive * ha, - TMPQFile * hfSrc, - TMPQFile ** phf) -{ - TFileEntry * pFileEntry = NULL; - TMPQFile * hf = NULL; // File structure for newly added file - ULONGLONG FileTime = hfSrc->pFileEntry->FileTime; - DWORD dwFileSize = hfSrc->pFileEntry->dwFileSize; - DWORD dwFlags = hfSrc->pFileEntry->dwFlags; - int nError = ERROR_SUCCESS; - - // Allocate the TMPQFile entry for newly added file - hf = CreateWritableHandle(ha, dwFileSize); - if(hf == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - - // We need to keep the file entry index the same like in the source archive - // This is because multiple hash table entries can point to the same file entry - if(nError == ERROR_SUCCESS) - { - // Retrieve the file entry for the target file - pFileEntry = ha->pFileTable + (hfSrc->pFileEntry - hfSrc->ha->pFileTable); - - // Copy all variables except file name - if((pFileEntry->dwFlags & MPQ_FILE_EXISTS) == 0) - { - pFileEntry[0] = hfSrc->pFileEntry[0]; - pFileEntry->szFileName = NULL; - } - else - nError = ERROR_ALREADY_EXISTS; - - // Set the file entry to the file structure - hf->pFileEntry = pFileEntry; - } - - // Prepare the pointer to hash table entry - if(nError == ERROR_SUCCESS && ha->pHashTable != NULL && hfSrc->pHashEntry != NULL) - { - hf->dwHashIndex = (DWORD)(hfSrc->pHashEntry - hfSrc->ha->pHashTable); - hf->pHashEntry = ha->pHashTable + hf->dwHashIndex; - } - - // Prepare the file key (copy from source file) - if(nError == ERROR_SUCCESS && (dwFlags & MPQ_FILE_ENCRYPTED)) - { - hf->dwFileKey = hfSrc->dwFileKey; - if(hf->dwFileKey == 0) - nError = ERROR_UNKNOWN_FILE_KEY; - } - - // Fill the file entry and TMPQFile structure - if(nError == ERROR_SUCCESS) - { - nError = FillWritableHandle(ha, hf, FileTime, dwFileSize, dwFlags); - } - - // Free the file handle if failed - if(nError != ERROR_SUCCESS && hf != NULL) - FreeFileHandle(hf); - - // Give the handle to the caller - *phf = hf; - return nError; -} - -int SFileAddFile_Write(TMPQFile * hf, const void * pvData, DWORD dwSize, DWORD dwCompression) -{ - TMPQArchive * ha; - TFileEntry * pFileEntry; - int nError = ERROR_SUCCESS; - - // Don't bother if the caller gave us zero size - if(pvData == NULL || dwSize == 0) - return ERROR_SUCCESS; - - // Get pointer to the MPQ archive - pFileEntry = hf->pFileEntry; - ha = hf->ha; - - // Allocate file buffers - if(hf->pbFileSector == NULL) - { - ULONGLONG RawFilePos = hf->RawFilePos; - - // Allocate buffer for file sector - hf->nAddFileError = nError = AllocateSectorBuffer(hf); - if(nError != ERROR_SUCCESS) - return nError; - - // Allocate patch info, if the data is patch - if(hf->pPatchInfo == NULL && IsIncrementalPatchFile(pvData, dwSize, &hf->dwPatchedFileSize)) - { - // Set the MPQ_FILE_PATCH_FILE flag - hf->pFileEntry->dwFlags |= MPQ_FILE_PATCH_FILE; - - // Allocate the patch info - hf->nAddFileError = nError = AllocatePatchInfo(hf, false); - if(nError != ERROR_SUCCESS) - return nError; - } - - // Allocate sector offsets - if(hf->SectorOffsets == NULL) - { - hf->nAddFileError = nError = AllocateSectorOffsets(hf, false); - if(nError != ERROR_SUCCESS) - return nError; - } - - // Create array of sector checksums - if(hf->SectorChksums == NULL && (pFileEntry->dwFlags & MPQ_FILE_SECTOR_CRC)) - { - hf->nAddFileError = nError = AllocateSectorChecksums(hf, false); - if(nError != ERROR_SUCCESS) - return nError; - } - - // Pre-save the patch info, if any - if(hf->pPatchInfo != NULL) - { - if(!FileStream_Write(ha->pStream, &RawFilePos, hf->pPatchInfo, hf->pPatchInfo->dwLength)) - nError = GetLastError(); - - pFileEntry->dwCmpSize += hf->pPatchInfo->dwLength; - RawFilePos += hf->pPatchInfo->dwLength; - } - - // Pre-save the sector offset table, just to reserve space in the file. - // Note that we dont need to swap the sector positions, nor encrypt the table - // at the moment, as it will be written again after writing all file sectors. - if(hf->SectorOffsets != NULL) - { - if(!FileStream_Write(ha->pStream, &RawFilePos, hf->SectorOffsets, hf->SectorOffsets[0])) - nError = GetLastError(); - - pFileEntry->dwCmpSize += hf->SectorOffsets[0]; - RawFilePos += hf->SectorOffsets[0]; - } - } - - // Write the MPQ data to the file - if(nError == ERROR_SUCCESS) - { - // Save the first sector compression to the file structure - // Note that the entire first file sector will be compressed - // by compression that was passed to the first call of SFileAddFile_Write - if(hf->dwFilePos == 0) - hf->dwCompression0 = dwCompression; - - // Write the data to the MPQ - nError = WriteDataToMpqFile(ha, hf, (LPBYTE)pvData, dwSize, dwCompression); - } - - // If it succeeded and we wrote all the file data, - // we need to re-save sector offset table - if(nError == ERROR_SUCCESS) - { - if(hf->dwFilePos >= pFileEntry->dwFileSize) - { - // Finish calculating CRC32 - hf->pFileEntry->dwCrc32 = hf->dwCrc32; - - // Finish calculating MD5 - md5_done((hash_state *)hf->hctx, hf->pFileEntry->md5); - - // If we also have sector checksums, write them to the file - if(hf->SectorChksums != NULL) - { - nError = WriteSectorChecksums(hf); - } - - // Now write patch info - if(hf->pPatchInfo != NULL) - { - memcpy(hf->pPatchInfo->md5, hf->pFileEntry->md5, MD5_DIGEST_SIZE); - hf->pPatchInfo->dwDataSize = hf->pFileEntry->dwFileSize; - hf->pFileEntry->dwFileSize = hf->dwPatchedFileSize; - nError = WritePatchInfo(hf); - } - - // Now write sector offsets to the file - if(hf->SectorOffsets != NULL) - { - nError = WriteSectorOffsets(hf); - } - - // Write the MD5 hashes of each file chunk, if required - if(ha->pHeader->dwRawChunkSize != 0) - { - nError = WriteMpqDataMD5(ha->pStream, - ha->MpqPos + hf->pFileEntry->ByteOffset, - hf->pFileEntry->dwCmpSize, - ha->pHeader->dwRawChunkSize); - } - } - } - - // Store the error code from the Write File operation - hf->nAddFileError = nError; - return nError; -} - -int SFileAddFile_Finish(TMPQFile * hf) -{ - TMPQArchive * ha = hf->ha; - TFileEntry * pFileEntry = hf->pFileEntry; - int nError = hf->nAddFileError; - - // If all previous operations succeeded, we can update the MPQ - if(nError == ERROR_SUCCESS) - { - // Verify if the caller wrote the file properly - if(hf->pPatchInfo == NULL) - { - assert(pFileEntry != NULL); - if(hf->dwFilePos != pFileEntry->dwFileSize) - nError = ERROR_CAN_NOT_COMPLETE; - } - else - { - if(hf->dwFilePos != hf->pPatchInfo->dwDataSize) - nError = ERROR_CAN_NOT_COMPLETE; - } - } - - // Now we need to recreate the HET table, if exists - if(nError == ERROR_SUCCESS && ha->pHetTable != NULL) - { - nError = RebuildHetTable(ha); - } - - // Update the block table size - if(nError == ERROR_SUCCESS) - { - // Call the user callback, if any - if(ha->pfnAddFileCB != NULL) - ha->pfnAddFileCB(ha->pvAddFileUserData, hf->dwDataSize, hf->dwDataSize, true); - } - else - { - // Free the file entry in MPQ tables - if(pFileEntry != NULL) - DeleteFileEntry(ha, hf); - } - - // Clear the add file callback - FreeFileHandle(hf); - return nError; -} - -//----------------------------------------------------------------------------- -// Adds data as file to the archive - -bool WINAPI SFileCreateFile( - HANDLE hMpq, - const char * szArchivedName, - ULONGLONG FileTime, - DWORD dwFileSize, - LCID lcLocale, - DWORD dwFlags, - HANDLE * phFile) -{ - TMPQArchive * ha = (TMPQArchive *)hMpq; - int nError = ERROR_SUCCESS; - - // Check valid parameters - if(!IsValidMpqHandle(hMpq)) - nError = ERROR_INVALID_HANDLE; - if(szArchivedName == NULL || *szArchivedName == 0) - nError = ERROR_INVALID_PARAMETER; - if(phFile == NULL) - nError = ERROR_INVALID_PARAMETER; - - // Don't allow to add file if the MPQ is open for read only - if(nError == ERROR_SUCCESS) - { - if(ha->dwFlags & MPQ_FLAG_READ_ONLY) - nError = ERROR_ACCESS_DENIED; - - // Don't allow to add a file under pseudo-file name - if(IsPseudoFileName(szArchivedName, NULL)) - nError = ERROR_INVALID_PARAMETER; - - // Don't allow to add any of the internal files - if(IsInternalMpqFileName(szArchivedName)) - nError = ERROR_INTERNAL_FILE; - } - - // Perform validity check of the MPQ flags - if(nError == ERROR_SUCCESS) - { - // Mask all unsupported flags out - dwFlags &= (ha->dwFlags & MPQ_FLAG_WAR3_MAP) ? MPQ_FILE_VALID_FLAGS_W3X : MPQ_FILE_VALID_FLAGS; - - // Check for valid flag combinations - if((dwFlags & (MPQ_FILE_IMPLODE | MPQ_FILE_COMPRESS)) == (MPQ_FILE_IMPLODE | MPQ_FILE_COMPRESS)) - nError = ERROR_INVALID_PARAMETER; - } - - // Initiate the add file operation - if(nError == ERROR_SUCCESS) - nError = SFileAddFile_Init(ha, szArchivedName, FileTime, dwFileSize, lcLocale, dwFlags, (TMPQFile **)phFile); - - // Deal with the errors - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (nError == ERROR_SUCCESS); -} - -bool WINAPI SFileWriteFile( - HANDLE hFile, - const void * pvData, - DWORD dwSize, - DWORD dwCompression) -{ - TMPQFile * hf = (TMPQFile *)hFile; - int nError = ERROR_SUCCESS; - - // Check the proper parameters - if(!IsValidFileHandle(hFile)) - nError = ERROR_INVALID_HANDLE; - if(hf->bIsWriteHandle == false) - nError = ERROR_INVALID_HANDLE; - - // Special checks for single unit files - if(nError == ERROR_SUCCESS && (hf->pFileEntry->dwFlags & MPQ_FILE_SINGLE_UNIT)) - { - // - // Note: Blizzard doesn't support single unit files - // that are stored as encrypted or imploded. We will allow them here, - // the calling application must ensure that such flag combination doesn't get here - // - -// if(dwFlags & MPQ_FILE_IMPLODE) -// nError = ERROR_INVALID_PARAMETER; -// -// if(dwFlags & MPQ_FILE_ENCRYPTED) -// nError = ERROR_INVALID_PARAMETER; - - // Lossy compression is not allowed on single unit files - if(dwCompression & MPQ_LOSSY_COMPRESSION_MASK) - nError = ERROR_INVALID_PARAMETER; - } - - - // Write the data to the file - if(nError == ERROR_SUCCESS) - nError = SFileAddFile_Write(hf, pvData, dwSize, dwCompression); - - // Deal with errors - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (nError == ERROR_SUCCESS); -} - -bool WINAPI SFileFinishFile(HANDLE hFile) -{ - TMPQFile * hf = (TMPQFile *)hFile; - int nError = ERROR_SUCCESS; - - // Check the proper parameters - if(!IsValidFileHandle(hFile)) - nError = ERROR_INVALID_HANDLE; - if(hf->bIsWriteHandle == false) - nError = ERROR_INVALID_HANDLE; - - // Finish the file - if(nError == ERROR_SUCCESS) - nError = SFileAddFile_Finish(hf); - - // Deal with errors - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (nError == ERROR_SUCCESS); -} - -//----------------------------------------------------------------------------- -// Adds a file to the archive - -bool WINAPI SFileAddFileEx( - HANDLE hMpq, - const TCHAR * szFileName, - const char * szArchivedName, - DWORD dwFlags, - DWORD dwCompression, // Compression of the first sector - DWORD dwCompressionNext) // Compression of next sectors -{ - ULONGLONG FileSize = 0; - ULONGLONG FileTime = 0; - TFileStream * pStream = NULL; - HANDLE hMpqFile = NULL; - LPBYTE pbFileData = NULL; - DWORD dwBytesRemaining = 0; - DWORD dwBytesToRead; - DWORD dwSectorSize = 0x1000; - DWORD dwChannels = 0; - bool bIsAdpcmCompression = false; - bool bIsFirstSector = true; - int nError = ERROR_SUCCESS; - - // Check parameters - if(hMpq == NULL || szFileName == NULL || *szFileName == 0) - { - SetLastError(ERROR_INVALID_PARAMETER); - return false; - } - - // Open added file - pStream = FileStream_OpenFile(szFileName, STREAM_FLAG_READ_ONLY | STREAM_PROVIDER_FLAT | BASE_PROVIDER_FILE); - if(pStream == NULL) - return false; - - // Files bigger than 4GB cannot be added to MPQ - FileStream_GetTime(pStream, &FileTime); - FileStream_GetSize(pStream, &FileSize); - if(FileSize >> 32) - nError = ERROR_DISK_FULL; - - // Allocate data buffer for reading from the source file - if(nError == ERROR_SUCCESS) - { - dwBytesRemaining = (DWORD)FileSize; - pbFileData = STORM_ALLOC(BYTE, dwSectorSize); - if(pbFileData == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Deal with various combination of compressions - if(nError == ERROR_SUCCESS) - { - // When the compression for next blocks is set to default, - // we will copy the compression for the first sector - if(dwCompressionNext == MPQ_COMPRESSION_NEXT_SAME) - dwCompressionNext = dwCompression; - - // If the caller wants ADPCM compression, we make sure - // that the first sector is not compressed with lossy compression - if(dwCompressionNext & (MPQ_COMPRESSION_ADPCM_MONO | MPQ_COMPRESSION_ADPCM_STEREO)) - { - // The compression of the first file sector must not be ADPCM - // in order not to corrupt the headers - if(dwCompression & (MPQ_COMPRESSION_ADPCM_MONO | MPQ_COMPRESSION_ADPCM_STEREO)) - dwCompression = MPQ_COMPRESSION_PKWARE; - - // Remove both flag mono and stereo flags. - // They will be re-added according to WAVE type - dwCompressionNext &= ~(MPQ_COMPRESSION_ADPCM_MONO | MPQ_COMPRESSION_ADPCM_STEREO); - bIsAdpcmCompression = true; - } - - // Initiate adding file to the MPQ - if(!SFileCreateFile(hMpq, szArchivedName, FileTime, (DWORD)FileSize, lcFileLocale, dwFlags, &hMpqFile)) - nError = GetLastError(); - } - - // Write the file data to the MPQ - while(nError == ERROR_SUCCESS && dwBytesRemaining != 0) - { - // Get the number of bytes remaining in the source file - dwBytesToRead = dwBytesRemaining; - if(dwBytesToRead > dwSectorSize) - dwBytesToRead = dwSectorSize; - - // Read data from the local file - if(!FileStream_Read(pStream, NULL, pbFileData, dwBytesToRead)) - { - nError = GetLastError(); - break; - } - - // If the file being added is a WAVE file, we check number of channels - if(bIsFirstSector && bIsAdpcmCompression) - { - // The file must really be a WAVE file with at least 16 bits per sample, - // otherwise the ADPCM compression will corrupt it - if(IsWaveFile_16BitsPerAdpcmSample(pbFileData, dwBytesToRead, &dwChannels)) - { - // Setup the compression of next sectors according to number of channels - dwCompressionNext |= (dwChannels == 1) ? MPQ_COMPRESSION_ADPCM_MONO : MPQ_COMPRESSION_ADPCM_STEREO; - } - else - { - // Setup the compression of next sectors to a lossless compression - dwCompressionNext = (dwCompression & MPQ_LOSSY_COMPRESSION_MASK) ? MPQ_COMPRESSION_PKWARE : dwCompression; - } - - bIsFirstSector = false; - } - - // Add the file sectors to the MPQ - if(!SFileWriteFile(hMpqFile, pbFileData, dwBytesToRead, dwCompression)) - { - nError = GetLastError(); - break; - } - - // Set the next data compression - dwBytesRemaining -= dwBytesToRead; - dwCompression = dwCompressionNext; - } - - // Finish the file writing - if(hMpqFile != NULL) - { - if(!SFileFinishFile(hMpqFile)) - nError = GetLastError(); - } - - // Cleanup and exit - if(pbFileData != NULL) - STORM_FREE(pbFileData); - if(pStream != NULL) - FileStream_Close(pStream); - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (nError == ERROR_SUCCESS); -} - -// Adds a data file into the archive -bool WINAPI SFileAddFile(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags) -{ - return SFileAddFileEx(hMpq, - szFileName, - szArchivedName, - dwFlags, - DefaultDataCompression, - DefaultDataCompression); -} - -// Adds a WAVE file into the archive -bool WINAPI SFileAddWave(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality) -{ - DWORD dwCompression = 0; - - // - // Note to wave compression level: - // The following conversion table applied: - // High quality: WaveCompressionLevel = -1 - // Medium quality: WaveCompressionLevel = 4 - // Low quality: WaveCompressionLevel = 2 - // - // Starcraft files are packed as Mono (0x41) on medium quality. - // Because this compression is not used anymore, our compression functions - // will default to WaveCompressionLevel = 4 when using ADPCM compression - // - - // Convert quality to data compression - switch(dwQuality) - { - case MPQ_WAVE_QUALITY_HIGH: -// WaveCompressionLevel = -1; - dwCompression = MPQ_COMPRESSION_PKWARE; - break; - - case MPQ_WAVE_QUALITY_MEDIUM: -// WaveCompressionLevel = 4; - dwCompression = MPQ_COMPRESSION_ADPCM_STEREO | MPQ_COMPRESSION_HUFFMANN; - break; - - case MPQ_WAVE_QUALITY_LOW: -// WaveCompressionLevel = 2; - dwCompression = MPQ_COMPRESSION_ADPCM_STEREO | MPQ_COMPRESSION_HUFFMANN; - break; - } - - return SFileAddFileEx(hMpq, - szFileName, - szArchivedName, - dwFlags, - MPQ_COMPRESSION_PKWARE, // First sector should be compressed as data - dwCompression); // Next sectors should be compressed as WAVE -} - -//----------------------------------------------------------------------------- -// bool SFileRemoveFile(HANDLE hMpq, char * szFileName) -// -// This function removes a file from the archive. -// - -bool WINAPI SFileRemoveFile(HANDLE hMpq, const char * szFileName, DWORD dwSearchScope) -{ - TMPQArchive * ha = IsValidMpqHandle(hMpq); - TMPQFile * hf = NULL; - int nError = ERROR_SUCCESS; - - // Keep compiler happy - dwSearchScope = dwSearchScope; - - // Check the parameters - if(ha == NULL) - nError = ERROR_INVALID_HANDLE; - if(szFileName == NULL || *szFileName == 0) - nError = ERROR_INVALID_PARAMETER; - if(IsInternalMpqFileName(szFileName)) - nError = ERROR_INTERNAL_FILE; - - // Do not allow to remove files from read-only or patched MPQs - if(nError == ERROR_SUCCESS) - { - if((ha->dwFlags & MPQ_FLAG_READ_ONLY) || (ha->haPatch != NULL)) - nError = ERROR_ACCESS_DENIED; - } - - // If all checks have passed, we can delete the file from the MPQ - if(nError == ERROR_SUCCESS) - { - // Open the file from the MPQ - if(SFileOpenFileEx(hMpq, szFileName, SFILE_OPEN_BASE_FILE, (HANDLE *)&hf)) - { - // Delete the file entry - nError = DeleteFileEntry(ha, hf); - FreeFileHandle(hf); - } - else - nError = GetLastError(); - } - - // If the file has been deleted, we need to invalidate - // the internal files and recreate HET table - if(nError == ERROR_SUCCESS) - { - // Invalidate the entries for internal files - // After we are done with MPQ changes, we need to re-create them anyway - InvalidateInternalFiles(ha); - - // - // Don't rebuild HET table now; the file's flags indicate - // that it's been deleted, which is enough - // - } - - // Resolve error and exit - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (nError == ERROR_SUCCESS); -} - -// Renames the file within the archive. -bool WINAPI SFileRenameFile(HANDLE hMpq, const char * szFileName, const char * szNewFileName) -{ - TMPQArchive * ha = IsValidMpqHandle(hMpq); - TMPQFile * hf; - int nError = ERROR_SUCCESS; - - // Test the valid parameters - if(ha == NULL) - nError = ERROR_INVALID_HANDLE; - if(szFileName == NULL || *szFileName == 0 || szNewFileName == NULL || *szNewFileName == 0) - nError = ERROR_INVALID_PARAMETER; - if(IsInternalMpqFileName(szFileName) || IsInternalMpqFileName(szNewFileName)) - nError = ERROR_INTERNAL_FILE; - - // Do not allow to rename files in MPQ open for read only - if(nError == ERROR_SUCCESS) - { - if(ha->dwFlags & MPQ_FLAG_READ_ONLY) - nError = ERROR_ACCESS_DENIED; - } - - // Open the new file. If exists, we don't allow rename operation - if(nError == ERROR_SUCCESS) - { - if(GetFileEntryLocale(ha, szNewFileName, lcFileLocale) != NULL) - nError = ERROR_ALREADY_EXISTS; - } - - // Open the file from the MPQ - if(nError == ERROR_SUCCESS) - { - // Attempt to open the file - if(SFileOpenFileEx(hMpq, szFileName, SFILE_OPEN_BASE_FILE, (HANDLE *)&hf)) - { - ULONGLONG RawDataOffs; - TFileEntry * pFileEntry = hf->pFileEntry; - - // Invalidate the entries for internal files - InvalidateInternalFiles(ha); - - // Rename the file entry in the table - nError = RenameFileEntry(ha, hf, szNewFileName); - - // If the file is encrypted, we have to re-crypt the file content - // with the new decryption key - if((nError == ERROR_SUCCESS) && (pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED)) - { - // Recrypt the file data in the MPQ - nError = RecryptFileData(ha, hf, szFileName, szNewFileName); - - // Update the MD5 of the raw block - if(nError == ERROR_SUCCESS && ha->pHeader->dwRawChunkSize != 0) - { - RawDataOffs = ha->MpqPos + pFileEntry->ByteOffset; - WriteMpqDataMD5(ha->pStream, - RawDataOffs, - pFileEntry->dwCmpSize, - ha->pHeader->dwRawChunkSize); - } - } - - // Free the file handle - FreeFileHandle(hf); - } - else - { - nError = GetLastError(); - } - } - - // We also need to rebuild the HET table, if present - if(nError == ERROR_SUCCESS && ha->pHetTable != NULL) - nError = RebuildHetTable(ha); - - // Resolve error and exit - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (nError == ERROR_SUCCESS); -} - -//----------------------------------------------------------------------------- -// Sets default data compression for SFileAddFile - -bool WINAPI SFileSetDataCompression(DWORD DataCompression) -{ - unsigned int uValidMask = (MPQ_COMPRESSION_ZLIB | MPQ_COMPRESSION_PKWARE | MPQ_COMPRESSION_BZIP2 | MPQ_COMPRESSION_SPARSE); - - if((DataCompression & uValidMask) != DataCompression) - { - SetLastError(ERROR_INVALID_PARAMETER); - return false; - } - - DefaultDataCompression = DataCompression; - return true; -} - -//----------------------------------------------------------------------------- -// Changes locale ID of a file - -bool WINAPI SFileSetFileLocale(HANDLE hFile, LCID lcNewLocale) -{ - TMPQArchive * ha; - TFileEntry * pFileEntry; - TMPQFile * hf = IsValidFileHandle(hFile); - - // Invalid handle => do nothing - if(hf == NULL) - { - SetLastError(ERROR_INVALID_HANDLE); - return false; - } - - // Do not allow to rename files in MPQ open for read only - ha = hf->ha; - if(ha->dwFlags & MPQ_FLAG_READ_ONLY) - { - SetLastError(ERROR_ACCESS_DENIED); - return false; - } - - // Do not allow unnamed access - if(hf->pFileEntry->szFileName == NULL) - { - SetLastError(ERROR_CAN_NOT_COMPLETE); - return false; - } - - // Do not allow to change locale of any internal file - if(IsInternalMpqFileName(hf->pFileEntry->szFileName)) - { - SetLastError(ERROR_INTERNAL_FILE); - return false; - } - - // Do not allow changing file locales if there is no hash table - if(hf->pHashEntry == NULL) - { - SetLastError(ERROR_NOT_SUPPORTED); - return false; - } - - // We have to check if the file+locale is not already there - pFileEntry = GetFileEntryExact(ha, hf->pFileEntry->szFileName, lcNewLocale, NULL); - if(pFileEntry != NULL) - { - SetLastError(ERROR_ALREADY_EXISTS); - return false; - } - - // Update the locale in the hash table entry - hf->pHashEntry->lcLocale = (USHORT)lcNewLocale; - ha->dwFlags |= MPQ_FLAG_CHANGED; - return true; -} - -//----------------------------------------------------------------------------- -// Sets add file callback - -bool WINAPI SFileSetAddFileCallback(HANDLE hMpq, SFILE_ADDFILE_CALLBACK AddFileCB, void * pvUserData) -{ - TMPQArchive * ha = (TMPQArchive *) hMpq; - - if(!IsValidMpqHandle(hMpq)) - { - SetLastError(ERROR_INVALID_HANDLE); - return false; - } - - ha->pvAddFileUserData = pvUserData; - ha->pfnAddFileCB = AddFileCB; - return true; -} diff --git a/libs/storm-sys/StormLib/src/SFileAttributes.cpp b/libs/storm-sys/StormLib/src/SFileAttributes.cpp deleted file mode 100644 index d565be7..0000000 --- a/libs/storm-sys/StormLib/src/SFileAttributes.cpp +++ /dev/null @@ -1,570 +0,0 @@ -/*****************************************************************************/ -/* SAttrFile.cpp Copyright (c) Ladislav Zezula 2007 */ -/*---------------------------------------------------------------------------*/ -/* Description: */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 12.06.04 1.00 Lad The first version of SAttrFile.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "StormCommon.h" - -//----------------------------------------------------------------------------- -// Local structures - -typedef struct _MPQ_ATTRIBUTES_HEADER -{ - DWORD dwVersion; // Version of the (attributes) file. Must be 100 (0x64) - DWORD dwFlags; // See MPQ_ATTRIBUTE_XXXX - - // Followed by an array of CRC32 - // Followed by an array of file times - // Followed by an array of MD5 - // Followed by an array of patch bits - - // Note: The MD5 in (attributes), if present, is a hash of the entire file. - // In case the file is an incremental patch, it contains MD5 of the file - // after being patched. - -} MPQ_ATTRIBUTES_HEADER, *PMPQ_ATTRIBUTES_HEADER; - -//----------------------------------------------------------------------------- -// Local functions - -static DWORD GetSizeOfAttributesFile(DWORD dwAttrFlags, DWORD dwBlockTableSize) -{ - DWORD cbAttrFile = sizeof(MPQ_ATTRIBUTES_HEADER); - - // Calculate size of the (attributes) file - if(dwAttrFlags & MPQ_ATTRIBUTE_CRC32) - cbAttrFile += dwBlockTableSize * sizeof(DWORD); - if(dwAttrFlags & MPQ_ATTRIBUTE_FILETIME) - cbAttrFile += dwBlockTableSize * sizeof(ULONGLONG); - if(dwAttrFlags & MPQ_ATTRIBUTE_MD5) - cbAttrFile += dwBlockTableSize * MD5_DIGEST_SIZE; - - // The bit array has been created without the last bit belonging to (attributes) - // When the number of files is a multiplier of 8 plus one, then the size of (attributes) - // if 1 byte less than expected. - // Example: wow-update-13164.MPQ: BlockTableSize = 0x62E1, but there's only 0xC5C bytes - if(dwAttrFlags & MPQ_ATTRIBUTE_PATCH_BIT) - cbAttrFile += (dwBlockTableSize + 6) / 8; - - return cbAttrFile; -} - -static DWORD CheckSizeOfAttributesFile(DWORD cbAttrFile, DWORD dwAttrFlags, DWORD dwBlockTableSize) -{ - DWORD cbHeaderSize = sizeof(MPQ_ATTRIBUTES_HEADER); - DWORD cbChecksumSize1 = 0; - DWORD cbChecksumSize2 = 0; - DWORD cbFileTimeSize1 = 0; - DWORD cbFileTimeSize2 = 0; - DWORD cbFileHashSize1 = 0; - DWORD cbFileHashSize2 = 0; - DWORD cbPatchBitSize1 = 0; - DWORD cbPatchBitSize2 = 0; - DWORD cbPatchBitSize3 = 0; - - // - // Various variants with the patch bit - // - // interface.MPQ.part from WoW build 10958 has - // the MPQ_ATTRIBUTE_PATCH_BIT set, but there's an array of DWORDs instead. - // The array is filled with zeros, so we don't know what it should contain - // - // Zenith.SC2MAP has the MPQ_ATTRIBUTE_PATCH_BIT set, but the bit array is missing - // - // Elimination Tournament 2.w3x's (attributes) have one entry less - // - // There may be two variants: Either the (attributes) file has full - // number of entries, or has one entry less - // - - // Get the expected size of CRC32 array - if(dwAttrFlags & MPQ_ATTRIBUTE_CRC32) - { - cbChecksumSize1 += dwBlockTableSize * sizeof(DWORD); - cbChecksumSize2 += cbChecksumSize1 - sizeof(DWORD); - } - - // Get the expected size of FILETIME array - if(dwAttrFlags & MPQ_ATTRIBUTE_FILETIME) - { - cbFileTimeSize1 += dwBlockTableSize * sizeof(ULONGLONG); - cbFileTimeSize2 += cbFileTimeSize1 - sizeof(ULONGLONG); - } - - // Get the expected size of MD5 array - if(dwAttrFlags & MPQ_ATTRIBUTE_MD5) - { - cbFileHashSize1 += dwBlockTableSize * MD5_DIGEST_SIZE; - cbFileHashSize2 += cbFileHashSize1 - MD5_DIGEST_SIZE; - } - - // Get the expected size of patch bit array - if(dwAttrFlags & MPQ_ATTRIBUTE_PATCH_BIT) - { - cbPatchBitSize1 = - cbPatchBitSize2 = ((dwBlockTableSize + 6) / 8); - cbPatchBitSize3 = dwBlockTableSize * sizeof(DWORD); - } - - // Check if the (attributes) file entry count is equal to our file table size - if(cbAttrFile == (cbHeaderSize + cbChecksumSize1 + cbFileTimeSize1 + cbFileHashSize1 + cbPatchBitSize1)) - return dwBlockTableSize; - - // Check if the (attributes) file entry count is equal to our file table size minus one - if(cbAttrFile == (cbHeaderSize + cbChecksumSize2 + cbFileTimeSize2 + cbFileHashSize2 + cbPatchBitSize2)) - return dwBlockTableSize - 1; - - // Zenith.SC2MAP has the MPQ_ATTRIBUTE_PATCH_BIT set, but the bit array is missing - if(cbAttrFile == (cbHeaderSize + cbChecksumSize1 + cbFileTimeSize1 + cbFileHashSize1)) - return dwBlockTableSize; - - // interface.MPQ.part (WoW build 10958) has the MPQ_ATTRIBUTE_PATCH_BIT set - // but there's an array of DWORDs (filled with zeros) instead of array of bits - if(cbAttrFile == (cbHeaderSize + cbChecksumSize1 + cbFileTimeSize1 + cbFileHashSize1 + cbPatchBitSize3)) - return dwBlockTableSize; - -#ifdef __STORMLIB_TEST__ - // Invalid size of the (attributes) file - // Note that many MPQs, especially Warcraft III maps have the size of (attributes) invalid. - // We only perform this check if this is the STORMLIB testprogram itself -// assert(false); -#endif - - return 0; -} - -static int LoadAttributesFile(TMPQArchive * ha, LPBYTE pbAttrFile, DWORD cbAttrFile) -{ - LPBYTE pbAttrFileEnd = pbAttrFile + cbAttrFile; - LPBYTE pbAttrPtr = pbAttrFile; - DWORD dwAttributesEntries = 0; - DWORD i; - - // Load and verify the header - if((pbAttrPtr + sizeof(MPQ_ATTRIBUTES_HEADER)) <= pbAttrFileEnd) - { - PMPQ_ATTRIBUTES_HEADER pAttrHeader = (PMPQ_ATTRIBUTES_HEADER)pbAttrPtr; - - // Verify the header version - BSWAP_ARRAY32_UNSIGNED(pAttrHeader, sizeof(MPQ_ATTRIBUTES_HEADER)); - if(pAttrHeader->dwVersion != MPQ_ATTRIBUTES_V1) - return ERROR_BAD_FORMAT; - - // Verify the flags - if(pAttrHeader->dwFlags & ~MPQ_ATTRIBUTE_ALL) - return ERROR_BAD_FORMAT; - - // Verify whether file size of (attributes) is expected - dwAttributesEntries = CheckSizeOfAttributesFile(cbAttrFile, pAttrHeader->dwFlags, ha->pHeader->dwBlockTableSize); - if(dwAttributesEntries == 0) - return ERROR_BAD_FORMAT; - - ha->dwAttrFlags = pAttrHeader->dwFlags; - pbAttrPtr = (LPBYTE)(pAttrHeader + 1); - } - - // Load the CRC32 (if present) - if(ha->dwAttrFlags & MPQ_ATTRIBUTE_CRC32) - { - LPDWORD ArrayCRC32 = (LPDWORD)pbAttrPtr; - DWORD cbArraySize = dwAttributesEntries * sizeof(DWORD); - - // Verify if there's enough data - if((pbAttrPtr + cbArraySize) > pbAttrFileEnd) - return ERROR_FILE_CORRUPT; - - BSWAP_ARRAY32_UNSIGNED(ArrayCRC32, cbCRC32Size); - for(i = 0; i < dwAttributesEntries; i++) - ha->pFileTable[i].dwCrc32 = ArrayCRC32[i]; - pbAttrPtr += cbArraySize; - } - - // Load the FILETIME (if present) - if(ha->dwAttrFlags & MPQ_ATTRIBUTE_FILETIME) - { - ULONGLONG * ArrayFileTime = (ULONGLONG *)pbAttrPtr; - DWORD cbArraySize = dwAttributesEntries * sizeof(ULONGLONG); - - // Verify if there's enough data - if((pbAttrPtr + cbArraySize) > pbAttrFileEnd) - return ERROR_FILE_CORRUPT; - - BSWAP_ARRAY64_UNSIGNED(ArrayFileTime, cbFileTimeSize); - for(i = 0; i < dwAttributesEntries; i++) - ha->pFileTable[i].FileTime = ArrayFileTime[i]; - pbAttrPtr += cbArraySize; - } - - // Load the MD5 (if present) - if(ha->dwAttrFlags & MPQ_ATTRIBUTE_MD5) - { - LPBYTE ArrayMd5 = pbAttrPtr; - DWORD cbArraySize = dwAttributesEntries * MD5_DIGEST_SIZE; - - // Verify if there's enough data - if((pbAttrPtr + cbArraySize) > pbAttrFileEnd) - return ERROR_FILE_CORRUPT; - - for(i = 0; i < dwAttributesEntries; i++) - { - memcpy(ha->pFileTable[i].md5, ArrayMd5, MD5_DIGEST_SIZE); - ArrayMd5 += MD5_DIGEST_SIZE; - } - pbAttrPtr += cbArraySize; - } - - // Read the patch bit for each file (if present) - if(ha->dwAttrFlags & MPQ_ATTRIBUTE_PATCH_BIT) - { - LPBYTE pbBitArray = pbAttrPtr; - DWORD cbArraySize = (dwAttributesEntries + 7) / 8; - DWORD dwByteIndex = 0; - DWORD dwBitMask = 0x80; - - // Verify if there's enough data - if((pbAttrPtr + cbArraySize) == pbAttrFileEnd) - { - for(i = 0; i < dwAttributesEntries; i++) - { - ha->pFileTable[i].dwFlags |= (pbBitArray[dwByteIndex] & dwBitMask) ? MPQ_FILE_PATCH_FILE : 0; - dwByteIndex += (dwBitMask & 0x01); - dwBitMask = (dwBitMask << 0x07) | (dwBitMask >> 0x01); - } - } - } - - return ERROR_SUCCESS; -} - -static LPBYTE CreateAttributesFile(TMPQArchive * ha, DWORD * pcbAttrFile) -{ - PMPQ_ATTRIBUTES_HEADER pAttrHeader; - TFileEntry * pFileTableEnd = ha->pFileTable + ha->pHeader->dwBlockTableSize; - TFileEntry * pFileEntry; - LPBYTE pbAttrFile; - LPBYTE pbAttrPtr; - size_t cbAttrFile; - - // Check if we need patch bits in the (attributes) file - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - { - if(pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) - { - ha->dwAttrFlags |= MPQ_ATTRIBUTE_PATCH_BIT; - break; - } - } - - // Allocate the buffer for holding the entire (attributes) - // Allocate 1 byte more (See GetSizeOfAttributesFile for more info) - cbAttrFile = GetSizeOfAttributesFile(ha->dwAttrFlags, ha->pHeader->dwBlockTableSize); - pbAttrFile = pbAttrPtr = STORM_ALLOC(BYTE, cbAttrFile + 1); - if(pbAttrFile != NULL) - { - // Make sure it's all zeroed - memset(pbAttrFile, 0, cbAttrFile + 1); - - // Write the header of the (attributes) file - pAttrHeader = (PMPQ_ATTRIBUTES_HEADER)pbAttrPtr; - pAttrHeader->dwVersion = BSWAP_INT32_UNSIGNED(100); - pAttrHeader->dwFlags = BSWAP_INT32_UNSIGNED((ha->dwAttrFlags & MPQ_ATTRIBUTE_ALL)); - pbAttrPtr = (LPBYTE)(pAttrHeader + 1); - - // Write the array of CRC32, if present - if(ha->dwAttrFlags & MPQ_ATTRIBUTE_CRC32) - { - LPDWORD pArrayCRC32 = (LPDWORD)pbAttrPtr; - - // Copy from file table - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - *pArrayCRC32++ = BSWAP_INT32_UNSIGNED(pFileEntry->dwCrc32); - - // Update pointer - pbAttrPtr = (LPBYTE)pArrayCRC32; - } - - // Write the array of file time - if(ha->dwAttrFlags & MPQ_ATTRIBUTE_FILETIME) - { - ULONGLONG * pArrayFileTime = (ULONGLONG *)pbAttrPtr; - - // Copy from file table - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - *pArrayFileTime++ = BSWAP_INT64_UNSIGNED(pFileEntry->FileTime); - - // Update pointer - pbAttrPtr = (LPBYTE)pArrayFileTime; - } - - // Write the array of MD5s - if(ha->dwAttrFlags & MPQ_ATTRIBUTE_MD5) - { - LPBYTE pbArrayMD5 = pbAttrPtr; - - // Copy from file table - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - { - memcpy(pbArrayMD5, pFileEntry->md5, MD5_DIGEST_SIZE); - pbArrayMD5 += MD5_DIGEST_SIZE; - } - - // Update pointer - pbAttrPtr = pbArrayMD5; - } - - // Write the array of patch bits - if(ha->dwAttrFlags & MPQ_ATTRIBUTE_PATCH_BIT) - { - LPBYTE pbBitArray = pbAttrPtr; - DWORD dwByteIndex = 0; - BYTE dwBitMask = 0x80; - - // Copy from file table - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - { - // Set the bit, if needed - if(pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) - pbBitArray[dwByteIndex] |= dwBitMask; - - // Update bit index and bit mask - dwByteIndex += (dwBitMask & 0x01); - dwBitMask = (dwBitMask << 0x07) | (dwBitMask >> 0x01); - } - - // Move past the bit array - pbAttrPtr += (ha->pHeader->dwBlockTableSize + 6) / 8; - } - - // Now we expect that current position matches the estimated size - // Note that if there is 1 extra bit above the byte size, - // the table is actually 1 byte shorter in Blizzard MPQs. See GetSizeOfAttributesFile - assert((size_t)(pbAttrPtr - pbAttrFile) == cbAttrFile); - } - - // Give away the attributes file - if(pcbAttrFile != NULL) - *pcbAttrFile = (DWORD)cbAttrFile; - return pbAttrFile; -} - -//----------------------------------------------------------------------------- -// Public functions (internal use by StormLib) - -int SAttrLoadAttributes(TMPQArchive * ha) -{ - HANDLE hFile = NULL; - LPBYTE pbAttrFile; - DWORD dwBytesRead; - DWORD cbAttrFile = 0; - int nError = ERROR_FILE_CORRUPT; - - // File table must be initialized - assert(ha->pFileTable != NULL); - assert((ha->dwFlags & MPQ_FLAG_BLOCK_TABLE_CUT) == 0); - - // Don't load the attributes file from malformed Warcraft III maps - if(ha->dwFlags & MPQ_FLAG_MALFORMED) - return ERROR_FILE_CORRUPT; - - // Attempt to open the "(attributes)" file. - if(SFileOpenFileEx((HANDLE)ha, ATTRIBUTES_NAME, SFILE_OPEN_ANY_LOCALE, &hFile)) - { - // Retrieve and check size of the (attributes) file - cbAttrFile = SFileGetFileSize(hFile, NULL); - - // Integer overflow check - if((cbAttrFile + 1) > cbAttrFile) - { - // Size of the (attributes) might be 1 byte less than expected - // See GetSizeOfAttributesFile for more info - pbAttrFile = STORM_ALLOC(BYTE, cbAttrFile + 1); - if(pbAttrFile != NULL) - { - // Set the last byte to 0 in case the size should be 1 byte greater - pbAttrFile[cbAttrFile] = 0; - - // Load the entire file to memory - SFileReadFile(hFile, pbAttrFile, cbAttrFile, &dwBytesRead, NULL); - if(dwBytesRead == cbAttrFile) - nError = LoadAttributesFile(ha, pbAttrFile, cbAttrFile); - - // Free the buffer - STORM_FREE(pbAttrFile); - } - } - - // Close the attributes file - SFileCloseFile(hFile); - } - - return nError; -} - -// Saves the (attributes) to the MPQ -int SAttrFileSaveToMpq(TMPQArchive * ha) -{ - TMPQFile * hf = NULL; - LPBYTE pbAttrFile; - DWORD cbAttrFile = 0; - int nError = ERROR_SUCCESS; - - // Only save the attributes if we should do so - if(ha->dwFileFlags2 != 0) - { - // At this point, we expect to have at least one reserved entry in the file table - assert(ha->dwFlags & MPQ_FLAG_ATTRIBUTES_NEW); - assert(ha->dwReservedFiles > 0); - - // Create the raw data that is to be written to (attributes) - // Note: Blizzard MPQs have entries for (listfile) and (attributes), - // but they are filled empty - pbAttrFile = CreateAttributesFile(ha, &cbAttrFile); - if(pbAttrFile != NULL) - { - // Determine the real flags for (attributes) - if(ha->dwFileFlags2 == MPQ_FILE_DEFAULT_INTERNAL) - ha->dwFileFlags2 = GetDefaultSpecialFileFlags(cbAttrFile, ha->pHeader->wFormatVersion); - - // Create the attributes file in the MPQ - nError = SFileAddFile_Init(ha, ATTRIBUTES_NAME, - 0, - cbAttrFile, - LANG_NEUTRAL, - ha->dwFileFlags2 | MPQ_FILE_REPLACEEXISTING, - &hf); - - // Write the attributes file raw data to it - if(nError == ERROR_SUCCESS) - { - // Write the content of the attributes file to the MPQ - nError = SFileAddFile_Write(hf, pbAttrFile, cbAttrFile, MPQ_COMPRESSION_ZLIB); - SFileAddFile_Finish(hf); - } - - // Clear the number of reserved files - ha->dwFlags &= ~(MPQ_FLAG_ATTRIBUTES_NEW | MPQ_FLAG_ATTRIBUTES_NONE); - ha->dwReservedFiles--; - - // Free the attributes buffer - STORM_FREE(pbAttrFile); - } - else - { - // If the (attributes) file would be empty, its OK - nError = (cbAttrFile == 0) ? ERROR_SUCCESS : ERROR_NOT_ENOUGH_MEMORY; - } - } - - return nError; -} - -//----------------------------------------------------------------------------- -// Public functions - -DWORD WINAPI SFileGetAttributes(HANDLE hMpq) -{ - TMPQArchive * ha = (TMPQArchive *)hMpq; - - // Verify the parameters - if(!IsValidMpqHandle(hMpq)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return SFILE_INVALID_ATTRIBUTES; - } - - return ha->dwAttrFlags; -} - -bool WINAPI SFileSetAttributes(HANDLE hMpq, DWORD dwFlags) -{ - TMPQArchive * ha = (TMPQArchive *)hMpq; - - // Verify the parameters - if(!IsValidMpqHandle(hMpq)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return false; - } - - // Not allowed when the archive is read-only - if(ha->dwFlags & MPQ_FLAG_READ_ONLY) - { - SetLastError(ERROR_ACCESS_DENIED); - return false; - } - - // Set the attributes - InvalidateInternalFiles(ha); - ha->dwAttrFlags = (dwFlags & MPQ_ATTRIBUTE_ALL); - return true; -} - -bool WINAPI SFileUpdateFileAttributes(HANDLE hMpq, const char * szFileName) -{ - hash_state md5_state; - TMPQArchive * ha = (TMPQArchive *)hMpq; - TMPQFile * hf; - BYTE Buffer[0x1000]; - HANDLE hFile = NULL; - DWORD dwTotalBytes = 0; - DWORD dwBytesRead; - DWORD dwCrc32; - - // Verify the parameters - if(!IsValidMpqHandle(ha)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return false; - } - - // Not allowed when the archive is read-only - if(ha->dwFlags & MPQ_FLAG_READ_ONLY) - { - SetLastError(ERROR_ACCESS_DENIED); - return false; - } - - // Attempt to open the file - if(!SFileOpenFileEx(hMpq, szFileName, SFILE_OPEN_BASE_FILE, &hFile)) - return false; - - // Get the file size - hf = (TMPQFile *)hFile; - dwTotalBytes = hf->pFileEntry->dwFileSize; - - // Initialize the CRC32 and MD5 contexts - md5_init(&md5_state); - dwCrc32 = crc32(0, Z_NULL, 0); - - // Go through entire file and calculate both CRC32 and MD5 - while(dwTotalBytes != 0) - { - // Read data from file - SFileReadFile(hFile, Buffer, sizeof(Buffer), &dwBytesRead, NULL); - if(dwBytesRead == 0) - break; - - // Update CRC32 and MD5 - dwCrc32 = crc32(dwCrc32, Buffer, dwBytesRead); - md5_process(&md5_state, Buffer, dwBytesRead); - - // Decrement the total size - dwTotalBytes -= dwBytesRead; - } - - // Update both CRC32 and MD5 - hf->pFileEntry->dwCrc32 = dwCrc32; - md5_done(&md5_state, hf->pFileEntry->md5); - - // Remember that we need to save the MPQ tables - InvalidateInternalFiles(ha); - SFileCloseFile(hFile); - return true; -} diff --git a/libs/storm-sys/StormLib/src/SFileCompactArchive.cpp b/libs/storm-sys/StormLib/src/SFileCompactArchive.cpp deleted file mode 100644 index 7b3fcd6..0000000 --- a/libs/storm-sys/StormLib/src/SFileCompactArchive.cpp +++ /dev/null @@ -1,654 +0,0 @@ -/*****************************************************************************/ -/* SFileCompactArchive.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Archive compacting function */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 14.04.03 1.00 Lad Splitted from SFileCreateArchiveEx.cpp */ -/* 19.11.03 1.01 Dan Big endian handling */ -/* 21.04.13 1.02 Dea Compact callback now part of TMPQArchive */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "StormCommon.h" - -/*****************************************************************************/ -/* Local functions */ -/*****************************************************************************/ - -static int CheckIfAllFilesKnown(TMPQArchive * ha) -{ - TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; - TFileEntry * pFileEntry; - DWORD dwBlockIndex = 0; - int nError = ERROR_SUCCESS; - - // Verify the file table - if(nError == ERROR_SUCCESS) - { - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++, dwBlockIndex++) - { - // If there is an existing entry in the file table, check its name - if(pFileEntry->dwFlags & MPQ_FILE_EXISTS) - { - // The name must be valid and must not be a pseudo-name - if(pFileEntry->szFileName == NULL || IsPseudoFileName(pFileEntry->szFileName, NULL)) - { - nError = ERROR_UNKNOWN_FILE_NAMES; - break; - } - } - } - } - - return nError; -} - -static int CheckIfAllKeysKnown(TMPQArchive * ha, const TCHAR * szListFile, LPDWORD pFileKeys) -{ - TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; - TFileEntry * pFileEntry; - DWORD dwBlockIndex = 0; - int nError = ERROR_SUCCESS; - - // Add the listfile to the MPQ - if(szListFile != NULL) - { - // Notify the user - if(ha->pfnCompactCB != NULL) - ha->pfnCompactCB(ha->pvCompactUserData, CCB_CHECKING_FILES, ha->CompactBytesProcessed, ha->CompactTotalBytes); - - nError = SFileAddListFile((HANDLE)ha, szListFile); - } - - // Verify the file table - if(nError == ERROR_SUCCESS) - { - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++, dwBlockIndex++) - { - // If the file exists and it's encrypted - if(pFileEntry->dwFlags & MPQ_FILE_EXISTS) - { - // If we know the name, we decrypt the file key from the file name - if(pFileEntry->szFileName != NULL && !IsPseudoFileName(pFileEntry->szFileName, NULL)) - { - // Give the key to the caller - pFileKeys[dwBlockIndex] = DecryptFileKey(pFileEntry->szFileName, - pFileEntry->ByteOffset, - pFileEntry->dwFileSize, - pFileEntry->dwFlags); - continue; - } - - // We don't know the encryption key of this file, - // thus we cannot compact the file - nError = ERROR_UNKNOWN_FILE_NAMES; - break; - } - } - } - - return nError; -} - -static int CopyNonMpqData( - TMPQArchive * ha, - TFileStream * pSrcStream, - TFileStream * pTrgStream, - ULONGLONG & ByteOffset, - ULONGLONG & ByteCount) -{ - ULONGLONG DataSize = ByteCount; - DWORD dwToRead; - char DataBuffer[0x1000]; - int nError = ERROR_SUCCESS; - - // Copy the data - while(DataSize > 0) - { - // Get the proper size of data - dwToRead = sizeof(DataBuffer); - if(DataSize < dwToRead) - dwToRead = (DWORD)DataSize; - - // Read from the source stream - if(!FileStream_Read(pSrcStream, &ByteOffset, DataBuffer, dwToRead)) - { - nError = GetLastError(); - break; - } - - // Write to the target stream - if(!FileStream_Write(pTrgStream, NULL, DataBuffer, dwToRead)) - { - nError = GetLastError(); - break; - } - - // Update the progress - if(ha->pfnCompactCB != NULL) - { - ha->CompactBytesProcessed += dwToRead; - ha->pfnCompactCB(ha->pvCompactUserData, CCB_COPYING_NON_MPQ_DATA, ha->CompactBytesProcessed, ha->CompactTotalBytes); - } - - // Decrement the number of data to be copied - ByteOffset += dwToRead; - DataSize -= dwToRead; - } - - return nError; -} - -// Copies all file sectors into another archive. -static int CopyMpqFileSectors( - TMPQArchive * ha, - TMPQFile * hf, - TFileStream * pNewStream, - ULONGLONG MpqFilePos) // MPQ file position in the new archive -{ - TFileEntry * pFileEntry = hf->pFileEntry; - ULONGLONG RawFilePos; // Used for calculating sector offset in the old MPQ archive - DWORD dwBytesToCopy = pFileEntry->dwCmpSize; - DWORD dwPatchSize = 0; // Size of patch header - DWORD dwFileKey1 = 0; // File key used for decryption - DWORD dwFileKey2 = 0; // File key used for encryption - DWORD dwCmpSize = 0; // Compressed file size, including patch header - int nError = ERROR_SUCCESS; - - // Resolve decryption keys. Note that the file key given - // in the TMPQFile structure also includes the key adjustment - if(nError == ERROR_SUCCESS && (pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED)) - { - dwFileKey2 = dwFileKey1 = hf->dwFileKey; - if(pFileEntry->dwFlags & MPQ_FILE_FIX_KEY) - { - dwFileKey2 = (dwFileKey1 ^ pFileEntry->dwFileSize) - (DWORD)pFileEntry->ByteOffset; - dwFileKey2 = (dwFileKey2 + (DWORD)MpqFilePos) ^ pFileEntry->dwFileSize; - } - } - - // If we have to save patch header, do it - if(nError == ERROR_SUCCESS && hf->pPatchInfo != NULL) - { - BSWAP_ARRAY32_UNSIGNED(hf->pPatchInfo, sizeof(DWORD) * 3); - if(!FileStream_Write(pNewStream, NULL, hf->pPatchInfo, hf->pPatchInfo->dwLength)) - nError = GetLastError(); - - // Save the size of the patch info - dwPatchSize = hf->pPatchInfo->dwLength; - } - - // If we have to save sector offset table, do it. - if(nError == ERROR_SUCCESS && hf->SectorOffsets != NULL) - { - DWORD * SectorOffsetsCopy = STORM_ALLOC(DWORD, hf->SectorOffsets[0] / sizeof(DWORD)); - DWORD dwSectorOffsLen = hf->SectorOffsets[0]; - - assert((pFileEntry->dwFlags & MPQ_FILE_SINGLE_UNIT) == 0); - assert(pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK); - - if(SectorOffsetsCopy == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - - // Encrypt the secondary sector offset table and write it to the target file - if(nError == ERROR_SUCCESS) - { - memcpy(SectorOffsetsCopy, hf->SectorOffsets, dwSectorOffsLen); - if(pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED) - EncryptMpqBlock(SectorOffsetsCopy, dwSectorOffsLen, dwFileKey2 - 1); - - BSWAP_ARRAY32_UNSIGNED(SectorOffsetsCopy, dwSectorOffsLen); - if(!FileStream_Write(pNewStream, NULL, SectorOffsetsCopy, dwSectorOffsLen)) - nError = GetLastError(); - - dwBytesToCopy -= dwSectorOffsLen; - dwCmpSize += dwSectorOffsLen; - } - - // Update compact progress - if(ha->pfnCompactCB != NULL) - { - ha->CompactBytesProcessed += dwSectorOffsLen; - ha->pfnCompactCB(ha->pvCompactUserData, CCB_COMPACTING_FILES, ha->CompactBytesProcessed, ha->CompactTotalBytes); - } - - STORM_FREE(SectorOffsetsCopy); - } - - // Now we have to copy all file sectors. We do it without - // recompression, because recompression is not necessary in this case - if(nError == ERROR_SUCCESS) - { - for(DWORD dwSector = 0; dwSector < hf->dwSectorCount; dwSector++) - { - DWORD dwRawDataInSector = hf->dwSectorSize; - DWORD dwRawByteOffset = dwSector * hf->dwSectorSize; - - // Fix the raw data length if the file is compressed - if(hf->SectorOffsets != NULL) - { - dwRawDataInSector = hf->SectorOffsets[dwSector+1] - hf->SectorOffsets[dwSector]; - dwRawByteOffset = hf->SectorOffsets[dwSector]; - } - - // Last sector: If there is not enough bytes remaining in the file, cut the raw size - if(dwRawDataInSector > dwBytesToCopy) - dwRawDataInSector = dwBytesToCopy; - - // Calculate the raw file offset of the file sector - RawFilePos = CalculateRawSectorOffset(hf, dwRawByteOffset); - - // Read the file sector - if(!FileStream_Read(ha->pStream, &RawFilePos, hf->pbFileSector, dwRawDataInSector)) - { - nError = GetLastError(); - break; - } - - // If necessary, re-encrypt the sector - // Note: Recompression is not necessary here. Unlike encryption, - // the compression does not depend on the position of the file in MPQ. - if((pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED) && dwFileKey1 != dwFileKey2) - { - BSWAP_ARRAY32_UNSIGNED(hf->pbFileSector, dwRawDataInSector); - DecryptMpqBlock(hf->pbFileSector, dwRawDataInSector, dwFileKey1 + dwSector); - EncryptMpqBlock(hf->pbFileSector, dwRawDataInSector, dwFileKey2 + dwSector); - BSWAP_ARRAY32_UNSIGNED(hf->pbFileSector, dwRawDataInSector); - } - - // Now write the sector back to the file - if(!FileStream_Write(pNewStream, NULL, hf->pbFileSector, dwRawDataInSector)) - { - nError = GetLastError(); - break; - } - - // Update compact progress - if(ha->pfnCompactCB != NULL) - { - ha->CompactBytesProcessed += dwRawDataInSector; - ha->pfnCompactCB(ha->pvCompactUserData, CCB_COMPACTING_FILES, ha->CompactBytesProcessed, ha->CompactTotalBytes); - } - - // Adjust byte counts - dwBytesToCopy -= dwRawDataInSector; - dwCmpSize += dwRawDataInSector; - } - } - - // Copy the sector CRCs, if any - // Sector CRCs are always compressed (not imploded) and unencrypted - if(nError == ERROR_SUCCESS && hf->SectorOffsets != NULL && hf->SectorChksums != NULL) - { - DWORD dwCrcLength; - - dwCrcLength = hf->SectorOffsets[hf->dwSectorCount + 1] - hf->SectorOffsets[hf->dwSectorCount]; - if(dwCrcLength != 0) - { - if(!FileStream_Read(ha->pStream, NULL, hf->SectorChksums, dwCrcLength)) - nError = GetLastError(); - - if(!FileStream_Write(pNewStream, NULL, hf->SectorChksums, dwCrcLength)) - nError = GetLastError(); - - // Update compact progress - if(ha->pfnCompactCB != NULL) - { - ha->CompactBytesProcessed += dwCrcLength; - ha->pfnCompactCB(ha->pvCompactUserData, CCB_COMPACTING_FILES, ha->CompactBytesProcessed, ha->CompactTotalBytes); - } - - // Size of the CRC block is also included in the compressed file size - dwBytesToCopy -= dwCrcLength; - dwCmpSize += dwCrcLength; - } - } - - // There might be extra data beyond sector checksum table - // Sometimes, these data are even part of sector offset table - // Examples: - // 2012 - WoW\15354\locale-enGB.MPQ:DBFilesClient\SpellLevels.dbc - // 2012 - WoW\15354\locale-enGB.MPQ:Interface\AddOns\Blizzard_AuctionUI\Blizzard_AuctionUI.xml - if(nError == ERROR_SUCCESS && dwBytesToCopy != 0) - { - LPBYTE pbExtraData; - - // Allocate space for the extra data - pbExtraData = STORM_ALLOC(BYTE, dwBytesToCopy); - if(pbExtraData != NULL) - { - if(!FileStream_Read(ha->pStream, NULL, pbExtraData, dwBytesToCopy)) - nError = GetLastError(); - - if(!FileStream_Write(pNewStream, NULL, pbExtraData, dwBytesToCopy)) - nError = GetLastError(); - - // Include these extra data in the compressed size - dwCmpSize += dwBytesToCopy; - STORM_FREE(pbExtraData); - } - else - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Write the MD5's of the raw file data, if needed - if(nError == ERROR_SUCCESS && ha->pHeader->dwRawChunkSize != 0) - { - nError = WriteMpqDataMD5(pNewStream, - ha->MpqPos + MpqFilePos, - pFileEntry->dwCmpSize, - ha->pHeader->dwRawChunkSize); - } - - // Verify the number of bytes written - if(nError == ERROR_SUCCESS) - { - // At this point, number of bytes written should be exactly - // the same like the compressed file size. If it isn't, - // there's something wrong (an unknown archive version, MPQ malformation, ...) - // - // Note: Diablo savegames have very weird layout, and the file "hero" - // seems to have improper compressed size. Instead of real compressed size, - // the "dwCmpSize" member of the block table entry contains - // uncompressed size of file data + size of the sector table. - // If we compact the archive, Diablo will refuse to load the game - // - // Note: Some patch files in WOW patches don't count the patch header - // into compressed size - // - - if(!(dwCmpSize <= pFileEntry->dwCmpSize && pFileEntry->dwCmpSize <= dwCmpSize + dwPatchSize)) - { - nError = ERROR_FILE_CORRUPT; - assert(false); - } - } - - return nError; -} - -static int CopyMpqFiles(TMPQArchive * ha, LPDWORD pFileKeys, TFileStream * pNewStream) -{ - TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; - TFileEntry * pFileEntry; - TMPQFile * hf = NULL; - ULONGLONG MpqFilePos; - int nError = ERROR_SUCCESS; - - // Walk through all files and write them to the destination MPQ archive - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - { - // Copy all the file sectors - // Only do that when the file has nonzero size - if((pFileEntry->dwFlags & MPQ_FILE_EXISTS)) - { - // Query the position where the destination file will be - FileStream_GetPos(pNewStream, &MpqFilePos); - MpqFilePos = MpqFilePos - ha->MpqPos; - - // Perform file copy ONLY if the file has nonzero size - if(pFileEntry->dwFileSize != 0) - { - // Allocate structure for the MPQ file - hf = CreateFileHandle(ha, pFileEntry); - if(hf == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - // Set the file decryption key - hf->dwFileKey = pFileKeys[pFileEntry - ha->pFileTable]; - - // If the file is a patch file, load the patch header - if(pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) - { - nError = AllocatePatchInfo(hf, true); - if(nError != ERROR_SUCCESS) - break; - } - - // Allocate buffers for file sector and sector offset table - nError = AllocateSectorBuffer(hf); - if(nError != ERROR_SUCCESS) - break; - - // Also allocate sector offset table and sector checksum table - nError = AllocateSectorOffsets(hf, true); - if(nError != ERROR_SUCCESS) - break; - - // Also load sector checksums, if any - if(pFileEntry->dwFlags & MPQ_FILE_SECTOR_CRC) - { - nError = AllocateSectorChecksums(hf, false); - if(nError != ERROR_SUCCESS) - break; - } - - // Copy all file sectors - nError = CopyMpqFileSectors(ha, hf, pNewStream, MpqFilePos); - if(nError != ERROR_SUCCESS) - break; - - // Free buffers. This also sets "hf" to NULL. - FreeFileHandle(hf); - } - - // Note: DO NOT update the compressed size in the file entry, no matter how bad it is. - pFileEntry->ByteOffset = MpqFilePos; - } - } - - // Cleanup and exit - if(hf != NULL) - FreeFileHandle(hf); - return nError; -} - -/*****************************************************************************/ -/* Public functions */ -/*****************************************************************************/ - -//----------------------------------------------------------------------------- -// Changing hash table size - -DWORD WINAPI SFileGetMaxFileCount(HANDLE hMpq) -{ - TMPQArchive * ha = (TMPQArchive *)hMpq; - - return ha->dwMaxFileCount; -} - -bool WINAPI SFileSetMaxFileCount(HANDLE hMpq, DWORD dwMaxFileCount) -{ - TMPQArchive * ha = (TMPQArchive *)hMpq; - DWORD dwNewHashTableSize = 0; - int nError = ERROR_SUCCESS; - - // Test the valid parameters - if(!IsValidMpqHandle(hMpq)) - nError = ERROR_INVALID_HANDLE; - if(ha->dwFlags & MPQ_FLAG_READ_ONLY) - nError = ERROR_ACCESS_DENIED; - if(dwMaxFileCount < ha->dwFileTableSize) - nError = ERROR_DISK_FULL; - - // ALL file names must be known in order to be able to rebuild hash table - if(nError == ERROR_SUCCESS && ha->pHashTable != NULL) - { - nError = CheckIfAllFilesKnown(ha); - if(nError == ERROR_SUCCESS) - { - // Calculate the hash table size for the new file limit - dwNewHashTableSize = GetNearestPowerOfTwo(dwMaxFileCount); - - // Rebuild both file tables - nError = RebuildFileTable(ha, dwNewHashTableSize); - } - } - - // We always have to rebuild the (attributes) file due to file table change - if(nError == ERROR_SUCCESS) - { - // Invalidate (listfile) and (attributes) - InvalidateInternalFiles(ha); - - // Rebuild the HET table, if we have any - if(ha->pHetTable != NULL) - nError = RebuildHetTable(ha); - } - - // Return the error - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (nError == ERROR_SUCCESS); -} - -//----------------------------------------------------------------------------- -// Archive compacting - -bool WINAPI SFileSetCompactCallback(HANDLE hMpq, SFILE_COMPACT_CALLBACK pfnCompactCB, void * pvUserData) -{ - TMPQArchive * ha = (TMPQArchive *) hMpq; - - if (!IsValidMpqHandle(hMpq)) - { - SetLastError(ERROR_INVALID_HANDLE); - return false; - } - - ha->pfnCompactCB = pfnCompactCB; - ha->pvCompactUserData = pvUserData; - return true; -} - -bool WINAPI SFileCompactArchive(HANDLE hMpq, const TCHAR * szListFile, bool /* bReserved */) -{ - TFileStream * pTempStream = NULL; - TMPQArchive * ha = (TMPQArchive *)hMpq; - ULONGLONG ByteOffset; - ULONGLONG ByteCount; - LPDWORD pFileKeys = NULL; - TCHAR szTempFile[MAX_PATH+1] = _T(""); - int nError = ERROR_SUCCESS; - - // Test the valid parameters - if(!IsValidMpqHandle(hMpq)) - nError = ERROR_INVALID_HANDLE; - if(ha->dwFlags & MPQ_FLAG_READ_ONLY) - nError = ERROR_ACCESS_DENIED; - - // If the MPQ is changed at this moment, we have to flush the archive - if(nError == ERROR_SUCCESS && (ha->dwFlags & MPQ_FLAG_CHANGED)) - { - SFileFlushArchive(hMpq); - } - - // Create the table with file keys - if(nError == ERROR_SUCCESS) - { - if((pFileKeys = STORM_ALLOC(DWORD, ha->dwFileTableSize)) != NULL) - memset(pFileKeys, 0, sizeof(DWORD) * ha->dwFileTableSize); - else - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // First of all, we have to check of we are able to decrypt all files. - // If not, sorry, but the archive cannot be compacted. - if(nError == ERROR_SUCCESS) - { - // Initialize the progress variables for compact callback - FileStream_GetSize(ha->pStream, &(ha->CompactTotalBytes)); - ha->CompactBytesProcessed = 0; - nError = CheckIfAllKeysKnown(ha, szListFile, pFileKeys); - } - - // Get the temporary file name and create it - if(nError == ERROR_SUCCESS) - { - // Create temporary file name. Prevent buffer overflow - StringCopy(szTempFile, _countof(szTempFile), FileStream_GetFileName(ha->pStream)); - StringCat(szTempFile, _countof(szTempFile), _T(".tmp")); - - // Create temporary file - pTempStream = FileStream_CreateFile(szTempFile, STREAM_PROVIDER_FLAT | BASE_PROVIDER_FILE); - if(pTempStream == NULL) - nError = GetLastError(); - } - - // Write the data before MPQ user data (if any) - if(nError == ERROR_SUCCESS && ha->UserDataPos != 0) - { - // Inform the application about the progress - if(ha->pfnCompactCB != NULL) - ha->pfnCompactCB(ha->pvCompactUserData, CCB_COPYING_NON_MPQ_DATA, ha->CompactBytesProcessed, ha->CompactTotalBytes); - - ByteOffset = 0; - ByteCount = ha->UserDataPos; - nError = CopyNonMpqData(ha, ha->pStream, pTempStream, ByteOffset, ByteCount); - } - - // Write the MPQ user data (if any) - if(nError == ERROR_SUCCESS && ha->MpqPos > ha->UserDataPos) - { - // At this point, we assume that the user data size is equal - // to pUserData->dwHeaderOffs. - // If this assumption doesn't work, then we have an unknown version of MPQ - ByteOffset = ha->UserDataPos; - ByteCount = ha->MpqPos - ha->UserDataPos; - - assert(ha->pUserData != NULL); - assert(ha->pUserData->dwHeaderOffs == ByteCount); - nError = CopyNonMpqData(ha, ha->pStream, pTempStream, ByteOffset, ByteCount); - } - - // Write the MPQ header - if(nError == ERROR_SUCCESS) - { - TMPQHeader SaveMpqHeader; - - // Write the MPQ header to the file - memcpy(&SaveMpqHeader, ha->pHeader, ha->pHeader->dwHeaderSize); - BSWAP_TMPQHEADER(&SaveMpqHeader, MPQ_FORMAT_VERSION_1); - BSWAP_TMPQHEADER(&SaveMpqHeader, MPQ_FORMAT_VERSION_2); - BSWAP_TMPQHEADER(&SaveMpqHeader, MPQ_FORMAT_VERSION_3); - BSWAP_TMPQHEADER(&SaveMpqHeader, MPQ_FORMAT_VERSION_4); - if(!FileStream_Write(pTempStream, NULL, &SaveMpqHeader, ha->pHeader->dwHeaderSize)) - nError = GetLastError(); - - // Update the progress - ha->CompactBytesProcessed += ha->pHeader->dwHeaderSize; - } - - // Now copy all files - if(nError == ERROR_SUCCESS) - nError = CopyMpqFiles(ha, pFileKeys, pTempStream); - - // If succeeded, switch the streams - if(nError == ERROR_SUCCESS) - { - ha->dwFlags |= MPQ_FLAG_CHANGED; - if(FileStream_Replace(ha->pStream, pTempStream)) - pTempStream = NULL; - else - nError = ERROR_CAN_NOT_COMPLETE; - } - - // Final user notification - if(nError == ERROR_SUCCESS && ha->pfnCompactCB != NULL) - { - ha->CompactBytesProcessed += (ha->pHeader->dwHashTableSize * sizeof(TMPQHash)); - ha->CompactBytesProcessed += (ha->dwFileTableSize * sizeof(TMPQBlock)); - ha->pfnCompactCB(ha->pvCompactUserData, CCB_CLOSING_ARCHIVE, ha->CompactBytesProcessed, ha->CompactTotalBytes); - } - - // Cleanup and return - if(pTempStream != NULL) - FileStream_Close(pTempStream); - if(pFileKeys != NULL) - STORM_FREE(pFileKeys); - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (nError == ERROR_SUCCESS); -} diff --git a/libs/storm-sys/StormLib/src/SFileCreateArchive.cpp b/libs/storm-sys/StormLib/src/SFileCreateArchive.cpp deleted file mode 100644 index de4ab36..0000000 --- a/libs/storm-sys/StormLib/src/SFileCreateArchive.cpp +++ /dev/null @@ -1,274 +0,0 @@ -/*****************************************************************************/ -/* SFileCreateArchive.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* MPQ Editing functions */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 24.03.03 1.00 Lad Splitted from SFileOpenArchive.cpp */ -/* 08.06.10 1.00 Lad Renamed to SFileCreateArchive.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "StormCommon.h" - -//----------------------------------------------------------------------------- -// Local variables - -static const DWORD MpqHeaderSizes[] = -{ - MPQ_HEADER_SIZE_V1, - MPQ_HEADER_SIZE_V2, - MPQ_HEADER_SIZE_V3, - MPQ_HEADER_SIZE_V4 -}; - -//----------------------------------------------------------------------------- -// Local functions - -static USHORT GetSectorSizeShift(DWORD dwSectorSize) -{ - USHORT wSectorSizeShift = 0; - - while(dwSectorSize > 0x200) - { - dwSectorSize >>= 1; - wSectorSizeShift++; - } - - return wSectorSizeShift; -} - -static int WriteNakedMPQHeader(TMPQArchive * ha) -{ - TMPQHeader * pHeader = ha->pHeader; - TMPQHeader Header; - DWORD dwBytesToWrite = pHeader->dwHeaderSize; - int nError = ERROR_SUCCESS; - - // Prepare the naked MPQ header - memset(&Header, 0, sizeof(TMPQHeader)); - Header.dwID = pHeader->dwID; - Header.dwHeaderSize = pHeader->dwHeaderSize; - Header.dwArchiveSize = pHeader->dwHeaderSize; - Header.wFormatVersion = pHeader->wFormatVersion; - Header.wSectorSize = pHeader->wSectorSize; - - // Write it to the file - BSWAP_TMPQHEADER(&Header, MPQ_FORMAT_VERSION_1); - BSWAP_TMPQHEADER(&Header, MPQ_FORMAT_VERSION_2); - BSWAP_TMPQHEADER(&Header, MPQ_FORMAT_VERSION_3); - BSWAP_TMPQHEADER(&Header, MPQ_FORMAT_VERSION_4); - if(!FileStream_Write(ha->pStream, &ha->MpqPos, &Header, dwBytesToWrite)) - nError = GetLastError(); - - return nError; -} - -//----------------------------------------------------------------------------- -// Creates a new MPQ archive. - -bool WINAPI SFileCreateArchive(const TCHAR * szMpqName, DWORD dwCreateFlags, DWORD dwMaxFileCount, HANDLE * phMpq) -{ - SFILE_CREATE_MPQ CreateInfo; - - // Fill the create structure - memset(&CreateInfo, 0, sizeof(SFILE_CREATE_MPQ)); - CreateInfo.cbSize = sizeof(SFILE_CREATE_MPQ); - CreateInfo.dwMpqVersion = (dwCreateFlags & MPQ_CREATE_ARCHIVE_VMASK) >> FLAGS_TO_FORMAT_SHIFT; - CreateInfo.dwStreamFlags = STREAM_PROVIDER_FLAT | BASE_PROVIDER_FILE; - CreateInfo.dwFileFlags1 = (dwCreateFlags & MPQ_CREATE_LISTFILE) ? MPQ_FILE_DEFAULT_INTERNAL : 0; - CreateInfo.dwFileFlags2 = (dwCreateFlags & MPQ_CREATE_ATTRIBUTES) ? MPQ_FILE_DEFAULT_INTERNAL : 0; - CreateInfo.dwFileFlags3 = (dwCreateFlags & MPQ_CREATE_SIGNATURE) ? MPQ_FILE_DEFAULT_INTERNAL : 0; - CreateInfo.dwAttrFlags = (dwCreateFlags & MPQ_CREATE_ATTRIBUTES) ? (MPQ_ATTRIBUTE_CRC32 | MPQ_ATTRIBUTE_FILETIME | MPQ_ATTRIBUTE_MD5) : 0; - CreateInfo.dwSectorSize = (CreateInfo.dwMpqVersion >= MPQ_FORMAT_VERSION_3) ? 0x4000 : 0x1000; - CreateInfo.dwRawChunkSize = (CreateInfo.dwMpqVersion >= MPQ_FORMAT_VERSION_4) ? 0x4000 : 0; - CreateInfo.dwMaxFileCount = dwMaxFileCount; - - // Set the proper attribute parts - if((CreateInfo.dwMpqVersion >= MPQ_FORMAT_VERSION_3) && (dwCreateFlags & MPQ_CREATE_ATTRIBUTES)) - CreateInfo.dwAttrFlags |= MPQ_ATTRIBUTE_PATCH_BIT; - - // Backward compatibility: SFileCreateArchive always used to add (listfile) - // We would break loads of applications if we change that - CreateInfo.dwFileFlags1 = MPQ_FILE_DEFAULT_INTERNAL; - - // Let the main function create the archive - return SFileCreateArchive2(szMpqName, &CreateInfo, phMpq); -} - -bool WINAPI SFileCreateArchive2(const TCHAR * szMpqName, PSFILE_CREATE_MPQ pCreateInfo, HANDLE * phMpq) -{ - TFileStream * pStream = NULL; // File stream - TMPQArchive * ha = NULL; // MPQ archive handle - TMPQHeader * pHeader; - ULONGLONG MpqPos = 0; // Position of MPQ header in the file - HANDLE hMpq = NULL; - DWORD dwBlockTableSize = 0; // Initial block table size - DWORD dwHashTableSize = 0; - DWORD dwReservedFiles = 0; // Number of reserved file entries - DWORD dwMpqFlags = 0; - int nError = ERROR_SUCCESS; - - // Check the parameters, if they are valid - if(szMpqName == NULL || *szMpqName == 0 || pCreateInfo == NULL || phMpq == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return false; - } - - // Verify if all variables in SFILE_CREATE_MPQ are correct - if((pCreateInfo->cbSize == 0 || pCreateInfo->cbSize > sizeof(SFILE_CREATE_MPQ)) || - (pCreateInfo->dwMpqVersion > MPQ_FORMAT_VERSION_4) || - (pCreateInfo->pvUserData != NULL || pCreateInfo->cbUserData != 0) || - (pCreateInfo->dwAttrFlags & ~MPQ_ATTRIBUTE_ALL) || - (pCreateInfo->dwSectorSize & (pCreateInfo->dwSectorSize - 1)) || - (pCreateInfo->dwRawChunkSize & (pCreateInfo->dwRawChunkSize - 1))) - { - SetLastError(ERROR_INVALID_PARAMETER); - return false; - } - - // One time initialization of MPQ cryptography - InitializeMpqCryptography(); - - // We verify if the file already exists and if it's a MPQ archive. - // If yes, we won't allow to overwrite it. - if(SFileOpenArchive(szMpqName, 0, STREAM_PROVIDER_FLAT | BASE_PROVIDER_FILE | MPQ_OPEN_NO_ATTRIBUTES | MPQ_OPEN_NO_LISTFILE, &hMpq)) - { - SFileCloseArchive(hMpq); - SetLastError(ERROR_ALREADY_EXISTS); - return false; - } - - // - // At this point, we have to create the archive. - // - If the file exists, convert it to MPQ archive. - // - If the file doesn't exist, create new empty file - // - - pStream = FileStream_OpenFile(szMpqName, pCreateInfo->dwStreamFlags); - if(pStream == NULL) - { - pStream = FileStream_CreateFile(szMpqName, pCreateInfo->dwStreamFlags); - if(pStream == NULL) - return false; - } - - // Increment the maximum amount of files to have space for (listfile) - if(pCreateInfo->dwMaxFileCount && pCreateInfo->dwFileFlags1) - { - dwMpqFlags |= MPQ_FLAG_LISTFILE_NEW; - dwReservedFiles++; - } - - // Increment the maximum amount of files to have space for (attributes) - if(pCreateInfo->dwMaxFileCount && pCreateInfo->dwFileFlags2 && pCreateInfo->dwAttrFlags) - { - dwMpqFlags |= MPQ_FLAG_ATTRIBUTES_NEW; - dwReservedFiles++; - } - - // Increment the maximum amount of files to have space for (signature) - if(pCreateInfo->dwMaxFileCount && pCreateInfo->dwFileFlags3) - { - dwMpqFlags |= MPQ_FLAG_SIGNATURE_NEW; - dwReservedFiles++; - } - - // If file count is not zero, initialize the hash table size - dwHashTableSize = GetNearestPowerOfTwo(pCreateInfo->dwMaxFileCount + dwReservedFiles); - - // Retrieve the file size and round it up to 0x200 bytes - FileStream_GetSize(pStream, &MpqPos); - MpqPos = (MpqPos + 0x1FF) & (ULONGLONG)0xFFFFFFFFFFFFFE00ULL; - if(!FileStream_SetSize(pStream, MpqPos)) - nError = GetLastError(); - -#ifdef _DEBUG - // Debug code, used for testing StormLib -// dwBlockTableSize = dwHashTableSize * 2; -#endif - - // Create the archive handle - if(nError == ERROR_SUCCESS) - { - if((ha = STORM_ALLOC(TMPQArchive, 1)) == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Fill the MPQ archive handle structure - if(nError == ERROR_SUCCESS) - { - memset(ha, 0, sizeof(TMPQArchive)); - ha->pfnHashString = HashStringSlash; - ha->pStream = pStream; - ha->dwSectorSize = pCreateInfo->dwSectorSize; - ha->UserDataPos = MpqPos; - ha->MpqPos = MpqPos; - ha->pHeader = pHeader = (TMPQHeader *)ha->HeaderData; - ha->dwMaxFileCount = dwHashTableSize; - ha->dwFileTableSize = 0; - ha->dwReservedFiles = dwReservedFiles; - ha->dwFileFlags1 = pCreateInfo->dwFileFlags1; - ha->dwFileFlags2 = pCreateInfo->dwFileFlags2; - ha->dwFileFlags3 = pCreateInfo->dwFileFlags3 ? MPQ_FILE_EXISTS : 0; - ha->dwAttrFlags = pCreateInfo->dwAttrFlags; - ha->dwFlags = dwMpqFlags | MPQ_FLAG_CHANGED; - pStream = NULL; - - // Fill the MPQ header - memset(pHeader, 0, sizeof(ha->HeaderData)); - pHeader->dwID = ID_MPQ; - pHeader->dwHeaderSize = MpqHeaderSizes[pCreateInfo->dwMpqVersion]; - pHeader->dwArchiveSize = pHeader->dwHeaderSize + dwHashTableSize * sizeof(TMPQHash); - pHeader->wFormatVersion = (USHORT)pCreateInfo->dwMpqVersion; - pHeader->wSectorSize = GetSectorSizeShift(ha->dwSectorSize); - pHeader->dwHashTablePos = pHeader->dwHeaderSize; - pHeader->dwHashTableSize = dwHashTableSize; - pHeader->dwBlockTablePos = pHeader->dwHashTablePos + dwHashTableSize * sizeof(TMPQHash); - pHeader->dwBlockTableSize = dwBlockTableSize; - - // For MPQs version 4 and higher, we set the size of raw data block - // for calculating MD5 - if(pCreateInfo->dwMpqVersion >= MPQ_FORMAT_VERSION_4) - pHeader->dwRawChunkSize = pCreateInfo->dwRawChunkSize; - - // Write the naked MPQ header - nError = WriteNakedMPQHeader(ha); - } - - // Create initial HET table, if the caller required an MPQ format 3.0 or newer - if(nError == ERROR_SUCCESS && pCreateInfo->dwMpqVersion >= MPQ_FORMAT_VERSION_3 && pCreateInfo->dwMaxFileCount != 0) - { - ha->pHetTable = CreateHetTable(ha->dwFileTableSize, 0, 0x40, NULL); - if(ha->pHetTable == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Create initial hash table - if(nError == ERROR_SUCCESS && dwHashTableSize != 0) - { - nError = CreateHashTable(ha, dwHashTableSize); - } - - // Create initial file table - if(nError == ERROR_SUCCESS && ha->dwMaxFileCount != 0) - { - nError = CreateFileTable(ha, ha->dwMaxFileCount); - } - - // Cleanup : If an error, delete all buffers and return - if(nError != ERROR_SUCCESS) - { - FileStream_Close(pStream); - FreeArchiveHandle(ha); - SetLastError(nError); - ha = NULL; - } - - // Return the values - *phMpq = (HANDLE)ha; - return (nError == ERROR_SUCCESS); -} diff --git a/libs/storm-sys/StormLib/src/SFileExtractFile.cpp b/libs/storm-sys/StormLib/src/SFileExtractFile.cpp deleted file mode 100644 index cabde49..0000000 --- a/libs/storm-sys/StormLib/src/SFileExtractFile.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/*****************************************************************************/ -/* SFileExtractFile.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Simple extracting utility */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 20.06.03 1.00 Lad The first version of SFileExtractFile.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "StormCommon.h" - -bool WINAPI SFileExtractFile(HANDLE hMpq, const char * szToExtract, const TCHAR * szExtracted, DWORD dwSearchScope) -{ - TFileStream * pLocalFile = NULL; - HANDLE hMpqFile = NULL; - int nError = ERROR_SUCCESS; - - // Open the MPQ file - if(nError == ERROR_SUCCESS) - { - if(!SFileOpenFileEx(hMpq, szToExtract, dwSearchScope, &hMpqFile)) - nError = GetLastError(); - } - - // Create the local file - if(nError == ERROR_SUCCESS) - { - pLocalFile = FileStream_CreateFile(szExtracted, 0); - if(pLocalFile == NULL) - nError = GetLastError(); - } - - // Copy the file's content - while(nError == ERROR_SUCCESS) - { - char szBuffer[0x1000]; - DWORD dwTransferred = 0; - - // dwTransferred is only set to nonzero if something has been read. - // nError can be ERROR_SUCCESS or ERROR_HANDLE_EOF - if(!SFileReadFile(hMpqFile, szBuffer, sizeof(szBuffer), &dwTransferred, NULL)) - nError = GetLastError(); - if(nError == ERROR_HANDLE_EOF) - nError = ERROR_SUCCESS; - if(dwTransferred == 0) - break; - - // If something has been actually read, write it - if(!FileStream_Write(pLocalFile, NULL, szBuffer, dwTransferred)) - nError = GetLastError(); - } - - // Close the files - if(hMpqFile != NULL) - SFileCloseFile(hMpqFile); - if(pLocalFile != NULL) - FileStream_Close(pLocalFile); - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (nError == ERROR_SUCCESS); -} diff --git a/libs/storm-sys/StormLib/src/SFileFindFile.cpp b/libs/storm-sys/StormLib/src/SFileFindFile.cpp deleted file mode 100644 index a27cf02..0000000 --- a/libs/storm-sys/StormLib/src/SFileFindFile.cpp +++ /dev/null @@ -1,479 +0,0 @@ -/*****************************************************************************/ -/* SFileFindFile.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* A module for file searching within MPQs */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 25.03.03 1.00 Lad The first version of SFileFindFile.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "StormCommon.h" - -//----------------------------------------------------------------------------- -// Private structure used for file search (search handle) - -// Used by searching in MPQ archives -struct TMPQSearch -{ - TMPQArchive * ha; // Handle to MPQ, where the search runs - TFileEntry ** pSearchTable; // Table for files that have been already found - DWORD dwSearchTableItems; // Number of items in the search table - DWORD dwNextIndex; // Next file index to be checked - DWORD dwFlagMask; // For checking flag mask - char szSearchMask[1]; // Search mask (variable length) -}; - -//----------------------------------------------------------------------------- -// Local functions - -static TMPQSearch * IsValidSearchHandle(HANDLE hFind) -{ - TMPQSearch * hs = (TMPQSearch *)hFind; - - if(hs != NULL && IsValidMpqHandle(hs->ha)) - return hs; - - return NULL; -} - -bool CheckWildCard(const char * szString, const char * szWildCard) -{ - const char * szWildCardPtr; - - for(;;) - { - // If there is '?' in the wildcard, we skip one char - while(szWildCard[0] == '?') - { - if(szString[0] == 0) - return false; - - szWildCard++; - szString++; - } - - // Handle '*' - szWildCardPtr = szWildCard; - if(szWildCardPtr[0] != 0) - { - if(szWildCardPtr[0] == '*') - { - szWildCardPtr++; - - if(szWildCardPtr[0] == '*') - continue; - - if(szWildCardPtr[0] == 0) - return true; - - if(AsciiToUpperTable[szWildCardPtr[0]] == AsciiToUpperTable[szString[0]]) - { - if(CheckWildCard(szString, szWildCardPtr)) - return true; - } - } - else - { - if(AsciiToUpperTable[szWildCardPtr[0]] != AsciiToUpperTable[szString[0]]) - return false; - - szWildCard = szWildCardPtr + 1; - } - - if(szString[0] == 0) - return false; - szString++; - } - else - { - return (szString[0] == 0) ? true : false; - } - } -} - -static DWORD GetSearchTableItems(TMPQArchive * ha) -{ - DWORD dwMergeItems = 0; - - // Loop over all patches - while(ha != NULL) - { - // Append the number of files - dwMergeItems += (ha->pHetTable != NULL) ? ha->pHetTable->dwEntryCount - : ha->pHeader->dwBlockTableSize; - // Move to the patched archive - ha = ha->haPatch; - } - - // Return the double size of number of items - return (dwMergeItems | 1); -} - -static bool FileWasFoundBefore( - TMPQArchive * ha, - TMPQSearch * hs, - TFileEntry * pFileEntry) -{ - TFileEntry * pEntry; - char * szRealFileName = pFileEntry->szFileName; - DWORD dwStartIndex; - DWORD dwNameHash; - DWORD dwIndex; - - if(hs->pSearchTable != NULL && szRealFileName != NULL) - { - // If we are in patch MPQ, we check if patch prefix matches - // and then trim the patch prefix - if(ha->pPatchPrefix != NULL) - { - // If the patch prefix doesn't fit, we pretend that the file - // was there before and it will be skipped - if(_strnicmp(szRealFileName, ha->pPatchPrefix->szPatchPrefix, ha->pPatchPrefix->nLength)) - return true; - - szRealFileName += ha->pPatchPrefix->nLength; - } - - // Calculate the hash to the table - dwNameHash = ha->pfnHashString(szRealFileName, MPQ_HASH_NAME_A); - dwStartIndex = dwIndex = (dwNameHash % hs->dwSearchTableItems); - - // The file might have been found before - // only if this is not the first MPQ being searched - if(ha->haBase != NULL) - { - // Enumerate all entries in the search table - for(;;) - { - // Get the file entry at that position - pEntry = hs->pSearchTable[dwIndex]; - if(pEntry == NULL) - break; - - if(pEntry->szFileName != NULL) - { - // Does the name match? - if(!_stricmp(pEntry->szFileName, szRealFileName)) - return true; - } - - // Move to the next entry - dwIndex = (dwIndex + 1) % hs->dwSearchTableItems; - if(dwIndex == dwStartIndex) - break; - } - } - - // Put the entry to the table for later use - hs->pSearchTable[dwIndex] = pFileEntry; - } - return false; -} - -static TFileEntry * FindPatchEntry(TMPQArchive * ha, TFileEntry * pFileEntry) -{ - TFileEntry * pPatchEntry = pFileEntry; - TFileEntry * pTempEntry; - char szFileName[MAX_PATH+1]; - - // Can't find patch entry for a file that doesn't have name - if(pFileEntry->szFileName != NULL && pFileEntry->szFileName[0] != 0) - { - // Go while there are patches - while(ha->haPatch != NULL) - { - // Move to the patch archive - ha = ha->haPatch; - szFileName[0] = 0; - - // Prepare the prefix for the file name - if(ha->pPatchPrefix && ha->pPatchPrefix->nLength) - StringCopy(szFileName, _countof(szFileName), ha->pPatchPrefix->szPatchPrefix); - StringCat(szFileName, _countof(szFileName), pFileEntry->szFileName); - - // Try to find the file there - pTempEntry = GetFileEntryExact(ha, szFileName, 0, NULL); - if(pTempEntry != NULL) - pPatchEntry = pTempEntry; - } - } - - // Return the found patch entry - return pPatchEntry; -} - -static bool DoMPQSearch_FileEntry( - TMPQSearch * hs, - SFILE_FIND_DATA * lpFindFileData, - TMPQArchive * ha, - TMPQHash * pHashEntry, - TFileEntry * pFileEntry) -{ - TFileEntry * pPatchEntry; - HANDLE hFile = NULL; - const char * szFileName; - size_t nPrefixLength = (ha->pPatchPrefix != NULL) ? ha->pPatchPrefix->nLength : 0; - DWORD dwBlockIndex; - char szNameBuff[MAX_PATH]; - - // Is it a file but not a patch file? - if((pFileEntry->dwFlags & hs->dwFlagMask) == MPQ_FILE_EXISTS) - { - // Now we have to check if this file was not enumerated before - if(!FileWasFoundBefore(ha, hs, pFileEntry)) - { -// if(pFileEntry != NULL && !_stricmp(pFileEntry->szFileName, "TriggerLibs\\NativeLib.galaxy")) -// DebugBreak(); - - // Find a patch to this file - // Note: This either succeeds or returns pFileEntry - pPatchEntry = FindPatchEntry(ha, pFileEntry); - - // Prepare the block index - dwBlockIndex = (DWORD)(pFileEntry - ha->pFileTable); - - // Get the file name. If it's not known, we will create pseudo-name - szFileName = pFileEntry->szFileName; - if(szFileName == NULL) - { - // Open the file by its pseudo-name. - sprintf(szNameBuff, "File%08u.xxx", (unsigned int)dwBlockIndex); - if(SFileOpenFileEx((HANDLE)hs->ha, szNameBuff, SFILE_OPEN_BASE_FILE, &hFile)) - { - SFileGetFileName(hFile, szNameBuff); - szFileName = szNameBuff; - SFileCloseFile(hFile); - } - } - - // If the file name is still NULL, we cannot include the file to search results - if(szFileName != NULL) - { - // Check the file name against the wildcard - if(CheckWildCard(szFileName + nPrefixLength, hs->szSearchMask)) - { - // Fill the found entry. hash entry and block index are taken from the base MPQ - lpFindFileData->dwHashIndex = HASH_ENTRY_FREE; - lpFindFileData->dwBlockIndex = dwBlockIndex; - lpFindFileData->dwFileSize = pPatchEntry->dwFileSize; - lpFindFileData->dwFileFlags = pPatchEntry->dwFlags; - lpFindFileData->dwCompSize = pPatchEntry->dwCmpSize; - lpFindFileData->lcLocale = 0; // pPatchEntry->lcLocale; - - // Fill the filetime - lpFindFileData->dwFileTimeHi = (DWORD)(pPatchEntry->FileTime >> 32); - lpFindFileData->dwFileTimeLo = (DWORD)(pPatchEntry->FileTime); - - // Fill-in the entries from hash table entry, if given - if(pHashEntry != NULL) - { - lpFindFileData->dwHashIndex = (DWORD)(pHashEntry - ha->pHashTable); - lpFindFileData->lcLocale = pHashEntry->lcLocale; - } - - // Fill the file name and plain file name - StringCopy(lpFindFileData->cFileName, _countof(lpFindFileData->cFileName), szFileName + nPrefixLength); - lpFindFileData->szPlainName = (char *)GetPlainFileName(lpFindFileData->cFileName); - return true; - } - } - } - } - - // Either not a valid item or was found before - return false; -} - -static int DoMPQSearch_HashTable(TMPQSearch * hs, SFILE_FIND_DATA * lpFindFileData, TMPQArchive * ha) -{ - TMPQHash * pHashTableEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - TMPQHash * pHash; - - // Parse the file table - for(pHash = ha->pHashTable + hs->dwNextIndex; pHash < pHashTableEnd; pHash++) - { - // Increment the next index for subsequent search - hs->dwNextIndex++; - - // Does this hash table entry point to a proper block table entry? - if(IsValidHashEntry(ha, pHash)) - { - // Check if this file entry should be included in the search result - if(DoMPQSearch_FileEntry(hs, lpFindFileData, ha, pHash, ha->pFileTable + MPQ_BLOCK_INDEX(pHash))) - return ERROR_SUCCESS; - } - } - - // No more files - return ERROR_NO_MORE_FILES; -} - -static int DoMPQSearch_FileTable(TMPQSearch * hs, SFILE_FIND_DATA * lpFindFileData, TMPQArchive * ha) -{ - TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; - TFileEntry * pFileEntry; - - // Parse the file table - for(pFileEntry = ha->pFileTable + hs->dwNextIndex; pFileEntry < pFileTableEnd; pFileEntry++) - { - // Increment the next index for subsequent search - hs->dwNextIndex++; - - // Check if this file entry should be included in the search result - if(DoMPQSearch_FileEntry(hs, lpFindFileData, ha, NULL, pFileEntry)) - return ERROR_SUCCESS; - } - - // No more files - return ERROR_NO_MORE_FILES; -} - -// Performs one MPQ search -static int DoMPQSearch(TMPQSearch * hs, SFILE_FIND_DATA * lpFindFileData) -{ - TMPQArchive * ha = hs->ha; - int nError; - - // Start searching with base MPQ - while(ha != NULL) - { - // If the archive has hash table, we need to use hash table - // in order to catch hash table index and file locale. - // Note: If multiple hash table entries, point to the same block entry, - // we need, to report them all - nError = (ha->pHashTable != NULL) ? DoMPQSearch_HashTable(hs, lpFindFileData, ha) - : DoMPQSearch_FileTable(hs, lpFindFileData, ha); - if(nError == ERROR_SUCCESS) - return nError; - - // If there is no more patches in the chain, stop it. - // This also keeps hs->ha non-NULL, which is required - // for freeing the handle later - if(ha->haPatch == NULL) - break; - - // Move to the next patch in the patch chain - hs->ha = ha = ha->haPatch; - hs->dwNextIndex = 0; - } - - // No more files found, return error - return ERROR_NO_MORE_FILES; -} - -static void FreeMPQSearch(TMPQSearch *& hs) -{ - if(hs != NULL) - { - if(hs->pSearchTable != NULL) - STORM_FREE(hs->pSearchTable); - STORM_FREE(hs); - hs = NULL; - } -} - -//----------------------------------------------------------------------------- -// Public functions - -HANDLE WINAPI SFileFindFirstFile(HANDLE hMpq, const char * szMask, SFILE_FIND_DATA * lpFindFileData, const TCHAR * szListFile) -{ - TMPQArchive * ha = (TMPQArchive *)hMpq; - TMPQSearch * hs = NULL; - size_t nSize = 0; - int nError = ERROR_SUCCESS; - - // Check for the valid parameters - if(!IsValidMpqHandle(hMpq)) - nError = ERROR_INVALID_HANDLE; - if(szMask == NULL || lpFindFileData == NULL) - nError = ERROR_INVALID_PARAMETER; - - // Include the listfile into the MPQ's internal listfile - // Note that if the listfile name is NULL, do nothing because the - // internal listfile is always included. - if(nError == ERROR_SUCCESS && szListFile != NULL && *szListFile != 0) - nError = SFileAddListFile((HANDLE)ha, szListFile); - - // Allocate the structure for MPQ search - if(nError == ERROR_SUCCESS) - { - nSize = sizeof(TMPQSearch) + strlen(szMask) + 1; - if((hs = (TMPQSearch *)STORM_ALLOC(char, nSize)) == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Perform the first search - if(nError == ERROR_SUCCESS) - { - memset(hs, 0, sizeof(TMPQSearch)); - strcpy(hs->szSearchMask, szMask); - hs->dwFlagMask = MPQ_FILE_EXISTS; - hs->ha = ha; - - // If the archive is patched archive, we have to create a merge table - // to prevent files being repeated - if(ha->haPatch != NULL) - { - hs->dwSearchTableItems = GetSearchTableItems(ha); - hs->pSearchTable = STORM_ALLOC(TFileEntry *, hs->dwSearchTableItems); - hs->dwFlagMask = MPQ_FILE_EXISTS | MPQ_FILE_PATCH_FILE; - if(hs->pSearchTable != NULL) - memset(hs->pSearchTable, 0, hs->dwSearchTableItems * sizeof(TFileEntry *)); - else - nError = ERROR_NOT_ENOUGH_MEMORY; - } - } - - // Perform first item searching - if(nError == ERROR_SUCCESS) - { - nError = DoMPQSearch(hs, lpFindFileData); - } - - // Cleanup - if(nError != ERROR_SUCCESS) - { - FreeMPQSearch(hs); - SetLastError(nError); - } - - // Return the result value - return (HANDLE)hs; -} - -bool WINAPI SFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData) -{ - TMPQSearch * hs = IsValidSearchHandle(hFind); - int nError = ERROR_SUCCESS; - - // Check the parameters - if(hs == NULL) - nError = ERROR_INVALID_HANDLE; - if(lpFindFileData == NULL) - nError = ERROR_INVALID_PARAMETER; - - if(nError == ERROR_SUCCESS) - nError = DoMPQSearch(hs, lpFindFileData); - - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (nError == ERROR_SUCCESS); -} - -bool WINAPI SFileFindClose(HANDLE hFind) -{ - TMPQSearch * hs = IsValidSearchHandle(hFind); - - // Check the parameters - if(hs == NULL) - { - SetLastError(ERROR_INVALID_HANDLE); - return false; - } - - FreeMPQSearch(hs); - return true; -} diff --git a/libs/storm-sys/StormLib/src/SFileGetFileInfo.cpp b/libs/storm-sys/StormLib/src/SFileGetFileInfo.cpp deleted file mode 100644 index 226e8b8..0000000 --- a/libs/storm-sys/StormLib/src/SFileGetFileInfo.cpp +++ /dev/null @@ -1,1003 +0,0 @@ -/*****************************************************************************/ -/* SFileGetFileInfo.cpp Copyright (c) Ladislav Zezula 2013 */ -/*---------------------------------------------------------------------------*/ -/* Description: */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 30.11.13 1.00 Lad The first version of SFileGetFileInfo.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "StormCommon.h" - -//----------------------------------------------------------------------------- -// Local defines - -// Information types for SFileGetFileInfo -#define SFILE_INFO_TYPE_INVALID_HANDLE 0 -#define SFILE_INFO_TYPE_NOT_FOUND 1 -#define SFILE_INFO_TYPE_DIRECT_POINTER 2 -#define SFILE_INFO_TYPE_ALLOCATED 3 -#define SFILE_INFO_TYPE_READ_FROM_FILE 4 -#define SFILE_INFO_TYPE_TABLE_POINTER 5 -#define SFILE_INFO_TYPE_FILE_ENTRY 6 - -//----------------------------------------------------------------------------- -// Local functions - -static void ConvertFileEntryToSelfRelative(TFileEntry * pFileEntry, TFileEntry * pSrcFileEntry) -{ - // Copy the file entry itself - memcpy(pFileEntry, pSrcFileEntry, sizeof(TFileEntry)); - - // If source is NULL, leave it NULL - if(pSrcFileEntry->szFileName != NULL) - { - // Set the file name pointer after the file entry - pFileEntry->szFileName = (char *)(pFileEntry + 1); - strcpy(pFileEntry->szFileName, pSrcFileEntry->szFileName); - } -} - - -static DWORD GetMpqFileCount(TMPQArchive * ha) -{ - TFileEntry * pFileTableEnd; - TFileEntry * pFileEntry; - DWORD dwFileCount = 0; - - // Go through all open MPQs, including patches - while(ha != NULL) - { - // Only count files that are not patch files - pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - { - // If the file is patch file and this is not primary archive, skip it - // BUGBUG: This errorneously counts non-patch files that are in both - // base MPQ and in patches, and increases the number of files by cca 50% - if((pFileEntry->dwFlags & (MPQ_FILE_EXISTS | MPQ_FILE_PATCH_FILE)) == MPQ_FILE_EXISTS) - dwFileCount++; - } - - // Move to the next patch archive - ha = ha->haPatch; - } - - return dwFileCount; -} - -static bool GetFilePatchChain(TMPQFile * hf, void * pvFileInfo, DWORD cbFileInfo, DWORD * pcbLengthNeeded) -{ - TMPQFile * hfTemp; - TCHAR * szFileInfo = (TCHAR *)pvFileInfo; - size_t cchCharsNeeded = 1; - size_t cchFileInfo = (cbFileInfo / sizeof(TCHAR)); - size_t nLength; - - // Patch chain is only supported on MPQ files. - if(hf->pStream != NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return false; - } - - // Calculate the necessary length of the multi-string - for(hfTemp = hf; hfTemp != NULL; hfTemp = hfTemp->hfPatch) - cchCharsNeeded += _tcslen(FileStream_GetFileName(hfTemp->ha->pStream)) + 1; - - // Give the caller the needed length - if(pcbLengthNeeded != NULL) - pcbLengthNeeded[0] = (DWORD)(cchCharsNeeded * sizeof(TCHAR)); - - // If the caller gave both buffer pointer and data length, - // try to copy the patch chain - if(szFileInfo != NULL && cchFileInfo != 0) - { - // If there is enough space in the buffer, copy the patch chain - if(cchCharsNeeded > cchFileInfo) - { - SetLastError(ERROR_INSUFFICIENT_BUFFER); - return false; - } - - // Copy each patch - for(hfTemp = hf; hfTemp != NULL; hfTemp = hfTemp->hfPatch) - { - // Get the file name and its length - const TCHAR * szFileName = FileStream_GetFileName(hfTemp->ha->pStream); - nLength = _tcslen(szFileName) + 1; - - // Copy the file name - memcpy(szFileInfo, szFileName, nLength * sizeof(TCHAR)); - szFileInfo += nLength; - } - - // Make it multi-string - szFileInfo[0] = 0; - } - - return true; -} - -//----------------------------------------------------------------------------- -// Retrieves an information about an archive or about a file within the archive -// -// hMpqOrFile - Handle to an MPQ archive or to a file -// InfoClass - Information to obtain -// pvFileInfo - Pointer to buffer to store the information -// cbFileInfo - Size of the buffer pointed by pvFileInfo -// pcbLengthNeeded - Receives number of bytes necessary to store the information - -bool WINAPI SFileGetFileInfo( - HANDLE hMpqOrFile, - SFileInfoClass InfoClass, - void * pvFileInfo, - DWORD cbFileInfo, - LPDWORD pcbLengthNeeded) -{ - MPQ_SIGNATURE_INFO SignatureInfo; - TMPQArchive * ha = NULL; - TFileEntry * pFileEntry = NULL; - ULONGLONG Int64Value = 0; - ULONGLONG ByteOffset = 0; - TMPQFile * hf = NULL; - void * pvSrcFileInfo = NULL; - DWORD cbSrcFileInfo = 0; - DWORD dwInt32Value = 0; - int nInfoType = SFILE_INFO_TYPE_INVALID_HANDLE; - int nError = ERROR_SUCCESS; - - switch(InfoClass) - { - case SFileMpqFileName: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - pvSrcFileInfo = (void *)FileStream_GetFileName(ha->pStream); - cbSrcFileInfo = (DWORD)(_tcslen((TCHAR *)pvSrcFileInfo) + 1) * sizeof(TCHAR); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqStreamBitmap: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - return FileStream_GetBitmap(ha->pStream, pvFileInfo, cbFileInfo, pcbLengthNeeded); - break; - - case SFileMpqUserDataOffset: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - nInfoType = SFILE_INFO_TYPE_NOT_FOUND; - if(ha->pUserData != NULL) - { - pvSrcFileInfo = &ha->UserDataPos; - cbSrcFileInfo = sizeof(ULONGLONG); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - } - break; - - case SFileMpqUserDataHeader: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - nInfoType = SFILE_INFO_TYPE_NOT_FOUND; - if(ha->pUserData != NULL) - { - ByteOffset = ha->UserDataPos; - cbSrcFileInfo = sizeof(TMPQUserData); - nInfoType = SFILE_INFO_TYPE_READ_FROM_FILE; - } - } - break; - - case SFileMpqUserData: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - nInfoType = SFILE_INFO_TYPE_NOT_FOUND; - if(ha->pUserData != NULL) - { - ByteOffset = ha->UserDataPos + sizeof(TMPQUserData); - cbSrcFileInfo = ha->pUserData->dwHeaderOffs - sizeof(TMPQUserData); - nInfoType = SFILE_INFO_TYPE_READ_FROM_FILE; - } - } - break; - - case SFileMpqHeaderOffset: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - pvSrcFileInfo = &ha->MpqPos; - cbSrcFileInfo = sizeof(ULONGLONG); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqHeaderSize: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - pvSrcFileInfo = &ha->pHeader->dwHeaderSize; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqHeader: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - ByteOffset = ha->MpqPos; - cbSrcFileInfo = ha->pHeader->dwHeaderSize; - nInfoType = SFILE_INFO_TYPE_READ_FROM_FILE; - } - break; - - case SFileMpqHetTableOffset: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - pvSrcFileInfo = &ha->pHeader->HetTablePos64; - cbSrcFileInfo = sizeof(ULONGLONG); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqHetTableSize: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - pvSrcFileInfo = &ha->pHeader->HetTableSize64; - cbSrcFileInfo = sizeof(ULONGLONG); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqHetHeader: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - nInfoType = SFILE_INFO_TYPE_NOT_FOUND; - pvSrcFileInfo = LoadExtTable(ha, ha->pHeader->HetTablePos64, (size_t)ha->pHeader->HetTableSize64, HET_TABLE_SIGNATURE, MPQ_KEY_HASH_TABLE); - if(pvSrcFileInfo != NULL) - { - cbSrcFileInfo = sizeof(TMPQHetHeader); - nInfoType = SFILE_INFO_TYPE_ALLOCATED; - } - } - break; - - case SFileMpqHetTable: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - nInfoType = SFILE_INFO_TYPE_NOT_FOUND; - pvSrcFileInfo = LoadHetTable(ha); - if(pvSrcFileInfo != NULL) - { - cbSrcFileInfo = sizeof(void *); - nInfoType = SFILE_INFO_TYPE_TABLE_POINTER; - } - } - break; - - case SFileMpqBetTableOffset: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - pvSrcFileInfo = &ha->pHeader->BetTablePos64; - cbSrcFileInfo = sizeof(ULONGLONG); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqBetTableSize: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - pvSrcFileInfo = &ha->pHeader->BetTableSize64; - cbSrcFileInfo = sizeof(ULONGLONG); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqBetHeader: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - nInfoType = SFILE_INFO_TYPE_NOT_FOUND; - pvSrcFileInfo = LoadExtTable(ha, ha->pHeader->BetTablePos64, (size_t)ha->pHeader->BetTableSize64, BET_TABLE_SIGNATURE, MPQ_KEY_BLOCK_TABLE); - if(pvSrcFileInfo != NULL) - { - // It is allowed for the caller to only require BET header. - cbSrcFileInfo = sizeof(TMPQBetHeader) + ((TMPQBetHeader *)pvSrcFileInfo)->dwFlagCount * sizeof(DWORD); - if(cbFileInfo == sizeof(TMPQBetHeader)) - cbSrcFileInfo = sizeof(TMPQBetHeader); - nInfoType = SFILE_INFO_TYPE_ALLOCATED; - } - } - break; - - case SFileMpqBetTable: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - nInfoType = SFILE_INFO_TYPE_NOT_FOUND; - pvSrcFileInfo = LoadBetTable(ha); - if(pvSrcFileInfo != NULL) - { - cbSrcFileInfo = sizeof(void *); - nInfoType = SFILE_INFO_TYPE_TABLE_POINTER; - } - } - break; - - case SFileMpqHashTableOffset: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - Int64Value = MAKE_OFFSET64(ha->pHeader->wHashTablePosHi, ha->pHeader->dwHashTablePos); - pvSrcFileInfo = &Int64Value; - cbSrcFileInfo = sizeof(ULONGLONG); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqHashTableSize64: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - pvSrcFileInfo = &ha->pHeader->HashTableSize64; - cbSrcFileInfo = sizeof(ULONGLONG); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqHashTableSize: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - pvSrcFileInfo = &ha->pHeader->dwHashTableSize; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqHashTable: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL && ha->pHashTable != NULL) - { - pvSrcFileInfo = ha->pHashTable; - cbSrcFileInfo = ha->pHeader->dwHashTableSize * sizeof(TMPQHash); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqBlockTableOffset: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - Int64Value = MAKE_OFFSET64(ha->pHeader->wBlockTablePosHi, ha->pHeader->dwBlockTablePos); - pvSrcFileInfo = &Int64Value; - cbSrcFileInfo = sizeof(ULONGLONG); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqBlockTableSize64: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - pvSrcFileInfo = &ha->pHeader->BlockTableSize64; - cbSrcFileInfo = sizeof(ULONGLONG); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqBlockTableSize: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - pvSrcFileInfo = &ha->pHeader->dwBlockTableSize; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqBlockTable: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - nInfoType = SFILE_INFO_TYPE_NOT_FOUND; - if(MAKE_OFFSET64(ha->pHeader->wBlockTablePosHi, ha->pHeader->dwBlockTablePos) < ha->FileSize) - { - cbSrcFileInfo = ha->pHeader->dwBlockTableSize * sizeof(TMPQBlock); - if(cbFileInfo >= cbSrcFileInfo) - pvSrcFileInfo = LoadBlockTable(ha, true); - nInfoType = SFILE_INFO_TYPE_ALLOCATED; - } - } - break; - - case SFileMpqHiBlockTableOffset: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - pvSrcFileInfo = &ha->pHeader->HiBlockTablePos64; - cbSrcFileInfo = sizeof(ULONGLONG); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqHiBlockTableSize64: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - pvSrcFileInfo = &ha->pHeader->HiBlockTableSize64; - cbSrcFileInfo = sizeof(ULONGLONG); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqHiBlockTable: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - nInfoType = SFILE_INFO_TYPE_NOT_FOUND; - if(ha->pHeader->HiBlockTablePos64 && ha->pHeader->HiBlockTableSize64) - { - assert(false); - } - } - break; - - case SFileMpqSignatures: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL && QueryMpqSignatureInfo(ha, &SignatureInfo)) - { - pvSrcFileInfo = &SignatureInfo.SignatureTypes; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqStrongSignatureOffset: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - nInfoType = SFILE_INFO_TYPE_NOT_FOUND; - if(QueryMpqSignatureInfo(ha, &SignatureInfo) && (SignatureInfo.SignatureTypes & SIGNATURE_TYPE_STRONG)) - { - pvSrcFileInfo = &SignatureInfo.EndMpqData; - cbSrcFileInfo = sizeof(ULONGLONG); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - } - break; - - case SFileMpqStrongSignatureSize: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - nInfoType = SFILE_INFO_TYPE_NOT_FOUND; - if(QueryMpqSignatureInfo(ha, &SignatureInfo) && (SignatureInfo.SignatureTypes & SIGNATURE_TYPE_STRONG)) - { - dwInt32Value = MPQ_STRONG_SIGNATURE_SIZE + 4; - pvSrcFileInfo = &dwInt32Value; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - } - break; - - case SFileMpqStrongSignature: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - nInfoType = SFILE_INFO_TYPE_NOT_FOUND; - if(QueryMpqSignatureInfo(ha, &SignatureInfo) && (SignatureInfo.SignatureTypes & SIGNATURE_TYPE_STRONG)) - { - pvSrcFileInfo = SignatureInfo.Signature; - cbSrcFileInfo = MPQ_STRONG_SIGNATURE_SIZE + 4; - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - } - break; - - case SFileMpqArchiveSize64: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - pvSrcFileInfo = &ha->pHeader->ArchiveSize64; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqArchiveSize: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - pvSrcFileInfo = &ha->pHeader->dwArchiveSize; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqMaxFileCount: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - pvSrcFileInfo = &ha->dwMaxFileCount; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqFileTableSize: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - pvSrcFileInfo = &ha->dwFileTableSize; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqSectorSize: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - pvSrcFileInfo = &ha->dwSectorSize; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqNumberOfFiles: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - pvSrcFileInfo = &dwInt32Value; - cbSrcFileInfo = sizeof(DWORD); - dwInt32Value = GetMpqFileCount(ha); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqRawChunkSize: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - nInfoType = SFILE_INFO_TYPE_NOT_FOUND; - if(ha->pHeader->dwRawChunkSize != 0) - { - pvSrcFileInfo = &ha->pHeader->dwRawChunkSize; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - } - break; - - case SFileMpqStreamFlags: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - FileStream_GetFlags(ha->pStream, &dwInt32Value); - pvSrcFileInfo = &dwInt32Value; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileMpqFlags: - ha = IsValidMpqHandle(hMpqOrFile); - if(ha != NULL) - { - dwInt32Value = ha->dwFlags; - pvSrcFileInfo = &dwInt32Value; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileInfoPatchChain: - hf = IsValidFileHandle(hMpqOrFile); - if(hf != NULL) - return GetFilePatchChain(hf, pvFileInfo, cbFileInfo, pcbLengthNeeded); - break; - - case SFileInfoFileEntry: - hf = IsValidFileHandle(hMpqOrFile); - if(hf != NULL && hf->pFileEntry != NULL) - { - pvSrcFileInfo = pFileEntry = hf->pFileEntry; - cbSrcFileInfo = sizeof(TFileEntry); - if(pFileEntry->szFileName != NULL) - cbSrcFileInfo += (DWORD)strlen(pFileEntry->szFileName) + 1; - nInfoType = SFILE_INFO_TYPE_FILE_ENTRY; - } - break; - - case SFileInfoHashEntry: - hf = IsValidFileHandle(hMpqOrFile); - if(hf != NULL && hf->pHashEntry != NULL) - { - pvSrcFileInfo = hf->pHashEntry; - cbSrcFileInfo = sizeof(TMPQHash); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileInfoHashIndex: - hf = IsValidFileHandle(hMpqOrFile); - if(hf != NULL && hf->pHashEntry != NULL) - { - pvSrcFileInfo = &hf->dwHashIndex; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileInfoNameHash1: - hf = IsValidFileHandle(hMpqOrFile); - if(hf != NULL && hf->pHashEntry != NULL) - { - dwInt32Value = hf->pHashEntry->dwName1; - pvSrcFileInfo = &dwInt32Value; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileInfoNameHash2: - hf = IsValidFileHandle(hMpqOrFile); - if(hf != NULL && hf->pHashEntry != NULL) - { - dwInt32Value = hf->pHashEntry->dwName2; - pvSrcFileInfo = &dwInt32Value; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileInfoNameHash3: - hf = IsValidFileHandle(hMpqOrFile); - if(hf != NULL && hf->pFileEntry != NULL) - { - pvSrcFileInfo = &hf->pFileEntry->FileNameHash; - cbSrcFileInfo = sizeof(ULONGLONG); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileInfoLocale: - hf = IsValidFileHandle(hMpqOrFile); - if(hf != NULL && hf->pHashEntry != NULL) - { - dwInt32Value = hf->pHashEntry->lcLocale; - pvSrcFileInfo = &dwInt32Value; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileInfoFileIndex: - hf = IsValidFileHandle(hMpqOrFile); - if(hf != NULL && hf->ha != NULL && hf->pFileEntry != NULL) - { - dwInt32Value = (DWORD)(hf->pFileEntry - hf->ha->pFileTable); - pvSrcFileInfo = &dwInt32Value; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileInfoByteOffset: - hf = IsValidFileHandle(hMpqOrFile); - if(hf != NULL && hf->pFileEntry != NULL) - { - pvSrcFileInfo = &hf->pFileEntry->ByteOffset; - cbSrcFileInfo = sizeof(ULONGLONG); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileInfoFileTime: - hf = IsValidFileHandle(hMpqOrFile); - if(hf != NULL && hf->pFileEntry != NULL) - { - pvSrcFileInfo = &hf->pFileEntry->FileTime; - cbSrcFileInfo = sizeof(ULONGLONG); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileInfoFileSize: - hf = IsValidFileHandle(hMpqOrFile); - if(hf != NULL && hf->pFileEntry != NULL) - { - pvSrcFileInfo = &hf->pFileEntry->dwFileSize; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileInfoCompressedSize: - hf = IsValidFileHandle(hMpqOrFile); - if(hf != NULL && hf->pFileEntry != NULL) - { - pvSrcFileInfo = &hf->pFileEntry->dwCmpSize; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileInfoFlags: - hf = IsValidFileHandle(hMpqOrFile); - if(hf != NULL && hf->pFileEntry != NULL) - { - pvSrcFileInfo = &hf->pFileEntry->dwFlags; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileInfoEncryptionKey: - hf = IsValidFileHandle(hMpqOrFile); - if(hf != NULL) - { - pvSrcFileInfo = &hf->dwFileKey; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileInfoEncryptionKeyRaw: - hf = IsValidFileHandle(hMpqOrFile); - if(hf != NULL && hf->pFileEntry != NULL) - { - dwInt32Value = hf->dwFileKey; - if(hf->pFileEntry->dwFlags & MPQ_FILE_FIX_KEY) - dwInt32Value = (dwInt32Value ^ hf->pFileEntry->dwFileSize) - (DWORD)hf->MpqFilePos; - pvSrcFileInfo = &dwInt32Value; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - case SFileInfoCRC32: - hf = IsValidFileHandle(hMpqOrFile); - if(hf != NULL && hf->pFileEntry != NULL) - { - dwInt32Value = hf->pFileEntry->dwCrc32; - pvSrcFileInfo = &dwInt32Value; - cbSrcFileInfo = sizeof(DWORD); - nInfoType = SFILE_INFO_TYPE_DIRECT_POINTER; - } - break; - - default: // Invalid info class - SetLastError(ERROR_INVALID_PARAMETER); - return false; - } - - // If we validated the handle and info class, give as much info as possible - if(nInfoType >= SFILE_INFO_TYPE_DIRECT_POINTER) - { - // Give the length needed, if wanted - if(pcbLengthNeeded != NULL) - pcbLengthNeeded[0] = cbSrcFileInfo; - - // If the caller entered an output buffer, the output size must also be entered - if(pvFileInfo != NULL && cbFileInfo != 0) - { - // Check if there is enough space in the output buffer - if(cbSrcFileInfo <= cbFileInfo) - { - switch(nInfoType) - { - case SFILE_INFO_TYPE_DIRECT_POINTER: - case SFILE_INFO_TYPE_ALLOCATED: - assert(pvSrcFileInfo != NULL); - memcpy(pvFileInfo, pvSrcFileInfo, cbSrcFileInfo); - break; - - case SFILE_INFO_TYPE_READ_FROM_FILE: - if(!FileStream_Read(ha->pStream, &ByteOffset, pvFileInfo, cbSrcFileInfo)) - nError = GetLastError(); - break; - - case SFILE_INFO_TYPE_TABLE_POINTER: - assert(pvSrcFileInfo != NULL); - *(void **)pvFileInfo = pvSrcFileInfo; - pvSrcFileInfo = NULL; - break; - - case SFILE_INFO_TYPE_FILE_ENTRY: - assert(pFileEntry != NULL); - ConvertFileEntryToSelfRelative((TFileEntry *)pvFileInfo, pFileEntry); - break; - } - } - else - { - nError = ERROR_INSUFFICIENT_BUFFER; - } - } - - // Free the file info if needed - if(nInfoType == SFILE_INFO_TYPE_ALLOCATED && pvSrcFileInfo != NULL) - STORM_FREE(pvSrcFileInfo); - if(nInfoType == SFILE_INFO_TYPE_TABLE_POINTER && pvSrcFileInfo != NULL) - SFileFreeFileInfo(pvSrcFileInfo, InfoClass); - } - else - { - // Handle error cases - if(nInfoType == SFILE_INFO_TYPE_INVALID_HANDLE) - nError = ERROR_INVALID_HANDLE; - if(nInfoType == SFILE_INFO_TYPE_NOT_FOUND) - nError = ERROR_FILE_NOT_FOUND; - } - - // Set the last error value, if needed - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (nError == ERROR_SUCCESS); -} - -bool WINAPI SFileFreeFileInfo(void * pvFileInfo, SFileInfoClass InfoClass) -{ - switch(InfoClass) - { - case SFileMpqHetTable: - FreeHetTable((TMPQHetTable *)pvFileInfo); - return true; - - case SFileMpqBetTable: - FreeBetTable((TMPQBetTable *)pvFileInfo); - return true; - - default: - break; - } - - SetLastError(ERROR_INVALID_PARAMETER); - return false; -} - -//----------------------------------------------------------------------------- -// Tries to retrieve the file name - -struct TFileHeader2Ext -{ - DWORD dwOffset00Data; // Required data at offset 00 (32-bits) - DWORD dwOffset00Mask; // Mask for data at offset 00 (32 bits). 0 = data are ignored - DWORD dwOffset04Data; // Required data at offset 04 (32-bits) - DWORD dwOffset04Mask; // Mask for data at offset 04 (32 bits). 0 = data are ignored - const char * szExt; // Supplied extension, if the condition is true -}; - -static TFileHeader2Ext data2ext[] = -{ - {0x00005A4D, 0x0000FFFF, 0x00000000, 0x00000000, "exe"}, // EXE files - {0x00000006, 0xFFFFFFFF, 0x00000001, 0xFFFFFFFF, "dc6"}, // EXE files - {0x1A51504D, 0xFFFFFFFF, 0x00000000, 0x00000000, "mpq"}, // MPQ archive header ID ('MPQ\x1A') - {0x46464952, 0xFFFFFFFF, 0x00000000, 0x00000000, "wav"}, // WAVE header 'RIFF' - {0x324B4D53, 0xFFFFFFFF, 0x00000000, 0x00000000, "smk"}, // Old "Smacker Video" files 'SMK2' - {0x694B4942, 0xFFFFFFFF, 0x00000000, 0x00000000, "bik"}, // Bink video files (new) - {0x0801050A, 0xFFFFFFFF, 0x00000000, 0x00000000, "pcx"}, // PCX images used in Diablo I - {0x544E4F46, 0xFFFFFFFF, 0x00000000, 0x00000000, "fnt"}, // Font files used in Diablo II - {0x6D74683C, 0xFFFFFFFF, 0x00000000, 0x00000000, "html"}, // HTML 'ha->pFileTable), data2ext[i].szExt); - - // Save the pseudo-name in the file entry as well - AllocateFileName(hf->ha, pFileEntry, szPseudoName); - - // If the caller wants to copy the file name, do it - if(szFileName != NULL) - strcpy(szFileName, szPseudoName); - return ERROR_SUCCESS; - } - } - } - - return ERROR_CAN_NOT_COMPLETE; -} - -bool WINAPI SFileGetFileName(HANDLE hFile, char * szFileName) -{ - TMPQFile * hf = (TMPQFile *)hFile; // MPQ File handle - int nError = ERROR_INVALID_HANDLE; - - // Check valid parameters - if(IsValidFileHandle(hFile)) - { - TFileEntry * pFileEntry = hf->pFileEntry; - - // For MPQ files, retrieve the file name from the file entry - if(hf->pStream == NULL) - { - if(pFileEntry != NULL) - { - // If the file name is not there yet, create a pseudo name - if(pFileEntry->szFileName == NULL) - nError = CreatePseudoFileName(hFile, pFileEntry, szFileName); - - // Copy the file name to the output buffer, if any - if(pFileEntry->szFileName && szFileName) - { - strcpy(szFileName, pFileEntry->szFileName); - nError = ERROR_SUCCESS; - } - } - } - - // For local files, copy the file name from the stream - else - { - if(szFileName != NULL) - { - const TCHAR * szStreamName = FileStream_GetFileName(hf->pStream); - StringCopy(szFileName, MAX_PATH, szStreamName); - } - nError = ERROR_SUCCESS; - } - } - - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (nError == ERROR_SUCCESS); -} - diff --git a/libs/storm-sys/StormLib/src/SFileListFile.cpp b/libs/storm-sys/StormLib/src/SFileListFile.cpp deleted file mode 100644 index 777bba3..0000000 --- a/libs/storm-sys/StormLib/src/SFileListFile.cpp +++ /dev/null @@ -1,668 +0,0 @@ -/*****************************************************************************/ -/* SListFile.cpp Copyright (c) Ladislav Zezula 2004 */ -/*---------------------------------------------------------------------------*/ -/* Description: */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 12.06.04 1.00 Lad The first version of SListFile.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "StormCommon.h" -#include - -//----------------------------------------------------------------------------- -// Listfile entry structure - -#define CACHE_BUFFER_SIZE 0x1000 // Size of the cache buffer -#define MAX_LISTFILE_SIZE 0x04000000 // Maximum accepted listfile size is about 68 MB - -union TListFileHandle -{ - TFileStream * pStream; // Opened local file - HANDLE hFile; // Opened MPQ file -}; - -struct TListFileCache -{ - char * szWildCard; // Self-relative pointer to file mask - LPBYTE pBegin; // The begin of the listfile cache - LPBYTE pPos; // Current position in the cache - LPBYTE pEnd; // The last character in the file cache - DWORD dwFlags; // Flags from TMPQArchive - -// char szWildCard[wildcard_length]; // Followed by the name mask (if any) -// char szListFile[listfile_length]; // Followed by the listfile (if any) -}; - -typedef bool (*LOAD_LISTFILE)(TListFileHandle * pHandle, void * pvBuffer, DWORD cbBuffer, LPDWORD pdwBytesRead); - -//----------------------------------------------------------------------------- -// Local functions (cache) - -static char * CopyListLine(char * szListLine, const char * szFileName) -{ - // Copy the string - while(szFileName[0] != 0) - *szListLine++ = *szFileName++; - - // Append the end-of-line - *szListLine++ = 0x0D; - *szListLine++ = 0x0A; - return szListLine; -} - -static bool LoadListFile_Stream(TListFileHandle * pHandle, void * pvBuffer, DWORD cbBuffer, LPDWORD pdwBytesRead) -{ - ULONGLONG ByteOffset = 0; - bool bResult; - - bResult = FileStream_Read(pHandle->pStream, &ByteOffset, pvBuffer, cbBuffer); - if(bResult) - *pdwBytesRead = cbBuffer; - return bResult; -} - -static bool LoadListFile_MPQ(TListFileHandle * pHandle, void * pvBuffer, DWORD cbBuffer, LPDWORD pdwBytesRead) -{ - return SFileReadFile(pHandle->hFile, pvBuffer, cbBuffer, pdwBytesRead, NULL); -} - -static bool FreeListFileCache(TListFileCache * pCache) -{ - // Valid parameter check - if(pCache != NULL) - STORM_FREE(pCache); - return true; -} - -static TListFileCache * CreateListFileCache( - LOAD_LISTFILE PfnLoadFile, - TListFileHandle * pHandle, - const char * szWildCard, - DWORD dwFileSize, - DWORD dwMaxSize, - DWORD dwFlags) -{ - TListFileCache * pCache = NULL; - size_t cchWildCard = 0; - DWORD dwBytesRead = 0; - - // Get the amount of bytes that need to be allocated - if(dwFileSize == 0 || dwFileSize > dwMaxSize) - return NULL; - - // Append buffer for name mask, if any - if(szWildCard != NULL) - cchWildCard = strlen(szWildCard) + 1; - - // Allocate cache for one file block - pCache = (TListFileCache *)STORM_ALLOC(BYTE, sizeof(TListFileCache) + cchWildCard + dwFileSize + 1); - if(pCache != NULL) - { - // Clear the entire structure - memset(pCache, 0, sizeof(TListFileCache) + cchWildCard); - pCache->dwFlags = dwFlags; - - // Shall we copy the mask? - if(cchWildCard != 0) - { - pCache->szWildCard = (char *)(pCache + 1); - memcpy(pCache->szWildCard, szWildCard, cchWildCard); - } - - // Fill-in the rest of the cache pointers - pCache->pBegin = (LPBYTE)(pCache + 1) + cchWildCard; - - // Load the entire listfile to the cache - PfnLoadFile(pHandle, pCache->pBegin, dwFileSize, &dwBytesRead); - if(dwBytesRead != 0) - { - // Allocate pointers - pCache->pPos = pCache->pBegin; - pCache->pEnd = pCache->pBegin + dwBytesRead; - } - else - { - FreeListFileCache(pCache); - pCache = NULL; - } - } - - // Return the cache - return pCache; -} - -static TListFileCache * CreateListFileCache( - HANDLE hMpq, - const TCHAR * szListFile, - const char * szWildCard, - DWORD dwMaxSize, - DWORD dwFlags) -{ - TListFileCache * pCache = NULL; - TListFileHandle ListHandle = {NULL}; - - // Internal listfile: hMPQ must be non NULL and szListFile must be NULL. - // We load the MPQ::(listfile) file - if(hMpq != NULL && szListFile == NULL) - { - DWORD dwFileSize = 0; - - // Open the file from the MPQ - if(SFileOpenFileEx(hMpq, LISTFILE_NAME, 0, &ListHandle.hFile)) - { - // Get the file size and create the listfile cache - dwFileSize = SFileGetFileSize(ListHandle.hFile, NULL); - pCache = CreateListFileCache(LoadListFile_MPQ, &ListHandle, szWildCard, dwFileSize, dwMaxSize, dwFlags); - - // Close the MPQ file - SFileCloseFile(ListHandle.hFile); - } - - // Return the loaded cache - return pCache; - } - - // External listfile: hMpq must be NULL and szListFile must be non-NULL. - // We load the file using TFileStream - if(hMpq == NULL && szListFile != NULL) - { - ULONGLONG FileSize = 0; - - // Open the local file - ListHandle.pStream = FileStream_OpenFile(szListFile, STREAM_FLAG_READ_ONLY); - if(ListHandle.pStream != NULL) - { - // Verify the file size - FileStream_GetSize(ListHandle.pStream, &FileSize); - if(0 < FileSize && FileSize < MAX_LISTFILE_SIZE) - { - pCache = CreateListFileCache(LoadListFile_Stream, &ListHandle, szWildCard, (DWORD)FileSize, dwMaxSize, dwFlags); - } - - // Close the stream - FileStream_Close(ListHandle.pStream); - } - - // Return the loaded cache - return pCache; - } - - // This combination should never happen - SetLastError(ERROR_INVALID_PARAMETER); - assert(false); - return NULL; -} - -#ifdef _DEBUG -/* -TMPQNameCache * CreateNameCache(HANDLE hListFile, const char * szSearchMask) -{ - TMPQNameCache * pNameCache; - char * szCachePointer; - size_t cbToAllocate; - size_t nMaskLength = 1; - DWORD dwBytesRead = 0; - DWORD dwFileSize; - - // Get the size of the listfile. Ignore zero or too long ones - dwFileSize = SFileGetFileSize(hListFile, NULL); - if(dwFileSize == 0 || dwFileSize > MAX_LISTFILE_SIZE) - return NULL; - - // Get the length of the search mask - if(szSearchMask == NULL) - szSearchMask = "*"; - nMaskLength = strlen(szSearchMask) + 1; - - // Allocate the name cache - cbToAllocate = sizeof(TMPQNameCache) + nMaskLength + dwFileSize + 1; - pNameCache = (TMPQNameCache *)STORM_ALLOC(BYTE, cbToAllocate); - if(pNameCache != NULL) - { - // Initialize the name cache - memset(pNameCache, 0, sizeof(TMPQNameCache)); - pNameCache->TotalCacheSize = (DWORD)(nMaskLength + dwFileSize + 1); - szCachePointer = (char *)(pNameCache + 1); - - // Copy the search mask, if any - memcpy(szCachePointer, szSearchMask, nMaskLength); - pNameCache->FirstNameOffset = (DWORD)nMaskLength; - pNameCache->FreeSpaceOffset = (DWORD)nMaskLength; - - // Read the listfile itself - SFileSetFilePointer(hListFile, 0, NULL, FILE_BEGIN); - SFileReadFile(hListFile, szCachePointer + nMaskLength, dwFileSize, &dwBytesRead, NULL); - - // If nothing has been read from the listfile, clear the cache - if(dwBytesRead == 0) - { - STORM_FREE(pNameCache); - return NULL; - } - - // Move the free space offset - pNameCache->FreeSpaceOffset = pNameCache->FirstNameOffset + dwBytesRead + 1; - szCachePointer[nMaskLength + dwBytesRead] = 0; - } - - return pNameCache; -} - -static void FreeNameCache(TMPQNameCache * pNameCache) -{ - if(pNameCache != NULL) - STORM_FREE(pNameCache); - pNameCache = NULL; -} -*/ -#endif // _DEBUG - -static char * ReadListFileLine(TListFileCache * pCache, size_t * PtrLength) -{ - LPBYTE pbLineBegin; - LPBYTE pbLineEnd; - - // Skip newlines. Keep spaces and tabs, as they can be a legal part of the file name - while(pCache->pPos < pCache->pEnd && (pCache->pPos[0] == 0x0A || pCache->pPos[0] == 0x0D)) - pCache->pPos++; - - // Set the line begin and end - if(pCache->pPos >= pCache->pEnd) - return NULL; - pbLineBegin = pbLineEnd = pCache->pPos; - - // Find the end of the line - while(pCache->pPos < pCache->pEnd && pCache->pPos[0] != 0x0A && pCache->pPos[0] != 0x0D) - pCache->pPos++; - - // Remember the end of the line - pbLineEnd = pCache->pPos++; - pbLineEnd[0] = 0; - - // Give the line to the caller - if(PtrLength != NULL) - PtrLength[0] = (size_t)(pbLineEnd - pbLineBegin); - return (char *)pbLineBegin; -} - -static int CompareFileNodes(const void * p1, const void * p2) -{ - char * szFileName1 = *(char **)p1; - char * szFileName2 = *(char **)p2; - - return _stricmp(szFileName1, szFileName2); -} - -static LPBYTE CreateListFile(TMPQArchive * ha, DWORD * pcbListFile) -{ - TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize; - TFileEntry * pFileEntry; - char ** SortTable = NULL; - char * szListFile = NULL; - char * szListLine; - size_t nFileNodes = 0; - size_t cbListFile = 0; - size_t nIndex0; - size_t nIndex1; - - // Allocate the table for sorting listfile - SortTable = STORM_ALLOC(char*, ha->dwFileTableSize); - if(SortTable == NULL) - return NULL; - - // Construct the sort table - // Note: in MPQs with multiple locale versions of the same file, - // this code causes adding multiple listfile entries. - // They will get removed after the listfile sorting - for(pFileEntry = ha->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - { - // Only take existing items - if((pFileEntry->dwFlags & MPQ_FILE_EXISTS) && pFileEntry->szFileName != NULL) - { - // Ignore pseudo-names and internal names - if(!IsPseudoFileName(pFileEntry->szFileName, NULL) && !IsInternalMpqFileName(pFileEntry->szFileName)) - { - SortTable[nFileNodes++] = pFileEntry->szFileName; - } - } - } - - // Remove duplicities - if(nFileNodes > 0) - { - // Sort the table - qsort(SortTable, nFileNodes, sizeof(char *), CompareFileNodes); - - // Count the 0-th item - cbListFile += strlen(SortTable[0]) + 2; - - // Walk through the items and only use the ones that are not duplicated - for(nIndex0 = 0, nIndex1 = 1; nIndex1 < nFileNodes; nIndex1++) - { - // If the next file node is different, we will include it to the result listfile - if(_stricmp(SortTable[nIndex1], SortTable[nIndex0]) != 0) - { - cbListFile += strlen(SortTable[nIndex1]) + 2; - nIndex0 = nIndex1; - } - } - - // Now allocate buffer for the entire listfile - szListFile = szListLine = STORM_ALLOC(char, cbListFile + 1); - if(szListFile != NULL) - { - // Copy the 0-th item - szListLine = CopyListLine(szListLine, SortTable[0]); - - // Walk through the items and only use the ones that are not duplicated - for(nIndex0 = 0, nIndex1 = 1; nIndex1 < nFileNodes; nIndex1++) - { - // If the next file node is different, we will include it to the result listfile - if(_stricmp(SortTable[nIndex1], SortTable[nIndex0]) != 0) - { - // Copy the listfile line - szListLine = CopyListLine(szListLine, SortTable[nIndex1]); - nIndex0 = nIndex1; - } - } - - // Sanity check - does the size match? - assert((size_t)(szListLine - szListFile) == cbListFile); - } - } - else - { - szListFile = STORM_ALLOC(char, 1); - cbListFile = 0; - } - - // Free the sort table - STORM_FREE(SortTable); - - // Give away the listfile - if(pcbListFile != NULL) - *pcbListFile = (DWORD)cbListFile; - return (LPBYTE)szListFile; -} - -//----------------------------------------------------------------------------- -// Local functions (listfile nodes) - -// Adds a name into the list of all names. For each locale in the MPQ, -// one entry will be created -// If the file name is already there, does nothing. -static int SListFileCreateNodeForAllLocales(TMPQArchive * ha, const char * szFileName) -{ - TFileEntry * pFileEntry; - TMPQHash * pFirstHash; - TMPQHash * pHash; - - // If we have HET table, use that one - if(ha->pHetTable != NULL) - { - pFileEntry = GetFileEntryLocale(ha, szFileName, 0); - if(pFileEntry != NULL) - { - // Allocate file name for the file entry - AllocateFileName(ha, pFileEntry, szFileName); - } - - return ERROR_SUCCESS; - } - - // If we have hash table, we use it - if(ha->pHashTable != NULL) - { - // Go while we found something - pFirstHash = pHash = GetFirstHashEntry(ha, szFileName); - while(pHash != NULL) - { - // Allocate file name for the file entry - AllocateFileName(ha, ha->pFileTable + MPQ_BLOCK_INDEX(pHash), szFileName); - - // Now find the next language version of the file - pHash = GetNextHashEntry(ha, pFirstHash, pHash); - } - - return ERROR_SUCCESS; - } - - return ERROR_CAN_NOT_COMPLETE; -} - -// Saves the whole listfile to the MPQ -int SListFileSaveToMpq(TMPQArchive * ha) -{ - TMPQFile * hf = NULL; - LPBYTE pbListFile; - DWORD cbListFile = 0; - int nError = ERROR_SUCCESS; - - // Only save the listfile if we should do so - if(ha->dwFileFlags1 != 0) - { - // At this point, we expect to have at least one reserved entry in the file table - assert(ha->dwFlags & MPQ_FLAG_LISTFILE_NEW); - assert(ha->dwReservedFiles > 0); - - // Create the raw data that is to be written to (listfile) - // Note: Creating the raw data before the (listfile) has been created in the MPQ - // causes that the name of the listfile will not be included in the listfile itself. - // That is OK, because (listfile) in Blizzard MPQs does not contain it either. - pbListFile = CreateListFile(ha, &cbListFile); - if(pbListFile != NULL) - { - // Determine the real flags for (listfile) - if(ha->dwFileFlags1 == MPQ_FILE_DEFAULT_INTERNAL) - ha->dwFileFlags1 = GetDefaultSpecialFileFlags(cbListFile, ha->pHeader->wFormatVersion); - - // Create the listfile in the MPQ - nError = SFileAddFile_Init(ha, LISTFILE_NAME, - 0, - cbListFile, - LANG_NEUTRAL, - ha->dwFileFlags1 | MPQ_FILE_REPLACEEXISTING, - &hf); - - // Write the listfile raw data to it - if(nError == ERROR_SUCCESS) - { - // Write the content of the listfile to the MPQ - nError = SFileAddFile_Write(hf, pbListFile, cbListFile, MPQ_COMPRESSION_ZLIB); - SFileAddFile_Finish(hf); - } - - // Clear the listfile flags - ha->dwFlags &= ~(MPQ_FLAG_LISTFILE_NEW | MPQ_FLAG_LISTFILE_NONE); - ha->dwReservedFiles--; - - // Free the listfile buffer - STORM_FREE(pbListFile); - } - else - { - // If the (listfile) file would be empty, its OK - nError = (cbListFile == 0) ? ERROR_SUCCESS : ERROR_NOT_ENOUGH_MEMORY; - } - } - - return nError; -} - -static int SFileAddArbitraryListFile( - TMPQArchive * ha, - HANDLE hMpq, - const TCHAR * szListFile, - DWORD dwMaxSize) -{ - TListFileCache * pCache = NULL; - - // Create the listfile cache for that file - pCache = CreateListFileCache(hMpq, szListFile, NULL, dwMaxSize, ha->dwFlags); - if(pCache != NULL) - { - char * szFileName; - size_t nLength = 0; - - // Get the next line - while((szFileName = ReadListFileLine(pCache, &nLength)) != NULL) - { - // Add the line to the MPQ - if(nLength != 0) - SListFileCreateNodeForAllLocales(ha, szFileName); - } - - // Delete the cache - FreeListFileCache(pCache); - } - - return (pCache != NULL) ? ERROR_SUCCESS : ERROR_FILE_CORRUPT; -} - -static int SFileAddInternalListFile( - TMPQArchive * ha, - HANDLE hMpq) -{ - TMPQHash * pFirstHash; - TMPQHash * pHash; - LCID lcSaveLocale = lcFileLocale; - DWORD dwMaxSize = MAX_LISTFILE_SIZE; - int nError = ERROR_SUCCESS; - - // If there is hash table, we need to support multiple listfiles - // with different locales (BrooDat.mpq) - if(ha->pHashTable != NULL) - { - // If the archive is a malformed map, ignore too large listfiles - if(ha->dwFlags & MPQ_FLAG_MALFORMED) - dwMaxSize = 0x40000; - - pFirstHash = pHash = GetFirstHashEntry(ha, LISTFILE_NAME); - while(nError == ERROR_SUCCESS && pHash != NULL) - { - // Set the prefered locale to that from list file - SFileSetLocale(pHash->lcLocale); - - // Add that listfile - nError = SFileAddArbitraryListFile(ha, hMpq, NULL, dwMaxSize); - - // Move to the next hash - pHash = GetNextHashEntry(ha, pFirstHash, pHash); - } - - // Restore the original locale - SFileSetLocale(lcSaveLocale); - } - else - { - // Add the single listfile - nError = SFileAddArbitraryListFile(ha, hMpq, NULL, dwMaxSize); - } - - // Return the result of the operation - return nError; -} - -static bool DoListFileSearch(TListFileCache * pCache, SFILE_FIND_DATA * lpFindFileData) -{ - // Check for the valid search handle - if(pCache != NULL) - { - char * szFileName; - size_t nLength = 0; - - // Get the next line - while((szFileName = ReadListFileLine(pCache, &nLength)) != NULL) - { - // Check search mask - if(nLength != 0 && CheckWildCard(szFileName, pCache->szWildCard)) - { - if(nLength >= sizeof(lpFindFileData->cFileName)) - nLength = sizeof(lpFindFileData->cFileName) - 1; - - memcpy(lpFindFileData->cFileName, szFileName, nLength); - lpFindFileData->cFileName[nLength] = 0; - return true; - } - } - } - - // No more files - memset(lpFindFileData, 0, sizeof(SFILE_FIND_DATA)); - SetLastError(ERROR_NO_MORE_FILES); - return false; -} - -//----------------------------------------------------------------------------- -// File functions - -// Adds a listfile into the MPQ archive. -int WINAPI SFileAddListFile(HANDLE hMpq, const TCHAR * szListFile) -{ - TMPQArchive * ha = (TMPQArchive *)hMpq; - int nError = ERROR_SUCCESS; - - // Add the listfile for each MPQ in the patch chain - while(ha != NULL) - { - if(szListFile != NULL) - nError = SFileAddArbitraryListFile(ha, NULL, szListFile, MAX_LISTFILE_SIZE); - else - nError = SFileAddInternalListFile(ha, hMpq); - - // Also, add three special files to the listfile: - // (listfile) itself, (attributes) and (signature) - SListFileCreateNodeForAllLocales(ha, LISTFILE_NAME); - SListFileCreateNodeForAllLocales(ha, SIGNATURE_NAME); - SListFileCreateNodeForAllLocales(ha, ATTRIBUTES_NAME); - - // Move to the next archive in the chain - ha = ha->haPatch; - } - - return nError; -} - -//----------------------------------------------------------------------------- -// Enumerating files in listfile - -HANDLE WINAPI SListFileFindFirstFile(HANDLE hMpq, const TCHAR * szListFile, const char * szMask, SFILE_FIND_DATA * lpFindFileData) -{ - TListFileCache * pCache = NULL; - - // Initialize the structure with zeros - memset(lpFindFileData, 0, sizeof(SFILE_FIND_DATA)); - - // Open the local/internal listfile - pCache = CreateListFileCache(hMpq, szListFile, szMask, 0, 0); - if(pCache != NULL) - { - if(!DoListFileSearch(pCache, lpFindFileData)) - { - memset(lpFindFileData, 0, sizeof(SFILE_FIND_DATA)); - SetLastError(ERROR_NO_MORE_FILES); - FreeListFileCache(pCache); - pCache = NULL; - } - } - - // Return the listfile cache as handle - return (HANDLE)pCache; -} - -bool WINAPI SListFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData) -{ - return DoListFileSearch((TListFileCache *)hFind, lpFindFileData); -} - -bool WINAPI SListFileFindClose(HANDLE hFind) -{ - TListFileCache * pCache = (TListFileCache *)hFind; - - return FreeListFileCache(pCache); -} - diff --git a/libs/storm-sys/StormLib/src/SFileOpenArchive.cpp b/libs/storm-sys/StormLib/src/SFileOpenArchive.cpp deleted file mode 100644 index 9307cd8..0000000 --- a/libs/storm-sys/StormLib/src/SFileOpenArchive.cpp +++ /dev/null @@ -1,601 +0,0 @@ -/*****************************************************************************/ -/* SFileOpenArchive.cpp Copyright Ladislav Zezula 1999 */ -/* */ -/* Author : Ladislav Zezula */ -/* E-mail : ladik@zezula.net */ -/* WWW : www.zezula.net */ -/*---------------------------------------------------------------------------*/ -/* Archive functions of Storm.dll */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* xx.xx.xx 1.00 Lad The first version of SFileOpenArchive.cpp */ -/* 19.11.03 1.01 Dan Big endian handling */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "StormCommon.h" - -#define HEADER_SEARCH_BUFFER_SIZE 0x1000 - -/*****************************************************************************/ -/* Local functions */ -/*****************************************************************************/ - -static bool IsAviFile(DWORD * HeaderData) -{ - DWORD DwordValue0 = BSWAP_INT32_UNSIGNED(HeaderData[0]); - DWORD DwordValue2 = BSWAP_INT32_UNSIGNED(HeaderData[2]); - DWORD DwordValue3 = BSWAP_INT32_UNSIGNED(HeaderData[3]); - - // Test for 'RIFF', 'AVI ' or 'LIST' - return (DwordValue0 == 0x46464952 && DwordValue2 == 0x20495641 && DwordValue3 == 0x5453494C); -} - -static bool IsWarcraft3Map(DWORD * HeaderData) -{ - DWORD DwordValue0 = BSWAP_INT32_UNSIGNED(HeaderData[0]); - DWORD DwordValue1 = BSWAP_INT32_UNSIGNED(HeaderData[1]); - - return (DwordValue0 == 0x57334D48 && DwordValue1 == 0x00000000); -} - -static TMPQUserData * IsValidMpqUserData(ULONGLONG ByteOffset, ULONGLONG FileSize, void * pvUserData) -{ - TMPQUserData * pUserData; - - // BSWAP the source data and copy them to our buffer - BSWAP_ARRAY32_UNSIGNED(&pvUserData, sizeof(TMPQUserData)); - pUserData = (TMPQUserData *)pvUserData; - - // Check the sizes - if(pUserData->cbUserDataHeader <= pUserData->cbUserDataSize && pUserData->cbUserDataSize <= pUserData->dwHeaderOffs) - { - // Move to the position given by the userdata - ByteOffset += pUserData->dwHeaderOffs; - - // The MPQ header should be within range of the file size - if((ByteOffset + MPQ_HEADER_SIZE_V1) < FileSize) - { - // Note: We should verify if there is the MPQ header. - // However, the header could be at any position below that - // that is multiplier of 0x200 - return (TMPQUserData *)pvUserData; - } - } - - return NULL; -} - -// This function gets the right positions of the hash table and the block table. -static int VerifyMpqTablePositions(TMPQArchive * ha, ULONGLONG FileSize) -{ - TMPQHeader * pHeader = ha->pHeader; - ULONGLONG ByteOffset; - - // Check the begin of HET table - if(pHeader->HetTablePos64) - { - ByteOffset = ha->MpqPos + pHeader->HetTablePos64; - if(ByteOffset > FileSize) - return ERROR_BAD_FORMAT; - } - - // Check the begin of BET table - if(pHeader->BetTablePos64) - { - ByteOffset = ha->MpqPos + pHeader->BetTablePos64; - if(ByteOffset > FileSize) - return ERROR_BAD_FORMAT; - } - - // Check the begin of hash table - if(pHeader->wHashTablePosHi || pHeader->dwHashTablePos) - { - ByteOffset = FileOffsetFromMpqOffset(ha, MAKE_OFFSET64(pHeader->wHashTablePosHi, pHeader->dwHashTablePos)); - if(ByteOffset > FileSize) - return ERROR_BAD_FORMAT; - } - - // Check the begin of block table - if(pHeader->wBlockTablePosHi || pHeader->dwBlockTablePos) - { - ByteOffset = FileOffsetFromMpqOffset(ha, MAKE_OFFSET64(pHeader->wBlockTablePosHi, pHeader->dwBlockTablePos)); - if(ByteOffset > FileSize) - return ERROR_BAD_FORMAT; - } - - // Check the begin of hi-block table - if(pHeader->HiBlockTablePos64 != 0) - { - ByteOffset = ha->MpqPos + pHeader->HiBlockTablePos64; - if(ByteOffset > FileSize) - return ERROR_BAD_FORMAT; - } - - // All OK. - return ERROR_SUCCESS; -} - -/*****************************************************************************/ -/* Public functions */ -/*****************************************************************************/ - -//----------------------------------------------------------------------------- -// SFileGetLocale and SFileSetLocale -// Set the locale for all newly opened files - -LCID WINAPI SFileGetLocale() -{ - return lcFileLocale; -} - -LCID WINAPI SFileSetLocale(LCID lcNewLocale) -{ - lcFileLocale = lcNewLocale; - return lcFileLocale; -} - -//----------------------------------------------------------------------------- -// SFileOpenArchive -// -// szFileName - MPQ archive file name to open -// dwPriority - When SFileOpenFileEx called, this contains the search priority for searched archives -// dwFlags - See MPQ_OPEN_XXX in StormLib.h -// phMpq - Pointer to store open archive handle - -bool WINAPI SFileOpenArchive( - const TCHAR * szMpqName, - DWORD dwPriority, - DWORD dwFlags, - HANDLE * phMpq) -{ - TMPQUserData * pUserData; - TFileStream * pStream = NULL; // Open file stream - TMPQArchive * ha = NULL; // Archive handle - TFileEntry * pFileEntry; - ULONGLONG FileSize = 0; // Size of the file - LPBYTE pbHeaderBuffer = NULL; // Buffer for searching MPQ header - DWORD dwStreamFlags = (dwFlags & STREAM_FLAGS_MASK); - bool bIsWarcraft3Map = false; - int nError = ERROR_SUCCESS; - - // Verify the parameters - if(szMpqName == NULL || *szMpqName == 0 || phMpq == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return false; - } - - // One time initialization of MPQ cryptography - InitializeMpqCryptography(); - dwPriority = dwPriority; - - // If not forcing MPQ v 1.0, also use file bitmap - dwStreamFlags |= (dwFlags & MPQ_OPEN_FORCE_MPQ_V1) ? 0 : STREAM_FLAG_USE_BITMAP; - - // Open the MPQ archive file - pStream = FileStream_OpenFile(szMpqName, dwStreamFlags); - if(pStream == NULL) - return false; - - // Check the file size. There must be at least 0x20 bytes - if(nError == ERROR_SUCCESS) - { - FileStream_GetSize(pStream, &FileSize); - if(FileSize < MPQ_HEADER_SIZE_V1) - nError = ERROR_BAD_FORMAT; - } - - // Allocate the MPQhandle - if(nError == ERROR_SUCCESS) - { - if((ha = STORM_ALLOC(TMPQArchive, 1)) == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Allocate buffer for searching MPQ header - if(nError == ERROR_SUCCESS) - { - pbHeaderBuffer = STORM_ALLOC(BYTE, HEADER_SEARCH_BUFFER_SIZE); - if(pbHeaderBuffer == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - } - - // Find the position of MPQ header - if(nError == ERROR_SUCCESS) - { - ULONGLONG SearchOffset = 0; - ULONGLONG EndOfSearch = FileSize; - DWORD dwStrmFlags = 0; - DWORD dwHeaderSize; - DWORD dwHeaderID; - bool bSearchComplete = false; - - memset(ha, 0, sizeof(TMPQArchive)); - ha->pfnHashString = HashStringSlash; - ha->pStream = pStream; - pStream = NULL; - - // Set the archive read only if the stream is read-only - FileStream_GetFlags(ha->pStream, &dwStrmFlags); - ha->dwFlags |= (dwStrmFlags & STREAM_FLAG_READ_ONLY) ? MPQ_FLAG_READ_ONLY : 0; - - // Also remember if we shall check sector CRCs when reading file - ha->dwFlags |= (dwFlags & MPQ_OPEN_CHECK_SECTOR_CRC) ? MPQ_FLAG_CHECK_SECTOR_CRC : 0; - - // Also remember if this MPQ is a patch - ha->dwFlags |= (dwFlags & MPQ_OPEN_PATCH) ? MPQ_FLAG_PATCH : 0; - - // Limit the header searching to about 130 MB of data - if(EndOfSearch > 0x08000000) - EndOfSearch = 0x08000000; - - // Find the offset of MPQ header within the file - while(bSearchComplete == false && SearchOffset < EndOfSearch) - { - // Always read at least 0x1000 bytes for performance. - // This is what Storm.dll (2002) does. - DWORD dwBytesAvailable = HEADER_SEARCH_BUFFER_SIZE; - DWORD dwInBufferOffset = 0; - - // Cut the bytes available, if needed - if((FileSize - SearchOffset) < HEADER_SEARCH_BUFFER_SIZE) - dwBytesAvailable = (DWORD)(FileSize - SearchOffset); - - // Read the eventual MPQ header - if(!FileStream_Read(ha->pStream, &SearchOffset, pbHeaderBuffer, dwBytesAvailable)) - { - nError = GetLastError(); - break; - } - - // There are AVI files from Warcraft III with 'MPQ' extension. - if(SearchOffset == 0) - { - if(IsAviFile((DWORD *)pbHeaderBuffer)) - { - nError = ERROR_AVI_FILE; - break; - } - - bIsWarcraft3Map = IsWarcraft3Map((DWORD *)pbHeaderBuffer); - } - - // Search the header buffer - while(dwInBufferOffset < dwBytesAvailable) - { - // Copy the data from the potential header buffer to the MPQ header - memcpy(ha->HeaderData, pbHeaderBuffer + dwInBufferOffset, sizeof(ha->HeaderData)); - - // If there is the MPQ user data, process it - // Note that Warcraft III does not check for user data, which is abused by many map protectors - dwHeaderID = BSWAP_INT32_UNSIGNED(ha->HeaderData[0]); - if(bIsWarcraft3Map == false && (dwFlags & MPQ_OPEN_FORCE_MPQ_V1) == 0) - { - if(ha->pUserData == NULL && dwHeaderID == ID_MPQ_USERDATA) - { - // Verify if this looks like a valid user data - pUserData = IsValidMpqUserData(SearchOffset, FileSize, ha->HeaderData); - if(pUserData != NULL) - { - // Fill the user data header - ha->UserDataPos = SearchOffset; - ha->pUserData = &ha->UserData; - memcpy(ha->pUserData, pUserData, sizeof(TMPQUserData)); - - // Continue searching from that position - SearchOffset += ha->pUserData->dwHeaderOffs; - break; - } - } - } - - // There must be MPQ header signature. Note that STORM.dll from Warcraft III actually - // tests the MPQ header size. It must be at least 0x20 bytes in order to load it - // Abused by Spazzler Map protector. Note that the size check is not present - // in Storm.dll v 1.00, so Diablo I code would load the MPQ anyway. - dwHeaderSize = BSWAP_INT32_UNSIGNED(ha->HeaderData[1]); - if(dwHeaderID == ID_MPQ && dwHeaderSize >= MPQ_HEADER_SIZE_V1) - { - // Now convert the header to version 4 - nError = ConvertMpqHeaderToFormat4(ha, SearchOffset, FileSize, dwFlags, bIsWarcraft3Map); - bSearchComplete = true; - break; - } - - // Check for MPK archives (Longwu Online - MPQ fork) - if(bIsWarcraft3Map == false && dwHeaderID == ID_MPK) - { - // Now convert the MPK header to MPQ Header version 4 - nError = ConvertMpkHeaderToFormat4(ha, FileSize, dwFlags); - bSearchComplete = true; - break; - } - - // If searching for the MPQ header is disabled, return an error - if(dwFlags & MPQ_OPEN_NO_HEADER_SEARCH) - { - nError = ERROR_NOT_SUPPORTED; - bSearchComplete = true; - break; - } - - // Move the pointers - SearchOffset += 0x200; - dwInBufferOffset += 0x200; - } - } - - // Did we identify one of the supported headers? - if(nError == ERROR_SUCCESS) - { - // Set the user data position to the MPQ header, if none - if(ha->pUserData == NULL) - ha->UserDataPos = SearchOffset; - - // Set the position of the MPQ header - ha->pHeader = (TMPQHeader *)ha->HeaderData; - ha->MpqPos = SearchOffset; - ha->FileSize = FileSize; - - // Sector size must be nonzero. - if(SearchOffset >= FileSize || ha->pHeader->wSectorSize == 0) - nError = ERROR_BAD_FORMAT; - } - } - - // Fix table positions according to format - if(nError == ERROR_SUCCESS) - { - // Dump the header -// DumpMpqHeader(ha->pHeader); - - // W3x Map Protectors use the fact that War3's Storm.dll ignores the MPQ user data, - // and ignores the MPQ format version as well. The trick is to - // fake MPQ format 2, with an improper hi-word position of hash table and block table - // We can overcome such protectors by forcing opening the archive as MPQ v 1.0 - if(dwFlags & MPQ_OPEN_FORCE_MPQ_V1) - { - ha->pHeader->wFormatVersion = MPQ_FORMAT_VERSION_1; - ha->pHeader->dwHeaderSize = MPQ_HEADER_SIZE_V1; - ha->dwFlags |= MPQ_FLAG_READ_ONLY; - ha->pUserData = NULL; - } - - // Anti-overflow. If the hash table size in the header is - // higher than 0x10000000, it would overflow in 32-bit version - // Observed in the malformed Warcraft III maps - // Example map: MPQ_2016_v1_ProtectedMap_TableSizeOverflow.w3x - ha->pHeader->dwBlockTableSize = (ha->pHeader->dwBlockTableSize & BLOCK_INDEX_MASK); - ha->pHeader->dwHashTableSize = (ha->pHeader->dwHashTableSize & BLOCK_INDEX_MASK); - - // Both MPQ_OPEN_NO_LISTFILE or MPQ_OPEN_NO_ATTRIBUTES trigger read only mode - if(dwFlags & (MPQ_OPEN_NO_LISTFILE | MPQ_OPEN_NO_ATTRIBUTES)) - ha->dwFlags |= MPQ_FLAG_READ_ONLY; - - // Check if the caller wants to force adding listfile - if(dwFlags & MPQ_OPEN_FORCE_LISTFILE) - ha->dwFlags |= MPQ_FLAG_LISTFILE_FORCE; - - // Remember whether whis is a map for Warcraft III - if(bIsWarcraft3Map) - ha->dwFlags |= MPQ_FLAG_WAR3_MAP; - - // Set the size of file sector - ha->dwSectorSize = (0x200 << ha->pHeader->wSectorSize); - - // Verify if any of the tables doesn't start beyond the end of the file - nError = VerifyMpqTablePositions(ha, FileSize); - } - - // Read the hash table. Ignore the result, as hash table is no longer required - // Read HET table. Ignore the result, as HET table is no longer required - if(nError == ERROR_SUCCESS) - { - nError = LoadAnyHashTable(ha); - } - - // Now, build the file table. It will be built by combining - // the block table, BET table, hi-block table, (attributes) and (listfile). - if(nError == ERROR_SUCCESS) - { - nError = BuildFileTable(ha); - } - - // Load the internal listfile and include it to the file table - if(nError == ERROR_SUCCESS && (dwFlags & MPQ_OPEN_NO_LISTFILE) == 0) - { - // Quick check for (listfile) - pFileEntry = GetFileEntryLocale(ha, LISTFILE_NAME, LANG_NEUTRAL); - if(pFileEntry != NULL) - { - // Ignore result of the operation. (listfile) is optional. - SFileAddListFile((HANDLE)ha, NULL); - ha->dwFileFlags1 = pFileEntry->dwFlags; - } - } - - // Load the "(attributes)" file and merge it to the file table - if(nError == ERROR_SUCCESS && (dwFlags & MPQ_OPEN_NO_ATTRIBUTES) == 0 && (ha->dwFlags & MPQ_FLAG_BLOCK_TABLE_CUT) == 0) - { - // Quick check for (attributes) - pFileEntry = GetFileEntryLocale(ha, ATTRIBUTES_NAME, LANG_NEUTRAL); - if(pFileEntry != NULL) - { - // Ignore result of the operation. (attributes) is optional. - SAttrLoadAttributes(ha); - ha->dwFileFlags2 = pFileEntry->dwFlags; - } - } - - // Remember whether the archive has weak signature. Only for MPQs format 1.0. - if(nError == ERROR_SUCCESS) - { - // Quick check for (signature) - pFileEntry = GetFileEntryLocale(ha, SIGNATURE_NAME, LANG_NEUTRAL); - if(pFileEntry != NULL) - { - // Just remember that the archive is weak-signed - assert((pFileEntry->dwFlags & MPQ_FILE_EXISTS) != 0); - ha->dwFileFlags3 = pFileEntry->dwFlags; - } - - // Finally, set the MPQ_FLAG_READ_ONLY if the MPQ was found malformed - ha->dwFlags |= (ha->dwFlags & MPQ_FLAG_MALFORMED) ? MPQ_FLAG_READ_ONLY : 0; - } - - // Cleanup and exit - if(nError != ERROR_SUCCESS) - { - FileStream_Close(pStream); - FreeArchiveHandle(ha); - SetLastError(nError); - ha = NULL; - } - - // Free the header buffer - if(pbHeaderBuffer != NULL) - STORM_FREE(pbHeaderBuffer); - if(phMpq != NULL) - *phMpq = ha; - return (nError == ERROR_SUCCESS); -} - -//----------------------------------------------------------------------------- -// bool WINAPI SFileSetDownloadCallback(HANDLE, SFILE_DOWNLOAD_CALLBACK, void *); -// -// Sets a callback that is called when content is downloaded from the master MPQ -// - -bool WINAPI SFileSetDownloadCallback(HANDLE hMpq, SFILE_DOWNLOAD_CALLBACK DownloadCB, void * pvUserData) -{ - TMPQArchive * ha = (TMPQArchive *)hMpq; - - // Do nothing if 'hMpq' is bad parameter - if(!IsValidMpqHandle(hMpq)) - { - SetLastError(ERROR_INVALID_HANDLE); - return false; - } - - return FileStream_SetCallback(ha->pStream, DownloadCB, pvUserData); -} - -//----------------------------------------------------------------------------- -// bool SFileFlushArchive(HANDLE hMpq) -// -// Saves all dirty data into MPQ archive. -// Has similar effect like SFileCloseArchive, but the archive is not closed. -// Use on clients who keep MPQ archive open even for write operations, -// and terminating without calling SFileCloseArchive might corrupt the archive. -// - -bool WINAPI SFileFlushArchive(HANDLE hMpq) -{ - TMPQArchive * ha; - int nResultError = ERROR_SUCCESS; - int nError; - - // Do nothing if 'hMpq' is bad parameter - if((ha = IsValidMpqHandle(hMpq)) == NULL) - { - SetLastError(ERROR_INVALID_HANDLE); - return false; - } - - // Only if the MPQ was changed - if(ha->dwFlags & MPQ_FLAG_CHANGED) - { - // Indicate that we are saving MPQ internal structures - ha->dwFlags |= MPQ_FLAG_SAVING_TABLES; - - // Defragment the file table. This will allow us to put the internal files to the end - DefragmentFileTable(ha); - - // - // Create each internal file - // Note that the (signature) file is usually before (listfile) in the file table - // - - if(ha->dwFlags & MPQ_FLAG_SIGNATURE_NEW) - { - nError = SSignFileCreate(ha); - if(nError != ERROR_SUCCESS) - nResultError = nError; - } - - if(ha->dwFlags & (MPQ_FLAG_LISTFILE_NEW | MPQ_FLAG_LISTFILE_FORCE)) - { - nError = SListFileSaveToMpq(ha); - if(nError != ERROR_SUCCESS) - nResultError = nError; - } - - if(ha->dwFlags & MPQ_FLAG_ATTRIBUTES_NEW) - { - nError = SAttrFileSaveToMpq(ha); - if(nError != ERROR_SUCCESS) - nResultError = nError; - } - - // Save HET table, BET table, hash table, block table, hi-block table - if(ha->dwFlags & MPQ_FLAG_CHANGED) - { - // Rebuild the HET table - if(ha->pHetTable != NULL) - RebuildHetTable(ha); - - // Save all MPQ tables first - nError = SaveMPQTables(ha); - if(nError != ERROR_SUCCESS) - nResultError = nError; - - // If the archive has weak signature, we need to finish it - if(ha->dwFileFlags3 != 0) - { - nError = SSignFileFinish(ha); - if(nError != ERROR_SUCCESS) - nResultError = nError; - } - } - - // We are no longer saving internal MPQ structures - ha->dwFlags &= ~MPQ_FLAG_SAVING_TABLES; - } - - // Return the error - if(nResultError != ERROR_SUCCESS) - SetLastError(nResultError); - return (nResultError == ERROR_SUCCESS); -} - -//----------------------------------------------------------------------------- -// bool SFileCloseArchive(HANDLE hMpq); -// - -bool WINAPI SFileCloseArchive(HANDLE hMpq) -{ - TMPQArchive * ha = IsValidMpqHandle(hMpq); - bool bResult = false; - - // Only if the handle is valid - if(ha == NULL) - { - SetLastError(ERROR_INVALID_HANDLE); - return false; - } - - // Invalidate the add file callback so it won't be called - // when saving (listfile) and (attributes) - ha->pfnAddFileCB = NULL; - ha->pvAddFileUserData = NULL; - - // Flush all unsaved data to the storage - bResult = SFileFlushArchive(hMpq); - - // Free all memory used by MPQ archive - FreeArchiveHandle(ha); - return bResult; -} diff --git a/libs/storm-sys/StormLib/src/SFileOpenFileEx.cpp b/libs/storm-sys/StormLib/src/SFileOpenFileEx.cpp deleted file mode 100644 index a139585..0000000 --- a/libs/storm-sys/StormLib/src/SFileOpenFileEx.cpp +++ /dev/null @@ -1,399 +0,0 @@ -/*****************************************************************************/ -/* SFileOpenFileEx.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Description : */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* xx.xx.99 1.00 Lad The first version of SFileOpenFileEx.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "StormCommon.h" - -/*****************************************************************************/ -/* Local functions */ -/*****************************************************************************/ - -static DWORD FindHashIndex(TMPQArchive * ha, DWORD dwFileIndex) -{ - TMPQHash * pHashTableEnd; - TMPQHash * pHash; - DWORD dwFirstIndex = HASH_ENTRY_FREE; - - // Should only be called if the archive has hash table - assert(ha->pHashTable != NULL); - - // Multiple hash table entries can point to the file table entry. - // We need to search all of them - pHashTableEnd = ha->pHashTable + ha->pHeader->dwHashTableSize; - for(pHash = ha->pHashTable; pHash < pHashTableEnd; pHash++) - { - if(MPQ_BLOCK_INDEX(pHash) == dwFileIndex) - { - // Duplicate hash entry found - if(dwFirstIndex != HASH_ENTRY_FREE) - return HASH_ENTRY_FREE; - dwFirstIndex = (DWORD)(pHash - ha->pHashTable); - } - } - - // Return the hash table entry index - return dwFirstIndex; -} - -static const char * GetPatchFileName(TMPQArchive * ha, const char * szFileName, char * szBuffer) -{ - TMPQNamePrefix * pPrefix; - - // Are there patches in the current MPQ? - if(ha->dwFlags & MPQ_FLAG_PATCH) - { - // The patch prefix must be already known here - assert(ha->pPatchPrefix != NULL); - pPrefix = ha->pPatchPrefix; - - // The patch name for "OldWorld\\XXX\\YYY" is "Base\\XXX\YYY" - // We need to remove the "OldWorld\\" prefix - if(!_strnicmp(szFileName, "OldWorld\\", 9)) - szFileName += 9; - - // Create the file name from the known patch entry - memcpy(szBuffer, pPrefix->szPatchPrefix, pPrefix->nLength); - strcpy(szBuffer + pPrefix->nLength, szFileName); - szFileName = szBuffer; - } - - return szFileName; -} - -static bool OpenLocalFile(const char * szFileName, HANDLE * PtrFile) -{ - TFileStream * pStream; - TMPQFile * hf = NULL; - TCHAR szFileNameT[MAX_PATH]; - - // Convert the file name to UNICODE (if needed) - StringCopy(szFileNameT, _countof(szFileNameT), szFileName); - - // Open the file and create the TMPQFile structure - pStream = FileStream_OpenFile(szFileNameT, STREAM_FLAG_READ_ONLY); - if(pStream != NULL) - { - // Allocate and initialize file handle - hf = CreateFileHandle(NULL, NULL); - if(hf != NULL) - { - hf->pStream = pStream; - *PtrFile = hf; - return true; - } - else - { - FileStream_Close(pStream); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - } - } - *PtrFile = NULL; - return false; -} - -bool OpenPatchedFile(HANDLE hMpq, const char * szFileName, HANDLE * PtrFile) -{ - TMPQArchive * haBase = NULL; - TMPQArchive * ha = (TMPQArchive *)hMpq; - TFileEntry * pFileEntry; - TMPQFile * hfPatch; // Pointer to patch file - TMPQFile * hfBase = NULL; // Pointer to base open file - TMPQFile * hf = NULL; - HANDLE hPatchFile; - char szNameBuffer[MAX_PATH]; - - // First of all, find the latest archive where the file is in base version - // (i.e. where the original, unpatched version of the file exists) - while(ha != NULL) - { - // If the file is there, then we remember the archive - pFileEntry = GetFileEntryExact(ha, GetPatchFileName(ha, szFileName, szNameBuffer), 0, NULL); - if(pFileEntry != NULL && (pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) == 0) - haBase = ha; - - // Move to the patch archive - ha = ha->haPatch; - } - - // If we couldn't find the base file in any of the patches, it doesn't exist - if((ha = haBase) == NULL) - { - SetLastError(ERROR_FILE_NOT_FOUND); - return false; - } - - // Now open the base file - if(SFileOpenFileEx((HANDLE)ha, GetPatchFileName(ha, szFileName, szNameBuffer), SFILE_OPEN_BASE_FILE, (HANDLE *)&hfBase)) - { - // The file must be a base file, i.e. without MPQ_FILE_PATCH_FILE - assert((hfBase->pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) == 0); - hf = hfBase; - - // Now open all patches and attach them on top of the base file - for(ha = ha->haPatch; ha != NULL; ha = ha->haPatch) - { - // Prepare the file name with a correct prefix - if(SFileOpenFileEx((HANDLE)ha, GetPatchFileName(ha, szFileName, szNameBuffer), SFILE_OPEN_BASE_FILE, &hPatchFile)) - { - // Remember the new version - hfPatch = (TMPQFile *)hPatchFile; - - // We should not find patch file - assert((hfPatch->pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) != 0); - - // Attach the patch to the base file - hf->hfPatch = hfPatch; - hf = hfPatch; - } - } - } - - // Give the updated base MPQ - if(PtrFile != NULL) - *PtrFile = (HANDLE)hfBase; - return (hfBase != NULL); -} - -/*****************************************************************************/ -/* Public functions */ -/*****************************************************************************/ - -//----------------------------------------------------------------------------- -// SFileEnumLocales enums all locale versions within MPQ. -// Functions fills all available language identifiers on a file into the buffer -// pointed by plcLocales. There must be enough entries to copy the localed, -// otherwise the function returns ERROR_INSUFFICIENT_BUFFER. - -int WINAPI SFileEnumLocales( - HANDLE hMpq, - const char * szFileName, - LCID * PtrLocales, - LPDWORD PtrMaxLocales, - DWORD dwSearchScope) -{ - TMPQArchive * ha = (TMPQArchive *)hMpq; - TMPQHash * pFirstHash; - TMPQHash * pHash; - DWORD dwFileIndex = 0; - DWORD dwMaxLocales; - DWORD dwLocales = 0; - - // Test the parameters - if(!IsValidMpqHandle(hMpq)) - return ERROR_INVALID_HANDLE; - if(szFileName == NULL || *szFileName == 0) - return ERROR_INVALID_PARAMETER; - if(ha->pHashTable == NULL) - return ERROR_NOT_SUPPORTED; - if(PtrMaxLocales == NULL) - return ERROR_INVALID_PARAMETER; - if(IsPseudoFileName(szFileName, &dwFileIndex)) - return ERROR_INVALID_PARAMETER; - - // Keep compiler happy - dwMaxLocales = PtrMaxLocales[0]; - dwSearchScope = dwSearchScope; - - // Parse all files with that name - pFirstHash = pHash = GetFirstHashEntry(ha, szFileName); - while(pHash != NULL) - { - // Put the locales to the buffer - if(PtrLocales != NULL && dwLocales < dwMaxLocales) - *PtrLocales++ = pHash->lcLocale; - dwLocales++; - - // Get the next locale - pHash = GetNextHashEntry(ha, pFirstHash, pHash); - } - - // Give the caller the number of locales and return - PtrMaxLocales[0] = dwLocales; - return (dwLocales <= dwMaxLocales) ? ERROR_SUCCESS : ERROR_INSUFFICIENT_BUFFER; -} - -//----------------------------------------------------------------------------- -// SFileOpenFileEx -// -// hMpq - Handle of opened MPQ archive -// szFileName - Name of file to open -// dwSearchScope - Where to search -// PtrFile - Pointer to store opened file handle - -bool WINAPI SFileOpenFileEx(HANDLE hMpq, const char * szFileName, DWORD dwSearchScope, HANDLE * PtrFile) -{ - TMPQArchive * ha = IsValidMpqHandle(hMpq); - TFileEntry * pFileEntry = NULL; - TMPQFile * hf = NULL; - DWORD dwHashIndex = HASH_ENTRY_FREE; - DWORD dwFileIndex = 0; - bool bOpenByIndex = false; - int nError = ERROR_SUCCESS; - - // Don't accept NULL pointer to file handle - if(szFileName == NULL || *szFileName == 0) - nError = ERROR_INVALID_PARAMETER; - - // When opening a file from MPQ, the handle must be valid - if(dwSearchScope != SFILE_OPEN_LOCAL_FILE && ha == NULL) - nError = ERROR_INVALID_HANDLE; - - // When not checking for existence, the pointer to file handle must be valid - if(dwSearchScope != SFILE_OPEN_CHECK_EXISTS && PtrFile == NULL) - nError = ERROR_INVALID_PARAMETER; - - // Prepare the file opening - if(nError == ERROR_SUCCESS) - { - switch(dwSearchScope) - { - case SFILE_OPEN_FROM_MPQ: - case SFILE_OPEN_BASE_FILE: - case SFILE_OPEN_CHECK_EXISTS: - - // If this MPQ has no patches, open the file from this MPQ directly - if(ha->haPatch == NULL || dwSearchScope == SFILE_OPEN_BASE_FILE) - { - pFileEntry = GetFileEntryLocale2(ha, szFileName, lcFileLocale, &dwHashIndex); - } - - // If this MPQ is a patched archive, open the file as patched - else - { - return OpenPatchedFile(hMpq, szFileName, PtrFile); - } - break; - - case SFILE_OPEN_ANY_LOCALE: - - // This open option is reserved for opening MPQ internal listfile. - // No argument validation. Tries to open file with neutral locale first, - // then any other available. - pFileEntry = GetFileEntryLocale2(ha, szFileName, 0, &dwHashIndex); - break; - - case SFILE_OPEN_LOCAL_FILE: - - // Open a local file - return OpenLocalFile(szFileName, PtrFile); - - default: - - // Don't accept any other value - nError = ERROR_INVALID_PARAMETER; - break; - } - } - - // Check whether the file really exists in the MPQ - if(nError == ERROR_SUCCESS) - { - if(pFileEntry == NULL || (pFileEntry->dwFlags & MPQ_FILE_EXISTS) == 0) - { - // Check the pseudo-file name - if((bOpenByIndex = IsPseudoFileName(szFileName, &dwFileIndex)) == true) - { - // Get the file entry for the file - if(dwFileIndex < ha->dwFileTableSize) - { - pFileEntry = ha->pFileTable + dwFileIndex; - } - } - - if(pFileEntry == NULL) - { - nError = ERROR_FILE_NOT_FOUND; - } - } - - // Ignore unknown loading flags (example: MPQ_2016_v1_WME4_4.w3x) -// if(pFileEntry != NULL && pFileEntry->dwFlags & ~MPQ_FILE_VALID_FLAGS) -// nError = ERROR_NOT_SUPPORTED; - } - - // Did the caller just wanted to know if the file exists? - if(nError == ERROR_SUCCESS && dwSearchScope != SFILE_OPEN_CHECK_EXISTS) - { - // Allocate file handle - hf = CreateFileHandle(ha, pFileEntry); - if(hf != NULL) - { - // Get the hash index for the file - if(ha->pHashTable != NULL && dwHashIndex == HASH_ENTRY_FREE) - dwHashIndex = FindHashIndex(ha, dwFileIndex); - if(dwHashIndex != HASH_ENTRY_FREE) - hf->pHashEntry = ha->pHashTable + dwHashIndex; - hf->dwHashIndex = dwHashIndex; - - // If the MPQ has sector CRC enabled, enable if for the file - if(ha->dwFlags & MPQ_FLAG_CHECK_SECTOR_CRC) - hf->bCheckSectorCRCs = true; - - // If we know the real file name, copy it to the file entry - if(bOpenByIndex == false) - { - // If there is no file name yet, allocate it - AllocateFileName(ha, pFileEntry, szFileName); - - // If the file is encrypted, we should detect the file key - if(pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED) - { - hf->dwFileKey = DecryptFileKey(szFileName, - pFileEntry->ByteOffset, - pFileEntry->dwFileSize, - pFileEntry->dwFlags); - } - } - } - else - { - nError = ERROR_NOT_ENOUGH_MEMORY; - } - } - - // Give the file entry - if(PtrFile != NULL) - PtrFile[0] = hf; - - // Return error code - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (nError == ERROR_SUCCESS); -} - -//----------------------------------------------------------------------------- -// SFileHasFile -// -// hMpq - Handle of opened MPQ archive -// szFileName - Name of file to look for - -bool WINAPI SFileHasFile(HANDLE hMpq, const char * szFileName) -{ - return SFileOpenFileEx(hMpq, szFileName, SFILE_OPEN_CHECK_EXISTS, NULL); -} - -//----------------------------------------------------------------------------- -// bool WINAPI SFileCloseFile(HANDLE hFile); - -bool WINAPI SFileCloseFile(HANDLE hFile) -{ - TMPQFile * hf = (TMPQFile *)hFile; - - if(!IsValidFileHandle(hFile)) - { - SetLastError(ERROR_INVALID_HANDLE); - return false; - } - - // Free the structure - FreeFileHandle(hf); - return true; -} diff --git a/libs/storm-sys/StormLib/src/SFilePatchArchives.cpp b/libs/storm-sys/StormLib/src/SFilePatchArchives.cpp deleted file mode 100644 index dc16631..0000000 --- a/libs/storm-sys/StormLib/src/SFilePatchArchives.cpp +++ /dev/null @@ -1,1175 +0,0 @@ -/*****************************************************************************/ -/* SFilePatchArchives.cpp Copyright (c) Ladislav Zezula 2010 */ -/*---------------------------------------------------------------------------*/ -/* Description: */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 18.08.10 1.00 Lad The first version of SFilePatchArchives.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "StormCommon.h" - -//----------------------------------------------------------------------------- -// Local structures - -#define MAX_SC2_PATCH_PREFIX 0x80 - -#define PATCH_SIGNATURE_HEADER 0x48435450 -#define PATCH_SIGNATURE_MD5 0x5f35444d -#define PATCH_SIGNATURE_XFRM 0x4d524658 - -#define SIZE_OF_XFRM_HEADER 0x0C - -// Header for incremental patch files -typedef struct _MPQ_PATCH_HEADER -{ - //-- PATCH header ----------------------------------- - DWORD dwSignature; // 'PTCH' - DWORD dwSizeOfPatchData; // Size of the entire patch (decompressed) - DWORD dwSizeBeforePatch; // Size of the file before patch - DWORD dwSizeAfterPatch; // Size of file after patch - - //-- MD5 block -------------------------------------- - DWORD dwMD5; // 'MD5_' - DWORD dwMd5BlockSize; // Size of the MD5 block, including the signature and size itself - BYTE md5_before_patch[0x10]; // MD5 of the original (unpached) file - BYTE md5_after_patch[0x10]; // MD5 of the patched file - - //-- XFRM block ------------------------------------- - DWORD dwXFRM; // 'XFRM' - DWORD dwXfrmBlockSize; // Size of the XFRM block, includes XFRM header and patch data - DWORD dwPatchType; // Type of patch ('BSD0' or 'COPY') - - // Followed by the patch data -} MPQ_PATCH_HEADER, *PMPQ_PATCH_HEADER; - -typedef struct _BLIZZARD_BSDIFF40_FILE -{ - ULONGLONG Signature; - ULONGLONG CtrlBlockSize; - ULONGLONG DataBlockSize; - ULONGLONG NewFileSize; -} BLIZZARD_BSDIFF40_FILE, *PBLIZZARD_BSDIFF40_FILE; - -typedef struct _BSDIFF_CTRL_BLOCK -{ - DWORD dwAddDataLength; - DWORD dwMovDataLength; - DWORD dwOldMoveLength; - -} BSDIFF_CTRL_BLOCK, *PBSDIFF_CTRL_BLOCK; - -typedef struct _LOCALIZED_MPQ_INFO -{ - const char * szNameTemplate; // Name template - size_t nLangOffset; // Offset of the language - size_t nLength; // Length of the name template -} LOCALIZED_MPQ_INFO, *PLOCALIZED_MPQ_INFO; - -//----------------------------------------------------------------------------- -// Local variables - -// 4-byte groups for all languages -static const char * LanguageList = "baseteenenUSenGBenCNenTWdeDEesESesMXfrFRitITkoKRptBRptPTruRUzhCNzhTW"; - -// List of localized MPQs for World of Warcraft -static LOCALIZED_MPQ_INFO LocaleMpqs_WoW[] = -{ - {"expansion1-locale-####", 18, 22}, - {"expansion1-speech-####", 18, 22}, - {"expansion2-locale-####", 18, 22}, - {"expansion2-speech-####", 18, 22}, - {"expansion3-locale-####", 18, 22}, - {"expansion3-speech-####", 18, 22}, - {"locale-####", 7, 11}, - {"speech-####", 7, 11}, - {NULL, 0, 0} -}; - -//----------------------------------------------------------------------------- -// Local functions - -static inline bool IsPatchMetadataFile(TFileEntry * pFileEntry) -{ - // The file must ave a name - if(pFileEntry->szFileName != NULL && (pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) == 0) - { - // The file must be small - if(0 < pFileEntry->dwFileSize && pFileEntry->dwFileSize < 0x40) - { - // Compare the plain name - return (_stricmp(GetPlainFileName(pFileEntry->szFileName), PATCH_METADATA_NAME) == 0); - } - } - - // Not a patch_metadata - return false; -} - -static void Decompress_RLE(LPBYTE pbDecompressed, DWORD cbDecompressed, LPBYTE pbCompressed, DWORD cbCompressed) -{ - LPBYTE pbDecompressedEnd = pbDecompressed + cbDecompressed; - LPBYTE pbCompressedEnd = pbCompressed + cbCompressed; - BYTE RepeatCount; - BYTE OneByte; - - // Cut the initial DWORD from the compressed chunk - pbCompressed += sizeof(DWORD); - - // Pre-fill decompressed buffer with zeros - memset(pbDecompressed, 0, cbDecompressed); - - // Unpack - while(pbCompressed < pbCompressedEnd && pbDecompressed < pbDecompressedEnd) - { - OneByte = *pbCompressed++; - - // Is it a repetition byte ? - if(OneByte & 0x80) - { - RepeatCount = (OneByte & 0x7F) + 1; - for(BYTE i = 0; i < RepeatCount; i++) - { - if(pbDecompressed == pbDecompressedEnd || pbCompressed == pbCompressedEnd) - break; - - *pbDecompressed++ = *pbCompressed++; - } - } - else - { - pbDecompressed += (OneByte + 1); - } - } -} - -static int LoadFilePatch_COPY(TMPQFile * hf, PMPQ_PATCH_HEADER pFullPatch) -{ - DWORD cbBytesToRead = pFullPatch->dwSizeOfPatchData - sizeof(MPQ_PATCH_HEADER); - DWORD cbBytesRead = 0; - - // Simply load the rest of the patch - SFileReadFile((HANDLE)hf, (pFullPatch + 1), cbBytesToRead, &cbBytesRead, NULL); - return (cbBytesRead == cbBytesToRead) ? ERROR_SUCCESS : ERROR_FILE_CORRUPT; -} - -static int LoadFilePatch_BSD0(TMPQFile * hf, PMPQ_PATCH_HEADER pFullPatch) -{ - LPBYTE pbDecompressed = (LPBYTE)(pFullPatch + 1); - LPBYTE pbCompressed = NULL; - DWORD cbDecompressed = 0; - DWORD cbCompressed = 0; - DWORD dwBytesRead = 0; - int nError = ERROR_SUCCESS; - - // Calculate the size of compressed data - cbDecompressed = pFullPatch->dwSizeOfPatchData - sizeof(MPQ_PATCH_HEADER); - cbCompressed = pFullPatch->dwXfrmBlockSize - SIZE_OF_XFRM_HEADER; - - // Is that file compressed? - if(cbCompressed < cbDecompressed) - { - pbCompressed = STORM_ALLOC(BYTE, cbCompressed); - if(pbCompressed == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - - // Read the compressed patch data - if(nError == ERROR_SUCCESS) - { - SFileReadFile((HANDLE)hf, pbCompressed, cbCompressed, &dwBytesRead, NULL); - if(dwBytesRead != cbCompressed) - nError = ERROR_FILE_CORRUPT; - } - - // Decompress the data - if(nError == ERROR_SUCCESS) - Decompress_RLE(pbDecompressed, cbDecompressed, pbCompressed, cbCompressed); - - if(pbCompressed != NULL) - STORM_FREE(pbCompressed); - } - else - { - SFileReadFile((HANDLE)hf, pbDecompressed, cbDecompressed, &dwBytesRead, NULL); - if(dwBytesRead != cbDecompressed) - nError = ERROR_FILE_CORRUPT; - } - - return nError; -} - -static int ApplyFilePatch_COPY( - TMPQPatcher * pPatcher, - PMPQ_PATCH_HEADER pFullPatch, - LPBYTE pbTarget, - LPBYTE pbSource) -{ - // Sanity checks - assert(pPatcher->cbMaxFileData >= pPatcher->cbFileData); - pFullPatch = pFullPatch; - - // Copy the patch data as-is - memcpy(pbTarget, pbSource, pPatcher->cbFileData); - return ERROR_SUCCESS; -} - -static int ApplyFilePatch_BSD0( - TMPQPatcher * pPatcher, - PMPQ_PATCH_HEADER pFullPatch, - LPBYTE pbTarget, - LPBYTE pbSource) -{ - PBLIZZARD_BSDIFF40_FILE pBsdiff; - PBSDIFF_CTRL_BLOCK pCtrlBlock; - LPBYTE pbPatchData = (LPBYTE)(pFullPatch + 1); - LPBYTE pDataBlock; - LPBYTE pExtraBlock; - LPBYTE pbOldData = pbSource; - LPBYTE pbNewData = pbTarget; - DWORD dwCombineSize; - DWORD dwNewOffset = 0; // Current position to patch - DWORD dwOldOffset = 0; // Current source position - DWORD dwNewSize; // Patched file size - DWORD dwOldSize = pPatcher->cbFileData; // File size before patch - - // Get pointer to the patch header - // Format of BSDIFF header corresponds to original BSDIFF, which is: - // 0000 8 bytes signature "BSDIFF40" - // 0008 8 bytes size of the control block - // 0010 8 bytes size of the data block - // 0018 8 bytes new size of the patched file - pBsdiff = (PBLIZZARD_BSDIFF40_FILE)pbPatchData; - pbPatchData += sizeof(BLIZZARD_BSDIFF40_FILE); - - // Get pointer to the 32-bit BSDIFF control block - // The control block follows immediately after the BSDIFF header - // and consists of three 32-bit integers - // 0000 4 bytes Length to copy from the BSDIFF data block the new file - // 0004 4 bytes Length to copy from the BSDIFF extra block - // 0008 4 bytes Size to increment source file offset - pCtrlBlock = (PBSDIFF_CTRL_BLOCK)pbPatchData; - pbPatchData += (size_t)BSWAP_INT64_UNSIGNED(pBsdiff->CtrlBlockSize); - - // Get the pointer to the data block - pDataBlock = (LPBYTE)pbPatchData; - pbPatchData += (size_t)BSWAP_INT64_UNSIGNED(pBsdiff->DataBlockSize); - - // Get the pointer to the extra block - pExtraBlock = (LPBYTE)pbPatchData; - dwNewSize = (DWORD)BSWAP_INT64_UNSIGNED(pBsdiff->NewFileSize); - - // Now patch the file - while(dwNewOffset < dwNewSize) - { - DWORD dwAddDataLength = BSWAP_INT32_UNSIGNED(pCtrlBlock->dwAddDataLength); - DWORD dwMovDataLength = BSWAP_INT32_UNSIGNED(pCtrlBlock->dwMovDataLength); - DWORD dwOldMoveLength = BSWAP_INT32_UNSIGNED(pCtrlBlock->dwOldMoveLength); - DWORD i; - - // Sanity check - if((dwNewOffset + dwAddDataLength) > dwNewSize) - return ERROR_FILE_CORRUPT; - - // Read the diff string to the target buffer - memcpy(pbNewData + dwNewOffset, pDataBlock, dwAddDataLength); - pDataBlock += dwAddDataLength; - - // Get the longest block that we can combine - dwCombineSize = ((dwOldOffset + dwAddDataLength) >= dwOldSize) ? (dwOldSize - dwOldOffset) : dwAddDataLength; - if((dwNewOffset + dwCombineSize) > dwNewSize || (dwNewOffset + dwCombineSize) < dwNewOffset) - return ERROR_FILE_CORRUPT; - - // Now combine the patch data with the original file - for(i = 0; i < dwCombineSize; i++) - pbNewData[dwNewOffset + i] = pbNewData[dwNewOffset + i] + pbOldData[dwOldOffset + i]; - - // Move the offsets - dwNewOffset += dwAddDataLength; - dwOldOffset += dwAddDataLength; - - // Sanity check - if((dwNewOffset + dwMovDataLength) > dwNewSize) - return ERROR_FILE_CORRUPT; - - // Copy the data from the extra block in BSDIFF patch - memcpy(pbNewData + dwNewOffset, pExtraBlock, dwMovDataLength); - pExtraBlock += dwMovDataLength; - dwNewOffset += dwMovDataLength; - - // Move the old offset - if(dwOldMoveLength & 0x80000000) - dwOldMoveLength = 0x80000000 - dwOldMoveLength; - dwOldOffset += dwOldMoveLength; - pCtrlBlock++; - } - - // The size after patch must match - if(dwNewOffset != pFullPatch->dwSizeAfterPatch) - return ERROR_FILE_CORRUPT; - - // Update the new data size - pPatcher->cbFileData = dwNewOffset; - return ERROR_SUCCESS; -} - -static PMPQ_PATCH_HEADER LoadFullFilePatch(TMPQFile * hf, MPQ_PATCH_HEADER & PatchHeader) -{ - PMPQ_PATCH_HEADER pFullPatch; - int nError = ERROR_SUCCESS; - - // BSWAP the entire header, if needed - BSWAP_ARRAY32_UNSIGNED(&PatchHeader, sizeof(DWORD) * 6); - BSWAP_ARRAY32_UNSIGNED(&PatchHeader.dwXFRM, sizeof(DWORD) * 3); - - // Verify the signatures in the patch header - if(PatchHeader.dwSignature != PATCH_SIGNATURE_HEADER || PatchHeader.dwMD5 != PATCH_SIGNATURE_MD5 || PatchHeader.dwXFRM != PATCH_SIGNATURE_XFRM) - return NULL; - - // Allocate space for patch header and compressed data - pFullPatch = (PMPQ_PATCH_HEADER)STORM_ALLOC(BYTE, PatchHeader.dwSizeOfPatchData); - if(pFullPatch != NULL) - { - // Copy the patch header - memcpy(pFullPatch, &PatchHeader, sizeof(MPQ_PATCH_HEADER)); - - // Read the patch, depending on patch type - if(nError == ERROR_SUCCESS) - { - switch(PatchHeader.dwPatchType) - { - case 0x59504f43: // 'COPY' - nError = LoadFilePatch_COPY(hf, pFullPatch); - break; - - case 0x30445342: // 'BSD0' - nError = LoadFilePatch_BSD0(hf, pFullPatch); - break; - - default: - nError = ERROR_FILE_CORRUPT; - break; - } - } - - // If something failed, free the patch buffer - if(nError != ERROR_SUCCESS) - { - STORM_FREE(pFullPatch); - pFullPatch = NULL; - } - } - - // Give the result to the caller - return pFullPatch; -} - -static int ApplyFilePatch( - TMPQPatcher * pPatcher, - PMPQ_PATCH_HEADER pFullPatch) -{ - LPBYTE pbSource = (pPatcher->nCounter & 0x1) ? pPatcher->pbFileData2 : pPatcher->pbFileData1; - LPBYTE pbTarget = (pPatcher->nCounter & 0x1) ? pPatcher->pbFileData1 : pPatcher->pbFileData2; - int nError; - - // Sanity checks - assert(pFullPatch->dwSizeAfterPatch <= pPatcher->cbMaxFileData); - - // Apply the patch according to the type - switch(pFullPatch->dwPatchType) - { - case 0x59504f43: // 'COPY' - nError = ApplyFilePatch_COPY(pPatcher, pFullPatch, pbTarget, pbSource); - break; - - case 0x30445342: // 'BSD0' - nError = ApplyFilePatch_BSD0(pPatcher, pFullPatch, pbTarget, pbSource); - break; - - default: - nError = ERROR_FILE_CORRUPT; - break; - } - - // Verify MD5 after patch - if(nError == ERROR_SUCCESS && pFullPatch->dwSizeAfterPatch != 0) - { - // Verify the patched file - if(!VerifyDataBlockHash(pbTarget, pFullPatch->dwSizeAfterPatch, pFullPatch->md5_after_patch)) - nError = ERROR_FILE_CORRUPT; - - // Copy the MD5 of the new block - memcpy(pPatcher->this_md5, pFullPatch->md5_after_patch, MD5_DIGEST_SIZE); - } - - return nError; -} - -//----------------------------------------------------------------------------- -// Local functions (patch prefix matching) - -static bool CreatePatchPrefix(TMPQArchive * ha, const char * szFileName, size_t nLength) -{ - TMPQNamePrefix * pNewPrefix; - - // If the length of the patch prefix was not entered, find it - // Not that the patch prefix must always begin with backslash - if(szFileName != NULL && nLength == 0) - nLength = strlen(szFileName); - - // Create the patch prefix - pNewPrefix = (TMPQNamePrefix *)STORM_ALLOC(BYTE, sizeof(TMPQNamePrefix) + nLength + 1); - if(pNewPrefix != NULL) - { - // Fill the name prefix. Also add the backslash - if(szFileName && nLength) - { - memcpy(pNewPrefix->szPatchPrefix, szFileName, nLength); - if(pNewPrefix->szPatchPrefix[nLength - 1] != '\\') - pNewPrefix->szPatchPrefix[nLength++] = '\\'; - } - - // Terminate the string and fill the length - pNewPrefix->szPatchPrefix[nLength] = 0; - pNewPrefix->nLength = nLength; - } - - ha->pPatchPrefix = pNewPrefix; - return (pNewPrefix != NULL); -} - -static bool CheckAndCreatePatchPrefix(TMPQArchive * ha, const char * szPatchPrefix, size_t nLength) -{ - char szTempName[MAX_SC2_PATCH_PREFIX + 0x41]; - bool bResult = false; - - // Prepare the patch file name - if(nLength > MAX_SC2_PATCH_PREFIX) - return false; - - // Prepare the patched file name - memcpy(szTempName, szPatchPrefix, nLength); - memcpy(&szTempName[nLength], "\\(patch_metadata)", 18); - - // Verifywhether that file exists - if(GetFileEntryLocale(ha, szTempName, 0) != NULL) - bResult = CreatePatchPrefix(ha, szPatchPrefix, nLength); - - return bResult; -} - -static bool IsMatchingPatchFile( - TMPQArchive * ha, - const char * szFileName, - LPBYTE pbBaseFileMd5) -{ - MPQ_PATCH_HEADER PatchHeader = {0}; - HANDLE hFile = NULL; - DWORD dwTransferred = 0; - DWORD dwFlags = 0; - bool bResult = false; - - // Open the file and load the patch header - if(SFileOpenFileEx((HANDLE)ha, szFileName, SFILE_OPEN_BASE_FILE, &hFile)) - { - // Retrieve the flags. We need to know whether the file is a patch or not - SFileGetFileInfo(hFile, SFileInfoFlags, &dwFlags, sizeof(DWORD), &dwTransferred); - if(dwFlags & MPQ_FILE_PATCH_FILE) - { - // Load the patch header - SFileReadFile(hFile, &PatchHeader, sizeof(MPQ_PATCH_HEADER), &dwTransferred, NULL); - BSWAP_ARRAY32_UNSIGNED(pPatchHeader, sizeof(DWORD) * 6); - - // If the file contains an incremental patch, - // compare the "MD5 before patching" with the base file MD5 - if(dwTransferred == sizeof(MPQ_PATCH_HEADER) && PatchHeader.dwSignature == PATCH_SIGNATURE_HEADER) - bResult = (!memcmp(PatchHeader.md5_before_patch, pbBaseFileMd5, MD5_DIGEST_SIZE)); - } - else - { - // TODO: How to match it if it's not an incremental patch? - // Example: StarCraft II\Updates\enGB\s2-update-enGB-23258.MPQ: - // Mods\Core.SC2Mod\enGB.SC2Assets\StreamingBuckets.txt" - bResult = false; - } - - // Close the file - SFileCloseFile(hFile); - } - - return bResult; -} - -static const char * FindArchiveLanguage(TMPQArchive * ha, PLOCALIZED_MPQ_INFO pMpqInfo) -{ - TFileEntry * pFileEntry; - const char * szLanguage = LanguageList; - char szFileName[0x40]; - - // Iterate through all localized languages - while(pMpqInfo->szNameTemplate != NULL) - { - // Iterate through all languages - for(szLanguage = LanguageList; szLanguage[0] != 0; szLanguage += 4) - { - // Construct the file name - memcpy(szFileName, pMpqInfo->szNameTemplate, pMpqInfo->nLength); - szFileName[pMpqInfo->nLangOffset + 0] = szLanguage[0]; - szFileName[pMpqInfo->nLangOffset + 1] = szLanguage[1]; - szFileName[pMpqInfo->nLangOffset + 2] = szLanguage[2]; - szFileName[pMpqInfo->nLangOffset + 3] = szLanguage[3]; - - // Append the suffix - memcpy(szFileName + pMpqInfo->nLength, "-md5.lst", 9); - - // Check whether the name exists - pFileEntry = GetFileEntryLocale(ha, szFileName, 0); - if(pFileEntry != NULL) - return szLanguage; - } - - // Move to the next language name - pMpqInfo++; - } - - // Not found - return NULL; -} - -//----------------------------------------------------------------------------- -// Finding ratch prefix for an temporary build of WoW (Pre-Cataclysm) - -static bool FindPatchPrefix_WoW_13164_13623(TMPQArchive * haBase, TMPQArchive * haPatch) -{ - const char * szPatchPrefix; - char szNamePrefix[0x08]; - - // Try to find the language of the MPQ archive - szPatchPrefix = FindArchiveLanguage(haBase, LocaleMpqs_WoW); - if(szPatchPrefix == NULL) - szPatchPrefix = "Base"; - - // Format the patch prefix - szNamePrefix[0] = szPatchPrefix[0]; - szNamePrefix[1] = szPatchPrefix[1]; - szNamePrefix[2] = szPatchPrefix[2]; - szNamePrefix[3] = szPatchPrefix[3]; - szNamePrefix[4] = '\\'; - szNamePrefix[5] = 0; - return CreatePatchPrefix(haPatch, szNamePrefix, 5); -} - -//----------------------------------------------------------------------------- -// Finding patch prefix for Starcraft II (Pre-Legacy of the Void) - -// -// This method tries to match the patch by placement of the archive (in the game subdirectory) -// -// Archive Path: %GAME_DIR%\Mods\SwarmMulti.SC2Mod\Base.SC2Data -// Patch Prefix: Mods\SwarmMulti.SC2Mod\Base.SC2Data -// -// Archive Path: %ANY_DIR%\MPQ_2013_v4_Mods#Liberty.SC2Mod#enGB.SC2Data -// Patch Prefix: Mods\Liberty.SC2Mod\enGB.SC2Data -// - -static bool CheckPatchPrefix_SC2_ArchiveName( - TMPQArchive * haPatch, - const TCHAR * szPathPtr, - const TCHAR * szSeparator, - const TCHAR * szPathEnd, - const TCHAR * szExpectedString, - size_t cchExpectedString) -{ - char szPatchPrefix[MAX_SC2_PATCH_PREFIX+0x41]; - size_t nLength = 0; - bool bResult = false; - - // Check whether the length is equal to the length of the expected string - if((size_t)(szSeparator - szPathPtr) == cchExpectedString) - { - // Now check the string itself - if(!_tcsnicmp(szPathPtr, szExpectedString, szSeparator - szPathPtr)) - { - // Copy the name string - for(; szPathPtr < szPathEnd; szPathPtr++) - { - if(szPathPtr[0] != _T('/') && szPathPtr[0] != _T('#')) - szPatchPrefix[nLength++] = (char)szPathPtr[0]; - else - szPatchPrefix[nLength++] = '\\'; - } - - // Check and create the patch prefix - bResult = CheckAndCreatePatchPrefix(haPatch, szPatchPrefix, nLength); - } - } - - return bResult; -} - -static bool FindPatchPrefix_SC2_ArchiveName(TMPQArchive * haBase, TMPQArchive * haPatch) -{ - const TCHAR * szPathBegin = FileStream_GetFileName(haBase->pStream); - const TCHAR * szSeparator = NULL; - const TCHAR * szPathEnd = szPathBegin + _tcslen(szPathBegin); - const TCHAR * szPathPtr; - int nSlashCount = 0; - int nDotCount = 0; - - // Skip the part where the patch prefix would be too long - if((szPathEnd - szPathBegin) > MAX_SC2_PATCH_PREFIX) - szPathBegin = szPathEnd - MAX_SC2_PATCH_PREFIX; - - // Search for the file extension - for(szPathPtr = szPathEnd; szPathPtr > szPathBegin; szPathPtr--) - { - if(szPathPtr[0] == _T('.')) - { - nDotCount++; - break; - } - } - - // Search for the possible begin of the prefix name - for(/* NOTHING */; szPathPtr > szPathBegin; szPathPtr--) - { - // Check the slashes, backslashes and hashes - if(szPathPtr[0] == _T('\\') || szPathPtr[0] == _T('/') || szPathPtr[0] == _T('#')) - { - if(nDotCount == 0) - return false; - szSeparator = szPathPtr; - nSlashCount++; - } - - // Check the path parts - if(szSeparator != NULL && nSlashCount >= nDotCount) - { - if(CheckPatchPrefix_SC2_ArchiveName(haPatch, szPathPtr, szSeparator, szPathEnd, _T("Battle.net"), 10)) - return true; - if(CheckPatchPrefix_SC2_ArchiveName(haPatch, szPathPtr, szSeparator, szPathEnd, _T("Campaigns"), 9)) - return true; - if(CheckPatchPrefix_SC2_ArchiveName(haPatch, szPathPtr, szSeparator, szPathEnd, _T("Mods"), 4)) - return true; - } - } - - // Not matched, sorry - return false; -} - -// -// This method tries to read the patch prefix from a helper file -// -// Example -// ========================================================= -// MPQ File Name: MPQ_2013_v4_Base1.SC2Data -// Helper File : MPQ_2013_v4_Base1.SC2Data-PATCH -// File Contains: PatchPrefix=Mods\Core.SC2Mod\Base.SC2Data -// Patch Prefix : Mods\Core.SC2Mod\Base.SC2Data -// - -static bool ExtractPatchPrefixFromFile(const TCHAR * szHelperFile, char * szPatchPrefix, size_t nMaxChars, size_t * PtrLength) -{ - TFileStream * pStream; - ULONGLONG FileSize = 0; - size_t nLength; - char szFileData[MAX_PATH+1]; - bool bResult = false; - - pStream = FileStream_OpenFile(szHelperFile, STREAM_FLAG_READ_ONLY); - if(pStream != NULL) - { - // Retrieve and check the file size - FileStream_GetSize(pStream, &FileSize); - if(12 <= FileSize && FileSize < MAX_PATH) - { - // Read the entire file to memory - if(FileStream_Read(pStream, NULL, szFileData, (DWORD)FileSize)) - { - // Terminate the buffer with zero - szFileData[(DWORD)FileSize] = 0; - - // The file data must begin with the "PatchPrefix" variable - if(!_strnicmp(szFileData, "PatchPrefix", 11)) - { - char * szLinePtr = szFileData + 11; - char * szLineEnd; - - // Skip spaces or '=' - while(szLinePtr[0] == ' ' || szLinePtr[0] == '=') - szLinePtr++; - szLineEnd = szLinePtr; - - // Find the end - while(szLineEnd[0] != 0 && szLineEnd[0] != 0x0A && szLineEnd[0] != 0x0D) - szLineEnd++; - nLength = (size_t)(szLineEnd - szLinePtr); - - // Copy the variable - if(szLineEnd > szLinePtr && nLength <= nMaxChars) - { - memcpy(szPatchPrefix, szLinePtr, nLength); - szPatchPrefix[nLength] = 0; - PtrLength[0] = nLength; - bResult = true; - } - } - } - } - - // Close the stream - FileStream_Close(pStream); - } - - return bResult; -} - - -static bool FindPatchPrefix_SC2_HelperFile(TMPQArchive * haBase, TMPQArchive * haPatch) -{ - TCHAR szHelperFile[MAX_PATH+1]; - char szPatchPrefix[MAX_SC2_PATCH_PREFIX+0x41]; - size_t nLength = 0; - bool bResult = false; - - // Create the name of the patch helper file - _tcscpy(szHelperFile, FileStream_GetFileName(haBase->pStream)); - if(_tcslen(szHelperFile) + 6 > MAX_PATH) - return false; - _tcscat(szHelperFile, _T("-PATCH")); - - // Open the patch helper file and read the line - if(ExtractPatchPrefixFromFile(szHelperFile, szPatchPrefix, MAX_SC2_PATCH_PREFIX, &nLength)) - bResult = CheckAndCreatePatchPrefix(haPatch, szPatchPrefix, nLength); - - return bResult; -} - -// -// Find match in Starcraft II patch MPQs -// Match a LST file in the root directory if the MPQ with any of the file in subdirectories -// -// The problem: -// File in the base MPQ: enGB-md5.lst -// File in the patch MPQ: Campaigns\Liberty.SC2Campaign\enGB.SC2Assets\enGB-md5.lst -// Campaigns\Liberty.SC2Campaign\enGB.SC2Data\enGB-md5.lst -// Campaigns\LibertyStory.SC2Campaign\enGB.SC2Data\enGB-md5.lst -// Campaigns\LibertyStory.SC2Campaign\enGB.SC2Data\enGB-md5.lst Mods\Core.SC2Mod\enGB.SC2Assets\enGB-md5.lst -// Mods\Core.SC2Mod\enGB.SC2Data\enGB-md5.lst -// Mods\Liberty.SC2Mod\enGB.SC2Assets\enGB-md5.lst -// Mods\Liberty.SC2Mod\enGB.SC2Data\enGB-md5.lst -// Mods\LibertyMulti.SC2Mod\enGB.SC2Data\enGB-md5.lst -// -// Solution: -// We need to match the file by its MD5 -// - -static bool FindPatchPrefix_SC2_MatchFiles(TMPQArchive * haBase, TMPQArchive * haPatch, TFileEntry * pBaseEntry) -{ - TMPQNamePrefix * pPatchPrefix; - char * szPatchFileName; - char * szPlainName; - size_t cchWorkBuffer = 0x400; - bool bResult = false; - - // First-level patches: Find the same file within the patch archive - // and verify by MD5-before-patch - if(haBase->haPatch == NULL) - { - TFileEntry * pFileTableEnd = haPatch->pFileTable + haPatch->dwFileTableSize; - TFileEntry * pFileEntry; - - // Allocate working buffer for merging LST file - szPatchFileName = STORM_ALLOC(char, cchWorkBuffer); - if(szPatchFileName != NULL) - { - // Parse the entire file table - for(pFileEntry = haPatch->pFileTable; pFileEntry < pFileTableEnd; pFileEntry++) - { - // Look for "patch_metadata" file - if(IsPatchMetadataFile(pFileEntry)) - { - // Construct the name of the MD5 file - strcpy(szPatchFileName, pFileEntry->szFileName); - szPlainName = (char *)GetPlainFileName(szPatchFileName); - strcpy(szPlainName, pBaseEntry->szFileName); - - // Check for matching MD5 file - if(IsMatchingPatchFile(haPatch, szPatchFileName, pBaseEntry->md5)) - { - bResult = CreatePatchPrefix(haPatch, szPatchFileName, (size_t)(szPlainName - szPatchFileName)); - break; - } - } - } - - // Delete the merge buffer - STORM_FREE(szPatchFileName); - } - } - - // For second-level patches, just take the patch prefix from the lower level patch - else - { - // There must be at least two patches in the chain - assert(haBase->haPatch->pPatchPrefix != NULL); - pPatchPrefix = haBase->haPatch->pPatchPrefix; - - // Copy the patch prefix - bResult = CreatePatchPrefix(haPatch, - pPatchPrefix->szPatchPrefix, - pPatchPrefix->nLength); - } - - return bResult; -} - -// Note: pBaseEntry is the file entry of the base version of "StreamingBuckets.txt" -static bool FindPatchPrefix_SC2(TMPQArchive * haBase, TMPQArchive * haPatch, TFileEntry * pBaseEntry) -{ - // Method 1: Try it by the placement of the archive. - // Works when someone is opening an archive in the game (sub)directory - if(FindPatchPrefix_SC2_ArchiveName(haBase, haPatch)) - return true; - - // Method 2: Try to locate the Name.Ext-PATCH file and read the patch prefix from it - if(FindPatchPrefix_SC2_HelperFile(haBase, haPatch)) - return true; - - // Method 3: Try to pair any version of "StreamingBuckets.txt" from the patch MPQ - // with the "StreamingBuckets.txt" in the base MPQ. Does not always work - if(FindPatchPrefix_SC2_MatchFiles(haBase, haPatch, pBaseEntry)) - return true; - - return false; -} - -// -// Patch prefix is the path subdirectory where the patched files are within MPQ. -// -// Example 1: -// Main MPQ: locale-enGB.MPQ -// Patch MPQ: wow-update-12694.MPQ -// File in main MPQ: DBFilesClient\Achievement.dbc -// File in patch MPQ: enGB\DBFilesClient\Achievement.dbc -// Path prefix: enGB -// -// Example 2: -// Main MPQ: expansion1.MPQ -// Patch MPQ: wow-update-12694.MPQ -// File in main MPQ: DBFilesClient\Achievement.dbc -// File in patch MPQ: Base\DBFilesClient\Achievement.dbc -// Path prefix: Base -// -// Example 3: -// Main MPQ: %GAME%\Battle.net\Battle.net.MPQ -// Patch MPQ: s2-update-base-26147.MPQ -// File in main MPQ: Battle.net\i18n\deDE\String\CLIENT_ACHIEVEMENTS.xml -// File in patch MPQ: Battle.net\Battle.net.MPQ\Battle.net\i18n\deDE\String\CLIENT_ACHIEVEMENTS.xml -// Path prefix: Battle.net\Battle.net.MPQ -// -// Example 4: -// Main MPQ: %GAME%\Campaigns\Liberty.SC2Campaign\enGB.SC2Data -// *OR* %ANY_DIR%\%ANY_NAME%Campaigns#Liberty.SC2Campaign#enGB.SC2Data -// Patch MPQ: s2-update-enGB-23258.MPQ -// File in main MPQ: LocalizedData\GameHotkeys.txt -// File in patch MPQ: Campaigns\Liberty.SC2Campaign\enGB.SC2Data\LocalizedData\GameHotkeys.txt -// Patch Prefix: Campaigns\Liberty.SC2Campaign\enGB.SC2Data -// - -static bool FindPatchPrefix(TMPQArchive * haBase, TMPQArchive * haPatch, const char * szPatchPathPrefix) -{ - TFileEntry * pFileEntry; - - // If the patch prefix was explicitly entered, we use that one - if(szPatchPathPrefix != NULL) - return CreatePatchPrefix(haPatch, szPatchPathPrefix, 0); - - // Patches for World of Warcraft - they mostly do not use prefix. - // All patches that use patch prefix have the "base\\(patch_metadata) file present - if(GetFileEntryLocale(haPatch, "base\\" PATCH_METADATA_NAME, 0)) - return FindPatchPrefix_WoW_13164_13623(haBase, haPatch); - - // Updates for Starcraft II - // Match: LocalizedData\GameHotkeys.txt <==> Campaigns\Liberty.SC2Campaign\enGB.SC2Data\LocalizedData\GameHotkeys.txt - // All Starcraft II base archives seem to have the file "StreamingBuckets.txt" present - pFileEntry = GetFileEntryLocale(haBase, "StreamingBuckets.txt", 0); - if(pFileEntry != NULL) - return FindPatchPrefix_SC2(haBase, haPatch, pFileEntry); - - // Diablo III patch MPQs don't use patch prefix - // Hearthstone MPQs don't use patch prefix - CreatePatchPrefix(haPatch, NULL, 0); - return true; -} - -//----------------------------------------------------------------------------- -// Public functions (StormLib internals) - -bool IsIncrementalPatchFile(const void * pvData, DWORD cbData, LPDWORD pdwPatchedFileSize) -{ - PMPQ_PATCH_HEADER pPatchHeader = (PMPQ_PATCH_HEADER)pvData; - BLIZZARD_BSDIFF40_FILE DiffFile; - DWORD dwPatchType; - - if(cbData >= sizeof(MPQ_PATCH_HEADER) + sizeof(BLIZZARD_BSDIFF40_FILE)) - { - dwPatchType = BSWAP_INT32_UNSIGNED(pPatchHeader->dwPatchType); - if(dwPatchType == 0x30445342) - { - // Give the caller the patch file size - if(pdwPatchedFileSize != NULL) - { - Decompress_RLE((LPBYTE)&DiffFile, sizeof(BLIZZARD_BSDIFF40_FILE), (LPBYTE)(pPatchHeader + 1), sizeof(BLIZZARD_BSDIFF40_FILE)); - DiffFile.NewFileSize = BSWAP_INT64_UNSIGNED(DiffFile.NewFileSize); - *pdwPatchedFileSize = (DWORD)DiffFile.NewFileSize; - return true; - } - } - } - - return false; -} - -int Patch_InitPatcher(TMPQPatcher * pPatcher, TMPQFile * hf) -{ - DWORD cbMaxFileData = 0; - - // Overflow check - if((cbMaxFileData + (DWORD)sizeof(MPQ_PATCH_HEADER)) < cbMaxFileData) - return ERROR_NOT_ENOUGH_MEMORY; - if(hf->hfPatch == NULL) - return ERROR_INVALID_PARAMETER; - - // Initialize the entire structure with zeros - memset(pPatcher, 0, sizeof(TMPQPatcher)); - - // Copy the MD5 of the current file - memcpy(pPatcher->this_md5, hf->pFileEntry->md5, MD5_DIGEST_SIZE); - - // Find out the biggest data size needed during the patching process - while(hf != NULL) - { - if(hf->pFileEntry->dwFileSize > cbMaxFileData) - cbMaxFileData = hf->pFileEntry->dwFileSize; - hf = hf->hfPatch; - } - - // Allocate primary and secondary buffer - pPatcher->pbFileData1 = STORM_ALLOC(BYTE, cbMaxFileData); - pPatcher->pbFileData2 = STORM_ALLOC(BYTE, cbMaxFileData); - if(!pPatcher->pbFileData1 || !pPatcher->pbFileData2) - return ERROR_NOT_ENOUGH_MEMORY; - - pPatcher->cbMaxFileData = cbMaxFileData; - return ERROR_SUCCESS; -} - -// -// Note: The patch may either be applied to the base file or to the previous version -// In Starcraft II, Mods\Core.SC2Mod\Base.SC2Data, file StreamingBuckets.txt: -// -// Base file MD5: 31376b0344b6df59ad009d4296125539 -// -// s2-update-base-23258: from 31376b0344b6df59ad009d4296125539 to 941a82683452e54bf024a8d491501824 -// s2-update-base-24540: from 31376b0344b6df59ad009d4296125539 to 941a82683452e54bf024a8d491501824 -// s2-update-base-26147: from 31376b0344b6df59ad009d4296125539 to d5d5253c762fac6b9761240288a0771a -// s2-update-base-28522: from 31376b0344b6df59ad009d4296125539 to 5a76c4b356920aab7afd22e0e1913d7a -// s2-update-base-30508: from 31376b0344b6df59ad009d4296125539 to 8cb0d4799893fe801cc78ae4488a3671 -// s2-update-base-32283: from 31376b0344b6df59ad009d4296125539 to 8cb0d4799893fe801cc78ae4488a3671 -// -// We don't keep all intermediate versions in memory, as it would cause massive -// memory usage during patching process. A prime example is the file -// DBFilesClient\\Item-Sparse.db2 from locale-enGB.MPQ (WoW 16965), which has -// 9 patches in a row, each requiring 70 MB memory (35 MB patch data + 35 MB work buffer) -// - -int Patch_Process(TMPQPatcher * pPatcher, TMPQFile * hf) -{ - PMPQ_PATCH_HEADER pFullPatch; - MPQ_PATCH_HEADER PatchHeader1; - MPQ_PATCH_HEADER PatchHeader2 = {0}; - TMPQFile * hfBase = hf; - DWORD cbBytesRead = 0; - int nError = ERROR_SUCCESS; - - // Move to the first patch - assert(hfBase->pbFileData == NULL); - assert(hfBase->cbFileData == 0); - hf = hf->hfPatch; - - // Read the header of the current patch - SFileReadFile((HANDLE)hf, &PatchHeader1, sizeof(MPQ_PATCH_HEADER), &cbBytesRead, NULL); - if(cbBytesRead != sizeof(MPQ_PATCH_HEADER)) - return ERROR_FILE_CORRUPT; - - // Perform the patching process - while(nError == ERROR_SUCCESS && hf != NULL) - { - // Try to read the next patch header. If the md5_before_patch - // still matches we go directly to the next one and repeat - while(hf->hfPatch != NULL) - { - // Attempt to read the patch header - SFileReadFile((HANDLE)hf->hfPatch, &PatchHeader2, sizeof(MPQ_PATCH_HEADER), &cbBytesRead, NULL); - if(cbBytesRead != sizeof(MPQ_PATCH_HEADER)) - return ERROR_FILE_CORRUPT; - - // Compare the md5_before_patch - if(memcmp(PatchHeader2.md5_before_patch, pPatcher->this_md5, MD5_DIGEST_SIZE)) - break; - - // Move one patch fuhrter - PatchHeader1 = PatchHeader2; - hf = hf->hfPatch; - } - - // Allocate memory for the patch data - pFullPatch = LoadFullFilePatch(hf, PatchHeader1); - if(pFullPatch != NULL) - { - // Apply the patch - nError = ApplyFilePatch(pPatcher, pFullPatch); - STORM_FREE(pFullPatch); - } - else - { - nError = ERROR_FILE_CORRUPT; - } - - // Move to the next patch - PatchHeader1 = PatchHeader2; - pPatcher->nCounter++; - hf = hf->hfPatch; - } - - // Put the result data to the file structure - if(nError == ERROR_SUCCESS) - { - // Swap the pointer to the file data structure - if(pPatcher->nCounter & 0x01) - { - hfBase->pbFileData = pPatcher->pbFileData2; - pPatcher->pbFileData2 = NULL; - } - else - { - hfBase->pbFileData = pPatcher->pbFileData1; - pPatcher->pbFileData1 = NULL; - } - - // Also supply the data size - hfBase->cbFileData = pPatcher->cbFileData; - } - - return ERROR_SUCCESS; -} - -void Patch_Finalize(TMPQPatcher * pPatcher) -{ - if(pPatcher != NULL) - { - if(pPatcher->pbFileData1 != NULL) - STORM_FREE(pPatcher->pbFileData1); - if(pPatcher->pbFileData2 != NULL) - STORM_FREE(pPatcher->pbFileData2); - - memset(pPatcher, 0, sizeof(TMPQPatcher)); - } -} - - -//----------------------------------------------------------------------------- -// Public functions - -bool WINAPI SFileOpenPatchArchive( - HANDLE hMpq, - const TCHAR * szPatchMpqName, - const char * szPatchPathPrefix, - DWORD dwFlags) -{ - TMPQArchive * haPatch; - TMPQArchive * ha = (TMPQArchive *)hMpq; - HANDLE hPatchMpq = NULL; - int nError = ERROR_SUCCESS; - - // Keep compiler happy - dwFlags = dwFlags; - - // Verify input parameters - if(!IsValidMpqHandle(hMpq)) - nError = ERROR_INVALID_HANDLE; - if(szPatchMpqName == NULL || *szPatchMpqName == 0) - nError = ERROR_INVALID_PARAMETER; - - // - // We don't allow adding patches to archives that have been open for write - // - // Error scenario: - // - // 1) Open archive for writing - // 2) Modify or replace a file - // 3) Add patch archive to the opened MPQ - // 4) Read patched file - // 5) Now what ? - // - - if(nError == ERROR_SUCCESS) - { - if(!(ha->dwFlags & MPQ_FLAG_READ_ONLY)) - nError = ERROR_ACCESS_DENIED; - } - - // Open the archive like it is normal archive - if(nError == ERROR_SUCCESS) - { - if(SFileOpenArchive(szPatchMpqName, 0, MPQ_OPEN_READ_ONLY | MPQ_OPEN_PATCH, &hPatchMpq)) - { - // Cast the archive handle to structure pointer - haPatch = (TMPQArchive *)hPatchMpq; - - // We need to remember the proper patch prefix to match names of patched files - if(FindPatchPrefix(ha, (TMPQArchive *)hPatchMpq, szPatchPathPrefix)) - { - // Now add the patch archive to the list of patches to the original MPQ - while(ha != NULL) - { - if(ha->haPatch == NULL) - { - haPatch->haBase = ha; - ha->haPatch = haPatch; - return true; - } - - // Move to the next archive - ha = ha->haPatch; - } - } - - // Close the archive - SFileCloseArchive(hPatchMpq); - nError = ERROR_CANT_FIND_PATCH_PREFIX; - } - else - { - nError = GetLastError(); - } - } - - SetLastError(nError); - return false; -} - -bool WINAPI SFileIsPatchedArchive(HANDLE hMpq) -{ - TMPQArchive * ha = (TMPQArchive *)hMpq; - - // Verify input parameters - if(!IsValidMpqHandle(hMpq)) - return false; - - return (ha->haPatch != NULL); -} diff --git a/libs/storm-sys/StormLib/src/SFileReadFile.cpp b/libs/storm-sys/StormLib/src/SFileReadFile.cpp deleted file mode 100644 index a6b3bc4..0000000 --- a/libs/storm-sys/StormLib/src/SFileReadFile.cpp +++ /dev/null @@ -1,899 +0,0 @@ -/*****************************************************************************/ -/* SFileReadFile.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Description : */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* xx.xx.99 1.00 Lad The first version of SFileReadFile.cpp */ -/* 24.03.99 1.00 Lad Added the SFileGetFileInfo function */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "StormCommon.h" - -//----------------------------------------------------------------------------- -// Local functions - -// hf - MPQ File handle. -// pbBuffer - Pointer to target buffer to store sectors. -// dwByteOffset - Position of sector in the file (relative to file begin) -// dwBytesToRead - Number of bytes to read. Must be multiplier of sector size. -// pdwBytesRead - Stored number of bytes loaded -static int ReadMpqSectors(TMPQFile * hf, LPBYTE pbBuffer, DWORD dwByteOffset, DWORD dwBytesToRead, LPDWORD pdwBytesRead) -{ - ULONGLONG RawFilePos; - TMPQArchive * ha = hf->ha; - TFileEntry * pFileEntry = hf->pFileEntry; - LPBYTE pbRawSector = NULL; - LPBYTE pbOutSector = pbBuffer; - LPBYTE pbInSector = pbBuffer; - DWORD dwRawBytesToRead; - DWORD dwRawSectorOffset = dwByteOffset; - DWORD dwSectorsToRead = dwBytesToRead / ha->dwSectorSize; - DWORD dwSectorIndex = dwByteOffset / ha->dwSectorSize; - DWORD dwSectorsDone = 0; - DWORD dwBytesRead = 0; - int nError = ERROR_SUCCESS; - - // Note that dwByteOffset must be aligned to size of one sector - // Note that dwBytesToRead must be a multiplier of one sector size - // This is local function, so we won't check if that's true. - // Note that files stored in single units are processed by a separate function - - // If there is not enough bytes remaining, cut dwBytesToRead - if((dwByteOffset + dwBytesToRead) > hf->dwDataSize) - dwBytesToRead = hf->dwDataSize - dwByteOffset; - dwRawBytesToRead = dwBytesToRead; - - // Perform all necessary work to do with compressed files - if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK) - { - // If the sector positions are not loaded yet, do it - if(hf->SectorOffsets == NULL) - { - nError = AllocateSectorOffsets(hf, true); - if(nError != ERROR_SUCCESS || hf->SectorOffsets == NULL) - return nError; - } - - // If the sector checksums are not loaded yet, load them now. - if(hf->SectorChksums == NULL && (pFileEntry->dwFlags & MPQ_FILE_SECTOR_CRC) && hf->bLoadedSectorCRCs == false) - { - // - // Sector CRCs is plain crap feature. It is almost never present, - // often it's empty, or the end offset of sector CRCs is zero. - // We only try to load sector CRCs once, and regardless if it fails - // or not, we won't try that again for the given file. - // - - AllocateSectorChecksums(hf, true); - hf->bLoadedSectorCRCs = true; - } - - // TODO: If the raw data MD5s are not loaded yet, load them now - // Only do it if the MPQ is of format 4.0 -// if(ha->pHeader->wFormatVersion >= MPQ_FORMAT_VERSION_4 && ha->pHeader->dwRawChunkSize != 0) -// { -// nError = AllocateRawMD5s(hf, true); -// if(nError != ERROR_SUCCESS) -// return nError; -// } - - // Assign the temporary buffer as target for read operation - dwRawSectorOffset = hf->SectorOffsets[dwSectorIndex]; - dwRawBytesToRead = hf->SectorOffsets[dwSectorIndex + dwSectorsToRead] - dwRawSectorOffset; - - // If the file is compressed, also allocate secondary buffer - pbInSector = pbRawSector = STORM_ALLOC(BYTE, dwRawBytesToRead); - if(pbRawSector == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - } - - // Calculate raw file offset where the sector(s) are stored. - RawFilePos = CalculateRawSectorOffset(hf, dwRawSectorOffset); - - // Set file pointer and read all required sectors - if(FileStream_Read(ha->pStream, &RawFilePos, pbInSector, dwRawBytesToRead)) - { - // Now we have to decrypt and decompress all file sectors that have been loaded - for(DWORD i = 0; i < dwSectorsToRead; i++) - { - DWORD dwRawBytesInThisSector = ha->dwSectorSize; - DWORD dwBytesInThisSector = ha->dwSectorSize; - DWORD dwIndex = dwSectorIndex + i; - - // If there is not enough bytes in the last sector, - // cut the number of bytes in this sector - if(dwRawBytesInThisSector > dwBytesToRead) - dwRawBytesInThisSector = dwBytesToRead; - if(dwBytesInThisSector > dwBytesToRead) - dwBytesInThisSector = dwBytesToRead; - - // If the file is compressed, we have to adjust the raw sector size - if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK) - dwRawBytesInThisSector = hf->SectorOffsets[dwIndex + 1] - hf->SectorOffsets[dwIndex]; - - // If the file is encrypted, we have to decrypt the sector - if(pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED) - { - BSWAP_ARRAY32_UNSIGNED(pbInSector, dwRawBytesInThisSector); - - // If we don't know the key, try to detect it by file content - if(hf->dwFileKey == 0) - { - hf->dwFileKey = DetectFileKeyByContent(pbInSector, dwBytesInThisSector, hf->dwDataSize); - if(hf->dwFileKey == 0) - { - nError = ERROR_UNKNOWN_FILE_KEY; - break; - } - } - - DecryptMpqBlock(pbInSector, dwRawBytesInThisSector, hf->dwFileKey + dwIndex); - BSWAP_ARRAY32_UNSIGNED(pbInSector, dwRawBytesInThisSector); - } - - // If the file has sector CRC check turned on, perform it - if(hf->bCheckSectorCRCs && hf->SectorChksums != NULL) - { - DWORD dwAdlerExpected = hf->SectorChksums[dwIndex]; - DWORD dwAdlerValue = 0; - - // We can only check sector CRC when it's not zero - // Neither can we check it if it's 0xFFFFFFFF. - if(dwAdlerExpected != 0 && dwAdlerExpected != 0xFFFFFFFF) - { - dwAdlerValue = adler32(0, pbInSector, dwRawBytesInThisSector); - if(dwAdlerValue != dwAdlerExpected) - { - nError = ERROR_CHECKSUM_ERROR; - break; - } - } - } - - // If the sector is really compressed, decompress it. - // WARNING : Some sectors may not be compressed, it can be determined only - // by comparing uncompressed and compressed size !!! - if(dwRawBytesInThisSector < dwBytesInThisSector) - { - int cbOutSector = dwBytesInThisSector; - int cbInSector = dwRawBytesInThisSector; - int nResult = 0; - - // Is the file compressed by Blizzard's multiple compression ? - if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS) - { - // Remember the last used compression - hf->dwCompression0 = pbInSector[0]; - - // Decompress the data - if(ha->pHeader->wFormatVersion >= MPQ_FORMAT_VERSION_2) - nResult = SCompDecompress2(pbOutSector, &cbOutSector, pbInSector, cbInSector); - else - nResult = SCompDecompress(pbOutSector, &cbOutSector, pbInSector, cbInSector); - } - - // Is the file compressed by PKWARE Data Compression Library ? - else if(pFileEntry->dwFlags & MPQ_FILE_IMPLODE) - { - nResult = SCompExplode(pbOutSector, &cbOutSector, pbInSector, cbInSector); - } - - // Did the decompression fail ? - if(nResult == 0) - { - nError = ERROR_FILE_CORRUPT; - break; - } - } - else - { - if(pbOutSector != pbInSector) - memcpy(pbOutSector, pbInSector, dwBytesInThisSector); - } - - // Move pointers - dwBytesToRead -= dwBytesInThisSector; - dwByteOffset += dwBytesInThisSector; - dwBytesRead += dwBytesInThisSector; - pbOutSector += dwBytesInThisSector; - pbInSector += dwRawBytesInThisSector; - dwSectorsDone++; - } - } - else - { - nError = GetLastError(); - } - - // Free all used buffers - if(pbRawSector != NULL) - STORM_FREE(pbRawSector); - - // Give the caller thenumber of bytes read - *pdwBytesRead = dwBytesRead; - return nError; -} - -static int ReadMpqFileSingleUnit(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos, DWORD dwToRead, LPDWORD pdwBytesRead) -{ - ULONGLONG RawFilePos = hf->RawFilePos; - TMPQArchive * ha = hf->ha; - TFileEntry * pFileEntry = hf->pFileEntry; - LPBYTE pbCompressed = NULL; - LPBYTE pbRawData; - int nError = ERROR_SUCCESS; - - // If the file buffer is not allocated yet, do it. - if(hf->pbFileSector == NULL) - { - nError = AllocateSectorBuffer(hf); - if(nError != ERROR_SUCCESS || hf->pbFileSector == NULL) - return nError; - } - - // If the file is a patch file, adjust raw data offset - if(hf->pPatchInfo != NULL) - RawFilePos += hf->pPatchInfo->dwLength; - pbRawData = hf->pbFileSector; - - // If the file sector is not loaded yet, do it - if(hf->dwSectorOffs != 0) - { - // Is the file compressed? - if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK) - { - // Allocate space for compressed data - pbCompressed = STORM_ALLOC(BYTE, pFileEntry->dwCmpSize); - if(pbCompressed == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - pbRawData = pbCompressed; - } - - // Load the raw (compressed, encrypted) data - if(!FileStream_Read(ha->pStream, &RawFilePos, pbRawData, pFileEntry->dwCmpSize)) - { - STORM_FREE(pbCompressed); - return GetLastError(); - } - - // If the file is encrypted, we have to decrypt the data first - if(pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED) - { - BSWAP_ARRAY32_UNSIGNED(pbRawData, pFileEntry->dwCmpSize); - DecryptMpqBlock(pbRawData, pFileEntry->dwCmpSize, hf->dwFileKey); - BSWAP_ARRAY32_UNSIGNED(pbRawData, pFileEntry->dwCmpSize); - } - - // If the file is compressed, we have to decompress it now - if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK) - { - int cbOutBuffer = (int)hf->dwDataSize; - int cbInBuffer = (int)pFileEntry->dwCmpSize; - int nResult = 0; - - // - // If the file is an incremental patch, the size of compressed data - // is determined as pFileEntry->dwCmpSize - sizeof(TPatchInfo) - // - // In "wow-update-12694.MPQ" from Wow-Cataclysm BETA: - // - // File CmprSize DcmpSize DataSize Compressed? - // -------------------------------------- ---------- -------- -------- --------------- - // esES\DBFilesClient\LightSkyBox.dbc 0xBE->0xA2 0xBC 0xBC Yes - // deDE\DBFilesClient\MountCapability.dbc 0x93->0x77 0x77 0x77 No - // - - if(pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) - cbInBuffer = cbInBuffer - sizeof(TPatchInfo); - - // Is the file compressed by Blizzard's multiple compression ? - if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS) - { - // Remember the last used compression - hf->dwCompression0 = pbRawData[0]; - - // Decompress the file - if(ha->pHeader->wFormatVersion >= MPQ_FORMAT_VERSION_2) - nResult = SCompDecompress2(hf->pbFileSector, &cbOutBuffer, pbRawData, cbInBuffer); - else - nResult = SCompDecompress(hf->pbFileSector, &cbOutBuffer, pbRawData, cbInBuffer); - } - - // Is the file compressed by PKWARE Data Compression Library ? - // Note: Single unit files compressed with IMPLODE are not supported by Blizzard - else if(pFileEntry->dwFlags & MPQ_FILE_IMPLODE) - nResult = SCompExplode(hf->pbFileSector, &cbOutBuffer, pbRawData, cbInBuffer); - - nError = (nResult != 0) ? ERROR_SUCCESS : ERROR_FILE_CORRUPT; - } - else - { - if(hf->pbFileSector != NULL && pbRawData != hf->pbFileSector) - memcpy(hf->pbFileSector, pbRawData, hf->dwDataSize); - } - - // Free the decompression buffer. - if(pbCompressed != NULL) - STORM_FREE(pbCompressed); - - // The file sector is now properly loaded - hf->dwSectorOffs = 0; - } - - // At this moment, we have the file loaded into the file buffer. - // Copy as much as the caller wants - if(nError == ERROR_SUCCESS && hf->dwSectorOffs == 0) - { - // File position is greater or equal to file size ? - if(dwFilePos >= hf->dwDataSize) - { - *pdwBytesRead = 0; - return ERROR_SUCCESS; - } - - // If not enough bytes remaining in the file, cut them - if((hf->dwDataSize - dwFilePos) < dwToRead) - dwToRead = (hf->dwDataSize - dwFilePos); - - // Copy the bytes - memcpy(pvBuffer, hf->pbFileSector + dwFilePos, dwToRead); - - // Give the number of bytes read - *pdwBytesRead = dwToRead; - return ERROR_SUCCESS; - } - - // An error, sorry - return ERROR_CAN_NOT_COMPLETE; -} - -static int ReadMpkFileSingleUnit(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos, DWORD dwToRead, LPDWORD pdwBytesRead) -{ - ULONGLONG RawFilePos = hf->RawFilePos + 0x0C; // For some reason, MPK files start at position (hf->RawFilePos + 0x0C) - TMPQArchive * ha = hf->ha; - TFileEntry * pFileEntry = hf->pFileEntry; - LPBYTE pbCompressed = NULL; - LPBYTE pbRawData = hf->pbFileSector; - int nError = ERROR_SUCCESS; - - // We do not support patch files in MPK archives - assert(hf->pPatchInfo == NULL); - - // If the file buffer is not allocated yet, do it. - if(hf->pbFileSector == NULL) - { - nError = AllocateSectorBuffer(hf); - if(nError != ERROR_SUCCESS || hf->pbFileSector == NULL) - return nError; - pbRawData = hf->pbFileSector; - } - - // If the file sector is not loaded yet, do it - if(hf->dwSectorOffs != 0) - { - // Is the file compressed? - if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK) - { - // Allocate space for compressed data - pbCompressed = STORM_ALLOC(BYTE, pFileEntry->dwCmpSize); - if(pbCompressed == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - pbRawData = pbCompressed; - } - - // Load the raw (compressed, encrypted) data - if(!FileStream_Read(ha->pStream, &RawFilePos, pbRawData, pFileEntry->dwCmpSize)) - { - STORM_FREE(pbCompressed); - return GetLastError(); - } - - // If the file is encrypted, we have to decrypt the data first - if(pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED) - { - DecryptMpkTable(pbRawData, pFileEntry->dwCmpSize); - } - - // If the file is compressed, we have to decompress it now - if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK) - { - int cbOutBuffer = (int)hf->dwDataSize; - - hf->dwCompression0 = pbRawData[0]; - if(!SCompDecompressMpk(hf->pbFileSector, &cbOutBuffer, pbRawData, (int)pFileEntry->dwCmpSize)) - nError = ERROR_FILE_CORRUPT; - } - else - { - if(pbRawData != hf->pbFileSector) - memcpy(hf->pbFileSector, pbRawData, hf->dwDataSize); - } - - // Free the decompression buffer. - if(pbCompressed != NULL) - STORM_FREE(pbCompressed); - - // The file sector is now properly loaded - hf->dwSectorOffs = 0; - } - - // At this moment, we have the file loaded into the file buffer. - // Copy as much as the caller wants - if(nError == ERROR_SUCCESS && hf->dwSectorOffs == 0) - { - // File position is greater or equal to file size ? - if(dwFilePos >= hf->dwDataSize) - { - *pdwBytesRead = 0; - return ERROR_SUCCESS; - } - - // If not enough bytes remaining in the file, cut them - if((hf->dwDataSize - dwFilePos) < dwToRead) - dwToRead = (hf->dwDataSize - dwFilePos); - - // Copy the bytes - memcpy(pvBuffer, hf->pbFileSector + dwFilePos, dwToRead); - - // Give the number of bytes read - *pdwBytesRead = dwToRead; - return ERROR_SUCCESS; - } - - // An error, sorry - return ERROR_CAN_NOT_COMPLETE; -} - - -static int ReadMpqFileSectorFile(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos, DWORD dwBytesToRead, LPDWORD pdwBytesRead) -{ - TMPQArchive * ha = hf->ha; - LPBYTE pbBuffer = (BYTE *)pvBuffer; - DWORD dwTotalBytesRead = 0; // Total bytes read in all three parts - DWORD dwSectorSizeMask = ha->dwSectorSize - 1; // Mask for block size, usually 0x0FFF - DWORD dwFileSectorPos; // File offset of the loaded sector - DWORD dwBytesRead; // Number of bytes read (temporary variable) - int nError; - - // If the file position is at or beyond end of file, do nothing - if(dwFilePos >= hf->dwDataSize) - { - *pdwBytesRead = 0; - return ERROR_SUCCESS; - } - - // If not enough bytes in the file remaining, cut them - if(dwBytesToRead > (hf->dwDataSize - dwFilePos)) - dwBytesToRead = (hf->dwDataSize - dwFilePos); - - // Compute sector position in the file - dwFileSectorPos = dwFilePos & ~dwSectorSizeMask; // Position in the block - - // If the file sector buffer is not allocated yet, do it now - if(hf->pbFileSector == NULL) - { - nError = AllocateSectorBuffer(hf); - if(nError != ERROR_SUCCESS || hf->pbFileSector == NULL) - return nError; - } - - // Load the first (incomplete) file sector - if(dwFilePos & dwSectorSizeMask) - { - DWORD dwBytesInSector = ha->dwSectorSize; - DWORD dwBufferOffs = dwFilePos & dwSectorSizeMask; - DWORD dwToCopy; - - // Is the file sector already loaded ? - if(hf->dwSectorOffs != dwFileSectorPos) - { - // Load one MPQ sector into archive buffer - nError = ReadMpqSectors(hf, hf->pbFileSector, dwFileSectorPos, ha->dwSectorSize, &dwBytesInSector); - if(nError != ERROR_SUCCESS) - return nError; - - // Remember that the data loaded to the sector have new file offset - hf->dwSectorOffs = dwFileSectorPos; - } - else - { - if((dwFileSectorPos + dwBytesInSector) > hf->dwDataSize) - dwBytesInSector = hf->dwDataSize - dwFileSectorPos; - } - - // Copy the data from the offset in the loaded sector to the end of the sector - dwToCopy = dwBytesInSector - dwBufferOffs; - if(dwToCopy > dwBytesToRead) - dwToCopy = dwBytesToRead; - - // Copy data from sector buffer into target buffer - memcpy(pbBuffer, hf->pbFileSector + dwBufferOffs, dwToCopy); - - // Update pointers and byte counts - dwTotalBytesRead += dwToCopy; - dwFileSectorPos += dwBytesInSector; - pbBuffer += dwToCopy; - dwBytesToRead -= dwToCopy; - } - - // Load the whole ("middle") sectors only if there is at least one full sector to be read - if(dwBytesToRead >= ha->dwSectorSize) - { - DWORD dwBlockBytes = dwBytesToRead & ~dwSectorSizeMask; - - // Load all sectors to the output buffer - nError = ReadMpqSectors(hf, pbBuffer, dwFileSectorPos, dwBlockBytes, &dwBytesRead); - if(nError != ERROR_SUCCESS) - return nError; - - // Update pointers - dwTotalBytesRead += dwBytesRead; - dwFileSectorPos += dwBytesRead; - pbBuffer += dwBytesRead; - dwBytesToRead -= dwBytesRead; - } - - // Read the terminating sector - if(dwBytesToRead > 0) - { - DWORD dwToCopy = ha->dwSectorSize; - - // Is the file sector already loaded ? - if(hf->dwSectorOffs != dwFileSectorPos) - { - // Load one MPQ sector into archive buffer - nError = ReadMpqSectors(hf, hf->pbFileSector, dwFileSectorPos, ha->dwSectorSize, &dwBytesRead); - if(nError != ERROR_SUCCESS) - return nError; - - // Remember that the data loaded to the sector have new file offset - hf->dwSectorOffs = dwFileSectorPos; - } - - // Check number of bytes read - if(dwToCopy > dwBytesToRead) - dwToCopy = dwBytesToRead; - - // Copy the data from the cached last sector to the caller's buffer - memcpy(pbBuffer, hf->pbFileSector, dwToCopy); - - // Update pointers - dwTotalBytesRead += dwToCopy; - } - - // Store total number of bytes read to the caller - *pdwBytesRead = dwTotalBytesRead; - return ERROR_SUCCESS; -} - -static int ReadMpqFilePatchFile(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos, DWORD dwToRead, LPDWORD pdwBytesRead) -{ - TMPQPatcher Patcher; - DWORD dwBytesToRead = dwToRead; - DWORD dwBytesRead = 0; - int nError = ERROR_SUCCESS; - - // Make sure that the patch file is loaded completely - if(nError == ERROR_SUCCESS && hf->pbFileData == NULL) - { - // Initialize patching process and allocate data - nError = Patch_InitPatcher(&Patcher, hf); - if(nError != ERROR_SUCCESS) - return nError; - - // Set the current data size - Patcher.cbFileData = hf->pFileEntry->dwFileSize; - - // Initialize the patcher object with initial file data - if(hf->pFileEntry->dwFlags & MPQ_FILE_SINGLE_UNIT) - nError = ReadMpqFileSingleUnit(hf, Patcher.pbFileData1, 0, Patcher.cbFileData, &dwBytesRead); - else - nError = ReadMpqFileSectorFile(hf, Patcher.pbFileData1, 0, Patcher.cbFileData, &dwBytesRead); - - // Perform the patching process - if(nError == ERROR_SUCCESS) - nError = Patch_Process(&Patcher, hf); - - // Finalize the patcher structure - Patch_Finalize(&Patcher); - dwBytesRead = 0; - } - - // If there is something to read, do it - if(nError == ERROR_SUCCESS) - { - if(dwFilePos < hf->cbFileData) - { - // Make sure we don't copy more than file size - if((dwFilePos + dwToRead) > hf->cbFileData) - dwToRead = hf->cbFileData - dwFilePos; - - // Copy the appropriate amount of the file data to the caller's buffer - memcpy(pvBuffer, hf->pbFileData + dwFilePos, dwToRead); - dwBytesRead = dwToRead; - } - - // Set the proper error code - nError = (dwBytesRead == dwBytesToRead) ? ERROR_SUCCESS : ERROR_HANDLE_EOF; - } - - // Give the result to the caller - if(pdwBytesRead != NULL) - *pdwBytesRead = dwBytesRead; - return nError; -} - -static int ReadMpqFileLocalFile(TMPQFile * hf, void * pvBuffer, DWORD dwFilePos, DWORD dwToRead, LPDWORD pdwBytesRead) -{ - ULONGLONG FilePosition1 = dwFilePos; - ULONGLONG FilePosition2; - DWORD dwBytesRead = 0; - int nError = ERROR_SUCCESS; - - assert(hf->pStream != NULL); - - // Because stream I/O functions are designed to read - // "all or nothing", we compare file position before and after, - // and if they differ, we assume that number of bytes read - // is the difference between them - - if(!FileStream_Read(hf->pStream, &FilePosition1, pvBuffer, dwToRead)) - { - // If not all bytes have been read, then return the number of bytes read - if((nError = GetLastError()) == ERROR_HANDLE_EOF) - { - FileStream_GetPos(hf->pStream, &FilePosition2); - dwBytesRead = (DWORD)(FilePosition2 - FilePosition1); - } - } - else - { - dwBytesRead = dwToRead; - } - - *pdwBytesRead = dwBytesRead; - return nError; -} - -//----------------------------------------------------------------------------- -// SFileReadFile - -bool WINAPI SFileReadFile(HANDLE hFile, void * pvBuffer, DWORD dwToRead, LPDWORD pdwRead, LPOVERLAPPED lpOverlapped) -{ - TMPQFile * hf = (TMPQFile *)hFile; - DWORD dwBytesRead = 0; // Number of bytes read - int nError = ERROR_SUCCESS; - - // Always zero the result - if(pdwRead != NULL) - *pdwRead = 0; - lpOverlapped = lpOverlapped; - - // Check valid parameters - if(!IsValidFileHandle(hFile)) - { - SetLastError(ERROR_INVALID_HANDLE); - return false; - } - - if(pvBuffer == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return false; - } - - // If we didn't load the patch info yet, do it now - if(hf->pFileEntry != NULL && (hf->pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) && hf->pPatchInfo == NULL) - { - nError = AllocatePatchInfo(hf, true); - if(nError != ERROR_SUCCESS || hf->pPatchInfo == NULL) - { - SetLastError(nError); - return false; - } - } - - // Clear the last used compression - hf->dwCompression0 = 0; - - // If the file is local file, read the data directly from the stream - if(hf->pStream != NULL) - { - nError = ReadMpqFileLocalFile(hf, pvBuffer, hf->dwFilePos, dwToRead, &dwBytesRead); - } - - // If the file is a patch file, we have to read it special way - else if(hf->hfPatch != NULL && (hf->pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) == 0) - { - nError = ReadMpqFilePatchFile(hf, pvBuffer, hf->dwFilePos, dwToRead, &dwBytesRead); - } - - // If the archive is a MPK archive, we need special way to read the file - else if(hf->ha->dwSubType == MPQ_SUBTYPE_MPK) - { - nError = ReadMpkFileSingleUnit(hf, pvBuffer, hf->dwFilePos, dwToRead, &dwBytesRead); - } - - // If the file is single unit file, redirect it to read file - else if(hf->pFileEntry->dwFlags & MPQ_FILE_SINGLE_UNIT) - { - nError = ReadMpqFileSingleUnit(hf, pvBuffer, hf->dwFilePos, dwToRead, &dwBytesRead); - } - - // Otherwise read it as sector based MPQ file - else - { - nError = ReadMpqFileSectorFile(hf, pvBuffer, hf->dwFilePos, dwToRead, &dwBytesRead); - } - - // Increment the file position - hf->dwFilePos += dwBytesRead; - - // Give the caller the number of bytes read - if(pdwRead != NULL) - *pdwRead = dwBytesRead; - - // If the read operation succeeded, but not full number of bytes was read, - // set the last error to ERROR_HANDLE_EOF - if(nError == ERROR_SUCCESS && (dwBytesRead < dwToRead)) - nError = ERROR_HANDLE_EOF; - - // If something failed, set the last error value - if(nError != ERROR_SUCCESS) - SetLastError(nError); - return (nError == ERROR_SUCCESS); -} - -//----------------------------------------------------------------------------- -// SFileGetFileSize - -DWORD WINAPI SFileGetFileSize(HANDLE hFile, LPDWORD pdwFileSizeHigh) -{ - ULONGLONG FileSize; - TMPQFile * hf = (TMPQFile *)hFile; - - // Validate the file handle before we go on - if(IsValidFileHandle(hFile)) - { - // Make sure that the variable is initialized - FileSize = 0; - - // If the file is patched file, we have to get the size of the last version - if(hf->hfPatch != NULL) - { - // Walk through the entire patch chain, take the last version - while(hf != NULL) - { - // Get the size of the currently pointed version - FileSize = hf->pFileEntry->dwFileSize; - - // Move to the next patch file in the hierarchy - hf = hf->hfPatch; - } - } - else - { - // Is it a local file ? - if(hf->pStream != NULL) - { - FileStream_GetSize(hf->pStream, &FileSize); - } - else - { - FileSize = hf->dwDataSize; - } - } - - // If opened from archive, return file size - if(pdwFileSizeHigh != NULL) - *pdwFileSizeHigh = (DWORD)(FileSize >> 32); - return (DWORD)FileSize; - } - - SetLastError(ERROR_INVALID_HANDLE); - return SFILE_INVALID_SIZE; -} - -DWORD WINAPI SFileSetFilePointer(HANDLE hFile, LONG lFilePos, LONG * plFilePosHigh, DWORD dwMoveMethod) -{ - TMPQFile * hf = (TMPQFile *)hFile; - ULONGLONG OldPosition; - ULONGLONG NewPosition; - ULONGLONG FileSize; - ULONGLONG DeltaPos; - - // If the hFile is not a valid file handle, return an error. - if(!IsValidFileHandle(hFile)) - { - SetLastError(ERROR_INVALID_HANDLE); - return SFILE_INVALID_POS; - } - - // Retrieve the file size for handling the limits - if(hf->pStream != NULL) - { - FileStream_GetSize(hf->pStream, &FileSize); - } - else - { - FileSize = SFileGetFileSize(hFile, NULL); - } - - // Handle the NULL and non-NULL values of plFilePosHigh - // Non-NULL: The DeltaPos is combined from lFilePos and *lpFilePosHigh - // NULL: The DeltaPos is sign-extended value of lFilePos - DeltaPos = (plFilePosHigh != NULL) ? MAKE_OFFSET64(plFilePosHigh[0], lFilePos) : (ULONGLONG)(LONGLONG)lFilePos; - - // Get the relative point where to move from - switch(dwMoveMethod) - { - case FILE_BEGIN: - - // Move relative to the file begin. - OldPosition = 0; - break; - - case FILE_CURRENT: - - // Retrieve the current file position - if(hf->pStream != NULL) - { - FileStream_GetPos(hf->pStream, &OldPosition); - } - else - { - OldPosition = hf->dwFilePos; - } - break; - - case FILE_END: - - // Move relative to the end of the file - OldPosition = FileSize; - break; - - default: - SetLastError(ERROR_INVALID_PARAMETER); - return SFILE_INVALID_POS; - } - - // Calculate the new position - NewPosition = OldPosition + DeltaPos; - - // If moving backward, don't allow the new position go negative - if((LONGLONG)DeltaPos < 0) - { - if(NewPosition > FileSize) // Position is negative - { - SetLastError(ERROR_NEGATIVE_SEEK); - return SFILE_INVALID_POS; - } - } - - // If moving forward, don't allow the new position go past the end of the file - else - { - if(NewPosition > FileSize) - NewPosition = FileSize; - } - - // Now apply the file pointer to the file - if(hf->pStream != NULL) - { - if(!FileStream_Read(hf->pStream, &NewPosition, NULL, 0)) - return SFILE_INVALID_POS; - } - else - { - hf->dwFilePos = (DWORD)NewPosition; - } - - // Return the new file position - if(plFilePosHigh != NULL) - *plFilePosHigh = (LONG)(NewPosition >> 32); - return (DWORD)NewPosition; -} diff --git a/libs/storm-sys/StormLib/src/SFileVerify.cpp b/libs/storm-sys/StormLib/src/SFileVerify.cpp deleted file mode 100644 index 45ff58e..0000000 --- a/libs/storm-sys/StormLib/src/SFileVerify.cpp +++ /dev/null @@ -1,1054 +0,0 @@ -/*****************************************************************************/ -/* SFileVerify.cpp Copyright (c) Ladislav Zezula 2010 */ -/*---------------------------------------------------------------------------*/ -/* MPQ files and MPQ archives verification. */ -/* */ -/* The MPQ signature verification has been written by Jean-Francois Roy */ -/* and Justin Olbrantz (Quantam). */ -/* The MPQ public keys have been created by MPQKit, using OpenSSL library. */ -/* */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 04.05.10 1.00 Lad The first version of SFileVerify.cpp */ -/*****************************************************************************/ - -#define __STORMLIB_SELF__ -#include "StormLib.h" -#include "StormCommon.h" - -//----------------------------------------------------------------------------- -// Local defines - -#define MPQ_DIGEST_UNIT_SIZE 0x10000 - -//----------------------------------------------------------------------------- -// Known Blizzard public keys -// Created by Jean-Francois Roy using OpenSSL - -static const char * szBlizzardWeakPrivateKey = - "-----BEGIN PRIVATE KEY-----" - "MIIBOQIBAAJBAJJidwS/uILMBSO5DLGsBFknIXWWjQJe2kfdfEk3G/j66w4KkhZ1" - "V61Rt4zLaMVCYpDun7FLwRjkMDSepO1q2DcCAwEAAQJANtiztVDMJh2hE1hjPDKy" - "UmEJ9U/aN3gomuKOjbQbQ/bWWcM/WfhSVHmPqtqh/bQI2UXFr0rnXngeteZHLr/b" - "8QIhAMuWriSKGMACw18/rVVfUrThs915odKBH1Alr3vMVVzZAiEAuBHPSQkgwcb6" - "L4MWaiKuOzq08mSyNqPeN8oSy18q848CIHeMn+3s+eOmu7su1UYQl6yH7OrdBd1q" - "3UxfFNEJiAbhAiAqxdCyOxHGlbM7aS3DOg3cq5ayoN2cvtV7h1R4t8OmVwIgF+5z" - "/6vkzBUsZhd8Nwyis+MeQYH0rpFpMKdTlqmPF2Q=" - "-----END PRIVATE KEY-----"; - -static const char * szBlizzardWeakPublicKey = - "-----BEGIN PUBLIC KEY-----" - "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJJidwS/uILMBSO5DLGsBFknIXWWjQJe" - "2kfdfEk3G/j66w4KkhZ1V61Rt4zLaMVCYpDun7FLwRjkMDSepO1q2DcCAwEAAQ==" - "-----END PUBLIC KEY-----"; - -static const char * szBlizzardStrongPublicKey = - "-----BEGIN PUBLIC KEY-----" - "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsQZ+ziT2h8h+J/iMQpgd" - "tH1HaJzOBE3agjU4yMPcrixaPOZoA4t8bwfey7qczfWywocYo3pleytFF+IuD4HD" - "Fl9OXN1SFyupSgMx1EGZlgbFAomnbq9MQJyMqQtMhRAjFgg4TndS7YNb+JMSAEKp" - "kXNqY28n/EVBHD5TsMuVCL579gIenbr61dI92DDEdy790IzIG0VKWLh/KOTcTJfm" - "Ds/7HQTkGouVW+WUsfekuqNQo7ND9DBnhLjLjptxeFE2AZqYcA1ao3S9LN3GL1tW" - "lVXFIX9c7fWqaVTQlZ2oNsI/ARVApOK3grNgqvwH6YoVYVXjNJEo5sQJsPsdV/hk" - "dwIDAQAB" - "-----END PUBLIC KEY-----"; - -static const char * szWarcraft3MapPublicKey = - "-----BEGIN PUBLIC KEY-----" - "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1BwklUUQ3UvjizOBRoF5" - "yyOVc7KD+oGOQH5i6eUk1yfs0luCC70kNucNrfqhmviywVtahRse1JtXCPrx2bd3" - "iN8Dx91fbkxjYIOGTsjYoHKTp0BbaFkJih776fcHgnFSb+7mJcDuJVvJOXxEH6w0" - "1vo6VtujCqj1arqbyoal+xtAaczF3us5cOEp45sR1zAWTn1+7omN7VWV4QqJPaDS" - "gBSESc0l1grO0i1VUSumayk7yBKIkb+LBvcG6WnYZHCi7VdLmaxER5m8oZfER66b" - "heHoiSQIZf9PAY6Guw2DT5BTc54j/AaLQAKf2qcRSgQLVo5kQaddF3rCpsXoB/74" - "6QIDAQAB" - "-----END PUBLIC KEY-----"; - -static const char * szWowPatchPublicKey = - "-----BEGIN PUBLIC KEY-----" - "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwOsMV0LagAWPEtEQM6b9" - "6FHFkUyGbbyda2/Dfc9dyl21E9QvX+Yw7qKRMAKPzA2TlQQLZKvXpnKXF/YIK5xa" - "5uwg9CEHCEAYolLG4xn0FUOE0E/0PuuytI0p0ICe6rk00PifZzTr8na2wI/l/GnQ" - "bvnIVF1ck6cslATpQJ5JJVMXzoFlUABS19WESw4MXuJAS3AbMhxNWdEhVv7eO51c" - "yGjRLy9QjogZODZTY0fSEksgBqQxNCoYVJYI/sF5K2flDsGqrIp0OdJ6teJlzg1Y" - "UjYnb6bKjlidXoHEXI2TgA/mD6O3XFIt08I9s3crOCTgICq7cgX35qrZiIVWZdRv" - "TwIDAQAB" - "-----END PUBLIC KEY-----"; - -static const char * szWowSurveyPublicKey = - "-----BEGIN PUBLIC KEY-----" - "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnIt1DR6nRyyKsy2qahHe" - "MKLtacatn/KxieHcwH87wLBxKy+jZ0gycTmJ7SaTdBAEMDs/V5IPIXEtoqYnid2c" - "63TmfGDU92oc3Ph1PWUZ2PWxBhT06HYxRdbrgHw9/I29pNPi/607x+lzPORITOgU" - "BR6MR8au8HsQP4bn4vkJNgnSgojh48/XQOB/cAln7As1neP61NmVimoLR4Bwi3zt" - "zfgrZaUpyeNCUrOYJmH09YIjbBySTtXOUidoPHjFrMsCWpr6xs8xbETbs7MJFL6a" - "vcUfTT67qfIZ9RsuKfnXJTIrV0kwDSjjuNXiPTmWAehSsiHIsrUXX5RNcwsSjClr" - "nQIDAQAB" - "-----END PUBLIC KEY-----"; - -static const char * szStarcraft2MapPublicKey = - "-----BEGIN PUBLIC KEY-----" - "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmk4GT8zb+ICC25a17KZB" - "q/ygKGJ2VSO6IT5PGHJlm1KfnHBA4B6SH3xMlJ4c6eG2k7QevZv+FOhjsAHubyWq" - "2VKqWbrIFKv2ILc2RfMn8J9EDVRxvcxh6slRrVL69D0w1tfVGjMiKq2Fym5yGoRT" - "E7CRgDqbAbXP9LBsCNWHiJLwfxMGzHbk8pIl9oia5pvM7ofZamSHchxlpy6xa4GJ" - "7xKN01YCNvklTL1D7uol3wkwcHc7vrF8QwuJizuA5bSg4poEGtH62BZOYi+UL/z0" - "31YK+k9CbQyM0X0pJoJoYz1TK+Y5J7vBnXCZtfcTYQ/ZzN6UcxTa57dJaiOlCh9z" - "nQIDAQAB" - "-----END PUBLIC KEY-----"; - -//----------------------------------------------------------------------------- -// Local functions - -static void memrev(unsigned char *buf, size_t count) -{ - unsigned char *r; - - for (r = buf + count - 1; buf < r; buf++, r--) - { - *buf ^= *r; - *r ^= *buf; - *buf ^= *r; - } -} - -static bool decode_base64_key(const char * szKeyBase64, rsa_key * key) -{ - unsigned char decoded_key[0x200]; - const char * szBase64Begin; - const char * szBase64End; - unsigned long decoded_length = sizeof(decoded_key); - unsigned long length; - - // Find out the begin of the BASE64 data - szBase64Begin = szKeyBase64 + strlen("-----BEGIN PUBLIC KEY-----"); - szBase64End = szBase64Begin + strlen(szBase64Begin) - strlen("-----END PUBLIC KEY-----"); - if(szBase64End[0] != '-') - return false; - - // decode the base64 string - length = (unsigned long)(szBase64End - szBase64Begin); - if(base64_decode((unsigned char *)szBase64Begin, length, decoded_key, &decoded_length) != CRYPT_OK) - return false; - - // Create RSA key - if(rsa_import(decoded_key, decoded_length, key) != CRYPT_OK) - return false; - - return true; -} - -static void GetPlainAnsiFileName( - const TCHAR * szFileName, - char * szPlainName) -{ - const TCHAR * szPlainNameT = GetPlainFileName(szFileName); - - // Convert the plain name to ANSI - while(*szPlainNameT != 0) - *szPlainName++ = (char)*szPlainNameT++; - *szPlainName = 0; -} - -// Calculate begin and end of the MPQ archive -static void CalculateArchiveRange( - TMPQArchive * ha, - PMPQ_SIGNATURE_INFO pSI) -{ - ULONGLONG TempPos = 0; - char szMapHeader[0x200]; - - // Get the MPQ begin - pSI->BeginMpqData = ha->MpqPos; - - // Warcraft III maps are signed from the map header to the end - if(FileStream_Read(ha->pStream, &TempPos, szMapHeader, sizeof(szMapHeader))) - { - // Is it a map header ? - if(szMapHeader[0] == 'H' && szMapHeader[1] == 'M' && szMapHeader[2] == '3' && szMapHeader[3] == 'W') - { - // We will have to hash since the map header - pSI->BeginMpqData = 0; - } - } - - // Get the MPQ data end. This is stored in the MPQ header - pSI->EndMpqData = ha->MpqPos + ha->pHeader->ArchiveSize64; - - // Get the size of the entire file - FileStream_GetSize(ha->pStream, &pSI->EndOfFile); -} - -static bool CalculateMpqHashMd5( - TMPQArchive * ha, - PMPQ_SIGNATURE_INFO pSI, - LPBYTE pMd5Digest) -{ - hash_state md5_state; - ULONGLONG BeginBuffer; - ULONGLONG EndBuffer; - LPBYTE pbDigestBuffer = NULL; - - // Allocate buffer for creating the MPQ digest. - pbDigestBuffer = STORM_ALLOC(BYTE, MPQ_DIGEST_UNIT_SIZE); - if(pbDigestBuffer == NULL) - return false; - - // Initialize the MD5 hash state - md5_init(&md5_state); - - // Set the byte offset of begin of the data - BeginBuffer = pSI->BeginMpqData; - - // Create the digest - for(;;) - { - ULONGLONG BytesRemaining; - LPBYTE pbSigBegin = NULL; - LPBYTE pbSigEnd = NULL; - DWORD dwToRead = MPQ_DIGEST_UNIT_SIZE; - - // Check the number of bytes remaining - BytesRemaining = pSI->EndMpqData - BeginBuffer; - if(BytesRemaining < MPQ_DIGEST_UNIT_SIZE) - dwToRead = (DWORD)BytesRemaining; - if(dwToRead == 0) - break; - - // Read the next chunk - if(!FileStream_Read(ha->pStream, &BeginBuffer, pbDigestBuffer, dwToRead)) - { - STORM_FREE(pbDigestBuffer); - return false; - } - - // Move the current byte offset - EndBuffer = BeginBuffer + dwToRead; - - // Check if the signature is within the loaded digest - if(BeginBuffer <= pSI->BeginExclude && pSI->BeginExclude < EndBuffer) - pbSigBegin = pbDigestBuffer + (size_t)(pSI->BeginExclude - BeginBuffer); - if(BeginBuffer <= pSI->EndExclude && pSI->EndExclude < EndBuffer) - pbSigEnd = pbDigestBuffer + (size_t)(pSI->EndExclude - BeginBuffer); - - // Zero the part that belongs to the signature - if(pbSigBegin != NULL || pbSigEnd != NULL) - { - if(pbSigBegin == NULL) - pbSigBegin = pbDigestBuffer; - if(pbSigEnd == NULL) - pbSigEnd = pbDigestBuffer + dwToRead; - - memset(pbSigBegin, 0, (pbSigEnd - pbSigBegin)); - } - - // Pass the buffer to the hashing function - md5_process(&md5_state, pbDigestBuffer, dwToRead); - - // Move pointers - BeginBuffer += dwToRead; - } - - // Finalize the MD5 hash - md5_done(&md5_state, pMd5Digest); - STORM_FREE(pbDigestBuffer); - return true; -} - -static void AddTailToSha1( - hash_state * psha1_state, - const char * szTail) -{ - unsigned char * pbTail = (unsigned char *)szTail; - unsigned char szUpperCase[0x200]; - unsigned long nLength = 0; - - // Convert the tail to uppercase - // Note that we don't need to terminate the string with zero - while(*pbTail != 0) - { - szUpperCase[nLength++] = AsciiToUpperTable[*pbTail++]; - } - - // Append the tail to the SHA1 - sha1_process(psha1_state, szUpperCase, nLength); -} - -static bool CalculateMpqHashSha1( - TMPQArchive * ha, - PMPQ_SIGNATURE_INFO pSI, - unsigned char * sha1_tail0, - unsigned char * sha1_tail1, - unsigned char * sha1_tail2) -{ - ULONGLONG BeginBuffer; - hash_state sha1_state_temp; - hash_state sha1_state; - LPBYTE pbDigestBuffer = NULL; - char szPlainName[MAX_PATH]; - - // Allocate buffer for creating the MPQ digest. - pbDigestBuffer = STORM_ALLOC(BYTE, MPQ_DIGEST_UNIT_SIZE); - if(pbDigestBuffer == NULL) - return false; - - // Initialize SHA1 state structure - sha1_init(&sha1_state); - - // Calculate begin of data to be hashed - BeginBuffer = pSI->BeginMpqData; - - // Create the digest - for(;;) - { - ULONGLONG BytesRemaining; - DWORD dwToRead = MPQ_DIGEST_UNIT_SIZE; - - // Check the number of bytes remaining - BytesRemaining = pSI->EndMpqData - BeginBuffer; - if(BytesRemaining < MPQ_DIGEST_UNIT_SIZE) - dwToRead = (DWORD)BytesRemaining; - if(dwToRead == 0) - break; - - // Read the next chunk - if(!FileStream_Read(ha->pStream, &BeginBuffer, pbDigestBuffer, dwToRead)) - { - STORM_FREE(pbDigestBuffer); - return false; - } - - // Pass the buffer to the hashing function - sha1_process(&sha1_state, pbDigestBuffer, dwToRead); - - // Move pointers - BeginBuffer += dwToRead; - } - - // Add all three known tails and generate three hashes - memcpy(&sha1_state_temp, &sha1_state, sizeof(hash_state)); - sha1_done(&sha1_state_temp, sha1_tail0); - - memcpy(&sha1_state_temp, &sha1_state, sizeof(hash_state)); - GetPlainAnsiFileName(FileStream_GetFileName(ha->pStream), szPlainName); - AddTailToSha1(&sha1_state_temp, szPlainName); - sha1_done(&sha1_state_temp, sha1_tail1); - - memcpy(&sha1_state_temp, &sha1_state, sizeof(hash_state)); - AddTailToSha1(&sha1_state_temp, "ARCHIVE"); - sha1_done(&sha1_state_temp, sha1_tail2); - - // Finalize the MD5 hash - STORM_FREE(pbDigestBuffer); - return true; -} - -static int VerifyRawMpqData( - TMPQArchive * ha, - ULONGLONG ByteOffset, - DWORD dwDataSize) -{ - ULONGLONG DataOffset = ha->MpqPos + ByteOffset; - LPBYTE pbDataChunk; - LPBYTE pbMD5Array1; // Calculated MD5 array - LPBYTE pbMD5Array2; // MD5 array loaded from the MPQ - DWORD dwBytesInChunk; - DWORD dwChunkCount; - DWORD dwChunkSize = ha->pHeader->dwRawChunkSize; - DWORD dwMD5Size; - int nError = ERROR_SUCCESS; - - // Don't verify zero-sized blocks - if(dwDataSize == 0) - return ERROR_SUCCESS; - - // Get the number of data chunks to calculate MD5 - assert(dwChunkSize != 0); - dwChunkCount = ((dwDataSize - 1) / dwChunkSize) + 1; - dwMD5Size = dwChunkCount * MD5_DIGEST_SIZE; - - // Allocate space for data chunk and for the MD5 array - pbDataChunk = STORM_ALLOC(BYTE, dwChunkSize); - if(pbDataChunk == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - // Allocate space for MD5 array - pbMD5Array1 = STORM_ALLOC(BYTE, dwMD5Size); - pbMD5Array2 = STORM_ALLOC(BYTE, dwMD5Size); - if(pbMD5Array1 == NULL || pbMD5Array2 == NULL) - nError = ERROR_NOT_ENOUGH_MEMORY; - - // Calculate MD5 of each data chunk - if(nError == ERROR_SUCCESS) - { - LPBYTE pbMD5 = pbMD5Array1; - - for(DWORD i = 0; i < dwChunkCount; i++) - { - // Get the number of bytes in the chunk - dwBytesInChunk = STORMLIB_MIN(dwChunkSize, dwDataSize); - - // Read the data chunk - if(!FileStream_Read(ha->pStream, &DataOffset, pbDataChunk, dwBytesInChunk)) - { - nError = ERROR_FILE_CORRUPT; - break; - } - - // Calculate MD5 - CalculateDataBlockHash(pbDataChunk, dwBytesInChunk, pbMD5); - - // Move pointers and offsets - DataOffset += dwBytesInChunk; - dwDataSize -= dwBytesInChunk; - pbMD5 += MD5_DIGEST_SIZE; - } - } - - // Read the MD5 array - if(nError == ERROR_SUCCESS) - { - // Read the array of MD5 - if(!FileStream_Read(ha->pStream, &DataOffset, pbMD5Array2, dwMD5Size)) - nError = GetLastError(); - } - - // Compare the array of MD5 - if(nError == ERROR_SUCCESS) - { - // Compare the MD5 - if(memcmp(pbMD5Array1, pbMD5Array2, dwMD5Size)) - nError = ERROR_FILE_CORRUPT; - } - - // Free memory and return result - if(pbMD5Array2 != NULL) - STORM_FREE(pbMD5Array2); - if(pbMD5Array1 != NULL) - STORM_FREE(pbMD5Array1); - if(pbDataChunk != NULL) - STORM_FREE(pbDataChunk); - return nError; -} - -static DWORD VerifyWeakSignature( - TMPQArchive * ha, - PMPQ_SIGNATURE_INFO pSI) -{ - BYTE RevSignature[MPQ_WEAK_SIGNATURE_SIZE]; - BYTE Md5Digest[MD5_DIGEST_SIZE]; - rsa_key key; - int hash_idx = find_hash("md5"); - int result = 0; - - // The signature might be zeroed out. In that case, we ignore it - if(!IsValidSignature(pSI->Signature)) - return ERROR_WEAK_SIGNATURE_OK; - - // Calculate hash of the entire archive, skipping the (signature) file - if(!CalculateMpqHashMd5(ha, pSI, Md5Digest)) - return ERROR_VERIFY_FAILED; - - // Import the Blizzard key in OpenSSL format - if(!decode_base64_key(szBlizzardWeakPublicKey, &key)) - return ERROR_VERIFY_FAILED; - - // Verify the signature - memcpy(RevSignature, &pSI->Signature[8], MPQ_WEAK_SIGNATURE_SIZE); - memrev(RevSignature, MPQ_WEAK_SIGNATURE_SIZE); - rsa_verify_hash_ex(RevSignature, MPQ_WEAK_SIGNATURE_SIZE, Md5Digest, sizeof(Md5Digest), LTC_LTC_PKCS_1_V1_5, hash_idx, 0, &result, &key); - rsa_free(&key); - - // Return the result - return result ? ERROR_WEAK_SIGNATURE_OK : ERROR_WEAK_SIGNATURE_ERROR; -} - -static DWORD VerifyStrongSignatureWithKey( - unsigned char * reversed_signature, - unsigned char * padded_digest, - const char * szPublicKey) -{ - rsa_key key; - int result = 0; - - // Import the Blizzard key in OpenSSL format - if(!decode_base64_key(szPublicKey, &key)) - { - assert(false); - return ERROR_VERIFY_FAILED; - } - - // Verify the signature - if(rsa_verify_simple(reversed_signature, MPQ_STRONG_SIGNATURE_SIZE, padded_digest, MPQ_STRONG_SIGNATURE_SIZE, &result, &key) != CRYPT_OK) - return ERROR_VERIFY_FAILED; - - // Free the key and return result - rsa_free(&key); - return result ? ERROR_STRONG_SIGNATURE_OK : ERROR_STRONG_SIGNATURE_ERROR; -} - -static DWORD VerifyStrongSignature( - TMPQArchive * ha, - PMPQ_SIGNATURE_INFO pSI) -{ - unsigned char reversed_signature[MPQ_STRONG_SIGNATURE_SIZE]; - unsigned char Sha1Digest_tail0[SHA1_DIGEST_SIZE]; - unsigned char Sha1Digest_tail1[SHA1_DIGEST_SIZE]; - unsigned char Sha1Digest_tail2[SHA1_DIGEST_SIZE]; - unsigned char padded_digest[MPQ_STRONG_SIGNATURE_SIZE]; - DWORD dwResult; - size_t digest_offset; - - // Calculate SHA1 hash of the archive - if(!CalculateMpqHashSha1(ha, pSI, Sha1Digest_tail0, Sha1Digest_tail1, Sha1Digest_tail2)) - return ERROR_VERIFY_FAILED; - - // Prepare the signature for decryption - memcpy(reversed_signature, &pSI->Signature[4], MPQ_STRONG_SIGNATURE_SIZE); - memrev(reversed_signature, MPQ_STRONG_SIGNATURE_SIZE); - - // Prepare the padded digest for comparison - digest_offset = sizeof(padded_digest) - SHA1_DIGEST_SIZE; - memset(padded_digest, 0xbb, digest_offset); - padded_digest[0] = 0x0b; - - // Try Blizzard Strong public key with no SHA1 tail - memcpy(padded_digest + digest_offset, Sha1Digest_tail0, SHA1_DIGEST_SIZE); - memrev(padded_digest + digest_offset, SHA1_DIGEST_SIZE); - dwResult = VerifyStrongSignatureWithKey(reversed_signature, padded_digest, szBlizzardStrongPublicKey); - if(dwResult == ERROR_STRONG_SIGNATURE_OK) - return dwResult; - - // Try War 3 map public key with plain file name as SHA1 tail - memcpy(padded_digest + digest_offset, Sha1Digest_tail1, SHA1_DIGEST_SIZE); - memrev(padded_digest + digest_offset, SHA1_DIGEST_SIZE); - dwResult = VerifyStrongSignatureWithKey(reversed_signature, padded_digest, szWarcraft3MapPublicKey); - if(dwResult == ERROR_STRONG_SIGNATURE_OK) - return dwResult; - - // Try WoW-TBC public key with "ARCHIVE" as SHA1 tail - memcpy(padded_digest + digest_offset, Sha1Digest_tail2, SHA1_DIGEST_SIZE); - memrev(padded_digest + digest_offset, SHA1_DIGEST_SIZE); - dwResult = VerifyStrongSignatureWithKey(reversed_signature, padded_digest, szWowPatchPublicKey); - if(dwResult == ERROR_STRONG_SIGNATURE_OK) - return dwResult; - - // Try Survey public key with no SHA1 tail - memcpy(padded_digest + digest_offset, Sha1Digest_tail0, SHA1_DIGEST_SIZE); - memrev(padded_digest + digest_offset, SHA1_DIGEST_SIZE); - dwResult = VerifyStrongSignatureWithKey(reversed_signature, padded_digest, szWowSurveyPublicKey); - if(dwResult == ERROR_STRONG_SIGNATURE_OK) - return dwResult; - - // Try Starcraft II public key with no SHA1 tail - memcpy(padded_digest + digest_offset, Sha1Digest_tail0, SHA1_DIGEST_SIZE); - memrev(padded_digest + digest_offset, SHA1_DIGEST_SIZE); - dwResult = VerifyStrongSignatureWithKey(reversed_signature, padded_digest, szStarcraft2MapPublicKey); - if(dwResult == ERROR_STRONG_SIGNATURE_OK) - return dwResult; - - return ERROR_STRONG_SIGNATURE_ERROR; -} - -static DWORD VerifyFile( - HANDLE hMpq, - const char * szFileName, - LPDWORD pdwCrc32, - char * pMD5, - DWORD dwFlags) -{ - hash_state md5_state; - unsigned char * pFileMd5; - unsigned char md5[MD5_DIGEST_SIZE]; - TFileEntry * pFileEntry; - TMPQFile * hf; - BYTE Buffer[0x1000]; - HANDLE hFile = NULL; - DWORD dwVerifyResult = 0; - DWORD dwTotalBytes = 0; - DWORD dwCrc32 = 0; - - // - // Note: When the MPQ is patched, it will - // automatically check the patched version of the file - // - - // Make sure the md5 is initialized - memset(md5, 0, sizeof(md5)); - - // If we have to verify raw data MD5, do it before file open - if(dwFlags & SFILE_VERIFY_RAW_MD5) - { - TMPQArchive * ha = (TMPQArchive *)hMpq; - - // Parse the base MPQ and all patches - while(ha != NULL) - { - // Does the archive have support for raw MD5? - if(ha->pHeader->dwRawChunkSize != 0) - { - // The file has raw MD5 if the archive supports it - dwVerifyResult |= VERIFY_FILE_HAS_RAW_MD5; - - // Find file entry for the file - pFileEntry = GetFileEntryLocale(ha, szFileName, lcFileLocale); - if(pFileEntry != NULL) - { - // If the file's raw MD5 doesn't match, don't bother with more checks - if(VerifyRawMpqData(ha, pFileEntry->ByteOffset, pFileEntry->dwCmpSize) != ERROR_SUCCESS) - return dwVerifyResult | VERIFY_FILE_RAW_MD5_ERROR; - } - } - - // Move to the next patch - ha = ha->haPatch; - } - } - - // Attempt to open the file - if(SFileOpenFileEx(hMpq, szFileName, SFILE_OPEN_FROM_MPQ, &hFile)) - { - // Get the file size - hf = (TMPQFile *)hFile; - pFileEntry = hf->pFileEntry; - dwTotalBytes = SFileGetFileSize(hFile, NULL); - - // Initialize the CRC32 and MD5 contexts - md5_init(&md5_state); - dwCrc32 = crc32(0, Z_NULL, 0); - - // Also turn on sector checksum verification - if(dwFlags & SFILE_VERIFY_SECTOR_CRC) - hf->bCheckSectorCRCs = true; - - // Go through entire file and update both CRC32 and MD5 - for(;;) - { - DWORD dwBytesRead = 0; - - // Read data from file - SFileReadFile(hFile, Buffer, sizeof(Buffer), &dwBytesRead, NULL); - if(dwBytesRead == 0) - { - if(GetLastError() == ERROR_CHECKSUM_ERROR) - dwVerifyResult |= VERIFY_FILE_SECTOR_CRC_ERROR; - break; - } - - // Update CRC32 value - if(dwFlags & SFILE_VERIFY_FILE_CRC) - dwCrc32 = crc32(dwCrc32, Buffer, dwBytesRead); - - // Update MD5 value - if(dwFlags & SFILE_VERIFY_FILE_MD5) - md5_process(&md5_state, Buffer, dwBytesRead); - - // Decrement the total size - dwTotalBytes -= dwBytesRead; - } - - // If the file has sector checksums, indicate it in the flags - if(dwFlags & SFILE_VERIFY_SECTOR_CRC) - { - if((hf->pFileEntry->dwFlags & MPQ_FILE_SECTOR_CRC) && hf->SectorChksums != NULL && hf->SectorChksums[0] != 0) - dwVerifyResult |= VERIFY_FILE_HAS_SECTOR_CRC; - } - - // Check if the entire file has been read - // No point in checking CRC32 and MD5 if not - // Skip checksum checks if the file has patches - if(dwTotalBytes == 0) - { - // Check CRC32 and MD5 only if there is no patches - if(hf->hfPatch == NULL) - { - // Check if the CRC32 matches. - if(dwFlags & SFILE_VERIFY_FILE_CRC) - { - // Only check the CRC32 if it is valid - if(pFileEntry->dwCrc32 != 0) - { - dwVerifyResult |= VERIFY_FILE_HAS_CHECKSUM; - if(dwCrc32 != pFileEntry->dwCrc32) - dwVerifyResult |= VERIFY_FILE_CHECKSUM_ERROR; - } - } - - // Check if MD5 matches - if(dwFlags & SFILE_VERIFY_FILE_MD5) - { - // Patch files have their MD5 saved in the patch info - pFileMd5 = (hf->pPatchInfo != NULL) ? hf->pPatchInfo->md5 : pFileEntry->md5; - md5_done(&md5_state, md5); - - // Only check the MD5 if it is valid - if(IsValidMD5(pFileMd5)) - { - dwVerifyResult |= VERIFY_FILE_HAS_MD5; - if(memcmp(md5, pFileMd5, MD5_DIGEST_SIZE)) - dwVerifyResult |= VERIFY_FILE_MD5_ERROR; - } - } - } - else - { - // Patched files are MD5-checked automatically - dwVerifyResult |= VERIFY_FILE_HAS_MD5; - } - } - else - { - dwVerifyResult |= VERIFY_READ_ERROR; - } - - SFileCloseFile(hFile); - } - else - { - // Remember that the file couldn't be open - dwVerifyResult |= VERIFY_OPEN_ERROR; - } - - // If the caller required CRC32 and/or MD5, give it to him - if(pdwCrc32 != NULL) - *pdwCrc32 = dwCrc32; - if(pMD5 != NULL) - memcpy(pMD5, md5, MD5_DIGEST_SIZE); - - return dwVerifyResult; -} - -// Used in SFileGetFileInfo -bool QueryMpqSignatureInfo( - TMPQArchive * ha, - PMPQ_SIGNATURE_INFO pSI) -{ - TFileEntry * pFileEntry; - ULONGLONG ExtraBytes; - DWORD dwFileSize; - - // Make sure it's all zeroed - memset(pSI, 0, sizeof(MPQ_SIGNATURE_INFO)); - - // Calculate the range of the MPQ - CalculateArchiveRange(ha, pSI); - - // If there is "(signature)" file in the MPQ, it has a weak signature - pFileEntry = GetFileEntryLocale(ha, SIGNATURE_NAME, LANG_NEUTRAL); - if(pFileEntry != NULL) - { - // Calculate the begin and end of the signature file itself - pSI->BeginExclude = ha->MpqPos + pFileEntry->ByteOffset; - pSI->EndExclude = pSI->BeginExclude + pFileEntry->dwCmpSize; - dwFileSize = (DWORD)(pSI->EndExclude - pSI->BeginExclude); - - // Does the signature have proper size? - if(dwFileSize == MPQ_SIGNATURE_FILE_SIZE) - { - // Read the weak signature - if(!FileStream_Read(ha->pStream, &pSI->BeginExclude, pSI->Signature, dwFileSize)) - return false; - - pSI->SignatureTypes |= SIGNATURE_TYPE_WEAK; - pSI->cbSignatureSize = dwFileSize; - return true; - } - } - - // If there is extra bytes beyond the end of the archive, - // it's the strong signature - ExtraBytes = pSI->EndOfFile - pSI->EndMpqData; - if(ExtraBytes >= (MPQ_STRONG_SIGNATURE_SIZE + 4)) - { - // Read the strong signature - if(!FileStream_Read(ha->pStream, &pSI->EndMpqData, pSI->Signature, (MPQ_STRONG_SIGNATURE_SIZE + 4))) - return false; - - // Check the signature header "NGIS" - if(pSI->Signature[0] != 'N' || pSI->Signature[1] != 'G' || pSI->Signature[2] != 'I' || pSI->Signature[3] != 'S') - return false; - - pSI->SignatureTypes |= SIGNATURE_TYPE_STRONG; - return true; - } - - // Succeeded, but no known signature found - return true; -} - -//----------------------------------------------------------------------------- -// Support for weak signature - -int SSignFileCreate(TMPQArchive * ha) -{ - TMPQFile * hf = NULL; - BYTE EmptySignature[MPQ_SIGNATURE_FILE_SIZE]; - int nError = ERROR_SUCCESS; - - // Only save the signature if we should do so - if(ha->dwFileFlags3 != 0) - { - // The (signature) file must be non-encrypted and non-compressed - assert(ha->dwFlags & MPQ_FLAG_SIGNATURE_NEW); - assert(ha->dwFileFlags3 == MPQ_FILE_EXISTS); - assert(ha->dwReservedFiles > 0); - - // Create the (signature) file file in the MPQ - // Note that the file must not be compressed or encrypted - nError = SFileAddFile_Init(ha, SIGNATURE_NAME, - 0, - sizeof(EmptySignature), - LANG_NEUTRAL, - ha->dwFileFlags3 | MPQ_FILE_REPLACEEXISTING, - &hf); - - // Write the empty signature file to the archive - if(nError == ERROR_SUCCESS) - { - // Write the empty zeroed file to the MPQ - memset(EmptySignature, 0, sizeof(EmptySignature)); - nError = SFileAddFile_Write(hf, EmptySignature, (DWORD)sizeof(EmptySignature), 0); - SFileAddFile_Finish(hf); - - // Clear the invalid mark - ha->dwFlags &= ~(MPQ_FLAG_SIGNATURE_NEW | MPQ_FLAG_SIGNATURE_NONE); - ha->dwReservedFiles--; - } - } - - return nError; -} - -int SSignFileFinish(TMPQArchive * ha) -{ - MPQ_SIGNATURE_INFO si; - unsigned long signature_len = MPQ_WEAK_SIGNATURE_SIZE; - BYTE WeakSignature[MPQ_SIGNATURE_FILE_SIZE]; - BYTE Md5Digest[MD5_DIGEST_SIZE]; - rsa_key key; - int hash_idx = find_hash("md5"); - - // Sanity checks - assert((ha->dwFlags & MPQ_FLAG_CHANGED) == 0); - assert(ha->dwFileFlags3 == MPQ_FILE_EXISTS); - - // Query the weak signature info - memset(&si, 0, sizeof(MPQ_SIGNATURE_INFO)); - if(!QueryMpqSignatureInfo(ha, &si)) - return ERROR_FILE_CORRUPT; - - // There must be exactly one signature - if(si.SignatureTypes != SIGNATURE_TYPE_WEAK) - return ERROR_FILE_CORRUPT; - - // Calculate MD5 of the entire archive - if(!CalculateMpqHashMd5(ha, &si, Md5Digest)) - return ERROR_VERIFY_FAILED; - - // Decode the private key - if(!decode_base64_key(szBlizzardWeakPrivateKey, &key)) - return ERROR_VERIFY_FAILED; - - // Sign the hash - memset(WeakSignature, 0, sizeof(WeakSignature)); - rsa_sign_hash_ex(Md5Digest, sizeof(Md5Digest), WeakSignature + 8, &signature_len, LTC_LTC_PKCS_1_V1_5, 0, 0, hash_idx, 0, &key); - memrev(WeakSignature + 8, MPQ_WEAK_SIGNATURE_SIZE); - rsa_free(&key); - - // Write the signature to the MPQ. Don't use SFile* functions, but write the hash directly - if(!FileStream_Write(ha->pStream, &si.BeginExclude, WeakSignature, MPQ_SIGNATURE_FILE_SIZE)) - return GetLastError(); - - return ERROR_SUCCESS; -} - -//----------------------------------------------------------------------------- -// Public (exported) functions - -bool WINAPI SFileGetFileChecksums(HANDLE hMpq, const char * szFileName, LPDWORD pdwCrc32, char * pMD5) -{ - DWORD dwVerifyResult; - DWORD dwVerifyFlags = 0; - - if(pdwCrc32 != NULL) - dwVerifyFlags |= SFILE_VERIFY_FILE_CRC; - if(pMD5 != NULL) - dwVerifyFlags |= SFILE_VERIFY_FILE_MD5; - - dwVerifyResult = VerifyFile(hMpq, - szFileName, - pdwCrc32, - pMD5, - dwVerifyFlags); - - // If verification failed, return zero - if(dwVerifyResult & VERIFY_FILE_ERROR_MASK) - { - SetLastError(ERROR_FILE_CORRUPT); - return false; - } - - return true; -} - - -DWORD WINAPI SFileVerifyFile(HANDLE hMpq, const char * szFileName, DWORD dwFlags) -{ - return VerifyFile(hMpq, - szFileName, - NULL, - NULL, - dwFlags); -} - -// Verifies raw data of the archive Only works for MPQs version 4 or newer -int WINAPI SFileVerifyRawData(HANDLE hMpq, DWORD dwWhatToVerify, const char * szFileName) -{ - TMPQArchive * ha = (TMPQArchive *)hMpq; - TFileEntry * pFileEntry; - TMPQHeader * pHeader; - - // Verify input parameters - if(!IsValidMpqHandle(hMpq)) - return ERROR_INVALID_PARAMETER; - pHeader = ha->pHeader; - - // If the archive doesn't have raw data MD5, report it as OK - if(pHeader->dwRawChunkSize == 0) - return ERROR_SUCCESS; - - // If we have to verify MPQ header, do it - switch(dwWhatToVerify) - { - case SFILE_VERIFY_MPQ_HEADER: - - // Only if the header is of version 4 or newer - if(pHeader->dwHeaderSize >= (MPQ_HEADER_SIZE_V4 - MD5_DIGEST_SIZE)) - return VerifyRawMpqData(ha, 0, MPQ_HEADER_SIZE_V4 - MD5_DIGEST_SIZE); - return ERROR_SUCCESS; - - case SFILE_VERIFY_HET_TABLE: - - // Only if we have HET table - if(pHeader->HetTablePos64 && pHeader->HetTableSize64) - return VerifyRawMpqData(ha, pHeader->HetTablePos64, (DWORD)pHeader->HetTableSize64); - return ERROR_SUCCESS; - - case SFILE_VERIFY_BET_TABLE: - - // Only if we have BET table - if(pHeader->BetTablePos64 && pHeader->BetTableSize64) - return VerifyRawMpqData(ha, pHeader->BetTablePos64, (DWORD)pHeader->BetTableSize64); - return ERROR_SUCCESS; - - case SFILE_VERIFY_HASH_TABLE: - - // Hash table is not protected by MD5 - return ERROR_SUCCESS; - - case SFILE_VERIFY_BLOCK_TABLE: - - // Block table is not protected by MD5 - return ERROR_SUCCESS; - - case SFILE_VERIFY_HIBLOCK_TABLE: - - // It is unknown if the hi-block table is protected my MD5 or not. - return ERROR_SUCCESS; - - case SFILE_VERIFY_FILE: - - // Verify parameters - if(szFileName == NULL || *szFileName == 0) - return ERROR_INVALID_PARAMETER; - - // Get the offset of a file - pFileEntry = GetFileEntryLocale(ha, szFileName, lcFileLocale); - if(pFileEntry == NULL) - return ERROR_FILE_NOT_FOUND; - - return VerifyRawMpqData(ha, pFileEntry->ByteOffset, pFileEntry->dwCmpSize); - } - - return ERROR_INVALID_PARAMETER; -} - - -// Verifies the archive against the signature -DWORD WINAPI SFileVerifyArchive(HANDLE hMpq) -{ - MPQ_SIGNATURE_INFO si; - TMPQArchive * ha = (TMPQArchive *)hMpq; - - // Verify input parameters - if(!IsValidMpqHandle(hMpq)) - return ERROR_VERIFY_FAILED; - - // If the archive was modified, we need to flush it - if(ha->dwFlags & MPQ_FLAG_CHANGED) - SFileFlushArchive(hMpq); - - // Get the MPQ signature and signature type - memset(&si, 0, sizeof(MPQ_SIGNATURE_INFO)); - if(!QueryMpqSignatureInfo(ha, &si)) - return ERROR_VERIFY_FAILED; - - // If there is no signature - if(si.SignatureTypes == 0) - return ERROR_NO_SIGNATURE; - - // We haven't seen a MPQ with both signatures - assert(si.SignatureTypes == SIGNATURE_TYPE_WEAK || si.SignatureTypes == SIGNATURE_TYPE_STRONG); - - // Verify the strong signature, if present - if(si.SignatureTypes & SIGNATURE_TYPE_STRONG) - return VerifyStrongSignature(ha, &si); - - // Verify the weak signature, if present - if(si.SignatureTypes & SIGNATURE_TYPE_WEAK) - return VerifyWeakSignature(ha, &si); - - return ERROR_NO_SIGNATURE; -} - -// Verifies the archive against the signature -bool WINAPI SFileSignArchive(HANDLE hMpq, DWORD dwSignatureType) -{ - TMPQArchive * ha; - - // Verify the archive handle - ha = IsValidMpqHandle(hMpq); - if(ha == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return false; - } - - // We only support weak signature, and only for MPQs version 1.0 - if(dwSignatureType != SIGNATURE_TYPE_WEAK) - { - SetLastError(ERROR_INVALID_PARAMETER); - return false; - } - - // The archive must not be malformed and must not be read-only - if(ha->dwFlags & (MPQ_FLAG_READ_ONLY | MPQ_FLAG_MALFORMED)) - { - SetLastError(ERROR_ACCESS_DENIED); - return false; - } - - // If the signature is not there yet - if(ha->dwFileFlags3 == 0) - { - // Turn the signature on. The signature will - // be applied when the archive is closed - ha->dwFlags |= MPQ_FLAG_SIGNATURE_NEW | MPQ_FLAG_CHANGED; - ha->dwFileFlags3 = MPQ_FILE_EXISTS; - ha->dwReservedFiles++; - } - - return true; -} - diff --git a/libs/storm-sys/StormLib/src/StormCommon.h b/libs/storm-sys/StormLib/src/StormCommon.h deleted file mode 100644 index 9d9f43c..0000000 --- a/libs/storm-sys/StormLib/src/StormCommon.h +++ /dev/null @@ -1,385 +0,0 @@ -/*****************************************************************************/ -/* SCommon.h Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Common functions for encryption/decryption from Storm.dll. Included by */ -/* SFile*** functions, do not include and do not use this file directly */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 24.03.03 1.00 Lad The first version of SFileCommon.h */ -/* 12.06.04 1.00 Lad Renamed to SCommon.h */ -/* 06.09.10 1.00 Lad Renamed to StormCommon.h */ -/*****************************************************************************/ - -#ifndef __STORMCOMMON_H__ -#define __STORMCOMMON_H__ - -//----------------------------------------------------------------------------- -// Compression support - -// Include functions from Pkware Data Compression Library -#include "pklib/pklib.h" - -// Include functions from Huffmann compression -#include "huffman/huff.h" - -// Include functions from IMA ADPCM compression -#include "adpcm/adpcm.h" - -// Include functions from SPARSE compression -#include "sparse/sparse.h" - -// Include functions from LZMA compression -#include "lzma/C/LzmaEnc.h" -#include "lzma/C/LzmaDec.h" - -// Include functions from zlib -#ifndef __SYS_ZLIB - #include "zlib/zlib.h" -#else - #include -#endif - -// Include functions from bzlib -#ifndef __SYS_BZLIB - #include "bzip2/bzlib.h" -#else - #include -#endif - -//----------------------------------------------------------------------------- -// Cryptography support - -// Headers from LibTomCrypt -#include "libtomcrypt/src/headers/tomcrypt.h" - -// For HashStringJenkins -#include "jenkins/lookup.h" - -//----------------------------------------------------------------------------- -// StormLib private defines - -#define ID_MPQ_FILE 0x46494c45 // Used internally for checking TMPQFile ('FILE') - -// Prevent problems with CRT "min" and "max" functions, -// as they are not defined on all platforms -#define STORMLIB_MIN(a, b) ((a < b) ? a : b) -#define STORMLIB_MAX(a, b) ((a > b) ? a : b) -#define STORMLIB_UNUSED(p) ((void)(p)) - -// Macro for building 64-bit file offset from two 32-bit -#define MAKE_OFFSET64(hi, lo) (((ULONGLONG)hi << 32) | (ULONGLONG)lo) - -//----------------------------------------------------------------------------- -// MPQ signature information - -// Size of each signature type -#define MPQ_WEAK_SIGNATURE_SIZE 64 -#define MPQ_STRONG_SIGNATURE_SIZE 256 -#define MPQ_STRONG_SIGNATURE_ID 0x5349474E // ID of the strong signature ("NGIS") -#define MPQ_SIGNATURE_FILE_SIZE (MPQ_WEAK_SIGNATURE_SIZE + 8) - -// MPQ signature info -typedef struct _MPQ_SIGNATURE_INFO -{ - ULONGLONG BeginMpqData; // File offset where the hashing starts - ULONGLONG BeginExclude; // Begin of the excluded area (used for (signature) file) - ULONGLONG EndExclude; // End of the excluded area (used for (signature) file) - ULONGLONG EndMpqData; // File offset where the hashing ends - ULONGLONG EndOfFile; // Size of the entire file - BYTE Signature[MPQ_STRONG_SIGNATURE_SIZE + 0x10]; - DWORD cbSignatureSize; // Length of the signature - DWORD SignatureTypes; // See SIGNATURE_TYPE_XXX - -} MPQ_SIGNATURE_INFO, *PMPQ_SIGNATURE_INFO; - -//----------------------------------------------------------------------------- -// Memory management -// -// We use our own macros for allocating/freeing memory. If you want -// to redefine them, please keep the following rules: -// -// - The memory allocation must return NULL if not enough memory -// (i.e not to throw exception) -// - The allocating function does not need to fill the allocated buffer with zeros -// - Memory freeing function doesn't have to test the pointer to NULL -// - -//#if defined(_MSC_VER) && defined(_DEBUG) -// -//#define STORM_ALLOC(type, nitems) (type *)HeapAlloc(GetProcessHeap(), 0, ((nitems) * sizeof(type))) -//#define STORM_REALLOC(type, ptr, nitems) (type *)HeapReAlloc(GetProcessHeap(), 0, ptr, ((nitems) * sizeof(type))) -//#define STORM_FREE(ptr) HeapFree(GetProcessHeap(), 0, ptr) -// -//#else - -#define STORM_ALLOC(type, nitems) (type *)malloc((nitems) * sizeof(type)) -#define STORM_REALLOC(type, ptr, nitems) (type *)realloc(ptr, ((nitems) * sizeof(type))) -#define STORM_FREE(ptr) free(ptr) - -//#endif - -//----------------------------------------------------------------------------- -// StormLib internal global variables - -extern LCID lcFileLocale; // Preferred file locale - -//----------------------------------------------------------------------------- -// Conversion to uppercase/lowercase (and "/" to "\") - -extern unsigned char AsciiToLowerTable[256]; -extern unsigned char AsciiToUpperTable[256]; - -//----------------------------------------------------------------------------- -// Safe string functions - -void StringCopy(char * szTarget, size_t cchTarget, const char * szSource); -void StringCat(char * szTarget, size_t cchTargetMax, const char * szSource); - -#ifdef _UNICODE -void StringCopy(TCHAR * szTarget, size_t cchTarget, const char * szSource); -void StringCopy(char * szTarget, size_t cchTarget, const TCHAR * szSource); -void StringCopy(TCHAR * szTarget, size_t cchTarget, const TCHAR * szSource); -void StringCat(TCHAR * szTarget, size_t cchTargetMax, const TCHAR * szSource); -#endif - -//----------------------------------------------------------------------------- -// Encryption and decryption functions - -#define MPQ_HASH_TABLE_INDEX 0x000 -#define MPQ_HASH_NAME_A 0x100 -#define MPQ_HASH_NAME_B 0x200 -#define MPQ_HASH_FILE_KEY 0x300 -#define MPQ_HASH_KEY2_MIX 0x400 - -DWORD HashString(const char * szFileName, DWORD dwHashType); -DWORD HashStringSlash(const char * szFileName, DWORD dwHashType); -DWORD HashStringLower(const char * szFileName, DWORD dwHashType); - -void InitializeMpqCryptography(); - -DWORD GetNearestPowerOfTwo(DWORD dwFileCount); - -bool IsPseudoFileName(const char * szFileName, LPDWORD pdwFileIndex); -ULONGLONG HashStringJenkins(const char * szFileName); - -DWORD GetDefaultSpecialFileFlags(DWORD dwFileSize, USHORT wFormatVersion); - -void EncryptMpqBlock(void * pvDataBlock, DWORD dwLength, DWORD dwKey); -void DecryptMpqBlock(void * pvDataBlock, DWORD dwLength, DWORD dwKey); - -DWORD DetectFileKeyBySectorSize(LPDWORD EncryptedData, DWORD dwSectorSize, DWORD dwSectorOffsLen); -DWORD DetectFileKeyByContent(void * pvEncryptedData, DWORD dwSectorSize, DWORD dwFileSize); -DWORD DecryptFileKey(const char * szFileName, ULONGLONG MpqPos, DWORD dwFileSize, DWORD dwFlags); - -bool IsValidMD5(LPBYTE pbMd5); -bool IsValidSignature(LPBYTE pbSignature); -bool VerifyDataBlockHash(void * pvDataBlock, DWORD cbDataBlock, LPBYTE expected_md5); -void CalculateDataBlockHash(void * pvDataBlock, DWORD cbDataBlock, LPBYTE md5_hash); - -//----------------------------------------------------------------------------- -// Handle validation functions - -TMPQArchive * IsValidMpqHandle(HANDLE hMpq); -TMPQFile * IsValidFileHandle(HANDLE hFile); - -//----------------------------------------------------------------------------- -// Support for MPQ file tables - -ULONGLONG FileOffsetFromMpqOffset(TMPQArchive * ha, ULONGLONG MpqOffset); -ULONGLONG CalculateRawSectorOffset(TMPQFile * hf, DWORD dwSectorOffset); - -int ConvertMpqHeaderToFormat4(TMPQArchive * ha, ULONGLONG MpqOffset, ULONGLONG FileSize, DWORD dwFlags, bool bIsWarcraft3Map); - -bool IsValidHashEntry(TMPQArchive * ha, TMPQHash * pHash); - -TMPQHash * FindFreeHashEntry(TMPQArchive * ha, DWORD dwStartIndex, DWORD dwName1, DWORD dwName2, LCID lcLocale); -TMPQHash * GetFirstHashEntry(TMPQArchive * ha, const char * szFileName); -TMPQHash * GetNextHashEntry(TMPQArchive * ha, TMPQHash * pFirstHash, TMPQHash * pPrevHash); -TMPQHash * AllocateHashEntry(TMPQArchive * ha, TFileEntry * pFileEntry, LCID lcLocale); - -TMPQExtHeader * LoadExtTable(TMPQArchive * ha, ULONGLONG ByteOffset, size_t Size, DWORD dwSignature, DWORD dwKey); -TMPQHetTable * LoadHetTable(TMPQArchive * ha); -TMPQBetTable * LoadBetTable(TMPQArchive * ha); - -TMPQBlock * LoadBlockTable(TMPQArchive * ha, bool bDontFixEntries = false); -TMPQBlock * TranslateBlockTable(TMPQArchive * ha, ULONGLONG * pcbTableSize, bool * pbNeedHiBlockTable); - -ULONGLONG FindFreeMpqSpace(TMPQArchive * ha); - -// Functions that load the HET and BET tables -int CreateHashTable(TMPQArchive * ha, DWORD dwHashTableSize); -int LoadAnyHashTable(TMPQArchive * ha); -int BuildFileTable(TMPQArchive * ha); -int DefragmentFileTable(TMPQArchive * ha); - -int CreateFileTable(TMPQArchive * ha, DWORD dwFileTableSize); -int RebuildHetTable(TMPQArchive * ha); -int RebuildFileTable(TMPQArchive * ha, DWORD dwNewHashTableSize); -int SaveMPQTables(TMPQArchive * ha); - -TMPQHetTable * CreateHetTable(DWORD dwEntryCount, DWORD dwTotalCount, DWORD dwHashBitSize, LPBYTE pbSrcData); -void FreeHetTable(TMPQHetTable * pHetTable); - -TMPQBetTable * CreateBetTable(DWORD dwMaxFileCount); -void FreeBetTable(TMPQBetTable * pBetTable); - -// Functions for finding files in the file table -TFileEntry * GetFileEntryLocale2(TMPQArchive * ha, const char * szFileName, LCID lcLocale, LPDWORD PtrHashIndex); -TFileEntry * GetFileEntryLocale(TMPQArchive * ha, const char * szFileName, LCID lcLocale); -TFileEntry * GetFileEntryExact(TMPQArchive * ha, const char * szFileName, LCID lcLocale, LPDWORD PtrHashIndex); - -// Allocates file name in the file entry -void AllocateFileName(TMPQArchive * ha, TFileEntry * pFileEntry, const char * szFileName); - -// Allocates new file entry in the MPQ tables. Reuses existing, if possible -TFileEntry * AllocateFileEntry(TMPQArchive * ha, const char * szFileName, LCID lcLocale, LPDWORD PtrHashIndex); -int RenameFileEntry(TMPQArchive * ha, TMPQFile * hf, const char * szNewFileName); -int DeleteFileEntry(TMPQArchive * ha, TMPQFile * hf); - -// Invalidates entries for (listfile) and (attributes) -void InvalidateInternalFiles(TMPQArchive * ha); - -// Retrieves information about the strong signature -bool QueryMpqSignatureInfo(TMPQArchive * ha, PMPQ_SIGNATURE_INFO pSignatureInfo); - -//----------------------------------------------------------------------------- -// Support for alternate file formats (SBaseSubTypes.cpp) - -int ConvertSqpHeaderToFormat4(TMPQArchive * ha, ULONGLONG FileSize, DWORD dwFlags); -TMPQHash * LoadSqpHashTable(TMPQArchive * ha); -TMPQBlock * LoadSqpBlockTable(TMPQArchive * ha); - -int ConvertMpkHeaderToFormat4(TMPQArchive * ha, ULONGLONG FileSize, DWORD dwFlags); -void DecryptMpkTable(void * pvMpkTable, size_t cbSize); -TMPQHash * LoadMpkHashTable(TMPQArchive * ha); -TMPQBlock * LoadMpkBlockTable(TMPQArchive * ha); -int SCompDecompressMpk(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer); - -//----------------------------------------------------------------------------- -// Common functions - MPQ File - -TMPQFile * CreateFileHandle(TMPQArchive * ha, TFileEntry * pFileEntry); -TMPQFile * CreateWritableHandle(TMPQArchive * ha, DWORD dwFileSize); -void * LoadMpqTable(TMPQArchive * ha, ULONGLONG ByteOffset, DWORD dwCompressedSize, DWORD dwRealSize, DWORD dwKey, bool * pbTableIsCut); -int AllocateSectorBuffer(TMPQFile * hf); -int AllocatePatchInfo(TMPQFile * hf, bool bLoadFromFile); -int AllocateSectorOffsets(TMPQFile * hf, bool bLoadFromFile); -int AllocateSectorChecksums(TMPQFile * hf, bool bLoadFromFile); -int WritePatchInfo(TMPQFile * hf); -int WriteSectorOffsets(TMPQFile * hf); -int WriteSectorChecksums(TMPQFile * hf); -int WriteMemDataMD5(TFileStream * pStream, ULONGLONG RawDataOffs, void * pvRawData, DWORD dwRawDataSize, DWORD dwChunkSize, LPDWORD pcbTotalSize); -int WriteMpqDataMD5(TFileStream * pStream, ULONGLONG RawDataOffs, DWORD dwRawDataSize, DWORD dwChunkSize); -void FreeFileHandle(TMPQFile *& hf); -void FreeArchiveHandle(TMPQArchive *& ha); - -//----------------------------------------------------------------------------- -// Patch functions - -// Structure used for the patching process -typedef struct _TMPQPatcher -{ - BYTE this_md5[MD5_DIGEST_SIZE]; // MD5 of the current file state - LPBYTE pbFileData1; // Primary working buffer - LPBYTE pbFileData2; // Secondary working buffer - DWORD cbMaxFileData; // Maximum allowed size of the patch data - DWORD cbFileData; // Current size of the result data - DWORD nCounter; // Counter of the patch process - -} TMPQPatcher; - -bool IsIncrementalPatchFile(const void * pvData, DWORD cbData, LPDWORD pdwPatchedFileSize); -int Patch_InitPatcher(TMPQPatcher * pPatcher, TMPQFile * hf); -int Patch_Process(TMPQPatcher * pPatcher, TMPQFile * hf); -void Patch_Finalize(TMPQPatcher * pPatcher); - -//----------------------------------------------------------------------------- -// Utility functions - -bool CheckWildCard(const char * szString, const char * szWildCard); -bool IsInternalMpqFileName(const char * szFileName); - -template -const XCHAR * GetPlainFileName(const XCHAR * szFileName) -{ - const XCHAR * szPlainName = szFileName; - - while(*szFileName != 0) - { - if(*szFileName == '\\' || *szFileName == '/') - szPlainName = szFileName + 1; - szFileName++; - } - - return szPlainName; -} - -//----------------------------------------------------------------------------- -// Internal support for MPQ modifications - -int SFileAddFile_Init( - TMPQArchive * ha, - const char * szArchivedName, - ULONGLONG ft, - DWORD dwFileSize, - LCID lcLocale, - DWORD dwFlags, - TMPQFile ** phf - ); - -int SFileAddFile_Init( - TMPQArchive * ha, - TMPQFile * hfSrc, - TMPQFile ** phf - ); - -int SFileAddFile_Write( - TMPQFile * hf, - const void * pvData, - DWORD dwSize, - DWORD dwCompression - ); - -int SFileAddFile_Finish( - TMPQFile * hf - ); - -//----------------------------------------------------------------------------- -// Attributes support - -int SAttrLoadAttributes(TMPQArchive * ha); -int SAttrFileSaveToMpq(TMPQArchive * ha); - -//----------------------------------------------------------------------------- -// Listfile functions - -int SListFileSaveToMpq(TMPQArchive * ha); - -//----------------------------------------------------------------------------- -// Weak signature support - -int SSignFileCreate(TMPQArchive * ha); -int SSignFileFinish(TMPQArchive * ha); - -//----------------------------------------------------------------------------- -// Dump data support - -#ifdef __STORMLIB_DUMP_DATA__ - -void DumpMpqHeader(TMPQHeader * pHeader); -void DumpHashTable(TMPQHash * pHashTable, DWORD dwHashTableSize); -void DumpHetAndBetTable(TMPQHetTable * pHetTable, TMPQBetTable * pBetTable); -void DumpFileTable(TFileEntry * pFileTable, DWORD dwFileTableSize); - -#else - -#define DumpMpqHeader(h) /* */ -#define DumpHashTable(t, s) /* */ -#define DumpHetAndBetTable(t, s) /* */ -#define DumpFileTable(t, s) /* */ - -#endif - -#endif // __STORMCOMMON_H__ - diff --git a/libs/storm-sys/StormLib/src/StormLib.h b/libs/storm-sys/StormLib/src/StormLib.h deleted file mode 100644 index 31f6eda..0000000 --- a/libs/storm-sys/StormLib/src/StormLib.h +++ /dev/null @@ -1,1124 +0,0 @@ -/*****************************************************************************/ -/* StormLib.h Copyright (c) Ladislav Zezula 1999-2017 */ -/*---------------------------------------------------------------------------*/ -/* StormLib library v 9.22 */ -/* */ -/* Author : Ladislav Zezula */ -/* E-mail : ladik@zezula.net */ -/* WWW : http://www.zezula.net */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* xx.xx.99 1.00 Lad Created */ -/* 24.03.03 2.50 Lad Version 2.50 */ -/* 02.04.03 3.00 Lad Version 3.00 with compression */ -/* 11.04.03 3.01 Lad Renamed to StormLib.h for compatibility with */ -/* original headers for Storm.dll */ -/* 10.05.03 3.02 Lad Added Pkware DCL compression */ -/* 26.05.03 4.00 Lad Completed all compressions */ -/* 18.06.03 4.01 Lad Added SFileSetFileLocale */ -/* Added SFileExtractFile */ -/* 26.07.03 4.02 Lad Implemented nameless rename and delete */ -/* 26.07.03 4.03 Lad Added support for protected MPQs */ -/* 28.08.03 4.10 Lad Fixed bugs that caused StormLib incorrectly work */ -/* with Diablo I savegames and with files having full */ -/* hash table */ -/* 08.12.03 4.11 DCH Fixed bug in reading file sector larger than 0x1000 */ -/* on certain files. */ -/* Fixed bug in AddFile with MPQ_FILE_REPLACE_EXISTING */ -/* (Thanx Daniel Chiamarello, dchiamarello@madvawes.com)*/ -/* 21.12.03 4.50 Lad Completed port for Mac */ -/* Fixed bug in compacting (if fsize is mul of 0x1000) */ -/* Fixed bug in SCompCompress */ -/* 27.05.04 4.51 Lad Changed memory management from new/delete to our */ -/* own macros */ -/* 22.06.04 4.60 Lad Optimized search. Support for multiple listfiles. */ -/* 30.09.04 4.61 Lad Fixed some bugs (Aaargh !!!) */ -/* Correctly works if HashTableSize > BlockTableSize */ -/* 29.12.04 4.70 Lad Fixed compatibility problem with MPQs from WoW */ -/* 14.07.05 5.00 Lad Added the BZLIB compression support */ -/* Added suport of files stored as single unit */ -/* 17.04.06 5.01 Lad Converted to MS Visual Studio 8.0 */ -/* Fixed issue with protected Warcraft 3 protected maps */ -/* 15.05.06 5.02 Lad Fixed issue with WoW 1.10+ */ -/* 07.09.06 5.10 Lad Fixed processing files longer than 2GB */ -/* 22.11.06 6.00 Lad Support for MPQ archives V2 */ -/* 12.06.07 6.10 Lad Support for (attributes) file */ -/* 10.09.07 6.12 Lad Support for MPQs protected by corrupting hash table */ -/* 03.12.07 6.13 Lad Support for MPQs with hash tbl size > block tbl size */ -/* 07.04.08 6.20 Lad Added SFileFlushArchive */ -/* 09.04.08 Lad Removed FilePointer variable from MPQ handle */ -/* structure, as it caused more problems than benefits */ -/* 12.05.08 6.22 Lad Support for w3xMaster map protector */ -/* 05.10.08 6.23 Lad Support for protectors who set negative values in */ -/* the table of file blocks */ -/* 26.05.09 6.24 Lad Fixed search for multiple lang files with deleted */ -/* entries */ -/* 03.09.09 6.25 Lad Fixed decompression bug in huffmann decompression */ -/* 22.03.10 6.50 Lad New compressions in Starcraft II (LZMA, sparse) */ -/* Fixed compacting MPQs that contain single unit files */ -/* 26.04.10 7.00 Lad Major rewrite */ -/* 08.06.10 7.10 Lad Support for partial MPQs */ -/* 08.07.10 7.11 Lad Support for MPQs v 3.0 */ -/* 20.08.10 7.20 Lad Support for opening multiple MPQs in patch mode */ -/* 20.09.10 8.00 Lad MPQs v 4, HET and BET tables */ -/* 07.01.11 8.01 Lad Write support for MPQs v 3 and 4 */ -/* 15.09.11 8.04 Lad Bug fixes, testing for Diablo III MPQs */ -/* 26.04.12 8.10 Lad Support for data map, added SFileGetArchiveBitmap */ -/* 29.05.12 8.20 Lad C-only interface */ -/* 14.01.13 8.21 Lad ADPCM and Huffmann (de)compression refactored */ -/* 04.12.13 9.00 Lad Unit tests, bug fixes */ -/* 27.08.14 9.10 Lad Signing archives with weak digital signature */ -/* 25.11.14 9.11 Lad Fixed bug reading & creating HET table */ -/* 18.09.15 9.20 Lad Release 9.20 */ -/* 12.12.16 9.21 Lad Release 9.21 */ -/* 10.11.17 9.22 Lad Release 9.22 */ -/*****************************************************************************/ - -#ifndef __STORMLIB_H__ -#define __STORMLIB_H__ - -#ifdef _MSC_VER -#pragma warning(disable:4668) // 'XXX' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' -#pragma warning(disable:4820) // 'XXX' : '2' bytes padding added after data member 'XXX::yyy' -#endif - -#include "StormPort.h" - -#ifdef __cplusplus -extern "C" { -#endif - -//----------------------------------------------------------------------------- -// Use the apropriate library -// -// The library type is encoded in the library name as the following -// StormLibXYZ.lib -// -// X - D for Debug version, R for Release version -// Y - A for ANSI version, U for Unicode version -// Z - S for static-linked CRT library, D for multithreaded DLL CRT library -// - -#if defined(__STORMLIB_SELF__) && !defined(STORMLIB_NO_AUTO_LINK) -#define STORMLIB_NO_AUTO_LINK // Define this if you don't want to link using pragmas when using msvc -#endif - -#if defined(_MSC_VER) && !defined(STORMLIB_NO_AUTO_LINK) - #ifdef _DEBUG // DEBUG VERSIONS - #ifndef _UNICODE - #ifdef _DLL - #pragma comment(lib, "StormLibDAD.lib") // Debug Ansi CRT-DLL version - #else - #pragma comment(lib, "StormLibDAS.lib") // Debug Ansi CRT-LIB version - #endif - #else - #ifdef _DLL - #pragma comment(lib, "StormLibDUD.lib") // Debug Unicode CRT-DLL version - #else - #pragma comment(lib, "StormLibDUS.lib") // Debug Unicode CRT-LIB version - #endif - #endif - #else // RELEASE VERSIONS - #ifndef _UNICODE - #ifdef _DLL - #pragma comment(lib, "StormLibRAD.lib") // Release Ansi CRT-DLL version - #else - #pragma comment(lib, "StormLibRAS.lib") // Release Ansi CRT-LIB version - #endif - #else - #ifdef _DLL - #pragma comment(lib, "StormLibRUD.lib") // Release Unicode CRT-DLL version - #else - #pragma comment(lib, "StormLibRUS.lib") // Release Unicode CRT-LIB version - #endif - #endif - #endif - -#endif - -//----------------------------------------------------------------------------- -// Defines - -#define STORMLIB_VERSION 0x0916 // Current version of StormLib (9.21) -#define STORMLIB_VERSION_STRING "9.22" // String version of StormLib version - -#define ID_MPQ 0x1A51504D // MPQ archive header ID ('MPQ\x1A') -#define ID_MPQ_USERDATA 0x1B51504D // MPQ userdata entry ('MPQ\x1B') -#define ID_MPK 0x1A4B504D // MPK archive header ID ('MPK\x1A') - -#define ERROR_AVI_FILE 10000 // Not a MPQ file, but an AVI file. -#define ERROR_UNKNOWN_FILE_KEY 10001 // Returned by SFileReadFile when can't find file key -#define ERROR_CHECKSUM_ERROR 10002 // Returned by SFileReadFile when sector CRC doesn't match -#define ERROR_INTERNAL_FILE 10003 // The given operation is not allowed on internal file -#define ERROR_BASE_FILE_MISSING 10004 // The file is present as incremental patch file, but base file is missing -#define ERROR_MARKED_FOR_DELETE 10005 // The file was marked as "deleted" in the MPQ -#define ERROR_FILE_INCOMPLETE 10006 // The required file part is missing -#define ERROR_UNKNOWN_FILE_NAMES 10007 // A name of at least one file is unknown -#define ERROR_CANT_FIND_PATCH_PREFIX 10008 // StormLib was unable to find patch prefix for the patches - -// Values for SFileCreateArchive -#define HASH_TABLE_SIZE_MIN 0x00000004 // Verified: If there is 1 file, hash table size is 4 -#define HASH_TABLE_SIZE_DEFAULT 0x00001000 // Default hash table size for empty MPQs -#define HASH_TABLE_SIZE_MAX 0x00080000 // Maximum acceptable hash table size - -#define HASH_ENTRY_DELETED 0xFFFFFFFE // Block index for deleted entry in the hash table -#define HASH_ENTRY_FREE 0xFFFFFFFF // Block index for free entry in the hash table - -#define HET_ENTRY_DELETED 0x80 // NameHash1 value for a deleted entry -#define HET_ENTRY_FREE 0x00 // NameHash1 value for free entry - -#define HASH_STATE_SIZE 0x60 // Size of LibTomCrypt's hash_state structure - -// Values for SFileOpenArchive -#define SFILE_OPEN_HARD_DISK_FILE 2 // Open the archive on HDD -#define SFILE_OPEN_CDROM_FILE 3 // Open the archive only if it is on CDROM - -// Values for SFileOpenFile -#define SFILE_OPEN_FROM_MPQ 0x00000000 // Open the file from the MPQ archive -#define SFILE_OPEN_CHECK_EXISTS 0xFFFFFFFC // Only check whether the file exists -#define SFILE_OPEN_BASE_FILE 0xFFFFFFFD // Reserved for StormLib internal use -#define SFILE_OPEN_ANY_LOCALE 0xFFFFFFFE // Reserved for StormLib internal use -#define SFILE_OPEN_LOCAL_FILE 0xFFFFFFFF // Open a local file - -// Flags for TMPQArchive::dwFlags. Used internally -#define MPQ_FLAG_READ_ONLY 0x00000001 // If set, the MPQ has been open for read-only access -#define MPQ_FLAG_CHANGED 0x00000002 // If set, the MPQ tables have been changed -#define MPQ_FLAG_MALFORMED 0x00000004 // Malformed data structure detected (W3M map protectors) -#define MPQ_FLAG_HASH_TABLE_CUT 0x00000008 // The hash table goes beyond EOF -#define MPQ_FLAG_BLOCK_TABLE_CUT 0x00000010 // The hash table goes beyond EOF -#define MPQ_FLAG_CHECK_SECTOR_CRC 0x00000020 // Checking sector CRC when reading files -#define MPQ_FLAG_SAVING_TABLES 0x00000040 // If set, we are saving MPQ internal files and MPQ tables -#define MPQ_FLAG_PATCH 0x00000080 // If set, this MPQ is a patch archive -#define MPQ_FLAG_WAR3_MAP 0x00000100 // If set, this MPQ is a map for Warcraft III -#define MPQ_FLAG_LISTFILE_NONE 0x00000200 // Set when no (listfile) was found in InvalidateInternalFiles -#define MPQ_FLAG_LISTFILE_NEW 0x00000400 // Set when (listfile) invalidated by InvalidateInternalFiles -#define MPQ_FLAG_LISTFILE_FORCE 0x00000800 // Save updated listfile on exit -#define MPQ_FLAG_ATTRIBUTES_NONE 0x00001000 // Set when no (attributes) was found in InvalidateInternalFiles -#define MPQ_FLAG_ATTRIBUTES_NEW 0x00002000 // Set when (attributes) invalidated by InvalidateInternalFiles -#define MPQ_FLAG_SIGNATURE_NONE 0x00004000 // Set when no (signature) was found in InvalidateInternalFiles -#define MPQ_FLAG_SIGNATURE_NEW 0x00008000 // Set when (signature) invalidated by InvalidateInternalFiles - -// Values for TMPQArchive::dwSubType -#define MPQ_SUBTYPE_MPQ 0x00000000 // The file is a MPQ file (Blizzard games) -#define MPQ_SUBTYPE_SQP 0x00000001 // The file is a SQP file (War of the Immortals) -#define MPQ_SUBTYPE_MPK 0x00000002 // The file is a MPK file (Longwu Online) - -// Return value for SFileGetFileSize and SFileSetFilePointer -#define SFILE_INVALID_SIZE 0xFFFFFFFF -#define SFILE_INVALID_POS 0xFFFFFFFF -#define SFILE_INVALID_ATTRIBUTES 0xFFFFFFFF - -// Flags for SFileAddFile -#define MPQ_FILE_IMPLODE 0x00000100 // Implode method (By PKWARE Data Compression Library) -#define MPQ_FILE_COMPRESS 0x00000200 // Compress methods (By multiple methods) -#define MPQ_FILE_ENCRYPTED 0x00010000 // Indicates whether file is encrypted -#define MPQ_FILE_FIX_KEY 0x00020000 // File decryption key has to be fixed -#define MPQ_FILE_PATCH_FILE 0x00100000 // The file is a patch file. Raw file data begin with TPatchInfo structure -#define MPQ_FILE_SINGLE_UNIT 0x01000000 // File is stored as a single unit, rather than split into sectors (Thx, Quantam) -#define MPQ_FILE_DELETE_MARKER 0x02000000 // File is a deletion marker. Used in MPQ patches, indicating that the file no longer exists. -#define MPQ_FILE_SECTOR_CRC 0x04000000 // File has checksums for each sector. - // Ignored if file is not compressed or imploded. -#define MPQ_FILE_SIGNATURE 0x10000000 // Present on STANDARD.SNP\(signature). The only occurence ever observed -#define MPQ_FILE_EXISTS 0x80000000 // Set if file exists, reset when the file was deleted -#define MPQ_FILE_REPLACEEXISTING 0x80000000 // Replace when the file exist (SFileAddFile) - -#define MPQ_FILE_COMPRESS_MASK 0x0000FF00 // Mask for a file being compressed - -#define MPQ_FILE_DEFAULT_INTERNAL 0xFFFFFFFF // Use default flags for internal files - -#define MPQ_FILE_VALID_FLAGS (MPQ_FILE_IMPLODE | \ - MPQ_FILE_COMPRESS | \ - MPQ_FILE_ENCRYPTED | \ - MPQ_FILE_FIX_KEY | \ - MPQ_FILE_PATCH_FILE | \ - MPQ_FILE_SINGLE_UNIT | \ - MPQ_FILE_DELETE_MARKER | \ - MPQ_FILE_SECTOR_CRC | \ - MPQ_FILE_SIGNATURE | \ - MPQ_FILE_EXISTS) - -#define MPQ_FILE_VALID_FLAGS_W3X (MPQ_FILE_IMPLODE | \ - MPQ_FILE_COMPRESS | \ - MPQ_FILE_ENCRYPTED | \ - MPQ_FILE_FIX_KEY | \ - MPQ_FILE_DELETE_MARKER | \ - MPQ_FILE_SECTOR_CRC | \ - MPQ_FILE_SIGNATURE | \ - MPQ_FILE_EXISTS) - -// We need to mask out the upper 4 bits of the block table index. -// This is because it gets shifted out when calculating block table offset -// BlockTableOffset = pHash->dwBlockIndex << 0x04 -// Malformed MPQ maps may contain block indexes like 0x40000001 or 0xF0000023 -#define BLOCK_INDEX_MASK 0x0FFFFFFF -#define MPQ_BLOCK_INDEX(pHash) (pHash->dwBlockIndex & BLOCK_INDEX_MASK) - -// Compression types for multiple compressions -#define MPQ_COMPRESSION_HUFFMANN 0x01 // Huffmann compression (used on WAVE files only) -#define MPQ_COMPRESSION_ZLIB 0x02 // ZLIB compression -#define MPQ_COMPRESSION_PKWARE 0x08 // PKWARE DCL compression -#define MPQ_COMPRESSION_BZIP2 0x10 // BZIP2 compression (added in Warcraft III) -#define MPQ_COMPRESSION_SPARSE 0x20 // Sparse compression (added in Starcraft 2) -#define MPQ_COMPRESSION_ADPCM_MONO 0x40 // IMA ADPCM compression (mono) -#define MPQ_COMPRESSION_ADPCM_STEREO 0x80 // IMA ADPCM compression (stereo) -#define MPQ_COMPRESSION_LZMA 0x12 // LZMA compression. Added in Starcraft 2. This value is NOT a combination of flags. -#define MPQ_COMPRESSION_NEXT_SAME 0xFFFFFFFF // Same compression - -// Constants for SFileAddWave -#define MPQ_WAVE_QUALITY_HIGH 0 // Best quality, the worst compression -#define MPQ_WAVE_QUALITY_MEDIUM 1 // Medium quality, medium compression -#define MPQ_WAVE_QUALITY_LOW 2 // Low quality, the best compression - -// Signatures for HET and BET table -#define HET_TABLE_SIGNATURE 0x1A544548 // 'HET\x1a' -#define BET_TABLE_SIGNATURE 0x1A544542 // 'BET\x1a' - -// Decryption keys for MPQ tables -#define MPQ_KEY_HASH_TABLE 0xC3AF3770 // Obtained by HashString("(hash table)", MPQ_HASH_FILE_KEY) -#define MPQ_KEY_BLOCK_TABLE 0xEC83B3A3 // Obtained by HashString("(block table)", MPQ_HASH_FILE_KEY) - -#define LISTFILE_NAME "(listfile)" // Name of internal listfile -#define SIGNATURE_NAME "(signature)" // Name of internal signature -#define ATTRIBUTES_NAME "(attributes)" // Name of internal attributes file -#define PATCH_METADATA_NAME "(patch_metadata)" - -#define MPQ_FORMAT_VERSION_1 0 // Up to The Burning Crusade -#define MPQ_FORMAT_VERSION_2 1 // The Burning Crusade and newer -#define MPQ_FORMAT_VERSION_3 2 // WoW Cataclysm Beta -#define MPQ_FORMAT_VERSION_4 3 // WoW Cataclysm and newer - -// Flags for MPQ attributes -#define MPQ_ATTRIBUTE_CRC32 0x00000001 // The "(attributes)" contains CRC32 for each file -#define MPQ_ATTRIBUTE_FILETIME 0x00000002 // The "(attributes)" contains file time for each file -#define MPQ_ATTRIBUTE_MD5 0x00000004 // The "(attributes)" contains MD5 for each file -#define MPQ_ATTRIBUTE_PATCH_BIT 0x00000008 // The "(attributes)" contains a patch bit for each file -#define MPQ_ATTRIBUTE_ALL 0x0000000F // Summary mask - -#define MPQ_ATTRIBUTES_V1 100 // (attributes) format version 1.00 - -// Flags for SFileOpenArchive -#define BASE_PROVIDER_FILE 0x00000000 // Base data source is a file -#define BASE_PROVIDER_MAP 0x00000001 // Base data source is memory-mapped file -#define BASE_PROVIDER_HTTP 0x00000002 // Base data source is a file on web server -#define BASE_PROVIDER_MASK 0x0000000F // Mask for base provider value - -#define STREAM_PROVIDER_FLAT 0x00000000 // Stream is linear with no offset mapping -#define STREAM_PROVIDER_PARTIAL 0x00000010 // Stream is partial file (.part) -#define STREAM_PROVIDER_MPQE 0x00000020 // Stream is an encrypted MPQ -#define STREAM_PROVIDER_BLOCK4 0x00000030 // 0x4000 per block, text MD5 after each block, max 0x2000 blocks per file -#define STREAM_PROVIDER_MASK 0x000000F0 // Mask for stream provider value - -#define STREAM_FLAG_READ_ONLY 0x00000100 // Stream is read only -#define STREAM_FLAG_WRITE_SHARE 0x00000200 // Allow write sharing when open for write -#define STREAM_FLAG_USE_BITMAP 0x00000400 // If the file has a file bitmap, load it and use it -#define STREAM_OPTIONS_MASK 0x0000FF00 // Mask for stream options - -#define STREAM_PROVIDERS_MASK 0x000000FF // Mask to get stream providers -#define STREAM_FLAGS_MASK 0x0000FFFF // Mask for all stream flags (providers+options) - -#define MPQ_OPEN_NO_LISTFILE 0x00010000 // Don't load the internal listfile -#define MPQ_OPEN_NO_ATTRIBUTES 0x00020000 // Don't open the attributes -#define MPQ_OPEN_NO_HEADER_SEARCH 0x00040000 // Don't search for the MPQ header past the begin of the file -#define MPQ_OPEN_FORCE_MPQ_V1 0x00080000 // Always open the archive as MPQ v 1.00, ignore the "wFormatVersion" variable in the header -#define MPQ_OPEN_CHECK_SECTOR_CRC 0x00100000 // On files with MPQ_FILE_SECTOR_CRC, the CRC will be checked when reading file -#define MPQ_OPEN_PATCH 0x00200000 // This archive is a patch MPQ. Used internally. -#define MPQ_OPEN_FORCE_LISTFILE 0x00400000 // Force add listfile even if there is none at the moment of opening -#define MPQ_OPEN_READ_ONLY STREAM_FLAG_READ_ONLY - -// Flags for SFileCreateArchive -#define MPQ_CREATE_LISTFILE 0x00100000 // Also add the (listfile) file -#define MPQ_CREATE_ATTRIBUTES 0x00200000 // Also add the (attributes) file -#define MPQ_CREATE_SIGNATURE 0x00400000 // Also add the (signature) file -#define MPQ_CREATE_ARCHIVE_V1 0x00000000 // Creates archive of version 1 (size up to 4GB) -#define MPQ_CREATE_ARCHIVE_V2 0x01000000 // Creates archive of version 2 (larger than 4 GB) -#define MPQ_CREATE_ARCHIVE_V3 0x02000000 // Creates archive of version 3 -#define MPQ_CREATE_ARCHIVE_V4 0x03000000 // Creates archive of version 4 -#define MPQ_CREATE_ARCHIVE_VMASK 0x0F000000 // Mask for archive version - -#define FLAGS_TO_FORMAT_SHIFT 24 // (MPQ_CREATE_ARCHIVE_V4 >> FLAGS_TO_FORMAT_SHIFT) => MPQ_FORMAT_VERSION_4 - -// Flags for SFileVerifyFile -#define SFILE_VERIFY_SECTOR_CRC 0x00000001 // Verify sector checksum for the file, if available -#define SFILE_VERIFY_FILE_CRC 0x00000002 // Verify file CRC, if available -#define SFILE_VERIFY_FILE_MD5 0x00000004 // Verify file MD5, if available -#define SFILE_VERIFY_RAW_MD5 0x00000008 // Verify raw file MD5, if available -#define SFILE_VERIFY_ALL 0x0000000F // Verify every checksum possible - -// Return values for SFileVerifyFile -#define VERIFY_OPEN_ERROR 0x0001 // Failed to open the file -#define VERIFY_READ_ERROR 0x0002 // Failed to read all data from the file -#define VERIFY_FILE_HAS_SECTOR_CRC 0x0004 // File has sector CRC -#define VERIFY_FILE_SECTOR_CRC_ERROR 0x0008 // Sector CRC check failed -#define VERIFY_FILE_HAS_CHECKSUM 0x0010 // File has CRC32 -#define VERIFY_FILE_CHECKSUM_ERROR 0x0020 // CRC32 check failed -#define VERIFY_FILE_HAS_MD5 0x0040 // File has data MD5 -#define VERIFY_FILE_MD5_ERROR 0x0080 // MD5 check failed -#define VERIFY_FILE_HAS_RAW_MD5 0x0100 // File has raw data MD5 -#define VERIFY_FILE_RAW_MD5_ERROR 0x0200 // Raw MD5 check failed -#define VERIFY_FILE_ERROR_MASK (VERIFY_OPEN_ERROR | VERIFY_READ_ERROR | VERIFY_FILE_SECTOR_CRC_ERROR | VERIFY_FILE_CHECKSUM_ERROR | VERIFY_FILE_MD5_ERROR | VERIFY_FILE_RAW_MD5_ERROR) - -// Flags for SFileVerifyRawData (for MPQs version 4.0 or higher) -#define SFILE_VERIFY_MPQ_HEADER 0x0001 // Verify raw MPQ header -#define SFILE_VERIFY_HET_TABLE 0x0002 // Verify raw data of the HET table -#define SFILE_VERIFY_BET_TABLE 0x0003 // Verify raw data of the BET table -#define SFILE_VERIFY_HASH_TABLE 0x0004 // Verify raw data of the hash table -#define SFILE_VERIFY_BLOCK_TABLE 0x0005 // Verify raw data of the block table -#define SFILE_VERIFY_HIBLOCK_TABLE 0x0006 // Verify raw data of the hi-block table -#define SFILE_VERIFY_FILE 0x0007 // Verify raw data of a file - -// Signature types -#define SIGNATURE_TYPE_NONE 0x0000 // The archive has no signature in it -#define SIGNATURE_TYPE_WEAK 0x0001 // The archive has weak signature -#define SIGNATURE_TYPE_STRONG 0x0002 // The archive has strong signature - -// Return values for SFileVerifyArchive -#define ERROR_NO_SIGNATURE 0 // There is no signature in the MPQ -#define ERROR_VERIFY_FAILED 1 // There was an error during verifying signature (like no memory) -#define ERROR_WEAK_SIGNATURE_OK 2 // There is a weak signature and sign check passed -#define ERROR_WEAK_SIGNATURE_ERROR 3 // There is a weak signature but sign check failed -#define ERROR_STRONG_SIGNATURE_OK 4 // There is a strong signature and sign check passed -#define ERROR_STRONG_SIGNATURE_ERROR 5 // There is a strong signature but sign check failed - -#ifndef MD5_DIGEST_SIZE -#define MD5_DIGEST_SIZE 0x10 -#endif - -#ifndef SHA1_DIGEST_SIZE -#define SHA1_DIGEST_SIZE 0x14 // 160 bits -#endif - -#ifndef LANG_NEUTRAL -#define LANG_NEUTRAL 0x00 // Neutral locale -#endif - -// Pointer to hashing function -typedef DWORD (*HASH_STRING)(const char * szFileName, DWORD dwHashType); - -//----------------------------------------------------------------------------- -// File information classes for SFileGetFileInfo and SFileFreeFileInfo - -typedef enum _SFileInfoClass -{ - // Info classes for archives - SFileMpqFileName, // Name of the archive file (TCHAR []) - SFileMpqStreamBitmap, // Array of bits, each bit means availability of one block (BYTE []) - SFileMpqUserDataOffset, // Offset of the user data header (ULONGLONG) - SFileMpqUserDataHeader, // Raw (unfixed) user data header (TMPQUserData) - SFileMpqUserData, // MPQ USer data, without the header (BYTE []) - SFileMpqHeaderOffset, // Offset of the MPQ header (ULONGLONG) - SFileMpqHeaderSize, // Fixed size of the MPQ header - SFileMpqHeader, // Raw (unfixed) archive header (TMPQHeader) - SFileMpqHetTableOffset, // Offset of the HET table, relative to MPQ header (ULONGLONG) - SFileMpqHetTableSize, // Compressed size of the HET table (ULONGLONG) - SFileMpqHetHeader, // HET table header (TMPQHetHeader) - SFileMpqHetTable, // HET table as pointer. Must be freed using SFileFreeFileInfo - SFileMpqBetTableOffset, // Offset of the BET table, relative to MPQ header (ULONGLONG) - SFileMpqBetTableSize, // Compressed size of the BET table (ULONGLONG) - SFileMpqBetHeader, // BET table header, followed by the flags (TMPQBetHeader + DWORD[]) - SFileMpqBetTable, // BET table as pointer. Must be freed using SFileFreeFileInfo - SFileMpqHashTableOffset, // Hash table offset, relative to MPQ header (ULONGLONG) - SFileMpqHashTableSize64, // Compressed size of the hash table (ULONGLONG) - SFileMpqHashTableSize, // Size of the hash table, in entries (DWORD) - SFileMpqHashTable, // Raw (unfixed) hash table (TMPQBlock []) - SFileMpqBlockTableOffset, // Block table offset, relative to MPQ header (ULONGLONG) - SFileMpqBlockTableSize64, // Compressed size of the block table (ULONGLONG) - SFileMpqBlockTableSize, // Size of the block table, in entries (DWORD) - SFileMpqBlockTable, // Raw (unfixed) block table (TMPQBlock []) - SFileMpqHiBlockTableOffset, // Hi-block table offset, relative to MPQ header (ULONGLONG) - SFileMpqHiBlockTableSize64, // Compressed size of the hi-block table (ULONGLONG) - SFileMpqHiBlockTable, // The hi-block table (USHORT []) - SFileMpqSignatures, // Signatures present in the MPQ (DWORD) - SFileMpqStrongSignatureOffset, // Byte offset of the strong signature, relative to begin of the file (ULONGLONG) - SFileMpqStrongSignatureSize, // Size of the strong signature (DWORD) - SFileMpqStrongSignature, // The strong signature (BYTE []) - SFileMpqArchiveSize64, // Archive size from the header (ULONGLONG) - SFileMpqArchiveSize, // Archive size from the header (DWORD) - SFileMpqMaxFileCount, // Max number of files in the archive (DWORD) - SFileMpqFileTableSize, // Number of entries in the file table (DWORD) - SFileMpqSectorSize, // Sector size (DWORD) - SFileMpqNumberOfFiles, // Number of files (DWORD) - SFileMpqRawChunkSize, // Size of the raw data chunk for MD5 - SFileMpqStreamFlags, // Stream flags (DWORD) - SFileMpqFlags, // Nonzero if the MPQ is read only (DWORD) - - // Info classes for files - SFileInfoPatchChain, // Chain of patches where the file is (TCHAR []) - SFileInfoFileEntry, // The file entry for the file (TFileEntry) - SFileInfoHashEntry, // Hash table entry for the file (TMPQHash) - SFileInfoHashIndex, // Index of the hash table entry (DWORD) - SFileInfoNameHash1, // The first name hash in the hash table (DWORD) - SFileInfoNameHash2, // The second name hash in the hash table (DWORD) - SFileInfoNameHash3, // 64-bit file name hash for the HET/BET tables (ULONGLONG) - SFileInfoLocale, // File locale (DWORD) - SFileInfoFileIndex, // Block index (DWORD) - SFileInfoByteOffset, // File position in the archive (ULONGLONG) - SFileInfoFileTime, // File time (ULONGLONG) - SFileInfoFileSize, // Size of the file (DWORD) - SFileInfoCompressedSize, // Compressed file size (DWORD) - SFileInfoFlags, // File flags from (DWORD) - SFileInfoEncryptionKey, // File encryption key - SFileInfoEncryptionKeyRaw, // Unfixed value of the file key - SFileInfoCRC32, // CRC32 of the file -} SFileInfoClass; - -//----------------------------------------------------------------------------- -// Callback functions - -// Values for compact callback -#define CCB_CHECKING_FILES 1 // Checking archive (dwParam1 = current, dwParam2 = total) -#define CCB_CHECKING_HASH_TABLE 2 // Checking hash table (dwParam1 = current, dwParam2 = total) -#define CCB_COPYING_NON_MPQ_DATA 3 // Copying non-MPQ data: No params used -#define CCB_COMPACTING_FILES 4 // Compacting archive (dwParam1 = current, dwParam2 = total) -#define CCB_CLOSING_ARCHIVE 5 // Closing archive: No params used - -typedef void (WINAPI * SFILE_DOWNLOAD_CALLBACK)(void * pvUserData, ULONGLONG ByteOffset, DWORD dwTotalBytes); -typedef void (WINAPI * SFILE_ADDFILE_CALLBACK)(void * pvUserData, DWORD dwBytesWritten, DWORD dwTotalBytes, bool bFinalCall); -typedef void (WINAPI * SFILE_COMPACT_CALLBACK)(void * pvUserData, DWORD dwWorkType, ULONGLONG BytesProcessed, ULONGLONG TotalBytes); - -typedef struct TFileStream TFileStream; - -//----------------------------------------------------------------------------- -// Structure for bit arrays used for HET and BET tables - -typedef struct _TBitArray -{ - DWORD NumberOfBytes; // Total number of bytes in "Elements" - DWORD NumberOfBits; // Total number of bits that are available - BYTE Elements[1]; // Array of elements (variable length) -} TBitArray; - -void GetBits(TBitArray * array, unsigned int nBitPosition, unsigned int nBitLength, void * pvBuffer, int nResultSize); -void SetBits(TBitArray * array, unsigned int nBitPosition, unsigned int nBitLength, void * pvBuffer, int nResultSize); - -//----------------------------------------------------------------------------- -// Structures related to MPQ format -// -// Note: All structures in this header file are supposed to remain private -// to StormLib. The structures may (and will) change over time, as the MPQ -// file format evolves. Programmers directly using these structures need to -// be aware of this. And the last, but not least, NEVER do any modifications -// to those structures directly, always use SFile* functions. -// - -#define MPQ_HEADER_SIZE_V1 0x20 -#define MPQ_HEADER_SIZE_V2 0x2C -#define MPQ_HEADER_SIZE_V3 0x44 -#define MPQ_HEADER_SIZE_V4 0xD0 -#define MPQ_HEADER_DWORDS (MPQ_HEADER_SIZE_V4 / 0x04) - -typedef struct _TMPQUserData -{ - // The ID_MPQ_USERDATA ('MPQ\x1B') signature - DWORD dwID; - - // Maximum size of the user data - DWORD cbUserDataSize; - - // Offset of the MPQ header, relative to the begin of this header - DWORD dwHeaderOffs; - - // Appears to be size of user data header (Starcraft II maps) - DWORD cbUserDataHeader; -} TMPQUserData; - -// MPQ file header -// -// We have to make sure that the header is packed OK. -// Reason: A 64-bit integer at the beginning of 3.0 part, -// which is offset 0x2C -#pragma pack(push, 1) -typedef struct _TMPQHeader -{ - // The ID_MPQ ('MPQ\x1A') signature - DWORD dwID; - - // Size of the archive header - DWORD dwHeaderSize; - - // 32-bit size of MPQ archive - // This field is deprecated in the Burning Crusade MoPaQ format, and the size of the archive - // is calculated as the size from the beginning of the archive to the end of the hash table, - // block table, or hi-block table (whichever is largest). - DWORD dwArchiveSize; - - // 0 = Format 1 (up to The Burning Crusade) - // 1 = Format 2 (The Burning Crusade and newer) - // 2 = Format 3 (WoW - Cataclysm beta or newer) - // 3 = Format 4 (WoW - Cataclysm beta or newer) - USHORT wFormatVersion; - - // Power of two exponent specifying the number of 512-byte disk sectors in each file sector - // in the archive. The size of each file sector in the archive is 512 * 2 ^ wSectorSize. - USHORT wSectorSize; - - // Offset to the beginning of the hash table, relative to the beginning of the archive. - DWORD dwHashTablePos; - - // Offset to the beginning of the block table, relative to the beginning of the archive. - DWORD dwBlockTablePos; - - // Number of entries in the hash table. Must be a power of two, and must be less than 2^16 for - // the original MoPaQ format, or less than 2^20 for the Burning Crusade format. - DWORD dwHashTableSize; - - // Number of entries in the block table - DWORD dwBlockTableSize; - - //-- MPQ HEADER v 2 ------------------------------------------- - - // Offset to the beginning of array of 16-bit high parts of file offsets. - ULONGLONG HiBlockTablePos64; - - // High 16 bits of the hash table offset for large archives. - USHORT wHashTablePosHi; - - // High 16 bits of the block table offset for large archives. - USHORT wBlockTablePosHi; - - //-- MPQ HEADER v 3 ------------------------------------------- - - // 64-bit version of the archive size - ULONGLONG ArchiveSize64; - - // 64-bit position of the BET table - ULONGLONG BetTablePos64; - - // 64-bit position of the HET table - ULONGLONG HetTablePos64; - - //-- MPQ HEADER v 4 ------------------------------------------- - - // Compressed size of the hash table - ULONGLONG HashTableSize64; - - // Compressed size of the block table - ULONGLONG BlockTableSize64; - - // Compressed size of the hi-block table - ULONGLONG HiBlockTableSize64; - - // Compressed size of the HET block - ULONGLONG HetTableSize64; - - // Compressed size of the BET block - ULONGLONG BetTableSize64; - - // Size of raw data chunk to calculate MD5. - // MD5 of each data chunk follows the raw file data. - DWORD dwRawChunkSize; - - // MD5 of MPQ tables - unsigned char MD5_BlockTable[MD5_DIGEST_SIZE]; // MD5 of the block table before decryption - unsigned char MD5_HashTable[MD5_DIGEST_SIZE]; // MD5 of the hash table before decryption - unsigned char MD5_HiBlockTable[MD5_DIGEST_SIZE]; // MD5 of the hi-block table - unsigned char MD5_BetTable[MD5_DIGEST_SIZE]; // MD5 of the BET table before decryption - unsigned char MD5_HetTable[MD5_DIGEST_SIZE]; // MD5 of the HET table before decryption - unsigned char MD5_MpqHeader[MD5_DIGEST_SIZE]; // MD5 of the MPQ header from signature to (including) MD5_HetTable -} TMPQHeader; -#pragma pack(pop) - -// Hash table entry. All files in the archive are searched by their hashes. -typedef struct _TMPQHash -{ - // The hash of the file path, using method A. - DWORD dwName1; - - // The hash of the file path, using method B. - DWORD dwName2; - -#ifdef PLATFORM_LITTLE_ENDIAN - - // The language of the file. This is a Windows LANGID data type, and uses the same values. - // 0 indicates the default language (American English), or that the file is language-neutral. - USHORT lcLocale; - - // The platform the file is used for. 0 indicates the default platform. - // No other values have been observed. - BYTE Platform; - BYTE Reserved; - -#else - - BYTE Platform; - BYTE Reserved; - USHORT lcLocale; - -#endif - - // If the hash table entry is valid, this is the index into the block table of the file. - // Otherwise, one of the following two values: - // - FFFFFFFFh: Hash table entry is empty, and has always been empty. - // Terminates searches for a given file. - // - FFFFFFFEh: Hash table entry is empty, but was valid at some point (a deleted file). - // Does not terminate searches for a given file. - DWORD dwBlockIndex; -} TMPQHash; - -// File description block contains informations about the file -typedef struct _TMPQBlock -{ - // Offset of the beginning of the file, relative to the beginning of the archive. - DWORD dwFilePos; - - // Compressed file size - DWORD dwCSize; - - // Only valid if the block is a file; otherwise meaningless, and should be 0. - // If the file is compressed, this is the size of the uncompressed file data. - DWORD dwFSize; - - // Flags for the file. See MPQ_FILE_XXXX constants - DWORD dwFlags; -} TMPQBlock; - -// Patch file information, preceding the sector offset table -typedef struct _TPatchInfo -{ - DWORD dwLength; // Length of patch info header, in bytes - DWORD dwFlags; // Flags. 0x80000000 = MD5 (?) - DWORD dwDataSize; // Uncompressed size of the patch file - BYTE md5[0x10]; // MD5 of the entire patch file after decompression - - // Followed by the sector table (variable length) -} TPatchInfo; - -// This is the combined file entry for maintaining file list in the MPQ. -// This structure is combined from block table, hi-block table, -// (attributes) file and from (listfile). -typedef struct _TFileEntry -{ - ULONGLONG FileNameHash; // Jenkins hash of the file name. Only used when the MPQ has BET table. - ULONGLONG ByteOffset; // Position of the file content in the MPQ, relative to the MPQ header - ULONGLONG FileTime; // FileTime from the (attributes) file. 0 if not present. - DWORD dwFileSize; // Decompressed size of the file - DWORD dwCmpSize; // Compressed size of the file (i.e., size of the file data in the MPQ) - DWORD dwFlags; // File flags (from block table) - DWORD dwCrc32; // CRC32 from (attributes) file. 0 if not present. - BYTE md5[MD5_DIGEST_SIZE]; // File MD5 from the (attributes) file. 0 if not present. - char * szFileName; // File name. NULL if not known. -} TFileEntry; - -// Common header for HET and BET tables -typedef struct _TMPQExtHeader -{ - DWORD dwSignature; // 'HET\x1A' or 'BET\x1A' - DWORD dwVersion; // Version. Seems to be always 1 - DWORD dwDataSize; // Size of the contained table - - // Followed by the table header - // Followed by the table data - -} TMPQExtHeader; - -// Structure for HET table header -typedef struct _TMPQHetHeader -{ - TMPQExtHeader ExtHdr; - - DWORD dwTableSize; // Size of the entire HET table, including HET_TABLE_HEADER (in bytes) - DWORD dwEntryCount; // Number of occupied entries in the HET table - DWORD dwTotalCount; // Total number of entries in the HET table - DWORD dwNameHashBitSize; // Size of the name hash entry (in bits) - DWORD dwIndexSizeTotal; // Total size of file index (in bits) - DWORD dwIndexSizeExtra; // Extra bits in the file index - DWORD dwIndexSize; // Effective size of the file index (in bits) - DWORD dwIndexTableSize; // Size of the block index subtable (in bytes) - -} TMPQHetHeader; - -// Structure for BET table header -typedef struct _TMPQBetHeader -{ - TMPQExtHeader ExtHdr; - - DWORD dwTableSize; // Size of the entire BET table, including the header (in bytes) - DWORD dwEntryCount; // Number of entries in the BET table. Must match HET_TABLE_HEADER::dwEntryCount - DWORD dwUnknown08; - DWORD dwTableEntrySize; // Size of one table entry (in bits) - DWORD dwBitIndex_FilePos; // Bit index of the file position (within the entry record) - DWORD dwBitIndex_FileSize; // Bit index of the file size (within the entry record) - DWORD dwBitIndex_CmpSize; // Bit index of the compressed size (within the entry record) - DWORD dwBitIndex_FlagIndex; // Bit index of the flag index (within the entry record) - DWORD dwBitIndex_Unknown; // Bit index of the ??? (within the entry record) - DWORD dwBitCount_FilePos; // Bit size of file position (in the entry record) - DWORD dwBitCount_FileSize; // Bit size of file size (in the entry record) - DWORD dwBitCount_CmpSize; // Bit size of compressed file size (in the entry record) - DWORD dwBitCount_FlagIndex; // Bit size of flags index (in the entry record) - DWORD dwBitCount_Unknown; // Bit size of ??? (in the entry record) - DWORD dwBitTotal_NameHash2; // Total bit size of the NameHash2 - DWORD dwBitExtra_NameHash2; // Extra bits in the NameHash2 - DWORD dwBitCount_NameHash2; // Effective size of NameHash2 (in bits) - DWORD dwNameHashArraySize; // Size of NameHash2 table, in bytes - DWORD dwFlagCount; // Number of flags in the following array - -} TMPQBetHeader; - -// Structure for parsed HET table -typedef struct _TMPQHetTable -{ - TBitArray * pBetIndexes; // Bit array of FileIndex values - LPBYTE pNameHashes; // Array of NameHash1 values (NameHash1 = upper 8 bits of FileName hashe) - ULONGLONG AndMask64; // AND mask used for calculating file name hash - ULONGLONG OrMask64; // OR mask used for setting the highest bit of the file name hash - - DWORD dwEntryCount; // Number of occupied entries in the HET table - DWORD dwTotalCount; // Number of entries in both NameHash and FileIndex table - DWORD dwNameHashBitSize; // Size of the name hash entry (in bits) - DWORD dwIndexSizeTotal; // Total size of one entry in pBetIndexes (in bits) - DWORD dwIndexSizeExtra; // Extra bits in the entry in pBetIndexes - DWORD dwIndexSize; // Effective size of one entry in pBetIndexes (in bits) -} TMPQHetTable; - -// Structure for parsed BET table -typedef struct _TMPQBetTable -{ - TBitArray * pNameHashes; // Array of NameHash2 entries (lower 24 bits of FileName hash) - TBitArray * pFileTable; // Bit-based file table - LPDWORD pFileFlags; // Array of file flags - - DWORD dwTableEntrySize; // Size of one table entry, in bits - DWORD dwBitIndex_FilePos; // Bit index of the file position in the table entry - DWORD dwBitIndex_FileSize; // Bit index of the file size in the table entry - DWORD dwBitIndex_CmpSize; // Bit index of the compressed size in the table entry - DWORD dwBitIndex_FlagIndex; // Bit index of the flag index in the table entry - DWORD dwBitIndex_Unknown; // Bit index of ??? in the table entry - DWORD dwBitCount_FilePos; // Size of file offset (in bits) within table entry - DWORD dwBitCount_FileSize; // Size of file size (in bits) within table entry - DWORD dwBitCount_CmpSize; // Size of compressed file size (in bits) within table entry - DWORD dwBitCount_FlagIndex; // Size of flag index (in bits) within table entry - DWORD dwBitCount_Unknown; // Size of ??? (in bits) within table entry - DWORD dwBitTotal_NameHash2; // Total size of the NameHash2 - DWORD dwBitExtra_NameHash2; // Extra bits in the NameHash2 - DWORD dwBitCount_NameHash2; // Effective size of the NameHash2 - DWORD dwEntryCount; // Number of entries - DWORD dwFlagCount; // Number of file flags in pFileFlags -} TMPQBetTable; - -// Structure for patch prefix -typedef struct _TMPQNamePrefix -{ - size_t nLength; // Length of this patch prefix. Can be 0 - char szPatchPrefix[1]; // Patch name prefix (variable length). If not empty, it always starts with backslash. -} TMPQNamePrefix; - -// Structure for name cache -typedef struct _TMPQNameCache -{ - DWORD FirstNameOffset; // Offset of the first name in the name list (in bytes) - DWORD FreeSpaceOffset; // Offset of the first free byte in the name cache (in bytes) - DWORD TotalCacheSize; // Size, in bytes, of the cache. Includes wildcard - DWORD SearchOffset; // Used by SListFileFindFirstFile - - // Followed by search mask (ASCIIZ, '\0' if none) - // Followed by name cache (ANSI multistring) - -} TMPQNameCache; - -// Archive handle structure -typedef struct _TMPQArchive -{ - TFileStream * pStream; // Open stream for the MPQ - - ULONGLONG UserDataPos; // Position of user data (relative to the begin of the file) - ULONGLONG MpqPos; // MPQ header offset (relative to the begin of the file) - ULONGLONG FileSize; // Size of the file at the moment of file open - - struct _TMPQArchive * haPatch; // Pointer to patch archive, if any - struct _TMPQArchive * haBase; // Pointer to base ("previous version") archive, if any - TMPQNamePrefix * pPatchPrefix; // Patch prefix to precede names of patch files - - TMPQUserData * pUserData; // MPQ user data (NULL if not present in the file) - TMPQHeader * pHeader; // MPQ file header - TMPQHash * pHashTable; // Hash table - TMPQHetTable * pHetTable; // HET table - TFileEntry * pFileTable; // File table - HASH_STRING pfnHashString; // Hashing function that will convert the file name into hash - - TMPQUserData UserData; // MPQ user data. Valid only when ID_MPQ_USERDATA has been found - DWORD HeaderData[MPQ_HEADER_DWORDS]; // Storage for MPQ header - - DWORD dwHETBlockSize; - DWORD dwBETBlockSize; - DWORD dwMaxFileCount; // Maximum number of files in the MPQ. Also total size of the file table. - DWORD dwFileTableSize; // Current size of the file table, e.g. index of the entry past the last occupied one - DWORD dwReservedFiles; // Number of entries reserved for internal MPQ files (listfile, attributes) - DWORD dwSectorSize; // Default size of one file sector - DWORD dwFileFlags1; // Flags for (listfile) - DWORD dwFileFlags2; // Flags for (attributes) - DWORD dwFileFlags3; // Flags for (signature) - DWORD dwAttrFlags; // Flags for the (attributes) file, see MPQ_ATTRIBUTE_XXX - DWORD dwFlags; // See MPQ_FLAG_XXXXX - DWORD dwSubType; // See MPQ_SUBTYPE_XXX - - SFILE_ADDFILE_CALLBACK pfnAddFileCB; // Callback function for adding files - void * pvAddFileUserData; // User data thats passed to the callback - - SFILE_COMPACT_CALLBACK pfnCompactCB; // Callback function for compacting the archive - ULONGLONG CompactBytesProcessed; // Amount of bytes that have been processed during a particular compact call - ULONGLONG CompactTotalBytes; // Total amount of bytes to be compacted - void * pvCompactUserData; // User data thats passed to the callback -} TMPQArchive; - -// File handle structure -typedef struct _TMPQFile -{ - TFileStream * pStream; // File stream. Only used on local files - TMPQArchive * ha; // Archive handle - TMPQHash * pHashEntry; // Pointer to hash table entry, if the file was open using hash table - TFileEntry * pFileEntry; // File entry for the file - ULONGLONG RawFilePos; // Offset in MPQ archive (relative to file begin) - ULONGLONG MpqFilePos; // Offset in MPQ archive (relative to MPQ header) - DWORD dwHashIndex; // Hash table index (0xFFFFFFFF if not used) - DWORD dwFileKey; // Decryption key - DWORD dwFilePos; // Current file position - DWORD dwMagic; // 'FILE' - - struct _TMPQFile * hfPatch; // Pointer to opened patch file - - TPatchInfo * pPatchInfo; // Patch info block, preceding the sector table - LPDWORD SectorOffsets; // Position of each file sector, relative to the begin of the file. Only for compressed files. - LPDWORD SectorChksums; // Array of sector checksums (either ADLER32 or MD5) values for each file sector - LPBYTE pbFileData; // Data of the file (single unit files, patched files) - DWORD cbFileData; // Size of file data - DWORD dwCompression0; // Compression that will be used on the first file sector - DWORD dwSectorCount; // Number of sectors in the file - DWORD dwPatchedFileSize; // Size of patched file. Used when saving patch file to the MPQ - DWORD dwDataSize; // Size of data in the file (on patch files, this differs from file size in block table entry) - - LPBYTE pbFileSector; // Last loaded file sector. For single unit files, entire file content - DWORD dwSectorOffs; // File position of currently loaded file sector - DWORD dwSectorSize; // Size of the file sector. For single unit files, this is equal to the file size - - unsigned char hctx[HASH_STATE_SIZE]; // Hash state for MD5. Used when saving file to MPQ - DWORD dwCrc32; // CRC32 value, used when saving file to MPQ - - int nAddFileError; // Result of the "Add File" operations - - bool bLoadedSectorCRCs; // If true, we already tried to load sector CRCs - bool bCheckSectorCRCs; // If true, then SFileReadFile will check sector CRCs when reading the file - bool bIsWriteHandle; // If true, this handle has been created by SFileCreateFile -} TMPQFile; - -// Structure for SFileFindFirstFile and SFileFindNextFile -typedef struct _SFILE_FIND_DATA -{ - char cFileName[MAX_PATH]; // Full name of the found file - char * szPlainName; // Plain name of the found file - DWORD dwHashIndex; // Hash table index for the file (HAH_ENTRY_FREE if no hash table) - DWORD dwBlockIndex; // Block table index for the file - DWORD dwFileSize; // File size in bytes - DWORD dwFileFlags; // MPQ file flags - DWORD dwCompSize; // Compressed file size - DWORD dwFileTimeLo; // Low 32-bits of the file time (0 if not present) - DWORD dwFileTimeHi; // High 32-bits of the file time (0 if not present) - LCID lcLocale; // Locale version - -} SFILE_FIND_DATA, *PSFILE_FIND_DATA; - -typedef struct _SFILE_CREATE_MPQ -{ - DWORD cbSize; // Size of this structure, in bytes - DWORD dwMpqVersion; // Version of the MPQ to be created - void *pvUserData; // Reserved, must be NULL - DWORD cbUserData; // Reserved, must be 0 - DWORD dwStreamFlags; // Stream flags for creating the MPQ - DWORD dwFileFlags1; // File flags for (listfile). Use MPQ_FILE_DEFAULT_INTERNAL to set default flags - DWORD dwFileFlags2; // File flags for (attributes). Use MPQ_FILE_DEFAULT_INTERNAL to set default flags - DWORD dwFileFlags3; // File flags for (signature). Use MPQ_FILE_DEFAULT_INTERNAL to set default flags - DWORD dwAttrFlags; // Flags for the (attributes) file. If 0, no attributes will be created - DWORD dwSectorSize; // Sector size for compressed files - DWORD dwRawChunkSize; // Size of raw data chunk - DWORD dwMaxFileCount; // File limit for the MPQ - -} SFILE_CREATE_MPQ, *PSFILE_CREATE_MPQ; - -//----------------------------------------------------------------------------- -// Stream support - functions - -// Structure used by FileStream_GetBitmap -typedef struct _TStreamBitmap -{ - ULONGLONG StreamSize; // Size of the stream, in bytes - DWORD BitmapSize; // Size of the block map, in bytes - DWORD BlockCount; // Number of blocks in the stream - DWORD BlockSize; // Size of one block - DWORD IsComplete; // Nonzero if the file is complete - - // Followed by the BYTE array, each bit means availability of one block - -} TStreamBitmap; - -// UNICODE versions of the file access functions -TFileStream * FileStream_CreateFile(const TCHAR * szFileName, DWORD dwStreamFlags); -TFileStream * FileStream_OpenFile(const TCHAR * szFileName, DWORD dwStreamFlags); -const TCHAR * FileStream_GetFileName(TFileStream * pStream); -size_t FileStream_Prefix(const TCHAR * szFileName, DWORD * pdwProvider); - -bool FileStream_SetCallback(TFileStream * pStream, SFILE_DOWNLOAD_CALLBACK pfnCallback, void * pvUserData); - -bool FileStream_GetBitmap(TFileStream * pStream, void * pvBitmap, DWORD cbBitmap, LPDWORD pcbLengthNeeded); -bool FileStream_Read(TFileStream * pStream, ULONGLONG * pByteOffset, void * pvBuffer, DWORD dwBytesToRead); -bool FileStream_Write(TFileStream * pStream, ULONGLONG * pByteOffset, const void * pvBuffer, DWORD dwBytesToWrite); -bool FileStream_SetSize(TFileStream * pStream, ULONGLONG NewFileSize); -bool FileStream_GetSize(TFileStream * pStream, ULONGLONG * pFileSize); -bool FileStream_GetPos(TFileStream * pStream, ULONGLONG * pByteOffset); -bool FileStream_GetTime(TFileStream * pStream, ULONGLONG * pFT); -bool FileStream_GetFlags(TFileStream * pStream, LPDWORD pdwStreamFlags); -bool FileStream_Replace(TFileStream * pStream, TFileStream * pNewStream); -void FileStream_Close(TFileStream * pStream); - -//----------------------------------------------------------------------------- -// Functions prototypes for Storm.dll - -// Typedefs for functions exported by Storm.dll -typedef LCID (WINAPI * SFILESETLOCALE)(LCID); -typedef bool (WINAPI * SFILEOPENARCHIVE)(const char *, DWORD, DWORD, HANDLE *); -typedef bool (WINAPI * SFILECLOSEARCHIVE)(HANDLE); -typedef bool (WINAPI * SFILEOPENFILEEX)(HANDLE, const char *, DWORD, HANDLE *); -typedef bool (WINAPI * SFILECLOSEFILE)(HANDLE); -typedef DWORD (WINAPI * SFILEGETFILESIZE)(HANDLE, LPDWORD); -typedef DWORD (WINAPI * SFILESETFILEPOINTER)(HANDLE, LONG, LONG *, DWORD); -typedef bool (WINAPI * SFILEREADFILE)(HANDLE, void *, DWORD, LPDWORD, LPOVERLAPPED); - -//----------------------------------------------------------------------------- -// Functions for manipulation with StormLib global flags - -LCID WINAPI SFileGetLocale(); -LCID WINAPI SFileSetLocale(LCID lcNewLocale); - -//----------------------------------------------------------------------------- -// Functions for archive manipulation - -bool WINAPI SFileOpenArchive(const TCHAR * szMpqName, DWORD dwPriority, DWORD dwFlags, HANDLE * phMpq); -bool WINAPI SFileCreateArchive(const TCHAR * szMpqName, DWORD dwCreateFlags, DWORD dwMaxFileCount, HANDLE * phMpq); -bool WINAPI SFileCreateArchive2(const TCHAR * szMpqName, PSFILE_CREATE_MPQ pCreateInfo, HANDLE * phMpq); - -bool WINAPI SFileSetDownloadCallback(HANDLE hMpq, SFILE_DOWNLOAD_CALLBACK DownloadCB, void * pvUserData); -bool WINAPI SFileFlushArchive(HANDLE hMpq); -bool WINAPI SFileCloseArchive(HANDLE hMpq); - -// Adds another listfile into MPQ. The currently added listfile(s) remain, -// so you can use this API to combining more listfiles. -// Note that this function is internally called by SFileFindFirstFile -int WINAPI SFileAddListFile(HANDLE hMpq, const TCHAR * szListFile); - -// Archive compacting -bool WINAPI SFileSetCompactCallback(HANDLE hMpq, SFILE_COMPACT_CALLBACK CompactCB, void * pvUserData); -bool WINAPI SFileCompactArchive(HANDLE hMpq, const TCHAR * szListFile, bool bReserved); - -// Changing the maximum file count -DWORD WINAPI SFileGetMaxFileCount(HANDLE hMpq); -bool WINAPI SFileSetMaxFileCount(HANDLE hMpq, DWORD dwMaxFileCount); - -// Changing (attributes) file -DWORD WINAPI SFileGetAttributes(HANDLE hMpq); -bool WINAPI SFileSetAttributes(HANDLE hMpq, DWORD dwFlags); -bool WINAPI SFileUpdateFileAttributes(HANDLE hMpq, const char * szFileName); - -//----------------------------------------------------------------------------- -// Functions for manipulation with patch archives - -bool WINAPI SFileOpenPatchArchive(HANDLE hMpq, const TCHAR * szPatchMpqName, const char * szPatchPathPrefix, DWORD dwFlags); -bool WINAPI SFileIsPatchedArchive(HANDLE hMpq); - -//----------------------------------------------------------------------------- -// Functions for file manipulation - -// Reading from MPQ file -bool WINAPI SFileHasFile(HANDLE hMpq, const char * szFileName); -bool WINAPI SFileOpenFileEx(HANDLE hMpq, const char * szFileName, DWORD dwSearchScope, HANDLE * phFile); -DWORD WINAPI SFileGetFileSize(HANDLE hFile, LPDWORD pdwFileSizeHigh); -DWORD WINAPI SFileSetFilePointer(HANDLE hFile, LONG lFilePos, LONG * plFilePosHigh, DWORD dwMoveMethod); -bool WINAPI SFileReadFile(HANDLE hFile, void * lpBuffer, DWORD dwToRead, LPDWORD pdwRead, LPOVERLAPPED lpOverlapped); -bool WINAPI SFileCloseFile(HANDLE hFile); - -// Retrieving info about a file in the archive -bool WINAPI SFileGetFileInfo(HANDLE hMpqOrFile, SFileInfoClass InfoClass, void * pvFileInfo, DWORD cbFileInfo, LPDWORD pcbLengthNeeded); -bool WINAPI SFileGetFileName(HANDLE hFile, char * szFileName); -bool WINAPI SFileFreeFileInfo(void * pvFileInfo, SFileInfoClass InfoClass); - -// High-level extract function -bool WINAPI SFileExtractFile(HANDLE hMpq, const char * szToExtract, const TCHAR * szExtracted, DWORD dwSearchScope); - -//----------------------------------------------------------------------------- -// Functions for file and archive verification - -// Generates file CRC32 -bool WINAPI SFileGetFileChecksums(HANDLE hMpq, const char * szFileName, LPDWORD pdwCrc32, char * pMD5); - -// Verifies file against its checksums stored in (attributes) attributes (depending on dwFlags). -// For dwFlags, use one or more of MPQ_ATTRIBUTE_MD5 -DWORD WINAPI SFileVerifyFile(HANDLE hMpq, const char * szFileName, DWORD dwFlags); - -// Verifies raw data of the archive. Only works for MPQs version 4 or newer -int WINAPI SFileVerifyRawData(HANDLE hMpq, DWORD dwWhatToVerify, const char * szFileName); - -// Verifies the signature, if present -bool WINAPI SFileSignArchive(HANDLE hMpq, DWORD dwSignatureType); -DWORD WINAPI SFileVerifyArchive(HANDLE hMpq); - -//----------------------------------------------------------------------------- -// Functions for file searching - -HANDLE WINAPI SFileFindFirstFile(HANDLE hMpq, const char * szMask, SFILE_FIND_DATA * lpFindFileData, const TCHAR * szListFile); -bool WINAPI SFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData); -bool WINAPI SFileFindClose(HANDLE hFind); - -HANDLE WINAPI SListFileFindFirstFile(HANDLE hMpq, const TCHAR * szListFile, const char * szMask, SFILE_FIND_DATA * lpFindFileData); -bool WINAPI SListFileFindNextFile(HANDLE hFind, SFILE_FIND_DATA * lpFindFileData); -bool WINAPI SListFileFindClose(HANDLE hFind); - -// Locale support -int WINAPI SFileEnumLocales(HANDLE hMpq, const char * szFileName, LCID * plcLocales, LPDWORD pdwMaxLocales, DWORD dwSearchScope); - -//----------------------------------------------------------------------------- -// Support for adding files to the MPQ - -bool WINAPI SFileCreateFile(HANDLE hMpq, const char * szArchivedName, ULONGLONG FileTime, DWORD dwFileSize, LCID lcLocale, DWORD dwFlags, HANDLE * phFile); -bool WINAPI SFileWriteFile(HANDLE hFile, const void * pvData, DWORD dwSize, DWORD dwCompression); -bool WINAPI SFileFinishFile(HANDLE hFile); - -bool WINAPI SFileAddFileEx(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwCompression, DWORD dwCompressionNext = MPQ_COMPRESSION_NEXT_SAME); -bool WINAPI SFileAddFile(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags); -bool WINAPI SFileAddWave(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality); -bool WINAPI SFileRemoveFile(HANDLE hMpq, const char * szFileName, DWORD dwSearchScope); -bool WINAPI SFileRenameFile(HANDLE hMpq, const char * szOldFileName, const char * szNewFileName); -bool WINAPI SFileSetFileLocale(HANDLE hFile, LCID lcNewLocale); -bool WINAPI SFileSetDataCompression(DWORD DataCompression); - -bool WINAPI SFileSetAddFileCallback(HANDLE hMpq, SFILE_ADDFILE_CALLBACK AddFileCB, void * pvUserData); - -//----------------------------------------------------------------------------- -// Compression and decompression - -int WINAPI SCompImplode (void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer); -int WINAPI SCompExplode (void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer); -int WINAPI SCompCompress (void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer, unsigned uCompressionMask, int nCmpType, int nCmpLevel); -int WINAPI SCompDecompress (void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer); -int WINAPI SCompDecompress2(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer); - -//----------------------------------------------------------------------------- -// Non-Windows support for SetLastError/GetLastError - -#ifndef PLATFORM_WINDOWS - -void SetLastError(DWORD dwErrCode); -DWORD GetLastError(); - -#endif - -//----------------------------------------------------------------------------- -// Functions from Storm.dll. They use slightly different names for keeping -// possibility to use them together with StormLib (StormXXX instead of SFileXXX) - -#ifdef __LINK_STORM_DLL__ - #define STORM_ALTERNATE_NAMES // Force storm_dll.h to use alternate fnc names - #include "..\storm_dll\storm_dll.h" -#endif // __LINK_STORM_DLL__ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // __STORMLIB_H__ diff --git a/libs/storm-sys/StormLib/src/StormPort.h b/libs/storm-sys/StormLib/src/StormPort.h deleted file mode 100644 index fd74e69..0000000 --- a/libs/storm-sys/StormLib/src/StormPort.h +++ /dev/null @@ -1,300 +0,0 @@ -/*****************************************************************************/ -/* StormPort.h Copyright (c) Marko Friedemann 2001 */ -/*---------------------------------------------------------------------------*/ -/* Portability module for the StormLib library. Contains a wrapper symbols */ -/* to make the compilation under Linux work */ -/* */ -/* Author: Marko Friedemann */ -/* Created at: Mon Jan 29 18:26:01 CEST 2001 */ -/* Computer: whiplash.flachland-chemnitz.de */ -/* System: Linux 2.4.0 on i686 */ -/* */ -/* Author: Sam Wilkins */ -/* System: Mac OS X and port to big endian processor */ -/* */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 29.01.01 1.00 Mar Created */ -/* 24.03.03 1.01 Lad Some cosmetic changes */ -/* 12.11.03 1.02 Dan Macintosh compatibility */ -/* 24.07.04 1.03 Sam Mac OS X compatibility */ -/* 22.11.06 1.04 Sam Mac OS X compatibility (for StormLib 6.0) */ -/* 31.12.06 1.05 XPinguin Full GNU/Linux compatibility */ -/* 17.10.12 1.05 Lad Moved error codes so they don't overlap with errno.h */ -/*****************************************************************************/ - -#ifndef __STORMPORT_H__ -#define __STORMPORT_H__ - -#ifndef __cplusplus - #define bool char - #define true 1 - #define false 0 -#endif - -//----------------------------------------------------------------------------- -// Defines for Windows - -#if !defined(PLATFORM_DEFINED) && defined(_WIN32) - - // In MSVC 8.0, there are some functions declared as deprecated. - #if _MSC_VER >= 1400 - #define _CRT_SECURE_NO_DEPRECATE - #define _CRT_NON_CONFORMING_SWPRINTFS - #endif - - #include - #include - #include - #include - #include - #define PLATFORM_LITTLE_ENDIAN - - #ifdef _WIN64 - #define PLATFORM_64BIT - #else - #define PLATFORM_32BIT - #endif - - #define PLATFORM_WINDOWS - #define PLATFORM_DEFINED // The platform is known now - -#endif - -//----------------------------------------------------------------------------- -// Defines for Mac - -#if !defined(PLATFORM_DEFINED) && defined(__APPLE__) // Mac BSD API - - // Macintosh - #include - #include - #include - #include - #include - #include - #include - - // Support for PowerPC on Max OS X - #if (__ppc__ == 1) || (__POWERPC__ == 1) || (_ARCH_PPC == 1) - #include - #include - #endif - - #define PKEXPORT - #define __SYS_ZLIB - #define __SYS_BZLIB - - #ifndef __BIG_ENDIAN__ - #define PLATFORM_LITTLE_ENDIAN - #endif - - #define PLATFORM_MAC - #define PLATFORM_DEFINED // The platform is known now - -#endif - -//----------------------------------------------------------------------------- -// Assumption: we are not on Windows nor Macintosh, so this must be linux *grin* - -#if !defined(PLATFORM_DEFINED) - - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - - #define PLATFORM_LITTLE_ENDIAN - #define PLATFORM_LINUX - #define PLATFORM_DEFINED - -#endif - -//----------------------------------------------------------------------------- -// Definition of Windows-specific types for non-Windows platforms - -#ifndef PLATFORM_WINDOWS - #if __LP64__ - #define PLATFORM_64BIT - #else - #define PLATFORM_32BIT - #endif - - // Typedefs for ANSI C - typedef unsigned char BYTE; - typedef unsigned short USHORT; - typedef int LONG; - typedef unsigned int DWORD; - typedef unsigned long DWORD_PTR; - typedef long LONG_PTR; - typedef long INT_PTR; - typedef long long LONGLONG; - typedef unsigned long long ULONGLONG; - typedef void * HANDLE; - typedef void * LPOVERLAPPED; // Unsupported on Linux and Mac - typedef char TCHAR; - typedef unsigned int LCID; - typedef LONG * PLONG; - typedef DWORD * LPDWORD; - typedef BYTE * LPBYTE; - typedef const char * LPCTSTR; - typedef const char * LPCSTR; - typedef char * LPTSTR; - typedef char * LPSTR; - - #ifdef PLATFORM_32BIT - #define _LZMA_UINT32_IS_ULONG - #endif - - // Some Windows-specific defines - #ifndef MAX_PATH - #define MAX_PATH 1024 - #endif - - #ifndef _countof - #define _countof(x) (sizeof(x) / sizeof(x[0])) - #endif - - #define WINAPI - - #define FILE_BEGIN SEEK_SET - #define FILE_CURRENT SEEK_CUR - #define FILE_END SEEK_END - - #define _T(x) x - #define _tcslen strlen - #define _tcscpy strcpy - #define _tcscat strcat - #define _tcschr strchr - #define _tcsrchr strrchr - #define _tcsstr strstr - #define _tcsnicmp strncasecmp - #define _tprintf printf - #define _stprintf sprintf - #define _tremove remove - #define _tmain main - - #define _stricmp strcasecmp - #define _strnicmp strncasecmp - #define _tcsicmp strcasecmp - #define _tcsnicmp strncasecmp - -#endif // !PLATFORM_WINDOWS - -// 64-bit calls are supplied by "normal" calls on Mac -#if defined(PLATFORM_MAC) - #define stat64 stat - #define fstat64 fstat - #define lseek64 lseek - #define ftruncate64 ftruncate - #define off64_t off_t - #define O_LARGEFILE 0 -#endif - -// Platform-specific error codes for UNIX-based platforms -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) - #define ERROR_SUCCESS 0 - #define ERROR_FILE_NOT_FOUND ENOENT - #define ERROR_ACCESS_DENIED EPERM - #define ERROR_INVALID_HANDLE EBADF - #define ERROR_NOT_ENOUGH_MEMORY ENOMEM - #define ERROR_NOT_SUPPORTED ENOTSUP - #define ERROR_INVALID_PARAMETER EINVAL - #define ERROR_NEGATIVE_SEEK EINVAL - #define ERROR_DISK_FULL ENOSPC - #define ERROR_ALREADY_EXISTS EEXIST - #define ERROR_INSUFFICIENT_BUFFER ENOBUFS - #define ERROR_BAD_FORMAT 1000 // No such error code under Linux - #define ERROR_NO_MORE_FILES 1001 // No such error code under Linux - #define ERROR_HANDLE_EOF 1002 // No such error code under Linux - #define ERROR_CAN_NOT_COMPLETE 1003 // No such error code under Linux - #define ERROR_FILE_CORRUPT 1004 // No such error code under Linux -#endif - -//----------------------------------------------------------------------------- -// Swapping functions - -#ifdef PLATFORM_LITTLE_ENDIAN - #define BSWAP_INT16_UNSIGNED(a) (a) - #define BSWAP_INT16_SIGNED(a) (a) - #define BSWAP_INT32_UNSIGNED(a) (a) - #define BSWAP_INT32_SIGNED(a) (a) - #define BSWAP_INT64_SIGNED(a) (a) - #define BSWAP_INT64_UNSIGNED(a) (a) - #define BSWAP_ARRAY16_UNSIGNED(a,b) {} - #define BSWAP_ARRAY32_UNSIGNED(a,b) {} - #define BSWAP_ARRAY64_UNSIGNED(a,b) {} - #define BSWAP_PART_HEADER(a) {} - #define BSWAP_TMPQHEADER(a,b) {} - #define BSWAP_TMPKHEADER(a) {} -#else - -#ifdef __cplusplus - extern "C" { -#endif - int16_t SwapInt16(uint16_t); - uint16_t SwapUInt16(uint16_t); - int32_t SwapInt32(uint32_t); - uint32_t SwapUInt32(uint32_t); - int64_t SwapInt64(uint64_t); - uint64_t SwapUInt64(uint64_t); - void ConvertUInt16Buffer(void * ptr, size_t length); - void ConvertUInt32Buffer(void * ptr, size_t length); - void ConvertUInt64Buffer(void * ptr, size_t length); - void ConvertTMPQUserData(void *userData); - void ConvertTMPQHeader(void *header, uint16_t wPart); - void ConvertTMPKHeader(void *header); -#ifdef __cplusplus - } -#endif - #define BSWAP_INT16_SIGNED(a) SwapInt16((a)) - #define BSWAP_INT16_UNSIGNED(a) SwapUInt16((a)) - #define BSWAP_INT32_SIGNED(a) SwapInt32((a)) - #define BSWAP_INT32_UNSIGNED(a) SwapUInt32((a)) - #define BSWAP_INT64_SIGNED(a) SwapInt64((a)) - #define BSWAP_INT64_UNSIGNED(a) SwapUInt64((a)) - #define BSWAP_ARRAY16_UNSIGNED(a,b) ConvertUInt16Buffer((a),(b)) - #define BSWAP_ARRAY32_UNSIGNED(a,b) ConvertUInt32Buffer((a),(b)) - #define BSWAP_ARRAY64_UNSIGNED(a,b) ConvertUInt64Buffer((a),(b)) - #define BSWAP_TMPQHEADER(a,b) ConvertTMPQHeader((a),(b)) - #define BSWAP_TMPKHEADER(a) ConvertTMPKHeader((a)) -#endif - -//----------------------------------------------------------------------------- -// Macro for deprecated symbols - -/* -#ifdef _MSC_VER - #if _MSC_FULL_VER >= 140050320 - #define STORMLIB_DEPRECATED(_Text) __declspec(deprecated(_Text)) - #else - #define STORMLIB_DEPRECATED(_Text) __declspec(deprecated) - #endif -#else - #ifdef __GNUC__ - #define STORMLIB_DEPRECATED(_Text) __attribute__((deprecated)) - #else - #define STORMLIB_DEPRECATED(_Text) __attribute__((deprecated(_Text))) - #endif -#endif - -// When a flag is deprecated, use this macro -#ifndef _STORMLIB_NO_DEPRECATE - #define STORMLIB_DEPRECATED_FLAG(type, oldflag, newflag) \ - const STORMLIB_DEPRECATED(#oldflag " is deprecated. Use " #newflag ". To supress this warning, define _STORMLIB_NO_DEPRECATE") static type oldflag = (type)newflag; -#else -#define STORMLIB_DEPRECATED_FLAG(type, oldflag, newflag) static type oldflag = (type)newflag; -#endif -*/ - -#endif // __STORMPORT_H__ diff --git a/libs/storm-sys/StormLib/src/adpcm/adpcm.cpp b/libs/storm-sys/StormLib/src/adpcm/adpcm.cpp deleted file mode 100644 index c8086ab..0000000 --- a/libs/storm-sys/StormLib/src/adpcm/adpcm.cpp +++ /dev/null @@ -1,401 +0,0 @@ -/*****************************************************************************/ -/* adpcm.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* This module contains implementation of adpcm decompression method used by */ -/* Storm.dll to decompress WAVE files. Thanks to Tom Amigo for releasing */ -/* his sources. */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 11.03.03 1.00 Lad Splitted from Pkware.cpp */ -/* 20.05.03 2.00 Lad Added compression */ -/* 19.11.03 2.01 Dan Big endian handling */ -/* 10.01.13 3.00 Lad Refactored, beautified, documented :-) */ -/*****************************************************************************/ - -#include - -#include "adpcm.h" - -//----------------------------------------------------------------------------- -// Tables necessary dor decompression - -static int NextStepTable[] = -{ - -1, 0, -1, 4, -1, 2, -1, 6, - -1, 1, -1, 5, -1, 3, -1, 7, - -1, 1, -1, 5, -1, 3, -1, 7, - -1, 2, -1, 4, -1, 6, -1, 8 -}; - -static int StepSizeTable[] = -{ - 7, 8, 9, 10, 11, 12, 13, 14, - 16, 17, 19, 21, 23, 25, 28, 31, - 34, 37, 41, 45, 50, 55, 60, 66, - 73, 80, 88, 97, 107, 118, 130, 143, - 157, 173, 190, 209, 230, 253, 279, 307, - 337, 371, 408, 449, 494, 544, 598, 658, - 724, 796, 876, 963, 1060, 1166, 1282, 1411, - 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, - 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, - 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, - 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, - 32767 -}; - -//----------------------------------------------------------------------------- -// Helper class for writing output ADPCM data - -class TADPCMStream -{ - public: - - TADPCMStream(void * pvBuffer, size_t cbBuffer) - { - pbBufferEnd = (unsigned char *)pvBuffer + cbBuffer; - pbBuffer = (unsigned char *)pvBuffer; - } - - bool ReadByteSample(unsigned char & ByteSample) - { - // Check if there is enough space in the buffer - if(pbBuffer >= pbBufferEnd) - return false; - - ByteSample = *pbBuffer++; - return true; - } - - bool WriteByteSample(unsigned char ByteSample) - { - // Check if there is enough space in the buffer - if(pbBuffer >= pbBufferEnd) - return false; - - *pbBuffer++ = ByteSample; - return true; - } - - bool ReadWordSample(short & OneSample) - { - // Check if we have enough space in the output buffer - if((size_t)(pbBufferEnd - pbBuffer) < sizeof(short)) - return false; - - // Write the sample - OneSample = pbBuffer[0] + (((short)pbBuffer[1]) << 0x08); - pbBuffer += sizeof(short); - return true; - } - - bool WriteWordSample(short OneSample) - { - // Check if we have enough space in the output buffer - if((size_t)(pbBufferEnd - pbBuffer) < sizeof(short)) - return false; - - // Write the sample - *pbBuffer++ = (unsigned char)(OneSample & 0xFF); - *pbBuffer++ = (unsigned char)(OneSample >> 0x08); - return true; - } - - int LengthProcessed(void * pvOutBuffer) - { - return (int)((unsigned char *)pbBuffer - (unsigned char *)pvOutBuffer); - } - - unsigned char * pbBufferEnd; - unsigned char * pbBuffer; -}; - -//---------------------------------------------------------------------------- -// Local functions - -static inline short GetNextStepIndex(int StepIndex, unsigned int EncodedSample) -{ - // Get the next step index - StepIndex = StepIndex + NextStepTable[EncodedSample & 0x1F]; - - // Don't make the step index overflow - if(StepIndex < 0) - StepIndex = 0; - else if(StepIndex > 88) - StepIndex = 88; - - return (short)StepIndex; -} - -static inline int UpdatePredictedSample(int PredictedSample, int EncodedSample, int Difference) -{ - // Is the sign bit set? - if(EncodedSample & 0x40) - { - PredictedSample -= Difference; - if(PredictedSample <= -32768) - PredictedSample = -32768; - } - else - { - PredictedSample += Difference; - if(PredictedSample >= 32767) - PredictedSample = 32767; - } - - return PredictedSample; -} - -static inline int DecodeSample(int PredictedSample, int EncodedSample, int StepSize, int Difference) -{ - if(EncodedSample & 0x01) - Difference += (StepSize >> 0); - - if(EncodedSample & 0x02) - Difference += (StepSize >> 1); - - if(EncodedSample & 0x04) - Difference += (StepSize >> 2); - - if(EncodedSample & 0x08) - Difference += (StepSize >> 3); - - if(EncodedSample & 0x10) - Difference += (StepSize >> 4); - - if(EncodedSample & 0x20) - Difference += (StepSize >> 5); - - return UpdatePredictedSample(PredictedSample, EncodedSample, Difference); -} - -//---------------------------------------------------------------------------- -// Compression routine - -int CompressADPCM(void * pvOutBuffer, int cbOutBuffer, void * pvInBuffer, int cbInBuffer, int ChannelCount, int CompressionLevel) -{ - TADPCMStream os(pvOutBuffer, cbOutBuffer); // The output stream - TADPCMStream is(pvInBuffer, cbInBuffer); // The input stream - unsigned char BitShift = (unsigned char)(CompressionLevel - 1); - short PredictedSamples[MAX_ADPCM_CHANNEL_COUNT];// Predicted samples for each channel - short StepIndexes[MAX_ADPCM_CHANNEL_COUNT]; // Step indexes for each channel - short InputSample; // Input sample for the current channel - int TotalStepSize; - int ChannelIndex; - int AbsDifference; - int Difference; - int MaxBitMask; - int StepSize; - -// _tprintf(_T("== CMPR Started ==============\n")); - - // First byte in the output stream contains zero. The second one contains the compression level - os.WriteByteSample(0); - if(!os.WriteByteSample(BitShift)) - return 2; - - // Set the initial step index for each channel - PredictedSamples[0] = PredictedSamples[1] = 0; - StepIndexes[0] = StepIndexes[1] = INITIAL_ADPCM_STEP_INDEX; - - // Next, InitialSample value for each channel follows - for(int i = 0; i < ChannelCount; i++) - { - // Get the initial sample from the input stream - if(!is.ReadWordSample(InputSample)) - return os.LengthProcessed(pvOutBuffer); - - // Store the initial sample to our sample array - PredictedSamples[i] = InputSample; - - // Also store the loaded sample to the output stream - if(!os.WriteWordSample(InputSample)) - return os.LengthProcessed(pvOutBuffer); - } - - // Get the initial index - ChannelIndex = ChannelCount - 1; - - // Now keep reading the input data as long as there is something in the input buffer - while(is.ReadWordSample(InputSample)) - { - int EncodedSample = 0; - - // If we have two channels, we need to flip the channel index - ChannelIndex = (ChannelIndex + 1) % ChannelCount; - - // Get the difference from the previous sample. - // If the difference is negative, set the sign bit to the encoded sample - AbsDifference = InputSample - PredictedSamples[ChannelIndex]; - if(AbsDifference < 0) - { - AbsDifference = -AbsDifference; - EncodedSample |= 0x40; - } - - // If the difference is too low (higher that difference treshold), - // write a step index modifier marker - StepSize = StepSizeTable[StepIndexes[ChannelIndex]]; - if(AbsDifference < (StepSize >> CompressionLevel)) - { - if(StepIndexes[ChannelIndex] != 0) - StepIndexes[ChannelIndex]--; - - os.WriteByteSample(0x80); - } - else - { - // If the difference is too high, write marker that - // indicates increase in step size - while(AbsDifference > (StepSize << 1)) - { - if(StepIndexes[ChannelIndex] >= 0x58) - break; - - // Modify the step index - StepIndexes[ChannelIndex] += 8; - if(StepIndexes[ChannelIndex] > 0x58) - StepIndexes[ChannelIndex] = 0x58; - - // Write the "modify step index" marker - StepSize = StepSizeTable[StepIndexes[ChannelIndex]]; - os.WriteByteSample(0x81); - } - - // Get the limit bit value - MaxBitMask = (1 << (BitShift - 1)); - MaxBitMask = (MaxBitMask > 0x20) ? 0x20 : MaxBitMask; - Difference = StepSize >> BitShift; - TotalStepSize = 0; - - for(int BitVal = 0x01; BitVal <= MaxBitMask; BitVal <<= 1) - { - if((TotalStepSize + StepSize) <= AbsDifference) - { - TotalStepSize += StepSize; - EncodedSample |= BitVal; - } - StepSize >>= 1; - } - - PredictedSamples[ChannelIndex] = (short)UpdatePredictedSample(PredictedSamples[ChannelIndex], - EncodedSample, - Difference + TotalStepSize); - // Write the encoded sample to the output stream - if(!os.WriteByteSample((unsigned char)EncodedSample)) - break; - - // Calculates the step index to use for the next encode - StepIndexes[ChannelIndex] = GetNextStepIndex(StepIndexes[ChannelIndex], EncodedSample); - } - } - -// _tprintf(_T("== CMPR Ended ================\n")); - return os.LengthProcessed(pvOutBuffer); -} - -//---------------------------------------------------------------------------- -// Decompression routine - -int DecompressADPCM(void * pvOutBuffer, int cbOutBuffer, void * pvInBuffer, int cbInBuffer, int ChannelCount) -{ - TADPCMStream os(pvOutBuffer, cbOutBuffer); // Output stream - TADPCMStream is(pvInBuffer, cbInBuffer); // Input stream - unsigned char EncodedSample; - unsigned char BitShift; - short PredictedSamples[MAX_ADPCM_CHANNEL_COUNT]; // Predicted sample for each channel - short StepIndexes[MAX_ADPCM_CHANNEL_COUNT]; // Predicted step index for each channel - int ChannelIndex; // Current channel index - - // Initialize the StepIndex for each channel - PredictedSamples[0] = PredictedSamples[1] = 0; - StepIndexes[0] = StepIndexes[1] = INITIAL_ADPCM_STEP_INDEX; - -// _tprintf(_T("== DCMP Started ==============\n")); - - // The first byte is always zero, the second one contains bit shift (compression level - 1) - is.ReadByteSample(BitShift); - is.ReadByteSample(BitShift); -// _tprintf(_T("DCMP: BitShift = %u\n"), (unsigned int)(unsigned char)BitShift); - - // Next, InitialSample value for each channel follows - for(int i = 0; i < ChannelCount; i++) - { - // Get the initial sample from the input stream - short InitialSample; - - // Attempt to read the initial sample - if(!is.ReadWordSample(InitialSample)) - return os.LengthProcessed(pvOutBuffer); - -// _tprintf(_T("DCMP: Loaded InitialSample[%u]: %04X\n"), i, (unsigned int)(unsigned short)InitialSample); - - // Store the initial sample to our sample array - PredictedSamples[i] = InitialSample; - - // Also store the loaded sample to the output stream - if(!os.WriteWordSample(InitialSample)) - return os.LengthProcessed(pvOutBuffer); - } - - // Get the initial index - ChannelIndex = ChannelCount - 1; - - // Keep reading as long as there is something in the input buffer - while(is.ReadByteSample(EncodedSample)) - { -// _tprintf(_T("DCMP: Loaded Encoded Sample: %02X\n"), (unsigned int)(unsigned char)EncodedSample); - - // If we have two channels, we need to flip the channel index - ChannelIndex = (ChannelIndex + 1) % ChannelCount; - - if(EncodedSample == 0x80) - { - if(StepIndexes[ChannelIndex] != 0) - StepIndexes[ChannelIndex]--; - -// _tprintf(_T("DCMP: Writing Decoded Sample: %04lX\n"), (unsigned int)(unsigned short)PredictedSamples[ChannelIndex]); - if(!os.WriteWordSample(PredictedSamples[ChannelIndex])) - return os.LengthProcessed(pvOutBuffer); - } - else if(EncodedSample == 0x81) - { - // Modify the step index - StepIndexes[ChannelIndex] += 8; - if(StepIndexes[ChannelIndex] > 0x58) - StepIndexes[ChannelIndex] = 0x58; - -// _tprintf(_T("DCMP: New value of StepIndex: %04lX\n"), (unsigned int)(unsigned short)StepIndexes[ChannelIndex]); - - // Next pass, keep going on the same channel - ChannelIndex = (ChannelIndex + 1) % ChannelCount; - } - else - { - int StepIndex = StepIndexes[ChannelIndex]; - int StepSize = StepSizeTable[StepIndex]; - - // Encode one sample - PredictedSamples[ChannelIndex] = (short)DecodeSample(PredictedSamples[ChannelIndex], - EncodedSample, - StepSize, - StepSize >> BitShift); - -// _tprintf(_T("DCMP: Writing decoded sample: %04X\n"), (unsigned int)(unsigned short)PredictedSamples[ChannelIndex]); - - // Write the decoded sample to the output stream - if(!os.WriteWordSample(PredictedSamples[ChannelIndex])) - break; - - // Calculates the step index to use for the next encode - StepIndexes[ChannelIndex] = GetNextStepIndex(StepIndex, EncodedSample); -// _tprintf(_T("DCMP: New step index: %04X\n"), (unsigned int)(unsigned short)StepIndexes[ChannelIndex]); - } - } - -// _tprintf(_T("DCMP: Total length written: %u\n"), (unsigned int)os.LengthProcessed(pvOutBuffer)); -// _tprintf(_T("== DCMP Ended ================\n")); - - // Return total bytes written since beginning of the output buffer - return os.LengthProcessed(pvOutBuffer); -} diff --git a/libs/storm-sys/StormLib/src/adpcm/adpcm.h b/libs/storm-sys/StormLib/src/adpcm/adpcm.h deleted file mode 100644 index b1bf361..0000000 --- a/libs/storm-sys/StormLib/src/adpcm/adpcm.h +++ /dev/null @@ -1,26 +0,0 @@ -/*****************************************************************************/ -/* adpcm.h Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Header file for adpcm decompress functions */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 31.03.03 1.00 Lad The first version of adpcm.h */ -/*****************************************************************************/ - -#ifndef __ADPCM_H__ -#define __ADPCM_H__ - -//----------------------------------------------------------------------------- -// Defines - -#define MAX_ADPCM_CHANNEL_COUNT 2 -#define INITIAL_ADPCM_STEP_INDEX 0x2C - -//----------------------------------------------------------------------------- -// Public functions - -int CompressADPCM (void * pvOutBuffer, int dwOutLength, void * pvInBuffer, int dwInLength, int nCmpType, int ChannelCount); -int DecompressADPCM(void * pvOutBuffer, int dwOutLength, void * pvInBuffer, int dwInLength, int ChannelCount); - -#endif // __ADPCM_H__ diff --git a/libs/storm-sys/StormLib/src/adpcm/adpcm_old.cpp b/libs/storm-sys/StormLib/src/adpcm/adpcm_old.cpp deleted file mode 100644 index 916fa38..0000000 --- a/libs/storm-sys/StormLib/src/adpcm/adpcm_old.cpp +++ /dev/null @@ -1,358 +0,0 @@ -/*****************************************************************************/ -/* adpcm.cpp Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* This module contains implementation of adpcm decompression method used by */ -/* Storm.dll to decompress WAVE files. Thanks to Tom Amigo for releasing */ -/* his sources. */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 11.03.03 1.00 Lad Splitted from Pkware.cpp */ -/* 20.05.03 2.00 Lad Added compression */ -/* 19.11.03 2.01 Dan Big endian handling */ -/*****************************************************************************/ - -#include "adpcm.h" - -//------------------------------------------------------------------------------ -// Structures - -typedef union _BYTE_AND_WORD_PTR -{ - short * pw; - unsigned char * pb; -} BYTE_AND_WORD_PTR; - -typedef union _WORD_AND_BYTE_ARRAY -{ - short w; - unsigned char b[2]; -} WORD_AND_BYTE_ARRAY; - -//----------------------------------------------------------------------------- -// Tables necessary dor decompression - -static long Table1503F120[] = -{ - 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000004, 0xFFFFFFFF, 0x00000002, 0xFFFFFFFF, 0x00000006, - 0xFFFFFFFF, 0x00000001, 0xFFFFFFFF, 0x00000005, 0xFFFFFFFF, 0x00000003, 0xFFFFFFFF, 0x00000007, - 0xFFFFFFFF, 0x00000001, 0xFFFFFFFF, 0x00000005, 0xFFFFFFFF, 0x00000003, 0xFFFFFFFF, 0x00000007, - 0xFFFFFFFF, 0x00000002, 0xFFFFFFFF, 0x00000004, 0xFFFFFFFF, 0x00000006, 0xFFFFFFFF, 0x00000008 -}; - -static long step_table[] = -{ - 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, - 0x00000010, 0x00000011, 0x00000013, 0x00000015, 0x00000017, 0x00000019, 0x0000001C, 0x0000001F, - 0x00000022, 0x00000025, 0x00000029, 0x0000002D, 0x00000032, 0x00000037, 0x0000003C, 0x00000042, - 0x00000049, 0x00000050, 0x00000058, 0x00000061, 0x0000006B, 0x00000076, 0x00000082, 0x0000008F, - 0x0000009D, 0x000000AD, 0x000000BE, 0x000000D1, 0x000000E6, 0x000000FD, 0x00000117, 0x00000133, - 0x00000151, 0x00000173, 0x00000198, 0x000001C1, 0x000001EE, 0x00000220, 0x00000256, 0x00000292, - 0x000002D4, 0x0000031C, 0x0000036C, 0x000003C3, 0x00000424, 0x0000048E, 0x00000502, 0x00000583, - 0x00000610, 0x000006AB, 0x00000756, 0x00000812, 0x000008E0, 0x000009C3, 0x00000ABD, 0x00000BD0, - 0x00000CFF, 0x00000E4C, 0x00000FBA, 0x0000114C, 0x00001307, 0x000014EE, 0x00001706, 0x00001954, - 0x00001BDC, 0x00001EA5, 0x000021B6, 0x00002515, 0x000028CA, 0x00002CDF, 0x0000315B, 0x0000364B, - 0x00003BB9, 0x000041B2, 0x00004844, 0x00004F7E, 0x00005771, 0x0000602F, 0x000069CE, 0x00007462, - 0x00007FFF -}; - -//---------------------------------------------------------------------------- -// CompressWave - -// 1500EF70 -int CompressADPCM(unsigned char * pbOutBuffer, int dwOutLength, short * pwInBuffer, int dwInLength, int nChannels, int nCmpLevel) -// ECX EDX -{ - WORD_AND_BYTE_ARRAY Wcmp; - BYTE_AND_WORD_PTR out; // Pointer to the output buffer - long SInt32Array1[2]; - long SInt32Array2[2]; - long SInt32Array3[2]; - long nBytesRemains = dwOutLength; // Number of bytes remaining - long nWordsRemains; // Number of words remaining -// unsigned char * pbSaveOutBuffer; // Copy of output buffer (actually not used) - unsigned long dwBitBuff; - unsigned long dwStopBit; - unsigned long dwBit; - unsigned long ebx; - unsigned long esi; - long nTableValue; - long nOneWord; - long var_1C; - long var_2C; - int nLength; - int nIndex; - int nValue; - int i, chnl; - - // If less than 2 bytes remain, don't decompress anything -// pbSaveOutBuffer = pbOutBuffer; - out.pb = pbOutBuffer; - if(nBytesRemains < 2) - return 2; - - Wcmp.b[1] = (unsigned char)(nCmpLevel - 1); - Wcmp.b[0] = (unsigned char)0; - - *out.pw++ = BSWAP_INT16_SIGNED(Wcmp.w); - if((out.pb - pbOutBuffer + (nChannels * 2)) > nBytesRemains) - return (int)(out.pb - pbOutBuffer + (nChannels * 2)); - - SInt32Array1[0] = SInt32Array1[1] = 0x2C; - - for(i = 0; i < nChannels; i++) - { - nOneWord = BSWAP_INT16_SIGNED(*pwInBuffer++); - *out.pw++ = BSWAP_INT16_SIGNED((short)nOneWord); - SInt32Array2[i] = nOneWord; - } - - // Weird. But it's there - nLength = dwInLength; - if(nLength < 0) // mov eax, dwInLength; cdq; sub eax, edx; - nLength++; - - nLength = (nLength / 2) - (int)(out.pb - pbOutBuffer); - nLength = (nLength < 0) ? 0 : nLength; - - nIndex = nChannels - 1; // edi - nWordsRemains = dwInLength / 2; // eax - - // ebx - nChannels - // ecx - pwOutPos - for(chnl = nChannels; chnl < nWordsRemains; chnl++) - { - // 1500F030 - if((out.pb - pbOutBuffer + 2) > nBytesRemains) - return (int)(out.pb - pbOutBuffer + 2); - - // Switch index - if(nChannels == 2) - nIndex = (nIndex == 0) ? 1 : 0; - - // Load one word from the input stream - nOneWord = BSWAP_INT16_SIGNED(*pwInBuffer++); // ecx - nOneWord - SInt32Array3[nIndex] = nOneWord; - - // esi - SInt32Array2[nIndex] - // eax - nValue - nValue = nOneWord - SInt32Array2[nIndex]; - nValue = (nValue < 0) ? ((nValue ^ 0xFFFFFFFF) + 1) : nValue; - - ebx = (nOneWord >= SInt32Array2[nIndex]) ? 0 : 0x40; - - // esi - SInt32Array2[nIndex] - // edx - step_table[SInt32Array2[nIndex]] - // edi - (step_table[SInt32Array1[nIndex]] >> nCmpLevel) - nTableValue = step_table[SInt32Array1[nIndex]]; - dwStopBit = (unsigned long)nCmpLevel; - - // edi - nIndex; - if(nValue < (nTableValue >> nCmpLevel)) - { - if(SInt32Array1[nIndex] != 0) - SInt32Array1[nIndex]--; - *out.pb++ = 0x80; - } - else - { - while(nValue > nTableValue * 2) - { - if(SInt32Array1[nIndex] >= 0x58 || nLength == 0) - break; - - SInt32Array1[nIndex] += 8; - if(SInt32Array1[nIndex] > 0x58) - SInt32Array1[nIndex] = 0x58; - - nTableValue = step_table[SInt32Array1[nIndex]]; - *out.pb++ = 0x81; - nLength--; - } - - var_2C = nTableValue >> Wcmp.b[1]; - dwBitBuff = 0; - - esi = (1 << (dwStopBit - 2)); - dwStopBit = (esi <= 0x20) ? esi : 0x20; - - for(var_1C = 0, dwBit = 1; ; dwBit <<= 1) - { -// esi = var_1C + nTableValue; - if((var_1C + nTableValue) <= nValue) - { - var_1C += nTableValue; - dwBitBuff |= dwBit; - } - if(dwBit == dwStopBit) - break; - - nTableValue >>= 1; - } - - nValue = SInt32Array2[nIndex]; - if(ebx != 0) - { - nValue -= (var_1C + var_2C); - if(nValue < -32768) - nValue = -32768; - } - else - { - nValue += (var_1C + var_2C); - if(nValue > 32767) - nValue = 32767; - } - - SInt32Array2[nIndex] = nValue; - *out.pb++ = (unsigned char)(dwBitBuff | ebx); - nTableValue = Table1503F120[dwBitBuff & 0x1F]; - SInt32Array1[nIndex] = SInt32Array1[nIndex] + nTableValue; - if(SInt32Array1[nIndex] < 0) - SInt32Array1[nIndex] = 0; - else if(SInt32Array1[nIndex] > 0x58) - SInt32Array1[nIndex] = 0x58; - } - } - - return (int)(out.pb - pbOutBuffer); -} - -//---------------------------------------------------------------------------- -// DecompressADPCM - -// 1500F230 -int DecompressADPCM(unsigned char * pbOutBuffer, int dwOutLength, unsigned char * pbInBuffer, int dwInLength, int nChannels) -{ - BYTE_AND_WORD_PTR out; // Output buffer - BYTE_AND_WORD_PTR in; - unsigned char * pbInBufferEnd = (pbInBuffer + dwInLength); - long SInt32Array1[2]; - long SInt32Array2[2]; - long nOneWord; - int nIndex; - int i; - - SInt32Array1[0] = SInt32Array1[1] = 0x2C; - out.pb = pbOutBuffer; - in.pb = pbInBuffer; - in.pw++; - - // Fill the Uint32Array2 array by channel values. - for(i = 0; i < nChannels; i++) - { - nOneWord = BSWAP_INT16_SIGNED(*in.pw++); - SInt32Array2[i] = nOneWord; - if(dwOutLength < 2) - return (int)(out.pb - pbOutBuffer); - - *out.pw++ = BSWAP_INT16_SIGNED((short)nOneWord); - dwOutLength -= sizeof(short); - } - - // Get the initial index - nIndex = nChannels - 1; - - // Perform the decompression - while(in.pb < pbInBufferEnd) - { - unsigned char nOneByte = *in.pb++; - - // Switch index - if(nChannels == 2) - nIndex = (nIndex == 0) ? 1 : 0; - - // 1500F2A2: Get one byte from input buffer - if(nOneByte & 0x80) - { - switch(nOneByte & 0x7F) - { - case 0: // 1500F315 - if(SInt32Array1[nIndex] != 0) - SInt32Array1[nIndex]--; - - if(dwOutLength < 2) - return (int)(out.pb - pbOutBuffer); - - *out.pw++ = BSWAP_INT16_SIGNED((unsigned short)SInt32Array2[nIndex]); - dwOutLength -= sizeof(unsigned short); - break; - - case 1: // 1500F2E8 - SInt32Array1[nIndex] += 8; - if(SInt32Array1[nIndex] > 0x58) - SInt32Array1[nIndex] = 0x58; - - if(nChannels == 2) - nIndex = (nIndex == 0) ? 1 : 0; - break; - - case 2: // 1500F41E - break; - - default: // 1500F2C4 - SInt32Array1[nIndex] -= 8; - if(SInt32Array1[nIndex] < 0) - SInt32Array1[nIndex] = 0; - - if(nChannels == 2) - nIndex = (nIndex == 0) ? 1 : 0; - break; - } - } - else - { - // 1500F349 - long temp1 = step_table[SInt32Array1[nIndex]]; // EDI - long temp2 = temp1 >> pbInBuffer[1]; // ESI - long temp3 = SInt32Array2[nIndex]; // ECX - - if(nOneByte & 0x01) // EBX = nOneByte - temp2 += (temp1 >> 0); - - if(nOneByte & 0x02) - temp2 += (temp1 >> 1); - - if(nOneByte & 0x04) - temp2 += (temp1 >> 2); - - if(nOneByte & 0x08) - temp2 += (temp1 >> 3); - - if(nOneByte & 0x10) - temp2 += (temp1 >> 4); - - if(nOneByte & 0x20) - temp2 += (temp1 >> 5); - - if(nOneByte & 0x40) - { - temp3 = temp3 - temp2; - if(temp3 <= -32768) - temp3 = -32768; - } - else - { - temp3 = temp3 + temp2; - if(temp3 >= 32767) - temp3 = 32767; - } - - SInt32Array2[nIndex] = temp3; - if(dwOutLength < 2) - break; - - // Store the output 16-bit value - *out.pw++ = BSWAP_INT16_SIGNED((short)SInt32Array2[nIndex]); - dwOutLength -= 2; - - SInt32Array1[nIndex] += Table1503F120[nOneByte & 0x1F]; - - if(SInt32Array1[nIndex] < 0) - SInt32Array1[nIndex] = 0; - else if(SInt32Array1[nIndex] > 0x58) - SInt32Array1[nIndex] = 0x58; - } - } - return (int)(out.pb - pbOutBuffer); -} diff --git a/libs/storm-sys/StormLib/src/adpcm/adpcm_old.h b/libs/storm-sys/StormLib/src/adpcm/adpcm_old.h deleted file mode 100644 index 7b76aff..0000000 --- a/libs/storm-sys/StormLib/src/adpcm/adpcm_old.h +++ /dev/null @@ -1,22 +0,0 @@ -/*****************************************************************************/ -/* adpcm.h Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Header file for adpcm decompress functions */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 31.03.03 1.00 Lad The first version of adpcm.h */ -/*****************************************************************************/ - -#ifndef __ADPCM_H__ -#define __ADPCM_H__ - -//----------------------------------------------------------------------------- -// Functions - -#include - -int CompressADPCM (unsigned char * pbOutBuffer, int dwOutLength, short * pwInBuffer, int dwInLength, int nCmpType, int nChannels); -int DecompressADPCM(unsigned char * pbOutBuffer, int dwOutLength, unsigned char * pbInBuffer, int dwInLength, int nChannels); - -#endif // __ADPCM_H__ diff --git a/libs/storm-sys/StormLib/src/bzip2/blocksort.c b/libs/storm-sys/StormLib/src/bzip2/blocksort.c deleted file mode 100644 index bd2dec1..0000000 --- a/libs/storm-sys/StormLib/src/bzip2/blocksort.c +++ /dev/null @@ -1,1094 +0,0 @@ - -/*-------------------------------------------------------------*/ -/*--- Block sorting machinery ---*/ -/*--- blocksort.c ---*/ -/*-------------------------------------------------------------*/ - -/* ------------------------------------------------------------------ - This file is part of bzip2/libbzip2, a program and library for - lossless, block-sorting data compression. - - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward - - Please read the WARNING, DISCLAIMER and PATENTS sections in the - README file. - - This program is released under the terms of the license contained - in the file LICENSE. - ------------------------------------------------------------------ */ - - -#include "bzlib_private.h" - -/*---------------------------------------------*/ -/*--- Fallback O(N log(N)^2) sorting ---*/ -/*--- algorithm, for repetitive blocks ---*/ -/*---------------------------------------------*/ - -/*---------------------------------------------*/ -static -__inline__ -void fallbackSimpleSort ( UInt32* fmap, - UInt32* eclass, - Int32 lo, - Int32 hi ) -{ - Int32 i, j, tmp; - UInt32 ec_tmp; - - if (lo == hi) return; - - if (hi - lo > 3) { - for ( i = hi-4; i >= lo; i-- ) { - tmp = fmap[i]; - ec_tmp = eclass[tmp]; - for ( j = i+4; j <= hi && ec_tmp > eclass[fmap[j]]; j += 4 ) - fmap[j-4] = fmap[j]; - fmap[j-4] = tmp; - } - } - - for ( i = hi-1; i >= lo; i-- ) { - tmp = fmap[i]; - ec_tmp = eclass[tmp]; - for ( j = i+1; j <= hi && ec_tmp > eclass[fmap[j]]; j++ ) - fmap[j-1] = fmap[j]; - fmap[j-1] = tmp; - } -} - - -/*---------------------------------------------*/ -#define fswap(zz1, zz2) \ - { Int32 zztmp = zz1; zz1 = zz2; zz2 = zztmp; } - -#define fvswap(zzp1, zzp2, zzn) \ -{ \ - Int32 yyp1 = (zzp1); \ - Int32 yyp2 = (zzp2); \ - Int32 yyn = (zzn); \ - while (yyn > 0) { \ - fswap(fmap[yyp1], fmap[yyp2]); \ - yyp1++; yyp2++; yyn--; \ - } \ -} - - -#define fmin(a,b) ((a) < (b)) ? (a) : (b) - -#define fpush(lz,hz) { stackLo[sp] = lz; \ - stackHi[sp] = hz; \ - sp++; } - -#define fpop(lz,hz) { sp--; \ - lz = stackLo[sp]; \ - hz = stackHi[sp]; } - -#define FALLBACK_QSORT_SMALL_THRESH 10 -#define FALLBACK_QSORT_STACK_SIZE 100 - - -static -void fallbackQSort3 ( UInt32* fmap, - UInt32* eclass, - Int32 loSt, - Int32 hiSt ) -{ - Int32 unLo, unHi, ltLo, gtHi, n, m; - Int32 sp, lo, hi; - UInt32 med, r, r3; - Int32 stackLo[FALLBACK_QSORT_STACK_SIZE]; - Int32 stackHi[FALLBACK_QSORT_STACK_SIZE]; - - r = 0; - - sp = 0; - fpush ( loSt, hiSt ); - - while (sp > 0) { - - AssertH ( sp < FALLBACK_QSORT_STACK_SIZE - 1, 1004 ); - - fpop ( lo, hi ); - if (hi - lo < FALLBACK_QSORT_SMALL_THRESH) { - fallbackSimpleSort ( fmap, eclass, lo, hi ); - continue; - } - - /* Random partitioning. Median of 3 sometimes fails to - avoid bad cases. Median of 9 seems to help but - looks rather expensive. This too seems to work but - is cheaper. Guidance for the magic constants - 7621 and 32768 is taken from Sedgewick's algorithms - book, chapter 35. - */ - r = ((r * 7621) + 1) % 32768; - r3 = r % 3; - if (r3 == 0) med = eclass[fmap[lo]]; else - if (r3 == 1) med = eclass[fmap[(lo+hi)>>1]]; else - med = eclass[fmap[hi]]; - - unLo = ltLo = lo; - unHi = gtHi = hi; - - while (1) { - while (1) { - if (unLo > unHi) break; - n = (Int32)eclass[fmap[unLo]] - (Int32)med; - if (n == 0) { - fswap(fmap[unLo], fmap[ltLo]); - ltLo++; unLo++; - continue; - }; - if (n > 0) break; - unLo++; - } - while (1) { - if (unLo > unHi) break; - n = (Int32)eclass[fmap[unHi]] - (Int32)med; - if (n == 0) { - fswap(fmap[unHi], fmap[gtHi]); - gtHi--; unHi--; - continue; - }; - if (n < 0) break; - unHi--; - } - if (unLo > unHi) break; - fswap(fmap[unLo], fmap[unHi]); unLo++; unHi--; - } - - AssertD ( unHi == unLo-1, "fallbackQSort3(2)" ); - - if (gtHi < ltLo) continue; - - n = fmin(ltLo-lo, unLo-ltLo); fvswap(lo, unLo-n, n); - m = fmin(hi-gtHi, gtHi-unHi); fvswap(unLo, hi-m+1, m); - - n = lo + unLo - ltLo - 1; - m = hi - (gtHi - unHi) + 1; - - if (n - lo > hi - m) { - fpush ( lo, n ); - fpush ( m, hi ); - } else { - fpush ( m, hi ); - fpush ( lo, n ); - } - } -} - -#undef fmin -#undef fpush -#undef fpop -#undef fswap -#undef fvswap -#undef FALLBACK_QSORT_SMALL_THRESH -#undef FALLBACK_QSORT_STACK_SIZE - - -/*---------------------------------------------*/ -/* Pre: - nblock > 0 - eclass exists for [0 .. nblock-1] - ((UChar*)eclass) [0 .. nblock-1] holds block - ptr exists for [0 .. nblock-1] - - Post: - ((UChar*)eclass) [0 .. nblock-1] holds block - All other areas of eclass destroyed - fmap [0 .. nblock-1] holds sorted order - bhtab [ 0 .. 2+(nblock/32) ] destroyed -*/ - -#define SET_BH(zz) bhtab[(zz) >> 5] |= (1 << ((zz) & 31)) -#define CLEAR_BH(zz) bhtab[(zz) >> 5] &= ~(1 << ((zz) & 31)) -#define ISSET_BH(zz) (bhtab[(zz) >> 5] & (1 << ((zz) & 31))) -#define WORD_BH(zz) bhtab[(zz) >> 5] -#define UNALIGNED_BH(zz) ((zz) & 0x01f) - -static -void fallbackSort ( UInt32* fmap, - UInt32* eclass, - UInt32* bhtab, - Int32 nblock, - Int32 verb ) -{ - Int32 ftab[257]; - Int32 ftabCopy[256]; - Int32 H, i, j, k, l, r, cc, cc1; - Int32 nNotDone; - Int32 nBhtab; - UChar* eclass8 = (UChar*)eclass; - - /*-- - Initial 1-char radix sort to generate - initial fmap and initial BH bits. - --*/ - if (verb >= 4) - VPrintf0 ( " bucket sorting ...\n" ); - for (i = 0; i < 257; i++) ftab[i] = 0; - for (i = 0; i < nblock; i++) ftab[eclass8[i]]++; - for (i = 0; i < 256; i++) ftabCopy[i] = ftab[i]; - for (i = 1; i < 257; i++) ftab[i] += ftab[i-1]; - - for (i = 0; i < nblock; i++) { - j = eclass8[i]; - k = ftab[j] - 1; - ftab[j] = k; - fmap[k] = i; - } - - nBhtab = 2 + (nblock / 32); - for (i = 0; i < nBhtab; i++) bhtab[i] = 0; - for (i = 0; i < 256; i++) SET_BH(ftab[i]); - - /*-- - Inductively refine the buckets. Kind-of an - "exponential radix sort" (!), inspired by the - Manber-Myers suffix array construction algorithm. - --*/ - - /*-- set sentinel bits for block-end detection --*/ - for (i = 0; i < 32; i++) { - SET_BH(nblock + 2*i); - CLEAR_BH(nblock + 2*i + 1); - } - - /*-- the log(N) loop --*/ - H = 1; - while (1) { - - if (verb >= 4) - VPrintf1 ( " depth %6d has ", H ); - - j = 0; - for (i = 0; i < nblock; i++) { - if (ISSET_BH(i)) j = i; - k = fmap[i] - H; if (k < 0) k += nblock; - eclass[k] = j; - } - - nNotDone = 0; - r = -1; - while (1) { - - /*-- find the next non-singleton bucket --*/ - k = r + 1; - while (ISSET_BH(k) && UNALIGNED_BH(k)) k++; - if (ISSET_BH(k)) { - while (WORD_BH(k) == 0xffffffff) k += 32; - while (ISSET_BH(k)) k++; - } - l = k - 1; - if (l >= nblock) break; - while (!ISSET_BH(k) && UNALIGNED_BH(k)) k++; - if (!ISSET_BH(k)) { - while (WORD_BH(k) == 0x00000000) k += 32; - while (!ISSET_BH(k)) k++; - } - r = k - 1; - if (r >= nblock) break; - - /*-- now [l, r] bracket current bucket --*/ - if (r > l) { - nNotDone += (r - l + 1); - fallbackQSort3 ( fmap, eclass, l, r ); - - /*-- scan bucket and generate header bits-- */ - cc = -1; - for (i = l; i <= r; i++) { - cc1 = eclass[fmap[i]]; - if (cc != cc1) { SET_BH(i); cc = cc1; }; - } - } - } - - if (verb >= 4) - VPrintf1 ( "%6d unresolved strings\n", nNotDone ); - - H *= 2; - if (H > nblock || nNotDone == 0) break; - } - - /*-- - Reconstruct the original block in - eclass8 [0 .. nblock-1], since the - previous phase destroyed it. - --*/ - if (verb >= 4) - VPrintf0 ( " reconstructing block ...\n" ); - j = 0; - for (i = 0; i < nblock; i++) { - while (ftabCopy[j] == 0) j++; - ftabCopy[j]--; - eclass8[fmap[i]] = (UChar)j; - } - AssertH ( j < 256, 1005 ); -} - -#undef SET_BH -#undef CLEAR_BH -#undef ISSET_BH -#undef WORD_BH -#undef UNALIGNED_BH - - -/*---------------------------------------------*/ -/*--- The main, O(N^2 log(N)) sorting ---*/ -/*--- algorithm. Faster for "normal" ---*/ -/*--- non-repetitive blocks. ---*/ -/*---------------------------------------------*/ - -/*---------------------------------------------*/ -static -__inline__ -Bool mainGtU ( UInt32 i1, - UInt32 i2, - UChar* block, - UInt16* quadrant, - UInt32 nblock, - Int32* budget ) -{ - Int32 k; - UChar c1, c2; - UInt16 s1, s2; - - AssertD ( i1 != i2, "mainGtU" ); - /* 1 */ - c1 = block[i1]; c2 = block[i2]; - if (c1 != c2) return (c1 > c2); - i1++; i2++; - /* 2 */ - c1 = block[i1]; c2 = block[i2]; - if (c1 != c2) return (c1 > c2); - i1++; i2++; - /* 3 */ - c1 = block[i1]; c2 = block[i2]; - if (c1 != c2) return (c1 > c2); - i1++; i2++; - /* 4 */ - c1 = block[i1]; c2 = block[i2]; - if (c1 != c2) return (c1 > c2); - i1++; i2++; - /* 5 */ - c1 = block[i1]; c2 = block[i2]; - if (c1 != c2) return (c1 > c2); - i1++; i2++; - /* 6 */ - c1 = block[i1]; c2 = block[i2]; - if (c1 != c2) return (c1 > c2); - i1++; i2++; - /* 7 */ - c1 = block[i1]; c2 = block[i2]; - if (c1 != c2) return (c1 > c2); - i1++; i2++; - /* 8 */ - c1 = block[i1]; c2 = block[i2]; - if (c1 != c2) return (c1 > c2); - i1++; i2++; - /* 9 */ - c1 = block[i1]; c2 = block[i2]; - if (c1 != c2) return (c1 > c2); - i1++; i2++; - /* 10 */ - c1 = block[i1]; c2 = block[i2]; - if (c1 != c2) return (c1 > c2); - i1++; i2++; - /* 11 */ - c1 = block[i1]; c2 = block[i2]; - if (c1 != c2) return (c1 > c2); - i1++; i2++; - /* 12 */ - c1 = block[i1]; c2 = block[i2]; - if (c1 != c2) return (c1 > c2); - i1++; i2++; - - k = nblock + 8; - - do { - /* 1 */ - c1 = block[i1]; c2 = block[i2]; - if (c1 != c2) return (c1 > c2); - s1 = quadrant[i1]; s2 = quadrant[i2]; - if (s1 != s2) return (s1 > s2); - i1++; i2++; - /* 2 */ - c1 = block[i1]; c2 = block[i2]; - if (c1 != c2) return (c1 > c2); - s1 = quadrant[i1]; s2 = quadrant[i2]; - if (s1 != s2) return (s1 > s2); - i1++; i2++; - /* 3 */ - c1 = block[i1]; c2 = block[i2]; - if (c1 != c2) return (c1 > c2); - s1 = quadrant[i1]; s2 = quadrant[i2]; - if (s1 != s2) return (s1 > s2); - i1++; i2++; - /* 4 */ - c1 = block[i1]; c2 = block[i2]; - if (c1 != c2) return (c1 > c2); - s1 = quadrant[i1]; s2 = quadrant[i2]; - if (s1 != s2) return (s1 > s2); - i1++; i2++; - /* 5 */ - c1 = block[i1]; c2 = block[i2]; - if (c1 != c2) return (c1 > c2); - s1 = quadrant[i1]; s2 = quadrant[i2]; - if (s1 != s2) return (s1 > s2); - i1++; i2++; - /* 6 */ - c1 = block[i1]; c2 = block[i2]; - if (c1 != c2) return (c1 > c2); - s1 = quadrant[i1]; s2 = quadrant[i2]; - if (s1 != s2) return (s1 > s2); - i1++; i2++; - /* 7 */ - c1 = block[i1]; c2 = block[i2]; - if (c1 != c2) return (c1 > c2); - s1 = quadrant[i1]; s2 = quadrant[i2]; - if (s1 != s2) return (s1 > s2); - i1++; i2++; - /* 8 */ - c1 = block[i1]; c2 = block[i2]; - if (c1 != c2) return (c1 > c2); - s1 = quadrant[i1]; s2 = quadrant[i2]; - if (s1 != s2) return (s1 > s2); - i1++; i2++; - - if (i1 >= nblock) i1 -= nblock; - if (i2 >= nblock) i2 -= nblock; - - k -= 8; - (*budget)--; - } - while (k >= 0); - - return False; -} - - -/*---------------------------------------------*/ -/*-- - Knuth's increments seem to work better - than Incerpi-Sedgewick here. Possibly - because the number of elems to sort is - usually small, typically <= 20. ---*/ -static -Int32 incs[14] = { 1, 4, 13, 40, 121, 364, 1093, 3280, - 9841, 29524, 88573, 265720, - 797161, 2391484 }; - -static -void mainSimpleSort ( UInt32* ptr, - UChar* block, - UInt16* quadrant, - Int32 nblock, - Int32 lo, - Int32 hi, - Int32 d, - Int32* budget ) -{ - Int32 i, j, h, bigN, hp; - UInt32 v; - - bigN = hi - lo + 1; - if (bigN < 2) return; - - hp = 0; - while (incs[hp] < bigN) hp++; - hp--; - - for (; hp >= 0; hp--) { - h = incs[hp]; - - i = lo + h; - while (True) { - - /*-- copy 1 --*/ - if (i > hi) break; - v = ptr[i]; - j = i; - while ( mainGtU ( - ptr[j-h]+d, v+d, block, quadrant, nblock, budget - ) ) { - ptr[j] = ptr[j-h]; - j = j - h; - if (j <= (lo + h - 1)) break; - } - ptr[j] = v; - i++; - - /*-- copy 2 --*/ - if (i > hi) break; - v = ptr[i]; - j = i; - while ( mainGtU ( - ptr[j-h]+d, v+d, block, quadrant, nblock, budget - ) ) { - ptr[j] = ptr[j-h]; - j = j - h; - if (j <= (lo + h - 1)) break; - } - ptr[j] = v; - i++; - - /*-- copy 3 --*/ - if (i > hi) break; - v = ptr[i]; - j = i; - while ( mainGtU ( - ptr[j-h]+d, v+d, block, quadrant, nblock, budget - ) ) { - ptr[j] = ptr[j-h]; - j = j - h; - if (j <= (lo + h - 1)) break; - } - ptr[j] = v; - i++; - - if (*budget < 0) return; - } - } -} - - -/*---------------------------------------------*/ -/*-- - The following is an implementation of - an elegant 3-way quicksort for strings, - described in a paper "Fast Algorithms for - Sorting and Searching Strings", by Robert - Sedgewick and Jon L. Bentley. ---*/ - -#define mswap(zz1, zz2) \ - { Int32 zztmp = zz1; zz1 = zz2; zz2 = zztmp; } - -#define mvswap(zzp1, zzp2, zzn) \ -{ \ - Int32 yyp1 = (zzp1); \ - Int32 yyp2 = (zzp2); \ - Int32 yyn = (zzn); \ - while (yyn > 0) { \ - mswap(ptr[yyp1], ptr[yyp2]); \ - yyp1++; yyp2++; yyn--; \ - } \ -} - -static -__inline__ -UChar mmed3 ( UChar a, UChar b, UChar c ) -{ - UChar t; - if (a > b) { t = a; a = b; b = t; }; - if (b > c) { - b = c; - if (a > b) b = a; - } - return b; -} - -#define mmin(a,b) ((a) < (b)) ? (a) : (b) - -#define mpush(lz,hz,dz) { stackLo[sp] = lz; \ - stackHi[sp] = hz; \ - stackD [sp] = dz; \ - sp++; } - -#define mpop(lz,hz,dz) { sp--; \ - lz = stackLo[sp]; \ - hz = stackHi[sp]; \ - dz = stackD [sp]; } - - -#define mnextsize(az) (nextHi[az]-nextLo[az]) - -#define mnextswap(az,bz) \ - { Int32 tz; \ - tz = nextLo[az]; nextLo[az] = nextLo[bz]; nextLo[bz] = tz; \ - tz = nextHi[az]; nextHi[az] = nextHi[bz]; nextHi[bz] = tz; \ - tz = nextD [az]; nextD [az] = nextD [bz]; nextD [bz] = tz; } - - -#define MAIN_QSORT_SMALL_THRESH 20 -#define MAIN_QSORT_DEPTH_THRESH (BZ_N_RADIX + BZ_N_QSORT) -#define MAIN_QSORT_STACK_SIZE 100 - -static -void mainQSort3 ( UInt32* ptr, - UChar* block, - UInt16* quadrant, - Int32 nblock, - Int32 loSt, - Int32 hiSt, - Int32 dSt, - Int32* budget ) -{ - Int32 unLo, unHi, ltLo, gtHi, n, m, med; - Int32 sp, lo, hi, d; - - Int32 stackLo[MAIN_QSORT_STACK_SIZE]; - Int32 stackHi[MAIN_QSORT_STACK_SIZE]; - Int32 stackD [MAIN_QSORT_STACK_SIZE]; - - Int32 nextLo[3]; - Int32 nextHi[3]; - Int32 nextD [3]; - - sp = 0; - mpush ( loSt, hiSt, dSt ); - - while (sp > 0) { - - AssertH ( sp < MAIN_QSORT_STACK_SIZE - 2, 1001 ); - - mpop ( lo, hi, d ); - if (hi - lo < MAIN_QSORT_SMALL_THRESH || - d > MAIN_QSORT_DEPTH_THRESH) { - mainSimpleSort ( ptr, block, quadrant, nblock, lo, hi, d, budget ); - if (*budget < 0) return; - continue; - } - - med = (Int32) - mmed3 ( block[ptr[ lo ]+d], - block[ptr[ hi ]+d], - block[ptr[ (lo+hi)>>1 ]+d] ); - - unLo = ltLo = lo; - unHi = gtHi = hi; - - while (True) { - while (True) { - if (unLo > unHi) break; - n = ((Int32)block[ptr[unLo]+d]) - med; - if (n == 0) { - mswap(ptr[unLo], ptr[ltLo]); - ltLo++; unLo++; continue; - }; - if (n > 0) break; - unLo++; - } - while (True) { - if (unLo > unHi) break; - n = ((Int32)block[ptr[unHi]+d]) - med; - if (n == 0) { - mswap(ptr[unHi], ptr[gtHi]); - gtHi--; unHi--; continue; - }; - if (n < 0) break; - unHi--; - } - if (unLo > unHi) break; - mswap(ptr[unLo], ptr[unHi]); unLo++; unHi--; - } - - AssertD ( unHi == unLo-1, "mainQSort3(2)" ); - - if (gtHi < ltLo) { - mpush(lo, hi, d+1 ); - continue; - } - - n = mmin(ltLo-lo, unLo-ltLo); mvswap(lo, unLo-n, n); - m = mmin(hi-gtHi, gtHi-unHi); mvswap(unLo, hi-m+1, m); - - n = lo + unLo - ltLo - 1; - m = hi - (gtHi - unHi) + 1; - - nextLo[0] = lo; nextHi[0] = n; nextD[0] = d; - nextLo[1] = m; nextHi[1] = hi; nextD[1] = d; - nextLo[2] = n+1; nextHi[2] = m-1; nextD[2] = d+1; - - if (mnextsize(0) < mnextsize(1)) mnextswap(0,1); - if (mnextsize(1) < mnextsize(2)) mnextswap(1,2); - if (mnextsize(0) < mnextsize(1)) mnextswap(0,1); - - AssertD (mnextsize(0) >= mnextsize(1), "mainQSort3(8)" ); - AssertD (mnextsize(1) >= mnextsize(2), "mainQSort3(9)" ); - - mpush (nextLo[0], nextHi[0], nextD[0]); - mpush (nextLo[1], nextHi[1], nextD[1]); - mpush (nextLo[2], nextHi[2], nextD[2]); - } -} - -#undef mswap -#undef mvswap -#undef mpush -#undef mpop -#undef mmin -#undef mnextsize -#undef mnextswap -#undef MAIN_QSORT_SMALL_THRESH -#undef MAIN_QSORT_DEPTH_THRESH -#undef MAIN_QSORT_STACK_SIZE - - -/*---------------------------------------------*/ -/* Pre: - nblock > N_OVERSHOOT - block32 exists for [0 .. nblock-1 +N_OVERSHOOT] - ((UChar*)block32) [0 .. nblock-1] holds block - ptr exists for [0 .. nblock-1] - - Post: - ((UChar*)block32) [0 .. nblock-1] holds block - All other areas of block32 destroyed - ftab [0 .. 65536 ] destroyed - ptr [0 .. nblock-1] holds sorted order - if (*budget < 0), sorting was abandoned -*/ - -#define BIGFREQ(b) (ftab[((b)+1) << 8] - ftab[(b) << 8]) -#define SETMASK (1 << 21) -#define CLEARMASK (~(SETMASK)) - -static -void mainSort ( UInt32* ptr, - UChar* block, - UInt16* quadrant, - UInt32* ftab, - Int32 nblock, - Int32 verb, - Int32* budget ) -{ - Int32 i, j, k, ss, sb; - Int32 runningOrder[256]; - Bool bigDone[256]; - Int32 copyStart[256]; - Int32 copyEnd [256]; - UChar c1; - Int32 numQSorted; - UInt16 s; - if (verb >= 4) VPrintf0 ( " main sort initialise ...\n" ); - - /*-- set up the 2-byte frequency table --*/ - for (i = 65536; i >= 0; i--) ftab[i] = 0; - - j = block[0] << 8; - i = nblock-1; - for (; i >= 3; i -= 4) { - quadrant[i] = 0; - j = (j >> 8) | ( ((UInt16)block[i]) << 8); - ftab[j]++; - quadrant[i-1] = 0; - j = (j >> 8) | ( ((UInt16)block[i-1]) << 8); - ftab[j]++; - quadrant[i-2] = 0; - j = (j >> 8) | ( ((UInt16)block[i-2]) << 8); - ftab[j]++; - quadrant[i-3] = 0; - j = (j >> 8) | ( ((UInt16)block[i-3]) << 8); - ftab[j]++; - } - for (; i >= 0; i--) { - quadrant[i] = 0; - j = (j >> 8) | ( ((UInt16)block[i]) << 8); - ftab[j]++; - } - - /*-- (emphasises close relationship of block & quadrant) --*/ - for (i = 0; i < BZ_N_OVERSHOOT; i++) { - block [nblock+i] = block[i]; - quadrant[nblock+i] = 0; - } - - if (verb >= 4) VPrintf0 ( " bucket sorting ...\n" ); - - /*-- Complete the initial radix sort --*/ - for (i = 1; i <= 65536; i++) ftab[i] += ftab[i-1]; - - s = block[0] << 8; - i = nblock-1; - for (; i >= 3; i -= 4) { - s = (s >> 8) | (block[i] << 8); - j = ftab[s] -1; - ftab[s] = j; - ptr[j] = i; - s = (s >> 8) | (block[i-1] << 8); - j = ftab[s] -1; - ftab[s] = j; - ptr[j] = i-1; - s = (s >> 8) | (block[i-2] << 8); - j = ftab[s] -1; - ftab[s] = j; - ptr[j] = i-2; - s = (s >> 8) | (block[i-3] << 8); - j = ftab[s] -1; - ftab[s] = j; - ptr[j] = i-3; - } - for (; i >= 0; i--) { - s = (s >> 8) | (block[i] << 8); - j = ftab[s] -1; - ftab[s] = j; - ptr[j] = i; - } - - /*-- - Now ftab contains the first loc of every small bucket. - Calculate the running order, from smallest to largest - big bucket. - --*/ - for (i = 0; i <= 255; i++) { - bigDone [i] = False; - runningOrder[i] = i; - } - - { - Int32 vv; - Int32 h = 1; - do h = 3 * h + 1; while (h <= 256); - do { - h = h / 3; - for (i = h; i <= 255; i++) { - vv = runningOrder[i]; - j = i; - while ( BIGFREQ(runningOrder[j-h]) > BIGFREQ(vv) ) { - runningOrder[j] = runningOrder[j-h]; - j = j - h; - if (j <= (h - 1)) goto zero; - } - zero: - runningOrder[j] = vv; - } - } while (h != 1); - } - - /*-- - The main sorting loop. - --*/ - - numQSorted = 0; - - for (i = 0; i <= 255; i++) { - - /*-- - Process big buckets, starting with the least full. - Basically this is a 3-step process in which we call - mainQSort3 to sort the small buckets [ss, j], but - also make a big effort to avoid the calls if we can. - --*/ - ss = runningOrder[i]; - - /*-- - Step 1: - Complete the big bucket [ss] by quicksorting - any unsorted small buckets [ss, j], for j != ss. - Hopefully previous pointer-scanning phases have already - completed many of the small buckets [ss, j], so - we don't have to sort them at all. - --*/ - for (j = 0; j <= 255; j++) { - if (j != ss) { - sb = (ss << 8) + j; - if ( ! (ftab[sb] & SETMASK) ) { - Int32 lo = ftab[sb] & CLEARMASK; - Int32 hi = (ftab[sb+1] & CLEARMASK) - 1; - if (hi > lo) { - if (verb >= 4) - VPrintf4 ( " qsort [0x%x, 0x%x] " - "done %d this %d\n", - ss, j, numQSorted, hi - lo + 1 ); - mainQSort3 ( - ptr, block, quadrant, nblock, - lo, hi, BZ_N_RADIX, budget - ); - numQSorted += (hi - lo + 1); - if (*budget < 0) return; - } - } - ftab[sb] |= SETMASK; - } - } - - AssertH ( !bigDone[ss], 1006 ); - - /*-- - Step 2: - Now scan this big bucket [ss] so as to synthesise the - sorted order for small buckets [t, ss] for all t, - including, magically, the bucket [ss,ss] too. - This will avoid doing Real Work in subsequent Step 1's. - --*/ - { - for (j = 0; j <= 255; j++) { - copyStart[j] = ftab[(j << 8) + ss] & CLEARMASK; - copyEnd [j] = (ftab[(j << 8) + ss + 1] & CLEARMASK) - 1; - } - for (j = ftab[ss << 8] & CLEARMASK; j < copyStart[ss]; j++) { - k = ptr[j]-1; if (k < 0) k += nblock; - c1 = block[k]; - if (!bigDone[c1]) - ptr[ copyStart[c1]++ ] = k; - } - for (j = (ftab[(ss+1) << 8] & CLEARMASK) - 1; j > copyEnd[ss]; j--) { - k = ptr[j]-1; if (k < 0) k += nblock; - c1 = block[k]; - if (!bigDone[c1]) - ptr[ copyEnd[c1]-- ] = k; - } - } - - AssertH ( (copyStart[ss]-1 == copyEnd[ss]) - || - /* Extremely rare case missing in bzip2-1.0.0 and 1.0.1. - Necessity for this case is demonstrated by compressing - a sequence of approximately 48.5 million of character - 251; 1.0.0/1.0.1 will then die here. */ - (copyStart[ss] == 0 && copyEnd[ss] == nblock-1), - 1007 ) - - for (j = 0; j <= 255; j++) ftab[(j << 8) + ss] |= SETMASK; - - /*-- - Step 3: - The [ss] big bucket is now done. Record this fact, - and update the quadrant descriptors. Remember to - update quadrants in the overshoot area too, if - necessary. The "if (i < 255)" test merely skips - this updating for the last bucket processed, since - updating for the last bucket is pointless. - - The quadrant array provides a way to incrementally - cache sort orderings, as they appear, so as to - make subsequent comparisons in fullGtU() complete - faster. For repetitive blocks this makes a big - difference (but not big enough to be able to avoid - the fallback sorting mechanism, exponential radix sort). - - The precise meaning is: at all times: - - for 0 <= i < nblock and 0 <= j <= nblock - - if block[i] != block[j], - - then the relative values of quadrant[i] and - quadrant[j] are meaningless. - - else { - if quadrant[i] < quadrant[j] - then the string starting at i lexicographically - precedes the string starting at j - - else if quadrant[i] > quadrant[j] - then the string starting at j lexicographically - precedes the string starting at i - - else - the relative ordering of the strings starting - at i and j has not yet been determined. - } - --*/ - bigDone[ss] = True; - - if (i < 255) { - Int32 bbStart = ftab[ss << 8] & CLEARMASK; - Int32 bbSize = (ftab[(ss+1) << 8] & CLEARMASK) - bbStart; - Int32 shifts = 0; - - while ((bbSize >> shifts) > 65534) shifts++; - - for (j = bbSize-1; j >= 0; j--) { - Int32 a2update = ptr[bbStart + j]; - UInt16 qVal = (UInt16)(j >> shifts); - quadrant[a2update] = qVal; - if (a2update < BZ_N_OVERSHOOT) - quadrant[a2update + nblock] = qVal; - } - AssertH ( ((bbSize-1) >> shifts) <= 65535, 1002 ); - } - - } - - if (verb >= 4) - VPrintf3 ( " %d pointers, %d sorted, %d scanned\n", - nblock, numQSorted, nblock - numQSorted ); -} - -#undef BIGFREQ -#undef SETMASK -#undef CLEARMASK - - -/*---------------------------------------------*/ -/* Pre: - nblock > 0 - arr2 exists for [0 .. nblock-1 +N_OVERSHOOT] - ((UChar*)arr2) [0 .. nblock-1] holds block - arr1 exists for [0 .. nblock-1] - - Post: - ((UChar*)arr2) [0 .. nblock-1] holds block - All other areas of block destroyed - ftab [ 0 .. 65536 ] destroyed - arr1 [0 .. nblock-1] holds sorted order -*/ -void BZ2_blockSort ( EState* s ) -{ - UInt32* ptr = s->ptr; - UChar* block = s->block; - UInt32* ftab = s->ftab; - Int32 nblock = s->nblock; - Int32 verb = s->verbosity; - Int32 wfact = s->workFactor; - UInt16* quadrant; - Int32 budget; - Int32 budgetInit; - Int32 i; - - if (nblock < 10000) { - fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb ); - } else { - /* Calculate the location for quadrant, remembering to get - the alignment right. Assumes that &(block[0]) is at least - 2-byte aligned -- this should be ok since block is really - the first section of arr2. - */ - i = nblock+BZ_N_OVERSHOOT; - if (i & 1) i++; - quadrant = (UInt16*)(&(block[i])); - - /* (wfact-1) / 3 puts the default-factor-30 - transition point at very roughly the same place as - with v0.1 and v0.9.0. - Not that it particularly matters any more, since the - resulting compressed stream is now the same regardless - of whether or not we use the main sort or fallback sort. - */ - if (wfact < 1 ) wfact = 1; - if (wfact > 100) wfact = 100; - budgetInit = nblock * ((wfact-1) / 3); - budget = budgetInit; - - mainSort ( ptr, block, quadrant, ftab, nblock, verb, &budget ); - if (verb >= 3) - VPrintf3 ( " %d work, %d block, ratio %5.2f\n", - budgetInit - budget, - nblock, - (float)(budgetInit - budget) / - (float)(nblock==0 ? 1 : nblock) ); - if (budget < 0) { - if (verb >= 2) - VPrintf0 ( " too repetitive; using fallback" - " sorting algorithm\n" ); - fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb ); - } - } - - s->origPtr = -1; - for (i = 0; i < s->nblock; i++) - if (ptr[i] == 0) - { s->origPtr = i; break; }; - - AssertH( s->origPtr != -1, 1003 ); -} - - -/*-------------------------------------------------------------*/ -/*--- end blocksort.c ---*/ -/*-------------------------------------------------------------*/ diff --git a/libs/storm-sys/StormLib/src/bzip2/bzlib.c b/libs/storm-sys/StormLib/src/bzip2/bzlib.c deleted file mode 100644 index b98f3e5..0000000 --- a/libs/storm-sys/StormLib/src/bzip2/bzlib.c +++ /dev/null @@ -1,1573 +0,0 @@ - -/*-------------------------------------------------------------*/ -/*--- Library top-level functions. ---*/ -/*--- bzlib.c ---*/ -/*-------------------------------------------------------------*/ - -/* ------------------------------------------------------------------ - This file is part of bzip2/libbzip2, a program and library for - lossless, block-sorting data compression. - - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward - - Please read the WARNING, DISCLAIMER and PATENTS sections in the - README file. - - This program is released under the terms of the license contained - in the file LICENSE. - ------------------------------------------------------------------ */ - -/* CHANGES - 0.9.0 -- original version. - 0.9.0a/b -- no changes in this file. - 0.9.0c -- made zero-length BZ_FLUSH work correctly in bzCompress(). - fixed bzWrite/bzRead to ignore zero-length requests. - fixed bzread to correctly handle read requests after EOF. - wrong parameter order in call to bzDecompressInit in - bzBuffToBuffDecompress. Fixed. -*/ - -#define _CRT_SECURE_NO_WARNINGS -#include "bzlib_private.h" - - -/*---------------------------------------------------*/ -/*--- Compression stuff ---*/ -/*---------------------------------------------------*/ - - -/*---------------------------------------------------*/ -#ifndef BZ_NO_STDIO -void BZ2_bz__AssertH__fail ( int errcode ) -{ - fprintf(stderr, - "\n\nbzip2/libbzip2: internal error number %d.\n" - "This is a bug in bzip2/libbzip2, %s.\n" - "Please report it to me at: jseward@bzip.org. If this happened\n" - "when you were using some program which uses libbzip2 as a\n" - "component, you should also report this bug to the author(s)\n" - "of that program. Please make an effort to report this bug;\n" - "timely and accurate bug reports eventually lead to higher\n" - "quality software. Thanks. Julian Seward, 10 December 2007.\n\n", - errcode, - BZ2_bzlibVersion() - ); - - if (errcode == 1007) { - fprintf(stderr, - "\n*** A special note about internal error number 1007 ***\n" - "\n" - "Experience suggests that a common cause of i.e. 1007\n" - "is unreliable memory or other hardware. The 1007 assertion\n" - "just happens to cross-check the results of huge numbers of\n" - "memory reads/writes, and so acts (unintendedly) as a stress\n" - "test of your memory system.\n" - "\n" - "I suggest the following: try compressing the file again,\n" - "possibly monitoring progress in detail with the -vv flag.\n" - "\n" - "* If the error cannot be reproduced, and/or happens at different\n" - " points in compression, you may have a flaky memory system.\n" - " Try a memory-test program. I have used Memtest86\n" - " (www.memtest86.com). At the time of writing it is free (GPLd).\n" - " Memtest86 tests memory much more thorougly than your BIOSs\n" - " power-on test, and may find failures that the BIOS doesn't.\n" - "\n" - "* If the error can be repeatably reproduced, this is a bug in\n" - " bzip2, and I would very much like to hear about it. Please\n" - " let me know, and, ideally, save a copy of the file causing the\n" - " problem -- without which I will be unable to investigate it.\n" - "\n" - ); - } - - exit(3); -} -#endif - - -/*---------------------------------------------------*/ -static -int bz_config_ok ( void ) -{ - if (sizeof(int) != 4) return 0; - if (sizeof(short) != 2) return 0; - if (sizeof(char) != 1) return 0; - return 1; -} - - -/*---------------------------------------------------*/ -static -void* default_bzalloc ( void* opaque, Int32 items, Int32 size ) -{ - void* v = malloc ( items * size ); - return v; -} - -static -void default_bzfree ( void* opaque, void* addr ) -{ - if (addr != NULL) free ( addr ); -} - - -/*---------------------------------------------------*/ -static -void prepare_new_block ( EState* s ) -{ - Int32 i; - s->nblock = 0; - s->numZ = 0; - s->state_out_pos = 0; - BZ_INITIALISE_CRC ( s->blockCRC ); - for (i = 0; i < 256; i++) s->inUse[i] = False; - s->blockNo++; -} - - -/*---------------------------------------------------*/ -static -void init_RL ( EState* s ) -{ - s->state_in_ch = 256; - s->state_in_len = 0; -} - - -static -Bool isempty_RL ( EState* s ) -{ - if (s->state_in_ch < 256 && s->state_in_len > 0) - return False; else - return True; -} - - -/*---------------------------------------------------*/ -int BZ_API(BZ2_bzCompressInit) - ( bz_stream* strm, - int blockSize100k, - int verbosity, - int workFactor ) -{ - Int32 n; - EState* s; - - if (!bz_config_ok()) return BZ_CONFIG_ERROR; - - if (strm == NULL || - blockSize100k < 1 || blockSize100k > 9 || - workFactor < 0 || workFactor > 250) - return BZ_PARAM_ERROR; - - if (workFactor == 0) workFactor = 30; - if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc; - if (strm->bzfree == NULL) strm->bzfree = default_bzfree; - - s = BZALLOC( sizeof(EState) ); - if (s == NULL) return BZ_MEM_ERROR; - s->strm = strm; - - s->arr1 = NULL; - s->arr2 = NULL; - s->ftab = NULL; - - n = 100000 * blockSize100k; - s->arr1 = BZALLOC( n * sizeof(UInt32) ); - s->arr2 = BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) ); - s->ftab = BZALLOC( 65537 * sizeof(UInt32) ); - - if (s->arr1 == NULL || s->arr2 == NULL || s->ftab == NULL) { - if (s->arr1 != NULL) BZFREE(s->arr1); - if (s->arr2 != NULL) BZFREE(s->arr2); - if (s->ftab != NULL) BZFREE(s->ftab); - if (s != NULL) BZFREE(s); - return BZ_MEM_ERROR; - } - - s->blockNo = 0; - s->state = BZ_S_INPUT; - s->mode = BZ_M_RUNNING; - s->combinedCRC = 0; - s->blockSize100k = blockSize100k; - s->nblockMAX = 100000 * blockSize100k - 19; - s->verbosity = verbosity; - s->workFactor = workFactor; - - s->block = (UChar*)s->arr2; - s->mtfv = (UInt16*)s->arr1; - s->zbits = NULL; - s->ptr = (UInt32*)s->arr1; - - strm->state = s; - strm->total_in_lo32 = 0; - strm->total_in_hi32 = 0; - strm->total_out_lo32 = 0; - strm->total_out_hi32 = 0; - init_RL ( s ); - prepare_new_block ( s ); - return BZ_OK; -} - - -/*---------------------------------------------------*/ -static -void add_pair_to_block ( EState* s ) -{ - Int32 i; - UChar ch = (UChar)(s->state_in_ch); - for (i = 0; i < s->state_in_len; i++) { - BZ_UPDATE_CRC( s->blockCRC, ch ); - } - s->inUse[s->state_in_ch] = True; - switch (s->state_in_len) { - case 1: - s->block[s->nblock] = (UChar)ch; s->nblock++; - break; - case 2: - s->block[s->nblock] = (UChar)ch; s->nblock++; - s->block[s->nblock] = (UChar)ch; s->nblock++; - break; - case 3: - s->block[s->nblock] = (UChar)ch; s->nblock++; - s->block[s->nblock] = (UChar)ch; s->nblock++; - s->block[s->nblock] = (UChar)ch; s->nblock++; - break; - default: - s->inUse[s->state_in_len-4] = True; - s->block[s->nblock] = (UChar)ch; s->nblock++; - s->block[s->nblock] = (UChar)ch; s->nblock++; - s->block[s->nblock] = (UChar)ch; s->nblock++; - s->block[s->nblock] = (UChar)ch; s->nblock++; - s->block[s->nblock] = ((UChar)(s->state_in_len-4)); - s->nblock++; - break; - } -} - - -/*---------------------------------------------------*/ -static -void flush_RL ( EState* s ) -{ - if (s->state_in_ch < 256) add_pair_to_block ( s ); - init_RL ( s ); -} - - -/*---------------------------------------------------*/ -#define ADD_CHAR_TO_BLOCK(zs,zchh0) \ -{ \ - UInt32 zchh = (UInt32)(zchh0); \ - /*-- fast track the common case --*/ \ - if (zchh != zs->state_in_ch && \ - zs->state_in_len == 1) { \ - UChar ch = (UChar)(zs->state_in_ch); \ - BZ_UPDATE_CRC( zs->blockCRC, ch ); \ - zs->inUse[zs->state_in_ch] = True; \ - zs->block[zs->nblock] = (UChar)ch; \ - zs->nblock++; \ - zs->state_in_ch = zchh; \ - } \ - else \ - /*-- general, uncommon cases --*/ \ - if (zchh != zs->state_in_ch || \ - zs->state_in_len == 255) { \ - if (zs->state_in_ch < 256) \ - add_pair_to_block ( zs ); \ - zs->state_in_ch = zchh; \ - zs->state_in_len = 1; \ - } else { \ - zs->state_in_len++; \ - } \ -} - - -/*---------------------------------------------------*/ -static -Bool copy_input_until_stop ( EState* s ) -{ - Bool progress_in = False; - - if (s->mode == BZ_M_RUNNING) { - - /*-- fast track the common case --*/ - while (True) { - /*-- block full? --*/ - if (s->nblock >= s->nblockMAX) break; - /*-- no input? --*/ - if (s->strm->avail_in == 0) break; - progress_in = True; - ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); - s->strm->next_in++; - s->strm->avail_in--; - s->strm->total_in_lo32++; - if (s->strm->total_in_lo32 == 0) s->strm->total_in_hi32++; - } - - } else { - - /*-- general, uncommon case --*/ - while (True) { - /*-- block full? --*/ - if (s->nblock >= s->nblockMAX) break; - /*-- no input? --*/ - if (s->strm->avail_in == 0) break; - /*-- flush/finish end? --*/ - if (s->avail_in_expect == 0) break; - progress_in = True; - ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); - s->strm->next_in++; - s->strm->avail_in--; - s->strm->total_in_lo32++; - if (s->strm->total_in_lo32 == 0) s->strm->total_in_hi32++; - s->avail_in_expect--; - } - } - return progress_in; -} - - -/*---------------------------------------------------*/ -static -Bool copy_output_until_stop ( EState* s ) -{ - Bool progress_out = False; - - while (True) { - - /*-- no output space? --*/ - if (s->strm->avail_out == 0) break; - - /*-- block done? --*/ - if (s->state_out_pos >= s->numZ) break; - - progress_out = True; - *(s->strm->next_out) = s->zbits[s->state_out_pos]; - s->state_out_pos++; - s->strm->avail_out--; - s->strm->next_out++; - s->strm->total_out_lo32++; - if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; - } - - return progress_out; -} - - -/*---------------------------------------------------*/ -static -Bool handle_compress ( bz_stream* strm ) -{ - Bool progress_in = False; - Bool progress_out = False; - EState* s = strm->state; - - while (True) { - - if (s->state == BZ_S_OUTPUT) { - progress_out |= copy_output_until_stop ( s ); - if (s->state_out_pos < s->numZ) break; - if (s->mode == BZ_M_FINISHING && - s->avail_in_expect == 0 && - isempty_RL(s)) break; - prepare_new_block ( s ); - s->state = BZ_S_INPUT; - if (s->mode == BZ_M_FLUSHING && - s->avail_in_expect == 0 && - isempty_RL(s)) break; - } - - if (s->state == BZ_S_INPUT) { - progress_in |= copy_input_until_stop ( s ); - if (s->mode != BZ_M_RUNNING && s->avail_in_expect == 0) { - flush_RL ( s ); - BZ2_compressBlock ( s, (Bool)(s->mode == BZ_M_FINISHING) ); - s->state = BZ_S_OUTPUT; - } - else - if (s->nblock >= s->nblockMAX) { - BZ2_compressBlock ( s, False ); - s->state = BZ_S_OUTPUT; - } - else - if (s->strm->avail_in == 0) { - break; - } - } - - } - - return progress_in || progress_out; -} - - -/*---------------------------------------------------*/ -int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action ) -{ - Bool progress; - EState* s; - if (strm == NULL) return BZ_PARAM_ERROR; - s = strm->state; - if (s == NULL) return BZ_PARAM_ERROR; - if (s->strm != strm) return BZ_PARAM_ERROR; - - preswitch: - switch (s->mode) { - - case BZ_M_IDLE: - return BZ_SEQUENCE_ERROR; - - case BZ_M_RUNNING: - if (action == BZ_RUN) { - progress = handle_compress ( strm ); - return progress ? BZ_RUN_OK : BZ_PARAM_ERROR; - } - else - if (action == BZ_FLUSH) { - s->avail_in_expect = strm->avail_in; - s->mode = BZ_M_FLUSHING; - goto preswitch; - } - else - if (action == BZ_FINISH) { - s->avail_in_expect = strm->avail_in; - s->mode = BZ_M_FINISHING; - goto preswitch; - } - else - return BZ_PARAM_ERROR; - - case BZ_M_FLUSHING: - if (action != BZ_FLUSH) return BZ_SEQUENCE_ERROR; - if (s->avail_in_expect != s->strm->avail_in) - return BZ_SEQUENCE_ERROR; - progress = handle_compress ( strm ); - if (s->avail_in_expect > 0 || !isempty_RL(s) || - s->state_out_pos < s->numZ) return BZ_FLUSH_OK; - s->mode = BZ_M_RUNNING; - return BZ_RUN_OK; - - case BZ_M_FINISHING: - if (action != BZ_FINISH) return BZ_SEQUENCE_ERROR; - if (s->avail_in_expect != s->strm->avail_in) - return BZ_SEQUENCE_ERROR; - progress = handle_compress ( strm ); - if (!progress) return BZ_SEQUENCE_ERROR; - if (s->avail_in_expect > 0 || !isempty_RL(s) || - s->state_out_pos < s->numZ) return BZ_FINISH_OK; - s->mode = BZ_M_IDLE; - return BZ_STREAM_END; - } - return BZ_OK; /*--not reached--*/ -} - - -/*---------------------------------------------------*/ -int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm ) -{ - EState* s; - if (strm == NULL) return BZ_PARAM_ERROR; - s = strm->state; - if (s == NULL) return BZ_PARAM_ERROR; - if (s->strm != strm) return BZ_PARAM_ERROR; - - if (s->arr1 != NULL) BZFREE(s->arr1); - if (s->arr2 != NULL) BZFREE(s->arr2); - if (s->ftab != NULL) BZFREE(s->ftab); - BZFREE(strm->state); - - strm->state = NULL; - - return BZ_OK; -} - - -/*---------------------------------------------------*/ -/*--- Decompression stuff ---*/ -/*---------------------------------------------------*/ - -/*---------------------------------------------------*/ -int BZ_API(BZ2_bzDecompressInit) - ( bz_stream* strm, - int verbosity, - int small ) -{ - DState* s; - - if (!bz_config_ok()) return BZ_CONFIG_ERROR; - - if (strm == NULL) return BZ_PARAM_ERROR; - if (small != 0 && small != 1) return BZ_PARAM_ERROR; - if (verbosity < 0 || verbosity > 4) return BZ_PARAM_ERROR; - - if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc; - if (strm->bzfree == NULL) strm->bzfree = default_bzfree; - - s = BZALLOC( sizeof(DState) ); - if (s == NULL) return BZ_MEM_ERROR; - s->strm = strm; - strm->state = s; - s->state = BZ_X_MAGIC_1; - s->bsLive = 0; - s->bsBuff = 0; - s->calculatedCombinedCRC = 0; - strm->total_in_lo32 = 0; - strm->total_in_hi32 = 0; - strm->total_out_lo32 = 0; - strm->total_out_hi32 = 0; - s->smallDecompress = (Bool)small; - s->ll4 = NULL; - s->ll16 = NULL; - s->tt = NULL; - s->currBlockNo = 0; - s->verbosity = verbosity; - - return BZ_OK; -} - - -/*---------------------------------------------------*/ -/* Return True iff data corruption is discovered. - Returns False if there is no problem. -*/ -static -Bool unRLE_obuf_to_output_FAST ( DState* s ) -{ - UChar k1; - - if (s->blockRandomised) { - - while (True) { - /* try to finish existing run */ - while (True) { - if (s->strm->avail_out == 0) return False; - if (s->state_out_len == 0) break; - *( (UChar*)(s->strm->next_out) ) = s->state_out_ch; - BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch ); - s->state_out_len--; - s->strm->next_out++; - s->strm->avail_out--; - s->strm->total_out_lo32++; - if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; - } - - /* can a new run be started? */ - if (s->nblock_used == s->save_nblock+1) return False; - - /* Only caused by corrupt data stream? */ - if (s->nblock_used > s->save_nblock+1) - return True; - - s->state_out_len = 1; - s->state_out_ch = s->k0; - BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; - k1 ^= BZ_RAND_MASK; s->nblock_used++; - if (s->nblock_used == s->save_nblock+1) continue; - if (k1 != s->k0) { s->k0 = k1; continue; }; - - s->state_out_len = 2; - BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; - k1 ^= BZ_RAND_MASK; s->nblock_used++; - if (s->nblock_used == s->save_nblock+1) continue; - if (k1 != s->k0) { s->k0 = k1; continue; }; - - s->state_out_len = 3; - BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; - k1 ^= BZ_RAND_MASK; s->nblock_used++; - if (s->nblock_used == s->save_nblock+1) continue; - if (k1 != s->k0) { s->k0 = k1; continue; }; - - BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; - k1 ^= BZ_RAND_MASK; s->nblock_used++; - s->state_out_len = ((Int32)k1) + 4; - BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK; - s->k0 ^= BZ_RAND_MASK; s->nblock_used++; - } - - } else { - - /* restore */ - UInt32 c_calculatedBlockCRC = s->calculatedBlockCRC; - UChar c_state_out_ch = s->state_out_ch; - Int32 c_state_out_len = s->state_out_len; - Int32 c_nblock_used = s->nblock_used; - Int32 c_k0 = s->k0; - UInt32* c_tt = s->tt; - UInt32 c_tPos = s->tPos; - char* cs_next_out = s->strm->next_out; - unsigned int cs_avail_out = s->strm->avail_out; - Int32 ro_blockSize100k = s->blockSize100k; - /* end restore */ - - UInt32 avail_out_INIT = cs_avail_out; - Int32 s_save_nblockPP = s->save_nblock+1; - unsigned int total_out_lo32_old; - - while (True) { - - /* try to finish existing run */ - if (c_state_out_len > 0) { - while (True) { - if (cs_avail_out == 0) goto return_notr; - if (c_state_out_len == 1) break; - *( (UChar*)(cs_next_out) ) = c_state_out_ch; - BZ_UPDATE_CRC ( c_calculatedBlockCRC, c_state_out_ch ); - c_state_out_len--; - cs_next_out++; - cs_avail_out--; - } - s_state_out_len_eq_one: - { - if (cs_avail_out == 0) { - c_state_out_len = 1; goto return_notr; - }; - *( (UChar*)(cs_next_out) ) = c_state_out_ch; - BZ_UPDATE_CRC ( c_calculatedBlockCRC, c_state_out_ch ); - cs_next_out++; - cs_avail_out--; - } - } - /* Only caused by corrupt data stream? */ - if (c_nblock_used > s_save_nblockPP) - return True; - - /* can a new run be started? */ - if (c_nblock_used == s_save_nblockPP) { - c_state_out_len = 0; goto return_notr; - }; - c_state_out_ch = c_k0; - BZ_GET_FAST_C(k1); c_nblock_used++; - if (k1 != c_k0) { - c_k0 = k1; goto s_state_out_len_eq_one; - }; - if (c_nblock_used == s_save_nblockPP) - goto s_state_out_len_eq_one; - - c_state_out_len = 2; - BZ_GET_FAST_C(k1); c_nblock_used++; - if (c_nblock_used == s_save_nblockPP) continue; - if (k1 != c_k0) { c_k0 = k1; continue; }; - - c_state_out_len = 3; - BZ_GET_FAST_C(k1); c_nblock_used++; - if (c_nblock_used == s_save_nblockPP) continue; - if (k1 != c_k0) { c_k0 = k1; continue; }; - - BZ_GET_FAST_C(k1); c_nblock_used++; - c_state_out_len = ((Int32)k1) + 4; - BZ_GET_FAST_C(c_k0); c_nblock_used++; - } - - return_notr: - total_out_lo32_old = s->strm->total_out_lo32; - s->strm->total_out_lo32 += (avail_out_INIT - cs_avail_out); - if (s->strm->total_out_lo32 < total_out_lo32_old) - s->strm->total_out_hi32++; - - /* save */ - s->calculatedBlockCRC = c_calculatedBlockCRC; - s->state_out_ch = c_state_out_ch; - s->state_out_len = c_state_out_len; - s->nblock_used = c_nblock_used; - s->k0 = c_k0; - s->tt = c_tt; - s->tPos = c_tPos; - s->strm->next_out = cs_next_out; - s->strm->avail_out = cs_avail_out; - /* end save */ - } - return False; -} - - - -/*---------------------------------------------------*/ -__inline__ Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab ) -{ - Int32 nb, na, mid; - nb = 0; - na = 256; - do { - mid = (nb + na) >> 1; - if (indx >= cftab[mid]) nb = mid; else na = mid; - } - while (na - nb != 1); - return nb; -} - - -/*---------------------------------------------------*/ -/* Return True iff data corruption is discovered. - Returns False if there is no problem. -*/ -static -Bool unRLE_obuf_to_output_SMALL ( DState* s ) -{ - UChar k1; - - if (s->blockRandomised) { - - while (True) { - /* try to finish existing run */ - while (True) { - if (s->strm->avail_out == 0) return False; - if (s->state_out_len == 0) break; - *( (UChar*)(s->strm->next_out) ) = s->state_out_ch; - BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch ); - s->state_out_len--; - s->strm->next_out++; - s->strm->avail_out--; - s->strm->total_out_lo32++; - if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; - } - - /* can a new run be started? */ - if (s->nblock_used == s->save_nblock+1) return False; - - /* Only caused by corrupt data stream? */ - if (s->nblock_used > s->save_nblock+1) - return True; - - s->state_out_len = 1; - s->state_out_ch = s->k0; - BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; - k1 ^= BZ_RAND_MASK; s->nblock_used++; - if (s->nblock_used == s->save_nblock+1) continue; - if (k1 != s->k0) { s->k0 = k1; continue; }; - - s->state_out_len = 2; - BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; - k1 ^= BZ_RAND_MASK; s->nblock_used++; - if (s->nblock_used == s->save_nblock+1) continue; - if (k1 != s->k0) { s->k0 = k1; continue; }; - - s->state_out_len = 3; - BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; - k1 ^= BZ_RAND_MASK; s->nblock_used++; - if (s->nblock_used == s->save_nblock+1) continue; - if (k1 != s->k0) { s->k0 = k1; continue; }; - - BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; - k1 ^= BZ_RAND_MASK; s->nblock_used++; - s->state_out_len = ((Int32)k1) + 4; - BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK; - s->k0 ^= BZ_RAND_MASK; s->nblock_used++; - } - - } else { - - while (True) { - /* try to finish existing run */ - while (True) { - if (s->strm->avail_out == 0) return False; - if (s->state_out_len == 0) break; - *( (UChar*)(s->strm->next_out) ) = s->state_out_ch; - BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch ); - s->state_out_len--; - s->strm->next_out++; - s->strm->avail_out--; - s->strm->total_out_lo32++; - if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; - } - - /* can a new run be started? */ - if (s->nblock_used == s->save_nblock+1) return False; - - /* Only caused by corrupt data stream? */ - if (s->nblock_used > s->save_nblock+1) - return True; - - s->state_out_len = 1; - s->state_out_ch = s->k0; - BZ_GET_SMALL(k1); s->nblock_used++; - if (s->nblock_used == s->save_nblock+1) continue; - if (k1 != s->k0) { s->k0 = k1; continue; }; - - s->state_out_len = 2; - BZ_GET_SMALL(k1); s->nblock_used++; - if (s->nblock_used == s->save_nblock+1) continue; - if (k1 != s->k0) { s->k0 = k1; continue; }; - - s->state_out_len = 3; - BZ_GET_SMALL(k1); s->nblock_used++; - if (s->nblock_used == s->save_nblock+1) continue; - if (k1 != s->k0) { s->k0 = k1; continue; }; - - BZ_GET_SMALL(k1); s->nblock_used++; - s->state_out_len = ((Int32)k1) + 4; - BZ_GET_SMALL(s->k0); s->nblock_used++; - } - - } -} - - -/*---------------------------------------------------*/ -int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) -{ - Bool corrupt; - DState* s; - if (strm == NULL) return BZ_PARAM_ERROR; - s = strm->state; - if (s == NULL) return BZ_PARAM_ERROR; - if (s->strm != strm) return BZ_PARAM_ERROR; - - while (True) { - if (s->state == BZ_X_IDLE) return BZ_SEQUENCE_ERROR; - if (s->state == BZ_X_OUTPUT) { - if (s->smallDecompress) - corrupt = unRLE_obuf_to_output_SMALL ( s ); else - corrupt = unRLE_obuf_to_output_FAST ( s ); - if (corrupt) return BZ_DATA_ERROR; - if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) { - BZ_FINALISE_CRC ( s->calculatedBlockCRC ); - if (s->verbosity >= 3) - VPrintf2 ( " {0x%08x, 0x%08x}", s->storedBlockCRC, - s->calculatedBlockCRC ); - if (s->verbosity >= 2) VPrintf0 ( "]" ); - if (s->calculatedBlockCRC != s->storedBlockCRC) - return BZ_DATA_ERROR; - s->calculatedCombinedCRC - = (s->calculatedCombinedCRC << 1) | - (s->calculatedCombinedCRC >> 31); - s->calculatedCombinedCRC ^= s->calculatedBlockCRC; - s->state = BZ_X_BLKHDR_1; - } else { - return BZ_OK; - } - } - if (s->state >= BZ_X_MAGIC_1) { - Int32 r = BZ2_decompress ( s ); - if (r == BZ_STREAM_END) { - if (s->verbosity >= 3) - VPrintf2 ( "\n combined CRCs: stored = 0x%08x, computed = 0x%08x", - s->storedCombinedCRC, s->calculatedCombinedCRC ); - if (s->calculatedCombinedCRC != s->storedCombinedCRC) - return BZ_DATA_ERROR; - return r; - } - if (s->state != BZ_X_OUTPUT) return r; - } - } - - AssertH ( 0, 6001 ); - - return 0; /*NOTREACHED*/ -} - - -/*---------------------------------------------------*/ -int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm ) -{ - DState* s; - if (strm == NULL) return BZ_PARAM_ERROR; - s = strm->state; - if (s == NULL) return BZ_PARAM_ERROR; - if (s->strm != strm) return BZ_PARAM_ERROR; - - if (s->tt != NULL) BZFREE(s->tt); - if (s->ll16 != NULL) BZFREE(s->ll16); - if (s->ll4 != NULL) BZFREE(s->ll4); - - BZFREE(strm->state); - strm->state = NULL; - - return BZ_OK; -} - - -#ifndef BZ_NO_STDIO -/*---------------------------------------------------*/ -/*--- File I/O stuff ---*/ -/*---------------------------------------------------*/ - -#define BZ_SETERR(eee) \ -{ \ - if (bzerror != NULL) *bzerror = eee; \ - if (bzf != NULL) bzf->lastErr = eee; \ -} - -typedef - struct { - FILE* handle; - Char buf[BZ_MAX_UNUSED]; - Int32 bufN; - Bool writing; - bz_stream strm; - Int32 lastErr; - Bool initialisedOk; - } - bzFile; - - -/*---------------------------------------------*/ -static Bool myfeof ( FILE* f ) -{ - Int32 c = fgetc ( f ); - if (c == EOF) return True; - ungetc ( c, f ); - return False; -} - - -/*---------------------------------------------------*/ -BZFILE* BZ_API(BZ2_bzWriteOpen) - ( int* bzerror, - FILE* f, - int blockSize100k, - int verbosity, - int workFactor ) -{ - Int32 ret; - bzFile* bzf = NULL; - - BZ_SETERR(BZ_OK); - - if (f == NULL || - (blockSize100k < 1 || blockSize100k > 9) || - (workFactor < 0 || workFactor > 250) || - (verbosity < 0 || verbosity > 4)) - { BZ_SETERR(BZ_PARAM_ERROR); return NULL; }; - - if (ferror(f)) - { BZ_SETERR(BZ_IO_ERROR); return NULL; }; - - bzf = malloc ( sizeof(bzFile) ); - if (bzf == NULL) - { BZ_SETERR(BZ_MEM_ERROR); return NULL; }; - - BZ_SETERR(BZ_OK); - bzf->initialisedOk = False; - bzf->bufN = 0; - bzf->handle = f; - bzf->writing = True; - bzf->strm.bzalloc = NULL; - bzf->strm.bzfree = NULL; - bzf->strm.opaque = NULL; - - if (workFactor == 0) workFactor = 30; - ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k, - verbosity, workFactor ); - if (ret != BZ_OK) - { BZ_SETERR(ret); free(bzf); return NULL; }; - - bzf->strm.avail_in = 0; - bzf->initialisedOk = True; - return bzf; -} - - - -/*---------------------------------------------------*/ -void BZ_API(BZ2_bzWrite) - ( int* bzerror, - BZFILE* b, - void* buf, - int len ) -{ - Int32 n, n2, ret; - bzFile* bzf = (bzFile*)b; - - BZ_SETERR(BZ_OK); - if (bzf == NULL || buf == NULL || len < 0) - { BZ_SETERR(BZ_PARAM_ERROR); return; }; - if (!(bzf->writing)) - { BZ_SETERR(BZ_SEQUENCE_ERROR); return; }; - if (ferror(bzf->handle)) - { BZ_SETERR(BZ_IO_ERROR); return; }; - - if (len == 0) - { BZ_SETERR(BZ_OK); return; }; - - bzf->strm.avail_in = len; - bzf->strm.next_in = buf; - - while (True) { - bzf->strm.avail_out = BZ_MAX_UNUSED; - bzf->strm.next_out = bzf->buf; - ret = BZ2_bzCompress ( &(bzf->strm), BZ_RUN ); - if (ret != BZ_RUN_OK) - { BZ_SETERR(ret); return; }; - - if (bzf->strm.avail_out < BZ_MAX_UNUSED) { - n = BZ_MAX_UNUSED - bzf->strm.avail_out; - n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), - n, bzf->handle ); - if (n != n2 || ferror(bzf->handle)) - { BZ_SETERR(BZ_IO_ERROR); return; }; - } - - if (bzf->strm.avail_in == 0) - { BZ_SETERR(BZ_OK); return; }; - } -} - - -/*---------------------------------------------------*/ -void BZ_API(BZ2_bzWriteClose) - ( int* bzerror, - BZFILE* b, - int abandon, - unsigned int* nbytes_in, - unsigned int* nbytes_out ) -{ - BZ2_bzWriteClose64 ( bzerror, b, abandon, - nbytes_in, NULL, nbytes_out, NULL ); -} - - -void BZ_API(BZ2_bzWriteClose64) - ( int* bzerror, - BZFILE* b, - int abandon, - unsigned int* nbytes_in_lo32, - unsigned int* nbytes_in_hi32, - unsigned int* nbytes_out_lo32, - unsigned int* nbytes_out_hi32 ) -{ - Int32 n, n2, ret; - bzFile* bzf = (bzFile*)b; - - if (bzf == NULL) - { BZ_SETERR(BZ_OK); return; }; - if (!(bzf->writing)) - { BZ_SETERR(BZ_SEQUENCE_ERROR); return; }; - if (ferror(bzf->handle)) - { BZ_SETERR(BZ_IO_ERROR); return; }; - - if (nbytes_in_lo32 != NULL) *nbytes_in_lo32 = 0; - if (nbytes_in_hi32 != NULL) *nbytes_in_hi32 = 0; - if (nbytes_out_lo32 != NULL) *nbytes_out_lo32 = 0; - if (nbytes_out_hi32 != NULL) *nbytes_out_hi32 = 0; - - if ((!abandon) && bzf->lastErr == BZ_OK) { - while (True) { - bzf->strm.avail_out = BZ_MAX_UNUSED; - bzf->strm.next_out = bzf->buf; - ret = BZ2_bzCompress ( &(bzf->strm), BZ_FINISH ); - if (ret != BZ_FINISH_OK && ret != BZ_STREAM_END) - { BZ_SETERR(ret); return; }; - - if (bzf->strm.avail_out < BZ_MAX_UNUSED) { - n = BZ_MAX_UNUSED - bzf->strm.avail_out; - n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), - n, bzf->handle ); - if (n != n2 || ferror(bzf->handle)) - { BZ_SETERR(BZ_IO_ERROR); return; }; - } - - if (ret == BZ_STREAM_END) break; - } - } - - if ( !abandon && !ferror ( bzf->handle ) ) { - fflush ( bzf->handle ); - if (ferror(bzf->handle)) - { BZ_SETERR(BZ_IO_ERROR); return; }; - } - - if (nbytes_in_lo32 != NULL) - *nbytes_in_lo32 = bzf->strm.total_in_lo32; - if (nbytes_in_hi32 != NULL) - *nbytes_in_hi32 = bzf->strm.total_in_hi32; - if (nbytes_out_lo32 != NULL) - *nbytes_out_lo32 = bzf->strm.total_out_lo32; - if (nbytes_out_hi32 != NULL) - *nbytes_out_hi32 = bzf->strm.total_out_hi32; - - BZ_SETERR(BZ_OK); - BZ2_bzCompressEnd ( &(bzf->strm) ); - free ( bzf ); -} - - -/*---------------------------------------------------*/ -BZFILE* BZ_API(BZ2_bzReadOpen) - ( int* bzerror, - FILE* f, - int verbosity, - int small, - void* unused, - int nUnused ) -{ - bzFile* bzf = NULL; - int ret; - - BZ_SETERR(BZ_OK); - - if (f == NULL || - (small != 0 && small != 1) || - (verbosity < 0 || verbosity > 4) || - (unused == NULL && nUnused != 0) || - (unused != NULL && (nUnused < 0 || nUnused > BZ_MAX_UNUSED))) - { BZ_SETERR(BZ_PARAM_ERROR); return NULL; }; - - if (ferror(f)) - { BZ_SETERR(BZ_IO_ERROR); return NULL; }; - - bzf = malloc ( sizeof(bzFile) ); - if (bzf == NULL) - { BZ_SETERR(BZ_MEM_ERROR); return NULL; }; - - BZ_SETERR(BZ_OK); - - bzf->initialisedOk = False; - bzf->handle = f; - bzf->bufN = 0; - bzf->writing = False; - bzf->strm.bzalloc = NULL; - bzf->strm.bzfree = NULL; - bzf->strm.opaque = NULL; - - while (nUnused > 0) { - bzf->buf[bzf->bufN] = *((UChar*)(unused)); bzf->bufN++; - unused = ((void*)( 1 + ((UChar*)(unused)) )); - nUnused--; - } - - ret = BZ2_bzDecompressInit ( &(bzf->strm), verbosity, small ); - if (ret != BZ_OK) - { BZ_SETERR(ret); free(bzf); return NULL; }; - - bzf->strm.avail_in = bzf->bufN; - bzf->strm.next_in = bzf->buf; - - bzf->initialisedOk = True; - return bzf; -} - - -/*---------------------------------------------------*/ -void BZ_API(BZ2_bzReadClose) ( int *bzerror, BZFILE *b ) -{ - bzFile* bzf = (bzFile*)b; - - BZ_SETERR(BZ_OK); - if (bzf == NULL) - { BZ_SETERR(BZ_OK); return; }; - - if (bzf->writing) - { BZ_SETERR(BZ_SEQUENCE_ERROR); return; }; - - if (bzf->initialisedOk) - (void)BZ2_bzDecompressEnd ( &(bzf->strm) ); - free ( bzf ); -} - - -/*---------------------------------------------------*/ -int BZ_API(BZ2_bzRead) - ( int* bzerror, - BZFILE* b, - void* buf, - int len ) -{ - Int32 n, ret; - bzFile* bzf = (bzFile*)b; - - BZ_SETERR(BZ_OK); - - if (bzf == NULL || buf == NULL || len < 0) - { BZ_SETERR(BZ_PARAM_ERROR); return 0; }; - - if (bzf->writing) - { BZ_SETERR(BZ_SEQUENCE_ERROR); return 0; }; - - if (len == 0) - { BZ_SETERR(BZ_OK); return 0; }; - - bzf->strm.avail_out = len; - bzf->strm.next_out = buf; - - while (True) { - - if (ferror(bzf->handle)) - { BZ_SETERR(BZ_IO_ERROR); return 0; }; - - if (bzf->strm.avail_in == 0 && !myfeof(bzf->handle)) { - n = fread ( bzf->buf, sizeof(UChar), - BZ_MAX_UNUSED, bzf->handle ); - if (ferror(bzf->handle)) - { BZ_SETERR(BZ_IO_ERROR); return 0; }; - bzf->bufN = n; - bzf->strm.avail_in = bzf->bufN; - bzf->strm.next_in = bzf->buf; - } - - ret = BZ2_bzDecompress ( &(bzf->strm) ); - - if (ret != BZ_OK && ret != BZ_STREAM_END) - { BZ_SETERR(ret); return 0; }; - - if (ret == BZ_OK && myfeof(bzf->handle) && - bzf->strm.avail_in == 0 && bzf->strm.avail_out > 0) - { BZ_SETERR(BZ_UNEXPECTED_EOF); return 0; }; - - if (ret == BZ_STREAM_END) - { BZ_SETERR(BZ_STREAM_END); - return len - bzf->strm.avail_out; }; - if (bzf->strm.avail_out == 0) - { BZ_SETERR(BZ_OK); return len; }; - - } - - return 0; /*not reached*/ -} - - -/*---------------------------------------------------*/ -void BZ_API(BZ2_bzReadGetUnused) - ( int* bzerror, - BZFILE* b, - void** unused, - int* nUnused ) -{ - bzFile* bzf = (bzFile*)b; - if (bzf == NULL) - { BZ_SETERR(BZ_PARAM_ERROR); return; }; - if (bzf->lastErr != BZ_STREAM_END) - { BZ_SETERR(BZ_SEQUENCE_ERROR); return; }; - if (unused == NULL || nUnused == NULL) - { BZ_SETERR(BZ_PARAM_ERROR); return; }; - - BZ_SETERR(BZ_OK); - *nUnused = bzf->strm.avail_in; - *unused = bzf->strm.next_in; -} -#endif - - -/*---------------------------------------------------*/ -/*--- Misc convenience stuff ---*/ -/*---------------------------------------------------*/ - -/*---------------------------------------------------*/ -int BZ_API(BZ2_bzBuffToBuffCompress) - ( char* dest, - unsigned int* destLen, - char* source, - unsigned int sourceLen, - int blockSize100k, - int verbosity, - int workFactor ) -{ - bz_stream strm; - int ret; - - if (dest == NULL || destLen == NULL || - source == NULL || - blockSize100k < 1 || blockSize100k > 9 || - verbosity < 0 || verbosity > 4 || - workFactor < 0 || workFactor > 250) - return BZ_PARAM_ERROR; - - if (workFactor == 0) workFactor = 30; - strm.bzalloc = NULL; - strm.bzfree = NULL; - strm.opaque = NULL; - ret = BZ2_bzCompressInit ( &strm, blockSize100k, - verbosity, workFactor ); - if (ret != BZ_OK) return ret; - - strm.next_in = source; - strm.next_out = dest; - strm.avail_in = sourceLen; - strm.avail_out = *destLen; - - ret = BZ2_bzCompress ( &strm, BZ_FINISH ); - if (ret == BZ_FINISH_OK) goto output_overflow; - if (ret != BZ_STREAM_END) goto errhandler; - - /* normal termination */ - *destLen -= strm.avail_out; - BZ2_bzCompressEnd ( &strm ); - return BZ_OK; - - output_overflow: - BZ2_bzCompressEnd ( &strm ); - return BZ_OUTBUFF_FULL; - - errhandler: - BZ2_bzCompressEnd ( &strm ); - return ret; -} - - -/*---------------------------------------------------*/ -int BZ_API(BZ2_bzBuffToBuffDecompress) - ( char* dest, - unsigned int* destLen, - char* source, - unsigned int sourceLen, - int small, - int verbosity ) -{ - bz_stream strm; - int ret; - - if (dest == NULL || destLen == NULL || - source == NULL || - (small != 0 && small != 1) || - verbosity < 0 || verbosity > 4) - return BZ_PARAM_ERROR; - - strm.bzalloc = NULL; - strm.bzfree = NULL; - strm.opaque = NULL; - ret = BZ2_bzDecompressInit ( &strm, verbosity, small ); - if (ret != BZ_OK) return ret; - - strm.next_in = source; - strm.next_out = dest; - strm.avail_in = sourceLen; - strm.avail_out = *destLen; - - ret = BZ2_bzDecompress ( &strm ); - if (ret == BZ_OK) goto output_overflow_or_eof; - if (ret != BZ_STREAM_END) goto errhandler; - - /* normal termination */ - *destLen -= strm.avail_out; - BZ2_bzDecompressEnd ( &strm ); - return BZ_OK; - - output_overflow_or_eof: - if (strm.avail_out > 0) { - BZ2_bzDecompressEnd ( &strm ); - return BZ_UNEXPECTED_EOF; - } else { - BZ2_bzDecompressEnd ( &strm ); - return BZ_OUTBUFF_FULL; - }; - - errhandler: - BZ2_bzDecompressEnd ( &strm ); - return ret; -} - - -/*---------------------------------------------------*/ -/*-- - Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp) - to support better zlib compatibility. - This code is not _officially_ part of libbzip2 (yet); - I haven't tested it, documented it, or considered the - threading-safeness of it. - If this code breaks, please contact both Yoshioka and me. ---*/ -/*---------------------------------------------------*/ - -/*---------------------------------------------------*/ -/*-- - return version like "0.9.5d, 4-Sept-1999". ---*/ -const char * BZ_API(BZ2_bzlibVersion)(void) -{ - return BZ_VERSION; -} - - -#ifndef BZ_NO_STDIO -/*---------------------------------------------------*/ - -#if defined(_WIN32) || defined(OS2) || defined(MSDOS) -# include -# include -# define SET_BINARY_MODE(file) _setmode(_fileno(file),O_BINARY) -#else -# define SET_BINARY_MODE(file) -#endif -static -BZFILE * bzopen_or_bzdopen - ( const char *path, /* no use when bzdopen */ - int fd, /* no use when bzdopen */ - const char *mode, - int open_mode) /* bzopen: 0, bzdopen:1 */ -{ - int bzerr; - char unused[BZ_MAX_UNUSED]; - int blockSize100k = 9; - int writing = 0; - char mode2[10] = ""; - FILE *fp = NULL; - BZFILE *bzfp = NULL; - int verbosity = 0; - int workFactor = 30; - int smallMode = 0; - int nUnused = 0; - - if (mode == NULL) return NULL; - while (*mode) { - switch (*mode) { - case 'r': - writing = 0; break; - case 'w': - writing = 1; break; - case 's': - smallMode = 1; break; - default: - if (isdigit((int)(*mode))) { - blockSize100k = *mode-BZ_HDR_0; - } - } - mode++; - } - strcat(mode2, writing ? "w" : "r" ); - strcat(mode2,"b"); /* binary mode */ - - if (open_mode==0) { - if (path==NULL || strcmp(path,"")==0) { - fp = (writing ? stdout : stdin); - SET_BINARY_MODE(fp); - } else { - fp = fopen(path,mode2); - } - } else { -#ifdef BZ_STRICT_ANSI - fp = NULL; -#else - fp = _fdopen(fd,mode2); -#endif - } - if (fp == NULL) return NULL; - - if (writing) { - /* Guard against total chaos and anarchy -- JRS */ - if (blockSize100k < 1) blockSize100k = 1; - if (blockSize100k > 9) blockSize100k = 9; - bzfp = BZ2_bzWriteOpen(&bzerr,fp,blockSize100k, - verbosity,workFactor); - } else { - bzfp = BZ2_bzReadOpen(&bzerr,fp,verbosity,smallMode, - unused,nUnused); - } - if (bzfp == NULL) { - if (fp != stdin && fp != stdout) fclose(fp); - return NULL; - } - return bzfp; -} - - -/*---------------------------------------------------*/ -/*-- - open file for read or write. - ex) bzopen("file","w9") - case path="" or NULL => use stdin or stdout. ---*/ -BZFILE * BZ_API(BZ2_bzopen) - ( const char *path, - const char *mode ) -{ - return bzopen_or_bzdopen(path,-1,mode,/*bzopen*/0); -} - - -/*---------------------------------------------------*/ -BZFILE * BZ_API(BZ2_bzdopen) - ( int fd, - const char *mode ) -{ - return bzopen_or_bzdopen(NULL,fd,mode,/*bzdopen*/1); -} - - -/*---------------------------------------------------*/ -int BZ_API(BZ2_bzread) (BZFILE* b, void* buf, int len ) -{ - int bzerr, nread; - if (((bzFile*)b)->lastErr == BZ_STREAM_END) return 0; - nread = BZ2_bzRead(&bzerr,b,buf,len); - if (bzerr == BZ_OK || bzerr == BZ_STREAM_END) { - return nread; - } else { - return -1; - } -} - - -/*---------------------------------------------------*/ -int BZ_API(BZ2_bzwrite) (BZFILE* b, void* buf, int len ) -{ - int bzerr; - - BZ2_bzWrite(&bzerr,b,buf,len); - if(bzerr == BZ_OK){ - return len; - }else{ - return -1; - } -} - - -/*---------------------------------------------------*/ -int BZ_API(BZ2_bzflush) (BZFILE *b) -{ - /* do nothing now... */ - return 0; -} - - -/*---------------------------------------------------*/ -void BZ_API(BZ2_bzclose) (BZFILE* b) -{ - int bzerr; - FILE *fp; - - if (b==NULL) {return;} - fp = ((bzFile *)b)->handle; - if(((bzFile*)b)->writing){ - BZ2_bzWriteClose(&bzerr,b,0,NULL,NULL); - if(bzerr != BZ_OK){ - BZ2_bzWriteClose(NULL,b,1,NULL,NULL); - } - }else{ - BZ2_bzReadClose(&bzerr,b); - } - if(fp!=stdin && fp!=stdout){ - fclose(fp); - } -} - - -/*---------------------------------------------------*/ -/*-- - return last error code ---*/ -static const char *bzerrorstrings[] = { - "OK" - ,"SEQUENCE_ERROR" - ,"PARAM_ERROR" - ,"MEM_ERROR" - ,"DATA_ERROR" - ,"DATA_ERROR_MAGIC" - ,"IO_ERROR" - ,"UNEXPECTED_EOF" - ,"OUTBUFF_FULL" - ,"CONFIG_ERROR" - ,"???" /* for future */ - ,"???" /* for future */ - ,"???" /* for future */ - ,"???" /* for future */ - ,"???" /* for future */ - ,"???" /* for future */ -}; - - -const char * BZ_API(BZ2_bzerror) (BZFILE *b, int *errnum) -{ - int err = ((bzFile *)b)->lastErr; - - if(err>0) err = 0; - *errnum = err; - return bzerrorstrings[err*-1]; -} -#endif - - -/*-------------------------------------------------------------*/ -/*--- end bzlib.c ---*/ -/*-------------------------------------------------------------*/ diff --git a/libs/storm-sys/StormLib/src/bzip2/bzlib.h b/libs/storm-sys/StormLib/src/bzip2/bzlib.h deleted file mode 100644 index c5b75d6..0000000 --- a/libs/storm-sys/StormLib/src/bzip2/bzlib.h +++ /dev/null @@ -1,282 +0,0 @@ - -/*-------------------------------------------------------------*/ -/*--- Public header file for the library. ---*/ -/*--- bzlib.h ---*/ -/*-------------------------------------------------------------*/ - -/* ------------------------------------------------------------------ - This file is part of bzip2/libbzip2, a program and library for - lossless, block-sorting data compression. - - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward - - Please read the WARNING, DISCLAIMER and PATENTS sections in the - README file. - - This program is released under the terms of the license contained - in the file LICENSE. - ------------------------------------------------------------------ */ - - -#ifndef _BZLIB_H -#define _BZLIB_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define BZ_RUN 0 -#define BZ_FLUSH 1 -#define BZ_FINISH 2 - -#define BZ_OK 0 -#define BZ_RUN_OK 1 -#define BZ_FLUSH_OK 2 -#define BZ_FINISH_OK 3 -#define BZ_STREAM_END 4 -#define BZ_SEQUENCE_ERROR (-1) -#define BZ_PARAM_ERROR (-2) -#define BZ_MEM_ERROR (-3) -#define BZ_DATA_ERROR (-4) -#define BZ_DATA_ERROR_MAGIC (-5) -#define BZ_IO_ERROR (-6) -#define BZ_UNEXPECTED_EOF (-7) -#define BZ_OUTBUFF_FULL (-8) -#define BZ_CONFIG_ERROR (-9) - -typedef - struct { - char *next_in; - unsigned int avail_in; - unsigned int total_in_lo32; - unsigned int total_in_hi32; - - char *next_out; - unsigned int avail_out; - unsigned int total_out_lo32; - unsigned int total_out_hi32; - - void *state; - - void *(*bzalloc)(void *,int,int); - void (*bzfree)(void *,void *); - void *opaque; - } - bz_stream; - - -#ifndef BZ_IMPORT -#define BZ_EXPORT -#endif - -#ifndef BZ_NO_STDIO -/* Need a definitition for FILE */ -#include -#endif - -#ifdef _WIN32 -# include -# ifdef small - /* windows.h define small to char */ -# undef small -# endif -# ifdef BZ_EXPORT -# define BZ_API(func) WINAPI func -# define BZ_EXTERN extern -# else - /* import windows dll dynamically */ -# define BZ_API(func) (WINAPI * func) -# define BZ_EXTERN -# endif -#else -# define BZ_API(func) func -# define BZ_EXTERN extern -#endif - - -/*-- Core (low-level) library functions --*/ - -BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( - bz_stream* strm, - int blockSize100k, - int verbosity, - int workFactor - ); - -BZ_EXTERN int BZ_API(BZ2_bzCompress) ( - bz_stream* strm, - int action - ); - -BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( - bz_stream* strm - ); - -BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( - bz_stream *strm, - int verbosity, - int small - ); - -BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( - bz_stream* strm - ); - -BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( - bz_stream *strm - ); - - - -/*-- High(er) level library functions --*/ - -#ifndef BZ_NO_STDIO -#define BZ_MAX_UNUSED 5000 - -typedef void BZFILE; - -BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( - int* bzerror, - FILE* f, - int verbosity, - int small, - void* unused, - int nUnused - ); - -BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( - int* bzerror, - BZFILE* b - ); - -BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( - int* bzerror, - BZFILE* b, - void** unused, - int* nUnused - ); - -BZ_EXTERN int BZ_API(BZ2_bzRead) ( - int* bzerror, - BZFILE* b, - void* buf, - int len - ); - -BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( - int* bzerror, - FILE* f, - int blockSize100k, - int verbosity, - int workFactor - ); - -BZ_EXTERN void BZ_API(BZ2_bzWrite) ( - int* bzerror, - BZFILE* b, - void* buf, - int len - ); - -BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( - int* bzerror, - BZFILE* b, - int abandon, - unsigned int* nbytes_in, - unsigned int* nbytes_out - ); - -BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( - int* bzerror, - BZFILE* b, - int abandon, - unsigned int* nbytes_in_lo32, - unsigned int* nbytes_in_hi32, - unsigned int* nbytes_out_lo32, - unsigned int* nbytes_out_hi32 - ); -#endif - - -/*-- Utility functions --*/ - -BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( - char* dest, - unsigned int* destLen, - char* source, - unsigned int sourceLen, - int blockSize100k, - int verbosity, - int workFactor - ); - -BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( - char* dest, - unsigned int* destLen, - char* source, - unsigned int sourceLen, - int small, - int verbosity - ); - - -/*-- - Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp) - to support better zlib compatibility. - This code is not _officially_ part of libbzip2 (yet); - I haven't tested it, documented it, or considered the - threading-safeness of it. - If this code breaks, please contact both Yoshioka and me. ---*/ - -BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) ( - void - ); - -#ifndef BZ_NO_STDIO -BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) ( - const char *path, - const char *mode - ); - -BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) ( - int fd, - const char *mode - ); - -BZ_EXTERN int BZ_API(BZ2_bzread) ( - BZFILE* b, - void* buf, - int len - ); - -BZ_EXTERN int BZ_API(BZ2_bzwrite) ( - BZFILE* b, - void* buf, - int len - ); - -BZ_EXTERN int BZ_API(BZ2_bzflush) ( - BZFILE* b - ); - -BZ_EXTERN void BZ_API(BZ2_bzclose) ( - BZFILE* b - ); - -BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( - BZFILE *b, - int *errnum - ); -#endif - -#ifdef __cplusplus -} -#endif - -#endif - -/*-------------------------------------------------------------*/ -/*--- end bzlib.h ---*/ -/*-------------------------------------------------------------*/ diff --git a/libs/storm-sys/StormLib/src/bzip2/bzlib_private.h b/libs/storm-sys/StormLib/src/bzip2/bzlib_private.h deleted file mode 100644 index 2342787..0000000 --- a/libs/storm-sys/StormLib/src/bzip2/bzlib_private.h +++ /dev/null @@ -1,509 +0,0 @@ - -/*-------------------------------------------------------------*/ -/*--- Private header file for the library. ---*/ -/*--- bzlib_private.h ---*/ -/*-------------------------------------------------------------*/ - -/* ------------------------------------------------------------------ - This file is part of bzip2/libbzip2, a program and library for - lossless, block-sorting data compression. - - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward - - Please read the WARNING, DISCLAIMER and PATENTS sections in the - README file. - - This program is released under the terms of the license contained - in the file LICENSE. - ------------------------------------------------------------------ */ - - -#ifndef _BZLIB_PRIVATE_H -#define _BZLIB_PRIVATE_H - -#include - -#ifndef BZ_NO_STDIO -#include -#include -#include -#endif - -#include "bzlib.h" - - - -/*-- General stuff. --*/ - -#define BZ_VERSION "1.0.5, 10-Dec-2007" - -typedef char Char; -typedef unsigned char Bool; -typedef unsigned char UChar; -typedef int Int32; -typedef unsigned int UInt32; -typedef short Int16; -typedef unsigned short UInt16; - -#define True ((Bool)1) -#define False ((Bool)0) - -#ifndef __GNUC__ -#define __inline__ /* */ -#endif - -#ifndef BZ_NO_STDIO - -extern void BZ2_bz__AssertH__fail ( int errcode ); -#define AssertH(cond,errcode) \ - { if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); } - -#if BZ_DEBUG -#define AssertD(cond,msg) \ - { if (!(cond)) { \ - fprintf ( stderr, \ - "\n\nlibbzip2(debug build): internal error\n\t%s\n", msg );\ - exit(1); \ - }} -#else -#define AssertD(cond,msg) /* */ -#endif - -#define VPrintf0(zf) \ - fprintf(stderr,zf) -#define VPrintf1(zf,za1) \ - fprintf(stderr,zf,za1) -#define VPrintf2(zf,za1,za2) \ - fprintf(stderr,zf,za1,za2) -#define VPrintf3(zf,za1,za2,za3) \ - fprintf(stderr,zf,za1,za2,za3) -#define VPrintf4(zf,za1,za2,za3,za4) \ - fprintf(stderr,zf,za1,za2,za3,za4) -#define VPrintf5(zf,za1,za2,za3,za4,za5) \ - fprintf(stderr,zf,za1,za2,za3,za4,za5) - -#else - -extern void bz_internal_error ( int errcode ); -#define AssertH(cond,errcode) \ - { if (!(cond)) bz_internal_error ( errcode ); } -#define AssertD(cond,msg) do { } while (0) -#define VPrintf0(zf) do { } while (0) -#define VPrintf1(zf,za1) do { } while (0) -#define VPrintf2(zf,za1,za2) do { } while (0) -#define VPrintf3(zf,za1,za2,za3) do { } while (0) -#define VPrintf4(zf,za1,za2,za3,za4) do { } while (0) -#define VPrintf5(zf,za1,za2,za3,za4,za5) do { } while (0) - -#endif - - -#define BZALLOC(nnn) (strm->bzalloc)(strm->opaque,(nnn),1) -#define BZFREE(ppp) (strm->bzfree)(strm->opaque,(ppp)) - - -/*-- Header bytes. --*/ - -#define BZ_HDR_B 0x42 /* 'B' */ -#define BZ_HDR_Z 0x5a /* 'Z' */ -#define BZ_HDR_h 0x68 /* 'h' */ -#define BZ_HDR_0 0x30 /* '0' */ - -/*-- Constants for the back end. --*/ - -#define BZ_MAX_ALPHA_SIZE 258 -#define BZ_MAX_CODE_LEN 23 - -#define BZ_RUNA 0 -#define BZ_RUNB 1 - -#define BZ_N_GROUPS 6 -#define BZ_G_SIZE 50 -#define BZ_N_ITERS 4 - -#define BZ_MAX_SELECTORS (2 + (900000 / BZ_G_SIZE)) - - - -/*-- Stuff for randomising repetitive blocks. --*/ - -extern Int32 BZ2_rNums[512]; - -#define BZ_RAND_DECLS \ - Int32 rNToGo; \ - Int32 rTPos \ - -#define BZ_RAND_INIT_MASK \ - s->rNToGo = 0; \ - s->rTPos = 0 \ - -#define BZ_RAND_MASK ((s->rNToGo == 1) ? 1 : 0) - -#define BZ_RAND_UPD_MASK \ - if (s->rNToGo == 0) { \ - s->rNToGo = BZ2_rNums[s->rTPos]; \ - s->rTPos++; \ - if (s->rTPos == 512) s->rTPos = 0; \ - } \ - s->rNToGo--; - - - -/*-- Stuff for doing CRCs. --*/ - -extern UInt32 BZ2_crc32Table[256]; - -#define BZ_INITIALISE_CRC(crcVar) \ -{ \ - crcVar = 0xffffffffL; \ -} - -#define BZ_FINALISE_CRC(crcVar) \ -{ \ - crcVar = ~(crcVar); \ -} - -#define BZ_UPDATE_CRC(crcVar,cha) \ -{ \ - crcVar = (crcVar << 8) ^ \ - BZ2_crc32Table[(crcVar >> 24) ^ \ - ((UChar)cha)]; \ -} - - - -/*-- States and modes for compression. --*/ - -#define BZ_M_IDLE 1 -#define BZ_M_RUNNING 2 -#define BZ_M_FLUSHING 3 -#define BZ_M_FINISHING 4 - -#define BZ_S_OUTPUT 1 -#define BZ_S_INPUT 2 - -#define BZ_N_RADIX 2 -#define BZ_N_QSORT 12 -#define BZ_N_SHELL 18 -#define BZ_N_OVERSHOOT (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2) - - - - -/*-- Structure holding all the compression-side stuff. --*/ - -typedef - struct { - /* pointer back to the struct bz_stream */ - bz_stream* strm; - - /* mode this stream is in, and whether inputting */ - /* or outputting data */ - Int32 mode; - Int32 state; - - /* remembers avail_in when flush/finish requested */ - UInt32 avail_in_expect; - - /* for doing the block sorting */ - UInt32* arr1; - UInt32* arr2; - UInt32* ftab; - Int32 origPtr; - - /* aliases for arr1 and arr2 */ - UInt32* ptr; - UChar* block; - UInt16* mtfv; - UChar* zbits; - - /* for deciding when to use the fallback sorting algorithm */ - Int32 workFactor; - - /* run-length-encoding of the input */ - UInt32 state_in_ch; - Int32 state_in_len; - BZ_RAND_DECLS; - - /* input and output limits and current posns */ - Int32 nblock; - Int32 nblockMAX; - Int32 numZ; - Int32 state_out_pos; - - /* map of bytes used in block */ - Int32 nInUse; - Bool inUse[256]; - UChar unseqToSeq[256]; - - /* the buffer for bit stream creation */ - UInt32 bsBuff; - Int32 bsLive; - - /* block and combined CRCs */ - UInt32 blockCRC; - UInt32 combinedCRC; - - /* misc administratium */ - Int32 verbosity; - Int32 blockNo; - Int32 blockSize100k; - - /* stuff for coding the MTF values */ - Int32 nMTF; - Int32 mtfFreq [BZ_MAX_ALPHA_SIZE]; - UChar selector [BZ_MAX_SELECTORS]; - UChar selectorMtf[BZ_MAX_SELECTORS]; - - UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; - Int32 code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; - Int32 rfreq [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; - /* second dimension: only 3 needed; 4 makes index calculations faster */ - UInt32 len_pack[BZ_MAX_ALPHA_SIZE][4]; - - } - EState; - - - -/*-- externs for compression. --*/ - -extern void -BZ2_blockSort ( EState* ); - -extern void -BZ2_compressBlock ( EState*, Bool ); - -extern void -BZ2_bsInitWrite ( EState* ); - -extern void -BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 ); - -extern void -BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 ); - - - -/*-- states for decompression. --*/ - -#define BZ_X_IDLE 1 -#define BZ_X_OUTPUT 2 - -#define BZ_X_MAGIC_1 10 -#define BZ_X_MAGIC_2 11 -#define BZ_X_MAGIC_3 12 -#define BZ_X_MAGIC_4 13 -#define BZ_X_BLKHDR_1 14 -#define BZ_X_BLKHDR_2 15 -#define BZ_X_BLKHDR_3 16 -#define BZ_X_BLKHDR_4 17 -#define BZ_X_BLKHDR_5 18 -#define BZ_X_BLKHDR_6 19 -#define BZ_X_BCRC_1 20 -#define BZ_X_BCRC_2 21 -#define BZ_X_BCRC_3 22 -#define BZ_X_BCRC_4 23 -#define BZ_X_RANDBIT 24 -#define BZ_X_ORIGPTR_1 25 -#define BZ_X_ORIGPTR_2 26 -#define BZ_X_ORIGPTR_3 27 -#define BZ_X_MAPPING_1 28 -#define BZ_X_MAPPING_2 29 -#define BZ_X_SELECTOR_1 30 -#define BZ_X_SELECTOR_2 31 -#define BZ_X_SELECTOR_3 32 -#define BZ_X_CODING_1 33 -#define BZ_X_CODING_2 34 -#define BZ_X_CODING_3 35 -#define BZ_X_MTF_1 36 -#define BZ_X_MTF_2 37 -#define BZ_X_MTF_3 38 -#define BZ_X_MTF_4 39 -#define BZ_X_MTF_5 40 -#define BZ_X_MTF_6 41 -#define BZ_X_ENDHDR_2 42 -#define BZ_X_ENDHDR_3 43 -#define BZ_X_ENDHDR_4 44 -#define BZ_X_ENDHDR_5 45 -#define BZ_X_ENDHDR_6 46 -#define BZ_X_CCRC_1 47 -#define BZ_X_CCRC_2 48 -#define BZ_X_CCRC_3 49 -#define BZ_X_CCRC_4 50 - - - -/*-- Constants for the fast MTF decoder. --*/ - -#define MTFA_SIZE 4096 -#define MTFL_SIZE 16 - - - -/*-- Structure holding all the decompression-side stuff. --*/ - -typedef - struct { - /* pointer back to the struct bz_stream */ - bz_stream* strm; - - /* state indicator for this stream */ - Int32 state; - - /* for doing the final run-length decoding */ - UChar state_out_ch; - Int32 state_out_len; - Bool blockRandomised; - BZ_RAND_DECLS; - - /* the buffer for bit stream reading */ - UInt32 bsBuff; - Int32 bsLive; - - /* misc administratium */ - Int32 blockSize100k; - Bool smallDecompress; - Int32 currBlockNo; - Int32 verbosity; - - /* for undoing the Burrows-Wheeler transform */ - Int32 origPtr; - UInt32 tPos; - Int32 k0; - Int32 unzftab[256]; - Int32 nblock_used; - Int32 cftab[257]; - Int32 cftabCopy[257]; - - /* for undoing the Burrows-Wheeler transform (FAST) */ - UInt32 *tt; - - /* for undoing the Burrows-Wheeler transform (SMALL) */ - UInt16 *ll16; - UChar *ll4; - - /* stored and calculated CRCs */ - UInt32 storedBlockCRC; - UInt32 storedCombinedCRC; - UInt32 calculatedBlockCRC; - UInt32 calculatedCombinedCRC; - - /* map of bytes used in block */ - Int32 nInUse; - Bool inUse[256]; - Bool inUse16[16]; - UChar seqToUnseq[256]; - - /* for decoding the MTF values */ - UChar mtfa [MTFA_SIZE]; - Int32 mtfbase[256 / MTFL_SIZE]; - UChar selector [BZ_MAX_SELECTORS]; - UChar selectorMtf[BZ_MAX_SELECTORS]; - UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; - - Int32 limit [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; - Int32 base [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; - Int32 perm [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; - Int32 minLens[BZ_N_GROUPS]; - - /* save area for scalars in the main decompress code */ - Int32 save_i; - Int32 save_j; - Int32 save_t; - Int32 save_alphaSize; - Int32 save_nGroups; - Int32 save_nSelectors; - Int32 save_EOB; - Int32 save_groupNo; - Int32 save_groupPos; - Int32 save_nextSym; - Int32 save_nblockMAX; - Int32 save_nblock; - Int32 save_es; - Int32 save_N; - Int32 save_curr; - Int32 save_zt; - Int32 save_zn; - Int32 save_zvec; - Int32 save_zj; - Int32 save_gSel; - Int32 save_gMinlen; - Int32* save_gLimit; - Int32* save_gBase; - Int32* save_gPerm; - - } - DState; - - - -/*-- Macros for decompression. --*/ - -#define BZ_GET_FAST(cccc) \ - /* c_tPos is unsigned, hence test < 0 is pointless. */ \ - if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k) return True; \ - s->tPos = s->tt[s->tPos]; \ - cccc = (UChar)(s->tPos & 0xff); \ - s->tPos >>= 8; - -#define BZ_GET_FAST_C(cccc) \ - /* c_tPos is unsigned, hence test < 0 is pointless. */ \ - if (c_tPos >= (UInt32)100000 * (UInt32)ro_blockSize100k) return True; \ - c_tPos = c_tt[c_tPos]; \ - cccc = (UChar)(c_tPos & 0xff); \ - c_tPos >>= 8; - -#define SET_LL4(i,n) \ - { if (((i) & 0x1) == 0) \ - s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0xf0) | (n); else \ - s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0x0f) | ((n) << 4); \ - } - -#define GET_LL4(i) \ - ((((UInt32)(s->ll4[(i) >> 1])) >> (((i) << 2) & 0x4)) & 0xF) - -#define SET_LL(i,n) \ - { s->ll16[i] = (UInt16)(n & 0x0000ffff); \ - SET_LL4(i, n >> 16); \ - } - -#define GET_LL(i) \ - (((UInt32)s->ll16[i]) | (GET_LL4(i) << 16)) - -#define BZ_GET_SMALL(cccc) \ - /* c_tPos is unsigned, hence test < 0 is pointless. */ \ - if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k) return True; \ - cccc = BZ2_indexIntoF ( s->tPos, s->cftab ); \ - s->tPos = GET_LL(s->tPos); - - -/*-- externs for decompression. --*/ - -extern Int32 -BZ2_indexIntoF ( Int32, Int32* ); - -extern Int32 -BZ2_decompress ( DState* ); - -extern void -BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*, - Int32, Int32, Int32 ); - - -#endif - - -/*-- BZ_NO_STDIO seems to make NULL disappear on some platforms. --*/ - -#ifdef BZ_NO_STDIO -#ifndef NULL -#define NULL 0 -#endif -#endif - - -/*-------------------------------------------------------------*/ -/*--- end bzlib_private.h ---*/ -/*-------------------------------------------------------------*/ diff --git a/libs/storm-sys/StormLib/src/bzip2/compress.c b/libs/storm-sys/StormLib/src/bzip2/compress.c deleted file mode 100644 index 8c80a07..0000000 --- a/libs/storm-sys/StormLib/src/bzip2/compress.c +++ /dev/null @@ -1,672 +0,0 @@ - -/*-------------------------------------------------------------*/ -/*--- Compression machinery (not incl block sorting) ---*/ -/*--- compress.c ---*/ -/*-------------------------------------------------------------*/ - -/* ------------------------------------------------------------------ - This file is part of bzip2/libbzip2, a program and library for - lossless, block-sorting data compression. - - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward - - Please read the WARNING, DISCLAIMER and PATENTS sections in the - README file. - - This program is released under the terms of the license contained - in the file LICENSE. - ------------------------------------------------------------------ */ - - -/* CHANGES - 0.9.0 -- original version. - 0.9.0a/b -- no changes in this file. - 0.9.0c -- changed setting of nGroups in sendMTFValues() - so as to do a bit better on small files -*/ - -#include "bzlib_private.h" - - -/*---------------------------------------------------*/ -/*--- Bit stream I/O ---*/ -/*---------------------------------------------------*/ - -/*---------------------------------------------------*/ -void BZ2_bsInitWrite ( EState* s ) -{ - s->bsLive = 0; - s->bsBuff = 0; -} - - -/*---------------------------------------------------*/ -static -void bsFinishWrite ( EState* s ) -{ - while (s->bsLive > 0) { - s->zbits[s->numZ] = (UChar)(s->bsBuff >> 24); - s->numZ++; - s->bsBuff <<= 8; - s->bsLive -= 8; - } -} - - -/*---------------------------------------------------*/ -#define bsNEEDW(nz) \ -{ \ - while (s->bsLive >= 8) { \ - s->zbits[s->numZ] \ - = (UChar)(s->bsBuff >> 24); \ - s->numZ++; \ - s->bsBuff <<= 8; \ - s->bsLive -= 8; \ - } \ -} - - -/*---------------------------------------------------*/ -static -__inline__ -void bsW ( EState* s, Int32 n, UInt32 v ) -{ - bsNEEDW ( n ); - s->bsBuff |= (v << (32 - s->bsLive - n)); - s->bsLive += n; -} - - -/*---------------------------------------------------*/ -static -void bsPutUInt32 ( EState* s, UInt32 u ) -{ - bsW ( s, 8, (u >> 24) & 0xffL ); - bsW ( s, 8, (u >> 16) & 0xffL ); - bsW ( s, 8, (u >> 8) & 0xffL ); - bsW ( s, 8, u & 0xffL ); -} - - -/*---------------------------------------------------*/ -static -void bsPutUChar ( EState* s, UChar c ) -{ - bsW( s, 8, (UInt32)c ); -} - - -/*---------------------------------------------------*/ -/*--- The back end proper ---*/ -/*---------------------------------------------------*/ - -/*---------------------------------------------------*/ -static -void makeMaps_e ( EState* s ) -{ - Int32 i; - s->nInUse = 0; - for (i = 0; i < 256; i++) - if (s->inUse[i]) { - s->unseqToSeq[i] = s->nInUse; - s->nInUse++; - } -} - - -/*---------------------------------------------------*/ -static -void generateMTFValues ( EState* s ) -{ - UChar yy[256]; - Int32 i, j; - Int32 zPend; - Int32 wr; - Int32 EOB; - - /* - After sorting (eg, here), - s->arr1 [ 0 .. s->nblock-1 ] holds sorted order, - and - ((UChar*)s->arr2) [ 0 .. s->nblock-1 ] - holds the original block data. - - The first thing to do is generate the MTF values, - and put them in - ((UInt16*)s->arr1) [ 0 .. s->nblock-1 ]. - Because there are strictly fewer or equal MTF values - than block values, ptr values in this area are overwritten - with MTF values only when they are no longer needed. - - The final compressed bitstream is generated into the - area starting at - (UChar*) (&((UChar*)s->arr2)[s->nblock]) - - These storage aliases are set up in bzCompressInit(), - except for the last one, which is arranged in - compressBlock(). - */ - UInt32* ptr = s->ptr; - UChar* block = s->block; - UInt16* mtfv = s->mtfv; - - makeMaps_e ( s ); - EOB = s->nInUse+1; - - for (i = 0; i <= EOB; i++) s->mtfFreq[i] = 0; - - wr = 0; - zPend = 0; - for (i = 0; i < s->nInUse; i++) yy[i] = (UChar) i; - - for (i = 0; i < s->nblock; i++) { - UChar ll_i; - AssertD ( wr <= i, "generateMTFValues(1)" ); - j = ptr[i]-1; if (j < 0) j += s->nblock; - ll_i = s->unseqToSeq[block[j]]; - AssertD ( ll_i < s->nInUse, "generateMTFValues(2a)" ); - - if (yy[0] == ll_i) { - zPend++; - } else { - - if (zPend > 0) { - zPend--; - while (True) { - if (zPend & 1) { - mtfv[wr] = BZ_RUNB; wr++; - s->mtfFreq[BZ_RUNB]++; - } else { - mtfv[wr] = BZ_RUNA; wr++; - s->mtfFreq[BZ_RUNA]++; - } - if (zPend < 2) break; - zPend = (zPend - 2) / 2; - }; - zPend = 0; - } - { - register UChar rtmp; - register UChar* ryy_j; - register UChar rll_i; - rtmp = yy[1]; - yy[1] = yy[0]; - ryy_j = &(yy[1]); - rll_i = ll_i; - while ( rll_i != rtmp ) { - register UChar rtmp2; - ryy_j++; - rtmp2 = rtmp; - rtmp = *ryy_j; - *ryy_j = rtmp2; - }; - yy[0] = rtmp; - j = ryy_j - &(yy[0]); - mtfv[wr] = j+1; wr++; s->mtfFreq[j+1]++; - } - - } - } - - if (zPend > 0) { - zPend--; - while (True) { - if (zPend & 1) { - mtfv[wr] = BZ_RUNB; wr++; - s->mtfFreq[BZ_RUNB]++; - } else { - mtfv[wr] = BZ_RUNA; wr++; - s->mtfFreq[BZ_RUNA]++; - } - if (zPend < 2) break; - zPend = (zPend - 2) / 2; - }; - zPend = 0; - } - - mtfv[wr] = EOB; wr++; s->mtfFreq[EOB]++; - - s->nMTF = wr; -} - - -/*---------------------------------------------------*/ -#define BZ_LESSER_ICOST 0 -#define BZ_GREATER_ICOST 15 - -static -void sendMTFValues ( EState* s ) -{ - Int32 v, t, i, j, gs, ge, totc, bt, bc, iter; - Int32 nSelectors, alphaSize, minLen, maxLen, selCtr; - Int32 nGroups, nBytes; - - /*-- - UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; - is a global since the decoder also needs it. - - Int32 code[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; - Int32 rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; - are also globals only used in this proc. - Made global to keep stack frame size small. - --*/ - - - UInt16 cost[BZ_N_GROUPS]; - Int32 fave[BZ_N_GROUPS]; - - UInt16* mtfv = s->mtfv; - - if (s->verbosity >= 3) - VPrintf3( " %d in block, %d after MTF & 1-2 coding, " - "%d+2 syms in use\n", - s->nblock, s->nMTF, s->nInUse ); - - alphaSize = s->nInUse+2; - for (t = 0; t < BZ_N_GROUPS; t++) - for (v = 0; v < alphaSize; v++) - s->len[t][v] = BZ_GREATER_ICOST; - - /*--- Decide how many coding tables to use ---*/ - AssertH ( s->nMTF > 0, 3001 ); - if (s->nMTF < 200) nGroups = 2; else - if (s->nMTF < 600) nGroups = 3; else - if (s->nMTF < 1200) nGroups = 4; else - if (s->nMTF < 2400) nGroups = 5; else - nGroups = 6; - - /*--- Generate an initial set of coding tables ---*/ - { - Int32 nPart, remF, tFreq, aFreq; - - nPart = nGroups; - remF = s->nMTF; - gs = 0; - while (nPart > 0) { - tFreq = remF / nPart; - ge = gs-1; - aFreq = 0; - while (aFreq < tFreq && ge < alphaSize-1) { - ge++; - aFreq += s->mtfFreq[ge]; - } - - if (ge > gs - && nPart != nGroups && nPart != 1 - && ((nGroups-nPart) % 2 == 1)) { - aFreq -= s->mtfFreq[ge]; - ge--; - } - - if (s->verbosity >= 3) - VPrintf5( " initial group %d, [%d .. %d], " - "has %d syms (%4.1f%%)\n", - nPart, gs, ge, aFreq, - (100.0 * (float)aFreq) / (float)(s->nMTF) ); - - for (v = 0; v < alphaSize; v++) - if (v >= gs && v <= ge) - s->len[nPart-1][v] = BZ_LESSER_ICOST; else - s->len[nPart-1][v] = BZ_GREATER_ICOST; - - nPart--; - gs = ge+1; - remF -= aFreq; - } - } - - /*--- - Iterate up to BZ_N_ITERS times to improve the tables. - ---*/ - for (iter = 0; iter < BZ_N_ITERS; iter++) { - - for (t = 0; t < nGroups; t++) fave[t] = 0; - - for (t = 0; t < nGroups; t++) - for (v = 0; v < alphaSize; v++) - s->rfreq[t][v] = 0; - - /*--- - Set up an auxiliary length table which is used to fast-track - the common case (nGroups == 6). - ---*/ - if (nGroups == 6) { - for (v = 0; v < alphaSize; v++) { - s->len_pack[v][0] = (s->len[1][v] << 16) | s->len[0][v]; - s->len_pack[v][1] = (s->len[3][v] << 16) | s->len[2][v]; - s->len_pack[v][2] = (s->len[5][v] << 16) | s->len[4][v]; - } - } - - nSelectors = 0; - totc = 0; - gs = 0; - while (True) { - - /*--- Set group start & end marks. --*/ - if (gs >= s->nMTF) break; - ge = gs + BZ_G_SIZE - 1; - if (ge >= s->nMTF) ge = s->nMTF-1; - - /*-- - Calculate the cost of this group as coded - by each of the coding tables. - --*/ - for (t = 0; t < nGroups; t++) cost[t] = 0; - - if (nGroups == 6 && 50 == ge-gs+1) { - /*--- fast track the common case ---*/ - register UInt32 cost01, cost23, cost45; - register UInt16 icv; - cost01 = cost23 = cost45 = 0; - -# define BZ_ITER(nn) \ - icv = mtfv[gs+(nn)]; \ - cost01 += s->len_pack[icv][0]; \ - cost23 += s->len_pack[icv][1]; \ - cost45 += s->len_pack[icv][2]; \ - - BZ_ITER(0); BZ_ITER(1); BZ_ITER(2); BZ_ITER(3); BZ_ITER(4); - BZ_ITER(5); BZ_ITER(6); BZ_ITER(7); BZ_ITER(8); BZ_ITER(9); - BZ_ITER(10); BZ_ITER(11); BZ_ITER(12); BZ_ITER(13); BZ_ITER(14); - BZ_ITER(15); BZ_ITER(16); BZ_ITER(17); BZ_ITER(18); BZ_ITER(19); - BZ_ITER(20); BZ_ITER(21); BZ_ITER(22); BZ_ITER(23); BZ_ITER(24); - BZ_ITER(25); BZ_ITER(26); BZ_ITER(27); BZ_ITER(28); BZ_ITER(29); - BZ_ITER(30); BZ_ITER(31); BZ_ITER(32); BZ_ITER(33); BZ_ITER(34); - BZ_ITER(35); BZ_ITER(36); BZ_ITER(37); BZ_ITER(38); BZ_ITER(39); - BZ_ITER(40); BZ_ITER(41); BZ_ITER(42); BZ_ITER(43); BZ_ITER(44); - BZ_ITER(45); BZ_ITER(46); BZ_ITER(47); BZ_ITER(48); BZ_ITER(49); - -# undef BZ_ITER - - cost[0] = cost01 & 0xffff; cost[1] = cost01 >> 16; - cost[2] = cost23 & 0xffff; cost[3] = cost23 >> 16; - cost[4] = cost45 & 0xffff; cost[5] = cost45 >> 16; - - } else { - /*--- slow version which correctly handles all situations ---*/ - for (i = gs; i <= ge; i++) { - UInt16 icv = mtfv[i]; - for (t = 0; t < nGroups; t++) cost[t] += s->len[t][icv]; - } - } - - /*-- - Find the coding table which is best for this group, - and record its identity in the selector table. - --*/ - bc = 999999999; bt = -1; - for (t = 0; t < nGroups; t++) - if (cost[t] < bc) { bc = cost[t]; bt = t; }; - totc += bc; - fave[bt]++; - s->selector[nSelectors] = bt; - nSelectors++; - - /*-- - Increment the symbol frequencies for the selected table. - --*/ - if (nGroups == 6 && 50 == ge-gs+1) { - /*--- fast track the common case ---*/ - -# define BZ_ITUR(nn) s->rfreq[bt][ mtfv[gs+(nn)] ]++ - - BZ_ITUR(0); BZ_ITUR(1); BZ_ITUR(2); BZ_ITUR(3); BZ_ITUR(4); - BZ_ITUR(5); BZ_ITUR(6); BZ_ITUR(7); BZ_ITUR(8); BZ_ITUR(9); - BZ_ITUR(10); BZ_ITUR(11); BZ_ITUR(12); BZ_ITUR(13); BZ_ITUR(14); - BZ_ITUR(15); BZ_ITUR(16); BZ_ITUR(17); BZ_ITUR(18); BZ_ITUR(19); - BZ_ITUR(20); BZ_ITUR(21); BZ_ITUR(22); BZ_ITUR(23); BZ_ITUR(24); - BZ_ITUR(25); BZ_ITUR(26); BZ_ITUR(27); BZ_ITUR(28); BZ_ITUR(29); - BZ_ITUR(30); BZ_ITUR(31); BZ_ITUR(32); BZ_ITUR(33); BZ_ITUR(34); - BZ_ITUR(35); BZ_ITUR(36); BZ_ITUR(37); BZ_ITUR(38); BZ_ITUR(39); - BZ_ITUR(40); BZ_ITUR(41); BZ_ITUR(42); BZ_ITUR(43); BZ_ITUR(44); - BZ_ITUR(45); BZ_ITUR(46); BZ_ITUR(47); BZ_ITUR(48); BZ_ITUR(49); - -# undef BZ_ITUR - - } else { - /*--- slow version which correctly handles all situations ---*/ - for (i = gs; i <= ge; i++) - s->rfreq[bt][ mtfv[i] ]++; - } - - gs = ge+1; - } - if (s->verbosity >= 3) { - VPrintf2 ( " pass %d: size is %d, grp uses are ", - iter+1, totc/8 ); - for (t = 0; t < nGroups; t++) - VPrintf1 ( "%d ", fave[t] ); - VPrintf0 ( "\n" ); - } - - /*-- - Recompute the tables based on the accumulated frequencies. - --*/ - /* maxLen was changed from 20 to 17 in bzip2-1.0.3. See - comment in huffman.c for details. */ - for (t = 0; t < nGroups; t++) - BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]), - alphaSize, 17 /*20*/ ); - } - - - AssertH( nGroups < 8, 3002 ); - AssertH( nSelectors < 32768 && - nSelectors <= (2 + (900000 / BZ_G_SIZE)), - 3003 ); - - - /*--- Compute MTF values for the selectors. ---*/ - { - UChar pos[BZ_N_GROUPS], ll_i, tmp2, tmp; - for (i = 0; i < nGroups; i++) pos[i] = i; - for (i = 0; i < nSelectors; i++) { - ll_i = s->selector[i]; - j = 0; - tmp = pos[j]; - while ( ll_i != tmp ) { - j++; - tmp2 = tmp; - tmp = pos[j]; - pos[j] = tmp2; - }; - pos[0] = tmp; - s->selectorMtf[i] = j; - } - }; - - /*--- Assign actual codes for the tables. --*/ - for (t = 0; t < nGroups; t++) { - minLen = 32; - maxLen = 0; - for (i = 0; i < alphaSize; i++) { - if (s->len[t][i] > maxLen) maxLen = s->len[t][i]; - if (s->len[t][i] < minLen) minLen = s->len[t][i]; - } - AssertH ( !(maxLen > 17 /*20*/ ), 3004 ); - AssertH ( !(minLen < 1), 3005 ); - BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]), - minLen, maxLen, alphaSize ); - } - - /*--- Transmit the mapping table. ---*/ - { - Bool inUse16[16]; - for (i = 0; i < 16; i++) { - inUse16[i] = False; - for (j = 0; j < 16; j++) - if (s->inUse[i * 16 + j]) inUse16[i] = True; - } - - nBytes = s->numZ; - for (i = 0; i < 16; i++) - if (inUse16[i]) bsW(s,1,1); else bsW(s,1,0); - - for (i = 0; i < 16; i++) - if (inUse16[i]) - for (j = 0; j < 16; j++) { - if (s->inUse[i * 16 + j]) bsW(s,1,1); else bsW(s,1,0); - } - - if (s->verbosity >= 3) - VPrintf1( " bytes: mapping %d, ", s->numZ-nBytes ); - } - - /*--- Now the selectors. ---*/ - nBytes = s->numZ; - bsW ( s, 3, nGroups ); - bsW ( s, 15, nSelectors ); - for (i = 0; i < nSelectors; i++) { - for (j = 0; j < s->selectorMtf[i]; j++) bsW(s,1,1); - bsW(s,1,0); - } - if (s->verbosity >= 3) - VPrintf1( "selectors %d, ", s->numZ-nBytes ); - - /*--- Now the coding tables. ---*/ - nBytes = s->numZ; - - for (t = 0; t < nGroups; t++) { - Int32 curr = s->len[t][0]; - bsW ( s, 5, curr ); - for (i = 0; i < alphaSize; i++) { - while (curr < s->len[t][i]) { bsW(s,2,2); curr++; /* 10 */ }; - while (curr > s->len[t][i]) { bsW(s,2,3); curr--; /* 11 */ }; - bsW ( s, 1, 0 ); - } - } - - if (s->verbosity >= 3) - VPrintf1 ( "code lengths %d, ", s->numZ-nBytes ); - - /*--- And finally, the block data proper ---*/ - nBytes = s->numZ; - selCtr = 0; - gs = 0; - while (True) { - if (gs >= s->nMTF) break; - ge = gs + BZ_G_SIZE - 1; - if (ge >= s->nMTF) ge = s->nMTF-1; - AssertH ( s->selector[selCtr] < nGroups, 3006 ); - - if (nGroups == 6 && 50 == ge-gs+1) { - /*--- fast track the common case ---*/ - UInt16 mtfv_i; - UChar* s_len_sel_selCtr - = &(s->len[s->selector[selCtr]][0]); - Int32* s_code_sel_selCtr - = &(s->code[s->selector[selCtr]][0]); - -# define BZ_ITAH(nn) \ - mtfv_i = mtfv[gs+(nn)]; \ - bsW ( s, \ - s_len_sel_selCtr[mtfv_i], \ - s_code_sel_selCtr[mtfv_i] ) - - BZ_ITAH(0); BZ_ITAH(1); BZ_ITAH(2); BZ_ITAH(3); BZ_ITAH(4); - BZ_ITAH(5); BZ_ITAH(6); BZ_ITAH(7); BZ_ITAH(8); BZ_ITAH(9); - BZ_ITAH(10); BZ_ITAH(11); BZ_ITAH(12); BZ_ITAH(13); BZ_ITAH(14); - BZ_ITAH(15); BZ_ITAH(16); BZ_ITAH(17); BZ_ITAH(18); BZ_ITAH(19); - BZ_ITAH(20); BZ_ITAH(21); BZ_ITAH(22); BZ_ITAH(23); BZ_ITAH(24); - BZ_ITAH(25); BZ_ITAH(26); BZ_ITAH(27); BZ_ITAH(28); BZ_ITAH(29); - BZ_ITAH(30); BZ_ITAH(31); BZ_ITAH(32); BZ_ITAH(33); BZ_ITAH(34); - BZ_ITAH(35); BZ_ITAH(36); BZ_ITAH(37); BZ_ITAH(38); BZ_ITAH(39); - BZ_ITAH(40); BZ_ITAH(41); BZ_ITAH(42); BZ_ITAH(43); BZ_ITAH(44); - BZ_ITAH(45); BZ_ITAH(46); BZ_ITAH(47); BZ_ITAH(48); BZ_ITAH(49); - -# undef BZ_ITAH - - } else { - /*--- slow version which correctly handles all situations ---*/ - for (i = gs; i <= ge; i++) { - bsW ( s, - s->len [s->selector[selCtr]] [mtfv[i]], - s->code [s->selector[selCtr]] [mtfv[i]] ); - } - } - - - gs = ge+1; - selCtr++; - } - AssertH( selCtr == nSelectors, 3007 ); - - if (s->verbosity >= 3) - VPrintf1( "codes %d\n", s->numZ-nBytes ); -} - - -/*---------------------------------------------------*/ -void BZ2_compressBlock ( EState* s, Bool is_last_block ) -{ - if (s->nblock > 0) { - - BZ_FINALISE_CRC ( s->blockCRC ); - s->combinedCRC = (s->combinedCRC << 1) | (s->combinedCRC >> 31); - s->combinedCRC ^= s->blockCRC; - if (s->blockNo > 1) s->numZ = 0; - - if (s->verbosity >= 2) - VPrintf4( " block %d: crc = 0x%08x, " - "combined CRC = 0x%08x, size = %d\n", - s->blockNo, s->blockCRC, s->combinedCRC, s->nblock ); - - BZ2_blockSort ( s ); - } - - s->zbits = (UChar*) (&((UChar*)s->arr2)[s->nblock]); - - /*-- If this is the first block, create the stream header. --*/ - if (s->blockNo == 1) { - BZ2_bsInitWrite ( s ); - bsPutUChar ( s, BZ_HDR_B ); - bsPutUChar ( s, BZ_HDR_Z ); - bsPutUChar ( s, BZ_HDR_h ); - bsPutUChar ( s, (UChar)(BZ_HDR_0 + s->blockSize100k) ); - } - - if (s->nblock > 0) { - - bsPutUChar ( s, 0x31 ); bsPutUChar ( s, 0x41 ); - bsPutUChar ( s, 0x59 ); bsPutUChar ( s, 0x26 ); - bsPutUChar ( s, 0x53 ); bsPutUChar ( s, 0x59 ); - - /*-- Now the block's CRC, so it is in a known place. --*/ - bsPutUInt32 ( s, s->blockCRC ); - - /*-- - Now a single bit indicating (non-)randomisation. - As of version 0.9.5, we use a better sorting algorithm - which makes randomisation unnecessary. So always set - the randomised bit to 'no'. Of course, the decoder - still needs to be able to handle randomised blocks - so as to maintain backwards compatibility with - older versions of bzip2. - --*/ - bsW(s,1,0); - - bsW ( s, 24, s->origPtr ); - generateMTFValues ( s ); - sendMTFValues ( s ); - } - - - /*-- If this is the last block, add the stream trailer. --*/ - if (is_last_block) { - - bsPutUChar ( s, 0x17 ); bsPutUChar ( s, 0x72 ); - bsPutUChar ( s, 0x45 ); bsPutUChar ( s, 0x38 ); - bsPutUChar ( s, 0x50 ); bsPutUChar ( s, 0x90 ); - bsPutUInt32 ( s, s->combinedCRC ); - if (s->verbosity >= 2) - VPrintf1( " final combined CRC = 0x%08x\n ", s->combinedCRC ); - bsFinishWrite ( s ); - } -} - - -/*-------------------------------------------------------------*/ -/*--- end compress.c ---*/ -/*-------------------------------------------------------------*/ diff --git a/libs/storm-sys/StormLib/src/bzip2/crctable.c b/libs/storm-sys/StormLib/src/bzip2/crctable.c deleted file mode 100644 index 215687b..0000000 --- a/libs/storm-sys/StormLib/src/bzip2/crctable.c +++ /dev/null @@ -1,104 +0,0 @@ - -/*-------------------------------------------------------------*/ -/*--- Table for doing CRCs ---*/ -/*--- crctable.c ---*/ -/*-------------------------------------------------------------*/ - -/* ------------------------------------------------------------------ - This file is part of bzip2/libbzip2, a program and library for - lossless, block-sorting data compression. - - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward - - Please read the WARNING, DISCLAIMER and PATENTS sections in the - README file. - - This program is released under the terms of the license contained - in the file LICENSE. - ------------------------------------------------------------------ */ - - -#include "bzlib_private.h" - -/*-- - I think this is an implementation of the AUTODIN-II, - Ethernet & FDDI 32-bit CRC standard. Vaguely derived - from code by Rob Warnock, in Section 51 of the - comp.compression FAQ. ---*/ - -UInt32 BZ2_crc32Table[256] = { - - /*-- Ugly, innit? --*/ - - 0x00000000L, 0x04c11db7L, 0x09823b6eL, 0x0d4326d9L, - 0x130476dcL, 0x17c56b6bL, 0x1a864db2L, 0x1e475005L, - 0x2608edb8L, 0x22c9f00fL, 0x2f8ad6d6L, 0x2b4bcb61L, - 0x350c9b64L, 0x31cd86d3L, 0x3c8ea00aL, 0x384fbdbdL, - 0x4c11db70L, 0x48d0c6c7L, 0x4593e01eL, 0x4152fda9L, - 0x5f15adacL, 0x5bd4b01bL, 0x569796c2L, 0x52568b75L, - 0x6a1936c8L, 0x6ed82b7fL, 0x639b0da6L, 0x675a1011L, - 0x791d4014L, 0x7ddc5da3L, 0x709f7b7aL, 0x745e66cdL, - 0x9823b6e0L, 0x9ce2ab57L, 0x91a18d8eL, 0x95609039L, - 0x8b27c03cL, 0x8fe6dd8bL, 0x82a5fb52L, 0x8664e6e5L, - 0xbe2b5b58L, 0xbaea46efL, 0xb7a96036L, 0xb3687d81L, - 0xad2f2d84L, 0xa9ee3033L, 0xa4ad16eaL, 0xa06c0b5dL, - 0xd4326d90L, 0xd0f37027L, 0xddb056feL, 0xd9714b49L, - 0xc7361b4cL, 0xc3f706fbL, 0xceb42022L, 0xca753d95L, - 0xf23a8028L, 0xf6fb9d9fL, 0xfbb8bb46L, 0xff79a6f1L, - 0xe13ef6f4L, 0xe5ffeb43L, 0xe8bccd9aL, 0xec7dd02dL, - 0x34867077L, 0x30476dc0L, 0x3d044b19L, 0x39c556aeL, - 0x278206abL, 0x23431b1cL, 0x2e003dc5L, 0x2ac12072L, - 0x128e9dcfL, 0x164f8078L, 0x1b0ca6a1L, 0x1fcdbb16L, - 0x018aeb13L, 0x054bf6a4L, 0x0808d07dL, 0x0cc9cdcaL, - 0x7897ab07L, 0x7c56b6b0L, 0x71159069L, 0x75d48ddeL, - 0x6b93dddbL, 0x6f52c06cL, 0x6211e6b5L, 0x66d0fb02L, - 0x5e9f46bfL, 0x5a5e5b08L, 0x571d7dd1L, 0x53dc6066L, - 0x4d9b3063L, 0x495a2dd4L, 0x44190b0dL, 0x40d816baL, - 0xaca5c697L, 0xa864db20L, 0xa527fdf9L, 0xa1e6e04eL, - 0xbfa1b04bL, 0xbb60adfcL, 0xb6238b25L, 0xb2e29692L, - 0x8aad2b2fL, 0x8e6c3698L, 0x832f1041L, 0x87ee0df6L, - 0x99a95df3L, 0x9d684044L, 0x902b669dL, 0x94ea7b2aL, - 0xe0b41de7L, 0xe4750050L, 0xe9362689L, 0xedf73b3eL, - 0xf3b06b3bL, 0xf771768cL, 0xfa325055L, 0xfef34de2L, - 0xc6bcf05fL, 0xc27dede8L, 0xcf3ecb31L, 0xcbffd686L, - 0xd5b88683L, 0xd1799b34L, 0xdc3abdedL, 0xd8fba05aL, - 0x690ce0eeL, 0x6dcdfd59L, 0x608edb80L, 0x644fc637L, - 0x7a089632L, 0x7ec98b85L, 0x738aad5cL, 0x774bb0ebL, - 0x4f040d56L, 0x4bc510e1L, 0x46863638L, 0x42472b8fL, - 0x5c007b8aL, 0x58c1663dL, 0x558240e4L, 0x51435d53L, - 0x251d3b9eL, 0x21dc2629L, 0x2c9f00f0L, 0x285e1d47L, - 0x36194d42L, 0x32d850f5L, 0x3f9b762cL, 0x3b5a6b9bL, - 0x0315d626L, 0x07d4cb91L, 0x0a97ed48L, 0x0e56f0ffL, - 0x1011a0faL, 0x14d0bd4dL, 0x19939b94L, 0x1d528623L, - 0xf12f560eL, 0xf5ee4bb9L, 0xf8ad6d60L, 0xfc6c70d7L, - 0xe22b20d2L, 0xe6ea3d65L, 0xeba91bbcL, 0xef68060bL, - 0xd727bbb6L, 0xd3e6a601L, 0xdea580d8L, 0xda649d6fL, - 0xc423cd6aL, 0xc0e2d0ddL, 0xcda1f604L, 0xc960ebb3L, - 0xbd3e8d7eL, 0xb9ff90c9L, 0xb4bcb610L, 0xb07daba7L, - 0xae3afba2L, 0xaafbe615L, 0xa7b8c0ccL, 0xa379dd7bL, - 0x9b3660c6L, 0x9ff77d71L, 0x92b45ba8L, 0x9675461fL, - 0x8832161aL, 0x8cf30badL, 0x81b02d74L, 0x857130c3L, - 0x5d8a9099L, 0x594b8d2eL, 0x5408abf7L, 0x50c9b640L, - 0x4e8ee645L, 0x4a4ffbf2L, 0x470cdd2bL, 0x43cdc09cL, - 0x7b827d21L, 0x7f436096L, 0x7200464fL, 0x76c15bf8L, - 0x68860bfdL, 0x6c47164aL, 0x61043093L, 0x65c52d24L, - 0x119b4be9L, 0x155a565eL, 0x18197087L, 0x1cd86d30L, - 0x029f3d35L, 0x065e2082L, 0x0b1d065bL, 0x0fdc1becL, - 0x3793a651L, 0x3352bbe6L, 0x3e119d3fL, 0x3ad08088L, - 0x2497d08dL, 0x2056cd3aL, 0x2d15ebe3L, 0x29d4f654L, - 0xc5a92679L, 0xc1683bceL, 0xcc2b1d17L, 0xc8ea00a0L, - 0xd6ad50a5L, 0xd26c4d12L, 0xdf2f6bcbL, 0xdbee767cL, - 0xe3a1cbc1L, 0xe760d676L, 0xea23f0afL, 0xeee2ed18L, - 0xf0a5bd1dL, 0xf464a0aaL, 0xf9278673L, 0xfde69bc4L, - 0x89b8fd09L, 0x8d79e0beL, 0x803ac667L, 0x84fbdbd0L, - 0x9abc8bd5L, 0x9e7d9662L, 0x933eb0bbL, 0x97ffad0cL, - 0xafb010b1L, 0xab710d06L, 0xa6322bdfL, 0xa2f33668L, - 0xbcb4666dL, 0xb8757bdaL, 0xb5365d03L, 0xb1f740b4L -}; - - -/*-------------------------------------------------------------*/ -/*--- end crctable.c ---*/ -/*-------------------------------------------------------------*/ diff --git a/libs/storm-sys/StormLib/src/bzip2/decompress.c b/libs/storm-sys/StormLib/src/bzip2/decompress.c deleted file mode 100644 index bba5e0f..0000000 --- a/libs/storm-sys/StormLib/src/bzip2/decompress.c +++ /dev/null @@ -1,626 +0,0 @@ - -/*-------------------------------------------------------------*/ -/*--- Decompression machinery ---*/ -/*--- decompress.c ---*/ -/*-------------------------------------------------------------*/ - -/* ------------------------------------------------------------------ - This file is part of bzip2/libbzip2, a program and library for - lossless, block-sorting data compression. - - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward - - Please read the WARNING, DISCLAIMER and PATENTS sections in the - README file. - - This program is released under the terms of the license contained - in the file LICENSE. - ------------------------------------------------------------------ */ - - -#include "bzlib_private.h" - - -/*---------------------------------------------------*/ -static -void makeMaps_d ( DState* s ) -{ - Int32 i; - s->nInUse = 0; - for (i = 0; i < 256; i++) - if (s->inUse[i]) { - s->seqToUnseq[s->nInUse] = i; - s->nInUse++; - } -} - - -/*---------------------------------------------------*/ -#define RETURN(rrr) \ - { retVal = rrr; goto save_state_and_return; }; - -#define GET_BITS(lll,vvv,nnn) \ - case lll: s->state = lll; \ - while (True) { \ - if (s->bsLive >= nnn) { \ - UInt32 v; \ - v = (s->bsBuff >> \ - (s->bsLive-nnn)) & ((1 << nnn)-1); \ - s->bsLive -= nnn; \ - vvv = v; \ - break; \ - } \ - if (s->strm->avail_in == 0) RETURN(BZ_OK); \ - s->bsBuff \ - = (s->bsBuff << 8) | \ - ((UInt32) \ - (*((UChar*)(s->strm->next_in)))); \ - s->bsLive += 8; \ - s->strm->next_in++; \ - s->strm->avail_in--; \ - s->strm->total_in_lo32++; \ - if (s->strm->total_in_lo32 == 0) \ - s->strm->total_in_hi32++; \ - } - -#define GET_UCHAR(lll,uuu) \ - GET_BITS(lll,uuu,8) - -#define GET_BIT(lll,uuu) \ - GET_BITS(lll,uuu,1) - -/*---------------------------------------------------*/ -#define GET_MTF_VAL(label1,label2,lval) \ -{ \ - if (groupPos == 0) { \ - groupNo++; \ - if (groupNo >= nSelectors) \ - RETURN(BZ_DATA_ERROR); \ - groupPos = BZ_G_SIZE; \ - gSel = s->selector[groupNo]; \ - gMinlen = s->minLens[gSel]; \ - gLimit = &(s->limit[gSel][0]); \ - gPerm = &(s->perm[gSel][0]); \ - gBase = &(s->base[gSel][0]); \ - } \ - groupPos--; \ - zn = gMinlen; \ - GET_BITS(label1, zvec, zn); \ - while (1) { \ - if (zn > 20 /* the longest code */) \ - RETURN(BZ_DATA_ERROR); \ - if (zvec <= gLimit[zn]) break; \ - zn++; \ - GET_BIT(label2, zj); \ - zvec = (zvec << 1) | zj; \ - }; \ - if (zvec - gBase[zn] < 0 \ - || zvec - gBase[zn] >= BZ_MAX_ALPHA_SIZE) \ - RETURN(BZ_DATA_ERROR); \ - lval = gPerm[zvec - gBase[zn]]; \ -} - - -/*---------------------------------------------------*/ -Int32 BZ2_decompress ( DState* s ) -{ - UChar uc; - Int32 retVal; - Int32 minLen, maxLen; - bz_stream* strm = s->strm; - - /* stuff that needs to be saved/restored */ - Int32 i; - Int32 j; - Int32 t; - Int32 alphaSize; - Int32 nGroups; - Int32 nSelectors; - Int32 EOB; - Int32 groupNo; - Int32 groupPos; - Int32 nextSym; - Int32 nblockMAX; - Int32 nblock; - Int32 es; - Int32 N; - Int32 curr; - Int32 zt; - Int32 zn; - Int32 zvec; - Int32 zj; - Int32 gSel; - Int32 gMinlen; - Int32* gLimit; - Int32* gBase; - Int32* gPerm; - - if (s->state == BZ_X_MAGIC_1) { - /*initialise the save area*/ - s->save_i = 0; - s->save_j = 0; - s->save_t = 0; - s->save_alphaSize = 0; - s->save_nGroups = 0; - s->save_nSelectors = 0; - s->save_EOB = 0; - s->save_groupNo = 0; - s->save_groupPos = 0; - s->save_nextSym = 0; - s->save_nblockMAX = 0; - s->save_nblock = 0; - s->save_es = 0; - s->save_N = 0; - s->save_curr = 0; - s->save_zt = 0; - s->save_zn = 0; - s->save_zvec = 0; - s->save_zj = 0; - s->save_gSel = 0; - s->save_gMinlen = 0; - s->save_gLimit = NULL; - s->save_gBase = NULL; - s->save_gPerm = NULL; - } - - /*restore from the save area*/ - i = s->save_i; - j = s->save_j; - t = s->save_t; - alphaSize = s->save_alphaSize; - nGroups = s->save_nGroups; - nSelectors = s->save_nSelectors; - EOB = s->save_EOB; - groupNo = s->save_groupNo; - groupPos = s->save_groupPos; - nextSym = s->save_nextSym; - nblockMAX = s->save_nblockMAX; - nblock = s->save_nblock; - es = s->save_es; - N = s->save_N; - curr = s->save_curr; - zt = s->save_zt; - zn = s->save_zn; - zvec = s->save_zvec; - zj = s->save_zj; - gSel = s->save_gSel; - gMinlen = s->save_gMinlen; - gLimit = s->save_gLimit; - gBase = s->save_gBase; - gPerm = s->save_gPerm; - - retVal = BZ_OK; - - switch (s->state) { - - GET_UCHAR(BZ_X_MAGIC_1, uc); - if (uc != BZ_HDR_B) RETURN(BZ_DATA_ERROR_MAGIC); - - GET_UCHAR(BZ_X_MAGIC_2, uc); - if (uc != BZ_HDR_Z) RETURN(BZ_DATA_ERROR_MAGIC); - - GET_UCHAR(BZ_X_MAGIC_3, uc) - if (uc != BZ_HDR_h) RETURN(BZ_DATA_ERROR_MAGIC); - - GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8) - if (s->blockSize100k < (BZ_HDR_0 + 1) || - s->blockSize100k > (BZ_HDR_0 + 9)) RETURN(BZ_DATA_ERROR_MAGIC); - s->blockSize100k -= BZ_HDR_0; - - if (s->smallDecompress) { - s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) ); - s->ll4 = BZALLOC( - ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar) - ); - if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR); - } else { - s->tt = BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) ); - if (s->tt == NULL) RETURN(BZ_MEM_ERROR); - } - - GET_UCHAR(BZ_X_BLKHDR_1, uc); - - if (uc == 0x17) goto endhdr_2; - if (uc != 0x31) RETURN(BZ_DATA_ERROR); - GET_UCHAR(BZ_X_BLKHDR_2, uc); - if (uc != 0x41) RETURN(BZ_DATA_ERROR); - GET_UCHAR(BZ_X_BLKHDR_3, uc); - if (uc != 0x59) RETURN(BZ_DATA_ERROR); - GET_UCHAR(BZ_X_BLKHDR_4, uc); - if (uc != 0x26) RETURN(BZ_DATA_ERROR); - GET_UCHAR(BZ_X_BLKHDR_5, uc); - if (uc != 0x53) RETURN(BZ_DATA_ERROR); - GET_UCHAR(BZ_X_BLKHDR_6, uc); - if (uc != 0x59) RETURN(BZ_DATA_ERROR); - - s->currBlockNo++; - if (s->verbosity >= 2) - VPrintf1 ( "\n [%d: huff+mtf ", s->currBlockNo ); - - s->storedBlockCRC = 0; - GET_UCHAR(BZ_X_BCRC_1, uc); - s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); - GET_UCHAR(BZ_X_BCRC_2, uc); - s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); - GET_UCHAR(BZ_X_BCRC_3, uc); - s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); - GET_UCHAR(BZ_X_BCRC_4, uc); - s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); - - GET_BITS(BZ_X_RANDBIT, s->blockRandomised, 1); - - s->origPtr = 0; - GET_UCHAR(BZ_X_ORIGPTR_1, uc); - s->origPtr = (s->origPtr << 8) | ((Int32)uc); - GET_UCHAR(BZ_X_ORIGPTR_2, uc); - s->origPtr = (s->origPtr << 8) | ((Int32)uc); - GET_UCHAR(BZ_X_ORIGPTR_3, uc); - s->origPtr = (s->origPtr << 8) | ((Int32)uc); - - if (s->origPtr < 0) - RETURN(BZ_DATA_ERROR); - if (s->origPtr > 10 + 100000*s->blockSize100k) - RETURN(BZ_DATA_ERROR); - - /*--- Receive the mapping table ---*/ - for (i = 0; i < 16; i++) { - GET_BIT(BZ_X_MAPPING_1, uc); - if (uc == 1) - s->inUse16[i] = True; else - s->inUse16[i] = False; - } - - for (i = 0; i < 256; i++) s->inUse[i] = False; - - for (i = 0; i < 16; i++) - if (s->inUse16[i]) - for (j = 0; j < 16; j++) { - GET_BIT(BZ_X_MAPPING_2, uc); - if (uc == 1) s->inUse[i * 16 + j] = True; - } - makeMaps_d ( s ); - if (s->nInUse == 0) RETURN(BZ_DATA_ERROR); - alphaSize = s->nInUse+2; - - /*--- Now the selectors ---*/ - GET_BITS(BZ_X_SELECTOR_1, nGroups, 3); - if (nGroups < 2 || nGroups > 6) RETURN(BZ_DATA_ERROR); - GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15); - if (nSelectors < 1) RETURN(BZ_DATA_ERROR); - for (i = 0; i < nSelectors; i++) { - j = 0; - while (True) { - GET_BIT(BZ_X_SELECTOR_3, uc); - if (uc == 0) break; - j++; - if (j >= nGroups) RETURN(BZ_DATA_ERROR); - } - s->selectorMtf[i] = j; - } - - /*--- Undo the MTF values for the selectors. ---*/ - { - UChar pos[BZ_N_GROUPS], tmp, v; - for (v = 0; v < nGroups; v++) pos[v] = v; - - for (i = 0; i < nSelectors; i++) { - v = s->selectorMtf[i]; - tmp = pos[v]; - while (v > 0) { pos[v] = pos[v-1]; v--; } - pos[0] = tmp; - s->selector[i] = tmp; - } - } - - /*--- Now the coding tables ---*/ - for (t = 0; t < nGroups; t++) { - GET_BITS(BZ_X_CODING_1, curr, 5); - for (i = 0; i < alphaSize; i++) { - while (True) { - if (curr < 1 || curr > 20) RETURN(BZ_DATA_ERROR); - GET_BIT(BZ_X_CODING_2, uc); - if (uc == 0) break; - GET_BIT(BZ_X_CODING_3, uc); - if (uc == 0) curr++; else curr--; - } - s->len[t][i] = curr; - } - } - - /*--- Create the Huffman decoding tables ---*/ - for (t = 0; t < nGroups; t++) { - minLen = 32; - maxLen = 0; - for (i = 0; i < alphaSize; i++) { - if (s->len[t][i] > maxLen) maxLen = s->len[t][i]; - if (s->len[t][i] < minLen) minLen = s->len[t][i]; - } - BZ2_hbCreateDecodeTables ( - &(s->limit[t][0]), - &(s->base[t][0]), - &(s->perm[t][0]), - &(s->len[t][0]), - minLen, maxLen, alphaSize - ); - s->minLens[t] = minLen; - } - - /*--- Now the MTF values ---*/ - - EOB = s->nInUse+1; - nblockMAX = 100000 * s->blockSize100k; - groupNo = -1; - groupPos = 0; - - for (i = 0; i <= 255; i++) s->unzftab[i] = 0; - - /*-- MTF init --*/ - { - Int32 ii, jj, kk; - kk = MTFA_SIZE-1; - for (ii = 256 / MTFL_SIZE - 1; ii >= 0; ii--) { - for (jj = MTFL_SIZE-1; jj >= 0; jj--) { - s->mtfa[kk] = (UChar)(ii * MTFL_SIZE + jj); - kk--; - } - s->mtfbase[ii] = kk + 1; - } - } - /*-- end MTF init --*/ - - nblock = 0; - GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym); - - while (True) { - - if (nextSym == EOB) break; - - if (nextSym == BZ_RUNA || nextSym == BZ_RUNB) { - - es = -1; - N = 1; - do { - if (nextSym == BZ_RUNA) es = es + (0+1) * N; else - if (nextSym == BZ_RUNB) es = es + (1+1) * N; - N = N * 2; - GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym); - } - while (nextSym == BZ_RUNA || nextSym == BZ_RUNB); - - es++; - uc = s->seqToUnseq[ s->mtfa[s->mtfbase[0]] ]; - s->unzftab[uc] += es; - - if (s->smallDecompress) - while (es > 0) { - if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR); - s->ll16[nblock] = (UInt16)uc; - nblock++; - es--; - } - else - while (es > 0) { - if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR); - s->tt[nblock] = (UInt32)uc; - nblock++; - es--; - }; - - continue; - - } else { - - if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR); - - /*-- uc = MTF ( nextSym-1 ) --*/ - { - Int32 ii, jj, kk, pp, lno, off; - UInt32 nn; - nn = (UInt32)(nextSym - 1); - - if (nn < MTFL_SIZE) { - /* avoid general-case expense */ - pp = s->mtfbase[0]; - uc = s->mtfa[pp+nn]; - while (nn > 3) { - Int32 z = pp+nn; - s->mtfa[(z) ] = s->mtfa[(z)-1]; - s->mtfa[(z)-1] = s->mtfa[(z)-2]; - s->mtfa[(z)-2] = s->mtfa[(z)-3]; - s->mtfa[(z)-3] = s->mtfa[(z)-4]; - nn -= 4; - } - while (nn > 0) { - s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--; - }; - s->mtfa[pp] = uc; - } else { - /* general case */ - lno = nn / MTFL_SIZE; - off = nn % MTFL_SIZE; - pp = s->mtfbase[lno] + off; - uc = s->mtfa[pp]; - while (pp > s->mtfbase[lno]) { - s->mtfa[pp] = s->mtfa[pp-1]; pp--; - }; - s->mtfbase[lno]++; - while (lno > 0) { - s->mtfbase[lno]--; - s->mtfa[s->mtfbase[lno]] - = s->mtfa[s->mtfbase[lno-1] + MTFL_SIZE - 1]; - lno--; - } - s->mtfbase[0]--; - s->mtfa[s->mtfbase[0]] = uc; - if (s->mtfbase[0] == 0) { - kk = MTFA_SIZE-1; - for (ii = 256 / MTFL_SIZE-1; ii >= 0; ii--) { - for (jj = MTFL_SIZE-1; jj >= 0; jj--) { - s->mtfa[kk] = s->mtfa[s->mtfbase[ii] + jj]; - kk--; - } - s->mtfbase[ii] = kk + 1; - } - } - } - } - /*-- end uc = MTF ( nextSym-1 ) --*/ - - s->unzftab[s->seqToUnseq[uc]]++; - if (s->smallDecompress) - s->ll16[nblock] = (UInt16)(s->seqToUnseq[uc]); else - s->tt[nblock] = (UInt32)(s->seqToUnseq[uc]); - nblock++; - - GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym); - continue; - } - } - - /* Now we know what nblock is, we can do a better sanity - check on s->origPtr. - */ - if (s->origPtr < 0 || s->origPtr >= nblock) - RETURN(BZ_DATA_ERROR); - - /*-- Set up cftab to facilitate generation of T^(-1) --*/ - s->cftab[0] = 0; - for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1]; - for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1]; - for (i = 0; i <= 256; i++) { - if (s->cftab[i] < 0 || s->cftab[i] > nblock) { - /* s->cftab[i] can legitimately be == nblock */ - RETURN(BZ_DATA_ERROR); - } - } - - s->state_out_len = 0; - s->state_out_ch = 0; - BZ_INITIALISE_CRC ( s->calculatedBlockCRC ); - s->state = BZ_X_OUTPUT; - if (s->verbosity >= 2) VPrintf0 ( "rt+rld" ); - - if (s->smallDecompress) { - - /*-- Make a copy of cftab, used in generation of T --*/ - for (i = 0; i <= 256; i++) s->cftabCopy[i] = s->cftab[i]; - - /*-- compute the T vector --*/ - for (i = 0; i < nblock; i++) { - uc = (UChar)(s->ll16[i]); - SET_LL(i, s->cftabCopy[uc]); - s->cftabCopy[uc]++; - } - - /*-- Compute T^(-1) by pointer reversal on T --*/ - i = s->origPtr; - j = GET_LL(i); - do { - Int32 tmp = GET_LL(j); - SET_LL(j, i); - i = j; - j = tmp; - } - while (i != s->origPtr); - - s->tPos = s->origPtr; - s->nblock_used = 0; - if (s->blockRandomised) { - BZ_RAND_INIT_MASK; - BZ_GET_SMALL(s->k0); s->nblock_used++; - BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; - } else { - BZ_GET_SMALL(s->k0); s->nblock_used++; - } - - } else { - - /*-- compute the T^(-1) vector --*/ - for (i = 0; i < nblock; i++) { - uc = (UChar)(s->tt[i] & 0xff); - s->tt[s->cftab[uc]] |= (i << 8); - s->cftab[uc]++; - } - - s->tPos = s->tt[s->origPtr] >> 8; - s->nblock_used = 0; - if (s->blockRandomised) { - BZ_RAND_INIT_MASK; - BZ_GET_FAST(s->k0); s->nblock_used++; - BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; - } else { - BZ_GET_FAST(s->k0); s->nblock_used++; - } - - } - - RETURN(BZ_OK); - - - - endhdr_2: - - GET_UCHAR(BZ_X_ENDHDR_2, uc); - if (uc != 0x72) RETURN(BZ_DATA_ERROR); - GET_UCHAR(BZ_X_ENDHDR_3, uc); - if (uc != 0x45) RETURN(BZ_DATA_ERROR); - GET_UCHAR(BZ_X_ENDHDR_4, uc); - if (uc != 0x38) RETURN(BZ_DATA_ERROR); - GET_UCHAR(BZ_X_ENDHDR_5, uc); - if (uc != 0x50) RETURN(BZ_DATA_ERROR); - GET_UCHAR(BZ_X_ENDHDR_6, uc); - if (uc != 0x90) RETURN(BZ_DATA_ERROR); - - s->storedCombinedCRC = 0; - GET_UCHAR(BZ_X_CCRC_1, uc); - s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc); - GET_UCHAR(BZ_X_CCRC_2, uc); - s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc); - GET_UCHAR(BZ_X_CCRC_3, uc); - s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc); - GET_UCHAR(BZ_X_CCRC_4, uc); - s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc); - - s->state = BZ_X_IDLE; - RETURN(BZ_STREAM_END); - - default: AssertH ( False, 4001 ); - } - - AssertH ( False, 4002 ); - - save_state_and_return: - - s->save_i = i; - s->save_j = j; - s->save_t = t; - s->save_alphaSize = alphaSize; - s->save_nGroups = nGroups; - s->save_nSelectors = nSelectors; - s->save_EOB = EOB; - s->save_groupNo = groupNo; - s->save_groupPos = groupPos; - s->save_nextSym = nextSym; - s->save_nblockMAX = nblockMAX; - s->save_nblock = nblock; - s->save_es = es; - s->save_N = N; - s->save_curr = curr; - s->save_zt = zt; - s->save_zn = zn; - s->save_zvec = zvec; - s->save_zj = zj; - s->save_gSel = gSel; - s->save_gMinlen = gMinlen; - s->save_gLimit = gLimit; - s->save_gBase = gBase; - s->save_gPerm = gPerm; - - return retVal; -} - - -/*-------------------------------------------------------------*/ -/*--- end decompress.c ---*/ -/*-------------------------------------------------------------*/ diff --git a/libs/storm-sys/StormLib/src/bzip2/huffman.c b/libs/storm-sys/StormLib/src/bzip2/huffman.c deleted file mode 100644 index 87e79e3..0000000 --- a/libs/storm-sys/StormLib/src/bzip2/huffman.c +++ /dev/null @@ -1,205 +0,0 @@ - -/*-------------------------------------------------------------*/ -/*--- Huffman coding low-level stuff ---*/ -/*--- huffman.c ---*/ -/*-------------------------------------------------------------*/ - -/* ------------------------------------------------------------------ - This file is part of bzip2/libbzip2, a program and library for - lossless, block-sorting data compression. - - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward - - Please read the WARNING, DISCLAIMER and PATENTS sections in the - README file. - - This program is released under the terms of the license contained - in the file LICENSE. - ------------------------------------------------------------------ */ - - -#include "bzlib_private.h" - -/*---------------------------------------------------*/ -#define WEIGHTOF(zz0) ((zz0) & 0xffffff00) -#define DEPTHOF(zz1) ((zz1) & 0x000000ff) -#define MYMAX(zz2,zz3) ((zz2) > (zz3) ? (zz2) : (zz3)) - -#define ADDWEIGHTS(zw1,zw2) \ - (WEIGHTOF(zw1)+WEIGHTOF(zw2)) | \ - (1 + MYMAX(DEPTHOF(zw1),DEPTHOF(zw2))) - -#define UPHEAP(z) \ -{ \ - Int32 zz, tmp; \ - zz = z; tmp = heap[zz]; \ - while (weight[tmp] < weight[heap[zz >> 1]]) { \ - heap[zz] = heap[zz >> 1]; \ - zz >>= 1; \ - } \ - heap[zz] = tmp; \ -} - -#define DOWNHEAP(z) \ -{ \ - Int32 zz, yy, tmp; \ - zz = z; tmp = heap[zz]; \ - while (True) { \ - yy = zz << 1; \ - if (yy > nHeap) break; \ - if (yy < nHeap && \ - weight[heap[yy+1]] < weight[heap[yy]]) \ - yy++; \ - if (weight[tmp] < weight[heap[yy]]) break; \ - heap[zz] = heap[yy]; \ - zz = yy; \ - } \ - heap[zz] = tmp; \ -} - - -/*---------------------------------------------------*/ -void BZ2_hbMakeCodeLengths ( UChar *len, - Int32 *freq, - Int32 alphaSize, - Int32 maxLen ) -{ - /*-- - Nodes and heap entries run from 1. Entry 0 - for both the heap and nodes is a sentinel. - --*/ - Int32 nNodes, nHeap, n1, n2, i, j, k; - Bool tooLong; - - Int32 heap [ BZ_MAX_ALPHA_SIZE + 2 ]; - Int32 weight [ BZ_MAX_ALPHA_SIZE * 2 ]; - Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ]; - - for (i = 0; i < alphaSize; i++) - weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8; - - while (True) { - - nNodes = alphaSize; - nHeap = 0; - - heap[0] = 0; - weight[0] = 0; - parent[0] = -2; - - for (i = 1; i <= alphaSize; i++) { - parent[i] = -1; - nHeap++; - heap[nHeap] = i; - UPHEAP(nHeap); - } - - AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 ); - - while (nHeap > 1) { - n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1); - n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1); - nNodes++; - parent[n1] = parent[n2] = nNodes; - weight[nNodes] = ADDWEIGHTS(weight[n1], weight[n2]); - parent[nNodes] = -1; - nHeap++; - heap[nHeap] = nNodes; - UPHEAP(nHeap); - } - - AssertH( nNodes < (BZ_MAX_ALPHA_SIZE * 2), 2002 ); - - tooLong = False; - for (i = 1; i <= alphaSize; i++) { - j = 0; - k = i; - while (parent[k] >= 0) { k = parent[k]; j++; } - len[i-1] = j; - if (j > maxLen) tooLong = True; - } - - if (! tooLong) break; - - /* 17 Oct 04: keep-going condition for the following loop used - to be 'i < alphaSize', which missed the last element, - theoretically leading to the possibility of the compressor - looping. However, this count-scaling step is only needed if - one of the generated Huffman code words is longer than - maxLen, which up to and including version 1.0.2 was 20 bits, - which is extremely unlikely. In version 1.0.3 maxLen was - changed to 17 bits, which has minimal effect on compression - ratio, but does mean this scaling step is used from time to - time, enough to verify that it works. - - This means that bzip2-1.0.3 and later will only produce - Huffman codes with a maximum length of 17 bits. However, in - order to preserve backwards compatibility with bitstreams - produced by versions pre-1.0.3, the decompressor must still - handle lengths of up to 20. */ - - for (i = 1; i <= alphaSize; i++) { - j = weight[i] >> 8; - j = 1 + (j / 2); - weight[i] = j << 8; - } - } -} - - -/*---------------------------------------------------*/ -void BZ2_hbAssignCodes ( Int32 *code, - UChar *length, - Int32 minLen, - Int32 maxLen, - Int32 alphaSize ) -{ - Int32 n, vec, i; - - vec = 0; - for (n = minLen; n <= maxLen; n++) { - for (i = 0; i < alphaSize; i++) - if (length[i] == n) { code[i] = vec; vec++; }; - vec <<= 1; - } -} - - -/*---------------------------------------------------*/ -void BZ2_hbCreateDecodeTables ( Int32 *limit, - Int32 *base, - Int32 *perm, - UChar *length, - Int32 minLen, - Int32 maxLen, - Int32 alphaSize ) -{ - Int32 pp, i, j, vec; - - pp = 0; - for (i = minLen; i <= maxLen; i++) - for (j = 0; j < alphaSize; j++) - if (length[j] == i) { perm[pp] = j; pp++; }; - - for (i = 0; i < BZ_MAX_CODE_LEN; i++) base[i] = 0; - for (i = 0; i < alphaSize; i++) base[length[i]+1]++; - - for (i = 1; i < BZ_MAX_CODE_LEN; i++) base[i] += base[i-1]; - - for (i = 0; i < BZ_MAX_CODE_LEN; i++) limit[i] = 0; - vec = 0; - - for (i = minLen; i <= maxLen; i++) { - vec += (base[i+1] - base[i]); - limit[i] = vec-1; - vec <<= 1; - } - for (i = minLen + 1; i <= maxLen; i++) - base[i] = ((limit[i-1] + 1) << 1) - base[i]; -} - - -/*-------------------------------------------------------------*/ -/*--- end huffman.c ---*/ -/*-------------------------------------------------------------*/ diff --git a/libs/storm-sys/StormLib/src/bzip2/randtable.c b/libs/storm-sys/StormLib/src/bzip2/randtable.c deleted file mode 100644 index 068b763..0000000 --- a/libs/storm-sys/StormLib/src/bzip2/randtable.c +++ /dev/null @@ -1,84 +0,0 @@ - -/*-------------------------------------------------------------*/ -/*--- Table for randomising repetitive blocks ---*/ -/*--- randtable.c ---*/ -/*-------------------------------------------------------------*/ - -/* ------------------------------------------------------------------ - This file is part of bzip2/libbzip2, a program and library for - lossless, block-sorting data compression. - - bzip2/libbzip2 version 1.0.5 of 10 December 2007 - Copyright (C) 1996-2007 Julian Seward - - Please read the WARNING, DISCLAIMER and PATENTS sections in the - README file. - - This program is released under the terms of the license contained - in the file LICENSE. - ------------------------------------------------------------------ */ - - -#include "bzlib_private.h" - - -/*---------------------------------------------*/ -Int32 BZ2_rNums[512] = { - 619, 720, 127, 481, 931, 816, 813, 233, 566, 247, - 985, 724, 205, 454, 863, 491, 741, 242, 949, 214, - 733, 859, 335, 708, 621, 574, 73, 654, 730, 472, - 419, 436, 278, 496, 867, 210, 399, 680, 480, 51, - 878, 465, 811, 169, 869, 675, 611, 697, 867, 561, - 862, 687, 507, 283, 482, 129, 807, 591, 733, 623, - 150, 238, 59, 379, 684, 877, 625, 169, 643, 105, - 170, 607, 520, 932, 727, 476, 693, 425, 174, 647, - 73, 122, 335, 530, 442, 853, 695, 249, 445, 515, - 909, 545, 703, 919, 874, 474, 882, 500, 594, 612, - 641, 801, 220, 162, 819, 984, 589, 513, 495, 799, - 161, 604, 958, 533, 221, 400, 386, 867, 600, 782, - 382, 596, 414, 171, 516, 375, 682, 485, 911, 276, - 98, 553, 163, 354, 666, 933, 424, 341, 533, 870, - 227, 730, 475, 186, 263, 647, 537, 686, 600, 224, - 469, 68, 770, 919, 190, 373, 294, 822, 808, 206, - 184, 943, 795, 384, 383, 461, 404, 758, 839, 887, - 715, 67, 618, 276, 204, 918, 873, 777, 604, 560, - 951, 160, 578, 722, 79, 804, 96, 409, 713, 940, - 652, 934, 970, 447, 318, 353, 859, 672, 112, 785, - 645, 863, 803, 350, 139, 93, 354, 99, 820, 908, - 609, 772, 154, 274, 580, 184, 79, 626, 630, 742, - 653, 282, 762, 623, 680, 81, 927, 626, 789, 125, - 411, 521, 938, 300, 821, 78, 343, 175, 128, 250, - 170, 774, 972, 275, 999, 639, 495, 78, 352, 126, - 857, 956, 358, 619, 580, 124, 737, 594, 701, 612, - 669, 112, 134, 694, 363, 992, 809, 743, 168, 974, - 944, 375, 748, 52, 600, 747, 642, 182, 862, 81, - 344, 805, 988, 739, 511, 655, 814, 334, 249, 515, - 897, 955, 664, 981, 649, 113, 974, 459, 893, 228, - 433, 837, 553, 268, 926, 240, 102, 654, 459, 51, - 686, 754, 806, 760, 493, 403, 415, 394, 687, 700, - 946, 670, 656, 610, 738, 392, 760, 799, 887, 653, - 978, 321, 576, 617, 626, 502, 894, 679, 243, 440, - 680, 879, 194, 572, 640, 724, 926, 56, 204, 700, - 707, 151, 457, 449, 797, 195, 791, 558, 945, 679, - 297, 59, 87, 824, 713, 663, 412, 693, 342, 606, - 134, 108, 571, 364, 631, 212, 174, 643, 304, 329, - 343, 97, 430, 751, 497, 314, 983, 374, 822, 928, - 140, 206, 73, 263, 980, 736, 876, 478, 430, 305, - 170, 514, 364, 692, 829, 82, 855, 953, 676, 246, - 369, 970, 294, 750, 807, 827, 150, 790, 288, 923, - 804, 378, 215, 828, 592, 281, 565, 555, 710, 82, - 896, 831, 547, 261, 524, 462, 293, 465, 502, 56, - 661, 821, 976, 991, 658, 869, 905, 758, 745, 193, - 768, 550, 608, 933, 378, 286, 215, 979, 792, 961, - 61, 688, 793, 644, 986, 403, 106, 366, 905, 644, - 372, 567, 466, 434, 645, 210, 389, 550, 919, 135, - 780, 773, 635, 389, 707, 100, 626, 958, 165, 504, - 920, 176, 193, 713, 857, 265, 203, 50, 668, 108, - 645, 990, 626, 197, 510, 357, 358, 850, 858, 364, - 936, 638 -}; - - -/*-------------------------------------------------------------*/ -/*--- end randtable.c ---*/ -/*-------------------------------------------------------------*/ diff --git a/libs/storm-sys/StormLib/src/huffman/huff.cpp b/libs/storm-sys/StormLib/src/huffman/huff.cpp deleted file mode 100644 index 9de5acb..0000000 --- a/libs/storm-sys/StormLib/src/huffman/huff.cpp +++ /dev/null @@ -1,873 +0,0 @@ -/*****************************************************************************/ -/* huffman.cpp Copyright (c) Ladislav Zezula 1998-2003 */ -/*---------------------------------------------------------------------------*/ -/* This module contains Huffmann (de)compression methods */ -/* */ -/* Authors : Ladislav Zezula (ladik@zezula.net) */ -/* ShadowFlare (BlakFlare@hotmail.com) */ -/* */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* xx.xx.xx 1.00 Lad The first version of dcmp.cpp */ -/* 03.05.03 1.00 Lad Added compression methods */ -/* 19.11.03 1.01 Dan Big endian handling */ -/* 08.12.03 2.01 Dan High-memory handling (> 0x80000000) */ -/* 09.01.13 3.00 Lad Refactored, beautified, documented :-) */ -/*****************************************************************************/ - -#include -#include - -#include "huff.h" - -//----------------------------------------------------------------------------- -// Table of byte-to-weight values - -// Table for (de)compression. Every compression type has 258 entries -static unsigned char ByteToWeight_00[] = -{ - 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00 -}; - -// Data for compression type 0x01 -static unsigned char ByteToWeight_01[] = -{ - 0x54, 0x16, 0x16, 0x0D, 0x0C, 0x08, 0x06, 0x05, 0x06, 0x05, 0x06, 0x03, 0x04, 0x04, 0x03, 0x05, - 0x0E, 0x0B, 0x14, 0x13, 0x13, 0x09, 0x0B, 0x06, 0x05, 0x04, 0x03, 0x02, 0x03, 0x02, 0x02, 0x02, - 0x0D, 0x07, 0x09, 0x06, 0x06, 0x04, 0x03, 0x02, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, - 0x09, 0x06, 0x04, 0x04, 0x04, 0x04, 0x03, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x04, - 0x08, 0x03, 0x04, 0x07, 0x09, 0x05, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, - 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, - 0x06, 0x0A, 0x08, 0x08, 0x06, 0x07, 0x04, 0x03, 0x04, 0x04, 0x02, 0x02, 0x04, 0x02, 0x03, 0x03, - 0x04, 0x03, 0x07, 0x07, 0x09, 0x06, 0x04, 0x03, 0x03, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x0A, 0x02, 0x02, 0x03, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x06, 0x03, 0x05, 0x02, 0x03, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x03, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x04, 0x04, 0x04, 0x07, 0x09, 0x08, 0x0C, 0x02, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x03, - 0x04, 0x01, 0x02, 0x04, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, - 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x06, 0x4B, - 0x00, 0x00 -}; - -// Data for compression type 0x02 -static unsigned char ByteToWeight_02[] = -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x27, 0x00, 0x00, 0x23, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x06, 0x0E, 0x10, 0x04, - 0x06, 0x08, 0x05, 0x04, 0x04, 0x03, 0x03, 0x02, 0x02, 0x03, 0x03, 0x01, 0x01, 0x02, 0x01, 0x01, - 0x01, 0x04, 0x02, 0x04, 0x02, 0x02, 0x02, 0x01, 0x01, 0x04, 0x01, 0x01, 0x02, 0x03, 0x03, 0x02, - 0x03, 0x01, 0x03, 0x06, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x01, 0x01, - 0x01, 0x29, 0x07, 0x16, 0x12, 0x40, 0x0A, 0x0A, 0x11, 0x25, 0x01, 0x03, 0x17, 0x10, 0x26, 0x2A, - 0x10, 0x01, 0x23, 0x23, 0x2F, 0x10, 0x06, 0x07, 0x02, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00 -}; - -// Data for compression type 0x03 -static unsigned char ByteToWeight_03[] = -{ - 0xFF, 0x0B, 0x07, 0x05, 0x0B, 0x02, 0x02, 0x02, 0x06, 0x02, 0x02, 0x01, 0x04, 0x02, 0x01, 0x03, - 0x09, 0x01, 0x01, 0x01, 0x03, 0x04, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, - 0x05, 0x01, 0x01, 0x01, 0x0D, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x0A, 0x04, 0x02, 0x01, 0x06, 0x03, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x01, - 0x05, 0x02, 0x03, 0x04, 0x03, 0x03, 0x03, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x03, 0x03, - 0x01, 0x03, 0x01, 0x01, 0x02, 0x05, 0x01, 0x01, 0x04, 0x03, 0x05, 0x01, 0x03, 0x01, 0x03, 0x03, - 0x02, 0x01, 0x04, 0x03, 0x0A, 0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x0A, 0x02, 0x05, 0x01, 0x01, 0x02, 0x07, 0x02, 0x17, 0x01, 0x05, 0x01, 0x01, - 0x0E, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x06, 0x02, 0x01, 0x04, 0x05, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x11, - 0x00, 0x00 -}; - -// Data for compression type 0x04 -static unsigned char ByteToWeight_04[] = -{ - 0xFF, 0xFB, 0x98, 0x9A, 0x84, 0x85, 0x63, 0x64, 0x3E, 0x3E, 0x22, 0x22, 0x13, 0x13, 0x18, 0x17, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00 -}; - -// Data for compression type 0x05 -static unsigned char ByteToWeight_05[] = -{ - 0xFF, 0xF1, 0x9D, 0x9E, 0x9A, 0x9B, 0x9A, 0x97, 0x93, 0x93, 0x8C, 0x8E, 0x86, 0x88, 0x80, 0x82, - 0x7C, 0x7C, 0x72, 0x73, 0x69, 0x6B, 0x5F, 0x60, 0x55, 0x56, 0x4A, 0x4B, 0x40, 0x41, 0x37, 0x37, - 0x2F, 0x2F, 0x27, 0x27, 0x21, 0x21, 0x1B, 0x1C, 0x17, 0x17, 0x13, 0x13, 0x10, 0x10, 0x0D, 0x0D, - 0x0B, 0x0B, 0x09, 0x09, 0x08, 0x08, 0x07, 0x07, 0x06, 0x05, 0x05, 0x04, 0x04, 0x04, 0x19, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00 -}; - - // Data for compression type 0x06 -static unsigned char ByteToWeight_06[] = -{ - 0xC3, 0xCB, 0xF5, 0x41, 0xFF, 0x7B, 0xF7, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xBF, 0xCC, 0xF2, 0x40, 0xFD, 0x7C, 0xF7, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x7A, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00 -}; - -// Data for compression type 0x07 -static unsigned char ByteToWeight_07[] = -{ - 0xC3, 0xD9, 0xEF, 0x3D, 0xF9, 0x7C, 0xE9, 0x1E, 0xFD, 0xAB, 0xF1, 0x2C, 0xFC, 0x5B, 0xFE, 0x17, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xBD, 0xD9, 0xEC, 0x3D, 0xF5, 0x7D, 0xE8, 0x1D, 0xFB, 0xAE, 0xF0, 0x2C, 0xFB, 0x5C, 0xFF, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x70, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00 -}; - -// Data for compression type 0x08 -static unsigned char ByteToWeight_08[] = -{ - 0xBA, 0xC5, 0xDA, 0x33, 0xE3, 0x6D, 0xD8, 0x18, 0xE5, 0x94, 0xDA, 0x23, 0xDF, 0x4A, 0xD1, 0x10, - 0xEE, 0xAF, 0xE4, 0x2C, 0xEA, 0x5A, 0xDE, 0x15, 0xF4, 0x87, 0xE9, 0x21, 0xF6, 0x43, 0xFC, 0x12, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xB0, 0xC7, 0xD8, 0x33, 0xE3, 0x6B, 0xD6, 0x18, 0xE7, 0x95, 0xD8, 0x23, 0xDB, 0x49, 0xD0, 0x11, - 0xE9, 0xB2, 0xE2, 0x2B, 0xE8, 0x5C, 0xDD, 0x15, 0xF1, 0x87, 0xE7, 0x20, 0xF7, 0x44, 0xFF, 0x13, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x5F, 0x9E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00 -}; - -static unsigned char * WeightTables[0x09] = -{ - ByteToWeight_00, - ByteToWeight_01, - ByteToWeight_02, - ByteToWeight_03, - ByteToWeight_04, - ByteToWeight_05, - ByteToWeight_06, - ByteToWeight_07, - ByteToWeight_08 -}; - -//----------------------------------------------------------------------------- -// Debug/diagnostics - -#ifdef _DEBUG -void DumpHuffmannTree(THTreeItem * pItem) -{ - THTreeItem * pChildLo; // Item with the lower weight - THTreeItem * pChildHi; // Item with the higher weight - - // Get the lower-weight branch - pChildLo = pItem->pChildLo; - if(pChildLo != NULL) - { - // Get the higher-weight branch - pChildHi = pChildLo->pPrev; - - // Parse the lower-weight branch - DumpHuffmannTree(pChildHi); - DumpHuffmannTree(pChildLo); - } -} -#endif - -//----------------------------------------------------------------------------- -// TInputStream functions - -TInputStream::TInputStream(void * pvInBuffer, size_t cbInBuffer) -{ - pbInBufferEnd = (unsigned char *)pvInBuffer + cbInBuffer; - pbInBuffer = (unsigned char *)pvInBuffer; - BitBuffer = 0; - BitCount = 0; -} - -// Gets 7 bits from the stream. DOES NOT remove the bits from input stream -unsigned int TInputStream::Peek7Bits() -{ - unsigned int dwReloadByte = 0; - - // If there is not enough bits to get the value, - // we have to add 8 more bits from the input buffer - if(BitCount < 7) - { - dwReloadByte = *pbInBuffer++; - BitBuffer |= dwReloadByte << BitCount; - BitCount += 8; - } - - // Return the first available 7 bits. DO NOT remove them from the input stream - return (BitBuffer & 0x7F); -} - -// Gets one bit from input stream -unsigned int TInputStream::Get1Bit() -{ - unsigned int OneBit = 0; - - // Ensure that the input stream is reloaded, if there are no bits left - if(BitCount == 0) - { - // Refill the bit buffer - BitBuffer = *pbInBuffer++; - BitCount = 8; - } - - // Copy the bit from bit buffer to the variable - OneBit = (BitBuffer & 0x01); - BitBuffer >>= 1; - BitCount--; - - return OneBit; -} - -// Gets the whole byte from the input stream. -unsigned int TInputStream::Get8Bits() -{ - unsigned int dwReloadByte = 0; - unsigned int dwOneByte = 0; - - // If there is not enough bits to get the value, - // we have to add 8 more bits from the input buffer - if(BitCount < 8) - { - dwReloadByte = *pbInBuffer++; - BitBuffer |= dwReloadByte << BitCount; - BitCount += 8; - } - - // Return the lowest 8 its - dwOneByte = (BitBuffer & 0xFF); - BitBuffer >>= 8; - BitCount -= 8; - return dwOneByte; -} - -void TInputStream::SkipBits(unsigned int dwBitsToSkip) -{ - unsigned int dwReloadByte = 0; - - // If there is not enough bits in the buffer, - // we have to add 8 more bits from the input buffer - if(BitCount < dwBitsToSkip) - { - dwReloadByte = *pbInBuffer++; - BitBuffer |= dwReloadByte << BitCount; - BitCount += 8; - } - - // Skip the remaining bits - BitBuffer >>= dwBitsToSkip; - BitCount -= dwBitsToSkip; -} - -//----------------------------------------------------------------------------- -// TOutputStream functions - -TOutputStream::TOutputStream(void * pvOutBuffer, size_t cbOutLength) -{ - pbOutBufferEnd = (unsigned char *)pvOutBuffer + cbOutLength; - pbOutBuffer = (unsigned char *)pvOutBuffer; - BitBuffer = 0; - BitCount = 0; -} - -void TOutputStream::PutBits(unsigned int dwValue, unsigned int nBitCount) -{ - BitBuffer |= (dwValue << BitCount); - BitCount += nBitCount; - - // Flush completed bytes - while(BitCount >= 8) - { - if(pbOutBuffer < pbOutBufferEnd) - *pbOutBuffer++ = (unsigned char)BitBuffer; - - BitBuffer >>= 8; - BitCount -= 8; - } -} - -void TOutputStream::Flush() -{ - while(BitCount != 0) - { - if(pbOutBuffer < pbOutBufferEnd) - *pbOutBuffer++ = (unsigned char)BitBuffer; - - BitBuffer >>= 8; - BitCount -= ((BitCount > 8) ? 8 : BitCount); - } -} - -//----------------------------------------------------------------------------- -// Methods of the THTreeItem struct - -void THTreeItem::RemoveItem() -{ - if(pNext != NULL) - { - pPrev->pNext = pNext; - pNext->pPrev = pPrev; - pNext = pPrev = NULL; - } -} - -//----------------------------------------------------------------------------- -// THuffmannTree class functions - -THuffmannTree::THuffmannTree(bool bCompression) -{ - pFirst = pLast = LIST_HEAD(); - MinValidValue = 1; - ItemsUsed = 0; - bIsCmp0 = 0; - - memset(ItemsByByte, 0, sizeof(ItemsByByte)); - - // If we are going to decompress data, we need to invalidate all item links - // We do so by zeroing their ValidValue, so it becomes lower MinValidValue - if(bCompression == false) - { - memset(QuickLinks, 0, sizeof(QuickLinks)); - } -} - -THuffmannTree::~THuffmannTree() -{ - // Our Huffmann tree does not use any memory allocations, - // so we don't need to do eny code in the destructor -} - -void THuffmannTree::LinkTwoItems(THTreeItem * pItem1, THTreeItem * pItem2) -{ - pItem2->pNext = pItem1->pNext; - pItem2->pPrev = pItem1->pNext->pPrev; - pItem1->pNext->pPrev = pItem2; - pItem1->pNext = pItem2; -} - -// Inserts item into the tree (?) -void THuffmannTree::InsertItem(THTreeItem * pNewItem, TInsertPoint InsertPoint, THTreeItem * pInsertPoint) -{ - // Remove the item from the tree - pNewItem->RemoveItem(); - - if(pInsertPoint == NULL) - pInsertPoint = LIST_HEAD(); - - switch(InsertPoint) - { - case InsertAfter: - LinkTwoItems(pInsertPoint, pNewItem); - return; - - case InsertBefore: - pNewItem->pNext = pInsertPoint; // Set next item (or pointer to pointer to first item) - pNewItem->pPrev = pInsertPoint->pPrev; // Set prev item (or last item in the tree) - pInsertPoint->pPrev->pNext = pNewItem; - pInsertPoint->pPrev = pNewItem; // Set the next/last item - return; - } -} - -THTreeItem * THuffmannTree::FindHigherOrEqualItem(THTreeItem * pItem, unsigned int Weight) -{ - // Parse all existing items - if(pItem != NULL) - { - while(pItem != LIST_HEAD()) - { - if(pItem->Weight >= Weight) - return pItem; - - pItem = pItem->pPrev; - } - } - - // If not found, we just get the first item - return LIST_HEAD(); -} - -THTreeItem * THuffmannTree::CreateNewItem(unsigned int DecompressedValue, unsigned int Weight, TInsertPoint InsertPoint) -{ - THTreeItem * pNewItem; - - // Allocate new item from the item pool - pNewItem = &ItemBuffer[ItemsUsed++]; - - // Insert this item to the top of the tree - InsertItem(pNewItem, InsertPoint, NULL); - - // Fill the rest of the item - pNewItem->DecompressedValue = DecompressedValue; - pNewItem->Weight = Weight; - pNewItem->pParent = NULL; - pNewItem->pChildLo = NULL; - return pNewItem; -} - -unsigned int THuffmannTree::FixupItemPosByWeight(THTreeItem * pNewItem, unsigned int MaxWeight) -{ - THTreeItem * pHigherItem; - - if(pNewItem->Weight < MaxWeight) - { - // Find an item that has higher weight than this one - pHigherItem = FindHigherOrEqualItem(pLast, pNewItem->Weight); - - // Remove the item and put it to the new position - pNewItem->RemoveItem(); - LinkTwoItems(pHigherItem, pNewItem); - } - else - { - MaxWeight = pNewItem->Weight; - } - - // Return the (updated) maximum weight - return MaxWeight; -} - -// Builds Huffman tree. Called with the first 8 bits loaded from input stream -bool THuffmannTree::BuildTree(unsigned int CompressionType) -{ - THTreeItem * pNewItem; - THTreeItem * pChildLo; - THTreeItem * pChildHi; - unsigned char * WeightTable; - unsigned int MaxWeight; // [ESP+10] - The greatest character found in table - - // Clear all pointers in HTree item array - memset(ItemsByByte, 0, sizeof(ItemsByByte)); - MaxWeight = 0; - - // Ensure that the compression type is in range - if((CompressionType & 0x0F) > 0x08) - return false; - WeightTable = WeightTables[CompressionType & 0x0F]; - - // Build the linear list of entries that is sorted by byte weight - for(unsigned int i = 0; i < 0x100; i++) - { - // Skip all the bytes which are zero. - if(WeightTable[i] != 0) - { - // Create new tree item - ItemsByByte[i] = pNewItem = CreateNewItem(i, WeightTable[i], InsertAfter); - - // We need to put the item to the right place in the list - MaxWeight = FixupItemPosByWeight(pNewItem, MaxWeight); - } - } - - // Insert termination entries at the end of the list - ItemsByByte[0x100] = CreateNewItem(0x100, 1, InsertBefore); - ItemsByByte[0x101] = CreateNewItem(0x101, 1, InsertBefore); - - // Now we need to build the tree. We start at the last entry - // and go backwards to the first one - pChildLo = pLast; - - // Work as long as both children are valid - // pChildHi is child with higher weight, pChildLo is the one with lower weight - while(pChildLo != LIST_HEAD()) - { - // Also get and verify the higher-weight child - pChildHi = pChildLo->pPrev; - if(pChildHi == LIST_HEAD()) - break; - - // Create new parent item for the children - pNewItem = CreateNewItem(0, pChildHi->Weight + pChildLo->Weight, InsertAfter); - - // Link both child items to their new parent - pChildLo->pParent = pNewItem; - pChildHi->pParent = pNewItem; - pNewItem->pChildLo = pChildLo; - - // Fixup the item's position by its weight - MaxWeight = FixupItemPosByWeight(pNewItem, MaxWeight); - - // Get the previous lower-weight child - pChildLo = pChildHi->pPrev; - } - - // Initialize the MinValidValue to 1, which invalidates all quick-link items - MinValidValue = 1; - return true; -} - -void THuffmannTree::IncWeightsAndRebalance(THTreeItem * pItem) -{ - THTreeItem * pHigherItem; // A previous item with greater or equal weight - THTreeItem * pChildHi; // The higher-weight child - THTreeItem * pChildLo; // The lower-weight child - THTreeItem * pParent; - - // Climb up the tree and increment weight of each tree item - for(; pItem != NULL; pItem = pItem->pParent) - { - // Increment the item's weight - pItem->Weight++; - - // Find a previous item with equal or greater weight, which is not equal to this item - pHigherItem = FindHigherOrEqualItem(pItem->pPrev, pItem->Weight); - pChildHi = pHigherItem->pNext; - - // If the item is not equal to the tree item, we need to rebalance the tree - if(pChildHi != pItem) - { - // Move the previous item to the RIGHT from the given item - pChildHi->RemoveItem(); - LinkTwoItems(pItem, pChildHi); - - // Move the given item AFTER the greater-weight tree item - pItem->RemoveItem(); - LinkTwoItems(pHigherItem, pItem); - - // We need to maintain the tree so that pChildHi->Weight is >= pChildLo->Weight. - // Rebalance the tree accordingly. - pChildLo = pChildHi->pParent->pChildLo; - pParent = pItem->pParent; - if(pParent->pChildLo == pItem) - pParent->pChildLo = pChildHi; - if(pChildLo == pChildHi) - pChildHi->pParent->pChildLo = pItem; - pParent = pItem->pParent; - pItem->pParent = pChildHi->pParent; - pChildHi->pParent = pParent; - - // Increment the global valid value. This invalidates all quick-link items. - MinValidValue++; - } - } -} - -void THuffmannTree::InsertNewBranchAndRebalance(unsigned int Value1, unsigned int Value2) -{ - THTreeItem * pLastItem = pLast; - THTreeItem * pChildHi; - THTreeItem * pChildLo; - - // Create higher-weight child - pChildHi = CreateNewItem(Value1, pLastItem->Weight, InsertBefore); - pChildHi->pParent = pLastItem; - ItemsByByte[Value1] = pChildHi; - - // Create lower-weight child - pChildLo = CreateNewItem(Value2, 0, InsertBefore); - pChildLo->pParent = pLastItem; - pLastItem->pChildLo = pChildLo; - ItemsByByte[Value2] = pChildLo; - - IncWeightsAndRebalance(pChildLo); -} - -void THuffmannTree::EncodeOneByte(TOutputStream * os, THTreeItem * pItem) -{ - THTreeItem * pParent = pItem->pParent; - unsigned int BitBuffer = 0; - unsigned int BitCount = 0; - - // Put 1's as long as there is parent - while(pParent != NULL) - { - // Fill the bit buffer - BitBuffer = (BitBuffer << 1) | ((pParent->pChildLo != pItem) ? 1 : 0); - BitCount++; - - // Move to the parent - pItem = pParent; - pParent = pParent->pParent; - } - - // Write the bits to the output stream - os->PutBits(BitBuffer, BitCount); -} - -unsigned int THuffmannTree::DecodeOneByte(TInputStream * is) -{ - THTreeItem * pItemLink = NULL; - THTreeItem * pItem; - unsigned int ItemLinkIndex; - unsigned int BitCount = 0; - - // Check for the end of the input stream - if(is->pbInBuffer >= is->pbInBufferEnd && is->BitCount < 7) - return 0x1FF; - - // Get the eventual quick-link index - ItemLinkIndex = is->Peek7Bits(); - - // Is the quick-link item valid? - if(QuickLinks[ItemLinkIndex].ValidValue > MinValidValue) - { - // If that item needs less than 7 bits, we can get decompressed value directly - if(QuickLinks[ItemLinkIndex].ValidBits <= 7) - { - is->SkipBits(QuickLinks[ItemLinkIndex].ValidBits); - return QuickLinks[ItemLinkIndex].DecompressedValue; - } - - // Otherwise we cannot get decompressed value directly - // but we can skip 7 levels of tree parsing - pItem = QuickLinks[ItemLinkIndex].pItem; - is->SkipBits(7); - } - else - { - // Just a sanity check - if(pFirst == LIST_HEAD()) - return 0x1FF; - - // We don't have the quick-link item, we need to parse the tree from its root - pItem = pFirst; - } - - // Step down the tree until we find a terminal item - while(pItem->pChildLo != NULL) - { - // If the next bit in the compressed stream is set, we get the higher-weight - // child. Otherwise, get the lower-weight child. - pItem = is->Get1Bit() ? pItem->pChildLo->pPrev : pItem->pChildLo; - BitCount++; - - // If the number of loaded bits reached 7, - // remember the current item for storing into quick-link item array - if(BitCount == 7) - pItemLink = pItem; - } - - // If we didn't get the item from the quick-link array, - // set the entry in it - if(QuickLinks[ItemLinkIndex].ValidValue < MinValidValue) - { - // If the current compressed byte was more than 7 bits, - // set a quick-link item with pointer to tree item - if(BitCount > 7) - { - QuickLinks[ItemLinkIndex].ValidValue = MinValidValue; - QuickLinks[ItemLinkIndex].ValidBits = BitCount; - QuickLinks[ItemLinkIndex].pItem = pItemLink; - } - else - { - // Limit the quick-decompress item to lower amount of bits - // Coverity fix 84457: (x >> 32) has undefined behavior - ItemLinkIndex = (BitCount != 0) ? ItemLinkIndex & (0xFFFFFFFF >> (32 - BitCount)) : 0; - while(ItemLinkIndex < LINK_ITEM_COUNT) - { - // Fill the quick-decompress item - QuickLinks[ItemLinkIndex].ValidValue = MinValidValue; - QuickLinks[ItemLinkIndex].ValidBits = BitCount; - QuickLinks[ItemLinkIndex].DecompressedValue = pItem->DecompressedValue; - - // Increment the index - ItemLinkIndex += (1 << BitCount); - } - } - } - - // Return the decompressed value from the found item - return pItem->DecompressedValue; -} - -unsigned int THuffmannTree::Compress(TOutputStream * os, void * pvInBuffer, int cbInBuffer, int CompressionType) -{ - unsigned char * pbInBufferEnd = (unsigned char *)pvInBuffer + cbInBuffer; - unsigned char * pbInBuffer = (unsigned char *)pvInBuffer; - unsigned char * pbOutBuff = os->pbOutBuffer; - unsigned char InputByte; - - if(!BuildTree(CompressionType)) - return 0; - bIsCmp0 = (CompressionType == 0); - - // Store the compression type into output buffer - os->PutBits(CompressionType, 8); - - // Process the entire input buffer - while(pbInBuffer < pbInBufferEnd) - { - // Get the (next) byte from the input buffer - InputByte = *pbInBuffer++; - - // Do we have an item for such input value? - if(ItemsByByte[InputByte] == NULL) - { - // Encode the relationship - EncodeOneByte(os, ItemsByByte[0x101]); - - // Store the loaded byte into output stream - os->PutBits(InputByte, 8); - - InsertNewBranchAndRebalance(pLast->DecompressedValue, InputByte); - - if(bIsCmp0) - { - IncWeightsAndRebalance(ItemsByByte[InputByte]); - continue; - } - - IncWeightsAndRebalance(ItemsByByte[InputByte]); - } - else - { - EncodeOneByte(os, ItemsByByte[InputByte]); - } - - if(bIsCmp0) - { - IncWeightsAndRebalance(ItemsByByte[InputByte]); - } - } - - // Put the termination mark to the compressed stream - EncodeOneByte(os, ItemsByByte[0x100]); - - // Flush the remaining bits - os->Flush(); - return (unsigned int)(os->pbOutBuffer - pbOutBuff); -} - -// Decompression using Huffman tree (1500E450) -unsigned int THuffmannTree::Decompress(void * pvOutBuffer, unsigned int cbOutLength, TInputStream * is) -{ - unsigned char * pbOutBufferEnd = (unsigned char *)pvOutBuffer + cbOutLength; - unsigned char * pbOutBuffer = (unsigned char *)pvOutBuffer; - unsigned int DecompressedValue = 0; - unsigned int CompressionType = 0; - - // Test the output length. Must not be NULL. - if(cbOutLength == 0) - return 0; - - // Get the compression type from the input stream - CompressionType = is->Get8Bits(); - bIsCmp0 = (CompressionType == 0) ? 1 : 0; - - // Build the Huffman tree - if(!BuildTree(CompressionType)) - return 0; - - // Process the entire input buffer until end of the stream - while((DecompressedValue = DecodeOneByte(is)) != 0x100) - { - // Did an error occur? - if(DecompressedValue == 0x1FF) // An error occurred - return 0; - - // Huffman tree needs to be modified - if(DecompressedValue == 0x101) - { - // The decompressed byte is stored in the next 8 bits - DecompressedValue = is->Get8Bits(); - - InsertNewBranchAndRebalance(pLast->DecompressedValue, DecompressedValue); - - if(bIsCmp0 == 0) - IncWeightsAndRebalance(ItemsByByte[DecompressedValue]); - } - - // A byte successfully decoded - store it in the output stream - *pbOutBuffer++ = (unsigned char)DecompressedValue; - if(pbOutBuffer >= pbOutBufferEnd) - break; - - if(bIsCmp0) - { - IncWeightsAndRebalance(ItemsByByte[DecompressedValue]); - } - } - - return (unsigned int)(pbOutBuffer - (unsigned char *)pvOutBuffer); -} - diff --git a/libs/storm-sys/StormLib/src/huffman/huff.h b/libs/storm-sys/StormLib/src/huffman/huff.h deleted file mode 100644 index 89993fd..0000000 --- a/libs/storm-sys/StormLib/src/huffman/huff.h +++ /dev/null @@ -1,143 +0,0 @@ -/*****************************************************************************/ -/* huffman.h Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Description : */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* xx.xx.xx 1.00 Lad The first version of huffman.h */ -/* 03.05.03 2.00 Lad Added compression */ -/* 08.12.03 2.01 Dan High-memory handling (> 0x80000000) */ -/*****************************************************************************/ - -#ifndef __HUFFMAN_H__ -#define __HUFFMAN_H__ - -//----------------------------------------------------------------------------- -// Defines - -#define HUFF_ITEM_COUNT 0x203 // Number of items in the item pool -#define LINK_ITEM_COUNT 0x80 // Maximum number of quick-link items - -//----------------------------------------------------------------------------- -// Structures and classes - -// Input stream for Huffmann decompression -class TInputStream -{ - public: - - TInputStream(void * pvInBuffer, size_t cbInBuffer); - unsigned int Get1Bit(); - unsigned int Peek7Bits(); - unsigned int Get8Bits(); - void SkipBits(unsigned int BitCount); - - unsigned char * pbInBufferEnd; // End position in the the input buffer - unsigned char * pbInBuffer; // Current position in the the input buffer - unsigned int BitBuffer; // Input bit buffer - unsigned int BitCount; // Number of bits remaining in 'dwBitBuff' -}; - - -// Output stream for Huffmann compression -class TOutputStream -{ - public: - - TOutputStream(void * pvOutBuffer, size_t cbOutLength); - void PutBits(unsigned int dwValue, unsigned int nBitCount); - void Flush(); - - unsigned char * pbOutBufferEnd; // End position in the output buffer - unsigned char * pbOutBuffer; // Current position in the output buffer - unsigned int BitBuffer; // Bit buffer - unsigned int BitCount; // Number of bits in the bit buffer -}; - -// A virtual tree item that represents the head of the item list -#define LIST_HEAD() ((THTreeItem *)(&pFirst)) - -enum TInsertPoint -{ - InsertAfter = 1, - InsertBefore = 2 -}; - -// Huffmann tree item -struct THTreeItem -{ - THTreeItem() { pPrev = pNext = NULL; DecompressedValue = 0; Weight = 0; pParent = pChildLo = NULL; } -// ~THTreeItem() { RemoveItem(); } - - void RemoveItem(); -// void RemoveEntry(); - - THTreeItem * pNext; // Pointer to lower-weight tree item - THTreeItem * pPrev; // Pointer to higher-weight item - unsigned int DecompressedValue; // 08 - Decompressed byte value (also index in the array) - unsigned int Weight; // 0C - Weight - THTreeItem * pParent; // 10 - Pointer to parent item (NULL if none) - THTreeItem * pChildLo; // 14 - Pointer to the child with lower-weight child ("left child") -}; - - -// Structure used for quick navigating in the huffmann tree. -// Allows skipping up to 7 bits in the compressed stream, thus -// decompressing a bit faster. Sometimes it can even get the decompressed -// byte directly. -struct TQuickLink -{ - unsigned int ValidValue; // If greater than THuffmannTree::MinValidValue, the entry is valid - unsigned int ValidBits; // Number of bits that are valid for this item link - union - { - THTreeItem * pItem; // Pointer to the item within the Huffmann tree - unsigned int DecompressedValue; // Value for direct decompression - }; -}; - - -// Structure for Huffman tree (Size 0x3674 bytes). Because I'm not expert -// for the decompression, I do not know actually if the class is really a Hufmann -// tree. If someone knows the decompression details, please let me know -class THuffmannTree -{ - public: - - THuffmannTree(bool bCompression); - ~THuffmannTree(); - - void LinkTwoItems(THTreeItem * pItem1, THTreeItem * pItem2); - void InsertItem(THTreeItem * item, TInsertPoint InsertPoint, THTreeItem * item2); - - THTreeItem * FindHigherOrEqualItem(THTreeItem * pItem, unsigned int Weight); - THTreeItem * CreateNewItem(unsigned int DecompressedValue, unsigned int Weight, TInsertPoint InsertPoint); - - unsigned int FixupItemPosByWeight(THTreeItem * pItem, unsigned int MaxWeight); - bool BuildTree(unsigned int CompressionType); - - void IncWeightsAndRebalance(THTreeItem * pItem); - void InsertNewBranchAndRebalance(unsigned int Value1, unsigned int Value2); - - void EncodeOneByte(TOutputStream * os, THTreeItem * pItem); - unsigned int DecodeOneByte(TInputStream * is); - - unsigned int Compress(TOutputStream * os, void * pvInBuffer, int cbInBuffer, int nCmpType); - unsigned int Decompress(void * pvOutBuffer, unsigned int cbOutLength, TInputStream * is); - - THTreeItem ItemBuffer[HUFF_ITEM_COUNT]; // Buffer for tree items. No memory allocation is needed - unsigned int ItemsUsed; // Number of tree items used from ItemBuffer - - // Head of the linear item list - THTreeItem * pFirst; // Pointer to the highest weight item - THTreeItem * pLast; // Pointer to the lowest weight item - - THTreeItem * ItemsByByte[0x102]; // Array of item pointers, one for each possible byte value - TQuickLink QuickLinks[LINK_ITEM_COUNT]; // Array of quick-link items - - unsigned int MinValidValue; // A minimum value of TQDecompress::ValidValue to be considered valid - unsigned int bIsCmp0; // 1 if compression type 0 -}; - -#endif // __HUFFMAN_H__ diff --git a/libs/storm-sys/StormLib/src/jenkins/lookup.h b/libs/storm-sys/StormLib/src/jenkins/lookup.h deleted file mode 100644 index 54ccc97..0000000 --- a/libs/storm-sys/StormLib/src/jenkins/lookup.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef __LOOKUP3_H__ -#define __LOOKUP3_H__ - -#ifdef WIN32 -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; -#else -#include /* defines uint32_t etc */ -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -uint32_t hashlittle(const void *key, size_t length, uint32_t initval); -void hashlittle2(const void *key, size_t length, uint32_t *pc, uint32_t *pb); - -#ifdef __cplusplus -} -#endif - -#endif // __LOOKUP3_H__ diff --git a/libs/storm-sys/StormLib/src/jenkins/lookup3.c b/libs/storm-sys/StormLib/src/jenkins/lookup3.c deleted file mode 100644 index 6af56b4..0000000 --- a/libs/storm-sys/StormLib/src/jenkins/lookup3.c +++ /dev/null @@ -1,1003 +0,0 @@ -/* -------------------------------------------------------------------------------- -lookup3.c, by Bob Jenkins, May 2006, Public Domain. - -These are functions for producing 32-bit hashes for hash table lookup. -hashword(), hashlittle(), hashlittle2(), hashbig(), mix(), and final() -are externally useful functions. Routines to test the hash are included -if SELF_TEST is defined. You can use this free for any purpose. It's in -the public domain. It has no warranty. - -You probably want to use hashlittle(). hashlittle() and hashbig() -hash byte arrays. hashlittle() is is faster than hashbig() on -little-endian machines. Intel and AMD are little-endian machines. -On second thought, you probably want hashlittle2(), which is identical to -hashlittle() except it returns two 32-bit hashes for the price of one. -You could implement hashbig2() if you wanted but I haven't bothered here. - -If you want to find a hash of, say, exactly 7 integers, do - a = i1; b = i2; c = i3; - mix(a,b,c); - a += i4; b += i5; c += i6; - mix(a,b,c); - a += i7; - final(a,b,c); -then use c as the hash value. If you have a variable length array of -4-byte integers to hash, use hashword(). If you have a byte array (like -a character string), use hashlittle(). If you have several byte arrays, or -a mix of things, see the comments above hashlittle(). - -Why is this so big? I read 12 bytes at a time into 3 4-byte integers, -then mix those integers. This is fast (you can do a lot more thorough -mixing with 12*3 instructions on 3 integers than you can with 3 instructions -on 1 byte), but shoehorning those bytes into integers efficiently is messy. -------------------------------------------------------------------------------- -*/ -//#define SELF_TEST 1 - -#include /* defines printf for tests */ -#include /* defines time_t for timings in the test */ - -#ifdef linux -#include /* attempt to define endianness */ -#include /* attempt to define endianness */ -#endif - -#include "lookup.h" - -/* - * My best guess at if you are big-endian or little-endian. This may - * need adjustment. - */ -#if (defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && \ - __BYTE_ORDER == __LITTLE_ENDIAN) || \ - (defined(i386) || defined(__i386__) || defined(__i486__) || \ - defined(__i586__) || defined(__i686__) || defined(vax) || defined(MIPSEL)) -# define HASH_LITTLE_ENDIAN 1 -# define HASH_BIG_ENDIAN 0 -#elif (defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && \ - __BYTE_ORDER == __BIG_ENDIAN) || \ - (defined(sparc) || defined(POWERPC) || defined(mc68000) || defined(sel)) -# define HASH_LITTLE_ENDIAN 0 -# define HASH_BIG_ENDIAN 1 -#else -# define HASH_LITTLE_ENDIAN 0 -# define HASH_BIG_ENDIAN 0 -#endif - -#define hashsize(n) ((uint32_t)1<<(n)) -#define hashmask(n) (hashsize(n)-1) -#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k)))) - -/* -------------------------------------------------------------------------------- -mix -- mix 3 32-bit values reversibly. - -This is reversible, so any information in (a,b,c) before mix() is -still in (a,b,c) after mix(). - -If four pairs of (a,b,c) inputs are run through mix(), or through -mix() in reverse, there are at least 32 bits of the output that -are sometimes the same for one pair and different for another pair. -This was tested for: -* pairs that differed by one bit, by two bits, in any combination - of top bits of (a,b,c), or in any combination of bottom bits of - (a,b,c). -* "differ" is defined as +, -, ^, or ~^. For + and -, I transformed - the output delta to a Gray code (a^(a>>1)) so a string of 1's (as - is commonly produced by subtraction) look like a single 1-bit - difference. -* the base values were pseudorandom, all zero but one bit set, or - all zero plus a counter that starts at zero. - -Some k values for my "a-=c; a^=rot(c,k); c+=b;" arrangement that -satisfy this are - 4 6 8 16 19 4 - 9 15 3 18 27 15 - 14 9 3 7 17 3 -Well, "9 15 3 18 27 15" didn't quite get 32 bits diffing -for "differ" defined as + with a one-bit base and a two-bit delta. I -used http://burtleburtle.net/bob/hash/avalanche.html to choose -the operations, constants, and arrangements of the variables. - -This does not achieve avalanche. There are input bits of (a,b,c) -that fail to affect some output bits of (a,b,c), especially of a. The -most thoroughly mixed value is c, but it doesn't really even achieve -avalanche in c. - -This allows some parallelism. Read-after-writes are good at doubling -the number of bits affected, so the goal of mixing pulls in the opposite -direction as the goal of parallelism. I did what I could. Rotates -seem to cost as much as shifts on every machine I could lay my hands -on, and rotates are much kinder to the top and bottom bits, so I used -rotates. -------------------------------------------------------------------------------- -*/ -#define mix(a,b,c) \ -{ \ - a -= c; a ^= rot(c, 4); c += b; \ - b -= a; b ^= rot(a, 6); a += c; \ - c -= b; c ^= rot(b, 8); b += a; \ - a -= c; a ^= rot(c,16); c += b; \ - b -= a; b ^= rot(a,19); a += c; \ - c -= b; c ^= rot(b, 4); b += a; \ -} - -/* -------------------------------------------------------------------------------- -final -- final mixing of 3 32-bit values (a,b,c) into c - -Pairs of (a,b,c) values differing in only a few bits will usually -produce values of c that look totally different. This was tested for -* pairs that differed by one bit, by two bits, in any combination - of top bits of (a,b,c), or in any combination of bottom bits of - (a,b,c). -* "differ" is defined as +, -, ^, or ~^. For + and -, I transformed - the output delta to a Gray code (a^(a>>1)) so a string of 1's (as - is commonly produced by subtraction) look like a single 1-bit - difference. -* the base values were pseudorandom, all zero but one bit set, or - all zero plus a counter that starts at zero. - -These constants passed: - 14 11 25 16 4 14 24 - 12 14 25 16 4 14 24 -and these came close: - 4 8 15 26 3 22 24 - 10 8 15 26 3 22 24 - 11 8 15 26 3 22 24 -------------------------------------------------------------------------------- -*/ -#define final(a,b,c) \ -{ \ - c ^= b; c -= rot(b,14); \ - a ^= c; a -= rot(c,11); \ - b ^= a; b -= rot(a,25); \ - c ^= b; c -= rot(b,16); \ - a ^= c; a -= rot(c,4); \ - b ^= a; b -= rot(a,14); \ - c ^= b; c -= rot(b,24); \ -} - -/* --------------------------------------------------------------------- - This works on all machines. To be useful, it requires - -- that the key be an array of uint32_t's, and - -- that the length be the number of uint32_t's in the key - - The function hashword() is identical to hashlittle() on little-endian - machines, and identical to hashbig() on big-endian machines, - except that the length has to be measured in uint32_ts rather than in - bytes. hashlittle() is more complicated than hashword() only because - hashlittle() has to dance around fitting the key bytes into registers. --------------------------------------------------------------------- -*/ -uint32_t hashword( -const uint32_t *k, /* the key, an array of uint32_t values */ -size_t length, /* the length of the key, in uint32_ts */ -uint32_t initval) /* the previous hash, or an arbitrary value */ -{ - uint32_t a,b,c; - - /* Set up the internal state */ - a = b = c = 0xdeadbeef + (((uint32_t)length)<<2) + initval; - - /*------------------------------------------------- handle most of the key */ - while (length > 3) - { - a += k[0]; - b += k[1]; - c += k[2]; - mix(a,b,c); - length -= 3; - k += 3; - } - - /*------------------------------------------- handle the last 3 uint32_t's */ - switch(length) /* all the case statements fall through */ - { - case 3 : c+=k[2]; - case 2 : b+=k[1]; - case 1 : a+=k[0]; - final(a,b,c); - case 0: /* case 0: nothing left to add */ - break; - } - /*------------------------------------------------------ report the result */ - return c; -} - - -/* --------------------------------------------------------------------- -hashword2() -- same as hashword(), but take two seeds and return two -32-bit values. pc and pb must both be nonnull, and *pc and *pb must -both be initialized with seeds. If you pass in (*pb)==0, the output -(*pc) will be the same as the return value from hashword(). --------------------------------------------------------------------- -*/ -void hashword2 ( -const uint32_t *k, /* the key, an array of uint32_t values */ -size_t length, /* the length of the key, in uint32_ts */ -uint32_t *pc, /* IN: seed OUT: primary hash value */ -uint32_t *pb) /* IN: more seed OUT: secondary hash value */ -{ - uint32_t a,b,c; - - /* Set up the internal state */ - a = b = c = 0xdeadbeef + ((uint32_t)(length<<2)) + *pc; - c += *pb; - - /*------------------------------------------------- handle most of the key */ - while (length > 3) - { - a += k[0]; - b += k[1]; - c += k[2]; - mix(a,b,c); - length -= 3; - k += 3; - } - - /*------------------------------------------- handle the last 3 uint32_t's */ - switch(length) /* all the case statements fall through */ - { - case 3 : c+=k[2]; - case 2 : b+=k[1]; - case 1 : a+=k[0]; - final(a,b,c); - case 0: /* case 0: nothing left to add */ - break; - } - /*------------------------------------------------------ report the result */ - *pc=c; *pb=b; -} - - -/* -------------------------------------------------------------------------------- -hashlittle() -- hash a variable-length key into a 32-bit value - k : the key (the unaligned variable-length array of bytes) - length : the length of the key, counting by bytes - initval : can be any 4-byte value -Returns a 32-bit value. Every bit of the key affects every bit of -the return value. Two keys differing by one or two bits will have -totally different hash values. - -The best hash table sizes are powers of 2. There is no need to do -mod a prime (mod is sooo slow!). If you need less than 32 bits, -use a bitmask. For example, if you need only 10 bits, do - h = (h & hashmask(10)); -In which case, the hash table should have hashsize(10) elements. - -If you are hashing n strings (uint8_t **)k, do it like this: - for (i=0, h=0; i 12) - { - a += k[0]; - b += k[1]; - c += k[2]; - mix(a,b,c); - length -= 12; - k += 3; - } - - /*----------------------------- handle the last (probably partial) block */ - /* - * "k[2]&0xffffff" actually reads beyond the end of the string, but - * then masks off the part it's not allowed to read. Because the - * string is aligned, the masked-off tail is in the same word as the - * rest of the string. Every machine with memory protection I've seen - * does it on word boundaries, so is OK with this. But VALGRIND will - * still catch it and complain. The masking trick does make the hash - * noticably faster for short strings (like English words). - */ -#ifndef VALGRIND - - switch(length) - { - case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; - case 11: c+=k[2]&0xffffff; b+=k[1]; a+=k[0]; break; - case 10: c+=k[2]&0xffff; b+=k[1]; a+=k[0]; break; - case 9 : c+=k[2]&0xff; b+=k[1]; a+=k[0]; break; - case 8 : b+=k[1]; a+=k[0]; break; - case 7 : b+=k[1]&0xffffff; a+=k[0]; break; - case 6 : b+=k[1]&0xffff; a+=k[0]; break; - case 5 : b+=k[1]&0xff; a+=k[0]; break; - case 4 : a+=k[0]; break; - case 3 : a+=k[0]&0xffffff; break; - case 2 : a+=k[0]&0xffff; break; - case 1 : a+=k[0]&0xff; break; - case 0 : return c; /* zero length strings require no mixing */ - } - -#else /* make valgrind happy */ - - k8 = (const uint8_t *)k; - switch(length) - { - case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; - case 11: c+=((uint32_t)k8[10])<<16; /* fall through */ - case 10: c+=((uint32_t)k8[9])<<8; /* fall through */ - case 9 : c+=k8[8]; /* fall through */ - case 8 : b+=k[1]; a+=k[0]; break; - case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */ - case 6 : b+=((uint32_t)k8[5])<<8; /* fall through */ - case 5 : b+=k8[4]; /* fall through */ - case 4 : a+=k[0]; break; - case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */ - case 2 : a+=((uint32_t)k8[1])<<8; /* fall through */ - case 1 : a+=k8[0]; break; - case 0 : return c; - } - -#endif /* !valgrind */ - - } else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0)) { - const uint16_t *k = (const uint16_t *)key; /* read 16-bit chunks */ - const uint8_t *k8; - - /*--------------- all but last block: aligned reads and different mixing */ - while (length > 12) - { - a += k[0] + (((uint32_t)k[1])<<16); - b += k[2] + (((uint32_t)k[3])<<16); - c += k[4] + (((uint32_t)k[5])<<16); - mix(a,b,c); - length -= 12; - k += 6; - } - - /*----------------------------- handle the last (probably partial) block */ - k8 = (const uint8_t *)k; - switch(length) - { - case 12: c+=k[4]+(((uint32_t)k[5])<<16); - b+=k[2]+(((uint32_t)k[3])<<16); - a+=k[0]+(((uint32_t)k[1])<<16); - break; - case 11: c+=((uint32_t)k8[10])<<16; /* fall through */ - case 10: c+=k[4]; - b+=k[2]+(((uint32_t)k[3])<<16); - a+=k[0]+(((uint32_t)k[1])<<16); - break; - case 9 : c+=k8[8]; /* fall through */ - case 8 : b+=k[2]+(((uint32_t)k[3])<<16); - a+=k[0]+(((uint32_t)k[1])<<16); - break; - case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */ - case 6 : b+=k[2]; - a+=k[0]+(((uint32_t)k[1])<<16); - break; - case 5 : b+=k8[4]; /* fall through */ - case 4 : a+=k[0]+(((uint32_t)k[1])<<16); - break; - case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */ - case 2 : a+=k[0]; - break; - case 1 : a+=k8[0]; - break; - case 0 : return c; /* zero length requires no mixing */ - } - - } else { /* need to read the key one byte at a time */ - const uint8_t *k = (const uint8_t *)key; - - /*--------------- all but the last block: affect some 32 bits of (a,b,c) */ - while (length > 12) - { - a += k[0]; - a += ((uint32_t)k[1])<<8; - a += ((uint32_t)k[2])<<16; - a += ((uint32_t)k[3])<<24; - b += k[4]; - b += ((uint32_t)k[5])<<8; - b += ((uint32_t)k[6])<<16; - b += ((uint32_t)k[7])<<24; - c += k[8]; - c += ((uint32_t)k[9])<<8; - c += ((uint32_t)k[10])<<16; - c += ((uint32_t)k[11])<<24; - mix(a,b,c); - length -= 12; - k += 12; - } - - /*-------------------------------- last block: affect all 32 bits of (c) */ - switch(length) /* all the case statements fall through */ - { - case 12: c+=((uint32_t)k[11])<<24; - case 11: c+=((uint32_t)k[10])<<16; - case 10: c+=((uint32_t)k[9])<<8; - case 9 : c+=k[8]; - case 8 : b+=((uint32_t)k[7])<<24; - case 7 : b+=((uint32_t)k[6])<<16; - case 6 : b+=((uint32_t)k[5])<<8; - case 5 : b+=k[4]; - case 4 : a+=((uint32_t)k[3])<<24; - case 3 : a+=((uint32_t)k[2])<<16; - case 2 : a+=((uint32_t)k[1])<<8; - case 1 : a+=k[0]; - break; - case 0 : return c; - } - } - - final(a,b,c); - return c; -} - - -/* - * hashlittle2: return 2 32-bit hash values - * - * This is identical to hashlittle(), except it returns two 32-bit hash - * values instead of just one. This is good enough for hash table - * lookup with 2^^64 buckets, or if you want a second hash if you're not - * happy with the first, or if you want a probably-unique 64-bit ID for - * the key. *pc is better mixed than *pb, so use *pc first. If you want - * a 64-bit value do something like "*pc + (((uint64_t)*pb)<<32)". - */ -void hashlittle2( - const void *key, /* the key to hash */ - size_t length, /* length of the key */ - uint32_t *pc, /* IN: primary initval, OUT: primary hash */ - uint32_t *pb) /* IN: secondary initval, OUT: secondary hash */ -{ - uint32_t a,b,c; /* internal state */ - union { const void *ptr; size_t i; } u; /* needed for Mac Powerbook G4 */ - - /* Set up the internal state */ - a = b = c = 0xdeadbeef + ((uint32_t)length) + *pc; - c += *pb; - - u.ptr = key; - if (HASH_LITTLE_ENDIAN && ((u.i & 0x3) == 0)) { - const uint32_t *k = (const uint32_t *)key; /* read 32-bit chunks */ - const uint8_t *k8; - - /*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */ - while (length > 12) - { - a += k[0]; - b += k[1]; - c += k[2]; - mix(a,b,c); - length -= 12; - k += 3; - } - - /*----------------------------- handle the last (probably partial) block */ - /* - * "k[2]&0xffffff" actually reads beyond the end of the string, but - * then masks off the part it's not allowed to read. Because the - * string is aligned, the masked-off tail is in the same word as the - * rest of the string. Every machine with memory protection I've seen - * does it on word boundaries, so is OK with this. But VALGRIND will - * still catch it and complain. The masking trick does make the hash - * noticably faster for short strings (like English words). - */ -#ifndef VALGRIND - - switch(length) - { - case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; - case 11: c+=k[2]&0xffffff; b+=k[1]; a+=k[0]; break; - case 10: c+=k[2]&0xffff; b+=k[1]; a+=k[0]; break; - case 9 : c+=k[2]&0xff; b+=k[1]; a+=k[0]; break; - case 8 : b+=k[1]; a+=k[0]; break; - case 7 : b+=k[1]&0xffffff; a+=k[0]; break; - case 6 : b+=k[1]&0xffff; a+=k[0]; break; - case 5 : b+=k[1]&0xff; a+=k[0]; break; - case 4 : a+=k[0]; break; - case 3 : a+=k[0]&0xffffff; break; - case 2 : a+=k[0]&0xffff; break; - case 1 : a+=k[0]&0xff; break; - case 0 : *pc=c; *pb=b; return; /* zero length strings require no mixing */ - } - -#else /* make valgrind happy */ - - k8 = (const uint8_t *)k; - switch(length) - { - case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; - case 11: c+=((uint32_t)k8[10])<<16; /* fall through */ - case 10: c+=((uint32_t)k8[9])<<8; /* fall through */ - case 9 : c+=k8[8]; /* fall through */ - case 8 : b+=k[1]; a+=k[0]; break; - case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */ - case 6 : b+=((uint32_t)k8[5])<<8; /* fall through */ - case 5 : b+=k8[4]; /* fall through */ - case 4 : a+=k[0]; break; - case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */ - case 2 : a+=((uint32_t)k8[1])<<8; /* fall through */ - case 1 : a+=k8[0]; break; - case 0 : *pc=c; *pb=b; return; /* zero length strings require no mixing */ - } - -#endif /* !valgrind */ - - } else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0)) { - const uint16_t *k = (const uint16_t *)key; /* read 16-bit chunks */ - const uint8_t *k8; - - /*--------------- all but last block: aligned reads and different mixing */ - while (length > 12) - { - a += k[0] + (((uint32_t)k[1])<<16); - b += k[2] + (((uint32_t)k[3])<<16); - c += k[4] + (((uint32_t)k[5])<<16); - mix(a,b,c); - length -= 12; - k += 6; - } - - /*----------------------------- handle the last (probably partial) block */ - k8 = (const uint8_t *)k; - switch(length) - { - case 12: c+=k[4]+(((uint32_t)k[5])<<16); - b+=k[2]+(((uint32_t)k[3])<<16); - a+=k[0]+(((uint32_t)k[1])<<16); - break; - case 11: c+=((uint32_t)k8[10])<<16; /* fall through */ - case 10: c+=k[4]; - b+=k[2]+(((uint32_t)k[3])<<16); - a+=k[0]+(((uint32_t)k[1])<<16); - break; - case 9 : c+=k8[8]; /* fall through */ - case 8 : b+=k[2]+(((uint32_t)k[3])<<16); - a+=k[0]+(((uint32_t)k[1])<<16); - break; - case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */ - case 6 : b+=k[2]; - a+=k[0]+(((uint32_t)k[1])<<16); - break; - case 5 : b+=k8[4]; /* fall through */ - case 4 : a+=k[0]+(((uint32_t)k[1])<<16); - break; - case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */ - case 2 : a+=k[0]; - break; - case 1 : a+=k8[0]; - break; - case 0 : *pc=c; *pb=b; return; /* zero length strings require no mixing */ - } - - } else { /* need to read the key one byte at a time */ - const uint8_t *k = (const uint8_t *)key; - - /*--------------- all but the last block: affect some 32 bits of (a,b,c) */ - while (length > 12) - { - a += k[0]; - a += ((uint32_t)k[1])<<8; - a += ((uint32_t)k[2])<<16; - a += ((uint32_t)k[3])<<24; - b += k[4]; - b += ((uint32_t)k[5])<<8; - b += ((uint32_t)k[6])<<16; - b += ((uint32_t)k[7])<<24; - c += k[8]; - c += ((uint32_t)k[9])<<8; - c += ((uint32_t)k[10])<<16; - c += ((uint32_t)k[11])<<24; - mix(a,b,c); - length -= 12; - k += 12; - } - - /*-------------------------------- last block: affect all 32 bits of (c) */ - switch(length) /* all the case statements fall through */ - { - case 12: c+=((uint32_t)k[11])<<24; - case 11: c+=((uint32_t)k[10])<<16; - case 10: c+=((uint32_t)k[9])<<8; - case 9 : c+=k[8]; - case 8 : b+=((uint32_t)k[7])<<24; - case 7 : b+=((uint32_t)k[6])<<16; - case 6 : b+=((uint32_t)k[5])<<8; - case 5 : b+=k[4]; - case 4 : a+=((uint32_t)k[3])<<24; - case 3 : a+=((uint32_t)k[2])<<16; - case 2 : a+=((uint32_t)k[1])<<8; - case 1 : a+=k[0]; - break; - case 0 : *pc=c; *pb=b; return; /* zero length strings require no mixing */ - } - } - - final(a,b,c); - *pc=c; *pb=b; -} - - - -/* - * hashbig(): - * This is the same as hashword() on big-endian machines. It is different - * from hashlittle() on all machines. hashbig() takes advantage of - * big-endian byte ordering. - */ -uint32_t hashbig( const void *key, size_t length, uint32_t initval) -{ - uint32_t a,b,c; - union { const void *ptr; size_t i; } u; /* to cast key to (size_t) happily */ - - /* Set up the internal state */ - a = b = c = 0xdeadbeef + ((uint32_t)length) + initval; - - u.ptr = key; - if (HASH_BIG_ENDIAN && ((u.i & 0x3) == 0)) { - const uint32_t *k = (const uint32_t *)key; /* read 32-bit chunks */ - const uint8_t *k8; - - /*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */ - while (length > 12) - { - a += k[0]; - b += k[1]; - c += k[2]; - mix(a,b,c); - length -= 12; - k += 3; - } - - /*----------------------------- handle the last (probably partial) block */ - /* - * "k[2]<<8" actually reads beyond the end of the string, but - * then shifts out the part it's not allowed to read. Because the - * string is aligned, the illegal read is in the same word as the - * rest of the string. Every machine with memory protection I've seen - * does it on word boundaries, so is OK with this. But VALGRIND will - * still catch it and complain. The masking trick does make the hash - * noticably faster for short strings (like English words). - */ -#ifndef VALGRIND - - switch(length) - { - case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; - case 11: c+=k[2]&0xffffff00; b+=k[1]; a+=k[0]; break; - case 10: c+=k[2]&0xffff0000; b+=k[1]; a+=k[0]; break; - case 9 : c+=k[2]&0xff000000; b+=k[1]; a+=k[0]; break; - case 8 : b+=k[1]; a+=k[0]; break; - case 7 : b+=k[1]&0xffffff00; a+=k[0]; break; - case 6 : b+=k[1]&0xffff0000; a+=k[0]; break; - case 5 : b+=k[1]&0xff000000; a+=k[0]; break; - case 4 : a+=k[0]; break; - case 3 : a+=k[0]&0xffffff00; break; - case 2 : a+=k[0]&0xffff0000; break; - case 1 : a+=k[0]&0xff000000; break; - case 0 : return c; /* zero length strings require no mixing */ - } - -#else /* make valgrind happy */ - - k8 = (const uint8_t *)k; - switch(length) /* all the case statements fall through */ - { - case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; - case 11: c+=((uint32_t)k8[10])<<8; /* fall through */ - case 10: c+=((uint32_t)k8[9])<<16; /* fall through */ - case 9 : c+=((uint32_t)k8[8])<<24; /* fall through */ - case 8 : b+=k[1]; a+=k[0]; break; - case 7 : b+=((uint32_t)k8[6])<<8; /* fall through */ - case 6 : b+=((uint32_t)k8[5])<<16; /* fall through */ - case 5 : b+=((uint32_t)k8[4])<<24; /* fall through */ - case 4 : a+=k[0]; break; - case 3 : a+=((uint32_t)k8[2])<<8; /* fall through */ - case 2 : a+=((uint32_t)k8[1])<<16; /* fall through */ - case 1 : a+=((uint32_t)k8[0])<<24; break; - case 0 : return c; - } - -#endif /* !VALGRIND */ - - } else { /* need to read the key one byte at a time */ - const uint8_t *k = (const uint8_t *)key; - - /*--------------- all but the last block: affect some 32 bits of (a,b,c) */ - while (length > 12) - { - a += ((uint32_t)k[0])<<24; - a += ((uint32_t)k[1])<<16; - a += ((uint32_t)k[2])<<8; - a += ((uint32_t)k[3]); - b += ((uint32_t)k[4])<<24; - b += ((uint32_t)k[5])<<16; - b += ((uint32_t)k[6])<<8; - b += ((uint32_t)k[7]); - c += ((uint32_t)k[8])<<24; - c += ((uint32_t)k[9])<<16; - c += ((uint32_t)k[10])<<8; - c += ((uint32_t)k[11]); - mix(a,b,c); - length -= 12; - k += 12; - } - - /*-------------------------------- last block: affect all 32 bits of (c) */ - switch(length) /* all the case statements fall through */ - { - case 12: c+=k[11]; - case 11: c+=((uint32_t)k[10])<<8; - case 10: c+=((uint32_t)k[9])<<16; - case 9 : c+=((uint32_t)k[8])<<24; - case 8 : b+=k[7]; - case 7 : b+=((uint32_t)k[6])<<8; - case 6 : b+=((uint32_t)k[5])<<16; - case 5 : b+=((uint32_t)k[4])<<24; - case 4 : a+=k[3]; - case 3 : a+=((uint32_t)k[2])<<8; - case 2 : a+=((uint32_t)k[1])<<16; - case 1 : a+=((uint32_t)k[0])<<24; - break; - case 0 : return c; - } - } - - final(a,b,c); - return c; -} - - -#ifdef SELF_TEST - -/* used for timings */ -void driver1() -{ - uint8_t buf[256]; - uint32_t i; - uint32_t h=0; - time_t a,z; - - time(&a); - for (i=0; i<256; ++i) buf[i] = 'x'; - for (i=0; i<1; ++i) - { - h = hashlittle(&buf[0],1,h); - } - time(&z); - if (z-a > 0) printf("time %d %.8x\n", z-a, h); -} - -/* check that every input bit changes every output bit half the time */ -#define HASHSTATE 1 -#define HASHLEN 1 -#define MAXPAIR 60 -#define MAXLEN 70 -void driver2() -{ - uint8_t qa[MAXLEN+1], qb[MAXLEN+2], *a = &qa[0], *b = &qb[1]; - uint32_t c[HASHSTATE], d[HASHSTATE], i=0, j=0, k, l, m=0, z; - uint32_t e[HASHSTATE],f[HASHSTATE],g[HASHSTATE],h[HASHSTATE]; - uint32_t x[HASHSTATE],y[HASHSTATE]; - uint32_t hlen; - - printf("No more than %d trials should ever be needed \n",MAXPAIR/2); - for (hlen=0; hlen < MAXLEN; ++hlen) - { - z=0; - for (i=0; i>(8-j)); - c[0] = hashlittle(a, hlen, m); - b[i] ^= ((k+1)<>(8-j)); - d[0] = hashlittle(b, hlen, m); - /* check every bit is 1, 0, set, and not set at least once */ - for (l=0; lz) z=k; - if (k==MAXPAIR) - { - printf("Some bit didn't change: "); - printf("%.8x %.8x %.8x %.8x %.8x %.8x ", - e[0],f[0],g[0],h[0],x[0],y[0]); - printf("i %d j %d m %d len %d\n", i, j, m, hlen); - } - if (z==MAXPAIR) goto done; - } - } - } - done: - if (z < MAXPAIR) - { - printf("Mix success %2d bytes %2d initvals ",i,m); - printf("required %d trials\n", z/2); - } - } - printf("\n"); -} - -/* Check for reading beyond the end of the buffer and alignment problems */ -void driver3() -{ - uint8_t buf[MAXLEN+20], *b; - uint32_t len; - uint8_t q[] = "This is the time for all good men to come to the aid of their country..."; - uint32_t h; - uint8_t qq[] = "xThis is the time for all good men to come to the aid of their country..."; - uint32_t i; - uint8_t qqq[] = "xxThis is the time for all good men to come to the aid of their country..."; - uint32_t j; - uint8_t qqqq[] = "xxxThis is the time for all good men to come to the aid of their country..."; - uint32_t ref,x,y; - uint8_t *p; - - printf("Endianness. These lines should all be the same (for values filled in):\n"); - printf("%.8x %.8x %.8x\n", - hashword((const uint32_t *)q, (sizeof(q)-1)/4, 13), - hashword((const uint32_t *)q, (sizeof(q)-5)/4, 13), - hashword((const uint32_t *)q, (sizeof(q)-9)/4, 13)); - p = q; - printf("%.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x\n", - hashlittle(p, sizeof(q)-1, 13), hashlittle(p, sizeof(q)-2, 13), - hashlittle(p, sizeof(q)-3, 13), hashlittle(p, sizeof(q)-4, 13), - hashlittle(p, sizeof(q)-5, 13), hashlittle(p, sizeof(q)-6, 13), - hashlittle(p, sizeof(q)-7, 13), hashlittle(p, sizeof(q)-8, 13), - hashlittle(p, sizeof(q)-9, 13), hashlittle(p, sizeof(q)-10, 13), - hashlittle(p, sizeof(q)-11, 13), hashlittle(p, sizeof(q)-12, 13)); - p = &qq[1]; - printf("%.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x\n", - hashlittle(p, sizeof(q)-1, 13), hashlittle(p, sizeof(q)-2, 13), - hashlittle(p, sizeof(q)-3, 13), hashlittle(p, sizeof(q)-4, 13), - hashlittle(p, sizeof(q)-5, 13), hashlittle(p, sizeof(q)-6, 13), - hashlittle(p, sizeof(q)-7, 13), hashlittle(p, sizeof(q)-8, 13), - hashlittle(p, sizeof(q)-9, 13), hashlittle(p, sizeof(q)-10, 13), - hashlittle(p, sizeof(q)-11, 13), hashlittle(p, sizeof(q)-12, 13)); - p = &qqq[2]; - printf("%.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x\n", - hashlittle(p, sizeof(q)-1, 13), hashlittle(p, sizeof(q)-2, 13), - hashlittle(p, sizeof(q)-3, 13), hashlittle(p, sizeof(q)-4, 13), - hashlittle(p, sizeof(q)-5, 13), hashlittle(p, sizeof(q)-6, 13), - hashlittle(p, sizeof(q)-7, 13), hashlittle(p, sizeof(q)-8, 13), - hashlittle(p, sizeof(q)-9, 13), hashlittle(p, sizeof(q)-10, 13), - hashlittle(p, sizeof(q)-11, 13), hashlittle(p, sizeof(q)-12, 13)); - p = &qqqq[3]; - printf("%.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x\n", - hashlittle(p, sizeof(q)-1, 13), hashlittle(p, sizeof(q)-2, 13), - hashlittle(p, sizeof(q)-3, 13), hashlittle(p, sizeof(q)-4, 13), - hashlittle(p, sizeof(q)-5, 13), hashlittle(p, sizeof(q)-6, 13), - hashlittle(p, sizeof(q)-7, 13), hashlittle(p, sizeof(q)-8, 13), - hashlittle(p, sizeof(q)-9, 13), hashlittle(p, sizeof(q)-10, 13), - hashlittle(p, sizeof(q)-11, 13), hashlittle(p, sizeof(q)-12, 13)); - printf("\n"); - - /* check that hashlittle2 and hashlittle produce the same results */ - i=47; j=0; - hashlittle2(q, sizeof(q), &i, &j); - if (hashlittle(q, sizeof(q), 47) != i) - printf("hashlittle2 and hashlittle mismatch\n"); - - /* check that hashword2 and hashword produce the same results */ - len = 0xdeadbeef; - i=47, j=0; - hashword2(&len, 1, &i, &j); - if (hashword(&len, 1, 47) != i) - printf("hashword2 and hashword mismatch %x %x\n", - i, hashword(&len, 1, 47)); - - /* check hashlittle doesn't read before or after the ends of the string */ - for (h=0, b=buf+1; h<8; ++h, ++b) - { - for (i=0; imd5.state[0]; - b = md->md5.state[1]; - c = md->md5.state[2]; - d = md->md5.state[3]; - -#ifdef LTC_SMALL_CODE - for (i = 0; i < 16; ++i) { - FF(a,b,c,d,W[Worder[i]],Rorder[i],Korder[i]); - t = d; d = c; c = b; b = a; a = t; - } - - for (; i < 32; ++i) { - GG(a,b,c,d,W[Worder[i]],Rorder[i],Korder[i]); - t = d; d = c; c = b; b = a; a = t; - } - - for (; i < 48; ++i) { - HH(a,b,c,d,W[Worder[i]],Rorder[i],Korder[i]); - t = d; d = c; c = b; b = a; a = t; - } - - for (; i < 64; ++i) { - II(a,b,c,d,W[Worder[i]],Rorder[i],Korder[i]); - t = d; d = c; c = b; b = a; a = t; - } - -#else - FF(a,b,c,d,W[0],7,0xd76aa478UL) - FF(d,a,b,c,W[1],12,0xe8c7b756UL) - FF(c,d,a,b,W[2],17,0x242070dbUL) - FF(b,c,d,a,W[3],22,0xc1bdceeeUL) - FF(a,b,c,d,W[4],7,0xf57c0fafUL) - FF(d,a,b,c,W[5],12,0x4787c62aUL) - FF(c,d,a,b,W[6],17,0xa8304613UL) - FF(b,c,d,a,W[7],22,0xfd469501UL) - FF(a,b,c,d,W[8],7,0x698098d8UL) - FF(d,a,b,c,W[9],12,0x8b44f7afUL) - FF(c,d,a,b,W[10],17,0xffff5bb1UL) - FF(b,c,d,a,W[11],22,0x895cd7beUL) - FF(a,b,c,d,W[12],7,0x6b901122UL) - FF(d,a,b,c,W[13],12,0xfd987193UL) - FF(c,d,a,b,W[14],17,0xa679438eUL) - FF(b,c,d,a,W[15],22,0x49b40821UL) - GG(a,b,c,d,W[1],5,0xf61e2562UL) - GG(d,a,b,c,W[6],9,0xc040b340UL) - GG(c,d,a,b,W[11],14,0x265e5a51UL) - GG(b,c,d,a,W[0],20,0xe9b6c7aaUL) - GG(a,b,c,d,W[5],5,0xd62f105dUL) - GG(d,a,b,c,W[10],9,0x02441453UL) - GG(c,d,a,b,W[15],14,0xd8a1e681UL) - GG(b,c,d,a,W[4],20,0xe7d3fbc8UL) - GG(a,b,c,d,W[9],5,0x21e1cde6UL) - GG(d,a,b,c,W[14],9,0xc33707d6UL) - GG(c,d,a,b,W[3],14,0xf4d50d87UL) - GG(b,c,d,a,W[8],20,0x455a14edUL) - GG(a,b,c,d,W[13],5,0xa9e3e905UL) - GG(d,a,b,c,W[2],9,0xfcefa3f8UL) - GG(c,d,a,b,W[7],14,0x676f02d9UL) - GG(b,c,d,a,W[12],20,0x8d2a4c8aUL) - HH(a,b,c,d,W[5],4,0xfffa3942UL) - HH(d,a,b,c,W[8],11,0x8771f681UL) - HH(c,d,a,b,W[11],16,0x6d9d6122UL) - HH(b,c,d,a,W[14],23,0xfde5380cUL) - HH(a,b,c,d,W[1],4,0xa4beea44UL) - HH(d,a,b,c,W[4],11,0x4bdecfa9UL) - HH(c,d,a,b,W[7],16,0xf6bb4b60UL) - HH(b,c,d,a,W[10],23,0xbebfbc70UL) - HH(a,b,c,d,W[13],4,0x289b7ec6UL) - HH(d,a,b,c,W[0],11,0xeaa127faUL) - HH(c,d,a,b,W[3],16,0xd4ef3085UL) - HH(b,c,d,a,W[6],23,0x04881d05UL) - HH(a,b,c,d,W[9],4,0xd9d4d039UL) - HH(d,a,b,c,W[12],11,0xe6db99e5UL) - HH(c,d,a,b,W[15],16,0x1fa27cf8UL) - HH(b,c,d,a,W[2],23,0xc4ac5665UL) - II(a,b,c,d,W[0],6,0xf4292244UL) - II(d,a,b,c,W[7],10,0x432aff97UL) - II(c,d,a,b,W[14],15,0xab9423a7UL) - II(b,c,d,a,W[5],21,0xfc93a039UL) - II(a,b,c,d,W[12],6,0x655b59c3UL) - II(d,a,b,c,W[3],10,0x8f0ccc92UL) - II(c,d,a,b,W[10],15,0xffeff47dUL) - II(b,c,d,a,W[1],21,0x85845dd1UL) - II(a,b,c,d,W[8],6,0x6fa87e4fUL) - II(d,a,b,c,W[15],10,0xfe2ce6e0UL) - II(c,d,a,b,W[6],15,0xa3014314UL) - II(b,c,d,a,W[13],21,0x4e0811a1UL) - II(a,b,c,d,W[4],6,0xf7537e82UL) - II(d,a,b,c,W[11],10,0xbd3af235UL) - II(c,d,a,b,W[2],15,0x2ad7d2bbUL) - II(b,c,d,a,W[9],21,0xeb86d391UL) -#endif - - md->md5.state[0] = md->md5.state[0] + a; - md->md5.state[1] = md->md5.state[1] + b; - md->md5.state[2] = md->md5.state[2] + c; - md->md5.state[3] = md->md5.state[3] + d; - - return CRYPT_OK; -} - -#ifdef LTC_CLEAN_STACK -static int md5_compress(hash_state *md, unsigned char *buf) -{ - int err; - err = _md5_compress(md, buf); - burn_stack(sizeof(ulong32) * 21); - return err; -} -#endif - -/** - Initialize the hash state - @param md The hash state you wish to initialize - @return CRYPT_OK if successful -*/ -int md5_init(hash_state * md) -{ - LTC_ARGCHK(md != NULL); - md->md5.state[0] = 0x67452301UL; - md->md5.state[1] = 0xefcdab89UL; - md->md5.state[2] = 0x98badcfeUL; - md->md5.state[3] = 0x10325476UL; - md->md5.curlen = 0; - md->md5.length = 0; - return CRYPT_OK; -} - -/** - Process a block of memory though the hash - @param md The hash state - @param in The data to hash - @param inlen The length of the data (octets) - @return CRYPT_OK if successful -*/ -HASH_PROCESS(md5_process, md5_compress, md5, 64) - -/** - Terminate the hash to get the digest - @param md The hash state - @param out [out] The destination of the hash (16 bytes) - @return CRYPT_OK if successful -*/ -int md5_done(hash_state * md, unsigned char *out) -{ - int i; - - LTC_ARGCHK(md != NULL); - LTC_ARGCHK(out != NULL); - - if (md->md5.curlen >= sizeof(md->md5.buf)) { - return CRYPT_INVALID_ARG; - } - - - /* increase the length of the message */ - md->md5.length += md->md5.curlen * 8; - - /* append the '1' bit */ - md->md5.buf[md->md5.curlen++] = (unsigned char)0x80; - - /* if the length is currently above 56 bytes we append zeros - * then compress. Then we can fall back to padding zeros and length - * encoding like normal. - */ - if (md->md5.curlen > 56) { - while (md->md5.curlen < 64) { - md->md5.buf[md->md5.curlen++] = (unsigned char)0; - } - md5_compress(md, md->md5.buf); - md->md5.curlen = 0; - } - - /* pad upto 56 bytes of zeroes */ - while (md->md5.curlen < 56) { - md->md5.buf[md->md5.curlen++] = (unsigned char)0; - } - - /* store length */ - STORE64L(md->md5.length, md->md5.buf+56); - md5_compress(md, md->md5.buf); - - /* copy output */ - for (i = 0; i < 4; i++) { - STORE32L(md->md5.state[i], out+(4*i)); - } -#ifdef LTC_CLEAN_STACK - zeromem(md, sizeof(hash_state)); -#endif - return CRYPT_OK; -} - -/** - Self-test the hash - @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled -*/ -int md5_test(void) -{ - #ifndef LTC_TEST - return CRYPT_NOP; - #else - static const struct { - char *msg; - unsigned char hash[16]; - } tests[] = { - { "", - { 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04, - 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e } }, - { "a", - {0x0c, 0xc1, 0x75, 0xb9, 0xc0, 0xf1, 0xb6, 0xa8, - 0x31, 0xc3, 0x99, 0xe2, 0x69, 0x77, 0x26, 0x61 } }, - { "abc", - { 0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0, - 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72 } }, - { "message digest", - { 0xf9, 0x6b, 0x69, 0x7d, 0x7c, 0xb7, 0x93, 0x8d, - 0x52, 0x5a, 0x2f, 0x31, 0xaa, 0xf1, 0x61, 0xd0 } }, - { "abcdefghijklmnopqrstuvwxyz", - { 0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00, - 0x7d, 0xfb, 0x49, 0x6c, 0xca, 0x67, 0xe1, 0x3b } }, - { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", - { 0xd1, 0x74, 0xab, 0x98, 0xd2, 0x77, 0xd9, 0xf5, - 0xa5, 0x61, 0x1c, 0x2c, 0x9f, 0x41, 0x9d, 0x9f } }, - { "12345678901234567890123456789012345678901234567890123456789012345678901234567890", - { 0x57, 0xed, 0xf4, 0xa2, 0x2b, 0xe3, 0xc9, 0x55, - 0xac, 0x49, 0xda, 0x2e, 0x21, 0x07, 0xb6, 0x7a } }, - { NULL, { 0 } } - }; - - int i; - unsigned char tmp[16]; - hash_state md; - - for (i = 0; tests[i].msg != NULL; i++) { - md5_init(&md); - md5_process(&md, (unsigned char *)tests[i].msg, (unsigned long)strlen(tests[i].msg)); - md5_done(&md, tmp); - if (XMEMCMP(tmp, tests[i].hash, 16) != 0) { - return CRYPT_FAIL_TESTVECTOR; - } - } - return CRYPT_OK; - #endif -} - -#endif - - - -/* $Source: /cvs/libtom/libtomcrypt/src/hashes/md5.c,v $ */ -/* $Revision: 1.10 $ */ -/* $Date: 2007/05/12 14:25:28 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/hashes/sha1.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/hashes/sha1.c deleted file mode 100644 index 409d095..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/hashes/sha1.c +++ /dev/null @@ -1,288 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../headers/tomcrypt.h" - -/** - @file sha1.c - LTC_SHA1 code by Tom St Denis -*/ - - -#ifdef LTC_SHA1 - -const struct ltc_hash_descriptor sha1_desc = -{ - "sha1", - 2, - 20, - 64, - - /* OID */ - { 1, 3, 14, 3, 2, 26, }, - 6, - - &sha1_init, - &sha1_process, - &sha1_done, - &sha1_test, - NULL -}; - -#define F0(x,y,z) (z ^ (x & (y ^ z))) -#define F1(x,y,z) (x ^ y ^ z) -#define F2(x,y,z) ((x & y) | (z & (x | y))) -#define F3(x,y,z) (x ^ y ^ z) - -#ifdef LTC_CLEAN_STACK -static int _sha1_compress(hash_state *md, unsigned char *buf) -#else -static int sha1_compress(hash_state *md, unsigned char *buf) -#endif -{ - ulong32 a,b,c,d,e,W[80],i; -#ifdef LTC_SMALL_CODE - ulong32 t; -#endif - - /* copy the state into 512-bits into W[0..15] */ - for (i = 0; i < 16; i++) { - LOAD32H(W[i], buf + (4*i)); - } - - /* copy state */ - a = md->sha1.state[0]; - b = md->sha1.state[1]; - c = md->sha1.state[2]; - d = md->sha1.state[3]; - e = md->sha1.state[4]; - - /* expand it */ - for (i = 16; i < 80; i++) { - W[i] = ROL(W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16], 1); - } - - /* compress */ - /* round one */ - #define FF0(a,b,c,d,e,i) e = (ROLc(a, 5) + F0(b,c,d) + e + W[i] + 0x5a827999UL); b = ROLc(b, 30); - #define FF1(a,b,c,d,e,i) e = (ROLc(a, 5) + F1(b,c,d) + e + W[i] + 0x6ed9eba1UL); b = ROLc(b, 30); - #define FF2(a,b,c,d,e,i) e = (ROLc(a, 5) + F2(b,c,d) + e + W[i] + 0x8f1bbcdcUL); b = ROLc(b, 30); - #define FF3(a,b,c,d,e,i) e = (ROLc(a, 5) + F3(b,c,d) + e + W[i] + 0xca62c1d6UL); b = ROLc(b, 30); - -#ifdef LTC_SMALL_CODE - - for (i = 0; i < 20; ) { - FF0(a,b,c,d,e,i++); t = e; e = d; d = c; c = b; b = a; a = t; - } - - for (; i < 40; ) { - FF1(a,b,c,d,e,i++); t = e; e = d; d = c; c = b; b = a; a = t; - } - - for (; i < 60; ) { - FF2(a,b,c,d,e,i++); t = e; e = d; d = c; c = b; b = a; a = t; - } - - for (; i < 80; ) { - FF3(a,b,c,d,e,i++); t = e; e = d; d = c; c = b; b = a; a = t; - } - -#else - - for (i = 0; i < 20; ) { - FF0(a,b,c,d,e,i++); - FF0(e,a,b,c,d,i++); - FF0(d,e,a,b,c,i++); - FF0(c,d,e,a,b,i++); - FF0(b,c,d,e,a,i++); - } - - /* round two */ - for (; i < 40; ) { - FF1(a,b,c,d,e,i++); - FF1(e,a,b,c,d,i++); - FF1(d,e,a,b,c,i++); - FF1(c,d,e,a,b,i++); - FF1(b,c,d,e,a,i++); - } - - /* round three */ - for (; i < 60; ) { - FF2(a,b,c,d,e,i++); - FF2(e,a,b,c,d,i++); - FF2(d,e,a,b,c,i++); - FF2(c,d,e,a,b,i++); - FF2(b,c,d,e,a,i++); - } - - /* round four */ - for (; i < 80; ) { - FF3(a,b,c,d,e,i++); - FF3(e,a,b,c,d,i++); - FF3(d,e,a,b,c,i++); - FF3(c,d,e,a,b,i++); - FF3(b,c,d,e,a,i++); - } -#endif - - #undef FF0 - #undef FF1 - #undef FF2 - #undef FF3 - - /* store */ - md->sha1.state[0] = md->sha1.state[0] + a; - md->sha1.state[1] = md->sha1.state[1] + b; - md->sha1.state[2] = md->sha1.state[2] + c; - md->sha1.state[3] = md->sha1.state[3] + d; - md->sha1.state[4] = md->sha1.state[4] + e; - - return CRYPT_OK; -} - -#ifdef LTC_CLEAN_STACK -static int sha1_compress(hash_state *md, unsigned char *buf) -{ - int err; - err = _sha1_compress(md, buf); - burn_stack(sizeof(ulong32) * 87); - return err; -} -#endif - -/** - Initialize the hash state - @param md The hash state you wish to initialize - @return CRYPT_OK if successful -*/ -int sha1_init(hash_state * md) -{ - LTC_ARGCHK(md != NULL); - md->sha1.state[0] = 0x67452301UL; - md->sha1.state[1] = 0xefcdab89UL; - md->sha1.state[2] = 0x98badcfeUL; - md->sha1.state[3] = 0x10325476UL; - md->sha1.state[4] = 0xc3d2e1f0UL; - md->sha1.curlen = 0; - md->sha1.length = 0; - return CRYPT_OK; -} - -/** - Process a block of memory though the hash - @param md The hash state - @param in The data to hash - @param inlen The length of the data (octets) - @return CRYPT_OK if successful -*/ -HASH_PROCESS(sha1_process, sha1_compress, sha1, 64) - -/** - Terminate the hash to get the digest - @param md The hash state - @param out [out] The destination of the hash (20 bytes) - @return CRYPT_OK if successful -*/ -int sha1_done(hash_state * md, unsigned char *out) -{ - int i; - - LTC_ARGCHK(md != NULL); - LTC_ARGCHK(out != NULL); - - if (md->sha1.curlen >= sizeof(md->sha1.buf)) { - return CRYPT_INVALID_ARG; - } - - /* increase the length of the message */ - md->sha1.length += md->sha1.curlen * 8; - - /* append the '1' bit */ - md->sha1.buf[md->sha1.curlen++] = (unsigned char)0x80; - - /* if the length is currently above 56 bytes we append zeros - * then compress. Then we can fall back to padding zeros and length - * encoding like normal. - */ - if (md->sha1.curlen > 56) { - while (md->sha1.curlen < 64) { - md->sha1.buf[md->sha1.curlen++] = (unsigned char)0; - } - sha1_compress(md, md->sha1.buf); - md->sha1.curlen = 0; - } - - /* pad upto 56 bytes of zeroes */ - while (md->sha1.curlen < 56) { - md->sha1.buf[md->sha1.curlen++] = (unsigned char)0; - } - - /* store length */ - STORE64H(md->sha1.length, md->sha1.buf+56); - sha1_compress(md, md->sha1.buf); - - /* copy output */ - for (i = 0; i < 5; i++) { - STORE32H(md->sha1.state[i], out+(4*i)); - } -#ifdef LTC_CLEAN_STACK - zeromem(md, sizeof(hash_state)); -#endif - return CRYPT_OK; -} - -/** - Self-test the hash - @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled -*/ -int sha1_test(void) -{ - #ifndef LTC_TEST - return CRYPT_NOP; - #else - static const struct { - char *msg; - unsigned char hash[20]; - } tests[] = { - { "abc", - { 0xa9, 0x99, 0x3e, 0x36, 0x47, 0x06, 0x81, 0x6a, - 0xba, 0x3e, 0x25, 0x71, 0x78, 0x50, 0xc2, 0x6c, - 0x9c, 0xd0, 0xd8, 0x9d } - }, - { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", - { 0x84, 0x98, 0x3E, 0x44, 0x1C, 0x3B, 0xD2, 0x6E, - 0xBA, 0xAE, 0x4A, 0xA1, 0xF9, 0x51, 0x29, 0xE5, - 0xE5, 0x46, 0x70, 0xF1 } - } - }; - - int i; - unsigned char tmp[20]; - hash_state md; - - for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i++) { - sha1_init(&md); - sha1_process(&md, (unsigned char*)tests[i].msg, (unsigned long)strlen(tests[i].msg)); - sha1_done(&md, tmp); - if (XMEMCMP(tmp, tests[i].hash, 20) != 0) { - return CRYPT_FAIL_TESTVECTOR; - } - } - return CRYPT_OK; - #endif -} - -#endif - - - -/* $Source: /cvs/libtom/libtomcrypt/src/hashes/sha1.c,v $ */ -/* $Revision: 1.10 $ */ -/* $Date: 2007/05/12 14:25:28 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt.h b/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt.h deleted file mode 100644 index 7df3f5a..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef TOMCRYPT_H_ -#define TOMCRYPT_H_ -#include -#include -#include -#include -#include -#include -#include - -/* use configuration data */ -#include "tomcrypt_custom.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* version */ -#define CRYPT 0x0117 -#define SCRYPT "1.17" - -/* max size of either a cipher/hash block or symmetric key [largest of the two] */ -#define MAXBLOCKSIZE 128 - -/* descriptor table size */ -#define TAB_SIZE 32 - -#ifdef _MSC_VER -#pragma warning(disable: 4333) // der_encode_utf8_string.c(91) : warning C4333: '>>' : right shift by too large amount, data loss -#endif - -/* error codes [will be expanded in future releases] */ -enum { - CRYPT_OK=0, /* Result OK */ - CRYPT_ERROR, /* Generic Error */ - CRYPT_NOP, /* Not a failure but no operation was performed */ - - CRYPT_INVALID_KEYSIZE, /* Invalid key size given */ - CRYPT_INVALID_ROUNDS, /* Invalid number of rounds */ - CRYPT_FAIL_TESTVECTOR, /* Algorithm failed test vectors */ - - CRYPT_BUFFER_OVERFLOW, /* Not enough space for output */ - CRYPT_INVALID_PACKET, /* Invalid input packet given */ - - CRYPT_INVALID_PRNGSIZE, /* Invalid number of bits for a PRNG */ - CRYPT_ERROR_READPRNG, /* Could not read enough from PRNG */ - - CRYPT_INVALID_CIPHER, /* Invalid cipher specified */ - CRYPT_INVALID_HASH, /* Invalid hash specified */ - CRYPT_INVALID_PRNG, /* Invalid PRNG specified */ - - CRYPT_MEM, /* Out of memory */ - - CRYPT_PK_TYPE_MISMATCH, /* Not equivalent types of PK keys */ - CRYPT_PK_NOT_PRIVATE, /* Requires a private PK key */ - - CRYPT_INVALID_ARG, /* Generic invalid argument */ - CRYPT_FILE_NOTFOUND, /* File Not Found */ - - CRYPT_PK_INVALID_TYPE, /* Invalid type of PK key */ - CRYPT_PK_INVALID_SYSTEM,/* Invalid PK system specified */ - CRYPT_PK_DUP, /* Duplicate key already in key ring */ - CRYPT_PK_NOT_FOUND, /* Key not found in keyring */ - CRYPT_PK_INVALID_SIZE, /* Invalid size input for PK parameters */ - - CRYPT_INVALID_PRIME_SIZE,/* Invalid size of prime requested */ - CRYPT_PK_INVALID_PADDING /* Invalid padding on input */ -}; - -#include "tomcrypt_cfg.h" -#include "tomcrypt_macros.h" -#include "tomcrypt_cipher.h" -#include "tomcrypt_hash.h" -#include "tomcrypt_mac.h" -#include "tomcrypt_prng.h" -#include "tomcrypt_pk.h" -#include "tomcrypt_math.h" -#include "tomcrypt_misc.h" -#include "tomcrypt_argchk.h" -#include "tomcrypt_pkcs.h" - -#ifdef __cplusplus - } -#endif - -#endif /* TOMCRYPT_H_ */ - - -/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt.h,v $ */ -/* $Revision: 1.21 $ */ -/* $Date: 2006/12/16 19:34:05 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_argchk.h b/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_argchk.h deleted file mode 100644 index cfc93ad..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_argchk.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Defines the LTC_ARGCHK macro used within the library */ -/* ARGTYPE is defined in mycrypt_cfg.h */ -#if ARGTYPE == 0 - -#include - -/* this is the default LibTomCrypt macro */ -void crypt_argchk(char *v, char *s, int d); -#define LTC_ARGCHK(x) if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } -#define LTC_ARGCHKVD(x) LTC_ARGCHK(x) - -#elif ARGTYPE == 1 - -/* fatal type of error */ -#define LTC_ARGCHK(x) assert((x)) -#define LTC_ARGCHKVD(x) LTC_ARGCHK(x) - -#elif ARGTYPE == 2 - -#define LTC_ARGCHK(x) if (!(x)) { fprintf(stderr, "\nwarning: ARGCHK failed at %s:%d\n", __FILE__, __LINE__); } -#define LTC_ARGCHKVD(x) LTC_ARGCHK(x) - -#elif ARGTYPE == 3 - -#define LTC_ARGCHK(x) -#define LTC_ARGCHKVD(x) LTC_ARGCHK(x) - -#elif ARGTYPE == 4 - -#define LTC_ARGCHK(x) if (!(x)) return CRYPT_INVALID_ARG; -#define LTC_ARGCHKVD(x) if (!(x)) return; - -#endif - - -/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_argchk.h,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/08/27 20:50:21 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_cfg.h b/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_cfg.h deleted file mode 100644 index 7feae6e..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_cfg.h +++ /dev/null @@ -1,136 +0,0 @@ -/* This is the build config file. - * - * With this you can setup what to inlcude/exclude automatically during any build. Just comment - * out the line that #define's the word for the thing you want to remove. phew! - */ - -#ifndef TOMCRYPT_CFG_H -#define TOMCRYPT_CFG_H - -#if defined(_WIN32) || defined(_MSC_VER) -#define LTC_CALL __cdecl -#else -#ifndef LTC_CALL - #define LTC_CALL -#endif -#endif - -#ifndef LTC_EXPORT -#define LTC_EXPORT -#endif - -/* certain platforms use macros for these, making the prototypes broken */ -#ifndef LTC_NO_PROTOTYPES - -/* you can change how memory allocation works ... */ -LTC_EXPORT void * LTC_CALL XMALLOC(size_t n); -LTC_EXPORT void * LTC_CALL XREALLOC(void *p, size_t n); -LTC_EXPORT void * LTC_CALL XCALLOC(size_t n, size_t s); -LTC_EXPORT void LTC_CALL XFREE(void *p); - -LTC_EXPORT void LTC_CALL XQSORT(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); - - -/* change the clock function too */ -LTC_EXPORT clock_t LTC_CALL XCLOCK(void); - -/* various other functions */ -LTC_EXPORT void * LTC_CALL XMEMCPY(void *dest, const void *src, size_t n); -LTC_EXPORT int LTC_CALL XMEMCMP(const void *s1, const void *s2, size_t n); -LTC_EXPORT void * LTC_CALL XMEMSET(void *s, int c, size_t n); - -LTC_EXPORT int LTC_CALL XSTRCMP(const char *s1, const char *s2); - -#endif - -/* type of argument checking, 0=default, 1=fatal and 2=error+continue, 3=nothing */ -#ifndef ARGTYPE - #define ARGTYPE 0 -#endif - -/* Controls endianess and size of registers. Leave uncommented to get platform neutral [slower] code - * - * Note: in order to use the optimized macros your platform must support unaligned 32 and 64 bit read/writes. - * The x86 platforms allow this but some others [ARM for instance] do not. On those platforms you **MUST** - * use the portable [slower] macros. - */ - -/* detect x86-32 machines somewhat */ -#if !defined(__STRICT_ANSI__) && (defined(INTEL_CC) || (defined(_MSC_VER) && defined(WIN32)) || (defined(__GNUC__) && (defined(__DJGPP__) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__i386__)))) - #define ENDIAN_LITTLE - #define ENDIAN_32BITWORD - #define LTC_FAST - #define LTC_FAST_TYPE unsigned long -#endif - -/* detects MIPS R5900 processors (PS2) */ -#if (defined(__R5900) || defined(R5900) || defined(__R5900__)) && (defined(_mips) || defined(__mips__) || defined(mips)) - #define ENDIAN_LITTLE - #define ENDIAN_64BITWORD -#endif - -/* detect amd64 */ -#if !defined(__STRICT_ANSI__) && defined(__x86_64__) - #define ENDIAN_LITTLE - #define ENDIAN_64BITWORD - #define LTC_FAST - #define LTC_FAST_TYPE unsigned long -#endif - -/* detect PPC32 */ -#if !defined(__STRICT_ANSI__) && defined(LTC_PPC32) - #define ENDIAN_BIG - #define ENDIAN_32BITWORD - #define LTC_FAST - #define LTC_FAST_TYPE unsigned long -#endif - -/* detect sparc and sparc64 */ -#if defined(__sparc__) - #define ENDIAN_BIG - #if defined(__arch64__) - #define ENDIAN_64BITWORD - #else - #define ENDIAN_32BITWORD - #endif -#endif - - -#ifdef LTC_NO_FAST - #ifdef LTC_FAST - #undef LTC_FAST - #endif -#endif - -/* No asm is a quick way to disable anything "not portable" */ -#ifdef LTC_NO_ASM - #undef ENDIAN_LITTLE - #undef ENDIAN_BIG - #undef ENDIAN_32BITWORD - #undef ENDIAN_64BITWORD - #undef LTC_FAST - #undef LTC_FAST_TYPE - #define LTC_NO_ROLC - #define LTC_NO_BSWAP -#endif - -/* #define ENDIAN_LITTLE */ -/* #define ENDIAN_BIG */ - -/* #define ENDIAN_32BITWORD */ -/* #define ENDIAN_64BITWORD */ - -#if (defined(ENDIAN_BIG) || defined(ENDIAN_LITTLE)) && !(defined(ENDIAN_32BITWORD) || defined(ENDIAN_64BITWORD)) - #error You must specify a word size as well as endianess in tomcrypt_cfg.h -#endif - -#if !(defined(ENDIAN_BIG) || defined(ENDIAN_LITTLE)) - #define ENDIAN_NEUTRAL -#endif - -#endif - - -/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_cfg.h,v $ */ -/* $Revision: 1.19 $ */ -/* $Date: 2006/12/04 02:19:48 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_cipher.h b/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_cipher.h deleted file mode 100644 index bd740bf..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_cipher.h +++ /dev/null @@ -1,891 +0,0 @@ -/* ---- SYMMETRIC KEY STUFF ----- - * - * We put each of the ciphers scheduled keys in their own structs then we put all of - * the key formats in one union. This makes the function prototypes easier to use. - */ -#ifdef LTC_BLOWFISH -struct blowfish_key { - ulong32 S[4][256]; - ulong32 K[18]; -}; -#endif - -#ifdef LTC_RC5 -struct rc5_key { - int rounds; - ulong32 K[50]; -}; -#endif - -#ifdef LTC_RC6 -struct rc6_key { - ulong32 K[44]; -}; -#endif - -#ifdef LTC_SAFERP -struct saferp_key { - unsigned char K[33][16]; - long rounds; -}; -#endif - -#ifdef LTC_RIJNDAEL -struct rijndael_key { - ulong32 eK[60], dK[60]; - int Nr; -}; -#endif - -#ifdef LTC_KSEED -struct kseed_key { - ulong32 K[32], dK[32]; -}; -#endif - -#ifdef LTC_KASUMI -struct kasumi_key { - ulong32 KLi1[8], KLi2[8], - KOi1[8], KOi2[8], KOi3[8], - KIi1[8], KIi2[8], KIi3[8]; -}; -#endif - -#ifdef LTC_XTEA -struct xtea_key { - unsigned long A[32], B[32]; -}; -#endif - -#ifdef LTC_TWOFISH -#ifndef LTC_TWOFISH_SMALL - struct twofish_key { - ulong32 S[4][256], K[40]; - }; -#else - struct twofish_key { - ulong32 K[40]; - unsigned char S[32], start; - }; -#endif -#endif - -#ifdef LTC_SAFER -#define LTC_SAFER_K64_DEFAULT_NOF_ROUNDS 6 -#define LTC_SAFER_K128_DEFAULT_NOF_ROUNDS 10 -#define LTC_SAFER_SK64_DEFAULT_NOF_ROUNDS 8 -#define LTC_SAFER_SK128_DEFAULT_NOF_ROUNDS 10 -#define LTC_SAFER_MAX_NOF_ROUNDS 13 -#define LTC_SAFER_BLOCK_LEN 8 -#define LTC_SAFER_KEY_LEN (1 + LTC_SAFER_BLOCK_LEN * (1 + 2 * LTC_SAFER_MAX_NOF_ROUNDS)) -typedef unsigned char safer_block_t[LTC_SAFER_BLOCK_LEN]; -typedef unsigned char safer_key_t[LTC_SAFER_KEY_LEN]; -struct safer_key { safer_key_t key; }; -#endif - -#ifdef LTC_RC2 -struct rc2_key { unsigned xkey[64]; }; -#endif - -#ifdef LTC_DES -struct des_key { - ulong32 ek[32], dk[32]; -}; - -struct des3_key { - ulong32 ek[3][32], dk[3][32]; -}; -#endif - -#ifdef LTC_CAST5 -struct cast5_key { - ulong32 K[32], keylen; -}; -#endif - -#ifdef LTC_NOEKEON -struct noekeon_key { - ulong32 K[4], dK[4]; -}; -#endif - -#ifdef LTC_SKIPJACK -struct skipjack_key { - unsigned char key[10]; -}; -#endif - -#ifdef LTC_KHAZAD -struct khazad_key { - ulong64 roundKeyEnc[8 + 1]; - ulong64 roundKeyDec[8 + 1]; -}; -#endif - -#ifdef LTC_ANUBIS -struct anubis_key { - int keyBits; - int R; - ulong32 roundKeyEnc[18 + 1][4]; - ulong32 roundKeyDec[18 + 1][4]; -}; -#endif - -#ifdef LTC_MULTI2 -struct multi2_key { - int N; - ulong32 uk[8]; -}; -#endif - -typedef union Symmetric_key { -#ifdef LTC_DES - struct des_key des; - struct des3_key des3; -#endif -#ifdef LTC_RC2 - struct rc2_key rc2; -#endif -#ifdef LTC_SAFER - struct safer_key safer; -#endif -#ifdef LTC_TWOFISH - struct twofish_key twofish; -#endif -#ifdef LTC_BLOWFISH - struct blowfish_key blowfish; -#endif -#ifdef LTC_RC5 - struct rc5_key rc5; -#endif -#ifdef LTC_RC6 - struct rc6_key rc6; -#endif -#ifdef LTC_SAFERP - struct saferp_key saferp; -#endif -#ifdef LTC_RIJNDAEL - struct rijndael_key rijndael; -#endif -#ifdef LTC_XTEA - struct xtea_key xtea; -#endif -#ifdef LTC_CAST5 - struct cast5_key cast5; -#endif -#ifdef LTC_NOEKEON - struct noekeon_key noekeon; -#endif -#ifdef LTC_SKIPJACK - struct skipjack_key skipjack; -#endif -#ifdef LTC_KHAZAD - struct khazad_key khazad; -#endif -#ifdef LTC_ANUBIS - struct anubis_key anubis; -#endif -#ifdef LTC_KSEED - struct kseed_key kseed; -#endif -#ifdef LTC_KASUMI - struct kasumi_key kasumi; -#endif -#ifdef LTC_MULTI2 - struct multi2_key multi2; -#endif - void *data; -} symmetric_key; - -#ifdef LTC_ECB_MODE -/** A block cipher ECB structure */ -typedef struct { - /** The index of the cipher chosen */ - int cipher, - /** The block size of the given cipher */ - blocklen; - /** The scheduled key */ - symmetric_key key; -} symmetric_ECB; -#endif - -#ifdef LTC_CFB_MODE -/** A block cipher CFB structure */ -typedef struct { - /** The index of the cipher chosen */ - int cipher, - /** The block size of the given cipher */ - blocklen, - /** The padding offset */ - padlen; - /** The current IV */ - unsigned char IV[MAXBLOCKSIZE], - /** The pad used to encrypt/decrypt */ - pad[MAXBLOCKSIZE]; - /** The scheduled key */ - symmetric_key key; -} symmetric_CFB; -#endif - -#ifdef LTC_OFB_MODE -/** A block cipher OFB structure */ -typedef struct { - /** The index of the cipher chosen */ - int cipher, - /** The block size of the given cipher */ - blocklen, - /** The padding offset */ - padlen; - /** The current IV */ - unsigned char IV[MAXBLOCKSIZE]; - /** The scheduled key */ - symmetric_key key; -} symmetric_OFB; -#endif - -#ifdef LTC_CBC_MODE -/** A block cipher CBC structure */ -typedef struct { - /** The index of the cipher chosen */ - int cipher, - /** The block size of the given cipher */ - blocklen; - /** The current IV */ - unsigned char IV[MAXBLOCKSIZE]; - /** The scheduled key */ - symmetric_key key; -} symmetric_CBC; -#endif - - -#ifdef LTC_CTR_MODE -/** A block cipher CTR structure */ -typedef struct { - /** The index of the cipher chosen */ - int cipher, - /** The block size of the given cipher */ - blocklen, - /** The padding offset */ - padlen, - /** The mode (endianess) of the CTR, 0==little, 1==big */ - mode, - /** counter width */ - ctrlen; - - /** The counter */ - unsigned char ctr[MAXBLOCKSIZE], - /** The pad used to encrypt/decrypt */ - pad[MAXBLOCKSIZE]; - /** The scheduled key */ - symmetric_key key; -} symmetric_CTR; -#endif - - -#ifdef LTC_LRW_MODE -/** A LRW structure */ -typedef struct { - /** The index of the cipher chosen (must be a 128-bit block cipher) */ - int cipher; - - /** The current IV */ - unsigned char IV[16], - - /** the tweak key */ - tweak[16], - - /** The current pad, it's the product of the first 15 bytes against the tweak key */ - pad[16]; - - /** The scheduled symmetric key */ - symmetric_key key; - -#ifdef LRW_TABLES - /** The pre-computed multiplication table */ - unsigned char PC[16][256][16]; -#endif -} symmetric_LRW; -#endif - -#ifdef LTC_F8_MODE -/** A block cipher F8 structure */ -typedef struct { - /** The index of the cipher chosen */ - int cipher, - /** The block size of the given cipher */ - blocklen, - /** The padding offset */ - padlen; - /** The current IV */ - unsigned char IV[MAXBLOCKSIZE], - MIV[MAXBLOCKSIZE]; - /** Current block count */ - ulong32 blockcnt; - /** The scheduled key */ - symmetric_key key; -} symmetric_F8; -#endif - - -/** cipher descriptor table, last entry has "name == NULL" to mark the end of table */ -extern struct ltc_cipher_descriptor { - /** name of cipher */ - char *name; - /** internal ID */ - unsigned char ID; - /** min keysize (octets) */ - int min_key_length, - /** max keysize (octets) */ - max_key_length, - /** block size (octets) */ - block_length, - /** default number of rounds */ - default_rounds; - /** Setup the cipher - @param key The input symmetric key - @param keylen The length of the input key (octets) - @param num_rounds The requested number of rounds (0==default) - @param skey [out] The destination of the scheduled key - @return CRYPT_OK if successful - */ - int (*setup)(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); - /** Encrypt a block - @param pt The plaintext - @param ct [out] The ciphertext - @param skey The scheduled key - @return CRYPT_OK if successful - */ - int (*ecb_encrypt)(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); - /** Decrypt a block - @param ct The ciphertext - @param pt [out] The plaintext - @param skey The scheduled key - @return CRYPT_OK if successful - */ - int (*ecb_decrypt)(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); - /** Test the block cipher - @return CRYPT_OK if successful, CRYPT_NOP if self-testing has been disabled - */ - int (*test)(void); - - /** Terminate the context - @param skey The scheduled key - */ - void (*done)(symmetric_key *skey); - - /** Determine a key size - @param keysize [in/out] The size of the key desired and the suggested size - @return CRYPT_OK if successful - */ - int (*keysize)(int *keysize); - -/** Accelerators **/ - /** Accelerated ECB encryption - @param pt Plaintext - @param ct Ciphertext - @param blocks The number of complete blocks to process - @param skey The scheduled key context - @return CRYPT_OK if successful - */ - int (*accel_ecb_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, symmetric_key *skey); - - /** Accelerated ECB decryption - @param pt Plaintext - @param ct Ciphertext - @param blocks The number of complete blocks to process - @param skey The scheduled key context - @return CRYPT_OK if successful - */ - int (*accel_ecb_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, symmetric_key *skey); - - /** Accelerated CBC encryption - @param pt Plaintext - @param ct Ciphertext - @param blocks The number of complete blocks to process - @param IV The initial value (input/output) - @param skey The scheduled key context - @return CRYPT_OK if successful - */ - int (*accel_cbc_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, symmetric_key *skey); - - /** Accelerated CBC decryption - @param pt Plaintext - @param ct Ciphertext - @param blocks The number of complete blocks to process - @param IV The initial value (input/output) - @param skey The scheduled key context - @return CRYPT_OK if successful - */ - int (*accel_cbc_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, unsigned char *IV, symmetric_key *skey); - - /** Accelerated CTR encryption - @param pt Plaintext - @param ct Ciphertext - @param blocks The number of complete blocks to process - @param IV The initial value (input/output) - @param mode little or big endian counter (mode=0 or mode=1) - @param skey The scheduled key context - @return CRYPT_OK if successful - */ - int (*accel_ctr_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, int mode, symmetric_key *skey); - - /** Accelerated LRW - @param pt Plaintext - @param ct Ciphertext - @param blocks The number of complete blocks to process - @param IV The initial value (input/output) - @param tweak The LRW tweak - @param skey The scheduled key context - @return CRYPT_OK if successful - */ - int (*accel_lrw_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, const unsigned char *tweak, symmetric_key *skey); - - /** Accelerated LRW - @param ct Ciphertext - @param pt Plaintext - @param blocks The number of complete blocks to process - @param IV The initial value (input/output) - @param tweak The LRW tweak - @param skey The scheduled key context - @return CRYPT_OK if successful - */ - int (*accel_lrw_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, unsigned char *IV, const unsigned char *tweak, symmetric_key *skey); - - /** Accelerated CCM packet (one-shot) - @param key The secret key to use - @param keylen The length of the secret key (octets) - @param uskey A previously scheduled key [optional can be NULL] - @param nonce The session nonce [use once] - @param noncelen The length of the nonce - @param header The header for the session - @param headerlen The length of the header (octets) - @param pt [out] The plaintext - @param ptlen The length of the plaintext (octets) - @param ct [out] The ciphertext - @param tag [out] The destination tag - @param taglen [in/out] The max size and resulting size of the authentication tag - @param direction Encrypt or Decrypt direction (0 or 1) - @return CRYPT_OK if successful - */ - int (*accel_ccm_memory)( - const unsigned char *key, unsigned long keylen, - symmetric_key *uskey, - const unsigned char *nonce, unsigned long noncelen, - const unsigned char *header, unsigned long headerlen, - unsigned char *pt, unsigned long ptlen, - unsigned char *ct, - unsigned char *tag, unsigned long *taglen, - int direction); - - /** Accelerated GCM packet (one shot) - @param key The secret key - @param keylen The length of the secret key - @param IV The initial vector - @param IVlen The length of the initial vector - @param adata The additional authentication data (header) - @param adatalen The length of the adata - @param pt The plaintext - @param ptlen The length of the plaintext (ciphertext length is the same) - @param ct The ciphertext - @param tag [out] The MAC tag - @param taglen [in/out] The MAC tag length - @param direction Encrypt or Decrypt mode (GCM_ENCRYPT or GCM_DECRYPT) - @return CRYPT_OK on success - */ - int (*accel_gcm_memory)( - const unsigned char *key, unsigned long keylen, - const unsigned char *IV, unsigned long IVlen, - const unsigned char *adata, unsigned long adatalen, - unsigned char *pt, unsigned long ptlen, - unsigned char *ct, - unsigned char *tag, unsigned long *taglen, - int direction); - - /** Accelerated one shot LTC_OMAC - @param key The secret key - @param keylen The key length (octets) - @param in The message - @param inlen Length of message (octets) - @param out [out] Destination for tag - @param outlen [in/out] Initial and final size of out - @return CRYPT_OK on success - */ - int (*omac_memory)( - const unsigned char *key, unsigned long keylen, - const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen); - - /** Accelerated one shot XCBC - @param key The secret key - @param keylen The key length (octets) - @param in The message - @param inlen Length of message (octets) - @param out [out] Destination for tag - @param outlen [in/out] Initial and final size of out - @return CRYPT_OK on success - */ - int (*xcbc_memory)( - const unsigned char *key, unsigned long keylen, - const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen); - - /** Accelerated one shot F9 - @param key The secret key - @param keylen The key length (octets) - @param in The message - @param inlen Length of message (octets) - @param out [out] Destination for tag - @param outlen [in/out] Initial and final size of out - @return CRYPT_OK on success - @remark Requires manual padding - */ - int (*f9_memory)( - const unsigned char *key, unsigned long keylen, - const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen); -} cipher_descriptor[]; - -#ifdef LTC_BLOWFISH -int blowfish_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); -int blowfish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); -int blowfish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); -int blowfish_test(void); -void blowfish_done(symmetric_key *skey); -int blowfish_keysize(int *keysize); -extern const struct ltc_cipher_descriptor blowfish_desc; -#endif - -#ifdef LTC_RC5 -int rc5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); -int rc5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); -int rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); -int rc5_test(void); -void rc5_done(symmetric_key *skey); -int rc5_keysize(int *keysize); -extern const struct ltc_cipher_descriptor rc5_desc; -#endif - -#ifdef LTC_RC6 -int rc6_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); -int rc6_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); -int rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); -int rc6_test(void); -void rc6_done(symmetric_key *skey); -int rc6_keysize(int *keysize); -extern const struct ltc_cipher_descriptor rc6_desc; -#endif - -#ifdef LTC_RC2 -int rc2_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); -int rc2_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); -int rc2_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); -int rc2_test(void); -void rc2_done(symmetric_key *skey); -int rc2_keysize(int *keysize); -extern const struct ltc_cipher_descriptor rc2_desc; -#endif - -#ifdef LTC_SAFERP -int saferp_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); -int saferp_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); -int saferp_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); -int saferp_test(void); -void saferp_done(symmetric_key *skey); -int saferp_keysize(int *keysize); -extern const struct ltc_cipher_descriptor saferp_desc; -#endif - -#ifdef LTC_SAFER -int safer_k64_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); -int safer_sk64_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); -int safer_k128_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); -int safer_sk128_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); -int safer_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *key); -int safer_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *key); -int safer_k64_test(void); -int safer_sk64_test(void); -int safer_sk128_test(void); -void safer_done(symmetric_key *skey); -int safer_64_keysize(int *keysize); -int safer_128_keysize(int *keysize); -extern const struct ltc_cipher_descriptor safer_k64_desc, safer_k128_desc, safer_sk64_desc, safer_sk128_desc; -#endif - -#ifdef LTC_RIJNDAEL - -/* make aes an alias */ -#define aes_setup rijndael_setup -#define aes_ecb_encrypt rijndael_ecb_encrypt -#define aes_ecb_decrypt rijndael_ecb_decrypt -#define aes_test rijndael_test -#define aes_done rijndael_done -#define aes_keysize rijndael_keysize - -#define aes_enc_setup rijndael_enc_setup -#define aes_enc_ecb_encrypt rijndael_enc_ecb_encrypt -#define aes_enc_keysize rijndael_enc_keysize - -int rijndael_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); -int rijndael_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); -int rijndael_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); -int rijndael_test(void); -void rijndael_done(symmetric_key *skey); -int rijndael_keysize(int *keysize); -int rijndael_enc_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); -int rijndael_enc_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); -void rijndael_enc_done(symmetric_key *skey); -int rijndael_enc_keysize(int *keysize); -extern const struct ltc_cipher_descriptor rijndael_desc, aes_desc; -extern const struct ltc_cipher_descriptor rijndael_enc_desc, aes_enc_desc; -#endif - -#ifdef LTC_XTEA -int xtea_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); -int xtea_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); -int xtea_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); -int xtea_test(void); -void xtea_done(symmetric_key *skey); -int xtea_keysize(int *keysize); -extern const struct ltc_cipher_descriptor xtea_desc; -#endif - -#ifdef LTC_TWOFISH -int twofish_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); -int twofish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); -int twofish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); -int twofish_test(void); -void twofish_done(symmetric_key *skey); -int twofish_keysize(int *keysize); -extern const struct ltc_cipher_descriptor twofish_desc; -#endif - -#ifdef LTC_DES -int des_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); -int des_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); -int des_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); -int des_test(void); -void des_done(symmetric_key *skey); -int des_keysize(int *keysize); -int des3_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); -int des3_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); -int des3_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); -int des3_test(void); -void des3_done(symmetric_key *skey); -int des3_keysize(int *keysize); -extern const struct ltc_cipher_descriptor des_desc, des3_desc; -#endif - -#ifdef LTC_CAST5 -int cast5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); -int cast5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); -int cast5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); -int cast5_test(void); -void cast5_done(symmetric_key *skey); -int cast5_keysize(int *keysize); -extern const struct ltc_cipher_descriptor cast5_desc; -#endif - -#ifdef LTC_NOEKEON -int noekeon_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); -int noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); -int noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); -int noekeon_test(void); -void noekeon_done(symmetric_key *skey); -int noekeon_keysize(int *keysize); -extern const struct ltc_cipher_descriptor noekeon_desc; -#endif - -#ifdef LTC_SKIPJACK -int skipjack_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); -int skipjack_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); -int skipjack_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); -int skipjack_test(void); -void skipjack_done(symmetric_key *skey); -int skipjack_keysize(int *keysize); -extern const struct ltc_cipher_descriptor skipjack_desc; -#endif - -#ifdef LTC_KHAZAD -int khazad_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); -int khazad_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); -int khazad_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); -int khazad_test(void); -void khazad_done(symmetric_key *skey); -int khazad_keysize(int *keysize); -extern const struct ltc_cipher_descriptor khazad_desc; -#endif - -#ifdef LTC_ANUBIS -int anubis_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); -int anubis_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); -int anubis_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); -int anubis_test(void); -void anubis_done(symmetric_key *skey); -int anubis_keysize(int *keysize); -extern const struct ltc_cipher_descriptor anubis_desc; -#endif - -#ifdef LTC_KSEED -int kseed_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); -int kseed_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); -int kseed_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); -int kseed_test(void); -void kseed_done(symmetric_key *skey); -int kseed_keysize(int *keysize); -extern const struct ltc_cipher_descriptor kseed_desc; -#endif - -#ifdef LTC_KASUMI -int kasumi_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); -int kasumi_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); -int kasumi_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); -int kasumi_test(void); -void kasumi_done(symmetric_key *skey); -int kasumi_keysize(int *keysize); -extern const struct ltc_cipher_descriptor kasumi_desc; -#endif - - -#ifdef LTC_MULTI2 -int multi2_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); -int multi2_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); -int multi2_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); -int multi2_test(void); -void multi2_done(symmetric_key *skey); -int multi2_keysize(int *keysize); -extern const struct ltc_cipher_descriptor multi2_desc; -#endif - -#ifdef LTC_ECB_MODE -int ecb_start(int cipher, const unsigned char *key, - int keylen, int num_rounds, symmetric_ECB *ecb); -int ecb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_ECB *ecb); -int ecb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_ECB *ecb); -int ecb_done(symmetric_ECB *ecb); -#endif - -#ifdef LTC_CFB_MODE -int cfb_start(int cipher, const unsigned char *IV, const unsigned char *key, - int keylen, int num_rounds, symmetric_CFB *cfb); -int cfb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CFB *cfb); -int cfb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_CFB *cfb); -int cfb_getiv(unsigned char *IV, unsigned long *len, symmetric_CFB *cfb); -int cfb_setiv(const unsigned char *IV, unsigned long len, symmetric_CFB *cfb); -int cfb_done(symmetric_CFB *cfb); -#endif - -#ifdef LTC_OFB_MODE -int ofb_start(int cipher, const unsigned char *IV, const unsigned char *key, - int keylen, int num_rounds, symmetric_OFB *ofb); -int ofb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_OFB *ofb); -int ofb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_OFB *ofb); -int ofb_getiv(unsigned char *IV, unsigned long *len, symmetric_OFB *ofb); -int ofb_setiv(const unsigned char *IV, unsigned long len, symmetric_OFB *ofb); -int ofb_done(symmetric_OFB *ofb); -#endif - -#ifdef LTC_CBC_MODE -int cbc_start(int cipher, const unsigned char *IV, const unsigned char *key, - int keylen, int num_rounds, symmetric_CBC *cbc); -int cbc_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CBC *cbc); -int cbc_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_CBC *cbc); -int cbc_getiv(unsigned char *IV, unsigned long *len, symmetric_CBC *cbc); -int cbc_setiv(const unsigned char *IV, unsigned long len, symmetric_CBC *cbc); -int cbc_done(symmetric_CBC *cbc); -#endif - -#ifdef LTC_CTR_MODE - -#define CTR_COUNTER_LITTLE_ENDIAN 0x0000 -#define CTR_COUNTER_BIG_ENDIAN 0x1000 -#define LTC_CTR_RFC3686 0x2000 - -int ctr_start( int cipher, - const unsigned char *IV, - const unsigned char *key, int keylen, - int num_rounds, int ctr_mode, - symmetric_CTR *ctr); -int ctr_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CTR *ctr); -int ctr_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_CTR *ctr); -int ctr_getiv(unsigned char *IV, unsigned long *len, symmetric_CTR *ctr); -int ctr_setiv(const unsigned char *IV, unsigned long len, symmetric_CTR *ctr); -int ctr_done(symmetric_CTR *ctr); -int ctr_test(void); -#endif - -#ifdef LTC_LRW_MODE - -#define LRW_ENCRYPT 0 -#define LRW_DECRYPT 1 - -int lrw_start( int cipher, - const unsigned char *IV, - const unsigned char *key, int keylen, - const unsigned char *tweak, - int num_rounds, - symmetric_LRW *lrw); -int lrw_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_LRW *lrw); -int lrw_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_LRW *lrw); -int lrw_getiv(unsigned char *IV, unsigned long *len, symmetric_LRW *lrw); -int lrw_setiv(const unsigned char *IV, unsigned long len, symmetric_LRW *lrw); -int lrw_done(symmetric_LRW *lrw); -int lrw_test(void); - -/* don't call */ -int lrw_process(const unsigned char *pt, unsigned char *ct, unsigned long len, int mode, symmetric_LRW *lrw); -#endif - -#ifdef LTC_F8_MODE -int f8_start( int cipher, const unsigned char *IV, - const unsigned char *key, int keylen, - const unsigned char *salt_key, int skeylen, - int num_rounds, symmetric_F8 *f8); -int f8_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_F8 *f8); -int f8_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_F8 *f8); -int f8_getiv(unsigned char *IV, unsigned long *len, symmetric_F8 *f8); -int f8_setiv(const unsigned char *IV, unsigned long len, symmetric_F8 *f8); -int f8_done(symmetric_F8 *f8); -int f8_test_mode(void); -#endif - -#ifdef LTC_XTS_MODE -typedef struct { - symmetric_key key1, key2; - int cipher; -} symmetric_xts; - -int xts_start( int cipher, - const unsigned char *key1, - const unsigned char *key2, - unsigned long keylen, - int num_rounds, - symmetric_xts *xts); - -int xts_encrypt( - const unsigned char *pt, unsigned long ptlen, - unsigned char *ct, - const unsigned char *tweak, - symmetric_xts *xts); -int xts_decrypt( - const unsigned char *ct, unsigned long ptlen, - unsigned char *pt, - const unsigned char *tweak, - symmetric_xts *xts); - -void xts_done(symmetric_xts *xts); -int xts_test(void); -void xts_mult_x(unsigned char *I); -#endif - -int find_cipher(const char *name); -int find_cipher_any(const char *name, int blocklen, int keylen); -int find_cipher_id(unsigned char ID); -int register_cipher(const struct ltc_cipher_descriptor *cipher); -int unregister_cipher(const struct ltc_cipher_descriptor *cipher); -int cipher_is_valid(int idx); - -LTC_MUTEX_PROTO(ltc_cipher_mutex) - -/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_cipher.h,v $ */ -/* $Revision: 1.54 $ */ -/* $Date: 2007/05/12 14:37:41 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_custom.h b/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_custom.h deleted file mode 100644 index 88ec8f9..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_custom.h +++ /dev/null @@ -1,424 +0,0 @@ -#ifndef TOMCRYPT_CUSTOM_H_ -#define TOMCRYPT_CUSTOM_H_ - -#define LTC_NO_CIPHERS -#define LTC_NO_HASHES -#define LTC_NO_MACS -#define LTC_NO_PRNGS -#define LTC_NO_CURVES -#define LTC_NO_MODES -#define LTC_NO_PKCS -#define LTC_NO_ROLC - -#define LTC_SOURCE -#define LTC_SHA1 -#define LTC_MD5 -#define LTC_DER -#define LTC_RC4 - -#define USE_LTM -#define LTM_DESC - -/* macros for various libc functions you can change for embedded targets */ -#ifndef XMALLOC - #ifdef malloc - #define LTC_NO_PROTOTYPES - #endif -#define XMALLOC LibTomMalloc -#endif -#ifndef XREALLOC - #ifdef realloc - #define LTC_NO_PROTOTYPES - #endif -#define XREALLOC LibTomRealloc -#endif -#ifndef XCALLOC - #ifdef calloc - #define LTC_NO_PROTOTYPES - #endif -#define XCALLOC LibTomCalloc -#endif -#ifndef XFREE - #ifdef free - #define LTC_NO_PROTOTYPES - #endif -#define XFREE LibTomFree -#endif - -#ifndef XMEMSET - #ifdef memset - #define LTC_NO_PROTOTYPES - #endif -#define XMEMSET memset -#endif -#ifndef XMEMCPY - #ifdef memcpy - #define LTC_NO_PROTOTYPES - #endif -#define XMEMCPY memcpy -#endif -#ifndef XMEMCMP - #ifdef memcmp - #define LTC_NO_PROTOTYPES - #endif -#define XMEMCMP memcmp -#endif -#ifndef XSTRCMP - #ifdef strcmp - #define LTC_NO_PROTOTYPES - #endif -#define XSTRCMP strcmp -#endif - -#ifndef XCLOCK -#define XCLOCK LibTomClock -#endif -#ifndef XCLOCKS_PER_SEC -#define XCLOCKS_PER_SEC CLOCKS_PER_SEC -#endif - -#ifndef XQSORT - #ifdef qsort - #define LTC_NO_PROTOTYPES - #endif -#define XQSORT LibTomQsort -#endif - -/* Easy button? */ -#ifdef LTC_EASY - #define LTC_NO_CIPHERS - #define LTC_RIJNDAEL - #define LTC_BLOWFISH - #define LTC_DES - #define LTC_CAST5 - - #define LTC_NO_MODES - #define LTC_ECB_MODE - #define LTC_CBC_MODE - #define LTC_CTR_MODE - - #define LTC_NO_HASHES - #define LTC_SHA1 - #define LTC_SHA512 - #define LTC_SHA384 - #define LTC_SHA256 - #define LTC_SHA224 - - #define LTC_NO_MACS - #define LTC_HMAC - #define LTC_OMAC - #define LTC_CCM_MODE - - #define LTC_NO_PRNGS - #define LTC_SPRNG - #define LTC_YARROW - #define LTC_DEVRANDOM - #define TRY_URANDOM_FIRST - - #define LTC_NO_PK - #define LTC_MRSA - #define LTC_MECC -#endif - -/* Use small code where possible */ -/* #define LTC_SMALL_CODE */ - -/* Enable self-test test vector checking */ -#ifndef LTC_NO_TEST - #define LTC_TEST -#endif - -/* clean the stack of functions which put private information on stack */ -/* #define LTC_CLEAN_STACK */ - -/* disable all file related functions */ -/* #define LTC_NO_FILE */ - -/* disable all forms of ASM */ -/* #define LTC_NO_ASM */ - -/* disable FAST mode */ -/* #define LTC_NO_FAST */ - -/* disable BSWAP on x86 */ -/* #define LTC_NO_BSWAP */ - -/* ---> Symmetric Block Ciphers <--- */ -#ifndef LTC_NO_CIPHERS - -#define LTC_BLOWFISH -#define LTC_RC2 -#define LTC_RC5 -#define LTC_RC6 -#define LTC_SAFERP -#define LTC_RIJNDAEL -#define LTC_XTEA -/* _TABLES tells it to use tables during setup, _SMALL means to use the smaller scheduled key format - * (saves 4KB of ram), _ALL_TABLES enables all tables during setup */ -#define LTC_TWOFISH -#ifndef LTC_NO_TABLES - #define LTC_TWOFISH_TABLES - /* #define LTC_TWOFISH_ALL_TABLES */ -#else - #define LTC_TWOFISH_SMALL -#endif -/* #define LTC_TWOFISH_SMALL */ -/* LTC_DES includes EDE triple-LTC_DES */ -#define LTC_DES -#define LTC_CAST5 -#define LTC_NOEKEON -#define LTC_SKIPJACK -#define LTC_SAFER -#define LTC_KHAZAD -#define LTC_ANUBIS -#define LTC_ANUBIS_TWEAK -#define LTC_KSEED -#define LTC_KASUMI - -#endif /* LTC_NO_CIPHERS */ - - -/* ---> Block Cipher Modes of Operation <--- */ -#ifndef LTC_NO_MODES - -#define LTC_CFB_MODE -#define LTC_OFB_MODE -#define LTC_ECB_MODE -#define LTC_CBC_MODE -#define LTC_CTR_MODE - -/* F8 chaining mode */ -#define LTC_F8_MODE - -/* LRW mode */ -#define LTC_LRW_MODE -#ifndef LTC_NO_TABLES - /* like GCM mode this will enable 16 8x128 tables [64KB] that make - * seeking very fast. - */ - #define LRW_TABLES -#endif - -/* XTS mode */ -#define LTC_XTS_MODE - -#endif /* LTC_NO_MODES */ - -/* ---> One-Way Hash Functions <--- */ -#ifndef LTC_NO_HASHES - -#define LTC_CHC_HASH -#define LTC_WHIRLPOOL -#define LTC_SHA512 -#define LTC_SHA384 -#define LTC_SHA256 -#define LTC_SHA224 -#define LTC_TIGER -#define LTC_SHA1 -#define LTC_MD5 -#define LTC_MD4 -#define LTC_MD2 -#define LTC_RIPEMD128 -#define LTC_RIPEMD160 -#define LTC_RIPEMD256 -#define LTC_RIPEMD320 - -#endif /* LTC_NO_HASHES */ - -/* ---> MAC functions <--- */ -#ifndef LTC_NO_MACS - -#define LTC_HMAC -#define LTC_OMAC -#define LTC_PMAC -#define LTC_XCBC -#define LTC_F9_MODE -#define LTC_PELICAN - -#if defined(LTC_PELICAN) && !defined(LTC_RIJNDAEL) - #error Pelican-MAC requires LTC_RIJNDAEL -#endif - -/* ---> Encrypt + Authenticate Modes <--- */ - -#define LTC_EAX_MODE -#if defined(LTC_EAX_MODE) && !(defined(LTC_CTR_MODE) && defined(LTC_OMAC)) - #error LTC_EAX_MODE requires CTR and LTC_OMAC mode -#endif - -#define LTC_OCB_MODE -#define LTC_CCM_MODE -#define LTC_GCM_MODE - -/* Use 64KiB tables */ -#ifndef LTC_NO_TABLES - #define LTC_GCM_TABLES -#endif - -/* USE SSE2? requires GCC works on x86_32 and x86_64*/ -#ifdef LTC_GCM_TABLES -/* #define LTC_GCM_TABLES_SSE2 */ -#endif - -#endif /* LTC_NO_MACS */ - -/* Various tidbits of modern neatoness */ -#define LTC_BASE64 - -/* --> Pseudo Random Number Generators <--- */ -#ifndef LTC_NO_PRNGS - -/* Yarrow */ -#define LTC_YARROW -/* which descriptor of AES to use? */ -/* 0 = rijndael_enc 1 = aes_enc, 2 = rijndael [full], 3 = aes [full] */ -#define LTC_YARROW_AES 0 - -#if defined(LTC_YARROW) && !defined(LTC_CTR_MODE) - #error LTC_YARROW requires LTC_CTR_MODE chaining mode to be defined! -#endif - -/* a PRNG that simply reads from an available system source */ -#define LTC_SPRNG - -/* The LTC_RC4 stream cipher */ -#define LTC_RC4 - -/* Fortuna PRNG */ -#define LTC_FORTUNA -/* reseed every N calls to the read function */ -#define LTC_FORTUNA_WD 10 -/* number of pools (4..32) can save a bit of ram by lowering the count */ -#define LTC_FORTUNA_POOLS 32 - -/* Greg's LTC_SOBER128 PRNG ;-0 */ -#define LTC_SOBER128 - -/* the *nix style /dev/random device */ -#define LTC_DEVRANDOM -/* try /dev/urandom before trying /dev/random */ -#define TRY_URANDOM_FIRST - -#endif /* LTC_NO_PRNGS */ - -/* ---> math provider? <--- */ -#ifndef LTC_NO_MATH - -/* LibTomMath */ -#define LTM_LTC_DESC - -/* TomsFastMath */ -//#define TFM_LTC_DESC - -#endif /* LTC_NO_MATH */ - -/* ---> Public Key Crypto <--- */ -#ifndef LTC_NO_PK - -/* Include RSA support */ -#define LTC_MRSA - -/* Include Katja (a Rabin variant like RSA) */ -/* #define MKAT */ - -/* Digital Signature Algorithm */ -#define LTC_MDSA - -/* ECC */ -#define LTC_MECC - -/* use Shamir's trick for point mul (speeds up signature verification) */ -#define LTC_ECC_SHAMIR - -#if defined(TFM_LTC_DESC) && defined(LTC_MECC) - #define LTC_MECC_ACCEL -#endif - -/* do we want fixed point ECC */ -/* #define LTC_MECC_FP */ - -/* Timing Resistant? */ -/* #define LTC_ECC_TIMING_RESISTANT */ - -#endif /* LTC_NO_PK */ - -/* LTC_PKCS #1 (RSA) and #5 (Password Handling) stuff */ -#ifndef LTC_NO_PKCS - -#define LTC_PKCS_1 -#define LTC_PKCS_5 - -/* Include ASN.1 DER (required by DSA/RSA) */ -#define LTC_DER - -#endif /* LTC_NO_PKCS */ - -/* cleanup */ - -#ifdef LTC_MECC -/* Supported ECC Key Sizes */ -#ifndef LTC_NO_CURVES - #define ECC112 - #define ECC128 - #define ECC160 - #define ECC192 - #define ECC224 - #define ECC256 - #define ECC384 - #define ECC521 -#endif -#endif - -#if defined(LTC_MECC) || defined(LTC_MRSA) || defined(LTC_MDSA) || defined(MKATJA) - /* Include the MPI functionality? (required by the PK algorithms) */ - #define MPI -#endif - -#ifdef LTC_MRSA - #define LTC_PKCS_1 -#endif - -#if defined(LTC_DER) && !defined(MPI) - #error ASN.1 DER requires MPI functionality -#endif - -#if (defined(LTC_MDSA) || defined(LTC_MRSA) || defined(LTC_MECC) || defined(MKATJA)) && !defined(LTC_DER) - #error PK requires ASN.1 DER functionality, make sure LTC_DER is enabled -#endif - -/* THREAD management */ -#ifdef LTC_PTHREAD - -#include - -#define LTC_MUTEX_GLOBAL(x) pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER; -#define LTC_MUTEX_PROTO(x) extern pthread_mutex_t x; -#define LTC_MUTEX_TYPE(x) pthread_mutex_t x; -#define LTC_MUTEX_INIT(x) pthread_mutex_init(x, NULL); -#define LTC_MUTEX_LOCK(x) pthread_mutex_lock(x); -#define LTC_MUTEX_UNLOCK(x) pthread_mutex_unlock(x); - -#else - -/* default no functions */ -#define LTC_MUTEX_GLOBAL(x) -#define LTC_MUTEX_PROTO(x) -#define LTC_MUTEX_TYPE(x) -#define LTC_MUTEX_INIT(x) -#define LTC_MUTEX_LOCK(x) -#define LTC_MUTEX_UNLOCK(x) - -#endif - -/* Debuggers */ - -/* define this if you use Valgrind, note: it CHANGES the way SOBER-128 and LTC_RC4 work (see the code) */ -/* #define LTC_VALGRIND */ - -#endif - - - -/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_custom.h,v $ */ -/* $Revision: 1.73 $ */ -/* $Date: 2007/05/12 14:37:41 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_hash.h b/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_hash.h deleted file mode 100644 index 18553eb..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_hash.h +++ /dev/null @@ -1,378 +0,0 @@ -/* ---- HASH FUNCTIONS ---- */ -#ifdef LTC_SHA512 -struct sha512_state { - ulong64 length, state[8]; - unsigned long curlen; - unsigned char buf[128]; -}; -#endif - -#ifdef LTC_SHA256 -struct sha256_state { - ulong64 length; - ulong32 state[8], curlen; - unsigned char buf[64]; -}; -#endif - -#ifdef LTC_SHA1 -struct sha1_state { - ulong64 length; - ulong32 state[5], curlen; - unsigned char buf[64]; -}; -#endif - -#ifdef LTC_MD5 -struct md5_state { - ulong64 length; - ulong32 state[4], curlen; - unsigned char buf[64]; -}; -#endif - -#ifdef LTC_MD4 -struct md4_state { - ulong64 length; - ulong32 state[4], curlen; - unsigned char buf[64]; -}; -#endif - -#ifdef LTC_TIGER -struct tiger_state { - ulong64 state[3], length; - unsigned long curlen; - unsigned char buf[64]; -}; -#endif - -#ifdef LTC_MD2 -struct md2_state { - unsigned char chksum[16], X[48], buf[16]; - unsigned long curlen; -}; -#endif - -#ifdef LTC_RIPEMD128 -struct rmd128_state { - ulong64 length; - unsigned char buf[64]; - ulong32 curlen, state[4]; -}; -#endif - -#ifdef LTC_RIPEMD160 -struct rmd160_state { - ulong64 length; - unsigned char buf[64]; - ulong32 curlen, state[5]; -}; -#endif - -#ifdef LTC_RIPEMD256 -struct rmd256_state { - ulong64 length; - unsigned char buf[64]; - ulong32 curlen, state[8]; -}; -#endif - -#ifdef LTC_RIPEMD320 -struct rmd320_state { - ulong64 length; - unsigned char buf[64]; - ulong32 curlen, state[10]; -}; -#endif - -#ifdef LTC_WHIRLPOOL -struct whirlpool_state { - ulong64 length, state[8]; - unsigned char buf[64]; - ulong32 curlen; -}; -#endif - -#ifdef LTC_CHC_HASH -struct chc_state { - ulong64 length; - unsigned char state[MAXBLOCKSIZE], buf[MAXBLOCKSIZE]; - ulong32 curlen; -}; -#endif - -typedef union Hash_state { -#ifdef LTC_CHC_HASH - struct chc_state chc; -#endif -#ifdef LTC_WHIRLPOOL - struct whirlpool_state whirlpool; -#endif -#ifdef LTC_SHA512 - struct sha512_state sha512; -#endif -#ifdef LTC_SHA256 - struct sha256_state sha256; -#endif -#ifdef LTC_SHA1 - struct sha1_state sha1; -#endif -#ifdef LTC_MD5 - struct md5_state md5; -#endif -#ifdef LTC_MD4 - struct md4_state md4; -#endif -#ifdef LTC_MD2 - struct md2_state md2; -#endif -#ifdef LTC_TIGER - struct tiger_state tiger; -#endif -#ifdef LTC_RIPEMD128 - struct rmd128_state rmd128; -#endif -#ifdef LTC_RIPEMD160 - struct rmd160_state rmd160; -#endif -#ifdef LTC_RIPEMD256 - struct rmd256_state rmd256; -#endif -#ifdef LTC_RIPEMD320 - struct rmd320_state rmd320; -#endif - void *data; -} hash_state; - -/** hash descriptor */ -extern struct ltc_hash_descriptor { - /** name of hash */ - char *name; - /** internal ID */ - unsigned char ID; - /** Size of digest in octets */ - unsigned long hashsize; - /** Input block size in octets */ - unsigned long blocksize; - /** ASN.1 OID */ - unsigned long OID[16]; - /** Length of DER encoding */ - unsigned long OIDlen; - - /** Init a hash state - @param hash The hash to initialize - @return CRYPT_OK if successful - */ - int (*init)(hash_state *hash); - /** Process a block of data - @param hash The hash state - @param in The data to hash - @param inlen The length of the data (octets) - @return CRYPT_OK if successful - */ - int (*process)(hash_state *hash, const unsigned char *in, unsigned long inlen); - /** Produce the digest and store it - @param hash The hash state - @param out [out] The destination of the digest - @return CRYPT_OK if successful - */ - int (*done)(hash_state *hash, unsigned char *out); - /** Self-test - @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled - */ - int (*test)(void); - - /* accelerated hmac callback: if you need to-do multiple packets just use the generic hmac_memory and provide a hash callback */ - int (*hmac_block)(const unsigned char *key, unsigned long keylen, - const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen); - -} hash_descriptor[]; - -#ifdef LTC_CHC_HASH -int chc_register(int cipher); -int chc_init(hash_state * md); -int chc_process(hash_state * md, const unsigned char *in, unsigned long inlen); -int chc_done(hash_state * md, unsigned char *hash); -int chc_test(void); -extern const struct ltc_hash_descriptor chc_desc; -#endif - -#ifdef LTC_WHIRLPOOL -int whirlpool_init(hash_state * md); -int whirlpool_process(hash_state * md, const unsigned char *in, unsigned long inlen); -int whirlpool_done(hash_state * md, unsigned char *hash); -int whirlpool_test(void); -extern const struct ltc_hash_descriptor whirlpool_desc; -#endif - -#ifdef LTC_SHA512 -int sha512_init(hash_state * md); -int sha512_process(hash_state * md, const unsigned char *in, unsigned long inlen); -int sha512_done(hash_state * md, unsigned char *hash); -int sha512_test(void); -extern const struct ltc_hash_descriptor sha512_desc; -#endif - -#ifdef LTC_SHA384 -#ifndef LTC_SHA512 - #error LTC_SHA512 is required for LTC_SHA384 -#endif -int sha384_init(hash_state * md); -#define sha384_process sha512_process -int sha384_done(hash_state * md, unsigned char *hash); -int sha384_test(void); -extern const struct ltc_hash_descriptor sha384_desc; -#endif - -#ifdef LTC_SHA256 -int sha256_init(hash_state * md); -int sha256_process(hash_state * md, const unsigned char *in, unsigned long inlen); -int sha256_done(hash_state * md, unsigned char *hash); -int sha256_test(void); -extern const struct ltc_hash_descriptor sha256_desc; - -#ifdef LTC_SHA224 -#ifndef LTC_SHA256 - #error LTC_SHA256 is required for LTC_SHA224 -#endif -int sha224_init(hash_state * md); -#define sha224_process sha256_process -int sha224_done(hash_state * md, unsigned char *hash); -int sha224_test(void); -extern const struct ltc_hash_descriptor sha224_desc; -#endif -#endif - -#ifdef LTC_SHA1 -int sha1_init(hash_state * md); -int sha1_process(hash_state * md, const unsigned char *in, unsigned long inlen); -int sha1_done(hash_state * md, unsigned char *hash); -int sha1_test(void); -extern const struct ltc_hash_descriptor sha1_desc; -#endif - -#ifdef LTC_MD5 -int md5_init(hash_state * md); -int md5_process(hash_state * md, const unsigned char *in, unsigned long inlen); -int md5_done(hash_state * md, unsigned char *hash); -int md5_test(void); -extern const struct ltc_hash_descriptor md5_desc; -#endif - -#ifdef LTC_MD4 -int md4_init(hash_state * md); -int md4_process(hash_state * md, const unsigned char *in, unsigned long inlen); -int md4_done(hash_state * md, unsigned char *hash); -int md4_test(void); -extern const struct ltc_hash_descriptor md4_desc; -#endif - -#ifdef LTC_MD2 -int md2_init(hash_state * md); -int md2_process(hash_state * md, const unsigned char *in, unsigned long inlen); -int md2_done(hash_state * md, unsigned char *hash); -int md2_test(void); -extern const struct ltc_hash_descriptor md2_desc; -#endif - -#ifdef LTC_TIGER -int tiger_init(hash_state * md); -int tiger_process(hash_state * md, const unsigned char *in, unsigned long inlen); -int tiger_done(hash_state * md, unsigned char *hash); -int tiger_test(void); -extern const struct ltc_hash_descriptor tiger_desc; -#endif - -#ifdef LTC_RIPEMD128 -int rmd128_init(hash_state * md); -int rmd128_process(hash_state * md, const unsigned char *in, unsigned long inlen); -int rmd128_done(hash_state * md, unsigned char *hash); -int rmd128_test(void); -extern const struct ltc_hash_descriptor rmd128_desc; -#endif - -#ifdef LTC_RIPEMD160 -int rmd160_init(hash_state * md); -int rmd160_process(hash_state * md, const unsigned char *in, unsigned long inlen); -int rmd160_done(hash_state * md, unsigned char *hash); -int rmd160_test(void); -extern const struct ltc_hash_descriptor rmd160_desc; -#endif - -#ifdef LTC_RIPEMD256 -int rmd256_init(hash_state * md); -int rmd256_process(hash_state * md, const unsigned char *in, unsigned long inlen); -int rmd256_done(hash_state * md, unsigned char *hash); -int rmd256_test(void); -extern const struct ltc_hash_descriptor rmd256_desc; -#endif - -#ifdef LTC_RIPEMD320 -int rmd320_init(hash_state * md); -int rmd320_process(hash_state * md, const unsigned char *in, unsigned long inlen); -int rmd320_done(hash_state * md, unsigned char *hash); -int rmd320_test(void); -extern const struct ltc_hash_descriptor rmd320_desc; -#endif - - -int find_hash(const char *name); -int find_hash_id(unsigned char ID); -int find_hash_oid(const unsigned long *ID, unsigned long IDlen); -int find_hash_any(const char *name, int digestlen); -int register_hash(const struct ltc_hash_descriptor *hash); -int unregister_hash(const struct ltc_hash_descriptor *hash); -int hash_is_valid(int idx); - -LTC_MUTEX_PROTO(ltc_hash_mutex) - -int hash_memory(int hash, - const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen); -int hash_memory_multi(int hash, unsigned char *out, unsigned long *outlen, - const unsigned char *in, unsigned long inlen, ...); -int hash_filehandle(int hash, FILE *in, unsigned char *out, unsigned long *outlen); -int hash_file(int hash, const char *fname, unsigned char *out, unsigned long *outlen); - -/* a simple macro for making hash "process" functions */ -#define HASH_PROCESS(func_name, compress_name, state_var, block_size) \ -int func_name (hash_state * md, const unsigned char *in, unsigned long inlen) \ -{ \ - unsigned long n; \ - int err; \ - LTC_ARGCHK(md != NULL); \ - LTC_ARGCHK(in != NULL); \ - if (md-> state_var .curlen > sizeof(md-> state_var .buf)) { \ - return CRYPT_INVALID_ARG; \ - } \ - while (inlen > 0) { \ - if (md-> state_var .curlen == 0 && inlen >= block_size) { \ - if ((err = compress_name (md, (unsigned char *)in)) != CRYPT_OK) { \ - return err; \ - } \ - md-> state_var .length += block_size * 8; \ - in += block_size; \ - inlen -= block_size; \ - } else { \ - n = MIN(inlen, (block_size - md-> state_var .curlen)); \ - memcpy(md-> state_var .buf + md-> state_var.curlen, in, (size_t)n); \ - md-> state_var .curlen += n; \ - in += n; \ - inlen -= n; \ - if (md-> state_var .curlen == block_size) { \ - if ((err = compress_name (md, md-> state_var .buf)) != CRYPT_OK) { \ - return err; \ - } \ - md-> state_var .length += 8*block_size; \ - md-> state_var .curlen = 0; \ - } \ - } \ - } \ - return CRYPT_OK; \ -} - -/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_hash.h,v $ */ -/* $Revision: 1.22 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_mac.h b/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_mac.h deleted file mode 100644 index 7ad9516..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_mac.h +++ /dev/null @@ -1,384 +0,0 @@ -#ifdef LTC_HMAC -typedef struct Hmac_state { - hash_state md; - int hash; - hash_state hashstate; - unsigned char *key; -} hmac_state; - -int hmac_init(hmac_state *hmac, int hash, const unsigned char *key, unsigned long keylen); -int hmac_process(hmac_state *hmac, const unsigned char *in, unsigned long inlen); -int hmac_done(hmac_state *hmac, unsigned char *out, unsigned long *outlen); -int hmac_test(void); -int hmac_memory(int hash, - const unsigned char *key, unsigned long keylen, - const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen); -int hmac_memory_multi(int hash, - const unsigned char *key, unsigned long keylen, - unsigned char *out, unsigned long *outlen, - const unsigned char *in, unsigned long inlen, ...); -int hmac_file(int hash, const char *fname, const unsigned char *key, - unsigned long keylen, - unsigned char *dst, unsigned long *dstlen); -#endif - -#ifdef LTC_OMAC - -typedef struct { - int cipher_idx, - buflen, - blklen; - unsigned char block[MAXBLOCKSIZE], - prev[MAXBLOCKSIZE], - Lu[2][MAXBLOCKSIZE]; - symmetric_key key; -} omac_state; - -int omac_init(omac_state *omac, int cipher, const unsigned char *key, unsigned long keylen); -int omac_process(omac_state *omac, const unsigned char *in, unsigned long inlen); -int omac_done(omac_state *omac, unsigned char *out, unsigned long *outlen); -int omac_memory(int cipher, - const unsigned char *key, unsigned long keylen, - const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen); -int omac_memory_multi(int cipher, - const unsigned char *key, unsigned long keylen, - unsigned char *out, unsigned long *outlen, - const unsigned char *in, unsigned long inlen, ...); -int omac_file(int cipher, - const unsigned char *key, unsigned long keylen, - const char *filename, - unsigned char *out, unsigned long *outlen); -int omac_test(void); -#endif /* LTC_OMAC */ - -#ifdef LTC_PMAC - -typedef struct { - unsigned char Ls[32][MAXBLOCKSIZE], /* L shifted by i bits to the left */ - Li[MAXBLOCKSIZE], /* value of Li [current value, we calc from previous recall] */ - Lr[MAXBLOCKSIZE], /* L * x^-1 */ - block[MAXBLOCKSIZE], /* currently accumulated block */ - checksum[MAXBLOCKSIZE]; /* current checksum */ - - symmetric_key key; /* scheduled key for cipher */ - unsigned long block_index; /* index # for current block */ - int cipher_idx, /* cipher idx */ - block_len, /* length of block */ - buflen; /* number of bytes in the buffer */ -} pmac_state; - -int pmac_init(pmac_state *pmac, int cipher, const unsigned char *key, unsigned long keylen); -int pmac_process(pmac_state *pmac, const unsigned char *in, unsigned long inlen); -int pmac_done(pmac_state *pmac, unsigned char *out, unsigned long *outlen); - -int pmac_memory(int cipher, - const unsigned char *key, unsigned long keylen, - const unsigned char *msg, unsigned long msglen, - unsigned char *out, unsigned long *outlen); - -int pmac_memory_multi(int cipher, - const unsigned char *key, unsigned long keylen, - unsigned char *out, unsigned long *outlen, - const unsigned char *in, unsigned long inlen, ...); - -int pmac_file(int cipher, - const unsigned char *key, unsigned long keylen, - const char *filename, - unsigned char *out, unsigned long *outlen); - -int pmac_test(void); - -/* internal functions */ -int pmac_ntz(unsigned long x); -void pmac_shift_xor(pmac_state *pmac); - -#endif /* PMAC */ - -#ifdef LTC_EAX_MODE - -#if !(defined(LTC_OMAC) && defined(LTC_CTR_MODE)) - #error LTC_EAX_MODE requires LTC_OMAC and CTR -#endif - -typedef struct { - unsigned char N[MAXBLOCKSIZE]; - symmetric_CTR ctr; - omac_state headeromac, ctomac; -} eax_state; - -int eax_init(eax_state *eax, int cipher, const unsigned char *key, unsigned long keylen, - const unsigned char *nonce, unsigned long noncelen, - const unsigned char *header, unsigned long headerlen); - -int eax_encrypt(eax_state *eax, const unsigned char *pt, unsigned char *ct, unsigned long length); -int eax_decrypt(eax_state *eax, const unsigned char *ct, unsigned char *pt, unsigned long length); -int eax_addheader(eax_state *eax, const unsigned char *header, unsigned long length); -int eax_done(eax_state *eax, unsigned char *tag, unsigned long *taglen); - -int eax_encrypt_authenticate_memory(int cipher, - const unsigned char *key, unsigned long keylen, - const unsigned char *nonce, unsigned long noncelen, - const unsigned char *header, unsigned long headerlen, - const unsigned char *pt, unsigned long ptlen, - unsigned char *ct, - unsigned char *tag, unsigned long *taglen); - -int eax_decrypt_verify_memory(int cipher, - const unsigned char *key, unsigned long keylen, - const unsigned char *nonce, unsigned long noncelen, - const unsigned char *header, unsigned long headerlen, - const unsigned char *ct, unsigned long ctlen, - unsigned char *pt, - unsigned char *tag, unsigned long taglen, - int *stat); - - int eax_test(void); -#endif /* EAX MODE */ - -#ifdef LTC_OCB_MODE -typedef struct { - unsigned char L[MAXBLOCKSIZE], /* L value */ - Ls[32][MAXBLOCKSIZE], /* L shifted by i bits to the left */ - Li[MAXBLOCKSIZE], /* value of Li [current value, we calc from previous recall] */ - Lr[MAXBLOCKSIZE], /* L * x^-1 */ - R[MAXBLOCKSIZE], /* R value */ - checksum[MAXBLOCKSIZE]; /* current checksum */ - - symmetric_key key; /* scheduled key for cipher */ - unsigned long block_index; /* index # for current block */ - int cipher, /* cipher idx */ - block_len; /* length of block */ -} ocb_state; - -int ocb_init(ocb_state *ocb, int cipher, - const unsigned char *key, unsigned long keylen, const unsigned char *nonce); - -int ocb_encrypt(ocb_state *ocb, const unsigned char *pt, unsigned char *ct); -int ocb_decrypt(ocb_state *ocb, const unsigned char *ct, unsigned char *pt); - -int ocb_done_encrypt(ocb_state *ocb, - const unsigned char *pt, unsigned long ptlen, - unsigned char *ct, - unsigned char *tag, unsigned long *taglen); - -int ocb_done_decrypt(ocb_state *ocb, - const unsigned char *ct, unsigned long ctlen, - unsigned char *pt, - const unsigned char *tag, unsigned long taglen, int *stat); - -int ocb_encrypt_authenticate_memory(int cipher, - const unsigned char *key, unsigned long keylen, - const unsigned char *nonce, - const unsigned char *pt, unsigned long ptlen, - unsigned char *ct, - unsigned char *tag, unsigned long *taglen); - -int ocb_decrypt_verify_memory(int cipher, - const unsigned char *key, unsigned long keylen, - const unsigned char *nonce, - const unsigned char *ct, unsigned long ctlen, - unsigned char *pt, - const unsigned char *tag, unsigned long taglen, - int *stat); - -int ocb_test(void); - -/* internal functions */ -void ocb_shift_xor(ocb_state *ocb, unsigned char *Z); -int ocb_ntz(unsigned long x); -int s_ocb_done(ocb_state *ocb, const unsigned char *pt, unsigned long ptlen, - unsigned char *ct, unsigned char *tag, unsigned long *taglen, int mode); - -#endif /* LTC_OCB_MODE */ - -#ifdef LTC_CCM_MODE - -#define CCM_ENCRYPT 0 -#define CCM_DECRYPT 1 - -int ccm_memory(int cipher, - const unsigned char *key, unsigned long keylen, - symmetric_key *uskey, - const unsigned char *nonce, unsigned long noncelen, - const unsigned char *header, unsigned long headerlen, - unsigned char *pt, unsigned long ptlen, - unsigned char *ct, - unsigned char *tag, unsigned long *taglen, - int direction); - -int ccm_test(void); - -#endif /* LTC_CCM_MODE */ - -#if defined(LRW_MODE) || defined(LTC_GCM_MODE) -void gcm_gf_mult(const unsigned char *a, const unsigned char *b, unsigned char *c); -#endif - - -/* table shared between GCM and LRW */ -#if defined(LTC_GCM_TABLES) || defined(LRW_TABLES) || ((defined(LTC_GCM_MODE) || defined(LTC_GCM_MODE)) && defined(LTC_FAST)) -extern const unsigned char gcm_shift_table[]; -#endif - -#ifdef LTC_GCM_MODE - -#define GCM_ENCRYPT 0 -#define GCM_DECRYPT 1 - -#define LTC_GCM_MODE_IV 0 -#define LTC_GCM_MODE_AAD 1 -#define LTC_GCM_MODE_TEXT 2 - -typedef struct { - symmetric_key K; - unsigned char H[16], /* multiplier */ - X[16], /* accumulator */ - Y[16], /* counter */ - Y_0[16], /* initial counter */ - buf[16]; /* buffer for stuff */ - - int cipher, /* which cipher */ - ivmode, /* Which mode is the IV in? */ - mode, /* mode the GCM code is in */ - buflen; /* length of data in buf */ - - ulong64 totlen, /* 64-bit counter used for IV and AAD */ - pttotlen; /* 64-bit counter for the PT */ - -#ifdef LTC_GCM_TABLES - unsigned char PC[16][256][16] /* 16 tables of 8x128 */ -#ifdef LTC_GCM_TABLES_SSE2 -__attribute__ ((aligned (16))) -#endif -; -#endif -} gcm_state; - -void gcm_mult_h(gcm_state *gcm, unsigned char *I); - -int gcm_init(gcm_state *gcm, int cipher, - const unsigned char *key, int keylen); - -int gcm_reset(gcm_state *gcm); - -int gcm_add_iv(gcm_state *gcm, - const unsigned char *IV, unsigned long IVlen); - -int gcm_add_aad(gcm_state *gcm, - const unsigned char *adata, unsigned long adatalen); - -int gcm_process(gcm_state *gcm, - unsigned char *pt, unsigned long ptlen, - unsigned char *ct, - int direction); - -int gcm_done(gcm_state *gcm, - unsigned char *tag, unsigned long *taglen); - -int gcm_memory( int cipher, - const unsigned char *key, unsigned long keylen, - const unsigned char *IV, unsigned long IVlen, - const unsigned char *adata, unsigned long adatalen, - unsigned char *pt, unsigned long ptlen, - unsigned char *ct, - unsigned char *tag, unsigned long *taglen, - int direction); -int gcm_test(void); - -#endif /* LTC_GCM_MODE */ - -#ifdef LTC_PELICAN - -typedef struct pelican_state -{ - symmetric_key K; - unsigned char state[16]; - int buflen; -} pelican_state; - -int pelican_init(pelican_state *pelmac, const unsigned char *key, unsigned long keylen); -int pelican_process(pelican_state *pelmac, const unsigned char *in, unsigned long inlen); -int pelican_done(pelican_state *pelmac, unsigned char *out); -int pelican_test(void); - -int pelican_memory(const unsigned char *key, unsigned long keylen, - const unsigned char *in, unsigned long inlen, - unsigned char *out); - -#endif - -#ifdef LTC_XCBC - -/* add this to "keylen" to xcbc_init to use a pure three-key XCBC MAC */ -#define LTC_XCBC_PURE 0x8000UL - -typedef struct { - unsigned char K[3][MAXBLOCKSIZE], - IV[MAXBLOCKSIZE]; - - symmetric_key key; - - int cipher, - buflen, - blocksize; -} xcbc_state; - -int xcbc_init(xcbc_state *xcbc, int cipher, const unsigned char *key, unsigned long keylen); -int xcbc_process(xcbc_state *xcbc, const unsigned char *in, unsigned long inlen); -int xcbc_done(xcbc_state *xcbc, unsigned char *out, unsigned long *outlen); -int xcbc_memory(int cipher, - const unsigned char *key, unsigned long keylen, - const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen); -int xcbc_memory_multi(int cipher, - const unsigned char *key, unsigned long keylen, - unsigned char *out, unsigned long *outlen, - const unsigned char *in, unsigned long inlen, ...); -int xcbc_file(int cipher, - const unsigned char *key, unsigned long keylen, - const char *filename, - unsigned char *out, unsigned long *outlen); -int xcbc_test(void); - -#endif - -#ifdef LTC_F9_MODE - -typedef struct { - unsigned char akey[MAXBLOCKSIZE], - ACC[MAXBLOCKSIZE], - IV[MAXBLOCKSIZE]; - - symmetric_key key; - - int cipher, - buflen, - keylen, - blocksize; -} f9_state; - -int f9_init(f9_state *f9, int cipher, const unsigned char *key, unsigned long keylen); -int f9_process(f9_state *f9, const unsigned char *in, unsigned long inlen); -int f9_done(f9_state *f9, unsigned char *out, unsigned long *outlen); -int f9_memory(int cipher, - const unsigned char *key, unsigned long keylen, - const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen); -int f9_memory_multi(int cipher, - const unsigned char *key, unsigned long keylen, - unsigned char *out, unsigned long *outlen, - const unsigned char *in, unsigned long inlen, ...); -int f9_file(int cipher, - const unsigned char *key, unsigned long keylen, - const char *filename, - unsigned char *out, unsigned long *outlen); -int f9_test(void); - -#endif - - -/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_mac.h,v $ */ -/* $Revision: 1.23 $ */ -/* $Date: 2007/05/12 14:37:41 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_macros.h b/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_macros.h deleted file mode 100644 index 53bda9b..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_macros.h +++ /dev/null @@ -1,424 +0,0 @@ -/* fix for MSVC ...evil! */ -#ifdef _MSC_VER - #define CONST64(n) n ## ui64 - typedef unsigned __int64 ulong64; -#else - #define CONST64(n) n ## ULL - typedef unsigned long long ulong64; -#endif - -/* this is the "32-bit at least" data type - * Re-define it to suit your platform but it must be at least 32-bits - */ -#if defined(__x86_64__) || (defined(__sparc__) && defined(__arch64__)) - typedef unsigned ulong32; -#else - typedef unsigned long ulong32; -#endif - -/* ---- HELPER MACROS ---- */ -#ifdef ENDIAN_NEUTRAL - -#define STORE32L(x, y) \ - { (y)[3] = (unsigned char)(((x)>>24)&255); (y)[2] = (unsigned char)(((x)>>16)&255); \ - (y)[1] = (unsigned char)(((x)>>8)&255); (y)[0] = (unsigned char)((x)&255); } - -#define LOAD32L(x, y) \ - { x = ((unsigned long)((y)[3] & 255)<<24) | \ - ((unsigned long)((y)[2] & 255)<<16) | \ - ((unsigned long)((y)[1] & 255)<<8) | \ - ((unsigned long)((y)[0] & 255)); } - -#define STORE64L(x, y) \ - { (y)[7] = (unsigned char)(((x)>>56)&255); (y)[6] = (unsigned char)(((x)>>48)&255); \ - (y)[5] = (unsigned char)(((x)>>40)&255); (y)[4] = (unsigned char)(((x)>>32)&255); \ - (y)[3] = (unsigned char)(((x)>>24)&255); (y)[2] = (unsigned char)(((x)>>16)&255); \ - (y)[1] = (unsigned char)(((x)>>8)&255); (y)[0] = (unsigned char)((x)&255); } - -#define LOAD64L(x, y) \ - { x = (((ulong64)((y)[7] & 255))<<56)|(((ulong64)((y)[6] & 255))<<48)| \ - (((ulong64)((y)[5] & 255))<<40)|(((ulong64)((y)[4] & 255))<<32)| \ - (((ulong64)((y)[3] & 255))<<24)|(((ulong64)((y)[2] & 255))<<16)| \ - (((ulong64)((y)[1] & 255))<<8)|(((ulong64)((y)[0] & 255))); } - -#define STORE32H(x, y) \ - { (y)[0] = (unsigned char)(((x)>>24)&255); (y)[1] = (unsigned char)(((x)>>16)&255); \ - (y)[2] = (unsigned char)(((x)>>8)&255); (y)[3] = (unsigned char)((x)&255); } - -#define LOAD32H(x, y) \ - { x = ((unsigned long)((y)[0] & 255)<<24) | \ - ((unsigned long)((y)[1] & 255)<<16) | \ - ((unsigned long)((y)[2] & 255)<<8) | \ - ((unsigned long)((y)[3] & 255)); } - -#define STORE64H(x, y) \ - { (y)[0] = (unsigned char)(((x)>>56)&255); (y)[1] = (unsigned char)(((x)>>48)&255); \ - (y)[2] = (unsigned char)(((x)>>40)&255); (y)[3] = (unsigned char)(((x)>>32)&255); \ - (y)[4] = (unsigned char)(((x)>>24)&255); (y)[5] = (unsigned char)(((x)>>16)&255); \ - (y)[6] = (unsigned char)(((x)>>8)&255); (y)[7] = (unsigned char)((x)&255); } - -#define LOAD64H(x, y) \ - { x = (((ulong64)((y)[0] & 255))<<56)|(((ulong64)((y)[1] & 255))<<48) | \ - (((ulong64)((y)[2] & 255))<<40)|(((ulong64)((y)[3] & 255))<<32) | \ - (((ulong64)((y)[4] & 255))<<24)|(((ulong64)((y)[5] & 255))<<16) | \ - (((ulong64)((y)[6] & 255))<<8)|(((ulong64)((y)[7] & 255))); } - -#endif /* ENDIAN_NEUTRAL */ - -#ifdef ENDIAN_LITTLE - -#if !defined(LTC_NO_BSWAP) && (defined(INTEL_CC) || (defined(__GNUC__) && (defined(__DJGPP__) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__i386__) || defined(__x86_64__)))) - -#define STORE32H(x, y) \ -asm __volatile__ ( \ - "bswapl %0 \n\t" \ - "movl %0,(%1)\n\t" \ - "bswapl %0 \n\t" \ - ::"r"(x), "r"(y)); - -#define LOAD32H(x, y) \ -asm __volatile__ ( \ - "movl (%1),%0\n\t" \ - "bswapl %0\n\t" \ - :"=r"(x): "r"(y)); - -#else - -#define STORE32H(x, y) \ - { (y)[0] = (unsigned char)(((x)>>24)&255); (y)[1] = (unsigned char)(((x)>>16)&255); \ - (y)[2] = (unsigned char)(((x)>>8)&255); (y)[3] = (unsigned char)((x)&255); } - -#define LOAD32H(x, y) \ - { x = ((unsigned long)((y)[0] & 255)<<24) | \ - ((unsigned long)((y)[1] & 255)<<16) | \ - ((unsigned long)((y)[2] & 255)<<8) | \ - ((unsigned long)((y)[3] & 255)); } - -#endif - - -/* x86_64 processor */ -#if !defined(LTC_NO_BSWAP) && (defined(__GNUC__) && defined(__x86_64__)) - -#define STORE64H(x, y) \ -asm __volatile__ ( \ - "bswapq %0 \n\t" \ - "movq %0,(%1)\n\t" \ - "bswapq %0 \n\t" \ - ::"r"(x), "r"(y)); - -#define LOAD64H(x, y) \ -asm __volatile__ ( \ - "movq (%1),%0\n\t" \ - "bswapq %0\n\t" \ - :"=r"(x): "r"(y)); - -#else - -#define STORE64H(x, y) \ - { (y)[0] = (unsigned char)(((x)>>56)&255); (y)[1] = (unsigned char)(((x)>>48)&255); \ - (y)[2] = (unsigned char)(((x)>>40)&255); (y)[3] = (unsigned char)(((x)>>32)&255); \ - (y)[4] = (unsigned char)(((x)>>24)&255); (y)[5] = (unsigned char)(((x)>>16)&255); \ - (y)[6] = (unsigned char)(((x)>>8)&255); (y)[7] = (unsigned char)((x)&255); } - -#define LOAD64H(x, y) \ - { x = (((ulong64)((y)[0] & 255))<<56)|(((ulong64)((y)[1] & 255))<<48) | \ - (((ulong64)((y)[2] & 255))<<40)|(((ulong64)((y)[3] & 255))<<32) | \ - (((ulong64)((y)[4] & 255))<<24)|(((ulong64)((y)[5] & 255))<<16) | \ - (((ulong64)((y)[6] & 255))<<8)|(((ulong64)((y)[7] & 255))); } - -#endif - -#ifdef ENDIAN_32BITWORD - -#define STORE32L(x, y) \ - { ulong32 __t = (x); XMEMCPY(y, &__t, 4); } - -#define LOAD32L(x, y) \ - XMEMCPY(&(x), y, 4); - -#define STORE64L(x, y) \ - { (y)[7] = (unsigned char)(((x)>>56)&255); (y)[6] = (unsigned char)(((x)>>48)&255); \ - (y)[5] = (unsigned char)(((x)>>40)&255); (y)[4] = (unsigned char)(((x)>>32)&255); \ - (y)[3] = (unsigned char)(((x)>>24)&255); (y)[2] = (unsigned char)(((x)>>16)&255); \ - (y)[1] = (unsigned char)(((x)>>8)&255); (y)[0] = (unsigned char)((x)&255); } - -#define LOAD64L(x, y) \ - { x = (((ulong64)((y)[7] & 255))<<56)|(((ulong64)((y)[6] & 255))<<48)| \ - (((ulong64)((y)[5] & 255))<<40)|(((ulong64)((y)[4] & 255))<<32)| \ - (((ulong64)((y)[3] & 255))<<24)|(((ulong64)((y)[2] & 255))<<16)| \ - (((ulong64)((y)[1] & 255))<<8)|(((ulong64)((y)[0] & 255))); } - -#else /* 64-bit words then */ - -#define STORE32L(x, y) \ - { ulong32 __t = (x); XMEMCPY(y, &__t, 4); } - -#define LOAD32L(x, y) \ - { XMEMCPY(&(x), y, 4); x &= 0xFFFFFFFF; } - -#define STORE64L(x, y) \ - { ulong64 __t = (x); XMEMCPY(y, &__t, 8); } - -#define LOAD64L(x, y) \ - { XMEMCPY(&(x), y, 8); } - -#endif /* ENDIAN_64BITWORD */ - -#endif /* ENDIAN_LITTLE */ - -#ifdef ENDIAN_BIG -#define STORE32L(x, y) \ - { (y)[3] = (unsigned char)(((x)>>24)&255); (y)[2] = (unsigned char)(((x)>>16)&255); \ - (y)[1] = (unsigned char)(((x)>>8)&255); (y)[0] = (unsigned char)((x)&255); } - -#define LOAD32L(x, y) \ - { x = ((unsigned long)((y)[3] & 255)<<24) | \ - ((unsigned long)((y)[2] & 255)<<16) | \ - ((unsigned long)((y)[1] & 255)<<8) | \ - ((unsigned long)((y)[0] & 255)); } - -#define STORE64L(x, y) \ - { (y)[7] = (unsigned char)(((x)>>56)&255); (y)[6] = (unsigned char)(((x)>>48)&255); \ - (y)[5] = (unsigned char)(((x)>>40)&255); (y)[4] = (unsigned char)(((x)>>32)&255); \ - (y)[3] = (unsigned char)(((x)>>24)&255); (y)[2] = (unsigned char)(((x)>>16)&255); \ - (y)[1] = (unsigned char)(((x)>>8)&255); (y)[0] = (unsigned char)((x)&255); } - -#define LOAD64L(x, y) \ - { x = (((ulong64)((y)[7] & 255))<<56)|(((ulong64)((y)[6] & 255))<<48) | \ - (((ulong64)((y)[5] & 255))<<40)|(((ulong64)((y)[4] & 255))<<32) | \ - (((ulong64)((y)[3] & 255))<<24)|(((ulong64)((y)[2] & 255))<<16) | \ - (((ulong64)((y)[1] & 255))<<8)|(((ulong64)((y)[0] & 255))); } - -#ifdef ENDIAN_32BITWORD - -#define STORE32H(x, y) \ - { ulong32 __t = (x); XMEMCPY(y, &__t, 4); } - -#define LOAD32H(x, y) \ - XMEMCPY(&(x), y, 4); - -#define STORE64H(x, y) \ - { (y)[0] = (unsigned char)(((x)>>56)&255); (y)[1] = (unsigned char)(((x)>>48)&255); \ - (y)[2] = (unsigned char)(((x)>>40)&255); (y)[3] = (unsigned char)(((x)>>32)&255); \ - (y)[4] = (unsigned char)(((x)>>24)&255); (y)[5] = (unsigned char)(((x)>>16)&255); \ - (y)[6] = (unsigned char)(((x)>>8)&255); (y)[7] = (unsigned char)((x)&255); } - -#define LOAD64H(x, y) \ - { x = (((ulong64)((y)[0] & 255))<<56)|(((ulong64)((y)[1] & 255))<<48)| \ - (((ulong64)((y)[2] & 255))<<40)|(((ulong64)((y)[3] & 255))<<32)| \ - (((ulong64)((y)[4] & 255))<<24)|(((ulong64)((y)[5] & 255))<<16)| \ - (((ulong64)((y)[6] & 255))<<8)| (((ulong64)((y)[7] & 255))); } - -#else /* 64-bit words then */ - -#define STORE32H(x, y) \ - { ulong32 __t = (x); XMEMCPY(y, &__t, 4); } - -#define LOAD32H(x, y) \ - { XMEMCPY(&(x), y, 4); x &= 0xFFFFFFFF; } - -#define STORE64H(x, y) \ - { ulong64 __t = (x); XMEMCPY(y, &__t, 8); } - -#define LOAD64H(x, y) \ - { XMEMCPY(&(x), y, 8); } - -#endif /* ENDIAN_64BITWORD */ -#endif /* ENDIAN_BIG */ - -#define BSWAP(x) ( ((x>>24)&0x000000FFUL) | ((x<<24)&0xFF000000UL) | \ - ((x>>8)&0x0000FF00UL) | ((x<<8)&0x00FF0000UL) ) - - -/* 32-bit Rotates */ -#if defined(_MSC_VER) - -/* instrinsic rotate */ -#include -#pragma intrinsic(_lrotr,_lrotl) -#define ROR(x,n) _lrotr(x,n) -#define ROL(x,n) _lrotl(x,n) -#define RORc(x,n) _lrotr(x,n) -#define ROLc(x,n) _lrotl(x,n) - -#elif !defined(__STRICT_ANSI__) && defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) && !defined(INTEL_CC) && !defined(LTC_NO_ASM) - -static inline unsigned ROL(unsigned word, int i) -{ - asm ("roll %%cl,%0" - :"=r" (word) - :"0" (word),"c" (i)); - return word; -} - -static inline unsigned ROR(unsigned word, int i) -{ - asm ("rorl %%cl,%0" - :"=r" (word) - :"0" (word),"c" (i)); - return word; -} - -#ifndef LTC_NO_ROLC - -static inline unsigned ROLc(unsigned word, const int i) -{ - asm ("roll %2,%0" - :"=r" (word) - :"0" (word),"I" (i)); - return word; -} - -static inline unsigned RORc(unsigned word, const int i) -{ - asm ("rorl %2,%0" - :"=r" (word) - :"0" (word),"I" (i)); - return word; -} - -#else - -#define ROLc ROL -#define RORc ROR - -#endif - -#elif !defined(__STRICT_ANSI__) && defined(LTC_PPC32) - -static inline unsigned ROL(unsigned word, int i) -{ - asm ("rotlw %0,%0,%2" - :"=r" (word) - :"0" (word),"r" (i)); - return word; -} - -static inline unsigned ROR(unsigned word, int i) -{ - asm ("rotlw %0,%0,%2" - :"=r" (word) - :"0" (word),"r" (32-i)); - return word; -} - -#ifndef LTC_NO_ROLC - -static inline unsigned ROLc(unsigned word, const int i) -{ - asm ("rotlwi %0,%0,%2" - :"=r" (word) - :"0" (word),"I" (i)); - return word; -} - -static inline unsigned RORc(unsigned word, const int i) -{ - asm ("rotrwi %0,%0,%2" - :"=r" (word) - :"0" (word),"I" (i)); - return word; -} - -#else - -#define ROLc ROL -#define RORc ROR - -#endif - - -#else - -/* rotates the hard way */ -#define ROL(x, y) ( (((unsigned long)(x)<<(unsigned long)((y)&31)) | (((unsigned long)(x)&0xFFFFFFFFUL)>>(unsigned long)(32-((y)&31)))) & 0xFFFFFFFFUL) -#define ROR(x, y) ( ((((unsigned long)(x)&0xFFFFFFFFUL)>>(unsigned long)((y)&31)) | ((unsigned long)(x)<<(unsigned long)(32-((y)&31)))) & 0xFFFFFFFFUL) -#define ROLc(x, y) ( (((unsigned long)(x)<<(unsigned long)((y)&31)) | (((unsigned long)(x)&0xFFFFFFFFUL)>>(unsigned long)(32-((y)&31)))) & 0xFFFFFFFFUL) -#define RORc(x, y) ( ((((unsigned long)(x)&0xFFFFFFFFUL)>>(unsigned long)((y)&31)) | ((unsigned long)(x)<<(unsigned long)(32-((y)&31)))) & 0xFFFFFFFFUL) - -#endif - - -/* 64-bit Rotates */ -#if !defined(__STRICT_ANSI__) && defined(__GNUC__) && defined(__x86_64__) && !defined(LTC_NO_ASM) - -static inline unsigned long ROL64(unsigned long word, int i) -{ - asm("rolq %%cl,%0" - :"=r" (word) - :"0" (word),"c" (i)); - return word; -} - -static inline unsigned long ROR64(unsigned long word, int i) -{ - asm("rorq %%cl,%0" - :"=r" (word) - :"0" (word),"c" (i)); - return word; -} - -#ifndef LTC_NO_ROLC - -static inline unsigned long ROL64c(unsigned long word, const int i) -{ - asm("rolq %2,%0" - :"=r" (word) - :"0" (word),"J" (i)); - return word; -} - -static inline unsigned long ROR64c(unsigned long word, const int i) -{ - asm("rorq %2,%0" - :"=r" (word) - :"0" (word),"J" (i)); - return word; -} - -#else /* LTC_NO_ROLC */ - -#define ROL64c ROL64 -#define ROR64c ROR64 - -#endif - -#else /* Not x86_64 */ - -#define ROL64(x, y) \ - ( (((x)<<((ulong64)(y)&63)) | \ - (((x)&CONST64(0xFFFFFFFFFFFFFFFF))>>((ulong64)64-((y)&63)))) & CONST64(0xFFFFFFFFFFFFFFFF)) - -#define ROR64(x, y) \ - ( ((((x)&CONST64(0xFFFFFFFFFFFFFFFF))>>((ulong64)(y)&CONST64(63))) | \ - ((x)<<((ulong64)(64-((y)&CONST64(63)))))) & CONST64(0xFFFFFFFFFFFFFFFF)) - -#define ROL64c(x, y) \ - ( (((x)<<((ulong64)(y)&63)) | \ - (((x)&CONST64(0xFFFFFFFFFFFFFFFF))>>((ulong64)64-((y)&63)))) & CONST64(0xFFFFFFFFFFFFFFFF)) - -#define ROR64c(x, y) \ - ( ((((x)&CONST64(0xFFFFFFFFFFFFFFFF))>>((ulong64)(y)&CONST64(63))) | \ - ((x)<<((ulong64)(64-((y)&CONST64(63)))))) & CONST64(0xFFFFFFFFFFFFFFFF)) - -#endif - -#ifndef MAX - #define MAX(x, y) ( ((x)>(y))?(x):(y) ) -#endif - -#ifndef MIN - #define MIN(x, y) ( ((x)<(y))?(x):(y) ) -#endif - -/* extract a byte portably */ -#ifdef _MSC_VER - #define byte(x, n) ((unsigned char)((x) >> (8 * (n)))) -#else - #define byte(x, n) (((x) >> (8 * (n))) & 255) -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_macros.h,v $ */ -/* $Revision: 1.15 $ */ -/* $Date: 2006/11/29 23:43:57 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_math.h b/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_math.h deleted file mode 100644 index a05d7ff..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_math.h +++ /dev/null @@ -1,500 +0,0 @@ -/** math functions **/ - -#define LTC_MP_LT -1 -#define LTC_MP_EQ 0 -#define LTC_MP_GT 1 - -#define LTC_MP_NO 0 -#define LTC_MP_YES 1 - -#ifndef LTC_MECC - typedef void ecc_point; -#endif - -#ifndef LTC_MRSA - typedef void rsa_key; -#endif - -/** math descriptor */ -typedef struct { - /** Name of the math provider */ - char *name; - - /** Bits per digit, amount of bits must fit in an unsigned long */ - int bits_per_digit; - -/* ---- init/deinit functions ---- */ - - /** initialize a bignum - @param a The number to initialize - @return CRYPT_OK on success - */ - int (*init)(void **a); - - /** init copy - @param dst The number to initialize and write to - @param src The number to copy from - @return CRYPT_OK on success - */ - int (*init_copy)(void **dst, void *src); - - /** deinit - @param a The number to free - @return CRYPT_OK on success - */ - void (*deinit)(void *a); - -/* ---- data movement ---- */ - - /** negate - @param src The number to negate - @param dst The destination - @return CRYPT_OK on success - */ - int (*neg)(void *src, void *dst); - - /** copy - @param src The number to copy from - @param dst The number to write to - @return CRYPT_OK on success - */ - int (*copy)(void *src, void *dst); - -/* ---- trivial low level functions ---- */ - - /** set small constant - @param a Number to write to - @param n Source upto bits_per_digit (actually meant for very small constants) - @return CRYPT_OK on succcess - */ - int (*set_int)(void *a, unsigned long n); - - /** get small constant - @param a Number to read, only fetches upto bits_per_digit from the number - @return The lower bits_per_digit of the integer (unsigned) - */ - unsigned long (*get_int)(void *a); - - /** get digit n - @param a The number to read from - @param n The number of the digit to fetch - @return The bits_per_digit sized n'th digit of a - */ - unsigned long (*get_digit)(void *a, int n); - - /** Get the number of digits that represent the number - @param a The number to count - @return The number of digits used to represent the number - */ - int (*get_digit_count)(void *a); - - /** compare two integers - @param a The left side integer - @param b The right side integer - @return LTC_MP_LT if a < b, LTC_MP_GT if a > b and LTC_MP_EQ otherwise. (signed comparison) - */ - int (*compare)(void *a, void *b); - - /** compare against int - @param a The left side integer - @param b The right side integer (upto bits_per_digit) - @return LTC_MP_LT if a < b, LTC_MP_GT if a > b and LTC_MP_EQ otherwise. (signed comparison) - */ - int (*compare_d)(void *a, unsigned long n); - - /** Count the number of bits used to represent the integer - @param a The integer to count - @return The number of bits required to represent the integer - */ - int (*count_bits)(void * a); - - /** Count the number of LSB bits which are zero - @param a The integer to count - @return The number of contiguous zero LSB bits - */ - int (*count_lsb_bits)(void *a); - - /** Compute a power of two - @param a The integer to store the power in - @param n The power of two you want to store (a = 2^n) - @return CRYPT_OK on success - */ - int (*twoexpt)(void *a , int n); - -/* ---- radix conversions ---- */ - - /** read ascii string - @param a The integer to store into - @param str The string to read - @param radix The radix the integer has been represented in (2-64) - @return CRYPT_OK on success - */ - int (*read_radix)(void *a, const char *str, int radix); - - /** write number to string - @param a The integer to store - @param str The destination for the string - @param radix The radix the integer is to be represented in (2-64) - @return CRYPT_OK on success - */ - int (*write_radix)(void *a, char *str, int radix); - - /** get size as unsigned char string - @param a The integer to get the size (when stored in array of octets) - @return The length of the integer - */ - unsigned long (*unsigned_size)(void *a); - - /** store an integer as an array of octets - @param src The integer to store - @param dst The buffer to store the integer in - @return CRYPT_OK on success - */ - int (*unsigned_write)(void *src, unsigned char *dst); - - /** read an array of octets and store as integer - @param dst The integer to load - @param src The array of octets - @param len The number of octets - @return CRYPT_OK on success - */ - int (*unsigned_read)(void *dst, unsigned char *src, unsigned long len); - -/* ---- basic math ---- */ - - /** add two integers - @param a The first source integer - @param b The second source integer - @param c The destination of "a + b" - @return CRYPT_OK on success - */ - int (*add)(void *a, void *b, void *c); - - - /** add two integers - @param a The first source integer - @param b The second source integer (single digit of upto bits_per_digit in length) - @param c The destination of "a + b" - @return CRYPT_OK on success - */ - int (*addi)(void *a, unsigned long b, void *c); - - /** subtract two integers - @param a The first source integer - @param b The second source integer - @param c The destination of "a - b" - @return CRYPT_OK on success - */ - int (*sub)(void *a, void *b, void *c); - - /** subtract two integers - @param a The first source integer - @param b The second source integer (single digit of upto bits_per_digit in length) - @param c The destination of "a - b" - @return CRYPT_OK on success - */ - int (*subi)(void *a, unsigned long b, void *c); - - /** multiply two integers - @param a The first source integer - @param b The second source integer (single digit of upto bits_per_digit in length) - @param c The destination of "a * b" - @return CRYPT_OK on success - */ - int (*mul)(void *a, void *b, void *c); - - /** multiply two integers - @param a The first source integer - @param b The second source integer (single digit of upto bits_per_digit in length) - @param c The destination of "a * b" - @return CRYPT_OK on success - */ - int (*muli)(void *a, unsigned long b, void *c); - - /** Square an integer - @param a The integer to square - @param b The destination - @return CRYPT_OK on success - */ - int (*sqr)(void *a, void *b); - - /** Divide an integer - @param a The dividend - @param b The divisor - @param c The quotient (can be NULL to signify don't care) - @param d The remainder (can be NULL to signify don't care) - @return CRYPT_OK on success - */ - int (*mpdiv)(void *a, void *b, void *c, void *d); - - /** divide by two - @param a The integer to divide (shift right) - @param b The destination - @return CRYPT_OK on success - */ - int (*div_2)(void *a, void *b); - - /** Get remainder (small value) - @param a The integer to reduce - @param b The modulus (upto bits_per_digit in length) - @param c The destination for the residue - @return CRYPT_OK on success - */ - int (*modi)(void *a, unsigned long b, unsigned long *c); - - /** gcd - @param a The first integer - @param b The second integer - @param c The destination for (a, b) - @return CRYPT_OK on success - */ - int (*gcd)(void *a, void *b, void *c); - - /** lcm - @param a The first integer - @param b The second integer - @param c The destination for [a, b] - @return CRYPT_OK on success - */ - int (*lcm)(void *a, void *b, void *c); - - /** Modular multiplication - @param a The first source - @param b The second source - @param c The modulus - @param d The destination (a*b mod c) - @return CRYPT_OK on success - */ - int (*mulmod)(void *a, void *b, void *c, void *d); - - /** Modular squaring - @param a The first source - @param b The modulus - @param c The destination (a*a mod b) - @return CRYPT_OK on success - */ - int (*sqrmod)(void *a, void *b, void *c); - - /** Modular inversion - @param a The value to invert - @param b The modulus - @param c The destination (1/a mod b) - @return CRYPT_OK on success - */ - int (*invmod)(void *, void *, void *); - -/* ---- reduction ---- */ - - /** setup montgomery - @param a The modulus - @param b The destination for the reduction digit - @return CRYPT_OK on success - */ - int (*montgomery_setup)(void *a, void **b); - - /** get normalization value - @param a The destination for the normalization value - @param b The modulus - @return CRYPT_OK on success - */ - int (*montgomery_normalization)(void *a, void *b); - - /** reduce a number - @param a The number [and dest] to reduce - @param b The modulus - @param c The value "b" from montgomery_setup() - @return CRYPT_OK on success - */ - int (*montgomery_reduce)(void *a, void *b, void *c); - - /** clean up (frees memory) - @param a The value "b" from montgomery_setup() - @return CRYPT_OK on success - */ - void (*montgomery_deinit)(void *a); - -/* ---- exponentiation ---- */ - - /** Modular exponentiation - @param a The base integer - @param b The power (can be negative) integer - @param c The modulus integer - @param d The destination - @return CRYPT_OK on success - */ - int (*exptmod)(void *a, void *b, void *c, void *d); - - /** Primality testing - @param a The integer to test - @param b The destination of the result (FP_YES if prime) - @return CRYPT_OK on success - */ - int (*isprime)(void *a, int *b); - -/* ---- (optional) ecc point math ---- */ - - /** ECC GF(p) point multiplication (from the NIST curves) - @param k The integer to multiply the point by - @param G The point to multiply - @param R The destination for kG - @param modulus The modulus for the field - @param map Boolean indicated whether to map back to affine or not (can be ignored if you work in affine only) - @return CRYPT_OK on success - */ - int (*ecc_ptmul)(void *k, ecc_point *G, ecc_point *R, void *modulus, int map); - - /** ECC GF(p) point addition - @param P The first point - @param Q The second point - @param R The destination of P + Q - @param modulus The modulus - @param mp The "b" value from montgomery_setup() - @return CRYPT_OK on success - */ - int (*ecc_ptadd)(ecc_point *P, ecc_point *Q, ecc_point *R, void *modulus, void *mp); - - /** ECC GF(p) point double - @param P The first point - @param R The destination of 2P - @param modulus The modulus - @param mp The "b" value from montgomery_setup() - @return CRYPT_OK on success - */ - int (*ecc_ptdbl)(ecc_point *P, ecc_point *R, void *modulus, void *mp); - - /** ECC mapping from projective to affine, currently uses (x,y,z) => (x/z^2, y/z^3, 1) - @param P The point to map - @param modulus The modulus - @param mp The "b" value from montgomery_setup() - @return CRYPT_OK on success - @remark The mapping can be different but keep in mind a ecc_point only has three - integers (x,y,z) so if you use a different mapping you have to make it fit. - */ - int (*ecc_map)(ecc_point *P, void *modulus, void *mp); - - /** Computes kA*A + kB*B = C using Shamir's Trick - @param A First point to multiply - @param kA What to multiple A by - @param B Second point to multiply - @param kB What to multiple B by - @param C [out] Destination point (can overlap with A or B - @param modulus Modulus for curve - @return CRYPT_OK on success - */ - int (*ecc_mul2add)(ecc_point *A, void *kA, - ecc_point *B, void *kB, - ecc_point *C, - void *modulus); - -/* ---- (optional) rsa optimized math (for internal CRT) ---- */ - - /** RSA Key Generation - @param prng An active PRNG state - @param wprng The index of the PRNG desired - @param size The size of the modulus (key size) desired (octets) - @param e The "e" value (public key). e==65537 is a good choice - @param key [out] Destination of a newly created private key pair - @return CRYPT_OK if successful, upon error all allocated ram is freed - */ - int (*rsa_keygen)(prng_state *prng, int wprng, int size, long e, rsa_key *key); - - - /** RSA exponentiation - @param in The octet array representing the base - @param inlen The length of the input - @param out The destination (to be stored in an octet array format) - @param outlen The length of the output buffer and the resulting size (zero padded to the size of the modulus) - @param which PK_PUBLIC for public RSA and PK_PRIVATE for private RSA - @param key The RSA key to use - @return CRYPT_OK on success - */ - int (*rsa_me)(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen, int which, - rsa_key *key); -} ltc_math_descriptor; - -extern ltc_math_descriptor ltc_mp; - -int ltc_init_multi(void **a, ...); -void ltc_deinit_multi(void *a, ...); - -#ifdef LTM_DESC -extern const ltc_math_descriptor ltm_desc; -#endif - -#ifdef TFM_DESC -extern const ltc_math_descriptor tfm_desc; -#endif - -#ifdef GMP_DESC -extern const ltc_math_descriptor gmp_desc; -#endif - -#if !defined(DESC_DEF_ONLY) && defined(LTC_SOURCE) - -#define MP_DIGIT_BIT ltc_mp.bits_per_digit - -/* some handy macros */ -#define mp_init(a) ltc_mp.init(a) -#define mp_init_multi ltc_init_multi -#define mp_clear(a) ltc_mp.deinit(a) -#define mp_clear_multi ltc_deinit_multi -#define mp_init_copy(a, b) ltc_mp.init_copy(a, b) - -#define mp_neg(a, b) ltc_mp.neg(a, b) -#define mp_copy(a, b) ltc_mp.copy(a, b) - -#define mp_set(a, b) ltc_mp.set_int(a, b) -#define mp_set_int(a, b) ltc_mp.set_int(a, b) -#define mp_get_int(a) ltc_mp.get_int(a) -#define mp_get_digit(a, n) ltc_mp.get_digit(a, n) -#define mp_get_digit_count(a) ltc_mp.get_digit_count(a) -#define mp_cmp(a, b) ltc_mp.compare(a, b) -#define mp_cmp_d(a, b) ltc_mp.compare_d(a, b) -#define mp_count_bits(a) ltc_mp.count_bits(a) -#define mp_cnt_lsb(a) ltc_mp.count_lsb_bits(a) -#define mp_2expt(a, b) ltc_mp.twoexpt(a, b) - -#define mp_read_radix(a, b, c) ltc_mp.read_radix(a, b, c) -#define mp_toradix(a, b, c) ltc_mp.write_radix(a, b, c) -#define mp_unsigned_bin_size(a) ltc_mp.unsigned_size(a) -#define mp_to_unsigned_bin(a, b) ltc_mp.unsigned_write(a, b) -#define mp_read_unsigned_bin(a, b, c) ltc_mp.unsigned_read(a, b, c) - -#define mp_add(a, b, c) ltc_mp.add(a, b, c) -#define mp_add_d(a, b, c) ltc_mp.addi(a, b, c) -#define mp_sub(a, b, c) ltc_mp.sub(a, b, c) -#define mp_sub_d(a, b, c) ltc_mp.subi(a, b, c) -#define mp_mul(a, b, c) ltc_mp.mul(a, b, c) -#define mp_mul_d(a, b, c) ltc_mp.muli(a, b, c) -#define mp_sqr(a, b) ltc_mp.sqr(a, b) -#define mp_div(a, b, c, d) ltc_mp.mpdiv(a, b, c, d) -#define mp_div_2(a, b) ltc_mp.div_2(a, b) -#define mp_mod(a, b, c) ltc_mp.mpdiv(a, b, NULL, c) -#define mp_mod_d(a, b, c) ltc_mp.modi(a, b, c) -#define mp_gcd(a, b, c) ltc_mp.gcd(a, b, c) -#define mp_lcm(a, b, c) ltc_mp.lcm(a, b, c) - -#define mp_mulmod(a, b, c, d) ltc_mp.mulmod(a, b, c, d) -#define mp_sqrmod(a, b, c) ltc_mp.sqrmod(a, b, c) -#define mp_invmod(a, b, c) ltc_mp.invmod(a, b, c) - -#define mp_montgomery_setup(a, b) ltc_mp.montgomery_setup(a, b) -#define mp_montgomery_normalization(a, b) ltc_mp.montgomery_normalization(a, b) -#define mp_montgomery_reduce(a, b, c) ltc_mp.montgomery_reduce(a, b, c) -#define mp_montgomery_free(a) ltc_mp.montgomery_deinit(a) - -#define mp_exptmod(a,b,c,d) ltc_mp.exptmod(a,b,c,d) -#define mp_prime_is_prime(a, b, c) ltc_mp.isprime(a, c) - -#define mp_iszero(a) (mp_cmp_d(a, 0) == LTC_MP_EQ ? LTC_MP_YES : LTC_MP_NO) -#define mp_isodd(a) (mp_get_digit_count(a) > 0 ? (mp_get_digit(a, 0) & 1 ? LTC_MP_YES : LTC_MP_NO) : LTC_MP_NO) -#define mp_exch(a, b) do { void *ABC__tmp = a; a = b; b = ABC__tmp; } while(0); - -#define mp_tohex(a, b) mp_toradix(a, b, 16) - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_math.h,v $ */ -/* $Revision: 1.44 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_misc.h b/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_misc.h deleted file mode 100644 index f5384ca..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_misc.h +++ /dev/null @@ -1,23 +0,0 @@ -/* ---- LTC_BASE64 Routines ---- */ -#ifdef LTC_BASE64 -int base64_encode(const unsigned char *in, unsigned long len, - unsigned char *out, unsigned long *outlen); - -int base64_decode(const unsigned char *in, unsigned long len, - unsigned char *out, unsigned long *outlen); -#endif - -/* ---- MEM routines ---- */ -void zeromem(void *dst, size_t len); -void burn_stack(unsigned long len); - -const char *error_to_string(int err); - -extern const char *crypt_build_settings; - -/* ---- HMM ---- */ -int crypt_fsa(void *mp, ...); - -/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_misc.h,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_pk.h b/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_pk.h deleted file mode 100644 index b5f277a..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_pk.h +++ /dev/null @@ -1,558 +0,0 @@ -/* ---- NUMBER THEORY ---- */ - -enum { - PK_PUBLIC=0, - PK_PRIVATE=1 -}; - -int rand_prime(void *N, long len, prng_state *prng, int wprng); - -/* ---- RSA ---- */ -#ifdef LTC_MRSA - -/* Min and Max RSA key sizes (in bits) */ -#define MIN_RSA_SIZE 1024 -#define MAX_RSA_SIZE 4096 - -/** RSA LTC_PKCS style key */ -typedef struct Rsa_key { - /** Type of key, PK_PRIVATE or PK_PUBLIC */ - int type; - /** The public exponent */ - void *e; - /** The private exponent */ - void *d; - /** The modulus */ - void *N; - /** The p factor of N */ - void *p; - /** The q factor of N */ - void *q; - /** The 1/q mod p CRT param */ - void *qP; - /** The d mod (p - 1) CRT param */ - void *dP; - /** The d mod (q - 1) CRT param */ - void *dQ; -} rsa_key; - -int rsa_make_key(prng_state *prng, int wprng, int size, long e, rsa_key *key); - -int rsa_exptmod(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen, int which, - rsa_key *key); - -void rsa_free(rsa_key *key); - -/* These use LTC_PKCS #1 v2.0 padding */ -#define rsa_encrypt_key(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _prng, _prng_idx, _hash_idx, _key) \ - rsa_encrypt_key_ex(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _prng, _prng_idx, _hash_idx, LTC_LTC_PKCS_1_OAEP, _key) - -#define rsa_decrypt_key(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _hash_idx, _stat, _key) \ - rsa_decrypt_key_ex(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _hash_idx, LTC_LTC_PKCS_1_OAEP, _stat, _key) - -#define rsa_sign_hash(_in, _inlen, _out, _outlen, _prng, _prng_idx, _hash_idx, _saltlen, _key) \ - rsa_sign_hash_ex(_in, _inlen, _out, _outlen, LTC_LTC_PKCS_1_PSS, _prng, _prng_idx, _hash_idx, _saltlen, _key) - -#define rsa_verify_hash(_sig, _siglen, _hash, _hashlen, _hash_idx, _saltlen, _stat, _key) \ - rsa_verify_hash_ex(_sig, _siglen, _hash, _hashlen, LTC_LTC_PKCS_1_PSS, _hash_idx, _saltlen, _stat, _key) - -/* These can be switched between LTC_PKCS #1 v2.x and LTC_PKCS #1 v1.5 paddings */ -int rsa_encrypt_key_ex(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen, - const unsigned char *lparam, unsigned long lparamlen, - prng_state *prng, int prng_idx, int hash_idx, int padding, rsa_key *key); - -int rsa_decrypt_key_ex(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen, - const unsigned char *lparam, unsigned long lparamlen, - int hash_idx, int padding, - int *stat, rsa_key *key); - -int rsa_sign_hash_ex(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen, - int padding, - prng_state *prng, int prng_idx, - int hash_idx, unsigned long saltlen, - rsa_key *key); - -int rsa_verify_hash_ex(const unsigned char *sig, unsigned long siglen, - const unsigned char *hash, unsigned long hashlen, - int padding, - int hash_idx, unsigned long saltlen, - int *stat, rsa_key *key); - -/* LTC_PKCS #1 import/export */ -int rsa_export(unsigned char *out, unsigned long *outlen, int type, rsa_key *key); -int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key *key); - -/* Ladik: Added for verifying Blizzard strong signature verification */ -int rsa_verify_simple(const unsigned char *sig, unsigned long siglen, - const unsigned char *hash, unsigned long hashlen, - int *stat, - rsa_key *key); - -#endif - -/* ---- Katja ---- */ -#ifdef MKAT - -/* Min and Max KAT key sizes (in bits) */ -#define MIN_KAT_SIZE 1024 -#define MAX_KAT_SIZE 4096 - -/** Katja LTC_PKCS style key */ -typedef struct KAT_key { - /** Type of key, PK_PRIVATE or PK_PUBLIC */ - int type; - /** The private exponent */ - void *d; - /** The modulus */ - void *N; - /** The p factor of N */ - void *p; - /** The q factor of N */ - void *q; - /** The 1/q mod p CRT param */ - void *qP; - /** The d mod (p - 1) CRT param */ - void *dP; - /** The d mod (q - 1) CRT param */ - void *dQ; - /** The pq param */ - void *pq; -} katja_key; - -int katja_make_key(prng_state *prng, int wprng, int size, katja_key *key); - -int katja_exptmod(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen, int which, - katja_key *key); - -void katja_free(katja_key *key); - -/* These use LTC_PKCS #1 v2.0 padding */ -int katja_encrypt_key(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen, - const unsigned char *lparam, unsigned long lparamlen, - prng_state *prng, int prng_idx, int hash_idx, katja_key *key); - -int katja_decrypt_key(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen, - const unsigned char *lparam, unsigned long lparamlen, - int hash_idx, int *stat, - katja_key *key); - -/* LTC_PKCS #1 import/export */ -int katja_export(unsigned char *out, unsigned long *outlen, int type, katja_key *key); -int katja_import(const unsigned char *in, unsigned long inlen, katja_key *key); - -#endif - -/* ---- ECC Routines ---- */ -#ifdef LTC_MECC - -/* size of our temp buffers for exported keys */ -#define ECC_BUF_SIZE 256 - -/* max private key size */ -#define ECC_MAXSIZE 66 - -/** Structure defines a NIST GF(p) curve */ -typedef struct { - /** The size of the curve in octets */ - int size; - - /** name of curve */ - char *name; - - /** The prime that defines the field the curve is in (encoded in hex) */ - char *prime; - - /** The fields B param (hex) */ - char *B; - - /** The order of the curve (hex) */ - char *order; - - /** The x co-ordinate of the base point on the curve (hex) */ - char *Gx; - - /** The y co-ordinate of the base point on the curve (hex) */ - char *Gy; -} ltc_ecc_set_type; - -/** A point on a ECC curve, stored in Jacbobian format such that (x,y,z) => (x/z^2, y/z^3, 1) when interpretted as affine */ -typedef struct { - /** The x co-ordinate */ - void *x; - - /** The y co-ordinate */ - void *y; - - /** The z co-ordinate */ - void *z; -} ecc_point; - -/** An ECC key */ -typedef struct { - /** Type of key, PK_PRIVATE or PK_PUBLIC */ - int type; - - /** Index into the ltc_ecc_sets[] for the parameters of this curve; if -1, then this key is using user supplied curve in dp */ - int idx; - - /** pointer to domain parameters; either points to NIST curves (identified by idx >= 0) or user supplied curve */ - const ltc_ecc_set_type *dp; - - /** The public key */ - ecc_point pubkey; - - /** The private key */ - void *k; -} ecc_key; - -/** the ECC params provided */ -extern const ltc_ecc_set_type ltc_ecc_sets[]; - -int ecc_test(void); -void ecc_sizes(int *low, int *high); -int ecc_get_size(ecc_key *key); - -int ecc_make_key(prng_state *prng, int wprng, int keysize, ecc_key *key); -int ecc_make_key_ex(prng_state *prng, int wprng, ecc_key *key, const ltc_ecc_set_type *dp); -void ecc_free(ecc_key *key); - -int ecc_export(unsigned char *out, unsigned long *outlen, int type, ecc_key *key); -int ecc_import(const unsigned char *in, unsigned long inlen, ecc_key *key); -int ecc_import_ex(const unsigned char *in, unsigned long inlen, ecc_key *key, const ltc_ecc_set_type *dp); - -int ecc_ansi_x963_export(ecc_key *key, unsigned char *out, unsigned long *outlen); -int ecc_ansi_x963_import(const unsigned char *in, unsigned long inlen, ecc_key *key); -int ecc_ansi_x963_import_ex(const unsigned char *in, unsigned long inlen, ecc_key *key, ltc_ecc_set_type *dp); - -int ecc_shared_secret(ecc_key *private_key, ecc_key *public_key, - unsigned char *out, unsigned long *outlen); - -int ecc_encrypt_key(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen, - prng_state *prng, int wprng, int hash, - ecc_key *key); - -int ecc_decrypt_key(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen, - ecc_key *key); - -int ecc_sign_hash(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen, - prng_state *prng, int wprng, ecc_key *key); - -int ecc_verify_hash(const unsigned char *sig, unsigned long siglen, - const unsigned char *hash, unsigned long hashlen, - int *stat, ecc_key *key); - -/* low level functions */ -ecc_point *ltc_ecc_new_point(void); -void ltc_ecc_del_point(ecc_point *p); -int ltc_ecc_is_valid_idx(int n); - -/* point ops (mp == montgomery digit) */ -#if !defined(LTC_MECC_ACCEL) || defined(LTM_LTC_DESC) || defined(GMP_LTC_DESC) -/* R = 2P */ -int ltc_ecc_projective_dbl_point(ecc_point *P, ecc_point *R, void *modulus, void *mp); - -/* R = P + Q */ -int ltc_ecc_projective_add_point(ecc_point *P, ecc_point *Q, ecc_point *R, void *modulus, void *mp); -#endif - -#if defined(LTC_MECC_FP) -/* optimized point multiplication using fixed point cache (HAC algorithm 14.117) */ -int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int map); - -/* functions for saving/loading/freeing/adding to fixed point cache */ -int ltc_ecc_fp_save_state(unsigned char **out, unsigned long *outlen); -int ltc_ecc_fp_restore_state(unsigned char *in, unsigned long inlen); -void ltc_ecc_fp_free(void); -int ltc_ecc_fp_add_point(ecc_point *g, void *modulus, int lock); - -/* lock/unlock all points currently in fixed point cache */ -void ltc_ecc_fp_tablelock(int lock); -#endif - -/* R = kG */ -int ltc_ecc_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int map); - -#ifdef LTC_ECC_SHAMIR -/* kA*A + kB*B = C */ -int ltc_ecc_mul2add(ecc_point *A, void *kA, - ecc_point *B, void *kB, - ecc_point *C, - void *modulus); - -#ifdef LTC_MECC_FP -/* Shamir's trick with optimized point multiplication using fixed point cache */ -int ltc_ecc_fp_mul2add(ecc_point *A, void *kA, - ecc_point *B, void *kB, - ecc_point *C, void *modulus); -#endif - -#endif - - -/* map P to affine from projective */ -int ltc_ecc_map(ecc_point *P, void *modulus, void *mp); - -#endif - -#ifdef LTC_MDSA - -/* Max diff between group and modulus size in bytes */ -#define LTC_MDSA_DELTA 512 - -/* Max DSA group size in bytes (default allows 4k-bit groups) */ -#define LTC_MDSA_MAX_GROUP 512 - -/** DSA key structure */ -typedef struct { - /** The key type, PK_PRIVATE or PK_PUBLIC */ - int type; - - /** The order of the sub-group used in octets */ - int qord; - - /** The generator */ - void *g; - - /** The prime used to generate the sub-group */ - void *q; - - /** The large prime that generats the field the contains the sub-group */ - void *p; - - /** The private key */ - void *x; - - /** The public key */ - void *y; -} dsa_key; - -int dsa_make_key(prng_state *prng, int wprng, int group_size, int modulus_size, dsa_key *key); -void dsa_free(dsa_key *key); - -int dsa_sign_hash_raw(const unsigned char *in, unsigned long inlen, - void *r, void *s, - prng_state *prng, int wprng, dsa_key *key); - -int dsa_sign_hash(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen, - prng_state *prng, int wprng, dsa_key *key); - -int dsa_verify_hash_raw( void *r, void *s, - const unsigned char *hash, unsigned long hashlen, - int *stat, dsa_key *key); - -int dsa_verify_hash(const unsigned char *sig, unsigned long siglen, - const unsigned char *hash, unsigned long hashlen, - int *stat, dsa_key *key); - -int dsa_encrypt_key(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen, - prng_state *prng, int wprng, int hash, - dsa_key *key); - -int dsa_decrypt_key(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen, - dsa_key *key); - -int dsa_import(const unsigned char *in, unsigned long inlen, dsa_key *key); -int dsa_export(unsigned char *out, unsigned long *outlen, int type, dsa_key *key); -int dsa_verify_key(dsa_key *key, int *stat); - -int dsa_shared_secret(void *private_key, void *base, - dsa_key *public_key, - unsigned char *out, unsigned long *outlen); -#endif - -#ifdef LTC_DER -/* DER handling */ - -enum { - LTC_ASN1_EOL, - LTC_ASN1_BOOLEAN, - LTC_ASN1_INTEGER, - LTC_ASN1_SHORT_INTEGER, - LTC_ASN1_BIT_STRING, - LTC_ASN1_OCTET_STRING, - LTC_ASN1_NULL, - LTC_ASN1_OBJECT_IDENTIFIER, - LTC_ASN1_IA5_STRING, - LTC_ASN1_PRINTABLE_STRING, - LTC_ASN1_UTF8_STRING, - LTC_ASN1_UTCTIME, - LTC_ASN1_CHOICE, - LTC_ASN1_SEQUENCE, - LTC_ASN1_SET, - LTC_ASN1_SETOF -}; - -/** A LTC ASN.1 list type */ -typedef struct ltc_asn1_list_ { - /** The LTC ASN.1 enumerated type identifier */ - int type; - /** The data to encode or place for decoding */ - void *data; - /** The size of the input or resulting output */ - unsigned long size; - /** The used flag, this is used by the CHOICE ASN.1 type to indicate which choice was made */ - int used; - /** prev/next entry in the list */ - struct ltc_asn1_list_ *prev, *next, *child, *parent; -} ltc_asn1_list; - -#define LTC_SET_ASN1(list, index, Type, Data, Size) \ - do { \ - int LTC_MACRO_temp = (index); \ - ltc_asn1_list *LTC_MACRO_list = (list); \ - LTC_MACRO_list[LTC_MACRO_temp].type = (Type); \ - LTC_MACRO_list[LTC_MACRO_temp].data = (void*)(Data); \ - LTC_MACRO_list[LTC_MACRO_temp].size = (Size); \ - LTC_MACRO_list[LTC_MACRO_temp].used = 0; \ - } while (0); - -/* SEQUENCE */ -int der_encode_sequence_ex(ltc_asn1_list *list, unsigned long inlen, - unsigned char *out, unsigned long *outlen, int type_of); - -#define der_encode_sequence(list, inlen, out, outlen) der_encode_sequence_ex(list, inlen, out, outlen, LTC_ASN1_SEQUENCE) - -int der_decode_sequence_ex(const unsigned char *in, unsigned long inlen, - ltc_asn1_list *list, unsigned long outlen, int ordered); - -#define der_decode_sequence(in, inlen, list, outlen) der_decode_sequence_ex(in, inlen, list, outlen, 1) - -int der_length_sequence(ltc_asn1_list *list, unsigned long inlen, - unsigned long *outlen); - -/* SET */ -#define der_decode_set(in, inlen, list, outlen) der_decode_sequence_ex(in, inlen, list, outlen, 0) -#define der_length_set der_length_sequence -int der_encode_set(ltc_asn1_list *list, unsigned long inlen, - unsigned char *out, unsigned long *outlen); - -int der_encode_setof(ltc_asn1_list *list, unsigned long inlen, - unsigned char *out, unsigned long *outlen); - -/* VA list handy helpers with triplets of */ -int der_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...); -int der_decode_sequence_multi(const unsigned char *in, unsigned long inlen, ...); - -/* FLEXI DECODER handle unknown list decoder */ -int der_decode_sequence_flexi(const unsigned char *in, unsigned long *inlen, ltc_asn1_list **out); -void der_free_sequence_flexi(ltc_asn1_list *list); -void der_sequence_free(ltc_asn1_list *in); - -/* BOOLEAN */ -int der_length_boolean(unsigned long *outlen); -int der_encode_boolean(int in, - unsigned char *out, unsigned long *outlen); -int der_decode_boolean(const unsigned char *in, unsigned long inlen, - int *out); -/* INTEGER */ -int der_encode_integer(void *num, unsigned char *out, unsigned long *outlen); -int der_decode_integer(const unsigned char *in, unsigned long inlen, void *num); -int der_length_integer(void *num, unsigned long *len); - -/* INTEGER -- handy for 0..2^32-1 values */ -int der_decode_short_integer(const unsigned char *in, unsigned long inlen, unsigned long *num); -int der_encode_short_integer(unsigned long num, unsigned char *out, unsigned long *outlen); -int der_length_short_integer(unsigned long num, unsigned long *outlen); - -/* BIT STRING */ -int der_encode_bit_string(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen); -int der_decode_bit_string(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen); -int der_length_bit_string(unsigned long nbits, unsigned long *outlen); - -/* OCTET STRING */ -int der_encode_octet_string(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen); -int der_decode_octet_string(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen); -int der_length_octet_string(unsigned long noctets, unsigned long *outlen); - -/* OBJECT IDENTIFIER */ -int der_encode_object_identifier(unsigned long *words, unsigned long nwords, - unsigned char *out, unsigned long *outlen); -int der_decode_object_identifier(const unsigned char *in, unsigned long inlen, - unsigned long *words, unsigned long *outlen); -int der_length_object_identifier(unsigned long *words, unsigned long nwords, unsigned long *outlen); -unsigned long der_object_identifier_bits(unsigned long x); - -/* IA5 STRING */ -int der_encode_ia5_string(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen); -int der_decode_ia5_string(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen); -int der_length_ia5_string(const unsigned char *octets, unsigned long noctets, unsigned long *outlen); - -int der_ia5_char_encode(int c); -int der_ia5_value_decode(int v); - -/* Printable STRING */ -int der_encode_printable_string(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen); -int der_decode_printable_string(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen); -int der_length_printable_string(const unsigned char *octets, unsigned long noctets, unsigned long *outlen); - -int der_printable_char_encode(int c); -int der_printable_value_decode(int v); - -/* UTF-8 */ -#if (defined(SIZE_MAX) || __STDC_VERSION__ >= 199901L || defined(WCHAR_MAX) || defined(_WCHAR_T) || defined(_WCHAR_T_DEFINED) || defined (__WCHAR_TYPE__)) && !defined(LTC_NO_WCHAR) -#include -#else -typedef ulong32 wchar_t; -#endif - -int der_encode_utf8_string(const wchar_t *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen); - -int der_decode_utf8_string(const unsigned char *in, unsigned long inlen, - wchar_t *out, unsigned long *outlen); -unsigned long der_utf8_charsize(const wchar_t c); -int der_length_utf8_string(const wchar_t *in, unsigned long noctets, unsigned long *outlen); - - -/* CHOICE */ -int der_decode_choice(const unsigned char *in, unsigned long *inlen, - ltc_asn1_list *list, unsigned long outlen); - -/* UTCTime */ -typedef struct { - unsigned YY, /* year */ - MM, /* month */ - DD, /* day */ - hh, /* hour */ - mm, /* minute */ - ss, /* second */ - off_dir, /* timezone offset direction 0 == +, 1 == - */ - off_hh, /* timezone offset hours */ - off_mm; /* timezone offset minutes */ -} ltc_utctime; - -int der_encode_utctime(ltc_utctime *utctime, - unsigned char *out, unsigned long *outlen); - -int der_decode_utctime(const unsigned char *in, unsigned long *inlen, - ltc_utctime *out); - -int der_length_utctime(ltc_utctime *utctime, unsigned long *outlen); - - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_pk.h,v $ */ -/* $Revision: 1.81 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_pkcs.h b/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_pkcs.h deleted file mode 100644 index 84fb82a..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_pkcs.h +++ /dev/null @@ -1,89 +0,0 @@ -/* LTC_PKCS Header Info */ - -/* ===> LTC_PKCS #1 -- RSA Cryptography <=== */ -#ifdef LTC_PKCS_1 - -enum ltc_pkcs_1_v1_5_blocks -{ - LTC_LTC_PKCS_1_EMSA = 1, /* Block type 1 (LTC_PKCS #1 v1.5 signature padding) */ - LTC_LTC_PKCS_1_EME = 2 /* Block type 2 (LTC_PKCS #1 v1.5 encryption padding) */ -}; - -enum ltc_pkcs_1_paddings -{ - LTC_LTC_PKCS_1_V1_5 = 1, /* LTC_PKCS #1 v1.5 padding (\sa ltc_pkcs_1_v1_5_blocks) */ - LTC_LTC_PKCS_1_OAEP = 2, /* LTC_PKCS #1 v2.0 encryption padding */ - LTC_LTC_PKCS_1_PSS = 3 /* LTC_PKCS #1 v2.1 signature padding */ -}; - -int pkcs_1_mgf1( int hash_idx, - const unsigned char *seed, unsigned long seedlen, - unsigned char *mask, unsigned long masklen); - -int pkcs_1_i2osp(void *n, unsigned long modulus_len, unsigned char *out); -int pkcs_1_os2ip(void *n, unsigned char *in, unsigned long inlen); - -/* *** v1.5 padding */ -int pkcs_1_v1_5_encode(const unsigned char *msg, - unsigned long msglen, - int block_type, - unsigned long modulus_bitlen, - prng_state *prng, - int prng_idx, - unsigned char *out, - unsigned long *outlen); - -int pkcs_1_v1_5_decode(const unsigned char *msg, - unsigned long msglen, - int block_type, - unsigned long modulus_bitlen, - unsigned char *out, - unsigned long *outlen, - int *is_valid); - -/* *** v2.1 padding */ -int pkcs_1_oaep_encode(const unsigned char *msg, unsigned long msglen, - const unsigned char *lparam, unsigned long lparamlen, - unsigned long modulus_bitlen, prng_state *prng, - int prng_idx, int hash_idx, - unsigned char *out, unsigned long *outlen); - -int pkcs_1_oaep_decode(const unsigned char *msg, unsigned long msglen, - const unsigned char *lparam, unsigned long lparamlen, - unsigned long modulus_bitlen, int hash_idx, - unsigned char *out, unsigned long *outlen, - int *res); - -int pkcs_1_pss_encode(const unsigned char *msghash, unsigned long msghashlen, - unsigned long saltlen, prng_state *prng, - int prng_idx, int hash_idx, - unsigned long modulus_bitlen, - unsigned char *out, unsigned long *outlen); - -int pkcs_1_pss_decode(const unsigned char *msghash, unsigned long msghashlen, - const unsigned char *sig, unsigned long siglen, - unsigned long saltlen, int hash_idx, - unsigned long modulus_bitlen, int *res); - -#endif /* LTC_PKCS_1 */ - -/* ===> LTC_PKCS #5 -- Password Based Cryptography <=== */ -#ifdef LTC_PKCS_5 - -/* Algorithm #1 (old) */ -int pkcs_5_alg1(const unsigned char *password, unsigned long password_len, - const unsigned char *salt, - int iteration_count, int hash_idx, - unsigned char *out, unsigned long *outlen); - -/* Algorithm #2 (new) */ -int pkcs_5_alg2(const unsigned char *password, unsigned long password_len, - const unsigned char *salt, unsigned long salt_len, - int iteration_count, int hash_idx, - unsigned char *out, unsigned long *outlen); - -#endif /* LTC_PKCS_5 */ - -/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_pkcs.h,v $ */ -/* $Revision: 1.8 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_prng.h b/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_prng.h deleted file mode 100644 index f3e3e55..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/headers/tomcrypt_prng.h +++ /dev/null @@ -1,199 +0,0 @@ -/* ---- PRNG Stuff ---- */ -#ifdef LTC_YARROW -struct yarrow_prng { - int cipher, hash; - unsigned char pool[MAXBLOCKSIZE]; - symmetric_CTR ctr; - LTC_MUTEX_TYPE(prng_lock) -}; -#endif - -#ifdef LTC_RC4 -struct rc4_prng { - int x, y; - unsigned char buf[256]; -}; -#endif - -#ifdef LTC_FORTUNA -struct fortuna_prng { - hash_state pool[LTC_FORTUNA_POOLS]; /* the pools */ - - symmetric_key skey; - - unsigned char K[32], /* the current key */ - IV[16]; /* IV for CTR mode */ - - unsigned long pool_idx, /* current pool we will add to */ - pool0_len, /* length of 0'th pool */ - wd; - - ulong64 reset_cnt; /* number of times we have reset */ - LTC_MUTEX_TYPE(prng_lock) -}; -#endif - -#ifdef LTC_SOBER128 -struct sober128_prng { - ulong32 R[17], /* Working storage for the shift register */ - initR[17], /* saved register contents */ - konst, /* key dependent constant */ - sbuf; /* partial word encryption buffer */ - - int nbuf, /* number of part-word stream bits buffered */ - flag, /* first add_entropy call or not? */ - set; /* did we call add_entropy to set key? */ - -}; -#endif - -typedef union Prng_state { - char dummy[1]; -#ifdef LTC_YARROW - struct yarrow_prng yarrow; -#endif -#ifdef LTC_RC4 - struct rc4_prng rc4; -#endif -#ifdef LTC_FORTUNA - struct fortuna_prng fortuna; -#endif -#ifdef LTC_SOBER128 - struct sober128_prng sober128; -#endif -} prng_state; - -/** PRNG descriptor */ -extern struct ltc_prng_descriptor { - /** Name of the PRNG */ - char *name; - /** size in bytes of exported state */ - int export_size; - /** Start a PRNG state - @param prng [out] The state to initialize - @return CRYPT_OK if successful - */ - int (*start)(prng_state *prng); - /** Add entropy to the PRNG - @param in The entropy - @param inlen Length of the entropy (octets)\ - @param prng The PRNG state - @return CRYPT_OK if successful - */ - int (*add_entropy)(const unsigned char *in, unsigned long inlen, prng_state *prng); - /** Ready a PRNG state to read from - @param prng The PRNG state to ready - @return CRYPT_OK if successful - */ - int (*ready)(prng_state *prng); - /** Read from the PRNG - @param out [out] Where to store the data - @param outlen Length of data desired (octets) - @param prng The PRNG state to read from - @return Number of octets read - */ - unsigned long (*read)(unsigned char *out, unsigned long outlen, prng_state *prng); - /** Terminate a PRNG state - @param prng The PRNG state to terminate - @return CRYPT_OK if successful - */ - int (*done)(prng_state *prng); - /** Export a PRNG state - @param out [out] The destination for the state - @param outlen [in/out] The max size and resulting size of the PRNG state - @param prng The PRNG to export - @return CRYPT_OK if successful - */ - int (*pexport)(unsigned char *out, unsigned long *outlen, prng_state *prng); - /** Import a PRNG state - @param in The data to import - @param inlen The length of the data to import (octets) - @param prng The PRNG to initialize/import - @return CRYPT_OK if successful - */ - int (*pimport)(const unsigned char *in, unsigned long inlen, prng_state *prng); - /** Self-test the PRNG - @return CRYPT_OK if successful, CRYPT_NOP if self-testing has been disabled - */ - int (*test)(void); -} prng_descriptor[]; - -#ifdef LTC_YARROW -int yarrow_start(prng_state *prng); -int yarrow_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng); -int yarrow_ready(prng_state *prng); -unsigned long yarrow_read(unsigned char *out, unsigned long outlen, prng_state *prng); -int yarrow_done(prng_state *prng); -int yarrow_export(unsigned char *out, unsigned long *outlen, prng_state *prng); -int yarrow_import(const unsigned char *in, unsigned long inlen, prng_state *prng); -int yarrow_test(void); -extern const struct ltc_prng_descriptor yarrow_desc; -#endif - -#ifdef LTC_FORTUNA -int fortuna_start(prng_state *prng); -int fortuna_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng); -int fortuna_ready(prng_state *prng); -unsigned long fortuna_read(unsigned char *out, unsigned long outlen, prng_state *prng); -int fortuna_done(prng_state *prng); -int fortuna_export(unsigned char *out, unsigned long *outlen, prng_state *prng); -int fortuna_import(const unsigned char *in, unsigned long inlen, prng_state *prng); -int fortuna_test(void); -extern const struct ltc_prng_descriptor fortuna_desc; -#endif - -#ifdef LTC_RC4 -int rc4_start(prng_state *prng); -int rc4_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng); -int rc4_ready(prng_state *prng); -unsigned long rc4_read(unsigned char *out, unsigned long outlen, prng_state *prng); -int rc4_done(prng_state *prng); -int rc4_export(unsigned char *out, unsigned long *outlen, prng_state *prng); -int rc4_import(const unsigned char *in, unsigned long inlen, prng_state *prng); -int rc4_test(void); -extern const struct ltc_prng_descriptor rc4_desc; -#endif - -#ifdef LTC_SPRNG -int sprng_start(prng_state *prng); -int sprng_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng); -int sprng_ready(prng_state *prng); -unsigned long sprng_read(unsigned char *out, unsigned long outlen, prng_state *prng); -int sprng_done(prng_state *prng); -int sprng_export(unsigned char *out, unsigned long *outlen, prng_state *prng); -int sprng_import(const unsigned char *in, unsigned long inlen, prng_state *prng); -int sprng_test(void); -extern const struct ltc_prng_descriptor sprng_desc; -#endif - -#ifdef LTC_SOBER128 -int sober128_start(prng_state *prng); -int sober128_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng); -int sober128_ready(prng_state *prng); -unsigned long sober128_read(unsigned char *out, unsigned long outlen, prng_state *prng); -int sober128_done(prng_state *prng); -int sober128_export(unsigned char *out, unsigned long *outlen, prng_state *prng); -int sober128_import(const unsigned char *in, unsigned long inlen, prng_state *prng); -int sober128_test(void); -extern const struct ltc_prng_descriptor sober128_desc; -#endif - -int find_prng(const char *name); -int register_prng(const struct ltc_prng_descriptor *prng); -int unregister_prng(const struct ltc_prng_descriptor *prng); -int prng_is_valid(int idx); -LTC_MUTEX_PROTO(ltc_prng_mutex) - -/* Slow RNG you **might** be able to use to seed a PRNG with. Be careful as this - * might not work on all platforms as planned - */ -unsigned long rng_get_bytes(unsigned char *out, - unsigned long outlen, - void (*callback)(void)); - -int rng_make_prng(int bits, int wprng, prng_state *prng, void (*callback)(void)); - - -/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_prng.h,v $ */ -/* $Revision: 1.9 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/math/ltm_desc.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/math/ltm_desc.c deleted file mode 100644 index 25dc0b3..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/math/ltm_desc.c +++ /dev/null @@ -1,483 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -#define DESC_DEF_ONLY -#include "../headers/tomcrypt.h" - -#ifdef LTM_DESC - -#include "../../../libtommath/tommath.h" - -static const struct { - int mpi_code, ltc_code; -} mpi_to_ltc_codes[] = { - { MP_OKAY , CRYPT_OK}, - { MP_MEM , CRYPT_MEM}, - { MP_VAL , CRYPT_INVALID_ARG}, -}; - -/** - Convert a MPI error to a LTC error (Possibly the most powerful function ever! Oh wait... no) - @param err The error to convert - @return The equivalent LTC error code or CRYPT_ERROR if none found -*/ -static int mpi_to_ltc_error(int err) -{ - int x; - - for (x = 0; x < (int)(sizeof(mpi_to_ltc_codes)/sizeof(mpi_to_ltc_codes[0])); x++) { - if (err == mpi_to_ltc_codes[x].mpi_code) { - return mpi_to_ltc_codes[x].ltc_code; - } - } - return CRYPT_ERROR; -} - -static int init(void **a) -{ - int err; - - LTC_ARGCHK(a != NULL); - - *a = XCALLOC(1, sizeof(mp_int)); - if (*a == NULL) { - return CRYPT_MEM; - } - - if ((err = mpi_to_ltc_error(mp_init(*a))) != CRYPT_OK) { - XFREE(*a); - } - return err; -} - -static void deinit(void *a) -{ - LTC_ARGCHKVD(a != NULL); - mp_clear(a); - XFREE(a); -} - -static int neg(void *a, void *b) -{ - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(b != NULL); - return mpi_to_ltc_error(mp_neg(a, b)); -} - -static int copy(void *a, void *b) -{ - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(b != NULL); - return mpi_to_ltc_error(mp_copy(a, b)); -} - -static int init_copy(void **a, void *b) -{ - if (init(a) != CRYPT_OK) { - return CRYPT_MEM; - } - return copy(b, *a); -} - -/* ---- trivial ---- */ -static int set_int(void *a, unsigned long b) -{ - LTC_ARGCHK(a != NULL); - return mpi_to_ltc_error(mp_set_int(a, b)); -} - -static unsigned long get_int(void *a) -{ - LTC_ARGCHK(a != NULL); - return mp_get_int(a); -} - -static unsigned long get_digit(void *a, int n) -{ - mp_int *A; - LTC_ARGCHK(a != NULL); - A = a; - return (n >= A->used || n < 0) ? 0 : A->dp[n]; -} - -static int get_digit_count(void *a) -{ - mp_int *A; - LTC_ARGCHK(a != NULL); - A = a; - return A->used; -} - -static int compare(void *a, void *b) -{ - int ret; - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(b != NULL); - ret = mp_cmp(a, b); - switch (ret) { - case MP_LT: return LTC_MP_LT; - case MP_EQ: return LTC_MP_EQ; - case MP_GT: return LTC_MP_GT; - } - return 0; -} - -static int compare_d(void *a, unsigned long b) -{ - int ret; - LTC_ARGCHK(a != NULL); - ret = mp_cmp_d(a, b); - switch (ret) { - case MP_LT: return LTC_MP_LT; - case MP_EQ: return LTC_MP_EQ; - case MP_GT: return LTC_MP_GT; - } - return 0; -} - -static int count_bits(void *a) -{ - LTC_ARGCHK(a != NULL); - return mp_count_bits(a); -} - -static int count_lsb_bits(void *a) -{ - LTC_ARGCHK(a != NULL); - return mp_cnt_lsb(a); -} - - -static int twoexpt(void *a, int n) -{ - LTC_ARGCHK(a != NULL); - return mpi_to_ltc_error(mp_2expt(a, n)); -} - -/* ---- conversions ---- */ - -/* read ascii string */ -static int read_radix(void *a, const char *b, int radix) -{ - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(b != NULL); - return mpi_to_ltc_error(mp_read_radix(a, b, radix)); -} - -/* write one */ -static int write_radix(void *a, char *b, int radix) -{ - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(b != NULL); - return mpi_to_ltc_error(mp_toradix(a, b, radix)); -} - -/* get size as unsigned char string */ -static unsigned long unsigned_size(void *a) -{ - LTC_ARGCHK(a != NULL); - return mp_unsigned_bin_size(a); -} - -/* store */ -static int unsigned_write(void *a, unsigned char *b) -{ - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(b != NULL); - return mpi_to_ltc_error(mp_to_unsigned_bin(a, b)); -} - -/* read */ -static int unsigned_read(void *a, unsigned char *b, unsigned long len) -{ - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(b != NULL); - return mpi_to_ltc_error(mp_read_unsigned_bin(a, b, len)); -} - -/* add */ -static int add(void *a, void *b, void *c) -{ - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(b != NULL); - LTC_ARGCHK(c != NULL); - return mpi_to_ltc_error(mp_add(a, b, c)); -} - -static int addi(void *a, unsigned long b, void *c) -{ - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(c != NULL); - return mpi_to_ltc_error(mp_add_d(a, b, c)); -} - -/* sub */ -static int sub(void *a, void *b, void *c) -{ - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(b != NULL); - LTC_ARGCHK(c != NULL); - return mpi_to_ltc_error(mp_sub(a, b, c)); -} - -static int subi(void *a, unsigned long b, void *c) -{ - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(c != NULL); - return mpi_to_ltc_error(mp_sub_d(a, b, c)); -} - -/* mul */ -static int mul(void *a, void *b, void *c) -{ - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(b != NULL); - LTC_ARGCHK(c != NULL); - return mpi_to_ltc_error(mp_mul(a, b, c)); -} - -static int muli(void *a, unsigned long b, void *c) -{ - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(c != NULL); - return mpi_to_ltc_error(mp_mul_d(a, b, c)); -} - -/* sqr */ -static int sqr(void *a, void *b) -{ - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(b != NULL); - return mpi_to_ltc_error(mp_sqr(a, b)); -} - -/* div */ -static int divide(void *a, void *b, void *c, void *d) -{ - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(b != NULL); - return mpi_to_ltc_error(mp_div(a, b, c, d)); -} - -static int div_2(void *a, void *b) -{ - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(b != NULL); - return mpi_to_ltc_error(mp_div_2(a, b)); -} - -/* modi */ -static int modi(void *a, unsigned long b, unsigned long *c) -{ - mp_digit tmp; - int err; - - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(c != NULL); - - if ((err = mpi_to_ltc_error(mp_mod_d(a, b, &tmp))) != CRYPT_OK) { - return err; - } - *c = tmp; - return CRYPT_OK; -} - -/* gcd */ -static int gcd(void *a, void *b, void *c) -{ - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(b != NULL); - LTC_ARGCHK(c != NULL); - return mpi_to_ltc_error(mp_gcd(a, b, c)); -} - -/* lcm */ -static int lcm(void *a, void *b, void *c) -{ - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(b != NULL); - LTC_ARGCHK(c != NULL); - return mpi_to_ltc_error(mp_lcm(a, b, c)); -} - -static int mulmod(void *a, void *b, void *c, void *d) -{ - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(b != NULL); - LTC_ARGCHK(c != NULL); - LTC_ARGCHK(d != NULL); - return mpi_to_ltc_error(mp_mulmod(a,b,c,d)); -} - -static int sqrmod(void *a, void *b, void *c) -{ - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(b != NULL); - LTC_ARGCHK(c != NULL); - return mpi_to_ltc_error(mp_sqrmod(a,b,c)); -} - -/* invmod */ -static int invmod(void *a, void *b, void *c) -{ - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(b != NULL); - LTC_ARGCHK(c != NULL); - return mpi_to_ltc_error(mp_invmod(a, b, c)); -} - -/* setup */ -static int montgomery_setup(void *a, void **b) -{ - int err; - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(b != NULL); - *b = XCALLOC(1, sizeof(mp_digit)); - if (*b == NULL) { - return CRYPT_MEM; - } - if ((err = mpi_to_ltc_error(mp_montgomery_setup(a, (mp_digit *)*b))) != CRYPT_OK) { - XFREE(*b); - } - return err; -} - -/* get normalization value */ -static int montgomery_normalization(void *a, void *b) -{ - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(b != NULL); - return mpi_to_ltc_error(mp_montgomery_calc_normalization(a, b)); -} - -/* reduce */ -static int montgomery_reduce(void *a, void *b, void *c) -{ - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(b != NULL); - LTC_ARGCHK(c != NULL); - return mpi_to_ltc_error(mp_montgomery_reduce(a, b, *((mp_digit *)c))); -} - -/* clean up */ -static void montgomery_deinit(void *a) -{ - XFREE(a); -} - -static int exptmod(void *a, void *b, void *c, void *d) -{ - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(b != NULL); - LTC_ARGCHK(c != NULL); - LTC_ARGCHK(d != NULL); - return mpi_to_ltc_error(mp_exptmod(a,b,c,d)); -} - -static int isprime(void *a, int *b) -{ - int err; - LTC_ARGCHK(a != NULL); - LTC_ARGCHK(b != NULL); - err = mpi_to_ltc_error(mp_prime_is_prime(a, 8, b)); - *b = (*b == MP_YES) ? LTC_MP_YES : LTC_MP_NO; - return err; -} - -const ltc_math_descriptor ltm_desc = { - - "LibTomMath", - (int)DIGIT_BIT, - - &init, - &init_copy, - &deinit, - - &neg, - ©, - - &set_int, - &get_int, - &get_digit, - &get_digit_count, - &compare, - &compare_d, - &count_bits, - &count_lsb_bits, - &twoexpt, - - &read_radix, - &write_radix, - &unsigned_size, - &unsigned_write, - &unsigned_read, - - &add, - &addi, - &sub, - &subi, - &mul, - &muli, - &sqr, - ÷, - &div_2, - &modi, - &gcd, - &lcm, - - &mulmod, - &sqrmod, - &invmod, - - &montgomery_setup, - &montgomery_normalization, - &montgomery_reduce, - &montgomery_deinit, - - &exptmod, - &isprime, - -#ifdef LTC_MECC -#ifdef LTC_MECC_FP - <c_ecc_fp_mulmod, -#else - <c_ecc_mulmod, -#endif - <c_ecc_projective_add_point, - <c_ecc_projective_dbl_point, - <c_ecc_map, -#ifdef LTC_ECC_SHAMIR -#ifdef LTC_MECC_FP - <c_ecc_fp_mul2add, -#else - <c_ecc_mul2add, -#endif /* LTC_MECC_FP */ -#else - NULL, -#endif /* LTC_ECC_SHAMIR */ -#else - NULL, NULL, NULL, NULL, NULL, -#endif /* LTC_MECC */ - -#ifdef LTC_MRSA - &rsa_make_key, - &rsa_exptmod, -#else - NULL, NULL -#endif -}; - - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/math/ltm_desc.c,v $ */ -/* $Revision: 1.31 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/math/multi.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/math/multi.c deleted file mode 100644 index 7d40040..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/math/multi.c +++ /dev/null @@ -1,61 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../headers/tomcrypt.h" - -#ifdef MPI -#include - -int ltc_init_multi(void **a, ...) -{ - void **cur = a; - int np = 0; - va_list args; - - va_start(args, a); - while (cur != NULL) { - if (mp_init(cur) != CRYPT_OK) { - /* failed */ - va_list clean_list; - - va_start(clean_list, a); - cur = a; - while (np--) { - mp_clear(*cur); - cur = va_arg(clean_list, void**); - } - va_end(clean_list); - return CRYPT_MEM; - } - ++np; - cur = va_arg(args, void**); - } - va_end(args); - return CRYPT_OK; -} - -void ltc_deinit_multi(void *a, ...) -{ - void *cur = a; - va_list args; - - va_start(args, a); - while (cur != NULL) { - mp_clear(cur); - cur = va_arg(args, void *); - } - va_end(args); -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/math/multi.c,v $ */ -/* $Revision: 1.6 $ */ -/* $Date: 2006/12/28 01:27:23 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/math/rand_prime.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/math/rand_prime.c deleted file mode 100644 index 913fa95..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/math/rand_prime.c +++ /dev/null @@ -1,87 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../headers/tomcrypt.h" - -/** - @file rand_prime.c - Generate a random prime, Tom St Denis -*/ - -#define USE_BBS 1 - -int rand_prime(void *N, long len, prng_state *prng, int wprng) -{ - int err, res, type; - unsigned char *buf; - - LTC_ARGCHK(N != NULL); - - /* get type */ - if (len < 0) { - type = USE_BBS; - len = -len; - } else { - type = 0; - } - - /* allow sizes between 2 and 512 bytes for a prime size */ - if (len < 2 || len > 512) { - return CRYPT_INVALID_PRIME_SIZE; - } - - /* valid PRNG? Better be! */ - if ((err = prng_is_valid(wprng)) != CRYPT_OK) { - return err; - } - - /* allocate buffer to work with */ - buf = XCALLOC(1, len); - if (buf == NULL) { - return CRYPT_MEM; - } - - do { - /* generate value */ - if (prng_descriptor[wprng].read(buf, len, prng) != (unsigned long)len) { - XFREE(buf); - return CRYPT_ERROR_READPRNG; - } - - /* munge bits */ - buf[0] |= 0x80 | 0x40; - buf[len-1] |= 0x01 | ((type & USE_BBS) ? 0x02 : 0x00); - - /* load value */ - if ((err = mp_read_unsigned_bin(N, buf, len)) != CRYPT_OK) { - XFREE(buf); - return err; - } - - /* test */ - if ((err = mp_prime_is_prime(N, 8, &res)) != CRYPT_OK) { - XFREE(buf); - return err; - } - } while (res == LTC_MP_NO); - -#ifdef LTC_CLEAN_STACK - zeromem(buf, len); -#endif - - XFREE(buf); - return CRYPT_OK; -} - - - -/* $Source: /cvs/libtom/libtomcrypt/src/math/rand_prime.c,v $ */ -/* $Revision: 1.7 $ */ -/* $Date: 2006/12/28 01:27:23 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/base64_decode.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/base64_decode.c deleted file mode 100644 index 3d13393..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/base64_decode.c +++ /dev/null @@ -1,104 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../headers/tomcrypt.h" - -/** - @file base64_decode.c - Compliant base64 code donated by Wayne Scott (wscott@bitmover.com) -*/ - - -#ifdef LTC_BASE64 - -static const unsigned char map[256] = { -255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, -255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, -255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, -255, 255, 255, 255, 255, 255, 255, 62, 255, 255, 255, 63, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, -255, 254, 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 255, -255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 255, 255, 255, 255, 255, 255, 255, 255, 255, -255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, -255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, -255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, -255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, -255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, -255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, -255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, -255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, -255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, -255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, -255, 255, 255, 255 }; - -/** - base64 decode a block of memory - @param in The base64 data to decode - @param inlen The length of the base64 data - @param out [out] The destination of the binary decoded data - @param outlen [in/out] The max size and resulting size of the decoded data - @return CRYPT_OK if successful -*/ -int base64_decode(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen) -{ - unsigned long t, x, y, z; - unsigned char c; - int g; - - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); - - g = 3; - for (x = y = z = t = 0; x < inlen; x++) { - c = map[in[x]&0xFF]; - if (c == 255) continue; - /* the final = symbols are read and used to trim the remaining bytes */ - if (c == 254) { - c = 0; - /* prevent g < 0 which would potentially allow an overflow later */ - if (--g < 0) { - return CRYPT_INVALID_PACKET; - } - } else if (g != 3) { - /* we only allow = to be at the end */ - return CRYPT_INVALID_PACKET; - } - - t = (t<<6)|c; - - if (++y == 4) { - if (z + g > *outlen) { - return CRYPT_BUFFER_OVERFLOW; - } - out[z++] = (unsigned char)((t>>16)&255); - if (g > 1) out[z++] = (unsigned char)((t>>8)&255); - if (g > 2) out[z++] = (unsigned char)(t&255); - y = t = 0; - } - } - if (y != 0) { - return CRYPT_INVALID_PACKET; - } - *outlen = z; - return CRYPT_OK; -} - -#endif - - -/* $Source: /cvs/libtom/libtomcrypt/src/misc/base64/base64_decode.c,v $ */ -/* $Revision: 1.6 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_argchk.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_argchk.c deleted file mode 100644 index 537516d..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_argchk.c +++ /dev/null @@ -1,30 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../headers/tomcrypt.h" -#include - -/** - @file crypt_argchk.c - Perform argument checking, Tom St Denis -*/ - -#if (ARGTYPE == 0) -void crypt_argchk(char *v, char *s, int d) -{ - fprintf(stderr, "LTC_ARGCHK '%s' failure on line %d of file %s\n", - v, d, s); - (void)raise(SIGABRT); -} -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_argchk.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_find_hash.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_find_hash.c deleted file mode 100644 index fef2d8c..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_find_hash.c +++ /dev/null @@ -1,40 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../headers/tomcrypt.h" - -/** - @file crypt_find_hash.c - Find a hash, Tom St Denis -*/ - -/** - Find a registered hash by name - @param name The name of the hash to look for - @return >= 0 if found, -1 if not present -*/ -int find_hash(const char *name) -{ - int x; - LTC_ARGCHK(name != NULL); - LTC_MUTEX_LOCK(<c_hash_mutex); - for (x = 0; x < TAB_SIZE; x++) { - if (hash_descriptor[x].name != NULL && XSTRCMP(hash_descriptor[x].name, name) == 0) { - LTC_MUTEX_UNLOCK(<c_hash_mutex); - return x; - } - } - LTC_MUTEX_UNLOCK(<c_hash_mutex); - return -1; -} - -/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_find_hash.c,v $ */ -/* $Revision: 1.7 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_find_prng.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_find_prng.c deleted file mode 100644 index fafbb0e..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_find_prng.c +++ /dev/null @@ -1,41 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../headers/tomcrypt.h" - -/** - @file crypt_find_prng.c - Find a PRNG, Tom St Denis -*/ - -/** - Find a registered PRNG by name - @param name The name of the PRNG to look for - @return >= 0 if found, -1 if not present -*/ -int find_prng(const char *name) -{ - int x; - LTC_ARGCHK(name != NULL); - LTC_MUTEX_LOCK(<c_prng_mutex); - for (x = 0; x < TAB_SIZE; x++) { - if ((prng_descriptor[x].name != NULL) && XSTRCMP(prng_descriptor[x].name, name) == 0) { - LTC_MUTEX_UNLOCK(<c_prng_mutex); - return x; - } - } - LTC_MUTEX_UNLOCK(<c_prng_mutex); - return -1; -} - - -/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_find_prng.c,v $ */ -/* $Revision: 1.7 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_hash_descriptor.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_hash_descriptor.c deleted file mode 100644 index 5925fd2..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_hash_descriptor.c +++ /dev/null @@ -1,27 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../headers/tomcrypt.h" - -/** - @file crypt_hash_descriptor.c - Stores the hash descriptor table, Tom St Denis -*/ - -struct ltc_hash_descriptor hash_descriptor[TAB_SIZE] = { -{ NULL, 0, 0, 0, { 0 }, 0, NULL, NULL, NULL, NULL, NULL } -}; - -LTC_MUTEX_GLOBAL(ltc_hash_mutex) - - -/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_hash_descriptor.c,v $ */ -/* $Revision: 1.10 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_hash_is_valid.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_hash_is_valid.c deleted file mode 100644 index 8ed5105..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_hash_is_valid.c +++ /dev/null @@ -1,36 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../headers/tomcrypt.h" - -/** - @file crypt_hash_is_valid.c - Determine if hash is valid, Tom St Denis -*/ - -/* - Test if a hash index is valid - @param idx The index of the hash to search for - @return CRYPT_OK if valid -*/ -int hash_is_valid(int idx) -{ - LTC_MUTEX_LOCK(<c_hash_mutex); - if (idx < 0 || idx >= TAB_SIZE || hash_descriptor[idx].name == NULL) { - LTC_MUTEX_UNLOCK(<c_hash_mutex); - return CRYPT_INVALID_HASH; - } - LTC_MUTEX_UNLOCK(<c_hash_mutex); - return CRYPT_OK; -} - -/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_hash_is_valid.c,v $ */ -/* $Revision: 1.6 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_libc.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_libc.c deleted file mode 100644 index bcc89f4..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_libc.c +++ /dev/null @@ -1,43 +0,0 @@ -/*****************************************************************************/ -/* crypt_libc.c Copyright (c) Ladislav Zezula 2010 */ -/*---------------------------------------------------------------------------*/ -/* Description: */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 05.05.10 1.00 Lad The first version of crypt_libc.c */ -/*****************************************************************************/ - -// LibTomCrypt header -#include -#include "../headers/tomcrypt.h" - -void * LibTomMalloc(size_t n) -{ - return malloc(n); -} - -void * LibTomCalloc(size_t n, size_t s) -{ - return calloc(n, s); -} - -void * LibTomRealloc(void *p, size_t n) -{ - return realloc(p, n); -} - -void LibTomFree(void * p) -{ - free(p); -} - -clock_t LibTomClock(void) -{ - return clock(); -} - -void LibTomQsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)) -{ - qsort(base, nmemb, size, compar); -} diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_ltc_mp_descriptor.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_ltc_mp_descriptor.c deleted file mode 100644 index c02a96f..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_ltc_mp_descriptor.c +++ /dev/null @@ -1,13 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../headers/tomcrypt.h" - -ltc_math_descriptor ltc_mp = {0}; diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_prng_descriptor.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_prng_descriptor.c deleted file mode 100644 index c5b39e0..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_prng_descriptor.c +++ /dev/null @@ -1,26 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../headers/tomcrypt.h" - -/** - @file crypt_prng_descriptor.c - Stores the PRNG descriptors, Tom St Denis -*/ -struct ltc_prng_descriptor prng_descriptor[TAB_SIZE] = { -{ NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } -}; - -LTC_MUTEX_GLOBAL(ltc_prng_mutex) - - -/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_prng_descriptor.c,v $ */ -/* $Revision: 1.8 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_prng_is_valid.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_prng_is_valid.c deleted file mode 100644 index d38fd3a..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_prng_is_valid.c +++ /dev/null @@ -1,36 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../headers/tomcrypt.h" - -/** - @file crypt_prng_is_valid.c - Determine if PRNG is valid, Tom St Denis -*/ - -/* - Test if a PRNG index is valid - @param idx The index of the PRNG to search for - @return CRYPT_OK if valid -*/ -int prng_is_valid(int idx) -{ - LTC_MUTEX_LOCK(<c_prng_mutex); - if (idx < 0 || idx >= TAB_SIZE || prng_descriptor[idx].name == NULL) { - LTC_MUTEX_UNLOCK(<c_prng_mutex); - return CRYPT_INVALID_PRNG; - } - LTC_MUTEX_UNLOCK(<c_prng_mutex); - return CRYPT_OK; -} - -/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_prng_is_valid.c,v $ */ -/* $Revision: 1.6 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_register_hash.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_register_hash.c deleted file mode 100644 index 1730091..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_register_hash.c +++ /dev/null @@ -1,54 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../headers/tomcrypt.h" - -/** - @file crypt_register_hash.c - Register a HASH, Tom St Denis -*/ - -/** - Register a hash with the descriptor table - @param hash The hash you wish to register - @return value >= 0 if successfully added (or already present), -1 if unsuccessful -*/ -int register_hash(const struct ltc_hash_descriptor *hash) -{ - int x; - - LTC_ARGCHK(hash != NULL); - - /* is it already registered? */ - LTC_MUTEX_LOCK(<c_hash_mutex); - for (x = 0; x < TAB_SIZE; x++) { - if (XMEMCMP(&hash_descriptor[x], hash, sizeof(struct ltc_hash_descriptor)) == 0) { - LTC_MUTEX_UNLOCK(<c_hash_mutex); - return x; - } - } - - /* find a blank spot */ - for (x = 0; x < TAB_SIZE; x++) { - if (hash_descriptor[x].name == NULL) { - XMEMCPY(&hash_descriptor[x], hash, sizeof(struct ltc_hash_descriptor)); - LTC_MUTEX_UNLOCK(<c_hash_mutex); - return x; - } - } - - /* no spot */ - LTC_MUTEX_UNLOCK(<c_hash_mutex); - return -1; -} - -/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_register_hash.c,v $ */ -/* $Revision: 1.7 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_register_prng.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_register_prng.c deleted file mode 100644 index 29fc9bd..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/crypt_register_prng.c +++ /dev/null @@ -1,54 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../headers/tomcrypt.h" - -/** - @file crypt_register_prng.c - Register a PRNG, Tom St Denis -*/ - -/** - Register a PRNG with the descriptor table - @param prng The PRNG you wish to register - @return value >= 0 if successfully added (or already present), -1 if unsuccessful -*/ -int register_prng(const struct ltc_prng_descriptor *prng) -{ - int x; - - LTC_ARGCHK(prng != NULL); - - /* is it already registered? */ - LTC_MUTEX_LOCK(<c_prng_mutex); - for (x = 0; x < TAB_SIZE; x++) { - if (XMEMCMP(&prng_descriptor[x], prng, sizeof(struct ltc_prng_descriptor)) == 0) { - LTC_MUTEX_UNLOCK(<c_prng_mutex); - return x; - } - } - - /* find a blank spot */ - for (x = 0; x < TAB_SIZE; x++) { - if (prng_descriptor[x].name == NULL) { - XMEMCPY(&prng_descriptor[x], prng, sizeof(struct ltc_prng_descriptor)); - LTC_MUTEX_UNLOCK(<c_prng_mutex); - return x; - } - } - - /* no spot */ - LTC_MUTEX_UNLOCK(<c_prng_mutex); - return -1; -} - -/* $Source: /cvs/libtom/libtomcrypt/src/misc/crypt/crypt_register_prng.c,v $ */ -/* $Revision: 1.8 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/zeromem.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/zeromem.c deleted file mode 100644 index faa0efa..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/misc/zeromem.c +++ /dev/null @@ -1,34 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../headers/tomcrypt.h" - -/** - @file zeromem.c - Zero a block of memory, Tom St Denis -*/ - -/** - Zero a block of memory - @param out The destination of the area to zero - @param outlen The length of the area to zero (octets) -*/ -void zeromem(void *out, size_t outlen) -{ - unsigned char *mem = out; - LTC_ARGCHKVD(out != NULL); - while (outlen-- > 0) { - *mem++ = 0; - } -} - -/* $Source: /cvs/libtom/libtomcrypt/src/misc/zeromem.c,v $ */ -/* $Revision: 1.7 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_bit_string.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_bit_string.c deleted file mode 100644 index e536867..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_bit_string.c +++ /dev/null @@ -1,102 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_decode_bit_string.c - ASN.1 DER, encode a BIT STRING, Tom St Denis -*/ - - -#ifdef LTC_DER - -/** - Store a BIT STRING - @param in The DER encoded BIT STRING - @param inlen The size of the DER BIT STRING - @param out [out] The array of bits stored (one per char) - @param outlen [in/out] The number of bits stored - @return CRYPT_OK if successful -*/ -int der_decode_bit_string(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen) -{ - unsigned long dlen, blen, x, y; - - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); - - /* packet must be at least 4 bytes */ - if (inlen < 4) { - return CRYPT_INVALID_ARG; - } - - /* check for 0x03 */ - if ((in[0]&0x1F) != 0x03) { - return CRYPT_INVALID_PACKET; - } - - /* offset in the data */ - x = 1; - - /* get the length of the data */ - if (in[x] & 0x80) { - /* long format get number of length bytes */ - y = in[x++] & 0x7F; - - /* invalid if 0 or > 2 */ - if (y == 0 || y > 2) { - return CRYPT_INVALID_PACKET; - } - - /* read the data len */ - dlen = 0; - while (y--) { - dlen = (dlen << 8) | (unsigned long)in[x++]; - } - } else { - /* short format */ - dlen = in[x++] & 0x7F; - } - - /* is the data len too long or too short? */ - if ((dlen == 0) || (dlen + x > inlen)) { - return CRYPT_INVALID_PACKET; - } - - /* get padding count */ - blen = ((dlen - 1) << 3) - (in[x++] & 7); - - /* too many bits? */ - if (blen > *outlen) { - *outlen = blen; - return CRYPT_BUFFER_OVERFLOW; - } - - /* decode/store the bits */ - for (y = 0; y < blen; y++) { - out[y] = (in[x] & (1 << (7 - (y & 7)))) ? 1 : 0; - if ((y & 7) == 7) { - ++x; - } - } - - /* we done */ - *outlen = blen; - return CRYPT_OK; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/bit/der_decode_bit_string.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_boolean.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_boolean.c deleted file mode 100644 index 617d4e8..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_boolean.c +++ /dev/null @@ -1,47 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_decode_boolean.c - ASN.1 DER, decode a BOOLEAN, Tom St Denis -*/ - - -#ifdef LTC_DER - -/** - Read a BOOLEAN - @param in The destination for the DER encoded BOOLEAN - @param inlen The size of the DER BOOLEAN - @param out [out] The boolean to decode - @return CRYPT_OK if successful -*/ -int der_decode_boolean(const unsigned char *in, unsigned long inlen, - int *out) -{ - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(out != NULL); - - if (inlen != 3 || in[0] != 0x01 || in[1] != 0x01 || (in[2] != 0x00 && in[2] != 0xFF)) { - return CRYPT_INVALID_ARG; - } - - *out = (in[2]==0xFF) ? 1 : 0; - - return CRYPT_OK; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/boolean/der_decode_boolean.c,v $ */ -/* $Revision: 1.2 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_choice.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_choice.c deleted file mode 100644 index 44a0891..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_choice.c +++ /dev/null @@ -1,182 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_decode_choice.c - ASN.1 DER, decode a CHOICE, Tom St Denis -*/ - -#ifdef LTC_DER - -/** - Decode a CHOICE - @param in The DER encoded input - @param inlen [in/out] The size of the input and resulting size of read type - @param list The list of items to decode - @param outlen The number of items in the list - @return CRYPT_OK on success -*/ -int der_decode_choice(const unsigned char *in, unsigned long *inlen, - ltc_asn1_list *list, unsigned long outlen) -{ - unsigned long size, x, z; - void *data; - - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(inlen != NULL); - LTC_ARGCHK(list != NULL); - - /* get blk size */ - if (*inlen < 2) { - return CRYPT_INVALID_PACKET; - } - - /* set all of the "used" flags to zero */ - for (x = 0; x < outlen; x++) { - list[x].used = 0; - } - - /* now scan until we have a winner */ - for (x = 0; x < outlen; x++) { - size = list[x].size; - data = list[x].data; - - switch (list[x].type) { - case LTC_ASN1_INTEGER: - if (der_decode_integer(in, *inlen, data) == CRYPT_OK) { - if (der_length_integer(data, &z) == CRYPT_OK) { - list[x].used = 1; - *inlen = z; - return CRYPT_OK; - } - } - break; - - case LTC_ASN1_SHORT_INTEGER: - if (der_decode_short_integer(in, *inlen, data) == CRYPT_OK) { - if (der_length_short_integer(size, &z) == CRYPT_OK) { - list[x].used = 1; - *inlen = z; - return CRYPT_OK; - } - } - break; - - case LTC_ASN1_BIT_STRING: - if (der_decode_bit_string(in, *inlen, data, &size) == CRYPT_OK) { - if (der_length_bit_string(size, &z) == CRYPT_OK) { - list[x].used = 1; - list[x].size = size; - *inlen = z; - return CRYPT_OK; - } - } - break; - - case LTC_ASN1_OCTET_STRING: - if (der_decode_octet_string(in, *inlen, data, &size) == CRYPT_OK) { - if (der_length_octet_string(size, &z) == CRYPT_OK) { - list[x].used = 1; - list[x].size = size; - *inlen = z; - return CRYPT_OK; - } - } - break; - - case LTC_ASN1_NULL: - if (*inlen == 2 && in[x] == 0x05 && in[x+1] == 0x00) { - *inlen = 2; - list[x].used = 1; - return CRYPT_OK; - } - break; - - case LTC_ASN1_OBJECT_IDENTIFIER: - if (der_decode_object_identifier(in, *inlen, data, &size) == CRYPT_OK) { - if (der_length_object_identifier(data, size, &z) == CRYPT_OK) { - list[x].used = 1; - list[x].size = size; - *inlen = z; - return CRYPT_OK; - } - } - break; - - case LTC_ASN1_IA5_STRING: - if (der_decode_ia5_string(in, *inlen, data, &size) == CRYPT_OK) { - if (der_length_ia5_string(data, size, &z) == CRYPT_OK) { - list[x].used = 1; - list[x].size = size; - *inlen = z; - return CRYPT_OK; - } - } - break; - - - case LTC_ASN1_PRINTABLE_STRING: - if (der_decode_printable_string(in, *inlen, data, &size) == CRYPT_OK) { - if (der_length_printable_string(data, size, &z) == CRYPT_OK) { - list[x].used = 1; - list[x].size = size; - *inlen = z; - return CRYPT_OK; - } - } - break; - - case LTC_ASN1_UTF8_STRING: - if (der_decode_utf8_string(in, *inlen, data, &size) == CRYPT_OK) { - if (der_length_utf8_string(data, size, &z) == CRYPT_OK) { - list[x].used = 1; - list[x].size = size; - *inlen = z; - return CRYPT_OK; - } - } - break; - - case LTC_ASN1_UTCTIME: - z = *inlen; - if (der_decode_utctime(in, &z, data) == CRYPT_OK) { - list[x].used = 1; - *inlen = z; - return CRYPT_OK; - } - break; - - case LTC_ASN1_SET: - case LTC_ASN1_SETOF: - case LTC_ASN1_SEQUENCE: - if (der_decode_sequence(in, *inlen, data, size) == CRYPT_OK) { - if (der_length_sequence(data, size, &z) == CRYPT_OK) { - list[x].used = 1; - *inlen = z; - return CRYPT_OK; - } - } - break; - - default: - return CRYPT_INVALID_ARG; - } - } - - return CRYPT_INVALID_PACKET; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/choice/der_decode_choice.c,v $ */ -/* $Revision: 1.9 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_ia5_string.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_ia5_string.c deleted file mode 100644 index f2e073b..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_ia5_string.c +++ /dev/null @@ -1,96 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_decode_ia5_string.c - ASN.1 DER, encode a IA5 STRING, Tom St Denis -*/ - - -#ifdef LTC_DER - -/** - Store a IA5 STRING - @param in The DER encoded IA5 STRING - @param inlen The size of the DER IA5 STRING - @param out [out] The array of octets stored (one per char) - @param outlen [in/out] The number of octets stored - @return CRYPT_OK if successful -*/ -int der_decode_ia5_string(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen) -{ - unsigned long x, y, len; - int t; - - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); - - /* must have header at least */ - if (inlen < 2) { - return CRYPT_INVALID_PACKET; - } - - /* check for 0x16 */ - if ((in[0] & 0x1F) != 0x16) { - return CRYPT_INVALID_PACKET; - } - x = 1; - - /* decode the length */ - if (in[x] & 0x80) { - /* valid # of bytes in length are 1,2,3 */ - y = in[x] & 0x7F; - if ((y == 0) || (y > 3) || ((x + y) > inlen)) { - return CRYPT_INVALID_PACKET; - } - - /* read the length in */ - len = 0; - ++x; - while (y--) { - len = (len << 8) | in[x++]; - } - } else { - len = in[x++] & 0x7F; - } - - /* is it too long? */ - if (len > *outlen) { - *outlen = len; - return CRYPT_BUFFER_OVERFLOW; - } - - if (len + x > inlen) { - return CRYPT_INVALID_PACKET; - } - - /* read the data */ - for (y = 0; y < len; y++) { - t = der_ia5_value_decode(in[x++]); - if (t == -1) { - return CRYPT_INVALID_ARG; - } - out[y] = t; - } - - *outlen = y; - - return CRYPT_OK; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/ia5/der_decode_ia5_string.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_integer.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_integer.c deleted file mode 100644 index cca2745..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_integer.c +++ /dev/null @@ -1,110 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_decode_integer.c - ASN.1 DER, decode an integer, Tom St Denis -*/ - - -#ifdef LTC_DER - -/** - Read a mp_int integer - @param in The DER encoded data - @param inlen Size of DER encoded data - @param num The first mp_int to decode - @return CRYPT_OK if successful -*/ -int der_decode_integer(const unsigned char *in, unsigned long inlen, void *num) -{ - unsigned long x, y, z; - int err; - - LTC_ARGCHK(num != NULL); - LTC_ARGCHK(in != NULL); - - /* min DER INTEGER is 0x02 01 00 == 0 */ - if (inlen < (1 + 1 + 1)) { - return CRYPT_INVALID_PACKET; - } - - /* ok expect 0x02 when we AND with 0001 1111 [1F] */ - x = 0; - if ((in[x++] & 0x1F) != 0x02) { - return CRYPT_INVALID_PACKET; - } - - /* now decode the len stuff */ - z = in[x++]; - - if ((z & 0x80) == 0x00) { - /* short form */ - - /* will it overflow? */ - if (x + z > inlen) { - return CRYPT_INVALID_PACKET; - } - - /* no so read it */ - if ((err = mp_read_unsigned_bin(num, (unsigned char *)in + x, z)) != CRYPT_OK) { - return err; - } - } else { - /* long form */ - z &= 0x7F; - - /* will number of length bytes overflow? (or > 4) */ - if (((x + z) > inlen) || (z > 4) || (z == 0)) { - return CRYPT_INVALID_PACKET; - } - - /* now read it in */ - y = 0; - while (z--) { - y = ((unsigned long)(in[x++])) | (y << 8); - } - - /* now will reading y bytes overrun? */ - if ((x + y) > inlen) { - return CRYPT_INVALID_PACKET; - } - - /* no so read it */ - if ((err = mp_read_unsigned_bin(num, (unsigned char *)in + x, y)) != CRYPT_OK) { - return err; - } - } - - /* see if it's negative */ - if (in[x] & 0x80) { - void *tmp; - if (mp_init(&tmp) != CRYPT_OK) { - return CRYPT_MEM; - } - - if (mp_2expt(tmp, mp_count_bits(num)) != CRYPT_OK || mp_sub(num, tmp, num) != CRYPT_OK) { - mp_clear(tmp); - return CRYPT_MEM; - } - mp_clear(tmp); - } - - return CRYPT_OK; - -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/integer/der_decode_integer.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_object_identifier.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_object_identifier.c deleted file mode 100644 index e7baae8..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_object_identifier.c +++ /dev/null @@ -1,99 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_decode_object_identifier.c - ASN.1 DER, Decode Object Identifier, Tom St Denis -*/ - -#ifdef LTC_DER -/** - Decode OID data and store the array of integers in words - @param in The OID DER encoded data - @param inlen The length of the OID data - @param words [out] The destination of the OID words - @param outlen [in/out] The number of OID words - @return CRYPT_OK if successful -*/ -int der_decode_object_identifier(const unsigned char *in, unsigned long inlen, - unsigned long *words, unsigned long *outlen) -{ - unsigned long x, y, t, len; - - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(words != NULL); - LTC_ARGCHK(outlen != NULL); - - /* header is at least 3 bytes */ - if (inlen < 3) { - return CRYPT_INVALID_PACKET; - } - - /* must be room for at least two words */ - if (*outlen < 2) { - return CRYPT_BUFFER_OVERFLOW; - } - - /* decode the packet header */ - x = 0; - if ((in[x++] & 0x1F) != 0x06) { - return CRYPT_INVALID_PACKET; - } - - /* get the length */ - if (in[x] < 128) { - len = in[x++]; - } else { - if (in[x] < 0x81 || in[x] > 0x82) { - return CRYPT_INVALID_PACKET; - } - y = in[x++] & 0x7F; - len = 0; - while (y--) { - len = (len << 8) | (unsigned long)in[x++]; - } - } - - if (len < 1 || (len + x) > inlen) { - return CRYPT_INVALID_PACKET; - } - - /* decode words */ - y = 0; - t = 0; - while (len--) { - t = (t << 7) | (in[x] & 0x7F); - if (!(in[x++] & 0x80)) { - /* store t */ - if (y >= *outlen) { - return CRYPT_BUFFER_OVERFLOW; - } - if (y == 0) { - words[0] = t / 40; - words[1] = t % 40; - y = 2; - } else { - words[y++] = t; - } - t = 0; - } - } - - *outlen = y; - return CRYPT_OK; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/object_identifier/der_decode_object_identifier.c,v $ */ -/* $Revision: 1.6 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_octet_string.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_octet_string.c deleted file mode 100644 index 523d0ba..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_octet_string.c +++ /dev/null @@ -1,91 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_decode_octet_string.c - ASN.1 DER, encode a OCTET STRING, Tom St Denis -*/ - - -#ifdef LTC_DER - -/** - Store a OCTET STRING - @param in The DER encoded OCTET STRING - @param inlen The size of the DER OCTET STRING - @param out [out] The array of octets stored (one per char) - @param outlen [in/out] The number of octets stored - @return CRYPT_OK if successful -*/ -int der_decode_octet_string(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen) -{ - unsigned long x, y, len; - - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); - - /* must have header at least */ - if (inlen < 2) { - return CRYPT_INVALID_PACKET; - } - - /* check for 0x04 */ - if ((in[0] & 0x1F) != 0x04) { - return CRYPT_INVALID_PACKET; - } - x = 1; - - /* decode the length */ - if (in[x] & 0x80) { - /* valid # of bytes in length are 1,2,3 */ - y = in[x] & 0x7F; - if ((y == 0) || (y > 3) || ((x + y) > inlen)) { - return CRYPT_INVALID_PACKET; - } - - /* read the length in */ - len = 0; - ++x; - while (y--) { - len = (len << 8) | in[x++]; - } - } else { - len = in[x++] & 0x7F; - } - - /* is it too long? */ - if (len > *outlen) { - *outlen = len; - return CRYPT_BUFFER_OVERFLOW; - } - - if (len + x > inlen) { - return CRYPT_INVALID_PACKET; - } - - /* read the data */ - for (y = 0; y < len; y++) { - out[y] = in[x++]; - } - - *outlen = y; - - return CRYPT_OK; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/octet/der_decode_octet_string.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_printable_string.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_printable_string.c deleted file mode 100644 index f832593..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_printable_string.c +++ /dev/null @@ -1,96 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_decode_printable_string.c - ASN.1 DER, encode a printable STRING, Tom St Denis -*/ - - -#ifdef LTC_DER - -/** - Store a printable STRING - @param in The DER encoded printable STRING - @param inlen The size of the DER printable STRING - @param out [out] The array of octets stored (one per char) - @param outlen [in/out] The number of octets stored - @return CRYPT_OK if successful -*/ -int der_decode_printable_string(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen) -{ - unsigned long x, y, len; - int t; - - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); - - /* must have header at least */ - if (inlen < 2) { - return CRYPT_INVALID_PACKET; - } - - /* check for 0x13 */ - if ((in[0] & 0x1F) != 0x13) { - return CRYPT_INVALID_PACKET; - } - x = 1; - - /* decode the length */ - if (in[x] & 0x80) { - /* valid # of bytes in length are 1,2,3 */ - y = in[x] & 0x7F; - if ((y == 0) || (y > 3) || ((x + y) > inlen)) { - return CRYPT_INVALID_PACKET; - } - - /* read the length in */ - len = 0; - ++x; - while (y--) { - len = (len << 8) | in[x++]; - } - } else { - len = in[x++] & 0x7F; - } - - /* is it too long? */ - if (len > *outlen) { - *outlen = len; - return CRYPT_BUFFER_OVERFLOW; - } - - if (len + x > inlen) { - return CRYPT_INVALID_PACKET; - } - - /* read the data */ - for (y = 0; y < len; y++) { - t = der_printable_value_decode(in[x++]); - if (t == -1) { - return CRYPT_INVALID_ARG; - } - out[y] = t; - } - - *outlen = y; - - return CRYPT_OK; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/printable_string/der_decode_printable_string.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_sequence_ex.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_sequence_ex.c deleted file mode 100644 index 9b00f61..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_sequence_ex.c +++ /dev/null @@ -1,287 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" -#include - - -/** - @file der_decode_sequence_ex.c - ASN.1 DER, decode a SEQUENCE, Tom St Denis -*/ - -#ifdef LTC_DER - -/** - Decode a SEQUENCE - @param in The DER encoded input - @param inlen The size of the input - @param list The list of items to decode - @param outlen The number of items in the list - @param ordered Search an unordeded or ordered list - @return CRYPT_OK on success -*/ -int der_decode_sequence_ex(const unsigned char *in, unsigned long inlen, - ltc_asn1_list *list, unsigned long outlen, int ordered) -{ - int err, type; - unsigned long size, x, y, z, i, blksize; - void *data; - - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(list != NULL); - - /* get blk size */ - if (inlen < 2) { - return CRYPT_INVALID_PACKET; - } - - /* sequence type? We allow 0x30 SEQUENCE and 0x31 SET since fundamentally they're the same structure */ - x = 0; - if (in[x] != 0x30 && in[x] != 0x31) { - return CRYPT_INVALID_PACKET; - } - ++x; - - if (in[x] < 128) { - blksize = in[x++]; - } else if (in[x] & 0x80) { - if (in[x] < 0x81 || in[x] > 0x83) { - return CRYPT_INVALID_PACKET; - } - y = in[x++] & 0x7F; - - /* would reading the len bytes overrun? */ - if (x + y > inlen) { - return CRYPT_INVALID_PACKET; - } - - /* read len */ - blksize = 0; - while (y--) { - blksize = (blksize << 8) | (unsigned long)in[x++]; - } - } - - /* would this blksize overflow? */ - if (x + blksize > inlen) { - return CRYPT_INVALID_PACKET; - } - - /* mark all as unused */ - for (i = 0; i < outlen; i++) { - list[i].used = 0; - } - - /* ok read data */ - inlen = blksize; - for (i = 0; i < outlen; i++) { - z = 0; - type = list[i].type; - size = list[i].size; - data = list[i].data; - if (!ordered && list[i].used == 1) { continue; } - - if (type == LTC_ASN1_EOL) { - break; - } - - switch (type) { - case LTC_ASN1_BOOLEAN: - z = inlen; - if ((err = der_decode_boolean(in + x, z, ((int *)data))) != CRYPT_OK) { - goto LBL_ERR; - } - if ((err = der_length_boolean(&z)) != CRYPT_OK) { - goto LBL_ERR; - } - break; - - case LTC_ASN1_INTEGER: - z = inlen; - if ((err = der_decode_integer(in + x, z, data)) != CRYPT_OK) { - if (!ordered) { continue; } - goto LBL_ERR; - } - if ((err = der_length_integer(data, &z)) != CRYPT_OK) { - goto LBL_ERR; - } - break; - - case LTC_ASN1_SHORT_INTEGER: - z = inlen; - if ((err = der_decode_short_integer(in + x, z, data)) != CRYPT_OK) { - if (!ordered) { continue; } - goto LBL_ERR; - } - if ((err = der_length_short_integer(((unsigned long*)data)[0], &z)) != CRYPT_OK) { - goto LBL_ERR; - } - - break; - - case LTC_ASN1_BIT_STRING: - z = inlen; - if ((err = der_decode_bit_string(in + x, z, data, &size)) != CRYPT_OK) { - if (!ordered) { continue; } - goto LBL_ERR; - } - list[i].size = size; - if ((err = der_length_bit_string(size, &z)) != CRYPT_OK) { - goto LBL_ERR; - } - break; - - case LTC_ASN1_OCTET_STRING: - z = inlen; - if ((err = der_decode_octet_string(in + x, z, data, &size)) != CRYPT_OK) { - if (!ordered) { continue; } - goto LBL_ERR; - } - list[i].size = size; - if ((err = der_length_octet_string(size, &z)) != CRYPT_OK) { - goto LBL_ERR; - } - break; - - case LTC_ASN1_NULL: - if (inlen < 2 || in[x] != 0x05 || in[x+1] != 0x00) { - if (!ordered) { continue; } - err = CRYPT_INVALID_PACKET; - goto LBL_ERR; - } - z = 2; - break; - - case LTC_ASN1_OBJECT_IDENTIFIER: - z = inlen; - if ((err = der_decode_object_identifier(in + x, z, data, &size)) != CRYPT_OK) { - if (!ordered) { continue; } - goto LBL_ERR; - } - list[i].size = size; - if ((err = der_length_object_identifier(data, size, &z)) != CRYPT_OK) { - goto LBL_ERR; - } - break; - - case LTC_ASN1_IA5_STRING: - z = inlen; - if ((err = der_decode_ia5_string(in + x, z, data, &size)) != CRYPT_OK) { - if (!ordered) { continue; } - goto LBL_ERR; - } - list[i].size = size; - if ((err = der_length_ia5_string(data, size, &z)) != CRYPT_OK) { - goto LBL_ERR; - } - break; - - - case LTC_ASN1_PRINTABLE_STRING: - z = inlen; - if ((err = der_decode_printable_string(in + x, z, data, &size)) != CRYPT_OK) { - if (!ordered) { continue; } - goto LBL_ERR; - } - list[i].size = size; - if ((err = der_length_printable_string(data, size, &z)) != CRYPT_OK) { - goto LBL_ERR; - } - break; - - case LTC_ASN1_UTF8_STRING: - z = inlen; - if ((err = der_decode_utf8_string(in + x, z, data, &size)) != CRYPT_OK) { - if (!ordered) { continue; } - goto LBL_ERR; - } - list[i].size = size; - if ((err = der_length_utf8_string(data, size, &z)) != CRYPT_OK) { - goto LBL_ERR; - } - break; - - case LTC_ASN1_UTCTIME: - z = inlen; - if ((err = der_decode_utctime(in + x, &z, data)) != CRYPT_OK) { - if (!ordered) { continue; } - goto LBL_ERR; - } - break; - - case LTC_ASN1_SET: - z = inlen; - if ((err = der_decode_set(in + x, z, data, size)) != CRYPT_OK) { - if (!ordered) { continue; } - goto LBL_ERR; - } - if ((err = der_length_sequence(data, size, &z)) != CRYPT_OK) { - goto LBL_ERR; - } - break; - - case LTC_ASN1_SETOF: - case LTC_ASN1_SEQUENCE: - /* detect if we have the right type */ - if ((type == LTC_ASN1_SETOF && (in[x] & 0x3F) != 0x31) || (type == LTC_ASN1_SEQUENCE && (in[x] & 0x3F) != 0x30)) { - err = CRYPT_INVALID_PACKET; - goto LBL_ERR; - } - - z = inlen; - if ((err = der_decode_sequence(in + x, z, data, size)) != CRYPT_OK) { - if (!ordered) { continue; } - goto LBL_ERR; - } - if ((err = der_length_sequence(data, size, &z)) != CRYPT_OK) { - goto LBL_ERR; - } - break; - - - case LTC_ASN1_CHOICE: - z = inlen; - if ((err = der_decode_choice(in + x, &z, data, size)) != CRYPT_OK) { - if (!ordered) { continue; } - goto LBL_ERR; - } - break; - - default: - err = CRYPT_INVALID_ARG; - goto LBL_ERR; - } - x += z; - inlen -= z; - list[i].used = 1; - if (!ordered) { - /* restart the decoder */ - i = -1; - } - } - - for (i = 0; i < outlen; i++) { - if (list[i].used == 0) { - err = CRYPT_INVALID_PACKET; - goto LBL_ERR; - } - } - err = CRYPT_OK; - -LBL_ERR: - return err; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/sequence/der_decode_sequence_ex.c,v $ */ -/* $Revision: 1.16 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_sequence_flexi.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_sequence_flexi.c deleted file mode 100644 index 9c648bc..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_sequence_flexi.c +++ /dev/null @@ -1,386 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_decode_sequence_flexi.c - ASN.1 DER, decode an array of ASN.1 types with a flexi parser, Tom St Denis -*/ - -#ifdef LTC_DER - -static unsigned long fetch_length(const unsigned char *in, unsigned long inlen) -{ - unsigned long x, y, z; - - y = 0; - - /* skip type and read len */ - if (inlen < 2) { - return 0xFFFFFFFF; - } - ++in; ++y; - - /* read len */ - x = *in++; ++y; - - /* <128 means literal */ - if (x < 128) { - return x+y; - } - x &= 0x7F; /* the lower 7 bits are the length of the length */ - inlen -= 2; - - /* len means len of len! */ - if (x == 0 || x > 4 || x > inlen) { - return 0xFFFFFFFF; - } - - y += x; - z = 0; - while (x--) { - z = (z<<8) | ((unsigned long)*in); - ++in; - } - return z+y; -} - -/** - ASN.1 DER Flexi(ble) decoder will decode arbitrary DER packets and create a linked list of the decoded elements. - @param in The input buffer - @param inlen [in/out] The length of the input buffer and on output the amount of decoded data - @param out [out] A pointer to the linked list - @return CRYPT_OK on success. -*/ -int der_decode_sequence_flexi(const unsigned char *in, unsigned long *inlen, ltc_asn1_list **out) -{ - ltc_asn1_list *l; - unsigned long err, type, len, totlen, x, y; - void *realloc_tmp; - - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(inlen != NULL); - LTC_ARGCHK(out != NULL); - - l = NULL; - totlen = 0; - - /* scan the input and and get lengths and what not */ - while (*inlen) { - /* read the type byte */ - type = *in; - - /* fetch length */ - len = fetch_length(in, *inlen); - if (len > *inlen) { - err = CRYPT_INVALID_PACKET; - goto error; - } - - /* alloc new link */ - if (l == NULL) { - l = XCALLOC(1, sizeof(*l)); - if (l == NULL) { - err = CRYPT_MEM; - goto error; - } - } else { - l->next = XCALLOC(1, sizeof(*l)); - if (l->next == NULL) { - err = CRYPT_MEM; - goto error; - } - l->next->prev = l; - l = l->next; - } - - /* now switch on type */ - switch (type) { - case 0x01: /* BOOLEAN */ - l->type = LTC_ASN1_BOOLEAN; - l->size = 1; - l->data = XCALLOC(1, sizeof(int)); - - if ((err = der_decode_boolean(in, *inlen, l->data)) != CRYPT_OK) { - goto error; - } - - if ((err = der_length_boolean(&len)) != CRYPT_OK) { - goto error; - } - break; - - case 0x02: /* INTEGER */ - /* init field */ - l->type = LTC_ASN1_INTEGER; - l->size = 1; - if ((err = mp_init(&l->data)) != CRYPT_OK) { - goto error; - } - - /* decode field */ - if ((err = der_decode_integer(in, *inlen, l->data)) != CRYPT_OK) { - goto error; - } - - /* calc length of object */ - if ((err = der_length_integer(l->data, &len)) != CRYPT_OK) { - goto error; - } - break; - - case 0x03: /* BIT */ - /* init field */ - l->type = LTC_ASN1_BIT_STRING; - l->size = len * 8; /* *8 because we store decoded bits one per char and they are encoded 8 per char. */ - - if ((l->data = XCALLOC(1, l->size)) == NULL) { - err = CRYPT_MEM; - goto error; - } - - if ((err = der_decode_bit_string(in, *inlen, l->data, &l->size)) != CRYPT_OK) { - goto error; - } - - if ((err = der_length_bit_string(l->size, &len)) != CRYPT_OK) { - goto error; - } - break; - - case 0x04: /* OCTET */ - - /* init field */ - l->type = LTC_ASN1_OCTET_STRING; - l->size = len; - - if ((l->data = XCALLOC(1, l->size)) == NULL) { - err = CRYPT_MEM; - goto error; - } - - if ((err = der_decode_octet_string(in, *inlen, l->data, &l->size)) != CRYPT_OK) { - goto error; - } - - if ((err = der_length_octet_string(l->size, &len)) != CRYPT_OK) { - goto error; - } - break; - - case 0x05: /* NULL */ - - /* valid NULL is 0x05 0x00 */ - if (in[0] != 0x05 || in[1] != 0x00) { - err = CRYPT_INVALID_PACKET; - goto error; - } - - /* simple to store ;-) */ - l->type = LTC_ASN1_NULL; - l->data = NULL; - l->size = 0; - len = 2; - - break; - - case 0x06: /* OID */ - - /* init field */ - l->type = LTC_ASN1_OBJECT_IDENTIFIER; - l->size = len; - - if ((l->data = XCALLOC(len, sizeof(unsigned long))) == NULL) { - err = CRYPT_MEM; - goto error; - } - - if ((err = der_decode_object_identifier(in, *inlen, l->data, &l->size)) != CRYPT_OK) { - goto error; - } - - if ((err = der_length_object_identifier(l->data, l->size, &len)) != CRYPT_OK) { - goto error; - } - - /* resize it to save a bunch of mem */ - if ((realloc_tmp = XREALLOC(l->data, l->size * sizeof(unsigned long))) == NULL) { - /* out of heap but this is not an error */ - break; - } - l->data = realloc_tmp; - break; - - case 0x0C: /* UTF8 */ - - /* init field */ - l->type = LTC_ASN1_UTF8_STRING; - l->size = len; - - if ((l->data = XCALLOC(sizeof(wchar_t), l->size)) == NULL) { - err = CRYPT_MEM; - goto error; - } - - if ((err = der_decode_utf8_string(in, *inlen, l->data, &l->size)) != CRYPT_OK) { - goto error; - } - - if ((err = der_length_utf8_string(l->data, l->size, &len)) != CRYPT_OK) { - goto error; - } - break; - - case 0x13: /* PRINTABLE */ - - /* init field */ - l->type = LTC_ASN1_PRINTABLE_STRING; - l->size = len; - - if ((l->data = XCALLOC(1, l->size)) == NULL) { - err = CRYPT_MEM; - goto error; - } - - if ((err = der_decode_printable_string(in, *inlen, l->data, &l->size)) != CRYPT_OK) { - goto error; - } - - if ((err = der_length_printable_string(l->data, l->size, &len)) != CRYPT_OK) { - goto error; - } - break; - - case 0x16: /* IA5 */ - - /* init field */ - l->type = LTC_ASN1_IA5_STRING; - l->size = len; - - if ((l->data = XCALLOC(1, l->size)) == NULL) { - err = CRYPT_MEM; - goto error; - } - - if ((err = der_decode_ia5_string(in, *inlen, l->data, &l->size)) != CRYPT_OK) { - goto error; - } - - if ((err = der_length_ia5_string(l->data, l->size, &len)) != CRYPT_OK) { - goto error; - } - break; - - case 0x17: /* UTC TIME */ - - /* init field */ - l->type = LTC_ASN1_UTCTIME; - l->size = 1; - - if ((l->data = XCALLOC(1, sizeof(ltc_utctime))) == NULL) { - err = CRYPT_MEM; - goto error; - } - - len = *inlen; - if ((err = der_decode_utctime(in, &len, l->data)) != CRYPT_OK) { - goto error; - } - - if ((err = der_length_utctime(l->data, &len)) != CRYPT_OK) { - goto error; - } - break; - - case 0x30: /* SEQUENCE */ - case 0x31: /* SET */ - - /* init field */ - l->type = (type == 0x30) ? LTC_ASN1_SEQUENCE : LTC_ASN1_SET; - - /* we have to decode the SEQUENCE header and get it's length */ - - /* move past type */ - ++in; --(*inlen); - - /* read length byte */ - x = *in++; --(*inlen); - - /* smallest SEQUENCE/SET header */ - y = 2; - - /* now if it's > 127 the next bytes are the length of the length */ - if (x > 128) { - x &= 0x7F; - in += x; - *inlen -= x; - - /* update sequence header len */ - y += x; - } - - /* Sequence elements go as child */ - len = len - y; - if ((err = der_decode_sequence_flexi(in, &len, &(l->child))) != CRYPT_OK) { - goto error; - } - - /* len update */ - totlen += y; - - /* link them up y0 */ - l->child->parent = l; - - break; - default: - /* invalid byte ... this is a soft error */ - /* remove link */ - l = l->prev; - XFREE(l->next); - l->next = NULL; - goto outside; - } - - /* advance pointers */ - totlen += len; - in += len; - *inlen -= len; - } - -outside: - - /* rewind l please */ - while (l->prev != NULL || l->parent != NULL) { - if (l->parent != NULL) { - l = l->parent; - } else { - l = l->prev; - } - } - - /* return */ - *out = l; - *inlen = totlen; - return CRYPT_OK; - -error: - /* free list */ - der_sequence_free(l); - - return err; -} - -#endif - - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/sequence/der_decode_sequence_flexi.c,v $ */ -/* $Revision: 1.26 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_sequence_multi.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_sequence_multi.c deleted file mode 100644 index ff633df..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_sequence_multi.c +++ /dev/null @@ -1,139 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" -#include - - -/** - @file der_decode_sequence_multi.c - ASN.1 DER, decode a SEQUENCE, Tom St Denis -*/ - -#ifdef LTC_DER - -/** - Decode a SEQUENCE type using a VA list - @param in Input buffer - @param inlen Length of input in octets - @remark <...> is of the form (int, unsigned long, void*) - @return CRYPT_OK on success -*/ -int der_decode_sequence_multi(const unsigned char *in, unsigned long inlen, ...) -{ - int err, type; - unsigned long size, x; - void *data; - va_list args; - ltc_asn1_list *list; - - LTC_ARGCHK(in != NULL); - - /* get size of output that will be required */ - va_start(args, inlen); - x = 0; - for (;;) { - type = va_arg(args, int); - size = va_arg(args, unsigned long); - data = va_arg(args, void*); - - if (type == LTC_ASN1_EOL) { - break; - } - - switch (type) { - case LTC_ASN1_BOOLEAN: - case LTC_ASN1_INTEGER: - case LTC_ASN1_SHORT_INTEGER: - case LTC_ASN1_BIT_STRING: - case LTC_ASN1_OCTET_STRING: - case LTC_ASN1_NULL: - case LTC_ASN1_OBJECT_IDENTIFIER: - case LTC_ASN1_IA5_STRING: - case LTC_ASN1_PRINTABLE_STRING: - case LTC_ASN1_UTF8_STRING: - case LTC_ASN1_UTCTIME: - case LTC_ASN1_SET: - case LTC_ASN1_SETOF: - case LTC_ASN1_SEQUENCE: - case LTC_ASN1_CHOICE: - ++x; - break; - - default: - va_end(args); - return CRYPT_INVALID_ARG; - } - } - va_end(args); - - /* allocate structure for x elements */ - if (x == 0) { - return CRYPT_NOP; - } - - list = XCALLOC(sizeof(*list), x); - if (list == NULL) { - return CRYPT_MEM; - } - - /* fill in the structure */ - va_start(args, inlen); - x = 0; - for (;;) { - type = va_arg(args, int); - size = va_arg(args, unsigned long); - data = va_arg(args, void*); - - if (type == LTC_ASN1_EOL) { - break; - } - - switch (type) { - case LTC_ASN1_BOOLEAN: - case LTC_ASN1_INTEGER: - case LTC_ASN1_SHORT_INTEGER: - case LTC_ASN1_BIT_STRING: - case LTC_ASN1_OCTET_STRING: - case LTC_ASN1_NULL: - case LTC_ASN1_OBJECT_IDENTIFIER: - case LTC_ASN1_IA5_STRING: - case LTC_ASN1_PRINTABLE_STRING: - case LTC_ASN1_UTF8_STRING: - case LTC_ASN1_UTCTIME: - case LTC_ASN1_SEQUENCE: - case LTC_ASN1_SET: - case LTC_ASN1_SETOF: - case LTC_ASN1_CHOICE: - list[x].type = type; - list[x].size = size; - list[x++].data = data; - break; - - default: - va_end(args); - err = CRYPT_INVALID_ARG; - goto LBL_ERR; - } - } - va_end(args); - - err = der_decode_sequence(in, inlen, list, x); -LBL_ERR: - XFREE(list); - return err; -} - -#endif - - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/sequence/der_decode_sequence_multi.c,v $ */ -/* $Revision: 1.13 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_short_integer.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_short_integer.c deleted file mode 100644 index 907e4e1..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_short_integer.c +++ /dev/null @@ -1,68 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_decode_short_integer.c - ASN.1 DER, decode an integer, Tom St Denis -*/ - - -#ifdef LTC_DER - -/** - Read a short integer - @param in The DER encoded data - @param inlen Size of data - @param num [out] The integer to decode - @return CRYPT_OK if successful -*/ -int der_decode_short_integer(const unsigned char *in, unsigned long inlen, unsigned long *num) -{ - unsigned long len, x, y; - - LTC_ARGCHK(num != NULL); - LTC_ARGCHK(in != NULL); - - /* check length */ - if (inlen < 2) { - return CRYPT_INVALID_PACKET; - } - - /* check header */ - x = 0; - if ((in[x++] & 0x1F) != 0x02) { - return CRYPT_INVALID_PACKET; - } - - /* get the packet len */ - len = in[x++]; - - if (x + len > inlen) { - return CRYPT_INVALID_PACKET; - } - - /* read number */ - y = 0; - while (len--) { - y = (y<<8) | (unsigned long)in[x++]; - } - *num = y; - - return CRYPT_OK; - -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/short_integer/der_decode_short_integer.c,v $ */ -/* $Revision: 1.7 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_utctime.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_utctime.c deleted file mode 100644 index 7f3f0d7..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_utctime.c +++ /dev/null @@ -1,127 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_decode_utctime.c - ASN.1 DER, decode a UTCTIME, Tom St Denis -*/ - -#ifdef LTC_DER - -static int char_to_int(unsigned char x) -{ - switch (x) { - case '0': return 0; - case '1': return 1; - case '2': return 2; - case '3': return 3; - case '4': return 4; - case '5': return 5; - case '6': return 6; - case '7': return 7; - case '8': return 8; - case '9': return 9; - } - return 100; -} - -#define DECODE_V(y, max) \ - y = char_to_int(buf[x])*10 + char_to_int(buf[x+1]); \ - if (y >= max) return CRYPT_INVALID_PACKET; \ - x += 2; - -/** - Decodes a UTC time structure in DER format (reads all 6 valid encoding formats) - @param in Input buffer - @param inlen Length of input buffer in octets - @param out [out] Destination of UTC time structure - @return CRYPT_OK if successful -*/ -int der_decode_utctime(const unsigned char *in, unsigned long *inlen, - ltc_utctime *out) -{ - unsigned char buf[32]; - unsigned long x; - int y; - - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(inlen != NULL); - LTC_ARGCHK(out != NULL); - - /* check header */ - if (*inlen < 2UL || (in[1] >= sizeof(buf)) || ((in[1] + 2UL) > *inlen)) { - return CRYPT_INVALID_PACKET; - } - - /* decode the string */ - for (x = 0; x < in[1]; x++) { - y = der_ia5_value_decode(in[x+2]); - if (y == -1) { - return CRYPT_INVALID_PACKET; - } - buf[x] = y; - } - *inlen = 2 + x; - - - /* possible encodings are -YYMMDDhhmmZ -YYMMDDhhmm+hh'mm' -YYMMDDhhmm-hh'mm' -YYMMDDhhmmssZ -YYMMDDhhmmss+hh'mm' -YYMMDDhhmmss-hh'mm' - - So let's do a trivial decode upto [including] mm - */ - - x = 0; - DECODE_V(out->YY, 100); - DECODE_V(out->MM, 13); - DECODE_V(out->DD, 32); - DECODE_V(out->hh, 24); - DECODE_V(out->mm, 60); - - /* clear timezone and seconds info */ - out->off_dir = out->off_hh = out->off_mm = out->ss = 0; - - /* now is it Z, +, - or 0-9 */ - if (buf[x] == 'Z') { - return CRYPT_OK; - } else if (buf[x] == '+' || buf[x] == '-') { - out->off_dir = (buf[x++] == '+') ? 0 : 1; - DECODE_V(out->off_hh, 24); - DECODE_V(out->off_mm, 60); - return CRYPT_OK; - } - - /* decode seconds */ - DECODE_V(out->ss, 60); - - /* now is it Z, +, - */ - if (buf[x] == 'Z') { - return CRYPT_OK; - } else if (buf[x] == '+' || buf[x] == '-') { - out->off_dir = (buf[x++] == '+') ? 0 : 1; - DECODE_V(out->off_hh, 24); - DECODE_V(out->off_mm, 60); - return CRYPT_OK; - } else { - return CRYPT_INVALID_PACKET; - } -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/utctime/der_decode_utctime.c,v $ */ -/* $Revision: 1.9 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_utf8_string.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_utf8_string.c deleted file mode 100644 index 898d6cd..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_decode_utf8_string.c +++ /dev/null @@ -1,111 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_decode_utf8_string.c - ASN.1 DER, encode a UTF8 STRING, Tom St Denis -*/ - - -#ifdef LTC_DER - -/** - Store a UTF8 STRING - @param in The DER encoded UTF8 STRING - @param inlen The size of the DER UTF8 STRING - @param out [out] The array of utf8s stored (one per char) - @param outlen [in/out] The number of utf8s stored - @return CRYPT_OK if successful -*/ -int der_decode_utf8_string(const unsigned char *in, unsigned long inlen, - wchar_t *out, unsigned long *outlen) -{ - wchar_t tmp; - unsigned long x, y, z, len; - - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); - - /* must have header at least */ - if (inlen < 2) { - return CRYPT_INVALID_PACKET; - } - - /* check for 0x0C */ - if ((in[0] & 0x1F) != 0x0C) { - return CRYPT_INVALID_PACKET; - } - x = 1; - - /* decode the length */ - if (in[x] & 0x80) { - /* valid # of bytes in length are 1,2,3 */ - y = in[x] & 0x7F; - if ((y == 0) || (y > 3) || ((x + y) > inlen)) { - return CRYPT_INVALID_PACKET; - } - - /* read the length in */ - len = 0; - ++x; - while (y--) { - len = (len << 8) | in[x++]; - } - } else { - len = in[x++] & 0x7F; - } - - if (len + x > inlen) { - return CRYPT_INVALID_PACKET; - } - - /* proceed to decode */ - for (y = 0; x < inlen; ) { - /* get first byte */ - tmp = in[x++]; - - /* count number of bytes */ - for (z = 0; (tmp & 0x80) && (z <= 4); z++, tmp = (tmp << 1) & 0xFF); - - if (z > 4 || (x + (z - 1) > inlen)) { - return CRYPT_INVALID_PACKET; - } - - /* decode, grab upper bits */ - tmp >>= z; - - /* grab remaining bytes */ - if (z > 1) { --z; } - while (z-- != 0) { - if ((in[x] & 0xC0) != 0x80) { - return CRYPT_INVALID_PACKET; - } - tmp = (tmp << 6) | ((wchar_t)in[x++] & 0x3F); - } - - if (y > *outlen) { - *outlen = y; - return CRYPT_BUFFER_OVERFLOW; - } - out[y++] = tmp; - } - *outlen = y; - - return CRYPT_OK; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/utf8/der_decode_utf8_string.c,v $ */ -/* $Revision: 1.8 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_bit_string.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_bit_string.c deleted file mode 100644 index ca29c58..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_bit_string.c +++ /dev/null @@ -1,89 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_encode_bit_string.c - ASN.1 DER, encode a BIT STRING, Tom St Denis -*/ - - -#ifdef LTC_DER - -/** - Store a BIT STRING - @param in The array of bits to store (one per char) - @param inlen The number of bits tostore - @param out [out] The destination for the DER encoded BIT STRING - @param outlen [in/out] The max size and resulting size of the DER BIT STRING - @return CRYPT_OK if successful -*/ -int der_encode_bit_string(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen) -{ - unsigned long len, x, y; - unsigned char buf; - int err; - - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); - - /* avoid overflows */ - if ((err = der_length_bit_string(inlen, &len)) != CRYPT_OK) { - return err; - } - - if (len > *outlen) { - *outlen = len; - return CRYPT_BUFFER_OVERFLOW; - } - - /* store header (include bit padding count in length) */ - x = 0; - y = (inlen >> 3) + ((inlen&7) ? 1 : 0) + 1; - - out[x++] = 0x03; - if (y < 128) { - out[x++] = (unsigned char)y; - } else if (y < 256) { - out[x++] = 0x81; - out[x++] = (unsigned char)y; - } else if (y < 65536) { - out[x++] = 0x82; - out[x++] = (unsigned char)((y>>8)&255); - out[x++] = (unsigned char)(y&255); - } - - /* store number of zero padding bits */ - out[x++] = (unsigned char)((8 - inlen) & 7); - - /* store the bits in big endian format */ - for (y = buf = 0; y < inlen; y++) { - buf |= (in[y] ? 1 : 0) << (7 - (y & 7)); - if ((y & 7) == 7) { - out[x++] = buf; - buf = 0; - } - } - /* store last byte */ - if (inlen & 7) { - out[x++] = buf; - } - *outlen = x; - return CRYPT_OK; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/bit/der_encode_bit_string.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_boolean.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_boolean.c deleted file mode 100644 index ded2731..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_boolean.c +++ /dev/null @@ -1,51 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_encode_boolean.c - ASN.1 DER, encode a BOOLEAN, Tom St Denis -*/ - - -#ifdef LTC_DER - -/** - Store a BOOLEAN - @param in The boolean to encode - @param out [out] The destination for the DER encoded BOOLEAN - @param outlen [in/out] The max size and resulting size of the DER BOOLEAN - @return CRYPT_OK if successful -*/ -int der_encode_boolean(int in, - unsigned char *out, unsigned long *outlen) -{ - LTC_ARGCHK(outlen != NULL); - LTC_ARGCHK(out != NULL); - - if (*outlen < 3) { - *outlen = 3; - return CRYPT_BUFFER_OVERFLOW; - } - - *outlen = 3; - out[0] = 0x01; - out[1] = 0x01; - out[2] = in ? 0xFF : 0x00; - - return CRYPT_OK; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/boolean/der_encode_boolean.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_ia5_string.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_ia5_string.c deleted file mode 100644 index 30d3f43..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_ia5_string.c +++ /dev/null @@ -1,85 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_encode_ia5_string.c - ASN.1 DER, encode a IA5 STRING, Tom St Denis -*/ - -#ifdef LTC_DER - -/** - Store an IA5 STRING - @param in The array of IA5 to store (one per char) - @param inlen The number of IA5 to store - @param out [out] The destination for the DER encoded IA5 STRING - @param outlen [in/out] The max size and resulting size of the DER IA5 STRING - @return CRYPT_OK if successful -*/ -int der_encode_ia5_string(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen) -{ - unsigned long x, y, len; - int err; - - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); - - /* get the size */ - if ((err = der_length_ia5_string(in, inlen, &len)) != CRYPT_OK) { - return err; - } - - /* too big? */ - if (len > *outlen) { - *outlen = len; - return CRYPT_BUFFER_OVERFLOW; - } - - /* encode the header+len */ - x = 0; - out[x++] = 0x16; - if (inlen < 128) { - out[x++] = (unsigned char)inlen; - } else if (inlen < 256) { - out[x++] = 0x81; - out[x++] = (unsigned char)inlen; - } else if (inlen < 65536UL) { - out[x++] = 0x82; - out[x++] = (unsigned char)((inlen>>8)&255); - out[x++] = (unsigned char)(inlen&255); - } else if (inlen < 16777216UL) { - out[x++] = 0x83; - out[x++] = (unsigned char)((inlen>>16)&255); - out[x++] = (unsigned char)((inlen>>8)&255); - out[x++] = (unsigned char)(inlen&255); - } else { - return CRYPT_INVALID_ARG; - } - - /* store octets */ - for (y = 0; y < inlen; y++) { - out[x++] = der_ia5_char_encode(in[y]); - } - - /* retun length */ - *outlen = x; - - return CRYPT_OK; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/ia5/der_encode_ia5_string.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_integer.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_integer.c deleted file mode 100644 index 4137a94..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_integer.c +++ /dev/null @@ -1,130 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_encode_integer.c - ASN.1 DER, encode an integer, Tom St Denis -*/ - - -#ifdef LTC_DER - -/* Exports a positive bignum as DER format (upto 2^32 bytes in size) */ -/** - Store a mp_int integer - @param num The first mp_int to encode - @param out [out] The destination for the DER encoded integers - @param outlen [in/out] The max size and resulting size of the DER encoded integers - @return CRYPT_OK if successful -*/ -int der_encode_integer(void *num, unsigned char *out, unsigned long *outlen) -{ - unsigned long tmplen, y; - int err, leading_zero; - - LTC_ARGCHK(num != NULL); - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); - - /* find out how big this will be */ - if ((err = der_length_integer(num, &tmplen)) != CRYPT_OK) { - return err; - } - - if (*outlen < tmplen) { - *outlen = tmplen; - return CRYPT_BUFFER_OVERFLOW; - } - - if (mp_cmp_d(num, 0) != LTC_MP_LT) { - /* we only need a leading zero if the msb of the first byte is one */ - if ((mp_count_bits(num) & 7) == 0 || mp_iszero(num) == LTC_MP_YES) { - leading_zero = 1; - } else { - leading_zero = 0; - } - - /* get length of num in bytes (plus 1 since we force the msbyte to zero) */ - y = mp_unsigned_bin_size(num) + leading_zero; - } else { - leading_zero = 0; - y = mp_count_bits(num); - y = y + (8 - (y & 7)); - y = y >> 3; - if (((mp_cnt_lsb(num)+1)==mp_count_bits(num)) && ((mp_count_bits(num)&7)==0)) --y; - } - - /* now store initial data */ - *out++ = 0x02; - if (y < 128) { - /* short form */ - *out++ = (unsigned char)y; - } else if (y < 256) { - *out++ = 0x81; - *out++ = (unsigned char)y; - } else if (y < 65536UL) { - *out++ = 0x82; - *out++ = (unsigned char)((y>>8)&255); - *out++ = (unsigned char)y; - } else if (y < 16777216UL) { - *out++ = 0x83; - *out++ = (unsigned char)((y>>16)&255); - *out++ = (unsigned char)((y>>8)&255); - *out++ = (unsigned char)y; - } else { - return CRYPT_INVALID_ARG; - } - - /* now store msbyte of zero if num is non-zero */ - if (leading_zero) { - *out++ = 0x00; - } - - /* if it's not zero store it as big endian */ - if (mp_cmp_d(num, 0) == LTC_MP_GT) { - /* now store the mpint */ - if ((err = mp_to_unsigned_bin(num, out)) != CRYPT_OK) { - return err; - } - } else if (mp_iszero(num) != LTC_MP_YES) { - void *tmp; - - /* negative */ - if (mp_init(&tmp) != CRYPT_OK) { - return CRYPT_MEM; - } - - /* 2^roundup and subtract */ - y = mp_count_bits(num); - y = y + (8 - (y & 7)); - if (((mp_cnt_lsb(num)+1)==mp_count_bits(num)) && ((mp_count_bits(num)&7)==0)) y -= 8; - if (mp_2expt(tmp, y) != CRYPT_OK || mp_add(tmp, num, tmp) != CRYPT_OK) { - mp_clear(tmp); - return CRYPT_MEM; - } - if ((err = mp_to_unsigned_bin(tmp, out)) != CRYPT_OK) { - mp_clear(tmp); - return err; - } - mp_clear(tmp); - } - - /* we good */ - *outlen = tmplen; - return CRYPT_OK; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/integer/der_encode_integer.c,v $ */ -/* $Revision: 1.9 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_object_identifier.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_object_identifier.c deleted file mode 100644 index 68e2162..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_object_identifier.c +++ /dev/null @@ -1,111 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_encode_object_identifier.c - ASN.1 DER, Encode Object Identifier, Tom St Denis -*/ - -#ifdef LTC_DER -/** - Encode an OID - @param words The words to encode (upto 32-bits each) - @param nwords The number of words in the OID - @param out [out] Destination of OID data - @param outlen [in/out] The max and resulting size of the OID - @return CRYPT_OK if successful -*/ -int der_encode_object_identifier(unsigned long *words, unsigned long nwords, - unsigned char *out, unsigned long *outlen) -{ - unsigned long i, x, y, z, t, mask, wordbuf; - int err; - - LTC_ARGCHK(words != NULL); - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); - - /* check length */ - if ((err = der_length_object_identifier(words, nwords, &x)) != CRYPT_OK) { - return err; - } - if (x > *outlen) { - *outlen = x; - return CRYPT_BUFFER_OVERFLOW; - } - - /* compute length to store OID data */ - z = 0; - wordbuf = words[0] * 40 + words[1]; - for (y = 1; y < nwords; y++) { - t = der_object_identifier_bits(wordbuf); - z += t/7 + ((t%7) ? 1 : 0) + (wordbuf == 0 ? 1 : 0); - if (y < nwords - 1) { - wordbuf = words[y + 1]; - } - } - - /* store header + length */ - x = 0; - out[x++] = 0x06; - if (z < 128) { - out[x++] = (unsigned char)z; - } else if (z < 256) { - out[x++] = 0x81; - out[x++] = (unsigned char)z; - } else if (z < 65536UL) { - out[x++] = 0x82; - out[x++] = (unsigned char)((z>>8)&255); - out[x++] = (unsigned char)(z&255); - } else { - return CRYPT_INVALID_ARG; - } - - /* store first byte */ - wordbuf = words[0] * 40 + words[1]; - for (i = 1; i < nwords; i++) { - /* store 7 bit words in little endian */ - t = wordbuf & 0xFFFFFFFF; - if (t) { - y = x; - mask = 0; - while (t) { - out[x++] = (unsigned char)((t & 0x7F) | mask); - t >>= 7; - mask |= 0x80; /* upper bit is set on all but the last byte */ - } - /* now swap bytes y...x-1 */ - z = x - 1; - while (y < z) { - t = out[y]; out[y] = out[z]; out[z] = (unsigned char)t; - ++y; - --z; - } - } else { - /* zero word */ - out[x++] = 0x00; - } - - if (i < nwords - 1) { - wordbuf = words[i + 1]; - } - } - - *outlen = x; - return CRYPT_OK; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/object_identifier/der_encode_object_identifier.c,v $ */ -/* $Revision: 1.7 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_octet_string.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_octet_string.c deleted file mode 100644 index b3ee7f4..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_octet_string.c +++ /dev/null @@ -1,86 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_encode_octet_string.c - ASN.1 DER, encode a OCTET STRING, Tom St Denis -*/ - - -#ifdef LTC_DER - -/** - Store an OCTET STRING - @param in The array of OCTETS to store (one per char) - @param inlen The number of OCTETS to store - @param out [out] The destination for the DER encoded OCTET STRING - @param outlen [in/out] The max size and resulting size of the DER OCTET STRING - @return CRYPT_OK if successful -*/ -int der_encode_octet_string(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen) -{ - unsigned long x, y, len; - int err; - - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); - - /* get the size */ - if ((err = der_length_octet_string(inlen, &len)) != CRYPT_OK) { - return err; - } - - /* too big? */ - if (len > *outlen) { - *outlen = len; - return CRYPT_BUFFER_OVERFLOW; - } - - /* encode the header+len */ - x = 0; - out[x++] = 0x04; - if (inlen < 128) { - out[x++] = (unsigned char)inlen; - } else if (inlen < 256) { - out[x++] = 0x81; - out[x++] = (unsigned char)inlen; - } else if (inlen < 65536UL) { - out[x++] = 0x82; - out[x++] = (unsigned char)((inlen>>8)&255); - out[x++] = (unsigned char)(inlen&255); - } else if (inlen < 16777216UL) { - out[x++] = 0x83; - out[x++] = (unsigned char)((inlen>>16)&255); - out[x++] = (unsigned char)((inlen>>8)&255); - out[x++] = (unsigned char)(inlen&255); - } else { - return CRYPT_INVALID_ARG; - } - - /* store octets */ - for (y = 0; y < inlen; y++) { - out[x++] = in[y]; - } - - /* retun length */ - *outlen = x; - - return CRYPT_OK; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/octet/der_encode_octet_string.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_printable_string.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_printable_string.c deleted file mode 100644 index a1dab5f..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_printable_string.c +++ /dev/null @@ -1,85 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_encode_printable_string.c - ASN.1 DER, encode a printable STRING, Tom St Denis -*/ - -#ifdef LTC_DER - -/** - Store an printable STRING - @param in The array of printable to store (one per char) - @param inlen The number of printable to store - @param out [out] The destination for the DER encoded printable STRING - @param outlen [in/out] The max size and resulting size of the DER printable STRING - @return CRYPT_OK if successful -*/ -int der_encode_printable_string(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen) -{ - unsigned long x, y, len; - int err; - - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); - - /* get the size */ - if ((err = der_length_printable_string(in, inlen, &len)) != CRYPT_OK) { - return err; - } - - /* too big? */ - if (len > *outlen) { - *outlen = len; - return CRYPT_BUFFER_OVERFLOW; - } - - /* encode the header+len */ - x = 0; - out[x++] = 0x13; - if (inlen < 128) { - out[x++] = (unsigned char)inlen; - } else if (inlen < 256) { - out[x++] = 0x81; - out[x++] = (unsigned char)inlen; - } else if (inlen < 65536UL) { - out[x++] = 0x82; - out[x++] = (unsigned char)((inlen>>8)&255); - out[x++] = (unsigned char)(inlen&255); - } else if (inlen < 16777216UL) { - out[x++] = 0x83; - out[x++] = (unsigned char)((inlen>>16)&255); - out[x++] = (unsigned char)((inlen>>8)&255); - out[x++] = (unsigned char)(inlen&255); - } else { - return CRYPT_INVALID_ARG; - } - - /* store octets */ - for (y = 0; y < inlen; y++) { - out[x++] = der_printable_char_encode(in[y]); - } - - /* retun length */ - *outlen = x; - - return CRYPT_OK; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/printable_string/der_encode_printable_string.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_sequence_ex.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_sequence_ex.c deleted file mode 100644 index 3df19cf..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_sequence_ex.c +++ /dev/null @@ -1,335 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" -#include - - -/** - @file der_encode_sequence_ex.c - ASN.1 DER, encode a SEQUENCE, Tom St Denis -*/ - -#ifdef LTC_DER - -/** - Encode a SEQUENCE - @param list The list of items to encode - @param inlen The number of items in the list - @param out [out] The destination - @param outlen [in/out] The size of the output - @param type_of LTC_ASN1_SEQUENCE or LTC_ASN1_SET/LTC_ASN1_SETOF - @return CRYPT_OK on success -*/ -int der_encode_sequence_ex(ltc_asn1_list *list, unsigned long inlen, - unsigned char *out, unsigned long *outlen, int type_of) -{ - int err, type; - unsigned long size, x, y, z, i; - void *data; - - LTC_ARGCHK(list != NULL); - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); - - /* get size of output that will be required */ - y = 0; - for (i = 0; i < inlen; i++) { - type = list[i].type; - size = list[i].size; - data = list[i].data; - - if (type == LTC_ASN1_EOL) { - break; - } - - switch (type) { - case LTC_ASN1_BOOLEAN: - if ((err = der_length_boolean(&x)) != CRYPT_OK) { - goto LBL_ERR; - } - y += x; - break; - - case LTC_ASN1_INTEGER: - if ((err = der_length_integer(data, &x)) != CRYPT_OK) { - goto LBL_ERR; - } - y += x; - break; - - case LTC_ASN1_SHORT_INTEGER: - if ((err = der_length_short_integer(*((unsigned long*)data), &x)) != CRYPT_OK) { - goto LBL_ERR; - } - y += x; - break; - - case LTC_ASN1_BIT_STRING: - if ((err = der_length_bit_string(size, &x)) != CRYPT_OK) { - goto LBL_ERR; - } - y += x; - break; - - case LTC_ASN1_OCTET_STRING: - if ((err = der_length_octet_string(size, &x)) != CRYPT_OK) { - goto LBL_ERR; - } - y += x; - break; - - case LTC_ASN1_NULL: - y += 2; - break; - - case LTC_ASN1_OBJECT_IDENTIFIER: - if ((err = der_length_object_identifier(data, size, &x)) != CRYPT_OK) { - goto LBL_ERR; - } - y += x; - break; - - case LTC_ASN1_IA5_STRING: - if ((err = der_length_ia5_string(data, size, &x)) != CRYPT_OK) { - goto LBL_ERR; - } - y += x; - break; - - case LTC_ASN1_PRINTABLE_STRING: - if ((err = der_length_printable_string(data, size, &x)) != CRYPT_OK) { - goto LBL_ERR; - } - y += x; - break; - - case LTC_ASN1_UTF8_STRING: - if ((err = der_length_utf8_string(data, size, &x)) != CRYPT_OK) { - goto LBL_ERR; - } - y += x; - break; - - case LTC_ASN1_UTCTIME: - if ((err = der_length_utctime(data, &x)) != CRYPT_OK) { - goto LBL_ERR; - } - y += x; - break; - - case LTC_ASN1_SET: - case LTC_ASN1_SETOF: - case LTC_ASN1_SEQUENCE: - if ((err = der_length_sequence(data, size, &x)) != CRYPT_OK) { - goto LBL_ERR; - } - y += x; - break; - - default: - err = CRYPT_INVALID_ARG; - goto LBL_ERR; - } - } - - /* calc header size */ - z = y; - if (y < 128) { - y += 2; - } else if (y < 256) { - /* 0x30 0x81 LL */ - y += 3; - } else if (y < 65536UL) { - /* 0x30 0x82 LL LL */ - y += 4; - } else if (y < 16777216UL) { - /* 0x30 0x83 LL LL LL */ - y += 5; - } else { - err = CRYPT_INVALID_ARG; - goto LBL_ERR; - } - - /* too big ? */ - if (*outlen < y) { - *outlen = y; - err = CRYPT_BUFFER_OVERFLOW; - goto LBL_ERR; - } - - /* store header */ - x = 0; - out[x++] = (type_of == LTC_ASN1_SEQUENCE) ? 0x30 : 0x31; - - if (z < 128) { - out[x++] = (unsigned char)z; - } else if (z < 256) { - out[x++] = 0x81; - out[x++] = (unsigned char)z; - } else if (z < 65536UL) { - out[x++] = 0x82; - out[x++] = (unsigned char)((z>>8UL)&255); - out[x++] = (unsigned char)(z&255); - } else if (z < 16777216UL) { - out[x++] = 0x83; - out[x++] = (unsigned char)((z>>16UL)&255); - out[x++] = (unsigned char)((z>>8UL)&255); - out[x++] = (unsigned char)(z&255); - } - - /* store data */ - *outlen -= x; - for (i = 0; i < inlen; i++) { - type = list[i].type; - size = list[i].size; - data = list[i].data; - - if (type == LTC_ASN1_EOL) { - break; - } - - switch (type) { - case LTC_ASN1_BOOLEAN: - z = *outlen; - if ((err = der_encode_boolean(*((int *)data), out + x, &z)) != CRYPT_OK) { - goto LBL_ERR; - } - x += z; - *outlen -= z; - break; - - case LTC_ASN1_INTEGER: - z = *outlen; - if ((err = der_encode_integer(data, out + x, &z)) != CRYPT_OK) { - goto LBL_ERR; - } - x += z; - *outlen -= z; - break; - - case LTC_ASN1_SHORT_INTEGER: - z = *outlen; - if ((err = der_encode_short_integer(*((unsigned long*)data), out + x, &z)) != CRYPT_OK) { - goto LBL_ERR; - } - x += z; - *outlen -= z; - break; - - case LTC_ASN1_BIT_STRING: - z = *outlen; - if ((err = der_encode_bit_string(data, size, out + x, &z)) != CRYPT_OK) { - goto LBL_ERR; - } - x += z; - *outlen -= z; - break; - - case LTC_ASN1_OCTET_STRING: - z = *outlen; - if ((err = der_encode_octet_string(data, size, out + x, &z)) != CRYPT_OK) { - goto LBL_ERR; - } - x += z; - *outlen -= z; - break; - - case LTC_ASN1_NULL: - out[x++] = 0x05; - out[x++] = 0x00; - *outlen -= 2; - break; - - case LTC_ASN1_OBJECT_IDENTIFIER: - z = *outlen; - if ((err = der_encode_object_identifier(data, size, out + x, &z)) != CRYPT_OK) { - goto LBL_ERR; - } - x += z; - *outlen -= z; - break; - - case LTC_ASN1_IA5_STRING: - z = *outlen; - if ((err = der_encode_ia5_string(data, size, out + x, &z)) != CRYPT_OK) { - goto LBL_ERR; - } - x += z; - *outlen -= z; - break; - - case LTC_ASN1_PRINTABLE_STRING: - z = *outlen; - if ((err = der_encode_printable_string(data, size, out + x, &z)) != CRYPT_OK) { - goto LBL_ERR; - } - x += z; - *outlen -= z; - break; - - case LTC_ASN1_UTF8_STRING: - z = *outlen; - if ((err = der_encode_utf8_string(data, size, out + x, &z)) != CRYPT_OK) { - goto LBL_ERR; - } - x += z; - *outlen -= z; - break; - - case LTC_ASN1_UTCTIME: - z = *outlen; - if ((err = der_encode_utctime(data, out + x, &z)) != CRYPT_OK) { - goto LBL_ERR; - } - x += z; - *outlen -= z; - break; - - case LTC_ASN1_SET: - z = *outlen; - if ((err = der_encode_set(data, size, out + x, &z)) != CRYPT_OK) { - goto LBL_ERR; - } - x += z; - *outlen -= z; - break; - - case LTC_ASN1_SETOF: - z = *outlen; - if ((err = der_encode_setof(data, size, out + x, &z)) != CRYPT_OK) { - goto LBL_ERR; - } - x += z; - *outlen -= z; - break; - - case LTC_ASN1_SEQUENCE: - z = *outlen; - if ((err = der_encode_sequence_ex(data, size, out + x, &z, type)) != CRYPT_OK) { - goto LBL_ERR; - } - x += z; - *outlen -= z; - break; - - default: - err = CRYPT_INVALID_ARG; - goto LBL_ERR; - } - } - *outlen = x; - err = CRYPT_OK; - -LBL_ERR: - return err; -} - -#endif diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_sequence_multi.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_sequence_multi.c deleted file mode 100644 index 782f042..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_sequence_multi.c +++ /dev/null @@ -1,138 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" -#include - - -/** - @file der_encode_sequence_multi.c - ASN.1 DER, encode a SEQUENCE, Tom St Denis -*/ - -#ifdef LTC_DER - -/** - Encode a SEQUENCE type using a VA list - @param out [out] Destination for data - @param outlen [in/out] Length of buffer and resulting length of output - @remark <...> is of the form (int, unsigned long, void*) - @return CRYPT_OK on success -*/ -int der_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...) -{ - int err, type; - unsigned long size, x; - void *data; - va_list args; - ltc_asn1_list *list; - - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); - - /* get size of output that will be required */ - va_start(args, outlen); - x = 0; - for (;;) { - type = va_arg(args, int); - size = va_arg(args, unsigned long); - data = va_arg(args, void*); - - if (type == LTC_ASN1_EOL) { - break; - } - - switch (type) { - case LTC_ASN1_BOOLEAN: - case LTC_ASN1_INTEGER: - case LTC_ASN1_SHORT_INTEGER: - case LTC_ASN1_BIT_STRING: - case LTC_ASN1_OCTET_STRING: - case LTC_ASN1_NULL: - case LTC_ASN1_OBJECT_IDENTIFIER: - case LTC_ASN1_IA5_STRING: - case LTC_ASN1_PRINTABLE_STRING: - case LTC_ASN1_UTF8_STRING: - case LTC_ASN1_UTCTIME: - case LTC_ASN1_SEQUENCE: - case LTC_ASN1_SET: - case LTC_ASN1_SETOF: - ++x; - break; - - default: - va_end(args); - return CRYPT_INVALID_ARG; - } - } - va_end(args); - - /* allocate structure for x elements */ - if (x == 0) { - return CRYPT_NOP; - } - - list = XCALLOC(sizeof(*list), x); - if (list == NULL) { - return CRYPT_MEM; - } - - /* fill in the structure */ - va_start(args, outlen); - x = 0; - for (;;) { - type = va_arg(args, int); - size = va_arg(args, unsigned long); - data = va_arg(args, void*); - - if (type == LTC_ASN1_EOL) { - break; - } - - switch (type) { - case LTC_ASN1_BOOLEAN: - case LTC_ASN1_INTEGER: - case LTC_ASN1_SHORT_INTEGER: - case LTC_ASN1_BIT_STRING: - case LTC_ASN1_OCTET_STRING: - case LTC_ASN1_NULL: - case LTC_ASN1_OBJECT_IDENTIFIER: - case LTC_ASN1_IA5_STRING: - case LTC_ASN1_PRINTABLE_STRING: - case LTC_ASN1_UTF8_STRING: - case LTC_ASN1_UTCTIME: - case LTC_ASN1_SEQUENCE: - case LTC_ASN1_SET: - case LTC_ASN1_SETOF: - list[x].type = type; - list[x].size = size; - list[x++].data = data; - break; - - default: - va_end(args); - err = CRYPT_INVALID_ARG; - goto LBL_ERR; - } - } - va_end(args); - - err = der_encode_sequence(list, x, out, outlen); -LBL_ERR: - XFREE(list); - return err; -} - -#endif - - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/sequence/der_encode_sequence_multi.c,v $ */ -/* $Revision: 1.12 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_set.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_set.c deleted file mode 100644 index 41f6587..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_set.c +++ /dev/null @@ -1,103 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_encode_set.c - ASN.1 DER, Encode a SET, Tom St Denis -*/ - -#ifdef LTC_DER - -/* LTC define to ASN.1 TAG */ -static int ltc_to_asn1(int v) -{ - switch (v) { - case LTC_ASN1_BOOLEAN: return 0x01; - case LTC_ASN1_INTEGER: - case LTC_ASN1_SHORT_INTEGER: return 0x02; - case LTC_ASN1_BIT_STRING: return 0x03; - case LTC_ASN1_OCTET_STRING: return 0x04; - case LTC_ASN1_NULL: return 0x05; - case LTC_ASN1_OBJECT_IDENTIFIER: return 0x06; - case LTC_ASN1_UTF8_STRING: return 0x0C; - case LTC_ASN1_PRINTABLE_STRING: return 0x13; - case LTC_ASN1_IA5_STRING: return 0x16; - case LTC_ASN1_UTCTIME: return 0x17; - case LTC_ASN1_SEQUENCE: return 0x30; - case LTC_ASN1_SET: - case LTC_ASN1_SETOF: return 0x31; - default: return -1; - } -} - - -static int qsort_helper(const void *a, const void *b) -{ - ltc_asn1_list *A = (ltc_asn1_list *)a, *B = (ltc_asn1_list *)b; - int r; - - r = ltc_to_asn1(A->type) - ltc_to_asn1(B->type); - - /* for QSORT the order is UNDEFINED if they are "equal" which means it is NOT DETERMINISTIC. So we force it to be :-) */ - if (r == 0) { - /* their order in the original list now determines the position */ - return A->used - B->used; - } else { - return r; - } -} - -/* - Encode a SET type - @param list The list of items to encode - @param inlen The number of items in the list - @param out [out] The destination - @param outlen [in/out] The size of the output - @return CRYPT_OK on success -*/ -int der_encode_set(ltc_asn1_list *list, unsigned long inlen, - unsigned char *out, unsigned long *outlen) -{ - ltc_asn1_list *copy; - unsigned long x; - int err; - - /* make copy of list */ - copy = XCALLOC(inlen, sizeof(*copy)); - if (copy == NULL) { - return CRYPT_MEM; - } - - /* fill in used member with index so we can fully sort it */ - for (x = 0; x < inlen; x++) { - copy[x] = list[x]; - copy[x].used = x; - } - - /* sort it by the "type" field */ - XQSORT(copy, inlen, sizeof(*copy), &qsort_helper); - - /* call der_encode_sequence_ex() */ - err = der_encode_sequence_ex(copy, inlen, out, outlen, LTC_ASN1_SET); - - /* free list */ - XFREE(copy); - - return err; -} - - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/set/der_encode_set.c,v $ */ -/* $Revision: 1.12 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_setof.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_setof.c deleted file mode 100644 index b4e97b5..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_setof.c +++ /dev/null @@ -1,162 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_encode_setof.c - ASN.1 DER, Encode SET OF, Tom St Denis -*/ - -#ifdef LTC_DER - -struct edge { - unsigned char *start; - unsigned long size; -}; - -static int qsort_helper(const void *a, const void *b) -{ - struct edge *A = (struct edge *)a, *B = (struct edge *)b; - int r; - unsigned long x; - - /* compare min length */ - r = XMEMCMP(A->start, B->start, MIN(A->size, B->size)); - - if (r == 0 && A->size != B->size) { - if (A->size > B->size) { - for (x = B->size; x < A->size; x++) { - if (A->start[x]) { - return 1; - } - } - } else { - for (x = A->size; x < B->size; x++) { - if (B->start[x]) { - return -1; - } - } - } - } - - return r; -} - -/** - Encode a SETOF stucture - @param list The list of items to encode - @param inlen The number of items in the list - @param out [out] The destination - @param outlen [in/out] The size of the output - @return CRYPT_OK on success -*/ -int der_encode_setof(ltc_asn1_list *list, unsigned long inlen, - unsigned char *out, unsigned long *outlen) -{ - unsigned long x, y, z, hdrlen; - int err; - struct edge *edges; - unsigned char *ptr, *buf; - - /* check that they're all the same type */ - for (x = 1; x < inlen; x++) { - if (list[x].type != list[x-1].type) { - return CRYPT_INVALID_ARG; - } - } - - /* alloc buffer to store copy of output */ - buf = XCALLOC(1, *outlen); - if (buf == NULL) { - return CRYPT_MEM; - } - - /* encode list */ - if ((err = der_encode_sequence_ex(list, inlen, buf, outlen, LTC_ASN1_SETOF)) != CRYPT_OK) { - XFREE(buf); - return err; - } - - /* allocate edges */ - edges = XCALLOC(inlen, sizeof(*edges)); - if (edges == NULL) { - XFREE(buf); - return CRYPT_MEM; - } - - /* skip header */ - ptr = buf + 1; - - /* now skip length data */ - x = *ptr++; - if (x >= 0x80) { - ptr += (x & 0x7F); - } - - /* get the size of the static header */ - hdrlen = (unsigned long)((size_t)ptr - (size_t)buf); - - - /* scan for edges */ - x = 0; - while (ptr < (buf + *outlen)) { - /* store start */ - edges[x].start = ptr; - - /* skip type */ - z = 1; - - /* parse length */ - y = ptr[z++]; - if (y < 128) { - edges[x].size = y; - } else { - y &= 0x7F; - edges[x].size = 0; - while (y--) { - edges[x].size = (edges[x].size << 8) | ((unsigned long)ptr[z++]); - } - } - - /* skip content */ - edges[x].size += z; - ptr += edges[x].size; - ++x; - } - - /* sort based on contents (using edges) */ - XQSORT(edges, inlen, sizeof(*edges), &qsort_helper); - - /* copy static header */ - XMEMCPY(out, buf, hdrlen); - - /* copy+sort using edges+indecies to output from buffer */ - for (y = hdrlen, x = 0; x < inlen; x++) { - XMEMCPY(out+y, edges[x].start, edges[x].size); - y += edges[x].size; - } - -#ifdef LTC_CLEAN_STACK - zeromem(buf, *outlen); -#endif - - /* free buffers */ - XFREE(edges); - XFREE(buf); - - return CRYPT_OK; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/set/der_encode_setof.c,v $ */ -/* $Revision: 1.12 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_short_integer.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_short_integer.c deleted file mode 100644 index 9b167d0..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_short_integer.c +++ /dev/null @@ -1,97 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_encode_short_integer.c - ASN.1 DER, encode an integer, Tom St Denis -*/ - - -#ifdef LTC_DER - -/** - Store a short integer in the range (0,2^32-1) - @param num The integer to encode - @param out [out] The destination for the DER encoded integers - @param outlen [in/out] The max size and resulting size of the DER encoded integers - @return CRYPT_OK if successful -*/ -int der_encode_short_integer(unsigned long num, unsigned char *out, unsigned long *outlen) -{ - unsigned long len, x, y, z; - int err; - - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); - - /* force to 32 bits */ - num &= 0xFFFFFFFFUL; - - /* find out how big this will be */ - if ((err = der_length_short_integer(num, &len)) != CRYPT_OK) { - return err; - } - - if (*outlen < len) { - *outlen = len; - return CRYPT_BUFFER_OVERFLOW; - } - - /* get len of output */ - z = 0; - y = num; - while (y) { - ++z; - y >>= 8; - } - - /* handle zero */ - if (z == 0) { - z = 1; - } - - /* see if msb is set */ - z += (num&(1UL<<((z<<3) - 1))) ? 1 : 0; - - /* adjust the number so the msB is non-zero */ - for (x = 0; (z <= 4) && (x < (4 - z)); x++) { - num <<= 8; - } - - /* store header */ - x = 0; - out[x++] = 0x02; - out[x++] = (unsigned char)z; - - /* if 31st bit is set output a leading zero and decrement count */ - if (z == 5) { - out[x++] = 0; - --z; - } - - /* store values */ - for (y = 0; y < z; y++) { - out[x++] = (unsigned char)((num >> 24) & 0xFF); - num <<= 8; - } - - /* we good */ - *outlen = x; - - return CRYPT_OK; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/short_integer/der_encode_short_integer.c,v $ */ -/* $Revision: 1.8 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_utctime.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_utctime.c deleted file mode 100644 index 167a2b4..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_utctime.c +++ /dev/null @@ -1,83 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_encode_utctime.c - ASN.1 DER, encode a UTCTIME, Tom St Denis -*/ - -#ifdef LTC_DER - -static const char *baseten = "0123456789"; - -#define STORE_V(y) \ - out[x++] = der_ia5_char_encode(baseten[(y/10) % 10]); \ - out[x++] = der_ia5_char_encode(baseten[y % 10]); - -/** - Encodes a UTC time structure in DER format - @param utctime The UTC time structure to encode - @param out The destination of the DER encoding of the UTC time structure - @param outlen [in/out] The length of the DER encoding - @return CRYPT_OK if successful -*/ -int der_encode_utctime(ltc_utctime *utctime, - unsigned char *out, unsigned long *outlen) -{ - unsigned long x, tmplen; - int err; - - LTC_ARGCHK(utctime != NULL); - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); - - if ((err = der_length_utctime(utctime, &tmplen)) != CRYPT_OK) { - return err; - } - if (tmplen > *outlen) { - *outlen = tmplen; - return CRYPT_BUFFER_OVERFLOW; - } - - /* store header */ - out[0] = 0x17; - - /* store values */ - x = 2; - STORE_V(utctime->YY); - STORE_V(utctime->MM); - STORE_V(utctime->DD); - STORE_V(utctime->hh); - STORE_V(utctime->mm); - STORE_V(utctime->ss); - - if (utctime->off_mm || utctime->off_hh) { - out[x++] = der_ia5_char_encode(utctime->off_dir ? '-' : '+'); - STORE_V(utctime->off_hh); - STORE_V(utctime->off_mm); - } else { - out[x++] = der_ia5_char_encode('Z'); - } - - /* store length */ - out[1] = (unsigned char)(x - 2); - - /* all good let's return */ - *outlen = x; - return CRYPT_OK; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/utctime/der_encode_utctime.c,v $ */ -/* $Revision: 1.10 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_utf8_string.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_utf8_string.c deleted file mode 100644 index 84d8d06..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_encode_utf8_string.c +++ /dev/null @@ -1,105 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_encode_utf8_string.c - ASN.1 DER, encode a UTF8 STRING, Tom St Denis -*/ - - -#ifdef LTC_DER - -/** - Store an UTF8 STRING - @param in The array of UTF8 to store (one per wchar_t) - @param inlen The number of UTF8 to store - @param out [out] The destination for the DER encoded UTF8 STRING - @param outlen [in/out] The max size and resulting size of the DER UTF8 STRING - @return CRYPT_OK if successful -*/ -int der_encode_utf8_string(const wchar_t *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen) -{ - unsigned long x, y, len; - - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); - - /* get the size */ - for (x = len = 0; x < inlen; x++) { - if (in[x] < 0 || in[x] > 0x1FFFF) { - return CRYPT_INVALID_ARG; - } - len += der_utf8_charsize(in[x]); - } - - if (len < 128) { - y = 2 + len; - } else if (len < 256) { - y = 3 + len; - } else if (len < 65536UL) { - y = 4 + len; - } else if (len < 16777216UL) { - y = 5 + len; - } else { - return CRYPT_INVALID_ARG; - } - - /* too big? */ - if (y > *outlen) { - *outlen = len; - return CRYPT_BUFFER_OVERFLOW; - } - - /* encode the header+len */ - x = 0; - out[x++] = 0x0C; - if (len < 128) { - out[x++] = (unsigned char)len; - } else if (len < 256) { - out[x++] = 0x81; - out[x++] = (unsigned char)len; - } else if (len < 65536UL) { - out[x++] = 0x82; - out[x++] = (unsigned char)((len>>8)&255); - out[x++] = (unsigned char)(len&255); - } else if (len < 16777216UL) { - out[x++] = 0x83; - out[x++] = (unsigned char)((len>>16)&255); - out[x++] = (unsigned char)((len>>8)&255); - out[x++] = (unsigned char)(len&255); - } else { - return CRYPT_INVALID_ARG; - } - - /* store UTF8 */ - for (y = 0; y < inlen; y++) { - switch (der_utf8_charsize(in[y])) { - case 1: out[x++] = (unsigned char)in[y]; break; - case 2: out[x++] = 0xC0 | ((in[y] >> 6) & 0x1F); out[x++] = 0x80 | (in[y] & 0x3F); break; - case 3: out[x++] = 0xE0 | ((in[y] >> 12) & 0x0F); out[x++] = 0x80 | ((in[y] >> 6) & 0x3F); out[x++] = 0x80 | (in[y] & 0x3F); break; - case 4: out[x++] = 0xF0 | ((in[y] >> 18) & 0x07); out[x++] = 0x80 | ((in[y] >> 12) & 0x3F); out[x++] = 0x80 | ((in[y] >> 6) & 0x3F); out[x++] = 0x80 | (in[y] & 0x3F); break; - } - } - - /* retun length */ - *outlen = x; - - return CRYPT_OK; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/utf8/der_encode_utf8_string.c,v $ */ -/* $Revision: 1.9 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_bit_string.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_bit_string.c deleted file mode 100644 index 2bffa3b..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_bit_string.c +++ /dev/null @@ -1,54 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_length_bit_string.c - ASN.1 DER, get length of BIT STRING, Tom St Denis -*/ - -#ifdef LTC_DER -/** - Gets length of DER encoding of BIT STRING - @param nbits The number of bits in the string to encode - @param outlen [out] The length of the DER encoding for the given string - @return CRYPT_OK if successful -*/ -int der_length_bit_string(unsigned long nbits, unsigned long *outlen) -{ - unsigned long nbytes; - LTC_ARGCHK(outlen != NULL); - - /* get the number of the bytes */ - nbytes = (nbits >> 3) + ((nbits & 7) ? 1 : 0) + 1; - - if (nbytes < 128) { - /* 03 LL PP DD DD DD ... */ - *outlen = 2 + nbytes; - } else if (nbytes < 256) { - /* 03 81 LL PP DD DD DD ... */ - *outlen = 3 + nbytes; - } else if (nbytes < 65536) { - /* 03 82 LL LL PP DD DD DD ... */ - *outlen = 4 + nbytes; - } else { - return CRYPT_INVALID_ARG; - } - - return CRYPT_OK; -} - -#endif - - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/bit/der_length_bit_string.c,v $ */ -/* $Revision: 1.3 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_boolean.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_boolean.c deleted file mode 100644 index e34ce5c..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_boolean.c +++ /dev/null @@ -1,35 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_length_boolean.c - ASN.1 DER, get length of a BOOLEAN, Tom St Denis -*/ - -#ifdef LTC_DER -/** - Gets length of DER encoding of a BOOLEAN - @param outlen [out] The length of the DER encoding - @return CRYPT_OK if successful -*/ -int der_length_boolean(unsigned long *outlen) -{ - LTC_ARGCHK(outlen != NULL); - *outlen = 3; - return CRYPT_OK; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/boolean/der_length_boolean.c,v $ */ -/* $Revision: 1.3 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_ia5_string.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_ia5_string.c deleted file mode 100644 index 473bc79..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_ia5_string.c +++ /dev/null @@ -1,194 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_length_ia5_string.c - ASN.1 DER, get length of IA5 STRING, Tom St Denis -*/ - -#ifdef LTC_DER - -static const struct { - int code, value; -} ia5_table[] = { -{ '\0', 0 }, -{ '\a', 7 }, -{ '\b', 8 }, -{ '\t', 9 }, -{ '\n', 10 }, -{ '\f', 12 }, -{ '\r', 13 }, -{ ' ', 32 }, -{ '!', 33 }, -{ '"', 34 }, -{ '#', 35 }, -{ '$', 36 }, -{ '%', 37 }, -{ '&', 38 }, -{ '\'', 39 }, -{ '(', 40 }, -{ ')', 41 }, -{ '*', 42 }, -{ '+', 43 }, -{ ',', 44 }, -{ '-', 45 }, -{ '.', 46 }, -{ '/', 47 }, -{ '0', 48 }, -{ '1', 49 }, -{ '2', 50 }, -{ '3', 51 }, -{ '4', 52 }, -{ '5', 53 }, -{ '6', 54 }, -{ '7', 55 }, -{ '8', 56 }, -{ '9', 57 }, -{ ':', 58 }, -{ ';', 59 }, -{ '<', 60 }, -{ '=', 61 }, -{ '>', 62 }, -{ '?', 63 }, -{ '@', 64 }, -{ 'A', 65 }, -{ 'B', 66 }, -{ 'C', 67 }, -{ 'D', 68 }, -{ 'E', 69 }, -{ 'F', 70 }, -{ 'G', 71 }, -{ 'H', 72 }, -{ 'I', 73 }, -{ 'J', 74 }, -{ 'K', 75 }, -{ 'L', 76 }, -{ 'M', 77 }, -{ 'N', 78 }, -{ 'O', 79 }, -{ 'P', 80 }, -{ 'Q', 81 }, -{ 'R', 82 }, -{ 'S', 83 }, -{ 'T', 84 }, -{ 'U', 85 }, -{ 'V', 86 }, -{ 'W', 87 }, -{ 'X', 88 }, -{ 'Y', 89 }, -{ 'Z', 90 }, -{ '[', 91 }, -{ '\\', 92 }, -{ ']', 93 }, -{ '^', 94 }, -{ '_', 95 }, -{ '`', 96 }, -{ 'a', 97 }, -{ 'b', 98 }, -{ 'c', 99 }, -{ 'd', 100 }, -{ 'e', 101 }, -{ 'f', 102 }, -{ 'g', 103 }, -{ 'h', 104 }, -{ 'i', 105 }, -{ 'j', 106 }, -{ 'k', 107 }, -{ 'l', 108 }, -{ 'm', 109 }, -{ 'n', 110 }, -{ 'o', 111 }, -{ 'p', 112 }, -{ 'q', 113 }, -{ 'r', 114 }, -{ 's', 115 }, -{ 't', 116 }, -{ 'u', 117 }, -{ 'v', 118 }, -{ 'w', 119 }, -{ 'x', 120 }, -{ 'y', 121 }, -{ 'z', 122 }, -{ '{', 123 }, -{ '|', 124 }, -{ '}', 125 }, -{ '~', 126 } -}; - -int der_ia5_char_encode(int c) -{ - int x; - for (x = 0; x < (int)(sizeof(ia5_table)/sizeof(ia5_table[0])); x++) { - if (ia5_table[x].code == c) { - return ia5_table[x].value; - } - } - return -1; -} - -int der_ia5_value_decode(int v) -{ - int x; - for (x = 0; x < (int)(sizeof(ia5_table)/sizeof(ia5_table[0])); x++) { - if (ia5_table[x].value == v) { - return ia5_table[x].code; - } - } - return -1; -} - -/** - Gets length of DER encoding of IA5 STRING - @param octets The values you want to encode - @param noctets The number of octets in the string to encode - @param outlen [out] The length of the DER encoding for the given string - @return CRYPT_OK if successful -*/ -int der_length_ia5_string(const unsigned char *octets, unsigned long noctets, unsigned long *outlen) -{ - unsigned long x; - - LTC_ARGCHK(outlen != NULL); - LTC_ARGCHK(octets != NULL); - - /* scan string for validity */ - for (x = 0; x < noctets; x++) { - if (der_ia5_char_encode(octets[x]) == -1) { - return CRYPT_INVALID_ARG; - } - } - - if (noctets < 128) { - /* 16 LL DD DD DD ... */ - *outlen = 2 + noctets; - } else if (noctets < 256) { - /* 16 81 LL DD DD DD ... */ - *outlen = 3 + noctets; - } else if (noctets < 65536UL) { - /* 16 82 LL LL DD DD DD ... */ - *outlen = 4 + noctets; - } else if (noctets < 16777216UL) { - /* 16 83 LL LL LL DD DD DD ... */ - *outlen = 5 + noctets; - } else { - return CRYPT_INVALID_ARG; - } - - return CRYPT_OK; -} - -#endif - - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/ia5/der_length_ia5_string.c,v $ */ -/* $Revision: 1.3 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_integer.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_integer.c deleted file mode 100644 index 540d205..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_integer.c +++ /dev/null @@ -1,82 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_length_integer.c - ASN.1 DER, get length of encoding, Tom St Denis -*/ - - -#ifdef LTC_DER -/** - Gets length of DER encoding of num - @param num The int to get the size of - @param outlen [out] The length of the DER encoding for the given integer - @return CRYPT_OK if successful -*/ -int der_length_integer(void *num, unsigned long *outlen) -{ - unsigned long z, len; - int leading_zero; - - LTC_ARGCHK(num != NULL); - LTC_ARGCHK(outlen != NULL); - - if (mp_cmp_d(num, 0) != LTC_MP_LT) { - /* positive */ - - /* we only need a leading zero if the msb of the first byte is one */ - if ((mp_count_bits(num) & 7) == 0 || mp_iszero(num) == LTC_MP_YES) { - leading_zero = 1; - } else { - leading_zero = 0; - } - - /* size for bignum */ - z = len = leading_zero + mp_unsigned_bin_size(num); - } else { - /* it's negative */ - /* find power of 2 that is a multiple of eight and greater than count bits */ - leading_zero = 0; - z = mp_count_bits(num); - z = z + (8 - (z & 7)); - if (((mp_cnt_lsb(num)+1)==mp_count_bits(num)) && ((mp_count_bits(num)&7)==0)) --z; - len = z = z >> 3; - } - - /* now we need a length */ - if (z < 128) { - /* short form */ - ++len; - } else { - /* long form (relies on z != 0), assumes length bytes < 128 */ - ++len; - - while (z) { - ++len; - z >>= 8; - } - } - - /* we need a 0x02 to indicate it's INTEGER */ - ++len; - - /* return length */ - *outlen = len; - return CRYPT_OK; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/integer/der_length_integer.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_object_identifier.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_object_identifier.c deleted file mode 100644 index 94c326f..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_object_identifier.c +++ /dev/null @@ -1,89 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_length_object_identifier.c - ASN.1 DER, get length of Object Identifier, Tom St Denis -*/ - -#ifdef LTC_DER - -unsigned long der_object_identifier_bits(unsigned long x) -{ - unsigned long c; - x &= 0xFFFFFFFF; - c = 0; - while (x) { - ++c; - x >>= 1; - } - return c; -} - - -/** - Gets length of DER encoding of Object Identifier - @param nwords The number of OID words - @param words The actual OID words to get the size of - @param outlen [out] The length of the DER encoding for the given string - @return CRYPT_OK if successful -*/ -int der_length_object_identifier(unsigned long *words, unsigned long nwords, unsigned long *outlen) -{ - unsigned long y, z, t, wordbuf; - - LTC_ARGCHK(words != NULL); - LTC_ARGCHK(outlen != NULL); - - - /* must be >= 2 words */ - if (nwords < 2) { - return CRYPT_INVALID_ARG; - } - - /* word1 = 0,1,2,3 and word2 0..39 */ - if (words[0] > 3 || (words[0] < 2 && words[1] > 39)) { - return CRYPT_INVALID_ARG; - } - - /* leading word is the first two */ - z = 0; - wordbuf = words[0] * 40 + words[1]; - for (y = 1; y < nwords; y++) { - t = der_object_identifier_bits(wordbuf); - z += t/7 + ((t%7) ? 1 : 0) + (wordbuf == 0 ? 1 : 0); - if (y < nwords - 1) { - /* grab next word */ - wordbuf = words[y+1]; - } - } - - /* now depending on the length our length encoding changes */ - if (z < 128) { - z += 2; - } else if (z < 256) { - z += 3; - } else if (z < 65536UL) { - z += 4; - } else { - return CRYPT_INVALID_ARG; - } - - *outlen = z; - return CRYPT_OK; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/object_identifier/der_length_object_identifier.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_octet_string.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_octet_string.c deleted file mode 100644 index acd4053..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_octet_string.c +++ /dev/null @@ -1,53 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_length_octet_string.c - ASN.1 DER, get length of OCTET STRING, Tom St Denis -*/ - -#ifdef LTC_DER -/** - Gets length of DER encoding of OCTET STRING - @param noctets The number of octets in the string to encode - @param outlen [out] The length of the DER encoding for the given string - @return CRYPT_OK if successful -*/ -int der_length_octet_string(unsigned long noctets, unsigned long *outlen) -{ - LTC_ARGCHK(outlen != NULL); - - if (noctets < 128) { - /* 04 LL DD DD DD ... */ - *outlen = 2 + noctets; - } else if (noctets < 256) { - /* 04 81 LL DD DD DD ... */ - *outlen = 3 + noctets; - } else if (noctets < 65536UL) { - /* 04 82 LL LL DD DD DD ... */ - *outlen = 4 + noctets; - } else if (noctets < 16777216UL) { - /* 04 83 LL LL LL DD DD DD ... */ - *outlen = 5 + noctets; - } else { - return CRYPT_INVALID_ARG; - } - - return CRYPT_OK; -} - -#endif - - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/octet/der_length_octet_string.c,v $ */ -/* $Revision: 1.3 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_printable_string.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_printable_string.c deleted file mode 100644 index ef1ed0e..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_printable_string.c +++ /dev/null @@ -1,166 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_length_printable_string.c - ASN.1 DER, get length of Printable STRING, Tom St Denis -*/ - -#ifdef LTC_DER - -static const struct { - int code, value; -} printable_table[] = { -{ ' ', 32 }, -{ '\'', 39 }, -{ '(', 40 }, -{ ')', 41 }, -{ '+', 43 }, -{ ',', 44 }, -{ '-', 45 }, -{ '.', 46 }, -{ '/', 47 }, -{ '0', 48 }, -{ '1', 49 }, -{ '2', 50 }, -{ '3', 51 }, -{ '4', 52 }, -{ '5', 53 }, -{ '6', 54 }, -{ '7', 55 }, -{ '8', 56 }, -{ '9', 57 }, -{ ':', 58 }, -{ '=', 61 }, -{ '?', 63 }, -{ 'A', 65 }, -{ 'B', 66 }, -{ 'C', 67 }, -{ 'D', 68 }, -{ 'E', 69 }, -{ 'F', 70 }, -{ 'G', 71 }, -{ 'H', 72 }, -{ 'I', 73 }, -{ 'J', 74 }, -{ 'K', 75 }, -{ 'L', 76 }, -{ 'M', 77 }, -{ 'N', 78 }, -{ 'O', 79 }, -{ 'P', 80 }, -{ 'Q', 81 }, -{ 'R', 82 }, -{ 'S', 83 }, -{ 'T', 84 }, -{ 'U', 85 }, -{ 'V', 86 }, -{ 'W', 87 }, -{ 'X', 88 }, -{ 'Y', 89 }, -{ 'Z', 90 }, -{ 'a', 97 }, -{ 'b', 98 }, -{ 'c', 99 }, -{ 'd', 100 }, -{ 'e', 101 }, -{ 'f', 102 }, -{ 'g', 103 }, -{ 'h', 104 }, -{ 'i', 105 }, -{ 'j', 106 }, -{ 'k', 107 }, -{ 'l', 108 }, -{ 'm', 109 }, -{ 'n', 110 }, -{ 'o', 111 }, -{ 'p', 112 }, -{ 'q', 113 }, -{ 'r', 114 }, -{ 's', 115 }, -{ 't', 116 }, -{ 'u', 117 }, -{ 'v', 118 }, -{ 'w', 119 }, -{ 'x', 120 }, -{ 'y', 121 }, -{ 'z', 122 }, -}; - -int der_printable_char_encode(int c) -{ - int x; - for (x = 0; x < (int)(sizeof(printable_table)/sizeof(printable_table[0])); x++) { - if (printable_table[x].code == c) { - return printable_table[x].value; - } - } - return -1; -} - -int der_printable_value_decode(int v) -{ - int x; - for (x = 0; x < (int)(sizeof(printable_table)/sizeof(printable_table[0])); x++) { - if (printable_table[x].value == v) { - return printable_table[x].code; - } - } - return -1; -} - -/** - Gets length of DER encoding of Printable STRING - @param octets The values you want to encode - @param noctets The number of octets in the string to encode - @param outlen [out] The length of the DER encoding for the given string - @return CRYPT_OK if successful -*/ -int der_length_printable_string(const unsigned char *octets, unsigned long noctets, unsigned long *outlen) -{ - unsigned long x; - - LTC_ARGCHK(outlen != NULL); - LTC_ARGCHK(octets != NULL); - - /* scan string for validity */ - for (x = 0; x < noctets; x++) { - if (der_printable_char_encode(octets[x]) == -1) { - return CRYPT_INVALID_ARG; - } - } - - if (noctets < 128) { - /* 16 LL DD DD DD ... */ - *outlen = 2 + noctets; - } else if (noctets < 256) { - /* 16 81 LL DD DD DD ... */ - *outlen = 3 + noctets; - } else if (noctets < 65536UL) { - /* 16 82 LL LL DD DD DD ... */ - *outlen = 4 + noctets; - } else if (noctets < 16777216UL) { - /* 16 83 LL LL LL DD DD DD ... */ - *outlen = 5 + noctets; - } else { - return CRYPT_INVALID_ARG; - } - - return CRYPT_OK; -} - -#endif - - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/printable_string/der_length_printable_string.c,v $ */ -/* $Revision: 1.3 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_sequence.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_sequence.c deleted file mode 100644 index e75ed7e..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_sequence.c +++ /dev/null @@ -1,169 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_length_sequence.c - ASN.1 DER, length a SEQUENCE, Tom St Denis -*/ - -#ifdef LTC_DER - -/** - Get the length of a DER sequence - @param list The sequences of items in the SEQUENCE - @param inlen The number of items - @param outlen [out] The length required in octets to store it - @return CRYPT_OK on success -*/ -int der_length_sequence(ltc_asn1_list *list, unsigned long inlen, - unsigned long *outlen) -{ - int err, type; - unsigned long size, x, y, z, i; - void *data; - - LTC_ARGCHK(list != NULL); - LTC_ARGCHK(outlen != NULL); - - /* get size of output that will be required */ - y = 0; - for (i = 0; i < inlen; i++) { - type = list[i].type; - size = list[i].size; - data = list[i].data; - - if (type == LTC_ASN1_EOL) { - break; - } - - switch (type) { - case LTC_ASN1_BOOLEAN: - if ((err = der_length_boolean(&x)) != CRYPT_OK) { - goto LBL_ERR; - } - y += x; - break; - - case LTC_ASN1_INTEGER: - if ((err = der_length_integer(data, &x)) != CRYPT_OK) { - goto LBL_ERR; - } - y += x; - break; - - case LTC_ASN1_SHORT_INTEGER: - if ((err = der_length_short_integer(*((unsigned long *)data), &x)) != CRYPT_OK) { - goto LBL_ERR; - } - y += x; - break; - - case LTC_ASN1_BIT_STRING: - if ((err = der_length_bit_string(size, &x)) != CRYPT_OK) { - goto LBL_ERR; - } - y += x; - break; - - case LTC_ASN1_OCTET_STRING: - if ((err = der_length_octet_string(size, &x)) != CRYPT_OK) { - goto LBL_ERR; - } - y += x; - break; - - case LTC_ASN1_NULL: - y += 2; - break; - - case LTC_ASN1_OBJECT_IDENTIFIER: - if ((err = der_length_object_identifier(data, size, &x)) != CRYPT_OK) { - goto LBL_ERR; - } - y += x; - break; - - case LTC_ASN1_IA5_STRING: - if ((err = der_length_ia5_string(data, size, &x)) != CRYPT_OK) { - goto LBL_ERR; - } - y += x; - break; - - case LTC_ASN1_PRINTABLE_STRING: - if ((err = der_length_printable_string(data, size, &x)) != CRYPT_OK) { - goto LBL_ERR; - } - y += x; - break; - - case LTC_ASN1_UTCTIME: - if ((err = der_length_utctime(data, &x)) != CRYPT_OK) { - goto LBL_ERR; - } - y += x; - break; - - case LTC_ASN1_UTF8_STRING: - if ((err = der_length_utf8_string(data, size, &x)) != CRYPT_OK) { - goto LBL_ERR; - } - y += x; - break; - - case LTC_ASN1_SET: - case LTC_ASN1_SETOF: - case LTC_ASN1_SEQUENCE: - if ((err = der_length_sequence(data, size, &x)) != CRYPT_OK) { - goto LBL_ERR; - } - y += x; - break; - - - default: - err = CRYPT_INVALID_ARG; - goto LBL_ERR; - } - } - - /* calc header size */ - z = y; - if (y < 128) { - y += 2; - } else if (y < 256) { - /* 0x30 0x81 LL */ - y += 3; - } else if (y < 65536UL) { - /* 0x30 0x82 LL LL */ - y += 4; - } else if (y < 16777216UL) { - /* 0x30 0x83 LL LL LL */ - y += 5; - } else { - err = CRYPT_INVALID_ARG; - goto LBL_ERR; - } - - /* store size */ - *outlen = y; - err = CRYPT_OK; - -LBL_ERR: - return err; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/sequence/der_length_sequence.c,v $ */ -/* $Revision: 1.14 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_short_integer.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_short_integer.c deleted file mode 100644 index afa6dd0..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_short_integer.c +++ /dev/null @@ -1,70 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_length_short_integer.c - ASN.1 DER, get length of encoding, Tom St Denis -*/ - - -#ifdef LTC_DER -/** - Gets length of DER encoding of num - @param num The integer to get the size of - @param outlen [out] The length of the DER encoding for the given integer - @return CRYPT_OK if successful -*/ -int der_length_short_integer(unsigned long num, unsigned long *outlen) -{ - unsigned long z, y, len; - - LTC_ARGCHK(outlen != NULL); - - /* force to 32 bits */ - num &= 0xFFFFFFFFUL; - - /* get the number of bytes */ - z = 0; - y = num; - while (y) { - ++z; - y >>= 8; - } - - /* handle zero */ - if (z == 0) { - z = 1; - } - - /* we need a 0x02 to indicate it's INTEGER */ - len = 1; - - /* length byte */ - ++len; - - /* bytes in value */ - len += z; - - /* see if msb is set */ - len += (num&(1UL<<((z<<3) - 1))) ? 1 : 0; - - /* return length */ - *outlen = len; - - return CRYPT_OK; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/short_integer/der_length_short_integer.c,v $ */ -/* $Revision: 1.6 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_utctime.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_utctime.c deleted file mode 100644 index 1296bab..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_utctime.c +++ /dev/null @@ -1,46 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_length_utctime.c - ASN.1 DER, get length of UTCTIME, Tom St Denis -*/ - -#ifdef LTC_DER - -/** - Gets length of DER encoding of UTCTIME - @param utctime The UTC time structure to get the size of - @param outlen [out] The length of the DER encoding - @return CRYPT_OK if successful -*/ -int der_length_utctime(ltc_utctime *utctime, unsigned long *outlen) -{ - LTC_ARGCHK(outlen != NULL); - LTC_ARGCHK(utctime != NULL); - - if (utctime->off_hh == 0 && utctime->off_mm == 0) { - /* we encode as YYMMDDhhmmssZ */ - *outlen = 2 + 13; - } else { - /* we encode as YYMMDDhhmmss{+|-}hh'mm' */ - *outlen = 2 + 17; - } - - return CRYPT_OK; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/utctime/der_length_utctime.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_utf8_string.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_utf8_string.c deleted file mode 100644 index 514db84..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_length_utf8_string.c +++ /dev/null @@ -1,83 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_length_utf8_string.c - ASN.1 DER, get length of UTF8 STRING, Tom St Denis -*/ - -#ifdef LTC_DER - -/** Return the size in bytes of a UTF-8 character - @param c The UTF-8 character to measure - @return The size in bytes -*/ -unsigned long der_utf8_charsize(const wchar_t c) -{ - if (c <= 0x7F) { - return 1; - } else if (c <= 0x7FF) { - return 2; - } else if (c <= 0xFFFF) { - return 3; - } else { - return 4; - } -} - -/** - Gets length of DER encoding of UTF8 STRING - @param in The characters to measure the length of - @param noctets The number of octets in the string to encode - @param outlen [out] The length of the DER encoding for the given string - @return CRYPT_OK if successful -*/ -int der_length_utf8_string(const wchar_t *in, unsigned long noctets, unsigned long *outlen) -{ - unsigned long x, len; - - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(outlen != NULL); - - len = 0; - for (x = 0; x < noctets; x++) { - if (in[x] < 0 || in[x] > 0x10FFFF) { - return CRYPT_INVALID_ARG; - } - len += der_utf8_charsize(in[x]); - } - - if (len < 128) { - /* 0C LL DD DD DD ... */ - *outlen = 2 + len; - } else if (len < 256) { - /* 0C 81 LL DD DD DD ... */ - *outlen = 3 + len; - } else if (len < 65536UL) { - /* 0C 82 LL LL DD DD DD ... */ - *outlen = 4 + len; - } else if (len < 16777216UL) { - /* 0C 83 LL LL LL DD DD DD ... */ - *outlen = 5 + len; - } else { - return CRYPT_INVALID_ARG; - } - - return CRYPT_OK; -} - -#endif - - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/utf8/der_length_utf8_string.c,v $ */ -/* $Revision: 1.6 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_sequence_free.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_sequence_free.c deleted file mode 100644 index 4887215..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/asn1/der_sequence_free.c +++ /dev/null @@ -1,65 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file der_sequence_free.c - ASN.1 DER, free's a structure allocated by der_decode_sequence_flexi(), Tom St Denis -*/ - -#ifdef LTC_DER - -/** - Free memory allocated by der_decode_sequence_flexi() - @param in The list to free -*/ -void der_sequence_free(ltc_asn1_list *in) -{ - ltc_asn1_list *l; - - /* walk to the start of the chain */ - while (in->prev != NULL || in->parent != NULL) { - if (in->parent != NULL) { - in = in->parent; - } else { - in = in->prev; - } - } - - /* now walk the list and free stuff */ - while (in != NULL) { - /* is there a child? */ - if (in->child) { - /* disconnect */ - in->child->parent = NULL; - der_sequence_free(in->child); - } - - switch (in->type) { - case LTC_ASN1_SET: - case LTC_ASN1_SETOF: - case LTC_ASN1_SEQUENCE: break; - case LTC_ASN1_INTEGER : if (in->data != NULL) { mp_clear(in->data); } break; - default : if (in->data != NULL) { XFREE(in->data); } - } - - /* move to next and free current */ - l = in->next; - free(in); - in = l; - } -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/asn1/der/sequence/der_sequence_free.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:27:24 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_map.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_map.c deleted file mode 100644 index 5a1324c..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_map.c +++ /dev/null @@ -1,76 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b - * - * All curves taken from NIST recommendation paper of July 1999 - * Available at http://csrc.nist.gov/cryptval/dss.htm - */ -#include "../../headers/tomcrypt.h" - -/** - @file ltc_ecc_map.c - ECC Crypto, Tom St Denis -*/ - -#ifdef LTC_MECC - -/** - Map a projective jacbobian point back to affine space - @param P [in/out] The point to map - @param modulus The modulus of the field the ECC curve is in - @param mp The "b" value from montgomery_setup() - @return CRYPT_OK on success -*/ -int ltc_ecc_map(ecc_point *P, void *modulus, void *mp) -{ - void *t1, *t2; - int err; - - LTC_ARGCHK(P != NULL); - LTC_ARGCHK(modulus != NULL); - LTC_ARGCHK(mp != NULL); - - if ((err = mp_init_multi(&t1, &t2, NULL)) != CRYPT_OK) { - return CRYPT_MEM; - } - - /* first map z back to normal */ - if ((err = mp_montgomery_reduce(P->z, modulus, mp)) != CRYPT_OK) { goto done; } - - /* get 1/z */ - if ((err = mp_invmod(P->z, modulus, t1)) != CRYPT_OK) { goto done; } - - /* get 1/z^2 and 1/z^3 */ - if ((err = mp_sqr(t1, t2)) != CRYPT_OK) { goto done; } - if ((err = mp_mod(t2, modulus, t2)) != CRYPT_OK) { goto done; } - if ((err = mp_mul(t1, t2, t1)) != CRYPT_OK) { goto done; } - if ((err = mp_mod(t1, modulus, t1)) != CRYPT_OK) { goto done; } - - /* multiply against x/y */ - if ((err = mp_mul(P->x, t2, P->x)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(P->x, modulus, mp)) != CRYPT_OK) { goto done; } - if ((err = mp_mul(P->y, t1, P->y)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(P->y, modulus, mp)) != CRYPT_OK) { goto done; } - if ((err = mp_set(P->z, 1)) != CRYPT_OK) { goto done; } - - err = CRYPT_OK; -done: - mp_clear_multi(t1, t2, NULL); - return err; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/ecc/ltc_ecc_map.c,v $ */ -/* $Revision: 1.7 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ - diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_mul2add.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_mul2add.c deleted file mode 100644 index 2c468ea..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_mul2add.c +++ /dev/null @@ -1,207 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b - * - * All curves taken from NIST recommendation paper of July 1999 - * Available at http://csrc.nist.gov/cryptval/dss.htm - */ -#include "../../headers/tomcrypt.h" - -/** - @file ltc_ecc_mul2add.c - ECC Crypto, Shamir's Trick, Tom St Denis -*/ - -#ifdef LTC_MECC - -#ifdef LTC_ECC_SHAMIR - -/** Computes kA*A + kB*B = C using Shamir's Trick - @param A First point to multiply - @param kA What to multiple A by - @param B Second point to multiply - @param kB What to multiple B by - @param C [out] Destination point (can overlap with A or B - @param modulus Modulus for curve - @return CRYPT_OK on success -*/ -int ltc_ecc_mul2add(ecc_point *A, void *kA, - ecc_point *B, void *kB, - ecc_point *C, - void *modulus) -{ - ecc_point *precomp[16]; - unsigned bitbufA, bitbufB, lenA, lenB, len, x, y, nA, nB, nibble; - unsigned char *tA, *tB; - int err, first; - void *mp, *mu; - - /* argchks */ - LTC_ARGCHK(A != NULL); - LTC_ARGCHK(B != NULL); - LTC_ARGCHK(C != NULL); - LTC_ARGCHK(kA != NULL); - LTC_ARGCHK(kB != NULL); - LTC_ARGCHK(modulus != NULL); - - /* allocate memory */ - tA = XCALLOC(1, ECC_BUF_SIZE); - if (tA == NULL) { - return CRYPT_MEM; - } - tB = XCALLOC(1, ECC_BUF_SIZE); - if (tB == NULL) { - XFREE(tA); - return CRYPT_MEM; - } - - /* get sizes */ - lenA = mp_unsigned_bin_size(kA); - lenB = mp_unsigned_bin_size(kB); - len = MAX(lenA, lenB); - - /* sanity check */ - if ((lenA > ECC_BUF_SIZE) || (lenB > ECC_BUF_SIZE)) { - err = CRYPT_INVALID_ARG; - goto ERR_T; - } - - /* extract and justify kA */ - mp_to_unsigned_bin(kA, (len - lenA) + tA); - - /* extract and justify kB */ - mp_to_unsigned_bin(kB, (len - lenB) + tB); - - /* allocate the table */ - for (x = 0; x < 16; x++) { - precomp[x] = ltc_ecc_new_point(); - if (precomp[x] == NULL) { - for (y = 0; y < x; ++y) { - ltc_ecc_del_point(precomp[y]); - } - err = CRYPT_MEM; - goto ERR_T; - } - } - - /* init montgomery reduction */ - if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) { - goto ERR_P; - } - if ((err = mp_init(&mu)) != CRYPT_OK) { - goto ERR_MP; - } - if ((err = mp_montgomery_normalization(mu, modulus)) != CRYPT_OK) { - goto ERR_MU; - } - - /* copy ones ... */ - if ((err = mp_mulmod(A->x, mu, modulus, precomp[1]->x)) != CRYPT_OK) { goto ERR_MU; } - if ((err = mp_mulmod(A->y, mu, modulus, precomp[1]->y)) != CRYPT_OK) { goto ERR_MU; } - if ((err = mp_mulmod(A->z, mu, modulus, precomp[1]->z)) != CRYPT_OK) { goto ERR_MU; } - - if ((err = mp_mulmod(B->x, mu, modulus, precomp[1<<2]->x)) != CRYPT_OK) { goto ERR_MU; } - if ((err = mp_mulmod(B->y, mu, modulus, precomp[1<<2]->y)) != CRYPT_OK) { goto ERR_MU; } - if ((err = mp_mulmod(B->z, mu, modulus, precomp[1<<2]->z)) != CRYPT_OK) { goto ERR_MU; } - - /* precomp [i,0](A + B) table */ - if ((err = ltc_mp.ecc_ptdbl(precomp[1], precomp[2], modulus, mp)) != CRYPT_OK) { goto ERR_MU; } - if ((err = ltc_mp.ecc_ptadd(precomp[1], precomp[2], precomp[3], modulus, mp)) != CRYPT_OK) { goto ERR_MU; } - - /* precomp [0,i](A + B) table */ - if ((err = ltc_mp.ecc_ptdbl(precomp[1<<2], precomp[2<<2], modulus, mp)) != CRYPT_OK) { goto ERR_MU; } - if ((err = ltc_mp.ecc_ptadd(precomp[1<<2], precomp[2<<2], precomp[3<<2], modulus, mp)) != CRYPT_OK) { goto ERR_MU; } - - /* precomp [i,j](A + B) table (i != 0, j != 0) */ - for (x = 1; x < 4; x++) { - for (y = 1; y < 4; y++) { - if ((err = ltc_mp.ecc_ptadd(precomp[x], precomp[(y<<2)], precomp[x+(y<<2)], modulus, mp)) != CRYPT_OK) { goto ERR_MU; } - } - } - - nibble = 3; - first = 1; - bitbufA = tA[0]; - bitbufB = tB[0]; - - /* for every byte of the multiplicands */ - for (x = -1;; ) { - /* grab a nibble */ - if (++nibble == 4) { - ++x; if (x == len) break; - bitbufA = tA[x]; - bitbufB = tB[x]; - nibble = 0; - } - - /* extract two bits from both, shift/update */ - nA = (bitbufA >> 6) & 0x03; - nB = (bitbufB >> 6) & 0x03; - bitbufA = (bitbufA << 2) & 0xFF; - bitbufB = (bitbufB << 2) & 0xFF; - - /* if both zero, if first, continue */ - if ((nA == 0) && (nB == 0) && (first == 1)) { - continue; - } - - /* double twice, only if this isn't the first */ - if (first == 0) { - /* double twice */ - if ((err = ltc_mp.ecc_ptdbl(C, C, modulus, mp)) != CRYPT_OK) { goto ERR_MU; } - if ((err = ltc_mp.ecc_ptdbl(C, C, modulus, mp)) != CRYPT_OK) { goto ERR_MU; } - } - - /* if not both zero */ - if ((nA != 0) || (nB != 0)) { - if (first == 1) { - /* if first, copy from table */ - first = 0; - if ((err = mp_copy(precomp[nA + (nB<<2)]->x, C->x)) != CRYPT_OK) { goto ERR_MU; } - if ((err = mp_copy(precomp[nA + (nB<<2)]->y, C->y)) != CRYPT_OK) { goto ERR_MU; } - if ((err = mp_copy(precomp[nA + (nB<<2)]->z, C->z)) != CRYPT_OK) { goto ERR_MU; } - } else { - /* if not first, add from table */ - if ((err = ltc_mp.ecc_ptadd(C, precomp[nA + (nB<<2)], C, modulus, mp)) != CRYPT_OK) { goto ERR_MU; } - } - } - } - - /* reduce to affine */ - err = ltc_ecc_map(C, modulus, mp); - - /* clean up */ -ERR_MU: - mp_clear(mu); -ERR_MP: - mp_montgomery_free(mp); -ERR_P: - for (x = 0; x < 16; x++) { - ltc_ecc_del_point(precomp[x]); - } -ERR_T: -#ifdef LTC_CLEAN_STACK - zeromem(tA, ECC_BUF_SIZE); - zeromem(tB, ECC_BUF_SIZE); -#endif - XFREE(tA); - XFREE(tB); - - return err; -} - -#endif -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/ecc/ltc_ecc_mul2add.c,v $ */ -/* $Revision: 1.8 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_mulmod.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_mulmod.c deleted file mode 100644 index f9d0cad..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_mulmod.c +++ /dev/null @@ -1,222 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b - * - * All curves taken from NIST recommendation paper of July 1999 - * Available at http://csrc.nist.gov/cryptval/dss.htm - */ -#include "../../headers/tomcrypt.h" - -/** - @file ltc_ecc_mulmod.c - ECC Crypto, Tom St Denis -*/ - -#ifdef LTC_MECC -#ifndef LTC_ECC_TIMING_RESISTANT - -/* size of sliding window, don't change this! */ -#define WINSIZE 4 - -/** - Perform a point multiplication - @param k The scalar to multiply by - @param G The base point - @param R [out] Destination for kG - @param modulus The modulus of the field the ECC curve is in - @param map Boolean whether to map back to affine or not (1==map, 0 == leave in projective) - @return CRYPT_OK on success -*/ -int ltc_ecc_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int map) -{ - ecc_point *tG, *M[8]; - int i, j, err; - void *mu, *mp; - unsigned long buf; - int first, bitbuf, bitcpy, bitcnt, mode, digidx; - - LTC_ARGCHK(k != NULL); - LTC_ARGCHK(G != NULL); - LTC_ARGCHK(R != NULL); - LTC_ARGCHK(modulus != NULL); - - /* init montgomery reduction */ - if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) { - return err; - } - if ((err = mp_init(&mu)) != CRYPT_OK) { - mp_montgomery_free(mp); - return err; - } - if ((err = mp_montgomery_normalization(mu, modulus)) != CRYPT_OK) { - mp_montgomery_free(mp); - mp_clear(mu); - return err; - } - - /* alloc ram for window temps */ - for (i = 0; i < 8; i++) { - M[i] = ltc_ecc_new_point(); - if (M[i] == NULL) { - for (j = 0; j < i; j++) { - ltc_ecc_del_point(M[j]); - } - mp_montgomery_free(mp); - mp_clear(mu); - return CRYPT_MEM; - } - } - - /* make a copy of G incase R==G */ - tG = ltc_ecc_new_point(); - if (tG == NULL) { err = CRYPT_MEM; goto done; } - - /* tG = G and convert to montgomery */ - if (mp_cmp_d(mu, 1) == LTC_MP_EQ) { - if ((err = mp_copy(G->x, tG->x)) != CRYPT_OK) { goto done; } - if ((err = mp_copy(G->y, tG->y)) != CRYPT_OK) { goto done; } - if ((err = mp_copy(G->z, tG->z)) != CRYPT_OK) { goto done; } - } else { - if ((err = mp_mulmod(G->x, mu, modulus, tG->x)) != CRYPT_OK) { goto done; } - if ((err = mp_mulmod(G->y, mu, modulus, tG->y)) != CRYPT_OK) { goto done; } - if ((err = mp_mulmod(G->z, mu, modulus, tG->z)) != CRYPT_OK) { goto done; } - } - mp_clear(mu); - mu = NULL; - - /* calc the M tab, which holds kG for k==8..15 */ - /* M[0] == 8G */ - if ((err = ltc_mp.ecc_ptdbl(tG, M[0], modulus, mp)) != CRYPT_OK) { goto done; } - if ((err = ltc_mp.ecc_ptdbl(M[0], M[0], modulus, mp)) != CRYPT_OK) { goto done; } - if ((err = ltc_mp.ecc_ptdbl(M[0], M[0], modulus, mp)) != CRYPT_OK) { goto done; } - - /* now find (8+k)G for k=1..7 */ - for (j = 9; j < 16; j++) { - if ((err = ltc_mp.ecc_ptadd(M[j-9], tG, M[j-8], modulus, mp)) != CRYPT_OK) { goto done; } - } - - /* setup sliding window */ - mode = 0; - bitcnt = 1; - buf = 0; - digidx = mp_get_digit_count(k) - 1; - bitcpy = bitbuf = 0; - first = 1; - - /* perform ops */ - for (;;) { - /* grab next digit as required */ - if (--bitcnt == 0) { - if (digidx == -1) { - break; - } - buf = mp_get_digit(k, digidx); - bitcnt = (int) ltc_mp.bits_per_digit; - --digidx; - } - - /* grab the next msb from the ltiplicand */ - i = (buf >> (ltc_mp.bits_per_digit - 1)) & 1; - buf <<= 1; - - /* skip leading zero bits */ - if (mode == 0 && i == 0) { - continue; - } - - /* if the bit is zero and mode == 1 then we double */ - if (mode == 1 && i == 0) { - if ((err = ltc_mp.ecc_ptdbl(R, R, modulus, mp)) != CRYPT_OK) { goto done; } - continue; - } - - /* else we add it to the window */ - bitbuf |= (i << (WINSIZE - ++bitcpy)); - mode = 2; - - if (bitcpy == WINSIZE) { - /* if this is the first window we do a simple copy */ - if (first == 1) { - /* R = kG [k = first window] */ - if ((err = mp_copy(M[bitbuf-8]->x, R->x)) != CRYPT_OK) { goto done; } - if ((err = mp_copy(M[bitbuf-8]->y, R->y)) != CRYPT_OK) { goto done; } - if ((err = mp_copy(M[bitbuf-8]->z, R->z)) != CRYPT_OK) { goto done; } - first = 0; - } else { - /* normal window */ - /* ok window is filled so double as required and add */ - /* double first */ - for (j = 0; j < WINSIZE; j++) { - if ((err = ltc_mp.ecc_ptdbl(R, R, modulus, mp)) != CRYPT_OK) { goto done; } - } - - /* then add, bitbuf will be 8..15 [8..2^WINSIZE] guaranteed */ - if ((err = ltc_mp.ecc_ptadd(R, M[bitbuf-8], R, modulus, mp)) != CRYPT_OK) { goto done; } - } - /* empty window and reset */ - bitcpy = bitbuf = 0; - mode = 1; - } - } - - /* if bits remain then double/add */ - if (mode == 2 && bitcpy > 0) { - /* double then add */ - for (j = 0; j < bitcpy; j++) { - /* only double if we have had at least one add first */ - if (first == 0) { - if ((err = ltc_mp.ecc_ptdbl(R, R, modulus, mp)) != CRYPT_OK) { goto done; } - } - - bitbuf <<= 1; - if ((bitbuf & (1 << WINSIZE)) != 0) { - if (first == 1){ - /* first add, so copy */ - if ((err = mp_copy(tG->x, R->x)) != CRYPT_OK) { goto done; } - if ((err = mp_copy(tG->y, R->y)) != CRYPT_OK) { goto done; } - if ((err = mp_copy(tG->z, R->z)) != CRYPT_OK) { goto done; } - first = 0; - } else { - /* then add */ - if ((err = ltc_mp.ecc_ptadd(R, tG, R, modulus, mp)) != CRYPT_OK) { goto done; } - } - } - } - } - - /* map R back from projective space */ - if (map) { - err = ltc_ecc_map(R, modulus, mp); - } else { - err = CRYPT_OK; - } -done: - if (mu != NULL) { - mp_clear(mu); - } - mp_montgomery_free(mp); - ltc_ecc_del_point(tG); - for (i = 0; i < 8; i++) { - ltc_ecc_del_point(M[i]); - } - return err; -} - -#endif - -#undef WINSIZE - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/ecc/ltc_ecc_mulmod.c,v $ */ -/* $Revision: 1.26 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_points.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_points.c deleted file mode 100644 index f5a4acb..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_points.c +++ /dev/null @@ -1,60 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b - * - * All curves taken from NIST recommendation paper of July 1999 - * Available at http://csrc.nist.gov/cryptval/dss.htm - */ -#include "../../headers/tomcrypt.h" - -/** - @file ltc_ecc_points.c - ECC Crypto, Tom St Denis -*/ - -#ifdef LTC_MECC - -/** - Allocate a new ECC point - @return A newly allocated point or NULL on error -*/ -ecc_point *ltc_ecc_new_point(void) -{ - ecc_point *p; - p = XCALLOC(1, sizeof(*p)); - if (p == NULL) { - return NULL; - } - if (mp_init_multi(&p->x, &p->y, &p->z, NULL) != CRYPT_OK) { - XFREE(p); - return NULL; - } - return p; -} - -/** Free an ECC point from memory - @param p The point to free -*/ -void ltc_ecc_del_point(ecc_point *p) -{ - /* prevents free'ing null arguments */ - if (p != NULL) { - mp_clear_multi(p->x, p->y, p->z, NULL); /* note: p->z may be NULL but that's ok with this function anyways */ - XFREE(p); - } -} - -#endif -/* $Source: /cvs/libtom/libtomcrypt/src/pk/ecc/ltc_ecc_points.c,v $ */ -/* $Revision: 1.7 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ - diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_projective_add_point.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_projective_add_point.c deleted file mode 100644 index b4416fc..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_projective_add_point.c +++ /dev/null @@ -1,196 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b - * - * All curves taken from NIST recommendation paper of July 1999 - * Available at http://csrc.nist.gov/cryptval/dss.htm - */ -#include "../../headers/tomcrypt.h" - -/** - @file ltc_ecc_projective_add_point.c - ECC Crypto, Tom St Denis -*/ - -#if defined(LTC_MECC) && (!defined(LTC_MECC_ACCEL) || defined(LTM_LTC_DESC)) - -/** - Add two ECC points - @param P The point to add - @param Q The point to add - @param R [out] The destination of the double - @param modulus The modulus of the field the ECC curve is in - @param mp The "b" value from montgomery_setup() - @return CRYPT_OK on success -*/ -int ltc_ecc_projective_add_point(ecc_point *P, ecc_point *Q, ecc_point *R, void *modulus, void *mp) -{ - void *t1, *t2, *x, *y, *z; - int err; - - LTC_ARGCHK(P != NULL); - LTC_ARGCHK(Q != NULL); - LTC_ARGCHK(R != NULL); - LTC_ARGCHK(modulus != NULL); - LTC_ARGCHK(mp != NULL); - - if ((err = mp_init_multi(&t1, &t2, &x, &y, &z, NULL)) != CRYPT_OK) { - return err; - } - - /* should we dbl instead? */ - if ((err = mp_sub(modulus, Q->y, t1)) != CRYPT_OK) { goto done; } - - if ( (mp_cmp(P->x, Q->x) == LTC_MP_EQ) && - (Q->z != NULL && mp_cmp(P->z, Q->z) == LTC_MP_EQ) && - (mp_cmp(P->y, Q->y) == LTC_MP_EQ || mp_cmp(P->y, t1) == LTC_MP_EQ)) { - mp_clear_multi(t1, t2, x, y, z, NULL); - return ltc_ecc_projective_dbl_point(P, R, modulus, mp); - } - - if ((err = mp_copy(P->x, x)) != CRYPT_OK) { goto done; } - if ((err = mp_copy(P->y, y)) != CRYPT_OK) { goto done; } - if ((err = mp_copy(P->z, z)) != CRYPT_OK) { goto done; } - - /* if Z is one then these are no-operations */ - if (Q->z != NULL) { - /* T1 = Z' * Z' */ - if ((err = mp_sqr(Q->z, t1)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK) { goto done; } - /* X = X * T1 */ - if ((err = mp_mul(t1, x, x)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(x, modulus, mp)) != CRYPT_OK) { goto done; } - /* T1 = Z' * T1 */ - if ((err = mp_mul(Q->z, t1, t1)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK) { goto done; } - /* Y = Y * T1 */ - if ((err = mp_mul(t1, y, y)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(y, modulus, mp)) != CRYPT_OK) { goto done; } - } - - /* T1 = Z*Z */ - if ((err = mp_sqr(z, t1)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK) { goto done; } - /* T2 = X' * T1 */ - if ((err = mp_mul(Q->x, t1, t2)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(t2, modulus, mp)) != CRYPT_OK) { goto done; } - /* T1 = Z * T1 */ - if ((err = mp_mul(z, t1, t1)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK) { goto done; } - /* T1 = Y' * T1 */ - if ((err = mp_mul(Q->y, t1, t1)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK) { goto done; } - - /* Y = Y - T1 */ - if ((err = mp_sub(y, t1, y)) != CRYPT_OK) { goto done; } - if (mp_cmp_d(y, 0) == LTC_MP_LT) { - if ((err = mp_add(y, modulus, y)) != CRYPT_OK) { goto done; } - } - /* T1 = 2T1 */ - if ((err = mp_add(t1, t1, t1)) != CRYPT_OK) { goto done; } - if (mp_cmp(t1, modulus) != LTC_MP_LT) { - if ((err = mp_sub(t1, modulus, t1)) != CRYPT_OK) { goto done; } - } - /* T1 = Y + T1 */ - if ((err = mp_add(t1, y, t1)) != CRYPT_OK) { goto done; } - if (mp_cmp(t1, modulus) != LTC_MP_LT) { - if ((err = mp_sub(t1, modulus, t1)) != CRYPT_OK) { goto done; } - } - /* X = X - T2 */ - if ((err = mp_sub(x, t2, x)) != CRYPT_OK) { goto done; } - if (mp_cmp_d(x, 0) == LTC_MP_LT) { - if ((err = mp_add(x, modulus, x)) != CRYPT_OK) { goto done; } - } - /* T2 = 2T2 */ - if ((err = mp_add(t2, t2, t2)) != CRYPT_OK) { goto done; } - if (mp_cmp(t2, modulus) != LTC_MP_LT) { - if ((err = mp_sub(t2, modulus, t2)) != CRYPT_OK) { goto done; } - } - /* T2 = X + T2 */ - if ((err = mp_add(t2, x, t2)) != CRYPT_OK) { goto done; } - if (mp_cmp(t2, modulus) != LTC_MP_LT) { - if ((err = mp_sub(t2, modulus, t2)) != CRYPT_OK) { goto done; } - } - - /* if Z' != 1 */ - if (Q->z != NULL) { - /* Z = Z * Z' */ - if ((err = mp_mul(z, Q->z, z)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(z, modulus, mp)) != CRYPT_OK) { goto done; } - } - - /* Z = Z * X */ - if ((err = mp_mul(z, x, z)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(z, modulus, mp)) != CRYPT_OK) { goto done; } - - /* T1 = T1 * X */ - if ((err = mp_mul(t1, x, t1)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK) { goto done; } - /* X = X * X */ - if ((err = mp_sqr(x, x)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(x, modulus, mp)) != CRYPT_OK) { goto done; } - /* T2 = T2 * x */ - if ((err = mp_mul(t2, x, t2)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(t2, modulus, mp)) != CRYPT_OK) { goto done; } - /* T1 = T1 * X */ - if ((err = mp_mul(t1, x, t1)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK) { goto done; } - - /* X = Y*Y */ - if ((err = mp_sqr(y, x)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(x, modulus, mp)) != CRYPT_OK) { goto done; } - /* X = X - T2 */ - if ((err = mp_sub(x, t2, x)) != CRYPT_OK) { goto done; } - if (mp_cmp_d(x, 0) == LTC_MP_LT) { - if ((err = mp_add(x, modulus, x)) != CRYPT_OK) { goto done; } - } - - /* T2 = T2 - X */ - if ((err = mp_sub(t2, x, t2)) != CRYPT_OK) { goto done; } - if (mp_cmp_d(t2, 0) == LTC_MP_LT) { - if ((err = mp_add(t2, modulus, t2)) != CRYPT_OK) { goto done; } - } - /* T2 = T2 - X */ - if ((err = mp_sub(t2, x, t2)) != CRYPT_OK) { goto done; } - if (mp_cmp_d(t2, 0) == LTC_MP_LT) { - if ((err = mp_add(t2, modulus, t2)) != CRYPT_OK) { goto done; } - } - /* T2 = T2 * Y */ - if ((err = mp_mul(t2, y, t2)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(t2, modulus, mp)) != CRYPT_OK) { goto done; } - /* Y = T2 - T1 */ - if ((err = mp_sub(t2, t1, y)) != CRYPT_OK) { goto done; } - if (mp_cmp_d(y, 0) == LTC_MP_LT) { - if ((err = mp_add(y, modulus, y)) != CRYPT_OK) { goto done; } - } - /* Y = Y/2 */ - if (mp_isodd(y)) { - if ((err = mp_add(y, modulus, y)) != CRYPT_OK) { goto done; } - } - if ((err = mp_div_2(y, y)) != CRYPT_OK) { goto done; } - - if ((err = mp_copy(x, R->x)) != CRYPT_OK) { goto done; } - if ((err = mp_copy(y, R->y)) != CRYPT_OK) { goto done; } - if ((err = mp_copy(z, R->z)) != CRYPT_OK) { goto done; } - - err = CRYPT_OK; -done: - mp_clear_multi(t1, t2, x, y, z, NULL); - return err; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/ecc/ltc_ecc_projective_add_point.c,v $ */ -/* $Revision: 1.16 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ - diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_projective_dbl_point.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_projective_dbl_point.c deleted file mode 100644 index b990e0a..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/ecc/ltc_ecc_projective_dbl_point.c +++ /dev/null @@ -1,147 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* Implements ECC over Z/pZ for curve y^2 = x^3 - 3x + b - * - * All curves taken from NIST recommendation paper of July 1999 - * Available at http://csrc.nist.gov/cryptval/dss.htm - */ -#include "../../headers/tomcrypt.h" - -/** - @file ltc_ecc_projective_dbl_point.c - ECC Crypto, Tom St Denis -*/ - -#if defined(LTC_MECC) && (!defined(LTC_MECC_ACCEL) || defined(LTM_LTC_DESC)) - -/** - Double an ECC point - @param P The point to double - @param R [out] The destination of the double - @param modulus The modulus of the field the ECC curve is in - @param mp The "b" value from montgomery_setup() - @return CRYPT_OK on success -*/ -int ltc_ecc_projective_dbl_point(ecc_point *P, ecc_point *R, void *modulus, void *mp) -{ - void *t1, *t2; - int err; - - LTC_ARGCHK(P != NULL); - LTC_ARGCHK(R != NULL); - LTC_ARGCHK(modulus != NULL); - LTC_ARGCHK(mp != NULL); - - if ((err = mp_init_multi(&t1, &t2, NULL)) != CRYPT_OK) { - return err; - } - - if (P != R) { - if ((err = mp_copy(P->x, R->x)) != CRYPT_OK) { goto done; } - if ((err = mp_copy(P->y, R->y)) != CRYPT_OK) { goto done; } - if ((err = mp_copy(P->z, R->z)) != CRYPT_OK) { goto done; } - } - - /* t1 = Z * Z */ - if ((err = mp_sqr(R->z, t1)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK) { goto done; } - /* Z = Y * Z */ - if ((err = mp_mul(R->z, R->y, R->z)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(R->z, modulus, mp)) != CRYPT_OK) { goto done; } - /* Z = 2Z */ - if ((err = mp_add(R->z, R->z, R->z)) != CRYPT_OK) { goto done; } - if (mp_cmp(R->z, modulus) != LTC_MP_LT) { - if ((err = mp_sub(R->z, modulus, R->z)) != CRYPT_OK) { goto done; } - } - - /* T2 = X - T1 */ - if ((err = mp_sub(R->x, t1, t2)) != CRYPT_OK) { goto done; } - if (mp_cmp_d(t2, 0) == LTC_MP_LT) { - if ((err = mp_add(t2, modulus, t2)) != CRYPT_OK) { goto done; } - } - /* T1 = X + T1 */ - if ((err = mp_add(t1, R->x, t1)) != CRYPT_OK) { goto done; } - if (mp_cmp(t1, modulus) != LTC_MP_LT) { - if ((err = mp_sub(t1, modulus, t1)) != CRYPT_OK) { goto done; } - } - /* T2 = T1 * T2 */ - if ((err = mp_mul(t1, t2, t2)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(t2, modulus, mp)) != CRYPT_OK) { goto done; } - /* T1 = 2T2 */ - if ((err = mp_add(t2, t2, t1)) != CRYPT_OK) { goto done; } - if (mp_cmp(t1, modulus) != LTC_MP_LT) { - if ((err = mp_sub(t1, modulus, t1)) != CRYPT_OK) { goto done; } - } - /* T1 = T1 + T2 */ - if ((err = mp_add(t1, t2, t1)) != CRYPT_OK) { goto done; } - if (mp_cmp(t1, modulus) != LTC_MP_LT) { - if ((err = mp_sub(t1, modulus, t1)) != CRYPT_OK) { goto done; } - } - - /* Y = 2Y */ - if ((err = mp_add(R->y, R->y, R->y)) != CRYPT_OK) { goto done; } - if (mp_cmp(R->y, modulus) != LTC_MP_LT) { - if ((err = mp_sub(R->y, modulus, R->y)) != CRYPT_OK) { goto done; } - } - /* Y = Y * Y */ - if ((err = mp_sqr(R->y, R->y)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(R->y, modulus, mp)) != CRYPT_OK) { goto done; } - /* T2 = Y * Y */ - if ((err = mp_sqr(R->y, t2)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(t2, modulus, mp)) != CRYPT_OK) { goto done; } - /* T2 = T2/2 */ - if (mp_isodd(t2)) { - if ((err = mp_add(t2, modulus, t2)) != CRYPT_OK) { goto done; } - } - if ((err = mp_div_2(t2, t2)) != CRYPT_OK) { goto done; } - /* Y = Y * X */ - if ((err = mp_mul(R->y, R->x, R->y)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(R->y, modulus, mp)) != CRYPT_OK) { goto done; } - - /* X = T1 * T1 */ - if ((err = mp_sqr(t1, R->x)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(R->x, modulus, mp)) != CRYPT_OK) { goto done; } - /* X = X - Y */ - if ((err = mp_sub(R->x, R->y, R->x)) != CRYPT_OK) { goto done; } - if (mp_cmp_d(R->x, 0) == LTC_MP_LT) { - if ((err = mp_add(R->x, modulus, R->x)) != CRYPT_OK) { goto done; } - } - /* X = X - Y */ - if ((err = mp_sub(R->x, R->y, R->x)) != CRYPT_OK) { goto done; } - if (mp_cmp_d(R->x, 0) == LTC_MP_LT) { - if ((err = mp_add(R->x, modulus, R->x)) != CRYPT_OK) { goto done; } - } - - /* Y = Y - X */ - if ((err = mp_sub(R->y, R->x, R->y)) != CRYPT_OK) { goto done; } - if (mp_cmp_d(R->y, 0) == LTC_MP_LT) { - if ((err = mp_add(R->y, modulus, R->y)) != CRYPT_OK) { goto done; } - } - /* Y = Y * T1 */ - if ((err = mp_mul(R->y, t1, R->y)) != CRYPT_OK) { goto done; } - if ((err = mp_montgomery_reduce(R->y, modulus, mp)) != CRYPT_OK) { goto done; } - /* Y = Y - T2 */ - if ((err = mp_sub(R->y, t2, R->y)) != CRYPT_OK) { goto done; } - if (mp_cmp_d(R->y, 0) == LTC_MP_LT) { - if ((err = mp_add(R->y, modulus, R->y)) != CRYPT_OK) { goto done; } - } - - err = CRYPT_OK; -done: - mp_clear_multi(t1, t2, NULL); - return err; -} -#endif -/* $Source: /cvs/libtom/libtomcrypt/src/pk/ecc/ltc_ecc_projective_dbl_point.c,v $ */ -/* $Revision: 1.11 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ - diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_mgf1.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_mgf1.c deleted file mode 100644 index e8f6418..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_mgf1.c +++ /dev/null @@ -1,108 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file pkcs_1_mgf1.c - The Mask Generation Function (MGF1) for LTC_PKCS #1, Tom St Denis -*/ - -#ifdef LTC_PKCS_1 - -/** - Perform LTC_PKCS #1 MGF1 (internal) - @param seed The seed for MGF1 - @param seedlen The length of the seed - @param hash_idx The index of the hash desired - @param mask [out] The destination - @param masklen The length of the mask desired - @return CRYPT_OK if successful -*/ -int pkcs_1_mgf1(int hash_idx, - const unsigned char *seed, unsigned long seedlen, - unsigned char *mask, unsigned long masklen) -{ - unsigned long hLen, x; - ulong32 counter; - int err; - hash_state *md; - unsigned char *buf; - - LTC_ARGCHK(seed != NULL); - LTC_ARGCHK(mask != NULL); - - /* ensure valid hash */ - if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) { - return err; - } - - /* get hash output size */ - hLen = hash_descriptor[hash_idx].hashsize; - - /* allocate memory */ - md = XMALLOC(sizeof(hash_state)); - buf = XMALLOC(hLen); - if (md == NULL || buf == NULL) { - if (md != NULL) { - XFREE(md); - } - if (buf != NULL) { - XFREE(buf); - } - return CRYPT_MEM; - } - - /* start counter */ - counter = 0; - - while (masklen > 0) { - /* handle counter */ - STORE32H(counter, buf); - ++counter; - - /* get hash of seed || counter */ - if ((err = hash_descriptor[hash_idx].init(md)) != CRYPT_OK) { - goto LBL_ERR; - } - if ((err = hash_descriptor[hash_idx].process(md, seed, seedlen)) != CRYPT_OK) { - goto LBL_ERR; - } - if ((err = hash_descriptor[hash_idx].process(md, buf, 4)) != CRYPT_OK) { - goto LBL_ERR; - } - if ((err = hash_descriptor[hash_idx].done(md, buf)) != CRYPT_OK) { - goto LBL_ERR; - } - - /* store it */ - for (x = 0; x < hLen && masklen > 0; x++, masklen--) { - *mask++ = buf[x]; - } - } - - err = CRYPT_OK; -LBL_ERR: -#ifdef LTC_CLEAN_STACK - zeromem(buf, hLen); - zeromem(md, sizeof(hash_state)); -#endif - - XFREE(buf); - XFREE(md); - - return err; -} - -#endif /* LTC_PKCS_1 */ - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/pkcs1/pkcs_1_mgf1.c,v $ */ -/* $Revision: 1.8 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_decode.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_decode.c deleted file mode 100644 index 709ab8a..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_decode.c +++ /dev/null @@ -1,189 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file pkcs_1_oaep_decode.c - OAEP Padding for LTC_PKCS #1, Tom St Denis -*/ - -#ifdef LTC_PKCS_1 - -/** - LTC_PKCS #1 v2.00 OAEP decode - @param msg The encoded data to decode - @param msglen The length of the encoded data (octets) - @param lparam The session or system data (can be NULL) - @param lparamlen The length of the lparam - @param modulus_bitlen The bit length of the RSA modulus - @param hash_idx The index of the hash desired - @param out [out] Destination of decoding - @param outlen [in/out] The max size and resulting size of the decoding - @param res [out] Result of decoding, 1==valid, 0==invalid - @return CRYPT_OK if successful (even if invalid) -*/ -int pkcs_1_oaep_decode(const unsigned char *msg, unsigned long msglen, - const unsigned char *lparam, unsigned long lparamlen, - unsigned long modulus_bitlen, int hash_idx, - unsigned char *out, unsigned long *outlen, - int *res) -{ - unsigned char *DB, *seed, *mask; - unsigned long hLen, x, y, modulus_len; - int err; - - LTC_ARGCHK(msg != NULL); - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); - LTC_ARGCHK(res != NULL); - - /* default to invalid packet */ - *res = 0; - - /* test valid hash */ - if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) { - return err; - } - hLen = hash_descriptor[hash_idx].hashsize; - modulus_len = (modulus_bitlen >> 3) + (modulus_bitlen & 7 ? 1 : 0); - - /* test hash/message size */ - if ((2*hLen >= (modulus_len - 2)) || (msglen != modulus_len)) { - return CRYPT_PK_INVALID_SIZE; - } - - /* allocate ram for DB/mask/salt of size modulus_len */ - DB = XMALLOC(modulus_len); - mask = XMALLOC(modulus_len); - seed = XMALLOC(hLen); - if (DB == NULL || mask == NULL || seed == NULL) { - if (DB != NULL) { - XFREE(DB); - } - if (mask != NULL) { - XFREE(mask); - } - if (seed != NULL) { - XFREE(seed); - } - return CRYPT_MEM; - } - - /* ok so it's now in the form - - 0x00 || maskedseed || maskedDB - - 1 || hLen || modulus_len - hLen - 1 - - */ - - /* must have leading 0x00 byte */ - if (msg[0] != 0x00) { - err = CRYPT_OK; - goto LBL_ERR; - } - - /* now read the masked seed */ - x = 1; - XMEMCPY(seed, msg + x, hLen); - x += hLen; - - /* now read the masked DB */ - XMEMCPY(DB, msg + x, modulus_len - hLen - 1); - x += modulus_len - hLen - 1; - - /* compute MGF1 of maskedDB (hLen) */ - if ((err = pkcs_1_mgf1(hash_idx, DB, modulus_len - hLen - 1, mask, hLen)) != CRYPT_OK) { - goto LBL_ERR; - } - - /* XOR against seed */ - for (y = 0; y < hLen; y++) { - seed[y] ^= mask[y]; - } - - /* compute MGF1 of seed (k - hlen - 1) */ - if ((err = pkcs_1_mgf1(hash_idx, seed, hLen, mask, modulus_len - hLen - 1)) != CRYPT_OK) { - goto LBL_ERR; - } - - /* xor against DB */ - for (y = 0; y < (modulus_len - hLen - 1); y++) { - DB[y] ^= mask[y]; - } - - /* now DB == lhash || PS || 0x01 || M, PS == k - mlen - 2hlen - 2 zeroes */ - - /* compute lhash and store it in seed [reuse temps!] */ - x = modulus_len; - if (lparam != NULL) { - if ((err = hash_memory(hash_idx, lparam, lparamlen, seed, &x)) != CRYPT_OK) { - goto LBL_ERR; - } - } else { - /* can't pass hash_memory a NULL so use DB with zero length */ - if ((err = hash_memory(hash_idx, DB, 0, seed, &x)) != CRYPT_OK) { - goto LBL_ERR; - } - } - - /* compare the lhash'es */ - if (XMEMCMP(seed, DB, hLen) != 0) { - err = CRYPT_OK; - goto LBL_ERR; - } - - /* now zeroes before a 0x01 */ - for (x = hLen; x < (modulus_len - hLen - 1) && DB[x] == 0x00; x++) { - /* step... */ - } - - /* error out if wasn't 0x01 */ - if (x == (modulus_len - hLen - 1) || DB[x] != 0x01) { - err = CRYPT_INVALID_PACKET; - goto LBL_ERR; - } - - /* rest is the message (and skip 0x01) */ - if ((modulus_len - hLen - 1 - ++x) > *outlen) { - *outlen = modulus_len - hLen - 1 - x; - err = CRYPT_BUFFER_OVERFLOW; - goto LBL_ERR; - } - - /* copy message */ - *outlen = modulus_len - hLen - 1 - x; - XMEMCPY(out, DB + x, modulus_len - hLen - 1 - x); - x += modulus_len - hLen - 1; - - /* valid packet */ - *res = 1; - - err = CRYPT_OK; -LBL_ERR: -#ifdef LTC_CLEAN_STACK - zeromem(DB, modulus_len); - zeromem(seed, hLen); - zeromem(mask, modulus_len); -#endif - - XFREE(seed); - XFREE(mask); - XFREE(DB); - - return err; -} - -#endif /* LTC_PKCS_1 */ - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_decode.c,v $ */ -/* $Revision: 1.13 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_pss_decode.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_pss_decode.c deleted file mode 100644 index c3a7211..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_pss_decode.c +++ /dev/null @@ -1,177 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file pkcs_1_pss_decode.c - LTC_PKCS #1 PSS Signature Padding, Tom St Denis -*/ - -#ifdef LTC_PKCS_1 - -/** - LTC_PKCS #1 v2.00 PSS decode - @param msghash The hash to verify - @param msghashlen The length of the hash (octets) - @param sig The signature data (encoded data) - @param siglen The length of the signature data (octets) - @param saltlen The length of the salt used (octets) - @param hash_idx The index of the hash desired - @param modulus_bitlen The bit length of the RSA modulus - @param res [out] The result of the comparison, 1==valid, 0==invalid - @return CRYPT_OK if successful (even if the comparison failed) -*/ -int pkcs_1_pss_decode(const unsigned char *msghash, unsigned long msghashlen, - const unsigned char *sig, unsigned long siglen, - unsigned long saltlen, int hash_idx, - unsigned long modulus_bitlen, int *res) -{ - unsigned char *DB, *mask, *salt, *hash; - unsigned long x, y, hLen, modulus_len; - int err; - hash_state md; - - LTC_ARGCHK(msghash != NULL); - LTC_ARGCHK(res != NULL); - - /* default to invalid */ - *res = 0; - - /* ensure hash is valid */ - if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) { - return err; - } - - hLen = hash_descriptor[hash_idx].hashsize; - modulus_len = (modulus_bitlen>>3) + (modulus_bitlen & 7 ? 1 : 0); - - /* check sizes */ - if ((saltlen > modulus_len) || - (modulus_len < hLen + saltlen + 2) || (siglen != modulus_len)) { - return CRYPT_PK_INVALID_SIZE; - } - - /* allocate ram for DB/mask/salt/hash of size modulus_len */ - DB = XMALLOC(modulus_len); - mask = XMALLOC(modulus_len); - salt = XMALLOC(modulus_len); - hash = XMALLOC(modulus_len); - if (DB == NULL || mask == NULL || salt == NULL || hash == NULL) { - if (DB != NULL) { - XFREE(DB); - } - if (mask != NULL) { - XFREE(mask); - } - if (salt != NULL) { - XFREE(salt); - } - if (hash != NULL) { - XFREE(hash); - } - return CRYPT_MEM; - } - - /* ensure the 0xBC byte */ - if (sig[siglen-1] != 0xBC) { - err = CRYPT_INVALID_PACKET; - goto LBL_ERR; - } - - /* copy out the DB */ - x = 0; - XMEMCPY(DB, sig + x, modulus_len - hLen - 1); - x += modulus_len - hLen - 1; - - /* copy out the hash */ - XMEMCPY(hash, sig + x, hLen); - x += hLen; - - /* check the MSB */ - if ((sig[0] & ~(0xFF >> ((modulus_len<<3) - (modulus_bitlen-1)))) != 0) { - err = CRYPT_INVALID_PACKET; - goto LBL_ERR; - } - - /* generate mask of length modulus_len - hLen - 1 from hash */ - if ((err = pkcs_1_mgf1(hash_idx, hash, hLen, mask, modulus_len - hLen - 1)) != CRYPT_OK) { - goto LBL_ERR; - } - - /* xor against DB */ - for (y = 0; y < (modulus_len - hLen - 1); y++) { - DB[y] ^= mask[y]; - } - - /* now clear the first byte [make sure smaller than modulus] */ - DB[0] &= 0xFF >> ((modulus_len<<3) - (modulus_bitlen-1)); - - /* DB = PS || 0x01 || salt, PS == modulus_len - saltlen - hLen - 2 zero bytes */ - - /* check for zeroes and 0x01 */ - for (x = 0; x < modulus_len - saltlen - hLen - 2; x++) { - if (DB[x] != 0x00) { - err = CRYPT_INVALID_PACKET; - goto LBL_ERR; - } - } - - /* check for the 0x01 */ - if (DB[x++] != 0x01) { - err = CRYPT_INVALID_PACKET; - goto LBL_ERR; - } - - /* M = (eight) 0x00 || msghash || salt, mask = H(M) */ - if ((err = hash_descriptor[hash_idx].init(&md)) != CRYPT_OK) { - goto LBL_ERR; - } - zeromem(mask, 8); - if ((err = hash_descriptor[hash_idx].process(&md, mask, 8)) != CRYPT_OK) { - goto LBL_ERR; - } - if ((err = hash_descriptor[hash_idx].process(&md, msghash, msghashlen)) != CRYPT_OK) { - goto LBL_ERR; - } - if ((err = hash_descriptor[hash_idx].process(&md, DB+x, saltlen)) != CRYPT_OK) { - goto LBL_ERR; - } - if ((err = hash_descriptor[hash_idx].done(&md, mask)) != CRYPT_OK) { - goto LBL_ERR; - } - - /* mask == hash means valid signature */ - if (XMEMCMP(mask, hash, hLen) == 0) { - *res = 1; - } - - err = CRYPT_OK; -LBL_ERR: -#ifdef LTC_CLEAN_STACK - zeromem(DB, modulus_len); - zeromem(mask, modulus_len); - zeromem(salt, modulus_len); - zeromem(hash, modulus_len); -#endif - - XFREE(hash); - XFREE(salt); - XFREE(mask); - XFREE(DB); - - return err; -} - -#endif /* LTC_PKCS_1 */ - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/pkcs1/pkcs_1_pss_decode.c,v $ */ -/* $Revision: 1.11 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_pss_encode.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_pss_encode.c deleted file mode 100644 index 68d5e86..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_pss_encode.c +++ /dev/null @@ -1,175 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file pkcs_1_pss_encode.c - LTC_PKCS #1 PSS Signature Padding, Tom St Denis -*/ - -#ifdef LTC_PKCS_1 - -/** - LTC_PKCS #1 v2.00 Signature Encoding - @param msghash The hash to encode - @param msghashlen The length of the hash (octets) - @param saltlen The length of the salt desired (octets) - @param prng An active PRNG context - @param prng_idx The index of the PRNG desired - @param hash_idx The index of the hash desired - @param modulus_bitlen The bit length of the RSA modulus - @param out [out] The destination of the encoding - @param outlen [in/out] The max size and resulting size of the encoded data - @return CRYPT_OK if successful -*/ -int pkcs_1_pss_encode(const unsigned char *msghash, unsigned long msghashlen, - unsigned long saltlen, prng_state *prng, - int prng_idx, int hash_idx, - unsigned long modulus_bitlen, - unsigned char *out, unsigned long *outlen) -{ - unsigned char *DB, *mask, *salt, *hash; - unsigned long x, y, hLen, modulus_len; - int err; - hash_state md; - - LTC_ARGCHK(msghash != NULL); - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); - - /* ensure hash and PRNG are valid */ - if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) { - return err; - } - if ((err = prng_is_valid(prng_idx)) != CRYPT_OK) { - return err; - } - - hLen = hash_descriptor[hash_idx].hashsize; - modulus_len = (modulus_bitlen>>3) + (modulus_bitlen & 7 ? 1 : 0); - - /* check sizes */ - if ((saltlen > modulus_len) || (modulus_len < hLen + saltlen + 2)) { - return CRYPT_PK_INVALID_SIZE; - } - - /* allocate ram for DB/mask/salt/hash of size modulus_len */ - DB = XMALLOC(modulus_len); - mask = XMALLOC(modulus_len); - salt = XMALLOC(modulus_len); - hash = XMALLOC(modulus_len); - if (DB == NULL || mask == NULL || salt == NULL || hash == NULL) { - if (DB != NULL) { - XFREE(DB); - } - if (mask != NULL) { - XFREE(mask); - } - if (salt != NULL) { - XFREE(salt); - } - if (hash != NULL) { - XFREE(hash); - } - return CRYPT_MEM; - } - - - /* generate random salt */ - if (saltlen > 0) { - if (prng_descriptor[prng_idx].read(salt, saltlen, prng) != saltlen) { - err = CRYPT_ERROR_READPRNG; - goto LBL_ERR; - } - } - - /* M = (eight) 0x00 || msghash || salt, hash = H(M) */ - if ((err = hash_descriptor[hash_idx].init(&md)) != CRYPT_OK) { - goto LBL_ERR; - } - zeromem(DB, 8); - if ((err = hash_descriptor[hash_idx].process(&md, DB, 8)) != CRYPT_OK) { - goto LBL_ERR; - } - if ((err = hash_descriptor[hash_idx].process(&md, msghash, msghashlen)) != CRYPT_OK) { - goto LBL_ERR; - } - if ((err = hash_descriptor[hash_idx].process(&md, salt, saltlen)) != CRYPT_OK) { - goto LBL_ERR; - } - if ((err = hash_descriptor[hash_idx].done(&md, hash)) != CRYPT_OK) { - goto LBL_ERR; - } - - /* generate DB = PS || 0x01 || salt, PS == modulus_len - saltlen - hLen - 2 zero bytes */ - x = 0; - XMEMSET(DB + x, 0, modulus_len - saltlen - hLen - 2); - x += modulus_len - saltlen - hLen - 2; - DB[x++] = 0x01; - XMEMCPY(DB + x, salt, saltlen); - x += saltlen; - - /* generate mask of length modulus_len - hLen - 1 from hash */ - if ((err = pkcs_1_mgf1(hash_idx, hash, hLen, mask, modulus_len - hLen - 1)) != CRYPT_OK) { - goto LBL_ERR; - } - - /* xor against DB */ - for (y = 0; y < (modulus_len - hLen - 1); y++) { - DB[y] ^= mask[y]; - } - - /* output is DB || hash || 0xBC */ - if (*outlen < modulus_len) { - *outlen = modulus_len; - err = CRYPT_BUFFER_OVERFLOW; - goto LBL_ERR; - } - - /* DB len = modulus_len - hLen - 1 */ - y = 0; - XMEMCPY(out + y, DB, modulus_len - hLen - 1); - y += modulus_len - hLen - 1; - - /* hash */ - XMEMCPY(out + y, hash, hLen); - y += hLen; - - /* 0xBC */ - out[y] = 0xBC; - - /* now clear the 8*modulus_len - modulus_bitlen most significant bits */ - out[0] &= 0xFF >> ((modulus_len<<3) - (modulus_bitlen-1)); - - /* store output size */ - *outlen = modulus_len; - err = CRYPT_OK; -LBL_ERR: -#ifdef LTC_CLEAN_STACK - zeromem(DB, modulus_len); - zeromem(mask, modulus_len); - zeromem(salt, modulus_len); - zeromem(hash, modulus_len); -#endif - - XFREE(hash); - XFREE(salt); - XFREE(mask); - XFREE(DB); - - return err; -} - -#endif /* LTC_PKCS_1 */ - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/pkcs1/pkcs_1_pss_encode.c,v $ */ -/* $Revision: 1.9 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_decode.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_decode.c deleted file mode 100644 index 7c3711c..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_decode.c +++ /dev/null @@ -1,110 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** @file pkcs_1_v1_5_decode.c - * - * LTC_PKCS #1 v1.5 Padding. (Andreas Lange) - */ - -#ifdef LTC_PKCS_1 - -/** @brief LTC_PKCS #1 v1.5 decode. - * - * @param msg The encoded data to decode - * @param msglen The length of the encoded data (octets) - * @param block_type Block type to use in padding (\sa ltc_pkcs_1_v1_5_blocks) - * @param modulus_bitlen The bit length of the RSA modulus - * @param out [out] Destination of decoding - * @param outlen [in/out] The max size and resulting size of the decoding - * @param is_valid [out] Boolean whether the padding was valid - * - * @return CRYPT_OK if successful (even if invalid) - */ -int pkcs_1_v1_5_decode(const unsigned char *msg, - unsigned long msglen, - int block_type, - unsigned long modulus_bitlen, - unsigned char *out, - unsigned long *outlen, - int *is_valid) -{ - unsigned long modulus_len, ps_len, i; - int result; - - /* default to invalid packet */ - *is_valid = 0; - - modulus_len = (modulus_bitlen >> 3) + (modulus_bitlen & 7 ? 1 : 0); - - /* test message size */ - - if ((msglen > modulus_len) || (modulus_len < 11)) { - return CRYPT_PK_INVALID_SIZE; - } - - /* separate encoded message */ - - if ((msg[0] != 0x00) || (msg[1] != (unsigned char)block_type)) { - result = CRYPT_INVALID_PACKET; - goto bail; - } - - if (block_type == LTC_LTC_PKCS_1_EME) { - for (i = 2; i < modulus_len; i++) { - /* separator */ - if (msg[i] == 0x00) { break; } - } - ps_len = i++ - 2; - - if ((i >= modulus_len) || (ps_len < 8)) { - /* There was no octet with hexadecimal value 0x00 to separate ps from m, - * or the length of ps is less than 8 octets. - */ - result = CRYPT_INVALID_PACKET; - goto bail; - } - } else { - for (i = 2; i < modulus_len - 1; i++) { - if (msg[i] != 0xFF) { break; } - } - - /* separator check */ - if (msg[i] != 0) { - /* There was no octet with hexadecimal value 0x00 to separate ps from m. */ - result = CRYPT_INVALID_PACKET; - goto bail; - } - - ps_len = i - 2; - } - - if (*outlen < (msglen - (2 + ps_len + 1))) { - *outlen = msglen - (2 + ps_len + 1); - result = CRYPT_BUFFER_OVERFLOW; - goto bail; - } - - *outlen = (msglen - (2 + ps_len + 1)); - XMEMCPY(out, &msg[2 + ps_len + 1], *outlen); - - /* valid packet */ - *is_valid = 1; - result = CRYPT_OK; -bail: - return result; -} /* pkcs_1_v1_5_decode */ - -#endif /* #ifdef LTC_PKCS_1 */ - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_decode.c,v $ */ -/* $Revision: 1.7 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_encode.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_encode.c deleted file mode 100644 index 4342919..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_encode.c +++ /dev/null @@ -1,111 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/*! \file pkcs_1_v1_5_encode.c - * - * LTC_PKCS #1 v1.5 Padding (Andreas Lange) - */ - -#ifdef LTC_PKCS_1 - -/*! \brief LTC_PKCS #1 v1.5 encode. - * - * \param msg The data to encode - * \param msglen The length of the data to encode (octets) - * \param block_type Block type to use in padding (\sa ltc_pkcs_1_v1_5_blocks) - * \param modulus_bitlen The bit length of the RSA modulus - * \param prng An active PRNG state (only for LTC_LTC_PKCS_1_EME) - * \param prng_idx The index of the PRNG desired (only for LTC_LTC_PKCS_1_EME) - * \param out [out] The destination for the encoded data - * \param outlen [in/out] The max size and resulting size of the encoded data - * - * \return CRYPT_OK if successful - */ -int pkcs_1_v1_5_encode(const unsigned char *msg, - unsigned long msglen, - int block_type, - unsigned long modulus_bitlen, - prng_state *prng, - int prng_idx, - unsigned char *out, - unsigned long *outlen) -{ - unsigned long modulus_len, ps_len, i; - unsigned char *ps; - int result; - - /* valid block_type? */ - if ((block_type != LTC_LTC_PKCS_1_EMSA) && - (block_type != LTC_LTC_PKCS_1_EME)) { - return CRYPT_PK_INVALID_PADDING; - } - - if (block_type == LTC_LTC_PKCS_1_EME) { /* encryption padding, we need a valid PRNG */ - if ((result = prng_is_valid(prng_idx)) != CRYPT_OK) { - return result; - } - } - - modulus_len = (modulus_bitlen >> 3) + (modulus_bitlen & 7 ? 1 : 0); - - /* test message size */ - if ((msglen + 11) > modulus_len) { - return CRYPT_PK_INVALID_SIZE; - } - - if (*outlen < modulus_len) { - *outlen = modulus_len; - result = CRYPT_BUFFER_OVERFLOW; - goto bail; - } - - /* generate an octets string PS */ - ps = &out[2]; - ps_len = modulus_len - msglen - 3; - - if (block_type == LTC_LTC_PKCS_1_EME) { - /* now choose a random ps */ - if (prng_descriptor[prng_idx].read(ps, ps_len, prng) != ps_len) { - result = CRYPT_ERROR_READPRNG; - goto bail; - } - - /* transform zero bytes (if any) to non-zero random bytes */ - for (i = 0; i < ps_len; i++) { - while (ps[i] == 0) { - if (prng_descriptor[prng_idx].read(&ps[i], 1, prng) != 1) { - result = CRYPT_ERROR_READPRNG; - goto bail; - } - } - } - } else { - XMEMSET(ps, 0xFF, ps_len); - } - - /* create string of length modulus_len */ - out[0] = 0x00; - out[1] = (unsigned char)block_type; /* block_type 1 or 2 */ - out[2 + ps_len] = 0x00; - XMEMCPY(&out[2 + ps_len + 1], msg, msglen); - *outlen = modulus_len; - - result = CRYPT_OK; -bail: - return result; -} /* pkcs_1_v1_5_encode */ - -#endif /* #ifdef LTC_PKCS_1 */ - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_encode.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_exptmod.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_exptmod.c deleted file mode 100644 index ba44106..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_exptmod.c +++ /dev/null @@ -1,113 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file rsa_exptmod.c - RSA LTC_PKCS exptmod, Tom St Denis -*/ - -#ifdef LTC_MRSA - -/** - Compute an RSA modular exponentiation - @param in The input data to send into RSA - @param inlen The length of the input (octets) - @param out [out] The destination - @param outlen [in/out] The max size and resulting size of the output - @param which Which exponent to use, e.g. PK_PRIVATE or PK_PUBLIC - @param key The RSA key to use - @return CRYPT_OK if successful -*/ -int rsa_exptmod(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen, int which, - rsa_key *key) -{ - void *tmp, *tmpa, *tmpb; - unsigned long x; - int err; - - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); - LTC_ARGCHK(key != NULL); - - /* is the key of the right type for the operation? */ - if (which == PK_PRIVATE && (key->type != PK_PRIVATE)) { - return CRYPT_PK_NOT_PRIVATE; - } - - /* must be a private or public operation */ - if (which != PK_PRIVATE && which != PK_PUBLIC) { - return CRYPT_PK_INVALID_TYPE; - } - - /* init and copy into tmp */ - if ((err = mp_init_multi(&tmp, &tmpa, &tmpb, NULL)) != CRYPT_OK) { return err; } - if ((err = mp_read_unsigned_bin(tmp, (unsigned char *)in, (int)inlen)) != CRYPT_OK) { goto error; } - - /* sanity check on the input */ - if (mp_cmp(key->N, tmp) == LTC_MP_LT) { - err = CRYPT_PK_INVALID_SIZE; - goto error; - } - - /* are we using the private exponent and is the key optimized? */ - if (which == PK_PRIVATE) { - /* tmpa = tmp^dP mod p */ - if ((err = mp_exptmod(tmp, key->dP, key->p, tmpa)) != CRYPT_OK) { goto error; } - - /* tmpb = tmp^dQ mod q */ - if ((err = mp_exptmod(tmp, key->dQ, key->q, tmpb)) != CRYPT_OK) { goto error; } - - /* tmp = (tmpa - tmpb) * qInv (mod p) */ - if ((err = mp_sub(tmpa, tmpb, tmp)) != CRYPT_OK) { goto error; } - if ((err = mp_mulmod(tmp, key->qP, key->p, tmp)) != CRYPT_OK) { goto error; } - - /* tmp = tmpb + q * tmp */ - if ((err = mp_mul(tmp, key->q, tmp)) != CRYPT_OK) { goto error; } - if ((err = mp_add(tmp, tmpb, tmp)) != CRYPT_OK) { goto error; } - } else { - /* exptmod it */ - if ((err = mp_exptmod(tmp, key->e, key->N, tmp)) != CRYPT_OK) { goto error; } - } - - /* read it back */ - x = (unsigned long)mp_unsigned_bin_size(key->N); - if (x > *outlen) { - *outlen = x; - err = CRYPT_BUFFER_OVERFLOW; - goto error; - } - - /* this should never happen ... */ - if (mp_unsigned_bin_size(tmp) > mp_unsigned_bin_size(key->N)) { - err = CRYPT_ERROR; - goto error; - } - *outlen = x; - - /* convert it */ - zeromem(out, x); - if ((err = mp_to_unsigned_bin(tmp, out+(x-mp_unsigned_bin_size(tmp)))) != CRYPT_OK) { goto error; } - - /* clean up and return */ - err = CRYPT_OK; -error: - mp_clear_multi(tmp, tmpa, tmpb, NULL); - return err; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/rsa/rsa_exptmod.c,v $ */ -/* $Revision: 1.18 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_free.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_free.c deleted file mode 100644 index a10ed59..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_free.c +++ /dev/null @@ -1,34 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file rsa_free.c - Free an RSA key, Tom St Denis -*/ - -#ifdef LTC_MRSA - -/** - Free an RSA key from memory - @param key The RSA key to free -*/ -void rsa_free(rsa_key *key) -{ - LTC_ARGCHKVD(key != NULL); - mp_clear_multi(key->e, key->d, key->N, key->dQ, key->dP, key->qP, key->p, key->q, NULL); -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/rsa/rsa_free.c,v $ */ -/* $Revision: 1.10 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_import.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_import.c deleted file mode 100644 index 6254fd7..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_import.c +++ /dev/null @@ -1,143 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file rsa_import.c - Import a LTC_PKCS RSA key, Tom St Denis -*/ - -#ifdef LTC_MRSA - -/** - Import an RSAPublicKey or RSAPrivateKey [two-prime only, only support >= 1024-bit keys, defined in LTC_PKCS #1 v2.1] - @param in The packet to import from - @param inlen It's length (octets) - @param key [out] Destination for newly imported key - @return CRYPT_OK if successful, upon error allocated memory is freed -*/ -int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key *key) -{ - int err; - void *zero; - unsigned char *tmpbuf; - unsigned long t, x, y, z, tmpoid[16]; - ltc_asn1_list ssl_pubkey_hashoid[2]; - ltc_asn1_list ssl_pubkey[2]; - - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(key != NULL); - LTC_ARGCHK(ltc_mp.name != NULL); - - /* init key */ - if ((err = mp_init_multi(&key->e, &key->d, &key->N, &key->dQ, - &key->dP, &key->qP, &key->p, &key->q, NULL)) != CRYPT_OK) { - return err; - } - - /* see if the OpenSSL DER format RSA public key will work */ - tmpbuf = XCALLOC(1, MAX_RSA_SIZE*8); - if (tmpbuf == NULL) { - err = CRYPT_MEM; - goto LBL_ERR; - } - - /* this includes the internal hash ID and optional params (NULL in this case) */ - LTC_SET_ASN1(ssl_pubkey_hashoid, 0, LTC_ASN1_OBJECT_IDENTIFIER, tmpoid, sizeof(tmpoid)/sizeof(tmpoid[0])); - LTC_SET_ASN1(ssl_pubkey_hashoid, 1, LTC_ASN1_NULL, NULL, 0); - - /* the actual format of the SSL DER key is odd, it stores a RSAPublicKey in a **BIT** string ... so we have to extract it - then proceed to convert bit to octet - */ - LTC_SET_ASN1(ssl_pubkey, 0, LTC_ASN1_SEQUENCE, &ssl_pubkey_hashoid, 2); - LTC_SET_ASN1(ssl_pubkey, 1, LTC_ASN1_BIT_STRING, tmpbuf, MAX_RSA_SIZE*8); - - if (der_decode_sequence(in, inlen, - ssl_pubkey, 2UL) == CRYPT_OK) { - - /* ok now we have to reassemble the BIT STRING to an OCTET STRING. Thanks OpenSSL... */ - for (t = y = z = x = 0; x < ssl_pubkey[1].size; x++) { - y = (y << 1) | tmpbuf[x]; - if (++z == 8) { - tmpbuf[t++] = (unsigned char)y; - y = 0; - z = 0; - } - } - - /* now it should be SEQUENCE { INTEGER, INTEGER } */ - if ((err = der_decode_sequence_multi(tmpbuf, t, - LTC_ASN1_INTEGER, 1UL, key->N, - LTC_ASN1_INTEGER, 1UL, key->e, - LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) { - XFREE(tmpbuf); - goto LBL_ERR; - } - XFREE(tmpbuf); - key->type = PK_PUBLIC; - return CRYPT_OK; - } - XFREE(tmpbuf); - - /* not SSL public key, try to match against LTC_PKCS #1 standards */ - if ((err = der_decode_sequence_multi(in, inlen, - LTC_ASN1_INTEGER, 1UL, key->N, - LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) { - goto LBL_ERR; - } - - if (mp_cmp_d(key->N, 0) == LTC_MP_EQ) { - if ((err = mp_init(&zero)) != CRYPT_OK) { - goto LBL_ERR; - } - /* it's a private key */ - if ((err = der_decode_sequence_multi(in, inlen, - LTC_ASN1_INTEGER, 1UL, zero, - LTC_ASN1_INTEGER, 1UL, key->N, - LTC_ASN1_INTEGER, 1UL, key->e, - LTC_ASN1_INTEGER, 1UL, key->d, - LTC_ASN1_INTEGER, 1UL, key->p, - LTC_ASN1_INTEGER, 1UL, key->q, - LTC_ASN1_INTEGER, 1UL, key->dP, - LTC_ASN1_INTEGER, 1UL, key->dQ, - LTC_ASN1_INTEGER, 1UL, key->qP, - LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) { - mp_clear(zero); - goto LBL_ERR; - } - mp_clear(zero); - key->type = PK_PRIVATE; - } else if (mp_cmp_d(key->N, 1) == LTC_MP_EQ) { - /* we don't support multi-prime RSA */ - err = CRYPT_PK_INVALID_TYPE; - goto LBL_ERR; - } else { - /* it's a public key and we lack e */ - if ((err = der_decode_sequence_multi(in, inlen, - LTC_ASN1_INTEGER, 1UL, key->N, - LTC_ASN1_INTEGER, 1UL, key->e, - LTC_ASN1_EOL, 0UL, NULL)) != CRYPT_OK) { - goto LBL_ERR; - } - key->type = PK_PUBLIC; - } - return CRYPT_OK; -LBL_ERR: - mp_clear_multi(key->d, key->e, key->N, key->dQ, key->dP, key->qP, key->p, key->q, NULL); - return err; -} - -#endif /* LTC_MRSA */ - - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/rsa/rsa_import.c,v $ */ -/* $Revision: 1.23 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_make_key.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_make_key.c deleted file mode 100644 index bd37b4a..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_make_key.c +++ /dev/null @@ -1,112 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file rsa_make_key.c - RSA key generation, Tom St Denis -*/ - -#ifdef LTC_MRSA - -/** - Create an RSA key - @param prng An active PRNG state - @param wprng The index of the PRNG desired - @param size The size of the modulus (key size) desired (octets) - @param e The "e" value (public key). e==65537 is a good choice - @param key [out] Destination of a newly created private key pair - @return CRYPT_OK if successful, upon error all allocated ram is freed -*/ -int rsa_make_key(prng_state *prng, int wprng, int size, long e, rsa_key *key) -{ - void *p, *q, *tmp1, *tmp2, *tmp3; - int err; - - LTC_ARGCHK(ltc_mp.name != NULL); - LTC_ARGCHK(key != NULL); - - if ((size < (MIN_RSA_SIZE/8)) || (size > (MAX_RSA_SIZE/8))) { - return CRYPT_INVALID_KEYSIZE; - } - - if ((e < 3) || ((e & 1) == 0)) { - return CRYPT_INVALID_ARG; - } - - if ((err = prng_is_valid(wprng)) != CRYPT_OK) { - return err; - } - - if ((err = mp_init_multi(&p, &q, &tmp1, &tmp2, &tmp3, NULL)) != CRYPT_OK) { - return err; - } - - /* make primes p and q (optimization provided by Wayne Scott) */ - if ((err = mp_set_int(tmp3, e)) != CRYPT_OK) { goto errkey; } /* tmp3 = e */ - - /* make prime "p" */ - do { - if ((err = rand_prime( p, size/2, prng, wprng)) != CRYPT_OK) { goto errkey; } - if ((err = mp_sub_d( p, 1, tmp1)) != CRYPT_OK) { goto errkey; } /* tmp1 = p-1 */ - if ((err = mp_gcd( tmp1, tmp3, tmp2)) != CRYPT_OK) { goto errkey; } /* tmp2 = gcd(p-1, e) */ - } while (mp_cmp_d( tmp2, 1) != 0); /* while e divides p-1 */ - - /* make prime "q" */ - do { - if ((err = rand_prime( q, size/2, prng, wprng)) != CRYPT_OK) { goto errkey; } - if ((err = mp_sub_d( q, 1, tmp1)) != CRYPT_OK) { goto errkey; } /* tmp1 = q-1 */ - if ((err = mp_gcd( tmp1, tmp3, tmp2)) != CRYPT_OK) { goto errkey; } /* tmp2 = gcd(q-1, e) */ - } while (mp_cmp_d( tmp2, 1) != 0); /* while e divides q-1 */ - - /* tmp1 = lcm(p-1, q-1) */ - if ((err = mp_sub_d( p, 1, tmp2)) != CRYPT_OK) { goto errkey; } /* tmp2 = p-1 */ - /* tmp1 = q-1 (previous do/while loop) */ - if ((err = mp_lcm( tmp1, tmp2, tmp1)) != CRYPT_OK) { goto errkey; } /* tmp1 = lcm(p-1, q-1) */ - - /* make key */ - if ((err = mp_init_multi(&key->e, &key->d, &key->N, &key->dQ, &key->dP, &key->qP, &key->p, &key->q, NULL)) != CRYPT_OK) { - goto errkey; - } - - if ((err = mp_set_int( key->e, e)) != CRYPT_OK) { goto errkey; } /* key->e = e */ - if ((err = mp_invmod( key->e, tmp1, key->d)) != CRYPT_OK) { goto errkey; } /* key->d = 1/e mod lcm(p-1,q-1) */ - if ((err = mp_mul( p, q, key->N)) != CRYPT_OK) { goto errkey; } /* key->N = pq */ - - /* optimize for CRT now */ - /* find d mod q-1 and d mod p-1 */ - if ((err = mp_sub_d( p, 1, tmp1)) != CRYPT_OK) { goto errkey; } /* tmp1 = q-1 */ - if ((err = mp_sub_d( q, 1, tmp2)) != CRYPT_OK) { goto errkey; } /* tmp2 = p-1 */ - if ((err = mp_mod( key->d, tmp1, key->dP)) != CRYPT_OK) { goto errkey; } /* dP = d mod p-1 */ - if ((err = mp_mod( key->d, tmp2, key->dQ)) != CRYPT_OK) { goto errkey; } /* dQ = d mod q-1 */ - if ((err = mp_invmod( q, p, key->qP)) != CRYPT_OK) { goto errkey; } /* qP = 1/q mod p */ - - if ((err = mp_copy( p, key->p)) != CRYPT_OK) { goto errkey; } - if ((err = mp_copy( q, key->q)) != CRYPT_OK) { goto errkey; } - - /* set key type (in this case it's CRT optimized) */ - key->type = PK_PRIVATE; - - /* return ok and free temps */ - err = CRYPT_OK; - goto cleanup; -errkey: - mp_clear_multi(key->d, key->e, key->N, key->dQ, key->dP, key->qP, key->p, key->q, NULL); -cleanup: - mp_clear_multi(tmp3, tmp2, tmp1, p, q, NULL); - return err; -} - -#endif - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/rsa/rsa_make_key.c,v $ */ -/* $Revision: 1.16 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_sign_hash.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_sign_hash.c deleted file mode 100644 index 49fb858..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_sign_hash.c +++ /dev/null @@ -1,134 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file rsa_sign_hash.c - RSA LTC_PKCS #1 v1.5 and v2 PSS sign hash, Tom St Denis and Andreas Lange -*/ - -#ifdef LTC_MRSA - -/** - LTC_PKCS #1 pad then sign - @param in The hash to sign - @param inlen The length of the hash to sign (octets) - @param out [out] The signature - @param outlen [in/out] The max size and resulting size of the signature - @param padding Type of padding (LTC_LTC_PKCS_1_PSS or LTC_LTC_PKCS_1_V1_5) - @param prng An active PRNG state - @param prng_idx The index of the PRNG desired - @param hash_idx The index of the hash desired - @param saltlen The length of the salt desired (octets) - @param key The private RSA key to use - @return CRYPT_OK if successful -*/ -int rsa_sign_hash_ex(const unsigned char *in, unsigned long inlen, - unsigned char *out, unsigned long *outlen, - int padding, - prng_state *prng, int prng_idx, - int hash_idx, unsigned long saltlen, - rsa_key *key) -{ - unsigned long modulus_bitlen, modulus_bytelen, x, y; - int err; - - LTC_ARGCHK(in != NULL); - LTC_ARGCHK(out != NULL); - LTC_ARGCHK(outlen != NULL); - LTC_ARGCHK(key != NULL); - - /* valid padding? */ - if ((padding != LTC_LTC_PKCS_1_V1_5) && (padding != LTC_LTC_PKCS_1_PSS)) { - return CRYPT_PK_INVALID_PADDING; - } - - if (padding == LTC_LTC_PKCS_1_PSS) { - /* valid prng and hash ? */ - if ((err = prng_is_valid(prng_idx)) != CRYPT_OK) { - return err; - } - if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) { - return err; - } - } - - /* get modulus len in bits */ - modulus_bitlen = mp_count_bits((key->N)); - - /* outlen must be at least the size of the modulus */ - modulus_bytelen = mp_unsigned_bin_size((key->N)); - if (modulus_bytelen > *outlen) { - *outlen = modulus_bytelen; - return CRYPT_BUFFER_OVERFLOW; - } - - if (padding == LTC_LTC_PKCS_1_PSS) { - /* PSS pad the key */ - x = *outlen; - if ((err = pkcs_1_pss_encode(in, inlen, saltlen, prng, prng_idx, - hash_idx, modulus_bitlen, out, &x)) != CRYPT_OK) { - return err; - } - } else { - /* LTC_PKCS #1 v1.5 pad the hash */ - unsigned char *tmpin; - ltc_asn1_list digestinfo[2], siginfo[2]; - - /* not all hashes have OIDs... so sad */ - if (hash_descriptor[hash_idx].OIDlen == 0) { - return CRYPT_INVALID_ARG; - } - - /* construct the SEQUENCE - SEQUENCE { - SEQUENCE {hashoid OID - blah NULL - } - hash OCTET STRING - } - */ - LTC_SET_ASN1(digestinfo, 0, LTC_ASN1_OBJECT_IDENTIFIER, hash_descriptor[hash_idx].OID, hash_descriptor[hash_idx].OIDlen); - LTC_SET_ASN1(digestinfo, 1, LTC_ASN1_NULL, NULL, 0); - LTC_SET_ASN1(siginfo, 0, LTC_ASN1_SEQUENCE, digestinfo, 2); - LTC_SET_ASN1(siginfo, 1, LTC_ASN1_OCTET_STRING, in, inlen); - - /* allocate memory for the encoding */ - y = mp_unsigned_bin_size(key->N); - tmpin = XMALLOC(y); - if (tmpin == NULL) { - return CRYPT_MEM; - } - - if ((err = der_encode_sequence(siginfo, 2, tmpin, &y)) != CRYPT_OK) { - XFREE(tmpin); - return err; - } - - x = *outlen; - if ((err = pkcs_1_v1_5_encode(tmpin, y, LTC_LTC_PKCS_1_EMSA, - modulus_bitlen, NULL, 0, - out, &x)) != CRYPT_OK) { - XFREE(tmpin); - return err; - } - XFREE(tmpin); - } - - /* RSA encode it */ - return ltc_mp.rsa_me(out, x, out, outlen, PK_PRIVATE, key); -} - -#endif /* LTC_MRSA */ - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/rsa/rsa_sign_hash.c,v $ */ -/* $Revision: 1.11 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_verify_hash.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_verify_hash.c deleted file mode 100644 index 103ae2f..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_verify_hash.c +++ /dev/null @@ -1,167 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file rsa_verify_hash.c - RSA LTC_PKCS #1 v1.5 or v2 PSS signature verification, Tom St Denis and Andreas Lange -*/ - -#ifdef LTC_MRSA - -/** - LTC_PKCS #1 de-sign then v1.5 or PSS depad - @param sig The signature data - @param siglen The length of the signature data (octets) - @param hash The hash of the message that was signed - @param hashlen The length of the hash of the message that was signed (octets) - @param padding Type of padding (LTC_LTC_PKCS_1_PSS or LTC_LTC_PKCS_1_V1_5) - @param hash_idx The index of the desired hash - @param saltlen The length of the salt used during signature - @param stat [out] The result of the signature comparison, 1==valid, 0==invalid - @param key The public RSA key corresponding to the key that performed the signature - @return CRYPT_OK on success (even if the signature is invalid) -*/ -int rsa_verify_hash_ex(const unsigned char *sig, unsigned long siglen, - const unsigned char *hash, unsigned long hashlen, - int padding, - int hash_idx, unsigned long saltlen, - int *stat, rsa_key *key) -{ - unsigned long modulus_bitlen, modulus_bytelen, x; - int err; - unsigned char *tmpbuf; - - LTC_ARGCHK(hash != NULL); - LTC_ARGCHK(sig != NULL); - LTC_ARGCHK(stat != NULL); - LTC_ARGCHK(key != NULL); - - /* default to invalid */ - *stat = 0; - - /* valid padding? */ - - if ((padding != LTC_LTC_PKCS_1_V1_5) && - (padding != LTC_LTC_PKCS_1_PSS)) { - return CRYPT_PK_INVALID_PADDING; - } - - if (padding == LTC_LTC_PKCS_1_PSS) { - /* valid hash ? */ - if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) { - return err; - } - } - - /* get modulus len in bits */ - modulus_bitlen = mp_count_bits( (key->N)); - - /* outlen must be at least the size of the modulus */ - modulus_bytelen = mp_unsigned_bin_size( (key->N)); - if (modulus_bytelen != siglen) { - return CRYPT_INVALID_PACKET; - } - - /* allocate temp buffer for decoded sig */ - tmpbuf = XMALLOC(siglen); - if (tmpbuf == NULL) { - return CRYPT_MEM; - } - - /* RSA decode it */ - x = siglen; - if ((err = ltc_mp.rsa_me(sig, siglen, tmpbuf, &x, PK_PUBLIC, key)) != CRYPT_OK) { - XFREE(tmpbuf); - return err; - } - - /* make sure the output is the right size */ - if (x != siglen) { - XFREE(tmpbuf); - return CRYPT_INVALID_PACKET; - } - - if (padding == LTC_LTC_PKCS_1_PSS) { - /* PSS decode and verify it */ - err = pkcs_1_pss_decode(hash, hashlen, tmpbuf, x, saltlen, hash_idx, modulus_bitlen, stat); - } else { - /* LTC_PKCS #1 v1.5 decode it */ - unsigned char *out; - unsigned long outlen, loid[16]; - int decoded; - ltc_asn1_list digestinfo[2], siginfo[2]; - - /* not all hashes have OIDs... so sad */ - if (hash_descriptor[hash_idx].OIDlen == 0) { - err = CRYPT_INVALID_ARG; - goto bail_2; - } - - /* allocate temp buffer for decoded hash */ - outlen = ((modulus_bitlen >> 3) + (modulus_bitlen & 7 ? 1 : 0)) - 3; - out = XMALLOC(outlen); - if (out == NULL) { - err = CRYPT_MEM; - goto bail_2; - } - - if ((err = pkcs_1_v1_5_decode(tmpbuf, x, LTC_LTC_PKCS_1_EMSA, modulus_bitlen, out, &outlen, &decoded)) != CRYPT_OK) { - XFREE(out); - goto bail_2; - } - - /* now we must decode out[0...outlen-1] using ASN.1, test the OID and then test the hash */ - /* construct the SEQUENCE - SEQUENCE { - SEQUENCE {hashoid OID - blah NULL - } - hash OCTET STRING - } - */ - LTC_SET_ASN1(digestinfo, 0, LTC_ASN1_OBJECT_IDENTIFIER, loid, sizeof(loid)/sizeof(loid[0])); - LTC_SET_ASN1(digestinfo, 1, LTC_ASN1_NULL, NULL, 0); - LTC_SET_ASN1(siginfo, 0, LTC_ASN1_SEQUENCE, digestinfo, 2); - LTC_SET_ASN1(siginfo, 1, LTC_ASN1_OCTET_STRING, tmpbuf, siglen); - - if ((err = der_decode_sequence(out, outlen, siginfo, 2)) != CRYPT_OK) { - XFREE(out); - goto bail_2; - } - - /* test OID */ - if ((digestinfo[0].size == hash_descriptor[hash_idx].OIDlen) && - (XMEMCMP(digestinfo[0].data, hash_descriptor[hash_idx].OID, sizeof(unsigned long) * hash_descriptor[hash_idx].OIDlen) == 0) && - (siginfo[1].size == hashlen) && - (XMEMCMP(siginfo[1].data, hash, hashlen) == 0)) { - *stat = 1; - } - -#ifdef LTC_CLEAN_STACK - zeromem(out, outlen); -#endif - XFREE(out); - } - -bail_2: -#ifdef LTC_CLEAN_STACK - zeromem(tmpbuf, siglen); -#endif - XFREE(tmpbuf); - return err; -} - -#endif /* LTC_MRSA */ - -/* $Source: /cvs/libtom/libtomcrypt/src/pk/rsa/rsa_verify_hash.c,v $ */ -/* $Revision: 1.13 $ */ -/* $Date: 2007/05/12 14:32:35 $ */ diff --git a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_verify_simple.c b/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_verify_simple.c deleted file mode 100644 index 6d8888c..0000000 --- a/libs/storm-sys/StormLib/src/libtomcrypt/src/pk/rsa/rsa_verify_simple.c +++ /dev/null @@ -1,87 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include "../../headers/tomcrypt.h" - -/** - @file rsa_verify_simple.c - Created by Ladislav Zezula (zezula@volny.cz) as modification - for Blizzard strong signature verification -*/ - -#ifdef LTC_MRSA - -/** - Simple RSA decryption - @param sig The signature data - @param siglen The length of the signature data (octets) - @param hash The hash of the message that was signed - @param hashlen The length of the hash of the message that was signed (octets) - @param stat [out] The result of the signature comparison, 1==valid, 0==invalid - @param key The public RSA key corresponding - @return Error code -*/ -int rsa_verify_simple(const unsigned char *sig, unsigned long siglen, - const unsigned char *hash, unsigned long hashlen, - int *stat, - rsa_key *key) -{ - unsigned long modulus_bitlen, modulus_bytelen, x; - unsigned char *tmpbuf; - int err; - - LTC_ARGCHK(sig != NULL); - LTC_ARGCHK(hash != NULL); - LTC_ARGCHK(stat != NULL); - LTC_ARGCHK(key != NULL); - - /* default to invalid */ - *stat = 0; - - /* get modulus len in bits */ - modulus_bitlen = mp_count_bits( (key->N)); - - /* outlen must be at least the size of the modulus */ - modulus_bytelen = mp_unsigned_bin_size( (key->N)); - if (modulus_bytelen != siglen) { - return CRYPT_INVALID_PACKET; - } - - /* allocate temp buffer for decoded sig */ - tmpbuf = XMALLOC(siglen); - if (tmpbuf == NULL) { - return CRYPT_MEM; - } - - /* RSA decode it */ - x = siglen; - if ((err = ltc_mp.rsa_me(sig, siglen, tmpbuf, &x, PK_PUBLIC, key)) != CRYPT_OK) { - XFREE(tmpbuf); - return err; - } - - /* make sure the output is the right size */ - if (x != siglen) { - XFREE(tmpbuf); - return CRYPT_INVALID_PACKET; - } - - /* compare the decrypted signature with the given hash */ - if(x == hashlen && XMEMCMP(tmpbuf, hash, hashlen) == 0) - *stat = 1; - -#ifdef LTC_CLEAN_STACK - zeromem(tmpbuf, siglen); -#endif - XFREE(tmpbuf); - return CRYPT_OK; -} - -#endif /* LTC_MRSA */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_fast_mp_invmod.c b/libs/storm-sys/StormLib/src/libtommath/bn_fast_mp_invmod.c deleted file mode 100644 index 597d7a9..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_fast_mp_invmod.c +++ /dev/null @@ -1,148 +0,0 @@ -#include "tommath.h" -#ifdef BN_FAST_MP_INVMOD_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* computes the modular inverse via binary extended euclidean algorithm, - * that is c = 1/a mod b - * - * Based on slow invmod except this is optimized for the case where b is - * odd as per HAC Note 14.64 on pp. 610 - */ -int fast_mp_invmod (mp_int * a, mp_int * b, mp_int * c) -{ - mp_int x, y, u, v, B, D; - int res, neg; - - /* 2. [modified] b must be odd */ - if (mp_iseven (b) == 1) { - return MP_VAL; - } - - /* init all our temps */ - if ((res = mp_init_multi(&x, &y, &u, &v, &B, &D, NULL)) != MP_OKAY) { - return res; - } - - /* x == modulus, y == value to invert */ - if ((res = mp_copy (b, &x)) != MP_OKAY) { - goto LBL_ERR; - } - - /* we need y = |a| */ - if ((res = mp_mod (a, b, &y)) != MP_OKAY) { - goto LBL_ERR; - } - - /* 3. u=x, v=y, A=1, B=0, C=0,D=1 */ - if ((res = mp_copy (&x, &u)) != MP_OKAY) { - goto LBL_ERR; - } - if ((res = mp_copy (&y, &v)) != MP_OKAY) { - goto LBL_ERR; - } - mp_set (&D, 1); - -top: - /* 4. while u is even do */ - while (mp_iseven (&u) == 1) { - /* 4.1 u = u/2 */ - if ((res = mp_div_2 (&u, &u)) != MP_OKAY) { - goto LBL_ERR; - } - /* 4.2 if B is odd then */ - if (mp_isodd (&B) == 1) { - if ((res = mp_sub (&B, &x, &B)) != MP_OKAY) { - goto LBL_ERR; - } - } - /* B = B/2 */ - if ((res = mp_div_2 (&B, &B)) != MP_OKAY) { - goto LBL_ERR; - } - } - - /* 5. while v is even do */ - while (mp_iseven (&v) == 1) { - /* 5.1 v = v/2 */ - if ((res = mp_div_2 (&v, &v)) != MP_OKAY) { - goto LBL_ERR; - } - /* 5.2 if D is odd then */ - if (mp_isodd (&D) == 1) { - /* D = (D-x)/2 */ - if ((res = mp_sub (&D, &x, &D)) != MP_OKAY) { - goto LBL_ERR; - } - } - /* D = D/2 */ - if ((res = mp_div_2 (&D, &D)) != MP_OKAY) { - goto LBL_ERR; - } - } - - /* 6. if u >= v then */ - if (mp_cmp (&u, &v) != MP_LT) { - /* u = u - v, B = B - D */ - if ((res = mp_sub (&u, &v, &u)) != MP_OKAY) { - goto LBL_ERR; - } - - if ((res = mp_sub (&B, &D, &B)) != MP_OKAY) { - goto LBL_ERR; - } - } else { - /* v - v - u, D = D - B */ - if ((res = mp_sub (&v, &u, &v)) != MP_OKAY) { - goto LBL_ERR; - } - - if ((res = mp_sub (&D, &B, &D)) != MP_OKAY) { - goto LBL_ERR; - } - } - - /* if not zero goto step 4 */ - if (mp_iszero (&u) == 0) { - goto top; - } - - /* now a = C, b = D, gcd == g*v */ - - /* if v != 1 then there is no inverse */ - if (mp_cmp_d (&v, 1) != MP_EQ) { - res = MP_VAL; - goto LBL_ERR; - } - - /* b is now the inverse */ - neg = a->sign; - while (D.sign == MP_NEG) { - if ((res = mp_add (&D, b, &D)) != MP_OKAY) { - goto LBL_ERR; - } - } - mp_exch (&D, c); - c->sign = neg; - res = MP_OKAY; - -LBL_ERR:mp_clear_multi (&x, &y, &u, &v, &B, &D, NULL); - return res; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_fast_mp_invmod.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_fast_mp_montgomery_reduce.c b/libs/storm-sys/StormLib/src/libtommath/bn_fast_mp_montgomery_reduce.c deleted file mode 100644 index 65eed7d..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_fast_mp_montgomery_reduce.c +++ /dev/null @@ -1,172 +0,0 @@ -#include "tommath.h" -#ifdef BN_FAST_MP_MONTGOMERY_REDUCE_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* computes xR**-1 == x (mod N) via Montgomery Reduction - * - * This is an optimized implementation of montgomery_reduce - * which uses the comba method to quickly calculate the columns of the - * reduction. - * - * Based on Algorithm 14.32 on pp.601 of HAC. -*/ -int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho) -{ - int ix, res, olduse; - mp_word W[MP_WARRAY]; - - /* get old used count */ - olduse = x->used; - - /* grow a as required */ - if (x->alloc < n->used + 1) { - if ((res = mp_grow (x, n->used + 1)) != MP_OKAY) { - return res; - } - } - - /* first we have to get the digits of the input into - * an array of double precision words W[...] - */ - { - register mp_word *_W; - register mp_digit *tmpx; - - /* alias for the W[] array */ - _W = W; - - /* alias for the digits of x*/ - tmpx = x->dp; - - /* copy the digits of a into W[0..a->used-1] */ - for (ix = 0; ix < x->used; ix++) { - *_W++ = *tmpx++; - } - - /* zero the high words of W[a->used..m->used*2] */ - for (; ix < n->used * 2 + 1; ix++) { - *_W++ = 0; - } - } - - /* now we proceed to zero successive digits - * from the least significant upwards - */ - for (ix = 0; ix < n->used; ix++) { - /* mu = ai * m' mod b - * - * We avoid a double precision multiplication (which isn't required) - * by casting the value down to a mp_digit. Note this requires - * that W[ix-1] have the carry cleared (see after the inner loop) - */ - register mp_digit mu; - mu = (mp_digit) (((W[ix] & MP_MASK) * rho) & MP_MASK); - - /* a = a + mu * m * b**i - * - * This is computed in place and on the fly. The multiplication - * by b**i is handled by offseting which columns the results - * are added to. - * - * Note the comba method normally doesn't handle carries in the - * inner loop In this case we fix the carry from the previous - * column since the Montgomery reduction requires digits of the - * result (so far) [see above] to work. This is - * handled by fixing up one carry after the inner loop. The - * carry fixups are done in order so after these loops the - * first m->used words of W[] have the carries fixed - */ - { - register int iy; - register mp_digit *tmpn; - register mp_word *_W; - - /* alias for the digits of the modulus */ - tmpn = n->dp; - - /* Alias for the columns set by an offset of ix */ - _W = W + ix; - - /* inner loop */ - for (iy = 0; iy < n->used; iy++) { - *_W++ += ((mp_word)mu) * ((mp_word)*tmpn++); - } - } - - /* now fix carry for next digit, W[ix+1] */ - W[ix + 1] += W[ix] >> ((mp_word) DIGIT_BIT); - } - - /* now we have to propagate the carries and - * shift the words downward [all those least - * significant digits we zeroed]. - */ - { - register mp_digit *tmpx; - register mp_word *_W, *_W1; - - /* nox fix rest of carries */ - - /* alias for current word */ - _W1 = W + ix; - - /* alias for next word, where the carry goes */ - _W = W + ++ix; - - for (; ix <= n->used * 2 + 1; ix++) { - *_W++ += *_W1++ >> ((mp_word) DIGIT_BIT); - } - - /* copy out, A = A/b**n - * - * The result is A/b**n but instead of converting from an - * array of mp_word to mp_digit than calling mp_rshd - * we just copy them in the right order - */ - - /* alias for destination word */ - tmpx = x->dp; - - /* alias for shifted double precision result */ - _W = W + n->used; - - for (ix = 0; ix < n->used + 1; ix++) { - *tmpx++ = (mp_digit)(*_W++ & ((mp_word) MP_MASK)); - } - - /* zero oldused digits, if the input a was larger than - * m->used+1 we'll have to clear the digits - */ - for (; ix < olduse; ix++) { - *tmpx++ = 0; - } - } - - /* set the max used and clamp */ - x->used = n->used + 1; - mp_clamp (x); - - /* if A >= m then A = A - m */ - if (mp_cmp_mag (x, n) != MP_LT) { - return s_mp_sub (x, n, x); - } - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_fast_mp_montgomery_reduce.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_fast_s_mp_mul_digs.c b/libs/storm-sys/StormLib/src/libtommath/bn_fast_s_mp_mul_digs.c deleted file mode 100644 index df83f89..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_fast_s_mp_mul_digs.c +++ /dev/null @@ -1,107 +0,0 @@ -#include "tommath.h" -#ifdef BN_FAST_S_MP_MUL_DIGS_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* Fast (comba) multiplier - * - * This is the fast column-array [comba] multiplier. It is - * designed to compute the columns of the product first - * then handle the carries afterwards. This has the effect - * of making the nested loops that compute the columns very - * simple and schedulable on super-scalar processors. - * - * This has been modified to produce a variable number of - * digits of output so if say only a half-product is required - * you don't have to compute the upper half (a feature - * required for fast Barrett reduction). - * - * Based on Algorithm 14.12 on pp.595 of HAC. - * - */ -int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs) -{ - int olduse, res, pa, ix, iz; - mp_digit W[MP_WARRAY]; - register mp_word _W; - - /* grow the destination as required */ - if (c->alloc < digs) { - if ((res = mp_grow (c, digs)) != MP_OKAY) { - return res; - } - } - - /* number of output digits to produce */ - pa = MIN(digs, a->used + b->used); - - /* clear the carry */ - _W = 0; - for (ix = 0; ix < pa; ix++) { - int tx, ty; - int iy; - mp_digit *tmpx, *tmpy; - - /* get offsets into the two bignums */ - ty = MIN(b->used-1, ix); - tx = ix - ty; - - /* setup temp aliases */ - tmpx = a->dp + tx; - tmpy = b->dp + ty; - - /* this is the number of times the loop will iterrate, essentially - while (tx++ < a->used && ty-- >= 0) { ... } - */ - iy = MIN(a->used-tx, ty+1); - - /* execute loop */ - for (iz = 0; iz < iy; ++iz) { - _W += ((mp_word)*tmpx++)*((mp_word)*tmpy--); - - } - - /* store term */ - W[ix] = ((mp_digit)_W) & MP_MASK; - - /* make next carry */ - _W = _W >> ((mp_word)DIGIT_BIT); - } - - /* setup dest */ - olduse = c->used; - c->used = pa; - - { - register mp_digit *tmpc; - tmpc = c->dp; - for (ix = 0; ix < pa+1; ix++) { - /* now extract the previous digit [below the carry] */ - *tmpc++ = W[ix]; - } - - /* clear unused digits [that existed in the old copy of c] */ - for (; ix < olduse; ix++) { - *tmpc++ = 0; - } - } - mp_clamp (c); - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_fast_s_mp_mul_digs.c,v $ */ -/* $Revision: 1.8 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_fast_s_mp_mul_high_digs.c b/libs/storm-sys/StormLib/src/libtommath/bn_fast_s_mp_mul_high_digs.c deleted file mode 100644 index 6866aab..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_fast_s_mp_mul_high_digs.c +++ /dev/null @@ -1,98 +0,0 @@ -#include "tommath.h" -#ifdef BN_FAST_S_MP_MUL_HIGH_DIGS_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* this is a modified version of fast_s_mul_digs that only produces - * output digits *above* digs. See the comments for fast_s_mul_digs - * to see how it works. - * - * This is used in the Barrett reduction since for one of the multiplications - * only the higher digits were needed. This essentially halves the work. - * - * Based on Algorithm 14.12 on pp.595 of HAC. - */ -int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs) -{ - int olduse, res, pa, ix, iz; - mp_digit W[MP_WARRAY]; - mp_word _W; - - /* grow the destination as required */ - pa = a->used + b->used; - if (c->alloc < pa) { - if ((res = mp_grow (c, pa)) != MP_OKAY) { - return res; - } - } - - /* number of output digits to produce */ - pa = a->used + b->used; - _W = 0; - for (ix = digs; ix < pa; ix++) { - int tx, ty, iy; - mp_digit *tmpx, *tmpy; - - /* get offsets into the two bignums */ - ty = MIN(b->used-1, ix); - tx = ix - ty; - - /* setup temp aliases */ - tmpx = a->dp + tx; - tmpy = b->dp + ty; - - /* this is the number of times the loop will iterrate, essentially its - while (tx++ < a->used && ty-- >= 0) { ... } - */ - iy = MIN(a->used-tx, ty+1); - - /* execute loop */ - for (iz = 0; iz < iy; iz++) { - _W += ((mp_word)*tmpx++)*((mp_word)*tmpy--); - } - - /* store term */ - W[ix] = ((mp_digit)_W) & MP_MASK; - - /* make next carry */ - _W = _W >> ((mp_word)DIGIT_BIT); - } - - /* setup dest */ - olduse = c->used; - c->used = pa; - - { - register mp_digit *tmpc; - - tmpc = c->dp + digs; - for (ix = digs; ix < pa; ix++) { - /* now extract the previous digit [below the carry] */ - *tmpc++ = W[ix]; - } - - /* clear unused digits [that existed in the old copy of c] */ - for (; ix < olduse; ix++) { - *tmpc++ = 0; - } - } - mp_clamp (c); - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_fast_s_mp_mul_high_digs.c,v $ */ -/* $Revision: 1.6 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_fast_s_mp_sqr.c b/libs/storm-sys/StormLib/src/libtommath/bn_fast_s_mp_sqr.c deleted file mode 100644 index 5f9d58c..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_fast_s_mp_sqr.c +++ /dev/null @@ -1,114 +0,0 @@ -#include "tommath.h" -#ifdef BN_FAST_S_MP_SQR_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* the jist of squaring... - * you do like mult except the offset of the tmpx [one that - * starts closer to zero] can't equal the offset of tmpy. - * So basically you set up iy like before then you min it with - * (ty-tx) so that it never happens. You double all those - * you add in the inner loop - -After that loop you do the squares and add them in. -*/ - -int fast_s_mp_sqr (mp_int * a, mp_int * b) -{ - int olduse, res, pa, ix, iz; - mp_digit W[MP_WARRAY], *tmpx; - mp_word W1; - - /* grow the destination as required */ - pa = a->used + a->used; - if (b->alloc < pa) { - if ((res = mp_grow (b, pa)) != MP_OKAY) { - return res; - } - } - - /* number of output digits to produce */ - W1 = 0; - for (ix = 0; ix < pa; ix++) { - int tx, ty, iy; - mp_word _W; - mp_digit *tmpy; - - /* clear counter */ - _W = 0; - - /* get offsets into the two bignums */ - ty = MIN(a->used-1, ix); - tx = ix - ty; - - /* setup temp aliases */ - tmpx = a->dp + tx; - tmpy = a->dp + ty; - - /* this is the number of times the loop will iterrate, essentially - while (tx++ < a->used && ty-- >= 0) { ... } - */ - iy = MIN(a->used-tx, ty+1); - - /* now for squaring tx can never equal ty - * we halve the distance since they approach at a rate of 2x - * and we have to round because odd cases need to be executed - */ - iy = MIN(iy, (ty-tx+1)>>1); - - /* execute loop */ - for (iz = 0; iz < iy; iz++) { - _W += ((mp_word)*tmpx++)*((mp_word)*tmpy--); - } - - /* double the inner product and add carry */ - _W = _W + _W + W1; - - /* even columns have the square term in them */ - if ((ix&1) == 0) { - _W += ((mp_word)a->dp[ix>>1])*((mp_word)a->dp[ix>>1]); - } - - /* store it */ - W[ix] = (mp_digit)(_W & MP_MASK); - - /* make next carry */ - W1 = _W >> ((mp_word)DIGIT_BIT); - } - - /* setup dest */ - olduse = b->used; - b->used = a->used+a->used; - - { - mp_digit *tmpb; - tmpb = b->dp; - for (ix = 0; ix < pa; ix++) { - *tmpb++ = W[ix] & MP_MASK; - } - - /* clear unused digits [that existed in the old copy of c] */ - for (; ix < olduse; ix++) { - *tmpb++ = 0; - } - } - mp_clamp (b); - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_fast_s_mp_sqr.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_2expt.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_2expt.c deleted file mode 100644 index f899eae..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_2expt.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_2EXPT_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* computes a = 2**b - * - * Simple algorithm which zeroes the int, grows it then just sets one bit - * as required. - */ -int -mp_2expt (mp_int * a, int b) -{ - int res; - - /* zero a as per default */ - mp_zero (a); - - /* grow a to accomodate the single bit */ - if ((res = mp_grow (a, b / DIGIT_BIT + 1)) != MP_OKAY) { - return res; - } - - /* set the used count of where the bit will go */ - a->used = b / DIGIT_BIT + 1; - - /* put the single bit in its place */ - a->dp[b / DIGIT_BIT] = ((mp_digit)1) << (b % DIGIT_BIT); - - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_2expt.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_abs.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_abs.c deleted file mode 100644 index 14f3a7e..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_abs.c +++ /dev/null @@ -1,43 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_ABS_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* b = |a| - * - * Simple function copies the input and fixes the sign to positive - */ -int -mp_abs (mp_int * a, mp_int * b) -{ - int res; - - /* copy a to b */ - if (a != b) { - if ((res = mp_copy (a, b)) != MP_OKAY) { - return res; - } - } - - /* force the sign of b to positive */ - b->sign = MP_ZPOS; - - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_abs.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_add.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_add.c deleted file mode 100644 index b368b21..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_add.c +++ /dev/null @@ -1,53 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_ADD_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* high level addition (handles signs) */ -int mp_add (mp_int * a, mp_int * b, mp_int * c) -{ - int sa, sb, res; - - /* get sign of both inputs */ - sa = a->sign; - sb = b->sign; - - /* handle two cases, not four */ - if (sa == sb) { - /* both positive or both negative */ - /* add their magnitudes, copy the sign */ - c->sign = sa; - res = s_mp_add (a, b, c); - } else { - /* one positive, the other negative */ - /* subtract the one with the greater magnitude from */ - /* the one of the lesser magnitude. The result gets */ - /* the sign of the one with the greater magnitude. */ - if (mp_cmp_mag (a, b) == MP_LT) { - c->sign = sb; - res = s_mp_sub (b, a, c); - } else { - c->sign = sa; - res = s_mp_sub (a, b, c); - } - } - return res; -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_add.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_add_d.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_add_d.c deleted file mode 100644 index c147554..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_add_d.c +++ /dev/null @@ -1,112 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_ADD_D_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* single digit addition */ -int -mp_add_d (mp_int * a, mp_digit b, mp_int * c) -{ - int res, ix, oldused; - mp_digit *tmpa, *tmpc, mu; - - /* grow c as required */ - if (c->alloc < a->used + 1) { - if ((res = mp_grow(c, a->used + 1)) != MP_OKAY) { - return res; - } - } - - /* if a is negative and |a| >= b, call c = |a| - b */ - if (a->sign == MP_NEG && (a->used > 1 || a->dp[0] >= b)) { - /* temporarily fix sign of a */ - a->sign = MP_ZPOS; - - /* c = |a| - b */ - res = mp_sub_d(a, b, c); - - /* fix sign */ - a->sign = c->sign = MP_NEG; - - /* clamp */ - mp_clamp(c); - - return res; - } - - /* old number of used digits in c */ - oldused = c->used; - - /* sign always positive */ - c->sign = MP_ZPOS; - - /* source alias */ - tmpa = a->dp; - - /* destination alias */ - tmpc = c->dp; - - /* if a is positive */ - if (a->sign == MP_ZPOS) { - /* add digit, after this we're propagating - * the carry. - */ - *tmpc = *tmpa++ + b; - mu = *tmpc >> DIGIT_BIT; - *tmpc++ &= MP_MASK; - - /* now handle rest of the digits */ - for (ix = 1; ix < a->used; ix++) { - *tmpc = *tmpa++ + mu; - mu = *tmpc >> DIGIT_BIT; - *tmpc++ &= MP_MASK; - } - /* set final carry */ - ix++; - *tmpc++ = mu; - - /* setup size */ - c->used = a->used + 1; - } else { - /* a was negative and |a| < b */ - c->used = 1; - - /* the result is a single digit */ - if (a->used == 1) { - *tmpc++ = b - a->dp[0]; - } else { - *tmpc++ = b; - } - - /* setup count so the clearing of oldused - * can fall through correctly - */ - ix = 1; - } - - /* now zero to oldused */ - while (ix++ < oldused) { - *tmpc++ = 0; - } - mp_clamp(c); - - return MP_OKAY; -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_add_d.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_addmod.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_addmod.c deleted file mode 100644 index 0a21f62..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_addmod.c +++ /dev/null @@ -1,41 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_ADDMOD_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* d = a + b (mod c) */ -int -mp_addmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d) -{ - int res; - mp_int t; - - if ((res = mp_init (&t)) != MP_OKAY) { - return res; - } - - if ((res = mp_add (a, b, &t)) != MP_OKAY) { - mp_clear (&t); - return res; - } - res = mp_mod (&t, c, d); - mp_clear (&t); - return res; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_addmod.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_and.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_and.c deleted file mode 100644 index 6b7afc1..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_and.c +++ /dev/null @@ -1,57 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_AND_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* AND two ints together */ -int -mp_and (mp_int * a, mp_int * b, mp_int * c) -{ - int res, ix, px; - mp_int t, *x; - - if (a->used > b->used) { - if ((res = mp_init_copy (&t, a)) != MP_OKAY) { - return res; - } - px = b->used; - x = b; - } else { - if ((res = mp_init_copy (&t, b)) != MP_OKAY) { - return res; - } - px = a->used; - x = a; - } - - for (ix = 0; ix < px; ix++) { - t.dp[ix] &= x->dp[ix]; - } - - /* zero digits above the last from the smallest mp_int */ - for (; ix < t.used; ix++) { - t.dp[ix] = 0; - } - - mp_clamp (&t); - mp_exch (c, &t); - mp_clear (&t); - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_and.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_clamp.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_clamp.c deleted file mode 100644 index d3cc21c..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_clamp.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_CLAMP_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* trim unused digits - * - * This is used to ensure that leading zero digits are - * trimed and the leading "used" digit will be non-zero - * Typically very fast. Also fixes the sign if there - * are no more leading digits - */ -void -mp_clamp (mp_int * a) -{ - /* decrease used while the most significant digit is - * zero. - */ - while (a->used > 0 && a->dp[a->used - 1] == 0) { - --(a->used); - } - - /* reset the sign flag if used == 0 */ - if (a->used == 0) { - a->sign = MP_ZPOS; - } -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_clamp.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_clear.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_clear.c deleted file mode 100644 index 7644c38..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_clear.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_CLEAR_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* clear one (frees) */ -void -mp_clear (mp_int * a) -{ - int i; - - /* only do anything if a hasn't been freed previously */ - if (a->dp != NULL) { - /* first zero the digits */ - for (i = 0; i < a->used; i++) { - a->dp[i] = 0; - } - - /* free ram */ - XFREE(a->dp); - - /* reset members to make debugging easier */ - a->dp = NULL; - a->alloc = a->used = 0; - a->sign = MP_ZPOS; - } -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_clear.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_clear_multi.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_clear_multi.c deleted file mode 100644 index a107624..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_clear_multi.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_CLEAR_MULTI_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include - -void mp_clear_multi(mp_int *mp, ...) -{ - mp_int* next_mp = mp; - va_list args; - va_start(args, mp); - while (next_mp != NULL) { - mp_clear(next_mp); - next_mp = va_arg(args, mp_int*); - } - va_end(args); -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_clear_multi.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_cmp.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_cmp.c deleted file mode 100644 index 761d2b0..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_cmp.c +++ /dev/null @@ -1,43 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_CMP_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* compare two ints (signed)*/ -int -mp_cmp (mp_int * a, mp_int * b) -{ - /* compare based on sign */ - if (a->sign != b->sign) { - if (a->sign == MP_NEG) { - return MP_LT; - } else { - return MP_GT; - } - } - - /* compare digits */ - if (a->sign == MP_NEG) { - /* if negative compare opposite direction */ - return mp_cmp_mag(b, a); - } else { - return mp_cmp_mag(a, b); - } -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_cmp.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_cmp_d.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_cmp_d.c deleted file mode 100644 index 420dfd3..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_cmp_d.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_CMP_D_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* compare a digit */ -int mp_cmp_d(mp_int * a, mp_digit b) -{ - /* compare based on sign */ - if (a->sign == MP_NEG) { - return MP_LT; - } - - /* compare based on magnitude */ - if (a->used > 1) { - return MP_GT; - } - - /* compare the only digit of a to b */ - if (a->dp[0] > b) { - return MP_GT; - } else if (a->dp[0] < b) { - return MP_LT; - } else { - return MP_EQ; - } -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_cmp_d.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_cmp_mag.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_cmp_mag.c deleted file mode 100644 index 92565a3..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_cmp_mag.c +++ /dev/null @@ -1,55 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_CMP_MAG_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* compare maginitude of two ints (unsigned) */ -int mp_cmp_mag (mp_int * a, mp_int * b) -{ - int n; - mp_digit *tmpa, *tmpb; - - /* compare based on # of non-zero digits */ - if (a->used > b->used) { - return MP_GT; - } - - if (a->used < b->used) { - return MP_LT; - } - - /* alias for a */ - tmpa = a->dp + (a->used - 1); - - /* alias for b */ - tmpb = b->dp + (a->used - 1); - - /* compare based on digits */ - for (n = 0; n < a->used; ++n, --tmpa, --tmpb) { - if (*tmpa > *tmpb) { - return MP_GT; - } - - if (*tmpa < *tmpb) { - return MP_LT; - } - } - return MP_EQ; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_cmp_mag.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_cnt_lsb.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_cnt_lsb.c deleted file mode 100644 index 6040661..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_cnt_lsb.c +++ /dev/null @@ -1,53 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_CNT_LSB_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -static const int lnz[16] = { - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 -}; - -/* Counts the number of lsbs which are zero before the first zero bit */ -int mp_cnt_lsb(mp_int *a) -{ - int x; - mp_digit q, qq; - - /* easy out */ - if (mp_iszero(a) == 1) { - return 0; - } - - /* scan lower digits until non-zero */ - for (x = 0; x < a->used && a->dp[x] == 0; x++); - q = a->dp[x]; - x *= DIGIT_BIT; - - /* now scan this digit until a 1 is found */ - if ((q & 1) == 0) { - do { - qq = q & 15; - x += lnz[qq]; - q >>= 4; - } while (qq == 0); - } - return x; -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_cnt_lsb.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_copy.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_copy.c deleted file mode 100644 index 7828592..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_copy.c +++ /dev/null @@ -1,68 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_COPY_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* copy, b = a */ -int -mp_copy (mp_int * a, mp_int * b) -{ - int res, n; - - /* if dst == src do nothing */ - if (a == b) { - return MP_OKAY; - } - - /* grow dest */ - if (b->alloc < a->used) { - if ((res = mp_grow (b, a->used)) != MP_OKAY) { - return res; - } - } - - /* zero b and copy the parameters over */ - { - register mp_digit *tmpa, *tmpb; - - /* pointer aliases */ - - /* source */ - tmpa = a->dp; - - /* destination */ - tmpb = b->dp; - - /* copy all the digits */ - for (n = 0; n < a->used; n++) { - *tmpb++ = *tmpa++; - } - - /* clear high digits */ - for (; n < b->used; n++) { - *tmpb++ = 0; - } - } - - /* copy used count and sign */ - b->used = a->used; - b->sign = a->sign; - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_copy.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_count_bits.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_count_bits.c deleted file mode 100644 index 9d8640f..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_count_bits.c +++ /dev/null @@ -1,45 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_COUNT_BITS_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* returns the number of bits in an int */ -int -mp_count_bits (mp_int * a) -{ - int r; - mp_digit q; - - /* shortcut */ - if (a->used == 0) { - return 0; - } - - /* get number of digits and add that */ - r = (a->used - 1) * DIGIT_BIT; - - /* take the last digit and count the bits in it */ - q = a->dp[a->used - 1]; - while (q > ((mp_digit) 0)) { - ++r; - q >>= ((mp_digit) 1); - } - return r; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_count_bits.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_div.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_div.c deleted file mode 100644 index 3004a3e..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_div.c +++ /dev/null @@ -1,292 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_DIV_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -#ifdef BN_MP_DIV_SMALL - -/* slower bit-bang division... also smaller */ -int mp_div(mp_int * a, mp_int * b, mp_int * c, mp_int * d) -{ - mp_int ta, tb, tq, q; - int res, n, n2; - - /* is divisor zero ? */ - if (mp_iszero (b) == 1) { - return MP_VAL; - } - - /* if a < b then q=0, r = a */ - if (mp_cmp_mag (a, b) == MP_LT) { - if (d != NULL) { - res = mp_copy (a, d); - } else { - res = MP_OKAY; - } - if (c != NULL) { - mp_zero (c); - } - return res; - } - - /* init our temps */ - if ((res = mp_init_multi(&ta, &tb, &tq, &q, NULL) != MP_OKAY)) { - return res; - } - - - mp_set(&tq, 1); - n = mp_count_bits(a) - mp_count_bits(b); - if (((res = mp_abs(a, &ta)) != MP_OKAY) || - ((res = mp_abs(b, &tb)) != MP_OKAY) || - ((res = mp_mul_2d(&tb, n, &tb)) != MP_OKAY) || - ((res = mp_mul_2d(&tq, n, &tq)) != MP_OKAY)) { - goto LBL_ERR; - } - - while (n-- >= 0) { - if (mp_cmp(&tb, &ta) != MP_GT) { - if (((res = mp_sub(&ta, &tb, &ta)) != MP_OKAY) || - ((res = mp_add(&q, &tq, &q)) != MP_OKAY)) { - goto LBL_ERR; - } - } - if (((res = mp_div_2d(&tb, 1, &tb, NULL)) != MP_OKAY) || - ((res = mp_div_2d(&tq, 1, &tq, NULL)) != MP_OKAY)) { - goto LBL_ERR; - } - } - - /* now q == quotient and ta == remainder */ - n = a->sign; - n2 = (a->sign == b->sign ? MP_ZPOS : MP_NEG); - if (c != NULL) { - mp_exch(c, &q); - c->sign = (mp_iszero(c) == MP_YES) ? MP_ZPOS : n2; - } - if (d != NULL) { - mp_exch(d, &ta); - d->sign = (mp_iszero(d) == MP_YES) ? MP_ZPOS : n; - } -LBL_ERR: - mp_clear_multi(&ta, &tb, &tq, &q, NULL); - return res; -} - -#else - -/* integer signed division. - * c*b + d == a [e.g. a/b, c=quotient, d=remainder] - * HAC pp.598 Algorithm 14.20 - * - * Note that the description in HAC is horribly - * incomplete. For example, it doesn't consider - * the case where digits are removed from 'x' in - * the inner loop. It also doesn't consider the - * case that y has fewer than three digits, etc.. - * - * The overall algorithm is as described as - * 14.20 from HAC but fixed to treat these cases. -*/ -int mp_div (mp_int * a, mp_int * b, mp_int * c, mp_int * d) -{ - mp_int q, x, y, t1, t2; - int res, n, t, i, norm, neg; - - /* is divisor zero ? */ - if (mp_iszero (b) == 1) { - return MP_VAL; - } - - /* if a < b then q=0, r = a */ - if (mp_cmp_mag (a, b) == MP_LT) { - if (d != NULL) { - res = mp_copy (a, d); - } else { - res = MP_OKAY; - } - if (c != NULL) { - mp_zero (c); - } - return res; - } - - if ((res = mp_init_size (&q, a->used + 2)) != MP_OKAY) { - return res; - } - q.used = a->used + 2; - - if ((res = mp_init (&t1)) != MP_OKAY) { - goto LBL_Q; - } - - if ((res = mp_init (&t2)) != MP_OKAY) { - goto LBL_T1; - } - - if ((res = mp_init_copy (&x, a)) != MP_OKAY) { - goto LBL_T2; - } - - if ((res = mp_init_copy (&y, b)) != MP_OKAY) { - goto LBL_X; - } - - /* fix the sign */ - neg = (a->sign == b->sign) ? MP_ZPOS : MP_NEG; - x.sign = y.sign = MP_ZPOS; - - /* normalize both x and y, ensure that y >= b/2, [b == 2**DIGIT_BIT] */ - norm = mp_count_bits(&y) % DIGIT_BIT; - if (norm < (int)(DIGIT_BIT-1)) { - norm = (DIGIT_BIT-1) - norm; - if ((res = mp_mul_2d (&x, norm, &x)) != MP_OKAY) { - goto LBL_Y; - } - if ((res = mp_mul_2d (&y, norm, &y)) != MP_OKAY) { - goto LBL_Y; - } - } else { - norm = 0; - } - - /* note hac does 0 based, so if used==5 then its 0,1,2,3,4, e.g. use 4 */ - n = x.used - 1; - t = y.used - 1; - - /* while (x >= y*b**n-t) do { q[n-t] += 1; x -= y*b**{n-t} } */ - if ((res = mp_lshd (&y, n - t)) != MP_OKAY) { /* y = y*b**{n-t} */ - goto LBL_Y; - } - - while (mp_cmp (&x, &y) != MP_LT) { - ++(q.dp[n - t]); - if ((res = mp_sub (&x, &y, &x)) != MP_OKAY) { - goto LBL_Y; - } - } - - /* reset y by shifting it back down */ - mp_rshd (&y, n - t); - - /* step 3. for i from n down to (t + 1) */ - for (i = n; i >= (t + 1); i--) { - if (i > x.used) { - continue; - } - - /* step 3.1 if xi == yt then set q{i-t-1} to b-1, - * otherwise set q{i-t-1} to (xi*b + x{i-1})/yt */ - if (x.dp[i] == y.dp[t]) { - q.dp[i - t - 1] = ((((mp_digit)1) << DIGIT_BIT) - 1); - } else { - mp_word tmp; - tmp = ((mp_word) x.dp[i]) << ((mp_word) DIGIT_BIT); - tmp |= ((mp_word) x.dp[i - 1]); - tmp /= ((mp_word) y.dp[t]); - if (tmp > (mp_word) MP_MASK) - tmp = MP_MASK; - q.dp[i - t - 1] = (mp_digit) (tmp & (mp_word) (MP_MASK)); - } - - /* while (q{i-t-1} * (yt * b + y{t-1})) > - xi * b**2 + xi-1 * b + xi-2 - - do q{i-t-1} -= 1; - */ - q.dp[i - t - 1] = (q.dp[i - t - 1] + 1) & MP_MASK; - do { - q.dp[i - t - 1] = (q.dp[i - t - 1] - 1) & MP_MASK; - - /* find left hand */ - mp_zero (&t1); - t1.dp[0] = (t - 1 < 0) ? 0 : y.dp[t - 1]; - t1.dp[1] = y.dp[t]; - t1.used = 2; - if ((res = mp_mul_d (&t1, q.dp[i - t - 1], &t1)) != MP_OKAY) { - goto LBL_Y; - } - - /* find right hand */ - t2.dp[0] = (i - 2 < 0) ? 0 : x.dp[i - 2]; - t2.dp[1] = (i - 1 < 0) ? 0 : x.dp[i - 1]; - t2.dp[2] = x.dp[i]; - t2.used = 3; - } while (mp_cmp_mag(&t1, &t2) == MP_GT); - - /* step 3.3 x = x - q{i-t-1} * y * b**{i-t-1} */ - if ((res = mp_mul_d (&y, q.dp[i - t - 1], &t1)) != MP_OKAY) { - goto LBL_Y; - } - - if ((res = mp_lshd (&t1, i - t - 1)) != MP_OKAY) { - goto LBL_Y; - } - - if ((res = mp_sub (&x, &t1, &x)) != MP_OKAY) { - goto LBL_Y; - } - - /* if x < 0 then { x = x + y*b**{i-t-1}; q{i-t-1} -= 1; } */ - if (x.sign == MP_NEG) { - if ((res = mp_copy (&y, &t1)) != MP_OKAY) { - goto LBL_Y; - } - if ((res = mp_lshd (&t1, i - t - 1)) != MP_OKAY) { - goto LBL_Y; - } - if ((res = mp_add (&x, &t1, &x)) != MP_OKAY) { - goto LBL_Y; - } - - q.dp[i - t - 1] = (q.dp[i - t - 1] - 1UL) & MP_MASK; - } - } - - /* now q is the quotient and x is the remainder - * [which we have to normalize] - */ - - /* get sign before writing to c */ - x.sign = x.used == 0 ? MP_ZPOS : a->sign; - - if (c != NULL) { - mp_clamp (&q); - mp_exch (&q, c); - c->sign = neg; - } - - if (d != NULL) { - mp_div_2d (&x, norm, &x, NULL); - mp_exch (&x, d); - } - - res = MP_OKAY; - -LBL_Y:mp_clear (&y); -LBL_X:mp_clear (&x); -LBL_T2:mp_clear (&t2); -LBL_T1:mp_clear (&t1); -LBL_Q:mp_clear (&q); - return res; -} - -#endif - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_div.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_div_2.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_div_2.c deleted file mode 100644 index f3b9d16..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_div_2.c +++ /dev/null @@ -1,68 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_DIV_2_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* b = a/2 */ -int mp_div_2(mp_int * a, mp_int * b) -{ - int x, res, oldused; - - /* copy */ - if (b->alloc < a->used) { - if ((res = mp_grow (b, a->used)) != MP_OKAY) { - return res; - } - } - - oldused = b->used; - b->used = a->used; - { - register mp_digit r, rr, *tmpa, *tmpb; - - /* source alias */ - tmpa = a->dp + b->used - 1; - - /* dest alias */ - tmpb = b->dp + b->used - 1; - - /* carry */ - r = 0; - for (x = b->used - 1; x >= 0; x--) { - /* get the carry for the next iteration */ - rr = *tmpa & 1; - - /* shift the current digit, add in carry and store */ - *tmpb-- = (*tmpa-- >> 1) | (r << (DIGIT_BIT - 1)); - - /* forward carry to next iteration */ - r = rr; - } - - /* zero excess digits */ - tmpb = b->dp + b->used; - for (x = b->used; x < oldused; x++) { - *tmpb++ = 0; - } - } - b->sign = a->sign; - mp_clamp (b); - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_div_2.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_div_2d.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_div_2d.c deleted file mode 100644 index 861ea23..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_div_2d.c +++ /dev/null @@ -1,97 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_DIV_2D_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* shift right by a certain bit count (store quotient in c, optional remainder in d) */ -int mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d) -{ - mp_digit D, r, rr; - int x, res; - mp_int t; - - - /* if the shift count is <= 0 then we do no work */ - if (b <= 0) { - res = mp_copy (a, c); - if (d != NULL) { - mp_zero (d); - } - return res; - } - - if ((res = mp_init (&t)) != MP_OKAY) { - return res; - } - - /* get the remainder */ - if (d != NULL) { - if ((res = mp_mod_2d (a, b, &t)) != MP_OKAY) { - mp_clear (&t); - return res; - } - } - - /* copy */ - if ((res = mp_copy (a, c)) != MP_OKAY) { - mp_clear (&t); - return res; - } - - /* shift by as many digits in the bit count */ - if (b >= (int)DIGIT_BIT) { - mp_rshd (c, b / DIGIT_BIT); - } - - /* shift any bit count < DIGIT_BIT */ - D = (mp_digit) (b % DIGIT_BIT); - if (D != 0) { - register mp_digit *tmpc, mask, shift; - - /* mask */ - mask = (((mp_digit)1) << D) - 1; - - /* shift for lsb */ - shift = DIGIT_BIT - D; - - /* alias */ - tmpc = c->dp + (c->used - 1); - - /* carry */ - r = 0; - for (x = c->used - 1; x >= 0; x--) { - /* get the lower bits of this word in a temp */ - rr = *tmpc & mask; - - /* shift the current word and mix in the carry bits from the previous word */ - *tmpc = (*tmpc >> D) | (r << shift); - --tmpc; - - /* set the carry to the carry bits of the current word found above */ - r = rr; - } - } - mp_clamp (c); - if (d != NULL) { - mp_exch (&t, d); - } - mp_clear (&t); - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_div_2d.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_div_3.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_div_3.c deleted file mode 100644 index 4fc08fc..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_div_3.c +++ /dev/null @@ -1,79 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_DIV_3_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* divide by three (based on routine from MPI and the GMP manual) */ -int -mp_div_3 (mp_int * a, mp_int *c, mp_digit * d) -{ - mp_int q; - mp_word w, t; - mp_digit b; - int res, ix; - - /* b = 2**DIGIT_BIT / 3 */ - b = (((mp_word)1) << ((mp_word)DIGIT_BIT)) / ((mp_word)3); - - if ((res = mp_init_size(&q, a->used)) != MP_OKAY) { - return res; - } - - q.used = a->used; - q.sign = a->sign; - w = 0; - for (ix = a->used - 1; ix >= 0; ix--) { - w = (w << ((mp_word)DIGIT_BIT)) | ((mp_word)a->dp[ix]); - - if (w >= 3) { - /* multiply w by [1/3] */ - t = (w * ((mp_word)b)) >> ((mp_word)DIGIT_BIT); - - /* now subtract 3 * [w/3] from w, to get the remainder */ - w -= t+t+t; - - /* fixup the remainder as required since - * the optimization is not exact. - */ - while (w >= 3) { - t += 1; - w -= 3; - } - } else { - t = 0; - } - q.dp[ix] = (mp_digit)t; - } - - /* [optional] store the remainder */ - if (d != NULL) { - *d = (mp_digit)w; - } - - /* [optional] store the quotient */ - if (c != NULL) { - mp_clamp(&q); - mp_exch(&q, c); - } - mp_clear(&q); - - return res; -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_div_3.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_div_d.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_div_d.c deleted file mode 100644 index c0318a4..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_div_d.c +++ /dev/null @@ -1,115 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_DIV_D_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -static int s_is_power_of_two(mp_digit b, int *p) -{ - int x; - - /* fast return if no power of two */ - if ((b==0) || (b & (b-1))) { - return 0; - } - - for (x = 0; x < DIGIT_BIT; x++) { - if (b == (((mp_digit)1)<dp[0] & ((((mp_digit)1)<used)) != MP_OKAY) { - return res; - } - - q.used = a->used; - q.sign = a->sign; - w = 0; - for (ix = a->used - 1; ix >= 0; ix--) { - w = (w << ((mp_word)DIGIT_BIT)) | ((mp_word)a->dp[ix]); - - if (w >= b) { - t = (mp_digit)(w / b); - w -= ((mp_word)t) * ((mp_word)b); - } else { - t = 0; - } - q.dp[ix] = (mp_digit)t; - } - - if (d != NULL) { - *d = (mp_digit)w; - } - - if (c != NULL) { - mp_clamp(&q); - mp_exch(&q, c); - } - mp_clear(&q); - - return res; -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_div_d.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2007/01/09 04:44:32 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_dr_is_modulus.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_dr_is_modulus.c deleted file mode 100644 index 22ba5df..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_dr_is_modulus.c +++ /dev/null @@ -1,43 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_DR_IS_MODULUS_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* determines if a number is a valid DR modulus */ -int mp_dr_is_modulus(mp_int *a) -{ - int ix; - - /* must be at least two digits */ - if (a->used < 2) { - return 0; - } - - /* must be of the form b**k - a [a <= b] so all - * but the first digit must be equal to -1 (mod b). - */ - for (ix = 1; ix < a->used; ix++) { - if (a->dp[ix] != MP_MASK) { - return 0; - } - } - return 1; -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_dr_is_modulus.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_dr_reduce.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_dr_reduce.c deleted file mode 100644 index 0afac94..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_dr_reduce.c +++ /dev/null @@ -1,94 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_DR_REDUCE_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* reduce "x" in place modulo "n" using the Diminished Radix algorithm. - * - * Based on algorithm from the paper - * - * "Generating Efficient Primes for Discrete Log Cryptosystems" - * Chae Hoon Lim, Pil Joong Lee, - * POSTECH Information Research Laboratories - * - * The modulus must be of a special format [see manual] - * - * Has been modified to use algorithm 7.10 from the LTM book instead - * - * Input x must be in the range 0 <= x <= (n-1)**2 - */ -int -mp_dr_reduce (mp_int * x, mp_int * n, mp_digit k) -{ - int err, i, m; - mp_word r; - mp_digit mu, *tmpx1, *tmpx2; - - /* m = digits in modulus */ - m = n->used; - - /* ensure that "x" has at least 2m digits */ - if (x->alloc < m + m) { - if ((err = mp_grow (x, m + m)) != MP_OKAY) { - return err; - } - } - -/* top of loop, this is where the code resumes if - * another reduction pass is required. - */ -top: - /* aliases for digits */ - /* alias for lower half of x */ - tmpx1 = x->dp; - - /* alias for upper half of x, or x/B**m */ - tmpx2 = x->dp + m; - - /* set carry to zero */ - mu = 0; - - /* compute (x mod B**m) + k * [x/B**m] inline and inplace */ - for (i = 0; i < m; i++) { - r = ((mp_word)*tmpx2++) * ((mp_word)k) + *tmpx1 + mu; - *tmpx1++ = (mp_digit)(r & MP_MASK); - mu = (mp_digit)(r >> ((mp_word)DIGIT_BIT)); - } - - /* set final carry */ - *tmpx1++ = mu; - - /* zero words above m */ - for (i = m + 1; i < x->used; i++) { - *tmpx1++ = 0; - } - - /* clamp, sub and return */ - mp_clamp (x); - - /* if x >= n then subtract and reduce again - * Each successive "recursion" makes the input smaller and smaller. - */ - if (mp_cmp_mag (x, n) != MP_LT) { - s_mp_sub(x, n, x); - goto top; - } - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_dr_reduce.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_dr_setup.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_dr_setup.c deleted file mode 100644 index a5152f7..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_dr_setup.c +++ /dev/null @@ -1,32 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_DR_SETUP_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* determines the setup value */ -void mp_dr_setup(mp_int *a, mp_digit *d) -{ - /* the casts are required if DIGIT_BIT is one less than - * the number of bits in a mp_digit [e.g. DIGIT_BIT==31] - */ - *d = (mp_digit)((((mp_word)1) << ((mp_word)DIGIT_BIT)) - - ((mp_word)a->dp[0])); -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_dr_setup.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_exch.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_exch.c deleted file mode 100644 index e5ec7f5..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_exch.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_EXCH_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* swap the elements of two integers, for cases where you can't simply swap the - * mp_int pointers around - */ -void -mp_exch (mp_int * a, mp_int * b) -{ - mp_int t; - - t = *a; - *a = *b; - *b = t; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_exch.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_expt_d.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_expt_d.c deleted file mode 100644 index 7bf371c..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_expt_d.c +++ /dev/null @@ -1,57 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_EXPT_D_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* calculate c = a**b using a square-multiply algorithm */ -int mp_expt_d (mp_int * a, mp_digit b, mp_int * c) -{ - int res, x; - mp_int g; - - if ((res = mp_init_copy (&g, a)) != MP_OKAY) { - return res; - } - - /* set initial result */ - mp_set (c, 1); - - for (x = 0; x < (int) DIGIT_BIT; x++) { - /* square */ - if ((res = mp_sqr (c, c)) != MP_OKAY) { - mp_clear (&g); - return res; - } - - /* if the bit is set multiply */ - if ((b & (mp_digit) (((mp_digit)1) << (DIGIT_BIT - 1))) != 0) { - if ((res = mp_mul (c, &g, c)) != MP_OKAY) { - mp_clear (&g); - return res; - } - } - - /* shift to next bit */ - b <<= 1; - } - - mp_clear (&g); - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_expt_d.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_exptmod.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_exptmod.c deleted file mode 100644 index 27c46ea..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_exptmod.c +++ /dev/null @@ -1,112 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_EXPTMOD_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - - -/* this is a shell function that calls either the normal or Montgomery - * exptmod functions. Originally the call to the montgomery code was - * embedded in the normal function but that wasted alot of stack space - * for nothing (since 99% of the time the Montgomery code would be called) - */ -int mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y) -{ - int dr; - - /* modulus P must be positive */ - if (P->sign == MP_NEG) { - return MP_VAL; - } - - /* if exponent X is negative we have to recurse */ - if (X->sign == MP_NEG) { -#ifdef BN_MP_INVMOD_C - mp_int tmpG, tmpX; - int err; - - /* first compute 1/G mod P */ - if ((err = mp_init(&tmpG)) != MP_OKAY) { - return err; - } - if ((err = mp_invmod(G, P, &tmpG)) != MP_OKAY) { - mp_clear(&tmpG); - return err; - } - - /* now get |X| */ - if ((err = mp_init(&tmpX)) != MP_OKAY) { - mp_clear(&tmpG); - return err; - } - if ((err = mp_abs(X, &tmpX)) != MP_OKAY) { - mp_clear_multi(&tmpG, &tmpX, NULL); - return err; - } - - /* and now compute (1/G)**|X| instead of G**X [X < 0] */ - err = mp_exptmod(&tmpG, &tmpX, P, Y); - mp_clear_multi(&tmpG, &tmpX, NULL); - return err; -#else - /* no invmod */ - return MP_VAL; -#endif - } - -/* modified diminished radix reduction */ -#if defined(BN_MP_REDUCE_IS_2K_L_C) && defined(BN_MP_REDUCE_2K_L_C) && defined(BN_S_MP_EXPTMOD_C) - if (mp_reduce_is_2k_l(P) == MP_YES) { - return s_mp_exptmod(G, X, P, Y, 1); - } -#endif - -#ifdef BN_MP_DR_IS_MODULUS_C - /* is it a DR modulus? */ - dr = mp_dr_is_modulus(P); -#else - /* default to no */ - dr = 0; -#endif - -#ifdef BN_MP_REDUCE_IS_2K_C - /* if not, is it a unrestricted DR modulus? */ - if (dr == 0) { - dr = mp_reduce_is_2k(P) << 1; - } -#endif - - /* if the modulus is odd or dr != 0 use the montgomery method */ -#ifdef BN_MP_EXPTMOD_FAST_C - if (mp_isodd (P) == 1 || dr != 0) { - return mp_exptmod_fast (G, X, P, Y, dr); - } else { -#endif -#ifdef BN_S_MP_EXPTMOD_C - /* otherwise use the generic Barrett reduction technique */ - return s_mp_exptmod (G, X, P, Y, 0); -#else - /* no exptmod for evens */ - return MP_VAL; -#endif -#ifdef BN_MP_EXPTMOD_FAST_C - } -#endif -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_exptmod.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_exptmod_fast.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_exptmod_fast.c deleted file mode 100644 index 31205d4..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_exptmod_fast.c +++ /dev/null @@ -1,321 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_EXPTMOD_FAST_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* computes Y == G**X mod P, HAC pp.616, Algorithm 14.85 - * - * Uses a left-to-right k-ary sliding window to compute the modular exponentiation. - * The value of k changes based on the size of the exponent. - * - * Uses Montgomery or Diminished Radix reduction [whichever appropriate] - */ - -#ifdef MP_LOW_MEM - #define TAB_SIZE 32 -#else - #define TAB_SIZE 256 -#endif - -int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode) -{ - mp_int M[TAB_SIZE], res; - mp_digit buf, mp; - int err, bitbuf, bitcpy, bitcnt, mode, digidx, x, y, winsize; - - /* use a pointer to the reduction algorithm. This allows us to use - * one of many reduction algorithms without modding the guts of - * the code with if statements everywhere. - */ - int (*redux)(mp_int*,mp_int*,mp_digit); - - /* find window size */ - x = mp_count_bits (X); - if (x <= 7) { - winsize = 2; - } else if (x <= 36) { - winsize = 3; - } else if (x <= 140) { - winsize = 4; - } else if (x <= 450) { - winsize = 5; - } else if (x <= 1303) { - winsize = 6; - } else if (x <= 3529) { - winsize = 7; - } else { - winsize = 8; - } - -#ifdef MP_LOW_MEM - if (winsize > 5) { - winsize = 5; - } -#endif - - /* init M array */ - /* init first cell */ - if ((err = mp_init(&M[1])) != MP_OKAY) { - return err; - } - - /* now init the second half of the array */ - for (x = 1<<(winsize-1); x < (1 << winsize); x++) { - if ((err = mp_init(&M[x])) != MP_OKAY) { - for (y = 1<<(winsize-1); y < x; y++) { - mp_clear (&M[y]); - } - mp_clear(&M[1]); - return err; - } - } - - /* determine and setup reduction code */ - if (redmode == 0) { -#ifdef BN_MP_MONTGOMERY_SETUP_C - /* now setup montgomery */ - if ((err = mp_montgomery_setup (P, &mp)) != MP_OKAY) { - goto LBL_M; - } -#else - err = MP_VAL; - goto LBL_M; -#endif - - /* automatically pick the comba one if available (saves quite a few calls/ifs) */ -#ifdef BN_FAST_MP_MONTGOMERY_REDUCE_C - if (((P->used * 2 + 1) < MP_WARRAY) && - P->used < (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) { - redux = fast_mp_montgomery_reduce; - } else -#endif - { -#ifdef BN_MP_MONTGOMERY_REDUCE_C - /* use slower baseline Montgomery method */ - redux = mp_montgomery_reduce; -#else - err = MP_VAL; - goto LBL_M; -#endif - } - } else if (redmode == 1) { -#if defined(BN_MP_DR_SETUP_C) && defined(BN_MP_DR_REDUCE_C) - /* setup DR reduction for moduli of the form B**k - b */ - mp_dr_setup(P, &mp); - redux = mp_dr_reduce; -#else - err = MP_VAL; - goto LBL_M; -#endif - } else { -#if defined(BN_MP_REDUCE_2K_SETUP_C) && defined(BN_MP_REDUCE_2K_C) - /* setup DR reduction for moduli of the form 2**k - b */ - if ((err = mp_reduce_2k_setup(P, &mp)) != MP_OKAY) { - goto LBL_M; - } - redux = mp_reduce_2k; -#else - err = MP_VAL; - goto LBL_M; -#endif - } - - /* setup result */ - if ((err = mp_init (&res)) != MP_OKAY) { - goto LBL_M; - } - - /* create M table - * - - * - * The first half of the table is not computed though accept for M[0] and M[1] - */ - - if (redmode == 0) { -#ifdef BN_MP_MONTGOMERY_CALC_NORMALIZATION_C - /* now we need R mod m */ - if ((err = mp_montgomery_calc_normalization (&res, P)) != MP_OKAY) { - goto LBL_RES; - } -#else - err = MP_VAL; - goto LBL_RES; -#endif - - /* now set M[1] to G * R mod m */ - if ((err = mp_mulmod (G, &res, P, &M[1])) != MP_OKAY) { - goto LBL_RES; - } - } else { - mp_set(&res, 1); - if ((err = mp_mod(G, P, &M[1])) != MP_OKAY) { - goto LBL_RES; - } - } - - /* compute the value at M[1<<(winsize-1)] by squaring M[1] (winsize-1) times */ - if ((err = mp_copy (&M[1], &M[1 << (winsize - 1)])) != MP_OKAY) { - goto LBL_RES; - } - - for (x = 0; x < (winsize - 1); x++) { - if ((err = mp_sqr (&M[1 << (winsize - 1)], &M[1 << (winsize - 1)])) != MP_OKAY) { - goto LBL_RES; - } - if ((err = redux (&M[1 << (winsize - 1)], P, mp)) != MP_OKAY) { - goto LBL_RES; - } - } - - /* create upper table */ - for (x = (1 << (winsize - 1)) + 1; x < (1 << winsize); x++) { - if ((err = mp_mul (&M[x - 1], &M[1], &M[x])) != MP_OKAY) { - goto LBL_RES; - } - if ((err = redux (&M[x], P, mp)) != MP_OKAY) { - goto LBL_RES; - } - } - - /* set initial mode and bit cnt */ - mode = 0; - bitcnt = 1; - buf = 0; - digidx = X->used - 1; - bitcpy = 0; - bitbuf = 0; - - for (;;) { - /* grab next digit as required */ - if (--bitcnt == 0) { - /* if digidx == -1 we are out of digits so break */ - if (digidx == -1) { - break; - } - /* read next digit and reset bitcnt */ - buf = X->dp[digidx--]; - bitcnt = (int)DIGIT_BIT; - } - - /* grab the next msb from the exponent */ - y = (mp_digit)(buf >> (DIGIT_BIT - 1)) & 1; - buf <<= (mp_digit)1; - - /* if the bit is zero and mode == 0 then we ignore it - * These represent the leading zero bits before the first 1 bit - * in the exponent. Technically this opt is not required but it - * does lower the # of trivial squaring/reductions used - */ - if (mode == 0 && y == 0) { - continue; - } - - /* if the bit is zero and mode == 1 then we square */ - if (mode == 1 && y == 0) { - if ((err = mp_sqr (&res, &res)) != MP_OKAY) { - goto LBL_RES; - } - if ((err = redux (&res, P, mp)) != MP_OKAY) { - goto LBL_RES; - } - continue; - } - - /* else we add it to the window */ - bitbuf |= (y << (winsize - ++bitcpy)); - mode = 2; - - if (bitcpy == winsize) { - /* ok window is filled so square as required and multiply */ - /* square first */ - for (x = 0; x < winsize; x++) { - if ((err = mp_sqr (&res, &res)) != MP_OKAY) { - goto LBL_RES; - } - if ((err = redux (&res, P, mp)) != MP_OKAY) { - goto LBL_RES; - } - } - - /* then multiply */ - if ((err = mp_mul (&res, &M[bitbuf], &res)) != MP_OKAY) { - goto LBL_RES; - } - if ((err = redux (&res, P, mp)) != MP_OKAY) { - goto LBL_RES; - } - - /* empty window and reset */ - bitcpy = 0; - bitbuf = 0; - mode = 1; - } - } - - /* if bits remain then square/multiply */ - if (mode == 2 && bitcpy > 0) { - /* square then multiply if the bit is set */ - for (x = 0; x < bitcpy; x++) { - if ((err = mp_sqr (&res, &res)) != MP_OKAY) { - goto LBL_RES; - } - if ((err = redux (&res, P, mp)) != MP_OKAY) { - goto LBL_RES; - } - - /* get next bit of the window */ - bitbuf <<= 1; - if ((bitbuf & (1 << winsize)) != 0) { - /* then multiply */ - if ((err = mp_mul (&res, &M[1], &res)) != MP_OKAY) { - goto LBL_RES; - } - if ((err = redux (&res, P, mp)) != MP_OKAY) { - goto LBL_RES; - } - } - } - } - - if (redmode == 0) { - /* fixup result if Montgomery reduction is used - * recall that any value in a Montgomery system is - * actually multiplied by R mod n. So we have - * to reduce one more time to cancel out the factor - * of R. - */ - if ((err = redux(&res, P, mp)) != MP_OKAY) { - goto LBL_RES; - } - } - - /* swap res with Y */ - mp_exch (&res, Y); - err = MP_OKAY; -LBL_RES:mp_clear (&res); -LBL_M: - mp_clear(&M[1]); - for (x = 1<<(winsize-1); x < (1 << winsize); x++) { - mp_clear (&M[x]); - } - return err; -} -#endif - - -/* $Source: /cvs/libtom/libtommath/bn_mp_exptmod_fast.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_exteuclid.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_exteuclid.c deleted file mode 100644 index 9881d6e..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_exteuclid.c +++ /dev/null @@ -1,82 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_EXTEUCLID_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* Extended euclidean algorithm of (a, b) produces - a*u1 + b*u2 = u3 - */ -int mp_exteuclid(mp_int *a, mp_int *b, mp_int *U1, mp_int *U2, mp_int *U3) -{ - mp_int u1,u2,u3,v1,v2,v3,t1,t2,t3,q,tmp; - int err; - - if ((err = mp_init_multi(&u1, &u2, &u3, &v1, &v2, &v3, &t1, &t2, &t3, &q, &tmp, NULL)) != MP_OKAY) { - return err; - } - - /* initialize, (u1,u2,u3) = (1,0,a) */ - mp_set(&u1, 1); - if ((err = mp_copy(a, &u3)) != MP_OKAY) { goto _ERR; } - - /* initialize, (v1,v2,v3) = (0,1,b) */ - mp_set(&v2, 1); - if ((err = mp_copy(b, &v3)) != MP_OKAY) { goto _ERR; } - - /* loop while v3 != 0 */ - while (mp_iszero(&v3) == MP_NO) { - /* q = u3/v3 */ - if ((err = mp_div(&u3, &v3, &q, NULL)) != MP_OKAY) { goto _ERR; } - - /* (t1,t2,t3) = (u1,u2,u3) - (v1,v2,v3)q */ - if ((err = mp_mul(&v1, &q, &tmp)) != MP_OKAY) { goto _ERR; } - if ((err = mp_sub(&u1, &tmp, &t1)) != MP_OKAY) { goto _ERR; } - if ((err = mp_mul(&v2, &q, &tmp)) != MP_OKAY) { goto _ERR; } - if ((err = mp_sub(&u2, &tmp, &t2)) != MP_OKAY) { goto _ERR; } - if ((err = mp_mul(&v3, &q, &tmp)) != MP_OKAY) { goto _ERR; } - if ((err = mp_sub(&u3, &tmp, &t3)) != MP_OKAY) { goto _ERR; } - - /* (u1,u2,u3) = (v1,v2,v3) */ - if ((err = mp_copy(&v1, &u1)) != MP_OKAY) { goto _ERR; } - if ((err = mp_copy(&v2, &u2)) != MP_OKAY) { goto _ERR; } - if ((err = mp_copy(&v3, &u3)) != MP_OKAY) { goto _ERR; } - - /* (v1,v2,v3) = (t1,t2,t3) */ - if ((err = mp_copy(&t1, &v1)) != MP_OKAY) { goto _ERR; } - if ((err = mp_copy(&t2, &v2)) != MP_OKAY) { goto _ERR; } - if ((err = mp_copy(&t3, &v3)) != MP_OKAY) { goto _ERR; } - } - - /* make sure U3 >= 0 */ - if (u3.sign == MP_NEG) { - mp_neg(&u1, &u1); - mp_neg(&u2, &u2); - mp_neg(&u3, &u3); - } - - /* copy result out */ - if (U1 != NULL) { mp_exch(U1, &u1); } - if (U2 != NULL) { mp_exch(U2, &u2); } - if (U3 != NULL) { mp_exch(U3, &u3); } - - err = MP_OKAY; -_ERR: mp_clear_multi(&u1, &u2, &u3, &v1, &v2, &v3, &t1, &t2, &t3, &q, &tmp, NULL); - return err; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_exteuclid.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_fread.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_fread.c deleted file mode 100644 index 2976b30..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_fread.c +++ /dev/null @@ -1,67 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_FREAD_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* read a bigint from a file stream in ASCII */ -int mp_fread(mp_int *a, int radix, FILE *stream) -{ - int err, ch, neg, y; - - /* clear a */ - mp_zero(a); - - /* if first digit is - then set negative */ - ch = fgetc(stream); - if (ch == '-') { - neg = MP_NEG; - ch = fgetc(stream); - } else { - neg = MP_ZPOS; - } - - for (;;) { - /* find y in the radix map */ - for (y = 0; y < radix; y++) { - if (mp_s_rmap[y] == ch) { - break; - } - } - if (y == radix) { - break; - } - - /* shift up and add */ - if ((err = mp_mul_d(a, radix, a)) != MP_OKAY) { - return err; - } - if ((err = mp_add_d(a, y, a)) != MP_OKAY) { - return err; - } - - ch = fgetc(stream); - } - if (mp_cmp_d(a, 0) != MP_EQ) { - a->sign = neg; - } - - return MP_OKAY; -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_fread.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_fwrite.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_fwrite.c deleted file mode 100644 index 6782b2e..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_fwrite.c +++ /dev/null @@ -1,52 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_FWRITE_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -int mp_fwrite(mp_int *a, int radix, FILE *stream) -{ - char *buf; - int err, len, x; - - if ((err = mp_radix_size(a, radix, &len)) != MP_OKAY) { - return err; - } - - buf = OPT_CAST(char) XMALLOC (len); - if (buf == NULL) { - return MP_MEM; - } - - if ((err = mp_toradix(a, buf, radix)) != MP_OKAY) { - XFREE (buf); - return err; - } - - for (x = 0; x < len; x++) { - if (fputc(buf[x], stream) == EOF) { - XFREE (buf); - return MP_VAL; - } - } - - XFREE (buf); - return MP_OKAY; -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_fwrite.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_gcd.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_gcd.c deleted file mode 100644 index ce980eb..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_gcd.c +++ /dev/null @@ -1,105 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_GCD_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* Greatest Common Divisor using the binary method */ -int mp_gcd (mp_int * a, mp_int * b, mp_int * c) -{ - mp_int u, v; - int k, u_lsb, v_lsb, res; - - /* either zero than gcd is the largest */ - if (mp_iszero (a) == MP_YES) { - return mp_abs (b, c); - } - if (mp_iszero (b) == MP_YES) { - return mp_abs (a, c); - } - - /* get copies of a and b we can modify */ - if ((res = mp_init_copy (&u, a)) != MP_OKAY) { - return res; - } - - if ((res = mp_init_copy (&v, b)) != MP_OKAY) { - goto LBL_U; - } - - /* must be positive for the remainder of the algorithm */ - u.sign = v.sign = MP_ZPOS; - - /* B1. Find the common power of two for u and v */ - u_lsb = mp_cnt_lsb(&u); - v_lsb = mp_cnt_lsb(&v); - k = MIN(u_lsb, v_lsb); - - if (k > 0) { - /* divide the power of two out */ - if ((res = mp_div_2d(&u, k, &u, NULL)) != MP_OKAY) { - goto LBL_V; - } - - if ((res = mp_div_2d(&v, k, &v, NULL)) != MP_OKAY) { - goto LBL_V; - } - } - - /* divide any remaining factors of two out */ - if (u_lsb != k) { - if ((res = mp_div_2d(&u, u_lsb - k, &u, NULL)) != MP_OKAY) { - goto LBL_V; - } - } - - if (v_lsb != k) { - if ((res = mp_div_2d(&v, v_lsb - k, &v, NULL)) != MP_OKAY) { - goto LBL_V; - } - } - - while (mp_iszero(&v) == 0) { - /* make sure v is the largest */ - if (mp_cmp_mag(&u, &v) == MP_GT) { - /* swap u and v to make sure v is >= u */ - mp_exch(&u, &v); - } - - /* subtract smallest from largest */ - if ((res = s_mp_sub(&v, &u, &v)) != MP_OKAY) { - goto LBL_V; - } - - /* Divide out all factors of two */ - if ((res = mp_div_2d(&v, mp_cnt_lsb(&v), &v, NULL)) != MP_OKAY) { - goto LBL_V; - } - } - - /* multiply by 2**k which we divided out at the beginning */ - if ((res = mp_mul_2d (&u, k, c)) != MP_OKAY) { - goto LBL_V; - } - c->sign = MP_ZPOS; - res = MP_OKAY; -LBL_V:mp_clear (&u); -LBL_U:mp_clear (&v); - return res; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_gcd.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_get_int.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_get_int.c deleted file mode 100644 index d9c76d0..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_get_int.c +++ /dev/null @@ -1,45 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_GET_INT_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* get the lower 32-bits of an mp_int */ -unsigned long mp_get_int(mp_int * a) -{ - int i; - unsigned long res; - - if (a->used == 0) { - return 0; - } - - /* get number of digits of the lsb we have to read */ - i = MIN(a->used,(int)((sizeof(unsigned long)*CHAR_BIT+DIGIT_BIT-1)/DIGIT_BIT))-1; - - /* get most significant digit of result */ - res = DIGIT(a,i); - - while (--i >= 0) { - res = (res << DIGIT_BIT) | DIGIT(a,i); - } - - /* force result to 32-bits always so it is consistent on non 32-bit platforms */ - return res & 0xFFFFFFFFUL; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_get_int.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_grow.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_grow.c deleted file mode 100644 index a05dad7..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_grow.c +++ /dev/null @@ -1,57 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_GROW_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* grow as required */ -int mp_grow (mp_int * a, int size) -{ - int i; - mp_digit *tmp; - - /* if the alloc size is smaller alloc more ram */ - if (a->alloc < size) { - /* ensure there are always at least MP_PREC digits extra on top */ - size += (MP_PREC * 2) - (size % MP_PREC); - - /* reallocate the array a->dp - * - * We store the return in a temporary variable - * in case the operation failed we don't want - * to overwrite the dp member of a. - */ - tmp = OPT_CAST(mp_digit) XREALLOC (a->dp, sizeof (mp_digit) * size); - if (tmp == NULL) { - /* reallocation failed but "a" is still valid [can be freed] */ - return MP_MEM; - } - - /* reallocation succeeded so set a->dp */ - a->dp = tmp; - - /* zero excess digits */ - i = a->alloc; - a->alloc = size; - for (; i < a->alloc; i++) { - a->dp[i] = 0; - } - } - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_grow.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_init.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_init.c deleted file mode 100644 index 107d98b..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_init.c +++ /dev/null @@ -1,46 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_INIT_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* init a new mp_int */ -int mp_init (mp_int * a) -{ - int i; - - /* allocate memory required and clear it */ - a->dp = OPT_CAST(mp_digit) XMALLOC (sizeof (mp_digit) * MP_PREC); - if (a->dp == NULL) { - return MP_MEM; - } - - /* set the digits to zero */ - for (i = 0; i < MP_PREC; i++) { - a->dp[i] = 0; - } - - /* set the used to zero, allocated digits to the default precision - * and sign to positive */ - a->used = 0; - a->alloc = MP_PREC; - a->sign = MP_ZPOS; - - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_init.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_init_copy.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_init_copy.c deleted file mode 100644 index 3ca1186..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_init_copy.c +++ /dev/null @@ -1,32 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_INIT_COPY_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* creates "a" then copies b into it */ -int mp_init_copy (mp_int * a, mp_int * b) -{ - int res; - - if ((res = mp_init (a)) != MP_OKAY) { - return res; - } - return mp_copy (b, a); -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_init_copy.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_init_multi.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_init_multi.c deleted file mode 100644 index 4f6f367..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_init_multi.c +++ /dev/null @@ -1,59 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_INIT_MULTI_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#include - -int mp_init_multi(mp_int *mp, ...) -{ - mp_err res = MP_OKAY; /* Assume ok until proven otherwise */ - int n = 0; /* Number of ok inits */ - mp_int* cur_arg = mp; - va_list args; - - va_start(args, mp); /* init args to next argument from caller */ - while (cur_arg != NULL) { - if (mp_init(cur_arg) != MP_OKAY) { - /* Oops - error! Back-track and mp_clear what we already - succeeded in init-ing, then return error. - */ - va_list clean_args; - - /* end the current list */ - va_end(args); - - /* now start cleaning up */ - cur_arg = mp; - va_start(clean_args, mp); - while (n--) { - mp_clear(cur_arg); - cur_arg = va_arg(clean_args, mp_int*); - } - va_end(clean_args); - res = MP_MEM; - break; - } - n++; - cur_arg = va_arg(args, mp_int*); - } - va_end(args); - return res; /* Assumed ok, if error flagged above. */ -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_init_multi.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_init_set.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_init_set.c deleted file mode 100644 index 853323f..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_init_set.c +++ /dev/null @@ -1,32 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_INIT_SET_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* initialize and set a digit */ -int mp_init_set (mp_int * a, mp_digit b) -{ - int err; - if ((err = mp_init(a)) != MP_OKAY) { - return err; - } - mp_set(a, b); - return err; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_init_set.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_init_set_int.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_init_set_int.c deleted file mode 100644 index b2f8727..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_init_set_int.c +++ /dev/null @@ -1,31 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_INIT_SET_INT_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* initialize and set a digit */ -int mp_init_set_int (mp_int * a, unsigned long b) -{ - int err; - if ((err = mp_init(a)) != MP_OKAY) { - return err; - } - return mp_set_int(a, b); -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_init_set_int.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_init_size.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_init_size.c deleted file mode 100644 index 17b8d9f..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_init_size.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_INIT_SIZE_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* init an mp_init for a given size */ -int mp_init_size (mp_int * a, int size) -{ - int x; - - /* pad size so there are always extra digits */ - size += (MP_PREC * 2) - (size % MP_PREC); - - /* alloc mem */ - a->dp = OPT_CAST(mp_digit) XMALLOC (sizeof (mp_digit) * size); - if (a->dp == NULL) { - return MP_MEM; - } - - /* set the members */ - a->used = 0; - a->alloc = size; - a->sign = MP_ZPOS; - - /* zero the digits */ - for (x = 0; x < size; x++) { - a->dp[x] = 0; - } - - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_init_size.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_invmod.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_invmod.c deleted file mode 100644 index 038e584..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_invmod.c +++ /dev/null @@ -1,43 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_INVMOD_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* hac 14.61, pp608 */ -int mp_invmod (mp_int * a, mp_int * b, mp_int * c) -{ - /* b cannot be negative */ - if (b->sign == MP_NEG || mp_iszero(b) == 1) { - return MP_VAL; - } - -#ifdef BN_FAST_MP_INVMOD_C - /* if the modulus is odd we can use a faster routine instead */ - if (mp_isodd (b) == 1) { - return fast_mp_invmod (a, b, c); - } -#endif - -#ifdef BN_MP_INVMOD_SLOW_C - return mp_invmod_slow(a, b, c); -#endif - - return MP_VAL; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_invmod.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_invmod_slow.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_invmod_slow.c deleted file mode 100644 index 3792a4c..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_invmod_slow.c +++ /dev/null @@ -1,175 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_INVMOD_SLOW_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* hac 14.61, pp608 */ -int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c) -{ - mp_int x, y, u, v, A, B, C, D; - int res; - - /* b cannot be negative */ - if (b->sign == MP_NEG || mp_iszero(b) == 1) { - return MP_VAL; - } - - /* init temps */ - if ((res = mp_init_multi(&x, &y, &u, &v, - &A, &B, &C, &D, NULL)) != MP_OKAY) { - return res; - } - - /* x = a, y = b */ - if ((res = mp_mod(a, b, &x)) != MP_OKAY) { - goto LBL_ERR; - } - if ((res = mp_copy (b, &y)) != MP_OKAY) { - goto LBL_ERR; - } - - /* 2. [modified] if x,y are both even then return an error! */ - if (mp_iseven (&x) == 1 && mp_iseven (&y) == 1) { - res = MP_VAL; - goto LBL_ERR; - } - - /* 3. u=x, v=y, A=1, B=0, C=0,D=1 */ - if ((res = mp_copy (&x, &u)) != MP_OKAY) { - goto LBL_ERR; - } - if ((res = mp_copy (&y, &v)) != MP_OKAY) { - goto LBL_ERR; - } - mp_set (&A, 1); - mp_set (&D, 1); - -top: - /* 4. while u is even do */ - while (mp_iseven (&u) == 1) { - /* 4.1 u = u/2 */ - if ((res = mp_div_2 (&u, &u)) != MP_OKAY) { - goto LBL_ERR; - } - /* 4.2 if A or B is odd then */ - if (mp_isodd (&A) == 1 || mp_isodd (&B) == 1) { - /* A = (A+y)/2, B = (B-x)/2 */ - if ((res = mp_add (&A, &y, &A)) != MP_OKAY) { - goto LBL_ERR; - } - if ((res = mp_sub (&B, &x, &B)) != MP_OKAY) { - goto LBL_ERR; - } - } - /* A = A/2, B = B/2 */ - if ((res = mp_div_2 (&A, &A)) != MP_OKAY) { - goto LBL_ERR; - } - if ((res = mp_div_2 (&B, &B)) != MP_OKAY) { - goto LBL_ERR; - } - } - - /* 5. while v is even do */ - while (mp_iseven (&v) == 1) { - /* 5.1 v = v/2 */ - if ((res = mp_div_2 (&v, &v)) != MP_OKAY) { - goto LBL_ERR; - } - /* 5.2 if C or D is odd then */ - if (mp_isodd (&C) == 1 || mp_isodd (&D) == 1) { - /* C = (C+y)/2, D = (D-x)/2 */ - if ((res = mp_add (&C, &y, &C)) != MP_OKAY) { - goto LBL_ERR; - } - if ((res = mp_sub (&D, &x, &D)) != MP_OKAY) { - goto LBL_ERR; - } - } - /* C = C/2, D = D/2 */ - if ((res = mp_div_2 (&C, &C)) != MP_OKAY) { - goto LBL_ERR; - } - if ((res = mp_div_2 (&D, &D)) != MP_OKAY) { - goto LBL_ERR; - } - } - - /* 6. if u >= v then */ - if (mp_cmp (&u, &v) != MP_LT) { - /* u = u - v, A = A - C, B = B - D */ - if ((res = mp_sub (&u, &v, &u)) != MP_OKAY) { - goto LBL_ERR; - } - - if ((res = mp_sub (&A, &C, &A)) != MP_OKAY) { - goto LBL_ERR; - } - - if ((res = mp_sub (&B, &D, &B)) != MP_OKAY) { - goto LBL_ERR; - } - } else { - /* v - v - u, C = C - A, D = D - B */ - if ((res = mp_sub (&v, &u, &v)) != MP_OKAY) { - goto LBL_ERR; - } - - if ((res = mp_sub (&C, &A, &C)) != MP_OKAY) { - goto LBL_ERR; - } - - if ((res = mp_sub (&D, &B, &D)) != MP_OKAY) { - goto LBL_ERR; - } - } - - /* if not zero goto step 4 */ - if (mp_iszero (&u) == 0) - goto top; - - /* now a = C, b = D, gcd == g*v */ - - /* if v != 1 then there is no inverse */ - if (mp_cmp_d (&v, 1) != MP_EQ) { - res = MP_VAL; - goto LBL_ERR; - } - - /* if its too low */ - while (mp_cmp_d(&C, 0) == MP_LT) { - if ((res = mp_add(&C, b, &C)) != MP_OKAY) { - goto LBL_ERR; - } - } - - /* too big */ - while (mp_cmp_mag(&C, b) != MP_LT) { - if ((res = mp_sub(&C, b, &C)) != MP_OKAY) { - goto LBL_ERR; - } - } - - /* C is now the inverse */ - mp_exch (&C, c); - res = MP_OKAY; -LBL_ERR:mp_clear_multi (&x, &y, &u, &v, &A, &B, &C, &D, NULL); - return res; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_invmod_slow.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_is_square.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_is_square.c deleted file mode 100644 index 5d2fa07..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_is_square.c +++ /dev/null @@ -1,109 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_IS_SQUARE_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* Check if remainders are possible squares - fast exclude non-squares */ -static const char rem_128[128] = { - 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, - 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, - 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, - 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, - 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, - 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, - 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, - 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1 -}; - -static const char rem_105[105] = { - 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, - 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, - 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, - 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, - 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, - 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 -}; - -/* Store non-zero to ret if arg is square, and zero if not */ -int mp_is_square(mp_int *arg,int *ret) -{ - int res; - mp_digit c; - mp_int t; - unsigned long r; - - /* Default to Non-square :) */ - *ret = MP_NO; - - if (arg->sign == MP_NEG) { - return MP_VAL; - } - - /* digits used? (TSD) */ - if (arg->used == 0) { - return MP_OKAY; - } - - /* First check mod 128 (suppose that DIGIT_BIT is at least 7) */ - if (rem_128[127 & DIGIT(arg,0)] == 1) { - return MP_OKAY; - } - - /* Next check mod 105 (3*5*7) */ - if ((res = mp_mod_d(arg,105,&c)) != MP_OKAY) { - return res; - } - if (rem_105[c] == 1) { - return MP_OKAY; - } - - - if ((res = mp_init_set_int(&t,11L*13L*17L*19L*23L*29L*31L)) != MP_OKAY) { - return res; - } - if ((res = mp_mod(arg,&t,&t)) != MP_OKAY) { - goto ERR; - } - r = mp_get_int(&t); - /* Check for other prime modules, note it's not an ERROR but we must - * free "t" so the easiest way is to goto ERR. We know that res - * is already equal to MP_OKAY from the mp_mod call - */ - if ( (1L<<(r%11)) & 0x5C4L ) goto ERR; - if ( (1L<<(r%13)) & 0x9E4L ) goto ERR; - if ( (1L<<(r%17)) & 0x5CE8L ) goto ERR; - if ( (1L<<(r%19)) & 0x4F50CL ) goto ERR; - if ( (1L<<(r%23)) & 0x7ACCA0L ) goto ERR; - if ( (1L<<(r%29)) & 0xC2EDD0CL ) goto ERR; - if ( (1L<<(r%31)) & 0x6DE2B848L ) goto ERR; - - /* Final check - is sqr(sqrt(arg)) == arg ? */ - if ((res = mp_sqrt(arg,&t)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_sqr(&t,&t)) != MP_OKAY) { - goto ERR; - } - - *ret = (mp_cmp_mag(&t,arg) == MP_EQ) ? MP_YES : MP_NO; -ERR:mp_clear(&t); - return res; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_is_square.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_jacobi.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_jacobi.c deleted file mode 100644 index c70b946..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_jacobi.c +++ /dev/null @@ -1,105 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_JACOBI_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* computes the jacobi c = (a | n) (or Legendre if n is prime) - * HAC pp. 73 Algorithm 2.149 - */ -int mp_jacobi (mp_int * a, mp_int * p, int *c) -{ - mp_int a1, p1; - int k, s, r, res; - mp_digit residue; - - /* if p <= 0 return MP_VAL */ - if (mp_cmp_d(p, 0) != MP_GT) { - return MP_VAL; - } - - /* step 1. if a == 0, return 0 */ - if (mp_iszero (a) == 1) { - *c = 0; - return MP_OKAY; - } - - /* step 2. if a == 1, return 1 */ - if (mp_cmp_d (a, 1) == MP_EQ) { - *c = 1; - return MP_OKAY; - } - - /* default */ - s = 0; - - /* step 3. write a = a1 * 2**k */ - if ((res = mp_init_copy (&a1, a)) != MP_OKAY) { - return res; - } - - if ((res = mp_init (&p1)) != MP_OKAY) { - goto LBL_A1; - } - - /* divide out larger power of two */ - k = mp_cnt_lsb(&a1); - if ((res = mp_div_2d(&a1, k, &a1, NULL)) != MP_OKAY) { - goto LBL_P1; - } - - /* step 4. if e is even set s=1 */ - if ((k & 1) == 0) { - s = 1; - } else { - /* else set s=1 if p = 1/7 (mod 8) or s=-1 if p = 3/5 (mod 8) */ - residue = p->dp[0] & 7; - - if (residue == 1 || residue == 7) { - s = 1; - } else if (residue == 3 || residue == 5) { - s = -1; - } - } - - /* step 5. if p == 3 (mod 4) *and* a1 == 3 (mod 4) then s = -s */ - if ( ((p->dp[0] & 3) == 3) && ((a1.dp[0] & 3) == 3)) { - s = -s; - } - - /* if a1 == 1 we're done */ - if (mp_cmp_d (&a1, 1) == MP_EQ) { - *c = s; - } else { - /* n1 = n mod a1 */ - if ((res = mp_mod (p, &a1, &p1)) != MP_OKAY) { - goto LBL_P1; - } - if ((res = mp_jacobi (&p1, &a1, &r)) != MP_OKAY) { - goto LBL_P1; - } - *c = s * r; - } - - /* done */ - res = MP_OKAY; -LBL_P1:mp_clear (&p1); -LBL_A1:mp_clear (&a1); - return res; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_jacobi.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_karatsuba_mul.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_karatsuba_mul.c deleted file mode 100644 index b15ec24..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_karatsuba_mul.c +++ /dev/null @@ -1,167 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_KARATSUBA_MUL_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* c = |a| * |b| using Karatsuba Multiplication using - * three half size multiplications - * - * Let B represent the radix [e.g. 2**DIGIT_BIT] and - * let n represent half of the number of digits in - * the min(a,b) - * - * a = a1 * B**n + a0 - * b = b1 * B**n + b0 - * - * Then, a * b => - a1b1 * B**2n + ((a1 + a0)(b1 + b0) - (a0b0 + a1b1)) * B + a0b0 - * - * Note that a1b1 and a0b0 are used twice and only need to be - * computed once. So in total three half size (half # of - * digit) multiplications are performed, a0b0, a1b1 and - * (a1+b1)(a0+b0) - * - * Note that a multiplication of half the digits requires - * 1/4th the number of single precision multiplications so in - * total after one call 25% of the single precision multiplications - * are saved. Note also that the call to mp_mul can end up back - * in this function if the a0, a1, b0, or b1 are above the threshold. - * This is known as divide-and-conquer and leads to the famous - * O(N**lg(3)) or O(N**1.584) work which is asymptopically lower than - * the standard O(N**2) that the baseline/comba methods use. - * Generally though the overhead of this method doesn't pay off - * until a certain size (N ~ 80) is reached. - */ -int mp_karatsuba_mul (mp_int * a, mp_int * b, mp_int * c) -{ - mp_int x0, x1, y0, y1, t1, x0y0, x1y1; - int B, err; - - /* default the return code to an error */ - err = MP_MEM; - - /* min # of digits */ - B = MIN (a->used, b->used); - - /* now divide in two */ - B = B >> 1; - - /* init copy all the temps */ - if (mp_init_size (&x0, B) != MP_OKAY) - goto ERR; - if (mp_init_size (&x1, a->used - B) != MP_OKAY) - goto X0; - if (mp_init_size (&y0, B) != MP_OKAY) - goto X1; - if (mp_init_size (&y1, b->used - B) != MP_OKAY) - goto Y0; - - /* init temps */ - if (mp_init_size (&t1, B * 2) != MP_OKAY) - goto Y1; - if (mp_init_size (&x0y0, B * 2) != MP_OKAY) - goto T1; - if (mp_init_size (&x1y1, B * 2) != MP_OKAY) - goto X0Y0; - - /* now shift the digits */ - x0.used = y0.used = B; - x1.used = a->used - B; - y1.used = b->used - B; - - { - register int x; - register mp_digit *tmpa, *tmpb, *tmpx, *tmpy; - - /* we copy the digits directly instead of using higher level functions - * since we also need to shift the digits - */ - tmpa = a->dp; - tmpb = b->dp; - - tmpx = x0.dp; - tmpy = y0.dp; - for (x = 0; x < B; x++) { - *tmpx++ = *tmpa++; - *tmpy++ = *tmpb++; - } - - tmpx = x1.dp; - for (x = B; x < a->used; x++) { - *tmpx++ = *tmpa++; - } - - tmpy = y1.dp; - for (x = B; x < b->used; x++) { - *tmpy++ = *tmpb++; - } - } - - /* only need to clamp the lower words since by definition the - * upper words x1/y1 must have a known number of digits - */ - mp_clamp (&x0); - mp_clamp (&y0); - - /* now calc the products x0y0 and x1y1 */ - /* after this x0 is no longer required, free temp [x0==t2]! */ - if (mp_mul (&x0, &y0, &x0y0) != MP_OKAY) - goto X1Y1; /* x0y0 = x0*y0 */ - if (mp_mul (&x1, &y1, &x1y1) != MP_OKAY) - goto X1Y1; /* x1y1 = x1*y1 */ - - /* now calc x1+x0 and y1+y0 */ - if (s_mp_add (&x1, &x0, &t1) != MP_OKAY) - goto X1Y1; /* t1 = x1 - x0 */ - if (s_mp_add (&y1, &y0, &x0) != MP_OKAY) - goto X1Y1; /* t2 = y1 - y0 */ - if (mp_mul (&t1, &x0, &t1) != MP_OKAY) - goto X1Y1; /* t1 = (x1 + x0) * (y1 + y0) */ - - /* add x0y0 */ - if (mp_add (&x0y0, &x1y1, &x0) != MP_OKAY) - goto X1Y1; /* t2 = x0y0 + x1y1 */ - if (s_mp_sub (&t1, &x0, &t1) != MP_OKAY) - goto X1Y1; /* t1 = (x1+x0)*(y1+y0) - (x1y1 + x0y0) */ - - /* shift by B */ - if (mp_lshd (&t1, B) != MP_OKAY) - goto X1Y1; /* t1 = (x0y0 + x1y1 - (x1-x0)*(y1-y0))<used; - - /* now divide in two */ - B = B >> 1; - - /* init copy all the temps */ - if (mp_init_size (&x0, B) != MP_OKAY) - goto ERR; - if (mp_init_size (&x1, a->used - B) != MP_OKAY) - goto X0; - - /* init temps */ - if (mp_init_size (&t1, a->used * 2) != MP_OKAY) - goto X1; - if (mp_init_size (&t2, a->used * 2) != MP_OKAY) - goto T1; - if (mp_init_size (&x0x0, B * 2) != MP_OKAY) - goto T2; - if (mp_init_size (&x1x1, (a->used - B) * 2) != MP_OKAY) - goto X0X0; - - { - register int x; - register mp_digit *dst, *src; - - src = a->dp; - - /* now shift the digits */ - dst = x0.dp; - for (x = 0; x < B; x++) { - *dst++ = *src++; - } - - dst = x1.dp; - for (x = B; x < a->used; x++) { - *dst++ = *src++; - } - } - - x0.used = B; - x1.used = a->used - B; - - mp_clamp (&x0); - - /* now calc the products x0*x0 and x1*x1 */ - if (mp_sqr (&x0, &x0x0) != MP_OKAY) - goto X1X1; /* x0x0 = x0*x0 */ - if (mp_sqr (&x1, &x1x1) != MP_OKAY) - goto X1X1; /* x1x1 = x1*x1 */ - - /* now calc (x1+x0)**2 */ - if (s_mp_add (&x1, &x0, &t1) != MP_OKAY) - goto X1X1; /* t1 = x1 - x0 */ - if (mp_sqr (&t1, &t1) != MP_OKAY) - goto X1X1; /* t1 = (x1 - x0) * (x1 - x0) */ - - /* add x0y0 */ - if (s_mp_add (&x0x0, &x1x1, &t2) != MP_OKAY) - goto X1X1; /* t2 = x0x0 + x1x1 */ - if (s_mp_sub (&t1, &t2, &t1) != MP_OKAY) - goto X1X1; /* t1 = (x1+x0)**2 - (x0x0 + x1x1) */ - - /* shift by B */ - if (mp_lshd (&t1, B) != MP_OKAY) - goto X1X1; /* t1 = (x0x0 + x1x1 - (x1-x0)*(x1-x0))<sign = MP_ZPOS; - -LBL_T: - mp_clear_multi (&t1, &t2, NULL); - return res; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_lcm.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_lshd.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_lshd.c deleted file mode 100644 index ffb0def..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_lshd.c +++ /dev/null @@ -1,67 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_LSHD_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* shift left a certain amount of digits */ -int mp_lshd (mp_int * a, int b) -{ - int x, res; - - /* if its less than zero return */ - if (b <= 0) { - return MP_OKAY; - } - - /* grow to fit the new digits */ - if (a->alloc < a->used + b) { - if ((res = mp_grow (a, a->used + b)) != MP_OKAY) { - return res; - } - } - - { - register mp_digit *top, *bottom; - - /* increment the used by the shift amount then copy upwards */ - a->used += b; - - /* top */ - top = a->dp + a->used - 1; - - /* base */ - bottom = a->dp + a->used - 1 - b; - - /* much like mp_rshd this is implemented using a sliding window - * except the window goes the otherway around. Copying from - * the bottom to the top. see bn_mp_rshd.c for more info. - */ - for (x = a->used - 1; x >= b; x--) { - *top-- = *bottom--; - } - - /* zero the lower digits */ - top = a->dp; - for (x = 0; x < b; x++) { - *top++ = 0; - } - } - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_lshd.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_mod.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_mod.c deleted file mode 100644 index b24c71f..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_mod.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_MOD_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* c = a mod b, 0 <= c < b */ -int -mp_mod (mp_int * a, mp_int * b, mp_int * c) -{ - mp_int t; - int res; - - if ((res = mp_init (&t)) != MP_OKAY) { - return res; - } - - if ((res = mp_div (a, b, NULL, &t)) != MP_OKAY) { - mp_clear (&t); - return res; - } - - if (t.sign != b->sign) { - res = mp_add (b, &t, c); - } else { - res = MP_OKAY; - mp_exch (&t, c); - } - - mp_clear (&t); - return res; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_mod.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_mod_2d.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_mod_2d.c deleted file mode 100644 index a54a024..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_mod_2d.c +++ /dev/null @@ -1,55 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_MOD_2D_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* calc a value mod 2**b */ -int -mp_mod_2d (mp_int * a, int b, mp_int * c) -{ - int x, res; - - /* if b is <= 0 then zero the int */ - if (b <= 0) { - mp_zero (c); - return MP_OKAY; - } - - /* if the modulus is larger than the value than return */ - if (b >= (int) (a->used * DIGIT_BIT)) { - res = mp_copy (a, c); - return res; - } - - /* copy */ - if ((res = mp_copy (a, c)) != MP_OKAY) { - return res; - } - - /* zero digits above the last digit of the modulus */ - for (x = (b / DIGIT_BIT) + ((b % DIGIT_BIT) == 0 ? 0 : 1); x < c->used; x++) { - c->dp[x] = 0; - } - /* clear the digit that is not completely outside/inside the modulus */ - c->dp[b / DIGIT_BIT] &= - (mp_digit) ((((mp_digit) 1) << (((mp_digit) b) % DIGIT_BIT)) - ((mp_digit) 1)); - mp_clamp (c); - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_mod_2d.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_mod_d.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_mod_d.c deleted file mode 100644 index 59886e7..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_mod_d.c +++ /dev/null @@ -1,27 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_MOD_D_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -int -mp_mod_d (mp_int * a, mp_digit b, mp_digit * c) -{ - return mp_div_d(a, b, NULL, c); -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_mod_d.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_montgomery_calc_normalization.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_montgomery_calc_normalization.c deleted file mode 100644 index fdefcbd..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_montgomery_calc_normalization.c +++ /dev/null @@ -1,59 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_MONTGOMERY_CALC_NORMALIZATION_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* - * shifts with subtractions when the result is greater than b. - * - * The method is slightly modified to shift B unconditionally upto just under - * the leading bit of b. This saves alot of multiple precision shifting. - */ -int mp_montgomery_calc_normalization (mp_int * a, mp_int * b) -{ - int x, bits, res; - - /* how many bits of last digit does b use */ - bits = mp_count_bits (b) % DIGIT_BIT; - - if (b->used > 1) { - if ((res = mp_2expt (a, (b->used - 1) * DIGIT_BIT + bits - 1)) != MP_OKAY) { - return res; - } - } else { - mp_set(a, 1); - bits = 1; - } - - - /* now compute C = A * B mod b */ - for (x = bits - 1; x < (int)DIGIT_BIT; x++) { - if ((res = mp_mul_2 (a, a)) != MP_OKAY) { - return res; - } - if (mp_cmp_mag (a, b) != MP_LT) { - if ((res = s_mp_sub (a, b, a)) != MP_OKAY) { - return res; - } - } - } - - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_montgomery_calc_normalization.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_montgomery_reduce.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_montgomery_reduce.c deleted file mode 100644 index 173848e..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_montgomery_reduce.c +++ /dev/null @@ -1,118 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_MONTGOMERY_REDUCE_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* computes xR**-1 == x (mod N) via Montgomery Reduction */ -int -mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho) -{ - int ix, res, digs; - mp_digit mu; - - /* can the fast reduction [comba] method be used? - * - * Note that unlike in mul you're safely allowed *less* - * than the available columns [255 per default] since carries - * are fixed up in the inner loop. - */ - digs = n->used * 2 + 1; - if ((digs < MP_WARRAY) && - n->used < - (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) { - return fast_mp_montgomery_reduce (x, n, rho); - } - - /* grow the input as required */ - if (x->alloc < digs) { - if ((res = mp_grow (x, digs)) != MP_OKAY) { - return res; - } - } - x->used = digs; - - for (ix = 0; ix < n->used; ix++) { - /* mu = ai * rho mod b - * - * The value of rho must be precalculated via - * montgomery_setup() such that - * it equals -1/n0 mod b this allows the - * following inner loop to reduce the - * input one digit at a time - */ - mu = (mp_digit) (((mp_word)x->dp[ix]) * ((mp_word)rho) & MP_MASK); - - /* a = a + mu * m * b**i */ - { - register int iy; - register mp_digit *tmpn, *tmpx, u; - register mp_word r; - - /* alias for digits of the modulus */ - tmpn = n->dp; - - /* alias for the digits of x [the input] */ - tmpx = x->dp + ix; - - /* set the carry to zero */ - u = 0; - - /* Multiply and add in place */ - for (iy = 0; iy < n->used; iy++) { - /* compute product and sum */ - r = ((mp_word)mu) * ((mp_word)*tmpn++) + - ((mp_word) u) + ((mp_word) * tmpx); - - /* get carry */ - u = (mp_digit)(r >> ((mp_word) DIGIT_BIT)); - - /* fix digit */ - *tmpx++ = (mp_digit)(r & ((mp_word) MP_MASK)); - } - /* At this point the ix'th digit of x should be zero */ - - - /* propagate carries upwards as required*/ - while (u) { - *tmpx += u; - u = *tmpx >> DIGIT_BIT; - *tmpx++ &= MP_MASK; - } - } - } - - /* at this point the n.used'th least - * significant digits of x are all zero - * which means we can shift x to the - * right by n.used digits and the - * residue is unchanged. - */ - - /* x = x/b**n.used */ - mp_clamp(x); - mp_rshd (x, n->used); - - /* if x >= n then x = x - n */ - if (mp_cmp_mag (x, n) != MP_LT) { - return s_mp_sub (x, n, x); - } - - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_montgomery_reduce.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_montgomery_setup.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_montgomery_setup.c deleted file mode 100644 index 6f27732..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_montgomery_setup.c +++ /dev/null @@ -1,59 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_MONTGOMERY_SETUP_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* setups the montgomery reduction stuff */ -int -mp_montgomery_setup (mp_int * n, mp_digit * rho) -{ - mp_digit x, b; - -/* fast inversion mod 2**k - * - * Based on the fact that - * - * XA = 1 (mod 2**n) => (X(2-XA)) A = 1 (mod 2**2n) - * => 2*X*A - X*X*A*A = 1 - * => 2*(1) - (1) = 1 - */ - b = n->dp[0]; - - if ((b & 1) == 0) { - return MP_VAL; - } - - x = (((b + 2) & 4) << 1) + b; /* here x*a==1 mod 2**4 */ - x *= 2 - b * x; /* here x*a==1 mod 2**8 */ -#if !defined(MP_8BIT) - x *= 2 - b * x; /* here x*a==1 mod 2**16 */ -#endif -#if defined(MP_64BIT) || !(defined(MP_8BIT) || defined(MP_16BIT)) - x *= 2 - b * x; /* here x*a==1 mod 2**32 */ -#endif -#ifdef MP_64BIT - x *= 2 - b * x; /* here x*a==1 mod 2**64 */ -#endif - - /* rho = -1/m mod b */ - *rho = (unsigned long)(((mp_word)1 << ((mp_word) DIGIT_BIT)) - x) & MP_MASK; - - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_montgomery_setup.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_mul.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_mul.c deleted file mode 100644 index a1315da..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_mul.c +++ /dev/null @@ -1,66 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_MUL_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* high level multiplication (handles sign) */ -int mp_mul (mp_int * a, mp_int * b, mp_int * c) -{ - int res, neg; - neg = (a->sign == b->sign) ? MP_ZPOS : MP_NEG; - - /* use Toom-Cook? */ -#ifdef BN_MP_TOOM_MUL_C - if (MIN (a->used, b->used) >= TOOM_MUL_CUTOFF) { - res = mp_toom_mul(a, b, c); - } else -#endif -#ifdef BN_MP_KARATSUBA_MUL_C - /* use Karatsuba? */ - if (MIN (a->used, b->used) >= KARATSUBA_MUL_CUTOFF) { - res = mp_karatsuba_mul (a, b, c); - } else -#endif - { - /* can we use the fast multiplier? - * - * The fast multiplier can be used if the output will - * have less than MP_WARRAY digits and the number of - * digits won't affect carry propagation - */ - int digs = a->used + b->used + 1; - -#ifdef BN_FAST_S_MP_MUL_DIGS_C - if ((digs < MP_WARRAY) && - MIN(a->used, b->used) <= - (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) { - res = fast_s_mp_mul_digs (a, b, c, digs); - } else -#endif -#ifdef BN_S_MP_MUL_DIGS_C - res = s_mp_mul (a, b, c); /* uses s_mp_mul_digs */ -#else - res = MP_VAL; -#endif - - } - c->sign = (c->used > 0) ? neg : MP_ZPOS; - return res; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_mul.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_mul_2.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_mul_2.c deleted file mode 100644 index 3315744..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_mul_2.c +++ /dev/null @@ -1,82 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_MUL_2_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* b = a*2 */ -int mp_mul_2(mp_int * a, mp_int * b) -{ - int x, res, oldused; - - /* grow to accomodate result */ - if (b->alloc < a->used + 1) { - if ((res = mp_grow (b, a->used + 1)) != MP_OKAY) { - return res; - } - } - - oldused = b->used; - b->used = a->used; - - { - register mp_digit r, rr, *tmpa, *tmpb; - - /* alias for source */ - tmpa = a->dp; - - /* alias for dest */ - tmpb = b->dp; - - /* carry */ - r = 0; - for (x = 0; x < a->used; x++) { - - /* get what will be the *next* carry bit from the - * MSB of the current digit - */ - rr = *tmpa >> ((mp_digit)(DIGIT_BIT - 1)); - - /* now shift up this digit, add in the carry [from the previous] */ - *tmpb++ = ((*tmpa++ << ((mp_digit)1)) | r) & MP_MASK; - - /* copy the carry that would be from the source - * digit into the next iteration - */ - r = rr; - } - - /* new leading digit? */ - if (r != 0) { - /* add a MSB which is always 1 at this point */ - *tmpb = 1; - ++(b->used); - } - - /* now zero any excess digits on the destination - * that we didn't write to - */ - tmpb = b->dp + b->used; - for (x = b->used; x < oldused; x++) { - *tmpb++ = 0; - } - } - b->sign = a->sign; - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_mul_2.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_mul_2d.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_mul_2d.c deleted file mode 100644 index c636c17..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_mul_2d.c +++ /dev/null @@ -1,85 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_MUL_2D_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* shift left by a certain bit count */ -int mp_mul_2d (mp_int * a, int b, mp_int * c) -{ - mp_digit d; - int res; - - /* copy */ - if (a != c) { - if ((res = mp_copy (a, c)) != MP_OKAY) { - return res; - } - } - - if (c->alloc < (int)(c->used + b/DIGIT_BIT + 1)) { - if ((res = mp_grow (c, c->used + b / DIGIT_BIT + 1)) != MP_OKAY) { - return res; - } - } - - /* shift by as many digits in the bit count */ - if (b >= (int)DIGIT_BIT) { - if ((res = mp_lshd (c, b / DIGIT_BIT)) != MP_OKAY) { - return res; - } - } - - /* shift any bit count < DIGIT_BIT */ - d = (mp_digit) (b % DIGIT_BIT); - if (d != 0) { - register mp_digit *tmpc, shift, mask, r, rr; - register int x; - - /* bitmask for carries */ - mask = (((mp_digit)1) << d) - 1; - - /* shift for msbs */ - shift = DIGIT_BIT - d; - - /* alias */ - tmpc = c->dp; - - /* carry */ - r = 0; - for (x = 0; x < c->used; x++) { - /* get the higher bits of the current word */ - rr = (*tmpc >> shift) & mask; - - /* shift the current word and OR in the carry */ - *tmpc = ((*tmpc << d) | r) & MP_MASK; - ++tmpc; - - /* set the carry to the carry bits of the current word */ - r = rr; - } - - /* set final carry */ - if (r != 0) { - c->dp[(c->used)++] = r; - } - } - mp_clamp (c); - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_mul_2d.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_mul_d.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_mul_d.c deleted file mode 100644 index a36a76b..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_mul_d.c +++ /dev/null @@ -1,79 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_MUL_D_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* multiply by a digit */ -int -mp_mul_d (mp_int * a, mp_digit b, mp_int * c) -{ - mp_digit u, *tmpa, *tmpc; - mp_word r; - int ix, res, olduse; - - /* make sure c is big enough to hold a*b */ - if (c->alloc < a->used + 1) { - if ((res = mp_grow (c, a->used + 1)) != MP_OKAY) { - return res; - } - } - - /* get the original destinations used count */ - olduse = c->used; - - /* set the sign */ - c->sign = a->sign; - - /* alias for a->dp [source] */ - tmpa = a->dp; - - /* alias for c->dp [dest] */ - tmpc = c->dp; - - /* zero carry */ - u = 0; - - /* compute columns */ - for (ix = 0; ix < a->used; ix++) { - /* compute product and carry sum for this term */ - r = ((mp_word) u) + ((mp_word)*tmpa++) * ((mp_word)b); - - /* mask off higher bits to get a single digit */ - *tmpc++ = (mp_digit) (r & ((mp_word) MP_MASK)); - - /* send carry into next iteration */ - u = (mp_digit) (r >> ((mp_word) DIGIT_BIT)); - } - - /* store final carry [if any] and increment ix offset */ - *tmpc++ = u; - ++ix; - - /* now zero digits above the top */ - while (ix++ < olduse) { - *tmpc++ = 0; - } - - /* set used count */ - c->used = a->used + 1; - mp_clamp(c); - - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_mul_d.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_mulmod.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_mulmod.c deleted file mode 100644 index 8ec98bb..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_mulmod.c +++ /dev/null @@ -1,40 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_MULMOD_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* d = a * b (mod c) */ -int mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d) -{ - int res; - mp_int t; - - if ((res = mp_init (&t)) != MP_OKAY) { - return res; - } - - if ((res = mp_mul (a, b, &t)) != MP_OKAY) { - mp_clear (&t); - return res; - } - res = mp_mod (&t, c, d); - mp_clear (&t); - return res; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_mulmod.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_n_root.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_n_root.c deleted file mode 100644 index f188f52..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_n_root.c +++ /dev/null @@ -1,132 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_N_ROOT_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* find the n'th root of an integer - * - * Result found such that (c)**b <= a and (c+1)**b > a - * - * This algorithm uses Newton's approximation - * x[i+1] = x[i] - f(x[i])/f'(x[i]) - * which will find the root in log(N) time where - * each step involves a fair bit. This is not meant to - * find huge roots [square and cube, etc]. - */ -int mp_n_root (mp_int * a, mp_digit b, mp_int * c) -{ - mp_int t1, t2, t3; - int res, neg; - - /* input must be positive if b is even */ - if ((b & 1) == 0 && a->sign == MP_NEG) { - return MP_VAL; - } - - if ((res = mp_init (&t1)) != MP_OKAY) { - return res; - } - - if ((res = mp_init (&t2)) != MP_OKAY) { - goto LBL_T1; - } - - if ((res = mp_init (&t3)) != MP_OKAY) { - goto LBL_T2; - } - - /* if a is negative fudge the sign but keep track */ - neg = a->sign; - a->sign = MP_ZPOS; - - /* t2 = 2 */ - mp_set (&t2, 2); - - do { - /* t1 = t2 */ - if ((res = mp_copy (&t2, &t1)) != MP_OKAY) { - goto LBL_T3; - } - - /* t2 = t1 - ((t1**b - a) / (b * t1**(b-1))) */ - - /* t3 = t1**(b-1) */ - if ((res = mp_expt_d (&t1, b - 1, &t3)) != MP_OKAY) { - goto LBL_T3; - } - - /* numerator */ - /* t2 = t1**b */ - if ((res = mp_mul (&t3, &t1, &t2)) != MP_OKAY) { - goto LBL_T3; - } - - /* t2 = t1**b - a */ - if ((res = mp_sub (&t2, a, &t2)) != MP_OKAY) { - goto LBL_T3; - } - - /* denominator */ - /* t3 = t1**(b-1) * b */ - if ((res = mp_mul_d (&t3, b, &t3)) != MP_OKAY) { - goto LBL_T3; - } - - /* t3 = (t1**b - a)/(b * t1**(b-1)) */ - if ((res = mp_div (&t2, &t3, &t3, NULL)) != MP_OKAY) { - goto LBL_T3; - } - - if ((res = mp_sub (&t1, &t3, &t2)) != MP_OKAY) { - goto LBL_T3; - } - } while (mp_cmp (&t1, &t2) != MP_EQ); - - /* result can be off by a few so check */ - for (;;) { - if ((res = mp_expt_d (&t1, b, &t2)) != MP_OKAY) { - goto LBL_T3; - } - - if (mp_cmp (&t2, a) == MP_GT) { - if ((res = mp_sub_d (&t1, 1, &t1)) != MP_OKAY) { - goto LBL_T3; - } - } else { - break; - } - } - - /* reset the sign of a first */ - a->sign = neg; - - /* set the result */ - mp_exch (&t1, c); - - /* set the sign of the result */ - c->sign = neg; - - res = MP_OKAY; - -LBL_T3:mp_clear (&t3); -LBL_T2:mp_clear (&t2); -LBL_T1:mp_clear (&t1); - return res; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_n_root.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_neg.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_neg.c deleted file mode 100644 index 87a8b50..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_neg.c +++ /dev/null @@ -1,40 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_NEG_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* b = -a */ -int mp_neg (mp_int * a, mp_int * b) -{ - int res; - if (a != b) { - if ((res = mp_copy (a, b)) != MP_OKAY) { - return res; - } - } - - if (mp_iszero(b) != MP_YES) { - b->sign = (a->sign == MP_ZPOS) ? MP_NEG : MP_ZPOS; - } else { - b->sign = MP_ZPOS; - } - - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_neg.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_or.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_or.c deleted file mode 100644 index 12601ea..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_or.c +++ /dev/null @@ -1,50 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_OR_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* OR two ints together */ -int mp_or (mp_int * a, mp_int * b, mp_int * c) -{ - int res, ix, px; - mp_int t, *x; - - if (a->used > b->used) { - if ((res = mp_init_copy (&t, a)) != MP_OKAY) { - return res; - } - px = b->used; - x = b; - } else { - if ((res = mp_init_copy (&t, b)) != MP_OKAY) { - return res; - } - px = a->used; - x = a; - } - - for (ix = 0; ix < px; ix++) { - t.dp[ix] |= x->dp[ix]; - } - mp_clamp (&t); - mp_exch (c, &t); - mp_clear (&t); - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_or.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_fermat.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_fermat.c deleted file mode 100644 index 297e13c..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_fermat.c +++ /dev/null @@ -1,62 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_PRIME_FERMAT_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* performs one Fermat test. - * - * If "a" were prime then b**a == b (mod a) since the order of - * the multiplicative sub-group would be phi(a) = a-1. That means - * it would be the same as b**(a mod (a-1)) == b**1 == b (mod a). - * - * Sets result to 1 if the congruence holds, or zero otherwise. - */ -int mp_prime_fermat (mp_int * a, mp_int * b, int *result) -{ - mp_int t; - int err; - - /* default to composite */ - *result = MP_NO; - - /* ensure b > 1 */ - if (mp_cmp_d(b, 1) != MP_GT) { - return MP_VAL; - } - - /* init t */ - if ((err = mp_init (&t)) != MP_OKAY) { - return err; - } - - /* compute t = b**a mod a */ - if ((err = mp_exptmod (b, a, a, &t)) != MP_OKAY) { - goto LBL_T; - } - - /* is it equal to b? */ - if (mp_cmp (&t, b) == MP_EQ) { - *result = MP_YES; - } - - err = MP_OKAY; -LBL_T:mp_clear (&t); - return err; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_prime_fermat.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_is_divisible.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_is_divisible.c deleted file mode 100644 index 0ae6498..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_is_divisible.c +++ /dev/null @@ -1,50 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_PRIME_IS_DIVISIBLE_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* determines if an integers is divisible by one - * of the first PRIME_SIZE primes or not - * - * sets result to 0 if not, 1 if yes - */ -int mp_prime_is_divisible (mp_int * a, int *result) -{ - int err, ix; - mp_digit res; - - /* default to not */ - *result = MP_NO; - - for (ix = 0; ix < PRIME_SIZE; ix++) { - /* what is a mod LBL_prime_tab[ix] */ - if ((err = mp_mod_d (a, ltm_prime_tab[ix], &res)) != MP_OKAY) { - return err; - } - - /* is the residue zero? */ - if (res == 0) { - *result = MP_YES; - return MP_OKAY; - } - } - - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_prime_is_divisible.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_is_prime.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_is_prime.c deleted file mode 100644 index 0e1e94b..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_is_prime.c +++ /dev/null @@ -1,83 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_PRIME_IS_PRIME_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* performs a variable number of rounds of Miller-Rabin - * - * Probability of error after t rounds is no more than - - * - * Sets result to 1 if probably prime, 0 otherwise - */ -int mp_prime_is_prime (mp_int * a, int t, int *result) -{ - mp_int b; - int ix, err, res; - - /* default to no */ - *result = MP_NO; - - /* valid value of t? */ - if (t <= 0 || t > PRIME_SIZE) { - return MP_VAL; - } - - /* is the input equal to one of the primes in the table? */ - for (ix = 0; ix < PRIME_SIZE; ix++) { - if (mp_cmp_d(a, ltm_prime_tab[ix]) == MP_EQ) { - *result = 1; - return MP_OKAY; - } - } - - /* first perform trial division */ - if ((err = mp_prime_is_divisible (a, &res)) != MP_OKAY) { - return err; - } - - /* return if it was trivially divisible */ - if (res == MP_YES) { - return MP_OKAY; - } - - /* now perform the miller-rabin rounds */ - if ((err = mp_init (&b)) != MP_OKAY) { - return err; - } - - for (ix = 0; ix < t; ix++) { - /* set the prime */ - mp_set (&b, ltm_prime_tab[ix]); - - if ((err = mp_prime_miller_rabin (a, &b, &res)) != MP_OKAY) { - goto LBL_B; - } - - if (res == MP_NO) { - goto LBL_B; - } - } - - /* passed the test */ - *result = MP_YES; -LBL_B:mp_clear (&b); - return err; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_prime_is_prime.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_miller_rabin.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_miller_rabin.c deleted file mode 100644 index 47385bc..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_miller_rabin.c +++ /dev/null @@ -1,103 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_PRIME_MILLER_RABIN_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* Miller-Rabin test of "a" to the base of "b" as described in - * HAC pp. 139 Algorithm 4.24 - * - * Sets result to 0 if definitely composite or 1 if probably prime. - * Randomly the chance of error is no more than 1/4 and often - * very much lower. - */ -int mp_prime_miller_rabin (mp_int * a, mp_int * b, int *result) -{ - mp_int n1, y, r; - int s, j, err; - - /* default */ - *result = MP_NO; - - /* ensure b > 1 */ - if (mp_cmp_d(b, 1) != MP_GT) { - return MP_VAL; - } - - /* get n1 = a - 1 */ - if ((err = mp_init_copy (&n1, a)) != MP_OKAY) { - return err; - } - if ((err = mp_sub_d (&n1, 1, &n1)) != MP_OKAY) { - goto LBL_N1; - } - - /* set 2**s * r = n1 */ - if ((err = mp_init_copy (&r, &n1)) != MP_OKAY) { - goto LBL_N1; - } - - /* count the number of least significant bits - * which are zero - */ - s = mp_cnt_lsb(&r); - - /* now divide n - 1 by 2**s */ - if ((err = mp_div_2d (&r, s, &r, NULL)) != MP_OKAY) { - goto LBL_R; - } - - /* compute y = b**r mod a */ - if ((err = mp_init (&y)) != MP_OKAY) { - goto LBL_R; - } - if ((err = mp_exptmod (b, &r, a, &y)) != MP_OKAY) { - goto LBL_Y; - } - - /* if y != 1 and y != n1 do */ - if (mp_cmp_d (&y, 1) != MP_EQ && mp_cmp (&y, &n1) != MP_EQ) { - j = 1; - /* while j <= s-1 and y != n1 */ - while ((j <= (s - 1)) && mp_cmp (&y, &n1) != MP_EQ) { - if ((err = mp_sqrmod (&y, a, &y)) != MP_OKAY) { - goto LBL_Y; - } - - /* if y == 1 then composite */ - if (mp_cmp_d (&y, 1) == MP_EQ) { - goto LBL_Y; - } - - ++j; - } - - /* if y != n1 then composite */ - if (mp_cmp (&y, &n1) != MP_EQ) { - goto LBL_Y; - } - } - - /* probably prime now */ - *result = MP_YES; -LBL_Y:mp_clear (&y); -LBL_R:mp_clear (&r); -LBL_N1:mp_clear (&n1); - return err; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_prime_miller_rabin.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_next_prime.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_next_prime.c deleted file mode 100644 index 833992b..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_next_prime.c +++ /dev/null @@ -1,170 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_PRIME_NEXT_PRIME_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* finds the next prime after the number "a" using "t" trials - * of Miller-Rabin. - * - * bbs_style = 1 means the prime must be congruent to 3 mod 4 - */ -int mp_prime_next_prime(mp_int *a, int t, int bbs_style) -{ - int err, res, x, y; - mp_digit res_tab[PRIME_SIZE], step, kstep; - mp_int b; - - /* ensure t is valid */ - if (t <= 0 || t > PRIME_SIZE) { - return MP_VAL; - } - - /* force positive */ - a->sign = MP_ZPOS; - - /* simple algo if a is less than the largest prime in the table */ - if (mp_cmp_d(a, ltm_prime_tab[PRIME_SIZE-1]) == MP_LT) { - /* find which prime it is bigger than */ - for (x = PRIME_SIZE - 2; x >= 0; x--) { - if (mp_cmp_d(a, ltm_prime_tab[x]) != MP_LT) { - if (bbs_style == 1) { - /* ok we found a prime smaller or - * equal [so the next is larger] - * - * however, the prime must be - * congruent to 3 mod 4 - */ - if ((ltm_prime_tab[x + 1] & 3) != 3) { - /* scan upwards for a prime congruent to 3 mod 4 */ - for (y = x + 1; y < PRIME_SIZE; y++) { - if ((ltm_prime_tab[y] & 3) == 3) { - mp_set(a, ltm_prime_tab[y]); - return MP_OKAY; - } - } - } - } else { - mp_set(a, ltm_prime_tab[x + 1]); - return MP_OKAY; - } - } - } - /* at this point a maybe 1 */ - if (mp_cmp_d(a, 1) == MP_EQ) { - mp_set(a, 2); - return MP_OKAY; - } - /* fall through to the sieve */ - } - - /* generate a prime congruent to 3 mod 4 or 1/3 mod 4? */ - if (bbs_style == 1) { - kstep = 4; - } else { - kstep = 2; - } - - /* at this point we will use a combination of a sieve and Miller-Rabin */ - - if (bbs_style == 1) { - /* if a mod 4 != 3 subtract the correct value to make it so */ - if ((a->dp[0] & 3) != 3) { - if ((err = mp_sub_d(a, (a->dp[0] & 3) + 1, a)) != MP_OKAY) { return err; }; - } - } else { - if (mp_iseven(a) == 1) { - /* force odd */ - if ((err = mp_sub_d(a, 1, a)) != MP_OKAY) { - return err; - } - } - } - - /* generate the restable */ - for (x = 1; x < PRIME_SIZE; x++) { - if ((err = mp_mod_d(a, ltm_prime_tab[x], res_tab + x)) != MP_OKAY) { - return err; - } - } - - /* init temp used for Miller-Rabin Testing */ - if ((err = mp_init(&b)) != MP_OKAY) { - return err; - } - - for (;;) { - /* skip to the next non-trivially divisible candidate */ - step = 0; - do { - /* y == 1 if any residue was zero [e.g. cannot be prime] */ - y = 0; - - /* increase step to next candidate */ - step += kstep; - - /* compute the new residue without using division */ - for (x = 1; x < PRIME_SIZE; x++) { - /* add the step to each residue */ - res_tab[x] += kstep; - - /* subtract the modulus [instead of using division] */ - if (res_tab[x] >= ltm_prime_tab[x]) { - res_tab[x] -= ltm_prime_tab[x]; - } - - /* set flag if zero */ - if (res_tab[x] == 0) { - y = 1; - } - } - } while (y == 1 && step < ((((mp_digit)1)<= ((((mp_digit)1)< size) { - return (x == 0) ? sizes[0].t : sizes[x - 1].t; - } - } - return sizes[x-1].t + 1; -} - - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_prime_rabin_miller_trials.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_random_ex.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_random_ex.c deleted file mode 100644 index 4eec3f6..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_prime_random_ex.c +++ /dev/null @@ -1,125 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_PRIME_RANDOM_EX_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* makes a truly random prime of a given size (bits), - * - * Flags are as follows: - * - * LTM_PRIME_BBS - make prime congruent to 3 mod 4 - * LTM_PRIME_SAFE - make sure (p-1)/2 is prime as well (implies LTM_PRIME_BBS) - * LTM_PRIME_2MSB_OFF - make the 2nd highest bit zero - * LTM_PRIME_2MSB_ON - make the 2nd highest bit one - * - * You have to supply a callback which fills in a buffer with random bytes. "dat" is a parameter you can - * have passed to the callback (e.g. a state or something). This function doesn't use "dat" itself - * so it can be NULL - * - */ - -/* This is possibly the mother of all prime generation functions, muahahahahaha! */ -int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback cb, void *dat) -{ - unsigned char *tmp, maskAND, maskOR_msb, maskOR_lsb; - int res, err, bsize, maskOR_msb_offset; - - /* sanity check the input */ - if (size <= 1 || t <= 0) { - return MP_VAL; - } - - /* LTM_PRIME_SAFE implies LTM_PRIME_BBS */ - if (flags & LTM_PRIME_SAFE) { - flags |= LTM_PRIME_BBS; - } - - /* calc the byte size */ - bsize = (size>>3) + ((size&7)?1:0); - - /* we need a buffer of bsize bytes */ - tmp = OPT_CAST(unsigned char) XMALLOC(bsize); - if (tmp == NULL) { - return MP_MEM; - } - - /* calc the maskAND value for the MSbyte*/ - maskAND = ((size&7) == 0) ? 0xFF : (0xFF >> (8 - (size & 7))); - - /* calc the maskOR_msb */ - maskOR_msb = 0; - maskOR_msb_offset = ((size & 7) == 1) ? 1 : 0; - if (flags & LTM_PRIME_2MSB_ON) { - maskOR_msb |= 0x80 >> ((9 - size) & 7); - } - - /* get the maskOR_lsb */ - maskOR_lsb = 1; - if (flags & LTM_PRIME_BBS) { - maskOR_lsb |= 3; - } - - do { - /* read the bytes */ - if (cb(tmp, bsize, dat) != bsize) { - err = MP_VAL; - goto error; - } - - /* work over the MSbyte */ - tmp[0] &= maskAND; - tmp[0] |= 1 << ((size - 1) & 7); - - /* mix in the maskORs */ - tmp[maskOR_msb_offset] |= maskOR_msb; - tmp[bsize-1] |= maskOR_lsb; - - /* read it in */ - if ((err = mp_read_unsigned_bin(a, tmp, bsize)) != MP_OKAY) { goto error; } - - /* is it prime? */ - if ((err = mp_prime_is_prime(a, t, &res)) != MP_OKAY) { goto error; } - if (res == MP_NO) { - continue; - } - - if (flags & LTM_PRIME_SAFE) { - /* see if (a-1)/2 is prime */ - if ((err = mp_sub_d(a, 1, a)) != MP_OKAY) { goto error; } - if ((err = mp_div_2(a, a)) != MP_OKAY) { goto error; } - - /* is it prime? */ - if ((err = mp_prime_is_prime(a, t, &res)) != MP_OKAY) { goto error; } - } - } while (res == MP_NO); - - if (flags & LTM_PRIME_SAFE) { - /* restore a to the original value */ - if ((err = mp_mul_2(a, a)) != MP_OKAY) { goto error; } - if ((err = mp_add_d(a, 1, a)) != MP_OKAY) { goto error; } - } - - err = MP_OKAY; -error: - XFREE(tmp); - return err; -} - - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_prime_random_ex.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_radix_size.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_radix_size.c deleted file mode 100644 index 2378f1f..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_radix_size.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_RADIX_SIZE_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* returns size of ASCII reprensentation */ -int mp_radix_size (mp_int * a, int radix, int *size) -{ - int res, digs; - mp_int t; - mp_digit d; - - *size = 0; - - /* special case for binary */ - if (radix == 2) { - *size = mp_count_bits (a) + (a->sign == MP_NEG ? 1 : 0) + 1; - return MP_OKAY; - } - - /* make sure the radix is in range */ - if (radix < 2 || radix > 64) { - return MP_VAL; - } - - if (mp_iszero(a) == MP_YES) { - *size = 2; - return MP_OKAY; - } - - /* digs is the digit count */ - digs = 0; - - /* if it's negative add one for the sign */ - if (a->sign == MP_NEG) { - ++digs; - } - - /* init a copy of the input */ - if ((res = mp_init_copy (&t, a)) != MP_OKAY) { - return res; - } - - /* force temp to positive */ - t.sign = MP_ZPOS; - - /* fetch out all of the digits */ - while (mp_iszero (&t) == MP_NO) { - if ((res = mp_div_d (&t, (mp_digit) radix, &t, &d)) != MP_OKAY) { - mp_clear (&t); - return res; - } - ++digs; - } - mp_clear (&t); - - /* return digs + 1, the 1 is for the NULL byte that would be required. */ - *size = digs + 1; - return MP_OKAY; -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_radix_size.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_radix_smap.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_radix_smap.c deleted file mode 100644 index 5cbe952..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_radix_smap.c +++ /dev/null @@ -1,24 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_RADIX_SMAP_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* chars used in radix conversions */ -const char *mp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/"; -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_radix_smap.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_rand.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_rand.c deleted file mode 100644 index e124178..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_rand.c +++ /dev/null @@ -1,55 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_RAND_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* makes a pseudo-random int of a given size */ -int -mp_rand (mp_int * a, int digits) -{ - int res; - mp_digit d; - - mp_zero (a); - if (digits <= 0) { - return MP_OKAY; - } - - /* first place a random non-zero digit */ - do { - d = ((mp_digit) abs (rand ())) & MP_MASK; - } while (d == 0); - - if ((res = mp_add_d (a, d, a)) != MP_OKAY) { - return res; - } - - while (--digits > 0) { - if ((res = mp_lshd (a, 1)) != MP_OKAY) { - return res; - } - - if ((res = mp_add_d (a, ((mp_digit) abs (rand ())), a)) != MP_OKAY) { - return res; - } - } - - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_rand.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_read_radix.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_read_radix.c deleted file mode 100644 index 6869668..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_read_radix.c +++ /dev/null @@ -1,85 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_READ_RADIX_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* read a string [ASCII] in a given radix */ -int mp_read_radix (mp_int * a, const char *str, int radix) -{ - int y, res, neg; - char ch; - - /* zero the digit bignum */ - mp_zero(a); - - /* make sure the radix is ok */ - if (radix < 2 || radix > 64) { - return MP_VAL; - } - - /* if the leading digit is a - * minus set the sign to negative. - */ - if (*str == '-') { - ++str; - neg = MP_NEG; - } else { - neg = MP_ZPOS; - } - - /* set the integer to the default of zero */ - mp_zero (a); - - /* process each digit of the string */ - while (*str) { - /* if the radix < 36 the conversion is case insensitive - * this allows numbers like 1AB and 1ab to represent the same value - * [e.g. in hex] - */ - ch = (char) ((radix < 36) ? toupper (*str) : *str); - for (y = 0; y < 64; y++) { - if (ch == mp_s_rmap[y]) { - break; - } - } - - /* if the char was found in the map - * and is less than the given radix add it - * to the number, otherwise exit the loop. - */ - if (y < radix) { - if ((res = mp_mul_d (a, (mp_digit) radix, a)) != MP_OKAY) { - return res; - } - if ((res = mp_add_d (a, (mp_digit) y, a)) != MP_OKAY) { - return res; - } - } else { - break; - } - ++str; - } - - /* set the sign only if a != 0 */ - if (mp_iszero(a) != 1) { - a->sign = neg; - } - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_read_radix.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_read_signed_bin.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_read_signed_bin.c deleted file mode 100644 index e9a780c..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_read_signed_bin.c +++ /dev/null @@ -1,41 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_READ_SIGNED_BIN_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* read signed bin, big endian, first byte is 0==positive or 1==negative */ -int mp_read_signed_bin (mp_int * a, const unsigned char *b, int c) -{ - int res; - - /* read magnitude */ - if ((res = mp_read_unsigned_bin (a, b + 1, c - 1)) != MP_OKAY) { - return res; - } - - /* first byte is 0 for positive, non-zero for negative */ - if (b[0] == 0) { - a->sign = MP_ZPOS; - } else { - a->sign = MP_NEG; - } - - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_read_signed_bin.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_read_unsigned_bin.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_read_unsigned_bin.c deleted file mode 100644 index 7d35370..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_read_unsigned_bin.c +++ /dev/null @@ -1,55 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_READ_UNSIGNED_BIN_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* reads a unsigned char array, assumes the msb is stored first [big endian] */ -int mp_read_unsigned_bin (mp_int * a, const unsigned char *b, int c) -{ - int res; - - /* make sure there are at least two digits */ - if (a->alloc < 2) { - if ((res = mp_grow(a, 2)) != MP_OKAY) { - return res; - } - } - - /* zero the int */ - mp_zero (a); - - /* read the bytes in */ - while (c-- > 0) { - if ((res = mp_mul_2d (a, 8, a)) != MP_OKAY) { - return res; - } - -#ifndef MP_8BIT - a->dp[0] |= *b++; - a->used += 1; -#else - a->dp[0] = (*b & MP_MASK); - a->dp[1] |= ((*b++ >> 7U) & 1); - a->used += 2; -#endif - } - mp_clamp (a); - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_read_unsigned_bin.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce.c deleted file mode 100644 index 3a6bb5a..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce.c +++ /dev/null @@ -1,100 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_REDUCE_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* reduces x mod m, assumes 0 < x < m**2, mu is - * precomputed via mp_reduce_setup. - * From HAC pp.604 Algorithm 14.42 - */ -int mp_reduce (mp_int * x, mp_int * m, mp_int * mu) -{ - mp_int q; - int res, um = m->used; - - /* q = x */ - if ((res = mp_init_copy (&q, x)) != MP_OKAY) { - return res; - } - - /* q1 = x / b**(k-1) */ - mp_rshd (&q, um - 1); - - /* according to HAC this optimization is ok */ - if (((unsigned long) um) > (((mp_digit)1) << (DIGIT_BIT - 1))) { - if ((res = mp_mul (&q, mu, &q)) != MP_OKAY) { - goto CLEANUP; - } - } else { -#ifdef BN_S_MP_MUL_HIGH_DIGS_C - if ((res = s_mp_mul_high_digs (&q, mu, &q, um)) != MP_OKAY) { - goto CLEANUP; - } -#elif defined(BN_FAST_S_MP_MUL_HIGH_DIGS_C) - if ((res = fast_s_mp_mul_high_digs (&q, mu, &q, um)) != MP_OKAY) { - goto CLEANUP; - } -#else - { - res = MP_VAL; - goto CLEANUP; - } -#endif - } - - /* q3 = q2 / b**(k+1) */ - mp_rshd (&q, um + 1); - - /* x = x mod b**(k+1), quick (no division) */ - if ((res = mp_mod_2d (x, DIGIT_BIT * (um + 1), x)) != MP_OKAY) { - goto CLEANUP; - } - - /* q = q * m mod b**(k+1), quick (no division) */ - if ((res = s_mp_mul_digs (&q, m, &q, um + 1)) != MP_OKAY) { - goto CLEANUP; - } - - /* x = x - q */ - if ((res = mp_sub (x, &q, x)) != MP_OKAY) { - goto CLEANUP; - } - - /* If x < 0, add b**(k+1) to it */ - if (mp_cmp_d (x, 0) == MP_LT) { - mp_set (&q, 1); - if ((res = mp_lshd (&q, um + 1)) != MP_OKAY) - goto CLEANUP; - if ((res = mp_add (x, &q, x)) != MP_OKAY) - goto CLEANUP; - } - - /* Back off if it's too big */ - while (mp_cmp (x, m) != MP_LT) { - if ((res = s_mp_sub (x, m, x)) != MP_OKAY) { - goto CLEANUP; - } - } - -CLEANUP: - mp_clear (&q); - - return res; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_reduce.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_2k.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_2k.c deleted file mode 100644 index 3191d82..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_2k.c +++ /dev/null @@ -1,61 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_REDUCE_2K_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* reduces a modulo n where n is of the form 2**p - d */ -int mp_reduce_2k(mp_int *a, mp_int *n, mp_digit d) -{ - mp_int q; - int p, res; - - if ((res = mp_init(&q)) != MP_OKAY) { - return res; - } - - p = mp_count_bits(n); -top: - /* q = a/2**p, a = a mod 2**p */ - if ((res = mp_div_2d(a, p, &q, a)) != MP_OKAY) { - goto ERR; - } - - if (d != 1) { - /* q = q * d */ - if ((res = mp_mul_d(&q, d, &q)) != MP_OKAY) { - goto ERR; - } - } - - /* a = a + q */ - if ((res = s_mp_add(a, &q, a)) != MP_OKAY) { - goto ERR; - } - - if (mp_cmp_mag(a, n) != MP_LT) { - s_mp_sub(a, n, a); - goto top; - } - -ERR: - mp_clear(&q); - return res; -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_2k.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_2k_l.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_2k_l.c deleted file mode 100644 index 49b7e34..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_2k_l.c +++ /dev/null @@ -1,62 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_REDUCE_2K_L_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* reduces a modulo n where n is of the form 2**p - d - This differs from reduce_2k since "d" can be larger - than a single digit. -*/ -int mp_reduce_2k_l(mp_int *a, mp_int *n, mp_int *d) -{ - mp_int q; - int p, res; - - if ((res = mp_init(&q)) != MP_OKAY) { - return res; - } - - p = mp_count_bits(n); -top: - /* q = a/2**p, a = a mod 2**p */ - if ((res = mp_div_2d(a, p, &q, a)) != MP_OKAY) { - goto ERR; - } - - /* q = q * d */ - if ((res = mp_mul(&q, d, &q)) != MP_OKAY) { - goto ERR; - } - - /* a = a + q */ - if ((res = s_mp_add(a, &q, a)) != MP_OKAY) { - goto ERR; - } - - if (mp_cmp_mag(a, n) != MP_LT) { - s_mp_sub(a, n, a); - goto top; - } - -ERR: - mp_clear(&q); - return res; -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_2k_l.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_2k_setup.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_2k_setup.c deleted file mode 100644 index aa3b3ba..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_2k_setup.c +++ /dev/null @@ -1,47 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_REDUCE_2K_SETUP_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* determines the setup value */ -int mp_reduce_2k_setup(mp_int *a, mp_digit *d) -{ - int res, p; - mp_int tmp; - - if ((res = mp_init(&tmp)) != MP_OKAY) { - return res; - } - - p = mp_count_bits(a); - if ((res = mp_2expt(&tmp, p)) != MP_OKAY) { - mp_clear(&tmp); - return res; - } - - if ((res = s_mp_sub(&tmp, a, &tmp)) != MP_OKAY) { - mp_clear(&tmp); - return res; - } - - *d = tmp.dp[0]; - mp_clear(&tmp); - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_2k_setup.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_2k_setup_l.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_2k_setup_l.c deleted file mode 100644 index 4eca870..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_2k_setup_l.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_REDUCE_2K_SETUP_L_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* determines the setup value */ -int mp_reduce_2k_setup_l(mp_int *a, mp_int *d) -{ - int res; - mp_int tmp; - - if ((res = mp_init(&tmp)) != MP_OKAY) { - return res; - } - - if ((res = mp_2expt(&tmp, mp_count_bits(a))) != MP_OKAY) { - goto ERR; - } - - if ((res = s_mp_sub(&tmp, a, d)) != MP_OKAY) { - goto ERR; - } - -ERR: - mp_clear(&tmp); - return res; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_2k_setup_l.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_is_2k.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_is_2k.c deleted file mode 100644 index b9ede97..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_is_2k.c +++ /dev/null @@ -1,52 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_REDUCE_IS_2K_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* determines if mp_reduce_2k can be used */ -int mp_reduce_is_2k(mp_int *a) -{ - int ix, iy, iw; - mp_digit iz; - - if (a->used == 0) { - return MP_NO; - } else if (a->used == 1) { - return MP_YES; - } else if (a->used > 1) { - iy = mp_count_bits(a); - iz = 1; - iw = 1; - - /* Test every bit from the second digit up, must be 1 */ - for (ix = DIGIT_BIT; ix < iy; ix++) { - if ((a->dp[iw] & iz) == 0) { - return MP_NO; - } - iz <<= 1; - if (iz > (mp_digit)MP_MASK) { - ++iw; - iz = 1; - } - } - } - return MP_YES; -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_is_2k.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_is_2k_l.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_is_2k_l.c deleted file mode 100644 index 787875f..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_is_2k_l.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_REDUCE_IS_2K_L_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* determines if reduce_2k_l can be used */ -int mp_reduce_is_2k_l(mp_int *a) -{ - int ix, iy; - - if (a->used == 0) { - return MP_NO; - } else if (a->used == 1) { - return MP_YES; - } else if (a->used > 1) { - /* if more than half of the digits are -1 we're sold */ - for (iy = ix = 0; ix < a->used; ix++) { - if (a->dp[ix] == MP_MASK) { - ++iy; - } - } - return (iy >= (a->used/2)) ? MP_YES : MP_NO; - - } - return MP_NO; -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_is_2k_l.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_setup.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_setup.c deleted file mode 100644 index 00e0a62..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_reduce_setup.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_REDUCE_SETUP_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* pre-calculate the value required for Barrett reduction - * For a given modulus "b" it calulates the value required in "a" - */ -int mp_reduce_setup (mp_int * a, mp_int * b) -{ - int res; - - if ((res = mp_2expt (a, b->used * 2 * DIGIT_BIT)) != MP_OKAY) { - return res; - } - return mp_div (a, b, a, NULL); -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_reduce_setup.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_rshd.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_rshd.c deleted file mode 100644 index eac6721..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_rshd.c +++ /dev/null @@ -1,72 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_RSHD_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* shift right a certain amount of digits */ -void mp_rshd (mp_int * a, int b) -{ - int x; - - /* if b <= 0 then ignore it */ - if (b <= 0) { - return; - } - - /* if b > used then simply zero it and return */ - if (a->used <= b) { - mp_zero (a); - return; - } - - { - register mp_digit *bottom, *top; - - /* shift the digits down */ - - /* bottom */ - bottom = a->dp; - - /* top [offset into digits] */ - top = a->dp + b; - - /* this is implemented as a sliding window where - * the window is b-digits long and digits from - * the top of the window are copied to the bottom - * - * e.g. - - b-2 | b-1 | b0 | b1 | b2 | ... | bb | ----> - /\ | ----> - \-------------------/ ----> - */ - for (x = 0; x < (a->used - b); x++) { - *bottom++ = *top++; - } - - /* zero the top digits */ - for (; x < a->used; x++) { - *bottom++ = 0; - } - } - - /* remove excess digits */ - a->used -= b; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_rshd.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_set.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_set.c deleted file mode 100644 index d76d5bb..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_set.c +++ /dev/null @@ -1,29 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_SET_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* set to a digit */ -void mp_set (mp_int * a, mp_digit b) -{ - mp_zero (a); - a->dp[0] = b & MP_MASK; - a->used = (a->dp[0] != 0) ? 1 : 0; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_set.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_set_int.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_set_int.c deleted file mode 100644 index 68cf0e3..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_set_int.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_SET_INT_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* set a 32-bit const */ -int mp_set_int (mp_int * a, unsigned long b) -{ - int x, res; - - mp_zero (a); - - /* set four bits at a time */ - for (x = 0; x < 8; x++) { - /* shift the number up four bits */ - if ((res = mp_mul_2d (a, 4, a)) != MP_OKAY) { - return res; - } - - /* OR in the top four bits of the source */ - a->dp[0] |= (b >> 28) & 15; - - /* shift the source up to the next four bits */ - b <<= 4; - - /* ensure that digits are not clamped off */ - a->used += 1; - } - mp_clamp (a); - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_set_int.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_shrink.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_shrink.c deleted file mode 100644 index 54920d1..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_shrink.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_SHRINK_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* shrink a bignum */ -int mp_shrink (mp_int * a) -{ - mp_digit *tmp; - if (a->alloc != a->used && a->used > 0) { - if ((tmp = OPT_CAST(mp_digit) XREALLOC (a->dp, sizeof (mp_digit) * a->used)) == NULL) { - return MP_MEM; - } - a->dp = tmp; - a->alloc = a->used; - } - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_shrink.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_signed_bin_size.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_signed_bin_size.c deleted file mode 100644 index b9492a5..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_signed_bin_size.c +++ /dev/null @@ -1,27 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_SIGNED_BIN_SIZE_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* get the size for an signed equivalent */ -int mp_signed_bin_size (mp_int * a) -{ - return 1 + mp_unsigned_bin_size (a); -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_signed_bin_size.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_sqr.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_sqr.c deleted file mode 100644 index c10fa6f..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_sqr.c +++ /dev/null @@ -1,58 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_SQR_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* computes b = a*a */ -int -mp_sqr (mp_int * a, mp_int * b) -{ - int res; - -#ifdef BN_MP_TOOM_SQR_C - /* use Toom-Cook? */ - if (a->used >= TOOM_SQR_CUTOFF) { - res = mp_toom_sqr(a, b); - /* Karatsuba? */ - } else -#endif -#ifdef BN_MP_KARATSUBA_SQR_C -if (a->used >= KARATSUBA_SQR_CUTOFF) { - res = mp_karatsuba_sqr (a, b); - } else -#endif - { -#ifdef BN_FAST_S_MP_SQR_C - /* can we use the fast comba multiplier? */ - if ((a->used * 2 + 1) < MP_WARRAY && - a->used < - (1 << (sizeof(mp_word) * CHAR_BIT - 2*DIGIT_BIT - 1))) { - res = fast_s_mp_sqr (a, b); - } else -#endif -#ifdef BN_S_MP_SQR_C - res = s_mp_sqr (a, b); -#else - res = MP_VAL; -#endif - } - b->sign = MP_ZPOS; - return res; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_sqr.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_sqrmod.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_sqrmod.c deleted file mode 100644 index 5f4b2f3..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_sqrmod.c +++ /dev/null @@ -1,41 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_SQRMOD_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* c = a * a (mod b) */ -int -mp_sqrmod (mp_int * a, mp_int * b, mp_int * c) -{ - int res; - mp_int t; - - if ((res = mp_init (&t)) != MP_OKAY) { - return res; - } - - if ((res = mp_sqr (a, &t)) != MP_OKAY) { - mp_clear (&t); - return res; - } - res = mp_mod (&t, b, c); - mp_clear (&t); - return res; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_sqrmod.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_sqrt.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_sqrt.c deleted file mode 100644 index e15ba98..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_sqrt.c +++ /dev/null @@ -1,81 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_SQRT_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* this function is less generic than mp_n_root, simpler and faster */ -int mp_sqrt(mp_int *arg, mp_int *ret) -{ - int res; - mp_int t1,t2; - - /* must be positive */ - if (arg->sign == MP_NEG) { - return MP_VAL; - } - - /* easy out */ - if (mp_iszero(arg) == MP_YES) { - mp_zero(ret); - return MP_OKAY; - } - - if ((res = mp_init_copy(&t1, arg)) != MP_OKAY) { - return res; - } - - if ((res = mp_init(&t2)) != MP_OKAY) { - goto E2; - } - - /* First approx. (not very bad for large arg) */ - mp_rshd (&t1,t1.used/2); - - /* t1 > 0 */ - if ((res = mp_div(arg,&t1,&t2,NULL)) != MP_OKAY) { - goto E1; - } - if ((res = mp_add(&t1,&t2,&t1)) != MP_OKAY) { - goto E1; - } - if ((res = mp_div_2(&t1,&t1)) != MP_OKAY) { - goto E1; - } - /* And now t1 > sqrt(arg) */ - do { - if ((res = mp_div(arg,&t1,&t2,NULL)) != MP_OKAY) { - goto E1; - } - if ((res = mp_add(&t1,&t2,&t1)) != MP_OKAY) { - goto E1; - } - if ((res = mp_div_2(&t1,&t1)) != MP_OKAY) { - goto E1; - } - /* t1 >= sqrt(arg) >= t2 at this point */ - } while (mp_cmp_mag(&t1,&t2) == MP_GT); - - mp_exch(&t1,ret); - -E1: mp_clear(&t2); -E2: mp_clear(&t1); - return res; -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_sqrt.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_sub.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_sub.c deleted file mode 100644 index 6e72138..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_sub.c +++ /dev/null @@ -1,59 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_SUB_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* high level subtraction (handles signs) */ -int -mp_sub (mp_int * a, mp_int * b, mp_int * c) -{ - int sa, sb, res; - - sa = a->sign; - sb = b->sign; - - if (sa != sb) { - /* subtract a negative from a positive, OR */ - /* subtract a positive from a negative. */ - /* In either case, ADD their magnitudes, */ - /* and use the sign of the first number. */ - c->sign = sa; - res = s_mp_add (a, b, c); - } else { - /* subtract a positive from a positive, OR */ - /* subtract a negative from a negative. */ - /* First, take the difference between their */ - /* magnitudes, then... */ - if (mp_cmp_mag (a, b) != MP_LT) { - /* Copy the sign from the first */ - c->sign = sa; - /* The first has a larger or equal magnitude */ - res = s_mp_sub (a, b, c); - } else { - /* The result has the *opposite* sign from */ - /* the first number. */ - c->sign = (sa == MP_ZPOS) ? MP_NEG : MP_ZPOS; - /* The second has a larger magnitude */ - res = s_mp_sub (b, a, c); - } - } - return res; -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_sub.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_sub_d.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_sub_d.c deleted file mode 100644 index aa08e31..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_sub_d.c +++ /dev/null @@ -1,93 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_SUB_D_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* single digit subtraction */ -int -mp_sub_d (mp_int * a, mp_digit b, mp_int * c) -{ - mp_digit *tmpa, *tmpc, mu; - int res, ix, oldused; - - /* grow c as required */ - if (c->alloc < a->used + 1) { - if ((res = mp_grow(c, a->used + 1)) != MP_OKAY) { - return res; - } - } - - /* if a is negative just do an unsigned - * addition [with fudged signs] - */ - if (a->sign == MP_NEG) { - a->sign = MP_ZPOS; - res = mp_add_d(a, b, c); - a->sign = c->sign = MP_NEG; - - /* clamp */ - mp_clamp(c); - - return res; - } - - /* setup regs */ - oldused = c->used; - tmpa = a->dp; - tmpc = c->dp; - - /* if a <= b simply fix the single digit */ - if ((a->used == 1 && a->dp[0] <= b) || a->used == 0) { - if (a->used == 1) { - *tmpc++ = b - *tmpa; - } else { - *tmpc++ = b; - } - ix = 1; - - /* negative/1digit */ - c->sign = MP_NEG; - c->used = 1; - } else { - /* positive/size */ - c->sign = MP_ZPOS; - c->used = a->used; - - /* subtract first digit */ - *tmpc = *tmpa++ - b; - mu = *tmpc >> (sizeof(mp_digit) * CHAR_BIT - 1); - *tmpc++ &= MP_MASK; - - /* handle rest of the digits */ - for (ix = 1; ix < a->used; ix++) { - *tmpc = *tmpa++ - mu; - mu = *tmpc >> (sizeof(mp_digit) * CHAR_BIT - 1); - *tmpc++ &= MP_MASK; - } - } - - /* zero excess digits */ - while (ix++ < oldused) { - *tmpc++ = 0; - } - mp_clamp(c); - return MP_OKAY; -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_sub_d.c,v $ */ -/* $Revision: 1.6 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_submod.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_submod.c deleted file mode 100644 index 6617ff4..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_submod.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_SUBMOD_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* d = a - b (mod c) */ -int -mp_submod (mp_int * a, mp_int * b, mp_int * c, mp_int * d) -{ - int res; - mp_int t; - - - if ((res = mp_init (&t)) != MP_OKAY) { - return res; - } - - if ((res = mp_sub (a, b, &t)) != MP_OKAY) { - mp_clear (&t); - return res; - } - res = mp_mod (&t, c, d); - mp_clear (&t); - return res; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_submod.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_to_signed_bin.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_to_signed_bin.c deleted file mode 100644 index 154f64b..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_to_signed_bin.c +++ /dev/null @@ -1,33 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_TO_SIGNED_BIN_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* store in signed [big endian] format */ -int mp_to_signed_bin (mp_int * a, unsigned char *b) -{ - int res; - - if ((res = mp_to_unsigned_bin (a, b + 1)) != MP_OKAY) { - return res; - } - b[0] = (unsigned char) ((a->sign == MP_ZPOS) ? 0 : 1); - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_to_signed_bin.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_to_signed_bin_n.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_to_signed_bin_n.c deleted file mode 100644 index e119c38..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_to_signed_bin_n.c +++ /dev/null @@ -1,31 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_TO_SIGNED_BIN_N_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* store in signed [big endian] format */ -int mp_to_signed_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen) -{ - if (*outlen < (unsigned long)mp_signed_bin_size(a)) { - return MP_VAL; - } - *outlen = mp_signed_bin_size(a); - return mp_to_signed_bin(a, b); -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_to_signed_bin_n.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_to_unsigned_bin.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_to_unsigned_bin.c deleted file mode 100644 index ce69e5b..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_to_unsigned_bin.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_TO_UNSIGNED_BIN_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* store in unsigned [big endian] format */ -int mp_to_unsigned_bin (mp_int * a, unsigned char *b) -{ - int x, res; - mp_int t; - - if ((res = mp_init_copy (&t, a)) != MP_OKAY) { - return res; - } - - x = 0; - while (mp_iszero (&t) == 0) { -#ifndef MP_8BIT - b[x++] = (unsigned char) (t.dp[0] & 255); -#else - b[x++] = (unsigned char) (t.dp[0] | ((t.dp[1] & 0x01) << 7)); -#endif - if ((res = mp_div_2d (&t, 8, &t, NULL)) != MP_OKAY) { - mp_clear (&t); - return res; - } - } - bn_reverse (b, x); - mp_clear (&t); - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_to_unsigned_bin.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_to_unsigned_bin_n.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_to_unsigned_bin_n.c deleted file mode 100644 index dfa27c4..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_to_unsigned_bin_n.c +++ /dev/null @@ -1,31 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_TO_UNSIGNED_BIN_N_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* store in unsigned [big endian] format */ -int mp_to_unsigned_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen) -{ - if (*outlen < (unsigned long)mp_unsigned_bin_size(a)) { - return MP_VAL; - } - *outlen = mp_unsigned_bin_size(a); - return mp_to_unsigned_bin(a, b); -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_to_unsigned_bin_n.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_toom_mul.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_toom_mul.c deleted file mode 100644 index e48c6b3..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_toom_mul.c +++ /dev/null @@ -1,284 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_TOOM_MUL_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* multiplication using the Toom-Cook 3-way algorithm - * - * Much more complicated than Karatsuba but has a lower - * asymptotic running time of O(N**1.464). This algorithm is - * only particularly useful on VERY large inputs - * (we're talking 1000s of digits here...). -*/ -int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c) -{ - mp_int w0, w1, w2, w3, w4, tmp1, tmp2, a0, a1, a2, b0, b1, b2; - int res, B; - - /* init temps */ - if ((res = mp_init_multi(&w0, &w1, &w2, &w3, &w4, - &a0, &a1, &a2, &b0, &b1, - &b2, &tmp1, &tmp2, NULL)) != MP_OKAY) { - return res; - } - - /* B */ - B = MIN(a->used, b->used) / 3; - - /* a = a2 * B**2 + a1 * B + a0 */ - if ((res = mp_mod_2d(a, DIGIT_BIT * B, &a0)) != MP_OKAY) { - goto ERR; - } - - if ((res = mp_copy(a, &a1)) != MP_OKAY) { - goto ERR; - } - mp_rshd(&a1, B); - mp_mod_2d(&a1, DIGIT_BIT * B, &a1); - - if ((res = mp_copy(a, &a2)) != MP_OKAY) { - goto ERR; - } - mp_rshd(&a2, B*2); - - /* b = b2 * B**2 + b1 * B + b0 */ - if ((res = mp_mod_2d(b, DIGIT_BIT * B, &b0)) != MP_OKAY) { - goto ERR; - } - - if ((res = mp_copy(b, &b1)) != MP_OKAY) { - goto ERR; - } - mp_rshd(&b1, B); - mp_mod_2d(&b1, DIGIT_BIT * B, &b1); - - if ((res = mp_copy(b, &b2)) != MP_OKAY) { - goto ERR; - } - mp_rshd(&b2, B*2); - - /* w0 = a0*b0 */ - if ((res = mp_mul(&a0, &b0, &w0)) != MP_OKAY) { - goto ERR; - } - - /* w4 = a2 * b2 */ - if ((res = mp_mul(&a2, &b2, &w4)) != MP_OKAY) { - goto ERR; - } - - /* w1 = (a2 + 2(a1 + 2a0))(b2 + 2(b1 + 2b0)) */ - if ((res = mp_mul_2(&a0, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_add(&tmp1, &a2, &tmp1)) != MP_OKAY) { - goto ERR; - } - - if ((res = mp_mul_2(&b0, &tmp2)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_add(&tmp2, &b1, &tmp2)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_mul_2(&tmp2, &tmp2)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_add(&tmp2, &b2, &tmp2)) != MP_OKAY) { - goto ERR; - } - - if ((res = mp_mul(&tmp1, &tmp2, &w1)) != MP_OKAY) { - goto ERR; - } - - /* w3 = (a0 + 2(a1 + 2a2))(b0 + 2(b1 + 2b2)) */ - if ((res = mp_mul_2(&a2, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) { - goto ERR; - } - - if ((res = mp_mul_2(&b2, &tmp2)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_add(&tmp2, &b1, &tmp2)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_mul_2(&tmp2, &tmp2)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_add(&tmp2, &b0, &tmp2)) != MP_OKAY) { - goto ERR; - } - - if ((res = mp_mul(&tmp1, &tmp2, &w3)) != MP_OKAY) { - goto ERR; - } - - - /* w2 = (a2 + a1 + a0)(b2 + b1 + b0) */ - if ((res = mp_add(&a2, &a1, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_add(&b2, &b1, &tmp2)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_add(&tmp2, &b0, &tmp2)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_mul(&tmp1, &tmp2, &w2)) != MP_OKAY) { - goto ERR; - } - - /* now solve the matrix - - 0 0 0 0 1 - 1 2 4 8 16 - 1 1 1 1 1 - 16 8 4 2 1 - 1 0 0 0 0 - - using 12 subtractions, 4 shifts, - 2 small divisions and 1 small multiplication - */ - - /* r1 - r4 */ - if ((res = mp_sub(&w1, &w4, &w1)) != MP_OKAY) { - goto ERR; - } - /* r3 - r0 */ - if ((res = mp_sub(&w3, &w0, &w3)) != MP_OKAY) { - goto ERR; - } - /* r1/2 */ - if ((res = mp_div_2(&w1, &w1)) != MP_OKAY) { - goto ERR; - } - /* r3/2 */ - if ((res = mp_div_2(&w3, &w3)) != MP_OKAY) { - goto ERR; - } - /* r2 - r0 - r4 */ - if ((res = mp_sub(&w2, &w0, &w2)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_sub(&w2, &w4, &w2)) != MP_OKAY) { - goto ERR; - } - /* r1 - r2 */ - if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) { - goto ERR; - } - /* r3 - r2 */ - if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) { - goto ERR; - } - /* r1 - 8r0 */ - if ((res = mp_mul_2d(&w0, 3, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_sub(&w1, &tmp1, &w1)) != MP_OKAY) { - goto ERR; - } - /* r3 - 8r4 */ - if ((res = mp_mul_2d(&w4, 3, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_sub(&w3, &tmp1, &w3)) != MP_OKAY) { - goto ERR; - } - /* 3r2 - r1 - r3 */ - if ((res = mp_mul_d(&w2, 3, &w2)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_sub(&w2, &w3, &w2)) != MP_OKAY) { - goto ERR; - } - /* r1 - r2 */ - if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) { - goto ERR; - } - /* r3 - r2 */ - if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) { - goto ERR; - } - /* r1/3 */ - if ((res = mp_div_3(&w1, &w1, NULL)) != MP_OKAY) { - goto ERR; - } - /* r3/3 */ - if ((res = mp_div_3(&w3, &w3, NULL)) != MP_OKAY) { - goto ERR; - } - - /* at this point shift W[n] by B*n */ - if ((res = mp_lshd(&w1, 1*B)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_lshd(&w2, 2*B)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_lshd(&w3, 3*B)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_lshd(&w4, 4*B)) != MP_OKAY) { - goto ERR; - } - - if ((res = mp_add(&w0, &w1, c)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_add(&w2, &w3, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_add(&w4, &tmp1, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_add(&tmp1, c, c)) != MP_OKAY) { - goto ERR; - } - -ERR: - mp_clear_multi(&w0, &w1, &w2, &w3, &w4, - &a0, &a1, &a2, &b0, &b1, - &b2, &tmp1, &tmp2, NULL); - return res; -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_toom_mul.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_toom_sqr.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_toom_sqr.c deleted file mode 100644 index fd8bc67..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_toom_sqr.c +++ /dev/null @@ -1,226 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_TOOM_SQR_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* squaring using Toom-Cook 3-way algorithm */ -int -mp_toom_sqr(mp_int *a, mp_int *b) -{ - mp_int w0, w1, w2, w3, w4, tmp1, a0, a1, a2; - int res, B; - - /* init temps */ - if ((res = mp_init_multi(&w0, &w1, &w2, &w3, &w4, &a0, &a1, &a2, &tmp1, NULL)) != MP_OKAY) { - return res; - } - - /* B */ - B = a->used / 3; - - /* a = a2 * B**2 + a1 * B + a0 */ - if ((res = mp_mod_2d(a, DIGIT_BIT * B, &a0)) != MP_OKAY) { - goto ERR; - } - - if ((res = mp_copy(a, &a1)) != MP_OKAY) { - goto ERR; - } - mp_rshd(&a1, B); - mp_mod_2d(&a1, DIGIT_BIT * B, &a1); - - if ((res = mp_copy(a, &a2)) != MP_OKAY) { - goto ERR; - } - mp_rshd(&a2, B*2); - - /* w0 = a0*a0 */ - if ((res = mp_sqr(&a0, &w0)) != MP_OKAY) { - goto ERR; - } - - /* w4 = a2 * a2 */ - if ((res = mp_sqr(&a2, &w4)) != MP_OKAY) { - goto ERR; - } - - /* w1 = (a2 + 2(a1 + 2a0))**2 */ - if ((res = mp_mul_2(&a0, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_add(&tmp1, &a2, &tmp1)) != MP_OKAY) { - goto ERR; - } - - if ((res = mp_sqr(&tmp1, &w1)) != MP_OKAY) { - goto ERR; - } - - /* w3 = (a0 + 2(a1 + 2a2))**2 */ - if ((res = mp_mul_2(&a2, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) { - goto ERR; - } - - if ((res = mp_sqr(&tmp1, &w3)) != MP_OKAY) { - goto ERR; - } - - - /* w2 = (a2 + a1 + a0)**2 */ - if ((res = mp_add(&a2, &a1, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_sqr(&tmp1, &w2)) != MP_OKAY) { - goto ERR; - } - - /* now solve the matrix - - 0 0 0 0 1 - 1 2 4 8 16 - 1 1 1 1 1 - 16 8 4 2 1 - 1 0 0 0 0 - - using 12 subtractions, 4 shifts, 2 small divisions and 1 small multiplication. - */ - - /* r1 - r4 */ - if ((res = mp_sub(&w1, &w4, &w1)) != MP_OKAY) { - goto ERR; - } - /* r3 - r0 */ - if ((res = mp_sub(&w3, &w0, &w3)) != MP_OKAY) { - goto ERR; - } - /* r1/2 */ - if ((res = mp_div_2(&w1, &w1)) != MP_OKAY) { - goto ERR; - } - /* r3/2 */ - if ((res = mp_div_2(&w3, &w3)) != MP_OKAY) { - goto ERR; - } - /* r2 - r0 - r4 */ - if ((res = mp_sub(&w2, &w0, &w2)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_sub(&w2, &w4, &w2)) != MP_OKAY) { - goto ERR; - } - /* r1 - r2 */ - if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) { - goto ERR; - } - /* r3 - r2 */ - if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) { - goto ERR; - } - /* r1 - 8r0 */ - if ((res = mp_mul_2d(&w0, 3, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_sub(&w1, &tmp1, &w1)) != MP_OKAY) { - goto ERR; - } - /* r3 - 8r4 */ - if ((res = mp_mul_2d(&w4, 3, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_sub(&w3, &tmp1, &w3)) != MP_OKAY) { - goto ERR; - } - /* 3r2 - r1 - r3 */ - if ((res = mp_mul_d(&w2, 3, &w2)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_sub(&w2, &w3, &w2)) != MP_OKAY) { - goto ERR; - } - /* r1 - r2 */ - if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) { - goto ERR; - } - /* r3 - r2 */ - if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) { - goto ERR; - } - /* r1/3 */ - if ((res = mp_div_3(&w1, &w1, NULL)) != MP_OKAY) { - goto ERR; - } - /* r3/3 */ - if ((res = mp_div_3(&w3, &w3, NULL)) != MP_OKAY) { - goto ERR; - } - - /* at this point shift W[n] by B*n */ - if ((res = mp_lshd(&w1, 1*B)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_lshd(&w2, 2*B)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_lshd(&w3, 3*B)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_lshd(&w4, 4*B)) != MP_OKAY) { - goto ERR; - } - - if ((res = mp_add(&w0, &w1, b)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_add(&w2, &w3, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_add(&w4, &tmp1, &tmp1)) != MP_OKAY) { - goto ERR; - } - if ((res = mp_add(&tmp1, b, b)) != MP_OKAY) { - goto ERR; - } - -ERR: - mp_clear_multi(&w0, &w1, &w2, &w3, &w4, &a0, &a1, &a2, &tmp1, NULL); - return res; -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_toom_sqr.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_toradix.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_toradix.c deleted file mode 100644 index 539abe9..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_toradix.c +++ /dev/null @@ -1,75 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_TORADIX_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* stores a bignum as a ASCII string in a given radix (2..64) */ -int mp_toradix (mp_int * a, char *str, int radix) -{ - int res, digs; - mp_int t; - mp_digit d; - char *_s = str; - - /* check range of the radix */ - if (radix < 2 || radix > 64) { - return MP_VAL; - } - - /* quick out if its zero */ - if (mp_iszero(a) == 1) { - *str++ = '0'; - *str = '\0'; - return MP_OKAY; - } - - if ((res = mp_init_copy (&t, a)) != MP_OKAY) { - return res; - } - - /* if it is negative output a - */ - if (t.sign == MP_NEG) { - ++_s; - *str++ = '-'; - t.sign = MP_ZPOS; - } - - digs = 0; - while (mp_iszero (&t) == 0) { - if ((res = mp_div_d (&t, (mp_digit) radix, &t, &d)) != MP_OKAY) { - mp_clear (&t); - return res; - } - *str++ = mp_s_rmap[d]; - ++digs; - } - - /* reverse the digits of the string. In this case _s points - * to the first digit [exluding the sign] of the number] - */ - bn_reverse ((unsigned char *)_s, digs); - - /* append a NULL so the string is properly terminated */ - *str = '\0'; - - mp_clear (&t); - return MP_OKAY; -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_toradix.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_toradix_n.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_toradix_n.c deleted file mode 100644 index 0322f8d..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_toradix_n.c +++ /dev/null @@ -1,88 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_TORADIX_N_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* stores a bignum as a ASCII string in a given radix (2..64) - * - * Stores upto maxlen-1 chars and always a NULL byte - */ -int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen) -{ - int res, digs; - mp_int t; - mp_digit d; - char *_s = str; - - /* check range of the maxlen, radix */ - if (maxlen < 2 || radix < 2 || radix > 64) { - return MP_VAL; - } - - /* quick out if its zero */ - if (mp_iszero(a) == MP_YES) { - *str++ = '0'; - *str = '\0'; - return MP_OKAY; - } - - if ((res = mp_init_copy (&t, a)) != MP_OKAY) { - return res; - } - - /* if it is negative output a - */ - if (t.sign == MP_NEG) { - /* we have to reverse our digits later... but not the - sign!! */ - ++_s; - - /* store the flag and mark the number as positive */ - *str++ = '-'; - t.sign = MP_ZPOS; - - /* subtract a char */ - --maxlen; - } - - digs = 0; - while (mp_iszero (&t) == 0) { - if (--maxlen < 1) { - /* no more room */ - break; - } - if ((res = mp_div_d (&t, (mp_digit) radix, &t, &d)) != MP_OKAY) { - mp_clear (&t); - return res; - } - *str++ = mp_s_rmap[d]; - ++digs; - } - - /* reverse the digits of the string. In this case _s points - * to the first digit [exluding the sign] of the number - */ - bn_reverse ((unsigned char *)_s, digs); - - /* append a NULL so the string is properly terminated */ - *str = '\0'; - - mp_clear (&t); - return MP_OKAY; -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_toradix_n.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_unsigned_bin_size.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_unsigned_bin_size.c deleted file mode 100644 index 88f3e92..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_unsigned_bin_size.c +++ /dev/null @@ -1,28 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_UNSIGNED_BIN_SIZE_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* get the size for an unsigned equivalent */ -int mp_unsigned_bin_size (mp_int * a) -{ - int size = mp_count_bits (a); - return (size / 8 + ((size & 7) != 0 ? 1 : 0)); -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_unsigned_bin_size.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_xor.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_xor.c deleted file mode 100644 index bf0446e..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_xor.c +++ /dev/null @@ -1,51 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_XOR_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* XOR two ints together */ -int -mp_xor (mp_int * a, mp_int * b, mp_int * c) -{ - int res, ix, px; - mp_int t, *x; - - if (a->used > b->used) { - if ((res = mp_init_copy (&t, a)) != MP_OKAY) { - return res; - } - px = b->used; - x = b; - } else { - if ((res = mp_init_copy (&t, b)) != MP_OKAY) { - return res; - } - px = a->used; - x = a; - } - - for (ix = 0; ix < px; ix++) { - t.dp[ix] ^= x->dp[ix]; - } - mp_clamp (&t); - mp_exch (c, &t); - mp_clear (&t); - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_xor.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_mp_zero.c b/libs/storm-sys/StormLib/src/libtommath/bn_mp_zero.c deleted file mode 100644 index f21db5e..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_mp_zero.c +++ /dev/null @@ -1,36 +0,0 @@ -#include "tommath.h" -#ifdef BN_MP_ZERO_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* set to zero */ -void mp_zero (mp_int * a) -{ - int n; - mp_digit *tmp; - - a->sign = MP_ZPOS; - a->used = 0; - - tmp = a->dp; - for (n = 0; n < a->alloc; n++) { - *tmp++ = 0; - } -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_mp_zero.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_prime_tab.c b/libs/storm-sys/StormLib/src/libtommath/bn_prime_tab.c deleted file mode 100644 index 7d306dd..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_prime_tab.c +++ /dev/null @@ -1,61 +0,0 @@ -#include "tommath.h" -#ifdef BN_PRIME_TAB_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -const mp_digit ltm_prime_tab[] = { - 0x0002, 0x0003, 0x0005, 0x0007, 0x000B, 0x000D, 0x0011, 0x0013, - 0x0017, 0x001D, 0x001F, 0x0025, 0x0029, 0x002B, 0x002F, 0x0035, - 0x003B, 0x003D, 0x0043, 0x0047, 0x0049, 0x004F, 0x0053, 0x0059, - 0x0061, 0x0065, 0x0067, 0x006B, 0x006D, 0x0071, 0x007F, -#ifndef MP_8BIT - 0x0083, - 0x0089, 0x008B, 0x0095, 0x0097, 0x009D, 0x00A3, 0x00A7, 0x00AD, - 0x00B3, 0x00B5, 0x00BF, 0x00C1, 0x00C5, 0x00C7, 0x00D3, 0x00DF, - 0x00E3, 0x00E5, 0x00E9, 0x00EF, 0x00F1, 0x00FB, 0x0101, 0x0107, - 0x010D, 0x010F, 0x0115, 0x0119, 0x011B, 0x0125, 0x0133, 0x0137, - - 0x0139, 0x013D, 0x014B, 0x0151, 0x015B, 0x015D, 0x0161, 0x0167, - 0x016F, 0x0175, 0x017B, 0x017F, 0x0185, 0x018D, 0x0191, 0x0199, - 0x01A3, 0x01A5, 0x01AF, 0x01B1, 0x01B7, 0x01BB, 0x01C1, 0x01C9, - 0x01CD, 0x01CF, 0x01D3, 0x01DF, 0x01E7, 0x01EB, 0x01F3, 0x01F7, - 0x01FD, 0x0209, 0x020B, 0x021D, 0x0223, 0x022D, 0x0233, 0x0239, - 0x023B, 0x0241, 0x024B, 0x0251, 0x0257, 0x0259, 0x025F, 0x0265, - 0x0269, 0x026B, 0x0277, 0x0281, 0x0283, 0x0287, 0x028D, 0x0293, - 0x0295, 0x02A1, 0x02A5, 0x02AB, 0x02B3, 0x02BD, 0x02C5, 0x02CF, - - 0x02D7, 0x02DD, 0x02E3, 0x02E7, 0x02EF, 0x02F5, 0x02F9, 0x0301, - 0x0305, 0x0313, 0x031D, 0x0329, 0x032B, 0x0335, 0x0337, 0x033B, - 0x033D, 0x0347, 0x0355, 0x0359, 0x035B, 0x035F, 0x036D, 0x0371, - 0x0373, 0x0377, 0x038B, 0x038F, 0x0397, 0x03A1, 0x03A9, 0x03AD, - 0x03B3, 0x03B9, 0x03C7, 0x03CB, 0x03D1, 0x03D7, 0x03DF, 0x03E5, - 0x03F1, 0x03F5, 0x03FB, 0x03FD, 0x0407, 0x0409, 0x040F, 0x0419, - 0x041B, 0x0425, 0x0427, 0x042D, 0x043F, 0x0443, 0x0445, 0x0449, - 0x044F, 0x0455, 0x045D, 0x0463, 0x0469, 0x047F, 0x0481, 0x048B, - - 0x0493, 0x049D, 0x04A3, 0x04A9, 0x04B1, 0x04BD, 0x04C1, 0x04C7, - 0x04CD, 0x04CF, 0x04D5, 0x04E1, 0x04EB, 0x04FD, 0x04FF, 0x0503, - 0x0509, 0x050B, 0x0511, 0x0515, 0x0517, 0x051B, 0x0527, 0x0529, - 0x052F, 0x0551, 0x0557, 0x055D, 0x0565, 0x0577, 0x0581, 0x058F, - 0x0593, 0x0595, 0x0599, 0x059F, 0x05A7, 0x05AB, 0x05AD, 0x05B3, - 0x05BF, 0x05C9, 0x05CB, 0x05CF, 0x05D1, 0x05D5, 0x05DB, 0x05E7, - 0x05F3, 0x05FB, 0x0607, 0x060D, 0x0611, 0x0617, 0x061F, 0x0623, - 0x062B, 0x062F, 0x063D, 0x0641, 0x0647, 0x0649, 0x064D, 0x0653 -#endif -}; -#endif - -/* $Source: /cvs/libtom/libtommath/bn_prime_tab.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_reverse.c b/libs/storm-sys/StormLib/src/libtommath/bn_reverse.c deleted file mode 100644 index d4a919a..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_reverse.c +++ /dev/null @@ -1,39 +0,0 @@ -#include "tommath.h" -#ifdef BN_REVERSE_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* reverse an array, used for radix code */ -void -bn_reverse (unsigned char *s, int len) -{ - int ix, iy; - unsigned char t; - - ix = 0; - iy = len - 1; - while (ix < iy) { - t = s[ix]; - s[ix] = s[iy]; - s[iy] = t; - ++ix; - --iy; - } -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_reverse.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_s_mp_add.c b/libs/storm-sys/StormLib/src/libtommath/bn_s_mp_add.c deleted file mode 100644 index 5ea9c6d..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_s_mp_add.c +++ /dev/null @@ -1,109 +0,0 @@ -#include "tommath.h" -#ifdef BN_S_MP_ADD_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* low level addition, based on HAC pp.594, Algorithm 14.7 */ -int -s_mp_add (mp_int * a, mp_int * b, mp_int * c) -{ - mp_int *x; - int olduse, res, min, max; - - /* find sizes, we let |a| <= |b| which means we have to sort - * them. "x" will point to the input with the most digits - */ - if (a->used > b->used) { - min = b->used; - max = a->used; - x = a; - } else { - min = a->used; - max = b->used; - x = b; - } - - /* init result */ - if (c->alloc < max + 1) { - if ((res = mp_grow (c, max + 1)) != MP_OKAY) { - return res; - } - } - - /* get old used digit count and set new one */ - olduse = c->used; - c->used = max + 1; - - { - register mp_digit u, *tmpa, *tmpb, *tmpc; - register int i; - - /* alias for digit pointers */ - - /* first input */ - tmpa = a->dp; - - /* second input */ - tmpb = b->dp; - - /* destination */ - tmpc = c->dp; - - /* zero the carry */ - u = 0; - for (i = 0; i < min; i++) { - /* Compute the sum at one digit, T[i] = A[i] + B[i] + U */ - *tmpc = *tmpa++ + *tmpb++ + u; - - /* U = carry bit of T[i] */ - u = *tmpc >> ((mp_digit)DIGIT_BIT); - - /* take away carry bit from T[i] */ - *tmpc++ &= MP_MASK; - } - - /* now copy higher words if any, that is in A+B - * if A or B has more digits add those in - */ - if (min != max) { - for (; i < max; i++) { - /* T[i] = X[i] + U */ - *tmpc = x->dp[i] + u; - - /* U = carry bit of T[i] */ - u = *tmpc >> ((mp_digit)DIGIT_BIT); - - /* take away carry bit from T[i] */ - *tmpc++ &= MP_MASK; - } - } - - /* add carry */ - *tmpc++ = u; - - /* clear digits above oldused */ - for (i = c->used; i < olduse; i++) { - *tmpc++ = 0; - } - } - - mp_clamp (c); - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_s_mp_add.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_s_mp_exptmod.c b/libs/storm-sys/StormLib/src/libtommath/bn_s_mp_exptmod.c deleted file mode 100644 index 9fb2da8..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_s_mp_exptmod.c +++ /dev/null @@ -1,252 +0,0 @@ -#include "tommath.h" -#ifdef BN_S_MP_EXPTMOD_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ -#ifdef MP_LOW_MEM - #define TAB_SIZE 32 -#else - #define TAB_SIZE 256 -#endif - -int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode) -{ - mp_int M[TAB_SIZE], res, mu; - mp_digit buf; - int err, bitbuf, bitcpy, bitcnt, mode, digidx, x, y, winsize; - int (*redux)(mp_int*,mp_int*,mp_int*); - - /* find window size */ - x = mp_count_bits (X); - if (x <= 7) { - winsize = 2; - } else if (x <= 36) { - winsize = 3; - } else if (x <= 140) { - winsize = 4; - } else if (x <= 450) { - winsize = 5; - } else if (x <= 1303) { - winsize = 6; - } else if (x <= 3529) { - winsize = 7; - } else { - winsize = 8; - } - -#ifdef MP_LOW_MEM - if (winsize > 5) { - winsize = 5; - } -#endif - - /* init M array */ - /* init first cell */ - if ((err = mp_init(&M[1])) != MP_OKAY) { - return err; - } - - /* now init the second half of the array */ - for (x = 1<<(winsize-1); x < (1 << winsize); x++) { - if ((err = mp_init(&M[x])) != MP_OKAY) { - for (y = 1<<(winsize-1); y < x; y++) { - mp_clear (&M[y]); - } - mp_clear(&M[1]); - return err; - } - } - - /* create mu, used for Barrett reduction */ - if ((err = mp_init (&mu)) != MP_OKAY) { - goto LBL_M; - } - - if (redmode == 0) { - if ((err = mp_reduce_setup (&mu, P)) != MP_OKAY) { - goto LBL_MU; - } - redux = mp_reduce; - } else { - if ((err = mp_reduce_2k_setup_l (P, &mu)) != MP_OKAY) { - goto LBL_MU; - } - redux = mp_reduce_2k_l; - } - - /* create M table - * - * The M table contains powers of the base, - * e.g. M[x] = G**x mod P - * - * The first half of the table is not - * computed though accept for M[0] and M[1] - */ - if ((err = mp_mod (G, P, &M[1])) != MP_OKAY) { - goto LBL_MU; - } - - /* compute the value at M[1<<(winsize-1)] by squaring - * M[1] (winsize-1) times - */ - if ((err = mp_copy (&M[1], &M[1 << (winsize - 1)])) != MP_OKAY) { - goto LBL_MU; - } - - for (x = 0; x < (winsize - 1); x++) { - /* square it */ - if ((err = mp_sqr (&M[1 << (winsize - 1)], - &M[1 << (winsize - 1)])) != MP_OKAY) { - goto LBL_MU; - } - - /* reduce modulo P */ - if ((err = redux (&M[1 << (winsize - 1)], P, &mu)) != MP_OKAY) { - goto LBL_MU; - } - } - - /* create upper table, that is M[x] = M[x-1] * M[1] (mod P) - * for x = (2**(winsize - 1) + 1) to (2**winsize - 1) - */ - for (x = (1 << (winsize - 1)) + 1; x < (1 << winsize); x++) { - if ((err = mp_mul (&M[x - 1], &M[1], &M[x])) != MP_OKAY) { - goto LBL_MU; - } - if ((err = redux (&M[x], P, &mu)) != MP_OKAY) { - goto LBL_MU; - } - } - - /* setup result */ - if ((err = mp_init (&res)) != MP_OKAY) { - goto LBL_MU; - } - mp_set (&res, 1); - - /* set initial mode and bit cnt */ - mode = 0; - bitcnt = 1; - buf = 0; - digidx = X->used - 1; - bitcpy = 0; - bitbuf = 0; - - for (;;) { - /* grab next digit as required */ - if (--bitcnt == 0) { - /* if digidx == -1 we are out of digits */ - if (digidx == -1) { - break; - } - /* read next digit and reset the bitcnt */ - buf = X->dp[digidx--]; - bitcnt = (int) DIGIT_BIT; - } - - /* grab the next msb from the exponent */ - y = (buf >> (mp_digit)(DIGIT_BIT - 1)) & 1; - buf <<= (mp_digit)1; - - /* if the bit is zero and mode == 0 then we ignore it - * These represent the leading zero bits before the first 1 bit - * in the exponent. Technically this opt is not required but it - * does lower the # of trivial squaring/reductions used - */ - if (mode == 0 && y == 0) { - continue; - } - - /* if the bit is zero and mode == 1 then we square */ - if (mode == 1 && y == 0) { - if ((err = mp_sqr (&res, &res)) != MP_OKAY) { - goto LBL_RES; - } - if ((err = redux (&res, P, &mu)) != MP_OKAY) { - goto LBL_RES; - } - continue; - } - - /* else we add it to the window */ - bitbuf |= (y << (winsize - ++bitcpy)); - mode = 2; - - if (bitcpy == winsize) { - /* ok window is filled so square as required and multiply */ - /* square first */ - for (x = 0; x < winsize; x++) { - if ((err = mp_sqr (&res, &res)) != MP_OKAY) { - goto LBL_RES; - } - if ((err = redux (&res, P, &mu)) != MP_OKAY) { - goto LBL_RES; - } - } - - /* then multiply */ - if ((err = mp_mul (&res, &M[bitbuf], &res)) != MP_OKAY) { - goto LBL_RES; - } - if ((err = redux (&res, P, &mu)) != MP_OKAY) { - goto LBL_RES; - } - - /* empty window and reset */ - bitcpy = 0; - bitbuf = 0; - mode = 1; - } - } - - /* if bits remain then square/multiply */ - if (mode == 2 && bitcpy > 0) { - /* square then multiply if the bit is set */ - for (x = 0; x < bitcpy; x++) { - if ((err = mp_sqr (&res, &res)) != MP_OKAY) { - goto LBL_RES; - } - if ((err = redux (&res, P, &mu)) != MP_OKAY) { - goto LBL_RES; - } - - bitbuf <<= 1; - if ((bitbuf & (1 << winsize)) != 0) { - /* then multiply */ - if ((err = mp_mul (&res, &M[1], &res)) != MP_OKAY) { - goto LBL_RES; - } - if ((err = redux (&res, P, &mu)) != MP_OKAY) { - goto LBL_RES; - } - } - } - } - - mp_exch (&res, Y); - err = MP_OKAY; -LBL_RES:mp_clear (&res); -LBL_MU:mp_clear (&mu); -LBL_M: - mp_clear(&M[1]); - for (x = 1<<(winsize-1); x < (1 << winsize); x++) { - mp_clear (&M[x]); - } - return err; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_s_mp_exptmod.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_s_mp_mul_digs.c b/libs/storm-sys/StormLib/src/libtommath/bn_s_mp_mul_digs.c deleted file mode 100644 index f04dacf..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_s_mp_mul_digs.c +++ /dev/null @@ -1,90 +0,0 @@ -#include "tommath.h" -#ifdef BN_S_MP_MUL_DIGS_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* multiplies |a| * |b| and only computes upto digs digits of result - * HAC pp. 595, Algorithm 14.12 Modified so you can control how - * many digits of output are created. - */ -int s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs) -{ - mp_int t; - int res, pa, pb, ix, iy; - mp_digit u; - mp_word r; - mp_digit tmpx, *tmpt, *tmpy; - - /* can we use the fast multiplier? */ - if (((digs) < MP_WARRAY) && - MIN (a->used, b->used) < - (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) { - return fast_s_mp_mul_digs (a, b, c, digs); - } - - if ((res = mp_init_size (&t, digs)) != MP_OKAY) { - return res; - } - t.used = digs; - - /* compute the digits of the product directly */ - pa = a->used; - for (ix = 0; ix < pa; ix++) { - /* set the carry to zero */ - u = 0; - - /* limit ourselves to making digs digits of output */ - pb = MIN (b->used, digs - ix); - - /* setup some aliases */ - /* copy of the digit from a used within the nested loop */ - tmpx = a->dp[ix]; - - /* an alias for the destination shifted ix places */ - tmpt = t.dp + ix; - - /* an alias for the digits of b */ - tmpy = b->dp; - - /* compute the columns of the output and propagate the carry */ - for (iy = 0; iy < pb; iy++) { - /* compute the column as a mp_word */ - r = ((mp_word)*tmpt) + - ((mp_word)tmpx) * ((mp_word)*tmpy++) + - ((mp_word) u); - - /* the new column is the lower part of the result */ - *tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK)); - - /* get the carry word from the result */ - u = (mp_digit) (r >> ((mp_word) DIGIT_BIT)); - } - /* set carry if it is placed below digs */ - if (ix + iy < digs) { - *tmpt = u; - } - } - - mp_clamp (&t); - mp_exch (&t, c); - - mp_clear (&t); - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_s_mp_mul_digs.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_s_mp_mul_high_digs.c b/libs/storm-sys/StormLib/src/libtommath/bn_s_mp_mul_high_digs.c deleted file mode 100644 index b1d0199..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_s_mp_mul_high_digs.c +++ /dev/null @@ -1,81 +0,0 @@ -#include "tommath.h" -#ifdef BN_S_MP_MUL_HIGH_DIGS_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* multiplies |a| * |b| and does not compute the lower digs digits - * [meant to get the higher part of the product] - */ -int -s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs) -{ - mp_int t; - int res, pa, pb, ix, iy; - mp_digit u; - mp_word r; - mp_digit tmpx, *tmpt, *tmpy; - - /* can we use the fast multiplier? */ -#ifdef BN_FAST_S_MP_MUL_HIGH_DIGS_C - if (((a->used + b->used + 1) < MP_WARRAY) - && MIN (a->used, b->used) < (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) { - return fast_s_mp_mul_high_digs (a, b, c, digs); - } -#endif - - if ((res = mp_init_size (&t, a->used + b->used + 1)) != MP_OKAY) { - return res; - } - t.used = a->used + b->used + 1; - - pa = a->used; - pb = b->used; - for (ix = 0; ix < pa; ix++) { - /* clear the carry */ - u = 0; - - /* left hand side of A[ix] * B[iy] */ - tmpx = a->dp[ix]; - - /* alias to the address of where the digits will be stored */ - tmpt = &(t.dp[digs]); - - /* alias for where to read the right hand side from */ - tmpy = b->dp + (digs - ix); - - for (iy = digs - ix; iy < pb; iy++) { - /* calculate the double precision result */ - r = ((mp_word)*tmpt) + - ((mp_word)tmpx) * ((mp_word)*tmpy++) + - ((mp_word) u); - - /* get the lower part */ - *tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK)); - - /* carry the carry */ - u = (mp_digit) (r >> ((mp_word) DIGIT_BIT)); - } - *tmpt = u; - } - mp_clamp (&t); - mp_exch (&t, c); - mp_clear (&t); - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_s_mp_mul_high_digs.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_s_mp_sqr.c b/libs/storm-sys/StormLib/src/libtommath/bn_s_mp_sqr.c deleted file mode 100644 index c1e994e..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_s_mp_sqr.c +++ /dev/null @@ -1,84 +0,0 @@ -#include "tommath.h" -#ifdef BN_S_MP_SQR_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* low level squaring, b = a*a, HAC pp.596-597, Algorithm 14.16 */ -int s_mp_sqr (mp_int * a, mp_int * b) -{ - mp_int t; - int res, ix, iy, pa; - mp_word r; - mp_digit u, tmpx, *tmpt; - - pa = a->used; - if ((res = mp_init_size (&t, 2*pa + 1)) != MP_OKAY) { - return res; - } - - /* default used is maximum possible size */ - t.used = 2*pa + 1; - - for (ix = 0; ix < pa; ix++) { - /* first calculate the digit at 2*ix */ - /* calculate double precision result */ - r = ((mp_word) t.dp[2*ix]) + - ((mp_word)a->dp[ix])*((mp_word)a->dp[ix]); - - /* store lower part in result */ - t.dp[ix+ix] = (mp_digit) (r & ((mp_word) MP_MASK)); - - /* get the carry */ - u = (mp_digit)(r >> ((mp_word) DIGIT_BIT)); - - /* left hand side of A[ix] * A[iy] */ - tmpx = a->dp[ix]; - - /* alias for where to store the results */ - tmpt = t.dp + (2*ix + 1); - - for (iy = ix + 1; iy < pa; iy++) { - /* first calculate the product */ - r = ((mp_word)tmpx) * ((mp_word)a->dp[iy]); - - /* now calculate the double precision result, note we use - * addition instead of *2 since it's easier to optimize - */ - r = ((mp_word) *tmpt) + r + r + ((mp_word) u); - - /* store lower part */ - *tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK)); - - /* get carry */ - u = (mp_digit)(r >> ((mp_word) DIGIT_BIT)); - } - /* propagate upwards */ - while (u != ((mp_digit) 0)) { - r = ((mp_word) *tmpt) + ((mp_word) u); - *tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK)); - u = (mp_digit)(r >> ((mp_word) DIGIT_BIT)); - } - } - - mp_clamp (&t); - mp_exch (&t, b); - mp_clear (&t); - return MP_OKAY; -} -#endif - -/* $Source: /cvs/libtom/libtommath/bn_s_mp_sqr.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bn_s_mp_sub.c b/libs/storm-sys/StormLib/src/libtommath/bn_s_mp_sub.c deleted file mode 100644 index 0ae91cc..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bn_s_mp_sub.c +++ /dev/null @@ -1,89 +0,0 @@ -#include "tommath.h" -#ifdef BN_S_MP_SUB_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* low level subtraction (assumes |a| > |b|), HAC pp.595 Algorithm 14.9 */ -int -s_mp_sub (mp_int * a, mp_int * b, mp_int * c) -{ - int olduse, res, min, max; - - /* find sizes */ - min = b->used; - max = a->used; - - /* init result */ - if (c->alloc < max) { - if ((res = mp_grow (c, max)) != MP_OKAY) { - return res; - } - } - olduse = c->used; - c->used = max; - - { - register mp_digit u, *tmpa, *tmpb, *tmpc; - register int i; - - /* alias for digit pointers */ - tmpa = a->dp; - tmpb = b->dp; - tmpc = c->dp; - - /* set carry to zero */ - u = 0; - for (i = 0; i < min; i++) { - /* T[i] = A[i] - B[i] - U */ - *tmpc = *tmpa++ - *tmpb++ - u; - - /* U = carry bit of T[i] - * Note this saves performing an AND operation since - * if a carry does occur it will propagate all the way to the - * MSB. As a result a single shift is enough to get the carry - */ - u = *tmpc >> ((mp_digit)(CHAR_BIT * sizeof (mp_digit) - 1)); - - /* Clear carry from T[i] */ - *tmpc++ &= MP_MASK; - } - - /* now copy higher words if any, e.g. if A has more digits than B */ - for (; i < max; i++) { - /* T[i] = A[i] - U */ - *tmpc = *tmpa++ - u; - - /* U = carry bit of T[i] */ - u = *tmpc >> ((mp_digit)(CHAR_BIT * sizeof (mp_digit) - 1)); - - /* Clear carry from T[i] */ - *tmpc++ &= MP_MASK; - } - - /* clear digits above used (since we may not have grown result above) */ - for (i = c->used; i < olduse; i++) { - *tmpc++ = 0; - } - } - - mp_clamp (c); - return MP_OKAY; -} - -#endif - -/* $Source: /cvs/libtom/libtommath/bn_s_mp_sub.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/bncore.c b/libs/storm-sys/StormLib/src/libtommath/bncore.c deleted file mode 100644 index ad7347f..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/bncore.c +++ /dev/null @@ -1,36 +0,0 @@ -#include "tommath.h" -#ifdef BNCORE_C -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -/* Known optimal configurations - - CPU /Compiler /MUL CUTOFF/SQR CUTOFF -------------------------------------------------------------- - Intel P4 Northwood /GCC v3.4.1 / 88/ 128/LTM 0.32 ;-) - AMD Athlon64 /GCC v3.4.4 / 80/ 120/LTM 0.35 - -*/ - -int KARATSUBA_MUL_CUTOFF = 80, /* Min. number of digits before Karatsuba multiplication is used. */ - KARATSUBA_SQR_CUTOFF = 120, /* Min. number of digits before Karatsuba squaring is used. */ - - TOOM_MUL_CUTOFF = 350, /* no optimal values of these are known yet so set em high */ - TOOM_SQR_CUTOFF = 400; -#endif - -/* $Source: /cvs/libtom/libtommath/bncore.c,v $ */ -/* $Revision: 1.5 $ */ -/* $Date: 2006/12/28 01:25:13 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/tommath.h b/libs/storm-sys/StormLib/src/libtommath/tommath.h deleted file mode 100644 index 1ead3d0..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/tommath.h +++ /dev/null @@ -1,584 +0,0 @@ -/* LibTomMath, multiple-precision integer library -- Tom St Denis - * - * LibTomMath is a library that provides multiple-precision - * integer arithmetic as well as number theoretic functionality. - * - * The library was designed directly after the MPI library by - * Michael Fromberger but has been written from scratch with - * additional optimizations in place. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com - */ -#ifndef BN_H_ -#define BN_H_ - -#include -#include -#include -#include -#include - -#include "tommath_class.h" - -#ifndef MIN - #define MIN(x,y) ((x)<(y)?(x):(y)) -#endif - -#ifndef MAX - #define MAX(x,y) ((x)>(y)?(x):(y)) -#endif - -#ifdef __cplusplus -extern "C" { - -/* C++ compilers don't like assigning void * to mp_digit * */ -#define OPT_CAST(x) (x *) - -#else - -/* C on the other hand doesn't care */ -#define OPT_CAST(x) - -#endif - - -/* detect 64-bit mode if possible */ -#if defined(__x86_64__) - #if !(defined(MP_64BIT) && defined(MP_16BIT) && defined(MP_8BIT)) - #define MP_64BIT - #endif -#endif - -/* some default configurations. - * - * A "mp_digit" must be able to hold DIGIT_BIT + 1 bits - * A "mp_word" must be able to hold 2*DIGIT_BIT + 1 bits - * - * At the very least a mp_digit must be able to hold 7 bits - * [any size beyond that is ok provided it doesn't overflow the data type] - */ -#ifdef MP_8BIT - typedef unsigned char mp_digit; - typedef unsigned short mp_word; -#elif defined(MP_16BIT) - typedef unsigned short mp_digit; - typedef unsigned long mp_word; -#elif defined(MP_64BIT) - /* for GCC only on supported platforms */ -#ifndef CRYPT - typedef unsigned long long ulong64; - typedef signed long long long64; -#endif - - typedef unsigned long mp_digit; - typedef unsigned long mp_word __attribute__ ((mode(TI))); - - #define DIGIT_BIT 60 -#else - /* this is the default case, 28-bit digits */ - - /* this is to make porting into LibTomCrypt easier :-) */ -#ifndef CRYPT - #if defined(_MSC_VER) || defined(__BORLANDC__) - typedef unsigned __int64 ulong64; - typedef signed __int64 long64; - #else - typedef unsigned long long ulong64; - typedef signed long long long64; - #endif -#endif - - typedef unsigned long mp_digit; - typedef ulong64 mp_word; - -#ifdef MP_31BIT - /* this is an extension that uses 31-bit digits */ - #define DIGIT_BIT 31 -#else - /* default case is 28-bit digits, defines MP_28BIT as a handy macro to test */ - #define DIGIT_BIT 28 - #define MP_28BIT -#endif -#endif - -/* define heap macros */ -#ifndef CRYPT - /* default to libc stuff */ - #ifndef XMALLOC - #define XMALLOC malloc - #define XFREE free - #define XREALLOC realloc - #define XCALLOC calloc - #else - /* prototypes for our heap functions */ - extern void *XMALLOC(size_t n); - extern void *XREALLOC(void *p, size_t n); - extern void *XCALLOC(size_t n, size_t s); - extern void XFREE(void *p); - #endif -#endif - - -/* otherwise the bits per digit is calculated automatically from the size of a mp_digit */ -#ifndef DIGIT_BIT - #define DIGIT_BIT ((int)((CHAR_BIT * sizeof(mp_digit) - 1))) /* bits per digit */ -#endif - -#define MP_DIGIT_BIT DIGIT_BIT -#define MP_MASK ((((mp_digit)1)<<((mp_digit)DIGIT_BIT))-((mp_digit)1)) -#define MP_DIGIT_MAX MP_MASK - -/* equalities */ -#define MP_LT -1 /* less than */ -#define MP_EQ 0 /* equal to */ -#define MP_GT 1 /* greater than */ - -#define MP_ZPOS 0 /* positive integer */ -#define MP_NEG 1 /* negative */ - -#define MP_OKAY 0 /* ok result */ -#define MP_MEM -2 /* out of mem */ -#define MP_VAL -3 /* invalid input */ -#define MP_RANGE MP_VAL - -#define MP_YES 1 /* yes response */ -#define MP_NO 0 /* no response */ - -/* Primality generation flags */ -#define LTM_PRIME_BBS 0x0001 /* BBS style prime */ -#define LTM_PRIME_SAFE 0x0002 /* Safe prime (p-1)/2 == prime */ -#define LTM_PRIME_2MSB_ON 0x0008 /* force 2nd MSB to 1 */ - -typedef int mp_err; - -/* you'll have to tune these... */ -extern int KARATSUBA_MUL_CUTOFF, - KARATSUBA_SQR_CUTOFF, - TOOM_MUL_CUTOFF, - TOOM_SQR_CUTOFF; - -/* define this to use lower memory usage routines (exptmods mostly) */ -/* #define MP_LOW_MEM */ - -/* default precision */ -#ifndef MP_PREC - #ifndef MP_LOW_MEM - #define MP_PREC 32 /* default digits of precision */ - #else - #define MP_PREC 8 /* default digits of precision */ - #endif -#endif - -/* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - BITS_PER_DIGIT*2) */ -#define MP_WARRAY (1 << (sizeof(mp_word) * CHAR_BIT - 2 * DIGIT_BIT + 1)) - -/* the infamous mp_int structure */ -typedef struct { - int used, alloc, sign; - mp_digit *dp; -} mp_int; - -/* callback for mp_prime_random, should fill dst with random bytes and return how many read [upto len] */ -typedef int ltm_prime_callback(unsigned char *dst, int len, void *dat); - - -#define USED(m) ((m)->used) -#define DIGIT(m,k) ((m)->dp[(k)]) -#define SIGN(m) ((m)->sign) - -/* error code to char* string */ -char *mp_error_to_string(int code); - -/* ---> init and deinit bignum functions <--- */ -/* init a bignum */ -int mp_init(mp_int *a); - -/* free a bignum */ -void mp_clear(mp_int *a); - -/* init a null terminated series of arguments */ -int mp_init_multi(mp_int *mp, ...); - -/* clear a null terminated series of arguments */ -void mp_clear_multi(mp_int *mp, ...); - -/* exchange two ints */ -void mp_exch(mp_int *a, mp_int *b); - -/* shrink ram required for a bignum */ -int mp_shrink(mp_int *a); - -/* grow an int to a given size */ -int mp_grow(mp_int *a, int size); - -/* init to a given number of digits */ -int mp_init_size(mp_int *a, int size); - -/* ---> Basic Manipulations <--- */ -#define mp_iszero(a) (((a)->used == 0) ? MP_YES : MP_NO) -#define mp_iseven(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 0)) ? MP_YES : MP_NO) -#define mp_isodd(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 1)) ? MP_YES : MP_NO) - -/* set to zero */ -void mp_zero(mp_int *a); - -/* set to a digit */ -void mp_set(mp_int *a, mp_digit b); - -/* set a 32-bit const */ -int mp_set_int(mp_int *a, unsigned long b); - -/* get a 32-bit value */ -unsigned long mp_get_int(mp_int * a); - -/* initialize and set a digit */ -int mp_init_set (mp_int * a, mp_digit b); - -/* initialize and set 32-bit value */ -int mp_init_set_int (mp_int * a, unsigned long b); - -/* copy, b = a */ -int mp_copy(mp_int *a, mp_int *b); - -/* inits and copies, a = b */ -int mp_init_copy(mp_int *a, mp_int *b); - -/* trim unused digits */ -void mp_clamp(mp_int *a); - -/* ---> digit manipulation <--- */ - -/* right shift by "b" digits */ -void mp_rshd(mp_int *a, int b); - -/* left shift by "b" digits */ -int mp_lshd(mp_int *a, int b); - -/* c = a / 2**b */ -int mp_div_2d(mp_int *a, int b, mp_int *c, mp_int *d); - -/* b = a/2 */ -int mp_div_2(mp_int *a, mp_int *b); - -/* c = a * 2**b */ -int mp_mul_2d(mp_int *a, int b, mp_int *c); - -/* b = a*2 */ -int mp_mul_2(mp_int *a, mp_int *b); - -/* c = a mod 2**d */ -int mp_mod_2d(mp_int *a, int b, mp_int *c); - -/* computes a = 2**b */ -int mp_2expt(mp_int *a, int b); - -/* Counts the number of lsbs which are zero before the first zero bit */ -int mp_cnt_lsb(mp_int *a); - -/* I Love Earth! */ - -/* makes a pseudo-random int of a given size */ -int mp_rand(mp_int *a, int digits); - -/* ---> binary operations <--- */ -/* c = a XOR b */ -int mp_xor(mp_int *a, mp_int *b, mp_int *c); - -/* c = a OR b */ -int mp_or(mp_int *a, mp_int *b, mp_int *c); - -/* c = a AND b */ -int mp_and(mp_int *a, mp_int *b, mp_int *c); - -/* ---> Basic arithmetic <--- */ - -/* b = -a */ -int mp_neg(mp_int *a, mp_int *b); - -/* b = |a| */ -int mp_abs(mp_int *a, mp_int *b); - -/* compare a to b */ -int mp_cmp(mp_int *a, mp_int *b); - -/* compare |a| to |b| */ -int mp_cmp_mag(mp_int *a, mp_int *b); - -/* c = a + b */ -int mp_add(mp_int *a, mp_int *b, mp_int *c); - -/* c = a - b */ -int mp_sub(mp_int *a, mp_int *b, mp_int *c); - -/* c = a * b */ -int mp_mul(mp_int *a, mp_int *b, mp_int *c); - -/* b = a*a */ -int mp_sqr(mp_int *a, mp_int *b); - -/* a/b => cb + d == a */ -int mp_div(mp_int *a, mp_int *b, mp_int *c, mp_int *d); - -/* c = a mod b, 0 <= c < b */ -int mp_mod(mp_int *a, mp_int *b, mp_int *c); - -/* ---> single digit functions <--- */ - -/* compare against a single digit */ -int mp_cmp_d(mp_int *a, mp_digit b); - -/* c = a + b */ -int mp_add_d(mp_int *a, mp_digit b, mp_int *c); - -/* c = a - b */ -int mp_sub_d(mp_int *a, mp_digit b, mp_int *c); - -/* c = a * b */ -int mp_mul_d(mp_int *a, mp_digit b, mp_int *c); - -/* a/b => cb + d == a */ -int mp_div_d(mp_int *a, mp_digit b, mp_int *c, mp_digit *d); - -/* a/3 => 3c + d == a */ -int mp_div_3(mp_int *a, mp_int *c, mp_digit *d); - -/* c = a**b */ -int mp_expt_d(mp_int *a, mp_digit b, mp_int *c); - -/* c = a mod b, 0 <= c < b */ -int mp_mod_d(mp_int *a, mp_digit b, mp_digit *c); - -/* ---> number theory <--- */ - -/* d = a + b (mod c) */ -int mp_addmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d); - -/* d = a - b (mod c) */ -int mp_submod(mp_int *a, mp_int *b, mp_int *c, mp_int *d); - -/* d = a * b (mod c) */ -int mp_mulmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d); - -/* c = a * a (mod b) */ -int mp_sqrmod(mp_int *a, mp_int *b, mp_int *c); - -/* c = 1/a (mod b) */ -int mp_invmod(mp_int *a, mp_int *b, mp_int *c); - -/* c = (a, b) */ -int mp_gcd(mp_int *a, mp_int *b, mp_int *c); - -/* produces value such that U1*a + U2*b = U3 */ -int mp_exteuclid(mp_int *a, mp_int *b, mp_int *U1, mp_int *U2, mp_int *U3); - -/* c = [a, b] or (a*b)/(a, b) */ -int mp_lcm(mp_int *a, mp_int *b, mp_int *c); - -/* finds one of the b'th root of a, such that |c|**b <= |a| - * - * returns error if a < 0 and b is even - */ -int mp_n_root(mp_int *a, mp_digit b, mp_int *c); - -/* special sqrt algo */ -int mp_sqrt(mp_int *arg, mp_int *ret); - -/* is number a square? */ -int mp_is_square(mp_int *arg, int *ret); - -/* computes the jacobi c = (a | n) (or Legendre if b is prime) */ -int mp_jacobi(mp_int *a, mp_int *n, int *c); - -/* used to setup the Barrett reduction for a given modulus b */ -int mp_reduce_setup(mp_int *a, mp_int *b); - -/* Barrett Reduction, computes a (mod b) with a precomputed value c - * - * Assumes that 0 < a <= b*b, note if 0 > a > -(b*b) then you can merely - * compute the reduction as -1 * mp_reduce(mp_abs(a)) [pseudo code]. - */ -int mp_reduce(mp_int *a, mp_int *b, mp_int *c); - -/* setups the montgomery reduction */ -int mp_montgomery_setup(mp_int *a, mp_digit *mp); - -/* computes a = B**n mod b without division or multiplication useful for - * normalizing numbers in a Montgomery system. - */ -int mp_montgomery_calc_normalization(mp_int *a, mp_int *b); - -/* computes x/R == x (mod N) via Montgomery Reduction */ -int mp_montgomery_reduce(mp_int *a, mp_int *m, mp_digit mp); - -/* returns 1 if a is a valid DR modulus */ -int mp_dr_is_modulus(mp_int *a); - -/* sets the value of "d" required for mp_dr_reduce */ -void mp_dr_setup(mp_int *a, mp_digit *d); - -/* reduces a modulo b using the Diminished Radix method */ -int mp_dr_reduce(mp_int *a, mp_int *b, mp_digit mp); - -/* returns true if a can be reduced with mp_reduce_2k */ -int mp_reduce_is_2k(mp_int *a); - -/* determines k value for 2k reduction */ -int mp_reduce_2k_setup(mp_int *a, mp_digit *d); - -/* reduces a modulo b where b is of the form 2**p - k [0 <= a] */ -int mp_reduce_2k(mp_int *a, mp_int *n, mp_digit d); - -/* returns true if a can be reduced with mp_reduce_2k_l */ -int mp_reduce_is_2k_l(mp_int *a); - -/* determines k value for 2k reduction */ -int mp_reduce_2k_setup_l(mp_int *a, mp_int *d); - -/* reduces a modulo b where b is of the form 2**p - k [0 <= a] */ -int mp_reduce_2k_l(mp_int *a, mp_int *n, mp_int *d); - -/* d = a**b (mod c) */ -int mp_exptmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d); - -/* ---> Primes <--- */ - -/* number of primes */ -#ifdef MP_8BIT - #define PRIME_SIZE 31 -#else - #define PRIME_SIZE 256 -#endif - -/* table of first PRIME_SIZE primes */ -extern const mp_digit ltm_prime_tab[]; - -/* result=1 if a is divisible by one of the first PRIME_SIZE primes */ -int mp_prime_is_divisible(mp_int *a, int *result); - -/* performs one Fermat test of "a" using base "b". - * Sets result to 0 if composite or 1 if probable prime - */ -int mp_prime_fermat(mp_int *a, mp_int *b, int *result); - -/* performs one Miller-Rabin test of "a" using base "b". - * Sets result to 0 if composite or 1 if probable prime - */ -int mp_prime_miller_rabin(mp_int *a, mp_int *b, int *result); - -/* This gives [for a given bit size] the number of trials required - * such that Miller-Rabin gives a prob of failure lower than 2^-96 - */ -int mp_prime_rabin_miller_trials(int size); - -/* performs t rounds of Miller-Rabin on "a" using the first - * t prime bases. Also performs an initial sieve of trial - * division. Determines if "a" is prime with probability - * of error no more than (1/4)**t. - * - * Sets result to 1 if probably prime, 0 otherwise - */ -int mp_prime_is_prime(mp_int *a, int t, int *result); - -/* finds the next prime after the number "a" using "t" trials - * of Miller-Rabin. - * - * bbs_style = 1 means the prime must be congruent to 3 mod 4 - */ -int mp_prime_next_prime(mp_int *a, int t, int bbs_style); - -/* makes a truly random prime of a given size (bytes), - * call with bbs = 1 if you want it to be congruent to 3 mod 4 - * - * You have to supply a callback which fills in a buffer with random bytes. "dat" is a parameter you can - * have passed to the callback (e.g. a state or something). This function doesn't use "dat" itself - * so it can be NULL - * - * The prime generated will be larger than 2^(8*size). - */ -#define mp_prime_random(a, t, size, bbs, cb, dat) mp_prime_random_ex(a, t, ((size) * 8) + 1, (bbs==1)?LTM_PRIME_BBS:0, cb, dat) - -/* makes a truly random prime of a given size (bits), - * - * Flags are as follows: - * - * LTM_PRIME_BBS - make prime congruent to 3 mod 4 - * LTM_PRIME_SAFE - make sure (p-1)/2 is prime as well (implies LTM_PRIME_BBS) - * LTM_PRIME_2MSB_OFF - make the 2nd highest bit zero - * LTM_PRIME_2MSB_ON - make the 2nd highest bit one - * - * You have to supply a callback which fills in a buffer with random bytes. "dat" is a parameter you can - * have passed to the callback (e.g. a state or something). This function doesn't use "dat" itself - * so it can be NULL - * - */ -int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback cb, void *dat); - -/* ---> radix conversion <--- */ -int mp_count_bits(mp_int *a); - -int mp_unsigned_bin_size(mp_int *a); -int mp_read_unsigned_bin(mp_int *a, const unsigned char *b, int c); -int mp_to_unsigned_bin(mp_int *a, unsigned char *b); -int mp_to_unsigned_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen); - -int mp_signed_bin_size(mp_int *a); -int mp_read_signed_bin(mp_int *a, const unsigned char *b, int c); -int mp_to_signed_bin(mp_int *a, unsigned char *b); -int mp_to_signed_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen); - -int mp_read_radix(mp_int *a, const char *str, int radix); -int mp_toradix(mp_int *a, char *str, int radix); -int mp_toradix_n(mp_int * a, char *str, int radix, int maxlen); -int mp_radix_size(mp_int *a, int radix, int *size); - -int mp_fread(mp_int *a, int radix, FILE *stream); -int mp_fwrite(mp_int *a, int radix, FILE *stream); - -#define mp_read_raw(mp, str, len) mp_read_signed_bin((mp), (str), (len)) -#define mp_raw_size(mp) mp_signed_bin_size(mp) -#define mp_toraw(mp, str) mp_to_signed_bin((mp), (str)) -#define mp_read_mag(mp, str, len) mp_read_unsigned_bin((mp), (str), (len)) -#define mp_mag_size(mp) mp_unsigned_bin_size(mp) -#define mp_tomag(mp, str) mp_to_unsigned_bin((mp), (str)) - -#define mp_tobinary(M, S) mp_toradix((M), (S), 2) -#define mp_tooctal(M, S) mp_toradix((M), (S), 8) -#define mp_todecimal(M, S) mp_toradix((M), (S), 10) -#define mp_tohex(M, S) mp_toradix((M), (S), 16) - -/* lowlevel functions, do not call! */ -int s_mp_add(mp_int *a, mp_int *b, mp_int *c); -int s_mp_sub(mp_int *a, mp_int *b, mp_int *c); -#define s_mp_mul(a, b, c) s_mp_mul_digs(a, b, c, (a)->used + (b)->used + 1) -int fast_s_mp_mul_digs(mp_int *a, mp_int *b, mp_int *c, int digs); -int s_mp_mul_digs(mp_int *a, mp_int *b, mp_int *c, int digs); -int fast_s_mp_mul_high_digs(mp_int *a, mp_int *b, mp_int *c, int digs); -int s_mp_mul_high_digs(mp_int *a, mp_int *b, mp_int *c, int digs); -int fast_s_mp_sqr(mp_int *a, mp_int *b); -int s_mp_sqr(mp_int *a, mp_int *b); -int mp_karatsuba_mul(mp_int *a, mp_int *b, mp_int *c); -int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c); -int mp_karatsuba_sqr(mp_int *a, mp_int *b); -int mp_toom_sqr(mp_int *a, mp_int *b); -int fast_mp_invmod(mp_int *a, mp_int *b, mp_int *c); -int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c); -int fast_mp_montgomery_reduce(mp_int *a, mp_int *m, mp_digit mp); -int mp_exptmod_fast(mp_int *G, mp_int *X, mp_int *P, mp_int *Y, int mode); -int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int mode); -void bn_reverse(unsigned char *s, int len); - -extern const char *mp_s_rmap; - -#ifdef __cplusplus - } -#endif - -#endif - - -/* $Source: /cvs/libtom/libtommath/tommath.h,v $ */ -/* $Revision: 1.8 $ */ -/* $Date: 2006/03/31 14:18:44 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/tommath_class.h b/libs/storm-sys/StormLib/src/libtommath/tommath_class.h deleted file mode 100644 index 18d1553..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/tommath_class.h +++ /dev/null @@ -1,999 +0,0 @@ -#if !(defined(LTM1) && defined(LTM2) && defined(LTM3)) -#if defined(LTM2) -#define LTM3 -#endif -#if defined(LTM1) -#define LTM2 -#endif -#define LTM1 - -#if defined(LTM_ALL) -#define BN_ERROR_C -#define BN_FAST_MP_INVMOD_C -#define BN_FAST_MP_MONTGOMERY_REDUCE_C -#define BN_FAST_S_MP_MUL_DIGS_C -#define BN_FAST_S_MP_MUL_HIGH_DIGS_C -#define BN_FAST_S_MP_SQR_C -#define BN_MP_2EXPT_C -#define BN_MP_ABS_C -#define BN_MP_ADD_C -#define BN_MP_ADD_D_C -#define BN_MP_ADDMOD_C -#define BN_MP_AND_C -#define BN_MP_CLAMP_C -#define BN_MP_CLEAR_C -#define BN_MP_CLEAR_MULTI_C -#define BN_MP_CMP_C -#define BN_MP_CMP_D_C -#define BN_MP_CMP_MAG_C -#define BN_MP_CNT_LSB_C -#define BN_MP_COPY_C -#define BN_MP_COUNT_BITS_C -#define BN_MP_DIV_C -#define BN_MP_DIV_2_C -#define BN_MP_DIV_2D_C -#define BN_MP_DIV_3_C -#define BN_MP_DIV_D_C -#define BN_MP_DR_IS_MODULUS_C -#define BN_MP_DR_REDUCE_C -#define BN_MP_DR_SETUP_C -#define BN_MP_EXCH_C -#define BN_MP_EXPT_D_C -#define BN_MP_EXPTMOD_C -#define BN_MP_EXPTMOD_FAST_C -#define BN_MP_EXTEUCLID_C -#define BN_MP_FREAD_C -#define BN_MP_FWRITE_C -#define BN_MP_GCD_C -#define BN_MP_GET_INT_C -#define BN_MP_GROW_C -#define BN_MP_INIT_C -#define BN_MP_INIT_COPY_C -#define BN_MP_INIT_MULTI_C -#define BN_MP_INIT_SET_C -#define BN_MP_INIT_SET_INT_C -#define BN_MP_INIT_SIZE_C -#define BN_MP_INVMOD_C -#define BN_MP_INVMOD_SLOW_C -#define BN_MP_IS_SQUARE_C -#define BN_MP_JACOBI_C -#define BN_MP_KARATSUBA_MUL_C -#define BN_MP_KARATSUBA_SQR_C -#define BN_MP_LCM_C -#define BN_MP_LSHD_C -#define BN_MP_MOD_C -#define BN_MP_MOD_2D_C -#define BN_MP_MOD_D_C -#define BN_MP_MONTGOMERY_CALC_NORMALIZATION_C -#define BN_MP_MONTGOMERY_REDUCE_C -#define BN_MP_MONTGOMERY_SETUP_C -#define BN_MP_MUL_C -#define BN_MP_MUL_2_C -#define BN_MP_MUL_2D_C -#define BN_MP_MUL_D_C -#define BN_MP_MULMOD_C -#define BN_MP_N_ROOT_C -#define BN_MP_NEG_C -#define BN_MP_OR_C -#define BN_MP_PRIME_FERMAT_C -#define BN_MP_PRIME_IS_DIVISIBLE_C -#define BN_MP_PRIME_IS_PRIME_C -#define BN_MP_PRIME_MILLER_RABIN_C -#define BN_MP_PRIME_NEXT_PRIME_C -#define BN_MP_PRIME_RABIN_MILLER_TRIALS_C -#define BN_MP_PRIME_RANDOM_EX_C -#define BN_MP_RADIX_SIZE_C -#define BN_MP_RADIX_SMAP_C -#define BN_MP_RAND_C -#define BN_MP_READ_RADIX_C -#define BN_MP_READ_SIGNED_BIN_C -#define BN_MP_READ_UNSIGNED_BIN_C -#define BN_MP_REDUCE_C -#define BN_MP_REDUCE_2K_C -#define BN_MP_REDUCE_2K_L_C -#define BN_MP_REDUCE_2K_SETUP_C -#define BN_MP_REDUCE_2K_SETUP_L_C -#define BN_MP_REDUCE_IS_2K_C -#define BN_MP_REDUCE_IS_2K_L_C -#define BN_MP_REDUCE_SETUP_C -#define BN_MP_RSHD_C -#define BN_MP_SET_C -#define BN_MP_SET_INT_C -#define BN_MP_SHRINK_C -#define BN_MP_SIGNED_BIN_SIZE_C -#define BN_MP_SQR_C -#define BN_MP_SQRMOD_C -#define BN_MP_SQRT_C -#define BN_MP_SUB_C -#define BN_MP_SUB_D_C -#define BN_MP_SUBMOD_C -#define BN_MP_TO_SIGNED_BIN_C -#define BN_MP_TO_SIGNED_BIN_N_C -#define BN_MP_TO_UNSIGNED_BIN_C -#define BN_MP_TO_UNSIGNED_BIN_N_C -#define BN_MP_TOOM_MUL_C -#define BN_MP_TOOM_SQR_C -#define BN_MP_TORADIX_C -#define BN_MP_TORADIX_N_C -#define BN_MP_UNSIGNED_BIN_SIZE_C -#define BN_MP_XOR_C -#define BN_MP_ZERO_C -#define BN_PRIME_TAB_C -#define BN_REVERSE_C -#define BN_S_MP_ADD_C -#define BN_S_MP_EXPTMOD_C -#define BN_S_MP_MUL_DIGS_C -#define BN_S_MP_MUL_HIGH_DIGS_C -#define BN_S_MP_SQR_C -#define BN_S_MP_SUB_C -#define BNCORE_C -#endif - -#if defined(BN_ERROR_C) - #define BN_MP_ERROR_TO_STRING_C -#endif - -#if defined(BN_FAST_MP_INVMOD_C) - #define BN_MP_ISEVEN_C - #define BN_MP_INIT_MULTI_C - #define BN_MP_COPY_C - #define BN_MP_MOD_C - #define BN_MP_SET_C - #define BN_MP_DIV_2_C - #define BN_MP_ISODD_C - #define BN_MP_SUB_C - #define BN_MP_CMP_C - #define BN_MP_ISZERO_C - #define BN_MP_CMP_D_C - #define BN_MP_ADD_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_MULTI_C -#endif - -#if defined(BN_FAST_MP_MONTGOMERY_REDUCE_C) - #define BN_MP_GROW_C - #define BN_MP_RSHD_C - #define BN_MP_CLAMP_C - #define BN_MP_CMP_MAG_C - #define BN_S_MP_SUB_C -#endif - -#if defined(BN_FAST_S_MP_MUL_DIGS_C) - #define BN_MP_GROW_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_FAST_S_MP_MUL_HIGH_DIGS_C) - #define BN_MP_GROW_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_FAST_S_MP_SQR_C) - #define BN_MP_GROW_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_MP_2EXPT_C) - #define BN_MP_ZERO_C - #define BN_MP_GROW_C -#endif - -#if defined(BN_MP_ABS_C) - #define BN_MP_COPY_C -#endif - -#if defined(BN_MP_ADD_C) - #define BN_S_MP_ADD_C - #define BN_MP_CMP_MAG_C - #define BN_S_MP_SUB_C -#endif - -#if defined(BN_MP_ADD_D_C) - #define BN_MP_GROW_C - #define BN_MP_SUB_D_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_MP_ADDMOD_C) - #define BN_MP_INIT_C - #define BN_MP_ADD_C - #define BN_MP_CLEAR_C - #define BN_MP_MOD_C -#endif - -#if defined(BN_MP_AND_C) - #define BN_MP_INIT_COPY_C - #define BN_MP_CLAMP_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_CLAMP_C) -#endif - -#if defined(BN_MP_CLEAR_C) -#endif - -#if defined(BN_MP_CLEAR_MULTI_C) - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_CMP_C) - #define BN_MP_CMP_MAG_C -#endif - -#if defined(BN_MP_CMP_D_C) -#endif - -#if defined(BN_MP_CMP_MAG_C) -#endif - -#if defined(BN_MP_CNT_LSB_C) - #define BN_MP_ISZERO_C -#endif - -#if defined(BN_MP_COPY_C) - #define BN_MP_GROW_C -#endif - -#if defined(BN_MP_COUNT_BITS_C) -#endif - -#if defined(BN_MP_DIV_C) - #define BN_MP_ISZERO_C - #define BN_MP_CMP_MAG_C - #define BN_MP_COPY_C - #define BN_MP_ZERO_C - #define BN_MP_INIT_MULTI_C - #define BN_MP_SET_C - #define BN_MP_COUNT_BITS_C - #define BN_MP_ABS_C - #define BN_MP_MUL_2D_C - #define BN_MP_CMP_C - #define BN_MP_SUB_C - #define BN_MP_ADD_C - #define BN_MP_DIV_2D_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_MULTI_C - #define BN_MP_INIT_SIZE_C - #define BN_MP_INIT_C - #define BN_MP_INIT_COPY_C - #define BN_MP_LSHD_C - #define BN_MP_RSHD_C - #define BN_MP_MUL_D_C - #define BN_MP_CLAMP_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_DIV_2_C) - #define BN_MP_GROW_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_MP_DIV_2D_C) - #define BN_MP_COPY_C - #define BN_MP_ZERO_C - #define BN_MP_INIT_C - #define BN_MP_MOD_2D_C - #define BN_MP_CLEAR_C - #define BN_MP_RSHD_C - #define BN_MP_CLAMP_C - #define BN_MP_EXCH_C -#endif - -#if defined(BN_MP_DIV_3_C) - #define BN_MP_INIT_SIZE_C - #define BN_MP_CLAMP_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_DIV_D_C) - #define BN_MP_ISZERO_C - #define BN_MP_COPY_C - #define BN_MP_DIV_2D_C - #define BN_MP_DIV_3_C - #define BN_MP_INIT_SIZE_C - #define BN_MP_CLAMP_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_DR_IS_MODULUS_C) -#endif - -#if defined(BN_MP_DR_REDUCE_C) - #define BN_MP_GROW_C - #define BN_MP_CLAMP_C - #define BN_MP_CMP_MAG_C - #define BN_S_MP_SUB_C -#endif - -#if defined(BN_MP_DR_SETUP_C) -#endif - -#if defined(BN_MP_EXCH_C) -#endif - -#if defined(BN_MP_EXPT_D_C) - #define BN_MP_INIT_COPY_C - #define BN_MP_SET_C - #define BN_MP_SQR_C - #define BN_MP_CLEAR_C - #define BN_MP_MUL_C -#endif - -#if defined(BN_MP_EXPTMOD_C) - #define BN_MP_INIT_C - #define BN_MP_INVMOD_C - #define BN_MP_CLEAR_C - #define BN_MP_ABS_C - #define BN_MP_CLEAR_MULTI_C - #define BN_MP_REDUCE_IS_2K_L_C - #define BN_S_MP_EXPTMOD_C - #define BN_MP_DR_IS_MODULUS_C - #define BN_MP_REDUCE_IS_2K_C - #define BN_MP_ISODD_C - #define BN_MP_EXPTMOD_FAST_C -#endif - -#if defined(BN_MP_EXPTMOD_FAST_C) - #define BN_MP_COUNT_BITS_C - #define BN_MP_INIT_C - #define BN_MP_CLEAR_C - #define BN_MP_MONTGOMERY_SETUP_C - #define BN_FAST_MP_MONTGOMERY_REDUCE_C - #define BN_MP_MONTGOMERY_REDUCE_C - #define BN_MP_DR_SETUP_C - #define BN_MP_DR_REDUCE_C - #define BN_MP_REDUCE_2K_SETUP_C - #define BN_MP_REDUCE_2K_C - #define BN_MP_MONTGOMERY_CALC_NORMALIZATION_C - #define BN_MP_MULMOD_C - #define BN_MP_SET_C - #define BN_MP_MOD_C - #define BN_MP_COPY_C - #define BN_MP_SQR_C - #define BN_MP_MUL_C - #define BN_MP_EXCH_C -#endif - -#if defined(BN_MP_EXTEUCLID_C) - #define BN_MP_INIT_MULTI_C - #define BN_MP_SET_C - #define BN_MP_COPY_C - #define BN_MP_ISZERO_C - #define BN_MP_DIV_C - #define BN_MP_MUL_C - #define BN_MP_SUB_C - #define BN_MP_NEG_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_MULTI_C -#endif - -#if defined(BN_MP_FREAD_C) - #define BN_MP_ZERO_C - #define BN_MP_S_RMAP_C - #define BN_MP_MUL_D_C - #define BN_MP_ADD_D_C - #define BN_MP_CMP_D_C -#endif - -#if defined(BN_MP_FWRITE_C) - #define BN_MP_RADIX_SIZE_C - #define BN_MP_TORADIX_C -#endif - -#if defined(BN_MP_GCD_C) - #define BN_MP_ISZERO_C - #define BN_MP_ABS_C - #define BN_MP_ZERO_C - #define BN_MP_INIT_COPY_C - #define BN_MP_CNT_LSB_C - #define BN_MP_DIV_2D_C - #define BN_MP_CMP_MAG_C - #define BN_MP_EXCH_C - #define BN_S_MP_SUB_C - #define BN_MP_MUL_2D_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_GET_INT_C) -#endif - -#if defined(BN_MP_GROW_C) -#endif - -#if defined(BN_MP_INIT_C) -#endif - -#if defined(BN_MP_INIT_COPY_C) - #define BN_MP_COPY_C -#endif - -#if defined(BN_MP_INIT_MULTI_C) - #define BN_MP_ERR_C - #define BN_MP_INIT_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_INIT_SET_C) - #define BN_MP_INIT_C - #define BN_MP_SET_C -#endif - -#if defined(BN_MP_INIT_SET_INT_C) - #define BN_MP_INIT_C - #define BN_MP_SET_INT_C -#endif - -#if defined(BN_MP_INIT_SIZE_C) - #define BN_MP_INIT_C -#endif - -#if defined(BN_MP_INVMOD_C) - #define BN_MP_ISZERO_C - #define BN_MP_ISODD_C - #define BN_FAST_MP_INVMOD_C - #define BN_MP_INVMOD_SLOW_C -#endif - -#if defined(BN_MP_INVMOD_SLOW_C) - #define BN_MP_ISZERO_C - #define BN_MP_INIT_MULTI_C - #define BN_MP_MOD_C - #define BN_MP_COPY_C - #define BN_MP_ISEVEN_C - #define BN_MP_SET_C - #define BN_MP_DIV_2_C - #define BN_MP_ISODD_C - #define BN_MP_ADD_C - #define BN_MP_SUB_C - #define BN_MP_CMP_C - #define BN_MP_CMP_D_C - #define BN_MP_CMP_MAG_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_MULTI_C -#endif - -#if defined(BN_MP_IS_SQUARE_C) - #define BN_MP_MOD_D_C - #define BN_MP_INIT_SET_INT_C - #define BN_MP_MOD_C - #define BN_MP_GET_INT_C - #define BN_MP_SQRT_C - #define BN_MP_SQR_C - #define BN_MP_CMP_MAG_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_JACOBI_C) - #define BN_MP_CMP_D_C - #define BN_MP_ISZERO_C - #define BN_MP_INIT_COPY_C - #define BN_MP_CNT_LSB_C - #define BN_MP_DIV_2D_C - #define BN_MP_MOD_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_KARATSUBA_MUL_C) - #define BN_MP_MUL_C - #define BN_MP_INIT_SIZE_C - #define BN_MP_CLAMP_C - #define BN_MP_SUB_C - #define BN_MP_ADD_C - #define BN_MP_LSHD_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_KARATSUBA_SQR_C) - #define BN_MP_INIT_SIZE_C - #define BN_MP_CLAMP_C - #define BN_MP_SQR_C - #define BN_MP_SUB_C - #define BN_S_MP_ADD_C - #define BN_MP_LSHD_C - #define BN_MP_ADD_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_LCM_C) - #define BN_MP_INIT_MULTI_C - #define BN_MP_GCD_C - #define BN_MP_CMP_MAG_C - #define BN_MP_DIV_C - #define BN_MP_MUL_C - #define BN_MP_CLEAR_MULTI_C -#endif - -#if defined(BN_MP_LSHD_C) - #define BN_MP_GROW_C - #define BN_MP_RSHD_C -#endif - -#if defined(BN_MP_MOD_C) - #define BN_MP_INIT_C - #define BN_MP_DIV_C - #define BN_MP_CLEAR_C - #define BN_MP_ADD_C - #define BN_MP_EXCH_C -#endif - -#if defined(BN_MP_MOD_2D_C) - #define BN_MP_ZERO_C - #define BN_MP_COPY_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_MP_MOD_D_C) - #define BN_MP_DIV_D_C -#endif - -#if defined(BN_MP_MONTGOMERY_CALC_NORMALIZATION_C) - #define BN_MP_COUNT_BITS_C - #define BN_MP_2EXPT_C - #define BN_MP_SET_C - #define BN_MP_MUL_2_C - #define BN_MP_CMP_MAG_C - #define BN_S_MP_SUB_C -#endif - -#if defined(BN_MP_MONTGOMERY_REDUCE_C) - #define BN_FAST_MP_MONTGOMERY_REDUCE_C - #define BN_MP_GROW_C - #define BN_MP_CLAMP_C - #define BN_MP_RSHD_C - #define BN_MP_CMP_MAG_C - #define BN_S_MP_SUB_C -#endif - -#if defined(BN_MP_MONTGOMERY_SETUP_C) -#endif - -#if defined(BN_MP_MUL_C) - #define BN_MP_TOOM_MUL_C - #define BN_MP_KARATSUBA_MUL_C - #define BN_FAST_S_MP_MUL_DIGS_C - #define BN_S_MP_MUL_C - #define BN_S_MP_MUL_DIGS_C -#endif - -#if defined(BN_MP_MUL_2_C) - #define BN_MP_GROW_C -#endif - -#if defined(BN_MP_MUL_2D_C) - #define BN_MP_COPY_C - #define BN_MP_GROW_C - #define BN_MP_LSHD_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_MP_MUL_D_C) - #define BN_MP_GROW_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_MP_MULMOD_C) - #define BN_MP_INIT_C - #define BN_MP_MUL_C - #define BN_MP_CLEAR_C - #define BN_MP_MOD_C -#endif - -#if defined(BN_MP_N_ROOT_C) - #define BN_MP_INIT_C - #define BN_MP_SET_C - #define BN_MP_COPY_C - #define BN_MP_EXPT_D_C - #define BN_MP_MUL_C - #define BN_MP_SUB_C - #define BN_MP_MUL_D_C - #define BN_MP_DIV_C - #define BN_MP_CMP_C - #define BN_MP_SUB_D_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_NEG_C) - #define BN_MP_COPY_C - #define BN_MP_ISZERO_C -#endif - -#if defined(BN_MP_OR_C) - #define BN_MP_INIT_COPY_C - #define BN_MP_CLAMP_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_PRIME_FERMAT_C) - #define BN_MP_CMP_D_C - #define BN_MP_INIT_C - #define BN_MP_EXPTMOD_C - #define BN_MP_CMP_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_PRIME_IS_DIVISIBLE_C) - #define BN_MP_MOD_D_C -#endif - -#if defined(BN_MP_PRIME_IS_PRIME_C) - #define BN_MP_CMP_D_C - #define BN_MP_PRIME_IS_DIVISIBLE_C - #define BN_MP_INIT_C - #define BN_MP_SET_C - #define BN_MP_PRIME_MILLER_RABIN_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_PRIME_MILLER_RABIN_C) - #define BN_MP_CMP_D_C - #define BN_MP_INIT_COPY_C - #define BN_MP_SUB_D_C - #define BN_MP_CNT_LSB_C - #define BN_MP_DIV_2D_C - #define BN_MP_EXPTMOD_C - #define BN_MP_CMP_C - #define BN_MP_SQRMOD_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_PRIME_NEXT_PRIME_C) - #define BN_MP_CMP_D_C - #define BN_MP_SET_C - #define BN_MP_SUB_D_C - #define BN_MP_ISEVEN_C - #define BN_MP_MOD_D_C - #define BN_MP_INIT_C - #define BN_MP_ADD_D_C - #define BN_MP_PRIME_MILLER_RABIN_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_PRIME_RABIN_MILLER_TRIALS_C) -#endif - -#if defined(BN_MP_PRIME_RANDOM_EX_C) - #define BN_MP_READ_UNSIGNED_BIN_C - #define BN_MP_PRIME_IS_PRIME_C - #define BN_MP_SUB_D_C - #define BN_MP_DIV_2_C - #define BN_MP_MUL_2_C - #define BN_MP_ADD_D_C -#endif - -#if defined(BN_MP_RADIX_SIZE_C) - #define BN_MP_COUNT_BITS_C - #define BN_MP_INIT_COPY_C - #define BN_MP_ISZERO_C - #define BN_MP_DIV_D_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_RADIX_SMAP_C) - #define BN_MP_S_RMAP_C -#endif - -#if defined(BN_MP_RAND_C) - #define BN_MP_ZERO_C - #define BN_MP_ADD_D_C - #define BN_MP_LSHD_C -#endif - -#if defined(BN_MP_READ_RADIX_C) - #define BN_MP_ZERO_C - #define BN_MP_S_RMAP_C - #define BN_MP_RADIX_SMAP_C - #define BN_MP_MUL_D_C - #define BN_MP_ADD_D_C - #define BN_MP_ISZERO_C -#endif - -#if defined(BN_MP_READ_SIGNED_BIN_C) - #define BN_MP_READ_UNSIGNED_BIN_C -#endif - -#if defined(BN_MP_READ_UNSIGNED_BIN_C) - #define BN_MP_GROW_C - #define BN_MP_ZERO_C - #define BN_MP_MUL_2D_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_MP_REDUCE_C) - #define BN_MP_REDUCE_SETUP_C - #define BN_MP_INIT_COPY_C - #define BN_MP_RSHD_C - #define BN_MP_MUL_C - #define BN_S_MP_MUL_HIGH_DIGS_C - #define BN_FAST_S_MP_MUL_HIGH_DIGS_C - #define BN_MP_MOD_2D_C - #define BN_S_MP_MUL_DIGS_C - #define BN_MP_SUB_C - #define BN_MP_CMP_D_C - #define BN_MP_SET_C - #define BN_MP_LSHD_C - #define BN_MP_ADD_C - #define BN_MP_CMP_C - #define BN_S_MP_SUB_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_REDUCE_2K_C) - #define BN_MP_INIT_C - #define BN_MP_COUNT_BITS_C - #define BN_MP_DIV_2D_C - #define BN_MP_MUL_D_C - #define BN_S_MP_ADD_C - #define BN_MP_CMP_MAG_C - #define BN_S_MP_SUB_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_REDUCE_2K_L_C) - #define BN_MP_INIT_C - #define BN_MP_COUNT_BITS_C - #define BN_MP_DIV_2D_C - #define BN_MP_MUL_C - #define BN_S_MP_ADD_C - #define BN_MP_CMP_MAG_C - #define BN_S_MP_SUB_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_REDUCE_2K_SETUP_C) - #define BN_MP_INIT_C - #define BN_MP_COUNT_BITS_C - #define BN_MP_2EXPT_C - #define BN_MP_CLEAR_C - #define BN_S_MP_SUB_C -#endif - -#if defined(BN_MP_REDUCE_2K_SETUP_L_C) - #define BN_MP_INIT_C - #define BN_MP_2EXPT_C - #define BN_MP_COUNT_BITS_C - #define BN_S_MP_SUB_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_REDUCE_IS_2K_C) - #define BN_MP_REDUCE_2K_C - #define BN_MP_COUNT_BITS_C -#endif - -#if defined(BN_MP_REDUCE_IS_2K_L_C) -#endif - -#if defined(BN_MP_REDUCE_SETUP_C) - #define BN_MP_2EXPT_C - #define BN_MP_DIV_C -#endif - -#if defined(BN_MP_RSHD_C) - #define BN_MP_ZERO_C -#endif - -#if defined(BN_MP_SET_C) - #define BN_MP_ZERO_C -#endif - -#if defined(BN_MP_SET_INT_C) - #define BN_MP_ZERO_C - #define BN_MP_MUL_2D_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_MP_SHRINK_C) -#endif - -#if defined(BN_MP_SIGNED_BIN_SIZE_C) - #define BN_MP_UNSIGNED_BIN_SIZE_C -#endif - -#if defined(BN_MP_SQR_C) - #define BN_MP_TOOM_SQR_C - #define BN_MP_KARATSUBA_SQR_C - #define BN_FAST_S_MP_SQR_C - #define BN_S_MP_SQR_C -#endif - -#if defined(BN_MP_SQRMOD_C) - #define BN_MP_INIT_C - #define BN_MP_SQR_C - #define BN_MP_CLEAR_C - #define BN_MP_MOD_C -#endif - -#if defined(BN_MP_SQRT_C) - #define BN_MP_N_ROOT_C - #define BN_MP_ISZERO_C - #define BN_MP_ZERO_C - #define BN_MP_INIT_COPY_C - #define BN_MP_RSHD_C - #define BN_MP_DIV_C - #define BN_MP_ADD_C - #define BN_MP_DIV_2_C - #define BN_MP_CMP_MAG_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_SUB_C) - #define BN_S_MP_ADD_C - #define BN_MP_CMP_MAG_C - #define BN_S_MP_SUB_C -#endif - -#if defined(BN_MP_SUB_D_C) - #define BN_MP_GROW_C - #define BN_MP_ADD_D_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_MP_SUBMOD_C) - #define BN_MP_INIT_C - #define BN_MP_SUB_C - #define BN_MP_CLEAR_C - #define BN_MP_MOD_C -#endif - -#if defined(BN_MP_TO_SIGNED_BIN_C) - #define BN_MP_TO_UNSIGNED_BIN_C -#endif - -#if defined(BN_MP_TO_SIGNED_BIN_N_C) - #define BN_MP_SIGNED_BIN_SIZE_C - #define BN_MP_TO_SIGNED_BIN_C -#endif - -#if defined(BN_MP_TO_UNSIGNED_BIN_C) - #define BN_MP_INIT_COPY_C - #define BN_MP_ISZERO_C - #define BN_MP_DIV_2D_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_TO_UNSIGNED_BIN_N_C) - #define BN_MP_UNSIGNED_BIN_SIZE_C - #define BN_MP_TO_UNSIGNED_BIN_C -#endif - -#if defined(BN_MP_TOOM_MUL_C) - #define BN_MP_INIT_MULTI_C - #define BN_MP_MOD_2D_C - #define BN_MP_COPY_C - #define BN_MP_RSHD_C - #define BN_MP_MUL_C - #define BN_MP_MUL_2_C - #define BN_MP_ADD_C - #define BN_MP_SUB_C - #define BN_MP_DIV_2_C - #define BN_MP_MUL_2D_C - #define BN_MP_MUL_D_C - #define BN_MP_DIV_3_C - #define BN_MP_LSHD_C - #define BN_MP_CLEAR_MULTI_C -#endif - -#if defined(BN_MP_TOOM_SQR_C) - #define BN_MP_INIT_MULTI_C - #define BN_MP_MOD_2D_C - #define BN_MP_COPY_C - #define BN_MP_RSHD_C - #define BN_MP_SQR_C - #define BN_MP_MUL_2_C - #define BN_MP_ADD_C - #define BN_MP_SUB_C - #define BN_MP_DIV_2_C - #define BN_MP_MUL_2D_C - #define BN_MP_MUL_D_C - #define BN_MP_DIV_3_C - #define BN_MP_LSHD_C - #define BN_MP_CLEAR_MULTI_C -#endif - -#if defined(BN_MP_TORADIX_C) - #define BN_MP_ISZERO_C - #define BN_MP_INIT_COPY_C - #define BN_MP_DIV_D_C - #define BN_MP_CLEAR_C - #define BN_MP_S_RMAP_C -#endif - -#if defined(BN_MP_TORADIX_N_C) - #define BN_MP_ISZERO_C - #define BN_MP_INIT_COPY_C - #define BN_MP_DIV_D_C - #define BN_MP_CLEAR_C - #define BN_MP_S_RMAP_C -#endif - -#if defined(BN_MP_UNSIGNED_BIN_SIZE_C) - #define BN_MP_COUNT_BITS_C -#endif - -#if defined(BN_MP_XOR_C) - #define BN_MP_INIT_COPY_C - #define BN_MP_CLAMP_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_ZERO_C) -#endif - -#if defined(BN_PRIME_TAB_C) -#endif - -#if defined(BN_REVERSE_C) -#endif - -#if defined(BN_S_MP_ADD_C) - #define BN_MP_GROW_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_S_MP_EXPTMOD_C) - #define BN_MP_COUNT_BITS_C - #define BN_MP_INIT_C - #define BN_MP_CLEAR_C - #define BN_MP_REDUCE_SETUP_C - #define BN_MP_REDUCE_C - #define BN_MP_REDUCE_2K_SETUP_L_C - #define BN_MP_REDUCE_2K_L_C - #define BN_MP_MOD_C - #define BN_MP_COPY_C - #define BN_MP_SQR_C - #define BN_MP_MUL_C - #define BN_MP_SET_C - #define BN_MP_EXCH_C -#endif - -#if defined(BN_S_MP_MUL_DIGS_C) - #define BN_FAST_S_MP_MUL_DIGS_C - #define BN_MP_INIT_SIZE_C - #define BN_MP_CLAMP_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_S_MP_MUL_HIGH_DIGS_C) - #define BN_FAST_S_MP_MUL_HIGH_DIGS_C - #define BN_MP_INIT_SIZE_C - #define BN_MP_CLAMP_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_S_MP_SQR_C) - #define BN_MP_INIT_SIZE_C - #define BN_MP_CLAMP_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_S_MP_SUB_C) - #define BN_MP_GROW_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BNCORE_C) -#endif - -#ifdef LTM3 -#define LTM_LAST -#endif -#include "tommath_superclass.h" -#include "tommath_class.h" -#else -#define LTM_LAST -#endif - -/* $Source: /cvs/libtom/libtommath/tommath_class.h,v $ */ -/* $Revision: 1.3 $ */ -/* $Date: 2005/07/28 11:59:32 $ */ diff --git a/libs/storm-sys/StormLib/src/libtommath/tommath_superclass.h b/libs/storm-sys/StormLib/src/libtommath/tommath_superclass.h deleted file mode 100644 index 2fdebe6..0000000 --- a/libs/storm-sys/StormLib/src/libtommath/tommath_superclass.h +++ /dev/null @@ -1,76 +0,0 @@ -/* super class file for PK algos */ - -/* default ... include all MPI */ -#define LTM_ALL - -/* RSA only (does not support DH/DSA/ECC) */ -/* #define SC_RSA_1 */ - -/* For reference.... On an Athlon64 optimizing for speed... - - LTM's mpi.o with all functions [striped] is 142KiB in size. - -*/ - -/* Works for RSA only, mpi.o is 68KiB */ -#ifdef SC_RSA_1 - #define BN_MP_SHRINK_C - #define BN_MP_LCM_C - #define BN_MP_PRIME_RANDOM_EX_C - #define BN_MP_INVMOD_C - #define BN_MP_GCD_C - #define BN_MP_MOD_C - #define BN_MP_MULMOD_C - #define BN_MP_ADDMOD_C - #define BN_MP_EXPTMOD_C - #define BN_MP_SET_INT_C - #define BN_MP_INIT_MULTI_C - #define BN_MP_CLEAR_MULTI_C - #define BN_MP_UNSIGNED_BIN_SIZE_C - #define BN_MP_TO_UNSIGNED_BIN_C - #define BN_MP_MOD_D_C - #define BN_MP_PRIME_RABIN_MILLER_TRIALS_C - #define BN_REVERSE_C - #define BN_PRIME_TAB_C - - /* other modifiers */ - #define BN_MP_DIV_SMALL /* Slower division, not critical */ - - /* here we are on the last pass so we turn things off. The functions classes are still there - * but we remove them specifically from the build. This also invokes tweaks in functions - * like removing support for even moduli, etc... - */ -#ifdef LTM_LAST - #undef BN_MP_TOOM_MUL_C - #undef BN_MP_TOOM_SQR_C - #undef BN_MP_KARATSUBA_MUL_C - #undef BN_MP_KARATSUBA_SQR_C - #undef BN_MP_REDUCE_C - #undef BN_MP_REDUCE_SETUP_C - #undef BN_MP_DR_IS_MODULUS_C - #undef BN_MP_DR_SETUP_C - #undef BN_MP_DR_REDUCE_C - #undef BN_MP_REDUCE_IS_2K_C - #undef BN_MP_REDUCE_2K_SETUP_C - #undef BN_MP_REDUCE_2K_C - #undef BN_S_MP_EXPTMOD_C - #undef BN_MP_DIV_3_C - #undef BN_S_MP_MUL_HIGH_DIGS_C - #undef BN_FAST_S_MP_MUL_HIGH_DIGS_C - #undef BN_FAST_MP_INVMOD_C - - /* To safely undefine these you have to make sure your RSA key won't exceed the Comba threshold - * which is roughly 255 digits [7140 bits for 32-bit machines, 15300 bits for 64-bit machines] - * which means roughly speaking you can handle upto 2536-bit RSA keys with these defined without - * trouble. - */ - #undef BN_S_MP_MUL_DIGS_C - #undef BN_S_MP_SQR_C - #undef BN_MP_MONTGOMERY_REDUCE_C -#endif - -#endif - -/* $Source: /cvs/libtom/libtommath/tommath_superclass.h,v $ */ -/* $Revision: 1.3 $ */ -/* $Date: 2005/05/14 13:29:17 $ */ diff --git a/libs/storm-sys/StormLib/src/lzma/C/LzFind.c b/libs/storm-sys/StormLib/src/lzma/C/LzFind.c deleted file mode 100644 index e3ecb05..0000000 --- a/libs/storm-sys/StormLib/src/lzma/C/LzFind.c +++ /dev/null @@ -1,761 +0,0 @@ -/* LzFind.c -- Match finder for LZ algorithms -2009-04-22 : Igor Pavlov : Public domain */ - -#include - -#include "LzFind.h" -#include "LzHash.h" - -#define kEmptyHashValue 0 -#define kMaxValForNormalize ((UInt32)0xFFFFFFFF) -#define kNormalizeStepMin (1 << 10) /* it must be power of 2 */ -#define kNormalizeMask (~(kNormalizeStepMin - 1)) -#define kMaxHistorySize ((UInt32)3 << 30) - -#define kStartMaxLen 3 - -static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc) -{ - if (!p->directInput) - { - alloc->Free(alloc, p->bufferBase); - p->bufferBase = 0; - } -} - -/* keepSizeBefore + keepSizeAfter + keepSizeReserv must be < 4G) */ - -static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAlloc *alloc) -{ - UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv; - if (p->directInput) - { - p->blockSize = blockSize; - return 1; - } - if (p->bufferBase == 0 || p->blockSize != blockSize) - { - LzInWindow_Free(p, alloc); - p->blockSize = blockSize; - p->bufferBase = (Byte *)alloc->Alloc(alloc, (size_t)blockSize); - } - return (p->bufferBase != 0); -} - -Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; } -Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[index]; } - -UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; } - -void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue) -{ - p->posLimit -= subValue; - p->pos -= subValue; - p->streamPos -= subValue; -} - -static void MatchFinder_ReadBlock(CMatchFinder *p) -{ - if (p->streamEndWasReached || p->result != SZ_OK) - return; - if (p->directInput) - { - UInt32 curSize = 0xFFFFFFFF - p->streamPos; - if (curSize > p->directInputRem) - curSize = (UInt32)p->directInputRem; - p->directInputRem -= curSize; - p->streamPos += curSize; - if (p->directInputRem == 0) - p->streamEndWasReached = 1; - return; - } - for (;;) - { - Byte *dest = p->buffer + (p->streamPos - p->pos); - size_t size = (p->bufferBase + p->blockSize - dest); - if (size == 0) - return; - p->result = p->stream->Read(p->stream, dest, &size); - if (p->result != SZ_OK) - return; - if (size == 0) - { - p->streamEndWasReached = 1; - return; - } - p->streamPos += (UInt32)size; - if (p->streamPos - p->pos > p->keepSizeAfter) - return; - } -} - -void MatchFinder_MoveBlock(CMatchFinder *p) -{ - memmove(p->bufferBase, - p->buffer - p->keepSizeBefore, - (size_t)(p->streamPos - p->pos + p->keepSizeBefore)); - p->buffer = p->bufferBase + p->keepSizeBefore; -} - -int MatchFinder_NeedMove(CMatchFinder *p) -{ - if (p->directInput) - return 0; - /* if (p->streamEndWasReached) return 0; */ - return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter); -} - -void MatchFinder_ReadIfRequired(CMatchFinder *p) -{ - if (p->streamEndWasReached) - return; - if (p->keepSizeAfter >= p->streamPos - p->pos) - MatchFinder_ReadBlock(p); -} - -static void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p) -{ - if (MatchFinder_NeedMove(p)) - MatchFinder_MoveBlock(p); - MatchFinder_ReadBlock(p); -} - -static void MatchFinder_SetDefaultSettings(CMatchFinder *p) -{ - p->cutValue = 32; - p->btMode = 1; - p->numHashBytes = 4; - p->bigHash = 0; -} - -#define kCrcPoly 0xEDB88320 - -void MatchFinder_Construct(CMatchFinder *p) -{ - UInt32 i; - p->bufferBase = 0; - p->directInput = 0; - p->hash = 0; - MatchFinder_SetDefaultSettings(p); - - for (i = 0; i < 256; i++) - { - UInt32 r = i; - int j; - for (j = 0; j < 8; j++) - r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1)); - p->crc[i] = r; - } -} - -static void MatchFinder_FreeThisClassMemory(CMatchFinder *p, ISzAlloc *alloc) -{ - alloc->Free(alloc, p->hash); - p->hash = 0; -} - -void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc) -{ - MatchFinder_FreeThisClassMemory(p, alloc); - LzInWindow_Free(p, alloc); -} - -static CLzRef* AllocRefs(UInt32 num, ISzAlloc *alloc) -{ - size_t sizeInBytes = (size_t)num * sizeof(CLzRef); - if (sizeInBytes / sizeof(CLzRef) != num) - return 0; - return (CLzRef *)alloc->Alloc(alloc, sizeInBytes); -} - -int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, - UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter, - ISzAlloc *alloc) -{ - UInt32 sizeReserv; - if (historySize > kMaxHistorySize) - { - MatchFinder_Free(p, alloc); - return 0; - } - sizeReserv = historySize >> 1; - if (historySize > ((UInt32)2 << 30)) - sizeReserv = historySize >> 2; - sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 19); - - p->keepSizeBefore = historySize + keepAddBufferBefore + 1; - p->keepSizeAfter = matchMaxLen + keepAddBufferAfter; - /* we need one additional byte, since we use MoveBlock after pos++ and before dictionary using */ - if (LzInWindow_Create(p, sizeReserv, alloc)) - { - UInt32 newCyclicBufferSize = historySize + 1; - UInt32 hs; - p->matchMaxLen = matchMaxLen; - { - p->fixedHashSize = 0; - if (p->numHashBytes == 2) - hs = (1 << 16) - 1; - else - { - hs = historySize - 1; - hs |= (hs >> 1); - hs |= (hs >> 2); - hs |= (hs >> 4); - hs |= (hs >> 8); - hs >>= 1; - hs |= 0xFFFF; /* don't change it! It's required for Deflate */ - if (hs > (1 << 24)) - { - if (p->numHashBytes == 3) - hs = (1 << 24) - 1; - else - hs >>= 1; - } - } - p->hashMask = hs; - hs++; - if (p->numHashBytes > 2) p->fixedHashSize += kHash2Size; - if (p->numHashBytes > 3) p->fixedHashSize += kHash3Size; - if (p->numHashBytes > 4) p->fixedHashSize += kHash4Size; - hs += p->fixedHashSize; - } - - { - UInt32 prevSize = p->hashSizeSum + p->numSons; - UInt32 newSize; - p->historySize = historySize; - p->hashSizeSum = hs; - p->cyclicBufferSize = newCyclicBufferSize; - p->numSons = (p->btMode ? newCyclicBufferSize * 2 : newCyclicBufferSize); - newSize = p->hashSizeSum + p->numSons; - if (p->hash != 0 && prevSize == newSize) - return 1; - MatchFinder_FreeThisClassMemory(p, alloc); - p->hash = AllocRefs(newSize, alloc); - if (p->hash != 0) - { - p->son = p->hash + p->hashSizeSum; - return 1; - } - } - } - MatchFinder_Free(p, alloc); - return 0; -} - -static void MatchFinder_SetLimits(CMatchFinder *p) -{ - UInt32 limit = kMaxValForNormalize - p->pos; - UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos; - if (limit2 < limit) - limit = limit2; - limit2 = p->streamPos - p->pos; - if (limit2 <= p->keepSizeAfter) - { - if (limit2 > 0) - limit2 = 1; - } - else - limit2 -= p->keepSizeAfter; - if (limit2 < limit) - limit = limit2; - { - UInt32 lenLimit = p->streamPos - p->pos; - if (lenLimit > p->matchMaxLen) - lenLimit = p->matchMaxLen; - p->lenLimit = lenLimit; - } - p->posLimit = p->pos + limit; -} - -void MatchFinder_Init(CMatchFinder *p) -{ - UInt32 i; - for (i = 0; i < p->hashSizeSum; i++) - p->hash[i] = kEmptyHashValue; - p->cyclicBufferPos = 0; - p->buffer = p->bufferBase; - p->pos = p->streamPos = p->cyclicBufferSize; - p->result = SZ_OK; - p->streamEndWasReached = 0; - MatchFinder_ReadBlock(p); - MatchFinder_SetLimits(p); -} - -static UInt32 MatchFinder_GetSubValue(CMatchFinder *p) -{ - return (p->pos - p->historySize - 1) & kNormalizeMask; -} - -void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems) -{ - UInt32 i; - for (i = 0; i < numItems; i++) - { - UInt32 value = items[i]; - if (value <= subValue) - value = kEmptyHashValue; - else - value -= subValue; - items[i] = value; - } -} - -static void MatchFinder_Normalize(CMatchFinder *p) -{ - UInt32 subValue = MatchFinder_GetSubValue(p); - MatchFinder_Normalize3(subValue, p->hash, p->hashSizeSum + p->numSons); - MatchFinder_ReduceOffsets(p, subValue); -} - -static void MatchFinder_CheckLimits(CMatchFinder *p) -{ - if (p->pos == kMaxValForNormalize) - MatchFinder_Normalize(p); - if (!p->streamEndWasReached && p->keepSizeAfter == p->streamPos - p->pos) - MatchFinder_CheckAndMoveAndRead(p); - if (p->cyclicBufferPos == p->cyclicBufferSize) - p->cyclicBufferPos = 0; - MatchFinder_SetLimits(p); -} - -static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, - UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue, - UInt32 *distances, UInt32 maxLen) -{ - son[_cyclicBufferPos] = curMatch; - for (;;) - { - UInt32 delta = pos - curMatch; - if (cutValue-- == 0 || delta >= _cyclicBufferSize) - return distances; - { - const Byte *pb = cur - delta; - curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)]; - if (pb[maxLen] == cur[maxLen] && *pb == *cur) - { - UInt32 len = 0; - while (++len != lenLimit) - if (pb[len] != cur[len]) - break; - if (maxLen < len) - { - *distances++ = maxLen = len; - *distances++ = delta - 1; - if (len == lenLimit) - return distances; - } - } - } - } -} - -UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, - UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue, - UInt32 *distances, UInt32 maxLen) -{ - CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1; - CLzRef *ptr1 = son + (_cyclicBufferPos << 1); - UInt32 len0 = 0, len1 = 0; - for (;;) - { - UInt32 delta = pos - curMatch; - if (cutValue-- == 0 || delta >= _cyclicBufferSize) - { - *ptr0 = *ptr1 = kEmptyHashValue; - return distances; - } - { - CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1); - const Byte *pb = cur - delta; - UInt32 len = (len0 < len1 ? len0 : len1); - if (pb[len] == cur[len]) - { - if (++len != lenLimit && pb[len] == cur[len]) - while (++len != lenLimit) - if (pb[len] != cur[len]) - break; - if (maxLen < len) - { - *distances++ = maxLen = len; - *distances++ = delta - 1; - if (len == lenLimit) - { - *ptr1 = pair[0]; - *ptr0 = pair[1]; - return distances; - } - } - } - if (pb[len] < cur[len]) - { - *ptr1 = curMatch; - ptr1 = pair + 1; - curMatch = *ptr1; - len1 = len; - } - else - { - *ptr0 = curMatch; - ptr0 = pair; - curMatch = *ptr0; - len0 = len; - } - } - } -} - -static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, - UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue) -{ - CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1; - CLzRef *ptr1 = son + (_cyclicBufferPos << 1); - UInt32 len0 = 0, len1 = 0; - for (;;) - { - UInt32 delta = pos - curMatch; - if (cutValue-- == 0 || delta >= _cyclicBufferSize) - { - *ptr0 = *ptr1 = kEmptyHashValue; - return; - } - { - CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1); - const Byte *pb = cur - delta; - UInt32 len = (len0 < len1 ? len0 : len1); - if (pb[len] == cur[len]) - { - while (++len != lenLimit) - if (pb[len] != cur[len]) - break; - { - if (len == lenLimit) - { - *ptr1 = pair[0]; - *ptr0 = pair[1]; - return; - } - } - } - if (pb[len] < cur[len]) - { - *ptr1 = curMatch; - ptr1 = pair + 1; - curMatch = *ptr1; - len1 = len; - } - else - { - *ptr0 = curMatch; - ptr0 = pair; - curMatch = *ptr0; - len0 = len; - } - } - } -} - -#define MOVE_POS \ - ++p->cyclicBufferPos; \ - p->buffer++; \ - if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p); - -#define MOVE_POS_RET MOVE_POS return offset; - -static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; } - -#define GET_MATCHES_HEADER2(minLen, ret_op) \ - UInt32 lenLimit; UInt32 hashValue; const Byte *cur; UInt32 curMatch; \ - lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \ - cur = p->buffer; - -#define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return 0) -#define SKIP_HEADER(minLen) GET_MATCHES_HEADER2(minLen, continue) - -#define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue - -#define GET_MATCHES_FOOTER(offset, maxLen) \ - offset = (UInt32)(GetMatchesSpec1(lenLimit, curMatch, MF_PARAMS(p), \ - distances + offset, maxLen) - distances); MOVE_POS_RET; - -#define SKIP_FOOTER \ - SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS; - -static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) -{ - UInt32 offset; - GET_MATCHES_HEADER(2) - HASH2_CALC; - curMatch = p->hash[hashValue]; - p->hash[hashValue] = p->pos; - offset = 0; - GET_MATCHES_FOOTER(offset, 1) -} - -UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) -{ - UInt32 offset; - GET_MATCHES_HEADER(3) - HASH_ZIP_CALC; - curMatch = p->hash[hashValue]; - p->hash[hashValue] = p->pos; - offset = 0; - GET_MATCHES_FOOTER(offset, 2) -} - -static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) -{ - UInt32 hash2Value, delta2, maxLen, offset; - GET_MATCHES_HEADER(3) - - HASH3_CALC; - - delta2 = p->pos - p->hash[hash2Value]; - curMatch = p->hash[kFix3HashSize + hashValue]; - - p->hash[hash2Value] = - p->hash[kFix3HashSize + hashValue] = p->pos; - - - maxLen = 2; - offset = 0; - if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur) - { - for (; maxLen != lenLimit; maxLen++) - if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen]) - break; - distances[0] = maxLen; - distances[1] = delta2 - 1; - offset = 2; - if (maxLen == lenLimit) - { - SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); - MOVE_POS_RET; - } - } - GET_MATCHES_FOOTER(offset, maxLen) -} - -static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) -{ - UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset; - GET_MATCHES_HEADER(4) - - HASH4_CALC; - - delta2 = p->pos - p->hash[ hash2Value]; - delta3 = p->pos - p->hash[kFix3HashSize + hash3Value]; - curMatch = p->hash[kFix4HashSize + hashValue]; - - p->hash[ hash2Value] = - p->hash[kFix3HashSize + hash3Value] = - p->hash[kFix4HashSize + hashValue] = p->pos; - - maxLen = 1; - offset = 0; - if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur) - { - distances[0] = maxLen = 2; - distances[1] = delta2 - 1; - offset = 2; - } - if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur) - { - maxLen = 3; - distances[offset + 1] = delta3 - 1; - offset += 2; - delta2 = delta3; - } - if (offset != 0) - { - for (; maxLen != lenLimit; maxLen++) - if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen]) - break; - distances[offset - 2] = maxLen; - if (maxLen == lenLimit) - { - SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); - MOVE_POS_RET; - } - } - if (maxLen < 3) - maxLen = 3; - GET_MATCHES_FOOTER(offset, maxLen) -} - -static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) -{ - UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset; - GET_MATCHES_HEADER(4) - - HASH4_CALC; - - delta2 = p->pos - p->hash[ hash2Value]; - delta3 = p->pos - p->hash[kFix3HashSize + hash3Value]; - curMatch = p->hash[kFix4HashSize + hashValue]; - - p->hash[ hash2Value] = - p->hash[kFix3HashSize + hash3Value] = - p->hash[kFix4HashSize + hashValue] = p->pos; - - maxLen = 1; - offset = 0; - if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur) - { - distances[0] = maxLen = 2; - distances[1] = delta2 - 1; - offset = 2; - } - if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur) - { - maxLen = 3; - distances[offset + 1] = delta3 - 1; - offset += 2; - delta2 = delta3; - } - if (offset != 0) - { - for (; maxLen != lenLimit; maxLen++) - if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen]) - break; - distances[offset - 2] = maxLen; - if (maxLen == lenLimit) - { - p->son[p->cyclicBufferPos] = curMatch; - MOVE_POS_RET; - } - } - if (maxLen < 3) - maxLen = 3; - offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p), - distances + offset, maxLen) - (distances)); - MOVE_POS_RET -} - -UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) -{ - UInt32 offset; - GET_MATCHES_HEADER(3) - HASH_ZIP_CALC; - curMatch = p->hash[hashValue]; - p->hash[hashValue] = p->pos; - offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p), - distances, 2) - (distances)); - MOVE_POS_RET -} - -static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num) -{ - do - { - SKIP_HEADER(2) - HASH2_CALC; - curMatch = p->hash[hashValue]; - p->hash[hashValue] = p->pos; - SKIP_FOOTER - } - while (--num != 0); -} - -void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) -{ - do - { - SKIP_HEADER(3) - HASH_ZIP_CALC; - curMatch = p->hash[hashValue]; - p->hash[hashValue] = p->pos; - SKIP_FOOTER - } - while (--num != 0); -} - -static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num) -{ - do - { - UInt32 hash2Value; - SKIP_HEADER(3) - HASH3_CALC; - curMatch = p->hash[kFix3HashSize + hashValue]; - p->hash[hash2Value] = - p->hash[kFix3HashSize + hashValue] = p->pos; - SKIP_FOOTER - } - while (--num != 0); -} - -static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) -{ - do - { - UInt32 hash2Value, hash3Value; - SKIP_HEADER(4) - HASH4_CALC; - curMatch = p->hash[kFix4HashSize + hashValue]; - p->hash[ hash2Value] = - p->hash[kFix3HashSize + hash3Value] = p->pos; - p->hash[kFix4HashSize + hashValue] = p->pos; - SKIP_FOOTER - } - while (--num != 0); -} - -static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) -{ - do - { - UInt32 hash2Value, hash3Value; - SKIP_HEADER(4) - HASH4_CALC; - curMatch = p->hash[kFix4HashSize + hashValue]; - p->hash[ hash2Value] = - p->hash[kFix3HashSize + hash3Value] = - p->hash[kFix4HashSize + hashValue] = p->pos; - p->son[p->cyclicBufferPos] = curMatch; - MOVE_POS - } - while (--num != 0); -} - -void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) -{ - do - { - SKIP_HEADER(3) - HASH_ZIP_CALC; - curMatch = p->hash[hashValue]; - p->hash[hashValue] = p->pos; - p->son[p->cyclicBufferPos] = curMatch; - MOVE_POS - } - while (--num != 0); -} - -void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable) -{ - vTable->Init = (Mf_Init_Func)MatchFinder_Init; - vTable->GetIndexByte = (Mf_GetIndexByte_Func)MatchFinder_GetIndexByte; - vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes; - vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPos; - if (!p->btMode) - { - vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches; - vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip; - } - else if (p->numHashBytes == 2) - { - vTable->GetMatches = (Mf_GetMatches_Func)Bt2_MatchFinder_GetMatches; - vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip; - } - else if (p->numHashBytes == 3) - { - vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches; - vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip; - } - else - { - vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches; - vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip; - } -} diff --git a/libs/storm-sys/StormLib/src/lzma/C/LzFind.h b/libs/storm-sys/StormLib/src/lzma/C/LzFind.h deleted file mode 100644 index 010c4b9..0000000 --- a/libs/storm-sys/StormLib/src/lzma/C/LzFind.h +++ /dev/null @@ -1,115 +0,0 @@ -/* LzFind.h -- Match finder for LZ algorithms -2009-04-22 : Igor Pavlov : Public domain */ - -#ifndef __LZ_FIND_H -#define __LZ_FIND_H - -#include "Types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef UInt32 CLzRef; - -typedef struct _CMatchFinder -{ - Byte *buffer; - UInt32 pos; - UInt32 posLimit; - UInt32 streamPos; - UInt32 lenLimit; - - UInt32 cyclicBufferPos; - UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */ - - UInt32 matchMaxLen; - CLzRef *hash; - CLzRef *son; - UInt32 hashMask; - UInt32 cutValue; - - Byte *bufferBase; - ISeqInStream *stream; - int streamEndWasReached; - - UInt32 blockSize; - UInt32 keepSizeBefore; - UInt32 keepSizeAfter; - - UInt32 numHashBytes; - int directInput; - size_t directInputRem; - int btMode; - int bigHash; - UInt32 historySize; - UInt32 fixedHashSize; - UInt32 hashSizeSum; - UInt32 numSons; - SRes result; - UInt32 crc[256]; -} CMatchFinder; - -#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer) -#define Inline_MatchFinder_GetIndexByte(p, index) ((p)->buffer[(Int32)(index)]) - -#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos) - -int MatchFinder_NeedMove(CMatchFinder *p); -Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p); -void MatchFinder_MoveBlock(CMatchFinder *p); -void MatchFinder_ReadIfRequired(CMatchFinder *p); - -void MatchFinder_Construct(CMatchFinder *p); - -/* Conditions: - historySize <= 3 GB - keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB -*/ -int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, - UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter, - ISzAlloc *alloc); -void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc); -void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems); -void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue); - -UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son, - UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue, - UInt32 *distances, UInt32 maxLen); - -/* -Conditions: - Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func. - Mf_GetPointerToCurrentPos_Func's result must be used only before any other function -*/ - -typedef void (*Mf_Init_Func)(void *object); -typedef Byte (*Mf_GetIndexByte_Func)(void *object, Int32 index); -typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object); -typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object); -typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances); -typedef void (*Mf_Skip_Func)(void *object, UInt32); - -typedef struct _IMatchFinder -{ - Mf_Init_Func Init; - Mf_GetIndexByte_Func GetIndexByte; - Mf_GetNumAvailableBytes_Func GetNumAvailableBytes; - Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos; - Mf_GetMatches_Func GetMatches; - Mf_Skip_Func Skip; -} IMatchFinder; - -void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable); - -void MatchFinder_Init(CMatchFinder *p); -UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); -UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); -void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num); -void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libs/storm-sys/StormLib/src/lzma/C/LzFindMt.c b/libs/storm-sys/StormLib/src/lzma/C/LzFindMt.c deleted file mode 100644 index aa41ed9..0000000 --- a/libs/storm-sys/StormLib/src/lzma/C/LzFindMt.c +++ /dev/null @@ -1,793 +0,0 @@ -/* LzFindMt.c -- multithreaded Match finder for LZ algorithms -2009-09-20 : Igor Pavlov : Public domain */ - -#include "LzHash.h" - -#include "LzFindMt.h" - -void MtSync_Construct(CMtSync *p) -{ - p->wasCreated = False; - p->csWasInitialized = False; - p->csWasEntered = False; - Thread_Construct(&p->thread); - Event_Construct(&p->canStart); - Event_Construct(&p->wasStarted); - Event_Construct(&p->wasStopped); - Semaphore_Construct(&p->freeSemaphore); - Semaphore_Construct(&p->filledSemaphore); -} - -void MtSync_GetNextBlock(CMtSync *p) -{ - if (p->needStart) - { - p->numProcessedBlocks = 1; - p->needStart = False; - p->stopWriting = False; - p->exit = False; - Event_Reset(&p->wasStarted); - Event_Reset(&p->wasStopped); - - Event_Set(&p->canStart); - Event_Wait(&p->wasStarted); - } - else - { - CriticalSection_Leave(&p->cs); - p->csWasEntered = False; - p->numProcessedBlocks++; - Semaphore_Release1(&p->freeSemaphore); - } - Semaphore_Wait(&p->filledSemaphore); - CriticalSection_Enter(&p->cs); - p->csWasEntered = True; -} - -/* MtSync_StopWriting must be called if Writing was started */ - -void MtSync_StopWriting(CMtSync *p) -{ - UInt32 myNumBlocks = p->numProcessedBlocks; - if (!Thread_WasCreated(&p->thread) || p->needStart) - return; - p->stopWriting = True; - if (p->csWasEntered) - { - CriticalSection_Leave(&p->cs); - p->csWasEntered = False; - } - Semaphore_Release1(&p->freeSemaphore); - - Event_Wait(&p->wasStopped); - - while (myNumBlocks++ != p->numProcessedBlocks) - { - Semaphore_Wait(&p->filledSemaphore); - Semaphore_Release1(&p->freeSemaphore); - } - p->needStart = True; -} - -void MtSync_Destruct(CMtSync *p) -{ - if (Thread_WasCreated(&p->thread)) - { - MtSync_StopWriting(p); - p->exit = True; - if (p->needStart) - Event_Set(&p->canStart); - Thread_Wait(&p->thread); - Thread_Close(&p->thread); - } - if (p->csWasInitialized) - { - CriticalSection_Delete(&p->cs); - p->csWasInitialized = False; - } - - Event_Close(&p->canStart); - Event_Close(&p->wasStarted); - Event_Close(&p->wasStopped); - Semaphore_Close(&p->freeSemaphore); - Semaphore_Close(&p->filledSemaphore); - - p->wasCreated = False; -} - -#define RINOK_THREAD(x) { if ((x) != 0) return SZ_ERROR_THREAD; } - -static SRes MtSync_Create2(CMtSync *p, unsigned (MY_STD_CALL *startAddress)(void *), void *obj, UInt32 numBlocks) -{ - if (p->wasCreated) - return SZ_OK; - - RINOK_THREAD(CriticalSection_Init(&p->cs)); - p->csWasInitialized = True; - - RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->canStart)); - RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->wasStarted)); - RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->wasStopped)); - - RINOK_THREAD(Semaphore_Create(&p->freeSemaphore, numBlocks, numBlocks)); - RINOK_THREAD(Semaphore_Create(&p->filledSemaphore, 0, numBlocks)); - - p->needStart = True; - - RINOK_THREAD(Thread_Create(&p->thread, startAddress, obj)); - p->wasCreated = True; - return SZ_OK; -} - -static SRes MtSync_Create(CMtSync *p, unsigned (MY_STD_CALL *startAddress)(void *), void *obj, UInt32 numBlocks) -{ - SRes res = MtSync_Create2(p, startAddress, obj, numBlocks); - if (res != SZ_OK) - MtSync_Destruct(p); - return res; -} - -void MtSync_Init(CMtSync *p) { p->needStart = True; } - -#define kMtMaxValForNormalize 0xFFFFFFFF - -#define DEF_GetHeads2(name, v, action) \ -static void GetHeads ## name(const Byte *p, UInt32 pos, \ -UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads, const UInt32 *crc) \ -{ action; for (; numHeads != 0; numHeads--) { \ -const UInt32 value = (v); p++; *heads++ = pos - hash[value]; hash[value] = pos++; } } - -#define DEF_GetHeads(name, v) DEF_GetHeads2(name, v, ;) - -DEF_GetHeads2(2, (p[0] | ((UInt32)p[1] << 8)), hashMask = hashMask; crc = crc; ) -DEF_GetHeads(3, (crc[p[0]] ^ p[1] ^ ((UInt32)p[2] << 8)) & hashMask) -DEF_GetHeads(4, (crc[p[0]] ^ p[1] ^ ((UInt32)p[2] << 8) ^ (crc[p[3]] << 5)) & hashMask) -DEF_GetHeads(4b, (crc[p[0]] ^ p[1] ^ ((UInt32)p[2] << 8) ^ ((UInt32)p[3] << 16)) & hashMask) -/* DEF_GetHeads(5, (crc[p[0]] ^ p[1] ^ ((UInt32)p[2] << 8) ^ (crc[p[3]] << 5) ^ (crc[p[4]] << 3)) & hashMask) */ - -void HashThreadFunc(CMatchFinderMt *mt) -{ - CMtSync *p = &mt->hashSync; - for (;;) - { - UInt32 numProcessedBlocks = 0; - Event_Wait(&p->canStart); - Event_Set(&p->wasStarted); - for (;;) - { - if (p->exit) - return; - if (p->stopWriting) - { - p->numProcessedBlocks = numProcessedBlocks; - Event_Set(&p->wasStopped); - break; - } - - { - CMatchFinder *mf = mt->MatchFinder; - if (MatchFinder_NeedMove(mf)) - { - CriticalSection_Enter(&mt->btSync.cs); - CriticalSection_Enter(&mt->hashSync.cs); - { - const Byte *beforePtr = MatchFinder_GetPointerToCurrentPos(mf); - const Byte *afterPtr; - MatchFinder_MoveBlock(mf); - afterPtr = MatchFinder_GetPointerToCurrentPos(mf); - mt->pointerToCurPos -= beforePtr - afterPtr; - mt->buffer -= beforePtr - afterPtr; - } - CriticalSection_Leave(&mt->btSync.cs); - CriticalSection_Leave(&mt->hashSync.cs); - continue; - } - - Semaphore_Wait(&p->freeSemaphore); - - MatchFinder_ReadIfRequired(mf); - if (mf->pos > (kMtMaxValForNormalize - kMtHashBlockSize)) - { - UInt32 subValue = (mf->pos - mf->historySize - 1); - MatchFinder_ReduceOffsets(mf, subValue); - MatchFinder_Normalize3(subValue, mf->hash + mf->fixedHashSize, mf->hashMask + 1); - } - { - UInt32 *heads = mt->hashBuf + ((numProcessedBlocks++) & kMtHashNumBlocksMask) * kMtHashBlockSize; - UInt32 num = mf->streamPos - mf->pos; - heads[0] = 2; - heads[1] = num; - if (num >= mf->numHashBytes) - { - num = num - mf->numHashBytes + 1; - if (num > kMtHashBlockSize - 2) - num = kMtHashBlockSize - 2; - mt->GetHeadsFunc(mf->buffer, mf->pos, mf->hash + mf->fixedHashSize, mf->hashMask, heads + 2, num, mf->crc); - heads[0] += num; - } - mf->pos += num; - mf->buffer += num; - } - } - - Semaphore_Release1(&p->filledSemaphore); - } - } -} - -void MatchFinderMt_GetNextBlock_Hash(CMatchFinderMt *p) -{ - MtSync_GetNextBlock(&p->hashSync); - p->hashBufPosLimit = p->hashBufPos = ((p->hashSync.numProcessedBlocks - 1) & kMtHashNumBlocksMask) * kMtHashBlockSize; - p->hashBufPosLimit += p->hashBuf[p->hashBufPos++]; - p->hashNumAvail = p->hashBuf[p->hashBufPos++]; -} - -#define kEmptyHashValue 0 - -/* #define MFMT_GM_INLINE */ - -#ifdef MFMT_GM_INLINE - -#define NO_INLINE MY_FAST_CALL - -Int32 NO_INLINE GetMatchesSpecN(UInt32 lenLimit, UInt32 pos, const Byte *cur, CLzRef *son, - UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue, - UInt32 *_distances, UInt32 _maxLen, const UInt32 *hash, Int32 limit, UInt32 size, UInt32 *posRes) -{ - do - { - UInt32 *distances = _distances + 1; - UInt32 curMatch = pos - *hash++; - - CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1; - CLzRef *ptr1 = son + (_cyclicBufferPos << 1); - UInt32 len0 = 0, len1 = 0; - UInt32 cutValue = _cutValue; - UInt32 maxLen = _maxLen; - for (;;) - { - UInt32 delta = pos - curMatch; - if (cutValue-- == 0 || delta >= _cyclicBufferSize) - { - *ptr0 = *ptr1 = kEmptyHashValue; - break; - } - { - CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1); - const Byte *pb = cur - delta; - UInt32 len = (len0 < len1 ? len0 : len1); - if (pb[len] == cur[len]) - { - if (++len != lenLimit && pb[len] == cur[len]) - while (++len != lenLimit) - if (pb[len] != cur[len]) - break; - if (maxLen < len) - { - *distances++ = maxLen = len; - *distances++ = delta - 1; - if (len == lenLimit) - { - *ptr1 = pair[0]; - *ptr0 = pair[1]; - break; - } - } - } - if (pb[len] < cur[len]) - { - *ptr1 = curMatch; - ptr1 = pair + 1; - curMatch = *ptr1; - len1 = len; - } - else - { - *ptr0 = curMatch; - ptr0 = pair; - curMatch = *ptr0; - len0 = len; - } - } - } - pos++; - _cyclicBufferPos++; - cur++; - { - UInt32 num = (UInt32)(distances - _distances); - *_distances = num - 1; - _distances += num; - limit -= num; - } - } - while (limit > 0 && --size != 0); - *posRes = pos; - return limit; -} - -#endif - -void BtGetMatches(CMatchFinderMt *p, UInt32 *distances) -{ - UInt32 numProcessed = 0; - UInt32 curPos = 2; - UInt32 limit = kMtBtBlockSize - (p->matchMaxLen * 2); - distances[1] = p->hashNumAvail; - while (curPos < limit) - { - if (p->hashBufPos == p->hashBufPosLimit) - { - MatchFinderMt_GetNextBlock_Hash(p); - distances[1] = numProcessed + p->hashNumAvail; - if (p->hashNumAvail >= p->numHashBytes) - continue; - for (; p->hashNumAvail != 0; p->hashNumAvail--) - distances[curPos++] = 0; - break; - } - { - UInt32 size = p->hashBufPosLimit - p->hashBufPos; - UInt32 lenLimit = p->matchMaxLen; - UInt32 pos = p->pos; - UInt32 cyclicBufferPos = p->cyclicBufferPos; - if (lenLimit >= p->hashNumAvail) - lenLimit = p->hashNumAvail; - { - UInt32 size2 = p->hashNumAvail - lenLimit + 1; - if (size2 < size) - size = size2; - size2 = p->cyclicBufferSize - cyclicBufferPos; - if (size2 < size) - size = size2; - } - #ifndef MFMT_GM_INLINE - while (curPos < limit && size-- != 0) - { - UInt32 *startDistances = distances + curPos; - UInt32 num = (UInt32)(GetMatchesSpec1(lenLimit, pos - p->hashBuf[p->hashBufPos++], - pos, p->buffer, p->son, cyclicBufferPos, p->cyclicBufferSize, p->cutValue, - startDistances + 1, p->numHashBytes - 1) - startDistances); - *startDistances = num - 1; - curPos += num; - cyclicBufferPos++; - pos++; - p->buffer++; - } - #else - { - UInt32 posRes; - curPos = limit - GetMatchesSpecN(lenLimit, pos, p->buffer, p->son, cyclicBufferPos, p->cyclicBufferSize, p->cutValue, - distances + curPos, p->numHashBytes - 1, p->hashBuf + p->hashBufPos, (Int32)(limit - curPos) , size, &posRes); - p->hashBufPos += posRes - pos; - cyclicBufferPos += posRes - pos; - p->buffer += posRes - pos; - pos = posRes; - } - #endif - - numProcessed += pos - p->pos; - p->hashNumAvail -= pos - p->pos; - p->pos = pos; - if (cyclicBufferPos == p->cyclicBufferSize) - cyclicBufferPos = 0; - p->cyclicBufferPos = cyclicBufferPos; - } - } - distances[0] = curPos; -} - -void BtFillBlock(CMatchFinderMt *p, UInt32 globalBlockIndex) -{ - CMtSync *sync = &p->hashSync; - if (!sync->needStart) - { - CriticalSection_Enter(&sync->cs); - sync->csWasEntered = True; - } - - BtGetMatches(p, p->btBuf + (globalBlockIndex & kMtBtNumBlocksMask) * kMtBtBlockSize); - - if (p->pos > kMtMaxValForNormalize - kMtBtBlockSize) - { - UInt32 subValue = p->pos - p->cyclicBufferSize; - MatchFinder_Normalize3(subValue, p->son, p->cyclicBufferSize * 2); - p->pos -= subValue; - } - - if (!sync->needStart) - { - CriticalSection_Leave(&sync->cs); - sync->csWasEntered = False; - } -} - -void BtThreadFunc(CMatchFinderMt *mt) -{ - CMtSync *p = &mt->btSync; - for (;;) - { - UInt32 blockIndex = 0; - Event_Wait(&p->canStart); - Event_Set(&p->wasStarted); - for (;;) - { - if (p->exit) - return; - if (p->stopWriting) - { - p->numProcessedBlocks = blockIndex; - MtSync_StopWriting(&mt->hashSync); - Event_Set(&p->wasStopped); - break; - } - Semaphore_Wait(&p->freeSemaphore); - BtFillBlock(mt, blockIndex++); - Semaphore_Release1(&p->filledSemaphore); - } - } -} - -void MatchFinderMt_Construct(CMatchFinderMt *p) -{ - p->hashBuf = 0; - MtSync_Construct(&p->hashSync); - MtSync_Construct(&p->btSync); -} - -void MatchFinderMt_FreeMem(CMatchFinderMt *p, ISzAlloc *alloc) -{ - alloc->Free(alloc, p->hashBuf); - p->hashBuf = 0; -} - -void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAlloc *alloc) -{ - MtSync_Destruct(&p->hashSync); - MtSync_Destruct(&p->btSync); - MatchFinderMt_FreeMem(p, alloc); -} - -#define kHashBufferSize (kMtHashBlockSize * kMtHashNumBlocks) -#define kBtBufferSize (kMtBtBlockSize * kMtBtNumBlocks) - -static unsigned MY_STD_CALL HashThreadFunc2(void *p) { HashThreadFunc((CMatchFinderMt *)p); return 0; } -static unsigned MY_STD_CALL BtThreadFunc2(void *p) -{ - Byte allocaDummy[0x180]; - int i = 0; - for (i = 0; i < 16; i++) - allocaDummy[i] = (Byte)i; - BtThreadFunc((CMatchFinderMt *)p); - return 0; -} - -SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore, - UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAlloc *alloc) -{ - CMatchFinder *mf = p->MatchFinder; - p->historySize = historySize; - if (kMtBtBlockSize <= matchMaxLen * 4) - return SZ_ERROR_PARAM; - if (p->hashBuf == 0) - { - p->hashBuf = (UInt32 *)alloc->Alloc(alloc, (kHashBufferSize + kBtBufferSize) * sizeof(UInt32)); - if (p->hashBuf == 0) - return SZ_ERROR_MEM; - p->btBuf = p->hashBuf + kHashBufferSize; - } - keepAddBufferBefore += (kHashBufferSize + kBtBufferSize); - keepAddBufferAfter += kMtHashBlockSize; - if (!MatchFinder_Create(mf, historySize, keepAddBufferBefore, matchMaxLen, keepAddBufferAfter, alloc)) - return SZ_ERROR_MEM; - - RINOK(MtSync_Create(&p->hashSync, HashThreadFunc2, p, kMtHashNumBlocks)); - RINOK(MtSync_Create(&p->btSync, BtThreadFunc2, p, kMtBtNumBlocks)); - return SZ_OK; -} - -/* Call it after ReleaseStream / SetStream */ -void MatchFinderMt_Init(CMatchFinderMt *p) -{ - CMatchFinder *mf = p->MatchFinder; - p->btBufPos = p->btBufPosLimit = 0; - p->hashBufPos = p->hashBufPosLimit = 0; - MatchFinder_Init(mf); - p->pointerToCurPos = MatchFinder_GetPointerToCurrentPos(mf); - p->btNumAvailBytes = 0; - p->lzPos = p->historySize + 1; - - p->hash = mf->hash; - p->fixedHashSize = mf->fixedHashSize; - p->crc = mf->crc; - - p->son = mf->son; - p->matchMaxLen = mf->matchMaxLen; - p->numHashBytes = mf->numHashBytes; - p->pos = mf->pos; - p->buffer = mf->buffer; - p->cyclicBufferPos = mf->cyclicBufferPos; - p->cyclicBufferSize = mf->cyclicBufferSize; - p->cutValue = mf->cutValue; -} - -/* ReleaseStream is required to finish multithreading */ -void MatchFinderMt_ReleaseStream(CMatchFinderMt *p) -{ - MtSync_StopWriting(&p->btSync); - /* p->MatchFinder->ReleaseStream(); */ -} - -void MatchFinderMt_Normalize(CMatchFinderMt *p) -{ - MatchFinder_Normalize3(p->lzPos - p->historySize - 1, p->hash, p->fixedHashSize); - p->lzPos = p->historySize + 1; -} - -void MatchFinderMt_GetNextBlock_Bt(CMatchFinderMt *p) -{ - UInt32 blockIndex; - MtSync_GetNextBlock(&p->btSync); - blockIndex = ((p->btSync.numProcessedBlocks - 1) & kMtBtNumBlocksMask); - p->btBufPosLimit = p->btBufPos = blockIndex * kMtBtBlockSize; - p->btBufPosLimit += p->btBuf[p->btBufPos++]; - p->btNumAvailBytes = p->btBuf[p->btBufPos++]; - if (p->lzPos >= kMtMaxValForNormalize - kMtBtBlockSize) - MatchFinderMt_Normalize(p); -} - -const Byte * MatchFinderMt_GetPointerToCurrentPos(CMatchFinderMt *p) -{ - return p->pointerToCurPos; -} - -#define GET_NEXT_BLOCK_IF_REQUIRED if (p->btBufPos == p->btBufPosLimit) MatchFinderMt_GetNextBlock_Bt(p); - -UInt32 MatchFinderMt_GetNumAvailableBytes(CMatchFinderMt *p) -{ - GET_NEXT_BLOCK_IF_REQUIRED; - return p->btNumAvailBytes; -} - -Byte MatchFinderMt_GetIndexByte(CMatchFinderMt *p, Int32 index) -{ - return p->pointerToCurPos[index]; -} - -UInt32 * MixMatches2(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances) -{ - UInt32 hash2Value, curMatch2; - UInt32 *hash = p->hash; - const Byte *cur = p->pointerToCurPos; - UInt32 lzPos = p->lzPos; - MT_HASH2_CALC - - curMatch2 = hash[hash2Value]; - hash[hash2Value] = lzPos; - - if (curMatch2 >= matchMinPos) - if (cur[(ptrdiff_t)curMatch2 - lzPos] == cur[0]) - { - *distances++ = 2; - *distances++ = lzPos - curMatch2 - 1; - } - return distances; -} - -UInt32 * MixMatches3(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances) -{ - UInt32 hash2Value, hash3Value, curMatch2, curMatch3; - UInt32 *hash = p->hash; - const Byte *cur = p->pointerToCurPos; - UInt32 lzPos = p->lzPos; - MT_HASH3_CALC - - curMatch2 = hash[ hash2Value]; - curMatch3 = hash[kFix3HashSize + hash3Value]; - - hash[ hash2Value] = - hash[kFix3HashSize + hash3Value] = - lzPos; - - if (curMatch2 >= matchMinPos && cur[(ptrdiff_t)curMatch2 - lzPos] == cur[0]) - { - distances[1] = lzPos - curMatch2 - 1; - if (cur[(ptrdiff_t)curMatch2 - lzPos + 2] == cur[2]) - { - distances[0] = 3; - return distances + 2; - } - distances[0] = 2; - distances += 2; - } - if (curMatch3 >= matchMinPos && cur[(ptrdiff_t)curMatch3 - lzPos] == cur[0]) - { - *distances++ = 3; - *distances++ = lzPos - curMatch3 - 1; - } - return distances; -} - -/* -UInt32 *MixMatches4(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances) -{ - UInt32 hash2Value, hash3Value, hash4Value, curMatch2, curMatch3, curMatch4; - UInt32 *hash = p->hash; - const Byte *cur = p->pointerToCurPos; - UInt32 lzPos = p->lzPos; - MT_HASH4_CALC - - curMatch2 = hash[ hash2Value]; - curMatch3 = hash[kFix3HashSize + hash3Value]; - curMatch4 = hash[kFix4HashSize + hash4Value]; - - hash[ hash2Value] = - hash[kFix3HashSize + hash3Value] = - hash[kFix4HashSize + hash4Value] = - lzPos; - - if (curMatch2 >= matchMinPos && cur[(ptrdiff_t)curMatch2 - lzPos] == cur[0]) - { - distances[1] = lzPos - curMatch2 - 1; - if (cur[(ptrdiff_t)curMatch2 - lzPos + 2] == cur[2]) - { - distances[0] = (cur[(ptrdiff_t)curMatch2 - lzPos + 3] == cur[3]) ? 4 : 3; - return distances + 2; - } - distances[0] = 2; - distances += 2; - } - if (curMatch3 >= matchMinPos && cur[(ptrdiff_t)curMatch3 - lzPos] == cur[0]) - { - distances[1] = lzPos - curMatch3 - 1; - if (cur[(ptrdiff_t)curMatch3 - lzPos + 3] == cur[3]) - { - distances[0] = 4; - return distances + 2; - } - distances[0] = 3; - distances += 2; - } - - if (curMatch4 >= matchMinPos) - if ( - cur[(ptrdiff_t)curMatch4 - lzPos] == cur[0] && - cur[(ptrdiff_t)curMatch4 - lzPos + 3] == cur[3] - ) - { - *distances++ = 4; - *distances++ = lzPos - curMatch4 - 1; - } - return distances; -} -*/ - -#define INCREASE_LZ_POS p->lzPos++; p->pointerToCurPos++; - -UInt32 MatchFinderMt2_GetMatches(CMatchFinderMt *p, UInt32 *distances) -{ - const UInt32 *btBuf = p->btBuf + p->btBufPos; - UInt32 len = *btBuf++; - p->btBufPos += 1 + len; - p->btNumAvailBytes--; - { - UInt32 i; - for (i = 0; i < len; i += 2) - { - *distances++ = *btBuf++; - *distances++ = *btBuf++; - } - } - INCREASE_LZ_POS - return len; -} - -UInt32 MatchFinderMt_GetMatches(CMatchFinderMt *p, UInt32 *distances) -{ - const UInt32 *btBuf = p->btBuf + p->btBufPos; - UInt32 len = *btBuf++; - p->btBufPos += 1 + len; - - if (len == 0) - { - if (p->btNumAvailBytes-- >= 4) - len = (UInt32)(p->MixMatchesFunc(p, p->lzPos - p->historySize, distances) - (distances)); - } - else - { - /* Condition: there are matches in btBuf with length < p->numHashBytes */ - UInt32 *distances2; - p->btNumAvailBytes--; - distances2 = p->MixMatchesFunc(p, p->lzPos - btBuf[1], distances); - do - { - *distances2++ = *btBuf++; - *distances2++ = *btBuf++; - } - while ((len -= 2) != 0); - len = (UInt32)(distances2 - (distances)); - } - INCREASE_LZ_POS - return len; -} - -#define SKIP_HEADER2_MT do { GET_NEXT_BLOCK_IF_REQUIRED -#define SKIP_HEADER_MT(n) SKIP_HEADER2_MT if (p->btNumAvailBytes-- >= (n)) { const Byte *cur = p->pointerToCurPos; UInt32 *hash = p->hash; -#define SKIP_FOOTER_MT } INCREASE_LZ_POS p->btBufPos += p->btBuf[p->btBufPos] + 1; } while (--num != 0); - -void MatchFinderMt0_Skip(CMatchFinderMt *p, UInt32 num) -{ - SKIP_HEADER2_MT { p->btNumAvailBytes--; - SKIP_FOOTER_MT -} - -void MatchFinderMt2_Skip(CMatchFinderMt *p, UInt32 num) -{ - SKIP_HEADER_MT(2) - UInt32 hash2Value; - MT_HASH2_CALC - hash[hash2Value] = p->lzPos; - SKIP_FOOTER_MT -} - -void MatchFinderMt3_Skip(CMatchFinderMt *p, UInt32 num) -{ - SKIP_HEADER_MT(3) - UInt32 hash2Value, hash3Value; - MT_HASH3_CALC - hash[kFix3HashSize + hash3Value] = - hash[ hash2Value] = - p->lzPos; - SKIP_FOOTER_MT -} - -/* -void MatchFinderMt4_Skip(CMatchFinderMt *p, UInt32 num) -{ - SKIP_HEADER_MT(4) - UInt32 hash2Value, hash3Value, hash4Value; - MT_HASH4_CALC - hash[kFix4HashSize + hash4Value] = - hash[kFix3HashSize + hash3Value] = - hash[ hash2Value] = - p->lzPos; - SKIP_FOOTER_MT -} -*/ - -void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder *vTable) -{ - vTable->Init = (Mf_Init_Func)MatchFinderMt_Init; - vTable->GetIndexByte = (Mf_GetIndexByte_Func)MatchFinderMt_GetIndexByte; - vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinderMt_GetNumAvailableBytes; - vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinderMt_GetPointerToCurrentPos; - vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt_GetMatches; - switch(p->MatchFinder->numHashBytes) - { - case 2: - p->GetHeadsFunc = GetHeads2; - p->MixMatchesFunc = (Mf_Mix_Matches)0; - vTable->Skip = (Mf_Skip_Func)MatchFinderMt0_Skip; - vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt2_GetMatches; - break; - case 3: - p->GetHeadsFunc = GetHeads3; - p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches2; - vTable->Skip = (Mf_Skip_Func)MatchFinderMt2_Skip; - break; - default: - /* case 4: */ - p->GetHeadsFunc = p->MatchFinder->bigHash ? GetHeads4b : GetHeads4; - /* p->GetHeadsFunc = GetHeads4; */ - p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches3; - vTable->Skip = (Mf_Skip_Func)MatchFinderMt3_Skip; - break; - /* - default: - p->GetHeadsFunc = GetHeads5; - p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches4; - vTable->Skip = (Mf_Skip_Func)MatchFinderMt4_Skip; - break; - */ - } -} diff --git a/libs/storm-sys/StormLib/src/lzma/C/LzFindMt.h b/libs/storm-sys/StormLib/src/lzma/C/LzFindMt.h deleted file mode 100644 index b985af5..0000000 --- a/libs/storm-sys/StormLib/src/lzma/C/LzFindMt.h +++ /dev/null @@ -1,105 +0,0 @@ -/* LzFindMt.h -- multithreaded Match finder for LZ algorithms -2009-02-07 : Igor Pavlov : Public domain */ - -#ifndef __LZ_FIND_MT_H -#define __LZ_FIND_MT_H - -#include "LzFind.h" -#include "Threads.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define kMtHashBlockSize (1 << 13) -#define kMtHashNumBlocks (1 << 3) -#define kMtHashNumBlocksMask (kMtHashNumBlocks - 1) - -#define kMtBtBlockSize (1 << 14) -#define kMtBtNumBlocks (1 << 6) -#define kMtBtNumBlocksMask (kMtBtNumBlocks - 1) - -typedef struct _CMtSync -{ - Bool wasCreated; - Bool needStart; - Bool exit; - Bool stopWriting; - - CThread thread; - CAutoResetEvent canStart; - CAutoResetEvent wasStarted; - CAutoResetEvent wasStopped; - CSemaphore freeSemaphore; - CSemaphore filledSemaphore; - Bool csWasInitialized; - Bool csWasEntered; - CCriticalSection cs; - UInt32 numProcessedBlocks; -} CMtSync; - -typedef UInt32 * (*Mf_Mix_Matches)(void *p, UInt32 matchMinPos, UInt32 *distances); - -/* kMtCacheLineDummy must be >= size_of_CPU_cache_line */ -#define kMtCacheLineDummy 128 - -typedef void (*Mf_GetHeads)(const Byte *buffer, UInt32 pos, - UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads, const UInt32 *crc); - -typedef struct _CMatchFinderMt -{ - /* LZ */ - const Byte *pointerToCurPos; - UInt32 *btBuf; - UInt32 btBufPos; - UInt32 btBufPosLimit; - UInt32 lzPos; - UInt32 btNumAvailBytes; - - UInt32 *hash; - UInt32 fixedHashSize; - UInt32 historySize; - const UInt32 *crc; - - Mf_Mix_Matches MixMatchesFunc; - - /* LZ + BT */ - CMtSync btSync; - Byte btDummy[kMtCacheLineDummy]; - - /* BT */ - UInt32 *hashBuf; - UInt32 hashBufPos; - UInt32 hashBufPosLimit; - UInt32 hashNumAvail; - - CLzRef *son; - UInt32 matchMaxLen; - UInt32 numHashBytes; - UInt32 pos; - Byte *buffer; - UInt32 cyclicBufferPos; - UInt32 cyclicBufferSize; /* it must be historySize + 1 */ - UInt32 cutValue; - - /* BT + Hash */ - CMtSync hashSync; - /* Byte hashDummy[kMtCacheLineDummy]; */ - - /* Hash */ - Mf_GetHeads GetHeadsFunc; - CMatchFinder *MatchFinder; -} CMatchFinderMt; - -void MatchFinderMt_Construct(CMatchFinderMt *p); -void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAlloc *alloc); -SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore, - UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAlloc *alloc); -void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder *vTable); -void MatchFinderMt_ReleaseStream(CMatchFinderMt *p); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libs/storm-sys/StormLib/src/lzma/C/LzHash.h b/libs/storm-sys/StormLib/src/lzma/C/LzHash.h deleted file mode 100644 index f3e8996..0000000 --- a/libs/storm-sys/StormLib/src/lzma/C/LzHash.h +++ /dev/null @@ -1,54 +0,0 @@ -/* LzHash.h -- HASH functions for LZ algorithms -2009-02-07 : Igor Pavlov : Public domain */ - -#ifndef __LZ_HASH_H -#define __LZ_HASH_H - -#define kHash2Size (1 << 10) -#define kHash3Size (1 << 16) -#define kHash4Size (1 << 20) - -#define kFix3HashSize (kHash2Size) -#define kFix4HashSize (kHash2Size + kHash3Size) -#define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size) - -#define HASH2_CALC hashValue = cur[0] | ((UInt32)cur[1] << 8); - -#define HASH3_CALC { \ - UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ - hash2Value = temp & (kHash2Size - 1); \ - hashValue = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; } - -#define HASH4_CALC { \ - UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ - hash2Value = temp & (kHash2Size - 1); \ - hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ - hashValue = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & p->hashMask; } - -#define HASH5_CALC { \ - UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ - hash2Value = temp & (kHash2Size - 1); \ - hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ - hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)); \ - hashValue = (hash4Value ^ (p->crc[cur[4]] << 3)) & p->hashMask; \ - hash4Value &= (kHash4Size - 1); } - -/* #define HASH_ZIP_CALC hashValue = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */ -#define HASH_ZIP_CALC hashValue = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF; - - -#define MT_HASH2_CALC \ - hash2Value = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1); - -#define MT_HASH3_CALC { \ - UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ - hash2Value = temp & (kHash2Size - 1); \ - hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); } - -#define MT_HASH4_CALC { \ - UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ - hash2Value = temp & (kHash2Size - 1); \ - hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ - hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); } - -#endif diff --git a/libs/storm-sys/StormLib/src/lzma/C/LzmaDec.c b/libs/storm-sys/StormLib/src/lzma/C/LzmaDec.c deleted file mode 100644 index 2036761..0000000 --- a/libs/storm-sys/StormLib/src/lzma/C/LzmaDec.c +++ /dev/null @@ -1,999 +0,0 @@ -/* LzmaDec.c -- LZMA Decoder -2009-09-20 : Igor Pavlov : Public domain */ - -#include "LzmaDec.h" - -#include - -#define kNumTopBits 24 -#define kTopValue ((UInt32)1 << kNumTopBits) - -#define kNumBitModelTotalBits 11 -#define kBitModelTotal (1 << kNumBitModelTotalBits) -#define kNumMoveBits 5 - -#define RC_INIT_SIZE 5 - -#define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); } - -#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound) -#define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); -#define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits)); -#define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \ - { UPDATE_0(p); i = (i + i); A0; } else \ - { UPDATE_1(p); i = (i + i) + 1; A1; } -#define GET_BIT(p, i) GET_BIT2(p, i, ; , ;) - -#define TREE_GET_BIT(probs, i) { GET_BIT((probs + i), i); } -#define TREE_DECODE(probs, limit, i) \ - { i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; } - -/* #define _LZMA_SIZE_OPT */ - -#ifdef _LZMA_SIZE_OPT -#define TREE_6_DECODE(probs, i) TREE_DECODE(probs, (1 << 6), i) -#else -#define TREE_6_DECODE(probs, i) \ - { i = 1; \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - i -= 0x40; } -#endif - -#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); } - -#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound) -#define UPDATE_0_CHECK range = bound; -#define UPDATE_1_CHECK range -= bound; code -= bound; -#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \ - { UPDATE_0_CHECK; i = (i + i); A0; } else \ - { UPDATE_1_CHECK; i = (i + i) + 1; A1; } -#define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;) -#define TREE_DECODE_CHECK(probs, limit, i) \ - { i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; } - - -#define kNumPosBitsMax 4 -#define kNumPosStatesMax (1 << kNumPosBitsMax) - -#define kLenNumLowBits 3 -#define kLenNumLowSymbols (1 << kLenNumLowBits) -#define kLenNumMidBits 3 -#define kLenNumMidSymbols (1 << kLenNumMidBits) -#define kLenNumHighBits 8 -#define kLenNumHighSymbols (1 << kLenNumHighBits) - -#define LenChoice 0 -#define LenChoice2 (LenChoice + 1) -#define LenLow (LenChoice2 + 1) -#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits)) -#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits)) -#define kNumLenProbs (LenHigh + kLenNumHighSymbols) - - -#define kNumStates 12 -#define kNumLitStates 7 - -#define kStartPosModelIndex 4 -#define kEndPosModelIndex 14 -#define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) - -#define kNumPosSlotBits 6 -#define kNumLenToPosStates 4 - -#define kNumAlignBits 4 -#define kAlignTableSize (1 << kNumAlignBits) - -#define kMatchMinLen 2 -#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols) - -#define IsMatch 0 -#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax)) -#define IsRepG0 (IsRep + kNumStates) -#define IsRepG1 (IsRepG0 + kNumStates) -#define IsRepG2 (IsRepG1 + kNumStates) -#define IsRep0Long (IsRepG2 + kNumStates) -#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax)) -#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits)) -#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex) -#define LenCoder (Align + kAlignTableSize) -#define RepLenCoder (LenCoder + kNumLenProbs) -#define Literal (RepLenCoder + kNumLenProbs) - -#define LZMA_BASE_SIZE 1846 -#define LZMA_LIT_SIZE 768 - -#define LzmaProps_GetNumProbs(p) ((UInt32)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp))) - -#if Literal != LZMA_BASE_SIZE -StopCompilingDueBUG -#endif - -#define LZMA_DIC_MIN (1 << 12) - -/* First LZMA-symbol is always decoded. -And it decodes new LZMA-symbols while (buf < bufLimit), but "buf" is without last normalization -Out: - Result: - SZ_OK - OK - SZ_ERROR_DATA - Error - p->remainLen: - < kMatchSpecLenStart : normal remain - = kMatchSpecLenStart : finished - = kMatchSpecLenStart + 1 : Flush marker - = kMatchSpecLenStart + 2 : State Init Marker -*/ - -static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte *bufLimit) -{ - CLzmaProb *probs = p->probs; - - unsigned state = p->state; - UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3]; - unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1; - unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1; - unsigned lc = p->prop.lc; - - Byte *dic = p->dic; - SizeT dicBufSize = p->dicBufSize; - SizeT dicPos = p->dicPos; - - UInt32 processedPos = p->processedPos; - UInt32 checkDicSize = p->checkDicSize; - unsigned len = 0; - - const Byte *buf = p->buf; - UInt32 range = p->range; - UInt32 code = p->code; - - do - { - CLzmaProb *prob; - UInt32 bound; - unsigned ttt; - unsigned posState = processedPos & pbMask; - - prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; - IF_BIT_0(prob) - { - unsigned symbol; - UPDATE_0(prob); - prob = probs + Literal; - if (checkDicSize != 0 || processedPos != 0) - prob += (LZMA_LIT_SIZE * (((processedPos & lpMask) << lc) + - (dic[(dicPos == 0 ? dicBufSize : dicPos) - 1] >> (8 - lc)))); - - if (state < kNumLitStates) - { - state -= (state < 4) ? state : 3; - symbol = 1; - do { GET_BIT(prob + symbol, symbol) } while (symbol < 0x100); - } - else - { - unsigned matchByte = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; - unsigned offs = 0x100; - state -= (state < 10) ? 3 : 6; - symbol = 1; - do - { - unsigned bit; - CLzmaProb *probLit; - matchByte <<= 1; - bit = (matchByte & offs); - probLit = prob + offs + bit + symbol; - GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit) - } - while (symbol < 0x100); - } - dic[dicPos++] = (Byte)symbol; - processedPos++; - continue; - } - else - { - UPDATE_1(prob); - prob = probs + IsRep + state; - IF_BIT_0(prob) - { - UPDATE_0(prob); - state += kNumStates; - prob = probs + LenCoder; - } - else - { - UPDATE_1(prob); - if (checkDicSize == 0 && processedPos == 0) - return SZ_ERROR_DATA; - prob = probs + IsRepG0 + state; - IF_BIT_0(prob) - { - UPDATE_0(prob); - prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState; - IF_BIT_0(prob) - { - UPDATE_0(prob); - dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; - dicPos++; - processedPos++; - state = state < kNumLitStates ? 9 : 11; - continue; - } - UPDATE_1(prob); - } - else - { - UInt32 distance; - UPDATE_1(prob); - prob = probs + IsRepG1 + state; - IF_BIT_0(prob) - { - UPDATE_0(prob); - distance = rep1; - } - else - { - UPDATE_1(prob); - prob = probs + IsRepG2 + state; - IF_BIT_0(prob) - { - UPDATE_0(prob); - distance = rep2; - } - else - { - UPDATE_1(prob); - distance = rep3; - rep3 = rep2; - } - rep2 = rep1; - } - rep1 = rep0; - rep0 = distance; - } - state = state < kNumLitStates ? 8 : 11; - prob = probs + RepLenCoder; - } - { - unsigned limit, offset; - CLzmaProb *probLen = prob + LenChoice; - IF_BIT_0(probLen) - { - UPDATE_0(probLen); - probLen = prob + LenLow + (posState << kLenNumLowBits); - offset = 0; - limit = (1 << kLenNumLowBits); - } - else - { - UPDATE_1(probLen); - probLen = prob + LenChoice2; - IF_BIT_0(probLen) - { - UPDATE_0(probLen); - probLen = prob + LenMid + (posState << kLenNumMidBits); - offset = kLenNumLowSymbols; - limit = (1 << kLenNumMidBits); - } - else - { - UPDATE_1(probLen); - probLen = prob + LenHigh; - offset = kLenNumLowSymbols + kLenNumMidSymbols; - limit = (1 << kLenNumHighBits); - } - } - TREE_DECODE(probLen, limit, len); - len += offset; - } - - if (state >= kNumStates) - { - UInt32 distance; - prob = probs + PosSlot + - ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits); - TREE_6_DECODE(prob, distance); - if (distance >= kStartPosModelIndex) - { - unsigned posSlot = (unsigned)distance; - int numDirectBits = (int)(((distance >> 1) - 1)); - distance = (2 | (distance & 1)); - if (posSlot < kEndPosModelIndex) - { - distance <<= numDirectBits; - prob = probs + SpecPos + distance - posSlot - 1; - { - UInt32 mask = 1; - unsigned i = 1; - do - { - GET_BIT2(prob + i, i, ; , distance |= mask); - mask <<= 1; - } - while (--numDirectBits != 0); - } - } - else - { - numDirectBits -= kNumAlignBits; - do - { - NORMALIZE - range >>= 1; - - { - UInt32 t; - code -= range; - t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */ - distance = (distance << 1) + (t + 1); - code += range & t; - } - /* - distance <<= 1; - if (code >= range) - { - code -= range; - distance |= 1; - } - */ - } - while (--numDirectBits != 0); - prob = probs + Align; - distance <<= kNumAlignBits; - { - unsigned i = 1; - GET_BIT2(prob + i, i, ; , distance |= 1); - GET_BIT2(prob + i, i, ; , distance |= 2); - GET_BIT2(prob + i, i, ; , distance |= 4); - GET_BIT2(prob + i, i, ; , distance |= 8); - } - if (distance == (UInt32)0xFFFFFFFF) - { - len += kMatchSpecLenStart; - state -= kNumStates; - break; - } - } - } - rep3 = rep2; - rep2 = rep1; - rep1 = rep0; - rep0 = distance + 1; - if (checkDicSize == 0) - { - if (distance >= processedPos) - return SZ_ERROR_DATA; - } - else if (distance >= checkDicSize) - return SZ_ERROR_DATA; - state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3; - } - - len += kMatchMinLen; - - if (limit == dicPos) - return SZ_ERROR_DATA; - { - SizeT rem = limit - dicPos; - unsigned curLen = ((rem < len) ? (unsigned)rem : len); - SizeT pos = (dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0); - - processedPos += curLen; - - len -= curLen; - if (pos + curLen <= dicBufSize) - { - Byte *dest = dic + dicPos; - ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos; - const Byte *lim = dest + curLen; - dicPos += curLen; - do - *(dest) = (Byte)*(dest + src); - while (++dest != lim); - } - else - { - do - { - dic[dicPos++] = dic[pos]; - if (++pos == dicBufSize) - pos = 0; - } - while (--curLen != 0); - } - } - } - } - while (dicPos < limit && buf < bufLimit); - NORMALIZE; - p->buf = buf; - p->range = range; - p->code = code; - p->remainLen = len; - p->dicPos = dicPos; - p->processedPos = processedPos; - p->reps[0] = rep0; - p->reps[1] = rep1; - p->reps[2] = rep2; - p->reps[3] = rep3; - p->state = state; - - return SZ_OK; -} - -static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit) -{ - if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart) - { - Byte *dic = p->dic; - SizeT dicPos = p->dicPos; - SizeT dicBufSize = p->dicBufSize; - unsigned len = p->remainLen; - UInt32 rep0 = p->reps[0]; - if (limit - dicPos < len) - len = (unsigned)(limit - dicPos); - - if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len) - p->checkDicSize = p->prop.dicSize; - - p->processedPos += len; - p->remainLen -= len; - while (len-- != 0) - { - dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; - dicPos++; - } - p->dicPos = dicPos; - } -} - -static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit) -{ - do - { - SizeT limit2 = limit; - if (p->checkDicSize == 0) - { - UInt32 rem = p->prop.dicSize - p->processedPos; - if (limit - p->dicPos > rem) - limit2 = p->dicPos + rem; - } - RINOK(LzmaDec_DecodeReal(p, limit2, bufLimit)); - if (p->processedPos >= p->prop.dicSize) - p->checkDicSize = p->prop.dicSize; - LzmaDec_WriteRem(p, limit); - } - while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart); - - if (p->remainLen > kMatchSpecLenStart) - { - p->remainLen = kMatchSpecLenStart; - } - return 0; -} - -typedef enum -{ - DUMMY_ERROR, /* unexpected end of input stream */ - DUMMY_LIT, - DUMMY_MATCH, - DUMMY_REP -} ELzmaDummy; - -static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inSize) -{ - UInt32 range = p->range; - UInt32 code = p->code; - const Byte *bufLimit = buf + inSize; - CLzmaProb *probs = p->probs; - unsigned state = p->state; - ELzmaDummy res; - - { - CLzmaProb *prob; - UInt32 bound; - unsigned ttt; - unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1); - - prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK - - /* if (bufLimit - buf >= 7) return DUMMY_LIT; */ - - prob = probs + Literal; - if (p->checkDicSize != 0 || p->processedPos != 0) - prob += (LZMA_LIT_SIZE * - ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) + - (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc)))); - - if (state < kNumLitStates) - { - unsigned symbol = 1; - do { GET_BIT_CHECK(prob + symbol, symbol) } while (symbol < 0x100); - } - else - { - unsigned matchByte = p->dic[p->dicPos - p->reps[0] + - ((p->dicPos < p->reps[0]) ? p->dicBufSize : 0)]; - unsigned offs = 0x100; - unsigned symbol = 1; - do - { - unsigned bit; - CLzmaProb *probLit; - matchByte <<= 1; - bit = (matchByte & offs); - probLit = prob + offs + bit + symbol; - GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit) - } - while (symbol < 0x100); - } - res = DUMMY_LIT; - } - else - { - unsigned len; - UPDATE_1_CHECK; - - prob = probs + IsRep + state; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - state = 0; - prob = probs + LenCoder; - res = DUMMY_MATCH; - } - else - { - UPDATE_1_CHECK; - res = DUMMY_REP; - prob = probs + IsRepG0 + state; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - NORMALIZE_CHECK; - return DUMMY_REP; - } - else - { - UPDATE_1_CHECK; - } - } - else - { - UPDATE_1_CHECK; - prob = probs + IsRepG1 + state; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - } - else - { - UPDATE_1_CHECK; - prob = probs + IsRepG2 + state; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - } - else - { - UPDATE_1_CHECK; - } - } - } - state = kNumStates; - prob = probs + RepLenCoder; - } - { - unsigned limit, offset; - CLzmaProb *probLen = prob + LenChoice; - IF_BIT_0_CHECK(probLen) - { - UPDATE_0_CHECK; - probLen = prob + LenLow + (posState << kLenNumLowBits); - offset = 0; - limit = 1 << kLenNumLowBits; - } - else - { - UPDATE_1_CHECK; - probLen = prob + LenChoice2; - IF_BIT_0_CHECK(probLen) - { - UPDATE_0_CHECK; - probLen = prob + LenMid + (posState << kLenNumMidBits); - offset = kLenNumLowSymbols; - limit = 1 << kLenNumMidBits; - } - else - { - UPDATE_1_CHECK; - probLen = prob + LenHigh; - offset = kLenNumLowSymbols + kLenNumMidSymbols; - limit = 1 << kLenNumHighBits; - } - } - TREE_DECODE_CHECK(probLen, limit, len); - len += offset; - } - - if (state < 4) - { - unsigned posSlot; - prob = probs + PosSlot + - ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << - kNumPosSlotBits); - TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot); - if (posSlot >= kStartPosModelIndex) - { - int numDirectBits = ((posSlot >> 1) - 1); - - /* if (bufLimit - buf >= 8) return DUMMY_MATCH; */ - - if (posSlot < kEndPosModelIndex) - { - prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits) - posSlot - 1; - } - else - { - numDirectBits -= kNumAlignBits; - do - { - NORMALIZE_CHECK - range >>= 1; - code -= range & (((code - range) >> 31) - 1); - /* if (code >= range) code -= range; */ - } - while (--numDirectBits != 0); - prob = probs + Align; - numDirectBits = kNumAlignBits; - } - { - unsigned i = 1; - do - { - GET_BIT_CHECK(prob + i, i); - } - while (--numDirectBits != 0); - } - } - } - } - } - NORMALIZE_CHECK; - return res; -} - - -static void LzmaDec_InitRc(CLzmaDec *p, const Byte *data) -{ - p->code = ((UInt32)data[1] << 24) | ((UInt32)data[2] << 16) | ((UInt32)data[3] << 8) | ((UInt32)data[4]); - p->range = 0xFFFFFFFF; - p->needFlush = 0; -} - -void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState) -{ - p->needFlush = 1; - p->remainLen = 0; - p->tempBufSize = 0; - - if (initDic) - { - p->processedPos = 0; - p->checkDicSize = 0; - p->needInitState = 1; - } - if (initState) - p->needInitState = 1; -} - -void LzmaDec_Init(CLzmaDec *p) -{ - p->dicPos = 0; - LzmaDec_InitDicAndState(p, True, True); -} - -static void LzmaDec_InitStateReal(CLzmaDec *p) -{ - UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp)); - UInt32 i; - CLzmaProb *probs = p->probs; - for (i = 0; i < numProbs; i++) - probs[i] = kBitModelTotal >> 1; - p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1; - p->state = 0; - p->needInitState = 0; -} - -SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen, - ELzmaFinishMode finishMode, ELzmaStatus *status) -{ - SizeT inSize = *srcLen; - (*srcLen) = 0; - LzmaDec_WriteRem(p, dicLimit); - - *status = LZMA_STATUS_NOT_SPECIFIED; - - while (p->remainLen != kMatchSpecLenStart) - { - int checkEndMarkNow; - - if (p->needFlush != 0) - { - for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--) - p->tempBuf[p->tempBufSize++] = *src++; - if (p->tempBufSize < RC_INIT_SIZE) - { - *status = LZMA_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - if (p->tempBuf[0] != 0) - return SZ_ERROR_DATA; - - LzmaDec_InitRc(p, p->tempBuf); - p->tempBufSize = 0; - } - - checkEndMarkNow = 0; - if (p->dicPos >= dicLimit) - { - if (p->remainLen == 0 && p->code == 0) - { - *status = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK; - return SZ_OK; - } - if (finishMode == LZMA_FINISH_ANY) - { - *status = LZMA_STATUS_NOT_FINISHED; - return SZ_OK; - } - if (p->remainLen != 0) - { - *status = LZMA_STATUS_NOT_FINISHED; - return SZ_ERROR_DATA; - } - checkEndMarkNow = 1; - } - - if (p->needInitState) - LzmaDec_InitStateReal(p); - - if (p->tempBufSize == 0) - { - SizeT processed; - const Byte *bufLimit; - if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) - { - int dummyRes = LzmaDec_TryDummy(p, src, inSize); - if (dummyRes == DUMMY_ERROR) - { - memcpy(p->tempBuf, src, inSize); - p->tempBufSize = (unsigned)inSize; - (*srcLen) += inSize; - *status = LZMA_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - if (checkEndMarkNow && dummyRes != DUMMY_MATCH) - { - *status = LZMA_STATUS_NOT_FINISHED; - return SZ_ERROR_DATA; - } - bufLimit = src; - } - else - bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX; - p->buf = src; - if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0) - return SZ_ERROR_DATA; - processed = (SizeT)(p->buf - src); - (*srcLen) += processed; - src += processed; - inSize -= processed; - } - else - { - unsigned rem = p->tempBufSize, lookAhead = 0; - while (rem < LZMA_REQUIRED_INPUT_MAX && lookAhead < inSize) - p->tempBuf[rem++] = src[lookAhead++]; - p->tempBufSize = rem; - if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) - { - int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem); - if (dummyRes == DUMMY_ERROR) - { - (*srcLen) += lookAhead; - *status = LZMA_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - if (checkEndMarkNow && dummyRes != DUMMY_MATCH) - { - *status = LZMA_STATUS_NOT_FINISHED; - return SZ_ERROR_DATA; - } - } - p->buf = p->tempBuf; - if (LzmaDec_DecodeReal2(p, dicLimit, p->buf) != 0) - return SZ_ERROR_DATA; - lookAhead -= (rem - (unsigned)(p->buf - p->tempBuf)); - (*srcLen) += lookAhead; - src += lookAhead; - inSize -= lookAhead; - p->tempBufSize = 0; - } - } - if (p->code == 0) - *status = LZMA_STATUS_FINISHED_WITH_MARK; - return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA; -} - -SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) -{ - SizeT outSize = *destLen; - SizeT inSize = *srcLen; - *srcLen = *destLen = 0; - for (;;) - { - SizeT inSizeCur = inSize, outSizeCur, dicPos; - ELzmaFinishMode curFinishMode; - SRes res; - if (p->dicPos == p->dicBufSize) - p->dicPos = 0; - dicPos = p->dicPos; - if (outSize > p->dicBufSize - dicPos) - { - outSizeCur = p->dicBufSize; - curFinishMode = LZMA_FINISH_ANY; - } - else - { - outSizeCur = dicPos + outSize; - curFinishMode = finishMode; - } - - res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status); - src += inSizeCur; - inSize -= inSizeCur; - *srcLen += inSizeCur; - outSizeCur = p->dicPos - dicPos; - memcpy(dest, p->dic + dicPos, outSizeCur); - dest += outSizeCur; - outSize -= outSizeCur; - *destLen += outSizeCur; - if (res != 0) - return res; - if (outSizeCur == 0 || outSize == 0) - return SZ_OK; - } -} - -void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc) -{ - alloc->Free(alloc, p->probs); - p->probs = 0; -} - -static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc) -{ - alloc->Free(alloc, p->dic); - p->dic = 0; -} - -void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc) -{ - LzmaDec_FreeProbs(p, alloc); - LzmaDec_FreeDict(p, alloc); -} - -SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size) -{ - UInt32 dicSize; - Byte d; - - if (size < LZMA_PROPS_SIZE) - return SZ_ERROR_UNSUPPORTED; - else - dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24); - - if (dicSize < LZMA_DIC_MIN) - dicSize = LZMA_DIC_MIN; - p->dicSize = dicSize; - - d = data[0]; - if (d >= (9 * 5 * 5)) - return SZ_ERROR_UNSUPPORTED; - - p->lc = d % 9; - d /= 9; - p->pb = d / 5; - p->lp = d % 5; - - return SZ_OK; -} - -static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc) -{ - UInt32 numProbs = LzmaProps_GetNumProbs(propNew); - if (p->probs == 0 || numProbs != p->numProbs) - { - LzmaDec_FreeProbs(p, alloc); - p->probs = (CLzmaProb *)alloc->Alloc(alloc, numProbs * sizeof(CLzmaProb)); - p->numProbs = numProbs; - if (p->probs == 0) - return SZ_ERROR_MEM; - } - return SZ_OK; -} - -SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) -{ - CLzmaProps propNew; - RINOK(LzmaProps_Decode(&propNew, props, propsSize)); - RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); - p->prop = propNew; - return SZ_OK; -} - -SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) -{ - CLzmaProps propNew; - SizeT dicBufSize; - RINOK(LzmaProps_Decode(&propNew, props, propsSize)); - RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); - dicBufSize = propNew.dicSize; - if (p->dic == 0 || dicBufSize != p->dicBufSize) - { - LzmaDec_FreeDict(p, alloc); - p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize); - if (p->dic == 0) - { - LzmaDec_FreeProbs(p, alloc); - return SZ_ERROR_MEM; - } - } - p->dicBufSize = dicBufSize; - p->prop = propNew; - return SZ_OK; -} - -SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, - const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, - ELzmaStatus *status, ISzAlloc *alloc) -{ - CLzmaDec p; - SRes res; - SizeT inSize = *srcLen; - SizeT outSize = *destLen; - *srcLen = *destLen = 0; - if (inSize < RC_INIT_SIZE) - return SZ_ERROR_INPUT_EOF; - - LzmaDec_Construct(&p); - res = LzmaDec_AllocateProbs(&p, propData, propSize, alloc); - if (res != 0) - return res; - p.dic = dest; - p.dicBufSize = outSize; - - LzmaDec_Init(&p); - - *srcLen = inSize; - res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status); - - if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT) - res = SZ_ERROR_INPUT_EOF; - - (*destLen) = p.dicPos; - LzmaDec_FreeProbs(&p, alloc); - return res; -} diff --git a/libs/storm-sys/StormLib/src/lzma/C/LzmaDec.h b/libs/storm-sys/StormLib/src/lzma/C/LzmaDec.h deleted file mode 100644 index bf7f084..0000000 --- a/libs/storm-sys/StormLib/src/lzma/C/LzmaDec.h +++ /dev/null @@ -1,231 +0,0 @@ -/* LzmaDec.h -- LZMA Decoder -2009-02-07 : Igor Pavlov : Public domain */ - -#ifndef __LZMA_DEC_H -#define __LZMA_DEC_H - -#include "Types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* #define _LZMA_PROB32 */ -/* _LZMA_PROB32 can increase the speed on some CPUs, - but memory usage for CLzmaDec::probs will be doubled in that case */ - -#ifdef _LZMA_PROB32 -#define CLzmaProb UInt32 -#else -#define CLzmaProb UInt16 -#endif - - -/* ---------- LZMA Properties ---------- */ - -#define LZMA_PROPS_SIZE 5 - -typedef struct _CLzmaProps -{ - unsigned lc, lp, pb; - UInt32 dicSize; -} CLzmaProps; - -/* LzmaProps_Decode - decodes properties -Returns: - SZ_OK - SZ_ERROR_UNSUPPORTED - Unsupported properties -*/ - -SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size); - - -/* ---------- LZMA Decoder state ---------- */ - -/* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case. - Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */ - -#define LZMA_REQUIRED_INPUT_MAX 20 - -typedef struct -{ - CLzmaProps prop; - CLzmaProb *probs; - Byte *dic; - const Byte *buf; - UInt32 range, code; - SizeT dicPos; - SizeT dicBufSize; - UInt32 processedPos; - UInt32 checkDicSize; - unsigned state; - UInt32 reps[4]; - unsigned remainLen; - int needFlush; - int needInitState; - UInt32 numProbs; - unsigned tempBufSize; - Byte tempBuf[LZMA_REQUIRED_INPUT_MAX]; -} CLzmaDec; - -#define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; } - -void LzmaDec_Init(CLzmaDec *p); - -/* There are two types of LZMA streams: - 0) Stream with end mark. That end mark adds about 6 bytes to compressed size. - 1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */ - -typedef enum -{ - LZMA_FINISH_ANY, /* finish at any point */ - LZMA_FINISH_END /* block must be finished at the end */ -} ELzmaFinishMode; - -/* ELzmaFinishMode has meaning only if the decoding reaches output limit !!! - - You must use LZMA_FINISH_END, when you know that current output buffer - covers last bytes of block. In other cases you must use LZMA_FINISH_ANY. - - If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK, - and output value of destLen will be less than output buffer size limit. - You can check status result also. - - You can use multiple checks to test data integrity after full decompression: - 1) Check Result and "status" variable. - 2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize. - 3) Check that output(srcLen) = compressedSize, if you know real compressedSize. - You must use correct finish mode in that case. */ - -typedef enum -{ - LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */ - LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */ - LZMA_STATUS_NOT_FINISHED, /* stream was not finished */ - LZMA_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */ - LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK /* there is probability that stream was finished without end mark */ -} ELzmaStatus; - -/* ELzmaStatus is used only as output value for function call */ - - -/* ---------- Interfaces ---------- */ - -/* There are 3 levels of interfaces: - 1) Dictionary Interface - 2) Buffer Interface - 3) One Call Interface - You can select any of these interfaces, but don't mix functions from different - groups for same object. */ - - -/* There are two variants to allocate state for Dictionary Interface: - 1) LzmaDec_Allocate / LzmaDec_Free - 2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs - You can use variant 2, if you set dictionary buffer manually. - For Buffer Interface you must always use variant 1. - -LzmaDec_Allocate* can return: - SZ_OK - SZ_ERROR_MEM - Memory allocation error - SZ_ERROR_UNSUPPORTED - Unsupported properties -*/ - -SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc); -void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc); - -SRes LzmaDec_Allocate(CLzmaDec *state, const Byte *prop, unsigned propsSize, ISzAlloc *alloc); -void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc); - -/* ---------- Dictionary Interface ---------- */ - -/* You can use it, if you want to eliminate the overhead for data copying from - dictionary to some other external buffer. - You must work with CLzmaDec variables directly in this interface. - - STEPS: - LzmaDec_Constr() - LzmaDec_Allocate() - for (each new stream) - { - LzmaDec_Init() - while (it needs more decompression) - { - LzmaDec_DecodeToDic() - use data from CLzmaDec::dic and update CLzmaDec::dicPos - } - } - LzmaDec_Free() -*/ - -/* LzmaDec_DecodeToDic - - The decoding to internal dictionary buffer (CLzmaDec::dic). - You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!! - -finishMode: - It has meaning only if the decoding reaches output limit (dicLimit). - LZMA_FINISH_ANY - Decode just dicLimit bytes. - LZMA_FINISH_END - Stream must be finished after dicLimit. - -Returns: - SZ_OK - status: - LZMA_STATUS_FINISHED_WITH_MARK - LZMA_STATUS_NOT_FINISHED - LZMA_STATUS_NEEDS_MORE_INPUT - LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK - SZ_ERROR_DATA - Data error -*/ - -SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, - const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); - - -/* ---------- Buffer Interface ---------- */ - -/* It's zlib-like interface. - See LzmaDec_DecodeToDic description for information about STEPS and return results, - but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need - to work with CLzmaDec variables manually. - -finishMode: - It has meaning only if the decoding reaches output limit (*destLen). - LZMA_FINISH_ANY - Decode just destLen bytes. - LZMA_FINISH_END - Stream must be finished after (*destLen). -*/ - -SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, - const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); - - -/* ---------- One Call Interface ---------- */ - -/* LzmaDecode - -finishMode: - It has meaning only if the decoding reaches output limit (*destLen). - LZMA_FINISH_ANY - Decode just destLen bytes. - LZMA_FINISH_END - Stream must be finished after (*destLen). - -Returns: - SZ_OK - status: - LZMA_STATUS_FINISHED_WITH_MARK - LZMA_STATUS_NOT_FINISHED - LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK - SZ_ERROR_DATA - Data error - SZ_ERROR_MEM - Memory allocation error - SZ_ERROR_UNSUPPORTED - Unsupported properties - SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). -*/ - -SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, - const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, - ELzmaStatus *status, ISzAlloc *alloc); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libs/storm-sys/StormLib/src/lzma/C/LzmaEnc.c b/libs/storm-sys/StormLib/src/lzma/C/LzmaEnc.c deleted file mode 100644 index 169d4f4..0000000 --- a/libs/storm-sys/StormLib/src/lzma/C/LzmaEnc.c +++ /dev/null @@ -1,2268 +0,0 @@ -/* LzmaEnc.c -- LZMA Encoder -2009-11-24 : Igor Pavlov : Public domain */ - -#include - -/* #define SHOW_STAT */ -/* #define SHOW_STAT2 */ - -#if defined(SHOW_STAT) || defined(SHOW_STAT2) -#include -#endif - -#include "LzmaEnc.h" - -#include "LzFind.h" -#ifndef _7ZIP_ST -#include "LzFindMt.h" -#endif - -#ifdef SHOW_STAT -static int ttt = 0; -#endif - -#define kBlockSizeMax ((1 << LZMA_NUM_BLOCK_SIZE_BITS) - 1) - -#define kBlockSize (9 << 10) -#define kUnpackBlockSize (1 << 18) -#define kMatchArraySize (1 << 21) -#define kMatchRecordMaxSize ((LZMA_MATCH_LEN_MAX * 2 + 3) * LZMA_MATCH_LEN_MAX) - -#define kNumMaxDirectBits (31) - -#define kNumTopBits 24 -#define kTopValue ((UInt32)1 << kNumTopBits) - -#define kNumBitModelTotalBits 11 -#define kBitModelTotal (1 << kNumBitModelTotalBits) -#define kNumMoveBits 5 -#define kProbInitValue (kBitModelTotal >> 1) - -#define kNumMoveReducingBits 4 -#define kNumBitPriceShiftBits 4 -#define kBitPrice (1 << kNumBitPriceShiftBits) - -void LzmaEncProps_Init(CLzmaEncProps *p) -{ - p->level = 5; - p->dictSize = p->mc = 0; - p->lc = p->lp = p->pb = p->algo = p->fb = p->btMode = p->numHashBytes = p->numThreads = -1; - p->writeEndMark = 0; -} - -void LzmaEncProps_Normalize(CLzmaEncProps *p) -{ - int level = p->level; - if (level < 0) level = 5; - p->level = level; - if (p->dictSize == 0) p->dictSize = (level <= 5 ? (1 << (level * 2 + 14)) : (level == 6 ? (1 << 25) : (1 << 26))); - if (p->lc < 0) p->lc = 3; - if (p->lp < 0) p->lp = 0; - if (p->pb < 0) p->pb = 2; - if (p->algo < 0) p->algo = (level < 5 ? 0 : 1); - if (p->fb < 0) p->fb = (level < 7 ? 32 : 64); - if (p->btMode < 0) p->btMode = (p->algo == 0 ? 0 : 1); - if (p->numHashBytes < 0) p->numHashBytes = 4; - if (p->mc == 0) p->mc = (16 + (p->fb >> 1)) >> (p->btMode ? 0 : 1); - if (p->numThreads < 0) - p->numThreads = - #ifndef _7ZIP_ST - ((p->btMode && p->algo) ? 2 : 1); - #else - 1; - #endif -} - -UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2) -{ - CLzmaEncProps props = *props2; - LzmaEncProps_Normalize(&props); - return props.dictSize; -} - -/* #define LZMA_LOG_BSR */ -/* Define it for Intel's CPU */ - - -#ifdef LZMA_LOG_BSR - -#define kDicLogSizeMaxCompress 30 - -#define BSR2_RET(pos, res) { unsigned long i; _BitScanReverse(&i, (pos)); res = (i + i) + ((pos >> (i - 1)) & 1); } - -UInt32 GetPosSlot1(UInt32 pos) -{ - UInt32 res; - BSR2_RET(pos, res); - return res; -} -#define GetPosSlot2(pos, res) { BSR2_RET(pos, res); } -#define GetPosSlot(pos, res) { if (pos < 2) res = pos; else BSR2_RET(pos, res); } - -#else - -#define kNumLogBits (9 + (int)sizeof(size_t) / 2) -#define kDicLogSizeMaxCompress ((kNumLogBits - 1) * 2 + 7) - -void LzmaEnc_FastPosInit(Byte *g_FastPos) -{ - int c = 2, slotFast; - g_FastPos[0] = 0; - g_FastPos[1] = 1; - - for (slotFast = 2; slotFast < kNumLogBits * 2; slotFast++) - { - UInt32 k = (1 << ((slotFast >> 1) - 1)); - UInt32 j; - for (j = 0; j < k; j++, c++) - g_FastPos[c] = (Byte)slotFast; - } -} - -#define BSR2_RET(pos, res) { UInt32 i = 6 + ((kNumLogBits - 1) & \ - (0 - (((((UInt32)1 << (kNumLogBits + 6)) - 1) - pos) >> 31))); \ - res = p->g_FastPos[pos >> i] + (i * 2); } -/* -#define BSR2_RET(pos, res) { res = (pos < (1 << (kNumLogBits + 6))) ? \ - p->g_FastPos[pos >> 6] + 12 : \ - p->g_FastPos[pos >> (6 + kNumLogBits - 1)] + (6 + (kNumLogBits - 1)) * 2; } -*/ - -#define GetPosSlot1(pos) p->g_FastPos[pos] -#define GetPosSlot2(pos, res) { BSR2_RET(pos, res); } -#define GetPosSlot(pos, res) { if (pos < kNumFullDistances) res = p->g_FastPos[pos]; else BSR2_RET(pos, res); } - -#endif - - -#define LZMA_NUM_REPS 4 - -typedef unsigned CState; - -typedef struct -{ - UInt32 price; - - CState state; - int prev1IsChar; - int prev2; - - UInt32 posPrev2; - UInt32 backPrev2; - - UInt32 posPrev; - UInt32 backPrev; - UInt32 backs[LZMA_NUM_REPS]; -} COptimal; - -#define kNumOpts (1 << 12) - -#define kNumLenToPosStates 4 -#define kNumPosSlotBits 6 -#define kDicLogSizeMin 0 -#define kDicLogSizeMax 32 -#define kDistTableSizeMax (kDicLogSizeMax * 2) - - -#define kNumAlignBits 4 -#define kAlignTableSize (1 << kNumAlignBits) -#define kAlignMask (kAlignTableSize - 1) - -#define kStartPosModelIndex 4 -#define kEndPosModelIndex 14 -#define kNumPosModels (kEndPosModelIndex - kStartPosModelIndex) - -#define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) - -#ifdef _LZMA_PROB32 -#define CLzmaProb UInt32 -#else -#define CLzmaProb UInt16 -#endif - -#define LZMA_PB_MAX 4 -#define LZMA_LC_MAX 8 -#define LZMA_LP_MAX 4 - -#define LZMA_NUM_PB_STATES_MAX (1 << LZMA_PB_MAX) - - -#define kLenNumLowBits 3 -#define kLenNumLowSymbols (1 << kLenNumLowBits) -#define kLenNumMidBits 3 -#define kLenNumMidSymbols (1 << kLenNumMidBits) -#define kLenNumHighBits 8 -#define kLenNumHighSymbols (1 << kLenNumHighBits) - -#define kLenNumSymbolsTotal (kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols) - -#define LZMA_MATCH_LEN_MIN 2 -#define LZMA_MATCH_LEN_MAX (LZMA_MATCH_LEN_MIN + kLenNumSymbolsTotal - 1) - -#define kNumStates 12 - -typedef struct -{ - CLzmaProb choice; - CLzmaProb choice2; - CLzmaProb low[LZMA_NUM_PB_STATES_MAX << kLenNumLowBits]; - CLzmaProb mid[LZMA_NUM_PB_STATES_MAX << kLenNumMidBits]; - CLzmaProb high[kLenNumHighSymbols]; -} CLenEnc; - -typedef struct -{ - CLenEnc p; - UInt32 prices[LZMA_NUM_PB_STATES_MAX][kLenNumSymbolsTotal]; - UInt32 tableSize; - UInt32 counters[LZMA_NUM_PB_STATES_MAX]; -} CLenPriceEnc; - -typedef struct -{ - UInt32 range; - Byte cache; - UInt64 low; - UInt64 cacheSize; - Byte *buf; - Byte *bufLim; - Byte *bufBase; - ISeqOutStream *outStream; - UInt64 processed; - SRes res; -} CRangeEnc; - -typedef struct -{ - CLzmaProb *litProbs; - - CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX]; - CLzmaProb isRep[kNumStates]; - CLzmaProb isRepG0[kNumStates]; - CLzmaProb isRepG1[kNumStates]; - CLzmaProb isRepG2[kNumStates]; - CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX]; - - CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits]; - CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex]; - CLzmaProb posAlignEncoder[1 << kNumAlignBits]; - - CLenPriceEnc lenEnc; - CLenPriceEnc repLenEnc; - - UInt32 reps[LZMA_NUM_REPS]; - UInt32 state; -} CSaveState; - -typedef struct -{ - IMatchFinder matchFinder; - void *matchFinderObj; - - #ifndef _7ZIP_ST - Bool mtMode; - CMatchFinderMt matchFinderMt; - #endif - - CMatchFinder matchFinderBase; - - #ifndef _7ZIP_ST - Byte pad[128]; - #endif - - UInt32 optimumEndIndex; - UInt32 optimumCurrentIndex; - - UInt32 longestMatchLength; - UInt32 numPairs; - UInt32 numAvail; - COptimal opt[kNumOpts]; - - #ifndef LZMA_LOG_BSR - Byte g_FastPos[1 << kNumLogBits]; - #endif - - UInt32 ProbPrices[kBitModelTotal >> kNumMoveReducingBits]; - UInt32 matches[LZMA_MATCH_LEN_MAX * 2 + 2 + 1]; - UInt32 numFastBytes; - UInt32 additionalOffset; - UInt32 reps[LZMA_NUM_REPS]; - UInt32 state; - - UInt32 posSlotPrices[kNumLenToPosStates][kDistTableSizeMax]; - UInt32 distancesPrices[kNumLenToPosStates][kNumFullDistances]; - UInt32 alignPrices[kAlignTableSize]; - UInt32 alignPriceCount; - - UInt32 distTableSize; - - unsigned lc, lp, pb; - unsigned lpMask, pbMask; - - CLzmaProb *litProbs; - - CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX]; - CLzmaProb isRep[kNumStates]; - CLzmaProb isRepG0[kNumStates]; - CLzmaProb isRepG1[kNumStates]; - CLzmaProb isRepG2[kNumStates]; - CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX]; - - CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits]; - CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex]; - CLzmaProb posAlignEncoder[1 << kNumAlignBits]; - - CLenPriceEnc lenEnc; - CLenPriceEnc repLenEnc; - - unsigned lclp; - - Bool fastMode; - - CRangeEnc rc; - - Bool writeEndMark; - UInt64 nowPos64; - UInt32 matchPriceCount; - Bool finished; - Bool multiThread; - - SRes result; - UInt32 dictSize; - UInt32 matchFinderCycles; - - int needInit; - - CSaveState saveState; -} CLzmaEnc; - -void LzmaEnc_SaveState(CLzmaEncHandle pp) -{ - CLzmaEnc *p = (CLzmaEnc *)pp; - CSaveState *dest = &p->saveState; - int i; - dest->lenEnc = p->lenEnc; - dest->repLenEnc = p->repLenEnc; - dest->state = p->state; - - for (i = 0; i < kNumStates; i++) - { - memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i])); - memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i])); - } - for (i = 0; i < kNumLenToPosStates; i++) - memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i])); - memcpy(dest->isRep, p->isRep, sizeof(p->isRep)); - memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0)); - memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1)); - memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2)); - memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders)); - memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder)); - memcpy(dest->reps, p->reps, sizeof(p->reps)); - memcpy(dest->litProbs, p->litProbs, (0x300 << p->lclp) * sizeof(CLzmaProb)); -} - -void LzmaEnc_RestoreState(CLzmaEncHandle pp) -{ - CLzmaEnc *dest = (CLzmaEnc *)pp; - const CSaveState *p = &dest->saveState; - int i; - dest->lenEnc = p->lenEnc; - dest->repLenEnc = p->repLenEnc; - dest->state = p->state; - - for (i = 0; i < kNumStates; i++) - { - memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i])); - memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i])); - } - for (i = 0; i < kNumLenToPosStates; i++) - memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i])); - memcpy(dest->isRep, p->isRep, sizeof(p->isRep)); - memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0)); - memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1)); - memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2)); - memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders)); - memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder)); - memcpy(dest->reps, p->reps, sizeof(p->reps)); - memcpy(dest->litProbs, p->litProbs, (0x300 << dest->lclp) * sizeof(CLzmaProb)); -} - -SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2) -{ - CLzmaEnc *p = (CLzmaEnc *)pp; - CLzmaEncProps props = *props2; - LzmaEncProps_Normalize(&props); - - if (props.lc > LZMA_LC_MAX || props.lp > LZMA_LP_MAX || props.pb > LZMA_PB_MAX || - props.dictSize > (1 << kDicLogSizeMaxCompress) || props.dictSize > (1 << 30)) - return SZ_ERROR_PARAM; - p->dictSize = props.dictSize; - p->matchFinderCycles = props.mc; - { - unsigned fb = props.fb; - if (fb < 5) - fb = 5; - if (fb > LZMA_MATCH_LEN_MAX) - fb = LZMA_MATCH_LEN_MAX; - p->numFastBytes = fb; - } - p->lc = props.lc; - p->lp = props.lp; - p->pb = props.pb; - p->fastMode = (props.algo == 0); - p->matchFinderBase.btMode = props.btMode; - { - UInt32 numHashBytes = 4; - if (props.btMode) - { - if (props.numHashBytes < 2) - numHashBytes = 2; - else if (props.numHashBytes < 4) - numHashBytes = props.numHashBytes; - } - p->matchFinderBase.numHashBytes = numHashBytes; - } - - p->matchFinderBase.cutValue = props.mc; - - p->writeEndMark = props.writeEndMark; - - #ifndef _7ZIP_ST - /* - if (newMultiThread != _multiThread) - { - ReleaseMatchFinder(); - _multiThread = newMultiThread; - } - */ - p->multiThread = (props.numThreads > 1); - #endif - - return SZ_OK; -} - -static const int kLiteralNextStates[kNumStates] = {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5}; -static const int kMatchNextStates[kNumStates] = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10}; -static const int kRepNextStates[kNumStates] = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11}; -static const int kShortRepNextStates[kNumStates]= {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11}; - -#define IsCharState(s) ((s) < 7) - -#define GetLenToPosState(len) (((len) < kNumLenToPosStates + 1) ? (len) - 2 : kNumLenToPosStates - 1) - -#define kInfinityPrice (1 << 30) - -static void RangeEnc_Construct(CRangeEnc *p) -{ - p->outStream = 0; - p->bufBase = 0; -} - -#define RangeEnc_GetProcessed(p) ((p)->processed + ((p)->buf - (p)->bufBase) + (p)->cacheSize) - -#define RC_BUF_SIZE (1 << 16) -static int RangeEnc_Alloc(CRangeEnc *p, ISzAlloc *alloc) -{ - if (p->bufBase == 0) - { - p->bufBase = (Byte *)alloc->Alloc(alloc, RC_BUF_SIZE); - if (p->bufBase == 0) - return 0; - p->bufLim = p->bufBase + RC_BUF_SIZE; - } - return 1; -} - -static void RangeEnc_Free(CRangeEnc *p, ISzAlloc *alloc) -{ - alloc->Free(alloc, p->bufBase); - p->bufBase = 0; -} - -static void RangeEnc_Init(CRangeEnc *p) -{ - /* Stream.Init(); */ - p->low = 0; - p->range = 0xFFFFFFFF; - p->cacheSize = 1; - p->cache = 0; - - p->buf = p->bufBase; - - p->processed = 0; - p->res = SZ_OK; -} - -static void RangeEnc_FlushStream(CRangeEnc *p) -{ - size_t num; - if (p->res != SZ_OK) - return; - num = p->buf - p->bufBase; - if (num != p->outStream->Write(p->outStream, p->bufBase, num)) - p->res = SZ_ERROR_WRITE; - p->processed += num; - p->buf = p->bufBase; -} - -static void MY_FAST_CALL RangeEnc_ShiftLow(CRangeEnc *p) -{ - if ((UInt32)p->low < (UInt32)0xFF000000 || (int)(p->low >> 32) != 0) - { - Byte temp = p->cache; - do - { - Byte *buf = p->buf; - *buf++ = (Byte)(temp + (Byte)(p->low >> 32)); - p->buf = buf; - if (buf == p->bufLim) - RangeEnc_FlushStream(p); - temp = 0xFF; - } - while (--p->cacheSize != 0); - p->cache = (Byte)((UInt32)p->low >> 24); - } - p->cacheSize++; - p->low = (UInt32)p->low << 8; -} - -static void RangeEnc_FlushData(CRangeEnc *p) -{ - int i; - for (i = 0; i < 5; i++) - RangeEnc_ShiftLow(p); -} - -static void RangeEnc_EncodeDirectBits(CRangeEnc *p, UInt32 value, int numBits) -{ - do - { - p->range >>= 1; - p->low += p->range & (0 - ((value >> --numBits) & 1)); - if (p->range < kTopValue) - { - p->range <<= 8; - RangeEnc_ShiftLow(p); - } - } - while (numBits != 0); -} - -static void RangeEnc_EncodeBit(CRangeEnc *p, CLzmaProb *prob, UInt32 symbol) -{ - UInt32 ttt = *prob; - UInt32 newBound = (p->range >> kNumBitModelTotalBits) * ttt; - if (symbol == 0) - { - p->range = newBound; - ttt += (kBitModelTotal - ttt) >> kNumMoveBits; - } - else - { - p->low += newBound; - p->range -= newBound; - ttt -= ttt >> kNumMoveBits; - } - *prob = (CLzmaProb)ttt; - if (p->range < kTopValue) - { - p->range <<= 8; - RangeEnc_ShiftLow(p); - } -} - -static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol) -{ - symbol |= 0x100; - do - { - RangeEnc_EncodeBit(p, probs + (symbol >> 8), (symbol >> 7) & 1); - symbol <<= 1; - } - while (symbol < 0x10000); -} - -static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol, UInt32 matchByte) -{ - UInt32 offs = 0x100; - symbol |= 0x100; - do - { - matchByte <<= 1; - RangeEnc_EncodeBit(p, probs + (offs + (matchByte & offs) + (symbol >> 8)), (symbol >> 7) & 1); - symbol <<= 1; - offs &= ~(matchByte ^ symbol); - } - while (symbol < 0x10000); -} - -void LzmaEnc_InitPriceTables(UInt32 *ProbPrices) -{ - UInt32 i; - for (i = (1 << kNumMoveReducingBits) / 2; i < kBitModelTotal; i += (1 << kNumMoveReducingBits)) - { - const int kCyclesBits = kNumBitPriceShiftBits; - UInt32 w = i; - UInt32 bitCount = 0; - int j; - for (j = 0; j < kCyclesBits; j++) - { - w = w * w; - bitCount <<= 1; - while (w >= ((UInt32)1 << 16)) - { - w >>= 1; - bitCount++; - } - } - ProbPrices[i >> kNumMoveReducingBits] = ((kNumBitModelTotalBits << kCyclesBits) - 15 - bitCount); - } -} - - -#define GET_PRICE(prob, symbol) \ - p->ProbPrices[((prob) ^ (((-(int)(symbol))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits]; - -#define GET_PRICEa(prob, symbol) \ - ProbPrices[((prob) ^ ((-((int)(symbol))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits]; - -#define GET_PRICE_0(prob) p->ProbPrices[(prob) >> kNumMoveReducingBits] -#define GET_PRICE_1(prob) p->ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits] - -#define GET_PRICE_0a(prob) ProbPrices[(prob) >> kNumMoveReducingBits] -#define GET_PRICE_1a(prob) ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits] - -static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, UInt32 symbol, UInt32 *ProbPrices) -{ - UInt32 price = 0; - symbol |= 0x100; - do - { - price += GET_PRICEa(probs[symbol >> 8], (symbol >> 7) & 1); - symbol <<= 1; - } - while (symbol < 0x10000); - return price; -} - -static UInt32 LitEnc_GetPriceMatched(const CLzmaProb *probs, UInt32 symbol, UInt32 matchByte, UInt32 *ProbPrices) -{ - UInt32 price = 0; - UInt32 offs = 0x100; - symbol |= 0x100; - do - { - matchByte <<= 1; - price += GET_PRICEa(probs[offs + (matchByte & offs) + (symbol >> 8)], (symbol >> 7) & 1); - symbol <<= 1; - offs &= ~(matchByte ^ symbol); - } - while (symbol < 0x10000); - return price; -} - - -static void RcTree_Encode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, UInt32 symbol) -{ - UInt32 m = 1; - int i; - for (i = numBitLevels; i != 0;) - { - UInt32 bit; - i--; - bit = (symbol >> i) & 1; - RangeEnc_EncodeBit(rc, probs + m, bit); - m = (m << 1) | bit; - } -} - -static void RcTree_ReverseEncode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, UInt32 symbol) -{ - UInt32 m = 1; - int i; - for (i = 0; i < numBitLevels; i++) - { - UInt32 bit = symbol & 1; - RangeEnc_EncodeBit(rc, probs + m, bit); - m = (m << 1) | bit; - symbol >>= 1; - } -} - -static UInt32 RcTree_GetPrice(const CLzmaProb *probs, int numBitLevels, UInt32 symbol, UInt32 *ProbPrices) -{ - UInt32 price = 0; - symbol |= (1 << numBitLevels); - while (symbol != 1) - { - price += GET_PRICEa(probs[symbol >> 1], symbol & 1); - symbol >>= 1; - } - return price; -} - -static UInt32 RcTree_ReverseGetPrice(const CLzmaProb *probs, int numBitLevels, UInt32 symbol, UInt32 *ProbPrices) -{ - UInt32 price = 0; - UInt32 m = 1; - int i; - for (i = numBitLevels; i != 0; i--) - { - UInt32 bit = symbol & 1; - symbol >>= 1; - price += GET_PRICEa(probs[m], bit); - m = (m << 1) | bit; - } - return price; -} - - -static void LenEnc_Init(CLenEnc *p) -{ - unsigned i; - p->choice = p->choice2 = kProbInitValue; - for (i = 0; i < (LZMA_NUM_PB_STATES_MAX << kLenNumLowBits); i++) - p->low[i] = kProbInitValue; - for (i = 0; i < (LZMA_NUM_PB_STATES_MAX << kLenNumMidBits); i++) - p->mid[i] = kProbInitValue; - for (i = 0; i < kLenNumHighSymbols; i++) - p->high[i] = kProbInitValue; -} - -static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32 posState) -{ - if (symbol < kLenNumLowSymbols) - { - RangeEnc_EncodeBit(rc, &p->choice, 0); - RcTree_Encode(rc, p->low + (posState << kLenNumLowBits), kLenNumLowBits, symbol); - } - else - { - RangeEnc_EncodeBit(rc, &p->choice, 1); - if (symbol < kLenNumLowSymbols + kLenNumMidSymbols) - { - RangeEnc_EncodeBit(rc, &p->choice2, 0); - RcTree_Encode(rc, p->mid + (posState << kLenNumMidBits), kLenNumMidBits, symbol - kLenNumLowSymbols); - } - else - { - RangeEnc_EncodeBit(rc, &p->choice2, 1); - RcTree_Encode(rc, p->high, kLenNumHighBits, symbol - kLenNumLowSymbols - kLenNumMidSymbols); - } - } -} - -static void LenEnc_SetPrices(CLenEnc *p, UInt32 posState, UInt32 numSymbols, UInt32 *prices, UInt32 *ProbPrices) -{ - UInt32 a0 = GET_PRICE_0a(p->choice); - UInt32 a1 = GET_PRICE_1a(p->choice); - UInt32 b0 = a1 + GET_PRICE_0a(p->choice2); - UInt32 b1 = a1 + GET_PRICE_1a(p->choice2); - UInt32 i = 0; - for (i = 0; i < kLenNumLowSymbols; i++) - { - if (i >= numSymbols) - return; - prices[i] = a0 + RcTree_GetPrice(p->low + (posState << kLenNumLowBits), kLenNumLowBits, i, ProbPrices); - } - for (; i < kLenNumLowSymbols + kLenNumMidSymbols; i++) - { - if (i >= numSymbols) - return; - prices[i] = b0 + RcTree_GetPrice(p->mid + (posState << kLenNumMidBits), kLenNumMidBits, i - kLenNumLowSymbols, ProbPrices); - } - for (; i < numSymbols; i++) - prices[i] = b1 + RcTree_GetPrice(p->high, kLenNumHighBits, i - kLenNumLowSymbols - kLenNumMidSymbols, ProbPrices); -} - -static void MY_FAST_CALL LenPriceEnc_UpdateTable(CLenPriceEnc *p, UInt32 posState, UInt32 *ProbPrices) -{ - LenEnc_SetPrices(&p->p, posState, p->tableSize, p->prices[posState], ProbPrices); - p->counters[posState] = p->tableSize; -} - -static void LenPriceEnc_UpdateTables(CLenPriceEnc *p, UInt32 numPosStates, UInt32 *ProbPrices) -{ - UInt32 posState; - for (posState = 0; posState < numPosStates; posState++) - LenPriceEnc_UpdateTable(p, posState, ProbPrices); -} - -static void LenEnc_Encode2(CLenPriceEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32 posState, Bool updatePrice, UInt32 *ProbPrices) -{ - LenEnc_Encode(&p->p, rc, symbol, posState); - if (updatePrice) - if (--p->counters[posState] == 0) - LenPriceEnc_UpdateTable(p, posState, ProbPrices); -} - - - - -static void MovePos(CLzmaEnc *p, UInt32 num) -{ - #ifdef SHOW_STAT - ttt += num; - printf("\n MovePos %d", num); - #endif - if (num != 0) - { - p->additionalOffset += num; - p->matchFinder.Skip(p->matchFinderObj, num); - } -} - -static UInt32 ReadMatchDistances(CLzmaEnc *p, UInt32 *numDistancePairsRes) -{ - UInt32 lenRes = 0, numPairs; - p->numAvail = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); - numPairs = p->matchFinder.GetMatches(p->matchFinderObj, p->matches); - #ifdef SHOW_STAT - printf("\n i = %d numPairs = %d ", ttt, numPairs / 2); - ttt++; - { - UInt32 i; - for (i = 0; i < numPairs; i += 2) - printf("%2d %6d | ", p->matches[i], p->matches[i + 1]); - } - #endif - if (numPairs > 0) - { - lenRes = p->matches[numPairs - 2]; - if (lenRes == p->numFastBytes) - { - const Byte *pby = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; - UInt32 distance = p->matches[numPairs - 1] + 1; - UInt32 numAvail = p->numAvail; - if (numAvail > LZMA_MATCH_LEN_MAX) - numAvail = LZMA_MATCH_LEN_MAX; - { - const Byte *pby2 = pby - distance; - for (; lenRes < numAvail && pby[lenRes] == pby2[lenRes]; lenRes++); - } - } - } - p->additionalOffset++; - *numDistancePairsRes = numPairs; - return lenRes; -} - - -#define MakeAsChar(p) (p)->backPrev = (UInt32)(-1); (p)->prev1IsChar = False; -#define MakeAsShortRep(p) (p)->backPrev = 0; (p)->prev1IsChar = False; -#define IsShortRep(p) ((p)->backPrev == 0) - -static UInt32 GetRepLen1Price(CLzmaEnc *p, UInt32 state, UInt32 posState) -{ - return - GET_PRICE_0(p->isRepG0[state]) + - GET_PRICE_0(p->isRep0Long[state][posState]); -} - -static UInt32 GetPureRepPrice(CLzmaEnc *p, UInt32 repIndex, UInt32 state, UInt32 posState) -{ - UInt32 price; - if (repIndex == 0) - { - price = GET_PRICE_0(p->isRepG0[state]); - price += GET_PRICE_1(p->isRep0Long[state][posState]); - } - else - { - price = GET_PRICE_1(p->isRepG0[state]); - if (repIndex == 1) - price += GET_PRICE_0(p->isRepG1[state]); - else - { - price += GET_PRICE_1(p->isRepG1[state]); - price += GET_PRICE(p->isRepG2[state], repIndex - 2); - } - } - return price; -} - -static UInt32 GetRepPrice(CLzmaEnc *p, UInt32 repIndex, UInt32 len, UInt32 state, UInt32 posState) -{ - return p->repLenEnc.prices[posState][len - LZMA_MATCH_LEN_MIN] + - GetPureRepPrice(p, repIndex, state, posState); -} - -static UInt32 Backward(CLzmaEnc *p, UInt32 *backRes, UInt32 cur) -{ - UInt32 posMem = p->opt[cur].posPrev; - UInt32 backMem = p->opt[cur].backPrev; - p->optimumEndIndex = cur; - do - { - if (p->opt[cur].prev1IsChar) - { - MakeAsChar(&p->opt[posMem]) - p->opt[posMem].posPrev = posMem - 1; - if (p->opt[cur].prev2) - { - p->opt[posMem - 1].prev1IsChar = False; - p->opt[posMem - 1].posPrev = p->opt[cur].posPrev2; - p->opt[posMem - 1].backPrev = p->opt[cur].backPrev2; - } - } - { - UInt32 posPrev = posMem; - UInt32 backCur = backMem; - - backMem = p->opt[posPrev].backPrev; - posMem = p->opt[posPrev].posPrev; - - p->opt[posPrev].backPrev = backCur; - p->opt[posPrev].posPrev = cur; - cur = posPrev; - } - } - while (cur != 0); - *backRes = p->opt[0].backPrev; - p->optimumCurrentIndex = p->opt[0].posPrev; - return p->optimumCurrentIndex; -} - -#define LIT_PROBS(pos, prevByte) (p->litProbs + ((((pos) & p->lpMask) << p->lc) + ((prevByte) >> (8 - p->lc))) * 0x300) - -static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes) -{ - UInt32 numAvail, mainLen, numPairs, repMaxIndex, i, posState, lenEnd, len, cur; - UInt32 matchPrice, repMatchPrice, normalMatchPrice; - UInt32 reps[LZMA_NUM_REPS], repLens[LZMA_NUM_REPS]; - UInt32 *matches; - const Byte *data; - Byte curByte, matchByte; - if (p->optimumEndIndex != p->optimumCurrentIndex) - { - const COptimal *opt = &p->opt[p->optimumCurrentIndex]; - UInt32 lenRes = opt->posPrev - p->optimumCurrentIndex; - *backRes = opt->backPrev; - p->optimumCurrentIndex = opt->posPrev; - return lenRes; - } - p->optimumCurrentIndex = p->optimumEndIndex = 0; - - if (p->additionalOffset == 0) - mainLen = ReadMatchDistances(p, &numPairs); - else - { - mainLen = p->longestMatchLength; - numPairs = p->numPairs; - } - - numAvail = p->numAvail; - if (numAvail < 2) - { - *backRes = (UInt32)(-1); - return 1; - } - if (numAvail > LZMA_MATCH_LEN_MAX) - numAvail = LZMA_MATCH_LEN_MAX; - - data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; - repMaxIndex = 0; - for (i = 0; i < LZMA_NUM_REPS; i++) - { - UInt32 lenTest; - const Byte *data2; - reps[i] = p->reps[i]; - data2 = data - (reps[i] + 1); - if (data[0] != data2[0] || data[1] != data2[1]) - { - repLens[i] = 0; - continue; - } - for (lenTest = 2; lenTest < numAvail && data[lenTest] == data2[lenTest]; lenTest++); - repLens[i] = lenTest; - if (lenTest > repLens[repMaxIndex]) - repMaxIndex = i; - } - if (repLens[repMaxIndex] >= p->numFastBytes) - { - UInt32 lenRes; - *backRes = repMaxIndex; - lenRes = repLens[repMaxIndex]; - MovePos(p, lenRes - 1); - return lenRes; - } - - matches = p->matches; - if (mainLen >= p->numFastBytes) - { - *backRes = matches[numPairs - 1] + LZMA_NUM_REPS; - MovePos(p, mainLen - 1); - return mainLen; - } - curByte = *data; - matchByte = *(data - (reps[0] + 1)); - - if (mainLen < 2 && curByte != matchByte && repLens[repMaxIndex] < 2) - { - *backRes = (UInt32)-1; - return 1; - } - - p->opt[0].state = (CState)p->state; - - posState = (position & p->pbMask); - - { - const CLzmaProb *probs = LIT_PROBS(position, *(data - 1)); - p->opt[1].price = GET_PRICE_0(p->isMatch[p->state][posState]) + - (!IsCharState(p->state) ? - LitEnc_GetPriceMatched(probs, curByte, matchByte, p->ProbPrices) : - LitEnc_GetPrice(probs, curByte, p->ProbPrices)); - } - - MakeAsChar(&p->opt[1]); - - matchPrice = GET_PRICE_1(p->isMatch[p->state][posState]); - repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[p->state]); - - if (matchByte == curByte) - { - UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, p->state, posState); - if (shortRepPrice < p->opt[1].price) - { - p->opt[1].price = shortRepPrice; - MakeAsShortRep(&p->opt[1]); - } - } - lenEnd = ((mainLen >= repLens[repMaxIndex]) ? mainLen : repLens[repMaxIndex]); - - if (lenEnd < 2) - { - *backRes = p->opt[1].backPrev; - return 1; - } - - p->opt[1].posPrev = 0; - for (i = 0; i < LZMA_NUM_REPS; i++) - p->opt[0].backs[i] = reps[i]; - - len = lenEnd; - do - p->opt[len--].price = kInfinityPrice; - while (len >= 2); - - for (i = 0; i < LZMA_NUM_REPS; i++) - { - UInt32 repLen = repLens[i]; - UInt32 price; - if (repLen < 2) - continue; - price = repMatchPrice + GetPureRepPrice(p, i, p->state, posState); - do - { - UInt32 curAndLenPrice = price + p->repLenEnc.prices[posState][repLen - 2]; - COptimal *opt = &p->opt[repLen]; - if (curAndLenPrice < opt->price) - { - opt->price = curAndLenPrice; - opt->posPrev = 0; - opt->backPrev = i; - opt->prev1IsChar = False; - } - } - while (--repLen >= 2); - } - - normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[p->state]); - - len = ((repLens[0] >= 2) ? repLens[0] + 1 : 2); - if (len <= mainLen) - { - UInt32 offs = 0; - while (len > matches[offs]) - offs += 2; - for (; ; len++) - { - COptimal *opt; - UInt32 distance = matches[offs + 1]; - - UInt32 curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][len - LZMA_MATCH_LEN_MIN]; - UInt32 lenToPosState = GetLenToPosState(len); - if (distance < kNumFullDistances) - curAndLenPrice += p->distancesPrices[lenToPosState][distance]; - else - { - UInt32 slot; - GetPosSlot2(distance, slot); - curAndLenPrice += p->alignPrices[distance & kAlignMask] + p->posSlotPrices[lenToPosState][slot]; - } - opt = &p->opt[len]; - if (curAndLenPrice < opt->price) - { - opt->price = curAndLenPrice; - opt->posPrev = 0; - opt->backPrev = distance + LZMA_NUM_REPS; - opt->prev1IsChar = False; - } - if (len == matches[offs]) - { - offs += 2; - if (offs == numPairs) - break; - } - } - } - - cur = 0; - - #ifdef SHOW_STAT2 - if (position >= 0) - { - unsigned i; - printf("\n pos = %4X", position); - for (i = cur; i <= lenEnd; i++) - printf("\nprice[%4X] = %d", position - cur + i, p->opt[i].price); - } - #endif - - for (;;) - { - UInt32 numAvailFull, newLen, numPairs, posPrev, state, posState, startLen; - UInt32 curPrice, curAnd1Price, matchPrice, repMatchPrice; - Bool nextIsChar; - Byte curByte, matchByte; - const Byte *data; - COptimal *curOpt; - COptimal *nextOpt; - - cur++; - if (cur == lenEnd) - return Backward(p, backRes, cur); - - newLen = ReadMatchDistances(p, &numPairs); - if (newLen >= p->numFastBytes) - { - p->numPairs = numPairs; - p->longestMatchLength = newLen; - return Backward(p, backRes, cur); - } - position++; - curOpt = &p->opt[cur]; - posPrev = curOpt->posPrev; - if (curOpt->prev1IsChar) - { - posPrev--; - if (curOpt->prev2) - { - state = p->opt[curOpt->posPrev2].state; - if (curOpt->backPrev2 < LZMA_NUM_REPS) - state = kRepNextStates[state]; - else - state = kMatchNextStates[state]; - } - else - state = p->opt[posPrev].state; - state = kLiteralNextStates[state]; - } - else - state = p->opt[posPrev].state; - if (posPrev == cur - 1) - { - if (IsShortRep(curOpt)) - state = kShortRepNextStates[state]; - else - state = kLiteralNextStates[state]; - } - else - { - UInt32 pos; - const COptimal *prevOpt; - if (curOpt->prev1IsChar && curOpt->prev2) - { - posPrev = curOpt->posPrev2; - pos = curOpt->backPrev2; - state = kRepNextStates[state]; - } - else - { - pos = curOpt->backPrev; - if (pos < LZMA_NUM_REPS) - state = kRepNextStates[state]; - else - state = kMatchNextStates[state]; - } - prevOpt = &p->opt[posPrev]; - if (pos < LZMA_NUM_REPS) - { - UInt32 i; - reps[0] = prevOpt->backs[pos]; - for (i = 1; i <= pos; i++) - reps[i] = prevOpt->backs[i - 1]; - for (; i < LZMA_NUM_REPS; i++) - reps[i] = prevOpt->backs[i]; - } - else - { - UInt32 i; - reps[0] = (pos - LZMA_NUM_REPS); - for (i = 1; i < LZMA_NUM_REPS; i++) - reps[i] = prevOpt->backs[i - 1]; - } - } - curOpt->state = (CState)state; - - curOpt->backs[0] = reps[0]; - curOpt->backs[1] = reps[1]; - curOpt->backs[2] = reps[2]; - curOpt->backs[3] = reps[3]; - - curPrice = curOpt->price; - nextIsChar = False; - data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; - curByte = *data; - matchByte = *(data - (reps[0] + 1)); - - posState = (position & p->pbMask); - - curAnd1Price = curPrice + GET_PRICE_0(p->isMatch[state][posState]); - { - const CLzmaProb *probs = LIT_PROBS(position, *(data - 1)); - curAnd1Price += - (!IsCharState(state) ? - LitEnc_GetPriceMatched(probs, curByte, matchByte, p->ProbPrices) : - LitEnc_GetPrice(probs, curByte, p->ProbPrices)); - } - - nextOpt = &p->opt[cur + 1]; - - if (curAnd1Price < nextOpt->price) - { - nextOpt->price = curAnd1Price; - nextOpt->posPrev = cur; - MakeAsChar(nextOpt); - nextIsChar = True; - } - - matchPrice = curPrice + GET_PRICE_1(p->isMatch[state][posState]); - repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[state]); - - if (matchByte == curByte && !(nextOpt->posPrev < cur && nextOpt->backPrev == 0)) - { - UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, state, posState); - if (shortRepPrice <= nextOpt->price) - { - nextOpt->price = shortRepPrice; - nextOpt->posPrev = cur; - MakeAsShortRep(nextOpt); - nextIsChar = True; - } - } - numAvailFull = p->numAvail; - { - UInt32 temp = kNumOpts - 1 - cur; - if (temp < numAvailFull) - numAvailFull = temp; - } - - if (numAvailFull < 2) - continue; - numAvail = (numAvailFull <= p->numFastBytes ? numAvailFull : p->numFastBytes); - - if (!nextIsChar && matchByte != curByte) /* speed optimization */ - { - /* try Literal + rep0 */ - UInt32 temp; - UInt32 lenTest2; - const Byte *data2 = data - (reps[0] + 1); - UInt32 limit = p->numFastBytes + 1; - if (limit > numAvailFull) - limit = numAvailFull; - - for (temp = 1; temp < limit && data[temp] == data2[temp]; temp++); - lenTest2 = temp - 1; - if (lenTest2 >= 2) - { - UInt32 state2 = kLiteralNextStates[state]; - UInt32 posStateNext = (position + 1) & p->pbMask; - UInt32 nextRepMatchPrice = curAnd1Price + - GET_PRICE_1(p->isMatch[state2][posStateNext]) + - GET_PRICE_1(p->isRep[state2]); - /* for (; lenTest2 >= 2; lenTest2--) */ - { - UInt32 curAndLenPrice; - COptimal *opt; - UInt32 offset = cur + 1 + lenTest2; - while (lenEnd < offset) - p->opt[++lenEnd].price = kInfinityPrice; - curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext); - opt = &p->opt[offset]; - if (curAndLenPrice < opt->price) - { - opt->price = curAndLenPrice; - opt->posPrev = cur + 1; - opt->backPrev = 0; - opt->prev1IsChar = True; - opt->prev2 = False; - } - } - } - } - - startLen = 2; /* speed optimization */ - { - UInt32 repIndex; - for (repIndex = 0; repIndex < LZMA_NUM_REPS; repIndex++) - { - UInt32 lenTest; - UInt32 lenTestTemp; - UInt32 price; - const Byte *data2 = data - (reps[repIndex] + 1); - if (data[0] != data2[0] || data[1] != data2[1]) - continue; - for (lenTest = 2; lenTest < numAvail && data[lenTest] == data2[lenTest]; lenTest++); - while (lenEnd < cur + lenTest) - p->opt[++lenEnd].price = kInfinityPrice; - lenTestTemp = lenTest; - price = repMatchPrice + GetPureRepPrice(p, repIndex, state, posState); - do - { - UInt32 curAndLenPrice = price + p->repLenEnc.prices[posState][lenTest - 2]; - COptimal *opt = &p->opt[cur + lenTest]; - if (curAndLenPrice < opt->price) - { - opt->price = curAndLenPrice; - opt->posPrev = cur; - opt->backPrev = repIndex; - opt->prev1IsChar = False; - } - } - while (--lenTest >= 2); - lenTest = lenTestTemp; - - if (repIndex == 0) - startLen = lenTest + 1; - - /* if (_maxMode) */ - { - UInt32 lenTest2 = lenTest + 1; - UInt32 limit = lenTest2 + p->numFastBytes; - UInt32 nextRepMatchPrice; - if (limit > numAvailFull) - limit = numAvailFull; - for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++); - lenTest2 -= lenTest + 1; - if (lenTest2 >= 2) - { - UInt32 state2 = kRepNextStates[state]; - UInt32 posStateNext = (position + lenTest) & p->pbMask; - UInt32 curAndLenCharPrice = - price + p->repLenEnc.prices[posState][lenTest - 2] + - GET_PRICE_0(p->isMatch[state2][posStateNext]) + - LitEnc_GetPriceMatched(LIT_PROBS(position + lenTest, data[lenTest - 1]), - data[lenTest], data2[lenTest], p->ProbPrices); - state2 = kLiteralNextStates[state2]; - posStateNext = (position + lenTest + 1) & p->pbMask; - nextRepMatchPrice = curAndLenCharPrice + - GET_PRICE_1(p->isMatch[state2][posStateNext]) + - GET_PRICE_1(p->isRep[state2]); - - /* for (; lenTest2 >= 2; lenTest2--) */ - { - UInt32 curAndLenPrice; - COptimal *opt; - UInt32 offset = cur + lenTest + 1 + lenTest2; - while (lenEnd < offset) - p->opt[++lenEnd].price = kInfinityPrice; - curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext); - opt = &p->opt[offset]; - if (curAndLenPrice < opt->price) - { - opt->price = curAndLenPrice; - opt->posPrev = cur + lenTest + 1; - opt->backPrev = 0; - opt->prev1IsChar = True; - opt->prev2 = True; - opt->posPrev2 = cur; - opt->backPrev2 = repIndex; - } - } - } - } - } - } - /* for (UInt32 lenTest = 2; lenTest <= newLen; lenTest++) */ - if (newLen > numAvail) - { - newLen = numAvail; - for (numPairs = 0; newLen > matches[numPairs]; numPairs += 2); - matches[numPairs] = newLen; - numPairs += 2; - } - if (newLen >= startLen) - { - UInt32 normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[state]); - UInt32 offs, curBack, posSlot; - UInt32 lenTest; - while (lenEnd < cur + newLen) - p->opt[++lenEnd].price = kInfinityPrice; - - offs = 0; - while (startLen > matches[offs]) - offs += 2; - curBack = matches[offs + 1]; - GetPosSlot2(curBack, posSlot); - for (lenTest = /*2*/ startLen; ; lenTest++) - { - UInt32 curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][lenTest - LZMA_MATCH_LEN_MIN]; - UInt32 lenToPosState = GetLenToPosState(lenTest); - COptimal *opt; - if (curBack < kNumFullDistances) - curAndLenPrice += p->distancesPrices[lenToPosState][curBack]; - else - curAndLenPrice += p->posSlotPrices[lenToPosState][posSlot] + p->alignPrices[curBack & kAlignMask]; - - opt = &p->opt[cur + lenTest]; - if (curAndLenPrice < opt->price) - { - opt->price = curAndLenPrice; - opt->posPrev = cur; - opt->backPrev = curBack + LZMA_NUM_REPS; - opt->prev1IsChar = False; - } - - if (/*_maxMode && */lenTest == matches[offs]) - { - /* Try Match + Literal + Rep0 */ - const Byte *data2 = data - (curBack + 1); - UInt32 lenTest2 = lenTest + 1; - UInt32 limit = lenTest2 + p->numFastBytes; - UInt32 nextRepMatchPrice; - if (limit > numAvailFull) - limit = numAvailFull; - for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++); - lenTest2 -= lenTest + 1; - if (lenTest2 >= 2) - { - UInt32 state2 = kMatchNextStates[state]; - UInt32 posStateNext = (position + lenTest) & p->pbMask; - UInt32 curAndLenCharPrice = curAndLenPrice + - GET_PRICE_0(p->isMatch[state2][posStateNext]) + - LitEnc_GetPriceMatched(LIT_PROBS(position + lenTest, data[lenTest - 1]), - data[lenTest], data2[lenTest], p->ProbPrices); - state2 = kLiteralNextStates[state2]; - posStateNext = (posStateNext + 1) & p->pbMask; - nextRepMatchPrice = curAndLenCharPrice + - GET_PRICE_1(p->isMatch[state2][posStateNext]) + - GET_PRICE_1(p->isRep[state2]); - - /* for (; lenTest2 >= 2; lenTest2--) */ - { - UInt32 offset = cur + lenTest + 1 + lenTest2; - UInt32 curAndLenPrice; - COptimal *opt; - while (lenEnd < offset) - p->opt[++lenEnd].price = kInfinityPrice; - curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext); - opt = &p->opt[offset]; - if (curAndLenPrice < opt->price) - { - opt->price = curAndLenPrice; - opt->posPrev = cur + lenTest + 1; - opt->backPrev = 0; - opt->prev1IsChar = True; - opt->prev2 = True; - opt->posPrev2 = cur; - opt->backPrev2 = curBack + LZMA_NUM_REPS; - } - } - } - offs += 2; - if (offs == numPairs) - break; - curBack = matches[offs + 1]; - if (curBack >= kNumFullDistances) - GetPosSlot2(curBack, posSlot); - } - } - } - } -} - -#define ChangePair(smallDist, bigDist) (((bigDist) >> 7) > (smallDist)) - -static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes) -{ - UInt32 numAvail, mainLen, mainDist, numPairs, repIndex, repLen, i; - const Byte *data; - const UInt32 *matches; - - if (p->additionalOffset == 0) - mainLen = ReadMatchDistances(p, &numPairs); - else - { - mainLen = p->longestMatchLength; - numPairs = p->numPairs; - } - - numAvail = p->numAvail; - *backRes = (UInt32)-1; - if (numAvail < 2) - return 1; - if (numAvail > LZMA_MATCH_LEN_MAX) - numAvail = LZMA_MATCH_LEN_MAX; - data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; - - repLen = repIndex = 0; - for (i = 0; i < LZMA_NUM_REPS; i++) - { - UInt32 len; - const Byte *data2 = data - (p->reps[i] + 1); - if (data[0] != data2[0] || data[1] != data2[1]) - continue; - for (len = 2; len < numAvail && data[len] == data2[len]; len++); - if (len >= p->numFastBytes) - { - *backRes = i; - MovePos(p, len - 1); - return len; - } - if (len > repLen) - { - repIndex = i; - repLen = len; - } - } - - matches = p->matches; - if (mainLen >= p->numFastBytes) - { - *backRes = matches[numPairs - 1] + LZMA_NUM_REPS; - MovePos(p, mainLen - 1); - return mainLen; - } - - mainDist = 0; /* for GCC */ - if (mainLen >= 2) - { - mainDist = matches[numPairs - 1]; - while (numPairs > 2 && mainLen == matches[numPairs - 4] + 1) - { - if (!ChangePair(matches[numPairs - 3], mainDist)) - break; - numPairs -= 2; - mainLen = matches[numPairs - 2]; - mainDist = matches[numPairs - 1]; - } - if (mainLen == 2 && mainDist >= 0x80) - mainLen = 1; - } - - if (repLen >= 2 && ( - (repLen + 1 >= mainLen) || - (repLen + 2 >= mainLen && mainDist >= (1 << 9)) || - (repLen + 3 >= mainLen && mainDist >= (1 << 15)))) - { - *backRes = repIndex; - MovePos(p, repLen - 1); - return repLen; - } - - if (mainLen < 2 || numAvail <= 2) - return 1; - - p->longestMatchLength = ReadMatchDistances(p, &p->numPairs); - if (p->longestMatchLength >= 2) - { - UInt32 newDistance = matches[p->numPairs - 1]; - if ((p->longestMatchLength >= mainLen && newDistance < mainDist) || - (p->longestMatchLength == mainLen + 1 && !ChangePair(mainDist, newDistance)) || - (p->longestMatchLength > mainLen + 1) || - (p->longestMatchLength + 1 >= mainLen && mainLen >= 3 && ChangePair(newDistance, mainDist))) - return 1; - } - - data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; - for (i = 0; i < LZMA_NUM_REPS; i++) - { - UInt32 len, limit; - const Byte *data2 = data - (p->reps[i] + 1); - if (data[0] != data2[0] || data[1] != data2[1]) - continue; - limit = mainLen - 1; - for (len = 2; len < limit && data[len] == data2[len]; len++); - if (len >= limit) - return 1; - } - *backRes = mainDist + LZMA_NUM_REPS; - MovePos(p, mainLen - 2); - return mainLen; -} - -static void WriteEndMarker(CLzmaEnc *p, UInt32 posState) -{ - UInt32 len; - RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 1); - RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0); - p->state = kMatchNextStates[p->state]; - len = LZMA_MATCH_LEN_MIN; - LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices); - RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, (1 << kNumPosSlotBits) - 1); - RangeEnc_EncodeDirectBits(&p->rc, (((UInt32)1 << 30) - 1) >> kNumAlignBits, 30 - kNumAlignBits); - RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, kAlignMask); -} - -static SRes CheckErrors(CLzmaEnc *p) -{ - if (p->result != SZ_OK) - return p->result; - if (p->rc.res != SZ_OK) - p->result = SZ_ERROR_WRITE; - if (p->matchFinderBase.result != SZ_OK) - p->result = SZ_ERROR_READ; - if (p->result != SZ_OK) - p->finished = True; - return p->result; -} - -static SRes Flush(CLzmaEnc *p, UInt32 nowPos) -{ - /* ReleaseMFStream(); */ - p->finished = True; - if (p->writeEndMark) - WriteEndMarker(p, nowPos & p->pbMask); - RangeEnc_FlushData(&p->rc); - RangeEnc_FlushStream(&p->rc); - return CheckErrors(p); -} - -static void FillAlignPrices(CLzmaEnc *p) -{ - UInt32 i; - for (i = 0; i < kAlignTableSize; i++) - p->alignPrices[i] = RcTree_ReverseGetPrice(p->posAlignEncoder, kNumAlignBits, i, p->ProbPrices); - p->alignPriceCount = 0; -} - -static void FillDistancesPrices(CLzmaEnc *p) -{ - UInt32 tempPrices[kNumFullDistances]; - UInt32 i, lenToPosState; - for (i = kStartPosModelIndex; i < kNumFullDistances; i++) - { - UInt32 posSlot = GetPosSlot1(i); - UInt32 footerBits = ((posSlot >> 1) - 1); - UInt32 base = ((2 | (posSlot & 1)) << footerBits); - tempPrices[i] = RcTree_ReverseGetPrice(p->posEncoders + base - posSlot - 1, footerBits, i - base, p->ProbPrices); - } - - for (lenToPosState = 0; lenToPosState < kNumLenToPosStates; lenToPosState++) - { - UInt32 posSlot; - const CLzmaProb *encoder = p->posSlotEncoder[lenToPosState]; - UInt32 *posSlotPrices = p->posSlotPrices[lenToPosState]; - for (posSlot = 0; posSlot < p->distTableSize; posSlot++) - posSlotPrices[posSlot] = RcTree_GetPrice(encoder, kNumPosSlotBits, posSlot, p->ProbPrices); - for (posSlot = kEndPosModelIndex; posSlot < p->distTableSize; posSlot++) - posSlotPrices[posSlot] += ((((posSlot >> 1) - 1) - kNumAlignBits) << kNumBitPriceShiftBits); - - { - UInt32 *distancesPrices = p->distancesPrices[lenToPosState]; - UInt32 i; - for (i = 0; i < kStartPosModelIndex; i++) - distancesPrices[i] = posSlotPrices[i]; - for (; i < kNumFullDistances; i++) - distancesPrices[i] = posSlotPrices[GetPosSlot1(i)] + tempPrices[i]; - } - } - p->matchPriceCount = 0; -} - -void LzmaEnc_Construct(CLzmaEnc *p) -{ - RangeEnc_Construct(&p->rc); - MatchFinder_Construct(&p->matchFinderBase); - #ifndef _7ZIP_ST - MatchFinderMt_Construct(&p->matchFinderMt); - p->matchFinderMt.MatchFinder = &p->matchFinderBase; - #endif - - { - CLzmaEncProps props; - LzmaEncProps_Init(&props); - LzmaEnc_SetProps(p, &props); - } - - #ifndef LZMA_LOG_BSR - LzmaEnc_FastPosInit(p->g_FastPos); - #endif - - LzmaEnc_InitPriceTables(p->ProbPrices); - p->litProbs = 0; - p->saveState.litProbs = 0; -} - -CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc) -{ - void *p; - p = alloc->Alloc(alloc, sizeof(CLzmaEnc)); - if (p != 0) - LzmaEnc_Construct((CLzmaEnc *)p); - return p; -} - -void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc) -{ - alloc->Free(alloc, p->litProbs); - alloc->Free(alloc, p->saveState.litProbs); - p->litProbs = 0; - p->saveState.litProbs = 0; -} - -void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig) -{ - #ifndef _7ZIP_ST - MatchFinderMt_Destruct(&p->matchFinderMt, allocBig); - #endif - MatchFinder_Free(&p->matchFinderBase, allocBig); - LzmaEnc_FreeLits(p, alloc); - RangeEnc_Free(&p->rc, alloc); -} - -void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig) -{ - LzmaEnc_Destruct((CLzmaEnc *)p, alloc, allocBig); - alloc->Free(alloc, p); -} - -static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize, UInt32 maxUnpackSize) -{ - UInt32 nowPos32, startPos32; - if (p->needInit) - { - p->matchFinder.Init(p->matchFinderObj); - p->needInit = 0; - } - - if (p->finished) - return p->result; - RINOK(CheckErrors(p)); - - nowPos32 = (UInt32)p->nowPos64; - startPos32 = nowPos32; - - if (p->nowPos64 == 0) - { - UInt32 numPairs; - Byte curByte; - if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0) - return Flush(p, nowPos32); - ReadMatchDistances(p, &numPairs); - RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][0], 0); - p->state = kLiteralNextStates[p->state]; - curByte = p->matchFinder.GetIndexByte(p->matchFinderObj, 0 - p->additionalOffset); - LitEnc_Encode(&p->rc, p->litProbs, curByte); - p->additionalOffset--; - nowPos32++; - } - - if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) != 0) - for (;;) - { - UInt32 pos, len, posState; - - if (p->fastMode) - len = GetOptimumFast(p, &pos); - else - len = GetOptimum(p, nowPos32, &pos); - - #ifdef SHOW_STAT2 - printf("\n pos = %4X, len = %d pos = %d", nowPos32, len, pos); - #endif - - posState = nowPos32 & p->pbMask; - if (len == 1 && pos == (UInt32)-1) - { - Byte curByte; - CLzmaProb *probs; - const Byte *data; - - RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 0); - data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset; - curByte = *data; - probs = LIT_PROBS(nowPos32, *(data - 1)); - if (IsCharState(p->state)) - LitEnc_Encode(&p->rc, probs, curByte); - else - LitEnc_EncodeMatched(&p->rc, probs, curByte, *(data - p->reps[0] - 1)); - p->state = kLiteralNextStates[p->state]; - } - else - { - RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 1); - if (pos < LZMA_NUM_REPS) - { - RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 1); - if (pos == 0) - { - RangeEnc_EncodeBit(&p->rc, &p->isRepG0[p->state], 0); - RangeEnc_EncodeBit(&p->rc, &p->isRep0Long[p->state][posState], ((len == 1) ? 0 : 1)); - } - else - { - UInt32 distance = p->reps[pos]; - RangeEnc_EncodeBit(&p->rc, &p->isRepG0[p->state], 1); - if (pos == 1) - RangeEnc_EncodeBit(&p->rc, &p->isRepG1[p->state], 0); - else - { - RangeEnc_EncodeBit(&p->rc, &p->isRepG1[p->state], 1); - RangeEnc_EncodeBit(&p->rc, &p->isRepG2[p->state], pos - 2); - if (pos == 3) - p->reps[3] = p->reps[2]; - p->reps[2] = p->reps[1]; - } - p->reps[1] = p->reps[0]; - p->reps[0] = distance; - } - if (len == 1) - p->state = kShortRepNextStates[p->state]; - else - { - LenEnc_Encode2(&p->repLenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices); - p->state = kRepNextStates[p->state]; - } - } - else - { - UInt32 posSlot; - RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0); - p->state = kMatchNextStates[p->state]; - LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices); - pos -= LZMA_NUM_REPS; - GetPosSlot(pos, posSlot); - RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, posSlot); - - if (posSlot >= kStartPosModelIndex) - { - UInt32 footerBits = ((posSlot >> 1) - 1); - UInt32 base = ((2 | (posSlot & 1)) << footerBits); - UInt32 posReduced = pos - base; - - if (posSlot < kEndPosModelIndex) - RcTree_ReverseEncode(&p->rc, p->posEncoders + base - posSlot - 1, footerBits, posReduced); - else - { - RangeEnc_EncodeDirectBits(&p->rc, posReduced >> kNumAlignBits, footerBits - kNumAlignBits); - RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, posReduced & kAlignMask); - p->alignPriceCount++; - } - } - p->reps[3] = p->reps[2]; - p->reps[2] = p->reps[1]; - p->reps[1] = p->reps[0]; - p->reps[0] = pos; - p->matchPriceCount++; - } - } - p->additionalOffset -= len; - nowPos32 += len; - if (p->additionalOffset == 0) - { - UInt32 processed; - if (!p->fastMode) - { - if (p->matchPriceCount >= (1 << 7)) - FillDistancesPrices(p); - if (p->alignPriceCount >= kAlignTableSize) - FillAlignPrices(p); - } - if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0) - break; - processed = nowPos32 - startPos32; - if (useLimits) - { - if (processed + kNumOpts + 300 >= maxUnpackSize || - RangeEnc_GetProcessed(&p->rc) + kNumOpts * 2 >= maxPackSize) - break; - } - else if (processed >= (1 << 15)) - { - p->nowPos64 += nowPos32 - startPos32; - return CheckErrors(p); - } - } - } - p->nowPos64 += nowPos32 - startPos32; - return Flush(p, nowPos32); -} - -#define kBigHashDicLimit ((UInt32)1 << 24) - -static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig) -{ - UInt32 beforeSize = kNumOpts; - Bool btMode; - if (!RangeEnc_Alloc(&p->rc, alloc)) - return SZ_ERROR_MEM; - btMode = (p->matchFinderBase.btMode != 0); - #ifndef _7ZIP_ST - p->mtMode = (p->multiThread && !p->fastMode && btMode); - #endif - - { - unsigned lclp = p->lc + p->lp; - if (p->litProbs == 0 || p->saveState.litProbs == 0 || p->lclp != lclp) - { - LzmaEnc_FreeLits(p, alloc); - p->litProbs = (CLzmaProb *)alloc->Alloc(alloc, (0x300 << lclp) * sizeof(CLzmaProb)); - p->saveState.litProbs = (CLzmaProb *)alloc->Alloc(alloc, (0x300 << lclp) * sizeof(CLzmaProb)); - if (p->litProbs == 0 || p->saveState.litProbs == 0) - { - LzmaEnc_FreeLits(p, alloc); - return SZ_ERROR_MEM; - } - p->lclp = lclp; - } - } - - p->matchFinderBase.bigHash = (p->dictSize > kBigHashDicLimit); - - if (beforeSize + p->dictSize < keepWindowSize) - beforeSize = keepWindowSize - p->dictSize; - - #ifndef _7ZIP_ST - if (p->mtMode) - { - RINOK(MatchFinderMt_Create(&p->matchFinderMt, p->dictSize, beforeSize, p->numFastBytes, LZMA_MATCH_LEN_MAX, allocBig)); - p->matchFinderObj = &p->matchFinderMt; - MatchFinderMt_CreateVTable(&p->matchFinderMt, &p->matchFinder); - } - else - #endif - { - if (!MatchFinder_Create(&p->matchFinderBase, p->dictSize, beforeSize, p->numFastBytes, LZMA_MATCH_LEN_MAX, allocBig)) - return SZ_ERROR_MEM; - p->matchFinderObj = &p->matchFinderBase; - MatchFinder_CreateVTable(&p->matchFinderBase, &p->matchFinder); - } - return SZ_OK; -} - -void LzmaEnc_Init(CLzmaEnc *p) -{ - UInt32 i; - p->state = 0; - for (i = 0 ; i < LZMA_NUM_REPS; i++) - p->reps[i] = 0; - - RangeEnc_Init(&p->rc); - - - for (i = 0; i < kNumStates; i++) - { - UInt32 j; - for (j = 0; j < LZMA_NUM_PB_STATES_MAX; j++) - { - p->isMatch[i][j] = kProbInitValue; - p->isRep0Long[i][j] = kProbInitValue; - } - p->isRep[i] = kProbInitValue; - p->isRepG0[i] = kProbInitValue; - p->isRepG1[i] = kProbInitValue; - p->isRepG2[i] = kProbInitValue; - } - - { - UInt32 num = 0x300 << (p->lp + p->lc); - for (i = 0; i < num; i++) - p->litProbs[i] = kProbInitValue; - } - - { - for (i = 0; i < kNumLenToPosStates; i++) - { - CLzmaProb *probs = p->posSlotEncoder[i]; - UInt32 j; - for (j = 0; j < (1 << kNumPosSlotBits); j++) - probs[j] = kProbInitValue; - } - } - { - for (i = 0; i < kNumFullDistances - kEndPosModelIndex; i++) - p->posEncoders[i] = kProbInitValue; - } - - LenEnc_Init(&p->lenEnc.p); - LenEnc_Init(&p->repLenEnc.p); - - for (i = 0; i < (1 << kNumAlignBits); i++) - p->posAlignEncoder[i] = kProbInitValue; - - p->optimumEndIndex = 0; - p->optimumCurrentIndex = 0; - p->additionalOffset = 0; - - p->pbMask = (1 << p->pb) - 1; - p->lpMask = (1 << p->lp) - 1; -} - -void LzmaEnc_InitPrices(CLzmaEnc *p) -{ - if (!p->fastMode) - { - FillDistancesPrices(p); - FillAlignPrices(p); - } - - p->lenEnc.tableSize = - p->repLenEnc.tableSize = - p->numFastBytes + 1 - LZMA_MATCH_LEN_MIN; - LenPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb, p->ProbPrices); - LenPriceEnc_UpdateTables(&p->repLenEnc, 1 << p->pb, p->ProbPrices); -} - -static SRes LzmaEnc_AllocAndInit(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig) -{ - UInt32 i; - for (i = 0; i < (UInt32)kDicLogSizeMaxCompress; i++) - if (p->dictSize <= ((UInt32)1 << i)) - break; - p->distTableSize = i * 2; - - p->finished = False; - p->result = SZ_OK; - RINOK(LzmaEnc_Alloc(p, keepWindowSize, alloc, allocBig)); - LzmaEnc_Init(p); - LzmaEnc_InitPrices(p); - p->nowPos64 = 0; - return SZ_OK; -} - -static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, - ISzAlloc *alloc, ISzAlloc *allocBig) -{ - CLzmaEnc *p = (CLzmaEnc *)pp; - p->matchFinderBase.stream = inStream; - p->needInit = 1; - p->rc.outStream = outStream; - return LzmaEnc_AllocAndInit(p, 0, alloc, allocBig); -} - -SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp, - ISeqInStream *inStream, UInt32 keepWindowSize, - ISzAlloc *alloc, ISzAlloc *allocBig) -{ - CLzmaEnc *p = (CLzmaEnc *)pp; - p->matchFinderBase.stream = inStream; - p->needInit = 1; - return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig); -} - -static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const Byte *src, SizeT srcLen) -{ - p->matchFinderBase.directInput = 1; - p->matchFinderBase.bufferBase = (Byte *)src; - p->matchFinderBase.directInputRem = srcLen; -} - -SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen, - UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig) -{ - CLzmaEnc *p = (CLzmaEnc *)pp; - LzmaEnc_SetInputBuf(p, src, srcLen); - p->needInit = 1; - - return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig); -} - -void LzmaEnc_Finish(CLzmaEncHandle pp) -{ - #ifndef _7ZIP_ST - CLzmaEnc *p = (CLzmaEnc *)pp; - if (p->mtMode) - MatchFinderMt_ReleaseStream(&p->matchFinderMt); - #else - pp = pp; - #endif -} - -typedef struct -{ - ISeqOutStream funcTable; - Byte *data; - SizeT rem; - Bool overflow; -} CSeqOutStreamBuf; - -static size_t MyWrite(void *pp, const void *data, size_t size) -{ - CSeqOutStreamBuf *p = (CSeqOutStreamBuf *)pp; - if (p->rem < size) - { - size = p->rem; - p->overflow = True; - } - memcpy(p->data, data, size); - p->rem -= size; - p->data += size; - return size; -} - - -UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp) -{ - const CLzmaEnc *p = (CLzmaEnc *)pp; - return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); -} - -const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp) -{ - const CLzmaEnc *p = (CLzmaEnc *)pp; - return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset; -} - -SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit, - Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize) -{ - CLzmaEnc *p = (CLzmaEnc *)pp; - UInt64 nowPos64; - SRes res; - CSeqOutStreamBuf outStream; - - outStream.funcTable.Write = MyWrite; - outStream.data = dest; - outStream.rem = *destLen; - outStream.overflow = False; - - p->writeEndMark = False; - p->finished = False; - p->result = SZ_OK; - - if (reInit) - LzmaEnc_Init(p); - LzmaEnc_InitPrices(p); - nowPos64 = p->nowPos64; - RangeEnc_Init(&p->rc); - p->rc.outStream = &outStream.funcTable; - - res = LzmaEnc_CodeOneBlock(p, True, desiredPackSize, *unpackSize); - - *unpackSize = (UInt32)(p->nowPos64 - nowPos64); - *destLen -= outStream.rem; - if (outStream.overflow) - return SZ_ERROR_OUTPUT_EOF; - - return res; -} - -static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress) -{ - SRes res = SZ_OK; - - #ifndef _7ZIP_ST - Byte allocaDummy[0x300]; - int i = 0; - for (i = 0; i < 16; i++) - allocaDummy[i] = (Byte)i; - #endif - - for (;;) - { - res = LzmaEnc_CodeOneBlock(p, False, 0, 0); - if (res != SZ_OK || p->finished != 0) - break; - if (progress != 0) - { - res = progress->Progress(progress, p->nowPos64, RangeEnc_GetProcessed(&p->rc)); - if (res != SZ_OK) - { - res = SZ_ERROR_PROGRESS; - break; - } - } - } - LzmaEnc_Finish(p); - return res; -} - -SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress, - ISzAlloc *alloc, ISzAlloc *allocBig) -{ - RINOK(LzmaEnc_Prepare(pp, outStream, inStream, alloc, allocBig)); - return LzmaEnc_Encode2((CLzmaEnc *)pp, progress); -} - -SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size) -{ - CLzmaEnc *p = (CLzmaEnc *)pp; - int i; - UInt32 dictSize = p->dictSize; - if (*size < LZMA_PROPS_SIZE) - return SZ_ERROR_PARAM; - *size = LZMA_PROPS_SIZE; - props[0] = (Byte)((p->pb * 5 + p->lp) * 9 + p->lc); - - for (i = 11; i <= 30; i++) - { - if (dictSize <= ((UInt32)2 << i)) - { - dictSize = (2 << i); - break; - } - if (dictSize <= ((UInt32)3 << i)) - { - dictSize = (3 << i); - break; - } - } - - for (i = 0; i < 4; i++) - props[1 + i] = (Byte)(dictSize >> (8 * i)); - return SZ_OK; -} - -SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, - int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig) -{ - SRes res; - CLzmaEnc *p = (CLzmaEnc *)pp; - - CSeqOutStreamBuf outStream; - - LzmaEnc_SetInputBuf(p, src, srcLen); - - outStream.funcTable.Write = MyWrite; - outStream.data = dest; - outStream.rem = *destLen; - outStream.overflow = False; - - p->writeEndMark = writeEndMark; - - p->rc.outStream = &outStream.funcTable; - res = LzmaEnc_MemPrepare(pp, src, srcLen, 0, alloc, allocBig); - if (res == SZ_OK) - res = LzmaEnc_Encode2(p, progress); - - *destLen -= outStream.rem; - if (outStream.overflow) - return SZ_ERROR_OUTPUT_EOF; - return res; -} - -SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, - const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, - ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig) -{ - CLzmaEnc *p = (CLzmaEnc *)LzmaEnc_Create(alloc); - SRes res; - if (p == 0) - return SZ_ERROR_MEM; - - res = LzmaEnc_SetProps(p, props); - if (res == SZ_OK) - { - res = LzmaEnc_WriteProperties(p, propsEncoded, propsSize); - if (res == SZ_OK) - res = LzmaEnc_MemEncode(p, dest, destLen, src, srcLen, - writeEndMark, progress, alloc, allocBig); - } - - LzmaEnc_Destroy(p, alloc, allocBig); - return res; -} diff --git a/libs/storm-sys/StormLib/src/lzma/C/LzmaEnc.h b/libs/storm-sys/StormLib/src/lzma/C/LzmaEnc.h deleted file mode 100644 index 200d60e..0000000 --- a/libs/storm-sys/StormLib/src/lzma/C/LzmaEnc.h +++ /dev/null @@ -1,80 +0,0 @@ -/* LzmaEnc.h -- LZMA Encoder -2009-02-07 : Igor Pavlov : Public domain */ - -#ifndef __LZMA_ENC_H -#define __LZMA_ENC_H - -#include "Types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define LZMA_PROPS_SIZE 5 - -typedef struct _CLzmaEncProps -{ - int level; /* 0 <= level <= 9 */ - UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version - (1 << 12) <= dictSize <= (1 << 30) for 64-bit version - default = (1 << 24) */ - int lc; /* 0 <= lc <= 8, default = 3 */ - int lp; /* 0 <= lp <= 4, default = 0 */ - int pb; /* 0 <= pb <= 4, default = 2 */ - int algo; /* 0 - fast, 1 - normal, default = 1 */ - int fb; /* 5 <= fb <= 273, default = 32 */ - int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */ - int numHashBytes; /* 2, 3 or 4, default = 4 */ - UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */ - unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */ - int numThreads; /* 1 or 2, default = 2 */ -} CLzmaEncProps; - -void LzmaEncProps_Init(CLzmaEncProps *p); -void LzmaEncProps_Normalize(CLzmaEncProps *p); -UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2); - - -/* ---------- CLzmaEncHandle Interface ---------- */ - -/* LzmaEnc_* functions can return the following exit codes: -Returns: - SZ_OK - OK - SZ_ERROR_MEM - Memory allocation error - SZ_ERROR_PARAM - Incorrect paramater in props - SZ_ERROR_WRITE - Write callback error. - SZ_ERROR_PROGRESS - some break from progress callback - SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) -*/ - -typedef void * CLzmaEncHandle; - -CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc); -void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig); -SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props); -SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size); -SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream, - ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); -SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, - int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); - -/* ---------- One Call Interface ---------- */ - -/* LzmaEncode -Return code: - SZ_OK - OK - SZ_ERROR_MEM - Memory allocation error - SZ_ERROR_PARAM - Incorrect paramater - SZ_ERROR_OUTPUT_EOF - output buffer overflow - SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) -*/ - -SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, - const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, - ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libs/storm-sys/StormLib/src/lzma/C/Threads.c b/libs/storm-sys/StormLib/src/lzma/C/Threads.c deleted file mode 100644 index 7af1da2..0000000 --- a/libs/storm-sys/StormLib/src/lzma/C/Threads.c +++ /dev/null @@ -1,84 +0,0 @@ -/* Threads.c -- multithreading library -2009-09-20 : Igor Pavlov : Public domain */ - -#ifndef _WIN32_WCE -#include -#endif - -#include "Threads.h" - -static WRes GetError() -{ - DWORD res = GetLastError(); - return (res) ? (WRes)(res) : 1; -} - -WRes HandleToWRes(HANDLE h) { return (h != 0) ? 0 : GetError(); } -WRes BOOLToWRes(BOOL v) { return v ? 0 : GetError(); } - -WRes HandlePtr_Close(HANDLE *p) -{ - if (*p != NULL) - if (!CloseHandle(*p)) - return GetError(); - *p = NULL; - return 0; -} - -WRes Handle_WaitObject(HANDLE h) { return (WRes)WaitForSingleObject(h, INFINITE); } - -WRes Thread_Create(CThread *p, THREAD_FUNC_TYPE func, LPVOID param) -{ - unsigned threadId; /* Windows Me/98/95: threadId parameter may not be NULL in _beginthreadex/CreateThread functions */ - *p = - #ifdef UNDER_CE - CreateThread(0, 0, func, param, 0, &threadId); - #else - (HANDLE)_beginthreadex(NULL, 0, func, param, 0, &threadId); - #endif - /* maybe we must use errno here, but probably GetLastError() is also OK. */ - return HandleToWRes(*p); -} - -WRes Event_Create(CEvent *p, BOOL manualReset, int signaled) -{ - *p = CreateEvent(NULL, manualReset, (signaled ? TRUE : FALSE), NULL); - return HandleToWRes(*p); -} - -WRes Event_Set(CEvent *p) { return BOOLToWRes(SetEvent(*p)); } -WRes Event_Reset(CEvent *p) { return BOOLToWRes(ResetEvent(*p)); } - -WRes ManualResetEvent_Create(CManualResetEvent *p, int signaled) { return Event_Create(p, TRUE, signaled); } -WRes AutoResetEvent_Create(CAutoResetEvent *p, int signaled) { return Event_Create(p, FALSE, signaled); } -WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p) { return ManualResetEvent_Create(p, 0); } -WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p) { return AutoResetEvent_Create(p, 0); } - - -WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount) -{ - *p = CreateSemaphore(NULL, (LONG)initCount, (LONG)maxCount, NULL); - return HandleToWRes(*p); -} - -static WRes Semaphore_Release(CSemaphore *p, LONG releaseCount, LONG *previousCount) - { return BOOLToWRes(ReleaseSemaphore(*p, releaseCount, previousCount)); } -WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num) - { return Semaphore_Release(p, (LONG)num, NULL); } -WRes Semaphore_Release1(CSemaphore *p) { return Semaphore_ReleaseN(p, 1); } - -WRes CriticalSection_Init(CCriticalSection *p) -{ - /* InitializeCriticalSection can raise only STATUS_NO_MEMORY exception */ - #ifdef _MSC_VER - __try - #endif - { - InitializeCriticalSection(p); - /* InitializeCriticalSectionAndSpinCount(p, 0); */ - } - #ifdef _MSC_VER - __except (EXCEPTION_EXECUTE_HANDLER) { return 1; } - #endif - return 0; -} diff --git a/libs/storm-sys/StormLib/src/lzma/C/Threads.h b/libs/storm-sys/StormLib/src/lzma/C/Threads.h deleted file mode 100644 index d0ddd80..0000000 --- a/libs/storm-sys/StormLib/src/lzma/C/Threads.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Threads.h -- multithreading library -2009-03-27 : Igor Pavlov : Public domain */ - -#ifndef __7Z_THREADS_H -#define __7Z_THREADS_H - -#include "Types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -WRes HandlePtr_Close(HANDLE *h); -WRes Handle_WaitObject(HANDLE h); - -typedef HANDLE CThread; -#define Thread_Construct(p) *(p) = NULL -#define Thread_WasCreated(p) (*(p) != NULL) -#define Thread_Close(p) HandlePtr_Close(p) -#define Thread_Wait(p) Handle_WaitObject(*(p)) -typedef unsigned THREAD_FUNC_RET_TYPE; -#define THREAD_FUNC_CALL_TYPE MY_STD_CALL -#define THREAD_FUNC_DECL THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE -typedef THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE * THREAD_FUNC_TYPE)(void *); -WRes Thread_Create(CThread *p, THREAD_FUNC_TYPE func, LPVOID param); - -typedef HANDLE CEvent; -typedef CEvent CAutoResetEvent; -typedef CEvent CManualResetEvent; -#define Event_Construct(p) *(p) = NULL -#define Event_IsCreated(p) (*(p) != NULL) -#define Event_Close(p) HandlePtr_Close(p) -#define Event_Wait(p) Handle_WaitObject(*(p)) -WRes Event_Set(CEvent *p); -WRes Event_Reset(CEvent *p); -WRes ManualResetEvent_Create(CManualResetEvent *p, int signaled); -WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p); -WRes AutoResetEvent_Create(CAutoResetEvent *p, int signaled); -WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p); - -typedef HANDLE CSemaphore; -#define Semaphore_Construct(p) (*p) = NULL -#define Semaphore_Close(p) HandlePtr_Close(p) -#define Semaphore_Wait(p) Handle_WaitObject(*(p)) -WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount); -WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num); -WRes Semaphore_Release1(CSemaphore *p); - -typedef CRITICAL_SECTION CCriticalSection; -WRes CriticalSection_Init(CCriticalSection *p); -#define CriticalSection_Delete(p) DeleteCriticalSection(p) -#define CriticalSection_Enter(p) EnterCriticalSection(p) -#define CriticalSection_Leave(p) LeaveCriticalSection(p) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libs/storm-sys/StormLib/src/lzma/C/Types.h b/libs/storm-sys/StormLib/src/lzma/C/Types.h deleted file mode 100644 index 0526cb4..0000000 --- a/libs/storm-sys/StormLib/src/lzma/C/Types.h +++ /dev/null @@ -1,236 +0,0 @@ -/* Types.h -- Basic types -2010-03-11 : Igor Pavlov : Public domain */ - -#ifndef __7Z_TYPES_H -#define __7Z_TYPES_H - -#include - -#ifdef _WIN32 -#include -#endif - -#ifndef EXTERN_C_BEGIN -#ifdef __cplusplus -#define EXTERN_C_BEGIN extern "C" { -#define EXTERN_C_END } -#else -#define EXTERN_C_BEGIN -#define EXTERN_C_END -#endif -#endif - -EXTERN_C_BEGIN - -#define SZ_OK 0 - -#define SZ_ERROR_DATA 1 -#define SZ_ERROR_MEM 2 -#define SZ_ERROR_CRC 3 -#define SZ_ERROR_UNSUPPORTED 4 -#define SZ_ERROR_PARAM 5 -#define SZ_ERROR_INPUT_EOF 6 -#define SZ_ERROR_OUTPUT_EOF 7 -#define SZ_ERROR_READ 8 -#define SZ_ERROR_WRITE 9 -#define SZ_ERROR_PROGRESS 10 -#define SZ_ERROR_FAIL 11 -#define SZ_ERROR_THREAD 12 - -#define SZ_ERROR_ARCHIVE 16 -#define SZ_ERROR_NO_ARCHIVE 17 - -typedef int SRes; - -#ifdef _WIN32 -typedef DWORD WRes; -#else -typedef int WRes; -#endif - -#ifndef RINOK -#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; } -#endif - -typedef unsigned char Byte; -typedef short Int16; -typedef unsigned short UInt16; - -#ifdef _LZMA_UINT32_IS_ULONG -typedef long Int32; -typedef unsigned long UInt32; -#else -typedef int Int32; -typedef unsigned int UInt32; -#endif - -#ifdef _SZ_NO_INT_64 - -/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers. - NOTES: Some code will work incorrectly in that case! */ - -typedef long Int64; -typedef unsigned long UInt64; - -#else - -#if defined(_MSC_VER) || defined(__BORLANDC__) -typedef __int64 Int64; -typedef unsigned __int64 UInt64; -#else -typedef long long int Int64; -typedef unsigned long long int UInt64; -#endif - -#endif - -#ifdef _LZMA_NO_SYSTEM_SIZE_T -typedef UInt32 SizeT; -#else -typedef size_t SizeT; -#endif - -typedef int Bool; -#define True 1 -#define False 0 - - -#ifdef _WIN32 -#define MY_STD_CALL __stdcall -#else -#define MY_STD_CALL -#endif - -#ifdef _MSC_VER - -#if _MSC_VER >= 1300 -#define MY_NO_INLINE __declspec(noinline) -#else -#define MY_NO_INLINE -#endif - -#define MY_CDECL __cdecl -#define MY_FAST_CALL __fastcall - -#else - -#define MY_CDECL -#define MY_FAST_CALL - -#endif - - -/* The following interfaces use first parameter as pointer to structure */ - -typedef struct -{ - Byte (*Read)(void *p); /* reads one byte, returns 0 in case of EOF or error */ -} IByteIn; - -typedef struct -{ - void (*Write)(void *p, Byte b); -} IByteOut; - -typedef struct -{ - SRes (*Read)(void *p, void *buf, size_t *size); - /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. - (output(*size) < input(*size)) is allowed */ -} ISeqInStream; - -/* it can return SZ_ERROR_INPUT_EOF */ -SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size); -SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType); -SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf); - -typedef struct -{ - size_t (*Write)(void *p, const void *buf, size_t size); - /* Returns: result - the number of actually written bytes. - (result < size) means error */ -} ISeqOutStream; - -typedef enum -{ - SZ_SEEK_SET = 0, - SZ_SEEK_CUR = 1, - SZ_SEEK_END = 2 -} ESzSeek; - -typedef struct -{ - SRes (*Read)(void *p, void *buf, size_t *size); /* same as ISeqInStream::Read */ - SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin); -} ISeekInStream; - -typedef struct -{ - SRes (*Look)(void *p, const void **buf, size_t *size); - /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. - (output(*size) > input(*size)) is not allowed - (output(*size) < input(*size)) is allowed */ - SRes (*Skip)(void *p, size_t offset); - /* offset must be <= output(*size) of Look */ - - SRes (*Read)(void *p, void *buf, size_t *size); - /* reads directly (without buffer). It's same as ISeqInStream::Read */ - SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin); -} ILookInStream; - -SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size); -SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset); - -/* reads via ILookInStream::Read */ -SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType); -SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size); - -#define LookToRead_BUF_SIZE (1 << 14) - -typedef struct -{ - ILookInStream s; - ISeekInStream *realStream; - size_t pos; - size_t size; - Byte buf[LookToRead_BUF_SIZE]; -} CLookToRead; - -void LookToRead_CreateVTable(CLookToRead *p, int lookahead); -void LookToRead_Init(CLookToRead *p); - -typedef struct -{ - ISeqInStream s; - ILookInStream *realStream; -} CSecToLook; - -void SecToLook_CreateVTable(CSecToLook *p); - -typedef struct -{ - ISeqInStream s; - ILookInStream *realStream; -} CSecToRead; - -void SecToRead_CreateVTable(CSecToRead *p); - -typedef struct -{ - SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize); - /* Returns: result. (result != SZ_OK) means break. - Value (UInt64)(Int64)-1 for size means unknown value. */ -} ICompressProgress; - -typedef struct -{ - void *(*Alloc)(void *p, size_t size); - void (*Free)(void *p, void *address); /* address can be 0 */ -} ISzAlloc; - -#define IAlloc_Alloc(p, size) (p)->Alloc((p), size) -#define IAlloc_Free(p, a) (p)->Free((p), a) - -EXTERN_C_END - -#endif diff --git a/libs/storm-sys/StormLib/src/lzma/info.txt b/libs/storm-sys/StormLib/src/lzma/info.txt deleted file mode 100644 index 4cee86e..0000000 --- a/libs/storm-sys/StormLib/src/lzma/info.txt +++ /dev/null @@ -1 +0,0 @@ -Taken from LZMA SDK v 9.11 \ No newline at end of file diff --git a/libs/storm-sys/StormLib/src/pklib/crc32.c b/libs/storm-sys/StormLib/src/pklib/crc32.c deleted file mode 100644 index cd47b1d..0000000 --- a/libs/storm-sys/StormLib/src/pklib/crc32.c +++ /dev/null @@ -1,66 +0,0 @@ -/*****************************************************************************/ -/* crc32.c Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Pkware Data Compression Library Version 1.11 */ -/* Dissassembled method crc32 - cdecl version */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 09.04.03 1.00 Lad The first version of crc32.c */ -/* 02.05.03 1.00 Lad Stress test done */ -/*****************************************************************************/ - -#include "pklib.h" - -static unsigned long crc_table[] = -{ - 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, - 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, - 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, - 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, - 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, - 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, - 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, - 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, - 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, - 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, - 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, - 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, - 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, - 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, - 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, - 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, - 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, - 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, - 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, - 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, - 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, - 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, - 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, - 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, - 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, - 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, - 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, - 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, - 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, - 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, - 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, - 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D -}; - - -unsigned long PKEXPORT crc32_pklib(char * buffer, unsigned int * psize, unsigned long * old_crc) -{ - unsigned int size = *psize; - unsigned long ch; - unsigned long crc_value = *old_crc; - - while(size-- != 0) - { - ch = *buffer++ ^ (char)crc_value; - crc_value >>= 8; - - crc_value = crc_table[ch & 0x0FF] ^ crc_value; - } - return crc_value; -} diff --git a/libs/storm-sys/StormLib/src/pklib/explode.c b/libs/storm-sys/StormLib/src/pklib/explode.c deleted file mode 100644 index 9796173..0000000 --- a/libs/storm-sys/StormLib/src/pklib/explode.c +++ /dev/null @@ -1,522 +0,0 @@ -/*****************************************************************************/ -/* explode.c Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Implode function of PKWARE Data Compression library */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 11.03.03 1.00 Lad Splitted from Pkware.cpp */ -/* 08.04.03 1.01 Lad Renamed to explode.c to be compatible with pklib */ -/* 02.05.03 1.01 Lad Stress test done */ -/* 22.04.10 1.01 Lad Documented */ -/*****************************************************************************/ - -#include -#include - -#include "pklib.h" - -#define PKDCL_OK 0 -#define PKDCL_STREAM_END 1 // All data from the input stream is read -#define PKDCL_NEED_DICT 2 // Need more data (dictionary) -#define PKDCL_CONTINUE 10 // Internal flag, not returned to user -#define PKDCL_GET_INPUT 11 // Internal flag, not returned to user - -char CopyrightPkware[] = "PKWARE Data Compression Library for Win32\r\n" - "Copyright 1989-1995 PKWARE Inc. All Rights Reserved\r\n" - "Patent No. 5,051,745\r\n" - "PKWARE Data Compression Library Reg. U.S. Pat. and Tm. Off.\r\n" - "Version 1.11\r\n"; - -//----------------------------------------------------------------------------- -// Tables - -static unsigned char DistBits[] = -{ - 0x02, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 -}; - -static unsigned char DistCode[] = -{ - 0x03, 0x0D, 0x05, 0x19, 0x09, 0x11, 0x01, 0x3E, 0x1E, 0x2E, 0x0E, 0x36, 0x16, 0x26, 0x06, 0x3A, - 0x1A, 0x2A, 0x0A, 0x32, 0x12, 0x22, 0x42, 0x02, 0x7C, 0x3C, 0x5C, 0x1C, 0x6C, 0x2C, 0x4C, 0x0C, - 0x74, 0x34, 0x54, 0x14, 0x64, 0x24, 0x44, 0x04, 0x78, 0x38, 0x58, 0x18, 0x68, 0x28, 0x48, 0x08, - 0xF0, 0x70, 0xB0, 0x30, 0xD0, 0x50, 0x90, 0x10, 0xE0, 0x60, 0xA0, 0x20, 0xC0, 0x40, 0x80, 0x00 -}; - -static unsigned char ExLenBits[] = -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 -}; - -static unsigned short LenBase[] = -{ - 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, - 0x0008, 0x000A, 0x000E, 0x0016, 0x0026, 0x0046, 0x0086, 0x0106 -}; - -static unsigned char LenBits[] = -{ - 0x03, 0x02, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x07, 0x07 -}; - -static unsigned char LenCode[] = -{ - 0x05, 0x03, 0x01, 0x06, 0x0A, 0x02, 0x0C, 0x14, 0x04, 0x18, 0x08, 0x30, 0x10, 0x20, 0x40, 0x00 -}; - -static unsigned char ChBitsAsc[] = -{ - 0x0B, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x08, 0x07, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x04, 0x0A, 0x08, 0x0C, 0x0A, 0x0C, 0x0A, 0x08, 0x07, 0x07, 0x08, 0x09, 0x07, 0x06, 0x07, 0x08, - 0x07, 0x06, 0x07, 0x07, 0x07, 0x07, 0x08, 0x07, 0x07, 0x08, 0x08, 0x0C, 0x0B, 0x07, 0x09, 0x0B, - 0x0C, 0x06, 0x07, 0x06, 0x06, 0x05, 0x07, 0x08, 0x08, 0x06, 0x0B, 0x09, 0x06, 0x07, 0x06, 0x06, - 0x07, 0x0B, 0x06, 0x06, 0x06, 0x07, 0x09, 0x08, 0x09, 0x09, 0x0B, 0x08, 0x0B, 0x09, 0x0C, 0x08, - 0x0C, 0x05, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x05, 0x0B, 0x07, 0x05, 0x06, 0x05, 0x05, - 0x06, 0x0A, 0x05, 0x05, 0x05, 0x05, 0x08, 0x07, 0x08, 0x08, 0x0A, 0x0B, 0x0B, 0x0C, 0x0C, 0x0C, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, - 0x0D, 0x0D, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D -}; - -static unsigned short ChCodeAsc[] = -{ - 0x0490, 0x0FE0, 0x07E0, 0x0BE0, 0x03E0, 0x0DE0, 0x05E0, 0x09E0, - 0x01E0, 0x00B8, 0x0062, 0x0EE0, 0x06E0, 0x0022, 0x0AE0, 0x02E0, - 0x0CE0, 0x04E0, 0x08E0, 0x00E0, 0x0F60, 0x0760, 0x0B60, 0x0360, - 0x0D60, 0x0560, 0x1240, 0x0960, 0x0160, 0x0E60, 0x0660, 0x0A60, - 0x000F, 0x0250, 0x0038, 0x0260, 0x0050, 0x0C60, 0x0390, 0x00D8, - 0x0042, 0x0002, 0x0058, 0x01B0, 0x007C, 0x0029, 0x003C, 0x0098, - 0x005C, 0x0009, 0x001C, 0x006C, 0x002C, 0x004C, 0x0018, 0x000C, - 0x0074, 0x00E8, 0x0068, 0x0460, 0x0090, 0x0034, 0x00B0, 0x0710, - 0x0860, 0x0031, 0x0054, 0x0011, 0x0021, 0x0017, 0x0014, 0x00A8, - 0x0028, 0x0001, 0x0310, 0x0130, 0x003E, 0x0064, 0x001E, 0x002E, - 0x0024, 0x0510, 0x000E, 0x0036, 0x0016, 0x0044, 0x0030, 0x00C8, - 0x01D0, 0x00D0, 0x0110, 0x0048, 0x0610, 0x0150, 0x0060, 0x0088, - 0x0FA0, 0x0007, 0x0026, 0x0006, 0x003A, 0x001B, 0x001A, 0x002A, - 0x000A, 0x000B, 0x0210, 0x0004, 0x0013, 0x0032, 0x0003, 0x001D, - 0x0012, 0x0190, 0x000D, 0x0015, 0x0005, 0x0019, 0x0008, 0x0078, - 0x00F0, 0x0070, 0x0290, 0x0410, 0x0010, 0x07A0, 0x0BA0, 0x03A0, - 0x0240, 0x1C40, 0x0C40, 0x1440, 0x0440, 0x1840, 0x0840, 0x1040, - 0x0040, 0x1F80, 0x0F80, 0x1780, 0x0780, 0x1B80, 0x0B80, 0x1380, - 0x0380, 0x1D80, 0x0D80, 0x1580, 0x0580, 0x1980, 0x0980, 0x1180, - 0x0180, 0x1E80, 0x0E80, 0x1680, 0x0680, 0x1A80, 0x0A80, 0x1280, - 0x0280, 0x1C80, 0x0C80, 0x1480, 0x0480, 0x1880, 0x0880, 0x1080, - 0x0080, 0x1F00, 0x0F00, 0x1700, 0x0700, 0x1B00, 0x0B00, 0x1300, - 0x0DA0, 0x05A0, 0x09A0, 0x01A0, 0x0EA0, 0x06A0, 0x0AA0, 0x02A0, - 0x0CA0, 0x04A0, 0x08A0, 0x00A0, 0x0F20, 0x0720, 0x0B20, 0x0320, - 0x0D20, 0x0520, 0x0920, 0x0120, 0x0E20, 0x0620, 0x0A20, 0x0220, - 0x0C20, 0x0420, 0x0820, 0x0020, 0x0FC0, 0x07C0, 0x0BC0, 0x03C0, - 0x0DC0, 0x05C0, 0x09C0, 0x01C0, 0x0EC0, 0x06C0, 0x0AC0, 0x02C0, - 0x0CC0, 0x04C0, 0x08C0, 0x00C0, 0x0F40, 0x0740, 0x0B40, 0x0340, - 0x0300, 0x0D40, 0x1D00, 0x0D00, 0x1500, 0x0540, 0x0500, 0x1900, - 0x0900, 0x0940, 0x1100, 0x0100, 0x1E00, 0x0E00, 0x0140, 0x1600, - 0x0600, 0x1A00, 0x0E40, 0x0640, 0x0A40, 0x0A00, 0x1200, 0x0200, - 0x1C00, 0x0C00, 0x1400, 0x0400, 0x1800, 0x0800, 0x1000, 0x0000 -}; - -//----------------------------------------------------------------------------- -// Local functions - -static void GenDecodeTabs( - unsigned char * positions, // [out] Table of positions - unsigned char * start_indexes, // [in] Table of start indexes - unsigned char * length_bits, // [in] Table of lengths. Each length is stored as number of bits - size_t elements) // [in] Number of elements in start_indexes and length_bits -{ - unsigned int index; - unsigned int length; - size_t i; - - for(i = 0; i < elements; i++) - { - length = 1 << length_bits[i]; // Get the length in bytes - - for(index = start_indexes[i]; index < 0x100; index += length) - { - positions[index] = (unsigned char)i; - } - } -} - -static void GenAscTabs(TDcmpStruct * pWork) -{ - unsigned short * pChCodeAsc = &ChCodeAsc[0xFF]; - unsigned int acc, add; - unsigned short count; - - for(count = 0x00FF; pChCodeAsc >= ChCodeAsc; pChCodeAsc--, count--) - { - unsigned char * pChBitsAsc = pWork->ChBitsAsc + count; - unsigned char bits_asc = *pChBitsAsc; - - if(bits_asc <= 8) - { - add = (1 << bits_asc); - acc = *pChCodeAsc; - - do - { - pWork->offs2C34[acc] = (unsigned char)count; - acc += add; - } - while(acc < 0x100); - } - else if((acc = (*pChCodeAsc & 0xFF)) != 0) - { - pWork->offs2C34[acc] = 0xFF; - - if(*pChCodeAsc & 0x3F) - { - bits_asc -= 4; - *pChBitsAsc = bits_asc; - - add = (1 << bits_asc); - acc = *pChCodeAsc >> 4; - do - { - pWork->offs2D34[acc] = (unsigned char)count; - acc += add; - } - while(acc < 0x100); - } - else - { - bits_asc -= 6; - *pChBitsAsc = bits_asc; - - add = (1 << bits_asc); - acc = *pChCodeAsc >> 6; - do - { - pWork->offs2E34[acc] = (unsigned char)count; - acc += add; - } - while(acc < 0x80); - } - } - else - { - bits_asc -= 8; - *pChBitsAsc = bits_asc; - - add = (1 << bits_asc); - acc = *pChCodeAsc >> 8; - do - { - pWork->offs2EB4[acc] = (unsigned char)count; - acc += add; - } - while(acc < 0x100); - } - } -} - -//----------------------------------------------------------------------------- -// Removes given number of bits in the bit buffer. New bits are reloaded from -// the input buffer, if needed. -// Returns: PKDCL_OK: Operation was successful -// PKDCL_STREAM_END: There are no more bits in the input buffer - -static int WasteBits(TDcmpStruct * pWork, unsigned int nBits) -{ - // If number of bits required is less than number of (bits in the buffer) ? - if(nBits <= pWork->extra_bits) - { - pWork->extra_bits -= nBits; - pWork->bit_buff >>= nBits; - return PKDCL_OK; - } - - // Load input buffer if necessary - pWork->bit_buff >>= pWork->extra_bits; - if(pWork->in_pos == pWork->in_bytes) - { - pWork->in_pos = sizeof(pWork->in_buff); - if((pWork->in_bytes = pWork->read_buf((char *)pWork->in_buff, &pWork->in_pos, pWork->param)) == 0) - return PKDCL_STREAM_END; - pWork->in_pos = 0; - } - - // Update bit buffer - pWork->bit_buff |= (pWork->in_buff[pWork->in_pos++] << 8); - pWork->bit_buff >>= (nBits - pWork->extra_bits); - pWork->extra_bits = (pWork->extra_bits - nBits) + 8; - return PKDCL_OK; -} - -//----------------------------------------------------------------------------- -// Decodes next literal from the input (compressed) data. -// Returns : 0x000: One byte 0x00 -// 0x001: One byte 0x01 -// ... -// 0x0FF: One byte 0xFF -// 0x100: Repetition, length of 0x02 bytes -// 0x101: Repetition, length of 0x03 bytes -// ... -// 0x304: Repetition, length of 0x206 bytes -// 0x305: End of stream -// 0x306: Error - -static unsigned int DecodeLit(TDcmpStruct * pWork) -{ - unsigned int extra_length_bits; // Number of bits of extra literal length - unsigned int length_code; // Length code - unsigned int value; - - // Test the current bit in byte buffer. If is not set, simply return the next 8 bits. - if(pWork->bit_buff & 1) - { - // Remove one bit from the input data - if(WasteBits(pWork, 1)) - return 0x306; - - // The next 8 bits hold the index to the length code table - length_code = pWork->LengthCodes[pWork->bit_buff & 0xFF]; - - // Remove the apropriate number of bits - if(WasteBits(pWork, pWork->LenBits[length_code])) - return 0x306; - - // Are there some extra bits for the obtained length code ? - if((extra_length_bits = pWork->ExLenBits[length_code]) != 0) - { - unsigned int extra_length = pWork->bit_buff & ((1 << extra_length_bits) - 1); - - if(WasteBits(pWork, extra_length_bits)) - { - if((length_code + extra_length) != 0x10E) - return 0x306; - } - length_code = pWork->LenBase[length_code] + extra_length; - } - - // In order to distinguish uncompressed byte from repetition length, - // we have to add 0x100 to the length. - return length_code + 0x100; - } - - // Remove one bit from the input data - if(WasteBits(pWork, 1)) - return 0x306; - - // If the binary compression type, read 8 bits and return them as one byte. - if(pWork->ctype == CMP_BINARY) - { - unsigned int uncompressed_byte = pWork->bit_buff & 0xFF; - - if(WasteBits(pWork, 8)) - return 0x306; - return uncompressed_byte; - } - - // When ASCII compression ... - if(pWork->bit_buff & 0xFF) - { - value = pWork->offs2C34[pWork->bit_buff & 0xFF]; - - if(value == 0xFF) - { - if(pWork->bit_buff & 0x3F) - { - if(WasteBits(pWork, 4)) - return 0x306; - - value = pWork->offs2D34[pWork->bit_buff & 0xFF]; - } - else - { - if(WasteBits(pWork, 6)) - return 0x306; - - value = pWork->offs2E34[pWork->bit_buff & 0x7F]; - } - } - } - else - { - if(WasteBits(pWork, 8)) - return 0x306; - - value = pWork->offs2EB4[pWork->bit_buff & 0xFF]; - } - - return WasteBits(pWork, pWork->ChBitsAsc[value]) ? 0x306 : value; -} - -//----------------------------------------------------------------------------- -// Decodes the distance of the repetition, backwards relative to the -// current output buffer position - -static unsigned int DecodeDist(TDcmpStruct * pWork, unsigned int rep_length) -{ - unsigned int dist_pos_code; // Distance position code - unsigned int dist_pos_bits; // Number of bits of distance position - unsigned int distance; // Distance position - - // Next 2-8 bits in the input buffer is the distance position code - dist_pos_code = pWork->DistPosCodes[pWork->bit_buff & 0xFF]; - dist_pos_bits = pWork->DistBits[dist_pos_code]; - if(WasteBits(pWork, dist_pos_bits)) - return 0; - - if(rep_length == 2) - { - // If the repetition is only 2 bytes length, - // then take 2 bits from the stream in order to get the distance - distance = (dist_pos_code << 2) | (pWork->bit_buff & 0x03); - if(WasteBits(pWork, 2)) - return 0; - } - else - { - // If the repetition is more than 2 bytes length, - // then take "dsize_bits" bits in order to get the distance - distance = (dist_pos_code << pWork->dsize_bits) | (pWork->bit_buff & pWork->dsize_mask); - if(WasteBits(pWork, pWork->dsize_bits)) - return 0; - } - return distance + 1; -} - -static unsigned int Expand(TDcmpStruct * pWork) -{ - unsigned int next_literal; // Literal decoded from the compressed data - unsigned int result; // Value to be returned - unsigned int copyBytes; // Number of bytes to copy to the output buffer - - pWork->outputPos = 0x1000; // Initialize output buffer position - - // Decode the next literal from the input data. - // The returned literal can either be an uncompressed byte (next_literal < 0x100) - // or an encoded length of the repeating byte sequence that - // is to be copied to the current buffer position - while((result = next_literal = DecodeLit(pWork)) < 0x305) - { - // If the literal is greater than 0x100, it holds length - // of repeating byte sequence - // literal of 0x100 means repeating sequence of 0x2 bytes - // literal of 0x101 means repeating sequence of 0x3 bytes - // ... - // literal of 0x305 means repeating sequence of 0x207 bytes - if(next_literal >= 0x100) - { - unsigned char * source; - unsigned char * target; - unsigned int rep_length; // Length of the repetition, in bytes - unsigned int minus_dist; // Backward distance to the repetition, relative to the current buffer position - - // Get the length of the repeating sequence. - // Note that the repeating block may overlap the current output position, - // for example if there was a sequence of equal bytes - rep_length = next_literal - 0xFE; - - // Get backward distance to the repetition - if((minus_dist = DecodeDist(pWork, rep_length)) == 0) - { - result = 0x306; - break; - } - - // Target and source pointer - target = &pWork->out_buff[pWork->outputPos]; - source = target - minus_dist; - - // Update buffer output position - pWork->outputPos += rep_length; - - // Copy the repeating sequence - while(rep_length-- > 0) - *target++ = *source++; - } - else - { - pWork->out_buff[pWork->outputPos++] = (unsigned char)next_literal; - } - - // Flush the output buffer, if number of extracted bytes has reached the end - if(pWork->outputPos >= 0x2000) - { - // Copy decompressed data into user buffer - copyBytes = 0x1000; - pWork->write_buf((char *)&pWork->out_buff[0x1000], ©Bytes, pWork->param); - - // Now copy the decompressed data to the first half of the buffer. - // This is needed because the decompression might reuse them as repetitions. - // Note that if the output buffer overflowed previously, the extra decompressed bytes - // are stored in "out_buff_overflow", and they will now be - // within decompressed part of the output buffer. - memmove(pWork->out_buff, &pWork->out_buff[0x1000], pWork->outputPos - 0x1000); - pWork->outputPos -= 0x1000; - } - } - - // Flush any remaining decompressed bytes - copyBytes = pWork->outputPos - 0x1000; - pWork->write_buf((char *)&pWork->out_buff[0x1000], ©Bytes, pWork->param); - return result; -} - - -//----------------------------------------------------------------------------- -// Main exploding function. - -unsigned int explode( - unsigned int (*read_buf)(char *buf, unsigned int *size, void *param), - void (*write_buf)(char *buf, unsigned int *size, void *param), - char *work_buf, - void *param) -{ - TDcmpStruct * pWork = (TDcmpStruct *)work_buf; - - // Initialize work struct and load compressed data - // Note: The caller must zero the "work_buff" before passing it to explode - pWork->read_buf = read_buf; - pWork->write_buf = write_buf; - pWork->param = param; - pWork->in_pos = sizeof(pWork->in_buff); - pWork->in_bytes = pWork->read_buf((char *)pWork->in_buff, &pWork->in_pos, pWork->param); - if(pWork->in_bytes <= 4) - return CMP_BAD_DATA; - - pWork->ctype = pWork->in_buff[0]; // Get the compression type (CMP_BINARY or CMP_ASCII) - pWork->dsize_bits = pWork->in_buff[1]; // Get the dictionary size - pWork->bit_buff = pWork->in_buff[2]; // Initialize 16-bit bit buffer - pWork->extra_bits = 0; // Extra (over 8) bits - pWork->in_pos = 3; // Position in input buffer - - // Test for the valid dictionary size - if(4 > pWork->dsize_bits || pWork->dsize_bits > 6) - return CMP_INVALID_DICTSIZE; - - pWork->dsize_mask = 0xFFFF >> (0x10 - pWork->dsize_bits); // Shifted by 'sar' instruction - - if(pWork->ctype != CMP_BINARY) - { - if(pWork->ctype != CMP_ASCII) - return CMP_INVALID_MODE; - - memcpy(pWork->ChBitsAsc, ChBitsAsc, sizeof(pWork->ChBitsAsc)); - GenAscTabs(pWork); - } - - memcpy(pWork->LenBits, LenBits, sizeof(pWork->LenBits)); - GenDecodeTabs(pWork->LengthCodes, LenCode, pWork->LenBits, sizeof(pWork->LenBits)); - memcpy(pWork->ExLenBits, ExLenBits, sizeof(pWork->ExLenBits)); - memcpy(pWork->LenBase, LenBase, sizeof(pWork->LenBase)); - memcpy(pWork->DistBits, DistBits, sizeof(pWork->DistBits)); - GenDecodeTabs(pWork->DistPosCodes, DistCode, pWork->DistBits, sizeof(pWork->DistBits)); - if(Expand(pWork) != 0x306) - return CMP_NO_ERROR; - - return CMP_ABORT; -} diff --git a/libs/storm-sys/StormLib/src/pklib/implode.c b/libs/storm-sys/StormLib/src/pklib/implode.c deleted file mode 100644 index f29f54d..0000000 --- a/libs/storm-sys/StormLib/src/pklib/implode.c +++ /dev/null @@ -1,769 +0,0 @@ -/*****************************************************************************/ -/* implode.c Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Implode function of PKWARE Data Compression library */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 11.04.03 1.00 Lad First version of implode.c */ -/* 02.05.03 1.00 Lad Stress test done */ -/* 22.04.10 1.01 Lad Documented */ -/*****************************************************************************/ - -#include -#include - -#include "pklib.h" - -#if ((1200 < _MSC_VER) && (_MSC_VER < 1400)) -#pragma optimize("", off) // Fucking Microsoft VS.NET 2003 compiler !!! (_MSC_VER=1310) -#endif - -//----------------------------------------------------------------------------- -// Defines - -#define MAX_REP_LENGTH 0x204 // The longest allowed repetition - -//----------------------------------------------------------------------------- -// Tables - -static unsigned char DistBits[] = -{ - 0x02, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 -}; - -static unsigned char DistCode[] = -{ - 0x03, 0x0D, 0x05, 0x19, 0x09, 0x11, 0x01, 0x3E, 0x1E, 0x2E, 0x0E, 0x36, 0x16, 0x26, 0x06, 0x3A, - 0x1A, 0x2A, 0x0A, 0x32, 0x12, 0x22, 0x42, 0x02, 0x7C, 0x3C, 0x5C, 0x1C, 0x6C, 0x2C, 0x4C, 0x0C, - 0x74, 0x34, 0x54, 0x14, 0x64, 0x24, 0x44, 0x04, 0x78, 0x38, 0x58, 0x18, 0x68, 0x28, 0x48, 0x08, - 0xF0, 0x70, 0xB0, 0x30, 0xD0, 0x50, 0x90, 0x10, 0xE0, 0x60, 0xA0, 0x20, 0xC0, 0x40, 0x80, 0x00 -}; - -static unsigned char ExLenBits[] = -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 -}; - -static unsigned char LenBits[] = -{ - 0x03, 0x02, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x07, 0x07 -}; - -static unsigned char LenCode[] = -{ - 0x05, 0x03, 0x01, 0x06, 0x0A, 0x02, 0x0C, 0x14, 0x04, 0x18, 0x08, 0x30, 0x10, 0x20, 0x40, 0x00 -}; - -static unsigned char ChBitsAsc[] = -{ - 0x0B, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x08, 0x07, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x04, 0x0A, 0x08, 0x0C, 0x0A, 0x0C, 0x0A, 0x08, 0x07, 0x07, 0x08, 0x09, 0x07, 0x06, 0x07, 0x08, - 0x07, 0x06, 0x07, 0x07, 0x07, 0x07, 0x08, 0x07, 0x07, 0x08, 0x08, 0x0C, 0x0B, 0x07, 0x09, 0x0B, - 0x0C, 0x06, 0x07, 0x06, 0x06, 0x05, 0x07, 0x08, 0x08, 0x06, 0x0B, 0x09, 0x06, 0x07, 0x06, 0x06, - 0x07, 0x0B, 0x06, 0x06, 0x06, 0x07, 0x09, 0x08, 0x09, 0x09, 0x0B, 0x08, 0x0B, 0x09, 0x0C, 0x08, - 0x0C, 0x05, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x05, 0x0B, 0x07, 0x05, 0x06, 0x05, 0x05, - 0x06, 0x0A, 0x05, 0x05, 0x05, 0x05, 0x08, 0x07, 0x08, 0x08, 0x0A, 0x0B, 0x0B, 0x0C, 0x0C, 0x0C, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0C, 0x0D, - 0x0D, 0x0D, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D -}; - -static unsigned short ChCodeAsc[] = -{ - 0x0490, 0x0FE0, 0x07E0, 0x0BE0, 0x03E0, 0x0DE0, 0x05E0, 0x09E0, - 0x01E0, 0x00B8, 0x0062, 0x0EE0, 0x06E0, 0x0022, 0x0AE0, 0x02E0, - 0x0CE0, 0x04E0, 0x08E0, 0x00E0, 0x0F60, 0x0760, 0x0B60, 0x0360, - 0x0D60, 0x0560, 0x1240, 0x0960, 0x0160, 0x0E60, 0x0660, 0x0A60, - 0x000F, 0x0250, 0x0038, 0x0260, 0x0050, 0x0C60, 0x0390, 0x00D8, - 0x0042, 0x0002, 0x0058, 0x01B0, 0x007C, 0x0029, 0x003C, 0x0098, - 0x005C, 0x0009, 0x001C, 0x006C, 0x002C, 0x004C, 0x0018, 0x000C, - 0x0074, 0x00E8, 0x0068, 0x0460, 0x0090, 0x0034, 0x00B0, 0x0710, - 0x0860, 0x0031, 0x0054, 0x0011, 0x0021, 0x0017, 0x0014, 0x00A8, - 0x0028, 0x0001, 0x0310, 0x0130, 0x003E, 0x0064, 0x001E, 0x002E, - 0x0024, 0x0510, 0x000E, 0x0036, 0x0016, 0x0044, 0x0030, 0x00C8, - 0x01D0, 0x00D0, 0x0110, 0x0048, 0x0610, 0x0150, 0x0060, 0x0088, - 0x0FA0, 0x0007, 0x0026, 0x0006, 0x003A, 0x001B, 0x001A, 0x002A, - 0x000A, 0x000B, 0x0210, 0x0004, 0x0013, 0x0032, 0x0003, 0x001D, - 0x0012, 0x0190, 0x000D, 0x0015, 0x0005, 0x0019, 0x0008, 0x0078, - 0x00F0, 0x0070, 0x0290, 0x0410, 0x0010, 0x07A0, 0x0BA0, 0x03A0, - 0x0240, 0x1C40, 0x0C40, 0x1440, 0x0440, 0x1840, 0x0840, 0x1040, - 0x0040, 0x1F80, 0x0F80, 0x1780, 0x0780, 0x1B80, 0x0B80, 0x1380, - 0x0380, 0x1D80, 0x0D80, 0x1580, 0x0580, 0x1980, 0x0980, 0x1180, - 0x0180, 0x1E80, 0x0E80, 0x1680, 0x0680, 0x1A80, 0x0A80, 0x1280, - 0x0280, 0x1C80, 0x0C80, 0x1480, 0x0480, 0x1880, 0x0880, 0x1080, - 0x0080, 0x1F00, 0x0F00, 0x1700, 0x0700, 0x1B00, 0x0B00, 0x1300, - 0x0DA0, 0x05A0, 0x09A0, 0x01A0, 0x0EA0, 0x06A0, 0x0AA0, 0x02A0, - 0x0CA0, 0x04A0, 0x08A0, 0x00A0, 0x0F20, 0x0720, 0x0B20, 0x0320, - 0x0D20, 0x0520, 0x0920, 0x0120, 0x0E20, 0x0620, 0x0A20, 0x0220, - 0x0C20, 0x0420, 0x0820, 0x0020, 0x0FC0, 0x07C0, 0x0BC0, 0x03C0, - 0x0DC0, 0x05C0, 0x09C0, 0x01C0, 0x0EC0, 0x06C0, 0x0AC0, 0x02C0, - 0x0CC0, 0x04C0, 0x08C0, 0x00C0, 0x0F40, 0x0740, 0x0B40, 0x0340, - 0x0300, 0x0D40, 0x1D00, 0x0D00, 0x1500, 0x0540, 0x0500, 0x1900, - 0x0900, 0x0940, 0x1100, 0x0100, 0x1E00, 0x0E00, 0x0140, 0x1600, - 0x0600, 0x1A00, 0x0E40, 0x0640, 0x0A40, 0x0A00, 0x1200, 0x0200, - 0x1C00, 0x0C00, 0x1400, 0x0400, 0x1800, 0x0800, 0x1000, 0x0000 -}; - -//----------------------------------------------------------------------------- -// Macros - -// Macro for calculating hash of the current byte pair. -// Note that most exact byte pair hash would be buffer[0] + buffer[1] << 0x08, -// but even this way gives nice indication of equal byte pairs, with significantly -// smaller size of the array that holds numbers of those hashes -#define BYTE_PAIR_HASH(buffer) ((buffer[0] * 4) + (buffer[1] * 5)) - -//----------------------------------------------------------------------------- -// Local functions - -// Builds the "hash_to_index" table and "pair_hash_offsets" table. -// Every element of "hash_to_index" will contain lowest index to the -// "pair_hash_offsets" table, effectively giving offset of the first -// occurence of the given PAIR_HASH in the input data. -static void SortBuffer(TCmpStruct * pWork, unsigned char * buffer_begin, unsigned char * buffer_end) -{ - unsigned short * phash_to_index; - unsigned char * buffer_ptr; - unsigned short total_sum = 0; - unsigned long byte_pair_hash; // Hash value of the byte pair - unsigned short byte_pair_offs; // Offset of the byte pair, relative to "work_buff" - - // Zero the entire "phash_to_index" table - memset(pWork->phash_to_index, 0, sizeof(pWork->phash_to_index)); - - // Step 1: Count amount of each PAIR_HASH in the input buffer - // The table will look like this: - // offs 0x000: Number of occurences of PAIR_HASH 0 - // offs 0x001: Number of occurences of PAIR_HASH 1 - // ... - // offs 0x8F7: Number of occurences of PAIR_HASH 0x8F7 (the highest hash value) - for(buffer_ptr = buffer_begin; buffer_ptr < buffer_end; buffer_ptr++) - pWork->phash_to_index[BYTE_PAIR_HASH(buffer_ptr)]++; - - // Step 2: Convert the table to the array of PAIR_HASH amounts. - // Each element contains count of PAIR_HASHes that is less or equal - // to element index - // The table will look like this: - // offs 0x000: Number of occurences of PAIR_HASH 0 or lower - // offs 0x001: Number of occurences of PAIR_HASH 1 or lower - // ... - // offs 0x8F7: Number of occurences of PAIR_HASH 0x8F7 or lower - for(phash_to_index = pWork->phash_to_index; phash_to_index < &pWork->phash_to_index_end; phash_to_index++) - { - total_sum = total_sum + phash_to_index[0]; - phash_to_index[0] = total_sum; - } - - // Step 3: Convert the table to the array of indexes. - // Now, each element contains index to the first occurence of given PAIR_HASH - for(buffer_end--; buffer_end >= buffer_begin; buffer_end--) - { - byte_pair_hash = BYTE_PAIR_HASH(buffer_end); - byte_pair_offs = (unsigned short)(buffer_end - pWork->work_buff); - - pWork->phash_to_index[byte_pair_hash]--; - pWork->phash_offs[pWork->phash_to_index[byte_pair_hash]] = byte_pair_offs; - } -} - -static void FlushBuf(TCmpStruct * pWork) -{ - unsigned char save_ch1; - unsigned char save_ch2; - unsigned int size = 0x800; - - pWork->write_buf(pWork->out_buff, &size, pWork->param); - - save_ch1 = pWork->out_buff[0x800]; - save_ch2 = pWork->out_buff[pWork->out_bytes]; - pWork->out_bytes -= 0x800; - - memset(pWork->out_buff, 0, sizeof(pWork->out_buff)); - - if(pWork->out_bytes != 0) - pWork->out_buff[0] = save_ch1; - if(pWork->out_bits != 0) - pWork->out_buff[pWork->out_bytes] = save_ch2; -} - -static void OutputBits(TCmpStruct * pWork, unsigned int nbits, unsigned long bit_buff) -{ - unsigned int out_bits; - - // If more than 8 bits to output, do recursion - if(nbits > 8) - { - OutputBits(pWork, 8, bit_buff); - bit_buff >>= 8; - nbits -= 8; - } - - // Add bits to the last out byte in out_buff; - out_bits = pWork->out_bits; - pWork->out_buff[pWork->out_bytes] |= (unsigned char)(bit_buff << out_bits); - pWork->out_bits += nbits; - - // If 8 or more bits, increment number of bytes - if(pWork->out_bits > 8) - { - pWork->out_bytes++; - bit_buff >>= (8 - out_bits); - - pWork->out_buff[pWork->out_bytes] = (unsigned char)bit_buff; - pWork->out_bits &= 7; - } - else - { - pWork->out_bits &= 7; - if(pWork->out_bits == 0) - pWork->out_bytes++; - } - - // If there is enough compressed bytes, flush them - if(pWork->out_bytes >= 0x800) - FlushBuf(pWork); -} - -// This function searches for a repetition -// (a previous occurence of the current byte sequence) -// Returns length of the repetition, and stores the backward distance -// to pWork structure. -static unsigned int FindRep(TCmpStruct * pWork, unsigned char * input_data) -{ - unsigned short * phash_to_index; // Pointer into pWork->phash_to_index table - unsigned short * phash_offs; // Pointer to the table containing offsets of each PAIR_HASH - unsigned char * repetition_limit; // An eventual repetition must be at position below this pointer - unsigned char * prev_repetition; // Pointer to the previous occurence of the current PAIR_HASH - unsigned char * prev_rep_end; // End of the previous repetition - unsigned char * input_data_ptr; - unsigned short phash_offs_index; // Index to the table with PAIR_HASH positions - unsigned short min_phash_offs; // The lowest allowed hash offset - unsigned short offs_in_rep; // Offset within found repetition - unsigned int equal_byte_count; // Number of bytes that are equal to the previous occurence - unsigned int rep_length = 1; // Length of the found repetition - unsigned int rep_length2; // Secondary repetition - unsigned char pre_last_byte; // Last but one byte from a repetion - unsigned short di_val; - - // Calculate the previous position of the PAIR_HASH - phash_to_index = pWork->phash_to_index + BYTE_PAIR_HASH(input_data); - min_phash_offs = (unsigned short)((input_data - pWork->work_buff) - pWork->dsize_bytes + 1); - phash_offs_index = phash_to_index[0]; - - // If the PAIR_HASH offset is below the limit, find a next one - phash_offs = pWork->phash_offs + phash_offs_index; - if(*phash_offs < min_phash_offs) - { - while(*phash_offs < min_phash_offs) - { - phash_offs_index++; - phash_offs++; - } - *phash_to_index = phash_offs_index; - } - - // Get the first location of the PAIR_HASH, - // and thus the first eventual location of byte repetition - phash_offs = pWork->phash_offs + phash_offs_index; - prev_repetition = pWork->work_buff + phash_offs[0]; - repetition_limit = input_data - 1; - - // If the current PAIR_HASH was not encountered before, - // we haven't found a repetition. - if(prev_repetition >= repetition_limit) - return 0; - - // We have found a match of a PAIR_HASH. Now we have to make sure - // that it is also a byte match, because PAIR_HASH is not unique. - // We compare the bytes and count the length of the repetition - input_data_ptr = input_data; - for(;;) - { - // If the first byte of the repetition and the so-far-last byte - // of the repetition are equal, we will compare the blocks. - if(*input_data_ptr == *prev_repetition && input_data_ptr[rep_length-1] == prev_repetition[rep_length-1]) - { - // Skip the current byte - prev_repetition++; - input_data_ptr++; - equal_byte_count = 2; - - // Now count how many more bytes are equal - while(equal_byte_count < MAX_REP_LENGTH) - { - prev_repetition++; - input_data_ptr++; - - // Are the bytes different ? - if(*prev_repetition != *input_data_ptr) - break; - - equal_byte_count++; - } - - // If we found a repetition of at least the same length, take it. - // If there are multiple repetitions in the input buffer, this will - // make sure that we find the most recent one, which in turn allows - // us to store backward length in less amount of bits - input_data_ptr = input_data; - if(equal_byte_count >= rep_length) - { - // Calculate the backward distance of the repetition. - // Note that the distance is stored as decremented by 1 - pWork->distance = (unsigned int)(input_data - prev_repetition + equal_byte_count - 1); - - // Repetitions longer than 10 bytes will be stored in more bits, - // so they need a bit different handling - if((rep_length = equal_byte_count) > 10) - break; - } - } - - // Move forward in the table of PAIR_HASH repetitions. - // There might be a more recent occurence of the same repetition. - phash_offs_index++; - phash_offs++; - prev_repetition = pWork->work_buff + phash_offs[0]; - - // If the next repetition is beyond the minimum allowed repetition, we are done. - if(prev_repetition >= repetition_limit) - { - // A repetition must have at least 2 bytes, otherwise it's not worth it - return (rep_length >= 2) ? rep_length : 0; - } - } - - // If the repetition has max length of 0x204 bytes, we can't go any fuhrter - if(equal_byte_count == MAX_REP_LENGTH) - { - pWork->distance--; - return equal_byte_count; - } - - // Check for possibility of a repetition that occurs at more recent position - phash_offs = pWork->phash_offs + phash_offs_index; - if(pWork->work_buff + phash_offs[1] >= repetition_limit) - return rep_length; - - // - // The following part checks if there isn't a longer repetition at - // a latter offset, that would lead to better compression. - // - // Example of data that can trigger this optimization: - // - // "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEQQQQQQQQQQQQ" - // "XYZ" - // "EEEEEEEEEEEEEEEEQQQQQQQQQQQQ"; - // - // Description of data in this buffer - // [0x00] Single byte "E" - // [0x01] Single byte "E" - // [0x02] Repeat 0x1E bytes from [0x00] - // [0x20] Single byte "X" - // [0x21] Single byte "Y" - // [0x22] Single byte "Z" - // [0x23] 17 possible previous repetitions of length at least 0x10 bytes: - // - Repetition of 0x10 bytes from [0x00] "EEEEEEEEEEEEEEEE" - // - Repetition of 0x10 bytes from [0x01] "EEEEEEEEEEEEEEEE" - // - Repetition of 0x10 bytes from [0x02] "EEEEEEEEEEEEEEEE" - // ... - // - Repetition of 0x10 bytes from [0x0F] "EEEEEEEEEEEEEEEE" - // - Repetition of 0x1C bytes from [0x10] "EEEEEEEEEEEEEEEEQQQQQQQQQQQQ" - // The last repetition is the best one. - // - - pWork->offs09BC[0] = 0xFFFF; - pWork->offs09BC[1] = 0x0000; - di_val = 0; - - // Note: I failed to figure out what does the table "offs09BC" mean. - // If anyone has an idea, let me know to zezula_at_volny_dot_cz - for(offs_in_rep = 1; offs_in_rep < rep_length; ) - { - if(input_data[offs_in_rep] != input_data[di_val]) - { - di_val = pWork->offs09BC[di_val]; - if(di_val != 0xFFFF) - continue; - } - pWork->offs09BC[++offs_in_rep] = ++di_val; - } - - // - // Now go through all the repetitions from the first found one - // to the current input data, and check if any of them migh be - // a start of a greater sequence match. - // - - prev_repetition = pWork->work_buff + phash_offs[0]; - prev_rep_end = prev_repetition + rep_length; - rep_length2 = rep_length; - - for(;;) - { - rep_length2 = pWork->offs09BC[rep_length2]; - if(rep_length2 == 0xFFFF) - rep_length2 = 0; - - // Get the pointer to the previous repetition - phash_offs = pWork->phash_offs + phash_offs_index; - - // Skip those repetitions that don't reach the end - // of the first found repetition - do - { - phash_offs++; - phash_offs_index++; - prev_repetition = pWork->work_buff + *phash_offs; - if(prev_repetition >= repetition_limit) - return rep_length; - } - while(prev_repetition + rep_length2 < prev_rep_end); - - // Verify if the last but one byte from the repetition matches - // the last but one byte from the input data. - // If not, find a next repetition - pre_last_byte = input_data[rep_length - 2]; - if(pre_last_byte == prev_repetition[rep_length - 2]) - { - // If the new repetition reaches beyond the end - // of previously found repetition, reset the repetition length to zero. - if(prev_repetition + rep_length2 != prev_rep_end) - { - prev_rep_end = prev_repetition; - rep_length2 = 0; - } - } - else - { - phash_offs = pWork->phash_offs + phash_offs_index; - do - { - phash_offs++; - phash_offs_index++; - prev_repetition = pWork->work_buff + *phash_offs; - if(prev_repetition >= repetition_limit) - return rep_length; - } - while(prev_repetition[rep_length - 2] != pre_last_byte || prev_repetition[0] != input_data[0]); - - // Reset the length of the repetition to 2 bytes only - prev_rep_end = prev_repetition + 2; - rep_length2 = 2; - } - - // Find out how many more characters are equal to the first repetition. - while(*prev_rep_end == input_data[rep_length2]) - { - if(++rep_length2 >= 0x204) - break; - prev_rep_end++; - } - - // Is the newly found repetion at least as long as the previous one ? - if(rep_length2 >= rep_length) - { - // Calculate the distance of the new repetition - pWork->distance = (unsigned int)(input_data - prev_repetition - 1); - if((rep_length = rep_length2) == 0x204) - return rep_length; - - // Update the additional elements in the "offs09BC" table - // to reflect new rep length - while(offs_in_rep < rep_length2) - { - if(input_data[offs_in_rep] != input_data[di_val]) - { - di_val = pWork->offs09BC[di_val]; - if(di_val != 0xFFFF) - continue; - } - pWork->offs09BC[++offs_in_rep] = ++di_val; - } - } - } -} - -static void WriteCmpData(TCmpStruct * pWork) -{ - unsigned char * input_data_end; // Pointer to the end of the input data - unsigned char * input_data = pWork->work_buff + pWork->dsize_bytes + 0x204; - unsigned int input_data_ended = 0; // If 1, then all data from the input stream have been already loaded - unsigned int save_rep_length; // Saved length of current repetition - unsigned int save_distance = 0; // Saved distance of current repetition - unsigned int rep_length; // Length of the found repetition - unsigned int phase = 0; // - - // Store the compression type and dictionary size - pWork->out_buff[0] = (char)pWork->ctype; - pWork->out_buff[1] = (char)pWork->dsize_bits; - pWork->out_bytes = 2; - - // Reset output buffer to zero - memset(&pWork->out_buff[2], 0, sizeof(pWork->out_buff) - 2); - pWork->out_bits = 0; - - while(input_data_ended == 0) - { - unsigned int bytes_to_load = 0x1000; - int total_loaded = 0; - int bytes_loaded; - - // Load the bytes from the input stream, up to 0x1000 bytes - while(bytes_to_load != 0) - { - bytes_loaded = pWork->read_buf((char *)pWork->work_buff + pWork->dsize_bytes + 0x204 + total_loaded, - &bytes_to_load, - pWork->param); - if(bytes_loaded == 0) - { - if(total_loaded == 0 && phase == 0) - goto __Exit; - input_data_ended = 1; - break; - } - else - { - bytes_to_load -= bytes_loaded; - total_loaded += bytes_loaded; - } - } - - input_data_end = pWork->work_buff + pWork->dsize_bytes + total_loaded; - if(input_data_ended) - input_data_end += 0x204; - - // - // Warning: The end of the buffer passed to "SortBuffer" is actually 2 bytes beyond - // valid data. It is questionable if this is actually a bug or not, - // but it might cause the compressed data output to be dependent on random bytes - // that are in the buffer. - // To prevent that, the calling application must always zero the compression - // buffer before passing it to "implode" - // - - // Search the PAIR_HASHes of the loaded blocks. Also, include - // previously compressed data, if any. - switch(phase) - { - case 0: - SortBuffer(pWork, input_data, input_data_end + 1); - phase++; - if(pWork->dsize_bytes != 0x1000) - phase++; - break; - - case 1: - SortBuffer(pWork, input_data - pWork->dsize_bytes + 0x204, input_data_end + 1); - phase++; - break; - - default: - SortBuffer(pWork, input_data - pWork->dsize_bytes, input_data_end + 1); - break; - } - - // Perform the compression of the current block - while(input_data < input_data_end) - { - // Find if the current byte sequence wasn't there before. - rep_length = FindRep(pWork, input_data); - while(rep_length != 0) - { - // If we found repetition of 2 bytes, that is 0x100 or fuhrter back, - // don't bother. Storing the distance of 0x100 bytes would actually - // take more space than storing the 2 bytes as-is. - if(rep_length == 2 && pWork->distance >= 0x100) - break; - - // When we are at the end of the input data, we cannot allow - // the repetition to go past the end of the input data. - if(input_data_ended && input_data + rep_length > input_data_end) - { - // Shorten the repetition length so that it only covers valid data - rep_length = (unsigned long)(input_data_end - input_data); - if(rep_length < 2) - break; - - // If we got repetition of 2 bytes, that is 0x100 or more backward, don't bother - if(rep_length == 2 && pWork->distance >= 0x100) - break; - goto __FlushRepetition; - } - - if(rep_length >= 8 || input_data + 1 >= input_data_end) - goto __FlushRepetition; - - // Try to find better repetition 1 byte later. - // Example: "ARROCKFORT" "AROCKFORT" - // When "input_data" points to the second string, FindRep - // returns the occurence of "AR". But there is longer repetition "ROCKFORT", - // beginning 1 byte after. - save_rep_length = rep_length; - save_distance = pWork->distance; - rep_length = FindRep(pWork, input_data + 1); - - // Only use the new repetition if it's length is greater than the previous one - if(rep_length > save_rep_length) - { - // If the new repetition if only 1 byte better - // and the previous distance is less than 0x80 bytes, use the previous repetition - if(rep_length > save_rep_length + 1 || save_distance > 0x80) - { - // Flush one byte, so that input_data will point to the secondary repetition - OutputBits(pWork, pWork->nChBits[*input_data], pWork->nChCodes[*input_data]); - input_data++; - continue; - } - } - - // Revert to the previous repetition - rep_length = save_rep_length; - pWork->distance = save_distance; - - __FlushRepetition: - - OutputBits(pWork, pWork->nChBits[rep_length + 0xFE], pWork->nChCodes[rep_length + 0xFE]); - if(rep_length == 2) - { - OutputBits(pWork, pWork->dist_bits[pWork->distance >> 2], - pWork->dist_codes[pWork->distance >> 2]); - OutputBits(pWork, 2, pWork->distance & 3); - } - else - { - OutputBits(pWork, pWork->dist_bits[pWork->distance >> pWork->dsize_bits], - pWork->dist_codes[pWork->distance >> pWork->dsize_bits]); - OutputBits(pWork, pWork->dsize_bits, pWork->dsize_mask & pWork->distance); - } - - // Move the begin of the input data by the length of the repetition - input_data += rep_length; - goto _00402252; - } - - // If there was no previous repetition for the current position in the input data, - // just output the 9-bit literal for the one character - OutputBits(pWork, pWork->nChBits[*input_data], pWork->nChCodes[*input_data]); - input_data++; -_00402252:; - } - - if(input_data_ended == 0) - { - input_data -= 0x1000; - memmove(pWork->work_buff, pWork->work_buff + 0x1000, pWork->dsize_bytes + 0x204); - } - } - -__Exit: - - // Write the termination literal - OutputBits(pWork, pWork->nChBits[0x305], pWork->nChCodes[0x305]); - if(pWork->out_bits != 0) - pWork->out_bytes++; - pWork->write_buf(pWork->out_buff, &pWork->out_bytes, pWork->param); - return; -} - -//----------------------------------------------------------------------------- -// Main imploding function - -unsigned int PKEXPORT implode( - unsigned int (*read_buf)(char *buf, unsigned int *size, void *param), - void (*write_buf)(char *buf, unsigned int *size, void *param), - char *work_buf, - void *param, - unsigned int *type, - unsigned int *dsize) -{ - TCmpStruct * pWork = (TCmpStruct *)work_buf; - unsigned int nChCode; - unsigned int nCount; - unsigned int i; - int nCount2; - - // Fill the work buffer information - // Note: The caller must zero the "work_buff" before passing it to implode - pWork->read_buf = read_buf; - pWork->write_buf = write_buf; - pWork->dsize_bytes = *dsize; - pWork->ctype = *type; - pWork->param = param; - pWork->dsize_bits = 4; - pWork->dsize_mask = 0x0F; - - // Test dictionary size - switch(*dsize) - { - case CMP_IMPLODE_DICT_SIZE3: // 0x1000 bytes - pWork->dsize_bits++; - pWork->dsize_mask |= 0x20; - // No break here !!! - - case CMP_IMPLODE_DICT_SIZE2: // 0x800 bytes - pWork->dsize_bits++; - pWork->dsize_mask |= 0x10; - // No break here !!! - - case CMP_IMPLODE_DICT_SIZE1: // 0x400 - break; - - default: - return CMP_INVALID_DICTSIZE; - } - - // Test the compression type - switch(*type) - { - case CMP_BINARY: // We will compress data with binary compression type - for(nChCode = 0, nCount = 0; nCount < 0x100; nCount++) - { - pWork->nChBits[nCount] = 9; - pWork->nChCodes[nCount] = (unsigned short)nChCode; - nChCode = (nChCode & 0x0000FFFF) + 2; - } - break; - - - case CMP_ASCII: // We will compress data with ASCII compression type - for(nCount = 0; nCount < 0x100; nCount++) - { - pWork->nChBits[nCount] = (unsigned char )(ChBitsAsc[nCount] + 1); - pWork->nChCodes[nCount] = (unsigned short)(ChCodeAsc[nCount] * 2); - } - break; - - default: - return CMP_INVALID_MODE; - } - - for(i = 0; i < 0x10; i++) - { - if(1 << ExLenBits[i]) - { - for(nCount2 = 0; nCount2 < (1 << ExLenBits[i]); nCount2++) - { - pWork->nChBits[nCount] = (unsigned char)(ExLenBits[i] + LenBits[i] + 1); - pWork->nChCodes[nCount] = (unsigned short)((nCount2 << (LenBits[i] + 1)) | ((LenCode[i] & 0xFFFF00FF) * 2) | 1); - nCount++; - } - } - } - - // Copy the distance codes and distance bits and perform the compression - memcpy(&pWork->dist_codes, DistCode, sizeof(DistCode)); - memcpy(&pWork->dist_bits, DistBits, sizeof(DistBits)); - WriteCmpData(pWork); - return CMP_NO_ERROR; -} diff --git a/libs/storm-sys/StormLib/src/pklib/pklib.h b/libs/storm-sys/StormLib/src/pklib/pklib.h deleted file mode 100644 index 9eb2915..0000000 --- a/libs/storm-sys/StormLib/src/pklib/pklib.h +++ /dev/null @@ -1,146 +0,0 @@ -/*****************************************************************************/ -/* pklib.h Copyright (c) Ladislav Zezula 2003 */ -/*---------------------------------------------------------------------------*/ -/* Header file for PKWARE Data Compression Library */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 31.03.03 1.00 Lad The first version of pkware.h */ -/*****************************************************************************/ - -#ifndef __PKLIB_H__ -#define __PKLIB_H__ - -//----------------------------------------------------------------------------- -// Defines - -#define CMP_BINARY 0 // Binary compression -#define CMP_ASCII 1 // Ascii compression - -#define CMP_NO_ERROR 0 -#define CMP_INVALID_DICTSIZE 1 -#define CMP_INVALID_MODE 2 -#define CMP_BAD_DATA 3 -#define CMP_ABORT 4 - -#define CMP_IMPLODE_DICT_SIZE1 1024 // Dictionary size of 1024 -#define CMP_IMPLODE_DICT_SIZE2 2048 // Dictionary size of 2048 -#define CMP_IMPLODE_DICT_SIZE3 4096 // Dictionary size of 4096 - -//----------------------------------------------------------------------------- -// Define calling convention - -#ifndef PKEXPORT -#ifdef WIN32 -#define PKEXPORT __cdecl // Use for normal __cdecl calling -#else -#define PKEXPORT -#endif -#endif - -//----------------------------------------------------------------------------- -// Internal structures - -// Compression structure -typedef struct -{ - unsigned int distance; // 0000: Backward distance of the currently found repetition, decreased by 1 - unsigned int out_bytes; // 0004: # bytes available in out_buff - unsigned int out_bits; // 0008: # of bits available in the last out byte - unsigned int dsize_bits; // 000C: Number of bits needed for dictionary size. 4 = 0x400, 5 = 0x800, 6 = 0x1000 - unsigned int dsize_mask; // 0010: Bit mask for dictionary. 0x0F = 0x400, 0x1F = 0x800, 0x3F = 0x1000 - unsigned int ctype; // 0014: Compression type (CMP_ASCII or CMP_BINARY) - unsigned int dsize_bytes; // 0018: Dictionary size in bytes - unsigned char dist_bits[0x40]; // 001C: Distance bits - unsigned char dist_codes[0x40]; // 005C: Distance codes - unsigned char nChBits[0x306]; // 009C: Table of literal bit lengths to be put to the output stream - unsigned short nChCodes[0x306]; // 03A2: Table of literal codes to be put to the output stream - unsigned short offs09AE; // 09AE: - - void * param; // 09B0: User parameter - unsigned int (*read_buf)(char *buf, unsigned int *size, void *param); // 9B4 - void (*write_buf)(char *buf, unsigned int *size, void *param); // 9B8 - - unsigned short offs09BC[0x204]; // 09BC: - unsigned long offs0DC4; // 0DC4: - unsigned short phash_to_index[0x900]; // 0DC8: Array of indexes (one for each PAIR_HASH) to the "pair_hash_offsets" table - unsigned short phash_to_index_end; // 1FC8: End marker for "phash_to_index" table - char out_buff[0x802]; // 1FCA: Compressed data - unsigned char work_buff[0x2204]; // 27CC: Work buffer - // + DICT_OFFSET => Dictionary - // + UNCMP_OFFSET => Uncompressed data - unsigned short phash_offs[0x2204]; // 49D0: Table of offsets for each PAIR_HASH -} TCmpStruct; - -#define CMP_BUFFER_SIZE sizeof(TCmpStruct) // Size of compression structure. - // Defined as 36312 in pkware header file - - -// Decompression structure -typedef struct -{ - unsigned long offs0000; // 0000 - unsigned long ctype; // 0004: Compression type (CMP_BINARY or CMP_ASCII) - unsigned long outputPos; // 0008: Position in output buffer - unsigned long dsize_bits; // 000C: Dict size (4, 5, 6 for 0x400, 0x800, 0x1000) - unsigned long dsize_mask; // 0010: Dict size bitmask (0x0F, 0x1F, 0x3F for 0x400, 0x800, 0x1000) - unsigned long bit_buff; // 0014: 16-bit buffer for processing input data - unsigned long extra_bits; // 0018: Number of extra (above 8) bits in bit buffer - unsigned int in_pos; // 001C: Position in in_buff - unsigned long in_bytes; // 0020: Number of bytes in input buffer - void * param; // 0024: Custom parameter - unsigned int (*read_buf)(char *buf, unsigned int *size, void *param); // Pointer to function that reads data from the input stream - void (*write_buf)(char *buf, unsigned int *size, void *param);// Pointer to function that writes data to the output stream - - unsigned char out_buff[0x2204]; // 0030: Output circle buffer. - // 0x0000 - 0x0FFF: Previous uncompressed data, kept for repetitions - // 0x1000 - 0x1FFF: Currently decompressed data - // 0x2000 - 0x2203: Reserve space for the longest possible repetition - unsigned char in_buff[0x800]; // 2234: Buffer for data to be decompressed - unsigned char DistPosCodes[0x100]; // 2A34: Table of distance position codes - unsigned char LengthCodes[0x100]; // 2B34: Table of length codes - unsigned char offs2C34[0x100]; // 2C34: Buffer for - unsigned char offs2D34[0x100]; // 2D34: Buffer for - unsigned char offs2E34[0x80]; // 2EB4: Buffer for - unsigned char offs2EB4[0x100]; // 2EB4: Buffer for - unsigned char ChBitsAsc[0x100]; // 2FB4: Buffer for - unsigned char DistBits[0x40]; // 30B4: Numbers of bytes to skip copied block length - unsigned char LenBits[0x10]; // 30F4: Numbers of bits for skip copied block length - unsigned char ExLenBits[0x10]; // 3104: Number of valid bits for copied block - unsigned short LenBase[0x10]; // 3114: Buffer for -} TDcmpStruct; - -#define EXP_BUFFER_SIZE sizeof(TDcmpStruct) // Size of decompression structure - // Defined as 12596 in pkware headers - -//----------------------------------------------------------------------------- -// Public functions - -#ifdef __cplusplus - extern "C" { -#endif - -unsigned int PKEXPORT implode( - unsigned int (*read_buf)(char *buf, unsigned int *size, void *param), - void (*write_buf)(char *buf, unsigned int *size, void *param), - char *work_buf, - void *param, - unsigned int *type, - unsigned int *dsize); - - -unsigned int PKEXPORT explode( - unsigned int (*read_buf)(char *buf, unsigned int *size, void *param), - void (*write_buf)(char *buf, unsigned int *size, void *param), - char *work_buf, - void *param); - -// The original name "crc32" was changed to "crc32pk" due -// to compatibility with zlib -unsigned long PKEXPORT crc32_pklib(char *buffer, unsigned int *size, unsigned long *old_crc); - -#ifdef __cplusplus - } // End of 'extern "C"' declaration -#endif - -#endif // __PKLIB_H__ diff --git a/libs/storm-sys/StormLib/src/sparse/sparse.cpp b/libs/storm-sys/StormLib/src/sparse/sparse.cpp deleted file mode 100644 index 4fe0981..0000000 --- a/libs/storm-sys/StormLib/src/sparse/sparse.cpp +++ /dev/null @@ -1,282 +0,0 @@ -/*****************************************************************************/ -/* huffman.cpp Copyright (c) Ladislav Zezula 1998-2003 */ -/*---------------------------------------------------------------------------*/ -/* This module contains Huffmann (de)compression methods */ -/* */ -/* Authors : Ladislav Zezula (ladik.zezula.net) */ -/* ShadowFlare (BlakFlare@hotmail.com) */ -/* */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* xx.xx.xx 1.00 Lad The first version of dcmp.cpp */ -/* 03.05.03 1.00 Lad Added compression methods */ -/* 19.11.03 1.01 Dan Big endian handling */ -/* 08.12.03 2.01 Dan High-memory handling (> 0x80000000) */ -/*****************************************************************************/ - -#include -#include - -#include "sparse.h" - -//----------------------------------------------------------------------------- -// Public functions - -void CompressSparse(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) -{ - unsigned char * pbOutBufferEnd = (unsigned char *)pvOutBuffer + *pcbOutBuffer; - unsigned char * pbInBufferEnd = (unsigned char *)pvInBuffer + cbInBuffer; - unsigned char * pbLastNonZero = (unsigned char *)pvInBuffer; - unsigned char * pbOutBuffer0 = (unsigned char *)pvOutBuffer; - unsigned char * pbInBuffPtr = (unsigned char *)pvInBuffer; - unsigned char * pbOutBuffer = (unsigned char *)pvOutBuffer; - unsigned char * pbInBuffer = (unsigned char *)pvInBuffer; - size_t NumberOfNonZeros; - size_t NumberOfZeros; - - // There must be at least 4 bytes of free space in the output buffer now - if((pbInBuffer + 4) >= pbInBufferEnd) - return; - - // Put the original data length (in little endian) - *pbOutBuffer++ = (unsigned char)(cbInBuffer >> 0x18); - *pbOutBuffer++ = (unsigned char)(cbInBuffer >> 0x10); - *pbOutBuffer++ = (unsigned char)(cbInBuffer >> 0x08); - *pbOutBuffer++ = (unsigned char)(cbInBuffer >> 0x00); - - // If there is at least 3 bytes in the input buffer, do this loop - while(pbInBuffer < (pbInBufferEnd - 3)) - { - // Reset the zero count and frontal pointer - pbLastNonZero = pbInBuffer; - pbInBuffPtr = pbInBuffer; - NumberOfZeros = 0; - - if(pbInBuffPtr < pbInBufferEnd) - { - do - { - // Count number of zeros - if(*pbInBuffPtr == 0) - { - NumberOfZeros++; - } - else - { - // Were there at least 3 zeros before? If yes, we need to flush the data - if(NumberOfZeros >= 3) - break; - pbLastNonZero = pbInBuffPtr + 1; - NumberOfZeros = 0; - } - } - while(++pbInBuffPtr < pbInBufferEnd); - } - - // Get number of nonzeros that we found so far and flush them - NumberOfNonZeros = pbLastNonZero - pbInBuffer; - if(NumberOfNonZeros != 0) - { - // Process blocks that are longer than 0x81 nonzero bytes - while(NumberOfNonZeros > 0x81) - { - // Verify if we still have enough space in output buffer - if((pbOutBuffer + 0x81) >= pbOutBufferEnd) - return; - - // Put marker that means "0x80 of nonzeros" - *pbOutBuffer++ = 0xFF; - memcpy(pbOutBuffer, pbInBuffer, 0x80); - - // Adjust counter of nonzeros and both pointers - NumberOfNonZeros -= 0x80; - pbOutBuffer += 0x80; - pbInBuffer += 0x80; - } - - // BUGBUG: The following code will be triggered if the NumberOfNonZeros - // was 0x81 before. It will copy just one byte. This seems like a bug to me, - // but since I want StormLib to be exact like Blizzard code is, I will keep - // it that way here - if(NumberOfNonZeros > 0x80) - { - // Verify if we still have enough space in output buffer - if((pbOutBuffer + 2) >= pbOutBufferEnd) - return; - - // Put marker that means "1 nonzero byte" - *pbOutBuffer++ = 0x80; - memcpy(pbOutBuffer, pbInBuffer, 1); - - // Adjust counter of nonzeros and both pointers - NumberOfNonZeros--; - pbOutBuffer++; - pbInBuffer++; - } - - // If there is 1 nonzero or more, put the block - if(NumberOfNonZeros >= 0x01) - { - // Verify if we still have enough space in output buffer - if((pbOutBuffer + NumberOfNonZeros + 1) >= pbOutBufferEnd) - return; - - // Put marker that means "Several nonzero bytes" - *pbOutBuffer++ = (unsigned char)(0x80 | (NumberOfNonZeros - 1)); - memcpy(pbOutBuffer, pbInBuffer, NumberOfNonZeros); - - // Adjust pointers - pbOutBuffer += NumberOfNonZeros; - pbInBuffer += NumberOfNonZeros; - } - } - - // Now flush all zero bytes - while(NumberOfZeros > 0x85) - { - // Do we have at least 2 bytes in the output buffer ? - if((pbOutBuffer + 1) >= pbOutBufferEnd) - return; - - // Put marker that means "0x82 zeros" - *pbOutBuffer++ = 0x7F; - - // Adjust zero counter and input pointer - NumberOfZeros -= 0x82; - pbInBuffer += 0x82; - } - - // If we got more than 0x82 zeros, flush 3 of them now - if(NumberOfZeros > 0x82) - { - // Do we have at least 2 bytes in the output buffer ? - if((pbOutBuffer + 1) >= pbOutBufferEnd) - return; - - // Put marker that means "0x03 zeros" - *pbOutBuffer++ = 0; - - // Adjust zero counter and input pointer - NumberOfZeros -= 0x03; - pbInBuffer += 0x03; - } - - // Is there at least three zeros ? - if(NumberOfZeros >= 3) - { - // Do we have at least 2 bytes in the output buffer ? - if((pbOutBuffer + 1) >= pbOutBufferEnd) - return; - - // Put marker that means "Several zeros" - *pbOutBuffer++ = (unsigned char)(NumberOfZeros - 3); - - // Adjust pointer - pbInBuffer += NumberOfZeros; - } - } - - // Flush last three bytes - if(pbInBuffer < pbInBufferEnd) - { - pbInBuffPtr = pbInBuffer; - - for(;;) - { - if(*pbInBuffPtr++ != 0) - { - // Get number of bytes remaining - NumberOfNonZeros = (pbInBufferEnd - pbInBuffer); - - // Not enough space in the output buffer ==> exit - if((pbOutBuffer + NumberOfNonZeros + 1) >= pbOutBufferEnd) - return; - - // Terminate with a marker that means "0x80 of nonzeros" - *pbOutBuffer++ = 0xFF; - memcpy(pbOutBuffer, pbInBuffer, NumberOfNonZeros); - - // Adjust pointer - pbOutBuffer += NumberOfNonZeros; - break; - } - else - { - // Is there are more chars in the input buffer - if(pbInBuffPtr < pbInBufferEnd) - continue; - - // If the compression will not compress it by even 1 byte, do nothing - if((pbOutBuffer + 1) >= pbOutBufferEnd) - return; - - // Terminate with a chunk that means "0x82 of zeros" - *pbOutBuffer++ = 0x7F; - break; - } - } - } - - // Out the length of the output buffer - *pcbOutBuffer = (int)(pbOutBuffer - pbOutBuffer0); -} - -int DecompressSparse(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) -{ - unsigned char * pbInBufferEnd = (unsigned char *)pvInBuffer + cbInBuffer; - unsigned char * pbOutBuffer = (unsigned char *)pvOutBuffer; - unsigned char * pbInBuffer = (unsigned char *)pvInBuffer; - unsigned int cbChunkSize; - unsigned int cbOutBuffer = 0; - unsigned int OneByte; - - // Don't decompress anything that is shorter than 5 bytes - if(cbInBuffer < 5) - return 0; - - // Get the 32-bits from the input stream - OneByte = *pbInBuffer++; - cbOutBuffer |= (OneByte << 0x18); - OneByte = *pbInBuffer++; - cbOutBuffer |= (OneByte << 0x10); - OneByte = *pbInBuffer++; - cbOutBuffer |= (OneByte << 0x08); - OneByte = *pbInBuffer++; - cbOutBuffer |= (OneByte << 0x00); - - // Verify the size of the stream against the output buffer size - if(cbOutBuffer > (unsigned int)*pcbOutBuffer) - return 0; - - // Put the output size to the buffer - *pcbOutBuffer = cbOutBuffer; - - // Process the input buffer - while(pbInBuffer < pbInBufferEnd) - { - // Get (next) byte from the stream - OneByte = *pbInBuffer++; - - // If highest bit, it means that that normal data follow - if(OneByte & 0x80) - { - cbChunkSize = (OneByte & 0x7F) + 1; - cbChunkSize = (cbChunkSize < cbOutBuffer) ? cbChunkSize : cbOutBuffer; - memcpy(pbOutBuffer, pbInBuffer, cbChunkSize); - pbInBuffer += cbChunkSize; - } - else - { - cbChunkSize = (OneByte & 0x7F) + 3; - cbChunkSize = (cbChunkSize < cbOutBuffer) ? cbChunkSize : cbOutBuffer; - memset(pbOutBuffer, 0, cbChunkSize); - } - - // Increment output buffer pointer - pbOutBuffer += cbChunkSize; - cbOutBuffer -= cbChunkSize; - } - - return 1; -} diff --git a/libs/storm-sys/StormLib/src/sparse/sparse.h b/libs/storm-sys/StormLib/src/sparse/sparse.h deleted file mode 100644 index 12f62b5..0000000 --- a/libs/storm-sys/StormLib/src/sparse/sparse.h +++ /dev/null @@ -1,17 +0,0 @@ -/*****************************************************************************/ -/* sparse.h Copyright (c) Ladislav Zezula 2010 */ -/*---------------------------------------------------------------------------*/ -/* implementation of Sparse compression, used in Starcraft II */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 05.03.10 1.00 Lad The first version of sparse.h */ -/*****************************************************************************/ - -#ifndef __SPARSE_H__ -#define __SPARSE_H__ - -void CompressSparse(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer); -int DecompressSparse(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer); - -#endif // __SPARSE_H__ diff --git a/libs/storm-sys/StormLib/src/wrapper.h b/libs/storm-sys/StormLib/src/wrapper.h deleted file mode 100644 index 822842e..0000000 --- a/libs/storm-sys/StormLib/src/wrapper.h +++ /dev/null @@ -1 +0,0 @@ -#include "StormLib.h" \ No newline at end of file diff --git a/libs/storm-sys/StormLib/src/zlib/adler32.c b/libs/storm-sys/StormLib/src/zlib/adler32.c deleted file mode 100644 index 65ad6a5..0000000 --- a/libs/storm-sys/StormLib/src/zlib/adler32.c +++ /dev/null @@ -1,169 +0,0 @@ -/* adler32.c -- compute the Adler-32 checksum of a data stream - * Copyright (C) 1995-2007 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#include "zutil.h" - -#define local static - -local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2); - -#define BASE 65521UL /* largest prime smaller than 65536 */ -#define NMAX 5552 -/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ - -#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} -#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); -#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); -#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); -#define DO16(buf) DO8(buf,0); DO8(buf,8); - -/* use NO_DIVIDE if your processor does not do division in hardware */ -#ifdef NO_DIVIDE -# define MOD(a) \ - do { \ - if (a >= (BASE << 16)) a -= (BASE << 16); \ - if (a >= (BASE << 15)) a -= (BASE << 15); \ - if (a >= (BASE << 14)) a -= (BASE << 14); \ - if (a >= (BASE << 13)) a -= (BASE << 13); \ - if (a >= (BASE << 12)) a -= (BASE << 12); \ - if (a >= (BASE << 11)) a -= (BASE << 11); \ - if (a >= (BASE << 10)) a -= (BASE << 10); \ - if (a >= (BASE << 9)) a -= (BASE << 9); \ - if (a >= (BASE << 8)) a -= (BASE << 8); \ - if (a >= (BASE << 7)) a -= (BASE << 7); \ - if (a >= (BASE << 6)) a -= (BASE << 6); \ - if (a >= (BASE << 5)) a -= (BASE << 5); \ - if (a >= (BASE << 4)) a -= (BASE << 4); \ - if (a >= (BASE << 3)) a -= (BASE << 3); \ - if (a >= (BASE << 2)) a -= (BASE << 2); \ - if (a >= (BASE << 1)) a -= (BASE << 1); \ - if (a >= BASE) a -= BASE; \ - } while (0) -# define MOD4(a) \ - do { \ - if (a >= (BASE << 4)) a -= (BASE << 4); \ - if (a >= (BASE << 3)) a -= (BASE << 3); \ - if (a >= (BASE << 2)) a -= (BASE << 2); \ - if (a >= (BASE << 1)) a -= (BASE << 1); \ - if (a >= BASE) a -= BASE; \ - } while (0) -#else -# define MOD(a) a %= BASE -# define MOD4(a) a %= BASE -#endif - -/* ========================================================================= */ -uLong ZEXPORT adler32(adler, buf, len) - uLong adler; - const Bytef *buf; - uInt len; -{ - unsigned long sum2; - unsigned n; - - /* split Adler-32 into component sums */ - sum2 = (adler >> 16) & 0xffff; - adler &= 0xffff; - - /* in case user likes doing a byte at a time, keep it fast */ - if (len == 1) { - adler += buf[0]; - if (adler >= BASE) - adler -= BASE; - sum2 += adler; - if (sum2 >= BASE) - sum2 -= BASE; - return adler | (sum2 << 16); - } - - /* initial Adler-32 value (deferred check for len == 1 speed) */ - if (buf == Z_NULL) - return 1L; - - /* in case short lengths are provided, keep it somewhat fast */ - if (len < 16) { - while (len--) { - adler += *buf++; - sum2 += adler; - } - if (adler >= BASE) - adler -= BASE; - MOD4(sum2); /* only added so many BASE's */ - return adler | (sum2 << 16); - } - - /* do length NMAX blocks -- requires just one modulo operation */ - while (len >= NMAX) { - len -= NMAX; - n = NMAX / 16; /* NMAX is divisible by 16 */ - do { - DO16(buf); /* 16 sums unrolled */ - buf += 16; - } while (--n); - MOD(adler); - MOD(sum2); - } - - /* do remaining bytes (less than NMAX, still just one modulo) */ - if (len) { /* avoid modulos if none remaining */ - while (len >= 16) { - len -= 16; - DO16(buf); - buf += 16; - } - while (len--) { - adler += *buf++; - sum2 += adler; - } - MOD(adler); - MOD(sum2); - } - - /* return recombined sums */ - return adler | (sum2 << 16); -} - -/* ========================================================================= */ -local uLong adler32_combine_(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off64_t len2; -{ - unsigned long sum1; - unsigned long sum2; - unsigned rem; - - /* the derivation of this formula is left as an exercise for the reader */ - rem = (unsigned)(len2 % BASE); - sum1 = adler1 & 0xffff; - sum2 = rem * sum1; - MOD(sum2); - sum1 += (adler2 & 0xffff) + BASE - 1; - sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; - if (sum1 >= BASE) sum1 -= BASE; - if (sum1 >= BASE) sum1 -= BASE; - if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1); - if (sum2 >= BASE) sum2 -= BASE; - return sum1 | (sum2 << 16); -} - -/* ========================================================================= */ -uLong ZEXPORT adler32_combine(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off_t len2; -{ - return adler32_combine_(adler1, adler2, len2); -} - -uLong ZEXPORT adler32_combine64(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off64_t len2; -{ - return adler32_combine_(adler1, adler2, len2); -} diff --git a/libs/storm-sys/StormLib/src/zlib/compress.c b/libs/storm-sys/StormLib/src/zlib/compress.c deleted file mode 100644 index ea4dfbe..0000000 --- a/libs/storm-sys/StormLib/src/zlib/compress.c +++ /dev/null @@ -1,80 +0,0 @@ -/* compress.c -- compress a memory buffer - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#define ZLIB_INTERNAL -#include "zlib.h" - -/* =========================================================================== - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least 0.1% larger than sourceLen plus - 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ -int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; - int level; -{ - z_stream stream; - int err; - - stream.next_in = (Bytef*)source; - stream.avail_in = (uInt)sourceLen; -#ifdef MAXSEG_64K - /* Check for source > 64K on 16-bit machine: */ - if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; -#endif - stream.next_out = dest; - stream.avail_out = (uInt)*destLen; - if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; - - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - stream.opaque = (voidpf)0; - - err = deflateInit(&stream, level); - if (err != Z_OK) return err; - - err = deflate(&stream, Z_FINISH); - if (err != Z_STREAM_END) { - deflateEnd(&stream); - return err == Z_OK ? Z_BUF_ERROR : err; - } - *destLen = stream.total_out; - - err = deflateEnd(&stream); - return err; -} - -/* =========================================================================== - */ -int ZEXPORT compress (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ - return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); -} - -/* =========================================================================== - If the default memLevel or windowBits for deflateInit() is changed, then - this function needs to be updated. - */ -uLong ZEXPORT compressBound (sourceLen) - uLong sourceLen; -{ - return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + - (sourceLen >> 25) + 13; -} diff --git a/libs/storm-sys/StormLib/src/zlib/compress_zlib.c b/libs/storm-sys/StormLib/src/zlib/compress_zlib.c deleted file mode 100644 index 46e5061..0000000 --- a/libs/storm-sys/StormLib/src/zlib/compress_zlib.c +++ /dev/null @@ -1,5 +0,0 @@ -// Some compilers (e.g. Visual Studio 2012) don't like the name conflict between -// zlib\compress.c and bzip2\compress.c. This file is plain wrapper for compress.c -// in order to create obj file with a different name. - -#include "compress.c" diff --git a/libs/storm-sys/StormLib/src/zlib/crc32.c b/libs/storm-sys/StormLib/src/zlib/crc32.c deleted file mode 100644 index 91be372..0000000 --- a/libs/storm-sys/StormLib/src/zlib/crc32.c +++ /dev/null @@ -1,442 +0,0 @@ -/* crc32.c -- compute the CRC-32 of a data stream - * Copyright (C) 1995-2006, 2010 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - * - * Thanks to Rodney Brown for his contribution of faster - * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing - * tables for updating the shift register in one step with three exclusive-ors - * instead of four steps with four exclusive-ors. This results in about a - * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. - */ - -/* @(#) $Id$ */ - -/* - Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore - protection on the static variables used to control the first-use generation - of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should - first call get_crc_table() to initialize the tables before allowing more than - one thread to use crc32(). - */ - -#ifdef MAKECRCH -# include -# ifndef DYNAMIC_CRC_TABLE -# define DYNAMIC_CRC_TABLE -# endif /* !DYNAMIC_CRC_TABLE */ -#endif /* MAKECRCH */ - -#include "zutil.h" /* for STDC and FAR definitions */ - -#define local static - -/* Find a four-byte integer type for crc32_little() and crc32_big(). */ -#ifndef NOBYFOUR -# ifdef STDC /* need ANSI C limits.h to determine sizes */ -# include -# define BYFOUR -# if (UINT_MAX == 0xffffffffUL) - typedef unsigned int u4; -# else -# if (ULONG_MAX == 0xffffffffUL) - typedef unsigned long u4; -# else -# if (USHRT_MAX == 0xffffffffUL) - typedef unsigned short u4; -# else -# undef BYFOUR /* can't find a four-byte integer type! */ -# endif -# endif -# endif -# endif /* STDC */ -#endif /* !NOBYFOUR */ - -/* Definitions for doing the crc four data bytes at a time. */ -#ifdef BYFOUR -# define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \ - (((w)&0xff00)<<8)+(((w)&0xff)<<24)) - local unsigned long crc32_little OF((unsigned long, - const unsigned char FAR *, unsigned)); - local unsigned long crc32_big OF((unsigned long, - const unsigned char FAR *, unsigned)); -# define TBLS 8 -#else -# define TBLS 1 -#endif /* BYFOUR */ - -/* Local functions for crc concatenation */ -local unsigned long gf2_matrix_times OF((unsigned long *mat, - unsigned long vec)); -local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); -local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2); - - -#ifdef DYNAMIC_CRC_TABLE - -local volatile int crc_table_empty = 1; -local unsigned long FAR crc_table[TBLS][256]; -local void make_crc_table OF((void)); -#ifdef MAKECRCH - local void write_table OF((FILE *, const unsigned long FAR *)); -#endif /* MAKECRCH */ -/* - Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: - x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. - - Polynomials over GF(2) are represented in binary, one bit per coefficient, - with the lowest powers in the most significant bit. Then adding polynomials - is just exclusive-or, and multiplying a polynomial by x is a right shift by - one. If we call the above polynomial p, and represent a byte as the - polynomial q, also with the lowest power in the most significant bit (so the - byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, - where a mod b means the remainder after dividing a by b. - - This calculation is done using the shift-register method of multiplying and - taking the remainder. The register is initialized to zero, and for each - incoming bit, x^32 is added mod p to the register if the bit is a one (where - x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by - x (which is shifting right by one and adding x^32 mod p if the bit shifted - out is a one). We start with the highest power (least significant bit) of - q and repeat for all eight bits of q. - - The first table is simply the CRC of all possible eight bit values. This is - all the information needed to generate CRCs on data a byte at a time for all - combinations of CRC register values and incoming bytes. The remaining tables - allow for word-at-a-time CRC calculation for both big-endian and little- - endian machines, where a word is four bytes. -*/ -local void make_crc_table() -{ - unsigned long c; - int n, k; - unsigned long poly; /* polynomial exclusive-or pattern */ - /* terms of polynomial defining this crc (except x^32): */ - static volatile int first = 1; /* flag to limit concurrent making */ - static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; - - /* See if another task is already doing this (not thread-safe, but better - than nothing -- significantly reduces duration of vulnerability in - case the advice about DYNAMIC_CRC_TABLE is ignored) */ - if (first) { - first = 0; - - /* make exclusive-or pattern from polynomial (0xedb88320UL) */ - poly = 0UL; - for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++) - poly |= 1UL << (31 - p[n]); - - /* generate a crc for every 8-bit value */ - for (n = 0; n < 256; n++) { - c = (unsigned long)n; - for (k = 0; k < 8; k++) - c = c & 1 ? poly ^ (c >> 1) : c >> 1; - crc_table[0][n] = c; - } - -#ifdef BYFOUR - /* generate crc for each value followed by one, two, and three zeros, - and then the byte reversal of those as well as the first table */ - for (n = 0; n < 256; n++) { - c = crc_table[0][n]; - crc_table[4][n] = REV(c); - for (k = 1; k < 4; k++) { - c = crc_table[0][c & 0xff] ^ (c >> 8); - crc_table[k][n] = c; - crc_table[k + 4][n] = REV(c); - } - } -#endif /* BYFOUR */ - - crc_table_empty = 0; - } - else { /* not first */ - /* wait for the other guy to finish (not efficient, but rare) */ - while (crc_table_empty) - ; - } - -#ifdef MAKECRCH - /* write out CRC tables to crc32.h */ - { - FILE *out; - - out = fopen("crc32.h", "w"); - if (out == NULL) return; - fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); - fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); - fprintf(out, "local const unsigned long FAR "); - fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); - write_table(out, crc_table[0]); -# ifdef BYFOUR - fprintf(out, "#ifdef BYFOUR\n"); - for (k = 1; k < 8; k++) { - fprintf(out, " },\n {\n"); - write_table(out, crc_table[k]); - } - fprintf(out, "#endif\n"); -# endif /* BYFOUR */ - fprintf(out, " }\n};\n"); - fclose(out); - } -#endif /* MAKECRCH */ -} - -#ifdef MAKECRCH -local void write_table(out, table) - FILE *out; - const unsigned long FAR *table; -{ - int n; - - for (n = 0; n < 256; n++) - fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n], - n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); -} -#endif /* MAKECRCH */ - -#else /* !DYNAMIC_CRC_TABLE */ -/* ======================================================================== - * Tables of CRC-32s of all single-byte values, made by make_crc_table(). - */ -#include "crc32.h" -#endif /* DYNAMIC_CRC_TABLE */ - -/* ========================================================================= - * This function can be used by asm versions of crc32() - */ -const unsigned long FAR * ZEXPORT get_crc_table() -{ -#ifdef DYNAMIC_CRC_TABLE - if (crc_table_empty) - make_crc_table(); -#endif /* DYNAMIC_CRC_TABLE */ - return (const unsigned long FAR *)crc_table; -} - -/* ========================================================================= */ -#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8) -#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 - -/* ========================================================================= */ -unsigned long ZEXPORT crc32(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - uInt len; -{ - if (buf == Z_NULL) return 0UL; - -#ifdef DYNAMIC_CRC_TABLE - if (crc_table_empty) - make_crc_table(); -#endif /* DYNAMIC_CRC_TABLE */ - -#ifdef BYFOUR - if (sizeof(void *) == sizeof(ptrdiff_t)) { - u4 endian; - - endian = 1; - if (*((unsigned char *)(&endian))) - return crc32_little(crc, buf, len); - else - return crc32_big(crc, buf, len); - } -#endif /* BYFOUR */ - crc = crc ^ 0xffffffffUL; - while (len >= 8) { - DO8; - len -= 8; - } - if (len) do { - DO1; - } while (--len); - return crc ^ 0xffffffffUL; -} - -#ifdef BYFOUR - -/* ========================================================================= */ -#define DOLIT4 c ^= *buf4++; \ - c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \ - crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24] -#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4 - -/* ========================================================================= */ -local unsigned long crc32_little(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - unsigned len; -{ - register u4 c; - register const u4 FAR *buf4; - - c = (u4)crc; - c = ~c; - while (len && ((ptrdiff_t)buf & 3)) { - c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); - len--; - } - - buf4 = (const u4 FAR *)(const void FAR *)buf; - while (len >= 32) { - DOLIT32; - len -= 32; - } - while (len >= 4) { - DOLIT4; - len -= 4; - } - buf = (const unsigned char FAR *)buf4; - - if (len) do { - c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); - } while (--len); - c = ~c; - return (unsigned long)c; -} - -/* ========================================================================= */ -#define DOBIG4 c ^= *++buf4; \ - c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \ - crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24] -#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4 - -/* ========================================================================= */ -local unsigned long crc32_big(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - unsigned len; -{ - register u4 c; - register const u4 FAR *buf4; - - c = REV((u4)crc); - c = ~c; - while (len && ((ptrdiff_t)buf & 3)) { - c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); - len--; - } - - buf4 = (const u4 FAR *)(const void FAR *)buf; - buf4--; - while (len >= 32) { - DOBIG32; - len -= 32; - } - while (len >= 4) { - DOBIG4; - len -= 4; - } - buf4++; - buf = (const unsigned char FAR *)buf4; - - if (len) do { - c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); - } while (--len); - c = ~c; - return (unsigned long)(REV(c)); -} - -#endif /* BYFOUR */ - -#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */ - -/* ========================================================================= */ -local unsigned long gf2_matrix_times(mat, vec) - unsigned long *mat; - unsigned long vec; -{ - unsigned long sum; - - sum = 0; - while (vec) { - if (vec & 1) - sum ^= *mat; - vec >>= 1; - mat++; - } - return sum; -} - -/* ========================================================================= */ -local void gf2_matrix_square(square, mat) - unsigned long *square; - unsigned long *mat; -{ - int n; - - for (n = 0; n < GF2_DIM; n++) - square[n] = gf2_matrix_times(mat, mat[n]); -} - -/* ========================================================================= */ -local uLong crc32_combine_(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off64_t len2; -{ - int n; - unsigned long row; - unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */ - unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */ - - /* degenerate case (also disallow negative lengths) */ - if (len2 <= 0) - return crc1; - - /* put operator for one zero bit in odd */ - odd[0] = 0xedb88320UL; /* CRC-32 polynomial */ - row = 1; - for (n = 1; n < GF2_DIM; n++) { - odd[n] = row; - row <<= 1; - } - - /* put operator for two zero bits in even */ - gf2_matrix_square(even, odd); - - /* put operator for four zero bits in odd */ - gf2_matrix_square(odd, even); - - /* apply len2 zeros to crc1 (first square will put the operator for one - zero byte, eight zero bits, in even) */ - do { - /* apply zeros operator for this bit of len2 */ - gf2_matrix_square(even, odd); - if (len2 & 1) - crc1 = gf2_matrix_times(even, crc1); - len2 >>= 1; - - /* if no more bits set, then done */ - if (len2 == 0) - break; - - /* another iteration of the loop with odd and even swapped */ - gf2_matrix_square(odd, even); - if (len2 & 1) - crc1 = gf2_matrix_times(odd, crc1); - len2 >>= 1; - - /* if no more bits set, then done */ - } while (len2 != 0); - - /* return combined crc */ - crc1 ^= crc2; - return crc1; -} - -/* ========================================================================= */ -uLong ZEXPORT crc32_combine(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off_t len2; -{ - return crc32_combine_(crc1, crc2, len2); -} - -uLong ZEXPORT crc32_combine64(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off64_t len2; -{ - return crc32_combine_(crc1, crc2, len2); -} diff --git a/libs/storm-sys/StormLib/src/zlib/crc32.h b/libs/storm-sys/StormLib/src/zlib/crc32.h deleted file mode 100644 index 8053b61..0000000 --- a/libs/storm-sys/StormLib/src/zlib/crc32.h +++ /dev/null @@ -1,441 +0,0 @@ -/* crc32.h -- tables for rapid CRC calculation - * Generated automatically by crc32.c - */ - -local const unsigned long FAR crc_table[TBLS][256] = -{ - { - 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, - 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, - 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, - 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL, - 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL, - 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL, - 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL, - 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL, - 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL, - 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL, - 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL, - 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL, - 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL, - 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL, - 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL, - 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL, - 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL, - 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL, - 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL, - 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL, - 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL, - 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL, - 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL, - 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL, - 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL, - 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL, - 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL, - 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL, - 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL, - 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL, - 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL, - 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL, - 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL, - 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL, - 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL, - 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL, - 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL, - 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL, - 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL, - 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL, - 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL, - 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL, - 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL, - 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL, - 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL, - 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL, - 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL, - 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL, - 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL, - 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, - 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, - 0x2d02ef8dUL -#ifdef BYFOUR - }, - { - 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL, - 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL, - 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL, - 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL, - 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL, - 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL, - 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL, - 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL, - 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL, - 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL, - 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL, - 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL, - 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL, - 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL, - 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL, - 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL, - 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL, - 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL, - 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL, - 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL, - 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL, - 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL, - 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL, - 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL, - 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL, - 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL, - 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL, - 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL, - 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL, - 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL, - 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL, - 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL, - 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL, - 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL, - 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL, - 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL, - 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL, - 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL, - 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL, - 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL, - 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL, - 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL, - 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL, - 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL, - 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL, - 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL, - 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL, - 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL, - 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL, - 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL, - 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL, - 0x9324fd72UL - }, - { - 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL, - 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL, - 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL, - 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL, - 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL, - 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL, - 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL, - 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL, - 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL, - 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL, - 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL, - 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL, - 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL, - 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL, - 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL, - 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL, - 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL, - 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL, - 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL, - 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL, - 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL, - 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL, - 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL, - 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL, - 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL, - 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL, - 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL, - 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL, - 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL, - 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL, - 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL, - 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL, - 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL, - 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL, - 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL, - 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL, - 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL, - 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL, - 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL, - 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL, - 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL, - 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL, - 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL, - 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL, - 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL, - 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL, - 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL, - 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL, - 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL, - 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL, - 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL, - 0xbe9834edUL - }, - { - 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL, - 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL, - 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL, - 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL, - 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL, - 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL, - 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL, - 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL, - 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL, - 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL, - 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL, - 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL, - 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL, - 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL, - 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL, - 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL, - 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL, - 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL, - 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL, - 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL, - 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL, - 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL, - 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL, - 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL, - 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL, - 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL, - 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL, - 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL, - 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL, - 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL, - 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL, - 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL, - 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL, - 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL, - 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL, - 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL, - 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL, - 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL, - 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL, - 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL, - 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL, - 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL, - 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL, - 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL, - 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL, - 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL, - 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL, - 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL, - 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL, - 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL, - 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL, - 0xde0506f1UL - }, - { - 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL, - 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL, - 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL, - 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL, - 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL, - 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL, - 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL, - 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL, - 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL, - 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL, - 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL, - 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL, - 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL, - 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL, - 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL, - 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL, - 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL, - 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL, - 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL, - 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL, - 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL, - 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL, - 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL, - 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL, - 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL, - 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL, - 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL, - 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL, - 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL, - 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL, - 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL, - 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL, - 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL, - 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL, - 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL, - 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL, - 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL, - 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL, - 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL, - 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL, - 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL, - 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL, - 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL, - 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL, - 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL, - 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL, - 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL, - 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL, - 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL, - 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL, - 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL, - 0x8def022dUL - }, - { - 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL, - 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL, - 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL, - 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL, - 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL, - 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL, - 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL, - 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL, - 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL, - 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL, - 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL, - 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL, - 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL, - 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL, - 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL, - 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL, - 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL, - 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL, - 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL, - 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL, - 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL, - 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL, - 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL, - 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL, - 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL, - 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL, - 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL, - 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL, - 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL, - 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL, - 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL, - 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL, - 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL, - 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL, - 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL, - 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL, - 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL, - 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL, - 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL, - 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL, - 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL, - 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL, - 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL, - 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL, - 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL, - 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL, - 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL, - 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL, - 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL, - 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL, - 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL, - 0x72fd2493UL - }, - { - 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL, - 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL, - 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL, - 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL, - 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL, - 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL, - 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL, - 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL, - 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL, - 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL, - 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL, - 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL, - 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL, - 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL, - 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL, - 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL, - 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL, - 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL, - 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL, - 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL, - 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL, - 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL, - 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL, - 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL, - 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL, - 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL, - 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL, - 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL, - 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL, - 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL, - 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL, - 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL, - 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL, - 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL, - 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL, - 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL, - 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL, - 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL, - 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL, - 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL, - 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL, - 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL, - 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL, - 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL, - 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL, - 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL, - 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL, - 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL, - 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL, - 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL, - 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL, - 0xed3498beUL - }, - { - 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL, - 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL, - 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL, - 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL, - 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL, - 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL, - 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL, - 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL, - 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL, - 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL, - 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL, - 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL, - 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL, - 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL, - 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL, - 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL, - 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL, - 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL, - 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL, - 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL, - 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL, - 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL, - 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL, - 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL, - 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL, - 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL, - 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL, - 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL, - 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL, - 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL, - 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL, - 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL, - 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL, - 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL, - 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL, - 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL, - 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL, - 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL, - 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL, - 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL, - 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL, - 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL, - 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL, - 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL, - 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL, - 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL, - 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL, - 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL, - 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL, - 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL, - 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL, - 0xf10605deUL -#endif - } -}; diff --git a/libs/storm-sys/StormLib/src/zlib/deflate.c b/libs/storm-sys/StormLib/src/zlib/deflate.c deleted file mode 100644 index 5c4022f..0000000 --- a/libs/storm-sys/StormLib/src/zlib/deflate.c +++ /dev/null @@ -1,1834 +0,0 @@ -/* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * ALGORITHM - * - * The "deflation" process depends on being able to identify portions - * of the input text which are identical to earlier input (within a - * sliding window trailing behind the input currently being processed). - * - * The most straightforward technique turns out to be the fastest for - * most input files: try all possible matches and select the longest. - * The key feature of this algorithm is that insertions into the string - * dictionary are very simple and thus fast, and deletions are avoided - * completely. Insertions are performed at each input character, whereas - * string matches are performed only when the previous match ends. So it - * is preferable to spend more time in matches to allow very fast string - * insertions and avoid deletions. The matching algorithm for small - * strings is inspired from that of Rabin & Karp. A brute force approach - * is used to find longer strings when a small match has been found. - * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze - * (by Leonid Broukhis). - * A previous version of this file used a more sophisticated algorithm - * (by Fiala and Greene) which is guaranteed to run in linear amortized - * time, but has a larger average cost, uses more memory and is patented. - * However the F&G algorithm may be faster for some highly redundant - * files if the parameter max_chain_length (described below) is too large. - * - * ACKNOWLEDGEMENTS - * - * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and - * I found it in 'freeze' written by Leonid Broukhis. - * Thanks to many people for bug reports and testing. - * - * REFERENCES - * - * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". - * Available in http://www.ietf.org/rfc/rfc1951.txt - * - * A description of the Rabin and Karp algorithm is given in the book - * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. - * - * Fiala,E.R., and Greene,D.H. - * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595 - * - */ - -/* @(#) $Id$ */ - -#include "deflate.h" - -const char deflate_copyright[] = - " deflate 1.2.5 Copyright 1995-2010 Jean-loup Gailly and Mark Adler "; -/* - If you use the zlib library in a product, an acknowledgment is welcome - in the documentation of your product. If for some reason you cannot - include such an acknowledgment, I would appreciate that you keep this - copyright string in the executable of your product. - */ - -/* =========================================================================== - * Function prototypes. - */ -typedef enum { - need_more, /* block not completed, need more input or more output */ - block_done, /* block flush performed */ - finish_started, /* finish started, need only more output at next deflate */ - finish_done /* finish done, accept no more input or output */ -} block_state; - -typedef block_state (*compress_func) OF((deflate_state *s, int flush)); -/* Compression function. Returns the block state after the call. */ - -local void fill_window OF((deflate_state *s)); -local block_state deflate_stored OF((deflate_state *s, int flush)); -local block_state deflate_fast OF((deflate_state *s, int flush)); -#ifndef FASTEST -local block_state deflate_slow OF((deflate_state *s, int flush)); -#endif -local block_state deflate_rle OF((deflate_state *s, int flush)); -local block_state deflate_huff OF((deflate_state *s, int flush)); -local void lm_init OF((deflate_state *s)); -local void putShortMSB OF((deflate_state *s, uInt b)); -local void flush_pending OF((z_streamp strm)); -local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); -#ifdef ASMV - void match_init OF((void)); /* asm code initialization */ - uInt longest_match OF((deflate_state *s, IPos cur_match)); -#else -local uInt longest_match OF((deflate_state *s, IPos cur_match)); -#endif - -#ifdef DEBUG -local void check_match OF((deflate_state *s, IPos start, IPos match, - int length)); -#endif - -/* =========================================================================== - * Local data - */ - -#define NIL 0 -/* Tail of hash chains */ - -#ifndef TOO_FAR -# define TOO_FAR 4096 -#endif -/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */ - -/* Values for max_lazy_match, good_match and max_chain_length, depending on - * the desired pack level (0..9). The values given below have been tuned to - * exclude worst case performance for pathological files. Better values may be - * found for specific files. - */ -typedef struct config_s { - ush good_length; /* reduce lazy search above this match length */ - ush max_lazy; /* do not perform lazy search above this match length */ - ush nice_length; /* quit search above this match length */ - ush max_chain; - compress_func func; -} config; - -#ifdef FASTEST -local const config configuration_table[2] = { -/* good lazy nice chain */ -/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ -/* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */ -#else -local const config configuration_table[10] = { -/* good lazy nice chain */ -/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ -/* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */ -/* 2 */ {4, 5, 16, 8, deflate_fast}, -/* 3 */ {4, 6, 32, 32, deflate_fast}, - -/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */ -/* 5 */ {8, 16, 32, 32, deflate_slow}, -/* 6 */ {8, 16, 128, 128, deflate_slow}, -/* 7 */ {8, 32, 128, 256, deflate_slow}, -/* 8 */ {32, 128, 258, 1024, deflate_slow}, -/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */ -#endif - -/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 - * For deflate_fast() (levels <= 3) good is ignored and lazy has a different - * meaning. - */ - -#define EQUAL 0 -/* result of memcmp for equal strings */ - -#ifndef NO_DUMMY_DECL -struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ -#endif - -/* =========================================================================== - * Update a hash value with the given input byte - * IN assertion: all calls to to UPDATE_HASH are made with consecutive - * input characters, so that a running hash key can be computed from the - * previous key instead of complete recalculation each time. - */ -#define UPDATE_HASH(s,h,c) (h = (((h)<hash_shift) ^ (c)) & s->hash_mask) - - -/* =========================================================================== - * Insert string str in the dictionary and set match_head to the previous head - * of the hash chain (the most recent string with same hash key). Return - * the previous length of the hash chain. - * If this file is compiled with -DFASTEST, the compression level is forced - * to 1, and no hash chains are maintained. - * IN assertion: all calls to to INSERT_STRING are made with consecutive - * input characters and the first MIN_MATCH bytes of str are valid - * (except for the last MIN_MATCH-1 bytes of the input file). - */ -#ifdef FASTEST -#define INSERT_STRING(s, str, match_head) \ - (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ - match_head = s->head[s->ins_h], \ - s->head[s->ins_h] = (Pos)(str)) -#else -#define INSERT_STRING(s, str, match_head) \ - (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ - match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \ - s->head[s->ins_h] = (Pos)(str)) -#endif - -/* =========================================================================== - * Initialize the hash table (avoiding 64K overflow for 16 bit systems). - * prev[] will be initialized on the fly. - */ -#define CLEAR_HASH(s) \ - s->head[s->hash_size-1] = NIL; \ - zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); - -/* ========================================================================= */ -int ZEXPORT deflateInit_(strm, level, version, stream_size) - z_streamp strm; - int level; - const char *version; - int stream_size; -{ - return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, - Z_DEFAULT_STRATEGY, version, stream_size); - /* To do: ignore strm->next_in if we use it as window */ -} - -/* ========================================================================= */ -int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, - version, stream_size) - z_streamp strm; - int level; - int method; - int windowBits; - int memLevel; - int strategy; - const char *version; - int stream_size; -{ - deflate_state *s; - int wrap = 1; - static const char my_version[] = ZLIB_VERSION; - - ushf *overlay; - /* We overlay pending_buf and d_buf+l_buf. This works since the average - * output size for (length,distance) codes is <= 24 bits. - */ - - if (version == Z_NULL || version[0] != my_version[0] || - stream_size != sizeof(z_stream)) { - return Z_VERSION_ERROR; - } - if (strm == Z_NULL) return Z_STREAM_ERROR; - - strm->msg = Z_NULL; - if (strm->zalloc == (alloc_func)0) { - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; - } - if (strm->zfree == (free_func)0) strm->zfree = zcfree; - -#ifdef FASTEST - if (level != 0) level = 1; -#else - if (level == Z_DEFAULT_COMPRESSION) level = 6; -#endif - - if (windowBits < 0) { /* suppress zlib wrapper */ - wrap = 0; - windowBits = -windowBits; - } -#ifdef GZIP - else if (windowBits > 15) { - wrap = 2; /* write gzip wrapper instead */ - windowBits -= 16; - } -#endif - if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || - windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || - strategy < 0 || strategy > Z_FIXED) { - return Z_STREAM_ERROR; - } - if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */ - s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); - if (s == Z_NULL) return Z_MEM_ERROR; - strm->state = (struct internal_state FAR *)s; - s->strm = strm; - - s->wrap = wrap; - s->gzhead = Z_NULL; - s->w_bits = windowBits; - s->w_size = 1 << s->w_bits; - s->w_mask = s->w_size - 1; - - s->hash_bits = memLevel + 7; - s->hash_size = 1 << s->hash_bits; - s->hash_mask = s->hash_size - 1; - s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); - - s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); - s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); - s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); - - s->high_water = 0; /* nothing written to s->window yet */ - - s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ - - overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); - s->pending_buf = (uchf *) overlay; - s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L); - - if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || - s->pending_buf == Z_NULL) { - s->status = FINISH_STATE; - strm->msg = (char*)ERR_MSG(Z_MEM_ERROR); - deflateEnd (strm); - return Z_MEM_ERROR; - } - s->d_buf = overlay + s->lit_bufsize/sizeof(ush); - s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; - - s->level = level; - s->strategy = strategy; - s->method = (Byte)method; - - return deflateReset(strm); -} - -/* ========================================================================= */ -int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) - z_streamp strm; - const Bytef *dictionary; - uInt dictLength; -{ - deflate_state *s; - uInt length = dictLength; - uInt n; - IPos hash_head = 0; - - if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL || - strm->state->wrap == 2 || - (strm->state->wrap == 1 && strm->state->status != INIT_STATE)) - return Z_STREAM_ERROR; - - s = strm->state; - if (s->wrap) - strm->adler = adler32(strm->adler, dictionary, dictLength); - - if (length < MIN_MATCH) return Z_OK; - if (length > s->w_size) { - length = s->w_size; - dictionary += dictLength - length; /* use the tail of the dictionary */ - } - zmemcpy(s->window, dictionary, length); - s->strstart = length; - s->block_start = (long)length; - - /* Insert all strings in the hash table (except for the last two bytes). - * s->lookahead stays null, so s->ins_h will be recomputed at the next - * call of fill_window. - */ - s->ins_h = s->window[0]; - UPDATE_HASH(s, s->ins_h, s->window[1]); - for (n = 0; n <= length - MIN_MATCH; n++) { - INSERT_STRING(s, n, hash_head); - } - if (hash_head) hash_head = 0; /* to make compiler happy */ - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateReset (strm) - z_streamp strm; -{ - deflate_state *s; - - if (strm == Z_NULL || strm->state == Z_NULL || - strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) { - return Z_STREAM_ERROR; - } - - strm->total_in = strm->total_out = 0; - strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */ - strm->data_type = Z_UNKNOWN; - - s = (deflate_state *)strm->state; - s->pending = 0; - s->pending_out = s->pending_buf; - - if (s->wrap < 0) { - s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */ - } - s->status = s->wrap ? INIT_STATE : BUSY_STATE; - strm->adler = -#ifdef GZIP - s->wrap == 2 ? crc32(0L, Z_NULL, 0) : -#endif - adler32(0L, Z_NULL, 0); - s->last_flush = Z_NO_FLUSH; - - _tr_init(s); - lm_init(s); - - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateSetHeader (strm, head) - z_streamp strm; - gz_headerp head; -{ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - if (strm->state->wrap != 2) return Z_STREAM_ERROR; - strm->state->gzhead = head; - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflatePrime (strm, bits, value) - z_streamp strm; - int bits; - int value; -{ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - strm->state->bi_valid = bits; - strm->state->bi_buf = (ush)(value & ((1 << bits) - 1)); - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateParams(strm, level, strategy) - z_streamp strm; - int level; - int strategy; -{ - deflate_state *s; - compress_func func; - int err = Z_OK; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - s = strm->state; - -#ifdef FASTEST - if (level != 0) level = 1; -#else - if (level == Z_DEFAULT_COMPRESSION) level = 6; -#endif - if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) { - return Z_STREAM_ERROR; - } - func = configuration_table[s->level].func; - - if ((strategy != s->strategy || func != configuration_table[level].func) && - strm->total_in != 0) { - /* Flush the last buffer: */ - err = deflate(strm, Z_BLOCK); - } - if (s->level != level) { - s->level = level; - s->max_lazy_match = configuration_table[level].max_lazy; - s->good_match = configuration_table[level].good_length; - s->nice_match = configuration_table[level].nice_length; - s->max_chain_length = configuration_table[level].max_chain; - } - s->strategy = strategy; - return err; -} - -/* ========================================================================= */ -int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) - z_streamp strm; - int good_length; - int max_lazy; - int nice_length; - int max_chain; -{ - deflate_state *s; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - s = strm->state; - s->good_match = good_length; - s->max_lazy_match = max_lazy; - s->nice_match = nice_length; - s->max_chain_length = max_chain; - return Z_OK; -} - -/* ========================================================================= - * For the default windowBits of 15 and memLevel of 8, this function returns - * a close to exact, as well as small, upper bound on the compressed size. - * They are coded as constants here for a reason--if the #define's are - * changed, then this function needs to be changed as well. The return - * value for 15 and 8 only works for those exact settings. - * - * For any setting other than those defaults for windowBits and memLevel, - * the value returned is a conservative worst case for the maximum expansion - * resulting from using fixed blocks instead of stored blocks, which deflate - * can emit on compressed data for some combinations of the parameters. - * - * This function could be more sophisticated to provide closer upper bounds for - * every combination of windowBits and memLevel. But even the conservative - * upper bound of about 14% expansion does not seem onerous for output buffer - * allocation. - */ -uLong ZEXPORT deflateBound(strm, sourceLen) - z_streamp strm; - uLong sourceLen; -{ - deflate_state *s; - uLong complen, wraplen; - Bytef *str; - - /* conservative upper bound for compressed data */ - complen = sourceLen + - ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5; - - /* if can't get parameters, return conservative bound plus zlib wrapper */ - if (strm == Z_NULL || strm->state == Z_NULL) - return complen + 6; - - /* compute wrapper length */ - s = strm->state; - switch (s->wrap) { - case 0: /* raw deflate */ - wraplen = 0; - break; - case 1: /* zlib wrapper */ - wraplen = 6 + (s->strstart ? 4 : 0); - break; - case 2: /* gzip wrapper */ - wraplen = 18; - if (s->gzhead != Z_NULL) { /* user-supplied gzip header */ - if (s->gzhead->extra != Z_NULL) - wraplen += 2 + s->gzhead->extra_len; - str = s->gzhead->name; - if (str != Z_NULL) - do { - wraplen++; - } while (*str++); - str = s->gzhead->comment; - if (str != Z_NULL) - do { - wraplen++; - } while (*str++); - if (s->gzhead->hcrc) - wraplen += 2; - } - break; - default: /* for compiler happiness */ - wraplen = 6; - } - - /* if not default parameters, return conservative bound */ - if (s->w_bits != 15 || s->hash_bits != 8 + 7) - return complen + wraplen; - - /* default settings: return tight bound for that case */ - return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + - (sourceLen >> 25) + 13 - 6 + wraplen; -} - -/* ========================================================================= - * Put a short in the pending buffer. The 16-bit value is put in MSB order. - * IN assertion: the stream state is correct and there is enough room in - * pending_buf. - */ -local void putShortMSB (s, b) - deflate_state *s; - uInt b; -{ - put_byte(s, (Byte)(b >> 8)); - put_byte(s, (Byte)(b & 0xff)); -} - -/* ========================================================================= - * Flush as much pending output as possible. All deflate() output goes - * through this function so some applications may wish to modify it - * to avoid allocating a large strm->next_out buffer and copying into it. - * (See also read_buf()). - */ -local void flush_pending(strm) - z_streamp strm; -{ - unsigned len = strm->state->pending; - - if (len > strm->avail_out) len = strm->avail_out; - if (len == 0) return; - - zmemcpy(strm->next_out, strm->state->pending_out, len); - strm->next_out += len; - strm->state->pending_out += len; - strm->total_out += len; - strm->avail_out -= len; - strm->state->pending -= len; - if (strm->state->pending == 0) { - strm->state->pending_out = strm->state->pending_buf; - } -} - -/* ========================================================================= */ -int ZEXPORT deflate (strm, flush) - z_streamp strm; - int flush; -{ - int old_flush; /* value of flush param for previous deflate call */ - deflate_state *s; - - if (strm == Z_NULL || strm->state == Z_NULL || - flush > Z_BLOCK || flush < 0) { - return Z_STREAM_ERROR; - } - s = strm->state; - - if (strm->next_out == Z_NULL || - (strm->next_in == Z_NULL && strm->avail_in != 0) || - (s->status == FINISH_STATE && flush != Z_FINISH)) { - ERR_RETURN(strm, Z_STREAM_ERROR); - } - if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); - - s->strm = strm; /* just in case */ - old_flush = s->last_flush; - s->last_flush = flush; - - /* Write the header */ - if (s->status == INIT_STATE) { -#ifdef GZIP - if (s->wrap == 2) { - strm->adler = crc32(0L, Z_NULL, 0); - put_byte(s, 31); - put_byte(s, 139); - put_byte(s, 8); - if (s->gzhead == Z_NULL) { - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, s->level == 9 ? 2 : - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? - 4 : 0)); - put_byte(s, OS_CODE); - s->status = BUSY_STATE; - } - else { - put_byte(s, (s->gzhead->text ? 1 : 0) + - (s->gzhead->hcrc ? 2 : 0) + - (s->gzhead->extra == Z_NULL ? 0 : 4) + - (s->gzhead->name == Z_NULL ? 0 : 8) + - (s->gzhead->comment == Z_NULL ? 0 : 16) - ); - put_byte(s, (Byte)(s->gzhead->time & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff)); - put_byte(s, s->level == 9 ? 2 : - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? - 4 : 0)); - put_byte(s, s->gzhead->os & 0xff); - if (s->gzhead->extra != Z_NULL) { - put_byte(s, s->gzhead->extra_len & 0xff); - put_byte(s, (s->gzhead->extra_len >> 8) & 0xff); - } - if (s->gzhead->hcrc) - strm->adler = crc32(strm->adler, s->pending_buf, - s->pending); - s->gzindex = 0; - s->status = EXTRA_STATE; - } - } - else -#endif - { - uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; - uInt level_flags; - - if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) - level_flags = 0; - else if (s->level < 6) - level_flags = 1; - else if (s->level == 6) - level_flags = 2; - else - level_flags = 3; - header |= (level_flags << 6); - if (s->strstart != 0) header |= PRESET_DICT; - header += 31 - (header % 31); - - s->status = BUSY_STATE; - putShortMSB(s, header); - - /* Save the adler32 of the preset dictionary: */ - if (s->strstart != 0) { - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); - } - strm->adler = adler32(0L, Z_NULL, 0); - } - } -#ifdef GZIP - if (s->status == EXTRA_STATE) { - if (s->gzhead->extra != Z_NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ - - while (s->gzindex < (s->gzhead->extra_len & 0xffff)) { - if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) - break; - } - put_byte(s, s->gzhead->extra[s->gzindex]); - s->gzindex++; - } - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (s->gzindex == s->gzhead->extra_len) { - s->gzindex = 0; - s->status = NAME_STATE; - } - } - else - s->status = NAME_STATE; - } - if (s->status == NAME_STATE) { - if (s->gzhead->name != Z_NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ - int val; - - do { - if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) { - val = 1; - break; - } - } - val = s->gzhead->name[s->gzindex++]; - put_byte(s, val); - } while (val != 0); - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (val == 0) { - s->gzindex = 0; - s->status = COMMENT_STATE; - } - } - else - s->status = COMMENT_STATE; - } - if (s->status == COMMENT_STATE) { - if (s->gzhead->comment != Z_NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ - int val; - - do { - if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) { - val = 1; - break; - } - } - val = s->gzhead->comment[s->gzindex++]; - put_byte(s, val); - } while (val != 0); - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (val == 0) - s->status = HCRC_STATE; - } - else - s->status = HCRC_STATE; - } - if (s->status == HCRC_STATE) { - if (s->gzhead->hcrc) { - if (s->pending + 2 > s->pending_buf_size) - flush_pending(strm); - if (s->pending + 2 <= s->pending_buf_size) { - put_byte(s, (Byte)(strm->adler & 0xff)); - put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); - strm->adler = crc32(0L, Z_NULL, 0); - s->status = BUSY_STATE; - } - } - else - s->status = BUSY_STATE; - } -#endif - - /* Flush as much pending output as possible */ - if (s->pending != 0) { - flush_pending(strm); - if (strm->avail_out == 0) { - /* Since avail_out is 0, deflate will be called again with - * more output space, but possibly with both pending and - * avail_in equal to zero. There won't be anything to do, - * but this is not an error situation so make sure we - * return OK instead of BUF_ERROR at next call of deflate: - */ - s->last_flush = -1; - return Z_OK; - } - - /* Make sure there is something to do and avoid duplicate consecutive - * flushes. For repeated and useless calls with Z_FINISH, we keep - * returning Z_STREAM_END instead of Z_BUF_ERROR. - */ - } else if (strm->avail_in == 0 && flush <= old_flush && - flush != Z_FINISH) { - ERR_RETURN(strm, Z_BUF_ERROR); - } - - /* User must not provide more input after the first FINISH: */ - if (s->status == FINISH_STATE && strm->avail_in != 0) { - ERR_RETURN(strm, Z_BUF_ERROR); - } - - /* Start a new block or continue the current one. - */ - if (strm->avail_in != 0 || s->lookahead != 0 || - (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { - block_state bstate; - - bstate = s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : - (s->strategy == Z_RLE ? deflate_rle(s, flush) : - (*(configuration_table[s->level].func))(s, flush)); - - if (bstate == finish_started || bstate == finish_done) { - s->status = FINISH_STATE; - } - if (bstate == need_more || bstate == finish_started) { - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ - } - return Z_OK; - /* If flush != Z_NO_FLUSH && avail_out == 0, the next call - * of deflate should use the same flush parameter to make sure - * that the flush is complete. So we don't have to output an - * empty block here, this will be done at next call. This also - * ensures that for a very small output buffer, we emit at most - * one empty block. - */ - } - if (bstate == block_done) { - if (flush == Z_PARTIAL_FLUSH) { - _tr_align(s); - } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */ - _tr_stored_block(s, (char*)0, 0L, 0); - /* For a full flush, this empty block will be recognized - * as a special marker by inflate_sync(). - */ - if (flush == Z_FULL_FLUSH) { - CLEAR_HASH(s); /* forget history */ - if (s->lookahead == 0) { - s->strstart = 0; - s->block_start = 0L; - } - } - } - flush_pending(strm); - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ - return Z_OK; - } - } - } - Assert(strm->avail_out > 0, "bug2"); - - if (flush != Z_FINISH) return Z_OK; - if (s->wrap <= 0) return Z_STREAM_END; - - /* Write the trailer */ -#ifdef GZIP - if (s->wrap == 2) { - put_byte(s, (Byte)(strm->adler & 0xff)); - put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); - put_byte(s, (Byte)((strm->adler >> 16) & 0xff)); - put_byte(s, (Byte)((strm->adler >> 24) & 0xff)); - put_byte(s, (Byte)(strm->total_in & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 8) & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 16) & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 24) & 0xff)); - } - else -#endif - { - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); - } - flush_pending(strm); - /* If avail_out is zero, the application will call deflate again - * to flush the rest. - */ - if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */ - return s->pending != 0 ? Z_OK : Z_STREAM_END; -} - -/* ========================================================================= */ -int ZEXPORT deflateEnd (strm) - z_streamp strm; -{ - int status; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - - status = strm->state->status; - if (status != INIT_STATE && - status != EXTRA_STATE && - status != NAME_STATE && - status != COMMENT_STATE && - status != HCRC_STATE && - status != BUSY_STATE && - status != FINISH_STATE) { - return Z_STREAM_ERROR; - } - - /* Deallocate in reverse order of allocations: */ - TRY_FREE(strm, strm->state->pending_buf); - TRY_FREE(strm, strm->state->head); - TRY_FREE(strm, strm->state->prev); - TRY_FREE(strm, strm->state->window); - - ZFREE(strm, strm->state); - strm->state = Z_NULL; - - return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; -} - -/* ========================================================================= - * Copy the source state to the destination state. - * To simplify the source, this is not supported for 16-bit MSDOS (which - * doesn't have enough memory anyway to duplicate compression states). - */ -int ZEXPORT deflateCopy (dest, source) - z_streamp dest; - z_streamp source; -{ -#ifdef MAXSEG_64K - return Z_STREAM_ERROR; -#else - deflate_state *ds; - deflate_state *ss; - ushf *overlay; - - - if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { - return Z_STREAM_ERROR; - } - - ss = source->state; - - zmemcpy(dest, source, sizeof(z_stream)); - - ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); - if (ds == Z_NULL) return Z_MEM_ERROR; - dest->state = (struct internal_state FAR *) ds; - zmemcpy(ds, ss, sizeof(deflate_state)); - ds->strm = dest; - - ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); - ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); - ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); - overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2); - ds->pending_buf = (uchf *) overlay; - - if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || - ds->pending_buf == Z_NULL) { - deflateEnd (dest); - return Z_MEM_ERROR; - } - /* following zmemcpy do not work for 16-bit MSDOS */ - zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); - zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos)); - zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos)); - zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); - - ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); - ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush); - ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize; - - ds->l_desc.dyn_tree = ds->dyn_ltree; - ds->d_desc.dyn_tree = ds->dyn_dtree; - ds->bl_desc.dyn_tree = ds->bl_tree; - - return Z_OK; -#endif /* MAXSEG_64K */ -} - -/* =========================================================================== - * Read a new buffer from the current input stream, update the adler32 - * and total number of bytes read. All deflate() input goes through - * this function so some applications may wish to modify it to avoid - * allocating a large strm->next_in buffer and copying from it. - * (See also flush_pending()). - */ -local int read_buf(strm, buf, size) - z_streamp strm; - Bytef *buf; - unsigned size; -{ - unsigned len = strm->avail_in; - - if (len > size) len = size; - if (len == 0) return 0; - - strm->avail_in -= len; - - if (strm->state->wrap == 1) { - strm->adler = adler32(strm->adler, strm->next_in, len); - } -#ifdef GZIP - else if (strm->state->wrap == 2) { - strm->adler = crc32(strm->adler, strm->next_in, len); - } -#endif - zmemcpy(buf, strm->next_in, len); - strm->next_in += len; - strm->total_in += len; - - return (int)len; -} - -/* =========================================================================== - * Initialize the "longest match" routines for a new zlib stream - */ -local void lm_init (s) - deflate_state *s; -{ - s->window_size = (ulg)2L*s->w_size; - - CLEAR_HASH(s); - - /* Set the default configuration parameters: - */ - s->max_lazy_match = configuration_table[s->level].max_lazy; - s->good_match = configuration_table[s->level].good_length; - s->nice_match = configuration_table[s->level].nice_length; - s->max_chain_length = configuration_table[s->level].max_chain; - - s->strstart = 0; - s->block_start = 0L; - s->lookahead = 0; - s->match_length = s->prev_length = MIN_MATCH-1; - s->match_available = 0; - s->ins_h = 0; -#ifndef FASTEST -#ifdef ASMV - match_init(); /* initialize the asm code */ -#endif -#endif -} - -#ifndef FASTEST -/* =========================================================================== - * Set match_start to the longest match starting at the given string and - * return its length. Matches shorter or equal to prev_length are discarded, - * in which case the result is equal to prev_length and match_start is - * garbage. - * IN assertions: cur_match is the head of the hash chain for the current - * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 - * OUT assertion: the match length is not greater than s->lookahead. - */ -#ifndef ASMV -/* For 80x86 and 680x0, an optimized version will be provided in match.asm or - * match.S. The code will be functionally equivalent. - */ -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ - unsigned chain_length = s->max_chain_length;/* max hash chain length */ - register Bytef *scan = s->window + s->strstart; /* current string */ - register Bytef *match; /* matched string */ - register int len; /* length of current match */ - int best_len = s->prev_length; /* best match length so far */ - int nice_match = s->nice_match; /* stop if match long enough */ - IPos limit = s->strstart > (IPos)MAX_DIST(s) ? - s->strstart - (IPos)MAX_DIST(s) : NIL; - /* Stop when cur_match becomes <= limit. To simplify the code, - * we prevent matches with the string of window index 0. - */ - Posf *prev = s->prev; - uInt wmask = s->w_mask; - -#ifdef UNALIGNED_OK - /* Compare two bytes at a time. Note: this is not always beneficial. - * Try with and without -DUNALIGNED_OK to check. - */ - register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; - register ush scan_start = *(ushf*)scan; - register ush scan_end = *(ushf*)(scan+best_len-1); -#else - register Bytef *strend = s->window + s->strstart + MAX_MATCH; - register Byte scan_end1 = scan[best_len-1]; - register Byte scan_end = scan[best_len]; -#endif - - /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. - * It is easy to get rid of this optimization if necessary. - */ - Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); - - /* Do not waste too much time if we already have a good match: */ - if (s->prev_length >= s->good_match) { - chain_length >>= 2; - } - /* Do not look for matches beyond the end of the input. This is necessary - * to make deflate deterministic. - */ - if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; - - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); - - do { - Assert(cur_match < s->strstart, "no future"); - match = s->window + cur_match; - - /* Skip to next match if the match length cannot increase - * or if the match length is less than 2. Note that the checks below - * for insufficient lookahead only occur occasionally for performance - * reasons. Therefore uninitialized memory will be accessed, and - * conditional jumps will be made that depend on those values. - * However the length of the match is limited to the lookahead, so - * the output of deflate is not affected by the uninitialized values. - */ -#if (defined(UNALIGNED_OK) && MAX_MATCH == 258) - /* This code assumes sizeof(unsigned short) == 2. Do not use - * UNALIGNED_OK if your compiler uses a different size. - */ - if (*(ushf*)(match+best_len-1) != scan_end || - *(ushf*)match != scan_start) continue; - - /* It is not necessary to compare scan[2] and match[2] since they are - * always equal when the other bytes match, given that the hash keys - * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at - * strstart+3, +5, ... up to strstart+257. We check for insufficient - * lookahead only every 4th comparison; the 128th check will be made - * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is - * necessary to put more guard bytes at the end of the window, or - * to check more often for insufficient lookahead. - */ - Assert(scan[2] == match[2], "scan[2]?"); - scan++, match++; - do { - } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - scan < strend); - /* The funny "do {}" generates better code on most compilers */ - - /* Here, scan <= window+strstart+257 */ - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - if (*scan == *match) scan++; - - len = (MAX_MATCH - 1) - (int)(strend-scan); - scan = strend - (MAX_MATCH-1); - -#else /* UNALIGNED_OK */ - - if (match[best_len] != scan_end || - match[best_len-1] != scan_end1 || - *match != *scan || - *++match != scan[1]) continue; - - /* The check at best_len-1 can be removed because it will be made - * again later. (This heuristic is not always a win.) - * It is not necessary to compare scan[2] and match[2] since they - * are always equal when the other bytes match, given that - * the hash keys are equal and that HASH_BITS >= 8. - */ - scan += 2, match++; - Assert(*scan == *match, "match[2]?"); - - /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. - */ - do { - } while (*++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - scan < strend); - - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - - len = MAX_MATCH - (int)(strend - scan); - scan = strend - MAX_MATCH; - -#endif /* UNALIGNED_OK */ - - if (len > best_len) { - s->match_start = cur_match; - best_len = len; - if (len >= nice_match) break; -#ifdef UNALIGNED_OK - scan_end = *(ushf*)(scan+best_len-1); -#else - scan_end1 = scan[best_len-1]; - scan_end = scan[best_len]; -#endif - } - } while ((cur_match = prev[cur_match & wmask]) > limit - && --chain_length != 0); - - if ((uInt)best_len <= s->lookahead) return (uInt)best_len; - return s->lookahead; -} -#endif /* ASMV */ - -#else /* FASTEST */ - -/* --------------------------------------------------------------------------- - * Optimized version for FASTEST only - */ -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ - register Bytef *scan = s->window + s->strstart; /* current string */ - register Bytef *match; /* matched string */ - register int len; /* length of current match */ - register Bytef *strend = s->window + s->strstart + MAX_MATCH; - - /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. - * It is easy to get rid of this optimization if necessary. - */ - Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); - - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); - - Assert(cur_match < s->strstart, "no future"); - - match = s->window + cur_match; - - /* Return failure if the match length is less than 2: - */ - if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1; - - /* The check at best_len-1 can be removed because it will be made - * again later. (This heuristic is not always a win.) - * It is not necessary to compare scan[2] and match[2] since they - * are always equal when the other bytes match, given that - * the hash keys are equal and that HASH_BITS >= 8. - */ - scan += 2, match += 2; - Assert(*scan == *match, "match[2]?"); - - /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. - */ - do { - } while (*++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - scan < strend); - - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - - len = MAX_MATCH - (int)(strend - scan); - - if (len < MIN_MATCH) return MIN_MATCH - 1; - - s->match_start = cur_match; - return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead; -} - -#endif /* FASTEST */ - -#ifdef DEBUG -/* =========================================================================== - * Check that the match at match_start is indeed a match. - */ -local void check_match(s, start, match, length) - deflate_state *s; - IPos start, match; - int length; -{ - /* check that the match is indeed a match */ - if (zmemcmp(s->window + match, - s->window + start, length) != EQUAL) { - fprintf(stderr, " start %u, match %u, length %d\n", - start, match, length); - do { - fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); - } while (--length != 0); - z_error("invalid match"); - } - if (z_verbose > 1) { - fprintf(stderr,"\\[%d,%d]", start-match, length); - do { putc(s->window[start++], stderr); } while (--length != 0); - } -} -#else -# define check_match(s, start, match, length) -#endif /* DEBUG */ - -/* =========================================================================== - * Fill the window when the lookahead becomes insufficient. - * Updates strstart and lookahead. - * - * IN assertion: lookahead < MIN_LOOKAHEAD - * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD - * At least one byte has been read, or avail_in == 0; reads are - * performed for at least two bytes (required for the zip translate_eol - * option -- not supported here). - */ -local void fill_window(s) - deflate_state *s; -{ - register unsigned n, m; - register Posf *p; - unsigned more; /* Amount of free space at the end of the window. */ - uInt wsize = s->w_size; - - do { - more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); - - /* Deal with !@#$% 64K limit: */ - if (sizeof(int) <= 2) { - if (more == 0 && s->strstart == 0 && s->lookahead == 0) { - more = wsize; - - } else if (more == (unsigned)(-1)) { - /* Very unlikely, but possible on 16 bit machine if - * strstart == 0 && lookahead == 1 (input done a byte at time) - */ - more--; - } - } - - /* If the window is almost full and there is insufficient lookahead, - * move the upper half to the lower one to make room in the upper half. - */ - if (s->strstart >= wsize+MAX_DIST(s)) { - - zmemcpy(s->window, s->window+wsize, (unsigned)wsize); - s->match_start -= wsize; - s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ - s->block_start -= (long) wsize; - - /* Slide the hash table (could be avoided with 32 bit values - at the expense of memory usage). We slide even when level == 0 - to keep the hash table consistent if we switch back to level > 0 - later. (Using level 0 permanently is not an optimal usage of - zlib, so we don't care about this pathological case.) - */ - n = s->hash_size; - p = &s->head[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - } while (--n); - - n = wsize; -#ifndef FASTEST - p = &s->prev[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - /* If n is not on any hash chain, prev[n] is garbage but - * its value will never be used. - */ - } while (--n); -#endif - more += wsize; - } - if (s->strm->avail_in == 0) return; - - /* If there was no sliding: - * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && - * more == window_size - lookahead - strstart - * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) - * => more >= window_size - 2*WSIZE + 2 - * In the BIG_MEM or MMAP case (not yet supported), - * window_size == input_size + MIN_LOOKAHEAD && - * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. - * Otherwise, window_size == 2*WSIZE so more >= 2. - * If there was sliding, more >= WSIZE. So in all cases, more >= 2. - */ - Assert(more >= 2, "more < 2"); - - n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); - s->lookahead += n; - - /* Initialize the hash value now that we have some input: */ - if (s->lookahead >= MIN_MATCH) { - s->ins_h = s->window[s->strstart]; - UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); -#if MIN_MATCH != 3 - Call UPDATE_HASH() MIN_MATCH-3 more times -#endif - } - /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, - * but this is not important since only literal bytes will be emitted. - */ - - } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); - - /* If the WIN_INIT bytes after the end of the current data have never been - * written, then zero those bytes in order to avoid memory check reports of - * the use of uninitialized (or uninitialised as Julian writes) bytes by - * the longest match routines. Update the high water mark for the next - * time through here. WIN_INIT is set to MAX_MATCH since the longest match - * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. - */ - if (s->high_water < s->window_size) { - ulg curr = s->strstart + (ulg)(s->lookahead); - ulg init; - - if (s->high_water < curr) { - /* Previous high water mark below current data -- zero WIN_INIT - * bytes or up to end of window, whichever is less. - */ - init = s->window_size - curr; - if (init > WIN_INIT) - init = WIN_INIT; - zmemzero(s->window + curr, (unsigned)init); - s->high_water = curr + init; - } - else if (s->high_water < (ulg)curr + WIN_INIT) { - /* High water mark at or above current data, but below current data - * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up - * to end of window, whichever is less. - */ - init = (ulg)curr + WIN_INIT - s->high_water; - if (init > s->window_size - s->high_water) - init = s->window_size - s->high_water; - zmemzero(s->window + s->high_water, (unsigned)init); - s->high_water += init; - } - } -} - -/* =========================================================================== - * Flush the current block, with given end-of-file flag. - * IN assertion: strstart is set to the end of the current match. - */ -#define FLUSH_BLOCK_ONLY(s, last) { \ - _tr_flush_block(s, (s->block_start >= 0L ? \ - (charf *)&s->window[(unsigned)s->block_start] : \ - (charf *)Z_NULL), \ - (ulg)((long)s->strstart - s->block_start), \ - (last)); \ - s->block_start = s->strstart; \ - flush_pending(s->strm); \ - Tracev((stderr,"[FLUSH]")); \ -} - -/* Same but force premature exit if necessary. */ -#define FLUSH_BLOCK(s, last) { \ - FLUSH_BLOCK_ONLY(s, last); \ - if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \ -} - -/* =========================================================================== - * Copy without compression as much as possible from the input stream, return - * the current block state. - * This function does not insert new strings in the dictionary since - * uncompressible data is probably not useful. This function is used - * only for the level=0 compression option. - * NOTE: this function should be optimized to avoid extra copying from - * window to pending_buf. - */ -local block_state deflate_stored(s, flush) - deflate_state *s; - int flush; -{ - /* Stored blocks are limited to 0xffff bytes, pending_buf is limited - * to pending_buf_size, and each stored block has a 5 byte header: - */ - ulg max_block_size = 0xffff; - ulg max_start; - - if (max_block_size > s->pending_buf_size - 5) { - max_block_size = s->pending_buf_size - 5; - } - - /* Copy as much as possible from input to output: */ - for (;;) { - /* Fill the window as much as possible: */ - if (s->lookahead <= 1) { - - Assert(s->strstart < s->w_size+MAX_DIST(s) || - s->block_start >= (long)s->w_size, "slide too late"); - - fill_window(s); - if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more; - - if (s->lookahead == 0) break; /* flush the current block */ - } - Assert(s->block_start >= 0L, "block gone"); - - s->strstart += s->lookahead; - s->lookahead = 0; - - /* Emit a stored block if pending_buf will be full: */ - max_start = s->block_start + max_block_size; - if (s->strstart == 0 || (ulg)s->strstart >= max_start) { - /* strstart == 0 is possible when wraparound on 16-bit machine */ - s->lookahead = (uInt)(s->strstart - max_start); - s->strstart = (uInt)max_start; - FLUSH_BLOCK(s, 0); - } - /* Flush if we may have to slide, otherwise block_start may become - * negative and the data will be gone: - */ - if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) { - FLUSH_BLOCK(s, 0); - } - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} - -/* =========================================================================== - * Compress as much as possible from the input stream, return the current - * block state. - * This function does not perform lazy evaluation of matches and inserts - * new strings in the dictionary only for unmatched strings or for short - * matches. It is used only for the fast compression options. - */ -local block_state deflate_fast(s, flush) - deflate_state *s; - int flush; -{ - IPos hash_head; /* head of the hash chain */ - int bflush; /* set if current block must be flushed */ - - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - if (s->lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - hash_head = NIL; - if (s->lookahead >= MIN_MATCH) { - INSERT_STRING(s, s->strstart, hash_head); - } - - /* Find the longest match, discarding those <= prev_length. - * At this point we have always match_length < MIN_MATCH - */ - if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ - s->match_length = longest_match (s, hash_head); - /* longest_match() sets match_start */ - } - if (s->match_length >= MIN_MATCH) { - check_match(s, s->strstart, s->match_start, s->match_length); - - _tr_tally_dist(s, s->strstart - s->match_start, - s->match_length - MIN_MATCH, bflush); - - s->lookahead -= s->match_length; - - /* Insert new strings in the hash table only if the match length - * is not too large. This saves time but degrades compression. - */ -#ifndef FASTEST - if (s->match_length <= s->max_insert_length && - s->lookahead >= MIN_MATCH) { - s->match_length--; /* string at strstart already in table */ - do { - s->strstart++; - INSERT_STRING(s, s->strstart, hash_head); - /* strstart never exceeds WSIZE-MAX_MATCH, so there are - * always MIN_MATCH bytes ahead. - */ - } while (--s->match_length != 0); - s->strstart++; - } else -#endif - { - s->strstart += s->match_length; - s->match_length = 0; - s->ins_h = s->window[s->strstart]; - UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); -#if MIN_MATCH != 3 - Call UPDATE_HASH() MIN_MATCH-3 more times -#endif - /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not - * matter since it will be recomputed at next deflate call. - */ - } - } else { - /* No match, output a literal byte */ - Tracevv((stderr,"%c", s->window[s->strstart])); - _tr_tally_lit (s, s->window[s->strstart], bflush); - s->lookahead--; - s->strstart++; - } - if (bflush) FLUSH_BLOCK(s, 0); - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} - -#ifndef FASTEST -/* =========================================================================== - * Same as above, but achieves better compression. We use a lazy - * evaluation for matches: a match is finally adopted only if there is - * no better match at the next window position. - */ -local block_state deflate_slow(s, flush) - deflate_state *s; - int flush; -{ - IPos hash_head; /* head of hash chain */ - int bflush; /* set if current block must be flushed */ - - /* Process the input block. */ - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - if (s->lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - hash_head = NIL; - if (s->lookahead >= MIN_MATCH) { - INSERT_STRING(s, s->strstart, hash_head); - } - - /* Find the longest match, discarding those <= prev_length. - */ - s->prev_length = s->match_length, s->prev_match = s->match_start; - s->match_length = MIN_MATCH-1; - - if (hash_head != NIL && s->prev_length < s->max_lazy_match && - s->strstart - hash_head <= MAX_DIST(s)) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ - s->match_length = longest_match (s, hash_head); - /* longest_match() sets match_start */ - - if (s->match_length <= 5 && (s->strategy == Z_FILTERED -#if TOO_FAR <= 32767 - || (s->match_length == MIN_MATCH && - s->strstart - s->match_start > TOO_FAR) -#endif - )) { - - /* If prev_match is also MIN_MATCH, match_start is garbage - * but we will ignore the current match anyway. - */ - s->match_length = MIN_MATCH-1; - } - } - /* If there was a match at the previous step and the current - * match is not better, output the previous match: - */ - if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) { - uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; - /* Do not insert strings in hash table beyond this. */ - - check_match(s, s->strstart-1, s->prev_match, s->prev_length); - - _tr_tally_dist(s, s->strstart -1 - s->prev_match, - s->prev_length - MIN_MATCH, bflush); - - /* Insert in hash table all strings up to the end of the match. - * strstart-1 and strstart are already inserted. If there is not - * enough lookahead, the last two strings are not inserted in - * the hash table. - */ - s->lookahead -= s->prev_length-1; - s->prev_length -= 2; - do { - if (++s->strstart <= max_insert) { - INSERT_STRING(s, s->strstart, hash_head); - } - } while (--s->prev_length != 0); - s->match_available = 0; - s->match_length = MIN_MATCH-1; - s->strstart++; - - if (bflush) FLUSH_BLOCK(s, 0); - - } else if (s->match_available) { - /* If there was no match at the previous position, output a - * single literal. If there was a match but the current match - * is longer, truncate the previous match to a single literal. - */ - Tracevv((stderr,"%c", s->window[s->strstart-1])); - _tr_tally_lit(s, s->window[s->strstart-1], bflush); - if (bflush) { - FLUSH_BLOCK_ONLY(s, 0); - } - s->strstart++; - s->lookahead--; - if (s->strm->avail_out == 0) return need_more; - } else { - /* There is no previous match to compare with, wait for - * the next step to decide. - */ - s->match_available = 1; - s->strstart++; - s->lookahead--; - } - } - Assert (flush != Z_NO_FLUSH, "no flush?"); - if (s->match_available) { - Tracevv((stderr,"%c", s->window[s->strstart-1])); - _tr_tally_lit(s, s->window[s->strstart-1], bflush); - s->match_available = 0; - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} -#endif /* FASTEST */ - -/* =========================================================================== - * For Z_RLE, simply look for runs of bytes, generate matches only of distance - * one. Do not maintain a hash table. (It will be regenerated if this run of - * deflate switches away from Z_RLE.) - */ -local block_state deflate_rle(s, flush) - deflate_state *s; - int flush; -{ - int bflush; /* set if current block must be flushed */ - uInt prev; /* byte at distance one to match */ - Bytef *scan, *strend; /* scan goes up to strend for length of run */ - - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the longest encodable run. - */ - if (s->lookahead < MAX_MATCH) { - fill_window(s); - if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* See how many times the previous byte repeats */ - s->match_length = 0; - if (s->lookahead >= MIN_MATCH && s->strstart > 0) { - scan = s->window + s->strstart - 1; - prev = *scan; - if (prev == *++scan && prev == *++scan && prev == *++scan) { - strend = s->window + s->strstart + MAX_MATCH; - do { - } while (prev == *++scan && prev == *++scan && - prev == *++scan && prev == *++scan && - prev == *++scan && prev == *++scan && - prev == *++scan && prev == *++scan && - scan < strend); - s->match_length = MAX_MATCH - (int)(strend - scan); - if (s->match_length > s->lookahead) - s->match_length = s->lookahead; - } - } - - /* Emit match if have run of MIN_MATCH or longer, else emit literal */ - if (s->match_length >= MIN_MATCH) { - check_match(s, s->strstart, s->strstart - 1, s->match_length); - - _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush); - - s->lookahead -= s->match_length; - s->strstart += s->match_length; - s->match_length = 0; - } else { - /* No match, output a literal byte */ - Tracevv((stderr,"%c", s->window[s->strstart])); - _tr_tally_lit (s, s->window[s->strstart], bflush); - s->lookahead--; - s->strstart++; - } - if (bflush) FLUSH_BLOCK(s, 0); - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} - -/* =========================================================================== - * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table. - * (It will be regenerated if this run of deflate switches away from Huffman.) - */ -local block_state deflate_huff(s, flush) - deflate_state *s; - int flush; -{ - int bflush; /* set if current block must be flushed */ - - for (;;) { - /* Make sure that we have a literal to write. */ - if (s->lookahead == 0) { - fill_window(s); - if (s->lookahead == 0) { - if (flush == Z_NO_FLUSH) - return need_more; - break; /* flush the current block */ - } - } - - /* Output a literal byte */ - s->match_length = 0; - Tracevv((stderr,"%c", s->window[s->strstart])); - _tr_tally_lit (s, s->window[s->strstart], bflush); - s->lookahead--; - s->strstart++; - if (bflush) FLUSH_BLOCK(s, 0); - } - FLUSH_BLOCK(s, flush == Z_FINISH); - return flush == Z_FINISH ? finish_done : block_done; -} diff --git a/libs/storm-sys/StormLib/src/zlib/deflate.h b/libs/storm-sys/StormLib/src/zlib/deflate.h deleted file mode 100644 index cbf0d1e..0000000 --- a/libs/storm-sys/StormLib/src/zlib/deflate.h +++ /dev/null @@ -1,342 +0,0 @@ -/* deflate.h -- internal compression state - * Copyright (C) 1995-2010 Jean-loup Gailly - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* @(#) $Id$ */ - -#ifndef DEFLATE_H -#define DEFLATE_H - -#include "zutil.h" - -/* define NO_GZIP when compiling if you want to disable gzip header and - trailer creation by deflate(). NO_GZIP would be used to avoid linking in - the crc code when it is not needed. For shared libraries, gzip encoding - should be left enabled. */ -#ifndef NO_GZIP -# define GZIP -#endif - -/* =========================================================================== - * Internal compression state. - */ - -#define LENGTH_CODES 29 -/* number of length codes, not counting the special END_BLOCK code */ - -#define LITERALS 256 -/* number of literal bytes 0..255 */ - -#define L_CODES (LITERALS+1+LENGTH_CODES) -/* number of Literal or Length codes, including the END_BLOCK code */ - -#define D_CODES 30 -/* number of distance codes */ - -#define BL_CODES 19 -/* number of codes used to transfer the bit lengths */ - -#define HEAP_SIZE (2*L_CODES+1) -/* maximum heap size */ - -#define MAX_BITS 15 -/* All codes must not exceed MAX_BITS bits */ - -#define INIT_STATE 42 -#define EXTRA_STATE 69 -#define NAME_STATE 73 -#define COMMENT_STATE 91 -#define HCRC_STATE 103 -#define BUSY_STATE 113 -#define FINISH_STATE 666 -/* Stream status */ - - -/* Data structure describing a single value and its code string. */ -typedef struct ct_data_s { - union { - ush freq; /* frequency count */ - ush code; /* bit string */ - } fc; - union { - ush dad; /* father node in Huffman tree */ - ush len; /* length of bit string */ - } dl; -} FAR ct_data; - -#define Freq fc.freq -#define Code fc.code -#define Dad dl.dad -#define Len dl.len - -typedef struct static_tree_desc_s static_tree_desc; - -typedef struct tree_desc_s { - ct_data *dyn_tree; /* the dynamic tree */ - int max_code; /* largest code with non zero frequency */ - static_tree_desc *stat_desc; /* the corresponding static tree */ -} FAR tree_desc; - -typedef ush Pos; -typedef Pos FAR Posf; -typedef unsigned IPos; - -/* A Pos is an index in the character window. We use short instead of int to - * save space in the various tables. IPos is used only for parameter passing. - */ - -typedef struct internal_state { - z_streamp strm; /* pointer back to this zlib stream */ - int status; /* as the name implies */ - Bytef *pending_buf; /* output still pending */ - ulg pending_buf_size; /* size of pending_buf */ - Bytef *pending_out; /* next pending byte to output to the stream */ - uInt pending; /* nb of bytes in the pending buffer */ - int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ - gz_headerp gzhead; /* gzip header information to write */ - uInt gzindex; /* where in extra, name, or comment */ - Byte method; /* STORED (for zip only) or DEFLATED */ - int last_flush; /* value of flush param for previous deflate call */ - - /* used by deflate.c: */ - - uInt w_size; /* LZ77 window size (32K by default) */ - uInt w_bits; /* log2(w_size) (8..16) */ - uInt w_mask; /* w_size - 1 */ - - Bytef *window; - /* Sliding window. Input bytes are read into the second half of the window, - * and move to the first half later to keep a dictionary of at least wSize - * bytes. With this organization, matches are limited to a distance of - * wSize-MAX_MATCH bytes, but this ensures that IO is always - * performed with a length multiple of the block size. Also, it limits - * the window size to 64K, which is quite useful on MSDOS. - * To do: use the user input buffer as sliding window. - */ - - ulg window_size; - /* Actual size of window: 2*wSize, except when the user input buffer - * is directly used as sliding window. - */ - - Posf *prev; - /* Link to older string with same hash index. To limit the size of this - * array to 64K, this link is maintained only for the last 32K strings. - * An index in this array is thus a window index modulo 32K. - */ - - Posf *head; /* Heads of the hash chains or NIL. */ - - uInt ins_h; /* hash index of string to be inserted */ - uInt hash_size; /* number of elements in hash table */ - uInt hash_bits; /* log2(hash_size) */ - uInt hash_mask; /* hash_size-1 */ - - uInt hash_shift; - /* Number of bits by which ins_h must be shifted at each input - * step. It must be such that after MIN_MATCH steps, the oldest - * byte no longer takes part in the hash key, that is: - * hash_shift * MIN_MATCH >= hash_bits - */ - - long block_start; - /* Window position at the beginning of the current output block. Gets - * negative when the window is moved backwards. - */ - - uInt match_length; /* length of best match */ - IPos prev_match; /* previous match */ - int match_available; /* set if previous match exists */ - uInt strstart; /* start of string to insert */ - uInt match_start; /* start of matching string */ - uInt lookahead; /* number of valid bytes ahead in window */ - - uInt prev_length; - /* Length of the best match at previous step. Matches not greater than this - * are discarded. This is used in the lazy match evaluation. - */ - - uInt max_chain_length; - /* To speed up deflation, hash chains are never searched beyond this - * length. A higher limit improves compression ratio but degrades the - * speed. - */ - - uInt max_lazy_match; - /* Attempt to find a better match only when the current match is strictly - * smaller than this value. This mechanism is used only for compression - * levels >= 4. - */ -# define max_insert_length max_lazy_match - /* Insert new strings in the hash table only if the match length is not - * greater than this length. This saves time but degrades compression. - * max_insert_length is used only for compression levels <= 3. - */ - - int level; /* compression level (1..9) */ - int strategy; /* favor or force Huffman coding*/ - - uInt good_match; - /* Use a faster search when the previous match is longer than this */ - - int nice_match; /* Stop searching when current match exceeds this */ - - /* used by trees.c: */ - /* Didn't use ct_data typedef below to supress compiler warning */ - struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ - struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ - struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ - - struct tree_desc_s l_desc; /* desc. for literal tree */ - struct tree_desc_s d_desc; /* desc. for distance tree */ - struct tree_desc_s bl_desc; /* desc. for bit length tree */ - - ush bl_count[MAX_BITS+1]; - /* number of codes at each bit length for an optimal tree */ - - int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ - int heap_len; /* number of elements in the heap */ - int heap_max; /* element of largest frequency */ - /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. - * The same heap array is used to build all trees. - */ - - uch depth[2*L_CODES+1]; - /* Depth of each subtree used as tie breaker for trees of equal frequency - */ - - uchf *l_buf; /* buffer for literals or lengths */ - - uInt lit_bufsize; - /* Size of match buffer for literals/lengths. There are 4 reasons for - * limiting lit_bufsize to 64K: - * - frequencies can be kept in 16 bit counters - * - if compression is not successful for the first block, all input - * data is still in the window so we can still emit a stored block even - * when input comes from standard input. (This can also be done for - * all blocks if lit_bufsize is not greater than 32K.) - * - if compression is not successful for a file smaller than 64K, we can - * even emit a stored file instead of a stored block (saving 5 bytes). - * This is applicable only for zip (not gzip or zlib). - * - creating new Huffman trees less frequently may not provide fast - * adaptation to changes in the input data statistics. (Take for - * example a binary file with poorly compressible code followed by - * a highly compressible string table.) Smaller buffer sizes give - * fast adaptation but have of course the overhead of transmitting - * trees more frequently. - * - I can't count above 4 - */ - - uInt last_lit; /* running index in l_buf */ - - ushf *d_buf; - /* Buffer for distances. To simplify the code, d_buf and l_buf have - * the same number of elements. To use different lengths, an extra flag - * array would be necessary. - */ - - ulg opt_len; /* bit length of current block with optimal trees */ - ulg static_len; /* bit length of current block with static trees */ - uInt matches; /* number of string matches in current block */ - int last_eob_len; /* bit length of EOB code for last block */ - -#ifdef DEBUG - ulg compressed_len; /* total bit length of compressed file mod 2^32 */ - ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ -#endif - - ush bi_buf; - /* Output buffer. bits are inserted starting at the bottom (least - * significant bits). - */ - int bi_valid; - /* Number of valid bits in bi_buf. All bits above the last valid bit - * are always zero. - */ - - ulg high_water; - /* High water mark offset in window for initialized bytes -- bytes above - * this are set to zero in order to avoid memory check warnings when - * longest match routines access bytes past the input. This is then - * updated to the new high water mark. - */ - -} FAR deflate_state; - -/* Output a byte on the stream. - * IN assertion: there is enough room in pending_buf. - */ -#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} - - -#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) -/* Minimum amount of lookahead, except at the end of the input file. - * See deflate.c for comments about the MIN_MATCH+1. - */ - -#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) -/* In order to simplify the code, particularly on 16 bit machines, match - * distances are limited to MAX_DIST instead of WSIZE. - */ - -#define WIN_INIT MAX_MATCH -/* Number of bytes after end of data in window to initialize in order to avoid - memory checker errors from longest match routines */ - - /* in trees.c */ -void ZLIB_INTERNAL _tr_init OF((deflate_state *s)); -int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); -void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, - ulg stored_len, int last)); -void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); -void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, - ulg stored_len, int last)); - -#define d_code(dist) \ - ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) -/* Mapping from a distance to a distance code. dist is the distance - 1 and - * must not have side effects. _dist_code[256] and _dist_code[257] are never - * used. - */ - -#ifndef DEBUG -/* Inline versions of _tr_tally for speed: */ - -#if defined(GEN_TREES_H) || !defined(STDC) - extern uch ZLIB_INTERNAL _length_code[]; - extern uch ZLIB_INTERNAL _dist_code[]; -#else - extern const uch ZLIB_INTERNAL _length_code[]; - extern const uch ZLIB_INTERNAL _dist_code[]; -#endif - -# define _tr_tally_lit(s, c, flush) \ - { uch cc = (c); \ - s->d_buf[s->last_lit] = 0; \ - s->l_buf[s->last_lit++] = cc; \ - s->dyn_ltree[cc].Freq++; \ - flush = (s->last_lit == s->lit_bufsize-1); \ - } -# define _tr_tally_dist(s, distance, length, flush) \ - { uch len = (length); \ - ush dist = (distance); \ - s->d_buf[s->last_lit] = dist; \ - s->l_buf[s->last_lit++] = len; \ - dist--; \ - s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ - s->dyn_dtree[d_code(dist)].Freq++; \ - flush = (s->last_lit == s->lit_bufsize-1); \ - } -#else -# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) -# define _tr_tally_dist(s, distance, length, flush) \ - flush = _tr_tally(s, distance, length) -#endif - -#endif /* DEFLATE_H */ diff --git a/libs/storm-sys/StormLib/src/zlib/inffast.c b/libs/storm-sys/StormLib/src/zlib/inffast.c deleted file mode 100644 index 2f1d60b..0000000 --- a/libs/storm-sys/StormLib/src/zlib/inffast.c +++ /dev/null @@ -1,340 +0,0 @@ -/* inffast.c -- fast decoding - * Copyright (C) 1995-2008, 2010 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -#ifndef ASMINF - -/* Allow machine dependent optimization for post-increment or pre-increment. - Based on testing to date, - Pre-increment preferred for: - - PowerPC G3 (Adler) - - MIPS R5000 (Randers-Pehrson) - Post-increment preferred for: - - none - No measurable difference: - - Pentium III (Anderson) - - M68060 (Nikl) - */ -#ifdef POSTINC -# define OFF 0 -# define PUP(a) *(a)++ -#else -# define OFF 1 -# define PUP(a) *++(a) -#endif - -/* - Decode literal, length, and distance codes and write out the resulting - literal and match bytes until either not enough input or output is - available, an end-of-block is encountered, or a data error is encountered. - When large enough input and output buffers are supplied to inflate(), for - example, a 16K input buffer and a 64K output buffer, more than 95% of the - inflate execution time is spent in this routine. - - Entry assumptions: - - state->mode == LEN - strm->avail_in >= 6 - strm->avail_out >= 258 - start >= strm->avail_out - state->bits < 8 - - On return, state->mode is one of: - - LEN -- ran out of enough output space or enough available input - TYPE -- reached end of block code, inflate() to interpret next block - BAD -- error in block data - - Notes: - - - The maximum input bits used by a length/distance pair is 15 bits for the - length code, 5 bits for the length extra, 15 bits for the distance code, - and 13 bits for the distance extra. This totals 48 bits, or six bytes. - Therefore if strm->avail_in >= 6, then there is enough input to avoid - checking for available input while decoding. - - - The maximum bytes that a single length/distance pair can output is 258 - bytes, which is the maximum length that can be coded. inflate_fast() - requires strm->avail_out >= 258 for each loop to avoid checking for - output space. - */ -void ZLIB_INTERNAL inflate_fast(strm, start) -z_streamp strm; -unsigned start; /* inflate()'s starting value for strm->avail_out */ -{ - struct inflate_state FAR *state; - unsigned char FAR *in; /* local strm->next_in */ - unsigned char FAR *last; /* while in < last, enough input available */ - unsigned char FAR *out; /* local strm->next_out */ - unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ - unsigned char FAR *end; /* while out < end, enough space available */ -#ifdef INFLATE_STRICT - unsigned dmax; /* maximum distance from zlib header */ -#endif - unsigned wsize; /* window size or zero if not using window */ - unsigned whave; /* valid bytes in the window */ - unsigned wnext; /* window write index */ - unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ - unsigned long hold; /* local strm->hold */ - unsigned bits; /* local strm->bits */ - code const FAR *lcode; /* local strm->lencode */ - code const FAR *dcode; /* local strm->distcode */ - unsigned lmask; /* mask for first level of length codes */ - unsigned dmask; /* mask for first level of distance codes */ - code here; /* retrieved table entry */ - unsigned op; /* code bits, operation, extra bits, or */ - /* window position, window bytes to copy */ - unsigned len; /* match length, unused bytes */ - unsigned dist; /* match distance */ - unsigned char FAR *from; /* where to copy match from */ - - /* copy state to local variables */ - state = (struct inflate_state FAR *)strm->state; - in = strm->next_in - OFF; - last = in + (strm->avail_in - 5); - out = strm->next_out - OFF; - beg = out - (start - strm->avail_out); - end = out + (strm->avail_out - 257); -#ifdef INFLATE_STRICT - dmax = state->dmax; -#endif - wsize = state->wsize; - whave = state->whave; - wnext = state->wnext; - window = state->window; - hold = state->hold; - bits = state->bits; - lcode = state->lencode; - dcode = state->distcode; - lmask = (1U << state->lenbits) - 1; - dmask = (1U << state->distbits) - 1; - - /* decode literals and length/distances until end-of-block or not enough - input data or output space */ - do { - if (bits < 15) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - here = lcode[hold & lmask]; - dolen: - op = (unsigned)(here.bits); - hold >>= op; - bits -= op; - op = (unsigned)(here.op); - if (op == 0) { /* literal */ - Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", here.val)); - PUP(out) = (unsigned char)(here.val); - } - else if (op & 16) { /* length base */ - len = (unsigned)(here.val); - op &= 15; /* number of extra bits */ - if (op) { - if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - len += (unsigned)hold & ((1U << op) - 1); - hold >>= op; - bits -= op; - } - Tracevv((stderr, "inflate: length %u\n", len)); - if (bits < 15) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - here = dcode[hold & dmask]; - dodist: - op = (unsigned)(here.bits); - hold >>= op; - bits -= op; - op = (unsigned)(here.op); - if (op & 16) { /* distance base */ - dist = (unsigned)(here.val); - op &= 15; /* number of extra bits */ - if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; - bits += 8; - } - } - dist += (unsigned)hold & ((1U << op) - 1); -#ifdef INFLATE_STRICT - if (dist > dmax) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#endif - hold >>= op; - bits -= op; - Tracevv((stderr, "inflate: distance %u\n", dist)); - op = (unsigned)(out - beg); /* max distance in output */ - if (dist > op) { /* see if copy from window */ - op = dist - op; /* distance back in window */ - if (op > whave) { - if (state->sane) { - strm->msg = - (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR - if (len <= op - whave) { - do { - PUP(out) = 0; - } while (--len); - continue; - } - len -= op - whave; - do { - PUP(out) = 0; - } while (--op > whave); - if (op == 0) { - from = out - dist; - do { - PUP(out) = PUP(from); - } while (--len); - continue; - } -#endif - } - from = window - OFF; - if (wnext == 0) { /* very common case */ - from += wsize - op; - if (op < len) { /* some from window */ - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = out - dist; /* rest from output */ - } - } - else if (wnext < op) { /* wrap around window */ - from += wsize + wnext - op; - op -= wnext; - if (op < len) { /* some from end of window */ - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = window - OFF; - if (wnext < len) { /* some from start of window */ - op = wnext; - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = out - dist; /* rest from output */ - } - } - } - else { /* contiguous in window */ - from += wnext - op; - if (op < len) { /* some from window */ - len -= op; - do { - PUP(out) = PUP(from); - } while (--op); - from = out - dist; /* rest from output */ - } - } - while (len > 2) { - PUP(out) = PUP(from); - PUP(out) = PUP(from); - PUP(out) = PUP(from); - len -= 3; - } - if (len) { - PUP(out) = PUP(from); - if (len > 1) - PUP(out) = PUP(from); - } - } - else { - from = out - dist; /* copy direct from output */ - do { /* minimum length is three */ - PUP(out) = PUP(from); - PUP(out) = PUP(from); - PUP(out) = PUP(from); - len -= 3; - } while (len > 2); - if (len) { - PUP(out) = PUP(from); - if (len > 1) - PUP(out) = PUP(from); - } - } - } - else if ((op & 64) == 0) { /* 2nd level distance code */ - here = dcode[here.val + (hold & ((1U << op) - 1))]; - goto dodist; - } - else { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - } - else if ((op & 64) == 0) { /* 2nd level length code */ - here = lcode[here.val + (hold & ((1U << op) - 1))]; - goto dolen; - } - else if (op & 32) { /* end-of-block */ - Tracevv((stderr, "inflate: end of block\n")); - state->mode = TYPE; - break; - } - else { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - } while (in < last && out < end); - - /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ - len = bits >> 3; - in -= len; - bits -= len << 3; - hold &= (1U << bits) - 1; - - /* update state and return */ - strm->next_in = in + OFF; - strm->next_out = out + OFF; - strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); - strm->avail_out = (unsigned)(out < end ? - 257 + (end - out) : 257 - (out - end)); - state->hold = hold; - state->bits = bits; - return; -} - -/* - inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe): - - Using bit fields for code structure - - Different op definition to avoid & for extra bits (do & for table bits) - - Three separate decoding do-loops for direct, window, and wnext == 0 - - Special case for distance > 1 copies to do overlapped load and store copy - - Explicit branch predictions (based on measured branch probabilities) - - Deferring match copy and interspersed it with decoding subsequent codes - - Swapping literal/length else - - Swapping window/direct else - - Larger unrolled copy loops (three is about right) - - Moving len -= 3 statement into middle of loop - */ - -#endif /* !ASMINF */ diff --git a/libs/storm-sys/StormLib/src/zlib/inffast.h b/libs/storm-sys/StormLib/src/zlib/inffast.h deleted file mode 100644 index e5c1aa4..0000000 --- a/libs/storm-sys/StormLib/src/zlib/inffast.h +++ /dev/null @@ -1,11 +0,0 @@ -/* inffast.h -- header to use inffast.c - * Copyright (C) 1995-2003, 2010 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); diff --git a/libs/storm-sys/StormLib/src/zlib/inffixed.h b/libs/storm-sys/StormLib/src/zlib/inffixed.h deleted file mode 100644 index 75ed4b5..0000000 --- a/libs/storm-sys/StormLib/src/zlib/inffixed.h +++ /dev/null @@ -1,94 +0,0 @@ - /* inffixed.h -- table for decoding fixed codes - * Generated automatically by makefixed(). - */ - - /* WARNING: this file should *not* be used by applications. It - is part of the implementation of the compression library and - is subject to change. Applications should only use zlib.h. - */ - - static const code lenfix[512] = { - {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, - {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, - {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, - {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, - {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, - {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, - {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, - {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, - {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, - {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, - {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, - {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, - {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, - {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, - {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, - {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, - {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, - {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, - {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, - {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, - {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, - {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, - {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, - {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, - {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, - {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, - {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, - {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, - {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, - {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, - {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, - {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, - {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, - {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, - {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, - {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, - {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, - {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, - {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, - {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, - {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, - {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, - {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, - {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, - {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, - {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, - {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, - {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, - {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, - {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, - {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, - {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, - {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, - {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, - {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, - {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, - {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, - {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, - {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, - {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, - {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, - {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, - {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, - {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, - {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, - {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, - {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, - {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, - {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, - {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, - {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, - {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, - {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, - {0,9,255} - }; - - static const code distfix[32] = { - {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, - {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, - {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, - {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, - {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, - {22,5,193},{64,5,0} - }; diff --git a/libs/storm-sys/StormLib/src/zlib/inflate.c b/libs/storm-sys/StormLib/src/zlib/inflate.c deleted file mode 100644 index a8431ab..0000000 --- a/libs/storm-sys/StormLib/src/zlib/inflate.c +++ /dev/null @@ -1,1480 +0,0 @@ -/* inflate.c -- zlib decompression - * Copyright (C) 1995-2010 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * Change history: - * - * 1.2.beta0 24 Nov 2002 - * - First version -- complete rewrite of inflate to simplify code, avoid - * creation of window when not needed, minimize use of window when it is - * needed, make inffast.c even faster, implement gzip decoding, and to - * improve code readability and style over the previous zlib inflate code - * - * 1.2.beta1 25 Nov 2002 - * - Use pointers for available input and output checking in inffast.c - * - Remove input and output counters in inffast.c - * - Change inffast.c entry and loop from avail_in >= 7 to >= 6 - * - Remove unnecessary second byte pull from length extra in inffast.c - * - Unroll direct copy to three copies per loop in inffast.c - * - * 1.2.beta2 4 Dec 2002 - * - Change external routine names to reduce potential conflicts - * - Correct filename to inffixed.h for fixed tables in inflate.c - * - Make hbuf[] unsigned char to match parameter type in inflate.c - * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset) - * to avoid negation problem on Alphas (64 bit) in inflate.c - * - * 1.2.beta3 22 Dec 2002 - * - Add comments on state->bits assertion in inffast.c - * - Add comments on op field in inftrees.h - * - Fix bug in reuse of allocated window after inflateReset() - * - Remove bit fields--back to byte structure for speed - * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths - * - Change post-increments to pre-increments in inflate_fast(), PPC biased? - * - Add compile time option, POSTINC, to use post-increments instead (Intel?) - * - Make MATCH copy in inflate() much faster for when inflate_fast() not used - * - Use local copies of stream next and avail values, as well as local bit - * buffer and bit count in inflate()--for speed when inflate_fast() not used - * - * 1.2.beta4 1 Jan 2003 - * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings - * - Move a comment on output buffer sizes from inffast.c to inflate.c - * - Add comments in inffast.c to introduce the inflate_fast() routine - * - Rearrange window copies in inflate_fast() for speed and simplification - * - Unroll last copy for window match in inflate_fast() - * - Use local copies of window variables in inflate_fast() for speed - * - Pull out common wnext == 0 case for speed in inflate_fast() - * - Make op and len in inflate_fast() unsigned for consistency - * - Add FAR to lcode and dcode declarations in inflate_fast() - * - Simplified bad distance check in inflate_fast() - * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new - * source file infback.c to provide a call-back interface to inflate for - * programs like gzip and unzip -- uses window as output buffer to avoid - * window copying - * - * 1.2.beta5 1 Jan 2003 - * - Improved inflateBack() interface to allow the caller to provide initial - * input in strm. - * - Fixed stored blocks bug in inflateBack() - * - * 1.2.beta6 4 Jan 2003 - * - Added comments in inffast.c on effectiveness of POSTINC - * - Typecasting all around to reduce compiler warnings - * - Changed loops from while (1) or do {} while (1) to for (;;), again to - * make compilers happy - * - Changed type of window in inflateBackInit() to unsigned char * - * - * 1.2.beta7 27 Jan 2003 - * - Changed many types to unsigned or unsigned short to avoid warnings - * - Added inflateCopy() function - * - * 1.2.0 9 Mar 2003 - * - Changed inflateBack() interface to provide separate opaque descriptors - * for the in() and out() functions - * - Changed inflateBack() argument and in_func typedef to swap the length - * and buffer address return values for the input function - * - Check next_in and next_out for Z_NULL on entry to inflate() - * - * The history for versions after 1.2.0 are in ChangeLog in zlib distribution. - */ - -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -#ifdef MAKEFIXED -# ifndef BUILDFIXED -# define BUILDFIXED -# endif -#endif - -/* function prototypes */ -local void fixedtables OF((struct inflate_state FAR *state)); -local int updatewindow OF((z_streamp strm, unsigned out)); -#ifdef BUILDFIXED - void makefixed OF((void)); -#endif -local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf, - unsigned len)); - -int ZEXPORT inflateReset(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - strm->total_in = strm->total_out = state->total = 0; - strm->msg = Z_NULL; - strm->adler = 1; /* to support ill-conceived Java test suite */ - state->mode = HEAD; - state->last = 0; - state->havedict = 0; - state->dmax = 32768U; - state->head = Z_NULL; - state->wsize = 0; - state->whave = 0; - state->wnext = 0; - state->hold = 0; - state->bits = 0; - state->lencode = state->distcode = state->next = state->codes; - state->sane = 1; - state->back = -1; - Tracev((stderr, "inflate: reset\n")); - return Z_OK; -} - -int ZEXPORT inflateReset2(strm, windowBits) -z_streamp strm; -int windowBits; -{ - int wrap; - struct inflate_state FAR *state; - - /* get the state */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - - /* extract wrap request from windowBits parameter */ - if (windowBits < 0) { - wrap = 0; - windowBits = -windowBits; - } - else { - wrap = (windowBits >> 4) + 1; -#ifdef GUNZIP - if (windowBits < 48) - windowBits &= 15; -#endif - } - - /* set number of window bits, free window if different */ - if (windowBits && (windowBits < 8 || windowBits > 15)) - return Z_STREAM_ERROR; - if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) { - ZFREE(strm, state->window); - state->window = Z_NULL; - } - - /* update state and reset the rest of it */ - state->wrap = wrap; - state->wbits = (unsigned)windowBits; - return inflateReset(strm); -} - -int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) -z_streamp strm; -int windowBits; -const char *version; -int stream_size; -{ - int ret; - struct inflate_state FAR *state; - - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || - stream_size != (int)(sizeof(z_stream))) - return Z_VERSION_ERROR; - if (strm == Z_NULL) return Z_STREAM_ERROR; - strm->msg = Z_NULL; /* in case we return an error */ - if (strm->zalloc == (alloc_func)0) { - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; - } - if (strm->zfree == (free_func)0) strm->zfree = zcfree; - state = (struct inflate_state FAR *) - ZALLOC(strm, 1, sizeof(struct inflate_state)); - if (state == Z_NULL) return Z_MEM_ERROR; - Tracev((stderr, "inflate: allocated\n")); - strm->state = (struct internal_state FAR *)state; - state->window = Z_NULL; - ret = inflateReset2(strm, windowBits); - if (ret != Z_OK) { - ZFREE(strm, state); - strm->state = Z_NULL; - } - return ret; -} - -int ZEXPORT inflateInit_(strm, version, stream_size) -z_streamp strm; -const char *version; -int stream_size; -{ - return inflateInit2_(strm, DEF_WBITS, version, stream_size); -} - -int ZEXPORT inflatePrime(strm, bits, value) -z_streamp strm; -int bits; -int value; -{ - struct inflate_state FAR *state; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (bits < 0) { - state->hold = 0; - state->bits = 0; - return Z_OK; - } - if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR; - value &= (1L << bits) - 1; - state->hold += value << state->bits; - state->bits += bits; - return Z_OK; -} - -/* - Return state with length and distance decoding tables and index sizes set to - fixed code decoding. Normally this returns fixed tables from inffixed.h. - If BUILDFIXED is defined, then instead this routine builds the tables the - first time it's called, and returns those tables the first time and - thereafter. This reduces the size of the code by about 2K bytes, in - exchange for a little execution time. However, BUILDFIXED should not be - used for threaded applications, since the rewriting of the tables and virgin - may not be thread-safe. - */ -local void fixedtables(state) -struct inflate_state FAR *state; -{ -#ifdef BUILDFIXED - static int virgin = 1; - static code *lenfix, *distfix; - static code fixed[544]; - - /* build fixed huffman tables if first call (may not be thread safe) */ - if (virgin) { - unsigned sym, bits; - static code *next; - - /* literal/length table */ - sym = 0; - while (sym < 144) state->lens[sym++] = 8; - while (sym < 256) state->lens[sym++] = 9; - while (sym < 280) state->lens[sym++] = 7; - while (sym < 288) state->lens[sym++] = 8; - next = fixed; - lenfix = next; - bits = 9; - inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); - - /* distance table */ - sym = 0; - while (sym < 32) state->lens[sym++] = 5; - distfix = next; - bits = 5; - inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); - - /* do this just once */ - virgin = 0; - } -#else /* !BUILDFIXED */ -# include "inffixed.h" -#endif /* BUILDFIXED */ - state->lencode = lenfix; - state->lenbits = 9; - state->distcode = distfix; - state->distbits = 5; -} - -#ifdef MAKEFIXED -#include - -/* - Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also - defines BUILDFIXED, so the tables are built on the fly. makefixed() writes - those tables to stdout, which would be piped to inffixed.h. A small program - can simply call makefixed to do this: - - void makefixed(void); - - int main(void) - { - makefixed(); - return 0; - } - - Then that can be linked with zlib built with MAKEFIXED defined and run: - - a.out > inffixed.h - */ -void makefixed() -{ - unsigned low, size; - struct inflate_state state; - - fixedtables(&state); - puts(" /* inffixed.h -- table for decoding fixed codes"); - puts(" * Generated automatically by makefixed()."); - puts(" */"); - puts(""); - puts(" /* WARNING: this file should *not* be used by applications."); - puts(" It is part of the implementation of this library and is"); - puts(" subject to change. Applications should only use zlib.h."); - puts(" */"); - puts(""); - size = 1U << 9; - printf(" static const code lenfix[%u] = {", size); - low = 0; - for (;;) { - if ((low % 7) == 0) printf("\n "); - printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits, - state.lencode[low].val); - if (++low == size) break; - putchar(','); - } - puts("\n };"); - size = 1U << 5; - printf("\n static const code distfix[%u] = {", size); - low = 0; - for (;;) { - if ((low % 6) == 0) printf("\n "); - printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, - state.distcode[low].val); - if (++low == size) break; - putchar(','); - } - puts("\n };"); -} -#endif /* MAKEFIXED */ - -/* - Update the window with the last wsize (normally 32K) bytes written before - returning. If window does not exist yet, create it. This is only called - when a window is already in use, or when output has been written during this - inflate call, but the end of the deflate stream has not been reached yet. - It is also called to create a window for dictionary data when a dictionary - is loaded. - - Providing output buffers larger than 32K to inflate() should provide a speed - advantage, since only the last 32K of output is copied to the sliding window - upon return from inflate(), and since all distances after the first 32K of - output will fall in the output data, making match copies simpler and faster. - The advantage may be dependent on the size of the processor's data caches. - */ -local int updatewindow(strm, out) -z_streamp strm; -unsigned out; -{ - struct inflate_state FAR *state; - unsigned copy, dist; - - state = (struct inflate_state FAR *)strm->state; - - /* if it hasn't been done already, allocate space for the window */ - if (state->window == Z_NULL) { - state->window = (unsigned char FAR *) - ZALLOC(strm, 1U << state->wbits, - sizeof(unsigned char)); - if (state->window == Z_NULL) return 1; - } - - /* if window not in use yet, initialize */ - if (state->wsize == 0) { - state->wsize = 1U << state->wbits; - state->wnext = 0; - state->whave = 0; - } - - /* copy state->wsize or less output bytes into the circular window */ - copy = out - strm->avail_out; - if (copy >= state->wsize) { - zmemcpy(state->window, strm->next_out - state->wsize, state->wsize); - state->wnext = 0; - state->whave = state->wsize; - } - else { - dist = state->wsize - state->wnext; - if (dist > copy) dist = copy; - zmemcpy(state->window + state->wnext, strm->next_out - copy, dist); - copy -= dist; - if (copy) { - zmemcpy(state->window, strm->next_out - copy, copy); - state->wnext = copy; - state->whave = state->wsize; - } - else { - state->wnext += dist; - if (state->wnext == state->wsize) state->wnext = 0; - if (state->whave < state->wsize) state->whave += dist; - } - } - return 0; -} - -/* Macros for inflate(): */ - -/* check function to use adler32() for zlib or crc32() for gzip */ -#ifdef GUNZIP -# define UPDATE(check, buf, len) \ - (state->flags ? crc32(check, buf, len) : adler32(check, buf, len)) -#else -# define UPDATE(check, buf, len) adler32(check, buf, len) -#endif - -/* check macros for header crc */ -#ifdef GUNZIP -# define CRC2(check, word) \ - do { \ - hbuf[0] = (unsigned char)(word); \ - hbuf[1] = (unsigned char)((word) >> 8); \ - check = crc32(check, hbuf, 2); \ - } while (0) - -# define CRC4(check, word) \ - do { \ - hbuf[0] = (unsigned char)(word); \ - hbuf[1] = (unsigned char)((word) >> 8); \ - hbuf[2] = (unsigned char)((word) >> 16); \ - hbuf[3] = (unsigned char)((word) >> 24); \ - check = crc32(check, hbuf, 4); \ - } while (0) -#endif - -/* Load registers with state in inflate() for speed */ -#define LOAD() \ - do { \ - put = strm->next_out; \ - left = strm->avail_out; \ - next = strm->next_in; \ - have = strm->avail_in; \ - hold = state->hold; \ - bits = state->bits; \ - } while (0) - -/* Restore state from registers in inflate() */ -#define RESTORE() \ - do { \ - strm->next_out = put; \ - strm->avail_out = left; \ - strm->next_in = next; \ - strm->avail_in = have; \ - state->hold = hold; \ - state->bits = bits; \ - } while (0) - -/* Clear the input bit accumulator */ -#define INITBITS() \ - do { \ - hold = 0; \ - bits = 0; \ - } while (0) - -/* Get a byte of input into the bit accumulator, or return from inflate() - if there is no input available. */ -#define PULLBYTE() \ - do { \ - if (have == 0) goto inf_leave; \ - have--; \ - hold += (unsigned long)(*next++) << bits; \ - bits += 8; \ - } while (0) - -/* Assure that there are at least n bits in the bit accumulator. If there is - not enough available input to do that, then return from inflate(). */ -#define NEEDBITS(n) \ - do { \ - while (bits < (unsigned)(n)) \ - PULLBYTE(); \ - } while (0) - -/* Return the low n bits of the bit accumulator (n < 16) */ -#define BITS(n) \ - ((unsigned)hold & ((1U << (n)) - 1)) - -/* Remove n bits from the bit accumulator */ -#define DROPBITS(n) \ - do { \ - hold >>= (n); \ - bits -= (unsigned)(n); \ - } while (0) - -/* Remove zero to seven bits as needed to go to a byte boundary */ -#define BYTEBITS() \ - do { \ - hold >>= bits & 7; \ - bits -= bits & 7; \ - } while (0) - -/* Reverse the bytes in a 32-bit value */ -#define REVERSE(q) \ - ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ - (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) - -/* - inflate() uses a state machine to process as much input data and generate as - much output data as possible before returning. The state machine is - structured roughly as follows: - - for (;;) switch (state) { - ... - case STATEn: - if (not enough input data or output space to make progress) - return; - ... make progress ... - state = STATEm; - break; - ... - } - - so when inflate() is called again, the same case is attempted again, and - if the appropriate resources are provided, the machine proceeds to the - next state. The NEEDBITS() macro is usually the way the state evaluates - whether it can proceed or should return. NEEDBITS() does the return if - the requested bits are not available. The typical use of the BITS macros - is: - - NEEDBITS(n); - ... do something with BITS(n) ... - DROPBITS(n); - - where NEEDBITS(n) either returns from inflate() if there isn't enough - input left to load n bits into the accumulator, or it continues. BITS(n) - gives the low n bits in the accumulator. When done, DROPBITS(n) drops - the low n bits off the accumulator. INITBITS() clears the accumulator - and sets the number of available bits to zero. BYTEBITS() discards just - enough bits to put the accumulator on a byte boundary. After BYTEBITS() - and a NEEDBITS(8), then BITS(8) would return the next byte in the stream. - - NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return - if there is no input available. The decoding of variable length codes uses - PULLBYTE() directly in order to pull just enough bytes to decode the next - code, and no more. - - Some states loop until they get enough input, making sure that enough - state information is maintained to continue the loop where it left off - if NEEDBITS() returns in the loop. For example, want, need, and keep - would all have to actually be part of the saved state in case NEEDBITS() - returns: - - case STATEw: - while (want < need) { - NEEDBITS(n); - keep[want++] = BITS(n); - DROPBITS(n); - } - state = STATEx; - case STATEx: - - As shown above, if the next state is also the next case, then the break - is omitted. - - A state may also return if there is not enough output space available to - complete that state. Those states are copying stored data, writing a - literal byte, and copying a matching string. - - When returning, a "goto inf_leave" is used to update the total counters, - update the check value, and determine whether any progress has been made - during that inflate() call in order to return the proper return code. - Progress is defined as a change in either strm->avail_in or strm->avail_out. - When there is a window, goto inf_leave will update the window with the last - output written. If a goto inf_leave occurs in the middle of decompression - and there is no window currently, goto inf_leave will create one and copy - output to the window for the next call of inflate(). - - In this implementation, the flush parameter of inflate() only affects the - return code (per zlib.h). inflate() always writes as much as possible to - strm->next_out, given the space available and the provided input--the effect - documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers - the allocation of and copying into a sliding window until necessary, which - provides the effect documented in zlib.h for Z_FINISH when the entire input - stream available. So the only thing the flush parameter actually does is: - when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it - will return Z_BUF_ERROR if it has not reached the end of the stream. - */ - -int ZEXPORT inflate(strm, flush) -z_streamp strm; -int flush; -{ - struct inflate_state FAR *state; - unsigned char FAR *next; /* next input */ - unsigned char FAR *put; /* next output */ - unsigned have, left; /* available input and output */ - unsigned long hold; /* bit buffer */ - unsigned bits; /* bits in bit buffer */ - unsigned in, out; /* save starting available input and output */ - unsigned copy; /* number of stored or match bytes to copy */ - unsigned char FAR *from; /* where to copy match bytes from */ - code here; /* current decoding table entry */ - code last; /* parent table entry */ - unsigned len; /* length to copy for repeats, bits to drop */ - int ret; /* return code */ -#ifdef GUNZIP - unsigned char hbuf[4]; /* buffer for gzip header crc calculation */ -#endif - static const unsigned short order[19] = /* permutation of code lengths */ - {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - - if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL || - (strm->next_in == Z_NULL && strm->avail_in != 0)) - return Z_STREAM_ERROR; - - state = (struct inflate_state FAR *)strm->state; - if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */ - LOAD(); - in = have; - out = left; - ret = Z_OK; - for (;;) - switch (state->mode) { - case HEAD: - if (state->wrap == 0) { - state->mode = TYPEDO; - break; - } - NEEDBITS(16); -#ifdef GUNZIP - if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */ - state->check = crc32(0L, Z_NULL, 0); - CRC2(state->check, hold); - INITBITS(); - state->mode = FLAGS; - break; - } - state->flags = 0; /* expect zlib header */ - if (state->head != Z_NULL) - state->head->done = -1; - if (!(state->wrap & 1) || /* check if zlib header allowed */ -#else - if ( -#endif - ((BITS(8) << 8) + (hold >> 8)) % 31) { - strm->msg = (char *)"incorrect header check"; - state->mode = BAD; - break; - } - if (BITS(4) != Z_DEFLATED) { - strm->msg = (char *)"unknown compression method"; - state->mode = BAD; - break; - } - DROPBITS(4); - len = BITS(4) + 8; - if (state->wbits == 0) - state->wbits = len; - else if (len > state->wbits) { - strm->msg = (char *)"invalid window size"; - state->mode = BAD; - break; - } - state->dmax = 1U << len; - Tracev((stderr, "inflate: zlib header ok\n")); - strm->adler = state->check = adler32(0L, Z_NULL, 0); - state->mode = hold & 0x200 ? DICTID : TYPE; - INITBITS(); - break; -#ifdef GUNZIP - case FLAGS: - NEEDBITS(16); - state->flags = (int)(hold); - if ((state->flags & 0xff) != Z_DEFLATED) { - strm->msg = (char *)"unknown compression method"; - state->mode = BAD; - break; - } - if (state->flags & 0xe000) { - strm->msg = (char *)"unknown header flags set"; - state->mode = BAD; - break; - } - if (state->head != Z_NULL) - state->head->text = (int)((hold >> 8) & 1); - if (state->flags & 0x0200) CRC2(state->check, hold); - INITBITS(); - state->mode = TIME; - case TIME: - NEEDBITS(32); - if (state->head != Z_NULL) - state->head->time = hold; - if (state->flags & 0x0200) CRC4(state->check, hold); - INITBITS(); - state->mode = OS; - case OS: - NEEDBITS(16); - if (state->head != Z_NULL) { - state->head->xflags = (int)(hold & 0xff); - state->head->os = (int)(hold >> 8); - } - if (state->flags & 0x0200) CRC2(state->check, hold); - INITBITS(); - state->mode = EXLEN; - case EXLEN: - if (state->flags & 0x0400) { - NEEDBITS(16); - state->length = (unsigned)(hold); - if (state->head != Z_NULL) - state->head->extra_len = (unsigned)hold; - if (state->flags & 0x0200) CRC2(state->check, hold); - INITBITS(); - } - else if (state->head != Z_NULL) - state->head->extra = Z_NULL; - state->mode = EXTRA; - case EXTRA: - if (state->flags & 0x0400) { - copy = state->length; - if (copy > have) copy = have; - if (copy) { - if (state->head != Z_NULL && - state->head->extra != Z_NULL) { - len = state->head->extra_len - state->length; - zmemcpy(state->head->extra + len, next, - len + copy > state->head->extra_max ? - state->head->extra_max - len : copy); - } - if (state->flags & 0x0200) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - state->length -= copy; - } - if (state->length) goto inf_leave; - } - state->length = 0; - state->mode = NAME; - case NAME: - if (state->flags & 0x0800) { - if (have == 0) goto inf_leave; - copy = 0; - do { - len = (unsigned)(next[copy++]); - if (state->head != Z_NULL && - state->head->name != Z_NULL && - state->length < state->head->name_max) - state->head->name[state->length++] = len; - } while (len && copy < have); - if (state->flags & 0x0200) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - if (len) goto inf_leave; - } - else if (state->head != Z_NULL) - state->head->name = Z_NULL; - state->length = 0; - state->mode = COMMENT; - case COMMENT: - if (state->flags & 0x1000) { - if (have == 0) goto inf_leave; - copy = 0; - do { - len = (unsigned)(next[copy++]); - if (state->head != Z_NULL && - state->head->comment != Z_NULL && - state->length < state->head->comm_max) - state->head->comment[state->length++] = len; - } while (len && copy < have); - if (state->flags & 0x0200) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - if (len) goto inf_leave; - } - else if (state->head != Z_NULL) - state->head->comment = Z_NULL; - state->mode = HCRC; - case HCRC: - if (state->flags & 0x0200) { - NEEDBITS(16); - if (hold != (state->check & 0xffff)) { - strm->msg = (char *)"header crc mismatch"; - state->mode = BAD; - break; - } - INITBITS(); - } - if (state->head != Z_NULL) { - state->head->hcrc = (int)((state->flags >> 9) & 1); - state->head->done = 1; - } - strm->adler = state->check = crc32(0L, Z_NULL, 0); - state->mode = TYPE; - break; -#endif - case DICTID: - NEEDBITS(32); - strm->adler = state->check = REVERSE(hold); - INITBITS(); - state->mode = DICT; - case DICT: - if (state->havedict == 0) { - RESTORE(); - return Z_NEED_DICT; - } - strm->adler = state->check = adler32(0L, Z_NULL, 0); - state->mode = TYPE; - case TYPE: - if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave; - case TYPEDO: - if (state->last) { - BYTEBITS(); - state->mode = CHECK; - break; - } - NEEDBITS(3); - state->last = BITS(1); - DROPBITS(1); - switch (BITS(2)) { - case 0: /* stored block */ - Tracev((stderr, "inflate: stored block%s\n", - state->last ? " (last)" : "")); - state->mode = STORED; - break; - case 1: /* fixed block */ - fixedtables(state); - Tracev((stderr, "inflate: fixed codes block%s\n", - state->last ? " (last)" : "")); - state->mode = LEN_; /* decode codes */ - if (flush == Z_TREES) { - DROPBITS(2); - goto inf_leave; - } - break; - case 2: /* dynamic block */ - Tracev((stderr, "inflate: dynamic codes block%s\n", - state->last ? " (last)" : "")); - state->mode = TABLE; - break; - case 3: - strm->msg = (char *)"invalid block type"; - state->mode = BAD; - } - DROPBITS(2); - break; - case STORED: - BYTEBITS(); /* go to byte boundary */ - NEEDBITS(32); - if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { - strm->msg = (char *)"invalid stored block lengths"; - state->mode = BAD; - break; - } - state->length = (unsigned)hold & 0xffff; - Tracev((stderr, "inflate: stored length %u\n", - state->length)); - INITBITS(); - state->mode = COPY_; - if (flush == Z_TREES) goto inf_leave; - case COPY_: - state->mode = COPY; - case COPY: - copy = state->length; - if (copy) { - if (copy > have) copy = have; - if (copy > left) copy = left; - if (copy == 0) goto inf_leave; - zmemcpy(put, next, copy); - have -= copy; - next += copy; - left -= copy; - put += copy; - state->length -= copy; - break; - } - Tracev((stderr, "inflate: stored end\n")); - state->mode = TYPE; - break; - case TABLE: - NEEDBITS(14); - state->nlen = BITS(5) + 257; - DROPBITS(5); - state->ndist = BITS(5) + 1; - DROPBITS(5); - state->ncode = BITS(4) + 4; - DROPBITS(4); -#ifndef PKZIP_BUG_WORKAROUND - if (state->nlen > 286 || state->ndist > 30) { - strm->msg = (char *)"too many length or distance symbols"; - state->mode = BAD; - break; - } -#endif - Tracev((stderr, "inflate: table sizes ok\n")); - state->have = 0; - state->mode = LENLENS; - case LENLENS: - while (state->have < state->ncode) { - NEEDBITS(3); - state->lens[order[state->have++]] = (unsigned short)BITS(3); - DROPBITS(3); - } - while (state->have < 19) - state->lens[order[state->have++]] = 0; - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 7; - ret = inflate_table(CODES, state->lens, 19, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid code lengths set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: code lengths ok\n")); - state->have = 0; - state->mode = CODELENS; - case CODELENS: - while (state->have < state->nlen + state->ndist) { - for (;;) { - here = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if (here.val < 16) { - NEEDBITS(here.bits); - DROPBITS(here.bits); - state->lens[state->have++] = here.val; - } - else { - if (here.val == 16) { - NEEDBITS(here.bits + 2); - DROPBITS(here.bits); - if (state->have == 0) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - len = state->lens[state->have - 1]; - copy = 3 + BITS(2); - DROPBITS(2); - } - else if (here.val == 17) { - NEEDBITS(here.bits + 3); - DROPBITS(here.bits); - len = 0; - copy = 3 + BITS(3); - DROPBITS(3); - } - else { - NEEDBITS(here.bits + 7); - DROPBITS(here.bits); - len = 0; - copy = 11 + BITS(7); - DROPBITS(7); - } - if (state->have + copy > state->nlen + state->ndist) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - while (copy--) - state->lens[state->have++] = (unsigned short)len; - } - } - - /* handle error breaks in while */ - if (state->mode == BAD) break; - - /* check for end-of-block code (better have one) */ - if (state->lens[256] == 0) { - strm->msg = (char *)"invalid code -- missing end-of-block"; - state->mode = BAD; - break; - } - - /* build code tables -- note: do not change the lenbits or distbits - values here (9 and 6) without reading the comments in inftrees.h - concerning the ENOUGH constants, which depend on those values */ - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 9; - ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid literal/lengths set"; - state->mode = BAD; - break; - } - state->distcode = (code const FAR *)(state->next); - state->distbits = 6; - ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, - &(state->next), &(state->distbits), state->work); - if (ret) { - strm->msg = (char *)"invalid distances set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: codes ok\n")); - state->mode = LEN_; - if (flush == Z_TREES) goto inf_leave; - case LEN_: - state->mode = LEN; - case LEN: - if (have >= 6 && left >= 258) { - RESTORE(); - inflate_fast(strm, out); - LOAD(); - if (state->mode == TYPE) - state->back = -1; - break; - } - state->back = 0; - for (;;) { - here = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if (here.op && (here.op & 0xf0) == 0) { - last = here; - for (;;) { - here = state->lencode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + here.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - state->back += last.bits; - } - DROPBITS(here.bits); - state->back += here.bits; - state->length = (unsigned)here.val; - if ((int)(here.op) == 0) { - Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", here.val)); - state->mode = LIT; - break; - } - if (here.op & 32) { - Tracevv((stderr, "inflate: end of block\n")); - state->back = -1; - state->mode = TYPE; - break; - } - if (here.op & 64) { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - state->extra = (unsigned)(here.op) & 15; - state->mode = LENEXT; - case LENEXT: - if (state->extra) { - NEEDBITS(state->extra); - state->length += BITS(state->extra); - DROPBITS(state->extra); - state->back += state->extra; - } - Tracevv((stderr, "inflate: length %u\n", state->length)); - state->was = state->length; - state->mode = DIST; - case DIST: - for (;;) { - here = state->distcode[BITS(state->distbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if ((here.op & 0xf0) == 0) { - last = here; - for (;;) { - here = state->distcode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + here.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - state->back += last.bits; - } - DROPBITS(here.bits); - state->back += here.bits; - if (here.op & 64) { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - state->offset = (unsigned)here.val; - state->extra = (unsigned)(here.op) & 15; - state->mode = DISTEXT; - case DISTEXT: - if (state->extra) { - NEEDBITS(state->extra); - state->offset += BITS(state->extra); - DROPBITS(state->extra); - state->back += state->extra; - } -#ifdef INFLATE_STRICT - if (state->offset > state->dmax) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#endif - Tracevv((stderr, "inflate: distance %u\n", state->offset)); - state->mode = MATCH; - case MATCH: - if (left == 0) goto inf_leave; - copy = out - left; - if (state->offset > copy) { /* copy from window */ - copy = state->offset - copy; - if (copy > state->whave) { - if (state->sane) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR - Trace((stderr, "inflate.c too far\n")); - copy -= state->whave; - if (copy > state->length) copy = state->length; - if (copy > left) copy = left; - left -= copy; - state->length -= copy; - do { - *put++ = 0; - } while (--copy); - if (state->length == 0) state->mode = LEN; - break; -#endif - } - if (copy > state->wnext) { - copy -= state->wnext; - from = state->window + (state->wsize - copy); - } - else - from = state->window + (state->wnext - copy); - if (copy > state->length) copy = state->length; - } - else { /* copy from output */ - from = put - state->offset; - copy = state->length; - } - if (copy > left) copy = left; - left -= copy; - state->length -= copy; - do { - *put++ = *from++; - } while (--copy); - if (state->length == 0) state->mode = LEN; - break; - case LIT: - if (left == 0) goto inf_leave; - *put++ = (unsigned char)(state->length); - left--; - state->mode = LEN; - break; - case CHECK: - if (state->wrap) { - NEEDBITS(32); - out -= left; - strm->total_out += out; - state->total += out; - if (out) - strm->adler = state->check = - UPDATE(state->check, put - out, out); - out = left; - if (( -#ifdef GUNZIP - state->flags ? hold : -#endif - REVERSE(hold)) != state->check) { - strm->msg = (char *)"incorrect data check"; - state->mode = BAD; - break; - } - INITBITS(); - Tracev((stderr, "inflate: check matches trailer\n")); - } -#ifdef GUNZIP - state->mode = LENGTH; - case LENGTH: - if (state->wrap && state->flags) { - NEEDBITS(32); - if (hold != (state->total & 0xffffffffUL)) { - strm->msg = (char *)"incorrect length check"; - state->mode = BAD; - break; - } - INITBITS(); - Tracev((stderr, "inflate: length matches trailer\n")); - } -#endif - state->mode = DONE; - case DONE: - ret = Z_STREAM_END; - goto inf_leave; - case BAD: - ret = Z_DATA_ERROR; - goto inf_leave; - case MEM: - return Z_MEM_ERROR; - case SYNC: - default: - return Z_STREAM_ERROR; - } - - /* - Return from inflate(), updating the total counts and the check value. - If there was no progress during the inflate() call, return a buffer - error. Call updatewindow() to create and/or update the window state. - Note: a memory error from inflate() is non-recoverable. - */ - inf_leave: - RESTORE(); - if (state->wsize || (state->mode < CHECK && out != strm->avail_out)) - if (updatewindow(strm, out)) { - state->mode = MEM; - return Z_MEM_ERROR; - } - in -= strm->avail_in; - out -= strm->avail_out; - strm->total_in += in; - strm->total_out += out; - state->total += out; - if (state->wrap && out) - strm->adler = state->check = - UPDATE(state->check, strm->next_out - out, out); - strm->data_type = state->bits + (state->last ? 64 : 0) + - (state->mode == TYPE ? 128 : 0) + - (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0); - if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) - ret = Z_BUF_ERROR; - return ret; -} - -int ZEXPORT inflateEnd(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (state->window != Z_NULL) ZFREE(strm, state->window); - ZFREE(strm, strm->state); - strm->state = Z_NULL; - Tracev((stderr, "inflate: end\n")); - return Z_OK; -} - -int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) -z_streamp strm; -const Bytef *dictionary; -uInt dictLength; -{ - struct inflate_state FAR *state; - unsigned long id; - - /* check state */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (state->wrap != 0 && state->mode != DICT) - return Z_STREAM_ERROR; - - /* check for correct dictionary id */ - if (state->mode == DICT) { - id = adler32(0L, Z_NULL, 0); - id = adler32(id, dictionary, dictLength); - if (id != state->check) - return Z_DATA_ERROR; - } - - /* copy dictionary to window */ - if (updatewindow(strm, strm->avail_out)) { - state->mode = MEM; - return Z_MEM_ERROR; - } - if (dictLength > state->wsize) { - zmemcpy(state->window, dictionary + dictLength - state->wsize, - state->wsize); - state->whave = state->wsize; - } - else { - zmemcpy(state->window + state->wsize - dictLength, dictionary, - dictLength); - state->whave = dictLength; - } - state->havedict = 1; - Tracev((stderr, "inflate: dictionary set\n")); - return Z_OK; -} - -int ZEXPORT inflateGetHeader(strm, head) -z_streamp strm; -gz_headerp head; -{ - struct inflate_state FAR *state; - - /* check state */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if ((state->wrap & 2) == 0) return Z_STREAM_ERROR; - - /* save header structure */ - state->head = head; - head->done = 0; - return Z_OK; -} - -/* - Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found - or when out of input. When called, *have is the number of pattern bytes - found in order so far, in 0..3. On return *have is updated to the new - state. If on return *have equals four, then the pattern was found and the - return value is how many bytes were read including the last byte of the - pattern. If *have is less than four, then the pattern has not been found - yet and the return value is len. In the latter case, syncsearch() can be - called again with more data and the *have state. *have is initialized to - zero for the first call. - */ -local unsigned syncsearch(have, buf, len) -unsigned FAR *have; -unsigned char FAR *buf; -unsigned len; -{ - unsigned got; - unsigned next; - - got = *have; - next = 0; - while (next < len && got < 4) { - if ((int)(buf[next]) == (got < 2 ? 0 : 0xff)) - got++; - else if (buf[next]) - got = 0; - else - got = 4 - got; - next++; - } - *have = got; - return next; -} - -int ZEXPORT inflateSync(strm) -z_streamp strm; -{ - unsigned len; /* number of bytes to look at or looked at */ - unsigned long in, out; /* temporary to save total_in and total_out */ - unsigned char buf[4]; /* to restore bit buffer to byte string */ - struct inflate_state FAR *state; - - /* check parameters */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR; - - /* if first time, start search in bit buffer */ - if (state->mode != SYNC) { - state->mode = SYNC; - state->hold <<= state->bits & 7; - state->bits -= state->bits & 7; - len = 0; - while (state->bits >= 8) { - buf[len++] = (unsigned char)(state->hold); - state->hold >>= 8; - state->bits -= 8; - } - state->have = 0; - syncsearch(&(state->have), buf, len); - } - - /* search available input */ - len = syncsearch(&(state->have), strm->next_in, strm->avail_in); - strm->avail_in -= len; - strm->next_in += len; - strm->total_in += len; - - /* return no joy or set up to restart inflate() on a new block */ - if (state->have != 4) return Z_DATA_ERROR; - in = strm->total_in; out = strm->total_out; - inflateReset(strm); - strm->total_in = in; strm->total_out = out; - state->mode = TYPE; - return Z_OK; -} - -/* - Returns true if inflate is currently at the end of a block generated by - Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP - implementation to provide an additional safety check. PPP uses - Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored - block. When decompressing, PPP checks that at the end of input packet, - inflate is waiting for these length bytes. - */ -int ZEXPORT inflateSyncPoint(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - return state->mode == STORED && state->bits == 0; -} - -int ZEXPORT inflateCopy(dest, source) -z_streamp dest; -z_streamp source; -{ - struct inflate_state FAR *state; - struct inflate_state FAR *copy; - unsigned char FAR *window; - unsigned wsize; - - /* check input */ - if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL || - source->zalloc == (alloc_func)0 || source->zfree == (free_func)0) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)source->state; - - /* allocate space */ - copy = (struct inflate_state FAR *) - ZALLOC(source, 1, sizeof(struct inflate_state)); - if (copy == Z_NULL) return Z_MEM_ERROR; - window = Z_NULL; - if (state->window != Z_NULL) { - window = (unsigned char FAR *) - ZALLOC(source, 1U << state->wbits, sizeof(unsigned char)); - if (window == Z_NULL) { - ZFREE(source, copy); - return Z_MEM_ERROR; - } - } - - /* copy state */ - zmemcpy(dest, source, sizeof(z_stream)); - zmemcpy(copy, state, sizeof(struct inflate_state)); - if (state->lencode >= state->codes && - state->lencode <= state->codes + ENOUGH - 1) { - copy->lencode = copy->codes + (state->lencode - state->codes); - copy->distcode = copy->codes + (state->distcode - state->codes); - } - copy->next = copy->codes + (state->next - state->codes); - if (window != Z_NULL) { - wsize = 1U << state->wbits; - zmemcpy(window, state->window, wsize); - } - copy->window = window; - dest->state = (struct internal_state FAR *)copy; - return Z_OK; -} - -int ZEXPORT inflateUndermine(strm, subvert) -z_streamp strm; -int subvert; -{ - struct inflate_state FAR *state; - - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - state->sane = !subvert; -#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR - return Z_OK; -#else - state->sane = 1; - return Z_DATA_ERROR; -#endif -} - -long ZEXPORT inflateMark(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - - if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16; - state = (struct inflate_state FAR *)strm->state; - return ((long)(state->back) << 16) + - (state->mode == COPY ? state->length : - (state->mode == MATCH ? state->was - state->length : 0)); -} diff --git a/libs/storm-sys/StormLib/src/zlib/inflate.h b/libs/storm-sys/StormLib/src/zlib/inflate.h deleted file mode 100644 index 95f4986..0000000 --- a/libs/storm-sys/StormLib/src/zlib/inflate.h +++ /dev/null @@ -1,122 +0,0 @@ -/* inflate.h -- internal inflate state definition - * Copyright (C) 1995-2009 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* define NO_GZIP when compiling if you want to disable gzip header and - trailer decoding by inflate(). NO_GZIP would be used to avoid linking in - the crc code when it is not needed. For shared libraries, gzip decoding - should be left enabled. */ -#ifndef NO_GZIP -# define GUNZIP -#endif - -/* Possible inflate modes between inflate() calls */ -typedef enum { - HEAD, /* i: waiting for magic header */ - FLAGS, /* i: waiting for method and flags (gzip) */ - TIME, /* i: waiting for modification time (gzip) */ - OS, /* i: waiting for extra flags and operating system (gzip) */ - EXLEN, /* i: waiting for extra length (gzip) */ - EXTRA, /* i: waiting for extra bytes (gzip) */ - NAME, /* i: waiting for end of file name (gzip) */ - COMMENT, /* i: waiting for end of comment (gzip) */ - HCRC, /* i: waiting for header crc (gzip) */ - DICTID, /* i: waiting for dictionary check value */ - DICT, /* waiting for inflateSetDictionary() call */ - TYPE, /* i: waiting for type bits, including last-flag bit */ - TYPEDO, /* i: same, but skip check to exit inflate on new block */ - STORED, /* i: waiting for stored size (length and complement) */ - COPY_, /* i/o: same as COPY below, but only first time in */ - COPY, /* i/o: waiting for input or output to copy stored block */ - TABLE, /* i: waiting for dynamic block table lengths */ - LENLENS, /* i: waiting for code length code lengths */ - CODELENS, /* i: waiting for length/lit and distance code lengths */ - LEN_, /* i: same as LEN below, but only first time in */ - LEN, /* i: waiting for length/lit/eob code */ - LENEXT, /* i: waiting for length extra bits */ - DIST, /* i: waiting for distance code */ - DISTEXT, /* i: waiting for distance extra bits */ - MATCH, /* o: waiting for output space to copy string */ - LIT, /* o: waiting for output space to write literal */ - CHECK, /* i: waiting for 32-bit check value */ - LENGTH, /* i: waiting for 32-bit length (gzip) */ - DONE, /* finished check, done -- remain here until reset */ - BAD, /* got a data error -- remain here until reset */ - MEM, /* got an inflate() memory error -- remain here until reset */ - SYNC /* looking for synchronization bytes to restart inflate() */ -} inflate_mode; - -/* - State transitions between above modes - - - (most modes can go to BAD or MEM on error -- not shown for clarity) - - Process header: - HEAD -> (gzip) or (zlib) or (raw) - (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT -> - HCRC -> TYPE - (zlib) -> DICTID or TYPE - DICTID -> DICT -> TYPE - (raw) -> TYPEDO - Read deflate blocks: - TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK - STORED -> COPY_ -> COPY -> TYPE - TABLE -> LENLENS -> CODELENS -> LEN_ - LEN_ -> LEN - Read deflate codes in fixed or dynamic block: - LEN -> LENEXT or LIT or TYPE - LENEXT -> DIST -> DISTEXT -> MATCH -> LEN - LIT -> LEN - Process trailer: - CHECK -> LENGTH -> DONE - */ - -/* state maintained between inflate() calls. Approximately 10K bytes. */ -struct inflate_state { - inflate_mode mode; /* current inflate mode */ - int last; /* true if processing last block */ - int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ - int havedict; /* true if dictionary provided */ - int flags; /* gzip header method and flags (0 if zlib) */ - unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ - unsigned long check; /* protected copy of check value */ - unsigned long total; /* protected copy of output count */ - gz_headerp head; /* where to save gzip header information */ - /* sliding window */ - unsigned wbits; /* log base 2 of requested window size */ - unsigned wsize; /* window size or zero if not using window */ - unsigned whave; /* valid bytes in the window */ - unsigned wnext; /* window write index */ - unsigned char FAR *window; /* allocated sliding window, if needed */ - /* bit accumulator */ - unsigned long hold; /* input bit accumulator */ - unsigned bits; /* number of bits in "in" */ - /* for string and stored block copying */ - unsigned length; /* literal or length of data to copy */ - unsigned offset; /* distance back to copy string from */ - /* for table and code decoding */ - unsigned extra; /* extra bits needed */ - /* fixed and dynamic code tables */ - code const FAR *lencode; /* starting table for length/literal codes */ - code const FAR *distcode; /* starting table for distance codes */ - unsigned lenbits; /* index bits for lencode */ - unsigned distbits; /* index bits for distcode */ - /* dynamic table building */ - unsigned ncode; /* number of code length code lengths */ - unsigned nlen; /* number of length code lengths */ - unsigned ndist; /* number of distance code lengths */ - unsigned have; /* number of code lengths in lens[] */ - code FAR *next; /* next available space in codes[] */ - unsigned short lens[320]; /* temporary storage for code lengths */ - unsigned short work[288]; /* work area for code table building */ - code codes[ENOUGH]; /* space for code tables */ - int sane; /* if false, allow invalid distance too far */ - int back; /* bits back of last unprocessed length/lit */ - unsigned was; /* initial length of match */ -}; diff --git a/libs/storm-sys/StormLib/src/zlib/inftrees.c b/libs/storm-sys/StormLib/src/zlib/inftrees.c deleted file mode 100644 index 11e9c52..0000000 --- a/libs/storm-sys/StormLib/src/zlib/inftrees.c +++ /dev/null @@ -1,330 +0,0 @@ -/* inftrees.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-2010 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "inftrees.h" - -#define MAXBITS 15 - -const char inflate_copyright[] = - " inflate 1.2.5 Copyright 1995-2010 Mark Adler "; -/* - If you use the zlib library in a product, an acknowledgment is welcome - in the documentation of your product. If for some reason you cannot - include such an acknowledgment, I would appreciate that you keep this - copyright string in the executable of your product. - */ - -/* - Build a set of tables to decode the provided canonical Huffman code. - The code lengths are lens[0..codes-1]. The result starts at *table, - whose indices are 0..2^bits-1. work is a writable array of at least - lens shorts, which is used as a work area. type is the type of code - to be generated, CODES, LENS, or DISTS. On return, zero is success, - -1 is an invalid code, and +1 means that ENOUGH isn't enough. table - on return points to the next available entry's address. bits is the - requested root table index bits, and on return it is the actual root - table index bits. It will differ if the request is greater than the - longest code or if it is less than the shortest code. - */ -int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work) -codetype type; -unsigned short FAR *lens; -unsigned codes; -code FAR * FAR *table; -unsigned FAR *bits; -unsigned short FAR *work; -{ - unsigned len; /* a code's length in bits */ - unsigned sym; /* index of code symbols */ - unsigned min, max; /* minimum and maximum code lengths */ - unsigned root; /* number of index bits for root table */ - unsigned curr; /* number of index bits for current table */ - unsigned drop; /* code bits to drop for sub-table */ - int left; /* number of prefix codes available */ - unsigned used; /* code entries in table used */ - unsigned huff; /* Huffman code */ - unsigned incr; /* for incrementing code, index */ - unsigned fill; /* index for replicating entries */ - unsigned low; /* low bits for current root entry */ - unsigned mask; /* mask for low root bits */ - code here; /* table entry for duplication */ - code FAR *next; /* next available space in table */ - const unsigned short FAR *base; /* base value table to use */ - const unsigned short FAR *extra; /* extra bits table to use */ - int end; /* use base and extra for symbol > end */ - unsigned short count[MAXBITS+1]; /* number of codes of each length */ - unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ - static const unsigned short lbase[31] = { /* Length codes 257..285 base */ - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, - 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; - static const unsigned short lext[31] = { /* Length codes 257..285 extra */ - 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 73, 195}; - static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, - 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, - 8193, 12289, 16385, 24577, 0, 0}; - static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ - 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, - 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, - 28, 28, 29, 29, 64, 64}; - - /* - Process a set of code lengths to create a canonical Huffman code. The - code lengths are lens[0..codes-1]. Each length corresponds to the - symbols 0..codes-1. The Huffman code is generated by first sorting the - symbols by length from short to long, and retaining the symbol order - for codes with equal lengths. Then the code starts with all zero bits - for the first code of the shortest length, and the codes are integer - increments for the same length, and zeros are appended as the length - increases. For the deflate format, these bits are stored backwards - from their more natural integer increment ordering, and so when the - decoding tables are built in the large loop below, the integer codes - are incremented backwards. - - This routine assumes, but does not check, that all of the entries in - lens[] are in the range 0..MAXBITS. The caller must assure this. - 1..MAXBITS is interpreted as that code length. zero means that that - symbol does not occur in this code. - - The codes are sorted by computing a count of codes for each length, - creating from that a table of starting indices for each length in the - sorted table, and then entering the symbols in order in the sorted - table. The sorted table is work[], with that space being provided by - the caller. - - The length counts are used for other purposes as well, i.e. finding - the minimum and maximum length codes, determining if there are any - codes at all, checking for a valid set of lengths, and looking ahead - at length counts to determine sub-table sizes when building the - decoding tables. - */ - - /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ - for (len = 0; len <= MAXBITS; len++) - count[len] = 0; - for (sym = 0; sym < codes; sym++) - count[lens[sym]]++; - - /* bound code lengths, force root to be within code lengths */ - root = *bits; - for (max = MAXBITS; max >= 1; max--) - if (count[max] != 0) break; - if (root > max) root = max; - if (max == 0) { /* no symbols to code at all */ - here.op = (unsigned char)64; /* invalid code marker */ - here.bits = (unsigned char)1; - here.val = (unsigned short)0; - *(*table)++ = here; /* make a table to force an error */ - *(*table)++ = here; - *bits = 1; - return 0; /* no symbols, but wait for decoding to report error */ - } - for (min = 1; min < max; min++) - if (count[min] != 0) break; - if (root < min) root = min; - - /* check for an over-subscribed or incomplete set of lengths */ - left = 1; - for (len = 1; len <= MAXBITS; len++) { - left <<= 1; - left -= count[len]; - if (left < 0) return -1; /* over-subscribed */ - } - if (left > 0 && (type == CODES || max != 1)) - return -1; /* incomplete set */ - - /* generate offsets into symbol table for each length for sorting */ - offs[1] = 0; - for (len = 1; len < MAXBITS; len++) - offs[len + 1] = offs[len] + count[len]; - - /* sort symbols by length, by symbol order within each length */ - for (sym = 0; sym < codes; sym++) - if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym; - - /* - Create and fill in decoding tables. In this loop, the table being - filled is at next and has curr index bits. The code being used is huff - with length len. That code is converted to an index by dropping drop - bits off of the bottom. For codes where len is less than drop + curr, - those top drop + curr - len bits are incremented through all values to - fill the table with replicated entries. - - root is the number of index bits for the root table. When len exceeds - root, sub-tables are created pointed to by the root entry with an index - of the low root bits of huff. This is saved in low to check for when a - new sub-table should be started. drop is zero when the root table is - being filled, and drop is root when sub-tables are being filled. - - When a new sub-table is needed, it is necessary to look ahead in the - code lengths to determine what size sub-table is needed. The length - counts are used for this, and so count[] is decremented as codes are - entered in the tables. - - used keeps track of how many table entries have been allocated from the - provided *table space. It is checked for LENS and DIST tables against - the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in - the initial root table size constants. See the comments in inftrees.h - for more information. - - sym increments through all symbols, and the loop terminates when - all codes of length max, i.e. all codes, have been processed. This - routine permits incomplete codes, so another loop after this one fills - in the rest of the decoding tables with invalid code markers. - */ - - /* set up for code type */ - switch (type) { - case CODES: - base = extra = work; /* dummy value--not used */ - end = 19; - break; - case LENS: - base = lbase; - base -= 257; - extra = lext; - extra -= 257; - end = 256; - break; - default: /* DISTS */ - base = dbase; - extra = dext; - end = -1; - } - - /* initialize state for loop */ - huff = 0; /* starting code */ - sym = 0; /* starting code symbol */ - len = min; /* starting code length */ - next = *table; /* current table to fill in */ - curr = root; /* current table index bits */ - drop = 0; /* current bits to drop from code for index */ - low = (unsigned)(-1); /* trigger new sub-table when len > root */ - used = 1U << root; /* use root table entries */ - mask = used - 1; /* mask for comparing low */ - - /* check available table space */ - if ((type == LENS && used >= ENOUGH_LENS) || - (type == DISTS && used >= ENOUGH_DISTS)) - return 1; - - /* process all codes and make table entries */ - for (;;) { - /* create table entry */ - here.bits = (unsigned char)(len - drop); - if ((int)(work[sym]) < end) { - here.op = (unsigned char)0; - here.val = work[sym]; - } - else if ((int)(work[sym]) > end) { - here.op = (unsigned char)(extra[work[sym]]); - here.val = base[work[sym]]; - } - else { - here.op = (unsigned char)(32 + 64); /* end of block */ - here.val = 0; - } - - /* replicate for those indices with low len bits equal to huff */ - incr = 1U << (len - drop); - fill = 1U << curr; - min = fill; /* save offset to next table */ - do { - fill -= incr; - next[(huff >> drop) + fill] = here; - } while (fill != 0); - - /* backwards increment the len-bit code huff */ - incr = 1U << (len - 1); - while (huff & incr) - incr >>= 1; - if (incr != 0) { - huff &= incr - 1; - huff += incr; - } - else - huff = 0; - - /* go to next symbol, update count, len */ - sym++; - if (--(count[len]) == 0) { - if (len == max) break; - len = lens[work[sym]]; - } - - /* create new sub-table if needed */ - if (len > root && (huff & mask) != low) { - /* if first time, transition to sub-tables */ - if (drop == 0) - drop = root; - - /* increment past last table */ - next += min; /* here min is 1 << curr */ - - /* determine length of next table */ - curr = len - drop; - left = (int)(1 << curr); - while (curr + drop < max) { - left -= count[curr + drop]; - if (left <= 0) break; - curr++; - left <<= 1; - } - - /* check for enough space */ - used += 1U << curr; - if ((type == LENS && used >= ENOUGH_LENS) || - (type == DISTS && used >= ENOUGH_DISTS)) - return 1; - - /* point entry in root table to sub-table */ - low = huff & mask; - (*table)[low].op = (unsigned char)curr; - (*table)[low].bits = (unsigned char)root; - (*table)[low].val = (unsigned short)(next - *table); - } - } - - /* - Fill in rest of table for incomplete codes. This loop is similar to the - loop above in incrementing huff for table indices. It is assumed that - len is equal to curr + drop, so there is no loop needed to increment - through high index bits. When the current sub-table is filled, the loop - drops back to the root table to fill in any remaining entries there. - */ - here.op = (unsigned char)64; /* invalid code marker */ - here.bits = (unsigned char)(len - drop); - here.val = (unsigned short)0; - while (huff != 0) { - /* when done with sub-table, drop back to root table */ - if (drop != 0 && (huff & mask) != low) { - drop = 0; - len = root; - next = *table; - here.bits = (unsigned char)len; - } - - /* put invalid code marker in table */ - next[huff >> drop] = here; - - /* backwards increment the len-bit code huff */ - incr = 1U << (len - 1); - while (huff & incr) - incr >>= 1; - if (incr != 0) { - huff &= incr - 1; - huff += incr; - } - else - huff = 0; - } - - /* set return parameters */ - *table += used; - *bits = root; - return 0; -} diff --git a/libs/storm-sys/StormLib/src/zlib/inftrees.h b/libs/storm-sys/StormLib/src/zlib/inftrees.h deleted file mode 100644 index baa53a0..0000000 --- a/libs/storm-sys/StormLib/src/zlib/inftrees.h +++ /dev/null @@ -1,62 +0,0 @@ -/* inftrees.h -- header to use inftrees.c - * Copyright (C) 1995-2005, 2010 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* Structure for decoding tables. Each entry provides either the - information needed to do the operation requested by the code that - indexed that table entry, or it provides a pointer to another - table that indexes more bits of the code. op indicates whether - the entry is a pointer to another table, a literal, a length or - distance, an end-of-block, or an invalid code. For a table - pointer, the low four bits of op is the number of index bits of - that table. For a length or distance, the low four bits of op - is the number of extra bits to get after the code. bits is - the number of bits in this code or part of the code to drop off - of the bit buffer. val is the actual byte to output in the case - of a literal, the base length or distance, or the offset from - the current table to the next table. Each entry is four bytes. */ -typedef struct { - unsigned char op; /* operation, extra bits, table bits */ - unsigned char bits; /* bits in this part of the code */ - unsigned short val; /* offset in table or code value */ -} code; - -/* op values as set by inflate_table(): - 00000000 - literal - 0000tttt - table link, tttt != 0 is the number of table index bits - 0001eeee - length or distance, eeee is the number of extra bits - 01100000 - end of block - 01000000 - invalid code - */ - -/* Maximum size of the dynamic table. The maximum number of code structures is - 1444, which is the sum of 852 for literal/length codes and 592 for distance - codes. These values were found by exhaustive searches using the program - examples/enough.c found in the zlib distribtution. The arguments to that - program are the number of symbols, the initial root table size, and the - maximum bit length of a code. "enough 286 9 15" for literal/length codes - returns returns 852, and "enough 30 6 15" for distance codes returns 592. - The initial root table size (9 or 6) is found in the fifth argument of the - inflate_table() calls in inflate.c and infback.c. If the root table size is - changed, then these maximum sizes would be need to be recalculated and - updated. */ -#define ENOUGH_LENS 852 -#define ENOUGH_DISTS 592 -#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) - -/* Type of code to build for inflate_table() */ -typedef enum { - CODES, - LENS, - DISTS -} codetype; - -int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, - unsigned codes, code FAR * FAR *table, - unsigned FAR *bits, unsigned short FAR *work)); diff --git a/libs/storm-sys/StormLib/src/zlib/trees.c b/libs/storm-sys/StormLib/src/zlib/trees.c deleted file mode 100644 index 56e9bb1..0000000 --- a/libs/storm-sys/StormLib/src/zlib/trees.c +++ /dev/null @@ -1,1244 +0,0 @@ -/* trees.c -- output deflated data using Huffman coding - * Copyright (C) 1995-2010 Jean-loup Gailly - * detect_data_type() function provided freely by Cosmin Truta, 2006 - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * ALGORITHM - * - * The "deflation" process uses several Huffman trees. The more - * common source values are represented by shorter bit sequences. - * - * Each code tree is stored in a compressed form which is itself - * a Huffman encoding of the lengths of all the code strings (in - * ascending order by source values). The actual code strings are - * reconstructed from the lengths in the inflate process, as described - * in the deflate specification. - * - * REFERENCES - * - * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification". - * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc - * - * Storer, James A. - * Data Compression: Methods and Theory, pp. 49-50. - * Computer Science Press, 1988. ISBN 0-7167-8156-5. - * - * Sedgewick, R. - * Algorithms, p290. - * Addison-Wesley, 1983. ISBN 0-201-06672-6. - */ - -/* @(#) $Id$ */ - -/* #define GEN_TREES_H */ - -#include "deflate.h" - -#ifdef DEBUG -# include -#endif - -/* =========================================================================== - * Constants - */ - -#define MAX_BL_BITS 7 -/* Bit length codes must not exceed MAX_BL_BITS bits */ - -#define END_BLOCK 256 -/* end of block literal code */ - -#define REP_3_6 16 -/* repeat previous bit length 3-6 times (2 bits of repeat count) */ - -#define REPZ_3_10 17 -/* repeat a zero length 3-10 times (3 bits of repeat count) */ - -#define REPZ_11_138 18 -/* repeat a zero length 11-138 times (7 bits of repeat count) */ - -local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */ - = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; - -local const int extra_dbits[D_CODES] /* extra bits for each distance code */ - = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; - -local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */ - = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; - -local const uch bl_order[BL_CODES] - = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; -/* The lengths of the bit length codes are sent in order of decreasing - * probability, to avoid transmitting the lengths for unused bit length codes. - */ - -#define Buf_size (8 * 2*sizeof(char)) -/* Number of bits used within bi_buf. (bi_buf might be implemented on - * more than 16 bits on some systems.) - */ - -/* =========================================================================== - * Local data. These are initialized only once. - */ - -#define DIST_CODE_LEN 512 /* see definition of array dist_code below */ - -#if defined(GEN_TREES_H) || !defined(STDC) -/* non ANSI compilers may not accept trees.h */ - -local ct_data static_ltree[L_CODES+2]; -/* The static literal tree. Since the bit lengths are imposed, there is no - * need for the L_CODES extra codes used during heap construction. However - * The codes 286 and 287 are needed to build a canonical tree (see _tr_init - * below). - */ - -local ct_data static_dtree[D_CODES]; -/* The static distance tree. (Actually a trivial tree since all codes use - * 5 bits.) - */ - -uch _dist_code[DIST_CODE_LEN]; -/* Distance codes. The first 256 values correspond to the distances - * 3 .. 258, the last 256 values correspond to the top 8 bits of - * the 15 bit distances. - */ - -uch _length_code[MAX_MATCH-MIN_MATCH+1]; -/* length code for each normalized match length (0 == MIN_MATCH) */ - -local int base_length[LENGTH_CODES]; -/* First normalized length for each code (0 = MIN_MATCH) */ - -local int base_dist[D_CODES]; -/* First normalized distance for each code (0 = distance of 1) */ - -#else -# include "trees.h" -#endif /* GEN_TREES_H */ - -struct static_tree_desc_s { - const ct_data *static_tree; /* static tree or NULL */ - const intf *extra_bits; /* extra bits for each code or NULL */ - int extra_base; /* base index for extra_bits */ - int elems; /* max number of elements in the tree */ - int max_length; /* max bit length for the codes */ -}; - -local static_tree_desc static_l_desc = -{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; - -local static_tree_desc static_d_desc = -{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; - -local static_tree_desc static_bl_desc = -{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; - -/* =========================================================================== - * Local (static) routines in this file. - */ - -local void tr_static_init OF((void)); -local void init_block OF((deflate_state *s)); -local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); -local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); -local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); -local void build_tree OF((deflate_state *s, tree_desc *desc)); -local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local int build_bl_tree OF((deflate_state *s)); -local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, - int blcodes)); -local void compress_block OF((deflate_state *s, ct_data *ltree, - ct_data *dtree)); -local int detect_data_type OF((deflate_state *s)); -local unsigned bi_reverse OF((unsigned value, int length)); -local void bi_windup OF((deflate_state *s)); -local void bi_flush OF((deflate_state *s)); -local void copy_block OF((deflate_state *s, charf *buf, unsigned len, - int header)); - -#ifdef GEN_TREES_H -local void gen_trees_header OF((void)); -#endif - -#ifndef DEBUG -# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) - /* Send a code of the given tree. c and tree must not have side effects */ - -#else /* DEBUG */ -# define send_code(s, c, tree) \ - { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ - send_bits(s, tree[c].Code, tree[c].Len); } -#endif - -/* =========================================================================== - * Output a short LSB first on the stream. - * IN assertion: there is enough room in pendingBuf. - */ -#define put_short(s, w) { \ - put_byte(s, (uch)((w) & 0xff)); \ - put_byte(s, (uch)((ush)(w) >> 8)); \ -} - -/* =========================================================================== - * Send a value on a given number of bits. - * IN assertion: length <= 16 and value fits in length bits. - */ -#ifdef DEBUG -local void send_bits OF((deflate_state *s, int value, int length)); - -local void send_bits(s, value, length) - deflate_state *s; - int value; /* value to send */ - int length; /* number of bits */ -{ - Tracevv((stderr," l %2d v %4x ", length, value)); - Assert(length > 0 && length <= 15, "invalid length"); - s->bits_sent += (ulg)length; - - /* If not enough room in bi_buf, use (valid) bits from bi_buf and - * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) - * unused bits in value. - */ - if (s->bi_valid > (int)Buf_size - length) { - s->bi_buf |= (ush)value << s->bi_valid; - put_short(s, s->bi_buf); - s->bi_buf = (ush)value >> (Buf_size - s->bi_valid); - s->bi_valid += length - Buf_size; - } else { - s->bi_buf |= (ush)value << s->bi_valid; - s->bi_valid += length; - } -} -#else /* !DEBUG */ - -#define send_bits(s, value, length) \ -{ int len = length;\ - if (s->bi_valid > (int)Buf_size - len) {\ - int val = value;\ - s->bi_buf |= (ush)val << s->bi_valid;\ - put_short(s, s->bi_buf);\ - s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\ - s->bi_valid += len - Buf_size;\ - } else {\ - s->bi_buf |= (ush)(value) << s->bi_valid;\ - s->bi_valid += len;\ - }\ -} -#endif /* DEBUG */ - - -/* the arguments must not have side effects */ - -/* =========================================================================== - * Initialize the various 'constant' tables. - */ -local void tr_static_init() -{ -#if defined(GEN_TREES_H) || !defined(STDC) - static int static_init_done = 0; - int n; /* iterates over tree elements */ - int bits; /* bit counter */ - int length; /* length value */ - int code; /* code value */ - int dist; /* distance index */ - ush bl_count[MAX_BITS+1]; - /* number of codes at each bit length for an optimal tree */ - - if (static_init_done) return; - - /* For some embedded targets, global variables are not initialized: */ -#ifdef NO_INIT_GLOBAL_POINTERS - static_l_desc.static_tree = static_ltree; - static_l_desc.extra_bits = extra_lbits; - static_d_desc.static_tree = static_dtree; - static_d_desc.extra_bits = extra_dbits; - static_bl_desc.extra_bits = extra_blbits; -#endif - - /* Initialize the mapping length (0..255) -> length code (0..28) */ - length = 0; - for (code = 0; code < LENGTH_CODES-1; code++) { - base_length[code] = length; - for (n = 0; n < (1< dist code (0..29) */ - dist = 0; - for (code = 0 ; code < 16; code++) { - base_dist[code] = dist; - for (n = 0; n < (1<>= 7; /* from now on, all distances are divided by 128 */ - for ( ; code < D_CODES; code++) { - base_dist[code] = dist << 7; - for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { - _dist_code[256 + dist++] = (uch)code; - } - } - Assert (dist == 256, "tr_static_init: 256+dist != 512"); - - /* Construct the codes of the static literal tree */ - for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; - n = 0; - while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++; - while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++; - while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++; - while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++; - /* Codes 286 and 287 do not exist, but we must include them in the - * tree construction to get a canonical Huffman tree (longest code - * all ones) - */ - gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count); - - /* The static distance tree is trivial: */ - for (n = 0; n < D_CODES; n++) { - static_dtree[n].Len = 5; - static_dtree[n].Code = bi_reverse((unsigned)n, 5); - } - static_init_done = 1; - -# ifdef GEN_TREES_H - gen_trees_header(); -# endif -#endif /* defined(GEN_TREES_H) || !defined(STDC) */ -} - -/* =========================================================================== - * Genererate the file trees.h describing the static trees. - */ -#ifdef GEN_TREES_H -# ifndef DEBUG -# include -# endif - -# define SEPARATOR(i, last, width) \ - ((i) == (last)? "\n};\n\n" : \ - ((i) % (width) == (width)-1 ? ",\n" : ", ")) - -void gen_trees_header() -{ - FILE *header = fopen("trees.h", "w"); - int i; - - Assert (header != NULL, "Can't open trees.h"); - fprintf(header, - "/* header created automatically with -DGEN_TREES_H */\n\n"); - - fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n"); - for (i = 0; i < L_CODES+2; i++) { - fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, - static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); - } - - fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n"); - for (i = 0; i < D_CODES; i++) { - fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, - static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); - } - - fprintf(header, "const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {\n"); - for (i = 0; i < DIST_CODE_LEN; i++) { - fprintf(header, "%2u%s", _dist_code[i], - SEPARATOR(i, DIST_CODE_LEN-1, 20)); - } - - fprintf(header, - "const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {\n"); - for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) { - fprintf(header, "%2u%s", _length_code[i], - SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); - } - - fprintf(header, "local const int base_length[LENGTH_CODES] = {\n"); - for (i = 0; i < LENGTH_CODES; i++) { - fprintf(header, "%1u%s", base_length[i], - SEPARATOR(i, LENGTH_CODES-1, 20)); - } - - fprintf(header, "local const int base_dist[D_CODES] = {\n"); - for (i = 0; i < D_CODES; i++) { - fprintf(header, "%5u%s", base_dist[i], - SEPARATOR(i, D_CODES-1, 10)); - } - - fclose(header); -} -#endif /* GEN_TREES_H */ - -/* =========================================================================== - * Initialize the tree data structures for a new zlib stream. - */ -void ZLIB_INTERNAL _tr_init(s) - deflate_state *s; -{ - tr_static_init(); - - s->l_desc.dyn_tree = s->dyn_ltree; - s->l_desc.stat_desc = &static_l_desc; - - s->d_desc.dyn_tree = s->dyn_dtree; - s->d_desc.stat_desc = &static_d_desc; - - s->bl_desc.dyn_tree = s->bl_tree; - s->bl_desc.stat_desc = &static_bl_desc; - - s->bi_buf = 0; - s->bi_valid = 0; - s->last_eob_len = 8; /* enough lookahead for inflate */ -#ifdef DEBUG - s->compressed_len = 0L; - s->bits_sent = 0L; -#endif - - /* Initialize the first block of the first file: */ - init_block(s); -} - -/* =========================================================================== - * Initialize a new block. - */ -local void init_block(s) - deflate_state *s; -{ - int n; /* iterates over tree elements */ - - /* Initialize the trees. */ - for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; - for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; - for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; - - s->dyn_ltree[END_BLOCK].Freq = 1; - s->opt_len = s->static_len = 0L; - s->last_lit = s->matches = 0; -} - -#define SMALLEST 1 -/* Index within the heap array of least frequent node in the Huffman tree */ - - -/* =========================================================================== - * Remove the smallest element from the heap and recreate the heap with - * one less element. Updates heap and heap_len. - */ -#define pqremove(s, tree, top) \ -{\ - top = s->heap[SMALLEST]; \ - s->heap[SMALLEST] = s->heap[s->heap_len--]; \ - pqdownheap(s, tree, SMALLEST); \ -} - -/* =========================================================================== - * Compares to subtrees, using the tree depth as tie breaker when - * the subtrees have equal frequency. This minimizes the worst case length. - */ -#define smaller(tree, n, m, depth) \ - (tree[n].Freq < tree[m].Freq || \ - (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m])) - -/* =========================================================================== - * Restore the heap property by moving down the tree starting at node k, - * exchanging a node with the smallest of its two sons if necessary, stopping - * when the heap property is re-established (each father smaller than its - * two sons). - */ -local void pqdownheap(s, tree, k) - deflate_state *s; - ct_data *tree; /* the tree to restore */ - int k; /* node to move down */ -{ - int v = s->heap[k]; - int j = k << 1; /* left son of k */ - while (j <= s->heap_len) { - /* Set j to the smallest of the two sons: */ - if (j < s->heap_len && - smaller(tree, s->heap[j+1], s->heap[j], s->depth)) { - j++; - } - /* Exit if v is smaller than both sons */ - if (smaller(tree, v, s->heap[j], s->depth)) break; - - /* Exchange v with the smallest son */ - s->heap[k] = s->heap[j]; k = j; - - /* And continue down the tree, setting j to the left son of k */ - j <<= 1; - } - s->heap[k] = v; -} - -/* =========================================================================== - * Compute the optimal bit lengths for a tree and update the total bit length - * for the current block. - * IN assertion: the fields freq and dad are set, heap[heap_max] and - * above are the tree nodes sorted by increasing frequency. - * OUT assertions: the field len is set to the optimal bit length, the - * array bl_count contains the frequencies for each bit length. - * The length opt_len is updated; static_len is also updated if stree is - * not null. - */ -local void gen_bitlen(s, desc) - deflate_state *s; - tree_desc *desc; /* the tree descriptor */ -{ - ct_data *tree = desc->dyn_tree; - int max_code = desc->max_code; - const ct_data *stree = desc->stat_desc->static_tree; - const intf *extra = desc->stat_desc->extra_bits; - int base = desc->stat_desc->extra_base; - int max_length = desc->stat_desc->max_length; - int h; /* heap index */ - int n, m; /* iterate over the tree elements */ - int bits; /* bit length */ - int xbits; /* extra bits */ - ush f; /* frequency */ - int overflow = 0; /* number of elements with bit length too large */ - - for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0; - - /* In a first pass, compute the optimal bit lengths (which may - * overflow in the case of the bit length tree). - */ - tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */ - - for (h = s->heap_max+1; h < HEAP_SIZE; h++) { - n = s->heap[h]; - bits = tree[tree[n].Dad].Len + 1; - if (bits > max_length) bits = max_length, overflow++; - tree[n].Len = (ush)bits; - /* We overwrite tree[n].Dad which is no longer needed */ - - if (n > max_code) continue; /* not a leaf node */ - - s->bl_count[bits]++; - xbits = 0; - if (n >= base) xbits = extra[n-base]; - f = tree[n].Freq; - s->opt_len += (ulg)f * (bits + xbits); - if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits); - } - if (overflow == 0) return; - - Trace((stderr,"\nbit length overflow\n")); - /* This happens for example on obj2 and pic of the Calgary corpus */ - - /* Find the first bit length which could increase: */ - do { - bits = max_length-1; - while (s->bl_count[bits] == 0) bits--; - s->bl_count[bits]--; /* move one leaf down the tree */ - s->bl_count[bits+1] += 2; /* move one overflow item as its brother */ - s->bl_count[max_length]--; - /* The brother of the overflow item also moves one step up, - * but this does not affect bl_count[max_length] - */ - overflow -= 2; - } while (overflow > 0); - - /* Now recompute all bit lengths, scanning in increasing frequency. - * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all - * lengths instead of fixing only the wrong ones. This idea is taken - * from 'ar' written by Haruhiko Okumura.) - */ - for (bits = max_length; bits != 0; bits--) { - n = s->bl_count[bits]; - while (n != 0) { - m = s->heap[--h]; - if (m > max_code) continue; - if ((unsigned) tree[m].Len != (unsigned) bits) { - Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); - s->opt_len += ((long)bits - (long)tree[m].Len) - *(long)tree[m].Freq; - tree[m].Len = (ush)bits; - } - n--; - } - } -} - -/* =========================================================================== - * Generate the codes for a given tree and bit counts (which need not be - * optimal). - * IN assertion: the array bl_count contains the bit length statistics for - * the given tree and the field len is set for all tree elements. - * OUT assertion: the field code is set for all tree elements of non - * zero code length. - */ -local void gen_codes (tree, max_code, bl_count) - ct_data *tree; /* the tree to decorate */ - int max_code; /* largest code with non zero frequency */ - ushf *bl_count; /* number of codes at each bit length */ -{ - ush next_code[MAX_BITS+1]; /* next code value for each bit length */ - ush code = 0; /* running code value */ - int bits; /* bit index */ - int n; /* code index */ - - /* The distribution counts are first used to generate the code values - * without bit reversal. - */ - for (bits = 1; bits <= MAX_BITS; bits++) { - next_code[bits] = code = (code + bl_count[bits-1]) << 1; - } - /* Check that the bit counts in bl_count are consistent. The last code - * must be all ones. - */ - Assert (code + bl_count[MAX_BITS]-1 == (1<dyn_tree; - const ct_data *stree = desc->stat_desc->static_tree; - int elems = desc->stat_desc->elems; - int n, m; /* iterate over heap elements */ - int max_code = -1; /* largest code with non zero frequency */ - int node; /* new node being created */ - - /* Construct the initial heap, with least frequent element in - * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. - * heap[0] is not used. - */ - s->heap_len = 0, s->heap_max = HEAP_SIZE; - - for (n = 0; n < elems; n++) { - if (tree[n].Freq != 0) { - s->heap[++(s->heap_len)] = max_code = n; - s->depth[n] = 0; - } else { - tree[n].Len = 0; - } - } - - /* The pkzip format requires that at least one distance code exists, - * and that at least one bit should be sent even if there is only one - * possible code. So to avoid special checks later on we force at least - * two codes of non zero frequency. - */ - while (s->heap_len < 2) { - node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0); - tree[node].Freq = 1; - s->depth[node] = 0; - s->opt_len--; if (stree) s->static_len -= stree[node].Len; - /* node is 0 or 1 so it does not have extra bits */ - } - desc->max_code = max_code; - - /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, - * establish sub-heaps of increasing lengths: - */ - for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n); - - /* Construct the Huffman tree by repeatedly combining the least two - * frequent nodes. - */ - node = elems; /* next internal node of the tree */ - do { - pqremove(s, tree, n); /* n = node of least frequency */ - m = s->heap[SMALLEST]; /* m = node of next least frequency */ - - s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */ - s->heap[--(s->heap_max)] = m; - - /* Create a new node father of n and m */ - tree[node].Freq = tree[n].Freq + tree[m].Freq; - s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ? - s->depth[n] : s->depth[m]) + 1); - tree[n].Dad = tree[m].Dad = (ush)node; -#ifdef DUMP_BL_TREE - if (tree == s->bl_tree) { - fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)", - node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); - } -#endif - /* and insert the new node in the heap */ - s->heap[SMALLEST] = node++; - pqdownheap(s, tree, SMALLEST); - - } while (s->heap_len >= 2); - - s->heap[--(s->heap_max)] = s->heap[SMALLEST]; - - /* At this point, the fields freq and dad are set. We can now - * generate the bit lengths. - */ - gen_bitlen(s, (tree_desc *)desc); - - /* The field len is now set, we can generate the bit codes */ - gen_codes ((ct_data *)tree, max_code, s->bl_count); -} - -/* =========================================================================== - * Scan a literal or distance tree to determine the frequencies of the codes - * in the bit length tree. - */ -local void scan_tree (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - int n; /* iterates over all tree elements */ - int prevlen = -1; /* last emitted length */ - int curlen; /* length of current code */ - int nextlen = tree[0].Len; /* length of next code */ - int count = 0; /* repeat count of the current code */ - int max_count = 7; /* max repeat count */ - int min_count = 4; /* min repeat count */ - - if (nextlen == 0) max_count = 138, min_count = 3; - tree[max_code+1].Len = (ush)0xffff; /* guard */ - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; - if (++count < max_count && curlen == nextlen) { - continue; - } else if (count < min_count) { - s->bl_tree[curlen].Freq += count; - } else if (curlen != 0) { - if (curlen != prevlen) s->bl_tree[curlen].Freq++; - s->bl_tree[REP_3_6].Freq++; - } else if (count <= 10) { - s->bl_tree[REPZ_3_10].Freq++; - } else { - s->bl_tree[REPZ_11_138].Freq++; - } - count = 0; prevlen = curlen; - if (nextlen == 0) { - max_count = 138, min_count = 3; - } else if (curlen == nextlen) { - max_count = 6, min_count = 3; - } else { - max_count = 7, min_count = 4; - } - } -} - -/* =========================================================================== - * Send a literal or distance tree in compressed form, using the codes in - * bl_tree. - */ -local void send_tree (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - int n; /* iterates over all tree elements */ - int prevlen = -1; /* last emitted length */ - int curlen; /* length of current code */ - int nextlen = tree[0].Len; /* length of next code */ - int count = 0; /* repeat count of the current code */ - int max_count = 7; /* max repeat count */ - int min_count = 4; /* min repeat count */ - - /* tree[max_code+1].Len = -1; */ /* guard already set */ - if (nextlen == 0) max_count = 138, min_count = 3; - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; - if (++count < max_count && curlen == nextlen) { - continue; - } else if (count < min_count) { - do { send_code(s, curlen, s->bl_tree); } while (--count != 0); - - } else if (curlen != 0) { - if (curlen != prevlen) { - send_code(s, curlen, s->bl_tree); count--; - } - Assert(count >= 3 && count <= 6, " 3_6?"); - send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2); - - } else if (count <= 10) { - send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3); - - } else { - send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7); - } - count = 0; prevlen = curlen; - if (nextlen == 0) { - max_count = 138, min_count = 3; - } else if (curlen == nextlen) { - max_count = 6, min_count = 3; - } else { - max_count = 7, min_count = 4; - } - } -} - -/* =========================================================================== - * Construct the Huffman tree for the bit lengths and return the index in - * bl_order of the last bit length code to send. - */ -local int build_bl_tree(s) - deflate_state *s; -{ - int max_blindex; /* index of last bit length code of non zero freq */ - - /* Determine the bit length frequencies for literal and distance trees */ - scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); - scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); - - /* Build the bit length tree: */ - build_tree(s, (tree_desc *)(&(s->bl_desc))); - /* opt_len now includes the length of the tree representations, except - * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. - */ - - /* Determine the number of bit length codes to send. The pkzip format - * requires that at least 4 bit length codes be sent. (appnote.txt says - * 3 but the actual value used is 4.) - */ - for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { - if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; - } - /* Update opt_len to include the bit length tree and counts */ - s->opt_len += 3*(max_blindex+1) + 5+5+4; - Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", - s->opt_len, s->static_len)); - - return max_blindex; -} - -/* =========================================================================== - * Send the header for a block using dynamic Huffman trees: the counts, the - * lengths of the bit length codes, the literal tree and the distance tree. - * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. - */ -local void send_all_trees(s, lcodes, dcodes, blcodes) - deflate_state *s; - int lcodes, dcodes, blcodes; /* number of codes for each tree */ -{ - int rank; /* index in bl_order */ - - Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); - Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, - "too many codes"); - Tracev((stderr, "\nbl counts: ")); - send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */ - send_bits(s, dcodes-1, 5); - send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */ - for (rank = 0; rank < blcodes; rank++) { - Tracev((stderr, "\nbl code %2d ", bl_order[rank])); - send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); - } - Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); - - send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */ - Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); - - send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */ - Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); -} - -/* =========================================================================== - * Send a stored block - */ -void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) - deflate_state *s; - charf *buf; /* input block */ - ulg stored_len; /* length of input block */ - int last; /* one if this is the last block for a file */ -{ - send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */ -#ifdef DEBUG - s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; - s->compressed_len += (stored_len + 4) << 3; -#endif - copy_block(s, buf, (unsigned)stored_len, 1); /* with header */ -} - -/* =========================================================================== - * Send one empty static block to give enough lookahead for inflate. - * This takes 10 bits, of which 7 may remain in the bit buffer. - * The current inflate code requires 9 bits of lookahead. If the - * last two codes for the previous block (real code plus EOB) were coded - * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode - * the last real code. In this case we send two empty static blocks instead - * of one. (There are no problems if the previous block is stored or fixed.) - * To simplify the code, we assume the worst case of last real code encoded - * on one bit only. - */ -void ZLIB_INTERNAL _tr_align(s) - deflate_state *s; -{ - send_bits(s, STATIC_TREES<<1, 3); - send_code(s, END_BLOCK, static_ltree); -#ifdef DEBUG - s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ -#endif - bi_flush(s); - /* Of the 10 bits for the empty block, we have already sent - * (10 - bi_valid) bits. The lookahead for the last real code (before - * the EOB of the previous block) was thus at least one plus the length - * of the EOB plus what we have just sent of the empty static block. - */ - if (1 + s->last_eob_len + 10 - s->bi_valid < 9) { - send_bits(s, STATIC_TREES<<1, 3); - send_code(s, END_BLOCK, static_ltree); -#ifdef DEBUG - s->compressed_len += 10L; -#endif - bi_flush(s); - } - s->last_eob_len = 7; -} - -/* =========================================================================== - * Determine the best encoding for the current block: dynamic trees, static - * trees or store, and output the encoded block to the zip file. - */ -void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) - deflate_state *s; - charf *buf; /* input block, or NULL if too old */ - ulg stored_len; /* length of input block */ - int last; /* one if this is the last block for a file */ -{ - ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ - int max_blindex = 0; /* index of last bit length code of non zero freq */ - - /* Build the Huffman trees unless a stored block is forced */ - if (s->level > 0) { - - /* Check if the file is binary or text */ - if (s->strm->data_type == Z_UNKNOWN) - s->strm->data_type = detect_data_type(s); - - /* Construct the literal and distance trees */ - build_tree(s, (tree_desc *)(&(s->l_desc))); - Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, - s->static_len)); - - build_tree(s, (tree_desc *)(&(s->d_desc))); - Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, - s->static_len)); - /* At this point, opt_len and static_len are the total bit lengths of - * the compressed block data, excluding the tree representations. - */ - - /* Build the bit length tree for the above two trees, and get the index - * in bl_order of the last bit length code to send. - */ - max_blindex = build_bl_tree(s); - - /* Determine the best encoding. Compute the block lengths in bytes. */ - opt_lenb = (s->opt_len+3+7)>>3; - static_lenb = (s->static_len+3+7)>>3; - - Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", - opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, - s->last_lit)); - - if (static_lenb <= opt_lenb) opt_lenb = static_lenb; - - } else { - Assert(buf != (char*)0, "lost buf"); - opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ - } - -#ifdef FORCE_STORED - if (buf != (char*)0) { /* force stored block */ -#else - if (stored_len+4 <= opt_lenb && buf != (char*)0) { - /* 4: two words for the lengths */ -#endif - /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. - * Otherwise we can't have processed more than WSIZE input bytes since - * the last block flush, because compression would have been - * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to - * transform a block into a stored block. - */ - _tr_stored_block(s, buf, stored_len, last); - -#ifdef FORCE_STATIC - } else if (static_lenb >= 0) { /* force static trees */ -#else - } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) { -#endif - send_bits(s, (STATIC_TREES<<1)+last, 3); - compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree); -#ifdef DEBUG - s->compressed_len += 3 + s->static_len; -#endif - } else { - send_bits(s, (DYN_TREES<<1)+last, 3); - send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, - max_blindex+1); - compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree); -#ifdef DEBUG - s->compressed_len += 3 + s->opt_len; -#endif - } - Assert (s->compressed_len == s->bits_sent, "bad compressed size"); - /* The above check is made mod 2^32, for files larger than 512 MB - * and uLong implemented on 32 bits. - */ - init_block(s); - - if (last) { - bi_windup(s); -#ifdef DEBUG - s->compressed_len += 7; /* align on byte boundary */ -#endif - } - Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, - s->compressed_len-7*last)); -} - -/* =========================================================================== - * Save the match info and tally the frequency counts. Return true if - * the current block must be flushed. - */ -int ZLIB_INTERNAL _tr_tally (s, dist, lc) - deflate_state *s; - unsigned dist; /* distance of matched string */ - unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ -{ - s->d_buf[s->last_lit] = (ush)dist; - s->l_buf[s->last_lit++] = (uch)lc; - if (dist == 0) { - /* lc is the unmatched char */ - s->dyn_ltree[lc].Freq++; - } else { - s->matches++; - /* Here, lc is the match length - MIN_MATCH */ - dist--; /* dist = match distance - 1 */ - Assert((ush)dist < (ush)MAX_DIST(s) && - (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && - (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); - - s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++; - s->dyn_dtree[d_code(dist)].Freq++; - } - -#ifdef TRUNCATE_BLOCK - /* Try to guess if it is profitable to stop the current block here */ - if ((s->last_lit & 0x1fff) == 0 && s->level > 2) { - /* Compute an upper bound for the compressed length */ - ulg out_length = (ulg)s->last_lit*8L; - ulg in_length = (ulg)((long)s->strstart - s->block_start); - int dcode; - for (dcode = 0; dcode < D_CODES; dcode++) { - out_length += (ulg)s->dyn_dtree[dcode].Freq * - (5L+extra_dbits[dcode]); - } - out_length >>= 3; - Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ", - s->last_lit, in_length, out_length, - 100L - out_length*100L/in_length)); - if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1; - } -#endif - return (s->last_lit == s->lit_bufsize-1); - /* We avoid equality with lit_bufsize because of wraparound at 64K - * on 16 bit machines and because stored blocks are restricted to - * 64K-1 bytes. - */ -} - -/* =========================================================================== - * Send the block data compressed using the given Huffman trees - */ -local void compress_block(s, ltree, dtree) - deflate_state *s; - ct_data *ltree; /* literal tree */ - ct_data *dtree; /* distance tree */ -{ - unsigned dist; /* distance of matched string */ - int lc; /* match length or unmatched char (if dist == 0) */ - unsigned lx = 0; /* running index in l_buf */ - unsigned code; /* the code to send */ - int extra; /* number of extra bits to send */ - - if (s->last_lit != 0) do { - dist = s->d_buf[lx]; - lc = s->l_buf[lx++]; - if (dist == 0) { - send_code(s, lc, ltree); /* send a literal byte */ - Tracecv(isgraph(lc), (stderr," '%c' ", lc)); - } else { - /* Here, lc is the match length - MIN_MATCH */ - code = _length_code[lc]; - send_code(s, code+LITERALS+1, ltree); /* send the length code */ - extra = extra_lbits[code]; - if (extra != 0) { - lc -= base_length[code]; - send_bits(s, lc, extra); /* send the extra length bits */ - } - dist--; /* dist is now the match distance - 1 */ - code = d_code(dist); - Assert (code < D_CODES, "bad d_code"); - - send_code(s, code, dtree); /* send the distance code */ - extra = extra_dbits[code]; - if (extra != 0) { - dist -= base_dist[code]; - send_bits(s, dist, extra); /* send the extra distance bits */ - } - } /* literal or match pair ? */ - - /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */ - Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx, - "pendingBuf overflow"); - - } while (lx < s->last_lit); - - send_code(s, END_BLOCK, ltree); - s->last_eob_len = ltree[END_BLOCK].Len; -} - -/* =========================================================================== - * Check if the data type is TEXT or BINARY, using the following algorithm: - * - TEXT if the two conditions below are satisfied: - * a) There are no non-portable control characters belonging to the - * "black list" (0..6, 14..25, 28..31). - * b) There is at least one printable character belonging to the - * "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255). - * - BINARY otherwise. - * - The following partially-portable control characters form a - * "gray list" that is ignored in this detection algorithm: - * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}). - * IN assertion: the fields Freq of dyn_ltree are set. - */ -local int detect_data_type(s) - deflate_state *s; -{ - /* black_mask is the bit mask of black-listed bytes - * set bits 0..6, 14..25, and 28..31 - * 0xf3ffc07f = binary 11110011111111111100000001111111 - */ - unsigned long black_mask = 0xf3ffc07fUL; - int n; - - /* Check for non-textual ("black-listed") bytes. */ - for (n = 0; n <= 31; n++, black_mask >>= 1) - if ((black_mask & 1) && (s->dyn_ltree[n].Freq != 0)) - return Z_BINARY; - - /* Check for textual ("white-listed") bytes. */ - if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 - || s->dyn_ltree[13].Freq != 0) - return Z_TEXT; - for (n = 32; n < LITERALS; n++) - if (s->dyn_ltree[n].Freq != 0) - return Z_TEXT; - - /* There are no "black-listed" or "white-listed" bytes: - * this stream either is empty or has tolerated ("gray-listed") bytes only. - */ - return Z_BINARY; -} - -/* =========================================================================== - * Reverse the first len bits of a code, using straightforward code (a faster - * method would use a table) - * IN assertion: 1 <= len <= 15 - */ -local unsigned bi_reverse(code, len) - unsigned code; /* the value to invert */ - int len; /* its bit length */ -{ - register unsigned res = 0; - do { - res |= code & 1; - code >>= 1, res <<= 1; - } while (--len > 0); - return res >> 1; -} - -/* =========================================================================== - * Flush the bit buffer, keeping at most 7 bits in it. - */ -local void bi_flush(s) - deflate_state *s; -{ - if (s->bi_valid == 16) { - put_short(s, s->bi_buf); - s->bi_buf = 0; - s->bi_valid = 0; - } else if (s->bi_valid >= 8) { - put_byte(s, (Byte)s->bi_buf); - s->bi_buf >>= 8; - s->bi_valid -= 8; - } -} - -/* =========================================================================== - * Flush the bit buffer and align the output on a byte boundary - */ -local void bi_windup(s) - deflate_state *s; -{ - if (s->bi_valid > 8) { - put_short(s, s->bi_buf); - } else if (s->bi_valid > 0) { - put_byte(s, (Byte)s->bi_buf); - } - s->bi_buf = 0; - s->bi_valid = 0; -#ifdef DEBUG - s->bits_sent = (s->bits_sent+7) & ~7; -#endif -} - -/* =========================================================================== - * Copy a stored block, storing first the length and its - * one's complement if requested. - */ -local void copy_block(s, buf, len, header) - deflate_state *s; - charf *buf; /* the input data */ - unsigned len; /* its length */ - int header; /* true if block header must be written */ -{ - bi_windup(s); /* align on byte boundary */ - s->last_eob_len = 8; /* enough lookahead for inflate */ - - if (header) { - put_short(s, (ush)len); - put_short(s, (ush)~len); -#ifdef DEBUG - s->bits_sent += 2*16; -#endif - } -#ifdef DEBUG - s->bits_sent += (ulg)len<<3; -#endif - while (len--) { - put_byte(s, *buf++); - } -} diff --git a/libs/storm-sys/StormLib/src/zlib/trees.h b/libs/storm-sys/StormLib/src/zlib/trees.h deleted file mode 100644 index d35639d..0000000 --- a/libs/storm-sys/StormLib/src/zlib/trees.h +++ /dev/null @@ -1,128 +0,0 @@ -/* header created automatically with -DGEN_TREES_H */ - -local const ct_data static_ltree[L_CODES+2] = { -{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, -{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, -{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, -{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, -{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, -{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, -{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, -{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, -{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, -{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, -{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, -{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, -{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, -{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, -{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, -{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, -{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, -{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, -{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, -{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, -{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, -{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, -{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, -{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, -{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, -{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, -{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, -{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, -{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, -{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, -{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, -{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, -{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, -{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, -{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, -{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, -{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, -{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, -{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, -{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, -{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, -{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, -{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, -{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, -{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, -{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, -{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, -{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, -{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, -{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, -{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, -{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, -{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, -{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, -{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, -{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, -{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, -{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} -}; - -local const ct_data static_dtree[D_CODES] = { -{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, -{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, -{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, -{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, -{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, -{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} -}; - -const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = { - 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, - 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, -10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, -11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, -12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, -13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, -13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, -18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 -}; - -const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, -13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, -17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, -19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, -21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, -22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 -}; - -local const int base_length[LENGTH_CODES] = { -0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, -64, 80, 96, 112, 128, 160, 192, 224, 0 -}; - -local const int base_dist[D_CODES] = { - 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, - 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, - 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 -}; - diff --git a/libs/storm-sys/StormLib/src/zlib/zconf.h b/libs/storm-sys/StormLib/src/zlib/zconf.h deleted file mode 100644 index 02ce56c..0000000 --- a/libs/storm-sys/StormLib/src/zlib/zconf.h +++ /dev/null @@ -1,428 +0,0 @@ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2010 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#ifndef ZCONF_H -#define ZCONF_H - -/* - * If you *really* need a unique prefix for all types and library functions, - * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. - * Even better than compiling with -DZ_PREFIX would be to use configure to set - * this permanently in zconf.h using "./configure --zprefix". - */ -#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ - -/* all linked symbols */ -# define _dist_code z__dist_code -# define _length_code z__length_code -# define _tr_align z__tr_align -# define _tr_flush_block z__tr_flush_block -# define _tr_init z__tr_init -# define _tr_stored_block z__tr_stored_block -# define _tr_tally z__tr_tally -# define adler32 z_adler32 -# define adler32_combine z_adler32_combine -# define adler32_combine64 z_adler32_combine64 -# define compress z_compress -# define compress2 z_compress2 -# define compressBound z_compressBound -# define crc32 z_crc32 -# define crc32_combine z_crc32_combine -# define crc32_combine64 z_crc32_combine64 -# define deflate z_deflate -# define deflateBound z_deflateBound -# define deflateCopy z_deflateCopy -# define deflateEnd z_deflateEnd -# define deflateInit2_ z_deflateInit2_ -# define deflateInit_ z_deflateInit_ -# define deflateParams z_deflateParams -# define deflatePrime z_deflatePrime -# define deflateReset z_deflateReset -# define deflateSetDictionary z_deflateSetDictionary -# define deflateSetHeader z_deflateSetHeader -# define deflateTune z_deflateTune -# define deflate_copyright z_deflate_copyright -# define get_crc_table z_get_crc_table -# define gz_error z_gz_error -# define gz_intmax z_gz_intmax -# define gz_strwinerror z_gz_strwinerror -# define gzbuffer z_gzbuffer -# define gzclearerr z_gzclearerr -# define gzclose z_gzclose -# define gzclose_r z_gzclose_r -# define gzclose_w z_gzclose_w -# define gzdirect z_gzdirect -# define gzdopen z_gzdopen -# define gzeof z_gzeof -# define gzerror z_gzerror -# define gzflush z_gzflush -# define gzgetc z_gzgetc -# define gzgets z_gzgets -# define gzoffset z_gzoffset -# define gzoffset64 z_gzoffset64 -# define gzopen z_gzopen -# define gzopen64 z_gzopen64 -# define gzprintf z_gzprintf -# define gzputc z_gzputc -# define gzputs z_gzputs -# define gzread z_gzread -# define gzrewind z_gzrewind -# define gzseek z_gzseek -# define gzseek64 z_gzseek64 -# define gzsetparams z_gzsetparams -# define gztell z_gztell -# define gztell64 z_gztell64 -# define gzungetc z_gzungetc -# define gzwrite z_gzwrite -# define inflate z_inflate -# define inflateBack z_inflateBack -# define inflateBackEnd z_inflateBackEnd -# define inflateBackInit_ z_inflateBackInit_ -# define inflateCopy z_inflateCopy -# define inflateEnd z_inflateEnd -# define inflateGetHeader z_inflateGetHeader -# define inflateInit2_ z_inflateInit2_ -# define inflateInit_ z_inflateInit_ -# define inflateMark z_inflateMark -# define inflatePrime z_inflatePrime -# define inflateReset z_inflateReset -# define inflateReset2 z_inflateReset2 -# define inflateSetDictionary z_inflateSetDictionary -# define inflateSync z_inflateSync -# define inflateSyncPoint z_inflateSyncPoint -# define inflateUndermine z_inflateUndermine -# define inflate_copyright z_inflate_copyright -# define inflate_fast z_inflate_fast -# define inflate_table z_inflate_table -# define uncompress z_uncompress -# define zError z_zError -# define zcalloc z_zcalloc -# define zcfree z_zcfree -# define zlibCompileFlags z_zlibCompileFlags -# define zlibVersion z_zlibVersion - -/* all zlib typedefs in zlib.h and zconf.h */ -# define Byte z_Byte -# define Bytef z_Bytef -# define alloc_func z_alloc_func -# define charf z_charf -# define free_func z_free_func -# define gzFile z_gzFile -# define gz_header z_gz_header -# define gz_headerp z_gz_headerp -# define in_func z_in_func -# define intf z_intf -# define out_func z_out_func -# define uInt z_uInt -# define uIntf z_uIntf -# define uLong z_uLong -# define uLongf z_uLongf -# define voidp z_voidp -# define voidpc z_voidpc -# define voidpf z_voidpf - -/* all zlib structs in zlib.h and zconf.h */ -# define gz_header_s z_gz_header_s -# define internal_state z_internal_state - -#endif - -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) -# define OS2 -#endif -#if defined(_WINDOWS) && !defined(WINDOWS) -# define WINDOWS -#endif -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) -# ifndef WIN32 -# define WIN32 -# endif -#endif -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) -# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) -# ifndef SYS16BIT -# define SYS16BIT -# endif -# endif -#endif - -/* - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more - * than 64k bytes at a time (needed on systems with 16-bit int). - */ -#ifdef SYS16BIT -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#ifdef __STDC_VERSION__ -# ifndef STDC -# define STDC -# endif -# if __STDC_VERSION__ >= 199901L -# ifndef STDC99 -# define STDC99 -# endif -# endif -#endif -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) -# define STDC -#endif -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) -# define STDC -#endif -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) -# define STDC -#endif -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) -# define STDC -#endif - -#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ -# define STDC -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const /* note: need a more gentle solution here */ -# endif -#endif - -/* Some Mac compilers merge all .h files incorrectly: */ -#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) -# define NO_DUMMY_DECL -#endif - -/* Maximum value for memLevel in deflateInit2 */ -#ifndef MAX_MEM_LEVEL -# ifdef MAXSEG_64K -# define MAX_MEM_LEVEL 8 -# else -# define MAX_MEM_LEVEL 9 -# endif -#endif - -/* Maximum value for windowBits in deflateInit2 and inflateInit2. - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files - * created by gzip. (Files created by minigzip can still be extracted by - * gzip.) - */ -#ifndef MAX_WBITS -# define MAX_WBITS 15 /* 32K LZ77 window */ -#endif - -/* The memory requirements for deflate are (in bytes): - (1 << (windowBits+2)) + (1 << (memLevel+9)) - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) - plus a few kilobytes for small objects. For example, if you want to reduce - the default memory requirements from 256K to 128K, compile with - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" - Of course this will generally degrade compression (there's no free lunch). - - The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus a few kilobytes - for small objects. -*/ - - /* Type declarations */ - -#ifndef OF /* function prototypes */ -# ifdef STDC -# define OF(args) args -# else -# define OF(args) () -# endif -#endif - -/* The following definitions for FAR are needed only for MSDOS mixed - * model programming (small or medium model with some far allocations). - * This was tested only with MSC; for other MSDOS compilers you may have - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, - * just define FAR to be empty. - */ -#ifdef SYS16BIT -# if defined(M_I86SM) || defined(M_I86MM) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -# endif -# if (defined(__SMALL__) || defined(__MEDIUM__)) - /* Turbo C small or medium model */ -# define SMALL_MEDIUM -# ifdef __BORLANDC__ -# define FAR _far -# else -# define FAR far -# endif -# endif -#endif - -#if defined(WINDOWS) || defined(WIN32) - /* If building or using zlib as a DLL, define ZLIB_DLL. - * This is not mandatory, but it offers a little performance increase. - */ -# ifdef ZLIB_DLL -# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) -# ifdef ZLIB_INTERNAL -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -# endif -# endif /* ZLIB_DLL */ - /* If building or using zlib with the WINAPI/WINAPIV calling convention, - * define ZLIB_WINAPI. - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. - */ -# ifdef ZLIB_WINAPI -# ifdef FAR -# undef FAR -# endif -# include - /* No need for _export, use ZLIB.DEF instead. */ - /* For complete Windows compatibility, use WINAPI, not __stdcall. */ -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR CDECL -# endif -# endif -#endif - -#if defined (__BEOS__) -# ifdef ZLIB_DLL -# ifdef ZLIB_INTERNAL -# define ZEXPORT __declspec(dllexport) -# define ZEXPORTVA __declspec(dllexport) -# else -# define ZEXPORT __declspec(dllimport) -# define ZEXPORTVA __declspec(dllimport) -# endif -# endif -#endif - -#ifndef ZEXTERN -# define ZEXTERN extern -#endif -#ifndef ZEXPORT -# define ZEXPORT -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif - -#ifndef FAR -# define FAR -#endif - -#if !defined(__MACTYPES__) -typedef unsigned char Byte; /* 8 bits */ -#endif -typedef unsigned int uInt; /* 16 bits or more */ -typedef unsigned long uLong; /* 32 bits or more */ - -#ifdef SMALL_MEDIUM - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ -# define Bytef Byte FAR -#else - typedef Byte FAR Bytef; -#endif -typedef char FAR charf; -typedef int FAR intf; -typedef uInt FAR uIntf; -typedef uLong FAR uLongf; - -#ifdef STDC - typedef void const *voidpc; - typedef void FAR *voidpf; - typedef void *voidp; -#else - typedef Byte const *voidpc; - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - -#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ -# define Z_HAVE_UNISTD_H -#endif - -#ifdef STDC -# include /* for off_t */ -#endif - -/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and - * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even - * though the former does not conform to the LFS document), but considering - * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as - * equivalently requesting no 64-bit operations - */ -#if -_LARGEFILE64_SOURCE - -1 == 1 -# undef _LARGEFILE64_SOURCE -#endif - -#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) -# include /* for SEEK_* and off_t */ -# ifdef VMS -# include /* for off_t */ -# endif -# ifndef z_off_t -# define z_off_t off_t -# endif -#endif - -#ifndef SEEK_SET -# define SEEK_SET 0 /* Seek from beginning of file. */ -# define SEEK_CUR 1 /* Seek from current position. */ -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ -#endif - -#ifndef z_off_t -# define z_off_t long -#endif - -#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 -# define z_off64_t off64_t -#else -# define z_off64_t z_off_t -#endif - -#if defined(__OS400__) -# define NO_vsnprintf -#endif - -#if defined(__MVS__) -# define NO_vsnprintf -#endif - -/* MVS linker does not support external names larger than 8 bytes */ -#if defined(__MVS__) - #pragma map(deflateInit_,"DEIN") - #pragma map(deflateInit2_,"DEIN2") - #pragma map(deflateEnd,"DEEND") - #pragma map(deflateBound,"DEBND") - #pragma map(inflateInit_,"ININ") - #pragma map(inflateInit2_,"ININ2") - #pragma map(inflateEnd,"INEND") - #pragma map(inflateSync,"INSY") - #pragma map(inflateSetDictionary,"INSEDI") - #pragma map(compressBound,"CMBND") - #pragma map(inflate_table,"INTABL") - #pragma map(inflate_fast,"INFA") - #pragma map(inflate_copyright,"INCOPY") -#endif - -#endif /* ZCONF_H */ diff --git a/libs/storm-sys/StormLib/src/zlib/zlib.h b/libs/storm-sys/StormLib/src/zlib/zlib.h deleted file mode 100644 index bfbba83..0000000 --- a/libs/storm-sys/StormLib/src/zlib/zlib.h +++ /dev/null @@ -1,1613 +0,0 @@ -/* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.5, April 19th, 2010 - - Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - - - The data format used by the zlib library is described by RFCs (Request for - Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt - (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). -*/ - -#ifndef ZLIB_H -#define ZLIB_H - -#include "zconf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ZLIB_VERSION "1.2.5" -#define ZLIB_VERNUM 0x1250 -#define ZLIB_VER_MAJOR 1 -#define ZLIB_VER_MINOR 2 -#define ZLIB_VER_REVISION 5 -#define ZLIB_VER_SUBREVISION 0 - -/* - The 'zlib' compression library provides in-memory compression and - decompression functions, including integrity checks of the uncompressed data. - This version of the library supports only one compression method (deflation) - but other algorithms will be added later and will have the same stream - interface. - - Compression can be done in a single step if the buffers are large enough, - or can be done by repeated calls of the compression function. In the latter - case, the application must provide more input and/or consume the output - (providing more output space) before each call. - - The compressed data format used by default by the in-memory functions is - the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped - around a deflate stream, which is itself documented in RFC 1951. - - The library also supports reading and writing files in gzip (.gz) format - with an interface similar to that of stdio using the functions that start - with "gz". The gzip format is different from the zlib format. gzip is a - gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. - - This library can optionally read and write gzip streams in memory as well. - - The zlib format was designed to be compact and fast for use in memory - and on communications channels. The gzip format was designed for single- - file compression on file systems, has a larger header than zlib to maintain - directory information, and uses a different, slower check method than zlib. - - The library does not install any signal handler. The decoder checks - the consistency of the compressed data, so the library should never crash - even in case of corrupted input. -*/ - -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); - -struct internal_state; - -typedef struct z_stream_s { - Bytef *next_in; /* next input byte */ - uInt avail_in; /* number of bytes available at next_in */ - uLong total_in; /* total nb of input bytes read so far */ - - Bytef *next_out; /* next output byte should be put there */ - uInt avail_out; /* remaining free space at next_out */ - uLong total_out; /* total nb of bytes output so far */ - - char *msg; /* last error message, NULL if no error */ - struct internal_state FAR *state; /* not visible by applications */ - - alloc_func zalloc; /* used to allocate the internal state */ - free_func zfree; /* used to free the internal state */ - voidpf opaque; /* private data object passed to zalloc and zfree */ - - int data_type; /* best guess about the data type: binary or text */ - uLong adler; /* adler32 value of the uncompressed data */ - uLong reserved; /* reserved for future use */ -} z_stream; - -typedef z_stream FAR *z_streamp; - -/* - gzip header information passed to and from zlib routines. See RFC 1952 - for more details on the meanings of these fields. -*/ -typedef struct gz_header_s { - int text; /* true if compressed data believed to be text */ - uLong time; /* modification time */ - int xflags; /* extra flags (not used when writing a gzip file) */ - int os; /* operating system */ - Bytef *extra; /* pointer to extra field or Z_NULL if none */ - uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ - uInt extra_max; /* space at extra (only when reading header) */ - Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ - uInt name_max; /* space at name (only when reading header) */ - Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ - uInt comm_max; /* space at comment (only when reading header) */ - int hcrc; /* true if there was or will be a header crc */ - int done; /* true when done reading gzip header (not used - when writing a gzip file) */ -} gz_header; - -typedef gz_header FAR *gz_headerp; - -/* - The application must update next_in and avail_in when avail_in has dropped - to zero. It must update next_out and avail_out when avail_out has dropped - to zero. The application must initialize zalloc, zfree and opaque before - calling the init function. All other fields are set by the compression - library and must not be updated by the application. - - The opaque value provided by the application will be passed as the first - parameter for calls of zalloc and zfree. This can be useful for custom - memory management. The compression library attaches no meaning to the - opaque value. - - zalloc must return Z_NULL if there is not enough memory for the object. - If zlib is used in a multi-threaded application, zalloc and zfree must be - thread safe. - - On 16-bit systems, the functions zalloc and zfree must be able to allocate - exactly 65536 bytes, but will not be required to allocate more than this if - the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers - returned by zalloc for objects of exactly 65536 bytes *must* have their - offset normalized to zero. The default allocation function provided by this - library ensures this (see zutil.c). To reduce memory requirements and avoid - any allocation of 64K objects, at the expense of compression ratio, compile - the library with -DMAX_WBITS=14 (see zconf.h). - - The fields total_in and total_out can be used for statistics or progress - reports. After compression, total_in holds the total size of the - uncompressed data and may be saved for use in the decompressor (particularly - if the decompressor wants to decompress everything in a single step). -*/ - - /* constants */ - -#define Z_NO_FLUSH 0 -#define Z_PARTIAL_FLUSH 1 -#define Z_SYNC_FLUSH 2 -#define Z_FULL_FLUSH 3 -#define Z_FINISH 4 -#define Z_BLOCK 5 -#define Z_TREES 6 -/* Allowed flush values; see deflate() and inflate() below for details */ - -#define Z_OK 0 -#define Z_STREAM_END 1 -#define Z_NEED_DICT 2 -#define Z_ERRNO (-1) -#define Z_STREAM_ERROR (-2) -#define Z_DATA_ERROR (-3) -#define Z_MEM_ERROR (-4) -#define Z_BUF_ERROR (-5) -#define Z_VERSION_ERROR (-6) -/* Return codes for the compression/decompression functions. Negative values - * are errors, positive values are used for special but normal events. - */ - -#define Z_NO_COMPRESSION 0 -#define Z_BEST_SPEED 1 -#define Z_BEST_COMPRESSION 9 -#define Z_DEFAULT_COMPRESSION (-1) -/* compression levels */ - -#define Z_FILTERED 1 -#define Z_HUFFMAN_ONLY 2 -#define Z_RLE 3 -#define Z_FIXED 4 -#define Z_DEFAULT_STRATEGY 0 -/* compression strategy; see deflateInit2() below for details */ - -#define Z_BINARY 0 -#define Z_TEXT 1 -#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ -#define Z_UNKNOWN 2 -/* Possible values of the data_type field (though see inflate()) */ - -#define Z_DEFLATED 8 -/* The deflate compression method (the only one supported in this version) */ - -#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ - -#define zlib_version zlibVersion() -/* for compatibility with versions < 1.0.2 */ - - - /* basic functions */ - -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); -/* The application can compare zlibVersion and ZLIB_VERSION for consistency. - If the first character differs, the library code actually used is not - compatible with the zlib.h header file used by the application. This check - is automatically made by deflateInit and inflateInit. - */ - -/* -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); - - Initializes the internal stream state for compression. The fields - zalloc, zfree and opaque must be initialized before by the caller. If - zalloc and zfree are set to Z_NULL, deflateInit updates them to use default - allocation functions. - - The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: - 1 gives best speed, 9 gives best compression, 0 gives no compression at all - (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION - requests a default compromise between speed and compression (currently - equivalent to level 6). - - deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if level is not a valid compression level, or - Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible - with the version assumed by the caller (ZLIB_VERSION). msg is set to null - if there is no error message. deflateInit does not perform any compression: - this will be done by deflate(). -*/ - - -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); -/* - deflate compresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. deflate performs one or both of the - following actions: - - - Compress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in and avail_in are updated and - processing will resume at this point for the next call of deflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. This action is forced if the parameter flush is non zero. - Forcing flush frequently degrades the compression ratio, so this parameter - should be set only when necessary (in interactive applications). Some - output may be provided even if flush is not set. - - Before the call of deflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming more - output, and updating avail_in or avail_out accordingly; avail_out should - never be zero before the call. The application can consume the compressed - output when it wants, for example when the output buffer is full (avail_out - == 0), or after each call of deflate(). If deflate returns Z_OK and with - zero avail_out, it must be called again after making room in the output - buffer because there might be more output pending. - - Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to - decide how much data to accumulate before producing output, in order to - maximize compression. - - If the parameter flush is set to Z_SYNC_FLUSH, all pending output is - flushed to the output buffer and the output is aligned on a byte boundary, so - that the decompressor can get all input data available so far. (In - particular avail_in is zero after the call if enough output space has been - provided before the call.) Flushing may degrade compression for some - compression algorithms and so it should be used only when necessary. This - completes the current deflate block and follows it with an empty stored block - that is three bits plus filler bits to the next byte, followed by four bytes - (00 00 ff ff). - - If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the - output buffer, but the output is not aligned to a byte boundary. All of the - input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. - This completes the current deflate block and follows it with an empty fixed - codes block that is 10 bits long. This assures that enough bytes are output - in order for the decompressor to finish the block before the empty fixed code - block. - - If flush is set to Z_BLOCK, a deflate block is completed and emitted, as - for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to - seven bits of the current block are held to be written as the next byte after - the next deflate block is completed. In this case, the decompressor may not - be provided enough bits at this point in order to complete decompression of - the data provided so far to the compressor. It may need to wait for the next - block to be emitted. This is for advanced applications that need to control - the emission of deflate blocks. - - If flush is set to Z_FULL_FLUSH, all output is flushed as with - Z_SYNC_FLUSH, and the compression state is reset so that decompression can - restart from this point if previous compressed data has been damaged or if - random access is desired. Using Z_FULL_FLUSH too often can seriously degrade - compression. - - If deflate returns with avail_out == 0, this function must be called again - with the same value of the flush parameter and more output space (updated - avail_out), until the flush is complete (deflate returns with non-zero - avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that - avail_out is greater than six to avoid repeated flush markers due to - avail_out == 0 on return. - - If the parameter flush is set to Z_FINISH, pending input is processed, - pending output is flushed and deflate returns with Z_STREAM_END if there was - enough output space; if deflate returns with Z_OK, this function must be - called again with Z_FINISH and more output space (updated avail_out) but no - more input data, until it returns with Z_STREAM_END or an error. After - deflate has returned Z_STREAM_END, the only possible operations on the stream - are deflateReset or deflateEnd. - - Z_FINISH can be used immediately after deflateInit if all the compression - is to be done in a single step. In this case, avail_out must be at least the - value returned by deflateBound (see below). If deflate does not return - Z_STREAM_END, then it must be called again as described above. - - deflate() sets strm->adler to the adler32 checksum of all input read - so far (that is, total_in bytes). - - deflate() may update strm->data_type if it can make a good guess about - the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered - binary. This field is only for information purposes and does not affect the - compression algorithm in any manner. - - deflate() returns Z_OK if some progress has been made (more input - processed or more output produced), Z_STREAM_END if all input has been - consumed and all output has been produced (only when flush is set to - Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example - if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible - (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not - fatal, and deflate() can be called again with more input and more output - space to continue compressing. -*/ - - -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any pending - output. - - deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the - stream state was inconsistent, Z_DATA_ERROR if the stream was freed - prematurely (some input or output was discarded). In the error case, msg - may be set but then points to a static string (which must not be - deallocated). -*/ - - -/* -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); - - Initializes the internal stream state for decompression. The fields - next_in, avail_in, zalloc, zfree and opaque must be initialized before by - the caller. If next_in is not Z_NULL and avail_in is large enough (the - exact value depends on the compression method), inflateInit determines the - compression method from the zlib header and allocates all data structures - accordingly; otherwise the allocation will be deferred to the first call of - inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to - use default allocation functions. - - inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller, or Z_STREAM_ERROR if the parameters are - invalid, such as a null pointer to the structure. msg is set to null if - there is no error message. inflateInit does not perform any decompression - apart from possibly reading the zlib header if present: actual decompression - will be done by inflate(). (So next_in and avail_in may be modified, but - next_out and avail_out are unused and unchanged.) The current implementation - of inflateInit() does not process any header information -- that is deferred - until inflate() is called. -*/ - - -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); -/* - inflate decompresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. inflate performs one or both of the - following actions: - - - Decompress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in is updated and processing will - resume at this point for the next call of inflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. inflate() provides as much output as possible, until there is - no more input data or no more space in the output buffer (see below about - the flush parameter). - - Before the call of inflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming more - output, and updating the next_* and avail_* values accordingly. The - application can consume the uncompressed output when it wants, for example - when the output buffer is full (avail_out == 0), or after each call of - inflate(). If inflate returns Z_OK and with zero avail_out, it must be - called again after making room in the output buffer because there might be - more output pending. - - The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, - Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much - output as possible to the output buffer. Z_BLOCK requests that inflate() - stop if and when it gets to the next deflate block boundary. When decoding - the zlib or gzip format, this will cause inflate() to return immediately - after the header and before the first block. When doing a raw inflate, - inflate() will go ahead and process the first block, and will return when it - gets to the end of that block, or when it runs out of data. - - The Z_BLOCK option assists in appending to or combining deflate streams. - Also to assist in this, on return inflate() will set strm->data_type to the - number of unused bits in the last byte taken from strm->next_in, plus 64 if - inflate() is currently decoding the last block in the deflate stream, plus - 128 if inflate() returned immediately after decoding an end-of-block code or - decoding the complete header up to just before the first byte of the deflate - stream. The end-of-block will not be indicated until all of the uncompressed - data from that block has been written to strm->next_out. The number of - unused bits may in general be greater than seven, except when bit 7 of - data_type is set, in which case the number of unused bits will be less than - eight. data_type is set as noted here every time inflate() returns for all - flush options, and so can be used to determine the amount of currently - consumed input in bits. - - The Z_TREES option behaves as Z_BLOCK does, but it also returns when the - end of each deflate block header is reached, before any actual data in that - block is decoded. This allows the caller to determine the length of the - deflate block header for later use in random access within a deflate block. - 256 is added to the value of strm->data_type when inflate() returns - immediately after reaching the end of the deflate block header. - - inflate() should normally be called until it returns Z_STREAM_END or an - error. However if all decompression is to be performed in a single step (a - single call of inflate), the parameter flush should be set to Z_FINISH. In - this case all pending input is processed and all pending output is flushed; - avail_out must be large enough to hold all the uncompressed data. (The size - of the uncompressed data may have been saved by the compressor for this - purpose.) The next operation on this stream must be inflateEnd to deallocate - the decompression state. The use of Z_FINISH is never required, but can be - used to inform inflate that a faster approach may be used for the single - inflate() call. - - In this implementation, inflate() always flushes as much output as - possible to the output buffer, and always uses the faster approach on the - first call. So the only effect of the flush parameter in this implementation - is on the return value of inflate(), as noted below, or when it returns early - because Z_BLOCK or Z_TREES is used. - - If a preset dictionary is needed after this call (see inflateSetDictionary - below), inflate sets strm->adler to the adler32 checksum of the dictionary - chosen by the compressor and returns Z_NEED_DICT; otherwise it sets - strm->adler to the adler32 checksum of all output produced so far (that is, - total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described - below. At the end of the stream, inflate() checks that its computed adler32 - checksum is equal to that saved by the compressor and returns Z_STREAM_END - only if the checksum is correct. - - inflate() can decompress and check either zlib-wrapped or gzip-wrapped - deflate data. The header type is detected automatically, if requested when - initializing with inflateInit2(). Any information contained in the gzip - header is not retained, so applications that need that information should - instead use raw inflate, see inflateInit2() below, or inflateBack() and - perform their own processing of the gzip header and trailer. - - inflate() returns Z_OK if some progress has been made (more input processed - or more output produced), Z_STREAM_END if the end of the compressed data has - been reached and all uncompressed output has been produced, Z_NEED_DICT if a - preset dictionary is needed at this point, Z_DATA_ERROR if the input data was - corrupted (input stream not conforming to the zlib format or incorrect check - value), Z_STREAM_ERROR if the stream structure was inconsistent (for example - next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory, - Z_BUF_ERROR if no progress is possible or if there was not enough room in the - output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and - inflate() can be called again with more input and more output space to - continue decompressing. If Z_DATA_ERROR is returned, the application may - then call inflateSync() to look for a good compression block if a partial - recovery of the data is desired. -*/ - - -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any pending - output. - - inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state - was inconsistent. In the error case, msg may be set but then points to a - static string (which must not be deallocated). -*/ - - - /* Advanced functions */ - -/* - The following functions are needed only in some special applications. -*/ - -/* -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); - - This is another version of deflateInit with more compression options. The - fields next_in, zalloc, zfree and opaque must be initialized before by the - caller. - - The method parameter is the compression method. It must be Z_DEFLATED in - this version of the library. - - The windowBits parameter is the base two logarithm of the window size - (the size of the history buffer). It should be in the range 8..15 for this - version of the library. Larger values of this parameter result in better - compression at the expense of memory usage. The default value is 15 if - deflateInit is used instead. - - windowBits can also be -8..-15 for raw deflate. In this case, -windowBits - determines the window size. deflate() will then generate raw deflate data - with no zlib header or trailer, and will not compute an adler32 check value. - - windowBits can also be greater than 15 for optional gzip encoding. Add - 16 to windowBits to write a simple gzip header and trailer around the - compressed data instead of a zlib wrapper. The gzip header will have no - file name, no extra data, no comment, no modification time (set to zero), no - header crc, and the operating system will be set to 255 (unknown). If a - gzip stream is being written, strm->adler is a crc32 instead of an adler32. - - The memLevel parameter specifies how much memory should be allocated - for the internal compression state. memLevel=1 uses minimum memory but is - slow and reduces compression ratio; memLevel=9 uses maximum memory for - optimal speed. The default value is 8. See zconf.h for total memory usage - as a function of windowBits and memLevel. - - The strategy parameter is used to tune the compression algorithm. Use the - value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a - filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match), or Z_RLE to limit match distances to one (run-length - encoding). Filtered data consists mostly of small values with a somewhat - random distribution. In this case, the compression algorithm is tuned to - compress them better. The effect of Z_FILTERED is to force more Huffman - coding and less string matching; it is somewhat intermediate between - Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as - fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The - strategy parameter only affects the compression ratio but not the - correctness of the compressed output even if it is not set appropriately. - Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler - decoder for special applications. - - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid - method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is - incompatible with the version assumed by the caller (ZLIB_VERSION). msg is - set to null if there is no error message. deflateInit2 does not perform any - compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the compression dictionary from the given byte sequence - without producing any compressed output. This function must be called - immediately after deflateInit, deflateInit2 or deflateReset, before any call - of deflate. The compressor and decompressor must use exactly the same - dictionary (see inflateSetDictionary). - - The dictionary should consist of strings (byte sequences) that are likely - to be encountered later in the data to be compressed, with the most commonly - used strings preferably put towards the end of the dictionary. Using a - dictionary is most useful when the data to be compressed is short and can be - predicted with good accuracy; the data can then be compressed better than - with the default empty dictionary. - - Depending on the size of the compression data structures selected by - deflateInit or deflateInit2, a part of the dictionary may in effect be - discarded, for example if the dictionary is larger than the window size - provided in deflateInit or deflateInit2. Thus the strings most likely to be - useful should be put at the end of the dictionary, not at the front. In - addition, the current implementation of deflate will use at most the window - size minus 262 bytes of the provided dictionary. - - Upon return of this function, strm->adler is set to the adler32 value - of the dictionary; the decompressor may later use this value to determine - which dictionary has been used by the compressor. (The adler32 value - applies to the whole dictionary even if only a subset of the dictionary is - actually used by the compressor.) If a raw deflate was requested, then the - adler32 value is not computed and strm->adler is not set. - - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is - inconsistent (for example if deflate has already been called for this stream - or if the compression method is bsort). deflateSetDictionary does not - perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when several compression strategies will be - tried, for example when there are several ways of pre-processing the input - data with a filter. The streams that will be discarded should then be freed - by calling deflateEnd. Note that deflateCopy duplicates the internal - compression state which can be quite large, so this strategy is slow and can - consume lots of memory. - - deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being Z_NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); -/* - This function is equivalent to deflateEnd followed by deflateInit, - but does not free and reallocate all the internal compression state. The - stream will keep the same compression level and any other attributes that - may have been set by deflateInit2. - - deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL). -*/ - -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); -/* - Dynamically update the compression level and compression strategy. The - interpretation of level and strategy is as in deflateInit2. This can be - used to switch between compression and straight copy of the input data, or - to switch to a different kind of input data requiring a different strategy. - If the compression level is changed, the input available so far is - compressed with the old level (and may be flushed); the new level will take - effect only at the next call of deflate(). - - Before the call of deflateParams, the stream state must be set as for - a call of deflate(), since the currently available input may have to be - compressed and flushed. In particular, strm->avail_out must be non-zero. - - deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source - stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if - strm->avail_out was zero. -*/ - -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, - int good_length, - int max_lazy, - int nice_length, - int max_chain)); -/* - Fine tune deflate's internal compression parameters. This should only be - used by someone who understands the algorithm used by zlib's deflate for - searching for the best matching string, and even then only by the most - fanatic optimizer trying to squeeze out the last compressed bit for their - specific input data. Read the deflate.c source code for the meaning of the - max_lazy, good_length, nice_length, and max_chain parameters. - - deflateTune() can be called after deflateInit() or deflateInit2(), and - returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. - */ - -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, - uLong sourceLen)); -/* - deflateBound() returns an upper bound on the compressed size after - deflation of sourceLen bytes. It must be called after deflateInit() or - deflateInit2(), and after deflateSetHeader(), if used. This would be used - to allocate an output buffer for deflation in a single pass, and so would be - called before deflate(). -*/ - -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - deflatePrime() inserts bits in the deflate output stream. The intent - is that this function is used to start off the deflate output with the bits - leftover from a previous deflate stream when appending to it. As such, this - function can only be used for raw deflate, and must be used before the first - deflate() call after a deflateInit2() or deflateReset(). bits must be less - than or equal to 16, and that many of the least significant bits of value - will be inserted in the output. - - deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, - gz_headerp head)); -/* - deflateSetHeader() provides gzip header information for when a gzip - stream is requested by deflateInit2(). deflateSetHeader() may be called - after deflateInit2() or deflateReset() and before the first call of - deflate(). The text, time, os, extra field, name, and comment information - in the provided gz_header structure are written to the gzip header (xflag is - ignored -- the extra flags are set according to the compression level). The - caller must assure that, if not Z_NULL, name and comment are terminated with - a zero byte, and that if extra is not Z_NULL, that extra_len bytes are - available there. If hcrc is true, a gzip header crc is included. Note that - the current versions of the command-line version of gzip (up through version - 1.3.x) do not support header crc's, and will report that it is a "multi-part - gzip file" and give up. - - If deflateSetHeader is not used, the default gzip header has text false, - the time set to zero, and os set to 255, with no extra, name, or comment - fields. The gzip header is returned to the default state by deflateReset(). - - deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); - - This is another version of inflateInit with an extra parameter. The - fields next_in, avail_in, zalloc, zfree and opaque must be initialized - before by the caller. - - The windowBits parameter is the base two logarithm of the maximum window - size (the size of the history buffer). It should be in the range 8..15 for - this version of the library. The default value is 15 if inflateInit is used - instead. windowBits must be greater than or equal to the windowBits value - provided to deflateInit2() while compressing, or it must be equal to 15 if - deflateInit2() was not used. If a compressed stream with a larger window - size is given as input, inflate() will return with the error code - Z_DATA_ERROR instead of trying to allocate a larger window. - - windowBits can also be zero to request that inflate use the window size in - the zlib header of the compressed stream. - - windowBits can also be -8..-15 for raw inflate. In this case, -windowBits - determines the window size. inflate() will then process raw deflate data, - not looking for a zlib or gzip header, not generating a check value, and not - looking for any check values for comparison at the end of the stream. This - is for use with other formats that use the deflate compressed data format - such as zip. Those formats provide their own check values. If a custom - format is developed using the raw deflate format for compressed data, it is - recommended that a check value such as an adler32 or a crc32 be applied to - the uncompressed data as is done in the zlib, gzip, and zip formats. For - most applications, the zlib format should be used as is. Note that comments - above on the use in deflateInit2() applies to the magnitude of windowBits. - - windowBits can also be greater than 15 for optional gzip decoding. Add - 32 to windowBits to enable zlib and gzip decoding with automatic header - detection, or add 16 to decode only the gzip format (the zlib format will - return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a - crc32 instead of an adler32. - - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller, or Z_STREAM_ERROR if the parameters are - invalid, such as a null pointer to the structure. msg is set to null if - there is no error message. inflateInit2 does not perform any decompression - apart from possibly reading the zlib header if present: actual decompression - will be done by inflate(). (So next_in and avail_in may be modified, but - next_out and avail_out are unused and unchanged.) The current implementation - of inflateInit2() does not process any header information -- that is - deferred until inflate() is called. -*/ - -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the decompression dictionary from the given uncompressed byte - sequence. This function must be called immediately after a call of inflate, - if that call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the adler32 value returned by that call of inflate. - The compressor and decompressor must use exactly the same dictionary (see - deflateSetDictionary). For raw inflate, this function can be called - immediately after inflateInit2() or inflateReset() and before any call of - inflate() to set the dictionary. The application must insure that the - dictionary that was used for compression is provided. - - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a - parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is - inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the - expected one (incorrect adler32 value). inflateSetDictionary does not - perform any decompression: this will be done by subsequent calls of - inflate(). -*/ - -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); -/* - Skips invalid compressed data until a full flush point (see above the - description of deflate with Z_FULL_FLUSH) can be found, or until all - available input is skipped. No output is provided. - - inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR - if no more input was provided, Z_DATA_ERROR if no flush point has been - found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the - success case, the application may save the current current value of total_in - which indicates where valid compressed data was found. In the error case, - the application may repeatedly call inflateSync, providing more input each - time, until success or end of the input data. -*/ - -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when randomly accessing a large stream. The - first pass through the stream can periodically record the inflate state, - allowing restarting inflate at those points when randomly accessing the - stream. - - inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being Z_NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); -/* - This function is equivalent to inflateEnd followed by inflateInit, - but does not free and reallocate all the internal decompression state. The - stream will keep attributes that may have been set by inflateInit2. - - inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL). -*/ - -ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, - int windowBits)); -/* - This function is the same as inflateReset, but it also permits changing - the wrap and window size requests. The windowBits parameter is interpreted - the same as it is for inflateInit2. - - inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL), or if - the windowBits parameter is invalid. -*/ - -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - This function inserts bits in the inflate input stream. The intent is - that this function is used to start inflating at a bit position in the - middle of a byte. The provided bits will be used before any bytes are used - from next_in. This function should only be used with raw inflate, and - should be used before the first inflate() call after inflateInit2() or - inflateReset(). bits must be less than or equal to 16, and that many of the - least significant bits of value will be inserted in the input. - - If bits is negative, then the input stream bit buffer is emptied. Then - inflatePrime() can be called again to put bits in the buffer. This is used - to clear out bits leftover after feeding inflate a block description prior - to feeding inflate codes. - - inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); -/* - This function returns two values, one in the lower 16 bits of the return - value, and the other in the remaining upper bits, obtained by shifting the - return value down 16 bits. If the upper value is -1 and the lower value is - zero, then inflate() is currently decoding information outside of a block. - If the upper value is -1 and the lower value is non-zero, then inflate is in - the middle of a stored block, with the lower value equaling the number of - bytes from the input remaining to copy. If the upper value is not -1, then - it is the number of bits back from the current bit position in the input of - the code (literal or length/distance pair) currently being processed. In - that case the lower value is the number of bytes already emitted for that - code. - - A code is being processed if inflate is waiting for more input to complete - decoding of the code, or if it has completed decoding but is waiting for - more output space to write the literal or match data. - - inflateMark() is used to mark locations in the input data for random - access, which may be at bit positions, and to note those cases where the - output of a code may span boundaries of random access blocks. The current - location in the input stream can be determined from avail_in and data_type - as noted in the description for the Z_BLOCK flush parameter for inflate. - - inflateMark returns the value noted above or -1 << 16 if the provided - source stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, - gz_headerp head)); -/* - inflateGetHeader() requests that gzip header information be stored in the - provided gz_header structure. inflateGetHeader() may be called after - inflateInit2() or inflateReset(), and before the first call of inflate(). - As inflate() processes the gzip stream, head->done is zero until the header - is completed, at which time head->done is set to one. If a zlib stream is - being decoded, then head->done is set to -1 to indicate that there will be - no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be - used to force inflate() to return immediately after header processing is - complete and before any actual data is decompressed. - - The text, time, xflags, and os fields are filled in with the gzip header - contents. hcrc is set to true if there is a header CRC. (The header CRC - was valid if done is set to one.) If extra is not Z_NULL, then extra_max - contains the maximum number of bytes to write to extra. Once done is true, - extra_len contains the actual extra field length, and extra contains the - extra field, or that field truncated if extra_max is less than extra_len. - If name is not Z_NULL, then up to name_max characters are written there, - terminated with a zero unless the length is greater than name_max. If - comment is not Z_NULL, then up to comm_max characters are written there, - terminated with a zero unless the length is greater than comm_max. When any - of extra, name, or comment are not Z_NULL and the respective field is not - present in the header, then that field is set to Z_NULL to signal its - absence. This allows the use of deflateSetHeader() with the returned - structure to duplicate the header. However if those fields are set to - allocated memory, then the application will need to save those pointers - elsewhere so that they can be eventually freed. - - If inflateGetHeader is not used, then the header information is simply - discarded. The header is always checked for validity, including the header - CRC if present. inflateReset() will reset the process to discard the header - information. The application would need to call inflateGetHeader() again to - retrieve the header from the next gzip stream. - - inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, - unsigned char FAR *window)); - - Initialize the internal stream state for decompression using inflateBack() - calls. The fields zalloc, zfree and opaque in strm must be initialized - before the call. If zalloc and zfree are Z_NULL, then the default library- - derived memory allocation routines are used. windowBits is the base two - logarithm of the window size, in the range 8..15. window is a caller - supplied buffer of that size. Except for special applications where it is - assured that deflate was used with small window sizes, windowBits must be 15 - and a 32K byte window must be supplied to be able to decompress general - deflate streams. - - See inflateBack() for the usage of these routines. - - inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of - the paramaters are invalid, Z_MEM_ERROR if the internal state could not be - allocated, or Z_VERSION_ERROR if the version of the library does not match - the version of the header file. -*/ - -typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); - -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, - in_func in, void FAR *in_desc, - out_func out, void FAR *out_desc)); -/* - inflateBack() does a raw inflate with a single call using a call-back - interface for input and output. This is more efficient than inflate() for - file i/o applications in that it avoids copying between the output and the - sliding window by simply making the window itself the output buffer. This - function trusts the application to not change the output buffer passed by - the output function, at least until inflateBack() returns. - - inflateBackInit() must be called first to allocate the internal state - and to initialize the state with the user-provided window buffer. - inflateBack() may then be used multiple times to inflate a complete, raw - deflate stream with each call. inflateBackEnd() is then called to free the - allocated state. - - A raw deflate stream is one with no zlib or gzip header or trailer. - This routine would normally be used in a utility that reads zip or gzip - files and writes out uncompressed files. The utility would decode the - header and process the trailer on its own, hence this routine expects only - the raw deflate stream to decompress. This is different from the normal - behavior of inflate(), which expects either a zlib or gzip header and - trailer around the deflate stream. - - inflateBack() uses two subroutines supplied by the caller that are then - called by inflateBack() for input and output. inflateBack() calls those - routines until it reads a complete deflate stream and writes out all of the - uncompressed data, or until it encounters an error. The function's - parameters and return types are defined above in the in_func and out_func - typedefs. inflateBack() will call in(in_desc, &buf) which should return the - number of bytes of provided input, and a pointer to that input in buf. If - there is no input available, in() must return zero--buf is ignored in that - case--and inflateBack() will return a buffer error. inflateBack() will call - out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() - should return zero on success, or non-zero on failure. If out() returns - non-zero, inflateBack() will return with an error. Neither in() nor out() - are permitted to change the contents of the window provided to - inflateBackInit(), which is also the buffer that out() uses to write from. - The length written by out() will be at most the window size. Any non-zero - amount of input may be provided by in(). - - For convenience, inflateBack() can be provided input on the first call by - setting strm->next_in and strm->avail_in. If that input is exhausted, then - in() will be called. Therefore strm->next_in must be initialized before - calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called - immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in - must also be initialized, and then if strm->avail_in is not zero, input will - initially be taken from strm->next_in[0 .. strm->avail_in - 1]. - - The in_desc and out_desc parameters of inflateBack() is passed as the - first parameter of in() and out() respectively when they are called. These - descriptors can be optionally used to pass any information that the caller- - supplied in() and out() functions need to do their job. - - On return, inflateBack() will set strm->next_in and strm->avail_in to - pass back any unused input that was provided by the last in() call. The - return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR - if in() or out() returned an error, Z_DATA_ERROR if there was a format error - in the deflate stream (in which case strm->msg is set to indicate the nature - of the error), or Z_STREAM_ERROR if the stream was not properly initialized. - In the case of Z_BUF_ERROR, an input or output error can be distinguished - using strm->next_in which will be Z_NULL only if in() returned an error. If - strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning - non-zero. (in() will always be called before out(), so strm->next_in is - assured to be defined if out() returns non-zero.) Note that inflateBack() - cannot return Z_OK. -*/ - -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); -/* - All memory allocated by inflateBackInit() is freed. - - inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream - state was inconsistent. -*/ - -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); -/* Return flags indicating compile-time options. - - Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: - 1.0: size of uInt - 3.2: size of uLong - 5.4: size of voidpf (pointer) - 7.6: size of z_off_t - - Compiler, assembler, and debug options: - 8: DEBUG - 9: ASMV or ASMINF -- use ASM code - 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention - 11: 0 (reserved) - - One-time table building (smaller code, but not thread-safe if true): - 12: BUILDFIXED -- build static block decoding tables when needed - 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed - 14,15: 0 (reserved) - - Library content (indicates missing functionality): - 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking - deflate code when not needed) - 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect - and decode gzip streams (to avoid linking crc code) - 18-19: 0 (reserved) - - Operation variations (changes in library functionality): - 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate - 21: FASTEST -- deflate algorithm with only one, lowest compression level - 22,23: 0 (reserved) - - The sprintf variant used by gzprintf (zero is best): - 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format - 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! - 26: 0 = returns value, 1 = void -- 1 means inferred string length returned - - Remainder: - 27-31: 0 (reserved) - */ - - - /* utility functions */ - -/* - The following utility functions are implemented on top of the basic - stream-oriented functions. To simplify the interface, some default options - are assumed (compression level and memory usage, standard memory allocation - functions). The source code of these utility functions can be modified if - you need special options. -*/ - -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Compresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total size - of the destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - - compress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer. -*/ - -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level)); -/* - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ - -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); -/* - compressBound() returns an upper bound on the compressed size after - compress() or compress2() on sourceLen bytes. It would be used before a - compress() or compress2() call to allocate the destination buffer. -*/ - -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total size - of the destination buffer, which must be large enough to hold the entire - uncompressed data. (The size of the uncompressed data must have been saved - previously by the compressor and transmitted to the decompressor by some - mechanism outside the scope of this compression library.) Upon exit, destLen - is the actual size of the uncompressed buffer. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. -*/ - - - /* gzip file access functions */ - -/* - This library supports reading and writing files in gzip (.gz) format with - an interface similar to that of stdio, using the functions that start with - "gz". The gzip format is different from the zlib format. gzip is a gzip - wrapper, documented in RFC 1952, wrapped around a deflate stream. -*/ - -typedef voidp gzFile; /* opaque gzip file descriptor */ - -/* -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); - - Opens a gzip (.gz) file for reading or writing. The mode parameter is as - in fopen ("rb" or "wb") but can also include a compression level ("wb9") or - a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only - compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F' - for fixed code compression as in "wb9F". (See the description of - deflateInit2 for more information about the strategy parameter.) Also "a" - can be used instead of "w" to request that the gzip stream that will be - written be appended to the file. "+" will result in an error, since reading - and writing to the same gzip file is not supported. - - gzopen can be used to read a file which is not in gzip format; in this - case gzread will directly read from the file without decompression. - - gzopen returns NULL if the file could not be opened, if there was - insufficient memory to allocate the gzFile state, or if an invalid mode was - specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). - errno can be checked to determine if the reason gzopen failed was that the - file could not be opened. -*/ - -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); -/* - gzdopen associates a gzFile with the file descriptor fd. File descriptors - are obtained from calls like open, dup, creat, pipe or fileno (if the file - has been previously opened with fopen). The mode parameter is as in gzopen. - - The next call of gzclose on the returned gzFile will also close the file - descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor - fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, - mode);. The duplicated descriptor should be saved to avoid a leak, since - gzdopen does not close fd if it fails. - - gzdopen returns NULL if there was insufficient memory to allocate the - gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not - provided, or '+' was provided), or if fd is -1. The file descriptor is not - used until the next gz* read, write, seek, or close operation, so gzdopen - will not detect if fd is invalid (unless fd is -1). -*/ - -ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); -/* - Set the internal buffer size used by this library's functions. The - default buffer size is 8192 bytes. This function must be called after - gzopen() or gzdopen(), and before any other calls that read or write the - file. The buffer memory allocation is always deferred to the first read or - write. Two buffers are allocated, either both of the specified size when - writing, or one of the specified size and the other twice that size when - reading. A larger buffer size of, for example, 64K or 128K bytes will - noticeably increase the speed of decompression (reading). - - The new buffer size also affects the maximum length for gzprintf(). - - gzbuffer() returns 0 on success, or -1 on failure, such as being called - too late. -*/ - -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); -/* - Dynamically update the compression level or strategy. See the description - of deflateInit2 for the meaning of these parameters. - - gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not - opened for writing. -*/ - -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); -/* - Reads the given number of uncompressed bytes from the compressed file. If - the input file was not in gzip format, gzread copies the given number of - bytes into the buffer. - - After reaching the end of a gzip stream in the input, gzread will continue - to read, looking for another gzip stream, or failing that, reading the rest - of the input file directly without decompression. The entire input file - will be read if gzread is called until it returns less than the requested - len. - - gzread returns the number of uncompressed bytes actually read, less than - len for end of file, or -1 for error. -*/ - -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, - voidpc buf, unsigned len)); -/* - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of uncompressed bytes written or 0 in case of - error. -*/ - -ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); -/* - Converts, formats, and writes the arguments to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written, or 0 in case of error. The number of - uncompressed bytes written is limited to 8191, or one less than the buffer - size given to gzbuffer(). The caller should assure that this limit is not - exceeded. If it is exceeded, then gzprintf() will return an error (0) with - nothing written. In this case, there may also be a buffer overflow with - unpredictable consequences, which is possible only if zlib was compiled with - the insecure functions sprintf() or vsprintf() because the secure snprintf() - or vsnprintf() functions were not available. This can be determined using - zlibCompileFlags(). -*/ - -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); -/* - Writes the given null-terminated string to the compressed file, excluding - the terminating null character. - - gzputs returns the number of characters written, or -1 in case of error. -*/ - -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); -/* - Reads bytes from the compressed file until len-1 characters are read, or a - newline character is read and transferred to buf, or an end-of-file - condition is encountered. If any characters are read or if len == 1, the - string is terminated with a null character. If no characters are read due - to an end-of-file or len < 1, then the buffer is left untouched. - - gzgets returns buf which is a null-terminated string, or it returns NULL - for end-of-file or in case of error. If there was an error, the contents at - buf are indeterminate. -*/ - -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); -/* - Writes c, converted to an unsigned char, into the compressed file. gzputc - returns the value that was written, or -1 in case of error. -*/ - -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); -/* - Reads one byte from the compressed file. gzgetc returns this byte or -1 - in case of end of file or error. -*/ - -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); -/* - Push one character back onto the stream to be read as the first character - on the next read. At least one character of push-back is allowed. - gzungetc() returns the character pushed, or -1 on failure. gzungetc() will - fail if c is -1, and may fail if a character has been pushed but not read - yet. If gzungetc is used immediately after gzopen or gzdopen, at least the - output buffer size of pushed characters is allowed. (See gzbuffer above.) - The pushed character will be discarded if the stream is repositioned with - gzseek() or gzrewind(). -*/ - -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); -/* - Flushes all pending output into the compressed file. The parameter flush - is as in the deflate() function. The return value is the zlib error number - (see function gzerror below). gzflush is only permitted when writing. - - If the flush parameter is Z_FINISH, the remaining data is written and the - gzip stream is completed in the output. If gzwrite() is called again, a new - gzip stream will be started in the output. gzread() is able to read such - concatented gzip streams. - - gzflush should be called only when strictly necessary because it will - degrade compression if called too often. -*/ - -/* -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); - - Sets the starting position for the next gzread or gzwrite on the given - compressed file. The offset represents a number of bytes in the - uncompressed data stream. The whence parameter is defined as in lseek(2); - the value SEEK_END is not supported. - - If the file is opened for reading, this function is emulated but can be - extremely slow. If the file is opened for writing, only forward seeks are - supported; gzseek then compresses a sequence of zeroes up to the new - starting position. - - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error, in - particular if the file is opened for writing and the new starting position - would be before the current position. -*/ - -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); -/* - Rewinds the given file. This function is supported only for reading. - - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) -*/ - -/* -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); - - Returns the starting position for the next gzread or gzwrite on the given - compressed file. This position represents a number of bytes in the - uncompressed data stream, and is zero when starting, even if appending or - reading a gzip stream from the middle of a file using gzdopen(). - - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) -*/ - -/* -ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); - - Returns the current offset in the file being read or written. This offset - includes the count of bytes that precede the gzip stream, for example when - appending or when using gzdopen() for reading. When reading, the offset - does not include as yet unused buffered input. This information can be used - for a progress indicator. On error, gzoffset() returns -1. -*/ - -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); -/* - Returns true (1) if the end-of-file indicator has been set while reading, - false (0) otherwise. Note that the end-of-file indicator is set only if the - read tried to go past the end of the input, but came up short. Therefore, - just like feof(), gzeof() may return false even if there is no more data to - read, in the event that the last read request was for the exact number of - bytes remaining in the input file. This will happen if the input file size - is an exact multiple of the buffer size. - - If gzeof() returns true, then the read functions will return no more data, - unless the end-of-file indicator is reset by gzclearerr() and the input file - has grown since the previous end of file was detected. -*/ - -ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); -/* - Returns true (1) if file is being copied directly while reading, or false - (0) if file is a gzip stream being decompressed. This state can change from - false to true while reading the input file if the end of a gzip stream is - reached, but is followed by data that is not another gzip stream. - - If the input file is empty, gzdirect() will return true, since the input - does not contain a gzip stream. - - If gzdirect() is used immediately after gzopen() or gzdopen() it will - cause buffers to be allocated to allow reading the file to determine if it - is a gzip file. Therefore if gzbuffer() is used, it should be called before - gzdirect(). -*/ - -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); -/* - Flushes all pending output if necessary, closes the compressed file and - deallocates the (de)compression state. Note that once file is closed, you - cannot call gzerror with file, since its structures have been deallocated. - gzclose must not be called more than once on the same file, just as free - must not be called more than once on the same allocation. - - gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a - file operation error, or Z_OK on success. -*/ - -ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); -ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); -/* - Same as gzclose(), but gzclose_r() is only for use when reading, and - gzclose_w() is only for use when writing or appending. The advantage to - using these instead of gzclose() is that they avoid linking in zlib - compression or decompression code that is not used when only reading or only - writing respectively. If gzclose() is used, then both compression and - decompression code will be included the application when linking to a static - zlib library. -*/ - -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); -/* - Returns the error message for the last error which occurred on the given - compressed file. errnum is set to zlib error number. If an error occurred - in the file system and not in the compression library, errnum is set to - Z_ERRNO and the application may consult errno to get the exact error code. - - The application must not modify the returned string. Future calls to - this function may invalidate the previously returned string. If file is - closed, then the string previously returned by gzerror will no longer be - available. - - gzerror() should be used to distinguish errors from end-of-file for those - functions above that do not distinguish those cases in their return values. -*/ - -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); -/* - Clears the error and end-of-file flags for file. This is analogous to the - clearerr() function in stdio. This is useful for continuing to read a gzip - file that is being written concurrently. -*/ - - - /* checksum functions */ - -/* - These functions are not related to compression but are exported - anyway because they might be useful in applications using the compression - library. -*/ - -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); -/* - Update a running Adler-32 checksum with the bytes buf[0..len-1] and - return the updated checksum. If buf is Z_NULL, this function returns the - required initial value for the checksum. - - An Adler-32 checksum is almost as reliable as a CRC32 but can be computed - much faster. - - Usage example: - - uLong adler = adler32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - adler = adler32(adler, buffer, length); - } - if (adler != original_adler) error(); -*/ - -/* -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, - z_off_t len2)); - - Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 - and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for - each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of - seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. -*/ - -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); -/* - Update a running CRC-32 with the bytes buf[0..len-1] and return the - updated CRC-32. If buf is Z_NULL, this function returns the required - initial value for the for the crc. Pre- and post-conditioning (one's - complement) is performed within this function so it shouldn't be done by the - application. - - Usage example: - - uLong crc = crc32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - crc = crc32(crc, buffer, length); - } - if (crc != original_crc) error(); -*/ - -/* -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); - - Combine two CRC-32 check values into one. For two sequences of bytes, - seq1 and seq2 with lengths len1 and len2, CRC-32 check values were - calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 - check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and - len2. -*/ - - - /* various hacks, don't look :) */ - -/* deflateInit and inflateInit are macros to allow checking the zlib version - * and the compiler's view of z_stream: - */ -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size)); -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, - unsigned char FAR *window, - const char *version, - int stream_size)); -#define deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) -#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) -#define inflateBackInit(strm, windowBits, window) \ - inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, sizeof(z_stream)) - -/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or - * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if - * both are true, the application gets the *64 functions, and the regular - * functions are changed to 64 bits) -- in case these are set on systems - * without large file support, _LFS64_LARGEFILE must also be true - */ -#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); - ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); -#endif - -#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0 -# define gzopen gzopen64 -# define gzseek gzseek64 -# define gztell gztell64 -# define gzoffset gzoffset64 -# define adler32_combine adler32_combine64 -# define crc32_combine crc32_combine64 -# ifdef _LARGEFILE64_SOURCE - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); -# endif -#else - ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); -#endif - -/* hack for buggy compilers */ -#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) - struct internal_state {int dummy;}; -#endif - -/* undocumented functions */ -ZEXTERN const char * ZEXPORT zError OF((int)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); -ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); -ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); - -#ifdef __cplusplus -} -#endif - -#endif /* ZLIB_H */ diff --git a/libs/storm-sys/StormLib/src/zlib/zutil.c b/libs/storm-sys/StormLib/src/zlib/zutil.c deleted file mode 100644 index 898ed34..0000000 --- a/libs/storm-sys/StormLib/src/zlib/zutil.c +++ /dev/null @@ -1,318 +0,0 @@ -/* zutil.c -- target dependent utility functions for the compression library - * Copyright (C) 1995-2005, 2010 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#include "zutil.h" - -#ifndef NO_DUMMY_DECL -struct internal_state {int dummy;}; /* for buggy compilers */ -#endif - -const char * const z_errmsg[10] = { -"need dictionary", /* Z_NEED_DICT 2 */ -"stream end", /* Z_STREAM_END 1 */ -"", /* Z_OK 0 */ -"file error", /* Z_ERRNO (-1) */ -"stream error", /* Z_STREAM_ERROR (-2) */ -"data error", /* Z_DATA_ERROR (-3) */ -"insufficient memory", /* Z_MEM_ERROR (-4) */ -"buffer error", /* Z_BUF_ERROR (-5) */ -"incompatible version",/* Z_VERSION_ERROR (-6) */ -""}; - - -const char * ZEXPORT zlibVersion() -{ - return ZLIB_VERSION; -} - -uLong ZEXPORT zlibCompileFlags() -{ - uLong flags; - - flags = 0; - switch ((int)(sizeof(uInt))) { - case 2: break; - case 4: flags += 1; break; - case 8: flags += 2; break; - default: flags += 3; - } - switch ((int)(sizeof(uLong))) { - case 2: break; - case 4: flags += 1 << 2; break; - case 8: flags += 2 << 2; break; - default: flags += 3 << 2; - } - switch ((int)(sizeof(voidpf))) { - case 2: break; - case 4: flags += 1 << 4; break; - case 8: flags += 2 << 4; break; - default: flags += 3 << 4; - } - switch ((int)(sizeof(z_off_t))) { - case 2: break; - case 4: flags += 1 << 6; break; - case 8: flags += 2 << 6; break; - default: flags += 3 << 6; - } -#ifdef DEBUG - flags += 1 << 8; -#endif -#if defined(ASMV) || defined(ASMINF) - flags += 1 << 9; -#endif -#ifdef ZLIB_WINAPI - flags += 1 << 10; -#endif -#ifdef BUILDFIXED - flags += 1 << 12; -#endif -#ifdef DYNAMIC_CRC_TABLE - flags += 1 << 13; -#endif -#ifdef NO_GZCOMPRESS - flags += 1L << 16; -#endif -#ifdef NO_GZIP - flags += 1L << 17; -#endif -#ifdef PKZIP_BUG_WORKAROUND - flags += 1L << 20; -#endif -#ifdef FASTEST - flags += 1L << 21; -#endif -#ifdef STDC -# ifdef NO_vsnprintf - flags += 1L << 25; -# ifdef HAS_vsprintf_void - flags += 1L << 26; -# endif -# else -# ifdef HAS_vsnprintf_void - flags += 1L << 26; -# endif -# endif -#else - flags += 1L << 24; -# ifdef NO_snprintf - flags += 1L << 25; -# ifdef HAS_sprintf_void - flags += 1L << 26; -# endif -# else -# ifdef HAS_snprintf_void - flags += 1L << 26; -# endif -# endif -#endif - return flags; -} - -#ifdef DEBUG - -# ifndef verbose -# define verbose 0 -# endif -int ZLIB_INTERNAL z_verbose = verbose; - -void ZLIB_INTERNAL z_error (m) - char *m; -{ - fprintf(stderr, "%s\n", m); - exit(1); -} -#endif - -/* exported to allow conversion of error code to string for compress() and - * uncompress() - */ -const char * ZEXPORT zError(err) - int err; -{ - return ERR_MSG(err); -} - -#if defined(_WIN32_WCE) - /* The Microsoft C Run-Time Library for Windows CE doesn't have - * errno. We define it as a global variable to simplify porting. - * Its value is always 0 and should not be used. - */ - int errno = 0; -#endif - -#ifndef HAVE_MEMCPY - -void ZLIB_INTERNAL zmemcpy(dest, source, len) - Bytef* dest; - const Bytef* source; - uInt len; -{ - if (len == 0) return; - do { - *dest++ = *source++; /* ??? to be unrolled */ - } while (--len != 0); -} - -int ZLIB_INTERNAL zmemcmp(s1, s2, len) - const Bytef* s1; - const Bytef* s2; - uInt len; -{ - uInt j; - - for (j = 0; j < len; j++) { - if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; - } - return 0; -} - -void ZLIB_INTERNAL zmemzero(dest, len) - Bytef* dest; - uInt len; -{ - if (len == 0) return; - do { - *dest++ = 0; /* ??? to be unrolled */ - } while (--len != 0); -} -#endif - - -#ifdef SYS16BIT - -#ifdef __TURBOC__ -/* Turbo C in 16-bit mode */ - -# define MY_ZCALLOC - -/* Turbo C malloc() does not allow dynamic allocation of 64K bytes - * and farmalloc(64K) returns a pointer with an offset of 8, so we - * must fix the pointer. Warning: the pointer must be put back to its - * original form in order to free it, use zcfree(). - */ - -#define MAX_PTR 10 -/* 10*64K = 640K */ - -local int next_ptr = 0; - -typedef struct ptr_table_s { - voidpf org_ptr; - voidpf new_ptr; -} ptr_table; - -local ptr_table table[MAX_PTR]; -/* This table is used to remember the original form of pointers - * to large buffers (64K). Such pointers are normalized with a zero offset. - * Since MSDOS is not a preemptive multitasking OS, this table is not - * protected from concurrent access. This hack doesn't work anyway on - * a protected system like OS/2. Use Microsoft C instead. - */ - -voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) -{ - voidpf buf = opaque; /* just to make some compilers happy */ - ulg bsize = (ulg)items*size; - - /* If we allocate less than 65520 bytes, we assume that farmalloc - * will return a usable pointer which doesn't have to be normalized. - */ - if (bsize < 65520L) { - buf = farmalloc(bsize); - if (*(ush*)&buf != 0) return buf; - } else { - buf = farmalloc(bsize + 16L); - } - if (buf == NULL || next_ptr >= MAX_PTR) return NULL; - table[next_ptr].org_ptr = buf; - - /* Normalize the pointer to seg:0 */ - *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; - *(ush*)&buf = 0; - table[next_ptr++].new_ptr = buf; - return buf; -} - -void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) -{ - int n; - if (*(ush*)&ptr != 0) { /* object < 64K */ - farfree(ptr); - return; - } - /* Find the original pointer */ - for (n = 0; n < next_ptr; n++) { - if (ptr != table[n].new_ptr) continue; - - farfree(table[n].org_ptr); - while (++n < next_ptr) { - table[n-1] = table[n]; - } - next_ptr--; - return; - } - ptr = opaque; /* just to make some compilers happy */ - Assert(0, "zcfree: ptr not found"); -} - -#endif /* __TURBOC__ */ - - -#ifdef M_I86 -/* Microsoft C in 16-bit mode */ - -# define MY_ZCALLOC - -#if (!defined(_MSC_VER) || (_MSC_VER <= 600)) -# define _halloc halloc -# define _hfree hfree -#endif - -voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size) -{ - if (opaque) opaque = 0; /* to make compiler happy */ - return _halloc((long)items, size); -} - -void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) -{ - if (opaque) opaque = 0; /* to make compiler happy */ - _hfree(ptr); -} - -#endif /* M_I86 */ - -#endif /* SYS16BIT */ - - -#ifndef MY_ZCALLOC /* Any system without a special alloc function */ - -#ifndef STDC -extern voidp malloc OF((uInt size)); -extern voidp calloc OF((uInt items, uInt size)); -extern void free OF((voidpf ptr)); -#endif - -voidpf ZLIB_INTERNAL zcalloc (opaque, items, size) - voidpf opaque; - unsigned items; - unsigned size; -{ - if (opaque) items += size - size; /* make compiler happy */ - return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : - (voidpf)calloc(items, size); -} - -void ZLIB_INTERNAL zcfree (opaque, ptr) - voidpf opaque; - voidpf ptr; -{ - free(ptr); - if (opaque) return; /* make compiler happy */ -} - -#endif /* MY_ZCALLOC */ diff --git a/libs/storm-sys/StormLib/src/zlib/zutil.h b/libs/storm-sys/StormLib/src/zlib/zutil.h deleted file mode 100644 index 258fa88..0000000 --- a/libs/storm-sys/StormLib/src/zlib/zutil.h +++ /dev/null @@ -1,274 +0,0 @@ -/* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-2010 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* @(#) $Id$ */ - -#ifndef ZUTIL_H -#define ZUTIL_H - -#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) -# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) -#else -# define ZLIB_INTERNAL -#endif - -#include "zlib.h" - -#ifdef STDC -# if !(defined(_WIN32_WCE) && defined(_MSC_VER)) -# include -# endif -# include -# include -#endif - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - -typedef unsigned char uch; -typedef uch FAR uchf; -typedef unsigned short ush; -typedef ush FAR ushf; -typedef unsigned long ulg; - -extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ -/* (size given to avoid silly warnings with Visual C++) */ - -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] - -#define ERR_RETURN(strm,err) \ - return (strm->msg = (char*)ERR_MSG(err), (err)) -/* To be used only when the state is known to be valid */ - - /* common constants */ - -#ifndef DEF_WBITS -# define DEF_WBITS MAX_WBITS -#endif -/* default windowBits for decompression. MAX_WBITS is for compression only */ - -#if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -#else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif -/* default memLevel */ - -#define STORED_BLOCK 0 -#define STATIC_TREES 1 -#define DYN_TREES 2 -/* The three kinds of block type */ - -#define MIN_MATCH 3 -#define MAX_MATCH 258 -/* The minimum and maximum match lengths */ - -#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ - - /* target dependencies */ - -#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) -# define OS_CODE 0x00 -# if defined(__TURBOC__) || defined(__BORLANDC__) -# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) - /* Allow compilation with ANSI keywords only enabled */ - void _Cdecl farfree( void *block ); - void *_Cdecl farmalloc( unsigned long nbytes ); -# else -# include -# endif -# else /* MSC or DJGPP */ -# include -# endif -#endif - -#ifdef AMIGA -# define OS_CODE 0x01 -#endif - -#if defined(VAXC) || defined(VMS) -# define OS_CODE 0x02 -# define F_OPEN(name, mode) \ - fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") -#endif - -#if defined(ATARI) || defined(atarist) -# define OS_CODE 0x05 -#endif - -#ifdef OS2 -# define OS_CODE 0x06 -# ifdef M_I86 -# include -# endif -#endif - -#if defined(MACOS) || defined(TARGET_OS_MAC) -# define OS_CODE 0x07 -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include /* for fdopen */ -# else -# ifndef fdopen -# define fdopen(fd,mode) NULL /* No fdopen() */ -# endif -# endif -#endif - -#ifdef TOPS20 -# define OS_CODE 0x0a -#endif - -#ifdef WIN32 -# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ -# define OS_CODE 0x0b -# endif -#endif - -#ifdef __50SERIES /* Prime/PRIMOS */ -# define OS_CODE 0x0f -#endif - -#if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ -#endif - -#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX -# if defined(_WIN32_WCE) -# define fdopen(fd,mode) NULL /* No fdopen() */ -# ifndef _PTRDIFF_T_DEFINED - typedef int ptrdiff_t; -# define _PTRDIFF_T_DEFINED -# endif -# else -# define fdopen(fd,type) _fdopen(fd,type) -# endif -#endif - -#if defined(__BORLANDC__) - #pragma warn -8004 - #pragma warn -8008 - #pragma warn -8066 -#endif - -/* provide prototypes for these when building zlib without LFS */ -#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); -#endif - - /* common defaults */ - -#ifndef OS_CODE -# define OS_CODE 0x03 /* assume Unix */ -#endif - -#ifndef F_OPEN -# define F_OPEN(name, mode) fopen((name), (mode)) -#endif - - /* functions */ - -#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif -#if defined(__CYGWIN__) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif -#ifndef HAVE_VSNPRINTF -# ifdef MSDOS - /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), - but for now we just assume it doesn't. */ -# define NO_vsnprintf -# endif -# ifdef __TURBOC__ -# define NO_vsnprintf -# endif -# ifdef WIN32 - /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ -# if !defined(vsnprintf) && !defined(NO_vsnprintf) -# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) -# define vsnprintf _vsnprintf -# endif -# endif -# endif -# ifdef __SASC -# define NO_vsnprintf -# endif -#endif -#ifdef VMS -# define NO_vsnprintf -#endif - -#if defined(pyr) -# define NO_MEMCPY -#endif -#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) - /* Use our own functions for small and medium model with MSC <= 5.0. - * You may have to use the same strategy for Borland C (untested). - * The __SC__ check is for Symantec. - */ -# define NO_MEMCPY -#endif -#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) -# define HAVE_MEMCPY -#endif -#ifdef HAVE_MEMCPY -# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ -# define zmemcpy _fmemcpy -# define zmemcmp _fmemcmp -# define zmemzero(dest, len) _fmemset(dest, 0, len) -# else -# define zmemcpy memcpy -# define zmemcmp memcmp -# define zmemzero(dest, len) memset(dest, 0, len) -# endif -#else - void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); - int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); - void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); -#endif - -/* Diagnostic functions */ -#ifdef DEBUG -# include - extern int ZLIB_INTERNAL z_verbose; - extern void ZLIB_INTERNAL z_error OF((char *m)); -# define Assert(cond,msg) {if(!(cond)) z_error(msg);} -# define Trace(x) {if (z_verbose>=0) fprintf x ;} -# define Tracev(x) {if (z_verbose>0) fprintf x ;} -# define Tracevv(x) {if (z_verbose>1) fprintf x ;} -# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} -# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} -#else -# define Assert(cond,msg) -# define Trace(x) -# define Tracev(x) -# define Tracevv(x) -# define Tracec(c,x) -# define Tracecv(c,x) -#endif - - -voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, - unsigned size)); -void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); - -#define ZALLOC(strm, items, size) \ - (*((strm)->zalloc))((strm)->opaque, (items), (size)) -#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) -#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} - -#endif /* ZUTIL_H */ diff --git a/libs/storm-sys/StormPort.h b/libs/storm-sys/StormPort.h deleted file mode 100644 index fd74e69..0000000 --- a/libs/storm-sys/StormPort.h +++ /dev/null @@ -1,300 +0,0 @@ -/*****************************************************************************/ -/* StormPort.h Copyright (c) Marko Friedemann 2001 */ -/*---------------------------------------------------------------------------*/ -/* Portability module for the StormLib library. Contains a wrapper symbols */ -/* to make the compilation under Linux work */ -/* */ -/* Author: Marko Friedemann */ -/* Created at: Mon Jan 29 18:26:01 CEST 2001 */ -/* Computer: whiplash.flachland-chemnitz.de */ -/* System: Linux 2.4.0 on i686 */ -/* */ -/* Author: Sam Wilkins */ -/* System: Mac OS X and port to big endian processor */ -/* */ -/*---------------------------------------------------------------------------*/ -/* Date Ver Who Comment */ -/* -------- ---- --- ------- */ -/* 29.01.01 1.00 Mar Created */ -/* 24.03.03 1.01 Lad Some cosmetic changes */ -/* 12.11.03 1.02 Dan Macintosh compatibility */ -/* 24.07.04 1.03 Sam Mac OS X compatibility */ -/* 22.11.06 1.04 Sam Mac OS X compatibility (for StormLib 6.0) */ -/* 31.12.06 1.05 XPinguin Full GNU/Linux compatibility */ -/* 17.10.12 1.05 Lad Moved error codes so they don't overlap with errno.h */ -/*****************************************************************************/ - -#ifndef __STORMPORT_H__ -#define __STORMPORT_H__ - -#ifndef __cplusplus - #define bool char - #define true 1 - #define false 0 -#endif - -//----------------------------------------------------------------------------- -// Defines for Windows - -#if !defined(PLATFORM_DEFINED) && defined(_WIN32) - - // In MSVC 8.0, there are some functions declared as deprecated. - #if _MSC_VER >= 1400 - #define _CRT_SECURE_NO_DEPRECATE - #define _CRT_NON_CONFORMING_SWPRINTFS - #endif - - #include - #include - #include - #include - #include - #define PLATFORM_LITTLE_ENDIAN - - #ifdef _WIN64 - #define PLATFORM_64BIT - #else - #define PLATFORM_32BIT - #endif - - #define PLATFORM_WINDOWS - #define PLATFORM_DEFINED // The platform is known now - -#endif - -//----------------------------------------------------------------------------- -// Defines for Mac - -#if !defined(PLATFORM_DEFINED) && defined(__APPLE__) // Mac BSD API - - // Macintosh - #include - #include - #include - #include - #include - #include - #include - - // Support for PowerPC on Max OS X - #if (__ppc__ == 1) || (__POWERPC__ == 1) || (_ARCH_PPC == 1) - #include - #include - #endif - - #define PKEXPORT - #define __SYS_ZLIB - #define __SYS_BZLIB - - #ifndef __BIG_ENDIAN__ - #define PLATFORM_LITTLE_ENDIAN - #endif - - #define PLATFORM_MAC - #define PLATFORM_DEFINED // The platform is known now - -#endif - -//----------------------------------------------------------------------------- -// Assumption: we are not on Windows nor Macintosh, so this must be linux *grin* - -#if !defined(PLATFORM_DEFINED) - - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - - #define PLATFORM_LITTLE_ENDIAN - #define PLATFORM_LINUX - #define PLATFORM_DEFINED - -#endif - -//----------------------------------------------------------------------------- -// Definition of Windows-specific types for non-Windows platforms - -#ifndef PLATFORM_WINDOWS - #if __LP64__ - #define PLATFORM_64BIT - #else - #define PLATFORM_32BIT - #endif - - // Typedefs for ANSI C - typedef unsigned char BYTE; - typedef unsigned short USHORT; - typedef int LONG; - typedef unsigned int DWORD; - typedef unsigned long DWORD_PTR; - typedef long LONG_PTR; - typedef long INT_PTR; - typedef long long LONGLONG; - typedef unsigned long long ULONGLONG; - typedef void * HANDLE; - typedef void * LPOVERLAPPED; // Unsupported on Linux and Mac - typedef char TCHAR; - typedef unsigned int LCID; - typedef LONG * PLONG; - typedef DWORD * LPDWORD; - typedef BYTE * LPBYTE; - typedef const char * LPCTSTR; - typedef const char * LPCSTR; - typedef char * LPTSTR; - typedef char * LPSTR; - - #ifdef PLATFORM_32BIT - #define _LZMA_UINT32_IS_ULONG - #endif - - // Some Windows-specific defines - #ifndef MAX_PATH - #define MAX_PATH 1024 - #endif - - #ifndef _countof - #define _countof(x) (sizeof(x) / sizeof(x[0])) - #endif - - #define WINAPI - - #define FILE_BEGIN SEEK_SET - #define FILE_CURRENT SEEK_CUR - #define FILE_END SEEK_END - - #define _T(x) x - #define _tcslen strlen - #define _tcscpy strcpy - #define _tcscat strcat - #define _tcschr strchr - #define _tcsrchr strrchr - #define _tcsstr strstr - #define _tcsnicmp strncasecmp - #define _tprintf printf - #define _stprintf sprintf - #define _tremove remove - #define _tmain main - - #define _stricmp strcasecmp - #define _strnicmp strncasecmp - #define _tcsicmp strcasecmp - #define _tcsnicmp strncasecmp - -#endif // !PLATFORM_WINDOWS - -// 64-bit calls are supplied by "normal" calls on Mac -#if defined(PLATFORM_MAC) - #define stat64 stat - #define fstat64 fstat - #define lseek64 lseek - #define ftruncate64 ftruncate - #define off64_t off_t - #define O_LARGEFILE 0 -#endif - -// Platform-specific error codes for UNIX-based platforms -#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) - #define ERROR_SUCCESS 0 - #define ERROR_FILE_NOT_FOUND ENOENT - #define ERROR_ACCESS_DENIED EPERM - #define ERROR_INVALID_HANDLE EBADF - #define ERROR_NOT_ENOUGH_MEMORY ENOMEM - #define ERROR_NOT_SUPPORTED ENOTSUP - #define ERROR_INVALID_PARAMETER EINVAL - #define ERROR_NEGATIVE_SEEK EINVAL - #define ERROR_DISK_FULL ENOSPC - #define ERROR_ALREADY_EXISTS EEXIST - #define ERROR_INSUFFICIENT_BUFFER ENOBUFS - #define ERROR_BAD_FORMAT 1000 // No such error code under Linux - #define ERROR_NO_MORE_FILES 1001 // No such error code under Linux - #define ERROR_HANDLE_EOF 1002 // No such error code under Linux - #define ERROR_CAN_NOT_COMPLETE 1003 // No such error code under Linux - #define ERROR_FILE_CORRUPT 1004 // No such error code under Linux -#endif - -//----------------------------------------------------------------------------- -// Swapping functions - -#ifdef PLATFORM_LITTLE_ENDIAN - #define BSWAP_INT16_UNSIGNED(a) (a) - #define BSWAP_INT16_SIGNED(a) (a) - #define BSWAP_INT32_UNSIGNED(a) (a) - #define BSWAP_INT32_SIGNED(a) (a) - #define BSWAP_INT64_SIGNED(a) (a) - #define BSWAP_INT64_UNSIGNED(a) (a) - #define BSWAP_ARRAY16_UNSIGNED(a,b) {} - #define BSWAP_ARRAY32_UNSIGNED(a,b) {} - #define BSWAP_ARRAY64_UNSIGNED(a,b) {} - #define BSWAP_PART_HEADER(a) {} - #define BSWAP_TMPQHEADER(a,b) {} - #define BSWAP_TMPKHEADER(a) {} -#else - -#ifdef __cplusplus - extern "C" { -#endif - int16_t SwapInt16(uint16_t); - uint16_t SwapUInt16(uint16_t); - int32_t SwapInt32(uint32_t); - uint32_t SwapUInt32(uint32_t); - int64_t SwapInt64(uint64_t); - uint64_t SwapUInt64(uint64_t); - void ConvertUInt16Buffer(void * ptr, size_t length); - void ConvertUInt32Buffer(void * ptr, size_t length); - void ConvertUInt64Buffer(void * ptr, size_t length); - void ConvertTMPQUserData(void *userData); - void ConvertTMPQHeader(void *header, uint16_t wPart); - void ConvertTMPKHeader(void *header); -#ifdef __cplusplus - } -#endif - #define BSWAP_INT16_SIGNED(a) SwapInt16((a)) - #define BSWAP_INT16_UNSIGNED(a) SwapUInt16((a)) - #define BSWAP_INT32_SIGNED(a) SwapInt32((a)) - #define BSWAP_INT32_UNSIGNED(a) SwapUInt32((a)) - #define BSWAP_INT64_SIGNED(a) SwapInt64((a)) - #define BSWAP_INT64_UNSIGNED(a) SwapUInt64((a)) - #define BSWAP_ARRAY16_UNSIGNED(a,b) ConvertUInt16Buffer((a),(b)) - #define BSWAP_ARRAY32_UNSIGNED(a,b) ConvertUInt32Buffer((a),(b)) - #define BSWAP_ARRAY64_UNSIGNED(a,b) ConvertUInt64Buffer((a),(b)) - #define BSWAP_TMPQHEADER(a,b) ConvertTMPQHeader((a),(b)) - #define BSWAP_TMPKHEADER(a) ConvertTMPKHeader((a)) -#endif - -//----------------------------------------------------------------------------- -// Macro for deprecated symbols - -/* -#ifdef _MSC_VER - #if _MSC_FULL_VER >= 140050320 - #define STORMLIB_DEPRECATED(_Text) __declspec(deprecated(_Text)) - #else - #define STORMLIB_DEPRECATED(_Text) __declspec(deprecated) - #endif -#else - #ifdef __GNUC__ - #define STORMLIB_DEPRECATED(_Text) __attribute__((deprecated)) - #else - #define STORMLIB_DEPRECATED(_Text) __attribute__((deprecated(_Text))) - #endif -#endif - -// When a flag is deprecated, use this macro -#ifndef _STORMLIB_NO_DEPRECATE - #define STORMLIB_DEPRECATED_FLAG(type, oldflag, newflag) \ - const STORMLIB_DEPRECATED(#oldflag " is deprecated. Use " #newflag ". To supress this warning, define _STORMLIB_NO_DEPRECATE") static type oldflag = (type)newflag; -#else -#define STORMLIB_DEPRECATED_FLAG(type, oldflag, newflag) static type oldflag = (type)newflag; -#endif -*/ - -#endif // __STORMPORT_H__ diff --git a/libs/storm-sys/build.rs b/libs/storm-sys/build.rs deleted file mode 100644 index 564c7df..0000000 --- a/libs/storm-sys/build.rs +++ /dev/null @@ -1,102 +0,0 @@ -use std::env; - -use std::path::Path; -use std::path::PathBuf; -use std::fs; - -fn find_source_files>(path: P) -> impl Iterator { - fs::read_dir(path) - .unwrap() - .map(|entry| entry.unwrap()) - .filter(|entry| entry.file_type().unwrap().is_file()) - .filter(|entry| { - if let Some(ext) = entry.path().extension() { - ext == "c" || ext == "cpp" - } else { - false - } - }) - .map(|entry| entry.path()) -} - -fn make_bindings() { - let target_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - - let bindings = bindgen::Builder::default() - .header("StormLib.h") - .clang_arg("-x") - .clang_arg("c++") - .layout_tests(true) - .whitelist_function("SFile.*") - .whitelist_function("SList.*") - .whitelist_function("GetLastError") - .whitelist_type("T.*") - .whitelist_var("ERROR.*") - .whitelist_var("MPQ.*") - .whitelist_var("SFILE.*") - .default_enum_style(bindgen::EnumVariation::Rust { - non_exhaustive: false, - }) - .generate() - .expect("Unable to generate bindings"); - - bindings - .write_to_file(target_dir.join("src/storm.rs")) - .expect("Couldn't write bindings!"); -} - -fn main() { - let target_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); - let target_triple = env::var("TARGET").unwrap(); - - let mut build = cc::Build::new(); - - build - .extra_warnings(false) - .warnings(false) - .define("_7ZIP_ST", None) - .flag("-w") - .files(find_source_files("StormLib/src")) - .files(find_source_files("StormLib/src/libtomcrypt/src/hashes")) - .files(find_source_files("StormLib/src/libtomcrypt/src/math")) - .files(find_source_files("StormLib/src/libtomcrypt/src/misc")) - .files(find_source_files("StormLib/src/libtomcrypt/src/pk/asn1")) - .files(find_source_files("StormLib/src/libtomcrypt/src/pk/ecc")) - .files(find_source_files("StormLib/src/libtomcrypt/src/pk/pkcs1")) - .files(find_source_files("StormLib/src/libtomcrypt/src/pk/rsa")) - .files(find_source_files("StormLib/src/libtommath")) - .files(find_source_files("StormLib/src/bzip2")) - .files(find_source_files("StormLib/src/huffman")) - .files(find_source_files("StormLib/src/pklib")) - .files(find_source_files("StormLib/src/jenkins")) - .file("StormLib/src/zlib/crc32.c") - .file("StormLib/src/zlib/trees.c") - .file("StormLib/src/zlib/compress.c") - .file("StormLib/src/zlib/adler32.c") - .file("StormLib/src/zlib/inftrees.c") - .file("StormLib/src/zlib/inffast.c") - .file("StormLib/src/zlib/deflate.c") - .file("StormLib/src/zlib/inflate.c") - .file("StormLib/src/zlib/zutil.c") - .file("StormLib/src/lzma/C/LzFind.c") - .file("StormLib/src/lzma/C/LzmaEnc.c") - .file("StormLib/src/lzma/C/LzmaDec.c") - .file("StormLib/src/adpcm/adpcm.cpp") - .file("StormLib/src/sparse/sparse.cpp"); - - if !target_triple.contains("windows-msvc") { - build.static_flag(true); - } - - build.compile("storm"); - - if target_triple.contains("windows-gnu") && env::var("CERES_NOBUNDLE_CPP").is_ok() { - println!("cargo:rustc-link-lib=static-nobundle=stdc++"); - println!("cargo:rustc-link-lib=static-nobundle=gcc"); - } else if target_triple.contains("darwin") { - println!("cargo:rustc-link-lib=dylib=c++"); - } else { - // println!("cargo:rustc-link-lib=dylib=stdc++"); - } -} diff --git a/libs/storm-sys/src/lib.rs b/libs/storm-sys/src/lib.rs deleted file mode 100644 index 527b75d..0000000 --- a/libs/storm-sys/src/lib.rs +++ /dev/null @@ -1,9 +0,0 @@ - - -#[allow(non_upper_case_globals)] -#[allow(non_camel_case_types)] -#[allow(non_snake_case)] -#[allow(dead_code)] -mod storm; - -pub use storm::*; diff --git a/libs/storm-sys/src/storm.rs b/libs/storm-sys/src/storm.rs deleted file mode 100644 index 5d6fc2d..0000000 --- a/libs/storm-sys/src/storm.rs +++ /dev/null @@ -1,3273 +0,0 @@ -/* automatically generated by rust-bindgen */ - -pub const ERROR_SUCCESS: u32 = 0; -pub const ERROR_FILE_NOT_FOUND: u32 = 2; -pub const ERROR_ACCESS_DENIED: u32 = 1; -pub const ERROR_INVALID_HANDLE: u32 = 9; -pub const ERROR_NOT_ENOUGH_MEMORY: u32 = 12; -pub const ERROR_NOT_SUPPORTED: u32 = 95; -pub const ERROR_INVALID_PARAMETER: u32 = 22; -pub const ERROR_NEGATIVE_SEEK: u32 = 22; -pub const ERROR_DISK_FULL: u32 = 28; -pub const ERROR_ALREADY_EXISTS: u32 = 17; -pub const ERROR_INSUFFICIENT_BUFFER: u32 = 105; -pub const ERROR_BAD_FORMAT: u32 = 1000; -pub const ERROR_NO_MORE_FILES: u32 = 1001; -pub const ERROR_HANDLE_EOF: u32 = 1002; -pub const ERROR_CAN_NOT_COMPLETE: u32 = 1003; -pub const ERROR_FILE_CORRUPT: u32 = 1004; -pub const ERROR_AVI_FILE: u32 = 10000; -pub const ERROR_UNKNOWN_FILE_KEY: u32 = 10001; -pub const ERROR_CHECKSUM_ERROR: u32 = 10002; -pub const ERROR_INTERNAL_FILE: u32 = 10003; -pub const ERROR_BASE_FILE_MISSING: u32 = 10004; -pub const ERROR_MARKED_FOR_DELETE: u32 = 10005; -pub const ERROR_FILE_INCOMPLETE: u32 = 10006; -pub const ERROR_UNKNOWN_FILE_NAMES: u32 = 10007; -pub const ERROR_CANT_FIND_PATCH_PREFIX: u32 = 10008; -pub const SFILE_OPEN_HARD_DISK_FILE: u32 = 2; -pub const SFILE_OPEN_CDROM_FILE: u32 = 3; -pub const SFILE_OPEN_FROM_MPQ: u32 = 0; -pub const SFILE_OPEN_CHECK_EXISTS: u32 = 4294967292; -pub const SFILE_OPEN_BASE_FILE: u32 = 4294967293; -pub const SFILE_OPEN_ANY_LOCALE: u32 = 4294967294; -pub const SFILE_OPEN_LOCAL_FILE: u32 = 4294967295; -pub const MPQ_FLAG_READ_ONLY: u32 = 1; -pub const MPQ_FLAG_CHANGED: u32 = 2; -pub const MPQ_FLAG_MALFORMED: u32 = 4; -pub const MPQ_FLAG_HASH_TABLE_CUT: u32 = 8; -pub const MPQ_FLAG_BLOCK_TABLE_CUT: u32 = 16; -pub const MPQ_FLAG_CHECK_SECTOR_CRC: u32 = 32; -pub const MPQ_FLAG_SAVING_TABLES: u32 = 64; -pub const MPQ_FLAG_PATCH: u32 = 128; -pub const MPQ_FLAG_WAR3_MAP: u32 = 256; -pub const MPQ_FLAG_LISTFILE_NONE: u32 = 512; -pub const MPQ_FLAG_LISTFILE_NEW: u32 = 1024; -pub const MPQ_FLAG_LISTFILE_FORCE: u32 = 2048; -pub const MPQ_FLAG_ATTRIBUTES_NONE: u32 = 4096; -pub const MPQ_FLAG_ATTRIBUTES_NEW: u32 = 8192; -pub const MPQ_FLAG_SIGNATURE_NONE: u32 = 16384; -pub const MPQ_FLAG_SIGNATURE_NEW: u32 = 32768; -pub const MPQ_SUBTYPE_MPQ: u32 = 0; -pub const MPQ_SUBTYPE_SQP: u32 = 1; -pub const MPQ_SUBTYPE_MPK: u32 = 2; -pub const SFILE_INVALID_SIZE: u32 = 4294967295; -pub const SFILE_INVALID_POS: u32 = 4294967295; -pub const SFILE_INVALID_ATTRIBUTES: u32 = 4294967295; -pub const MPQ_FILE_IMPLODE: u32 = 256; -pub const MPQ_FILE_COMPRESS: u32 = 512; -pub const MPQ_FILE_ENCRYPTED: u32 = 65536; -pub const MPQ_FILE_FIX_KEY: u32 = 131072; -pub const MPQ_FILE_PATCH_FILE: u32 = 1048576; -pub const MPQ_FILE_SINGLE_UNIT: u32 = 16777216; -pub const MPQ_FILE_DELETE_MARKER: u32 = 33554432; -pub const MPQ_FILE_SECTOR_CRC: u32 = 67108864; -pub const MPQ_FILE_SIGNATURE: u32 = 268435456; -pub const MPQ_FILE_EXISTS: u32 = 2147483648; -pub const MPQ_FILE_REPLACEEXISTING: u32 = 2147483648; -pub const MPQ_FILE_COMPRESS_MASK: u32 = 65280; -pub const MPQ_FILE_DEFAULT_INTERNAL: u32 = 4294967295; -pub const MPQ_FILE_VALID_FLAGS: u32 = 2534605568; -pub const MPQ_FILE_VALID_FLAGS_W3X: u32 = 2516779776; -pub const MPQ_COMPRESSION_HUFFMANN: u32 = 1; -pub const MPQ_COMPRESSION_ZLIB: u32 = 2; -pub const MPQ_COMPRESSION_PKWARE: u32 = 8; -pub const MPQ_COMPRESSION_BZIP2: u32 = 16; -pub const MPQ_COMPRESSION_SPARSE: u32 = 32; -pub const MPQ_COMPRESSION_ADPCM_MONO: u32 = 64; -pub const MPQ_COMPRESSION_ADPCM_STEREO: u32 = 128; -pub const MPQ_COMPRESSION_LZMA: u32 = 18; -pub const MPQ_COMPRESSION_NEXT_SAME: u32 = 4294967295; -pub const MPQ_WAVE_QUALITY_HIGH: u32 = 0; -pub const MPQ_WAVE_QUALITY_MEDIUM: u32 = 1; -pub const MPQ_WAVE_QUALITY_LOW: u32 = 2; -pub const MPQ_KEY_HASH_TABLE: u32 = 3283040112; -pub const MPQ_KEY_BLOCK_TABLE: u32 = 3968054179; -pub const MPQ_FORMAT_VERSION_1: u32 = 0; -pub const MPQ_FORMAT_VERSION_2: u32 = 1; -pub const MPQ_FORMAT_VERSION_3: u32 = 2; -pub const MPQ_FORMAT_VERSION_4: u32 = 3; -pub const MPQ_ATTRIBUTE_CRC32: u32 = 1; -pub const MPQ_ATTRIBUTE_FILETIME: u32 = 2; -pub const MPQ_ATTRIBUTE_MD5: u32 = 4; -pub const MPQ_ATTRIBUTE_PATCH_BIT: u32 = 8; -pub const MPQ_ATTRIBUTE_ALL: u32 = 15; -pub const MPQ_ATTRIBUTES_V1: u32 = 100; -pub const MPQ_OPEN_NO_LISTFILE: u32 = 65536; -pub const MPQ_OPEN_NO_ATTRIBUTES: u32 = 131072; -pub const MPQ_OPEN_NO_HEADER_SEARCH: u32 = 262144; -pub const MPQ_OPEN_FORCE_MPQ_V1: u32 = 524288; -pub const MPQ_OPEN_CHECK_SECTOR_CRC: u32 = 1048576; -pub const MPQ_OPEN_PATCH: u32 = 2097152; -pub const MPQ_OPEN_FORCE_LISTFILE: u32 = 4194304; -pub const MPQ_OPEN_READ_ONLY: u32 = 256; -pub const MPQ_CREATE_LISTFILE: u32 = 1048576; -pub const MPQ_CREATE_ATTRIBUTES: u32 = 2097152; -pub const MPQ_CREATE_SIGNATURE: u32 = 4194304; -pub const MPQ_CREATE_ARCHIVE_V1: u32 = 0; -pub const MPQ_CREATE_ARCHIVE_V2: u32 = 16777216; -pub const MPQ_CREATE_ARCHIVE_V3: u32 = 33554432; -pub const MPQ_CREATE_ARCHIVE_V4: u32 = 50331648; -pub const MPQ_CREATE_ARCHIVE_VMASK: u32 = 251658240; -pub const SFILE_VERIFY_SECTOR_CRC: u32 = 1; -pub const SFILE_VERIFY_FILE_CRC: u32 = 2; -pub const SFILE_VERIFY_FILE_MD5: u32 = 4; -pub const SFILE_VERIFY_RAW_MD5: u32 = 8; -pub const SFILE_VERIFY_ALL: u32 = 15; -pub const SFILE_VERIFY_MPQ_HEADER: u32 = 1; -pub const SFILE_VERIFY_HET_TABLE: u32 = 2; -pub const SFILE_VERIFY_BET_TABLE: u32 = 3; -pub const SFILE_VERIFY_HASH_TABLE: u32 = 4; -pub const SFILE_VERIFY_BLOCK_TABLE: u32 = 5; -pub const SFILE_VERIFY_HIBLOCK_TABLE: u32 = 6; -pub const SFILE_VERIFY_FILE: u32 = 7; -pub const ERROR_NO_SIGNATURE: u32 = 0; -pub const ERROR_VERIFY_FAILED: u32 = 1; -pub const ERROR_WEAK_SIGNATURE_OK: u32 = 2; -pub const ERROR_WEAK_SIGNATURE_ERROR: u32 = 3; -pub const ERROR_STRONG_SIGNATURE_OK: u32 = 4; -pub const ERROR_STRONG_SIGNATURE_ERROR: u32 = 5; -pub const MPQ_HEADER_SIZE_V1: u32 = 32; -pub const MPQ_HEADER_SIZE_V2: u32 = 44; -pub const MPQ_HEADER_SIZE_V3: u32 = 68; -pub const MPQ_HEADER_SIZE_V4: u32 = 208; -pub const MPQ_HEADER_DWORDS: u32 = 52; -pub type BYTE = ::std::os::raw::c_uchar; -pub type USHORT = ::std::os::raw::c_ushort; -pub type LONG = ::std::os::raw::c_int; -pub type DWORD = ::std::os::raw::c_uint; -pub type ULONGLONG = ::std::os::raw::c_ulonglong; -pub type HANDLE = *mut ::std::os::raw::c_void; -pub type LPOVERLAPPED = *mut ::std::os::raw::c_void; -pub type TCHAR = ::std::os::raw::c_char; -pub type LCID = ::std::os::raw::c_uint; -pub type LPDWORD = *mut DWORD; -pub type LPBYTE = *mut BYTE; -pub type HASH_STRING = ::std::option::Option< - unsafe extern "C" fn(szFileName: *const ::std::os::raw::c_char, dwHashType: DWORD) -> DWORD, ->; -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum _SFileInfoClass { - SFileMpqFileName = 0, - SFileMpqStreamBitmap = 1, - SFileMpqUserDataOffset = 2, - SFileMpqUserDataHeader = 3, - SFileMpqUserData = 4, - SFileMpqHeaderOffset = 5, - SFileMpqHeaderSize = 6, - SFileMpqHeader = 7, - SFileMpqHetTableOffset = 8, - SFileMpqHetTableSize = 9, - SFileMpqHetHeader = 10, - SFileMpqHetTable = 11, - SFileMpqBetTableOffset = 12, - SFileMpqBetTableSize = 13, - SFileMpqBetHeader = 14, - SFileMpqBetTable = 15, - SFileMpqHashTableOffset = 16, - SFileMpqHashTableSize64 = 17, - SFileMpqHashTableSize = 18, - SFileMpqHashTable = 19, - SFileMpqBlockTableOffset = 20, - SFileMpqBlockTableSize64 = 21, - SFileMpqBlockTableSize = 22, - SFileMpqBlockTable = 23, - SFileMpqHiBlockTableOffset = 24, - SFileMpqHiBlockTableSize64 = 25, - SFileMpqHiBlockTable = 26, - SFileMpqSignatures = 27, - SFileMpqStrongSignatureOffset = 28, - SFileMpqStrongSignatureSize = 29, - SFileMpqStrongSignature = 30, - SFileMpqArchiveSize64 = 31, - SFileMpqArchiveSize = 32, - SFileMpqMaxFileCount = 33, - SFileMpqFileTableSize = 34, - SFileMpqSectorSize = 35, - SFileMpqNumberOfFiles = 36, - SFileMpqRawChunkSize = 37, - SFileMpqStreamFlags = 38, - SFileMpqFlags = 39, - SFileInfoPatchChain = 40, - SFileInfoFileEntry = 41, - SFileInfoHashEntry = 42, - SFileInfoHashIndex = 43, - SFileInfoNameHash1 = 44, - SFileInfoNameHash2 = 45, - SFileInfoNameHash3 = 46, - SFileInfoLocale = 47, - SFileInfoFileIndex = 48, - SFileInfoByteOffset = 49, - SFileInfoFileTime = 50, - SFileInfoFileSize = 51, - SFileInfoCompressedSize = 52, - SFileInfoFlags = 53, - SFileInfoEncryptionKey = 54, - SFileInfoEncryptionKeyRaw = 55, - SFileInfoCRC32 = 56, -} -pub use self::_SFileInfoClass as SFileInfoClass; -pub type SFILE_DOWNLOAD_CALLBACK = ::std::option::Option< - unsafe extern "C" fn( - pvUserData: *mut ::std::os::raw::c_void, - ByteOffset: ULONGLONG, - dwTotalBytes: DWORD, - ), ->; -pub type SFILE_ADDFILE_CALLBACK = ::std::option::Option< - unsafe extern "C" fn( - pvUserData: *mut ::std::os::raw::c_void, - dwBytesWritten: DWORD, - dwTotalBytes: DWORD, - bFinalCall: bool, - ), ->; -pub type SFILE_COMPACT_CALLBACK = ::std::option::Option< - unsafe extern "C" fn( - pvUserData: *mut ::std::os::raw::c_void, - dwWorkType: DWORD, - BytesProcessed: ULONGLONG, - TotalBytes: ULONGLONG, - ), ->; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct TFileStream { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _TBitArray { - pub NumberOfBytes: DWORD, - pub NumberOfBits: DWORD, - pub Elements: [BYTE; 1usize], -} -#[test] -fn bindgen_test_layout__TBitArray() { - assert_eq!( - ::std::mem::size_of::<_TBitArray>(), - 12usize, - concat!("Size of: ", stringify!(_TBitArray)) - ); - assert_eq!( - ::std::mem::align_of::<_TBitArray>(), - 4usize, - concat!("Alignment of ", stringify!(_TBitArray)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TBitArray>())).NumberOfBytes as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_TBitArray), - "::", - stringify!(NumberOfBytes) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TBitArray>())).NumberOfBits as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(_TBitArray), - "::", - stringify!(NumberOfBits) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TBitArray>())).Elements as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_TBitArray), - "::", - stringify!(Elements) - ) - ); -} -pub type TBitArray = _TBitArray; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _TMPQUserData { - pub dwID: DWORD, - pub cbUserDataSize: DWORD, - pub dwHeaderOffs: DWORD, - pub cbUserDataHeader: DWORD, -} -#[test] -fn bindgen_test_layout__TMPQUserData() { - assert_eq!( - ::std::mem::size_of::<_TMPQUserData>(), - 16usize, - concat!("Size of: ", stringify!(_TMPQUserData)) - ); - assert_eq!( - ::std::mem::align_of::<_TMPQUserData>(), - 4usize, - concat!("Alignment of ", stringify!(_TMPQUserData)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQUserData>())).dwID as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_TMPQUserData), - "::", - stringify!(dwID) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQUserData>())).cbUserDataSize as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(_TMPQUserData), - "::", - stringify!(cbUserDataSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQUserData>())).dwHeaderOffs as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_TMPQUserData), - "::", - stringify!(dwHeaderOffs) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQUserData>())).cbUserDataHeader as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(_TMPQUserData), - "::", - stringify!(cbUserDataHeader) - ) - ); -} -pub type TMPQUserData = _TMPQUserData; -#[repr(C, packed)] -#[derive(Debug, Copy, Clone)] -pub struct _TMPQHeader { - pub dwID: DWORD, - pub dwHeaderSize: DWORD, - pub dwArchiveSize: DWORD, - pub wFormatVersion: USHORT, - pub wSectorSize: USHORT, - pub dwHashTablePos: DWORD, - pub dwBlockTablePos: DWORD, - pub dwHashTableSize: DWORD, - pub dwBlockTableSize: DWORD, - pub HiBlockTablePos64: ULONGLONG, - pub wHashTablePosHi: USHORT, - pub wBlockTablePosHi: USHORT, - pub ArchiveSize64: ULONGLONG, - pub BetTablePos64: ULONGLONG, - pub HetTablePos64: ULONGLONG, - pub HashTableSize64: ULONGLONG, - pub BlockTableSize64: ULONGLONG, - pub HiBlockTableSize64: ULONGLONG, - pub HetTableSize64: ULONGLONG, - pub BetTableSize64: ULONGLONG, - pub dwRawChunkSize: DWORD, - pub MD5_BlockTable: [::std::os::raw::c_uchar; 16usize], - pub MD5_HashTable: [::std::os::raw::c_uchar; 16usize], - pub MD5_HiBlockTable: [::std::os::raw::c_uchar; 16usize], - pub MD5_BetTable: [::std::os::raw::c_uchar; 16usize], - pub MD5_HetTable: [::std::os::raw::c_uchar; 16usize], - pub MD5_MpqHeader: [::std::os::raw::c_uchar; 16usize], -} -#[test] -fn bindgen_test_layout__TMPQHeader() { - assert_eq!( - ::std::mem::size_of::<_TMPQHeader>(), - 208usize, - concat!("Size of: ", stringify!(_TMPQHeader)) - ); - assert_eq!( - ::std::mem::align_of::<_TMPQHeader>(), - 1usize, - concat!("Alignment of ", stringify!(_TMPQHeader)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).dwID as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(dwID) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).dwHeaderSize as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(dwHeaderSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).dwArchiveSize as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(dwArchiveSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).wFormatVersion as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(wFormatVersion) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).wSectorSize as *const _ as usize }, - 14usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(wSectorSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).dwHashTablePos as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(dwHashTablePos) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).dwBlockTablePos as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(dwBlockTablePos) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).dwHashTableSize as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(dwHashTableSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).dwBlockTableSize as *const _ as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(dwBlockTableSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).HiBlockTablePos64 as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(HiBlockTablePos64) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).wHashTablePosHi as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(wHashTablePosHi) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).wBlockTablePosHi as *const _ as usize }, - 42usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(wBlockTablePosHi) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).ArchiveSize64 as *const _ as usize }, - 44usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(ArchiveSize64) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).BetTablePos64 as *const _ as usize }, - 52usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(BetTablePos64) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).HetTablePos64 as *const _ as usize }, - 60usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(HetTablePos64) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).HashTableSize64 as *const _ as usize }, - 68usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(HashTableSize64) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).BlockTableSize64 as *const _ as usize }, - 76usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(BlockTableSize64) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).HiBlockTableSize64 as *const _ as usize }, - 84usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(HiBlockTableSize64) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).HetTableSize64 as *const _ as usize }, - 92usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(HetTableSize64) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).BetTableSize64 as *const _ as usize }, - 100usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(BetTableSize64) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).dwRawChunkSize as *const _ as usize }, - 108usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(dwRawChunkSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).MD5_BlockTable as *const _ as usize }, - 112usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(MD5_BlockTable) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).MD5_HashTable as *const _ as usize }, - 128usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(MD5_HashTable) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).MD5_HiBlockTable as *const _ as usize }, - 144usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(MD5_HiBlockTable) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).MD5_BetTable as *const _ as usize }, - 160usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(MD5_BetTable) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).MD5_HetTable as *const _ as usize }, - 176usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(MD5_HetTable) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHeader>())).MD5_MpqHeader as *const _ as usize }, - 192usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHeader), - "::", - stringify!(MD5_MpqHeader) - ) - ); -} -pub type TMPQHeader = _TMPQHeader; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _TMPQHash { - pub dwName1: DWORD, - pub dwName2: DWORD, - pub lcLocale: USHORT, - pub Platform: BYTE, - pub Reserved: BYTE, - pub dwBlockIndex: DWORD, -} -#[test] -fn bindgen_test_layout__TMPQHash() { - assert_eq!( - ::std::mem::size_of::<_TMPQHash>(), - 16usize, - concat!("Size of: ", stringify!(_TMPQHash)) - ); - assert_eq!( - ::std::mem::align_of::<_TMPQHash>(), - 4usize, - concat!("Alignment of ", stringify!(_TMPQHash)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHash>())).dwName1 as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHash), - "::", - stringify!(dwName1) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHash>())).dwName2 as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHash), - "::", - stringify!(dwName2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHash>())).lcLocale as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHash), - "::", - stringify!(lcLocale) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHash>())).Platform as *const _ as usize }, - 10usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHash), - "::", - stringify!(Platform) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHash>())).Reserved as *const _ as usize }, - 11usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHash), - "::", - stringify!(Reserved) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHash>())).dwBlockIndex as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHash), - "::", - stringify!(dwBlockIndex) - ) - ); -} -pub type TMPQHash = _TMPQHash; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _TMPQBlock { - pub dwFilePos: DWORD, - pub dwCSize: DWORD, - pub dwFSize: DWORD, - pub dwFlags: DWORD, -} -#[test] -fn bindgen_test_layout__TMPQBlock() { - assert_eq!( - ::std::mem::size_of::<_TMPQBlock>(), - 16usize, - concat!("Size of: ", stringify!(_TMPQBlock)) - ); - assert_eq!( - ::std::mem::align_of::<_TMPQBlock>(), - 4usize, - concat!("Alignment of ", stringify!(_TMPQBlock)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQBlock>())).dwFilePos as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBlock), - "::", - stringify!(dwFilePos) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQBlock>())).dwCSize as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBlock), - "::", - stringify!(dwCSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQBlock>())).dwFSize as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBlock), - "::", - stringify!(dwFSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQBlock>())).dwFlags as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBlock), - "::", - stringify!(dwFlags) - ) - ); -} -pub type TMPQBlock = _TMPQBlock; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _TPatchInfo { - pub dwLength: DWORD, - pub dwFlags: DWORD, - pub dwDataSize: DWORD, - pub md5: [BYTE; 16usize], -} -#[test] -fn bindgen_test_layout__TPatchInfo() { - assert_eq!( - ::std::mem::size_of::<_TPatchInfo>(), - 28usize, - concat!("Size of: ", stringify!(_TPatchInfo)) - ); - assert_eq!( - ::std::mem::align_of::<_TPatchInfo>(), - 4usize, - concat!("Alignment of ", stringify!(_TPatchInfo)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TPatchInfo>())).dwLength as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_TPatchInfo), - "::", - stringify!(dwLength) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TPatchInfo>())).dwFlags as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(_TPatchInfo), - "::", - stringify!(dwFlags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TPatchInfo>())).dwDataSize as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_TPatchInfo), - "::", - stringify!(dwDataSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TPatchInfo>())).md5 as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(_TPatchInfo), - "::", - stringify!(md5) - ) - ); -} -pub type TPatchInfo = _TPatchInfo; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _TFileEntry { - pub FileNameHash: ULONGLONG, - pub ByteOffset: ULONGLONG, - pub FileTime: ULONGLONG, - pub dwFileSize: DWORD, - pub dwCmpSize: DWORD, - pub dwFlags: DWORD, - pub dwCrc32: DWORD, - pub md5: [BYTE; 16usize], - pub szFileName: *mut ::std::os::raw::c_char, -} -#[test] -fn bindgen_test_layout__TFileEntry() { - assert_eq!( - ::std::mem::size_of::<_TFileEntry>(), - 64usize, - concat!("Size of: ", stringify!(_TFileEntry)) - ); - assert_eq!( - ::std::mem::align_of::<_TFileEntry>(), - 8usize, - concat!("Alignment of ", stringify!(_TFileEntry)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TFileEntry>())).FileNameHash as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_TFileEntry), - "::", - stringify!(FileNameHash) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TFileEntry>())).ByteOffset as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_TFileEntry), - "::", - stringify!(ByteOffset) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TFileEntry>())).FileTime as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(_TFileEntry), - "::", - stringify!(FileTime) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TFileEntry>())).dwFileSize as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(_TFileEntry), - "::", - stringify!(dwFileSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TFileEntry>())).dwCmpSize as *const _ as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(_TFileEntry), - "::", - stringify!(dwCmpSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TFileEntry>())).dwFlags as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(_TFileEntry), - "::", - stringify!(dwFlags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TFileEntry>())).dwCrc32 as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(_TFileEntry), - "::", - stringify!(dwCrc32) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TFileEntry>())).md5 as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(_TFileEntry), - "::", - stringify!(md5) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TFileEntry>())).szFileName as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(_TFileEntry), - "::", - stringify!(szFileName) - ) - ); -} -pub type TFileEntry = _TFileEntry; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _TMPQExtHeader { - pub dwSignature: DWORD, - pub dwVersion: DWORD, - pub dwDataSize: DWORD, -} -#[test] -fn bindgen_test_layout__TMPQExtHeader() { - assert_eq!( - ::std::mem::size_of::<_TMPQExtHeader>(), - 12usize, - concat!("Size of: ", stringify!(_TMPQExtHeader)) - ); - assert_eq!( - ::std::mem::align_of::<_TMPQExtHeader>(), - 4usize, - concat!("Alignment of ", stringify!(_TMPQExtHeader)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQExtHeader>())).dwSignature as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_TMPQExtHeader), - "::", - stringify!(dwSignature) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQExtHeader>())).dwVersion as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(_TMPQExtHeader), - "::", - stringify!(dwVersion) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQExtHeader>())).dwDataSize as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_TMPQExtHeader), - "::", - stringify!(dwDataSize) - ) - ); -} -pub type TMPQExtHeader = _TMPQExtHeader; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _TMPQHetHeader { - pub ExtHdr: TMPQExtHeader, - pub dwTableSize: DWORD, - pub dwEntryCount: DWORD, - pub dwTotalCount: DWORD, - pub dwNameHashBitSize: DWORD, - pub dwIndexSizeTotal: DWORD, - pub dwIndexSizeExtra: DWORD, - pub dwIndexSize: DWORD, - pub dwIndexTableSize: DWORD, -} -#[test] -fn bindgen_test_layout__TMPQHetHeader() { - assert_eq!( - ::std::mem::size_of::<_TMPQHetHeader>(), - 44usize, - concat!("Size of: ", stringify!(_TMPQHetHeader)) - ); - assert_eq!( - ::std::mem::align_of::<_TMPQHetHeader>(), - 4usize, - concat!("Alignment of ", stringify!(_TMPQHetHeader)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHetHeader>())).ExtHdr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHetHeader), - "::", - stringify!(ExtHdr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHetHeader>())).dwTableSize as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHetHeader), - "::", - stringify!(dwTableSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHetHeader>())).dwEntryCount as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHetHeader), - "::", - stringify!(dwEntryCount) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHetHeader>())).dwTotalCount as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHetHeader), - "::", - stringify!(dwTotalCount) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQHetHeader>())).dwNameHashBitSize as *const _ as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHetHeader), - "::", - stringify!(dwNameHashBitSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHetHeader>())).dwIndexSizeTotal as *const _ as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHetHeader), - "::", - stringify!(dwIndexSizeTotal) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHetHeader>())).dwIndexSizeExtra as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHetHeader), - "::", - stringify!(dwIndexSizeExtra) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHetHeader>())).dwIndexSize as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHetHeader), - "::", - stringify!(dwIndexSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHetHeader>())).dwIndexTableSize as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHetHeader), - "::", - stringify!(dwIndexTableSize) - ) - ); -} -pub type TMPQHetHeader = _TMPQHetHeader; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _TMPQBetHeader { - pub ExtHdr: TMPQExtHeader, - pub dwTableSize: DWORD, - pub dwEntryCount: DWORD, - pub dwUnknown08: DWORD, - pub dwTableEntrySize: DWORD, - pub dwBitIndex_FilePos: DWORD, - pub dwBitIndex_FileSize: DWORD, - pub dwBitIndex_CmpSize: DWORD, - pub dwBitIndex_FlagIndex: DWORD, - pub dwBitIndex_Unknown: DWORD, - pub dwBitCount_FilePos: DWORD, - pub dwBitCount_FileSize: DWORD, - pub dwBitCount_CmpSize: DWORD, - pub dwBitCount_FlagIndex: DWORD, - pub dwBitCount_Unknown: DWORD, - pub dwBitTotal_NameHash2: DWORD, - pub dwBitExtra_NameHash2: DWORD, - pub dwBitCount_NameHash2: DWORD, - pub dwNameHashArraySize: DWORD, - pub dwFlagCount: DWORD, -} -#[test] -fn bindgen_test_layout__TMPQBetHeader() { - assert_eq!( - ::std::mem::size_of::<_TMPQBetHeader>(), - 88usize, - concat!("Size of: ", stringify!(_TMPQBetHeader)) - ); - assert_eq!( - ::std::mem::align_of::<_TMPQBetHeader>(), - 4usize, - concat!("Alignment of ", stringify!(_TMPQBetHeader)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQBetHeader>())).ExtHdr as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetHeader), - "::", - stringify!(ExtHdr) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQBetHeader>())).dwTableSize as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetHeader), - "::", - stringify!(dwTableSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQBetHeader>())).dwEntryCount as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetHeader), - "::", - stringify!(dwEntryCount) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQBetHeader>())).dwUnknown08 as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetHeader), - "::", - stringify!(dwUnknown08) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQBetHeader>())).dwTableEntrySize as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetHeader), - "::", - stringify!(dwTableEntrySize) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetHeader>())).dwBitIndex_FilePos as *const _ as usize - }, - 28usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetHeader), - "::", - stringify!(dwBitIndex_FilePos) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetHeader>())).dwBitIndex_FileSize as *const _ as usize - }, - 32usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetHeader), - "::", - stringify!(dwBitIndex_FileSize) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetHeader>())).dwBitIndex_CmpSize as *const _ as usize - }, - 36usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetHeader), - "::", - stringify!(dwBitIndex_CmpSize) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetHeader>())).dwBitIndex_FlagIndex as *const _ as usize - }, - 40usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetHeader), - "::", - stringify!(dwBitIndex_FlagIndex) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetHeader>())).dwBitIndex_Unknown as *const _ as usize - }, - 44usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetHeader), - "::", - stringify!(dwBitIndex_Unknown) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetHeader>())).dwBitCount_FilePos as *const _ as usize - }, - 48usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetHeader), - "::", - stringify!(dwBitCount_FilePos) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetHeader>())).dwBitCount_FileSize as *const _ as usize - }, - 52usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetHeader), - "::", - stringify!(dwBitCount_FileSize) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetHeader>())).dwBitCount_CmpSize as *const _ as usize - }, - 56usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetHeader), - "::", - stringify!(dwBitCount_CmpSize) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetHeader>())).dwBitCount_FlagIndex as *const _ as usize - }, - 60usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetHeader), - "::", - stringify!(dwBitCount_FlagIndex) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetHeader>())).dwBitCount_Unknown as *const _ as usize - }, - 64usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetHeader), - "::", - stringify!(dwBitCount_Unknown) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetHeader>())).dwBitTotal_NameHash2 as *const _ as usize - }, - 68usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetHeader), - "::", - stringify!(dwBitTotal_NameHash2) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetHeader>())).dwBitExtra_NameHash2 as *const _ as usize - }, - 72usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetHeader), - "::", - stringify!(dwBitExtra_NameHash2) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetHeader>())).dwBitCount_NameHash2 as *const _ as usize - }, - 76usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetHeader), - "::", - stringify!(dwBitCount_NameHash2) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetHeader>())).dwNameHashArraySize as *const _ as usize - }, - 80usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetHeader), - "::", - stringify!(dwNameHashArraySize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQBetHeader>())).dwFlagCount as *const _ as usize }, - 84usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetHeader), - "::", - stringify!(dwFlagCount) - ) - ); -} -pub type TMPQBetHeader = _TMPQBetHeader; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _TMPQHetTable { - pub pBetIndexes: *mut TBitArray, - pub pNameHashes: LPBYTE, - pub AndMask64: ULONGLONG, - pub OrMask64: ULONGLONG, - pub dwEntryCount: DWORD, - pub dwTotalCount: DWORD, - pub dwNameHashBitSize: DWORD, - pub dwIndexSizeTotal: DWORD, - pub dwIndexSizeExtra: DWORD, - pub dwIndexSize: DWORD, -} -#[test] -fn bindgen_test_layout__TMPQHetTable() { - assert_eq!( - ::std::mem::size_of::<_TMPQHetTable>(), - 56usize, - concat!("Size of: ", stringify!(_TMPQHetTable)) - ); - assert_eq!( - ::std::mem::align_of::<_TMPQHetTable>(), - 8usize, - concat!("Alignment of ", stringify!(_TMPQHetTable)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHetTable>())).pBetIndexes as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHetTable), - "::", - stringify!(pBetIndexes) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHetTable>())).pNameHashes as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHetTable), - "::", - stringify!(pNameHashes) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHetTable>())).AndMask64 as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHetTable), - "::", - stringify!(AndMask64) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHetTable>())).OrMask64 as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHetTable), - "::", - stringify!(OrMask64) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHetTable>())).dwEntryCount as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHetTable), - "::", - stringify!(dwEntryCount) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHetTable>())).dwTotalCount as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHetTable), - "::", - stringify!(dwTotalCount) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHetTable>())).dwNameHashBitSize as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHetTable), - "::", - stringify!(dwNameHashBitSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHetTable>())).dwIndexSizeTotal as *const _ as usize }, - 44usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHetTable), - "::", - stringify!(dwIndexSizeTotal) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHetTable>())).dwIndexSizeExtra as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHetTable), - "::", - stringify!(dwIndexSizeExtra) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQHetTable>())).dwIndexSize as *const _ as usize }, - 52usize, - concat!( - "Offset of field: ", - stringify!(_TMPQHetTable), - "::", - stringify!(dwIndexSize) - ) - ); -} -pub type TMPQHetTable = _TMPQHetTable; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _TMPQBetTable { - pub pNameHashes: *mut TBitArray, - pub pFileTable: *mut TBitArray, - pub pFileFlags: LPDWORD, - pub dwTableEntrySize: DWORD, - pub dwBitIndex_FilePos: DWORD, - pub dwBitIndex_FileSize: DWORD, - pub dwBitIndex_CmpSize: DWORD, - pub dwBitIndex_FlagIndex: DWORD, - pub dwBitIndex_Unknown: DWORD, - pub dwBitCount_FilePos: DWORD, - pub dwBitCount_FileSize: DWORD, - pub dwBitCount_CmpSize: DWORD, - pub dwBitCount_FlagIndex: DWORD, - pub dwBitCount_Unknown: DWORD, - pub dwBitTotal_NameHash2: DWORD, - pub dwBitExtra_NameHash2: DWORD, - pub dwBitCount_NameHash2: DWORD, - pub dwEntryCount: DWORD, - pub dwFlagCount: DWORD, -} -#[test] -fn bindgen_test_layout__TMPQBetTable() { - assert_eq!( - ::std::mem::size_of::<_TMPQBetTable>(), - 88usize, - concat!("Size of: ", stringify!(_TMPQBetTable)) - ); - assert_eq!( - ::std::mem::align_of::<_TMPQBetTable>(), - 8usize, - concat!("Alignment of ", stringify!(_TMPQBetTable)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQBetTable>())).pNameHashes as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetTable), - "::", - stringify!(pNameHashes) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQBetTable>())).pFileTable as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetTable), - "::", - stringify!(pFileTable) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQBetTable>())).pFileFlags as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetTable), - "::", - stringify!(pFileFlags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQBetTable>())).dwTableEntrySize as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetTable), - "::", - stringify!(dwTableEntrySize) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetTable>())).dwBitIndex_FilePos as *const _ as usize - }, - 28usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetTable), - "::", - stringify!(dwBitIndex_FilePos) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetTable>())).dwBitIndex_FileSize as *const _ as usize - }, - 32usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetTable), - "::", - stringify!(dwBitIndex_FileSize) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetTable>())).dwBitIndex_CmpSize as *const _ as usize - }, - 36usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetTable), - "::", - stringify!(dwBitIndex_CmpSize) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetTable>())).dwBitIndex_FlagIndex as *const _ as usize - }, - 40usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetTable), - "::", - stringify!(dwBitIndex_FlagIndex) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetTable>())).dwBitIndex_Unknown as *const _ as usize - }, - 44usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetTable), - "::", - stringify!(dwBitIndex_Unknown) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetTable>())).dwBitCount_FilePos as *const _ as usize - }, - 48usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetTable), - "::", - stringify!(dwBitCount_FilePos) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetTable>())).dwBitCount_FileSize as *const _ as usize - }, - 52usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetTable), - "::", - stringify!(dwBitCount_FileSize) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetTable>())).dwBitCount_CmpSize as *const _ as usize - }, - 56usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetTable), - "::", - stringify!(dwBitCount_CmpSize) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetTable>())).dwBitCount_FlagIndex as *const _ as usize - }, - 60usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetTable), - "::", - stringify!(dwBitCount_FlagIndex) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetTable>())).dwBitCount_Unknown as *const _ as usize - }, - 64usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetTable), - "::", - stringify!(dwBitCount_Unknown) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetTable>())).dwBitTotal_NameHash2 as *const _ as usize - }, - 68usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetTable), - "::", - stringify!(dwBitTotal_NameHash2) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetTable>())).dwBitExtra_NameHash2 as *const _ as usize - }, - 72usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetTable), - "::", - stringify!(dwBitExtra_NameHash2) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQBetTable>())).dwBitCount_NameHash2 as *const _ as usize - }, - 76usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetTable), - "::", - stringify!(dwBitCount_NameHash2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQBetTable>())).dwEntryCount as *const _ as usize }, - 80usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetTable), - "::", - stringify!(dwEntryCount) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQBetTable>())).dwFlagCount as *const _ as usize }, - 84usize, - concat!( - "Offset of field: ", - stringify!(_TMPQBetTable), - "::", - stringify!(dwFlagCount) - ) - ); -} -pub type TMPQBetTable = _TMPQBetTable; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _TMPQNamePrefix { - pub nLength: usize, - pub szPatchPrefix: [::std::os::raw::c_char; 1usize], -} -#[test] -fn bindgen_test_layout__TMPQNamePrefix() { - assert_eq!( - ::std::mem::size_of::<_TMPQNamePrefix>(), - 16usize, - concat!("Size of: ", stringify!(_TMPQNamePrefix)) - ); - assert_eq!( - ::std::mem::align_of::<_TMPQNamePrefix>(), - 8usize, - concat!("Alignment of ", stringify!(_TMPQNamePrefix)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQNamePrefix>())).nLength as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_TMPQNamePrefix), - "::", - stringify!(nLength) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQNamePrefix>())).szPatchPrefix as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_TMPQNamePrefix), - "::", - stringify!(szPatchPrefix) - ) - ); -} -pub type TMPQNamePrefix = _TMPQNamePrefix; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _TMPQNameCache { - pub FirstNameOffset: DWORD, - pub FreeSpaceOffset: DWORD, - pub TotalCacheSize: DWORD, - pub SearchOffset: DWORD, -} -#[test] -fn bindgen_test_layout__TMPQNameCache() { - assert_eq!( - ::std::mem::size_of::<_TMPQNameCache>(), - 16usize, - concat!("Size of: ", stringify!(_TMPQNameCache)) - ); - assert_eq!( - ::std::mem::align_of::<_TMPQNameCache>(), - 4usize, - concat!("Alignment of ", stringify!(_TMPQNameCache)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQNameCache>())).FirstNameOffset as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_TMPQNameCache), - "::", - stringify!(FirstNameOffset) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQNameCache>())).FreeSpaceOffset as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(_TMPQNameCache), - "::", - stringify!(FreeSpaceOffset) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQNameCache>())).TotalCacheSize as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_TMPQNameCache), - "::", - stringify!(TotalCacheSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQNameCache>())).SearchOffset as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(_TMPQNameCache), - "::", - stringify!(SearchOffset) - ) - ); -} -pub type TMPQNameCache = _TMPQNameCache; -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _TMPQArchive { - pub pStream: *mut TFileStream, - pub UserDataPos: ULONGLONG, - pub MpqPos: ULONGLONG, - pub FileSize: ULONGLONG, - pub haPatch: *mut _TMPQArchive, - pub haBase: *mut _TMPQArchive, - pub pPatchPrefix: *mut TMPQNamePrefix, - pub pUserData: *mut TMPQUserData, - pub pHeader: *mut TMPQHeader, - pub pHashTable: *mut TMPQHash, - pub pHetTable: *mut TMPQHetTable, - pub pFileTable: *mut TFileEntry, - pub pfnHashString: HASH_STRING, - pub UserData: TMPQUserData, - pub HeaderData: [DWORD; 52usize], - pub dwHETBlockSize: DWORD, - pub dwBETBlockSize: DWORD, - pub dwMaxFileCount: DWORD, - pub dwFileTableSize: DWORD, - pub dwReservedFiles: DWORD, - pub dwSectorSize: DWORD, - pub dwFileFlags1: DWORD, - pub dwFileFlags2: DWORD, - pub dwFileFlags3: DWORD, - pub dwAttrFlags: DWORD, - pub dwFlags: DWORD, - pub dwSubType: DWORD, - pub pfnAddFileCB: SFILE_ADDFILE_CALLBACK, - pub pvAddFileUserData: *mut ::std::os::raw::c_void, - pub pfnCompactCB: SFILE_COMPACT_CALLBACK, - pub CompactBytesProcessed: ULONGLONG, - pub CompactTotalBytes: ULONGLONG, - pub pvCompactUserData: *mut ::std::os::raw::c_void, -} -#[test] -fn bindgen_test_layout__TMPQArchive() { - assert_eq!( - ::std::mem::size_of::<_TMPQArchive>(), - 424usize, - concat!("Size of: ", stringify!(_TMPQArchive)) - ); - assert_eq!( - ::std::mem::align_of::<_TMPQArchive>(), - 8usize, - concat!("Alignment of ", stringify!(_TMPQArchive)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).pStream as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(pStream) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).UserDataPos as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(UserDataPos) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).MpqPos as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(MpqPos) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).FileSize as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(FileSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).haPatch as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(haPatch) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).haBase as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(haBase) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).pPatchPrefix as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(pPatchPrefix) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).pUserData as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(pUserData) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).pHeader as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(pHeader) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).pHashTable as *const _ as usize }, - 72usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(pHashTable) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).pHetTable as *const _ as usize }, - 80usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(pHetTable) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).pFileTable as *const _ as usize }, - 88usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(pFileTable) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).pfnHashString as *const _ as usize }, - 96usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(pfnHashString) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).UserData as *const _ as usize }, - 104usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(UserData) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).HeaderData as *const _ as usize }, - 120usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(HeaderData) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).dwHETBlockSize as *const _ as usize }, - 328usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(dwHETBlockSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).dwBETBlockSize as *const _ as usize }, - 332usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(dwBETBlockSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).dwMaxFileCount as *const _ as usize }, - 336usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(dwMaxFileCount) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).dwFileTableSize as *const _ as usize }, - 340usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(dwFileTableSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).dwReservedFiles as *const _ as usize }, - 344usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(dwReservedFiles) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).dwSectorSize as *const _ as usize }, - 348usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(dwSectorSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).dwFileFlags1 as *const _ as usize }, - 352usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(dwFileFlags1) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).dwFileFlags2 as *const _ as usize }, - 356usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(dwFileFlags2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).dwFileFlags3 as *const _ as usize }, - 360usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(dwFileFlags3) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).dwAttrFlags as *const _ as usize }, - 364usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(dwAttrFlags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).dwFlags as *const _ as usize }, - 368usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(dwFlags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).dwSubType as *const _ as usize }, - 372usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(dwSubType) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).pfnAddFileCB as *const _ as usize }, - 376usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(pfnAddFileCB) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).pvAddFileUserData as *const _ as usize }, - 384usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(pvAddFileUserData) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).pfnCompactCB as *const _ as usize }, - 392usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(pfnCompactCB) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_TMPQArchive>())).CompactBytesProcessed as *const _ as usize - }, - 400usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(CompactBytesProcessed) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).CompactTotalBytes as *const _ as usize }, - 408usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(CompactTotalBytes) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQArchive>())).pvCompactUserData as *const _ as usize }, - 416usize, - concat!( - "Offset of field: ", - stringify!(_TMPQArchive), - "::", - stringify!(pvCompactUserData) - ) - ); -} -pub type TMPQArchive = _TMPQArchive; -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _TMPQFile { - pub pStream: *mut TFileStream, - pub ha: *mut TMPQArchive, - pub pHashEntry: *mut TMPQHash, - pub pFileEntry: *mut TFileEntry, - pub RawFilePos: ULONGLONG, - pub MpqFilePos: ULONGLONG, - pub dwHashIndex: DWORD, - pub dwFileKey: DWORD, - pub dwFilePos: DWORD, - pub dwMagic: DWORD, - pub hfPatch: *mut _TMPQFile, - pub pPatchInfo: *mut TPatchInfo, - pub SectorOffsets: LPDWORD, - pub SectorChksums: LPDWORD, - pub pbFileData: LPBYTE, - pub cbFileData: DWORD, - pub dwCompression0: DWORD, - pub dwSectorCount: DWORD, - pub dwPatchedFileSize: DWORD, - pub dwDataSize: DWORD, - pub pbFileSector: LPBYTE, - pub dwSectorOffs: DWORD, - pub dwSectorSize: DWORD, - pub hctx: [::std::os::raw::c_uchar; 96usize], - pub dwCrc32: DWORD, - pub nAddFileError: ::std::os::raw::c_int, - pub bLoadedSectorCRCs: bool, - pub bCheckSectorCRCs: bool, - pub bIsWriteHandle: bool, -} -#[test] -fn bindgen_test_layout__TMPQFile() { - assert_eq!( - ::std::mem::size_of::<_TMPQFile>(), - 256usize, - concat!("Size of: ", stringify!(_TMPQFile)) - ); - assert_eq!( - ::std::mem::align_of::<_TMPQFile>(), - 8usize, - concat!("Alignment of ", stringify!(_TMPQFile)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).pStream as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(pStream) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).ha as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(ha) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).pHashEntry as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(pHashEntry) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).pFileEntry as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(pFileEntry) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).RawFilePos as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(RawFilePos) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).MpqFilePos as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(MpqFilePos) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).dwHashIndex as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(dwHashIndex) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).dwFileKey as *const _ as usize }, - 52usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(dwFileKey) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).dwFilePos as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(dwFilePos) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).dwMagic as *const _ as usize }, - 60usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(dwMagic) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).hfPatch as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(hfPatch) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).pPatchInfo as *const _ as usize }, - 72usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(pPatchInfo) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).SectorOffsets as *const _ as usize }, - 80usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(SectorOffsets) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).SectorChksums as *const _ as usize }, - 88usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(SectorChksums) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).pbFileData as *const _ as usize }, - 96usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(pbFileData) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).cbFileData as *const _ as usize }, - 104usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(cbFileData) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).dwCompression0 as *const _ as usize }, - 108usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(dwCompression0) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).dwSectorCount as *const _ as usize }, - 112usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(dwSectorCount) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).dwPatchedFileSize as *const _ as usize }, - 116usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(dwPatchedFileSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).dwDataSize as *const _ as usize }, - 120usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(dwDataSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).pbFileSector as *const _ as usize }, - 128usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(pbFileSector) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).dwSectorOffs as *const _ as usize }, - 136usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(dwSectorOffs) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).dwSectorSize as *const _ as usize }, - 140usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(dwSectorSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).hctx as *const _ as usize }, - 144usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(hctx) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).dwCrc32 as *const _ as usize }, - 240usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(dwCrc32) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).nAddFileError as *const _ as usize }, - 244usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(nAddFileError) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).bLoadedSectorCRCs as *const _ as usize }, - 248usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(bLoadedSectorCRCs) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).bCheckSectorCRCs as *const _ as usize }, - 249usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(bCheckSectorCRCs) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TMPQFile>())).bIsWriteHandle as *const _ as usize }, - 250usize, - concat!( - "Offset of field: ", - stringify!(_TMPQFile), - "::", - stringify!(bIsWriteHandle) - ) - ); -} -pub type TMPQFile = _TMPQFile; -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _SFILE_FIND_DATA { - pub cFileName: [::std::os::raw::c_char; 1024usize], - pub szPlainName: *mut ::std::os::raw::c_char, - pub dwHashIndex: DWORD, - pub dwBlockIndex: DWORD, - pub dwFileSize: DWORD, - pub dwFileFlags: DWORD, - pub dwCompSize: DWORD, - pub dwFileTimeLo: DWORD, - pub dwFileTimeHi: DWORD, - pub lcLocale: LCID, -} -#[test] -fn bindgen_test_layout__SFILE_FIND_DATA() { - assert_eq!( - ::std::mem::size_of::<_SFILE_FIND_DATA>(), - 1064usize, - concat!("Size of: ", stringify!(_SFILE_FIND_DATA)) - ); - assert_eq!( - ::std::mem::align_of::<_SFILE_FIND_DATA>(), - 8usize, - concat!("Alignment of ", stringify!(_SFILE_FIND_DATA)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).cFileName as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_SFILE_FIND_DATA), - "::", - stringify!(cFileName) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).szPlainName as *const _ as usize }, - 1024usize, - concat!( - "Offset of field: ", - stringify!(_SFILE_FIND_DATA), - "::", - stringify!(szPlainName) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwHashIndex as *const _ as usize }, - 1032usize, - concat!( - "Offset of field: ", - stringify!(_SFILE_FIND_DATA), - "::", - stringify!(dwHashIndex) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwBlockIndex as *const _ as usize }, - 1036usize, - concat!( - "Offset of field: ", - stringify!(_SFILE_FIND_DATA), - "::", - stringify!(dwBlockIndex) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwFileSize as *const _ as usize }, - 1040usize, - concat!( - "Offset of field: ", - stringify!(_SFILE_FIND_DATA), - "::", - stringify!(dwFileSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwFileFlags as *const _ as usize }, - 1044usize, - concat!( - "Offset of field: ", - stringify!(_SFILE_FIND_DATA), - "::", - stringify!(dwFileFlags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwCompSize as *const _ as usize }, - 1048usize, - concat!( - "Offset of field: ", - stringify!(_SFILE_FIND_DATA), - "::", - stringify!(dwCompSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwFileTimeLo as *const _ as usize }, - 1052usize, - concat!( - "Offset of field: ", - stringify!(_SFILE_FIND_DATA), - "::", - stringify!(dwFileTimeLo) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).dwFileTimeHi as *const _ as usize }, - 1056usize, - concat!( - "Offset of field: ", - stringify!(_SFILE_FIND_DATA), - "::", - stringify!(dwFileTimeHi) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_SFILE_FIND_DATA>())).lcLocale as *const _ as usize }, - 1060usize, - concat!( - "Offset of field: ", - stringify!(_SFILE_FIND_DATA), - "::", - stringify!(lcLocale) - ) - ); -} -pub type SFILE_FIND_DATA = _SFILE_FIND_DATA; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _SFILE_CREATE_MPQ { - pub cbSize: DWORD, - pub dwMpqVersion: DWORD, - pub pvUserData: *mut ::std::os::raw::c_void, - pub cbUserData: DWORD, - pub dwStreamFlags: DWORD, - pub dwFileFlags1: DWORD, - pub dwFileFlags2: DWORD, - pub dwFileFlags3: DWORD, - pub dwAttrFlags: DWORD, - pub dwSectorSize: DWORD, - pub dwRawChunkSize: DWORD, - pub dwMaxFileCount: DWORD, -} -#[test] -fn bindgen_test_layout__SFILE_CREATE_MPQ() { - assert_eq!( - ::std::mem::size_of::<_SFILE_CREATE_MPQ>(), - 56usize, - concat!("Size of: ", stringify!(_SFILE_CREATE_MPQ)) - ); - assert_eq!( - ::std::mem::align_of::<_SFILE_CREATE_MPQ>(), - 8usize, - concat!("Alignment of ", stringify!(_SFILE_CREATE_MPQ)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).cbSize as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_SFILE_CREATE_MPQ), - "::", - stringify!(cbSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwMpqVersion as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(_SFILE_CREATE_MPQ), - "::", - stringify!(dwMpqVersion) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).pvUserData as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_SFILE_CREATE_MPQ), - "::", - stringify!(pvUserData) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).cbUserData as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(_SFILE_CREATE_MPQ), - "::", - stringify!(cbUserData) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwStreamFlags as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(_SFILE_CREATE_MPQ), - "::", - stringify!(dwStreamFlags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwFileFlags1 as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(_SFILE_CREATE_MPQ), - "::", - stringify!(dwFileFlags1) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwFileFlags2 as *const _ as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(_SFILE_CREATE_MPQ), - "::", - stringify!(dwFileFlags2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwFileFlags3 as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(_SFILE_CREATE_MPQ), - "::", - stringify!(dwFileFlags3) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwAttrFlags as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(_SFILE_CREATE_MPQ), - "::", - stringify!(dwAttrFlags) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwSectorSize as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(_SFILE_CREATE_MPQ), - "::", - stringify!(dwSectorSize) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwRawChunkSize as *const _ as usize - }, - 44usize, - concat!( - "Offset of field: ", - stringify!(_SFILE_CREATE_MPQ), - "::", - stringify!(dwRawChunkSize) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::<_SFILE_CREATE_MPQ>())).dwMaxFileCount as *const _ as usize - }, - 48usize, - concat!( - "Offset of field: ", - stringify!(_SFILE_CREATE_MPQ), - "::", - stringify!(dwMaxFileCount) - ) - ); -} -pub type PSFILE_CREATE_MPQ = *mut _SFILE_CREATE_MPQ; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _TStreamBitmap { - pub StreamSize: ULONGLONG, - pub BitmapSize: DWORD, - pub BlockCount: DWORD, - pub BlockSize: DWORD, - pub IsComplete: DWORD, -} -#[test] -fn bindgen_test_layout__TStreamBitmap() { - assert_eq!( - ::std::mem::size_of::<_TStreamBitmap>(), - 24usize, - concat!("Size of: ", stringify!(_TStreamBitmap)) - ); - assert_eq!( - ::std::mem::align_of::<_TStreamBitmap>(), - 8usize, - concat!("Alignment of ", stringify!(_TStreamBitmap)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TStreamBitmap>())).StreamSize as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_TStreamBitmap), - "::", - stringify!(StreamSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TStreamBitmap>())).BitmapSize as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_TStreamBitmap), - "::", - stringify!(BitmapSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TStreamBitmap>())).BlockCount as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(_TStreamBitmap), - "::", - stringify!(BlockCount) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TStreamBitmap>())).BlockSize as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(_TStreamBitmap), - "::", - stringify!(BlockSize) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<_TStreamBitmap>())).IsComplete as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(_TStreamBitmap), - "::", - stringify!(IsComplete) - ) - ); -} -pub type TStreamBitmap = _TStreamBitmap; -extern "C" { - pub fn SFileGetLocale() -> LCID; -} -extern "C" { - pub fn SFileSetLocale(lcNewLocale: LCID) -> LCID; -} -extern "C" { - pub fn SFileOpenArchive( - szMpqName: *const TCHAR, - dwPriority: DWORD, - dwFlags: DWORD, - phMpq: *mut HANDLE, - ) -> bool; -} -extern "C" { - pub fn SFileCreateArchive( - szMpqName: *const TCHAR, - dwCreateFlags: DWORD, - dwMaxFileCount: DWORD, - phMpq: *mut HANDLE, - ) -> bool; -} -extern "C" { - pub fn SFileCreateArchive2( - szMpqName: *const TCHAR, - pCreateInfo: PSFILE_CREATE_MPQ, - phMpq: *mut HANDLE, - ) -> bool; -} -extern "C" { - pub fn SFileSetDownloadCallback( - hMpq: HANDLE, - DownloadCB: SFILE_DOWNLOAD_CALLBACK, - pvUserData: *mut ::std::os::raw::c_void, - ) -> bool; -} -extern "C" { - pub fn SFileFlushArchive(hMpq: HANDLE) -> bool; -} -extern "C" { - pub fn SFileCloseArchive(hMpq: HANDLE) -> bool; -} -extern "C" { - pub fn SFileAddListFile(hMpq: HANDLE, szListFile: *const TCHAR) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn SFileSetCompactCallback( - hMpq: HANDLE, - CompactCB: SFILE_COMPACT_CALLBACK, - pvUserData: *mut ::std::os::raw::c_void, - ) -> bool; -} -extern "C" { - pub fn SFileCompactArchive(hMpq: HANDLE, szListFile: *const TCHAR, bReserved: bool) -> bool; -} -extern "C" { - pub fn SFileGetMaxFileCount(hMpq: HANDLE) -> DWORD; -} -extern "C" { - pub fn SFileSetMaxFileCount(hMpq: HANDLE, dwMaxFileCount: DWORD) -> bool; -} -extern "C" { - pub fn SFileGetAttributes(hMpq: HANDLE) -> DWORD; -} -extern "C" { - pub fn SFileSetAttributes(hMpq: HANDLE, dwFlags: DWORD) -> bool; -} -extern "C" { - pub fn SFileUpdateFileAttributes( - hMpq: HANDLE, - szFileName: *const ::std::os::raw::c_char, - ) -> bool; -} -extern "C" { - pub fn SFileOpenPatchArchive( - hMpq: HANDLE, - szPatchMpqName: *const TCHAR, - szPatchPathPrefix: *const ::std::os::raw::c_char, - dwFlags: DWORD, - ) -> bool; -} -extern "C" { - pub fn SFileIsPatchedArchive(hMpq: HANDLE) -> bool; -} -extern "C" { - pub fn SFileHasFile(hMpq: HANDLE, szFileName: *const ::std::os::raw::c_char) -> bool; -} -extern "C" { - pub fn SFileOpenFileEx( - hMpq: HANDLE, - szFileName: *const ::std::os::raw::c_char, - dwSearchScope: DWORD, - phFile: *mut HANDLE, - ) -> bool; -} -extern "C" { - pub fn SFileGetFileSize(hFile: HANDLE, pdwFileSizeHigh: LPDWORD) -> DWORD; -} -extern "C" { - pub fn SFileSetFilePointer( - hFile: HANDLE, - lFilePos: LONG, - plFilePosHigh: *mut LONG, - dwMoveMethod: DWORD, - ) -> DWORD; -} -extern "C" { - pub fn SFileReadFile( - hFile: HANDLE, - lpBuffer: *mut ::std::os::raw::c_void, - dwToRead: DWORD, - pdwRead: LPDWORD, - lpOverlapped: LPOVERLAPPED, - ) -> bool; -} -extern "C" { - pub fn SFileCloseFile(hFile: HANDLE) -> bool; -} -extern "C" { - pub fn SFileGetFileInfo( - hMpqOrFile: HANDLE, - InfoClass: SFileInfoClass, - pvFileInfo: *mut ::std::os::raw::c_void, - cbFileInfo: DWORD, - pcbLengthNeeded: LPDWORD, - ) -> bool; -} -extern "C" { - pub fn SFileGetFileName(hFile: HANDLE, szFileName: *mut ::std::os::raw::c_char) -> bool; -} -extern "C" { - pub fn SFileFreeFileInfo( - pvFileInfo: *mut ::std::os::raw::c_void, - InfoClass: SFileInfoClass, - ) -> bool; -} -extern "C" { - pub fn SFileExtractFile( - hMpq: HANDLE, - szToExtract: *const ::std::os::raw::c_char, - szExtracted: *const TCHAR, - dwSearchScope: DWORD, - ) -> bool; -} -extern "C" { - pub fn SFileGetFileChecksums( - hMpq: HANDLE, - szFileName: *const ::std::os::raw::c_char, - pdwCrc32: LPDWORD, - pMD5: *mut ::std::os::raw::c_char, - ) -> bool; -} -extern "C" { - pub fn SFileVerifyFile( - hMpq: HANDLE, - szFileName: *const ::std::os::raw::c_char, - dwFlags: DWORD, - ) -> DWORD; -} -extern "C" { - pub fn SFileVerifyRawData( - hMpq: HANDLE, - dwWhatToVerify: DWORD, - szFileName: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn SFileSignArchive(hMpq: HANDLE, dwSignatureType: DWORD) -> bool; -} -extern "C" { - pub fn SFileVerifyArchive(hMpq: HANDLE) -> DWORD; -} -extern "C" { - pub fn SFileFindFirstFile( - hMpq: HANDLE, - szMask: *const ::std::os::raw::c_char, - lpFindFileData: *mut SFILE_FIND_DATA, - szListFile: *const TCHAR, - ) -> HANDLE; -} -extern "C" { - pub fn SFileFindNextFile(hFind: HANDLE, lpFindFileData: *mut SFILE_FIND_DATA) -> bool; -} -extern "C" { - pub fn SFileFindClose(hFind: HANDLE) -> bool; -} -extern "C" { - pub fn SListFileFindFirstFile( - hMpq: HANDLE, - szListFile: *const TCHAR, - szMask: *const ::std::os::raw::c_char, - lpFindFileData: *mut SFILE_FIND_DATA, - ) -> HANDLE; -} -extern "C" { - pub fn SListFileFindNextFile(hFind: HANDLE, lpFindFileData: *mut SFILE_FIND_DATA) -> bool; -} -extern "C" { - pub fn SListFileFindClose(hFind: HANDLE) -> bool; -} -extern "C" { - pub fn SFileEnumLocales( - hMpq: HANDLE, - szFileName: *const ::std::os::raw::c_char, - plcLocales: *mut LCID, - pdwMaxLocales: LPDWORD, - dwSearchScope: DWORD, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn SFileCreateFile( - hMpq: HANDLE, - szArchivedName: *const ::std::os::raw::c_char, - FileTime: ULONGLONG, - dwFileSize: DWORD, - lcLocale: LCID, - dwFlags: DWORD, - phFile: *mut HANDLE, - ) -> bool; -} -extern "C" { - pub fn SFileWriteFile( - hFile: HANDLE, - pvData: *const ::std::os::raw::c_void, - dwSize: DWORD, - dwCompression: DWORD, - ) -> bool; -} -extern "C" { - pub fn SFileFinishFile(hFile: HANDLE) -> bool; -} -extern "C" { - pub fn SFileAddFileEx( - hMpq: HANDLE, - szFileName: *const TCHAR, - szArchivedName: *const ::std::os::raw::c_char, - dwFlags: DWORD, - dwCompression: DWORD, - dwCompressionNext: DWORD, - ) -> bool; -} -extern "C" { - pub fn SFileAddFile( - hMpq: HANDLE, - szFileName: *const TCHAR, - szArchivedName: *const ::std::os::raw::c_char, - dwFlags: DWORD, - ) -> bool; -} -extern "C" { - pub fn SFileAddWave( - hMpq: HANDLE, - szFileName: *const TCHAR, - szArchivedName: *const ::std::os::raw::c_char, - dwFlags: DWORD, - dwQuality: DWORD, - ) -> bool; -} -extern "C" { - pub fn SFileRemoveFile( - hMpq: HANDLE, - szFileName: *const ::std::os::raw::c_char, - dwSearchScope: DWORD, - ) -> bool; -} -extern "C" { - pub fn SFileRenameFile( - hMpq: HANDLE, - szOldFileName: *const ::std::os::raw::c_char, - szNewFileName: *const ::std::os::raw::c_char, - ) -> bool; -} -extern "C" { - pub fn SFileSetFileLocale(hFile: HANDLE, lcNewLocale: LCID) -> bool; -} -extern "C" { - pub fn SFileSetDataCompression(DataCompression: DWORD) -> bool; -} -extern "C" { - pub fn SFileSetAddFileCallback( - hMpq: HANDLE, - AddFileCB: SFILE_ADDFILE_CALLBACK, - pvUserData: *mut ::std::os::raw::c_void, - ) -> bool; -} -extern "C" { - pub fn GetLastError() -> DWORD; -} diff --git a/src/main.rs b/src/main.rs index 9ab9048..4707e0c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,12 +2,11 @@ extern crate clap; use clap::{Arg, App, SubCommand}; use failure::{Error}; +use stormlib::OpenArchiveFlags; use std::collections::HashMap; use std::fs; -use ceres_mpq as mpq; - struct File { name: String, path: String, @@ -131,7 +130,7 @@ fn run(matches: clap::ArgMatches) -> Result<(), Error> { } else if let Some(matches) = matches.subcommand_matches("pack") { let mpq = matches.value_of("mpq").unwrap(); let input = matches.value_of("input").unwrap(); - if matches.is_present("remove"){ + if matches.is_present("remove") { let remove = matches.value_of("remove").unwrap(); remove_file(mpq, remove)?; } @@ -180,8 +179,7 @@ fn exec(files: &FileList, output: &str, filelist: bool) -> Result { if std::path::Path::new(output).is_file() { fs::remove_file(output)?; } - - let ar = mpq::MPQArchive::create(output, files.len(), filelist)?; + let ar = stormlib::Archive::create(output, files.len(), filelist)?; for f in files { let data = fs::read(f.path.as_str())?; ar.write_file(f.name.as_str(), &*data)?; @@ -191,39 +189,32 @@ fn exec(files: &FileList, output: &str, filelist: bool) -> Result { } fn extract(mpq: &str, file: &str, output: &str) -> Result { - use storm_sys as storm; - let ar = mpq::MPQArchive::open(mpq, storm::MPQ_OPEN_READ_ONLY)?; - let exists = ar.has_file(file); + let mut ar = stormlib::Archive::open(mpq, OpenArchiveFlags::MPQ_OPEN_READ_ONLY)?; + let exists = ar.has_file(file).unwrap(); if exists { - let f = ar.open_file(file)?; - fs::write(output, f.read_contents()?)?; + let mut f = ar.open_file(file)?; + fs::write(output, f.read_all()?)?; } println!("extract file {}, {}", file, exists); Ok(true) } fn pack(mpq: &str, files: &FileList) -> Result { - let ar = mpq::MPQArchive::open(mpq, 0)?; - + let mut ar = stormlib::Archive::open(mpq, OpenArchiveFlags::MPQ_OPEN_NO_FLAG)?; for f in files { ar.add_file(f.name.as_str(), f.path.as_str())?; } - - ar.compact(); + ar.compact().unwrap(); Ok(true) } fn remove_file(mpq: &str, file: &str) -> Result { - let ar = mpq::MPQArchive::open(mpq, 0)?; - let spl:Vec<&str> = file.split(";").collect(); - let max = ar.get_max_files(); - let len = spl.len(); + let mut ar = stormlib::Archive::open(mpq, OpenArchiveFlags::MPQ_OPEN_NO_FLAG)?; + let spl: Vec<&str> = file.split(";").collect(); for _f in spl { - ar.remove_file(_f); + ar.remove_file(_f).unwrap(); println!("remove file:{}", _f); } - ar.set_max_files(max - len); - ar.compact(); - + ar.compact().unwrap(); Ok(true) -} \ No newline at end of file +}