7zTypes.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. /* 7zTypes.h -- Basic types
  2. 2024-01-24 : Igor Pavlov : Public domain */
  3. #ifndef ZIP7_7Z_TYPES_H
  4. #define ZIP7_7Z_TYPES_H
  5. #ifdef _WIN32
  6. /* #include <windows.h> */
  7. #else
  8. #include <errno.h>
  9. #endif
  10. #include <stddef.h>
  11. #ifndef EXTERN_C_BEGIN
  12. #ifdef __cplusplus
  13. #define EXTERN_C_BEGIN extern "C" {
  14. #define EXTERN_C_END }
  15. #else
  16. #define EXTERN_C_BEGIN
  17. #define EXTERN_C_END
  18. #endif
  19. #endif
  20. EXTERN_C_BEGIN
  21. #define SZ_OK 0
  22. #define SZ_ERROR_DATA 1
  23. #define SZ_ERROR_MEM 2
  24. #define SZ_ERROR_CRC 3
  25. #define SZ_ERROR_UNSUPPORTED 4
  26. #define SZ_ERROR_PARAM 5
  27. #define SZ_ERROR_INPUT_EOF 6
  28. #define SZ_ERROR_OUTPUT_EOF 7
  29. #define SZ_ERROR_READ 8
  30. #define SZ_ERROR_WRITE 9
  31. #define SZ_ERROR_PROGRESS 10
  32. #define SZ_ERROR_FAIL 11
  33. #define SZ_ERROR_THREAD 12
  34. #define SZ_ERROR_ARCHIVE 16
  35. #define SZ_ERROR_NO_ARCHIVE 17
  36. typedef int SRes;
  37. #ifdef _MSC_VER
  38. #if _MSC_VER > 1200
  39. #define MY_ALIGN(n) __declspec(align(n))
  40. #else
  41. #define MY_ALIGN(n)
  42. #endif
  43. #else
  44. /*
  45. // C11/C++11:
  46. #include <stdalign.h>
  47. #define MY_ALIGN(n) alignas(n)
  48. */
  49. #define MY_ALIGN(n) __attribute__ ((aligned(n)))
  50. #endif
  51. #ifdef _WIN32
  52. /* typedef DWORD WRes; */
  53. typedef unsigned WRes;
  54. #define MY_SRes_HRESULT_FROM_WRes(x) HRESULT_FROM_WIN32(x)
  55. // #define MY_HRES_ERROR_INTERNAL_ERROR MY_SRes_HRESULT_FROM_WRes(ERROR_INTERNAL_ERROR)
  56. #else // _WIN32
  57. // #define ENV_HAVE_LSTAT
  58. typedef int WRes;
  59. // (FACILITY_ERRNO = 0x800) is 7zip's FACILITY constant to represent (errno) errors in HRESULT
  60. #define MY_FACILITY_ERRNO 0x800
  61. #define MY_FACILITY_WIN32 7
  62. #define MY_FACILITY_WRes MY_FACILITY_ERRNO
  63. #define MY_HRESULT_FROM_errno_CONST_ERROR(x) ((HRESULT)( \
  64. ( (HRESULT)(x) & 0x0000FFFF) \
  65. | (MY_FACILITY_WRes << 16) \
  66. | (HRESULT)0x80000000 ))
  67. #define MY_SRes_HRESULT_FROM_WRes(x) \
  68. ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) : MY_HRESULT_FROM_errno_CONST_ERROR(x))
  69. // we call macro HRESULT_FROM_WIN32 for system errors (WRes) that are (errno)
  70. #define HRESULT_FROM_WIN32(x) MY_SRes_HRESULT_FROM_WRes(x)
  71. /*
  72. #define ERROR_FILE_NOT_FOUND 2L
  73. #define ERROR_ACCESS_DENIED 5L
  74. #define ERROR_NO_MORE_FILES 18L
  75. #define ERROR_LOCK_VIOLATION 33L
  76. #define ERROR_FILE_EXISTS 80L
  77. #define ERROR_DISK_FULL 112L
  78. #define ERROR_NEGATIVE_SEEK 131L
  79. #define ERROR_ALREADY_EXISTS 183L
  80. #define ERROR_DIRECTORY 267L
  81. #define ERROR_TOO_MANY_POSTS 298L
  82. #define ERROR_INTERNAL_ERROR 1359L
  83. #define ERROR_INVALID_REPARSE_DATA 4392L
  84. #define ERROR_REPARSE_TAG_INVALID 4393L
  85. #define ERROR_REPARSE_TAG_MISMATCH 4394L
  86. */
  87. // we use errno equivalents for some WIN32 errors:
  88. #define ERROR_INVALID_PARAMETER EINVAL
  89. #define ERROR_INVALID_FUNCTION EINVAL
  90. #define ERROR_ALREADY_EXISTS EEXIST
  91. #define ERROR_FILE_EXISTS EEXIST
  92. #define ERROR_PATH_NOT_FOUND ENOENT
  93. #define ERROR_FILE_NOT_FOUND ENOENT
  94. #define ERROR_DISK_FULL ENOSPC
  95. // #define ERROR_INVALID_HANDLE EBADF
  96. // we use FACILITY_WIN32 for errors that has no errno equivalent
  97. // Too many posts were made to a semaphore.
  98. #define ERROR_TOO_MANY_POSTS ((HRESULT)0x8007012AL)
  99. #define ERROR_INVALID_REPARSE_DATA ((HRESULT)0x80071128L)
  100. #define ERROR_REPARSE_TAG_INVALID ((HRESULT)0x80071129L)
  101. // if (MY_FACILITY_WRes != FACILITY_WIN32),
  102. // we use FACILITY_WIN32 for COM errors:
  103. #define E_OUTOFMEMORY ((HRESULT)0x8007000EL)
  104. #define E_INVALIDARG ((HRESULT)0x80070057L)
  105. #define MY_E_ERROR_NEGATIVE_SEEK ((HRESULT)0x80070083L)
  106. /*
  107. // we can use FACILITY_ERRNO for some COM errors, that have errno equivalents:
  108. #define E_OUTOFMEMORY MY_HRESULT_FROM_errno_CONST_ERROR(ENOMEM)
  109. #define E_INVALIDARG MY_HRESULT_FROM_errno_CONST_ERROR(EINVAL)
  110. #define MY_E_ERROR_NEGATIVE_SEEK MY_HRESULT_FROM_errno_CONST_ERROR(EINVAL)
  111. */
  112. #define TEXT(quote) quote
  113. #define FILE_ATTRIBUTE_READONLY 0x0001
  114. #define FILE_ATTRIBUTE_HIDDEN 0x0002
  115. #define FILE_ATTRIBUTE_SYSTEM 0x0004
  116. #define FILE_ATTRIBUTE_DIRECTORY 0x0010
  117. #define FILE_ATTRIBUTE_ARCHIVE 0x0020
  118. #define FILE_ATTRIBUTE_DEVICE 0x0040
  119. #define FILE_ATTRIBUTE_NORMAL 0x0080
  120. #define FILE_ATTRIBUTE_TEMPORARY 0x0100
  121. #define FILE_ATTRIBUTE_SPARSE_FILE 0x0200
  122. #define FILE_ATTRIBUTE_REPARSE_POINT 0x0400
  123. #define FILE_ATTRIBUTE_COMPRESSED 0x0800
  124. #define FILE_ATTRIBUTE_OFFLINE 0x1000
  125. #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x2000
  126. #define FILE_ATTRIBUTE_ENCRYPTED 0x4000
  127. #define FILE_ATTRIBUTE_UNIX_EXTENSION 0x8000 /* trick for Unix */
  128. #endif
  129. #ifndef RINOK
  130. #define RINOK(x) { const int _result_ = (x); if (_result_ != 0) return _result_; }
  131. #endif
  132. #ifndef RINOK_WRes
  133. #define RINOK_WRes(x) { const WRes _result_ = (x); if (_result_ != 0) return _result_; }
  134. #endif
  135. typedef unsigned char Byte;
  136. typedef short Int16;
  137. typedef unsigned short UInt16;
  138. #ifdef Z7_DECL_Int32_AS_long
  139. typedef long Int32;
  140. typedef unsigned long UInt32;
  141. #else
  142. typedef int Int32;
  143. typedef unsigned int UInt32;
  144. #endif
  145. #ifndef _WIN32
  146. typedef int INT;
  147. typedef Int32 INT32;
  148. typedef unsigned int UINT;
  149. typedef UInt32 UINT32;
  150. typedef INT32 LONG; // LONG, ULONG and DWORD must be 32-bit for _WIN32 compatibility
  151. typedef UINT32 ULONG;
  152. #undef DWORD
  153. typedef UINT32 DWORD;
  154. #define VOID void
  155. #define HRESULT LONG
  156. typedef void *LPVOID;
  157. // typedef void VOID;
  158. // typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
  159. // gcc / clang on Unix : sizeof(long==sizeof(void*) in 32 or 64 bits)
  160. typedef long INT_PTR;
  161. typedef unsigned long UINT_PTR;
  162. typedef long LONG_PTR;
  163. typedef unsigned long DWORD_PTR;
  164. typedef size_t SIZE_T;
  165. #endif // _WIN32
  166. #define MY_HRES_ERROR_INTERNAL_ERROR ((HRESULT)0x8007054FL)
  167. #ifdef Z7_DECL_Int64_AS_long
  168. typedef long Int64;
  169. typedef unsigned long UInt64;
  170. #else
  171. #if (defined(_MSC_VER) || defined(__BORLANDC__)) && !defined(__clang__)
  172. typedef __int64 Int64;
  173. typedef unsigned __int64 UInt64;
  174. #else
  175. #if defined(__clang__) || defined(__GNUC__)
  176. #include <stdint.h>
  177. typedef int64_t Int64;
  178. typedef uint64_t UInt64;
  179. #else
  180. typedef long long int Int64;
  181. typedef unsigned long long int UInt64;
  182. // #define UINT64_CONST(n) n ## ULL
  183. #endif
  184. #endif
  185. #endif
  186. #define UINT64_CONST(n) n
  187. #ifdef Z7_DECL_SizeT_AS_unsigned_int
  188. typedef unsigned int SizeT;
  189. #else
  190. typedef size_t SizeT;
  191. #endif
  192. /*
  193. #if (defined(_MSC_VER) && _MSC_VER <= 1200)
  194. typedef size_t MY_uintptr_t;
  195. #else
  196. #include <stdint.h>
  197. typedef uintptr_t MY_uintptr_t;
  198. #endif
  199. */
  200. typedef int BoolInt;
  201. /* typedef BoolInt Bool; */
  202. #define True 1
  203. #define False 0
  204. #ifdef _WIN32
  205. #define Z7_STDCALL __stdcall
  206. #else
  207. #define Z7_STDCALL
  208. #endif
  209. #ifdef _MSC_VER
  210. #if _MSC_VER >= 1300
  211. #define Z7_NO_INLINE __declspec(noinline)
  212. #else
  213. #define Z7_NO_INLINE
  214. #endif
  215. #define Z7_FORCE_INLINE __forceinline
  216. #define Z7_CDECL __cdecl
  217. #define Z7_FASTCALL __fastcall
  218. #else // _MSC_VER
  219. #if (defined(__GNUC__) && (__GNUC__ >= 4)) \
  220. || (defined(__clang__) && (__clang_major__ >= 4)) \
  221. || defined(__INTEL_COMPILER) \
  222. || defined(__xlC__)
  223. #define Z7_NO_INLINE __attribute__((noinline))
  224. #define Z7_FORCE_INLINE __attribute__((always_inline)) inline
  225. #else
  226. #define Z7_NO_INLINE
  227. #define Z7_FORCE_INLINE
  228. #endif
  229. #define Z7_CDECL
  230. #if defined(_M_IX86) \
  231. || defined(__i386__)
  232. // #define Z7_FASTCALL __attribute__((fastcall))
  233. // #define Z7_FASTCALL __attribute__((cdecl))
  234. #define Z7_FASTCALL
  235. #elif defined(MY_CPU_AMD64)
  236. // #define Z7_FASTCALL __attribute__((ms_abi))
  237. #define Z7_FASTCALL
  238. #else
  239. #define Z7_FASTCALL
  240. #endif
  241. #endif // _MSC_VER
  242. /* The following interfaces use first parameter as pointer to structure */
  243. // #define Z7_C_IFACE_CONST_QUAL
  244. #define Z7_C_IFACE_CONST_QUAL const
  245. #define Z7_C_IFACE_DECL(a) \
  246. struct a ## _; \
  247. typedef Z7_C_IFACE_CONST_QUAL struct a ## _ * a ## Ptr; \
  248. typedef struct a ## _ a; \
  249. struct a ## _
  250. Z7_C_IFACE_DECL (IByteIn)
  251. {
  252. Byte (*Read)(IByteInPtr p); /* reads one byte, returns 0 in case of EOF or error */
  253. };
  254. #define IByteIn_Read(p) (p)->Read(p)
  255. Z7_C_IFACE_DECL (IByteOut)
  256. {
  257. void (*Write)(IByteOutPtr p, Byte b);
  258. };
  259. #define IByteOut_Write(p, b) (p)->Write(p, b)
  260. Z7_C_IFACE_DECL (ISeqInStream)
  261. {
  262. SRes (*Read)(ISeqInStreamPtr p, void *buf, size_t *size);
  263. /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
  264. (output(*size) < input(*size)) is allowed */
  265. };
  266. #define ISeqInStream_Read(p, buf, size) (p)->Read(p, buf, size)
  267. /* try to read as much as avail in stream and limited by (*processedSize) */
  268. SRes SeqInStream_ReadMax(ISeqInStreamPtr stream, void *buf, size_t *processedSize);
  269. /* it can return SZ_ERROR_INPUT_EOF */
  270. // SRes SeqInStream_Read(ISeqInStreamPtr stream, void *buf, size_t size);
  271. // SRes SeqInStream_Read2(ISeqInStreamPtr stream, void *buf, size_t size, SRes errorType);
  272. SRes SeqInStream_ReadByte(ISeqInStreamPtr stream, Byte *buf);
  273. Z7_C_IFACE_DECL (ISeqOutStream)
  274. {
  275. size_t (*Write)(ISeqOutStreamPtr p, const void *buf, size_t size);
  276. /* Returns: result - the number of actually written bytes.
  277. (result < size) means error */
  278. };
  279. #define ISeqOutStream_Write(p, buf, size) (p)->Write(p, buf, size)
  280. typedef enum
  281. {
  282. SZ_SEEK_SET = 0,
  283. SZ_SEEK_CUR = 1,
  284. SZ_SEEK_END = 2
  285. } ESzSeek;
  286. Z7_C_IFACE_DECL (ISeekInStream)
  287. {
  288. SRes (*Read)(ISeekInStreamPtr p, void *buf, size_t *size); /* same as ISeqInStream::Read */
  289. SRes (*Seek)(ISeekInStreamPtr p, Int64 *pos, ESzSeek origin);
  290. };
  291. #define ISeekInStream_Read(p, buf, size) (p)->Read(p, buf, size)
  292. #define ISeekInStream_Seek(p, pos, origin) (p)->Seek(p, pos, origin)
  293. Z7_C_IFACE_DECL (ILookInStream)
  294. {
  295. SRes (*Look)(ILookInStreamPtr p, const void **buf, size_t *size);
  296. /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
  297. (output(*size) > input(*size)) is not allowed
  298. (output(*size) < input(*size)) is allowed */
  299. SRes (*Skip)(ILookInStreamPtr p, size_t offset);
  300. /* offset must be <= output(*size) of Look */
  301. SRes (*Read)(ILookInStreamPtr p, void *buf, size_t *size);
  302. /* reads directly (without buffer). It's same as ISeqInStream::Read */
  303. SRes (*Seek)(ILookInStreamPtr p, Int64 *pos, ESzSeek origin);
  304. };
  305. #define ILookInStream_Look(p, buf, size) (p)->Look(p, buf, size)
  306. #define ILookInStream_Skip(p, offset) (p)->Skip(p, offset)
  307. #define ILookInStream_Read(p, buf, size) (p)->Read(p, buf, size)
  308. #define ILookInStream_Seek(p, pos, origin) (p)->Seek(p, pos, origin)
  309. SRes LookInStream_LookRead(ILookInStreamPtr stream, void *buf, size_t *size);
  310. SRes LookInStream_SeekTo(ILookInStreamPtr stream, UInt64 offset);
  311. /* reads via ILookInStream::Read */
  312. SRes LookInStream_Read2(ILookInStreamPtr stream, void *buf, size_t size, SRes errorType);
  313. SRes LookInStream_Read(ILookInStreamPtr stream, void *buf, size_t size);
  314. typedef struct
  315. {
  316. ILookInStream vt;
  317. ISeekInStreamPtr realStream;
  318. size_t pos;
  319. size_t size; /* it's data size */
  320. /* the following variables must be set outside */
  321. Byte *buf;
  322. size_t bufSize;
  323. } CLookToRead2;
  324. void LookToRead2_CreateVTable(CLookToRead2 *p, int lookahead);
  325. #define LookToRead2_INIT(p) { (p)->pos = (p)->size = 0; }
  326. typedef struct
  327. {
  328. ISeqInStream vt;
  329. ILookInStreamPtr realStream;
  330. } CSecToLook;
  331. void SecToLook_CreateVTable(CSecToLook *p);
  332. typedef struct
  333. {
  334. ISeqInStream vt;
  335. ILookInStreamPtr realStream;
  336. } CSecToRead;
  337. void SecToRead_CreateVTable(CSecToRead *p);
  338. Z7_C_IFACE_DECL (ICompressProgress)
  339. {
  340. SRes (*Progress)(ICompressProgressPtr p, UInt64 inSize, UInt64 outSize);
  341. /* Returns: result. (result != SZ_OK) means break.
  342. Value (UInt64)(Int64)-1 for size means unknown value. */
  343. };
  344. #define ICompressProgress_Progress(p, inSize, outSize) (p)->Progress(p, inSize, outSize)
  345. typedef struct ISzAlloc ISzAlloc;
  346. typedef const ISzAlloc * ISzAllocPtr;
  347. struct ISzAlloc
  348. {
  349. void *(*Alloc)(ISzAllocPtr p, size_t size);
  350. void (*Free)(ISzAllocPtr p, void *address); /* address can be 0 */
  351. };
  352. #define ISzAlloc_Alloc(p, size) (p)->Alloc(p, size)
  353. #define ISzAlloc_Free(p, a) (p)->Free(p, a)
  354. /* deprecated */
  355. #define IAlloc_Alloc(p, size) ISzAlloc_Alloc(p, size)
  356. #define IAlloc_Free(p, a) ISzAlloc_Free(p, a)
  357. #ifndef MY_offsetof
  358. #ifdef offsetof
  359. #define MY_offsetof(type, m) offsetof(type, m)
  360. /*
  361. #define MY_offsetof(type, m) FIELD_OFFSET(type, m)
  362. */
  363. #else
  364. #define MY_offsetof(type, m) ((size_t)&(((type *)0)->m))
  365. #endif
  366. #endif
  367. #ifndef Z7_container_of
  368. /*
  369. #define Z7_container_of(ptr, type, m) container_of(ptr, type, m)
  370. #define Z7_container_of(ptr, type, m) CONTAINING_RECORD(ptr, type, m)
  371. #define Z7_container_of(ptr, type, m) ((type *)((char *)(ptr) - offsetof(type, m)))
  372. #define Z7_container_of(ptr, type, m) (&((type *)0)->m == (ptr), ((type *)(((char *)(ptr)) - MY_offsetof(type, m))))
  373. */
  374. /*
  375. GCC shows warning: "perhaps the 'offsetof' macro was used incorrectly"
  376. GCC 3.4.4 : classes with constructor
  377. GCC 4.8.1 : classes with non-public variable members"
  378. */
  379. #define Z7_container_of(ptr, type, m) \
  380. ((type *)(void *)((char *)(void *) \
  381. (1 ? (ptr) : &((type *)NULL)->m) - MY_offsetof(type, m)))
  382. #define Z7_container_of_CONST(ptr, type, m) \
  383. ((const type *)(const void *)((const char *)(const void *) \
  384. (1 ? (ptr) : &((type *)NULL)->m) - MY_offsetof(type, m)))
  385. /*
  386. #define Z7_container_of_NON_CONST_FROM_CONST(ptr, type, m) \
  387. ((type *)(void *)(const void *)((const char *)(const void *) \
  388. (1 ? (ptr) : &((type *)NULL)->m) - MY_offsetof(type, m)))
  389. */
  390. #endif
  391. #define Z7_CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m) ((type *)(void *)(ptr))
  392. // #define Z7_CONTAINER_FROM_VTBL(ptr, type, m) Z7_CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m)
  393. #define Z7_CONTAINER_FROM_VTBL(ptr, type, m) Z7_container_of(ptr, type, m)
  394. // #define Z7_CONTAINER_FROM_VTBL(ptr, type, m) Z7_container_of_NON_CONST_FROM_CONST(ptr, type, m)
  395. #define Z7_CONTAINER_FROM_VTBL_CONST(ptr, type, m) Z7_container_of_CONST(ptr, type, m)
  396. #define Z7_CONTAINER_FROM_VTBL_CLS(ptr, type, m) Z7_CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m)
  397. /*
  398. #define Z7_CONTAINER_FROM_VTBL_CLS(ptr, type, m) Z7_CONTAINER_FROM_VTBL(ptr, type, m)
  399. */
  400. #if defined (__clang__) || defined(__GNUC__)
  401. #define Z7_DIAGNOSTIC_IGNORE_BEGIN_CAST_QUAL \
  402. _Pragma("GCC diagnostic push") \
  403. _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
  404. #define Z7_DIAGNOSTIC_IGNORE_END_CAST_QUAL \
  405. _Pragma("GCC diagnostic pop")
  406. #else
  407. #define Z7_DIAGNOSTIC_IGNORE_BEGIN_CAST_QUAL
  408. #define Z7_DIAGNOSTIC_IGNORE_END_CAST_QUAL
  409. #endif
  410. #define Z7_CONTAINER_FROM_VTBL_TO_DECL_VAR(ptr, type, m, p) \
  411. Z7_DIAGNOSTIC_IGNORE_BEGIN_CAST_QUAL \
  412. type *p = Z7_CONTAINER_FROM_VTBL(ptr, type, m); \
  413. Z7_DIAGNOSTIC_IGNORE_END_CAST_QUAL
  414. #define Z7_CONTAINER_FROM_VTBL_TO_DECL_VAR_pp_vt_p(type) \
  415. Z7_CONTAINER_FROM_VTBL_TO_DECL_VAR(pp, type, vt, p)
  416. // #define ZIP7_DECLARE_HANDLE(name) typedef void *name;
  417. #define Z7_DECLARE_HANDLE(name) struct name##_dummy{int unused;}; typedef struct name##_dummy *name;
  418. #define Z7_memset_0_ARRAY(a) memset((a), 0, sizeof(a))
  419. #ifndef Z7_ARRAY_SIZE
  420. #define Z7_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
  421. #endif
  422. #ifdef _WIN32
  423. #define CHAR_PATH_SEPARATOR '\\'
  424. #define WCHAR_PATH_SEPARATOR L'\\'
  425. #define STRING_PATH_SEPARATOR "\\"
  426. #define WSTRING_PATH_SEPARATOR L"\\"
  427. #else
  428. #define CHAR_PATH_SEPARATOR '/'
  429. #define WCHAR_PATH_SEPARATOR L'/'
  430. #define STRING_PATH_SEPARATOR "/"
  431. #define WSTRING_PATH_SEPARATOR L"/"
  432. #endif
  433. #define k_PropVar_TimePrec_0 0
  434. #define k_PropVar_TimePrec_Unix 1
  435. #define k_PropVar_TimePrec_DOS 2
  436. #define k_PropVar_TimePrec_HighPrec 3
  437. #define k_PropVar_TimePrec_Base 16
  438. #define k_PropVar_TimePrec_100ns (k_PropVar_TimePrec_Base + 7)
  439. #define k_PropVar_TimePrec_1ns (k_PropVar_TimePrec_Base + 9)
  440. EXTERN_C_END
  441. #endif
  442. /*
  443. #ifndef Z7_ST
  444. #ifdef _7ZIP_ST
  445. #define Z7_ST
  446. #endif
  447. #endif
  448. */