MagickCore  6.9.12-19
Convert, Edit, Or Compose Bitmap Images
nt-base.h
Go to the documentation of this file.
1 /*
2  Copyright 1999-2021 ImageMagick Studio LLC, a non-profit organization
3  dedicated to making software imaging solutions freely available.
4 
5  You may not use this file except in compliance with the License. You may
6  obtain a copy of the License at
7 
8  https://imagemagick.org/script/license.php
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16  MagickCore Windows NT utility methods.
17 */
18 #ifndef MAGICKCORE_NT_BASE_H
19 #define MAGICKCORE_NT_BASE_H
20 
21 #include "magick/exception.h"
22 #include "magick/geometry.h"
23 
24 #if defined(__cplusplus) || defined(c_plusplus)
25 extern "C" {
26 #endif
27 
28 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
29 
30 #define WIN32_LEAN_AND_MEAN
31 #define VC_EXTRALEAN
32 #if !defined(_CRT_SECURE_NO_DEPRECATE)
33 # define _CRT_SECURE_NO_DEPRECATE 1
34 #endif
35 #include <windows.h>
36 #include <wchar.h>
37 #include <winuser.h>
38 #include <wingdi.h>
39 #include <io.h>
40 #include <process.h>
41 #include <errno.h>
42 #include <malloc.h>
43 #include <sys/utime.h>
44 #if defined(_DEBUG) && !defined(__MINGW32__)
45 #include <crtdbg.h>
46 #endif
47 
48 #define PROT_READ 0x01
49 #define PROT_WRITE 0x02
50 #define MAP_SHARED 0x01
51 #define MAP_PRIVATE 0x02
52 #define MAP_ANONYMOUS 0x20
53 #define F_OK 0
54 #define R_OK 4
55 #define W_OK 2
56 #define RW_OK 6
57 #define _SC_PAGE_SIZE 1
58 #define _SC_PHYS_PAGES 2
59 #define _SC_OPEN_MAX 3
60 #if !defined(SSIZE_MAX)
61 # ifdef _WIN64
62 # define SSIZE_MAX LLONG_MAX
63 # else
64 # define SSIZE_MAX LONG_MAX
65 # endif
66 #endif
67 
68 /*
69  _MSC_VER values:
70  1100 MSVC 5.0
71  1200 MSVC 6.0
72  1300 MSVC 7.0 Visual C++ .NET 2002
73  1310 Visual c++ .NET 2003
74  1400 Visual C++ 2005
75  1500 Visual C++ 2008
76  1600 Visual C++ 2010
77  1700 Visual C++ 2012
78  1800 Visual C++ 2013
79  1900 Visual C++ 2015
80 */
81 
82 #if !defined(chsize)
83 # if defined(__BORLANDC__)
84 # define chsize(file,length) chsize(file,length)
85 # else
86 # define chsize(file,length) _chsize(file,length)
87 # endif
88 #endif
89 
90 #if !defined(access)
91 #if defined(_VISUALC_) && (_MSC_VER >= 1400)
92 # define access(path,mode) _access_s(path,mode)
93 #endif
94 #endif
95 #if !defined(chdir)
96 # define chdir _chdir
97 #endif
98 #if !defined(close)
99 # define close _close
100 #endif
101 #if !defined(closedir)
102 # define closedir(directory) NTCloseDirectory(directory)
103 #endif
104 #if !defined(fdopen)
105 # define fdopen _fdopen
106 #endif
107 #if !defined(fileno)
108 # define fileno _fileno
109 #endif
110 #if !defined(freelocale)
111 # define freelocale _free_locale
112 #endif
113 #if !defined(fseek) && !defined(__MINGW32__)
114 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
115  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
116  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
117 # define fseek _fseeki64
118 #endif
119 #endif
120 #if !defined(fstat) && !defined(__BORLANDC__)
121 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
122  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
123  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
124 # define fstat _fstati64
125 #else
126 # define fstat _fstat
127 #endif
128 #endif
129 #if !defined(fsync)
130 # define fsync _commit
131 #endif
132 #if !defined(ftell) && !defined(__MINGW32__)
133 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
134  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
135  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
136 # define ftell _ftelli64
137 #endif
138 #endif
139 #if !defined(ftruncate)
140 # define ftruncate(file,length) NTTruncateFile(file,length)
141 #endif
142 #if !defined(getcwd)
143 # define getcwd _getcwd
144 #endif
145 #if !defined(getpid)
146 # define getpid _getpid
147 #endif
148 #if !defined(hypot)
149 # define hypot _hypot
150 #endif
151 #if !defined(inline)
152 # define inline __inline
153 #endif
154 #if !defined(isatty)
155 # define isatty _isatty
156 #endif
157 #if !defined(locale_t)
158 #define locale_t _locale_t
159 #endif
160 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
161  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
162  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
163 #if !defined(lseek)
164 # define lseek _lseeki64
165 #endif
166 #else
167 #if !defined(lseek)
168 # define lseek _lseek
169 #endif
170 #endif
171 #if !defined(MAGICKCORE_LTDL_DELEGATE)
172 #if !defined(lt_dlclose)
173 # define lt_dlclose(handle) NTCloseLibrary(handle)
174 #endif
175 #if !defined(lt_dlerror)
176 # define lt_dlerror() NTGetLibraryError()
177 #endif
178 #if !defined(lt_dlexit)
179 # define lt_dlexit() NTExitLibrary()
180 #endif
181 #if !defined(lt_dlinit)
182 # define lt_dlinit() NTInitializeLibrary()
183 #endif
184 #if !defined(lt_dlopen)
185 # define lt_dlopen(filename) NTOpenLibrary(filename)
186 #endif
187 #if !defined(lt_dlsetsearchpath)
188 # define lt_dlsetsearchpath(path) NTSetSearchPath(path)
189 #endif
190 #if !defined(lt_dlsym)
191 # define lt_dlsym(handle,name) NTGetLibrarySymbol(handle,name)
192 #endif
193 #endif
194 #if !defined(mkdir)
195 # define mkdir _mkdir
196 #endif
197 #if !defined(mmap)
198 # define MAGICKCORE_HAVE_MMAP 1
199 # define mmap(address,length,protection,access,file,offset) \
200  NTMapMemory(address,length,protection,access,file,offset)
201 #endif
202 #if !defined(munmap)
203 # define munmap(address,length) NTUnmapMemory(address,length)
204 #endif
205 #if !defined(opendir)
206 # define opendir(directory) NTOpenDirectory(directory)
207 #endif
208 #if !defined(open)
209 # define open _open
210 #endif
211 #if !defined(pclose)
212 # define pclose _pclose
213 #endif
214 #if !defined(popen)
215 # define popen _popen
216 #endif
217 #if !defined(fprintf_l)
218 #define fprintf_l _fprintf_s_l
219 #endif
220 #if !defined(read)
221 # define read(fd,buffer,count) _read(fd,buffer,(unsigned int) count)
222 #endif
223 #if !defined(readdir)
224 # define readdir(directory) NTReadDirectory(directory)
225 #endif
226 #if !defined(setmode)
227 # define setmode _setmode
228 #endif
229 #if !defined(spawnvp)
230 # define spawnvp _spawnvp
231 #endif
232 #if !defined(strtod_l)
233 #define strtod_l _strtod_l
234 #endif
235 #if !defined(stat) && !defined(__BORLANDC__)
236 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
237  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
238  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
239 # define stat _stati64
240 #else
241 # define stat _stat
242 #endif
243 #endif
244 #if !defined(strcasecmp)
245 # define strcasecmp _stricmp
246 #endif
247 #if !defined(strncasecmp)
248 # define strncasecmp _strnicmp
249 #endif
250 #if !defined(sysconf)
251 # define sysconf(name) NTSystemConfiguration(name)
252 # define MAGICKCORE_HAVE_SYSCONF 1
253 #endif
254 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
255  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
256  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
257 # define tell _telli64
258 #else
259 # define tell _tell
260 #endif
261 #if !defined(tempnam)
262 # define tempnam _tempnam_s
263 #endif
264 #if !defined(tolower_l)
265 #define tolower_l _tolower_l
266 #endif
267 #if !defined(toupper_l)
268 #define toupper_l _toupper_l
269 #endif
270 #if !defined(umask)
271 # define umask _umask
272 #endif
273 #if !defined(unlink)
274 # define unlink _unlink
275 #endif
276 #if !defined(utime)
277 # define utime _utime
278 #endif
279 #if !defined(vfprintf_l)
280 #define vfprintf_l _vfprintf_l
281 #endif
282 #if !defined(vsnprintf)
283 #if !defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1500)
284 #define vsnprintf _vsnprintf
285 #endif
286 #endif
287 #if !defined(vsnprintf_l)
288 #define vsnprintf_l _vsnprintf_l
289 #endif
290 #if !defined(write)
291 # define write(fd,buffer,count) _write(fd,buffer,(unsigned int) count)
292 #endif
293 #if !defined(wstat) && !defined(__BORLANDC__)
294 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
295  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
296  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
297 # define wstat _wstati64
298 #else
299 # define wstat _wstat
300 #endif
301 #endif
302 
303 #if defined(__BORLANDC__)
304 #undef _O_RANDOM
305 #define _O_RANDOM 0
306 #undef _O_SEQUENTIAL
307 #define _O_SEQUENTIAL 0
308 #undef _O_SHORT_LIVED
309 #define _O_SHORT_LIVED 0
310 #undef _O_TEMPORARY
311 #define _O_TEMPORARY 0
312 #endif
313 
314 #undef gettimeofday
315 
316 typedef struct _GhostInfo
317  GhostInfo_;
318 
319 extern MagickExport char
320  **NTArgvToUTF8(const int argc,wchar_t **);
321 
322 extern MagickExport const GhostInfo_
323  *NTGhostscriptDLLVectors(void);
324 
325 extern MagickExport int
326  NTGhostscriptUnLoadDLL(void);
327 
328 extern MagickExport void
329  NTErrorHandler(const ExceptionType,const char *,const char *),
330  NTWarningHandler(const ExceptionType,const char *,const char *);
331 
332 #endif
333 
334 #if defined(__cplusplus) || defined(c_plusplus)
335 }
336 #endif
337 
338 #endif
ExceptionType
Definition: exception.h:28
Definition: delegate-private.h:54
#define MagickExport
Definition: method-attribute.h:80