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