MagickCore 7.0.10
studio.h
Go to the documentation of this file.
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.
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 Wizard's Toolkit methods.
17*/
18#ifndef _WIZARDSTOOLKIT_STUDIO_H
19#define _WIZARDSTOOLKIT_STUDIO_H
20
21#if defined(__cplusplus) || defined(c_plusplus)
22extern "C" {
23#endif
24
25#if defined(WIN32) || defined(WIN64)
26# define WIZARDSTOOLKIT_WINDOWS_SUPPORT
27#else
28# define WIZARDSTOOLKIT_POSIX_SUPPORT
29#endif
30
31#if !defined(_WIZARDSTOOLKIT_CONFIG_H)
32# define _WIZARDSTOOLKIT_CONFIG_H
33# if !defined(vms) && !defined(macintosh)
34# include "wizard/wizard-config.h"
35# else
36# include "wizard-config.h"
37# endif
38#if defined(_WIZARDSTOOLKIT__FILE_OFFSET_BITS) && !defined(_FILE_OFFSET_BITS)
39# define _FILE_OFFSET_BITS _WIZARDSTOOLKIT__FILE_OFFSET_BITS
40#endif
41#if defined(_wizardstoolkit_const) && !defined(const)
42# define const _wizardstoolkit_const
43#endif
44#if defined(_wizardstoolkit_inline) && !defined(inline)
45# define inline _wizardstoolkit_inline
46#endif
47# if defined(__cplusplus) || defined(c_plusplus)
48# undef inline
49# endif
50#endif
51
52#if !defined(const)
53# define STDC
54#endif
55
56#include <stdarg.h>
57#include <stdio.h>
58#if defined(WIZARDSTOOLKIT_HAVE_SYS_STAT_H)
59# include <sys/stat.h>
60#endif
61#if defined(WIZARDSTOOLKIT_STDC_HEADERS)
62# include <stdlib.h>
63# include <stddef.h>
64#else
65# if defined(WIZARDSTOOLKIT_HAVE_STDLIB_H)
66# include <stdlib.h>
67# endif
68#endif
69#if !defined(wizard_restrict)
70# if !defined(_wizardcore_restrict)
71# define wizard_restrict restrict
72# else
73# define wizard_restrict _wizardcore_restrict
74# endif
75#endif
76#if defined(WIZARDSTOOLKIT_HAVE_STRING_H)
77# if !defined(STDC_HEADERS) && defined(WIZARDSTOOLKIT_HAVE_MEMORY_H)
78# include <memory.h>
79# endif
80# include <string.h>
81#endif
82#if defined(WIZARDSTOOLKIT_HAVE_STRINGS_H)
83# include <strings.h>
84#endif
85#if defined(WIZARDSTOOLKIT_HAVE_INTTYPES_H)
86# include <inttypes.h>
87#endif
88#if defined(WIZARDSTOOLKIT_HAVE_STDINT_H)
89# include <stdint.h>
90#endif
91#if defined(WIZARDSTOOLKIT_HAVE_UNISTD_H)
92# include <unistd.h>
93#endif
94#if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT) && defined(_DEBUG)
95#define _CRTDBG_MAP_ALLOC
96#endif
97#if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT)
98# include <direct.h>
99# if !defined(WIZARDSTOOLKIT_HAVE_STRERROR)
100# define HAVE_STRERROR
101# endif
102#endif
103
104#if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT) && defined(_DEBUG)
105#define _CRTDBG_MAP_ALLOC
106#endif
107#if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT)
108# include <direct.h>
109# if !defined(WIZARDSTOOLKIT_HAVE_STRERROR)
110# define HAVE_STRERROR
111# endif
112#endif
113
114#include <ctype.h>
115#include <locale.h>
116#include <errno.h>
117#include <fcntl.h>
118#include <math.h>
119#include <time.h>
120#include <limits.h>
121#include <signal.h>
122#include <assert.h>
123
124#if defined(WIZARDSTOOLKIT_HAVE_XLOCALE_H)
125# include <xlocale.h>
126#endif
127#if defined(WIZARDSTOOLKIT_THREAD_SUPPORT)
128# include <pthread.h>
129#elif defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT)
130# define WIZARDSTOOLKIT_HAVE_WINTHREADS 1
131#include <windows.h>
132#endif
133#if defined(WIZARDSTOOLKIT_HAVE_SYS_SYSLIMITS_H)
134# include <sys/syslimits.h>
135#endif
136#if defined(WIZARDSTOOLKIT_HAVE_ARM_LIMITS_H)
137# include <arm/limits.h>
138#endif
139#if defined(_OPENMP) && (_OPENMP >= 200203)
140# include <omp.h>
141# define WIZARDSTOOLKIT_HAVE_OPENMP 1
142#endif
143
144#if defined(WIZARDSTOOLKIT_HAVE_PREAD) && defined(WIZARDSTOOLKIT_HAVE_DECL_PREAD) && !WIZARDSTOOLKIT_HAVE_DECL_PREAD
145ssize_t pread(int,void *,size_t,off_t);
146#endif
147
148#if defined(WIZARDSTOOLKIT_HAVE_PWRITE) && defined(WIZARDSTOOLKIT_HAVE_DECL_PWRITE) && !WIZARDSTOOLKIT_HAVE_DECL_PWRITE
149ssize_t pwrite(int,const void *,size_t,off_t);
150#endif
151
152#if defined(WIZARDSTOOLKIT_HAVE_STRLCPY) && defined(WIZARDSTOOLKIT_HAVE_DECL_STRLCPY) && !WIZARDSTOOLKIT_HAVE_DECL_STRLCPY
153extern size_t strlcpy(char *,const char *,size_t);
154#endif
155
156#if defined(WIZARDSTOOLKIT_HAVE_VSNPRINTF) && defined(WIZARDSTOOLKIT_HAVE_DECL_VSNPRINTF) && !WIZARDSTOOLKIT_HAVE_DECL_VSNPRINTF
157extern int vsnprintf(char *,size_t,const char *,va_list);
158#endif
159
161
162#if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT) || defined(WIZARDSTOOLKIT_POSIX_SUPPORT)
163# include <sys/types.h>
164# include <sys/stat.h>
165# if defined(WIZARDSTOOLKIT_HAVE_FTIME)
166# include <sys/timeb.h>
167# endif
168# if defined(WIZARDSTOOLKIT_POSIX_SUPPORT)
169# if defined(WIZARDSTOOLKIT_HAVE_SYS_NDIR_H) || defined(WIZARDSTOOLKIT_HAVE_SYS_DIR_H) || defined(WIZARDSTOOLKIT_HAVE_NDIR_H)
170# define dirent direct
171# define NAMLEN(dirent) (dirent)->d_namlen
172# if defined(WIZARDSTOOLKIT_HAVE_SYS_NDIR_H)
173# include <sys/ndir.h>
174# endif
175# if defined(WIZARDSTOOLKIT_HAVE_SYS_DIR_H)
176# include <sys/dir.h>
177# endif
178# if defined(WIZARDSTOOLKIT_HAVE_NDIR_H)
179# include <ndir.h>
180# endif
181# else
182# include <dirent.h>
183# define NAMLEN(dirent) strlen((dirent)->d_name)
184# endif
185# include <pwd.h>
186# endif
187# if !defined(S_ISDIR)
188# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
189# endif
190# if !defined(S_ISREG)
191# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
192# endif
193# include "wizard/wizard-type.h"
194# if !defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT)
195# include <sys/time.h>
196#if defined(WIZARDSTOOLKIT_HAVE_SYS_TIMES_H)
197# include <sys/times.h>
198#endif
199#if defined(WIZARDSTOOLKIT_HAVE_SYS_RESOURCE_H)
200# include <sys/resource.h>
201#endif
202#if defined(WIZARDSTOOLKIT_HAVE_SYS_MMAN_H)
203# include <sys/mman.h>
204#endif
205# endif
206#else
207# include <types.h>
208# include <stat.h>
209# if defined(macintosh)
210# include <SIOUX.h>
211# include <console.h>
212# include <unix.h>
213# endif
214# include "wizard/wizard-type.h"
215#endif
216
217#if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT)
218# include "wizard/nt-base.h"
219#endif
220#if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT) || defined(__CYGWIN__)
221#endif
222#if defined(macintosh)
223# include "mac.h"
224#endif
225#if defined(vms)
226# include "vms.h"
227#endif
228
229#undef HAVE_CONFIG_H
230#undef index
231#undef pipe
232
234
235/*
236 Review these platform specific definitions.
237*/
238#if defined(WIZARDSTOOLKIT_POSIX_SUPPORT)
239# define DirectorySeparator "/"
240# define DirectoryListSeparator ':'
241# define Exit _exit
242# define IsBasenameSeparator(c) ((c) == '/' ? WizardTrue : WizardFalse)
243# define PreferencesDefaults "~/."
244# define ProcessPendingEvents(text)
245# define ReadCommandlLine(argc,argv)
246# define SetNotifyHandlers
247#else
248
249# if defined(vms)
250# define ApplicationDefaults "decw$system_defaults:"
251# define DirectorySeparator ""
252# define DirectoryListSeparator ';'
253# define Exit exit
254# define IsBasenameSeparator(c) \
255 (((c) == ']') || ((c) == ':') || ((c) == '/') ? WizardTrue : WizardFalse)
256# define WizardLibPath "sys$login:"
257# define WizardModulesPath "sys$login:"
258# define WizardSignaturerePath "sys$login:"
259# define PreferencesDefaults "decw$user_defaults:"
260# define ProcessPendingEvents(text)
261# define ReadCommandlLine(argc,argv)
262# define SetNotifyHandlers
263# endif
264
265# if defined(macintosh)
266# define ApplicationDefaults "/usr/lib/X11/app-defaults/"
267# define DirectorySeparator ":"
268# define DirectoryListSeparator ';'
269# define IsBasenameSeparator(c) ((c) == ':' ? WizardTrue : WizardFalse)
270# define WizardLibPath ""
271# define WizardModulesPath ""
272# define WizardSignaturerePath ""
273# define PreferencesDefaults "~/."
274# define ReadCommandlLine(argc,argv) argc=ccommand(argv); puts(WizardVersion);
275# define SetNotifyHandlers \
276 SetErrorHandler(MACErrorHandler); \
277 SetWarningHandler(MACWarningHandler)
278# endif
279
280# if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT)
281# define DirectorySeparator "\\"
282# define DirectoryListSeparator ';'
283# define IsBasenameSeparator(c) \
284 (((c) == '/') || ((c) == '\\') ? WizardTrue : WizardFalse)
285# define ProcessPendingEvents(text)
286#if !defined(PreferencesDefaults)
287# define PreferencesDefaults "~\\."
288#endif /* PreferencesDefaults */
289# define ReadCommandlLine(argc,argv)
290# define SetNotifyHandlers \
291 SetErrorHandler(NTErrorHandler); \
292 SetWarningHandler(NTWarningHandler)
293# if !defined(WIZARDSTOOLKIT_HAVE_TIFFCONF_H)
294# define HAVE_TIFFCONF_H
295# endif
296# endif
297
298#endif
299
300/*
301 Define declarations.
302*/
303#define AbsoluteValue(x) ((x) < 0 ? -(x) : (x))
304#define WizardMaxRecursionDepth 1024
305#define WizardEpoch 1000000000L
306#define Max(x,y) (((x) > (y)) ? (x) : (y))
307#define Min(x,y) (((x) < (y)) ? (x) : (y))
308#define Swap(x,y) ((x)^=(y), (y)^=(x), (x)^=(y))
309
310/*
311 Define system symbols if not already defined.
312*/
313#if !defined(STDIN_FILENO)
314#define STDIN_FILENO 0x00
315#endif
316
317#if !defined(STDOUT_FILENO)
318#define STDOUT_FILENO 0x01
319#endif
320
321#if !defined(STDERR_FILENO)
322#define STDERR_FILENO 0x02
323#endif
324
325#if !defined(O_BINARY)
326#define O_BINARY 0x00
327#endif
328
329#if defined(S_IRUSR) && defined(S_IWUSR)
330# define S_MODE (S_IRUSR | S_IWUSR)
331#elif defined (WIZARDSTOOLKIT_WINDOWS_SUPPORT)
332# define S_MODE (_S_IREAD | _S_IWRITE)
333#else
334# define S_MODE 0600
335#endif
336
337#if !defined(PATH_MAX)
338#define PATH_MAX 4096
339#endif
340
341extern unsigned char
342 _wizard_info[1];
343
344#if defined(__cplusplus) || defined(c_plusplus)
345}
346#endif
347
348#endif
unsigned char _wizard_info[1]