]> granicus.if.org Git - imagemagick/blob - MagickCore/nt-base.h
(no commit message)
[imagemagick] / MagickCore / nt-base.h
1 /*
2   Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization
3   dedicated to making software imaging solutions freely available.
4   
5   You may not use this file except in compliance with the License.
6   obtain a copy of the License at
7   
8     http://www.imagemagick.org/script/license.php
9   
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.
15
16   MagickCore Windows NT utility methods.
17 */
18 #ifndef _MAGICKCORE_NT_BASE_H
19 #define _MAGICKCORE_NT_BASE_H
20
21 #include "MagickCore/exception.h"
22 #include "MagickCore/geometry.h"
23
24 #if defined(__cplusplus) || defined(c_plusplus)
25 extern "C" {
26 #endif
27
28 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
29
30 #define WIN32_LEAN_AND_MEAN
31 #define VC_EXTRALEAN
32 #define _CRT_SECURE_NO_DEPRECATE  1
33 #include <windows.h>
34 #include <wchar.h>
35 #include <winuser.h>
36 #include <wingdi.h>
37 #include <io.h>
38 #include <process.h>
39 #include <errno.h>
40 #if defined(_DEBUG) && !defined(__MINGW32__) && !defined(__MINGW64__)
41 #include <crtdbg.h>
42 #endif
43
44 #define PROT_READ  0x01
45 #define PROT_WRITE  0x02
46 #define MAP_SHARED  0x01
47 #define MAP_PRIVATE  0x02
48 #define MAP_ANONYMOUS  0x20
49 #define F_OK 0
50 #define R_OK 4
51 #define W_OK 2
52 #define RW_OK 6
53 #define _SC_PAGESIZE 1
54 #define _SC_PHYS_PAGES 2
55 #define _SC_OPEN_MAX 3
56 #if !defined(SSIZE_MAX)
57 #define SSIZE_MAX  0x7fffffffL
58 #endif
59
60 /*
61   _MSC_VER values:
62     1100 MSVC 5.0
63     1200 MSVC 6.0
64     1300 MSVC 7.0 Visual C++ .NET 2002
65     1310 Visual c++ .NET 2003
66     1400 Visual C++ 2005
67     1500 Visual C++ 2008
68 */
69
70 #if !defined(chsize)
71 # if defined(__BORLANDC__)
72 #   define chsize(file,length)  chsize(file,length)
73 # else
74 #   define chsize(file,length)  _chsize(file,length)
75 # endif
76 #endif
77
78 #if !defined(access)
79 #if defined(_VISUALC_) && (_MSC_VER >= 1400)
80 #  define access(path,mode)  _access_s(path,mode)
81 #endif
82 #endif
83 #if !defined(chdir)
84 #  define chdir  _chdir
85 #endif
86 #if !defined(close)
87 #  define close  _close
88 #endif
89 #if !defined(closedir)
90 #  define closedir(directory)  NTCloseDirectory(directory)
91 #endif
92 #if !defined(fdopen)
93 #  define fdopen  _fdopen
94 #endif
95 #if !defined(fileno)
96 #  define fileno  _fileno
97 #endif
98 #if !defined(fseek) && !defined(__MINGW32__) && !defined(__MINGW64__)
99 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
100   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
101 #  define fseek  _fseeki64
102 #endif
103 #endif
104 #if !defined(fstat) && !defined(__BORLANDC__)
105 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
106   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
107 #  define fstat  _fstati64
108 #else
109 #  define fstat  _fstat
110 #endif
111 #endif
112 #if !defined(fsync)
113 #  define fsync  _commit
114 #endif
115 #if !defined(ftell) && !defined(__MINGW32__) && !defined(__MINGW64__)
116 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
117   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
118 #  define ftell  _ftelli64
119 #endif
120 #endif
121 #if !defined(ftruncate)
122 #  define ftruncate(file,length)  NTTruncateFile(file,length)
123 #endif
124 #if !defined(getcwd)
125 #  define getcwd  _getcwd
126 #endif
127 #if !defined(getpid)
128 #  define getpid  _getpid
129 #endif
130 #if !defined(hypot)
131 #  define hypot  _hypot
132 #endif
133 #if !defined(inline)
134 #  define inline __inline
135 #endif
136 #if !defined(isatty)
137 #  define isatty  _isatty
138 #endif
139 #if !defined(locale_t)
140 #define locale_t _locale_t
141 #endif
142 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
143   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
144 #  define lseek  _lseeki64
145 #else
146 #  define lseek  _lseek
147 #endif
148 #if !defined(MAGICKCORE_LTDL_DELEGATE)
149 #if !defined(lt_dlclose)
150 #  define lt_dlclose(handle)  NTCloseLibrary(handle)
151 #endif
152 #if !defined(lt_dlerror)
153 #  define lt_dlerror()  NTGetLibraryError()
154 #endif
155 #if !defined(lt_dlexit)
156 #  define lt_dlexit()  NTExitLibrary()
157 #endif
158 #if !defined(lt_dlinit)
159 #  define lt_dlinit()  NTInitializeLibrary()
160 #endif
161 #if !defined(lt_dlopen)
162 #  define lt_dlopen(filename)  NTOpenLibrary(filename)
163 #endif
164 #if !defined(lt_dlsetsearchpath)
165 #  define lt_dlsetsearchpath(path)  NTSetSearchPath(path)
166 #endif
167 #if !defined(lt_dlsym)
168 #  define lt_dlsym(handle,name)  NTGetLibrarySymbol(handle,name)
169 #endif
170 #endif
171 #if !defined(mkdir)
172 #  define mkdir  _mkdir
173 #endif
174 #if !defined(mmap)
175 #  define mmap(address,length,protection,access,file,offset) \
176   NTMapMemory(address,length,protection,access,file,offset)
177 #endif
178 #if !defined(msync)
179 #  define msync(address,length,flags)  NTSyncMemory(address,length,flags)
180 #endif
181 #if !defined(munmap)
182 #  define munmap(address,length)  NTUnmapMemory(address,length)
183 #endif
184 #if !defined(opendir)
185 #  define opendir(directory)  NTOpenDirectory(directory)
186 #endif
187 #if !defined(open)
188 #  define open  _open
189 #endif
190 #if !defined(pclose)
191 #  define pclose  _pclose
192 #endif
193 #if !defined(popen)
194 #  define popen  _popen
195 #endif
196 #if !defined(fprintf_l)
197 #define fprintf_l  _fprintf_s_l
198 #endif
199 #if !defined(read)
200 #  define read  _read
201 #endif
202 #if !defined(readdir)
203 #  define readdir(directory)  NTReadDirectory(directory)
204 #endif
205 #if !defined(seekdir)
206 #  define seekdir(directory,offset)  NTSeekDirectory(directory,offset)
207 #endif
208 #if !defined(setmode)
209 #  define setmode  _setmode
210 #endif
211 #if !defined(spawnvp)
212 #  define spawnvp  _spawnvp
213 #endif
214 #if !defined(strtod_l)
215 #define strtod_l  _strtod_l
216 #endif
217 #if !defined(stat) && !defined(__BORLANDC__)
218 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
219   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
220 #  define stat  _stati64
221 #else
222 #  define stat  _stat
223 #endif
224 #endif
225 #if !defined(strcasecmp)
226 #  define strcasecmp  _stricmp
227 #endif
228 #if !defined(strncasecmp)
229 #  define strncasecmp  _strnicmp
230 #endif
231 #if !defined(sysconf)
232 #  define sysconf(name)  NTSystemConfiguration(name)
233 #endif
234 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
235   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
236 #  define tell  _telli64
237 #else
238 #  define tell  _tell
239 #endif
240 #if !defined(telldir)
241 #  define telldir(directory)  NTTellDirectory(directory)
242 #endif
243 #if !defined(tempnam)
244 #  define tempnam  _tempnam_s
245 #endif
246 #if !defined(vfprintf_l)
247 #define vfprintf_l  _vfprintf_l
248 #endif
249 #if !defined(vsnprintf)
250 #if !defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1500)
251 #define vsnprintf _vsnprintf 
252 #endif
253 #endif
254 #if !defined(vsnprintf_l)
255 #define vsnprintf_l  _vsnprintf_l
256 #endif
257 #if !defined(write)
258 #  define write  _write
259 #endif
260 #if !defined(wstat) && !defined(__BORLANDC__)
261 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
262   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
263 #  define wstat  _wstati64
264 #else
265 #  define wstat  _wstat
266 #endif
267 #endif
268
269 #if defined(_MT) && defined(MAGICKCORE_WINDOWS_SUPPORT)
270 #  define SAFE_GLOBAL  __declspec(thread)
271 #else
272 #  define SAFE_GLOBAL
273 #endif
274
275 #if defined(__BORLANDC__)
276 #undef _O_RANDOM
277 #define _O_RANDOM 0
278 #undef _O_SEQUENTIAL
279 #define _O_SEQUENTIAL 0
280 #undef _O_SHORT_LIVED
281 #define _O_SHORT_LIVED 0
282 #undef _O_TEMPORARY
283 #define _O_TEMPORARY 0
284 #endif
285
286 #undef gettimeofday
287
288 typedef struct _GhostInfo
289   GhostInfo_;
290
291 extern MagickExport char
292   **NTArgvToUTF8(const int argc,wchar_t **);
293
294 extern MagickExport const GhostInfo_
295   *NTGhostscriptDLLVectors(void);
296
297 extern MagickExport int
298   NTGhostscriptUnLoadDLL(void);
299
300 extern MagickExport void
301   NTErrorHandler(const ExceptionType,const char *,const char *),
302   NTWarningHandler(const ExceptionType,const char *,const char *);
303 #endif
304
305 #if defined(__cplusplus) || defined(c_plusplus)
306 }
307 #endif
308
309 #endif