2 Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization
3 dedicated to making software imaging solutions freely available.
5 You may not use this file except in compliance with the License.
6 obtain a copy of the License at
8 http://www.imagemagick.org/script/license.php
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.
16 MagickCore Windows NT utility methods.
18 #ifndef _MAGICKCORE_NT_BASE_H
19 #define _MAGICKCORE_NT_BASE_H
21 #include "MagickCore/exception.h"
22 #include "MagickCore/geometry.h"
24 #if defined(__cplusplus) || defined(c_plusplus)
28 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
30 #define WIN32_LEAN_AND_MEAN
32 #define _CRT_SECURE_NO_DEPRECATE 1
40 #if defined(_DEBUG) && !defined(__MINGW32__) && !defined(__MINGW64__)
44 #define PROT_READ 0x01
45 #define PROT_WRITE 0x02
46 #define MAP_SHARED 0x01
47 #define MAP_PRIVATE 0x02
48 #define MAP_ANONYMOUS 0x20
53 #define _SC_PAGESIZE 1
54 #define _SC_PHYS_PAGES 2
55 #define _SC_OPEN_MAX 3
56 #if !defined(SSIZE_MAX)
57 #define SSIZE_MAX 0x7fffffffL
64 1300 MSVC 7.0 Visual C++ .NET 2002
65 1310 Visual c++ .NET 2003
71 # if defined(__BORLANDC__)
72 # define chsize(file,length) chsize(file,length)
74 # define chsize(file,length) _chsize(file,length)
79 #if defined(_VISUALC_) && (_MSC_VER >= 1400)
80 # define access(path,mode) _access_s(path,mode)
89 #if !defined(closedir)
90 # define closedir(directory) NTCloseDirectory(directory)
93 # define fdopen _fdopen
96 # define fileno _fileno
98 #if !defined(fseek) && !defined(__MINGW32__) && !defined(__MINGW64__)
99 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
100 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
101 # define fseek _fseeki64
104 #if !defined(fstat) && !defined(__BORLANDC__)
105 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
106 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
107 # define fstat _fstati64
109 # define fstat _fstat
113 # define fsync _commit
115 #if !defined(ftell) && !defined(__MINGW32__) && !defined(__MINGW64__)
116 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
117 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
118 # define ftell _ftelli64
121 #if !defined(ftruncate)
122 # define ftruncate(file,length) NTTruncateFile(file,length)
125 # define getcwd _getcwd
128 # define getpid _getpid
131 # define hypot _hypot
134 # define inline __inline
137 # define isatty _isatty
139 #if !defined(locale_t)
140 #define locale_t _locale_t
142 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
143 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
144 # define lseek _lseeki64
146 # define lseek _lseek
148 #if !defined(MAGICKCORE_LTDL_DELEGATE)
149 #if !defined(lt_dlclose)
150 # define lt_dlclose(handle) NTCloseLibrary(handle)
152 #if !defined(lt_dlerror)
153 # define lt_dlerror() NTGetLibraryError()
155 #if !defined(lt_dlexit)
156 # define lt_dlexit() NTExitLibrary()
158 #if !defined(lt_dlinit)
159 # define lt_dlinit() NTInitializeLibrary()
161 #if !defined(lt_dlopen)
162 # define lt_dlopen(filename) NTOpenLibrary(filename)
164 #if !defined(lt_dlsetsearchpath)
165 # define lt_dlsetsearchpath(path) NTSetSearchPath(path)
167 #if !defined(lt_dlsym)
168 # define lt_dlsym(handle,name) NTGetLibrarySymbol(handle,name)
172 # define mkdir _mkdir
175 # define mmap(address,length,protection,access,file,offset) \
176 NTMapMemory(address,length,protection,access,file,offset)
179 # define msync(address,length,flags) NTSyncMemory(address,length,flags)
182 # define munmap(address,length) NTUnmapMemory(address,length)
184 #if !defined(opendir)
185 # define opendir(directory) NTOpenDirectory(directory)
191 # define pclose _pclose
194 # define popen _popen
196 #if !defined(fprintf_l)
197 #define fprintf_l _fprintf_s_l
202 #if !defined(readdir)
203 # define readdir(directory) NTReadDirectory(directory)
205 #if !defined(seekdir)
206 # define seekdir(directory,offset) NTSeekDirectory(directory,offset)
208 #if !defined(setmode)
209 # define setmode _setmode
211 #if !defined(spawnvp)
212 # define spawnvp _spawnvp
214 #if !defined(strtod_l)
215 #define strtod_l _strtod_l
217 #if !defined(stat) && !defined(__BORLANDC__)
218 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
219 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
220 # define stat _stati64
225 #if !defined(strcasecmp)
226 # define strcasecmp _stricmp
228 #if !defined(strncasecmp)
229 # define strncasecmp _strnicmp
231 #if !defined(sysconf)
232 # define sysconf(name) NTSystemConfiguration(name)
234 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
235 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
236 # define tell _telli64
240 #if !defined(telldir)
241 # define telldir(directory) NTTellDirectory(directory)
243 #if !defined(tempnam)
244 # define tempnam _tempnam_s
246 #if !defined(vfprintf_l)
247 #define vfprintf_l _vfprintf_l
249 #if !defined(vsnprintf)
250 #if !defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1500)
251 #define vsnprintf _vsnprintf
254 #if !defined(vsnprintf_l)
255 #define vsnprintf_l _vsnprintf_l
258 # define write _write
260 #if !defined(wstat) && !defined(__BORLANDC__)
261 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
262 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
263 # define wstat _wstati64
265 # define wstat _wstat
269 #if defined(_MT) && defined(MAGICKCORE_WINDOWS_SUPPORT)
270 # define SAFE_GLOBAL __declspec(thread)
275 #if defined(__BORLANDC__)
279 #define _O_SEQUENTIAL 0
280 #undef _O_SHORT_LIVED
281 #define _O_SHORT_LIVED 0
283 #define _O_TEMPORARY 0
288 typedef struct _GhostInfo
291 extern MagickExport char
292 **NTArgvToUTF8(const int argc,wchar_t **);
294 extern MagickExport const GhostInfo_
295 *NTGhostscriptDLLVectors(void);
297 extern MagickExport int
298 NTGhostscriptUnLoadDLL(void);
300 extern MagickExport void
301 NTErrorHandler(const ExceptionType,const char *,const char *),
302 NTWarningHandler(const ExceptionType,const char *,const char *);
305 #if defined(__cplusplus) || defined(c_plusplus)