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