unrarsrc  6.1.7
About: unrar extracts, views and tests the contents of archives created with the RAR archiver.
  Fossies Dox: unrarsrc-6.1.7.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

os.hpp
Go to the documentation of this file.
1#ifndef _RAR_OS_
2#define _RAR_OS_
3
4#define FALSE 0
5#define TRUE 1
6
7#ifdef __EMX__
8 #define INCL_BASE
9#endif
10
11#if defined(RARDLL) && !defined(SILENT)
12#define SILENT
13#endif
14
15#include <new>
16
17
18#if defined(_WIN_ALL) || defined(_EMX)
19
20#define LITTLE_ENDIAN
21#define NM 2048
22
23#ifdef _WIN_ALL
24
25
26// We got a report that just "#define STRICT" is incompatible with
27// "#define STRICT 1" in Windows 10 SDK minwindef.h and depending on the order
28// in which these statements are reached this may cause a compiler warning
29// and build break for other projects incorporating this source.
30// So we changed it to "#define STRICT 1".
31#ifndef STRICT
32#define STRICT 1
33#endif
34
35// 'ifndef' check here is needed for unrar.dll header to avoid macro
36// re-definition warnings in third party projects.
37#ifndef UNICODE
38#define UNICODE
39#define _UNICODE // Set _T() macro to convert from narrow to wide strings.
40#endif
41
42#define WINVER _WIN32_WINNT_WINXP
43#define _WIN32_WINNT _WIN32_WINNT_WINXP
44
45#if !defined(ZIPSFX)
46#define RAR_SMP
47#endif
48
49#define WIN32_LEAN_AND_MEAN
50
51#include <windows.h>
52#include <prsht.h>
53#include <shlwapi.h>
54#pragma comment(lib, "Shlwapi.lib")
55#include <PowrProf.h>
56#pragma comment(lib, "PowrProf.lib")
57#include <shellapi.h>
58#include <shlobj.h>
59#include <winioctl.h>
60#include <wincrypt.h>
61#include <wchar.h>
62#include <wctype.h>
63
64
65#endif // _WIN_ALL
66
67#include <sys/types.h>
68#include <sys/stat.h>
69#include <dos.h>
70
71#if !defined(_EMX) && !defined(_MSC_VER)
72 #include <dir.h>
73#endif
74#ifdef _MSC_VER
75 #if _MSC_VER<1500
76 #define for if (0) ; else for
77 #endif
78 #include <direct.h>
79 #include <intrin.h>
80
81 // Use SSE only for x86/x64, not ARM Windows.
82 #if defined(_M_IX86) || defined(_M_X64)
83 #define USE_SSE
84 #define SSE_ALIGNMENT 16
85 #endif
86#else
87 #include <dirent.h>
88#endif // _MSC_VER
89
90#include <stdio.h>
91#include <stdlib.h>
92#include <stdarg.h>
93#include <string.h>
94#include <ctype.h>
95#include <fcntl.h>
96#include <dos.h>
97#include <io.h>
98#include <time.h>
99#include <signal.h>
100
101
102#define SAVE_LINKS
103
104#define ENABLE_ACCESS
105
106#define DefConfigName L"rar.ini"
107#define DefLogName L"rar.log"
108
109
110#define SPATHDIVIDER L"\\"
111#define CPATHDIVIDER '\\'
112#define MASKALL L"*"
113
114#define READBINARY "rb"
115#define READTEXT "rt"
116#define UPDATEBINARY "r+b"
117#define CREATEBINARY "w+b"
118#define WRITEBINARY "wb"
119#define APPENDTEXT "at"
120
121#if defined(_WIN_ALL)
122 #ifdef _MSC_VER
123 #define _stdfunction __cdecl
124 #define _forceinline __forceinline
125 #else
126 #define _stdfunction _USERENTRY
127 #define _forceinline inline
128 #endif
129#else
130 #define _stdfunction
131 #define _forceinline inline
132#endif
133
134#endif // defined(_WIN_ALL) || defined(_EMX)
135
136#ifdef _UNIX
137
138#define NM 2048
139
140#include <unistd.h>
141#include <sys/types.h>
142#include <sys/stat.h>
143#include <sys/file.h>
144#if defined(__QNXNTO__)
145 #include <sys/param.h>
146#endif
147#if defined(RAR_SMP) && defined(__APPLE__)
148 #include <sys/sysctl.h>
149#endif
150#ifndef SFX_MODULE
151 #include <sys/statvfs.h>
152#endif
153#include <pwd.h>
154#include <grp.h>
155#include <wchar.h>
156#include <wctype.h>
157#include <stdio.h>
158#include <stdlib.h>
159#include <stdarg.h>
160#include <string.h>
161#include <ctype.h>
162#include <fcntl.h>
163#include <errno.h>
164#include <dirent.h>
165#include <time.h>
166#include <signal.h>
167#include <utime.h>
168#include <locale.h>
169
170
171#ifdef S_IFLNK
172#define SAVE_LINKS
173#endif
174
175#if defined(__linux) || defined(__FreeBSD__)
176#include <sys/time.h>
177#define USE_LUTIMES
178#endif
179
180#define ENABLE_ACCESS
181
182#define DefConfigName L".rarrc"
183#define DefLogName L".rarlog"
184
185
186#define SPATHDIVIDER L"/"
187#define CPATHDIVIDER '/'
188#define MASKALL L"*"
189
190#define READBINARY "r"
191#define READTEXT "r"
192#define UPDATEBINARY "r+"
193#define CREATEBINARY "w+"
194#define WRITEBINARY "w"
195#define APPENDTEXT "a"
196
197#define _stdfunction
198#define _forceinline inline
199
200#ifdef _APPLE
201 #if defined(__BIG_ENDIAN__) && !defined(BIG_ENDIAN)
202 #define BIG_ENDIAN
203 #undef LITTLE_ENDIAN
204 #endif
205 #if defined(__i386__) && !defined(LITTLE_ENDIAN)
206 #define LITTLE_ENDIAN
207 #undef BIG_ENDIAN
208 #endif
209#endif
210
211#if defined(__sparc) || defined(sparc) || defined(__hpux)
212 #ifndef BIG_ENDIAN
213 #define BIG_ENDIAN
214 #endif
215#endif
216
217// Unlike Apple x64, utimensat shall be available in all Apple M1 systems.
218#if _POSIX_C_SOURCE >= 200809L || defined(__APPLE__) && defined(__arm64__)
219 #define UNIX_TIME_NS // Nanosecond time precision in Unix.
220#endif
221
222#endif // _UNIX
223
224#if 0
225 #define MSGID_INT
226 typedef int MSGID;
227#else
228 typedef const wchar* MSGID;
229#endif
230
231#ifndef SSE_ALIGNMENT // No SSE use and no special data alignment is required.
232 #define SSE_ALIGNMENT 1
233#endif
234
235#define safebuf static
236
237// Solaris defines _LITTLE_ENDIAN or _BIG_ENDIAN.
238#if defined(_LITTLE_ENDIAN) && !defined(LITTLE_ENDIAN)
239 #define LITTLE_ENDIAN
240#endif
241#if defined(_BIG_ENDIAN) && !defined(BIG_ENDIAN)
242 #define BIG_ENDIAN
243#endif
244
245#if !defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)
246 #if defined(__i386) || defined(i386) || defined(__i386__) || defined(__x86_64)
247 #define LITTLE_ENDIAN
248 #elif defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN || defined(__LITTLE_ENDIAN__)
249 #define LITTLE_ENDIAN
250 #elif defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN || defined(__BIG_ENDIAN__)
251 #define BIG_ENDIAN
252 #else
253 #error "Neither LITTLE_ENDIAN nor BIG_ENDIAN are defined. Define one of them."
254 #endif
255#endif
256
257#if defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN)
258 #if defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN
259 #undef LITTLE_ENDIAN
260 #elif defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN
261 #undef BIG_ENDIAN
262 #else
263 #error "Both LITTLE_ENDIAN and BIG_ENDIAN are defined. Undef one of them."
264 #endif
265#endif
266
267#if !defined(BIG_ENDIAN) && defined(_WIN_ALL) || defined(__i386__) || defined(__x86_64__)
268// Allow not aligned integer access, increases speed in some operations.
269#define ALLOW_MISALIGNED
270#endif
271
272#endif // _RAR_OS_
const wchar * MSGID
Definition: os.hpp:228
wchar_t wchar
Definition: rartypes.hpp:13