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
285 #if !defined(XS_VERSION)
310 typedef struct _NTMEMORYSTATUSEX
323 ullAvailExtendedVirtual;
326 #if !defined(__MINGW32__)
336 (CALLBACK *LPFNDLLFUNC1)(DWORD,UINT);
339 (CALLBACK *LPFNDLLFUNC2)(NTMEMORYSTATUSEX *);
343 #if defined(MAGICKCORE_BZLIB_DELEGATE)
349 extern MagickExport char
350 *NTGetLastError(void),
351 **NTArgvToUTF8(const int argc,wchar_t **);
353 extern MagickExport const GhostInfo
354 *NTGhostscriptDLLVectors(void);
356 #if !defined(MAGICKCORE_LTDL_DELEGATE)
357 extern MagickExport const char
358 *NTGetLibraryError(void);
361 #if !defined(XS_VERSION)
362 extern MagickExport const char
363 *NTGetLibraryError(void);
365 extern MagickExport DIR
366 *NTOpenDirectory(const char *);
368 extern MagickExport double
372 extern MagickExport int
374 #if !defined(__MINGW32__)
375 gettimeofday(struct timeval *,struct timezone *),
378 NTCloseDirectory(DIR *),
379 NTCloseLibrary(void *),
380 NTControlHandler(void),
382 NTTruncateFile(int,off_t),
383 NTGhostscriptDLL(char *,int),
384 NTGhostscriptEXE(char *,int),
385 NTGhostscriptFonts(char *,int),
386 NTGhostscriptLoadDLL(void),
387 NTGhostscriptUnLoadDLL(void),
388 NTInitializeLibrary(void),
389 NTSetSearchPath(const char *),
390 NTSyncMemory(void *,size_t,int),
391 NTUnmapMemory(void *,size_t),
392 NTSystemCommand(const char *);
394 extern MagickExport ssize_t
395 NTSystemConfiguration(int),
396 NTTellDirectory(DIR *);
398 extern MagickExport MagickBooleanType
399 NTGatherRandomData(const size_t,unsigned char *),
400 NTGetExecutionPath(char *,const size_t),
401 NTGetModulePath(const char *,char *),
402 NTReportEvent(const char *,const MagickBooleanType),
403 NTReportException(const char *,const MagickBooleanType);
405 extern MagickExport struct dirent
406 *NTReadDirectory(DIR *);
408 extern MagickExport unsigned char
409 *NTRegistryKeyLookup(const char *),
410 *NTResourceToBlob(const char *);
412 extern MagickExport void
413 NTErrorHandler(const ExceptionType,const char *,const char *),
414 *NTGetLibrarySymbol(void *,const char *),
415 *NTMapMemory(char *,size_t,int,int,int,MagickOffsetType),
416 *NTOpenLibrary(const char *),
417 NTSeekDirectory(DIR *,ssize_t),
418 NTWarningHandler(const ExceptionType,const char *,const char *);
420 #endif /* !XS_VERSION */
422 #if defined(__cplusplus) || defined(c_plusplus)
426 #endif /* !_MAGICKCORE_NT_BASE_H */