fdi.h 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. /*
  2. * Copyright (C) 2002 Patrik Stridvall
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #ifndef __WINE_FDI_H
  19. #define __WINE_FDI_H
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif /* defined(__cplusplus) */
  23. #include <pshpack4.h>
  24. #ifndef INCLUDED_TYPES_FCI_FDI
  25. #define INCLUDED_TYPES_FCI_FDI 1
  26. /***********************************************************************
  27. * Common FCI/TDI declarations
  28. */
  29. typedef unsigned long CHECKSUM;
  30. typedef unsigned long UOFF;
  31. typedef unsigned long COFF;
  32. /**********************************************************************/
  33. typedef struct {
  34. int erfOper; /* FCI/FDI error code - see {FCI,FDI}ERROR_XXX for details. */
  35. int erfType; /* Optional error value filled in by FCI/FDI. */
  36. BOOL fError; /* TRUE => error present */
  37. } ERF, *PERF;
  38. /**********************************************************************/
  39. #define CB_MAX_CHUNK 32768U
  40. #define CB_MAX_DISK 0x7fffffffL
  41. #define CB_MAX_FILENAME 256
  42. #define CB_MAX_CABINET_NAME 256
  43. #define CB_MAX_CAB_PATH 256
  44. #define CB_MAX_DISK_NAME 256
  45. /**********************************************************************/
  46. typedef unsigned short TCOMP;
  47. #define tcompMASK_TYPE 0x000F /* Mask for compression type */
  48. #define tcompTYPE_NONE 0x0000 /* No compression */
  49. #define tcompTYPE_MSZIP 0x0001 /* MSZIP */
  50. #define tcompTYPE_QUANTUM 0x0002 /* Quantum */
  51. #define tcompTYPE_LZX 0x0003 /* LZX */
  52. #define tcompBAD 0x000F /* Unspecified compression type */
  53. #define tcompMASK_LZX_WINDOW 0x1F00 /* Mask for LZX Compression Memory */
  54. #define tcompLZX_WINDOW_LO 0x0F00 /* Lowest LZX Memory (15) */
  55. #define tcompLZX_WINDOW_HI 0x1500 /* Highest LZX Memory (21) */
  56. #define tcompSHIFT_LZX_WINDOW 8 /* Amount to shift over to get int */
  57. #define tcompMASK_QUANTUM_LEVEL 0x00F0 /* Mask for Quantum Compression Level */
  58. #define tcompQUANTUM_LEVEL_LO 0x0010 /* Lowest Quantum Level (1) */
  59. #define tcompQUANTUM_LEVEL_HI 0x0070 /* Highest Quantum Level (7) */
  60. #define tcompSHIFT_QUANTUM_LEVEL 4 /* Amount to shift over to get int */
  61. #define tcompMASK_QUANTUM_MEM 0x1F00 /* Mask for Quantum Compression Memory */
  62. #define tcompQUANTUM_MEM_LO 0x0A00 /* Lowest Quantum Memory (10) */
  63. #define tcompQUANTUM_MEM_HI 0x1500 /* Highest Quantum Memory (21) */
  64. #define tcompSHIFT_QUANTUM_MEM 8 /* Amount to shift over to get int */
  65. #define tcompMASK_RESERVED 0xE000 /* Reserved bits (high 3 bits) */
  66. /**********************************************************************/
  67. #define CompressionTypeFromTCOMP(tc) \
  68. ((tc) & tcompMASK_TYPE)
  69. #define CompressionLevelFromTCOMP(tc) \
  70. (((tc) & tcompMASK_QUANTUM_LEVEL) >> tcompSHIFT_QUANTUM_LEVEL)
  71. #define CompressionMemoryFromTCOMP(tc) \
  72. (((tc) & tcompMASK_QUANTUM_MEM) >> tcompSHIFT_QUANTUM_MEM)
  73. #define TCOMPfromTypeLevelMemory(t, l, m) \
  74. (((m) << tcompSHIFT_QUANTUM_MEM ) | \
  75. ((l) << tcompSHIFT_QUANTUM_LEVEL) | \
  76. ( t ))
  77. #define LZXCompressionWindowFromTCOMP(tc) \
  78. (((tc) & tcompMASK_LZX_WINDOW) >> tcompSHIFT_LZX_WINDOW)
  79. #define TCOMPfromLZXWindow(w) \
  80. (((w) << tcompSHIFT_LZX_WINDOW) | \
  81. ( tcompTYPE_LZX ))
  82. #endif /* !defined(INCLUDED_TYPES_FCI_FDI) */
  83. /***********************************************************************
  84. * FDI declarations
  85. */
  86. typedef enum {
  87. FDIERROR_NONE,
  88. FDIERROR_CABINET_NOT_FOUND,
  89. FDIERROR_NOT_A_CABINET,
  90. FDIERROR_UNKNOWN_CABINET_VERSION,
  91. FDIERROR_CORRUPT_CABINET,
  92. FDIERROR_ALLOC_FAIL,
  93. FDIERROR_BAD_COMPR_TYPE,
  94. FDIERROR_MDI_FAIL,
  95. FDIERROR_TARGET_FILE,
  96. FDIERROR_RESERVE_MISMATCH,
  97. FDIERROR_WRONG_CABINET,
  98. FDIERROR_USER_ABORT,
  99. } FDIERROR;
  100. /**********************************************************************/
  101. #ifndef _A_NAME_IS_UTF
  102. #define _A_NAME_IS_UTF 0x80
  103. #endif
  104. #ifndef _A_EXEC
  105. #define _A_EXEC 0x40
  106. #endif
  107. /**********************************************************************/
  108. typedef void *HFDI;
  109. /**********************************************************************/
  110. typedef struct {
  111. long cbCabinet; /* Total length of cabinet file */
  112. USHORT cFolders; /* Count of folders in cabinet */
  113. USHORT cFiles; /* Count of files in cabinet */
  114. USHORT setID; /* Cabinet set ID */
  115. USHORT iCabinet; /* Cabinet number in set (0 based) */
  116. BOOL fReserve; /* TRUE => RESERVE present in cabinet */
  117. BOOL hasprev; /* TRUE => Cabinet is chained prev */
  118. BOOL hasnext; /* TRUE => Cabinet is chained next */
  119. } FDICABINETINFO, *PFDICABINETINFO; /* pfdici */
  120. /**********************************************************************/
  121. typedef enum {
  122. fdidtNEW_CABINET, /* New cabinet */
  123. fdidtNEW_FOLDER, /* New folder */
  124. fdidtDECRYPT, /* Decrypt a data block */
  125. } FDIDECRYPTTYPE;
  126. /**********************************************************************/
  127. typedef struct {
  128. FDIDECRYPTTYPE fdidt; /* Command type (selects union below) */
  129. void *pvUser; /* Decryption context */
  130. union {
  131. struct { /* fdidtNEW_CABINET */
  132. void *pHeaderReserve; /* RESERVE section from CFHEADER */
  133. USHORT cbHeaderReserve; /* Size of pHeaderReserve */
  134. USHORT setID; /* Cabinet set ID */
  135. int iCabinet; /* Cabinet number in set (0 based) */
  136. } cabinet;
  137. struct { /* fdidtNEW_FOLDER */
  138. void *pFolderReserve; /* RESERVE section from CFFOLDER */
  139. USHORT cbFolderReserve; /* Size of pFolderReserve */
  140. USHORT iFolder; /* Folder number in cabinet (0 based) */
  141. } folder;
  142. struct { /* fdidtDECRYPT */
  143. void *pDataReserve; /* RESERVE section from CFDATA */
  144. USHORT cbDataReserve; /* Size of pDataReserve */
  145. void *pbData; /* Data buffer */
  146. USHORT cbData; /* Size of data buffer */
  147. BOOL fSplit; /* TRUE if this is a split data block */
  148. USHORT cbPartial; /* 0 if this is not a split block, or
  149. * the first piece of a split block;
  150. * Greater than 0 if this is the
  151. * second piece of a split block.
  152. */
  153. } decrypt;
  154. } DUMMYUNIONNAME;
  155. } FDIDECRYPT, *PFDIDECRYPT;
  156. /**********************************************************************/
  157. typedef void * (__cdecl *PFNALLOC)(ULONG cb);
  158. #define FNALLOC(fn) void * __cdecl fn(ULONG cb)
  159. typedef void (__cdecl *PFNFREE)(void *pv);
  160. #define FNFREE(fn) void __cdecl fn(void *pv)
  161. typedef INT_PTR (__cdecl *PFNOPEN) (char *pszFile, int oflag, int pmode);
  162. #define FNOPEN(fn) INT_PTR __cdecl fn(char *pszFile, int oflag, int pmode)
  163. typedef UINT (__cdecl *PFNREAD) (INT_PTR hf, void *pv, UINT cb);
  164. #define FNREAD(fn) UINT __cdecl fn(INT_PTR hf, void *pv, UINT cb)
  165. typedef UINT (__cdecl *PFNWRITE)(INT_PTR hf, void *pv, UINT cb);
  166. #define FNWRITE(fn) UINT __cdecl fn(INT_PTR hf, void *pv, UINT cb)
  167. typedef int (__cdecl *PFNCLOSE)(INT_PTR hf);
  168. #define FNCLOSE(fn) int __cdecl fn(INT_PTR hf)
  169. typedef long (__cdecl *PFNSEEK) (INT_PTR hf, long dist, int seektype);
  170. #define FNSEEK(fn) long __cdecl fn(INT_PTR hf, long dist, int seektype)
  171. typedef int (__cdecl *PFNFDIDECRYPT)(PFDIDECRYPT pfdid);
  172. #define FNFDIDECRYPT(fn) int __cdecl fn(PFDIDECRYPT pfdid)
  173. typedef struct {
  174. long cb;
  175. char *psz1;
  176. char *psz2;
  177. char *psz3; /* Points to a 256 character buffer */
  178. void *pv; /* Value for client */
  179. INT_PTR hf;
  180. USHORT date;
  181. USHORT time;
  182. USHORT attribs;
  183. USHORT setID; /* Cabinet set ID */
  184. USHORT iCabinet; /* Cabinet number (0-based) */
  185. USHORT iFolder; /* Folder number (0-based) */
  186. FDIERROR fdie;
  187. } FDINOTIFICATION, *PFDINOTIFICATION;
  188. typedef enum {
  189. fdintCABINET_INFO, /* General information about cabinet */
  190. fdintPARTIAL_FILE, /* First file in cabinet is continuation */
  191. fdintCOPY_FILE, /* File to be copied */
  192. fdintCLOSE_FILE_INFO, /* Close the file, set relevant info */
  193. fdintNEXT_CABINET, /* File continued to next cabinet */
  194. fdintENUMERATE, /* Enumeration status */
  195. } FDINOTIFICATIONTYPE;
  196. typedef INT_PTR (__cdecl *PFNFDINOTIFY)(FDINOTIFICATIONTYPE fdint,
  197. PFDINOTIFICATION pfdin);
  198. #define FNFDINOTIFY(fn) INT_PTR __cdecl fn(FDINOTIFICATIONTYPE fdint, \
  199. PFDINOTIFICATION pfdin)
  200. #include <pshpack1.h>
  201. typedef struct {
  202. char ach[2]; /* Set to { '*', '\0' } */
  203. long cbFile; /* Required spill file size */
  204. } FDISPILLFILE, *PFDISPILLFILE;
  205. #include <poppack.h>
  206. #define cpuUNKNOWN (-1) /* FDI does detection */
  207. #define cpu80286 (0) /* '286 opcodes only */
  208. #define cpu80386 (1) /* '386 opcodes used */
  209. /**********************************************************************/
  210. HFDI __cdecl FDICreate(PFNALLOC, PFNFREE, PFNOPEN, PFNREAD, PFNWRITE,
  211. PFNCLOSE, PFNSEEK, int, PERF);
  212. BOOL __cdecl FDIIsCabinet(HFDI, INT_PTR, PFDICABINETINFO);
  213. BOOL __cdecl FDICopy(HFDI, char *, char *, int, PFNFDINOTIFY,
  214. PFNFDIDECRYPT, void *pvUser);
  215. BOOL __cdecl FDIDestroy(HFDI);
  216. BOOL __cdecl FDITruncateCabinet(HFDI, char *, USHORT);
  217. /**********************************************************************/
  218. #include <poppack.h>
  219. #ifdef __cplusplus
  220. } /* extern "C" */
  221. #endif /* defined(__cplusplus) */
  222. #endif /* __WINE_FDI_H */