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
41 #if defined(_DEBUG) && !defined(__MINGW32__) && !defined(__MINGW64__)
45 #define PROT_READ 0x01
46 #define PROT_WRITE 0x02
47 #define MAP_SHARED 0x01
48 #define MAP_PRIVATE 0x02
49 #define MAP_ANONYMOUS 0x20
54 #define _SC_PAGESIZE 1
55 #define _SC_PHYS_PAGES 2
56 #define _SC_OPEN_MAX 3
57 #if !defined(SSIZE_MAX)
58 #define SSIZE_MAX 0x7fffffffL
65 1300 MSVC 7.0 Visual C++ .NET 2002
66 1310 Visual c++ .NET 2003
72 # if defined(__BORLANDC__)
73 # define chsize(file,length) chsize(file,length)
75 # define chsize(file,length) _chsize(file,length)
80 #if defined(_VISUALC_) && (_MSC_VER >= 1400)
81 # define access(path,mode) _access_s(path,mode)
90 #if !defined(closedir)
91 # define closedir(directory) NTCloseDirectory(directory)
94 # define fdopen _fdopen
97 # define fileno _fileno
99 #if !defined(fseek) && !defined(__MINGW32__) && !defined(__MINGW64__)
100 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
101 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
102 # define fseek _fseeki64
105 #if !defined(fstat) && !defined(__BORLANDC__)
106 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
107 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
108 # define fstat _fstati64
110 # define fstat _fstat
114 # define fsync _commit
116 #if !defined(ftell) && !defined(__MINGW32__) && !defined(__MINGW64__)
117 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
118 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
119 # define ftell _ftelli64
122 #if !defined(ftruncate)
123 # define ftruncate(file,length) NTTruncateFile(file,length)
126 # define getcwd _getcwd
129 # define getpid _getpid
132 # define hypot _hypot
135 # define inline __inline
138 # define isatty _isatty
140 #if !defined(locale_t)
141 #define locale_t _locale_t
143 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
144 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
146 # define lseek _lseeki64
150 # define lseek _lseek
153 #if !defined(MAGICKCORE_LTDL_DELEGATE)
154 #if !defined(lt_dlclose)
155 # define lt_dlclose(handle) NTCloseLibrary(handle)
157 #if !defined(lt_dlerror)
158 # define lt_dlerror() NTGetLibraryError()
160 #if !defined(lt_dlexit)
161 # define lt_dlexit() NTExitLibrary()
163 #if !defined(lt_dlinit)
164 # define lt_dlinit() NTInitializeLibrary()
166 #if !defined(lt_dlopen)
167 # define lt_dlopen(filename) NTOpenLibrary(filename)
169 #if !defined(lt_dlsetsearchpath)
170 # define lt_dlsetsearchpath(path) NTSetSearchPath(path)
172 #if !defined(lt_dlsym)
173 # define lt_dlsym(handle,name) NTGetLibrarySymbol(handle,name)
177 # define mkdir _mkdir
180 # define mmap(address,length,protection,access,file,offset) \
181 NTMapMemory(address,length,protection,access,file,offset)
184 # define msync(address,length,flags) NTSyncMemory(address,length,flags)
187 # define munmap(address,length) NTUnmapMemory(address,length)
189 #if !defined(opendir)
190 # define opendir(directory) NTOpenDirectory(directory)
196 # define pclose _pclose
199 # define popen _popen
201 #if !defined(fprintf_l)
202 #define fprintf_l _fprintf_s_l
205 # define read(fd,buffer,count) _read(fd,buffer,(unsigned int) count)
207 #if !defined(readdir)
208 # define readdir(directory) NTReadDirectory(directory)
210 #if !defined(seekdir)
211 # define seekdir(directory,offset) NTSeekDirectory(directory,offset)
213 #if !defined(setmode)
214 # define setmode _setmode
216 #if !defined(spawnvp)
217 # define spawnvp _spawnvp
219 #if !defined(strtod_l)
220 #define strtod_l _strtod_l
222 #if !defined(stat) && !defined(__BORLANDC__)
223 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
224 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
225 # define stat _stati64
230 #if !defined(strcasecmp)
231 # define strcasecmp _stricmp
233 #if !defined(strncasecmp)
234 # define strncasecmp _strnicmp
236 #if !defined(sysconf)
237 # define sysconf(name) NTSystemConfiguration(name)
239 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
240 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
241 # define tell _telli64
245 #if !defined(telldir)
246 # define telldir(directory) NTTellDirectory(directory)
248 #if !defined(tempnam)
249 # define tempnam _tempnam_s
251 #if !defined(vfprintf_l)
252 #define vfprintf_l _vfprintf_l
254 #if !defined(vsnprintf)
255 #if !defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1500)
256 #define vsnprintf _vsnprintf
259 #if !defined(vsnprintf_l)
260 #define vsnprintf_l _vsnprintf_l
263 # define write(fd,buffer,count) _write(fd,buffer,(unsigned int) count)
265 #if !defined(wstat) && !defined(__BORLANDC__)
266 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
267 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
268 # define wstat _wstati64
270 # define wstat _wstat
274 #if defined(__BORLANDC__)
278 #define _O_SEQUENTIAL 0
279 #undef _O_SHORT_LIVED
280 #define _O_SHORT_LIVED 0
282 #define _O_TEMPORARY 0
287 typedef struct _GhostInfo
290 extern MagickExport char
291 **NTArgvToUTF8(const int argc,wchar_t **);
293 extern MagickExport const GhostInfo_
294 *NTGhostscriptDLLVectors(void);
296 extern MagickExport int
297 NTGhostscriptUnLoadDLL(void);
299 extern MagickExport void
300 NTErrorHandler(const ExceptionType,const char *,const char *),
301 NTWarningHandler(const ExceptionType,const char *,const char *);
304 #if defined(__cplusplus) || defined(c_plusplus)