fdi.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. /**
  2. * This file has no copyright assigned and is placed in the Public Domain.
  3. * This file is part of the mingw-w64 runtime package.
  4. * No warranty is given; refer to the file DISCLAIMER.PD within this package.
  5. */
  6. #ifndef INCLUDED_TYPES_FCI_FDI
  7. #define INCLUDED_TYPES_FCI_FDI 1
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. #ifndef HUGE
  12. #define HUGE
  13. #endif
  14. #ifndef FAR
  15. #define FAR
  16. #endif
  17. #ifndef DIAMONDAPI
  18. #define DIAMONDAPI __cdecl
  19. #endif
  20. #ifndef _WIN64
  21. #include <pshpack4.h>
  22. #endif
  23. #ifndef BASETYPES
  24. #define BASETYPES
  25. typedef unsigned __LONG32 ULONG;
  26. typedef ULONG *PULONG;
  27. typedef unsigned short USHORT;
  28. typedef USHORT *PUSHORT;
  29. typedef unsigned char UCHAR;
  30. typedef UCHAR *PUCHAR;
  31. typedef char *PSZ;
  32. #endif
  33. #if !defined(_INC_WINDOWS) && !defined(_WINDOWS_)
  34. typedef int WINBOOL;
  35. typedef unsigned char BYTE;
  36. typedef unsigned int UINT;
  37. #endif
  38. typedef unsigned __LONG32 CHECKSUM;
  39. typedef unsigned __LONG32 UOFF;
  40. typedef unsigned __LONG32 COFF;
  41. #ifndef TRUE
  42. #define TRUE 1
  43. #endif
  44. #ifndef FALSE
  45. #define FALSE 0
  46. #endif
  47. #ifndef NULL
  48. #define NULL 0
  49. #endif
  50. typedef struct {
  51. int erfOper;
  52. int erfType;
  53. WINBOOL fError;
  54. } ERF;
  55. typedef ERF *PERF;
  56. #define STATIC static
  57. #define CB_MAX_CHUNK 32768U
  58. #define CB_MAX_DISK __MSABI_LONG(0x7fffffff)
  59. #define CB_MAX_FILENAME 256
  60. #define CB_MAX_CABINET_NAME 256
  61. #define CB_MAX_CAB_PATH 256
  62. #define CB_MAX_DISK_NAME 256
  63. typedef unsigned short TCOMP;
  64. #define tcompMASK_TYPE 0x000F
  65. #define tcompTYPE_NONE 0x0000
  66. #define tcompTYPE_MSZIP 0x0001
  67. #define tcompTYPE_QUANTUM 0x0002
  68. #define tcompTYPE_LZX 0x0003
  69. #define tcompBAD 0x000F
  70. #define tcompMASK_LZX_WINDOW 0x1F00
  71. #define tcompLZX_WINDOW_LO 0x0F00
  72. #define tcompLZX_WINDOW_HI 0x1500
  73. #define tcompSHIFT_LZX_WINDOW 8
  74. #define tcompMASK_QUANTUM_LEVEL 0x00F0
  75. #define tcompQUANTUM_LEVEL_LO 0x0010
  76. #define tcompQUANTUM_LEVEL_HI 0x0070
  77. #define tcompSHIFT_QUANTUM_LEVEL 4
  78. #define tcompMASK_QUANTUM_MEM 0x1F00
  79. #define tcompQUANTUM_MEM_LO 0x0A00
  80. #define tcompQUANTUM_MEM_HI 0x1500
  81. #define tcompSHIFT_QUANTUM_MEM 8
  82. #define tcompMASK_RESERVED 0xE000
  83. #define CompressionTypeFromTCOMP(tc) ((tc) & tcompMASK_TYPE)
  84. #define CompressionLevelFromTCOMP(tc) (((tc) & tcompMASK_QUANTUM_LEVEL) >> tcompSHIFT_QUANTUM_LEVEL)
  85. #define CompressionMemoryFromTCOMP(tc) (((tc) & tcompMASK_QUANTUM_MEM) >> tcompSHIFT_QUANTUM_MEM)
  86. #define TCOMPfromTypeLevelMemory(t,l,m) (((m) << tcompSHIFT_QUANTUM_MEM) | ((l) << tcompSHIFT_QUANTUM_LEVEL) | (t))
  87. #define LZXCompressionWindowFromTCOMP(tc) (((tc) & tcompMASK_LZX_WINDOW) >> tcompSHIFT_LZX_WINDOW)
  88. #define TCOMPfromLZXWindow(w) (((w) << tcompSHIFT_LZX_WINDOW) | (tcompTYPE_LZX))
  89. #ifndef _WIN64
  90. #include <poppack.h>
  91. #endif
  92. #ifdef __cplusplus
  93. }
  94. #endif
  95. #endif
  96. #include <basetsd.h>
  97. #ifndef INCLUDED_FDI
  98. #define INCLUDED_FDI 1
  99. #ifdef __cplusplus
  100. extern "C" {
  101. #endif
  102. #ifndef _WIN64
  103. #pragma pack(4)
  104. #endif
  105. typedef enum {
  106. FDIERROR_NONE,FDIERROR_CABINET_NOT_FOUND,FDIERROR_NOT_A_CABINET,FDIERROR_UNKNOWN_CABINET_VERSION,FDIERROR_CORRUPT_CABINET,FDIERROR_ALLOC_FAIL,
  107. FDIERROR_BAD_COMPR_TYPE,FDIERROR_MDI_FAIL,FDIERROR_TARGET_FILE,FDIERROR_RESERVE_MISMATCH,FDIERROR_WRONG_CABINET,FDIERROR_USER_ABORT
  108. } FDIERROR;
  109. #ifndef _A_NAME_IS_UTF
  110. #define _A_NAME_IS_UTF 0x80
  111. #endif
  112. #ifndef _A_EXEC
  113. #define _A_EXEC 0x40
  114. #endif
  115. typedef void *HFDI;
  116. typedef struct {
  117. __LONG32 cbCabinet;
  118. USHORT cFolders;
  119. USHORT cFiles;
  120. USHORT setID;
  121. USHORT iCabinet;
  122. WINBOOL fReserve;
  123. WINBOOL hasprev;
  124. WINBOOL hasnext;
  125. } FDICABINETINFO;
  126. typedef FDICABINETINFO *PFDICABINETINFO;
  127. typedef enum {
  128. fdidtNEW_CABINET,fdidtNEW_FOLDER,fdidtDECRYPT
  129. } FDIDECRYPTTYPE;
  130. typedef struct {
  131. FDIDECRYPTTYPE fdidt;
  132. void *pvUser;
  133. __C89_NAMELESS union {
  134. struct {
  135. void *pHeaderReserve;
  136. USHORT cbHeaderReserve;
  137. USHORT setID;
  138. int iCabinet;
  139. } cabinet;
  140. struct {
  141. void *pFolderReserve;
  142. USHORT cbFolderReserve;
  143. USHORT iFolder;
  144. } folder;
  145. struct {
  146. void *pDataReserve;
  147. USHORT cbDataReserve;
  148. void *pbData;
  149. USHORT cbData;
  150. WINBOOL fSplit;
  151. USHORT cbPartial;
  152. } decrypt;
  153. };
  154. } FDIDECRYPT;
  155. typedef FDIDECRYPT *PFDIDECRYPT;
  156. typedef void *(DIAMONDAPI *PFNALLOC)(ULONG cb);
  157. #define FNALLOC(fn) void *DIAMONDAPI fn(ULONG cb)
  158. typedef void (DIAMONDAPI *PFNFREE)(void *pv);
  159. #define FNFREE(fn) void DIAMONDAPI fn(void *pv)
  160. typedef INT_PTR (DIAMONDAPI *PFNOPEN) (char *pszFile,int oflag,int pmode);
  161. typedef UINT (DIAMONDAPI *PFNREAD) (INT_PTR hf,void *pv,UINT cb);
  162. typedef UINT (DIAMONDAPI *PFNWRITE)(INT_PTR hf,void *pv,UINT cb);
  163. typedef int (DIAMONDAPI *PFNCLOSE)(INT_PTR hf);
  164. typedef __LONG32 (DIAMONDAPI *PFNSEEK) (INT_PTR hf,__LONG32 dist,int seektype);
  165. #define FNOPEN(fn) INT_PTR DIAMONDAPI fn(char *pszFile,int oflag,int pmode)
  166. #define FNREAD(fn) UINT DIAMONDAPI fn(INT_PTR hf,void *pv,UINT cb)
  167. #define FNWRITE(fn) UINT DIAMONDAPI fn(INT_PTR hf,void *pv,UINT cb)
  168. #define FNCLOSE(fn) int DIAMONDAPI fn(INT_PTR hf)
  169. #define FNSEEK(fn) __LONG32 DIAMONDAPI fn(INT_PTR hf,__LONG32 dist,int seektype)
  170. typedef int (DIAMONDAPI *PFNFDIDECRYPT)(PFDIDECRYPT pfdid);
  171. #define FNFDIDECRYPT(fn) int DIAMONDAPI fn(PFDIDECRYPT pfdid)
  172. typedef struct {
  173. __LONG32 cb;
  174. char *psz1;
  175. char *psz2;
  176. char *psz3;
  177. void *pv;
  178. INT_PTR hf;
  179. USHORT date;
  180. USHORT time;
  181. USHORT attribs;
  182. USHORT setID;
  183. USHORT iCabinet;
  184. USHORT iFolder;
  185. FDIERROR fdie;
  186. } FDINOTIFICATION,*PFDINOTIFICATION;
  187. typedef enum {
  188. fdintCABINET_INFO,fdintPARTIAL_FILE,fdintCOPY_FILE,fdintCLOSE_FILE_INFO,fdintNEXT_CABINET,fdintENUMERATE
  189. } FDINOTIFICATIONTYPE;
  190. typedef INT_PTR (DIAMONDAPI *PFNFDINOTIFY)(FDINOTIFICATIONTYPE fdint,PFDINOTIFICATION pfdin);
  191. #define FNFDINOTIFY(fn) INT_PTR DIAMONDAPI fn(FDINOTIFICATIONTYPE fdint,PFDINOTIFICATION pfdin)
  192. #ifndef _WIN64
  193. #pragma pack (1)
  194. #endif
  195. typedef struct {
  196. char ach[2];
  197. __LONG32 cbFile;
  198. } FDISPILLFILE;
  199. typedef FDISPILLFILE *PFDISPILLFILE;
  200. #ifndef _WIN64
  201. #pragma pack ()
  202. #endif
  203. #define cpuUNKNOWN (-1)
  204. #define cpu80286 (0)
  205. #define cpu80386 (1)
  206. HFDI DIAMONDAPI FDICreate(PFNALLOC pfnalloc,PFNFREE pfnfree,PFNOPEN pfnopen,PFNREAD pfnread,PFNWRITE pfnwrite,PFNCLOSE pfnclose,PFNSEEK pfnseek,int cpuType,PERF perf);
  207. WINBOOL DIAMONDAPI FDIIsCabinet(HFDI hfdi,INT_PTR hf,PFDICABINETINFO pfdici);
  208. WINBOOL DIAMONDAPI FDICopy(HFDI hfdi,char *pszCabinet,char *pszCabPath,int flags,PFNFDINOTIFY pfnfdin,PFNFDIDECRYPT pfnfdid,void *pvUser);
  209. WINBOOL DIAMONDAPI FDIDestroy(HFDI hfdi);
  210. WINBOOL DIAMONDAPI FDITruncateCabinet(HFDI hfdi,char *pszCabinetName,USHORT iFolderToDelete);
  211. #ifndef _WIN64
  212. #pragma pack()
  213. #endif
  214. #ifdef __cplusplus
  215. }
  216. #endif
  217. #endif