2 Copyright 1999-2011 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 #if defined(__cplusplus) || defined(c_plusplus)
25 #include "MagickCore/delegate.h"
26 #include "MagickCore/delegate-private.h"
27 #include "MagickCore/exception.h"
29 #define WIN32_LEAN_AND_MEAN
31 #define _CRT_SECURE_NO_DEPRECATE 1
39 #if defined(_DEBUG) && !defined(__MINGW32__)
43 #define PROT_READ 0x01
44 #define PROT_WRITE 0x02
45 #define MAP_SHARED 0x01
46 #define MAP_PRIVATE 0x02
47 #define MAP_ANONYMOUS 0x20
52 #define _SC_PAGESIZE 1
53 #define _SC_PHYS_PAGES 2
54 #define _SC_OPEN_MAX 3
55 #if !defined(SSIZE_MAX)
56 #define SSIZE_MAX 0x7fffffffL
63 1300 MSVC 7.0 Visual C++ .NET 2002
64 1310 Visual c++ .NET 2003
70 # if defined(__BORLANDC__)
71 # define chsize(file,length) chsize(file,length)
73 # define chsize(file,length) _chsize(file,length)
78 # define access(path,mode) _access_s(path,mode)
86 #if !defined(closedir)
87 # define closedir(directory) NTCloseDirectory(directory)
90 # define fdopen _fdopen
93 # define fileno _fileno
95 #if !defined(fseek) && !defined(__MINGW32__)
96 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
97 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
98 # define fseek _fseeki64
100 # define fseek _fseek
103 #if !defined(fstat) && !defined(__BORLANDC__)
104 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
105 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
106 # define fstat _fstati64
108 # define fstat _fstat
112 # define fsync _commit
114 #if !defined(ftell) && !defined(__MINGW32__)
115 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
116 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
117 # define ftell _ftelli64
119 # define ftell _ftell
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)
145 # define lseek _lseeki64
147 # define lseek _lseek
149 #if !defined(MAGICKCORE_LTDL_DELEGATE)
150 #if !defined(lt_dlclose)
151 # define lt_dlclose(handle) NTCloseLibrary(handle)
153 #if !defined(lt_dlerror)
154 # define lt_dlerror() NTGetLibraryError()
156 #if !defined(lt_dlexit)
157 # define lt_dlexit() NTExitLibrary()
159 #if !defined(lt_dlinit)
160 # define lt_dlinit() NTInitializeLibrary()
162 #if !defined(lt_dlopen)
163 # define lt_dlopen(filename) NTOpenLibrary(filename)
165 #if !defined(lt_dlsetsearchpath)
166 # define lt_dlsetsearchpath(path) NTSetSearchPath(path)
168 #if !defined(lt_dlsym)
169 # define lt_dlsym(handle,name) NTGetLibrarySymbol(handle,name)
173 # define mkdir _mkdir
176 # define mmap(address,length,protection,access,file,offset) \
177 NTMapMemory(address,length,protection,access,file,offset)
180 # define msync(address,length,flags) NTSyncMemory(address,length,flags)
183 # define munmap(address,length) NTUnmapMemory(address,length)
185 #if !defined(opendir)
186 # define opendir(directory) NTOpenDirectory(directory)
192 # define pclose _pclose
195 # define popen _popen
197 #if !defined(fprintf_l)
198 #define fprintf_l _fprintf_s_l
203 #if !defined(readdir)
204 # define readdir(directory) NTReadDirectory(directory)
206 #if !defined(seekdir)
207 # define seekdir(directory,offset) NTSeekDirectory(directory,offset)
209 #if !defined(setmode)
210 # define setmode _setmode
212 #if !defined(spawnvp)
213 # define spawnvp _spawnvp
215 #if !defined(strtod_l)
216 #define strtod_l _strtod_l
218 #if !defined(stat) && !defined(__BORLANDC__)
219 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
220 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
221 # define stat _stati64
226 #if !defined(strcasecmp)
227 # define strcasecmp _strcmpi
229 #if !defined(strncasecmp)
230 # define strncasecmp _strnicmp
232 #if !defined(sysconf)
233 # define sysconf(name) NTSystemConfiguration(name)
235 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
236 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
237 # define tell _telli64
241 #if !defined(telldir)
242 # define telldir(directory) NTTellDirectory(directory)
244 #if !defined(tempnam)
245 # define tempnam _tempnam_s
247 #if !defined(vfprintf_l)
248 #define vfprintf_l _vfprintf_l
250 #if !defined(vsnprintf)
251 #if !defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1500)
252 #define vsnprintf _vsnprintf
255 #if !defined(vsnprintf_l)
256 #define vsnprintf_l _vsnprintf_l
259 # define write _write
261 #if !defined(wstat) && !defined(__BORLANDC__)
262 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
263 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
264 # define wstat _wstati64
266 # define wstat _wstat
270 #if defined(_MT) && defined(MAGICKCORE_WINDOWS_SUPPORT)
271 # define SAFE_GLOBAL __declspec(thread)
276 #if defined(__BORLANDC__)
280 #define _O_SEQUENTIAL 0
281 #undef _O_SHORT_LIVED
282 #define _O_SHORT_LIVED 0
284 #define _O_TEMPORARY 0
287 #if !defined(XS_VERSION)
312 typedef struct _NTMEMORYSTATUSEX
325 ullAvailExtendedVirtual;
328 #if !defined(__MINGW32__)
338 (CALLBACK *LPFNDLLFUNC1)(DWORD,UINT);
341 (CALLBACK *LPFNDLLFUNC2)(NTMEMORYSTATUSEX *);
345 #if defined(MAGICKCORE_BZLIB_DELEGATE)
351 extern MagickExport char
352 *NTGetLastError(void);
354 extern MagickExport const GhostInfo
355 *NTGhostscriptDLLVectors(void);
357 #if !defined(MAGICKCORE_LTDL_DELEGATE)
358 extern MagickExport const char
359 *NTGetLibraryError(void);
362 #if !defined(XS_VERSION)
363 extern MagickExport const char
364 *NTGetLibraryError(void);
366 extern MagickExport DIR
367 *NTOpenDirectory(const char *);
369 extern MagickExport double
373 extern MagickExport int
375 #if !defined(__MINGW32__)
376 gettimeofday(struct timeval *,struct timezone *),
379 NTCloseDirectory(DIR *),
380 NTCloseLibrary(void *),
381 NTControlHandler(void),
383 NTTruncateFile(int,off_t),
384 NTGhostscriptDLL(char *,int),
385 NTGhostscriptEXE(char *,int),
386 NTGhostscriptFonts(char *,int),
387 NTGhostscriptLoadDLL(void),
388 NTGhostscriptUnLoadDLL(void),
389 NTInitializeLibrary(void),
390 NTSetSearchPath(const char *),
391 NTSyncMemory(void *,size_t,int),
392 NTUnmapMemory(void *,size_t),
393 NTSystemCommand(const char *);
395 extern MagickExport ssize_t
396 NTSystemConfiguration(int),
397 NTTellDirectory(DIR *);
399 extern MagickExport MagickBooleanType
400 NTGatherRandomData(const size_t,unsigned char *),
401 NTGetExecutionPath(char *,const size_t),
402 NTGetModulePath(const char *,char *),
403 NTReportEvent(const char *,const MagickBooleanType),
404 NTReportException(const char *,const MagickBooleanType);
406 extern MagickExport struct dirent
407 *NTReadDirectory(DIR *);
409 extern MagickExport unsigned char
410 *NTRegistryKeyLookup(const char *),
411 *NTResourceToBlob(const char *);
413 extern MagickExport void
414 NTErrorHandler(const ExceptionType,const char *,const char *),
415 *NTGetLibrarySymbol(void *,const char *),
416 *NTMapMemory(char *,size_t,int,int,int,MagickOffsetType),
417 *NTOpenLibrary(const char *),
418 NTSeekDirectory(DIR *,ssize_t),
419 NTWarningHandler(const ExceptionType,const char *,const char *);
421 #endif /* !XS_VERSION */
423 #if defined(__cplusplus) || defined(c_plusplus)
427 #endif /* !_MAGICKCORE_NT_BASE_H */