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