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 #if defined(_VISUALC_) && (_MSC_VER >= 1400)
79 # define access(path,mode) _access_s(path,mode)
88 #if !defined(closedir)
89 # define closedir(directory) NTCloseDirectory(directory)
92 # define fdopen _fdopen
95 # define fileno _fileno
97 #if !defined(fseek) && !defined(__MINGW32__)
98 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
99 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
100 # define fseek _fseeki64
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
120 #if !defined(ftruncate)
121 # define ftruncate(file,length) NTTruncateFile(file,length)
124 # define getcwd _getcwd
127 # define getpid _getpid
130 # define hypot _hypot
133 # define inline __inline
136 # define isatty _isatty
138 #if !defined(locale_t)
139 #define locale_t _locale_t
141 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
142 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
143 # define lseek _lseeki64
145 # define lseek _lseek
147 #if !defined(MAGICKCORE_LTDL_DELEGATE)
148 #if !defined(lt_dlclose)
149 # define lt_dlclose(handle) NTCloseLibrary(handle)
151 #if !defined(lt_dlerror)
152 # define lt_dlerror() NTGetLibraryError()
154 #if !defined(lt_dlexit)
155 # define lt_dlexit() NTExitLibrary()
157 #if !defined(lt_dlinit)
158 # define lt_dlinit() NTInitializeLibrary()
160 #if !defined(lt_dlopen)
161 # define lt_dlopen(filename) NTOpenLibrary(filename)
163 #if !defined(lt_dlsetsearchpath)
164 # define lt_dlsetsearchpath(path) NTSetSearchPath(path)
166 #if !defined(lt_dlsym)
167 # define lt_dlsym(handle,name) NTGetLibrarySymbol(handle,name)
171 # define mkdir _mkdir
174 # define mmap(address,length,protection,access,file,offset) \
175 NTMapMemory(address,length,protection,access,file,offset)
178 # define msync(address,length,flags) NTSyncMemory(address,length,flags)
181 # define munmap(address,length) NTUnmapMemory(address,length)
183 #if !defined(opendir)
184 # define opendir(directory) NTOpenDirectory(directory)
190 # define pclose _pclose
193 # define popen _popen
195 #if !defined(fprintf_l)
196 #define fprintf_l _fprintf_s_l
201 #if !defined(readdir)
202 # define readdir(directory) NTReadDirectory(directory)
204 #if !defined(seekdir)
205 # define seekdir(directory,offset) NTSeekDirectory(directory,offset)
207 #if !defined(setmode)
208 # define setmode _setmode
210 #if !defined(spawnvp)
211 # define spawnvp _spawnvp
213 #if !defined(strtod_l)
214 #define strtod_l _strtod_l
216 #if !defined(stat) && !defined(__BORLANDC__)
217 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
218 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
219 # define stat _stati64
224 #if !defined(strcasecmp)
225 # define strcasecmp _strcmpi
227 #if !defined(strncasecmp)
228 # define strncasecmp _strnicmp
230 #if !defined(sysconf)
231 # define sysconf(name) NTSystemConfiguration(name)
233 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
234 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
235 # define tell _telli64
239 #if !defined(telldir)
240 # define telldir(directory) NTTellDirectory(directory)
242 #if !defined(tempnam)
243 # define tempnam _tempnam_s
245 #if !defined(vfprintf_l)
246 #define vfprintf_l _vfprintf_l
248 #if !defined(vsnprintf)
249 #if !defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1500)
250 #define vsnprintf _vsnprintf
253 #if !defined(vsnprintf_l)
254 #define vsnprintf_l _vsnprintf_l
257 # define write _write
259 #if !defined(wstat) && !defined(__BORLANDC__)
260 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
261 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
262 # define wstat _wstati64
264 # define wstat _wstat
268 #if defined(_MT) && defined(MAGICKCORE_WINDOWS_SUPPORT)
269 # define SAFE_GLOBAL __declspec(thread)
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 #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),
353 **NTArgvToUTF8(const int argc,wchar_t **);
355 extern MagickExport const GhostInfo
356 *NTGhostscriptDLLVectors(void);
358 #if !defined(MAGICKCORE_LTDL_DELEGATE)
359 extern MagickExport const char
360 *NTGetLibraryError(void);
363 #if !defined(XS_VERSION)
364 extern MagickExport const char
365 *NTGetLibraryError(void);
367 extern MagickExport DIR
368 *NTOpenDirectory(const char *);
370 extern MagickExport double
374 extern MagickExport int
376 #if !defined(__MINGW32__)
377 gettimeofday(struct timeval *,struct timezone *),
380 NTCloseDirectory(DIR *),
381 NTCloseLibrary(void *),
382 NTControlHandler(void),
384 NTTruncateFile(int,off_t),
385 NTGhostscriptDLL(char *,int),
386 NTGhostscriptEXE(char *,int),
387 NTGhostscriptFonts(char *,int),
388 NTGhostscriptLoadDLL(void),
389 NTGhostscriptUnLoadDLL(void),
390 NTInitializeLibrary(void),
391 NTSetSearchPath(const char *),
392 NTSyncMemory(void *,size_t,int),
393 NTUnmapMemory(void *,size_t),
394 NTSystemCommand(const char *);
396 extern MagickExport ssize_t
397 NTSystemConfiguration(int),
398 NTTellDirectory(DIR *);
400 extern MagickExport MagickBooleanType
401 NTGatherRandomData(const size_t,unsigned char *),
402 NTGetExecutionPath(char *,const size_t),
403 NTGetModulePath(const char *,char *),
404 NTReportEvent(const char *,const MagickBooleanType),
405 NTReportException(const char *,const MagickBooleanType);
407 extern MagickExport struct dirent
408 *NTReadDirectory(DIR *);
410 extern MagickExport unsigned char
411 *NTRegistryKeyLookup(const char *),
412 *NTResourceToBlob(const char *);
414 extern MagickExport void
415 NTErrorHandler(const ExceptionType,const char *,const char *),
416 *NTGetLibrarySymbol(void *,const char *),
417 *NTMapMemory(char *,size_t,int,int,int,MagickOffsetType),
418 *NTOpenLibrary(const char *),
419 NTSeekDirectory(DIR *,ssize_t),
420 NTWarningHandler(const ExceptionType,const char *,const char *);
422 #endif /* !XS_VERSION */
424 #if defined(__cplusplus) || defined(c_plusplus)
428 #endif /* !_MAGICKCORE_NT_BASE_H */