mpq.h
上传用户:yisoukefu
上传日期:2020-08-09
资源大小:39506k
文件大小:5k
源码类别:

其他游戏

开发平台:

Visual C++

  1. #ifndef MPQ_H
  2. #define MPQ_H
  3. #define LIBMPQ_MAJOR_VERSION 0
  4. #define LIBMPQ_MINOR_VERSION 3
  5. #define LIBMPQ_PATCH_VERSION 0
  6. #define LIBMPQ_TOOLS_SUCCESS 0
  7. #define LIBMPQ_TOOLS_BUFSIZE 0x500
  8. #define LIBMPQ_EFILE -1
  9. #define LIBMPQ_EFILE_FORMAT -2
  10. #define LIBMPQ_EFILE_CORRUPT -3
  11. #define LIBMPQ_EFILE_NOT_FOUND -4
  12. #define LIBMPQ_EFILE_READ -5
  13. #define LIBMPQ_EALLOCMEM -6
  14. #define LIBMPQ_EFREEMEM -7
  15. #define LIBMPQ_EINV_RANGE -8
  16. #define LIBMPQ_EHASHTABLE -9
  17. #define LIBMPQ_EBLOCKTABLE -10
  18. #define LIBMPQ_ID_MPQ 0x1A51504D
  19. #define LIBMPQ_HEADER_W3M 0x6D9E4B86
  20. #define LIBMPQ_FLAG_PROTECTED 0x00000002
  21. #define LIBMPQ_HASH_ENTRY_DELETED 0xFFFFFFFE
  22. #define LIBMPQ_LISTFILE_HASH1 0xfd657910
  23. #define LIBMPQ_LISTFILE_HASH2 0x4e9b98a7
  24. #define LIBMPQ_ATTRFILE_HASH1 0xd38437cb
  25. #define LIBMPQ_ATTRFILE_HASH2 0x07dfeaec
  26. #define LIBMPQ_FILE_COMPRESS_PKWARE 0x00000100
  27. #define LIBMPQ_FILE_COMPRESS_MULTI 0x00000200
  28. #define LIBMPQ_FILE_COMPRESSED 0x0000FF00
  29. #define LIBMPQ_FILE_EXISTS 0x80000000
  30. #define LIBMPQ_FILE_ENCRYPTED 0x00010000
  31. #define LIBMPQ_FILE_WHOLEBLOCK 0x01000000
  32. #define LIBMPQ_FILE_COMPRESSED_SIZE 1
  33. #define LIBMPQ_FILE_UNCOMPRESSED_SIZE 2
  34. #define LIBMPQ_FILE_COMPRESSION_TYPE 3
  35. #define LIBMPQ_FILE_TYPE_INT 4
  36. #define LIBMPQ_FILE_TYPE_CHAR 5
  37. #define LIBMPQ_FILE_HASH1 6
  38. #define LIBMPQ_FILE_HASH2 7
  39. #define LIBMPQ_MPQ_ARCHIVE_SIZE 1
  40. #define LIBMPQ_MPQ_HASHTABLE_SIZE 2
  41. #define LIBMPQ_MPQ_BLOCKTABLE_SIZE 3
  42. #define LIBMPQ_MPQ_BLOCKSIZE 4
  43. #define LIBMPQ_MPQ_NUMFILES 5
  44. #define LIBMPQ_MPQ_COMPRESSED_SIZE 6
  45. #define LIBMPQ_MPQ_UNCOMPRESSED_SIZE 7
  46. #define LIBMPQ_HUFF_DECOMPRESS 0
  47. #define LIBMPQ_CONF_EFILE_OPEN -1
  48. #define LIBMPQ_CONF_EFILE_CORRUPT -2
  49. #define LIBMPQ_CONF_EFILE_LIST_CORRUPT -3
  50. #define LIBMPQ_CONF_EFILE_NOT_FOUND -4
  51. #define LIBMPQ_CONF_EFILE_VERSION -5
  52. typedef unsigned int MPQ_BUFFER[LIBMPQ_TOOLS_BUFSIZE];
  53. typedef int (*DECOMPRESS)(char *, int *, char *, int);
  54. typedef struct {
  55. unsigned long mask;
  56. DECOMPRESS decompress;
  57. }DECOMPRESS_TABLE;
  58. #pragma pack(push,1)
  59. typedef struct 
  60. {
  61. unsigned long id;
  62. unsigned long offset;
  63. unsigned long archivesize;
  64. unsigned short offsetsc;
  65. unsigned short blocksize;
  66. unsigned long hashtablepos;
  67. unsigned long blocktablepos;
  68. unsigned long hashtablesize;
  69. unsigned long blocktablesize;
  70. }MPQ_HEADER;
  71. #pragma pack(pop)
  72. typedef struct
  73. {
  74. unsigned int name1;
  75. unsigned int name2;
  76. unsigned int locale;
  77. unsigned int blockindex;
  78. }MPQ_HASH;
  79. typedef struct
  80. {
  81. unsigned int filepos;
  82. unsigned int csize;
  83. unsigned int fsize;
  84. unsigned int flags;
  85. }MPQ_BLOCK;
  86. typedef struct
  87. {
  88. unsigned char filename[MAX_PATH];
  89. int fd;
  90. unsigned int seed;
  91. unsigned int filepos;
  92. unsigned int offset;
  93. unsigned int nblocks;
  94. unsigned int *blockpos;
  95. int blockposloaded;
  96. unsigned int offset2;
  97. MPQ_HASH *mpq_h;
  98. MPQ_BLOCK *mpq_b;
  99. unsigned int accessed;
  100. }MPQ_FILE;
  101. typedef struct
  102. {
  103. char filename[MAX_PATH];
  104. int fd;
  105. unsigned int blockpos;
  106. unsigned int blocksize;
  107. unsigned char *blockbuf;
  108. unsigned int bufpos;
  109. unsigned int mpqpos;
  110. unsigned int filepos;
  111. unsigned int openfiles;
  112. MPQ_BUFFER buf;
  113. MPQ_HEADER *header;
  114. MPQ_HASH *hashtable;
  115. MPQ_BLOCK *blocktable;
  116. unsigned int flags;
  117. unsigned int maxblockindex;
  118. }MPQ_ARCHIVE;
  119. char *libmpq_version();
  120. int libmpq_archive_open(MPQ_ARCHIVE *mpq_a, unsigned char *mpq_filename);
  121. int libmpq_archive_close(MPQ_ARCHIVE *mpq_a);
  122. int libmpq_archive_info(MPQ_ARCHIVE *mpq_a, unsigned int infotype);
  123. int libmpq_file_getdata(MPQ_ARCHIVE *mpq_a, const int number, unsigned char *dest);
  124. int libmpq_file_info(MPQ_ARCHIVE *mpq_a, unsigned int infotype, const int number);
  125. int libmpq_file_number(MPQ_ARCHIVE *mpq_a, const char *name);
  126. int libmpq_file_number_from_hash(MPQ_ARCHIVE *mpq_a, unsigned int hash1, unsigned int hash2);
  127. int libmpq_file_check(MPQ_ARCHIVE *mpq_a, void *file, int type);
  128. int libmpq_hash_filename(MPQ_ARCHIVE *mpq_a, const unsigned char *pbKey, unsigned int *seed1, unsigned int*seed2);
  129. int libmpq_pkzip_decompress(char *out_buf, int *out_length, char *in_buf, int in_length);
  130. int libmpq_zlib_decompress(char *out_buf, int *out_length, char *in_buf, int in_length);
  131. int libmpq_huff_decompress(char *out_buf, int *out_length, char *in_buf, int in_length);
  132. int libmpq_wave_decompress_stereo(char *out_buf, int *out_length, char *in_buf, int in_length);
  133. int libmpq_wave_decompress_mono(char *out_buf, int *out_length, char *in_buf, int in_length);
  134. int libmpq_multi_decompress(char *out_buf, int *pout_length, char *in_buf, int in_length);
  135. #endif