MagickCore  6.9.11-60
Convert, Edit, Or Compose Bitmap Images
nt-base.h
Go to the documentation of this file.
1 /*
2  Copyright 1999-2021 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 # ifdef _WIN64
60 # define SSIZE_MAX LLONG_MAX
61 # else
62 # define SSIZE_MAX LONG_MAX
63 # endif
64 #endif
65 
66 /*
67  _MSC_VER values:
68  1100 MSVC 5.0
69  1200 MSVC 6.0
70  1300 MSVC 7.0 Visual C++ .NET 2002
71  1310 Visual c++ .NET 2003
72  1400 Visual C++ 2005
73  1500 Visual C++ 2008
74  1600 Visual C++ 2010
75  1700 Visual C++ 2012
76  1800 Visual C++ 2013
77  1900 Visual C++ 2015
78 */
79 
80 #if !defined(chsize)
81 # if defined(__BORLANDC__)
82 # define chsize(file,length) chsize(file,length)
83 # else
84 # define chsize(file,length) _chsize(file,length)
85 # endif
86 #endif
87 
88 #if !defined(access)
89 #if defined(_VISUALC_) && (_MSC_VER >= 1400)
90 # define access(path,mode) _access_s(path,mode)
91 #endif
92 #endif
93 #if !defined(chdir)
94 # define chdir _chdir
95 #endif
96 #if !defined(close)
97 # define close _close
98 #endif
99 #if !defined(closedir)
100 # define closedir(directory) NTCloseDirectory(directory)
101 #endif
102 #if !defined(fdopen)
103 # define fdopen _fdopen
104 #endif
105 #if !defined(fileno)
106 # define fileno _fileno
107 #endif
108 #if !defined(freelocale)
109 # define freelocale _free_locale
110 #endif
111 #if !defined(fseek) && !defined(__MINGW32__)
112 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
113  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
114  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
115 # define fseek _fseeki64
116 #endif
117 #endif
118 #if !defined(fstat) && !defined(__BORLANDC__)
119 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
120  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
121  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
122 # define fstat _fstati64
123 #else
124 # define fstat _fstat
125 #endif
126 #endif
127 #if !defined(fsync)
128 # define fsync _commit
129 #endif
130 #if !defined(ftell) && !defined(__MINGW32__)
131 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
132  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
133  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
134 # define ftell _ftelli64
135 #endif
136 #endif
137 #if !defined(ftruncate)
138 # define ftruncate(file,length) NTTruncateFile(file,length)
139 #endif
140 #if !defined(getcwd)
141 # define getcwd _getcwd
142 #endif
143 #if !defined(getpid)
144 # define getpid _getpid
145 #endif
146 #if !defined(hypot)
147 # define hypot _hypot
148 #endif
149 #if !defined(inline)
150 # define inline __inline
151 #endif
152 #if !defined(isatty)
153 # define isatty _isatty
154 #endif
155 #if !defined(locale_t)
156 #define locale_t _locale_t
157 #endif
158 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
159  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
160  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
161 #if !defined(lseek)
162 # define lseek _lseeki64
163 #endif
164 #else
165 #if !defined(lseek)
166 # define lseek _lseek
167 #endif
168 #endif
169 #if !defined(MAGICKCORE_LTDL_DELEGATE)
170 #if !defined(lt_dlclose)
171 # define lt_dlclose(handle) NTCloseLibrary(handle)
172 #endif
173 #if !defined(lt_dlerror)
174 # define lt_dlerror() NTGetLibraryError()
175 #endif
176 #if !defined(lt_dlexit)
177 # define lt_dlexit() NTExitLibrary()
178 #endif
179 #if !defined(lt_dlinit)
180 # define lt_dlinit() NTInitializeLibrary()
181 #endif
182 #if !defined(lt_dlopen)
183 # define lt_dlopen(filename) NTOpenLibrary(filename)
184 #endif
185 #if !defined(lt_dlsetsearchpath)
186 # define lt_dlsetsearchpath(path) NTSetSearchPath(path)
187 #endif
188 #if !defined(lt_dlsym)
189 # define lt_dlsym(handle,name) NTGetLibrarySymbol(handle,name)
190 #endif
191 #endif
192 #if !defined(mkdir)
193 # define mkdir _mkdir
194 #endif
195 #if !defined(mmap)
196 # define mmap(address,length,protection,access,file,offset) \
197  NTMapMemory(address,length,protection,access,file,offset)
198 #endif
199 #if !defined(munmap)
200 # define munmap(address,length) NTUnmapMemory(address,length)
201 #endif
202 #if !defined(opendir)
203 # define opendir(directory) NTOpenDirectory(directory)
204 #endif
205 #if !defined(open)
206 # define open _open
207 #endif
208 #if !defined(pclose)
209 # define pclose _pclose
210 #endif
211 #if !defined(popen)
212 # define popen _popen
213 #endif
214 #if !defined(fprintf_l)
215 #define fprintf_l _fprintf_s_l
216 #endif
217 #if !defined(read)
218 # define read(fd,buffer,count) _read(fd,buffer,(unsigned int) count)
219 #endif
220 #if !defined(readdir)
221 # define readdir(directory) NTReadDirectory(directory)
222 #endif
223 #if !defined(setmode)
224 # define setmode _setmode
225 #endif
226 #if !defined(spawnvp)
227 # define spawnvp _spawnvp
228 #endif
229 #if !defined(strtod_l)
230 #define strtod_l _strtod_l
231 #endif
232 #if !defined(stat) && !defined(__BORLANDC__)
233 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
234  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
235  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
236 # define stat _stati64
237 #else
238 # define stat _stat
239 #endif
240 #endif
241 #if !defined(strcasecmp)
242 # define strcasecmp _stricmp
243 #endif
244 #if !defined(strncasecmp)
245 # define strncasecmp _strnicmp
246 #endif
247 #if !defined(sysconf)
248 # define sysconf(name) NTSystemConfiguration(name)
249 #endif
250 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
251  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
252  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
253 # define tell _telli64
254 #else
255 # define tell _tell
256 #endif
257 #if !defined(tempnam)
258 # define tempnam _tempnam_s
259 #endif
260 #if !defined(tolower_l)
261 #define tolower_l _tolower_l
262 #endif
263 #if !defined(toupper_l)
264 #define toupper_l _toupper_l
265 #endif
266 #if !defined(umask)
267 # define umask _umask
268 #endif
269 #if !defined(unlink)
270 # define unlink _unlink
271 #endif
272 #if !defined(utime)
273 # define utime _utime
274 #endif
275 #if !defined(vfprintf_l)
276 #define vfprintf_l _vfprintf_l
277 #endif
278 #if !defined(vsnprintf)
279 #if !defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1500)
280 #define vsnprintf _vsnprintf
281 #endif
282 #endif
283 #if !defined(vsnprintf_l)
284 #define vsnprintf_l _vsnprintf_l
285 #endif
286 #if !defined(write)
287 # define write(fd,buffer,count) _write(fd,buffer,(unsigned int) count)
288 #endif
289 #if !defined(wstat) && !defined(__BORLANDC__)
290 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
291  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
292  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
293 # define wstat _wstati64
294 #else
295 # define wstat _wstat
296 #endif
297 #endif
298 
299 #if defined(__BORLANDC__)
300 #undef _O_RANDOM
301 #define _O_RANDOM 0
302 #undef _O_SEQUENTIAL
303 #define _O_SEQUENTIAL 0
304 #undef _O_SHORT_LIVED
305 #define _O_SHORT_LIVED 0
306 #undef _O_TEMPORARY
307 #define _O_TEMPORARY 0
308 #endif
309 
310 #undef gettimeofday
311 
312 typedef struct _GhostInfo
313  GhostInfo_;
314 
315 extern MagickExport char
316  **NTArgvToUTF8(const int argc,wchar_t **);
317 
318 extern MagickExport const GhostInfo_
319  *NTGhostscriptDLLVectors(void);
320 
321 extern MagickExport int
322  NTGhostscriptUnLoadDLL(void);
323 
324 extern MagickExport void
325  NTErrorHandler(const ExceptionType,const char *,const char *),
326  NTWarningHandler(const ExceptionType,const char *,const char *);
327 
328 #endif
329 
330 #if defined(__cplusplus) || defined(c_plusplus)
331 }
332 #endif
333 
334 #endif
DirectorySeparator
#define DirectorySeparator
Definition: studio.h:274
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:28
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:1447
memory-private.h
image-private.h
DirectoryListSeparator
#define DirectoryListSeparator
Definition: studio.h:275
resource_.h
utility.h
_GhostInfo
Definition: delegate-private.h:55
AsynchronousResourceComponentTerminus
MagickExport void AsynchronousResourceComponentTerminus(void)
Definition: resource.c:466
version.h
string_.h
DestroyString
MagickExport char * DestroyString(char *string)
Definition: string.c:808
GetPathComponent
MagickExport void GetPathComponent(const char *path, PathType type, char *component)
Definition: utility.c:1218
MagickTrue
@ MagickTrue
Definition: magick-type.h:205
TraceEvent
@ TraceEvent
Definition: log.h:38
AcquireMagickMemory
MagickExport void * AcquireMagickMemory(const size_t size)
Definition: memory.c:552
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:425
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:204
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:203
RelinquishMagickMemory
MagickExport void * RelinquishMagickMemory(void *memory)
Definition: memory.c:1162
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:1246
AcquireCriticalMemory
MagickExport void * AcquireCriticalMemory(const size_t size)
Definition: memory.c:626
MAGICKCORE_QUANTUM_DEPTH
#define MAGICKCORE_QUANTUM_DEPTH
Definition: magick-type.h:28
memory_.h
MagickDLLCall
#define MagickDLLCall
Definition: delegate-private.h:50
GetEnvironmentValue
MagickExport char * GetEnvironmentValue(const char *name)
Definition: string.c:1150
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:751
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:1230
MagickCoreTerminus
MagickExport void MagickCoreTerminus(void)
Definition: magick.c:1369
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:42
MagickMin
#define MagickMin(x, y)
Definition: image-private.h:37
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:665
MagickOffsetType
ssize_t MagickOffsetType
Definition: magick-type.h:139
MagickPathExtent
#define MagickPathExtent
Definition: magick-type.h:31