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