2 Copyright 1999-2010 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 fseeko _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 ftello _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_LTDL_DELEGATE)
131 #if !defined(lt_dlclose)
132 # define lt_dlclose(handle) NTCloseLibrary(handle)
134 #if !defined(lt_dlerror)
135 # define lt_dlerror() NTGetLibraryError()
137 #if !defined(lt_dlexit)
138 # define lt_dlexit() NTExitLibrary()
140 #if !defined(lt_dlinit)
141 # define lt_dlinit() NTInitializeLibrary()
143 #if !defined(lt_dlopen)
144 # define lt_dlopen(filename) NTOpenLibrary(filename)
146 #if !defined(lt_dlsetsearchpath)
147 # define lt_dlsetsearchpath(path) NTSetSearchPath(path)
149 #if !defined(lt_dlsym)
150 # define lt_dlsym(handle,name) NTGetLibrarySymbol(handle,name)
154 # define mkdir _mkdir
157 # define mmap(address,length,protection,access,file,offset) \
158 NTMapMemory(address,length,protection,access,file,offset)
161 # define msync(address,length,flags) NTSyncMemory(address,length,flags)
164 # define munmap(address,length) NTUnmapMemory(address,length)
166 #if !defined(opendir)
167 # define opendir(directory) NTOpenDirectory(directory)
173 # define pclose _pclose
176 # define popen _popen
181 #if !defined(readdir)
182 # define readdir(directory) NTReadDirectory(directory)
184 #if !defined(seekdir)
185 # define seekdir(directory,offset) NTSeekDirectory(directory,offset)
187 #if !defined(setmode)
188 # define setmode _setmode
190 #if !defined(spawnvp)
191 # define spawnvp _spawnvp
193 #if !defined(stat) && !defined(__BORLANDC__)
194 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
195 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
196 # define stat _stati64
201 #if !defined(strcasecmp)
202 # define strcasecmp _strcmpi
204 #if !defined(strncasecmp)
205 # define strncasecmp _strnicmp
207 #if !defined(sysconf)
208 # define sysconf(name) NTSystemConfiguration(name)
210 #if !defined(telldir)
211 # define telldir(directory) NTTellDirectory(directory)
213 #if !defined(tempnam)
214 # define tempnam _tempnam
216 #if !defined(vsnprintf)
217 #if !defined(_MSC_VER) || (defined(_MSC_VER) && (_MSC_VER < 1500))
218 #define vsnprintf _vsnprintf
222 # define write _write
224 #if !defined(wstat) && !defined(__BORLANDC__)
225 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
226 !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
227 # define wstat _wstati64
229 # define wstat _wstat
233 #if defined(_MT) && defined(MAGICKCORE_WINDOWS_SUPPORT)
234 # define SAFE_GLOBAL __declspec(thread)
239 #if defined(__BORLANDC__)
243 #define _O_SEQUENTIAL 0
244 #undef _O_SHORT_LIVED
245 #define _O_SHORT_LIVED 0
247 #define _O_TEMPORARY 0
250 #if !defined(XS_VERSION)
275 typedef struct _NTMEMORYSTATUSEX
288 ullAvailExtendedVirtual;
291 #if !defined(__MINGW32__)
301 (CALLBACK *LPFNDLLFUNC1)(DWORD,UINT);
304 (CALLBACK *LPFNDLLFUNC2)(NTMEMORYSTATUSEX *);
308 #if !defined(ssize_t) && !defined(__MINGW32__)
309 typedef long ssize_t;
312 #if defined(MAGICKCORE_BZLIB_DELEGATE)
318 extern MagickExport char
319 *NTGetLastError(void);
321 extern MagickExport const GhostInfo
322 *NTGhostscriptDLLVectors(void);
324 #if !defined(MAGICKCORE_LTDL_DELEGATE)
325 extern MagickExport const char
326 *NTGetLibraryError(void);
329 #if !defined(XS_VERSION)
330 extern MagickExport const char
331 *NTGetLibraryError(void);
333 extern MagickExport DIR
334 *NTOpenDirectory(const char *);
336 extern MagickExport double
340 extern MagickExport int
342 #if !defined(__MINGW32__)
343 gettimeofday(struct timeval *,struct timezone *),
346 NTCloseDirectory(DIR *),
347 NTCloseLibrary(void *),
348 NTControlHandler(void),
350 NTTruncateFile(int,off_t),
351 NTGhostscriptDLL(char *,int),
352 NTGhostscriptEXE(char *,int),
353 NTGhostscriptFonts(char *,int),
354 NTGhostscriptLoadDLL(void),
355 NTGhostscriptUnLoadDLL(void),
356 NTInitializeLibrary(void),
357 NTSetSearchPath(const char *),
358 NTSyncMemory(void *,size_t,int),
359 NTUnmapMemory(void *,size_t),
360 NTSystemCommand(const char *);
362 extern MagickExport long
363 NTSystemConfiguration(int),
364 NTTellDirectory(DIR *);
366 extern MagickExport MagickBooleanType
367 NTGatherRandomData(const size_t,unsigned char *),
368 NTGetExecutionPath(char *,const size_t),
369 NTGetModulePath(const char *,char *),
370 NTReportEvent(const char *,const MagickBooleanType),
371 NTReportException(const char *,const MagickBooleanType);
373 extern MagickExport struct dirent
374 *NTReadDirectory(DIR *);
376 extern MagickExport unsigned char
377 *NTRegistryKeyLookup(const char *),
378 *NTResourceToBlob(const char *);
380 extern MagickExport void
381 NTErrorHandler(const ExceptionType,const char *,const char *),
382 *NTGetLibrarySymbol(void *,const char *),
383 *NTMapMemory(char *,size_t,int,int,int,MagickOffsetType),
384 *NTOpenLibrary(const char *),
385 NTSeekDirectory(DIR *,long),
386 NTWarningHandler(const ExceptionType,const char *,const char *);
388 #endif /* !XS_VERSION */
390 #if defined(__cplusplus) || defined(c_plusplus)
394 #endif /* !_MAGICKCORE_NT_BASE_H */