MagickCore  6.9.11
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 #define _CRT_SECURE_NO_DEPRECATE 1
33 #include <windows.h>
34 #include <wchar.h>
35 #include <winuser.h>
36 #include <wingdi.h>
37 #include <io.h>
38 #include <process.h>
39 #include <errno.h>
40 #include <malloc.h>
41 #include <sys/utime.h>
42 #if defined(_DEBUG) && !defined(__MINGW32__)
43 #include <crtdbg.h>
44 #endif
45 
46 #define PROT_READ 0x01
47 #define PROT_WRITE 0x02
48 #define MAP_SHARED 0x01
49 #define MAP_PRIVATE 0x02
50 #define MAP_ANONYMOUS 0x20
51 #define F_OK 0
52 #define R_OK 4
53 #define W_OK 2
54 #define RW_OK 6
55 #define _SC_PAGE_SIZE 1
56 #define _SC_PHYS_PAGES 2
57 #define _SC_OPEN_MAX 3
58 
59 /*
60  _MSC_VER values:
61  1100 MSVC 5.0
62  1200 MSVC 6.0
63  1300 MSVC 7.0 Visual C++ .NET 2002
64  1310 Visual c++ .NET 2003
65  1400 Visual C++ 2005
66  1500 Visual C++ 2008
67  1600 Visual C++ 2010
68  1700 Visual C++ 2012
69  1800 Visual C++ 2013
70  1900 Visual C++ 2015
71 */
72 
73 #if !defined(chsize)
74 # if defined(__BORLANDC__)
75 # define chsize(file,length) chsize(file,length)
76 # else
77 # define chsize(file,length) _chsize(file,length)
78 # endif
79 #endif
80 
81 #if !defined(access)
82 #if defined(_VISUALC_) && (_MSC_VER >= 1400)
83 # define access(path,mode) _access_s(path,mode)
84 #endif
85 #endif
86 #if !defined(chdir)
87 # define chdir _chdir
88 #endif
89 #if !defined(close)
90 # define close _close
91 #endif
92 #if !defined(closedir)
93 # define closedir(directory) NTCloseDirectory(directory)
94 #endif
95 #if !defined(fdopen)
96 # define fdopen _fdopen
97 #endif
98 #if !defined(fileno)
99 # define fileno _fileno
100 #endif
101 #if !defined(freelocale)
102 # define freelocale _free_locale
103 #endif
104 #if !defined(fseek) && !defined(__MINGW32__)
105 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
106  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
107  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
108 # define fseek _fseeki64
109 #endif
110 #endif
111 #if !defined(fstat) && !defined(__BORLANDC__)
112 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
113  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
114  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
115 # define fstat _fstati64
116 #else
117 # define fstat _fstat
118 #endif
119 #endif
120 #if !defined(fsync)
121 # define fsync _commit
122 #endif
123 #if !defined(ftell) && !defined(__MINGW32__)
124 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
125  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
126  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
127 # define ftell _ftelli64
128 #endif
129 #endif
130 #if !defined(ftruncate)
131 # define ftruncate(file,length) NTTruncateFile(file,length)
132 #endif
133 #if !defined(getcwd)
134 # define getcwd _getcwd
135 #endif
136 #if !defined(getpid)
137 # define getpid _getpid
138 #endif
139 #if !defined(hypot)
140 # define hypot _hypot
141 #endif
142 #if !defined(inline)
143 # define inline __inline
144 #endif
145 #if !defined(isatty)
146 # define isatty _isatty
147 #endif
148 #if !defined(locale_t)
149 #define locale_t _locale_t
150 #endif
151 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
152  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
153  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
154 #if !defined(lseek)
155 # define lseek _lseeki64
156 #endif
157 #else
158 #if !defined(lseek)
159 # define lseek _lseek
160 #endif
161 #endif
162 #if !defined(MAGICKCORE_LTDL_DELEGATE)
163 #if !defined(lt_dlclose)
164 # define lt_dlclose(handle) NTCloseLibrary(handle)
165 #endif
166 #if !defined(lt_dlerror)
167 # define lt_dlerror() NTGetLibraryError()
168 #endif
169 #if !defined(lt_dlexit)
170 # define lt_dlexit() NTExitLibrary()
171 #endif
172 #if !defined(lt_dlinit)
173 # define lt_dlinit() NTInitializeLibrary()
174 #endif
175 #if !defined(lt_dlopen)
176 # define lt_dlopen(filename) NTOpenLibrary(filename)
177 #endif
178 #if !defined(lt_dlsetsearchpath)
179 # define lt_dlsetsearchpath(path) NTSetSearchPath(path)
180 #endif
181 #if !defined(lt_dlsym)
182 # define lt_dlsym(handle,name) NTGetLibrarySymbol(handle,name)
183 #endif
184 #endif
185 #if !defined(mkdir)
186 # define mkdir _mkdir
187 #endif
188 #if !defined(mmap)
189 # define mmap(address,length,protection,access,file,offset) \
190  NTMapMemory(address,length,protection,access,file,offset)
191 #endif
192 #if !defined(munmap)
193 # define munmap(address,length) NTUnmapMemory(address,length)
194 #endif
195 #if !defined(opendir)
196 # define opendir(directory) NTOpenDirectory(directory)
197 #endif
198 #if !defined(open)
199 # define open _open
200 #endif
201 #if !defined(pclose)
202 # define pclose _pclose
203 #endif
204 #if !defined(popen)
205 # define popen _popen
206 #endif
207 #if !defined(fprintf_l)
208 #define fprintf_l _fprintf_s_l
209 #endif
210 #if !defined(read)
211 # define read(fd,buffer,count) _read(fd,buffer,(unsigned int) count)
212 #endif
213 #if !defined(readdir)
214 # define readdir(directory) NTReadDirectory(directory)
215 #endif
216 #if !defined(setmode)
217 # define setmode _setmode
218 #endif
219 #if !defined(spawnvp)
220 # define spawnvp _spawnvp
221 #endif
222 #if !defined(strtod_l)
223 #define strtod_l _strtod_l
224 #endif
225 #if !defined(stat) && !defined(__BORLANDC__)
226 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
227  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
228  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
229 # define stat _stati64
230 #else
231 # define stat _stat
232 #endif
233 #endif
234 #if !defined(strcasecmp)
235 # define strcasecmp _stricmp
236 #endif
237 #if !defined(strncasecmp)
238 # define strncasecmp _strnicmp
239 #endif
240 #if !defined(sysconf)
241 # define sysconf(name) NTSystemConfiguration(name)
242 #endif
243 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
244  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
245  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
246 # define tell _telli64
247 #else
248 # define tell _tell
249 #endif
250 #if !defined(tempnam)
251 # define tempnam _tempnam_s
252 #endif
253 #if !defined(tolower_l)
254 #define tolower_l _tolower_l
255 #endif
256 #if !defined(toupper_l)
257 #define toupper_l _toupper_l
258 #endif
259 #if !defined(umask)
260 # define umask _umask
261 #endif
262 #if !defined(unlink)
263 # define unlink _unlink
264 #endif
265 #if !defined(utime)
266 # define utime _utime
267 #endif
268 #if !defined(vfprintf_l)
269 #define vfprintf_l _vfprintf_l
270 #endif
271 #if !defined(vsnprintf)
272 #if !defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1500)
273 #define vsnprintf _vsnprintf
274 #endif
275 #endif
276 #if !defined(vsnprintf_l)
277 #define vsnprintf_l _vsnprintf_l
278 #endif
279 #if !defined(write)
280 # define write(fd,buffer,count) _write(fd,buffer,(unsigned int) count)
281 #endif
282 #if !defined(wstat) && !defined(__BORLANDC__)
283 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
284  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
285  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
286 # define wstat _wstati64
287 #else
288 # define wstat _wstat
289 #endif
290 #endif
291 
292 #if defined(__BORLANDC__)
293 #undef _O_RANDOM
294 #define _O_RANDOM 0
295 #undef _O_SEQUENTIAL
296 #define _O_SEQUENTIAL 0
297 #undef _O_SHORT_LIVED
298 #define _O_SHORT_LIVED 0
299 #undef _O_TEMPORARY
300 #define _O_TEMPORARY 0
301 #endif
302 
303 #undef gettimeofday
304 
305 typedef struct _GhostInfo
306  GhostInfo_;
307 
308 extern MagickExport char
309  **NTArgvToUTF8(const int argc,wchar_t **);
310 
311 extern MagickExport const GhostInfo_
312  *NTGhostscriptDLLVectors(void);
313 
314 extern MagickExport int
315  NTGhostscriptUnLoadDLL(void);
316 
317 extern MagickExport void
318  NTErrorHandler(const ExceptionType,const char *,const char *),
319  NTWarningHandler(const ExceptionType,const char *,const char *);
320 
321 #endif
322 
323 #if defined(__cplusplus) || defined(c_plusplus)
324 }
325 #endif
326 
327 #endif
ExceptionType
Definition: exception.h:28
Definition: delegate-private.h:52
#define MagickExport
Definition: method-attribute.h:80