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