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