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