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_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)
198 #define fprintf _fprintf_s
200 #if !defined(fprintf_l)
201 #define fprintf_l _fprintf_s_l
206 #if !defined(readdir)
207 # define readdir(directory) NTReadDirectory(directory)
209 #if !defined(seekdir)
210 # define seekdir(directory,offset) NTSeekDirectory(directory,offset)
212 #if !defined(setmode)
213 # define setmode _setmode
215 #if !defined(spawnvp)
216 # define spawnvp _spawnvp
218 #if !defined(strtod_l)
219 #define strtod_l _strtod_l
221 #if !defined(stat) && !defined(__BORLANDC__)
222 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
223 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
224 # define stat _stati64
229 #if !defined(strcasecmp)
230 # define strcasecmp _strcmpi
232 #if !defined(strncasecmp)
233 # define strncasecmp _strnicmp
235 #if !defined(sysconf)
236 # define sysconf(name) NTSystemConfiguration(name)
238 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
239 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
240 # define tell _telli64
244 #if !defined(telldir)
245 # define telldir(directory) NTTellDirectory(directory)
247 #if !defined(tempnam)
248 # define tempnam _tempnam_s
250 #if !defined(vfprintf_l)
251 #define vfprintf_l _vfprintf_l
253 #if !defined(vsnprintf)
254 #if !defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1500)
255 #define vsnprintf _vsnprintf
258 #if !defined(vsnprintf_l)
259 #define vsnprintf_l _vsnprintf_l
262 # define write _write
264 #if !defined(wstat) && !defined(__BORLANDC__)
265 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
266 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
267 # define wstat _wstati64
269 # define wstat _wstat
273 #if defined(_MT) && defined(MAGICKCORE_WINDOWS_SUPPORT)
274 # define SAFE_GLOBAL __declspec(thread)
279 #if defined(__BORLANDC__)
283 #define _O_SEQUENTIAL 0
284 #undef _O_SHORT_LIVED
285 #define _O_SHORT_LIVED 0
287 #define _O_TEMPORARY 0
290 #if !defined(XS_VERSION)
315 typedef struct _NTMEMORYSTATUSEX
328 ullAvailExtendedVirtual;
331 #if !defined(__MINGW32__)
341 (CALLBACK *LPFNDLLFUNC1)(DWORD,UINT);
344 (CALLBACK *LPFNDLLFUNC2)(NTMEMORYSTATUSEX *);
348 #if defined(MAGICKCORE_BZLIB_DELEGATE)
354 extern MagickExport char
355 *NTGetLastError(void);
357 extern MagickExport const GhostInfo
358 *NTGhostscriptDLLVectors(void);
360 #if !defined(MAGICKCORE_LTDL_DELEGATE)
361 extern MagickExport const char
362 *NTGetLibraryError(void);
365 #if !defined(XS_VERSION)
366 extern MagickExport const char
367 *NTGetLibraryError(void);
369 extern MagickExport DIR
370 *NTOpenDirectory(const char *);
372 extern MagickExport double
376 extern MagickExport int
378 #if !defined(__MINGW32__)
379 gettimeofday(struct timeval *,struct timezone *),
382 NTCloseDirectory(DIR *),
383 NTCloseLibrary(void *),
384 NTControlHandler(void),
386 NTTruncateFile(int,off_t),
387 NTGhostscriptDLL(char *,int),
388 NTGhostscriptEXE(char *,int),
389 NTGhostscriptFonts(char *,int),
390 NTGhostscriptLoadDLL(void),
391 NTGhostscriptUnLoadDLL(void),
392 NTInitializeLibrary(void),
393 NTSetSearchPath(const char *),
394 NTSyncMemory(void *,size_t,int),
395 NTUnmapMemory(void *,size_t),
396 NTSystemCommand(const char *);
398 extern MagickExport ssize_t
399 NTSystemConfiguration(int),
400 NTTellDirectory(DIR *);
402 extern MagickExport MagickBooleanType
403 NTGatherRandomData(const size_t,unsigned char *),
404 NTGetExecutionPath(char *,const size_t),
405 NTGetModulePath(const char *,char *),
406 NTReportEvent(const char *,const MagickBooleanType),
407 NTReportException(const char *,const MagickBooleanType);
409 extern MagickExport struct dirent
410 *NTReadDirectory(DIR *);
412 extern MagickExport unsigned char
413 *NTRegistryKeyLookup(const char *),
414 *NTResourceToBlob(const char *);
416 extern MagickExport void
417 NTErrorHandler(const ExceptionType,const char *,const char *),
418 *NTGetLibrarySymbol(void *,const char *),
419 *NTMapMemory(char *,size_t,int,int,int,MagickOffsetType),
420 *NTOpenLibrary(const char *),
421 NTSeekDirectory(DIR *,ssize_t),
422 NTWarningHandler(const ExceptionType,const char *,const char *);
424 #endif /* !XS_VERSION */
426 #if defined(__cplusplus) || defined(c_plusplus)
430 #endif /* !_MAGICKCORE_NT_BASE_H */