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