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 "magick/delegate.h"
26 #include "magick/delegate-private.h"
27 #include "magick/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(path,mode)
86 #if !defined(closedir)
87 # define closedir(directory) NTCloseDirectory(directory)
90 # define fdopen _fdopen
93 # define fileno _fileno
96 # define fseek _fseeki64
98 #if !defined(fstat) && !defined(__BORLANDC__)
99 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
100 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
101 # define fstat _fstati64
103 # define fstat _fstat
107 # define fsync _commit
110 # define ftell _ftelli64
112 #if !defined(ftruncate)
113 # define ftruncate(file,length) NTTruncateFile(file,length)
116 # define getcwd _getcwd
119 # define getpid _getpid
122 # define hypot _hypot
125 # define inline __inline
128 # define isatty _isatty
130 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
131 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
132 # define lseek _lseeki64
134 #if !defined(MAGICKCORE_LTDL_DELEGATE)
135 #if !defined(lt_dlclose)
136 # define lt_dlclose(handle) NTCloseLibrary(handle)
138 #if !defined(lt_dlerror)
139 # define lt_dlerror() NTGetLibraryError()
141 #if !defined(lt_dlexit)
142 # define lt_dlexit() NTExitLibrary()
144 #if !defined(lt_dlinit)
145 # define lt_dlinit() NTInitializeLibrary()
147 #if !defined(lt_dlopen)
148 # define lt_dlopen(filename) NTOpenLibrary(filename)
150 #if !defined(lt_dlsetsearchpath)
151 # define lt_dlsetsearchpath(path) NTSetSearchPath(path)
153 #if !defined(lt_dlsym)
154 # define lt_dlsym(handle,name) NTGetLibrarySymbol(handle,name)
158 # define mkdir _mkdir
161 # define mmap(address,length,protection,access,file,offset) \
162 NTMapMemory(address,length,protection,access,file,offset)
165 # define msync(address,length,flags) NTSyncMemory(address,length,flags)
168 # define munmap(address,length) NTUnmapMemory(address,length)
170 #if !defined(opendir)
171 # define opendir(directory) NTOpenDirectory(directory)
177 # define pclose _pclose
180 # define popen _popen
185 #if !defined(readdir)
186 # define readdir(directory) NTReadDirectory(directory)
188 #if !defined(seekdir)
189 # define seekdir(directory,offset) NTSeekDirectory(directory,offset)
191 #if !defined(setmode)
192 # define setmode _setmode
194 #if !defined(spawnvp)
195 # define spawnvp _spawnvp
197 #if !defined(stat) && !defined(__BORLANDC__)
198 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
199 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
200 # define stat _stati64
205 #if !defined(strcasecmp)
206 # define strcasecmp _strcmpi
208 #if !defined(strncasecmp)
209 # define strncasecmp _strnicmp
211 #if !defined(sysconf)
212 # define sysconf(name) NTSystemConfiguration(name)
214 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
215 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
216 # define tell _telli64
218 #if !defined(telldir)
219 # define telldir(directory) NTTellDirectory(directory)
221 #if !defined(tempnam)
222 # define tempnam _tempnam
224 #if !defined(vsnprintf)
225 #if !defined(_MSC_VER) || (defined(_MSC_VER) && (_MSC_VER < 1500))
226 #define vsnprintf _vsnprintf
230 # define write _write
232 #if !defined(wstat) && !defined(__BORLANDC__)
233 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
234 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
235 # define wstat _wstati64
237 # define wstat _wstat
241 #if defined(_MT) && defined(MAGICKCORE_WINDOWS_SUPPORT)
242 # define SAFE_GLOBAL __declspec(thread)
247 #if defined(__BORLANDC__)
251 #define _O_SEQUENTIAL 0
252 #undef _O_SHORT_LIVED
253 #define _O_SHORT_LIVED 0
255 #define _O_TEMPORARY 0
258 #if !defined(XS_VERSION)
283 typedef struct _NTMEMORYSTATUSEX
296 ullAvailExtendedVirtual;
299 #if !defined(__MINGW32__)
309 (CALLBACK *LPFNDLLFUNC1)(DWORD,UINT);
312 (CALLBACK *LPFNDLLFUNC2)(NTMEMORYSTATUSEX *);
316 #if defined(MAGICKCORE_BZLIB_DELEGATE)
322 extern MagickExport char
323 *NTGetLastError(void);
325 extern MagickExport const GhostInfo
326 *NTGhostscriptDLLVectors(void);
328 #if !defined(MAGICKCORE_LTDL_DELEGATE)
329 extern MagickExport const char
330 *NTGetLibraryError(void);
333 #if !defined(XS_VERSION)
334 extern MagickExport const char
335 *NTGetLibraryError(void);
337 extern MagickExport DIR
338 *NTOpenDirectory(const char *);
340 extern MagickExport double
344 extern MagickExport int
346 #if !defined(__MINGW32__)
347 gettimeofday(struct timeval *,struct timezone *),
350 NTCloseDirectory(DIR *),
351 NTCloseLibrary(void *),
352 NTControlHandler(void),
354 NTTruncateFile(int,off_t),
355 NTGhostscriptDLL(char *,int),
356 NTGhostscriptEXE(char *,int),
357 NTGhostscriptFonts(char *,int),
358 NTGhostscriptLoadDLL(void),
359 NTGhostscriptUnLoadDLL(void),
360 NTInitializeLibrary(void),
361 NTSetSearchPath(const char *),
362 NTSyncMemory(void *,size_t,int),
363 NTUnmapMemory(void *,size_t),
364 NTSystemCommand(const char *);
366 extern MagickExport ssize_t
367 NTSystemConfiguration(int),
368 NTTellDirectory(DIR *);
370 extern MagickExport MagickBooleanType
371 NTGatherRandomData(const size_t,unsigned char *),
372 NTGetExecutionPath(char *,const size_t),
373 NTGetModulePath(const char *,char *),
374 NTReportEvent(const char *,const MagickBooleanType),
375 NTReportException(const char *,const MagickBooleanType);
377 extern MagickExport struct dirent
378 *NTReadDirectory(DIR *);
380 extern MagickExport unsigned char
381 *NTRegistryKeyLookup(const char *),
382 *NTResourceToBlob(const char *);
384 extern MagickExport void
385 NTErrorHandler(const ExceptionType,const char *,const char *),
386 *NTGetLibrarySymbol(void *,const char *),
387 *NTMapMemory(char *,size_t,int,int,int,MagickOffsetType),
388 *NTOpenLibrary(const char *),
389 NTSeekDirectory(DIR *,ssize_t),
390 NTWarningHandler(const ExceptionType,const char *,const char *);
392 #endif /* !XS_VERSION */
394 #if defined(__cplusplus) || defined(c_plusplus)
398 #endif /* !_MAGICKCORE_NT_BASE_H */