]> 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 #include <malloc.h>
41 #if defined(_DEBUG) && !defined(__MINGW32__) && !defined(__MINGW64__)
42 #include <crtdbg.h>
43 #endif
44
45 #define PROT_READ  0x01
46 #define PROT_WRITE  0x02
47 #define MAP_SHARED  0x01
48 #define MAP_PRIVATE  0x02
49 #define MAP_ANONYMOUS  0x20
50 #define F_OK 0
51 #define R_OK 4
52 #define W_OK 2
53 #define RW_OK 6
54 #define _SC_PAGESIZE 1
55 #define _SC_PHYS_PAGES 2
56 #define _SC_OPEN_MAX 3
57 #if !defined(SSIZE_MAX)
58 #define SSIZE_MAX  0x7fffffffL
59 #endif
60
61 /*
62   _MSC_VER values:
63     1100 MSVC 5.0
64     1200 MSVC 6.0
65     1300 MSVC 7.0 Visual C++ .NET 2002
66     1310 Visual c++ .NET 2003
67     1400 Visual C++ 2005
68     1500 Visual C++ 2008
69 */
70
71 #if !defined(chsize)
72 # if defined(__BORLANDC__)
73 #   define chsize(file,length)  chsize(file,length)
74 # else
75 #   define chsize(file,length)  _chsize(file,length)
76 # endif
77 #endif
78
79 #if !defined(access)
80 #if defined(_VISUALC_) && (_MSC_VER >= 1400)
81 #  define access(path,mode)  _access_s(path,mode)
82 #endif
83 #endif
84 #if !defined(chdir)
85 #  define chdir  _chdir
86 #endif
87 #if !defined(close)
88 #  define close  _close
89 #endif
90 #if !defined(closedir)
91 #  define closedir(directory)  NTCloseDirectory(directory)
92 #endif
93 #if !defined(fdopen)
94 #  define fdopen  _fdopen
95 #endif
96 #if !defined(fileno)
97 #  define fileno  _fileno
98 #endif
99 #if !defined(fseek) && !defined(__MINGW32__) && !defined(__MINGW64__)
100 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
101   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
102 #  define fseek  _fseeki64
103 #endif
104 #endif
105 #if !defined(fstat) && !defined(__BORLANDC__)
106 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
107   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
108 #  define fstat  _fstati64
109 #else
110 #  define fstat  _fstat
111 #endif
112 #endif
113 #if !defined(fsync)
114 #  define fsync  _commit
115 #endif
116 #if !defined(ftell) && !defined(__MINGW32__) && !defined(__MINGW64__)
117 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
118   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
119 #  define ftell  _ftelli64
120 #endif
121 #endif
122 #if !defined(ftruncate)
123 #  define ftruncate(file,length)  NTTruncateFile(file,length)
124 #endif
125 #if !defined(getcwd)
126 #  define getcwd  _getcwd
127 #endif
128 #if !defined(getpid)
129 #  define getpid  _getpid
130 #endif
131 #if !defined(hypot)
132 #  define hypot  _hypot
133 #endif
134 #if !defined(inline)
135 #  define inline __inline
136 #endif
137 #if !defined(isatty)
138 #  define isatty  _isatty
139 #endif
140 #if !defined(locale_t)
141 #define locale_t _locale_t
142 #endif
143 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
144   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
145 #if !defined(lseek)
146 #  define lseek  _lseeki64
147 #endif
148 #else
149 #if !defined(lseek)
150 #  define lseek  _lseek
151 #endif
152 #else
153 #endif
154 #if !defined(MAGICKCORE_LTDL_DELEGATE)
155 #if !defined(lt_dlclose)
156 #  define lt_dlclose(handle)  NTCloseLibrary(handle)
157 #endif
158 #if !defined(lt_dlerror)
159 #  define lt_dlerror()  NTGetLibraryError()
160 #endif
161 #if !defined(lt_dlexit)
162 #  define lt_dlexit()  NTExitLibrary()
163 #endif
164 #if !defined(lt_dlinit)
165 #  define lt_dlinit()  NTInitializeLibrary()
166 #endif
167 #if !defined(lt_dlopen)
168 #  define lt_dlopen(filename)  NTOpenLibrary(filename)
169 #endif
170 #if !defined(lt_dlsetsearchpath)
171 #  define lt_dlsetsearchpath(path)  NTSetSearchPath(path)
172 #endif
173 #if !defined(lt_dlsym)
174 #  define lt_dlsym(handle,name)  NTGetLibrarySymbol(handle,name)
175 #endif
176 #endif
177 #if !defined(mkdir)
178 #  define mkdir  _mkdir
179 #endif
180 #if !defined(mmap)
181 #  define mmap(address,length,protection,access,file,offset) \
182   NTMapMemory(address,length,protection,access,file,offset)
183 #endif
184 #if !defined(msync)
185 #  define msync(address,length,flags)  NTSyncMemory(address,length,flags)
186 #endif
187 #if !defined(munmap)
188 #  define munmap(address,length)  NTUnmapMemory(address,length)
189 #endif
190 #if !defined(opendir)
191 #  define opendir(directory)  NTOpenDirectory(directory)
192 #endif
193 #if !defined(open)
194 #  define open  _open
195 #endif
196 #if !defined(pclose)
197 #  define pclose  _pclose
198 #endif
199 #if !defined(popen)
200 #  define popen  _popen
201 #endif
202 #if !defined(fprintf_l)
203 #define fprintf_l  _fprintf_s_l
204 #endif
205 #if !defined(read)
206 #  define read  _read
207 #endif
208 #if !defined(readdir)
209 #  define readdir(directory)  NTReadDirectory(directory)
210 #endif
211 #if !defined(seekdir)
212 #  define seekdir(directory,offset)  NTSeekDirectory(directory,offset)
213 #endif
214 #if !defined(setmode)
215 #  define setmode  _setmode
216 #endif
217 #if !defined(spawnvp)
218 #  define spawnvp  _spawnvp
219 #endif
220 #if !defined(strtod_l)
221 #define strtod_l  _strtod_l
222 #endif
223 #if !defined(stat) && !defined(__BORLANDC__)
224 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
225   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
226 #  define stat  _stati64
227 #else
228 #  define stat  _stat
229 #endif
230 #endif
231 #if !defined(strcasecmp)
232 #  define strcasecmp  _stricmp
233 #endif
234 #if !defined(strncasecmp)
235 #  define strncasecmp  _strnicmp
236 #endif
237 #if !defined(sysconf)
238 #  define sysconf(name)  NTSystemConfiguration(name)
239 #endif
240 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
241   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
242 #  define tell  _telli64
243 #else
244 #  define tell  _tell
245 #endif
246 #if !defined(telldir)
247 #  define telldir(directory)  NTTellDirectory(directory)
248 #endif
249 #if !defined(tempnam)
250 #  define tempnam  _tempnam_s
251 #endif
252 #if !defined(vfprintf_l)
253 #define vfprintf_l  _vfprintf_l
254 #endif
255 #if !defined(vsnprintf)
256 #if !defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1500)
257 #define vsnprintf _vsnprintf 
258 #endif
259 #endif
260 #if !defined(vsnprintf_l)
261 #define vsnprintf_l  _vsnprintf_l
262 #endif
263 #if !defined(write)
264 #  define write  _write
265 #endif
266 #if !defined(wstat) && !defined(__BORLANDC__)
267 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
268   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
269 #  define wstat  _wstati64
270 #else
271 #  define wstat  _wstat
272 #endif
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