MagickCore  6.9.11
Convert, Edit, Or Compose Bitmap Images
nt-base.h
Go to the documentation of this file.
1 /*
2  Copyright 1999-2020 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. You may
6  obtain a copy of the License at
7 
8  https://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 "magick/exception.h"
22 #include "magick/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 #include <sys/utime.h>
42 #if defined(_DEBUG) && !defined(__MINGW32__)
43 #include <crtdbg.h>
44 #endif
45 
46 #define PROT_READ 0x01
47 #define PROT_WRITE 0x02
48 #define MAP_SHARED 0x01
49 #define MAP_PRIVATE 0x02
50 #define MAP_ANONYMOUS 0x20
51 #define F_OK 0
52 #define R_OK 4
53 #define W_OK 2
54 #define RW_OK 6
55 #define _SC_PAGE_SIZE 1
56 #define _SC_PHYS_PAGES 2
57 #define _SC_OPEN_MAX 3
58 #if !defined(SSIZE_MAX)
59 #define SSIZE_MAX 0x7fffffffL
60 #endif
61 
62 /*
63  _MSC_VER values:
64  1100 MSVC 5.0
65  1200 MSVC 6.0
66  1300 MSVC 7.0 Visual C++ .NET 2002
67  1310 Visual c++ .NET 2003
68  1400 Visual C++ 2005
69  1500 Visual C++ 2008
70  1600 Visual C++ 2010
71  1700 Visual C++ 2012
72  1800 Visual C++ 2013
73  1900 Visual C++ 2015
74 */
75 
76 #if !defined(chsize)
77 # if defined(__BORLANDC__)
78 # define chsize(file,length) chsize(file,length)
79 # else
80 # define chsize(file,length) _chsize(file,length)
81 # endif
82 #endif
83 
84 #if !defined(access)
85 #if defined(_VISUALC_) && (_MSC_VER >= 1400)
86 # define access(path,mode) _access_s(path,mode)
87 #endif
88 #endif
89 #if !defined(chdir)
90 # define chdir _chdir
91 #endif
92 #if !defined(close)
93 # define close _close
94 #endif
95 #if !defined(closedir)
96 # define closedir(directory) NTCloseDirectory(directory)
97 #endif
98 #if !defined(fdopen)
99 # define fdopen _fdopen
100 #endif
101 #if !defined(fileno)
102 # define fileno _fileno
103 #endif
104 #if !defined(freelocale)
105 # define freelocale _free_locale
106 #endif
107 #if !defined(fseek) && !defined(__MINGW32__)
108 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
109  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
110  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
111 # define fseek _fseeki64
112 #endif
113 #endif
114 #if !defined(fstat) && !defined(__BORLANDC__)
115 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
116  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
117  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
118 # define fstat _fstati64
119 #else
120 # define fstat _fstat
121 #endif
122 #endif
123 #if !defined(fsync)
124 # define fsync _commit
125 #endif
126 #if !defined(ftell) && !defined(__MINGW32__)
127 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
128  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
129  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
130 # define ftell _ftelli64
131 #endif
132 #endif
133 #if !defined(ftruncate)
134 # define ftruncate(file,length) NTTruncateFile(file,length)
135 #endif
136 #if !defined(getcwd)
137 # define getcwd _getcwd
138 #endif
139 #if !defined(getpid)
140 # define getpid _getpid
141 #endif
142 #if !defined(hypot)
143 # define hypot _hypot
144 #endif
145 #if !defined(inline)
146 # define inline __inline
147 #endif
148 #if !defined(isatty)
149 # define isatty _isatty
150 #endif
151 #if !defined(locale_t)
152 #define locale_t _locale_t
153 #endif
154 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
155  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
156  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
157 #if !defined(lseek)
158 # define lseek _lseeki64
159 #endif
160 #else
161 #if !defined(lseek)
162 # define lseek _lseek
163 #endif
164 #endif
165 #if !defined(MAGICKCORE_LTDL_DELEGATE)
166 #if !defined(lt_dlclose)
167 # define lt_dlclose(handle) NTCloseLibrary(handle)
168 #endif
169 #if !defined(lt_dlerror)
170 # define lt_dlerror() NTGetLibraryError()
171 #endif
172 #if !defined(lt_dlexit)
173 # define lt_dlexit() NTExitLibrary()
174 #endif
175 #if !defined(lt_dlinit)
176 # define lt_dlinit() NTInitializeLibrary()
177 #endif
178 #if !defined(lt_dlopen)
179 # define lt_dlopen(filename) NTOpenLibrary(filename)
180 #endif
181 #if !defined(lt_dlsetsearchpath)
182 # define lt_dlsetsearchpath(path) NTSetSearchPath(path)
183 #endif
184 #if !defined(lt_dlsym)
185 # define lt_dlsym(handle,name) NTGetLibrarySymbol(handle,name)
186 #endif
187 #endif
188 #if !defined(mkdir)
189 # define mkdir _mkdir
190 #endif
191 #if !defined(mmap)
192 # define mmap(address,length,protection,access,file,offset) \
193  NTMapMemory(address,length,protection,access,file,offset)
194 #endif
195 #if !defined(munmap)
196 # define munmap(address,length) NTUnmapMemory(address,length)
197 #endif
198 #if !defined(opendir)
199 # define opendir(directory) NTOpenDirectory(directory)
200 #endif
201 #if !defined(open)
202 # define open _open
203 #endif
204 #if !defined(pclose)
205 # define pclose _pclose
206 #endif
207 #if !defined(popen)
208 # define popen _popen
209 #endif
210 #if !defined(fprintf_l)
211 #define fprintf_l _fprintf_s_l
212 #endif
213 #if !defined(read)
214 # define read(fd,buffer,count) _read(fd,buffer,(unsigned int) count)
215 #endif
216 #if !defined(readdir)
217 # define readdir(directory) NTReadDirectory(directory)
218 #endif
219 #if !defined(setmode)
220 # define setmode _setmode
221 #endif
222 #if !defined(spawnvp)
223 # define spawnvp _spawnvp
224 #endif
225 #if !defined(strtod_l)
226 #define strtod_l _strtod_l
227 #endif
228 #if !defined(stat) && !defined(__BORLANDC__)
229 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
230  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
231  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
232 # define stat _stati64
233 #else
234 # define stat _stat
235 #endif
236 #endif
237 #if !defined(strcasecmp)
238 # define strcasecmp _stricmp
239 #endif
240 #if !defined(strncasecmp)
241 # define strncasecmp _strnicmp
242 #endif
243 #if !defined(sysconf)
244 # define sysconf(name) NTSystemConfiguration(name)
245 #endif
246 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
247  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
248  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
249 # define tell _telli64
250 #else
251 # define tell _tell
252 #endif
253 #if !defined(tempnam)
254 # define tempnam _tempnam_s
255 #endif
256 #if !defined(tolower_l)
257 #define tolower_l _tolower_l
258 #endif
259 #if !defined(toupper_l)
260 #define toupper_l _toupper_l
261 #endif
262 #if !defined(umask)
263 # define umask _umask
264 #endif
265 #if !defined(unlink)
266 # define unlink _unlink
267 #endif
268 #if !defined(utime)
269 # define utime _utime
270 #endif
271 #if !defined(vfprintf_l)
272 #define vfprintf_l _vfprintf_l
273 #endif
274 #if !defined(vsnprintf)
275 #if !defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1500)
276 #define vsnprintf _vsnprintf
277 #endif
278 #endif
279 #if !defined(vsnprintf_l)
280 #define vsnprintf_l _vsnprintf_l
281 #endif
282 #if !defined(write)
283 # define write(fd,buffer,count) _write(fd,buffer,(unsigned int) count)
284 #endif
285 #if !defined(wstat) && !defined(__BORLANDC__)
286 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
287  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
288  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
289 # define wstat _wstati64
290 #else
291 # define wstat _wstat
292 #endif
293 #endif
294 
295 #if defined(__BORLANDC__)
296 #undef _O_RANDOM
297 #define _O_RANDOM 0
298 #undef _O_SEQUENTIAL
299 #define _O_SEQUENTIAL 0
300 #undef _O_SHORT_LIVED
301 #define _O_SHORT_LIVED 0
302 #undef _O_TEMPORARY
303 #define _O_TEMPORARY 0
304 #endif
305 
306 #undef gettimeofday
307 
308 typedef struct _GhostInfo
309  GhostInfo_;
310 
311 extern MagickExport char
312  **NTArgvToUTF8(const int argc,wchar_t **);
313 
314 extern MagickExport const GhostInfo_
315  *NTGhostscriptDLLVectors(void);
316 
317 extern MagickExport int
318  NTGhostscriptUnLoadDLL(void);
319 
320 extern MagickExport void
321  NTErrorHandler(const ExceptionType,const char *,const char *),
322  NTWarningHandler(const ExceptionType,const char *,const char *);
323 
324 #endif
325 
326 #if defined(__cplusplus) || defined(c_plusplus)
327 }
328 #endif
329 
330 #endif
DirectorySeparator
#define DirectorySeparator
Definition: studio.h:266
LockSemaphoreInfo
MagickExport void LockSemaphoreInfo(SemaphoreInfo *semaphore_info)
Definition: semaphore.c:293
MagickExport
#define MagickExport
Definition: method-attribute.h:80
gsapi_revision_s
Definition: delegate-private.h:26
magick.h
magick_unreferenced
#define magick_unreferenced(x)
Definition: method-attribute.h:106
HeadPath
@ HeadPath
Definition: utility.h:30
_DIR
Definition: mac.h:42
GetMagickModule
#define GetMagickModule()
Definition: log.h:29
nt-base-private.h
geometry.h
FormatLocaleString
MagickExport ssize_t FormatLocaleString(char *magick_restrict string, const size_t length, const char *magick_restrict format,...)
Definition: locale.c:497
GetClientPath
MagickExport const char * GetClientPath(void)
Definition: client.c:88
ResizeQuantumMemory
MagickExport void * ResizeQuantumMemory(void *memory, const size_t count, const size_t quantum)
Definition: memory.c:1408
memory-private.h
DirectoryListSeparator
#define DirectoryListSeparator
Definition: studio.h:267
resource_.h
Exit
MagickExport int Exit(int)
utility.h
_GhostInfo
Definition: delegate-private.h:53
AsynchronousResourceComponentTerminus
MagickExport void AsynchronousResourceComponentTerminus(void)
Definition: resource.c:466
version.h
string_.h
DestroyString
MagickExport char * DestroyString(char *string)
Definition: string.c:810
GetPathComponent
MagickExport void GetPathComponent(const char *path, PathType type, char *component)
Definition: utility.c:1218
MagickTrue
@ MagickTrue
Definition: magick-type.h:201
TraceEvent
@ TraceEvent
Definition: log.h:38
AcquireMagickMemory
MagickExport void * AcquireMagickMemory(const size_t size)
Definition: memory.c:521
SemaphoreInfo
Definition: semaphore.c:61
ConcatenateMagickString
MagickExport size_t ConcatenateMagickString(char *magick_restrict destination, const char *magick_restrict source, const size_t length)
Definition: string.c:426
MagickPackageName
#define MagickPackageName
Definition: version.h:28
CacheFatalError
@ CacheFatalError
Definition: exception.h:87
GhostInfo
struct _GhostInfo GhostInfo
ConfigureEvent
@ ConfigureEvent
Definition: log.h:43
nt-base.h
timer.h
dirent
Definition: mac.h:54
LocaleCompare
MagickExport int LocaleCompare(const char *p, const char *q)
Definition: locale.c:1435
locale_.h
MagickPrivate
#define MagickPrivate
Definition: method-attribute.h:81
MagickFalse
@ MagickFalse
Definition: magick-type.h:200
IsEventLogging
MagickExport MagickBooleanType IsEventLogging(void)
Definition: log.c:725
GetExceptionMessage
MagickExport char * GetExceptionMessage(const int error)
Definition: exception.c:530
GetClientName
MagickExport const char * GetClientName(void)
Definition: client.c:65
ExceptionType
ExceptionType
Definition: exception.h:29
ActivateSemaphoreInfo
MagickExport void ActivateSemaphoreInfo(SemaphoreInfo **semaphore_info)
Definition: semaphore.c:98
DestroySemaphoreInfo
MagickExport void DestroySemaphoreInfo(SemaphoreInfo **semaphore_info)
Definition: semaphore.c:351
StringToInteger
static int StringToInteger(const char *magick_restrict value)
Definition: string-private.h:103
log.h
MagickBooleanType
MagickBooleanType
Definition: magick-type.h:199
RelinquishMagickMemory
MagickExport void * RelinquishMagickMemory(void *memory)
Definition: memory.c:1123
utility-private.h
IsPathAccessible
MagickExport MagickBooleanType IsPathAccessible(const char *path)
Definition: utility.c:1472
studio.h
MAGICKCORE_PACKAGE_NAME
#define MAGICKCORE_PACKAGE_NAME
Definition: magick-baseconfig.h:1226
AcquireCriticalMemory
MagickExport void * AcquireCriticalMemory(const size_t size)
Definition: memory.c:595
MAGICKCORE_QUANTUM_DEPTH
#define MAGICKCORE_QUANTUM_DEPTH
Definition: magick-type.h:28
memory_.h
MagickDLLCall
#define MagickDLLCall
Definition: delegate-private.h:48
GetEnvironmentValue
MagickExport char * GetEnvironmentValue(const char *name)
Definition: string.c:1152
exception-private.h
ThrowFatalException
#define ThrowFatalException(severity, tag)
Definition: exception-private.h:42
UnlockSemaphoreInfo
MagickExport void UnlockSemaphoreInfo(SemaphoreInfo *semaphore_info)
Definition: semaphore.c:449
exception.h
CopyMagickString
MagickExport size_t CopyMagickString(char *magick_restrict destination, const char *magick_restrict source, const size_t length)
Definition: string.c:753
LogMagickEvent
MagickExport MagickBooleanType LogMagickEvent(const LogEventType type, const char *module, const char *function, const size_t line, const char *format,...)
Definition: log.c:1420
MagickCoreGenesis
MagickExport void MagickCoreGenesis(const char *path, const MagickBooleanType establish_signal_handlers)
Definition: magick.c:1229
MagickCoreTerminus
MagickExport void MagickCoreTerminus(void)
Definition: magick.c:1368
MaxTextExtent
#define MaxTextExtent
Definition: method-attribute.h:89
string-private.h
module
const char * module
Definition: static.c:70
ResourceLimitFatalError
@ ResourceLimitFatalError
Definition: exception.h:78
AcquireString
MagickExport char * AcquireString(const char *source)
Definition: string.c:125
gs_main_instance
struct gs_main_instance_s gs_main_instance
Definition: delegate-private.h:40
client.h
MagickLibVersionText
#define MagickLibVersionText
Definition: version.h:31
MAP_FAILED
#define MAP_FAILED
Definition: blob.c:89
AcquireQuantumMemory
MagickExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
Definition: memory.c:634
MagickOffsetType
ssize_t MagickOffsetType
Definition: magick-type.h:135
MagickPathExtent
#define MagickPathExtent
Definition: magick-type.h:31