MagickCore  7.1.0
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 "MagickCore/exception.h"
22 #include "MagickCore/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 #ifdef _WIN64
61 # if !defined(SSIZE_MAX)
62 # define SSIZE_MAX LLONG_MAX
63 # endif
64 # if defined(_MSC_VER)
65 # define MAGICKCORE_SIZEOF_SSIZE_T 8
66 # endif
67 #else
68 # if !defined(SSIZE_MAX)
69 # define SSIZE_MAX LONG_MAX
70 # endif
71 # if defined(_MSC_VER)
72 # define MAGICKCORE_SIZEOF_SSIZE_T 4
73 # endif
74 #endif
75 
76 #if defined(_MSC_VER)
77 # if !defined(MAGICKCORE_MSC_VER)
78 # if (_MSC_VER >= 1930)
79 # define MAGICKCORE_MSC_VER 2022
80 # elif (_MSC_VER >= 1920)
81 # define MAGICKCORE_MSC_VER 2019
82 # elif (_MSC_VER >= 1910)
83 # define MAGICKCORE_MSC_VER 2017
84 # elif (_MSC_VER >= 1900)
85 # define MAGICKCORE_MSC_VER 2015
86 # elif (_MSC_VER >= 1800)
87 # define MAGICKCORE_MSC_VER 2013
88 # elif (_MSC_VER >= 1700)
89 # define MAGICKCORE_MSC_VER 2012
90 # endif
91 # endif
92 #endif
93 
94 #if !defined(chsize)
95 # if defined(__BORLANDC__)
96 # define chsize(file,length) chsize(file,length)
97 # else
98 # define chsize(file,length) _chsize(file,length)
99 # endif
100 #endif
101 
102 #if !defined(access)
103 #if defined(_MSC_VER)
104 # define access(path,mode) _access_s(path,mode)
105 #endif
106 #endif
107 #if !defined(chdir)
108 # define chdir _chdir
109 #endif
110 #if !defined(close)
111 # define close _close
112 #endif
113 #if !defined(closedir)
114 # define closedir(directory) NTCloseDirectory(directory)
115 #endif
116 #if !defined(MAGICKCORE_HAVE_ERF)
117 # define MAGICKCORE_HAVE_ERF
118 #endif
119 #if !defined(fdopen)
120 # define fdopen _fdopen
121 #endif
122 #if !defined(fileno)
123 # define fileno _fileno
124 #endif
125 #if !defined(freelocale)
126 # define freelocale _free_locale
127 #endif
128 #if !defined(fsync)
129 # define fsync _commit
130 #endif
131 #if !defined(ftruncate)
132 # define ftruncate(file,length) NTTruncateFile(file,length)
133 #endif
134 #if !defined(getcwd)
135 # define getcwd _getcwd
136 #endif
137 #if !defined(getpid)
138 # define getpid _getpid
139 #endif
140 #if !defined(hypot)
141 # define hypot _hypot
142 #endif
143 #if !defined(isatty)
144 # define isatty _isatty
145 #endif
146 #if !defined(locale_t)
147 #define locale_t _locale_t
148 #endif
149 #if !defined(MAGICKCORE_LTDL_DELEGATE)
150 #if !defined(lt_dlclose)
151 # define lt_dlclose(handle) NTCloseLibrary(handle)
152 #endif
153 #if !defined(lt_dlerror)
154 # define lt_dlerror() NTGetLibraryError()
155 #endif
156 #if !defined(lt_dlexit)
157 # define lt_dlexit() NTExitLibrary()
158 #endif
159 #if !defined(lt_dlinit)
160 # define lt_dlinit() NTInitializeLibrary()
161 #endif
162 #if !defined(lt_dlopen)
163 # define lt_dlopen(filename) NTOpenLibrary(filename)
164 #endif
165 #if !defined(lt_dlsetsearchpath)
166 # define lt_dlsetsearchpath(path) NTSetSearchPath(path)
167 #endif
168 #if !defined(lt_dlsym)
169 # define lt_dlsym(handle,name) NTGetLibrarySymbol(handle,name)
170 #endif
171 #endif
172 #if !defined(mkdir)
173 # define mkdir _mkdir
174 #endif
175 #if !defined(mmap)
176 # define MAGICKCORE_HAVE_MMAP 1
177 # define mmap(address,length,protection,access,file,offset) \
178  NTMapMemory(address,length,protection,access,file,offset)
179 #endif
180 #if !defined(munmap)
181 # define munmap(address,length) NTUnmapMemory(address,length)
182 #endif
183 #if !defined(opendir)
184 # define opendir(directory) NTOpenDirectory(directory)
185 #endif
186 #if !defined(open)
187 # define open _open
188 #endif
189 #if !defined(pclose)
190 # define pclose _pclose
191 #endif
192 #if !defined(popen)
193 # define popen _popen
194 #endif
195 #if !defined(putenv)
196 # define putenv _putenv
197 #endif
198 #if !defined(fprintf_l)
199 #define fprintf_l _fprintf_s_l
200 #endif
201 #if !defined(read)
202 # define read(fd,buffer,count) _read(fd,buffer,(unsigned int) count)
203 #endif
204 #if !defined(readdir)
205 # define readdir(directory) NTReadDirectory(directory)
206 #endif
207 #if !defined(setmode)
208 # define setmode _setmode
209 #endif
210 #if !defined(spawnvp)
211 # define spawnvp _spawnvp
212 #endif
213 #if !defined(strtod_l)
214 #define strtod_l _strtod_l
215 #endif
216 #if !defined(strcasecmp)
217 # define strcasecmp _stricmp
218 #endif
219 #if !defined(strncasecmp)
220 # define strncasecmp _strnicmp
221 #endif
222 #if !defined(sysconf)
223 # define sysconf(name) NTSystemConfiguration(name)
224 # define MAGICKCORE_HAVE_SYSCONF 1
225 #endif
226 #if !defined(tempnam)
227 # define tempnam _tempnam_s
228 #endif
229 #if !defined(tolower_l)
230 #define tolower_l _tolower_l
231 #endif
232 #if !defined(toupper_l)
233 #define toupper_l _toupper_l
234 #endif
235 #if !defined(umask)
236 # define umask _umask
237 #endif
238 #if !defined(unlink)
239 # define unlink _unlink
240 #endif
241 #define MAGICKCORE_HAVE_UTIME 1
242 #if !defined(utime)
243 # define utime(filename,time) _utime(filename,(struct _utimbuf*) time)
244 #endif
245 #if !defined(vfprintf_l)
246 #define vfprintf_l _vfprintf_l
247 #endif
248 #if !defined(vsnprintf) && !defined(_MSC_VER)
249 #define vsnprintf _vsnprintf
250 #endif
251 #if !defined(vsnprintf_l)
252 #define vsnprintf_l _vsnprintf_l
253 #endif
254 #if !defined(write)
255 # define write(fd,buffer,count) _write(fd,buffer,(unsigned int) count)
256 #endif
257 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
258  !(defined(__BORLANDC__)) && \
259  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
260 # if !defined(fseek)
261 # define fseek _fseeki64
262 # endif
263 # if !defined(ftell)
264 # define ftell _ftelli64
265 # endif
266 # if !defined(lseek)
267 # define lseek _lseeki64
268 # endif
269 # if !defined(fstat)
270 # define fstat _fstati64
271 # endif
272 # if !defined(stat)
273 # define stat _stati64
274 # endif
275 # if !defined(tell)
276 # define tell _telli64
277 # endif
278 # if !defined(wstat)
279 # define wstat _wstati64
280 # endif
281 #else
282 # if !defined(__MINGW32__)
283 # if !defined(fseek)
284 # define fseek _fseek
285 # endif
286 # if !defined(ftell)
287 # define ftell _ftell
288 # endif
289 # endif
290 # if !defined(lseek)
291 # define lseek _lseek
292 # endif
293 # if !defined(fstat)
294 # define fstat _fstat
295 # endif
296 # if !defined(stat)
297 # define stat _stat
298 # endif
299 # if !defined(tell)
300 # define tell _tell
301 # endif
302 # if !defined(wstat)
303 # define wstat _wstat
304 # endif
305 #endif
306 
307 #if defined(__BORLANDC__)
308 #undef _O_RANDOM
309 #define _O_RANDOM 0
310 #undef _O_SEQUENTIAL
311 #define _O_SEQUENTIAL 0
312 #undef _O_SHORT_LIVED
313 #define _O_SHORT_LIVED 0
314 #undef _O_TEMPORARY
315 #define _O_TEMPORARY 0
316 #endif
317 
318 #undef gettimeofday
319 
320 typedef struct _GhostInfo
321  GhostInfo_;
322 
323 extern MagickExport char
324  **NTArgvToUTF8(const int argc,wchar_t **);
325 
326 extern MagickExport const GhostInfo_
327  *NTGhostscriptDLLVectors(void);
328 
329 extern MagickExport void
330  NTErrorHandler(const ExceptionType,const char *,const char *),
331  NTGhostscriptUnLoadDLL(void),
332  NTWarningHandler(const ExceptionType,const char *,const char *);
333 
334 #endif
335 
336 #if defined(__cplusplus) || defined(c_plusplus)
337 }
338 #endif
339 
340 #endif
ExceptionType
Definition: exception.h:27
#define MagickExport