2 Copyright 1999-2015 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
76 # if defined(__BORLANDC__)
77 # define chsize(file,length) chsize(file,length)
79 # define chsize(file,length) _chsize(file,length)
84 #if defined(_VISUALC_) && (_MSC_VER >= 1400)
85 # define access(path,mode) _access_s(path,mode)
94 #if !defined(closedir)
95 # define closedir(directory) NTCloseDirectory(directory)
98 # define fdopen _fdopen
101 # define fileno _fileno
103 #if !defined(fseek) && !defined(__MINGW32__) && !defined(__MINGW64__)
104 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
105 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
106 # define fseek _fseeki64
109 #if !defined(fstat) && !defined(__BORLANDC__)
110 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
111 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
112 # define fstat _fstati64
114 # define fstat _fstat
118 # define fsync _commit
120 #if !defined(ftell) && !defined(__MINGW32__) && !defined(__MINGW64__)
121 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
122 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
123 # define ftell _ftelli64
126 #if !defined(ftruncate)
127 # define ftruncate(file,length) NTTruncateFile(file,length)
130 # define getcwd _getcwd
133 # define getpid _getpid
136 # define hypot _hypot
139 # define inline __inline
142 # define isatty _isatty
144 #if !defined(locale_t)
145 #define locale_t _locale_t
147 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
148 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
150 # define lseek _lseeki64
154 # define lseek _lseek
157 #if !defined(MAGICKCORE_LTDL_DELEGATE)
158 #if !defined(lt_dlclose)
159 # define lt_dlclose(handle) NTCloseLibrary(handle)
161 #if !defined(lt_dlerror)
162 # define lt_dlerror() NTGetLibraryError()
164 #if !defined(lt_dlexit)
165 # define lt_dlexit() NTExitLibrary()
167 #if !defined(lt_dlinit)
168 # define lt_dlinit() NTInitializeLibrary()
170 #if !defined(lt_dlopen)
171 # define lt_dlopen(filename) NTOpenLibrary(filename)
173 #if !defined(lt_dlsetsearchpath)
174 # define lt_dlsetsearchpath(path) NTSetSearchPath(path)
176 #if !defined(lt_dlsym)
177 # define lt_dlsym(handle,name) NTGetLibrarySymbol(handle,name)
181 # define mkdir _mkdir
184 # define mmap(address,length,protection,access,file,offset) \
185 NTMapMemory(address,length,protection,access,file,offset)
188 # define msync(address,length,flags) NTSyncMemory(address,length,flags)
191 # define munmap(address,length) NTUnmapMemory(address,length)
193 #if !defined(opendir)
194 # define opendir(directory) NTOpenDirectory(directory)
200 # define pclose _pclose
203 # define popen _popen
205 #if !defined(fprintf_l)
206 #define fprintf_l _fprintf_s_l
209 # define read(fd,buffer,count) _read(fd,buffer,(unsigned int) count)
211 #if !defined(readdir)
212 # define readdir(directory) NTReadDirectory(directory)
214 #if !defined(seekdir)
215 # define seekdir(directory,offset) NTSeekDirectory(directory,offset)
217 #if !defined(setmode)
218 # define setmode _setmode
220 #if !defined(spawnvp)
221 # define spawnvp _spawnvp
223 #if !defined(strtod_l)
224 #define strtod_l _strtod_l
226 #if !defined(stat) && !defined(__BORLANDC__)
227 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
228 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
229 # define stat _stati64
234 #if !defined(strcasecmp)
235 # define strcasecmp _stricmp
237 #if !defined(strncasecmp)
238 # define strncasecmp _strnicmp
240 #if !defined(sysconf)
241 # define sysconf(name) NTSystemConfiguration(name)
243 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
244 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
245 # define tell _telli64
249 #if !defined(telldir)
250 # define telldir(directory) NTTellDirectory(directory)
252 #if !defined(tempnam)
253 # define tempnam _tempnam_s
256 # define umask _umask
259 # define unlink _unlink
261 #if !defined(vfprintf_l)
262 #define vfprintf_l _vfprintf_l
264 #if !defined(vsnprintf)
265 #if !defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1500)
266 #define vsnprintf _vsnprintf
269 #if !defined(vsnprintf_l)
270 #define vsnprintf_l _vsnprintf_l
273 # define write(fd,buffer,count) _write(fd,buffer,(unsigned int) count)
275 #if !defined(wstat) && !defined(__BORLANDC__)
276 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
277 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
278 # define wstat _wstati64
280 # define wstat _wstat
284 #if defined(__BORLANDC__)
288 #define _O_SEQUENTIAL 0
289 #undef _O_SHORT_LIVED
290 #define _O_SHORT_LIVED 0
292 #define _O_TEMPORARY 0
297 typedef struct _GhostInfo
300 extern MagickExport char
301 **NTArgvToUTF8(const int argc,wchar_t **);
303 extern MagickExport const GhostInfo_
304 *NTGhostscriptDLLVectors(void);
306 extern MagickExport int
307 NTGhostscriptUnLoadDLL(void);
309 extern MagickExport void
310 NTErrorHandler(const ExceptionType,const char *,const char *),
311 NTWarningHandler(const ExceptionType,const char *,const char *);
314 #if defined(__cplusplus) || defined(c_plusplus)