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