MagickCore  6.9.12-38
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 #if !defined(_CRT_SECURE_NO_DEPRECATE)
33 # define _CRT_SECURE_NO_DEPRECATE 1
34 #endif
35 #include <windows.h>
36 #include <wchar.h>
37 #include <winuser.h>
38 #include <wingdi.h>
39 #include <io.h>
40 #include <process.h>
41 #include <errno.h>
42 #include <malloc.h>
43 #include <sys/utime.h>
44 #if defined(_DEBUG) && !defined(__MINGW32__)
45 #include <crtdbg.h>
46 #endif
47 
48 #define PROT_READ 0x01
49 #define PROT_WRITE 0x02
50 #define MAP_SHARED 0x01
51 #define MAP_PRIVATE 0x02
52 #define MAP_ANONYMOUS 0x20
53 #define F_OK 0
54 #define R_OK 4
55 #define W_OK 2
56 #define RW_OK 6
57 #define _SC_PAGE_SIZE 1
58 #define _SC_PHYS_PAGES 2
59 #define _SC_OPEN_MAX 3
60 #if !defined(SSIZE_MAX)
61 # ifdef _WIN64
62 # define SSIZE_MAX LLONG_MAX
63 # else
64 # define SSIZE_MAX LONG_MAX
65 # endif
66 #endif
67 #ifndef S_ISCHR
68 # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
69 #endif
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(freelocale)
100 # define freelocale _free_locale
101 #endif
102 #if !defined(fseek) && !defined(__MINGW32__)
103 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
104  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
105  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
106 # define fseek _fseeki64
107 #endif
108 #endif
109 #if !defined(fstat) && !defined(__BORLANDC__)
110 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
111  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
112  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
113 # define fstat _fstati64
114 #else
115 # define fstat _fstat
116 #endif
117 #endif
118 #if !defined(fsync)
119 # define fsync _commit
120 #endif
121 #if !defined(ftell) && !defined(__MINGW32__)
122 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
123  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
124  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
125 # define ftell _ftelli64
126 #endif
127 #endif
128 #if !defined(ftruncate)
129 # define ftruncate(file,length) NTTruncateFile(file,length)
130 #endif
131 #if !defined(getcwd)
132 # define getcwd _getcwd
133 #endif
134 #if !defined(getpid)
135 # define getpid _getpid
136 #endif
137 #if !defined(hypot)
138 # define hypot _hypot
139 #endif
140 #if !defined(inline)
141 # define inline __inline
142 #endif
143 #if !defined(isatty)
144 # define isatty _isatty
145 #endif
146 #if !defined(locale_t)
147 #define locale_t _locale_t
148 #endif
149 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
150  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
151  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
152 #if !defined(lseek)
153 # define lseek _lseeki64
154 #endif
155 #else
156 #if !defined(lseek)
157 # define lseek _lseek
158 #endif
159 #endif
160 #if !defined(MAGICKCORE_LTDL_DELEGATE)
161 #if !defined(lt_dlclose)
162 # define lt_dlclose(handle) NTCloseLibrary(handle)
163 #endif
164 #if !defined(lt_dlerror)
165 # define lt_dlerror() NTGetLibraryError()
166 #endif
167 #if !defined(lt_dlexit)
168 # define lt_dlexit() NTExitLibrary()
169 #endif
170 #if !defined(lt_dlinit)
171 # define lt_dlinit() NTInitializeLibrary()
172 #endif
173 #if !defined(lt_dlopen)
174 # define lt_dlopen(filename) NTOpenLibrary(filename)
175 #endif
176 #if !defined(lt_dlsetsearchpath)
177 # define lt_dlsetsearchpath(path) NTSetSearchPath(path)
178 #endif
179 #if !defined(lt_dlsym)
180 # define lt_dlsym(handle,name) NTGetLibrarySymbol(handle,name)
181 #endif
182 #endif
183 #if !defined(mkdir)
184 # define mkdir _mkdir
185 #endif
186 #if !defined(mmap)
187 # define MAGICKCORE_HAVE_MMAP 1
188 # define mmap(address,length,protection,access,file,offset) \
189  NTMapMemory(address,length,protection,access,file,offset)
190 #endif
191 #if !defined(munmap)
192 # define munmap(address,length) NTUnmapMemory(address,length)
193 #endif
194 #if !defined(opendir)
195 # define opendir(directory) NTOpenDirectory(directory)
196 #endif
197 #if !defined(open)
198 # define open _open
199 #endif
200 #if !defined(pclose)
201 # define pclose _pclose
202 #endif
203 #if !defined(popen)
204 # define popen _popen
205 #endif
206 #if !defined(putenv)
207 # define putenv _putenv
208 #endif
209 #if !defined(fprintf_l)
210 #define fprintf_l _fprintf_s_l
211 #endif
212 #if !defined(read)
213 # define read(fd,buffer,count) _read(fd,buffer,(unsigned int) count)
214 #endif
215 #if !defined(readdir)
216 # define readdir(directory) NTReadDirectory(directory)
217 #endif
218 #if !defined(setmode)
219 # define setmode _setmode
220 #endif
221 #if !defined(spawnvp)
222 # define spawnvp _spawnvp
223 #endif
224 #if !defined(strtod_l)
225 #define strtod_l _strtod_l
226 #endif
227 #if !defined(stat) && !defined(__BORLANDC__)
228 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
229  !(defined(_MSC_VER) && (_MSC_VER < 1400)) && \
230  !(defined(__MSVCRT_VERSION__) && (__MSVCRT_VERSION__ < 0x800))
231 # define stat _stati64
232 #else
233 # define stat _stat
234 #endif
235 #endif
236 #if !defined(strcasecmp)
237 # define strcasecmp _stricmp
238 #endif
239 #if !defined(strncasecmp)
240 # define strncasecmp _strnicmp
241 #endif
242 #if !defined(sysconf)
243 # define sysconf(name) NTSystemConfiguration(name)
244 # define MAGICKCORE_HAVE_SYSCONF 1
245 #endif
246 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
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) && \
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:270
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:1458
memory-private.h
image-private.h
DirectoryListSeparator
#define DirectoryListSeparator
Definition: studio.h:271
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:821
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: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: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:1162
utility-private.h
IsPathAccessible
MagickExport MagickBooleanType IsPathAccessible(const char *path)
Definition: utility.c:1489
studio.h
MAGICKCORE_PACKAGE_NAME
#define MAGICKCORE_PACKAGE_NAME
Definition: magick-baseconfig.h:1284
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:1163
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:764
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:1374
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:126
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:135
MagickPathExtent
#define MagickPathExtent
Definition: magick-type.h:31