mpq.h
上传用户:yisoukefu
上传日期:2020-08-09
资源大小:39506k
文件大小:5k
- #ifndef MPQ_H
- #define MPQ_H
- #define LIBMPQ_MAJOR_VERSION 0
- #define LIBMPQ_MINOR_VERSION 3
- #define LIBMPQ_PATCH_VERSION 0
- #define LIBMPQ_TOOLS_SUCCESS 0
- #define LIBMPQ_TOOLS_BUFSIZE 0x500
- #define LIBMPQ_EFILE -1
- #define LIBMPQ_EFILE_FORMAT -2
- #define LIBMPQ_EFILE_CORRUPT -3
- #define LIBMPQ_EFILE_NOT_FOUND -4
- #define LIBMPQ_EFILE_READ -5
- #define LIBMPQ_EALLOCMEM -6
- #define LIBMPQ_EFREEMEM -7
- #define LIBMPQ_EINV_RANGE -8
- #define LIBMPQ_EHASHTABLE -9
- #define LIBMPQ_EBLOCKTABLE -10
- #define LIBMPQ_ID_MPQ 0x1A51504D
- #define LIBMPQ_HEADER_W3M 0x6D9E4B86
- #define LIBMPQ_FLAG_PROTECTED 0x00000002
- #define LIBMPQ_HASH_ENTRY_DELETED 0xFFFFFFFE
- #define LIBMPQ_LISTFILE_HASH1 0xfd657910
- #define LIBMPQ_LISTFILE_HASH2 0x4e9b98a7
- #define LIBMPQ_ATTRFILE_HASH1 0xd38437cb
- #define LIBMPQ_ATTRFILE_HASH2 0x07dfeaec
- #define LIBMPQ_FILE_COMPRESS_PKWARE 0x00000100
- #define LIBMPQ_FILE_COMPRESS_MULTI 0x00000200
- #define LIBMPQ_FILE_COMPRESSED 0x0000FF00
- #define LIBMPQ_FILE_EXISTS 0x80000000
- #define LIBMPQ_FILE_ENCRYPTED 0x00010000
- #define LIBMPQ_FILE_WHOLEBLOCK 0x01000000
- #define LIBMPQ_FILE_COMPRESSED_SIZE 1
- #define LIBMPQ_FILE_UNCOMPRESSED_SIZE 2
- #define LIBMPQ_FILE_COMPRESSION_TYPE 3
- #define LIBMPQ_FILE_TYPE_INT 4
- #define LIBMPQ_FILE_TYPE_CHAR 5
- #define LIBMPQ_FILE_HASH1 6
- #define LIBMPQ_FILE_HASH2 7
- #define LIBMPQ_MPQ_ARCHIVE_SIZE 1
- #define LIBMPQ_MPQ_HASHTABLE_SIZE 2
- #define LIBMPQ_MPQ_BLOCKTABLE_SIZE 3
- #define LIBMPQ_MPQ_BLOCKSIZE 4
- #define LIBMPQ_MPQ_NUMFILES 5
- #define LIBMPQ_MPQ_COMPRESSED_SIZE 6
- #define LIBMPQ_MPQ_UNCOMPRESSED_SIZE 7
- #define LIBMPQ_HUFF_DECOMPRESS 0
- #define LIBMPQ_CONF_EFILE_OPEN -1
- #define LIBMPQ_CONF_EFILE_CORRUPT -2
- #define LIBMPQ_CONF_EFILE_LIST_CORRUPT -3
- #define LIBMPQ_CONF_EFILE_NOT_FOUND -4
- #define LIBMPQ_CONF_EFILE_VERSION -5
- typedef unsigned int MPQ_BUFFER[LIBMPQ_TOOLS_BUFSIZE];
- typedef int (*DECOMPRESS)(char *, int *, char *, int);
- typedef struct {
- unsigned long mask;
- DECOMPRESS decompress;
- }DECOMPRESS_TABLE;
- #pragma pack(push,1)
- typedef struct
- {
- unsigned long id;
- unsigned long offset;
- unsigned long archivesize;
- unsigned short offsetsc;
- unsigned short blocksize;
- unsigned long hashtablepos;
- unsigned long blocktablepos;
- unsigned long hashtablesize;
- unsigned long blocktablesize;
- }MPQ_HEADER;
- #pragma pack(pop)
- typedef struct
- {
- unsigned int name1;
- unsigned int name2;
- unsigned int locale;
- unsigned int blockindex;
- }MPQ_HASH;
- typedef struct
- {
- unsigned int filepos;
- unsigned int csize;
- unsigned int fsize;
- unsigned int flags;
- }MPQ_BLOCK;
- typedef struct
- {
- unsigned char filename[MAX_PATH];
- int fd;
- unsigned int seed;
- unsigned int filepos;
- unsigned int offset;
- unsigned int nblocks;
- unsigned int *blockpos;
- int blockposloaded;
- unsigned int offset2;
- MPQ_HASH *mpq_h;
- MPQ_BLOCK *mpq_b;
- unsigned int accessed;
- }MPQ_FILE;
- typedef struct
- {
- char filename[MAX_PATH];
- int fd;
- unsigned int blockpos;
- unsigned int blocksize;
- unsigned char *blockbuf;
- unsigned int bufpos;
- unsigned int mpqpos;
- unsigned int filepos;
- unsigned int openfiles;
- MPQ_BUFFER buf;
- MPQ_HEADER *header;
- MPQ_HASH *hashtable;
- MPQ_BLOCK *blocktable;
- unsigned int flags;
- unsigned int maxblockindex;
- }MPQ_ARCHIVE;
- char *libmpq_version();
- int libmpq_archive_open(MPQ_ARCHIVE *mpq_a, unsigned char *mpq_filename);
- int libmpq_archive_close(MPQ_ARCHIVE *mpq_a);
- int libmpq_archive_info(MPQ_ARCHIVE *mpq_a, unsigned int infotype);
- int libmpq_file_getdata(MPQ_ARCHIVE *mpq_a, const int number, unsigned char *dest);
- int libmpq_file_info(MPQ_ARCHIVE *mpq_a, unsigned int infotype, const int number);
- int libmpq_file_number(MPQ_ARCHIVE *mpq_a, const char *name);
- int libmpq_file_number_from_hash(MPQ_ARCHIVE *mpq_a, unsigned int hash1, unsigned int hash2);
- int libmpq_file_check(MPQ_ARCHIVE *mpq_a, void *file, int type);
- int libmpq_hash_filename(MPQ_ARCHIVE *mpq_a, const unsigned char *pbKey, unsigned int *seed1, unsigned int*seed2);
- int libmpq_pkzip_decompress(char *out_buf, int *out_length, char *in_buf, int in_length);
- int libmpq_zlib_decompress(char *out_buf, int *out_length, char *in_buf, int in_length);
- int libmpq_huff_decompress(char *out_buf, int *out_length, char *in_buf, int in_length);
- int libmpq_wave_decompress_stereo(char *out_buf, int *out_length, char *in_buf, int in_length);
- int libmpq_wave_decompress_mono(char *out_buf, int *out_length, char *in_buf, int in_length);
- int libmpq_multi_decompress(char *out_buf, int *pout_length, char *in_buf, int in_length);
- #endif