]> 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 #  define lseek  _lseeki64
146 #else
147 #  define lseek  _lseek
148 #endif
149 #if !defined(MAGICKCORE_LTDL_DELEGATE)
150 #if !defined(lt_dlclose)
151 #  define lt_dlclose(handle)  NTCloseLibrary(handle)
152 #endif
153 #if !defined(lt_dlerror)
154 #  define lt_dlerror()  NTGetLibraryError()
155 #endif
156 #if !defined(lt_dlexit)
157 #  define lt_dlexit()  NTExitLibrary()
158 #endif
159 #if !defined(lt_dlinit)
160 #  define lt_dlinit()  NTInitializeLibrary()
161 #endif
162 #if !defined(lt_dlopen)
163 #  define lt_dlopen(filename)  NTOpenLibrary(filename)
164 #endif
165 #if !defined(lt_dlsetsearchpath)
166 #  define lt_dlsetsearchpath(path)  NTSetSearchPath(path)
167 #endif
168 #if !defined(lt_dlsym)
169 #  define lt_dlsym(handle,name)  NTGetLibrarySymbol(handle,name)
170 #endif
171 #endif
172 #if !defined(mkdir)
173 #  define mkdir  _mkdir
174 #endif
175 #if !defined(mmap)
176 #  define mmap(address,length,protection,access,file,offset) \
177   NTMapMemory(address,length,protection,access,file,offset)
178 #endif
179 #if !defined(msync)
180 #  define msync(address,length,flags)  NTSyncMemory(address,length,flags)
181 #endif
182 #if !defined(munmap)
183 #  define munmap(address,length)  NTUnmapMemory(address,length)
184 #endif
185 #if !defined(opendir)
186 #  define opendir(directory)  NTOpenDirectory(directory)
187 #endif
188 #if !defined(open)
189 #  define open  _open
190 #endif
191 #if !defined(pclose)
192 #  define pclose  _pclose
193 #endif
194 #if !defined(popen)
195 #  define popen  _popen
196 #endif
197 #if !defined(fprintf_l)
198 #define fprintf_l  _fprintf_s_l
199 #endif
200 #if !defined(read)
201 #  define read  _read
202 #endif
203 #if !defined(readdir)
204 #  define readdir(directory)  NTReadDirectory(directory)
205 #endif
206 #if !defined(seekdir)
207 #  define seekdir(directory,offset)  NTSeekDirectory(directory,offset)
208 #endif
209 #if !defined(setmode)
210 #  define setmode  _setmode
211 #endif
212 #if !defined(spawnvp)
213 #  define spawnvp  _spawnvp
214 #endif
215 #if !defined(strtod_l)
216 #define strtod_l  _strtod_l
217 #endif
218 #if !defined(stat) && !defined(__BORLANDC__)
219 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
220   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
221 #  define stat  _stati64
222 #else
223 #  define stat  _stat
224 #endif
225 #endif
226 #if !defined(strcasecmp)
227 #  define strcasecmp  _stricmp
228 #endif
229 #if !defined(strncasecmp)
230 #  define strncasecmp  _strnicmp
231 #endif
232 #if !defined(sysconf)
233 #  define sysconf(name)  NTSystemConfiguration(name)
234 #endif
235 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
236   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
237 #  define tell  _telli64
238 #else
239 #  define tell  _tell
240 #endif
241 #if !defined(telldir)
242 #  define telldir(directory)  NTTellDirectory(directory)
243 #endif
244 #if !defined(tempnam)
245 #  define tempnam  _tempnam_s
246 #endif
247 #if !defined(vfprintf_l)
248 #define vfprintf_l  _vfprintf_l
249 #endif
250 #if !defined(vsnprintf)
251 #if !defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1500)
252 #define vsnprintf _vsnprintf 
253 #endif
254 #endif
255 #if !defined(vsnprintf_l)
256 #define vsnprintf_l  _vsnprintf_l
257 #endif
258 #if !defined(write)
259 #  define write  _write
260 #endif
261 #if !defined(wstat) && !defined(__BORLANDC__)
262 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
263   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
264 #  define wstat  _wstati64
265 #else
266 #  define wstat  _wstat
267 #endif
268 #endif
269
270 #if defined(__BORLANDC__)
271 #undef _O_RANDOM
272 #define _O_RANDOM 0
273 #undef _O_SEQUENTIAL
274 #define _O_SEQUENTIAL 0
275 #undef _O_SHORT_LIVED
276 #define _O_SHORT_LIVED 0
277 #undef _O_TEMPORARY
278 #define _O_TEMPORARY 0
279 #endif
280
281 #undef gettimeofday
282
283 typedef struct _GhostInfo
284   GhostInfo_;
285
286 extern MagickExport char
287   **NTArgvToUTF8(const int argc,wchar_t **);
288
289 extern MagickExport const GhostInfo_
290   *NTGhostscriptDLLVectors(void);
291
292 extern MagickExport int
293   NTGhostscriptUnLoadDLL(void);
294
295 extern MagickExport void
296   NTErrorHandler(const ExceptionType,const char *,const char *),
297   NTWarningHandler(const ExceptionType,const char *,const char *);
298 #endif
299
300 #if defined(__cplusplus) || defined(c_plusplus)
301 }
302 #endif
303
304 #endif