os.hpp 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. #ifndef _RAR_OS_
  2. #define _RAR_OS_
  3. #define FALSE 0
  4. #define TRUE 1
  5. #ifdef __EMX__
  6. #define INCL_BASE
  7. #endif
  8. #if defined(RARDLL) && !defined(SILENT)
  9. #define SILENT
  10. #endif
  11. #if defined(_WIN_ALL) || defined(_EMX)
  12. #define ENABLE_BAD_ALLOC
  13. #endif
  14. #if defined(_WIN_ALL) || defined(_EMX)
  15. #define LITTLE_ENDIAN
  16. #define NM 1024
  17. #ifdef _WIN_ALL
  18. #define STRICT
  19. #define UNICODE
  20. #undef WINVER
  21. #undef _WIN32_WINNT
  22. #define WINVER 0x0500
  23. #define _WIN32_WINNT 0x0500
  24. #define WIN32_LEAN_AND_MEAN
  25. #include <windows.h>
  26. #include <prsht.h>
  27. #include <shlwapi.h>
  28. #ifndef _WIN_CE
  29. #include <shellapi.h>
  30. #include <shlobj.h>
  31. #include <winioctl.h>
  32. #endif // _WIN_CE
  33. #endif // _WIN_ALL
  34. #ifndef _WIN_CE
  35. #include <sys/types.h>
  36. #include <sys/stat.h>
  37. #include <dos.h>
  38. #endif // _WIN_CE
  39. #if !defined(_EMX) && !defined(_MSC_VER) && !defined(_WIN_CE)
  40. #include <dir.h>
  41. #endif
  42. #ifdef _MSC_VER
  43. #if _MSC_VER<1500
  44. #define for if (0) ; else for
  45. #endif
  46. #ifndef _WIN_CE
  47. #include <direct.h>
  48. #endif
  49. #else
  50. #include <dirent.h>
  51. #endif // _MSC_VER
  52. #ifndef _WIN_CE
  53. #include <share.h>
  54. #endif // _WIN_CE
  55. #if defined(ENABLE_BAD_ALLOC) && !defined(_WIN_CE)
  56. #include <new.h>
  57. #endif
  58. #ifdef _EMX
  59. #include <unistd.h>
  60. #include <pwd.h>
  61. #include <grp.h>
  62. #include <errno.h>
  63. #ifdef _DJGPP
  64. #include <utime.h>
  65. #else
  66. #include <os2.h>
  67. #include <sys/utime.h>
  68. #include <emx/syscalls.h>
  69. #endif
  70. #else
  71. #if defined(_MSC_VER) || defined(__MINGW32__)
  72. #include <exception>
  73. #else
  74. #include <except.h>
  75. #endif
  76. #endif
  77. #include <stdio.h>
  78. #include <stdlib.h>
  79. #include <stdarg.h>
  80. #include <string.h>
  81. #include <ctype.h>
  82. #ifndef _WIN_CE
  83. #include <fcntl.h>
  84. #include <dos.h>
  85. #include <io.h>
  86. #include <time.h>
  87. #include <signal.h>
  88. #endif
  89. /*
  90. #ifdef _WIN_ALL
  91. #pragma hdrstop
  92. #endif // _WIN_ALL
  93. */
  94. #define ENABLE_ACCESS
  95. #define DefConfigName "rar.ini"
  96. #define DefLogName "rar.log"
  97. #define PATHDIVIDER "\\"
  98. #define PATHDIVIDERW L"\\"
  99. #define CPATHDIVIDER '\\'
  100. #define MASKALL "*"
  101. #define MASKALLW L"*"
  102. #define READBINARY "rb"
  103. #define READTEXT "rt"
  104. #define UPDATEBINARY "r+b"
  105. #define CREATEBINARY "w+b"
  106. #define APPENDTEXT "at"
  107. #if defined(_WIN_ALL)
  108. #ifdef _MSC_VER
  109. #define _stdfunction __cdecl
  110. #ifdef SFX_MODULE
  111. // We want to keep SFX module small, so let compiler to decide.
  112. #define _forceinline inline
  113. #else
  114. #define _forceinline __forceinline
  115. #endif
  116. #else
  117. #define _stdfunction _USERENTRY
  118. #define _forceinline inline
  119. #endif
  120. #else
  121. #define _stdfunction
  122. #define _forceinline inline
  123. #endif
  124. #endif
  125. #ifdef _UNIX
  126. #define NM 1024
  127. #ifdef _BEOS
  128. #include <be/kernel/fs_info.h>
  129. #include <be/kernel/fs_attr.h>
  130. #endif
  131. #include <unistd.h>
  132. #include <sys/types.h>
  133. #include <sys/stat.h>
  134. #include <sys/file.h>
  135. #if defined(__QNXNTO__)
  136. #include <sys/param.h>
  137. #endif
  138. #if defined(__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined(__APPLE__)
  139. #include <sys/param.h>
  140. #include <sys/mount.h>
  141. #else
  142. #endif
  143. #include <pwd.h>
  144. #include <grp.h>
  145. #include <wchar.h>
  146. #include <stdio.h>
  147. #include <stdlib.h>
  148. #include <stdarg.h>
  149. #include <string.h>
  150. #include <ctype.h>
  151. #include <fcntl.h>
  152. #include <errno.h>
  153. #include <dirent.h>
  154. #include <time.h>
  155. #include <signal.h>
  156. #include <utime.h>
  157. #include <locale.h>
  158. #ifdef S_IFLNK
  159. #define SAVE_LINKS
  160. #endif
  161. #define ENABLE_ACCESS
  162. #define DefConfigName ".rarrc"
  163. #define DefLogName ".rarlog"
  164. #define PATHDIVIDER "/"
  165. #define PATHDIVIDERW L"/"
  166. #define CPATHDIVIDER '/'
  167. #define MASKALL "*"
  168. #define MASKALLW L"*"
  169. #define READBINARY "r"
  170. #define READTEXT "r"
  171. #define UPDATEBINARY "r+"
  172. #define CREATEBINARY "w+"
  173. #define APPENDTEXT "a"
  174. #define _stdfunction
  175. #define _forceinline inline
  176. #ifdef _APPLE
  177. #if defined(__BIG_ENDIAN__) && !defined(BIG_ENDIAN)
  178. #define BIG_ENDIAN
  179. #undef LITTLE_ENDIAN
  180. #endif
  181. #if defined(__i386__) && !defined(LITTLE_ENDIAN)
  182. #define LITTLE_ENDIAN
  183. #undef BIG_ENDIAN
  184. #endif
  185. #endif
  186. #if defined(__sparc) || defined(sparc) || defined(__hpux)
  187. #ifndef BIG_ENDIAN
  188. #define BIG_ENDIAN
  189. #endif
  190. #endif
  191. #endif
  192. typedef const char* MSGID;
  193. #define safebuf static
  194. #if !defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)
  195. #if defined(__i386) || defined(i386) || defined(__i386__)
  196. #define LITTLE_ENDIAN
  197. #elif defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN
  198. #define LITTLE_ENDIAN
  199. #elif defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN
  200. #define BIG_ENDIAN
  201. #else
  202. #error "Neither LITTLE_ENDIAN nor BIG_ENDIAN are defined. Define one of them."
  203. #endif
  204. #endif
  205. #if defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN)
  206. #if defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN
  207. #undef LITTLE_ENDIAN
  208. #elif defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN
  209. #undef BIG_ENDIAN
  210. #else
  211. #error "Both LITTLE_ENDIAN and BIG_ENDIAN are defined. Undef one of them."
  212. #endif
  213. #endif
  214. #if !defined(BIG_ENDIAN) && !defined(_WIN_CE) && defined(_WIN_ALL)
  215. /* allow not aligned integer access, increases speed in some operations */
  216. #define ALLOW_NOT_ALIGNED_INT
  217. #endif
  218. #if defined(__sparc) || defined(sparc) || defined(__sparcv9)
  219. /* prohibit not aligned access to data structures in text comression
  220. algorithm, increases memory requirements */
  221. #define STRICT_ALIGNMENT_REQUIRED
  222. #endif
  223. #endif // _RAR_OS_