MagickCore  6.9.12-67
Convert, Edit, Or Compose Bitmap Images
 All Data Structures
studio.h
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 private application programming interface declarations.
17 */
18 #ifndef MAGICKCORE_STUDIO_H
19 #define MAGICKCORE_STUDIO_H
20 
21 #if defined(__cplusplus) || defined(c_plusplus)
22 extern "C" {
23 #endif
24 
25 #if defined(WIN32) || defined(WIN64)
26 # define MAGICKCORE_WINDOWS_SUPPORT
27 #else
28 # define MAGICKCORE_POSIX_SUPPORT
29 #endif
30 
31 #define MAGICKCORE_IMPLEMENTATION 1
32 
33 #if !defined(MAGICKCORE_CONFIG_H)
34 # define MAGICKCORE_CONFIG_H
35 # if !defined(vms) && !defined(macintosh)
36 # include "magick/magick-config.h"
37 # else
38 # include "magick-config.h"
39 # endif
40 #if defined(MAGICKCORE__FILE_OFFSET_BITS) && !defined(_FILE_OFFSET_BITS)
41 # define _FILE_OFFSET_BITS MAGICKCORE__FILE_OFFSET_BITS
42 #endif
43 #if defined(_magickcore_const) && !defined(const)
44 # define const _magickcore_const
45 #endif
46 #if defined(_magickcore_inline) && !defined(inline)
47 # define inline _magickcore_inline
48 #endif
49 # if defined(__cplusplus) || defined(c_plusplus)
50 # undef inline
51 # endif
52 #endif
53 
54 #if defined(MAGICKCORE_NAMESPACE_PREFIX)
55 # include "magick/methods.h"
56 #endif
57 
58 #if !defined(const)
59 # define STDC
60 #endif
61 
62 /* Define to 1 if assertions should be disabled. */
63 #if defined(MAGICKCORE_NDEBUG)
64 #define NDEBUG 1
65 #endif
66 
67 #include <stdarg.h>
68 #include <stdio.h>
69 #if defined(MAGICKCORE_HAVE_SYS_STAT_H)
70 # include <sys/stat.h>
71 #endif
72 #if defined(MAGICKCORE_STDC_HEADERS)
73 # include <stdlib.h>
74 # include <stddef.h>
75 #else
76 # if defined(MAGICKCORE_HAVE_STDLIB_H)
77 # include <stdlib.h>
78 # endif
79 #endif
80 #if !defined(magick_restrict)
81 # if !defined(_magickcore_restrict)
82 # define magick_restrict restrict
83 # else
84 # define magick_restrict _magickcore_restrict
85 # endif
86 #endif
87 #if defined(MAGICKCORE_HAVE_STRING_H)
88 # if !defined(STDC_HEADERS) && defined(MAGICKCORE_HAVE_MEMORY_H)
89 # include <memory.h>
90 # endif
91 # include <string.h>
92 #endif
93 #if defined(MAGICKCORE_HAVE_STRINGS_H)
94 # include <strings.h>
95 #endif
96 #if defined(MAGICKCORE_HAVE_INTTYPES_H)
97 # include <inttypes.h>
98 #endif
99 #if defined(MAGICKCORE_HAVE_STDINT_H)
100 # include <stdint.h>
101 #endif
102 #if defined(MAGICKCORE_HAVE_UNISTD_H)
103 # include <unistd.h>
104 #endif
105 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && defined(_DEBUG)
106 #define _CRTDBG_MAP_ALLOC
107 #endif
108 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
109 # include <io.h>
110 #if !defined(__CYGWIN__)
111 # include <direct.h>
112 #endif
113 # if !defined(MAGICKCORE_HAVE_STRERROR)
114 # define HAVE_STRERROR
115 # endif
116 #endif
117 
118 #include <ctype.h>
119 #include <locale.h>
120 #include <errno.h>
121 #include <fcntl.h>
122 #include <math.h>
123 #include <time.h>
124 #include <limits.h>
125 #include <signal.h>
126 #include <assert.h>
127 
128 #if defined(MAGICKCORE_HAVE_XLOCALE_H)
129 # include <xlocale.h>
130 #endif
131 #if defined(MAGICKCORE_THREAD_SUPPORT)
132 # include <pthread.h>
133 #endif
134 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
135 #if !defined(__CYGWIN__)
136 #include <winsock2.h>
137 #include <ws2tcpip.h>
138 #endif
139 #include <windows.h>
140 #ifdef _MSC_VER
141 #pragma comment (lib, "ws2_32.lib")
142 #endif
143 #endif
144 #if defined(MAGICKCORE_HAVE_SYS_SYSLIMITS_H)
145 # include <sys/syslimits.h>
146 #endif
147 #if defined(MAGICKCORE_HAVE_ARM_LIMITS_H)
148 # include <arm/limits.h>
149 #endif
150 
151 #if defined(MAGICKCORE_HAVE_CL_CL_H) && !defined(MAGICK_PIXEL_RGBA)
152 # include <CL/cl.h>
153 # define MAGICKCORE_OPENCL_SUPPORT 1
154 #endif
155 #if defined(MAGICKCORE_HAVE_OPENCL_CL_H) && !defined(MAGICK_PIXEL_RGBA)
156 # include <OpenCL/cl.h>
157 # define MAGICKCORE_OPENCL_SUPPORT 1
158 #endif
159 
160 #if defined(_OPENMP) && ((_OPENMP >= 200203) || defined(__OPENCC__))
161 # include <omp.h>
162 # define MAGICKCORE_OPENMP_SUPPORT 1
163 #endif
164 
165 #if defined(MAGICKCORE_HAVE_PREAD) && defined(MAGICKCORE_HAVE_DECL_PREAD) && !MAGICKCORE_HAVE_DECL_PREAD
166 ssize_t pread(int,void *,size_t,off_t);
167 #endif
168 
169 #if defined(MAGICKCORE_HAVE_PWRITE) && defined(MAGICKCORE_HAVE_DECL_PWRITE) && !MAGICKCORE_HAVE_DECL_PWRITE
170 ssize_t pwrite(int,const void *,size_t,off_t);
171 #endif
172 
173 #if defined(MAGICKCORE_HAVE_STRLCPY) && defined(MAGICKCORE_HAVE_DECL_STRLCPY) && !MAGICKCORE_HAVE_DECL_STRLCPY
174 extern size_t strlcpy(char *,const char *,size_t);
175 #endif
176 
177 #if defined(MAGICKCORE_HAVE_VSNPRINTF) && defined(MAGICKCORE_HAVE_DECL_VSNPRINTF) && !MAGICKCORE_HAVE_DECL_VSNPRINTF
178 extern int vsnprintf(char *,size_t,const char *,va_list);
179 #endif
180 
181 #include "magick/method-attribute.h"
182 
183 #if defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(MAGICKCORE_POSIX_SUPPORT)
184 # include <sys/types.h>
185 # include <sys/stat.h>
186 # if defined(MAGICKCORE_POSIX_SUPPORT)
187 # if defined(MAGICKCORE_HAVE_SYS_NDIR_H) || defined(MAGICKCORE_HAVE_SYS_DIR_H) || defined(MAGICKCORE_HAVE_NDIR_H)
188 # define dirent direct
189 # define NAMLEN(dirent) (dirent)->d_namlen
190 # if defined(MAGICKCORE_HAVE_SYS_NDIR_H)
191 # include <sys/ndir.h>
192 # endif
193 # if defined(MAGICKCORE_HAVE_SYS_DIR_H)
194 # include <sys/dir.h>
195 # endif
196 # if defined(MAGICKCORE_HAVE_NDIR_H)
197 # include <ndir.h>
198 # endif
199 # else
200 # include <dirent.h>
201 # define NAMLEN(dirent) strlen((dirent)->d_name)
202 # endif
203 # include <sys/wait.h>
204 # include <pwd.h>
205 # endif
206 # if !defined(S_ISDIR)
207 # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
208 # endif
209 # if !defined(S_ISREG)
210 # define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
211 # endif
212 # include "magick/magick-type.h"
213 # if !defined(MAGICKCORE_WINDOWS_SUPPORT)
214 # include <sys/time.h>
215 # if defined(MAGICKCORE_HAVE_SYS_TIMES_H)
216 # include <sys/times.h>
217 # endif
218 # if defined(MAGICKCORE_HAVE_SYS_RESOURCE_H)
219 # include <sys/resource.h>
220 # endif
221 # if defined(MAGICKCORE_HAVE_SYS_MMAN_H)
222 # include <sys/mman.h>
223 # endif
224 # if defined(MAGICKCORE_HAVE_SYS_SENDFILE_H)
225 # include <sys/sendfile.h>
226 # endif
227 # if defined(MAGICKCORE_HAVE_SYS_SOCKET_H)
228 # include <sys/socket.h>
229 # endif
230 # if defined(MAGICKCORE_HAVE_SYS_UIO_H)
231 # include <sys/uio.h>
232 # endif
233 #endif
234 #else
235 # include <types.h>
236 # include <stat.h>
237 # if defined(macintosh)
238 # if !defined(DISABLE_SIOUX)
239 # include <SIOUX.h>
240 # include <console.h>
241 # endif
242 # include <unix.h>
243 # endif
244 # include "magick/magick-type.h"
245 #endif
246 
247 #if defined(S_IRUSR) && defined(S_IWUSR)
248 # define S_MODE (S_IRUSR | S_IWUSR)
249 #elif defined (MAGICKCORE_WINDOWS_SUPPORT)
250 # define S_MODE (_S_IREAD | _S_IWRITE)
251 #else
252 # define S_MODE 0600
253 #endif
254 
255 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
256 # include "magick/nt-base.h"
257 #endif
258 #if defined(macintosh)
259 # include "magick/mac.h"
260 #endif
261 #if defined(vms)
262 # include "magick/vms.h"
263 #endif
264 
265 #undef HAVE_CONFIG_H
266 #undef gamma
267 #undef index
268 #undef pipe
269 #undef y1
270 
271 /*
272  Review these platform specific definitions.
273 */
274 #if ( defined(MAGICKCORE_POSIX_SUPPORT) && !defined(__OS2__) ) && !defined( __VMS )
275 # define DirectorySeparator "/"
276 # define DirectoryListSeparator ':'
277 # define EditorOptions " -title \"Edit Image Comment\" -e vi"
278 # define Exit exit
279 # define IsBasenameSeparator(c) ((c) == '/' ? MagickTrue : MagickFalse)
280 # define X11_PREFERENCES_PATH "~/."
281 # define ProcessPendingEvents(text)
282 # define ReadCommandlLine(argc,argv)
283 # define SetNotifyHandlers
284 #else
285 # if defined(vms)
286 # define X11_APPLICATION_PATH "decw$system_defaults:"
287 # define DirectorySeparator ""
288 # define DirectoryListSeparator ';'
289 # define EditorOptions ""
290 # define Exit exit
291 # define IsBasenameSeparator(c) \
292  (((c) == ']') || ((c) == ':') || ((c) == '/') ? MagickTrue : MagickFalse)
293 # define MAGICKCORE_LIBRARY_PATH "sys$login:"
294 # define MAGICKCORE_SHARE_PATH "sys$login:"
295 # define X11_PREFERENCES_PATH "decw$user_defaults:"
296 # define ProcessPendingEvents(text)
297 # define ReadCommandlLine(argc,argv)
298 # define SetNotifyHandlers
299 # endif
300 # if defined(__OS2__)
301 # define DirectorySeparator "\\"
302 # define DirectoryListSeparator ';'
303 # define EditorOptions " -title \"Edit Image Comment\" -e vi"
304 # define Exit exit
305 # define IsBasenameSeparator(c) \
306  (((c) == '/') || ((c) == '\\') ? MagickTrue : MagickFalse)
307 # define PreferencesDefaults "~\."
308 # define ProcessPendingEvents(text)
309 # define ReadCommandlLine(argc,argv)
310 # define SetNotifyHandlers
311 #endif
312 # if defined(macintosh)
313 # define X11_APPLICATION_PATH "/usr/lib/X11/app-defaults/"
314 # define DirectorySeparator ":"
315 # define DirectoryListSeparator ';'
316 # define EditorOptions ""
317 # define IsBasenameSeparator(c) ((c) == ':' ? MagickTrue : MagickFalse)
318 # define MAGICKCORE_LIBRARY_PATH ""
319 # define MAGICKCORE_SHARE_PATH ""
320 # define X11_PREFERENCES_PATH "~/."
321 # if defined(DISABLE_SIOUX)
322 # define ReadCommandlLine(argc,argv)
323 # define SetNotifyHandlers \
324  SetFatalErrorHandler(MacFatalErrorHandler); \
325  SetErrorHandler(MACErrorHandler); \
326  SetWarningHandler(MACWarningHandler)
327 # else
328 # define ReadCommandlLine(argc,argv) argc=ccommand(argv); puts(MagickVersion);
329 # define SetNotifyHandlers \
330  SetErrorHandler(MACErrorHandler); \
331  SetWarningHandler(MACWarningHandler)
332 # endif
333 # endif
334 # if defined(MAGICKCORE_WINDOWS_SUPPORT)
335 # define DirectorySeparator "\\"
336 # define DirectoryListSeparator ';'
337 # define EditorOptions ""
338 # define IsBasenameSeparator(c) \
339  (((c) == '/') || ((c) == '\\') ? MagickTrue : MagickFalse)
340 # define ProcessPendingEvents(text)
341 # if !defined(X11_PREFERENCES_PATH)
342 # define X11_PREFERENCES_PATH "~\\."
343 # endif
344 # define ReadCommandlLine(argc,argv)
345 # define SetNotifyHandlers \
346  SetErrorHandler(NTErrorHandler); \
347  SetWarningHandler(NTWarningHandler)
348 # if !defined(MAGICKCORE_HAVE_TIFFCONF_H)
349 # define HAVE_TIFFCONF_H
350 # endif
351 # endif
352 
353 #endif
354 
355 /*
356  Define system symbols if not already defined.
357 */
358 #if !defined(STDIN_FILENO)
359 #define STDIN_FILENO 0x00
360 #endif
361 
362 #if !defined(O_BINARY)
363 #define O_BINARY 0x00
364 #endif
365 
366 #if !defined(PATH_MAX)
367 #define PATH_MAX 4096
368 #endif
369 
370 #if defined(MAGICKCORE_LTDL_DELEGATE) || (defined(MAGICKCORE_WINDOWS_SUPPORT) && defined(_DLL) && !defined(_LIB))
371 # define MAGICKCORE_MODULES_SUPPORT
372 #endif
373 
374 #if defined(_MAGICKMOD_)
375 # undef MAGICKCORE_BUILD_MODULES
376 # define MAGICKCORE_BUILD_MODULES
377 #endif
378 
379 /*
380  Magick defines.
381 */
382 #define MagickMaxRecursionDepth 600
383 #define MAGICK_SSIZE_MAX (SSIZE_MAX)
384 #define MAGICK_SSIZE_MIN (-(SSIZE_MAX)-1)
385 #define Swap(x,y) ((x)^=(y), (y)^=(x), (x)^=(y))
386 #if defined(_MSC_VER)
387 # define DisableMSCWarning(nr) __pragma(warning(push)) \
388  __pragma(warning(disable:nr))
389 # define RestoreMSCWarning __pragma(warning(pop))
390 #else
391 # define DisableMSCWarning(nr)
392 # define RestoreMSCWarning
393 #endif
394 
395 #if defined(__cplusplus) || defined(c_plusplus)
396 }
397 #endif
398 
399 #endif