MagickCore  6.9.12-34
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(putenv)
218 # define putenv _putenv
219 #endif
220 #if !defined(fprintf_l)
221 #define fprintf_l _fprintf_s_l
222 #endif
223 #if !defined(read)
224 # define read(fd,buffer,count) _read(fd,buffer,(unsigned int) count)
225 #endif
226 #if !defined(readdir)
227 # define readdir(directory) NTReadDirectory(directory)
228 #endif
229 #if !defined(setmode)
230 # define setmode _setmode
231 #endif
232 #if !defined(spawnvp)
233 # define spawnvp _spawnvp
234 #endif
235 #if !defined(strtod_l)
236 #define strtod_l _strtod_l
237 #endif
238 #if !defined(stat) && !defined(__BORLANDC__)
239 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
240  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
241  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
242 # define stat _stati64
243 #else
244 # define stat _stat
245 #endif
246 #endif
247 #if !defined(strcasecmp)
248 # define strcasecmp _stricmp
249 #endif
250 #if !defined(strncasecmp)
251 # define strncasecmp _strnicmp
252 #endif
253 #if !defined(sysconf)
254 # define sysconf(name) NTSystemConfiguration(name)
255 # define MAGICKCORE_HAVE_SYSCONF 1
256 #endif
257 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
258  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
259  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
260 # define tell _telli64
261 #else
262 # define tell _tell
263 #endif
264 #if !defined(tempnam)
265 # define tempnam _tempnam_s
266 #endif
267 #if !defined(tolower_l)
268 #define tolower_l _tolower_l
269 #endif
270 #if !defined(toupper_l)
271 #define toupper_l _toupper_l
272 #endif
273 #if !defined(umask)
274 # define umask _umask
275 #endif
276 #if !defined(unlink)
277 # define unlink _unlink
278 #endif
279 #if !defined(utime)
280 # define utime _utime
281 #endif
282 #if !defined(vfprintf_l)
283 #define vfprintf_l _vfprintf_l
284 #endif
285 #if !defined(vsnprintf)
286 #if !defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1500)
287 #define vsnprintf _vsnprintf
288 #endif
289 #endif
290 #if !defined(vsnprintf_l)
291 #define vsnprintf_l _vsnprintf_l
292 #endif
293 #if !defined(write)
294 # define write(fd,buffer,count) _write(fd,buffer,(unsigned int) count)
295 #endif
296 #if !defined(wstat) && !defined(__BORLANDC__)
297 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
298  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
299  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
300 # define wstat _wstati64
301 #else
302 # define wstat _wstat
303 #endif
304 #endif
305 
306 #if defined(__BORLANDC__)
307 #undef _O_RANDOM
308 #define _O_RANDOM 0
309 #undef _O_SEQUENTIAL
310 #define _O_SEQUENTIAL 0
311 #undef _O_SHORT_LIVED
312 #define _O_SHORT_LIVED 0
313 #undef _O_TEMPORARY
314 #define _O_TEMPORARY 0
315 #endif
316 
317 #undef gettimeofday
318 
319 typedef struct _GhostInfo
320  GhostInfo_;
321 
322 extern MagickExport char
323  **NTArgvToUTF8(const int argc,wchar_t **);
324 
325 extern MagickExport const GhostInfo_
326  *NTGhostscriptDLLVectors(void);
327 
328 extern MagickExport int
329  NTGhostscriptUnLoadDLL(void);
330 
331 extern MagickExport void
332  NTErrorHandler(const ExceptionType,const char *,const char *),
333  NTWarningHandler(const ExceptionType,const char *,const char *);
334 
335 #endif
336 
337 #if defined(__cplusplus) || defined(c_plusplus)
338 }
339 #endif
340 
341 #endif
ExceptionType
Definition: exception.h:28
Definition: delegate-private.h:54
#define MagickExport
Definition: method-attribute.h:80