blob: 18a2aeb4b7e4eef28172338ddf23e2d92883a8a0 [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
cristy16af1cb2009-12-11 21:38:29 +00002 Copyright 1999-2010 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
25#if defined(__CYGWIN32__)
26# if !defined(__CYGWIN__)
27# define __CYGWIN__ __CYGWIN32__
28# endif
29#endif
30
31#if defined(_WIN32) || defined(WIN32)
32# if !defined(__WINDOWS__)
33# if defined(_WIN32)
34# define __WINDOWS__ _WIN32
35# else
36# if defined(WIN32)
37# define __WINDOWS__ WIN32
38# endif
39# endif
40# endif
41#endif
42
43#if defined(_WIN64) || defined(WIN64)
44# if !defined(__WINDOWS__)
45# if defined(_WIN64)
46# define __WINDOWS__ _WIN64
47# else
48# if defined(WIN64)
49# define __WINDOWS__ WIN64
50# endif
51# endif
52# endif
53#endif
54
cristy3ed852e2009-09-05 21:47:34 +000055#if !defined(vms) && !defined(macintosh) && !defined(__WINDOWS__)
56# define MAGICKCORE_POSIX_SUPPORT
57#endif
58
59#define MAGICKCORE_IMPLEMENTATION 1
60
61#if !defined(_MAGICKCORE_CONFIG_H)
62# define _MAGICKCORE_CONFIG_H
63# if !defined(vms) && !defined(macintosh)
64# include "magick/magick-config.h"
65# else
66# include "magick-config.h"
67# endif
68#if defined(MAGICKCORE__FILE_OFFSET_BITS) && !defined(_FILE_OFFSET_BITS)
69# define _FILE_OFFSET_BITS MAGICKCORE__FILE_OFFSET_BITS
70#endif
71#if defined(_magickcore_const) && !defined(const)
cristyc47d1f82009-11-26 01:44:43 +000072# define const _magickcore_const
cristy3ed852e2009-09-05 21:47:34 +000073#endif
74#if defined(_magickcore_inline) && !defined(inline)
cristyc47d1f82009-11-26 01:44:43 +000075# define inline _magickcore_inline
cristy3ed852e2009-09-05 21:47:34 +000076#endif
77# if defined(__cplusplus) || defined(c_plusplus)
78# undef inline
79# endif
cristyc47d1f82009-11-26 01:44:43 +000080#if defined(_magickcore_restrict) && !defined(restrict)
81# define restrict _magickcore_restrict
cristy3ed852e2009-09-05 21:47:34 +000082#endif
83#endif
84
85#if defined(MAGICKCORE_NAMESPACE_PREFIX)
86# include "magick/methods.h"
87#endif
88
89#if !defined(const)
90# define STDC
91#endif
92
93#if defined(__BORLANDC__) && defined(_DLL)
94# pragma message("BCBMagick lib DLL export interface")
95# define _MAGICKDLL_
96# define _MAGICKLIB_
97# define MAGICKCORE_MODULES_SUPPORT
98# undef MAGICKCORE_BUILD_MODULES
99#endif
100
101#if defined(__WINDOWS__)
102# if defined(_MT) && defined(_DLL) && !defined(_MAGICKDLL_) && !defined(_LIB)
103# define _MAGICKDLL_
104# endif
105# if defined(_MAGICKDLL_)
106# if defined(_VISUALC_)
107# pragma warning( disable: 4273 ) /* Disable the dll linkage warnings */
108# endif
109# if !defined(_MAGICKLIB_)
110# define MagickExport __declspec(dllimport)
111# if defined(_VISUALC_)
112# pragma message( "MagickCore lib DLL import interface" )
113# endif
114# else
115# define MagickExport __declspec(dllexport)
116# if defined(_VISUALC_)
117# pragma message( "MagickCore lib DLL export interface" )
118# endif
119# endif
120# else
121# define MagickExport
122# if defined(_VISUALC_)
123# pragma message( "MagickCore lib static interface" )
124# endif
125# endif
126
127# if defined(_DLL) && !defined(_LIB)
128# define ModuleExport __declspec(dllexport)
129# if defined(_VISUALC_)
130# pragma message( "MagickCore module DLL export interface" )
131# endif
132# else
133# define ModuleExport
134# if defined(_VISUALC_)
135# pragma message( "MagickCore module static interface" )
136# endif
137
138# endif
139# define MagickGlobal __declspec(thread)
140# if defined(_VISUALC_)
141# pragma warning(disable : 4018)
142# pragma warning(disable : 4068)
143# pragma warning(disable : 4244)
144# pragma warning(disable : 4142)
145# pragma warning(disable : 4800)
146# pragma warning(disable : 4786)
147# pragma warning(disable : 4996)
148# endif
149#else
150# define MagickExport
151# define ModuleExport
152# define MagickGlobal
153#endif
154
155#define MagickSignature 0xabacadabUL
156#if !defined(MaxTextExtent)
157# define MaxTextExtent 4096
158#endif
159
160#include <stdarg.h>
161#include <stdio.h>
162#if defined(__WINDOWS__) && defined(_DEBUG)
163#define _CRTDBG_MAP_ALLOC
164#endif
165#include <stdlib.h>
166#if !defined(__WINDOWS__)
167# include <unistd.h>
168#else
169# include <direct.h>
170# if !defined(MAGICKCORE_HAVE_STRERROR)
171# define HAVE_STRERROR
172# endif
173#endif
174
175#if defined(MAGICKCORE_HAVE_STRINGS_H)
176# include <strings.h>
177#endif
178#include <string.h>
179#include <ctype.h>
180#include <locale.h>
181#include <errno.h>
182#include <fcntl.h>
183#include <math.h>
184#include <time.h>
185#include <limits.h>
186#include <signal.h>
187#include <assert.h>
188
189#if defined(MAGICKCORE_HAVE_PTHREAD)
190# include <pthread.h>
191#elif defined(__WINDOWS__)
cristyfe092d82009-10-11 04:00:45 +0000192# define MAGICKCORE_HAVE_WINTHREADS 1
cristy3ed852e2009-09-05 21:47:34 +0000193#include <windows.h>
194#endif
195#if defined(MAGICKCORE_HAVE_SYS_SYSLIMITS_H)
196# include <sys/syslimits.h>
197#endif
198#if defined(MAGICKCORE_HAVE_ARM_LIMITS_H)
199# include <arm/limits.h>
200#endif
201
cristy70b432b2009-11-06 02:32:25 +0000202#if defined(MAGICKCORE_HAVE_CL_CL_H)
cristy07425aa2009-09-20 22:59:24 +0000203# include <CL/cl.h>
204# define MAGICKCORE_OPENCL_SUPPORT 1
205#endif
206
cristy70b432b2009-11-06 02:32:25 +0000207#if defined(MAGICKCORE_HAVE_OPENCL_CL_H)
cristy07425aa2009-09-20 22:59:24 +0000208# include <OpenCL/cl.h>
209# define MAGICKCORE_OPENCL_SUPPORT 1
210#endif
211
cristy3ed852e2009-09-05 21:47:34 +0000212#if defined(_OPENMP) && (_OPENMP >= 200203)
213# include <omp.h>
cristyb28d6472009-10-17 20:13:35 +0000214# define MAGICKCORE_OPENMP_SUPPORT 1
cristy3ed852e2009-09-05 21:47:34 +0000215#endif
216
217#if defined(MAGICKCORE_HAVE_PREAD) && defined(MAGICKCORE_HAVE_DECL_PREAD) && !MAGICKCORE_HAVE_DECL_PREAD
218ssize_t pread(int,void *,size_t,off_t);
219#endif
220
221#if defined(MAGICKCORE_HAVE_PWRITE) && defined(MAGICKCORE_HAVE_DECL_PWRITE) && !MAGICKCORE_HAVE_DECL_PWRITE
222ssize_t pwrite(int,const void *,size_t,off_t);
223#endif
224
225#if defined(MAGICKCORE_HAVE_STRLCPY) && defined(MAGICKCORE_HAVE_DECL_STRLCPY) && !MAGICKCORE_HAVE_DECL_STRLCPY
226extern size_t strlcpy(char *,const char *,size_t);
227#endif
228
229#if defined(MAGICKCORE_HAVE_VSNPRINTF) && defined(MAGICKCORE_HAVE_DECL_VSNPRINTF) && !MAGICKCORE_HAVE_DECL_VSNPRINTF
230extern int vsnprintf(char *,size_t,const char *,va_list);
231#endif
232
233#if !defined(magick_attribute)
cristy4ef4f772009-11-20 15:04:30 +0000234# if (defined(__GNUC__) && (__GNUC__ >= 3))
cristy3ed852e2009-09-05 21:47:34 +0000235# define magick_attribute __attribute__
cristyd2fe6cb2009-11-19 19:00:50 +0000236# else
237# define magick_attribute(x) /* nothing */
cristy3ed852e2009-09-05 21:47:34 +0000238# endif
239#endif
240
241#if !defined(magick_unused)
cristy4ef4f772009-11-20 15:04:30 +0000242# if (defined(__GNUC__) && (__GNUC__ >= 3))
cristy3ed852e2009-09-05 21:47:34 +0000243# define magick_unused(x) magick_unused_ ## x __attribute__((unused))
244# elif defined(__LCLINT__)
245# define magick_unused(x) /*@unused@*/ x
246# else
247# define magick_unused(x) x
248# endif
249#endif
250
251#if defined(__WINDOWS__) || defined(MAGICKCORE_POSIX_SUPPORT)
252# include <sys/types.h>
253# include <sys/stat.h>
254# if defined(MAGICKCORE_HAVE_FTIME)
255# include <sys/timeb.h>
256# endif
257# if defined(MAGICKCORE_POSIX_SUPPORT)
258# if defined(MAGICKCORE_HAVE_SYS_NDIR_H) || defined(MAGICKCORE_HAVE_SYS_DIR_H) || defined(MAGICKCORE_HAVE_NDIR_H)
259# define dirent direct
260# define NAMLEN(dirent) (dirent)->d_namlen
261# if defined(MAGICKCORE_HAVE_SYS_NDIR_H)
262# include <sys/ndir.h>
263# endif
264# if defined(MAGICKCORE_HAVE_SYS_DIR_H)
265# include <sys/dir.h>
266# endif
267# if defined(MAGICKCORE_HAVE_NDIR_H)
268# include <ndir.h>
269# endif
270# else
271# include <dirent.h>
272# define NAMLEN(dirent) strlen((dirent)->d_name)
273# endif
274# include <sys/wait.h>
275# include <pwd.h>
276# endif
277# if !defined(S_ISDIR)
278# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
279# endif
280# if !defined(S_ISREG)
281# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
282# endif
283# include "magick/magick-type.h"
284# if !defined(__WINDOWS__)
285# include <sys/time.h>
286# if defined(MAGICKCORE_HAVE_SYS_TIMES_H)
287# include <sys/times.h>
288# endif
289# if defined(MAGICKCORE_HAVE_SYS_RESOURCE_H)
290# include <sys/resource.h>
291# endif
292#endif
293#else
294# include <types.h>
295# include <stat.h>
296# if defined(macintosh)
297# if !defined(DISABLE_SIOUX)
298# include <SIOUX.h>
299# include <console.h>
300# endif
301# include <unix.h>
302# endif
303# include "magick/magick-type.h"
304#endif
305
306#if defined(S_IRUSR) && defined(S_IWUSR)
307# define S_MODE (S_IRUSR | S_IWUSR)
308#elif defined (__WINDOWS__)
309# define S_MODE (_S_IREAD | _S_IWRITE)
310#else
311# define S_MODE 0600
312#endif
313
314#if defined(__WINDOWS__)
315# include "magick/nt-base.h"
316#endif
317#if defined(macintosh)
318# include "magick/mac.h"
319#endif
320#if defined(vms)
321# include "magick/vms.h"
322#endif
323
324#undef HAVE_CONFIG_H
325#undef gamma
326#undef index
327#undef pipe
328#undef y1
329
330/*
331 Review these platform specific definitions.
332*/
333#if defined(MAGICKCORE_POSIX_SUPPORT) && !defined(__OS2__)
334# define DirectorySeparator "/"
335# define DirectoryListSeparator ':'
336# define EditorOptions " -title \"Edit Image Comment\" -e vi"
337# define Exit exit
338# define IsBasenameSeparator(c) ((c) == '/' ? MagickTrue : MagickFalse)
339# define X11_PREFERENCES_PATH "~/."
340# define ProcessPendingEvents(text)
341# define ReadCommandlLine(argc,argv)
342# define SetNotifyHandlers
343#else
344# if defined(vms)
345# define X11_APPLICATION_PATH "decw$system_defaults:"
346# define DirectorySeparator ""
347# define DirectoryListSeparator ';'
348# define EditorOptions ""
349# define Exit exit
350# define IsBasenameSeparator(c) \
351 (((c) == ']') || ((c) == ':') || ((c) == '/') ? MagickTrue : MagickFalse)
352# define MAGICKCORE_LIBRARY_PATH "sys$login:"
353# define MAGICKCORE_CODER_PATH "sys$login:"
354# define MAGICKCORE_FILTER_PATH "sys$login:"
355# define MAGICKCORE_SHARE_PATH "sys$login:"
356# define X11_PREFERENCES_PATH "decw$user_defaults:"
357# define ProcessPendingEvents(text)
358# define ReadCommandlLine(argc,argv)
359# define SetNotifyHandlers
360# endif
361# if defined(__OS2__)
362# define DirectorySeparator "\\"
363# define DirectoryListSeparator ';'
364# define EditorOptions " -title \"Edit Image Comment\" -e vi"
365# define Exit exit
366# define IsBasenameSeparator(c) \
367 (((c) == '/') || ((c) == '\\') ? MagickTrue : MagickFalse)
368# define PreferencesDefaults "~\."
369# define ProcessPendingEvents(text)
370# define ReadCommandlLine(argc,argv)
371# define SetNotifyHandlers
372#endif
373# if defined(macintosh)
374# define X11_APPLICATION_PATH "/usr/lib/X11/app-defaults/"
375# define DirectorySeparator ":"
376# define DirectoryListSeparator ';'
377# define EditorOptions ""
378# define IsBasenameSeparator(c) ((c) == ':' ? MagickTrue : MagickFalse)
379# define MAGICKCORE_LIBRARY_PATH ""
380# define MAGICKCORE_CODER_PATH ""
381# define MAGICKCORE_FILTER_PATH ""
382# define MAGICKCORE_SHARE_PATH ""
383# define X11_PREFERENCES_PATH "~/."
384# if defined(DISABLE_SIOUX)
385# define ReadCommandlLine(argc,argv)
386# define SetNotifyHandlers \
387 SetFatalErrorHandler(MacFatalErrorHandler); \
388 SetErrorHandler(MACErrorHandler); \
389 SetWarningHandler(MACWarningHandler)
390# else
391# define ReadCommandlLine(argc,argv) argc=ccommand(argv); puts(MagickVersion);
392# define SetNotifyHandlers \
393 SetErrorHandler(MACErrorHandler); \
394 SetWarningHandler(MACWarningHandler)
395# endif
396# endif
397# if defined(__WINDOWS__)
398# define DirectorySeparator "\\"
399# define DirectoryListSeparator ';'
400# define EditorOptions ""
401# define IsBasenameSeparator(c) \
402 (((c) == '/') || ((c) == '\\') ? MagickTrue : MagickFalse)
403# define ProcessPendingEvents(text)
404# if !defined(X11_PREFERENCES_PATH)
405# define X11_PREFERENCES_PATH "~\\."
406# endif
407# define ReadCommandlLine(argc,argv)
408# define SetNotifyHandlers \
409 SetErrorHandler(NTErrorHandler); \
410 SetWarningHandler(NTWarningHandler)
411# undef sleep
412# define sleep(seconds) Sleep(seconds*1000)
413# if !defined(MAGICKCORE_HAVE_TIFFCONF_H)
414# define HAVE_TIFFCONF_H
415# endif
416# endif
417
418#endif
419
420/*
421 Define system symbols if not already defined.
422*/
423#if !defined(STDIN_FILENO)
424#define STDIN_FILENO 0x00
425#endif
426
427#if !defined(O_BINARY)
428#define O_BINARY 0x00
429#endif
430
cristy104cea82009-10-25 02:26:51 +0000431#if !defined(PATH_MAX)
432#define PATH_MAX 4096
433#endif
434
cristy3ed852e2009-09-05 21:47:34 +0000435#if defined(MAGICKCORE_LTDL_DELEGATE) || (defined(__WINDOWS__) && defined(_DLL) && !defined(_LIB))
436# define MAGICKCORE_MODULES_SUPPORT
437#endif
438
439#if defined(_MAGICKMOD_)
440# undef MAGICKCORE_BUILD_MODULES
441# define MAGICKCORE_BUILD_MODULES
442#endif
443
444/*
445 I/O defines.
446*/
447#if defined(__WINDOWS__) && !defined(Windows95) && !defined(__BORLANDC__)
448#define MagickSeek(file,offset,whence) _lseeki64(file,offset,whence)
449#define MagickTell(file) _telli64(file)
450#else
451#define MagickSeek(file,offset,whence) lseek(file,offset,whence)
452#define MagickTell(file) tell(file)
453#endif
454
455/*
456 Magick defines.
457*/
458#define Swap(x,y) ((x)^=(y), (y)^=(x), (x)^=(y))
459
460#if defined(__cplusplus) || defined(c_plusplus)
461}
462#endif
463
464#endif