diff options
author | yazoo <yazoo> | 2008-01-29 07:43:06 +0000 |
---|---|---|
committer | yazoo <yazoo> | 2008-01-29 07:43:06 +0000 |
commit | 8522e44467ebcac54201def2c6583639e74e9e24 (patch) | |
tree | 9d475da6b178bf96359f06d39773441b76b8d567 | |
parent | 7ecf94d4b339bc2197f449f0f1538f2915313087 (diff) |
Portage win32
-rw-r--r-- | MPQCryptography.c | 31 | ||||
-rw-r--r-- | MPQCryptography.h | 8 | ||||
-rw-r--r-- | extract.c | 9 | ||||
-rw-r--r-- | hashtab.c | 4 | ||||
-rw-r--r-- | hashtab.h | 4 | ||||
-rw-r--r-- | int-bios.h | 2 | ||||
-rw-r--r-- | lookupa.h | 4 | ||||
-rw-r--r-- | mpq-bios.c | 39 | ||||
-rw-r--r-- | mpq-bios.h | 4 | ||||
-rw-r--r-- | mpq-file.c | 9 | ||||
-rw-r--r-- | mpq-file.h | 5 | ||||
-rw-r--r-- | mpq-fs.h | 4 | ||||
-rw-r--r-- | mpq-misc.h | 4 | ||||
-rw-r--r-- | recycle.c | 4 |
14 files changed, 103 insertions, 28 deletions
diff --git a/MPQCryptography.c b/MPQCryptography.c index 9791c0a..6c33e55 100644 --- a/MPQCryptography.c +++ b/MPQCryptography.c @@ -25,7 +25,12 @@ #endif #include "MPQCryptography.h" + +#ifdef WIN32 +#include "stdint.h" +#else #include "inttypes.h" +#endif static int crypt_table_initialized = 0; static uint32_t crypt_table[0x500]; @@ -88,13 +93,13 @@ void __mpqlib_init_cryptography() void __mpqlib_encrypt(void *_data, uint32_t length, uint32_t key, bool disable_input_swapping) { - char * data = (char *) _data; - assert(crypt_table_initialized); - assert(data); - + char * data = (char *) _data; uint32_t *buffer32 = (uint32_t *) data; uint32_t seed = 0xEEEEEEEE; uint32_t ch; + + assert(crypt_table_initialized); + assert(data); // Round to 4 bytes length = length / 4; @@ -126,13 +131,13 @@ void __mpqlib_encrypt(void *_data, uint32_t length, uint32_t key, bool disable_i void __mpqlib_decrypt(void *_data, uint32_t length, uint32_t key, bool disable_output_swapping) { char * data = (char *) _data; - assert(crypt_table_initialized); - assert(data); - uint32_t *buffer32 = (uint32_t *) data; uint32_t seed = 0xEEEEEEEE; uint32_t ch; + assert(crypt_table_initialized); + assert(data); + // Round to 4 bytes length = length / 4; @@ -166,14 +171,14 @@ void __mpqlib_decrypt(void *_data, uint32_t length, uint32_t key, bool disable_o uint32_t __mpqlib_hash_cstring(const char *string, uint32_t type) { - assert(crypt_table_initialized); - assert(string); - uint32_t seed1 = 0x7FED7FED; uint32_t seed2 = 0xEEEEEEEE; uint32_t shifted_type = (type << 8); int32_t ch; + assert(crypt_table_initialized); + assert(string); + while (*string != 0) { ch = *string++; if (ch > 0x60 && ch < 0x7b) @@ -188,14 +193,14 @@ uint32_t __mpqlib_hash_cstring(const char *string, uint32_t type) uint32_t __mpqlib_hash_data(const char *data, uint32_t length, uint32_t type) { - assert(crypt_table_initialized); - assert(data); - uint32_t seed1 = 0x7FED7FED; uint32_t seed2 = 0xEEEEEEEE; uint32_t shifted_type = (type << 8); int32_t ch; + assert(crypt_table_initialized); + assert(data); + while (length > 0) { ch = *data++; diff --git a/MPQCryptography.h b/MPQCryptography.h index b1d621e..01aa418 100644 --- a/MPQCryptography.h +++ b/MPQCryptography.h @@ -7,9 +7,15 @@ * */ +#ifdef WIN32 +#include "stdint.h" +#include <stdlib.h> +#define bool char +#else #include <stdbool.h> #include <stdint.h> #include <openssl/rsa.h> +#endif #if defined(__cplusplus) extern "C" { @@ -40,8 +46,10 @@ extern "C" { #define __MPQLIB_CRC_FINALIZE 0x4 void __mpqlib_crc32(const unsigned char *buffer, uint32_t length, uint32_t * crc, uint32_t flags); +#ifdef USE_SSL int __mpqlib_verify_weak_signature(RSA * public_key, const unsigned char *signature, const unsigned char *digest); int __mpqlib_verify_strong_signature(RSA * public_key, const unsigned char *signature, const unsigned char *digest); +#endif #if defined(__cplusplus) } @@ -1242,6 +1242,9 @@ static void huff_init_tree(struct huffman_tree *ht, struct huffman_tree_item *hi /* * Compression structure (size: 12596 bytes on x86-32) */ +#ifdef WIN32 +#pragma pack(1) +#endif typedef struct { unsigned long offs0000; /* 0000 */ unsigned long cmp_type; /* 0004 - Compression type (PZIP_CMP_BINARY or @@ -1272,7 +1275,11 @@ typedef struct { unsigned char slen_bits[0x10]; /* 30F4 - Numbers of bits for skip copied block length */ unsigned char clen_bits[0x10]; /* 3104 - Number of valid bits for copied block */ unsigned short len_base[0x10]; /* 3114 - Buffer for */ -} __attribute__ ((packed)) pkzip_data_cmp; +} +#ifndef WIN32 +__attribute__ ((packed)) +#endif +pkzip_data_cmp; typedef struct { const char *in_buf; /* Pointer to input data buffer */ @@ -28,7 +28,11 @@ This implements a hash table. -------------------------------------------------------------------- */ +#ifdef WIN32 +#include "stdint.h" +#else #include <stdint.h> +#endif #include <memory.h> #include "lookupa.h" @@ -31,7 +31,11 @@ This implements a hash table. #ifndef HASHTAB #define HASHTAB +#ifdef WIN32 +#include "stdint.h" +#else #include <stdint.h> +#endif #include <stdlib.h> /* PRIVATE TYPES AND DEFINITIONS */ @@ -1,7 +1,7 @@ #ifndef __INT_BIOS_H__ #define __INT_BIOS_H__ -#include <mpq-bios.h> +#include "mpq-bios.h" /* * Internal BIOS functions. @@ -10,7 +10,11 @@ Source is http://burtleburtle.net/bob/c/lookupa.h #ifndef LOOKUPA #define LOOKUPA +#ifdef WIN32 +#include "stdint.h" +#else #include <stdint.h> +#endif #define CHECKSTATE 8 #define hashsize(n) ((uint32_t)1<<(n)) @@ -1,5 +1,14 @@ #define _LARGEFILE64_SOURCE + +#ifdef WIN32 +#include <stdio.h> +#include <io.h> +#include <sys/types.h> +#define lseek64 _lseeki64 +#else #include <unistd.h> +#endif + #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> @@ -12,11 +21,13 @@ #include "mpq-misc.h" #include "int-bios.h" #include "errors.h" -#include "inttypes.h" /* * MPQ header. */ +#ifdef WIN32 +#pragma pack(1) +#endif typedef struct { /* basic version of the header. */ @@ -35,7 +46,11 @@ typedef struct { uint64_t extended_block_table_offset; uint16_t hash_table_offset_high; uint16_t block_table_offset_high; -} __attribute__ ((packed)) mpq_header_t; +} +#ifndef WIN32 +__attribute__ ((packed)) +#endif +mpq_header_t; /* * One hash entry. @@ -47,7 +62,11 @@ typedef struct { uint16_t language; uint16_t platform; uint32_t file_block_index; -} __attribute__ ((packed)) mpq_hash_t; +} +#ifndef WIN32 +__attribute__ ((packed)) +#endif +mpq_hash_t; /* * One block entry. @@ -58,7 +77,11 @@ typedef struct { uint32_t block_size; uint32_t file_size; uint32_t flags; -} __attribute__ ((packed)) mpq_block_t; +} +#ifndef WIN32 +__attribute__ ((packed)) +#endif +mpq_block_t; /* @@ -81,7 +104,7 @@ typedef struct { } block_t; struct mpq_archive_t { - int fd; + int fd; int closeit; uint32_t header_size; @@ -108,7 +131,11 @@ struct mpq_archive_t * mpqlib_open_archive(const char * fname) { int fd; struct mpq_archive_t * r; - if ((fd = open(fname, O_RDONLY | O_LARGEFILE | O_BINARY)) == -1) { +#ifdef WIN32 + if ((fd = open(fname, _O_RDONLY | _O_BINARY)) == -1) { +#else + if ((fd = open(fname, O_RDONLY | O_LARGEFILE | O_BINARY)) == -1) { +#endif __mpqlib_errno = MPQLIB_ERROR_OPEN; return NULL; } @@ -1,7 +1,11 @@ #ifndef __MPQ_BIOS_H__ #define __MPQ_BIOS_H__ +#ifdef WIN32 +#include "stdint.h" +#else #include <stdint.h> +#endif struct mpq_archive_t; @@ -162,10 +162,11 @@ uint32_t mpqlib_read(struct mpq_file_t * mpq_f, void * _buffer, uint32_t size) { uint32_t cl_size; uint32_t offset_begin, offset_end; - __mpqlib_errno = MPQLIB_ERROR_NO_ERROR; - - uint32_t first_sector_begins, last_sector_ends; - + uint32_t first_sector_begins; + uint32_t last_sector_ends; + + __mpqlib_errno = MPQLIB_ERROR_NO_ERROR; + /* Computing various cursors and stuff. */ if ((size + mpq_f->cursor) >= mpq_f->file_size) size = mpq_f->file_size - mpq_f->cursor; @@ -1,8 +1,11 @@ #ifndef __MPQ_FILE_H__ #define __MPQ_FILE_H__ +#ifdef WIN32 +#include "stdint.h" +#else #include <stdint.h> - +#endif struct mpq_file_t; enum mpqlib_file_seek_t { @@ -1,8 +1,8 @@ #ifndef __MPQ_FS_H__ #define __MPQ_FS_H__ -#include <mpq-bios.h> -#include <mpq-file.h> +#include "mpq-bios.h" +#include "mpq-file.h" #ifdef __cplusplus extern "C" { @@ -1,7 +1,11 @@ #ifndef __MPQ_MISC_H__ #define __MPQ_MISC_H__ +#ifdef WIN32 +typedef unsigned long int uint32_t; +#else #include <stdint.h> +#endif #ifdef __cplusplus extern "C" { @@ -13,7 +13,11 @@ This also decreases memory fragmentation, and freeing structures -------------------------------------------------------------------- */ +#ifdef WIN32 +#include "stdint.h" +#else #include <stdint.h> +#endif #include <stdio.h> #include <memory.h> #include "recycle.h" |