blob: 31bbfd4ebcdd57efa5ad2f98b023a17d8b40d7cc [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
cristy1454be72011-12-19 01:52:48 +00002 Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization
cristy3ed852e2009-09-05 21:47:34 +00003 dedicated to making software imaging solutions freely available.
cristyd2fe6cb2009-11-19 19:00:50 +00004
cristy3ed852e2009-09-05 21:47:34 +00005 You may not use this file except in compliance with the License.
6 obtain a copy of the License at
cristyd2fe6cb2009-11-19 19:00:50 +00007
cristy3ed852e2009-09-05 21:47:34 +00008 http://www.imagemagick.org/script/license.php
cristyd2fe6cb2009-11-19 19:00:50 +00009
cristy3ed852e2009-09-05 21:47:34 +000010 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)
22extern "C" {
23#endif
24
cristy0157aea2010-04-24 21:12:18 +000025#if defined(WIN32) || defined(WIN64)
26# define MAGICKCORE_WINDOWS_SUPPORT
27#else
28# define MAGICKCORE_POSIX_SUPPORT
cristy3ed852e2009-09-05 21:47:34 +000029#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)
cristy4c08aed2011-07-01 19:47:50 +000036# include "MagickCore/magick-config.h"
cristy3ed852e2009-09-05 21:47:34 +000037# 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)
cristyc47d1f82009-11-26 01:44:43 +000044# define const _magickcore_const
cristy3ed852e2009-09-05 21:47:34 +000045#endif
46#if defined(_magickcore_inline) && !defined(inline)
cristyc47d1f82009-11-26 01:44:43 +000047# define inline _magickcore_inline
cristy3ed852e2009-09-05 21:47:34 +000048#endif
cristyc47d1f82009-11-26 01:44:43 +000049#if defined(_magickcore_restrict) && !defined(restrict)
50# define restrict _magickcore_restrict
cristy3ed852e2009-09-05 21:47:34 +000051#endif
cristyba56db52011-05-20 02:08:11 +000052# if defined(__cplusplus) || defined(c_plusplus)
53# undef inline
54# endif
cristy3ed852e2009-09-05 21:47:34 +000055#endif
56
57#if defined(MAGICKCORE_NAMESPACE_PREFIX)
cristy4c08aed2011-07-01 19:47:50 +000058# include "MagickCore/methods.h"
cristy3ed852e2009-09-05 21:47:34 +000059#endif
60
61#if !defined(const)
62# define STDC
63#endif
64
cristy3ed852e2009-09-05 21:47:34 +000065#include <stdarg.h>
66#include <stdio.h>
cristya0b81c32010-01-22 02:54:33 +000067#if defined(MAGICKCORE_HAVE_SYS_STAT_H)
68# include <sys/stat.h>
69#endif
70#if defined(MAGICKCORE_STDC_HEADERS)
71# include <stdlib.h>
72# include <stddef.h>
73#else
74# if defined(MAGICKCORE_HAVE_STDLIB_H)
75# include <stdlib.h>
76# endif
77#endif
78#if defined(MAGICKCORE_HAVE_STRING_H)
79# if !defined(STDC_HEADERS) && defined(MAGICKCORE_HAVE_MEMORY_H)
80# include <memory.h>
81# endif
82# include <string.h>
83#endif
84#if defined(MAGICKCORE_HAVE_STRINGS_H)
85# include <strings.h>
86#endif
87#if defined(MAGICKCORE_HAVE_INTTYPES_H)
88# include <inttypes.h>
89#endif
90#if defined(MAGICKCORE_HAVE_STDINT_H)
91# include <stdint.h>
92#endif
93#if defined(MAGICKCORE_HAVE_UNISTD_H)
94# include <unistd.h>
95#endif
cristy0157aea2010-04-24 21:12:18 +000096#if defined(MAGICKCORE_WINDOWS_SUPPORT) && defined(_DEBUG)
cristy3ed852e2009-09-05 21:47:34 +000097#define _CRTDBG_MAP_ALLOC
98#endif
cristy0157aea2010-04-24 21:12:18 +000099#if defined(MAGICKCORE_WINDOWS_SUPPORT)
cristyd9123432012-10-17 12:30:20 +0000100# include <io.h>
cristy3ed852e2009-09-05 21:47:34 +0000101# include <direct.h>
102# if !defined(MAGICKCORE_HAVE_STRERROR)
103# define HAVE_STRERROR
104# endif
105#endif
106
cristy3ed852e2009-09-05 21:47:34 +0000107#include <ctype.h>
108#include <locale.h>
109#include <errno.h>
110#include <fcntl.h>
111#include <math.h>
112#include <time.h>
113#include <limits.h>
114#include <signal.h>
115#include <assert.h>
116
cristy38d73d62011-05-19 01:55:37 +0000117#if defined(MAGICKCORE_HAVE_XLOCALE_H)
118# include <xlocale.h>
119#endif
cristy55bf91c2010-09-24 00:29:41 +0000120#if defined(MAGICKCORE_THREAD_SUPPORT)
cristy3ed852e2009-09-05 21:47:34 +0000121# include <pthread.h>
cristy0157aea2010-04-24 21:12:18 +0000122#elif defined(MAGICKCORE_WINDOWS_SUPPORT)
cristyfe092d82009-10-11 04:00:45 +0000123# define MAGICKCORE_HAVE_WINTHREADS 1
cristy3ed852e2009-09-05 21:47:34 +0000124#include <windows.h>
125#endif
126#if defined(MAGICKCORE_HAVE_SYS_SYSLIMITS_H)
127# include <sys/syslimits.h>
128#endif
129#if defined(MAGICKCORE_HAVE_ARM_LIMITS_H)
130# include <arm/limits.h>
131#endif
132
cristy1579d812010-01-22 15:45:14 +0000133#if defined(MAGICKCORE__OPENCL)
cristyfe2e68f2010-01-09 19:16:03 +0000134#if defined(MAGICKCORE_HAVE_CL_CL_H)
cristy07425aa2009-09-20 22:59:24 +0000135# include <CL/cl.h>
cristy07425aa2009-09-20 22:59:24 +0000136#endif
cristyfe2e68f2010-01-09 19:16:03 +0000137#if defined(MAGICKCORE_HAVE_OPENCL_CL_H)
cristy07425aa2009-09-20 22:59:24 +0000138# include <OpenCL/cl.h>
cristy99cc3002010-01-21 14:50:11 +0000139#endif
cristy68cc9c72010-01-22 14:40:18 +0000140# define MAGICKCORE_OPENCL_SUPPORT 1
cristy07425aa2009-09-20 22:59:24 +0000141#endif
142
cristybffe7d32012-01-20 01:46:17 +0000143#if defined(_OPENMP) && ((_OPENMP >= 200203) || defined(__OPENCC__))
cristy3ed852e2009-09-05 21:47:34 +0000144# include <omp.h>
cristyb28d6472009-10-17 20:13:35 +0000145# define MAGICKCORE_OPENMP_SUPPORT 1
cristy3ed852e2009-09-05 21:47:34 +0000146#endif
147
148#if defined(MAGICKCORE_HAVE_PREAD) && defined(MAGICKCORE_HAVE_DECL_PREAD) && !MAGICKCORE_HAVE_DECL_PREAD
149ssize_t pread(int,void *,size_t,off_t);
150#endif
151
152#if defined(MAGICKCORE_HAVE_PWRITE) && defined(MAGICKCORE_HAVE_DECL_PWRITE) && !MAGICKCORE_HAVE_DECL_PWRITE
153ssize_t pwrite(int,const void *,size_t,off_t);
154#endif
155
156#if defined(MAGICKCORE_HAVE_STRLCPY) && defined(MAGICKCORE_HAVE_DECL_STRLCPY) && !MAGICKCORE_HAVE_DECL_STRLCPY
157extern size_t strlcpy(char *,const char *,size_t);
158#endif
159
160#if defined(MAGICKCORE_HAVE_VSNPRINTF) && defined(MAGICKCORE_HAVE_DECL_VSNPRINTF) && !MAGICKCORE_HAVE_DECL_VSNPRINTF
161extern int vsnprintf(char *,size_t,const char *,va_list);
162#endif
163
cristyb2b54812012-02-19 18:15:55 +0000164#include "MagickCore/method-attribute.h"
165
cristy0157aea2010-04-24 21:12:18 +0000166#if defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(MAGICKCORE_POSIX_SUPPORT)
cristy3ed852e2009-09-05 21:47:34 +0000167# include <sys/types.h>
168# include <sys/stat.h>
169# if defined(MAGICKCORE_HAVE_FTIME)
170# include <sys/timeb.h>
171# endif
172# if defined(MAGICKCORE_POSIX_SUPPORT)
173# if defined(MAGICKCORE_HAVE_SYS_NDIR_H) || defined(MAGICKCORE_HAVE_SYS_DIR_H) || defined(MAGICKCORE_HAVE_NDIR_H)
174# define dirent direct
175# define NAMLEN(dirent) (dirent)->d_namlen
176# if defined(MAGICKCORE_HAVE_SYS_NDIR_H)
177# include <sys/ndir.h>
178# endif
179# if defined(MAGICKCORE_HAVE_SYS_DIR_H)
180# include <sys/dir.h>
181# endif
182# if defined(MAGICKCORE_HAVE_NDIR_H)
183# include <ndir.h>
184# endif
185# else
186# include <dirent.h>
187# define NAMLEN(dirent) strlen((dirent)->d_name)
188# endif
189# include <sys/wait.h>
190# include <pwd.h>
191# endif
192# if !defined(S_ISDIR)
193# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
194# endif
195# if !defined(S_ISREG)
196# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
197# endif
cristy4c08aed2011-07-01 19:47:50 +0000198# include "MagickCore/magick-type.h"
cristy0157aea2010-04-24 21:12:18 +0000199# if !defined(MAGICKCORE_WINDOWS_SUPPORT)
cristy3ed852e2009-09-05 21:47:34 +0000200# include <sys/time.h>
201# if defined(MAGICKCORE_HAVE_SYS_TIMES_H)
202# include <sys/times.h>
203# endif
204# if defined(MAGICKCORE_HAVE_SYS_RESOURCE_H)
205# include <sys/resource.h>
206# endif
cristy58945e42012-09-04 14:33:54 +0000207# if defined(MAGICKCORE_HAVE_SYS_MMAN_H)
208# include <sys/mman.h>
209# endif
cristy3ed852e2009-09-05 21:47:34 +0000210#endif
211#else
212# include <types.h>
213# include <stat.h>
214# if defined(macintosh)
215# if !defined(DISABLE_SIOUX)
216# include <SIOUX.h>
217# include <console.h>
218# endif
219# include <unix.h>
220# endif
cristy4c08aed2011-07-01 19:47:50 +0000221# include "MagickCore/magick-type.h"
cristy3ed852e2009-09-05 21:47:34 +0000222#endif
223
224#if defined(S_IRUSR) && defined(S_IWUSR)
225# define S_MODE (S_IRUSR | S_IWUSR)
cristy0157aea2010-04-24 21:12:18 +0000226#elif defined (MAGICKCORE_WINDOWS_SUPPORT)
cristy3ed852e2009-09-05 21:47:34 +0000227# define S_MODE (_S_IREAD | _S_IWRITE)
228#else
229# define S_MODE 0600
230#endif
231
cristy0157aea2010-04-24 21:12:18 +0000232#if defined(MAGICKCORE_WINDOWS_SUPPORT)
cristy4c08aed2011-07-01 19:47:50 +0000233# include "MagickCore/nt-base.h"
cristy3ed852e2009-09-05 21:47:34 +0000234#endif
235#if defined(macintosh)
cristy4c08aed2011-07-01 19:47:50 +0000236# include "MagickCore/mac.h"
cristy3ed852e2009-09-05 21:47:34 +0000237#endif
238#if defined(vms)
cristy4c08aed2011-07-01 19:47:50 +0000239# include "MagickCore/vms.h"
cristy3ed852e2009-09-05 21:47:34 +0000240#endif
241
242#undef HAVE_CONFIG_H
243#undef gamma
244#undef index
245#undef pipe
246#undef y1
247
248/*
249 Review these platform specific definitions.
250*/
251#if defined(MAGICKCORE_POSIX_SUPPORT) && !defined(__OS2__)
252# define DirectorySeparator "/"
253# define DirectoryListSeparator ':'
254# define EditorOptions " -title \"Edit Image Comment\" -e vi"
255# define Exit exit
256# define IsBasenameSeparator(c) ((c) == '/' ? MagickTrue : MagickFalse)
257# define X11_PREFERENCES_PATH "~/."
258# define ProcessPendingEvents(text)
259# define ReadCommandlLine(argc,argv)
260# define SetNotifyHandlers
261#else
262# if defined(vms)
263# define X11_APPLICATION_PATH "decw$system_defaults:"
264# define DirectorySeparator ""
265# define DirectoryListSeparator ';'
266# define EditorOptions ""
267# define Exit exit
268# define IsBasenameSeparator(c) \
269 (((c) == ']') || ((c) == ':') || ((c) == '/') ? MagickTrue : MagickFalse)
270# define MAGICKCORE_LIBRARY_PATH "sys$login:"
271# define MAGICKCORE_CODER_PATH "sys$login:"
272# define MAGICKCORE_FILTER_PATH "sys$login:"
273# define MAGICKCORE_SHARE_PATH "sys$login:"
274# define X11_PREFERENCES_PATH "decw$user_defaults:"
275# define ProcessPendingEvents(text)
276# define ReadCommandlLine(argc,argv)
277# define SetNotifyHandlers
278# endif
279# if defined(__OS2__)
280# define DirectorySeparator "\\"
281# define DirectoryListSeparator ';'
282# define EditorOptions " -title \"Edit Image Comment\" -e vi"
283# define Exit exit
284# define IsBasenameSeparator(c) \
285 (((c) == '/') || ((c) == '\\') ? MagickTrue : MagickFalse)
286# define PreferencesDefaults "~\."
287# define ProcessPendingEvents(text)
288# define ReadCommandlLine(argc,argv)
289# define SetNotifyHandlers
290#endif
291# if defined(macintosh)
292# define X11_APPLICATION_PATH "/usr/lib/X11/app-defaults/"
293# define DirectorySeparator ":"
294# define DirectoryListSeparator ';'
295# define EditorOptions ""
296# define IsBasenameSeparator(c) ((c) == ':' ? MagickTrue : MagickFalse)
297# define MAGICKCORE_LIBRARY_PATH ""
298# define MAGICKCORE_CODER_PATH ""
299# define MAGICKCORE_FILTER_PATH ""
300# define MAGICKCORE_SHARE_PATH ""
301# define X11_PREFERENCES_PATH "~/."
302# if defined(DISABLE_SIOUX)
303# define ReadCommandlLine(argc,argv)
304# define SetNotifyHandlers \
305 SetFatalErrorHandler(MacFatalErrorHandler); \
306 SetErrorHandler(MACErrorHandler); \
307 SetWarningHandler(MACWarningHandler)
308# else
309# define ReadCommandlLine(argc,argv) argc=ccommand(argv); puts(MagickVersion);
310# define SetNotifyHandlers \
311 SetErrorHandler(MACErrorHandler); \
312 SetWarningHandler(MACWarningHandler)
313# endif
314# endif
cristy0157aea2010-04-24 21:12:18 +0000315# if defined(MAGICKCORE_WINDOWS_SUPPORT)
cristy3ed852e2009-09-05 21:47:34 +0000316# define DirectorySeparator "\\"
317# define DirectoryListSeparator ';'
318# define EditorOptions ""
319# define IsBasenameSeparator(c) \
320 (((c) == '/') || ((c) == '\\') ? MagickTrue : MagickFalse)
321# define ProcessPendingEvents(text)
322# if !defined(X11_PREFERENCES_PATH)
323# define X11_PREFERENCES_PATH "~\\."
324# endif
325# define ReadCommandlLine(argc,argv)
326# define SetNotifyHandlers \
327 SetErrorHandler(NTErrorHandler); \
328 SetWarningHandler(NTWarningHandler)
329# undef sleep
330# define sleep(seconds) Sleep(seconds*1000)
331# if !defined(MAGICKCORE_HAVE_TIFFCONF_H)
332# define HAVE_TIFFCONF_H
333# endif
334# endif
335
336#endif
337
338/*
339 Define system symbols if not already defined.
340*/
341#if !defined(STDIN_FILENO)
342#define STDIN_FILENO 0x00
343#endif
344
345#if !defined(O_BINARY)
346#define O_BINARY 0x00
347#endif
348
cristy104cea82009-10-25 02:26:51 +0000349#if !defined(PATH_MAX)
350#define PATH_MAX 4096
351#endif
352
cristy0157aea2010-04-24 21:12:18 +0000353#if defined(MAGICKCORE_LTDL_DELEGATE) || (defined(MAGICKCORE_WINDOWS_SUPPORT) && defined(_DLL) && !defined(_LIB))
cristy3ed852e2009-09-05 21:47:34 +0000354# define MAGICKCORE_MODULES_SUPPORT
355#endif
356
357#if defined(_MAGICKMOD_)
358# undef MAGICKCORE_BUILD_MODULES
359# define MAGICKCORE_BUILD_MODULES
360#endif
361
362/*
cristy3ed852e2009-09-05 21:47:34 +0000363 Magick defines.
364*/
365#define Swap(x,y) ((x)^=(y), (y)^=(x), (x)^=(y))
366
367#if defined(__cplusplus) || defined(c_plusplus)
368}
369#endif
370
371#endif