blob: 340286a591891301ebadf373c421801c6a25ba2c [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)
cristy3ed852e2009-09-05 21:47:34 +0000100# include <direct.h>
101# if !defined(MAGICKCORE_HAVE_STRERROR)
102# define HAVE_STRERROR
103# endif
104#endif
105
cristy3ed852e2009-09-05 21:47:34 +0000106#include <ctype.h>
107#include <locale.h>
108#include <errno.h>
109#include <fcntl.h>
110#include <math.h>
111#include <time.h>
112#include <limits.h>
113#include <signal.h>
114#include <assert.h>
115
cristy38d73d62011-05-19 01:55:37 +0000116#if defined(MAGICKCORE_HAVE_XLOCALE_H)
117# include <xlocale.h>
118#endif
cristy55bf91c2010-09-24 00:29:41 +0000119#if defined(MAGICKCORE_THREAD_SUPPORT)
cristy3ed852e2009-09-05 21:47:34 +0000120# include <pthread.h>
cristy0157aea2010-04-24 21:12:18 +0000121#elif defined(MAGICKCORE_WINDOWS_SUPPORT)
cristyfe092d82009-10-11 04:00:45 +0000122# define MAGICKCORE_HAVE_WINTHREADS 1
cristy3ed852e2009-09-05 21:47:34 +0000123#include <windows.h>
124#endif
125#if defined(MAGICKCORE_HAVE_SYS_SYSLIMITS_H)
126# include <sys/syslimits.h>
127#endif
128#if defined(MAGICKCORE_HAVE_ARM_LIMITS_H)
129# include <arm/limits.h>
130#endif
131
cristy1579d812010-01-22 15:45:14 +0000132#if defined(MAGICKCORE__OPENCL)
cristyfe2e68f2010-01-09 19:16:03 +0000133#if defined(MAGICKCORE_HAVE_CL_CL_H)
cristy07425aa2009-09-20 22:59:24 +0000134# include <CL/cl.h>
cristy07425aa2009-09-20 22:59:24 +0000135#endif
cristyfe2e68f2010-01-09 19:16:03 +0000136#if defined(MAGICKCORE_HAVE_OPENCL_CL_H)
cristy07425aa2009-09-20 22:59:24 +0000137# include <OpenCL/cl.h>
cristy99cc3002010-01-21 14:50:11 +0000138#endif
cristy68cc9c72010-01-22 14:40:18 +0000139# define MAGICKCORE_OPENCL_SUPPORT 1
cristy07425aa2009-09-20 22:59:24 +0000140#endif
141
cristybffe7d32012-01-20 01:46:17 +0000142#if defined(_OPENMP) && ((_OPENMP >= 200203) || defined(__OPENCC__))
cristy3ed852e2009-09-05 21:47:34 +0000143# include <omp.h>
cristyb28d6472009-10-17 20:13:35 +0000144# define MAGICKCORE_OPENMP_SUPPORT 1
cristy3ed852e2009-09-05 21:47:34 +0000145#endif
146
147#if defined(MAGICKCORE_HAVE_PREAD) && defined(MAGICKCORE_HAVE_DECL_PREAD) && !MAGICKCORE_HAVE_DECL_PREAD
148ssize_t pread(int,void *,size_t,off_t);
149#endif
150
151#if defined(MAGICKCORE_HAVE_PWRITE) && defined(MAGICKCORE_HAVE_DECL_PWRITE) && !MAGICKCORE_HAVE_DECL_PWRITE
152ssize_t pwrite(int,const void *,size_t,off_t);
153#endif
154
155#if defined(MAGICKCORE_HAVE_STRLCPY) && defined(MAGICKCORE_HAVE_DECL_STRLCPY) && !MAGICKCORE_HAVE_DECL_STRLCPY
156extern size_t strlcpy(char *,const char *,size_t);
157#endif
158
159#if defined(MAGICKCORE_HAVE_VSNPRINTF) && defined(MAGICKCORE_HAVE_DECL_VSNPRINTF) && !MAGICKCORE_HAVE_DECL_VSNPRINTF
160extern int vsnprintf(char *,size_t,const char *,va_list);
161#endif
162
cristyb2b54812012-02-19 18:15:55 +0000163#include "MagickCore/method-attribute.h"
164
cristy0157aea2010-04-24 21:12:18 +0000165#if defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(MAGICKCORE_POSIX_SUPPORT)
cristy3ed852e2009-09-05 21:47:34 +0000166# include <sys/types.h>
167# include <sys/stat.h>
168# if defined(MAGICKCORE_HAVE_FTIME)
169# include <sys/timeb.h>
170# endif
171# if defined(MAGICKCORE_POSIX_SUPPORT)
172# if defined(MAGICKCORE_HAVE_SYS_NDIR_H) || defined(MAGICKCORE_HAVE_SYS_DIR_H) || defined(MAGICKCORE_HAVE_NDIR_H)
173# define dirent direct
174# define NAMLEN(dirent) (dirent)->d_namlen
175# if defined(MAGICKCORE_HAVE_SYS_NDIR_H)
176# include <sys/ndir.h>
177# endif
178# if defined(MAGICKCORE_HAVE_SYS_DIR_H)
179# include <sys/dir.h>
180# endif
181# if defined(MAGICKCORE_HAVE_NDIR_H)
182# include <ndir.h>
183# endif
184# else
185# include <dirent.h>
186# define NAMLEN(dirent) strlen((dirent)->d_name)
187# endif
188# include <sys/wait.h>
189# include <pwd.h>
190# endif
191# if !defined(S_ISDIR)
192# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
193# endif
194# if !defined(S_ISREG)
195# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
196# endif
cristy4c08aed2011-07-01 19:47:50 +0000197# include "MagickCore/magick-type.h"
cristy0157aea2010-04-24 21:12:18 +0000198# if !defined(MAGICKCORE_WINDOWS_SUPPORT)
cristy3ed852e2009-09-05 21:47:34 +0000199# include <sys/time.h>
200# if defined(MAGICKCORE_HAVE_SYS_TIMES_H)
201# include <sys/times.h>
202# endif
203# if defined(MAGICKCORE_HAVE_SYS_RESOURCE_H)
204# include <sys/resource.h>
205# endif
cristy58945e42012-09-04 14:33:54 +0000206# if defined(MAGICKCORE_HAVE_SYS_MMAN_H)
207# include <sys/mman.h>
208# endif
cristy3ed852e2009-09-05 21:47:34 +0000209#endif
210#else
211# include <types.h>
212# include <stat.h>
213# if defined(macintosh)
214# if !defined(DISABLE_SIOUX)
215# include <SIOUX.h>
216# include <console.h>
217# endif
218# include <unix.h>
219# endif
cristy4c08aed2011-07-01 19:47:50 +0000220# include "MagickCore/magick-type.h"
cristy3ed852e2009-09-05 21:47:34 +0000221#endif
222
223#if defined(S_IRUSR) && defined(S_IWUSR)
224# define S_MODE (S_IRUSR | S_IWUSR)
cristy0157aea2010-04-24 21:12:18 +0000225#elif defined (MAGICKCORE_WINDOWS_SUPPORT)
cristy3ed852e2009-09-05 21:47:34 +0000226# define S_MODE (_S_IREAD | _S_IWRITE)
227#else
228# define S_MODE 0600
229#endif
230
cristy0157aea2010-04-24 21:12:18 +0000231#if defined(MAGICKCORE_WINDOWS_SUPPORT)
cristy4c08aed2011-07-01 19:47:50 +0000232# include "MagickCore/nt-base.h"
cristy3ed852e2009-09-05 21:47:34 +0000233#endif
234#if defined(macintosh)
cristy4c08aed2011-07-01 19:47:50 +0000235# include "MagickCore/mac.h"
cristy3ed852e2009-09-05 21:47:34 +0000236#endif
237#if defined(vms)
cristy4c08aed2011-07-01 19:47:50 +0000238# include "MagickCore/vms.h"
cristy3ed852e2009-09-05 21:47:34 +0000239#endif
240
241#undef HAVE_CONFIG_H
242#undef gamma
243#undef index
244#undef pipe
245#undef y1
246
247/*
248 Review these platform specific definitions.
249*/
250#if defined(MAGICKCORE_POSIX_SUPPORT) && !defined(__OS2__)
251# define DirectorySeparator "/"
252# define DirectoryListSeparator ':'
253# define EditorOptions " -title \"Edit Image Comment\" -e vi"
254# define Exit exit
255# define IsBasenameSeparator(c) ((c) == '/' ? MagickTrue : MagickFalse)
256# define X11_PREFERENCES_PATH "~/."
257# define ProcessPendingEvents(text)
258# define ReadCommandlLine(argc,argv)
259# define SetNotifyHandlers
260#else
261# if defined(vms)
262# define X11_APPLICATION_PATH "decw$system_defaults:"
263# define DirectorySeparator ""
264# define DirectoryListSeparator ';'
265# define EditorOptions ""
266# define Exit exit
267# define IsBasenameSeparator(c) \
268 (((c) == ']') || ((c) == ':') || ((c) == '/') ? MagickTrue : MagickFalse)
269# define MAGICKCORE_LIBRARY_PATH "sys$login:"
270# define MAGICKCORE_CODER_PATH "sys$login:"
271# define MAGICKCORE_FILTER_PATH "sys$login:"
272# define MAGICKCORE_SHARE_PATH "sys$login:"
273# define X11_PREFERENCES_PATH "decw$user_defaults:"
274# define ProcessPendingEvents(text)
275# define ReadCommandlLine(argc,argv)
276# define SetNotifyHandlers
277# endif
278# if defined(__OS2__)
279# define DirectorySeparator "\\"
280# define DirectoryListSeparator ';'
281# define EditorOptions " -title \"Edit Image Comment\" -e vi"
282# define Exit exit
283# define IsBasenameSeparator(c) \
284 (((c) == '/') || ((c) == '\\') ? MagickTrue : MagickFalse)
285# define PreferencesDefaults "~\."
286# define ProcessPendingEvents(text)
287# define ReadCommandlLine(argc,argv)
288# define SetNotifyHandlers
289#endif
290# if defined(macintosh)
291# define X11_APPLICATION_PATH "/usr/lib/X11/app-defaults/"
292# define DirectorySeparator ":"
293# define DirectoryListSeparator ';'
294# define EditorOptions ""
295# define IsBasenameSeparator(c) ((c) == ':' ? MagickTrue : MagickFalse)
296# define MAGICKCORE_LIBRARY_PATH ""
297# define MAGICKCORE_CODER_PATH ""
298# define MAGICKCORE_FILTER_PATH ""
299# define MAGICKCORE_SHARE_PATH ""
300# define X11_PREFERENCES_PATH "~/."
301# if defined(DISABLE_SIOUX)
302# define ReadCommandlLine(argc,argv)
303# define SetNotifyHandlers \
304 SetFatalErrorHandler(MacFatalErrorHandler); \
305 SetErrorHandler(MACErrorHandler); \
306 SetWarningHandler(MACWarningHandler)
307# else
308# define ReadCommandlLine(argc,argv) argc=ccommand(argv); puts(MagickVersion);
309# define SetNotifyHandlers \
310 SetErrorHandler(MACErrorHandler); \
311 SetWarningHandler(MACWarningHandler)
312# endif
313# endif
cristy0157aea2010-04-24 21:12:18 +0000314# if defined(MAGICKCORE_WINDOWS_SUPPORT)
cristy3ed852e2009-09-05 21:47:34 +0000315# define DirectorySeparator "\\"
316# define DirectoryListSeparator ';'
317# define EditorOptions ""
318# define IsBasenameSeparator(c) \
319 (((c) == '/') || ((c) == '\\') ? MagickTrue : MagickFalse)
320# define ProcessPendingEvents(text)
321# if !defined(X11_PREFERENCES_PATH)
322# define X11_PREFERENCES_PATH "~\\."
323# endif
324# define ReadCommandlLine(argc,argv)
325# define SetNotifyHandlers \
326 SetErrorHandler(NTErrorHandler); \
327 SetWarningHandler(NTWarningHandler)
328# undef sleep
329# define sleep(seconds) Sleep(seconds*1000)
330# if !defined(MAGICKCORE_HAVE_TIFFCONF_H)
331# define HAVE_TIFFCONF_H
332# endif
333# endif
334
335#endif
336
337/*
338 Define system symbols if not already defined.
339*/
340#if !defined(STDIN_FILENO)
341#define STDIN_FILENO 0x00
342#endif
343
344#if !defined(O_BINARY)
345#define O_BINARY 0x00
346#endif
347
cristy104cea82009-10-25 02:26:51 +0000348#if !defined(PATH_MAX)
349#define PATH_MAX 4096
350#endif
351
cristy0157aea2010-04-24 21:12:18 +0000352#if defined(MAGICKCORE_LTDL_DELEGATE) || (defined(MAGICKCORE_WINDOWS_SUPPORT) && defined(_DLL) && !defined(_LIB))
cristy3ed852e2009-09-05 21:47:34 +0000353# define MAGICKCORE_MODULES_SUPPORT
354#endif
355
356#if defined(_MAGICKMOD_)
357# undef MAGICKCORE_BUILD_MODULES
358# define MAGICKCORE_BUILD_MODULES
359#endif
360
361/*
cristy3ed852e2009-09-05 21:47:34 +0000362 Magick defines.
363*/
364#define Swap(x,y) ((x)^=(y), (y)^=(x), (x)^=(y))
365
366#if defined(__cplusplus) || defined(c_plusplus)
367}
368#endif
369
370#endif