1 /*
2   Copyright 1999-2021 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   MagickWand private application programming interface declarations.
17 */
18 #ifndef MAGICKWAND_STUDIO_H
19 #define MAGICKWAND_STUDIO_H
20 
21 #if defined(__cplusplus) || defined(c_plusplus)
22 extern "C" {
23 #endif
24 
25 #if defined(WIN32) || defined(WIN64)
26 #  define MAGICKWAND_WINDOWS_SUPPORT
27 #else
28 #  define MAGICKWAND_POSIX_SUPPORT
29 #endif
30 
31 #define MAGICKWAND_IMPLEMENTATION  1
32 
33 #if !defined(MAGICKWAND_CONFIG_H)
34 # define MAGICKWAND_CONFIG_H
35 # include "MagickCore/magick-config.h"
36 #if defined(MAGICKCORE__FILE_OFFSET_BITS) && !defined(_FILE_OFFSET_BITS)
37 # define _FILE_OFFSET_BITS MAGICKCORE__FILE_OFFSET_BITS
38 #endif
39 #if defined(_magickcore_const) && !defined(const)
40 # define const _magickcore_const
41 #endif
42 #if defined(_magickcore_inline) && !defined(inline)
43 # define inline _magickcore_inline
44 #endif
45 # if defined(__cplusplus) || defined(c_plusplus)
46 #  undef inline
47 # endif
48 #endif
49 
50 #if !defined(const)
51 #  define STDC
52 #endif
53 
54 #include <stdarg.h>
55 #include <stdio.h>
56 #if defined(MAGICKCORE_HAVE_SYS_STAT_H)
57 # include <sys/stat.h>
58 #endif
59 #if defined(MAGICKCORE_STDC_HEADERS)
60 # include <stdlib.h>
61 # include <stddef.h>
62 #else
63 # if defined(MAGICKCORE_HAVE_STDLIB_H)
64 #  include <stdlib.h>
65 # endif
66 #endif
67 #if !defined(magick_restrict)
68 # if !defined(_magickcore_restrict)
69 #  define magick_restrict restrict
70 # else
71 #  define magick_restrict _magickcore_restrict
72 # endif
73 #endif
74 #if defined(MAGICKCORE_HAVE_STRING_H)
75 # if !defined(STDC_HEADERS) && defined(MAGICKCORE_HAVE_MEMORY_H)
76 #  include <memory.h>
77 # endif
78 # include <string.h>
79 #endif
80 #if defined(MAGICKCORE_HAVE_STRINGS_H)
81 # include <strings.h>
82 #endif
83 #if defined(MAGICKCORE_HAVE_INTTYPES_H)
84 # include <inttypes.h>
85 #endif
86 #if defined(MAGICKCORE_HAVE_STDINT_H)
87 # include <stdint.h>
88 #endif
89 #if defined(MAGICKCORE_HAVE_UNISTD_H)
90 # include <unistd.h>
91 #endif
92 #if defined(MAGICKWAND_WINDOWS_SUPPORT) && defined(_DEBUG)
93 #define _CRTDBG_MAP_ALLOC
94 #endif
95 
96 #if defined(MAGICKWAND_WINDOWS_SUPPORT) && defined(_DEBUG)
97 #define _CRTDBG_MAP_ALLOC
98 #endif
99 #if defined(MAGICKWAND_WINDOWS_SUPPORT)
100 # include <io.h>
101 #if !defined(__CYGWIN__)
102 # include <direct.h>
103 #endif
104 # if !defined(MAGICKCORE_HAVE_STRERROR)
105 #  define HAVE_STRERROR
106 # endif
107 #endif
108 
109 #include <ctype.h>
110 #include <locale.h>
111 #include <errno.h>
112 #include <fcntl.h>
113 #include <math.h>
114 #include <time.h>
115 #include <limits.h>
116 #include <signal.h>
117 #include <assert.h>
118 
119 #if defined(MAGICKCORE_HAVE_XLOCALE_H)
120 # include <xlocale.h>
121 #endif
122 #if defined(MAGICKCORE_THREAD_SUPPORT)
123 # include <pthread.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 
132 #if defined(MAGICKCORE_HAVE_CL_CL_H)
133 #  include <CL/cl.h>
134 #  define MAGICKCORE_OPENCL_SUPPORT  1
135 #endif
136 #if defined(MAGICKCORE_HAVE_OPENCL_CL_H)
137 #  include <OpenCL/cl.h>
138 #  define MAGICKCORE_OPENCL_SUPPORT  1
139 #endif
140 
141 #if defined(_OPENMP) && ((_OPENMP >= 200203) || defined(__OPENCC__))
142 #  include <omp.h>
143 #  define MAGICKCORE_OPENMP_SUPPORT  1
144 #endif
145 
146 #if defined(MAGICKCORE_HAVE_PREAD) && defined(MAGICKCORE_HAVE_DECL_PREAD) && !MAGICKCORE_HAVE_DECL_PREAD
147 ssize_t pread(int,void *,size_t,off_t);
148 #endif
149 
150 #if defined(MAGICKCORE_HAVE_PWRITE) && defined(MAGICKCORE_HAVE_DECL_PWRITE) && !MAGICKCORE_HAVE_DECL_PWRITE
151 ssize_t pwrite(int,const void *,size_t,off_t);
152 #endif
153 
154 #if defined(MAGICKCORE_HAVE_STRLCPY) && defined(MAGICKCORE_HAVE_DECL_STRLCPY) && !MAGICKCORE_HAVE_DECL_STRLCPY
155 extern size_t strlcpy(char *,const char *,size_t);
156 #endif
157 
158 #if defined(MAGICKCORE_HAVE_VSNPRINTF) && defined(MAGICKCORE_HAVE_DECL_VSNPRINTF) && !MAGICKCORE_HAVE_DECL_VSNPRINTF
159 extern int vsnprintf(char *,size_t,const char *,va_list);
160 #endif
161 
162 #include "MagickWand/method-attribute.h"
163 
164 #if defined(MAGICKWAND_WINDOWS_SUPPORT) || defined(MAGICKWAND_POSIX_SUPPORT)
165 # include <sys/types.h>
166 # include <sys/stat.h>
167 # if defined(MAGICKWAND_POSIX_SUPPORT)
168 #  if defined(MAGICKCORE_HAVE_SYS_NDIR_H) || defined(MAGICKCORE_HAVE_SYS_DIR_H) || defined(MAGICKCORE_HAVE_NDIR_H)
169 #   define dirent direct
170 #   define NAMLEN(dirent) (dirent)->d_namlen
171 #   if defined(MAGICKCORE_HAVE_SYS_NDIR_H)
172 #    include <sys/ndir.h>
173 #   endif
174 #   if defined(MAGICKCORE_HAVE_SYS_DIR_H)
175 #    include <sys/dir.h>
176 #   endif
177 #   if defined(MAGICKCORE_HAVE_NDIR_H)
178 #    include <ndir.h>
179 #   endif
180 #  else
181 #   include <dirent.h>
182 #   define NAMLEN(dirent) strlen((dirent)->d_name)
183 #  endif
184 #  include <sys/wait.h>
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 "MagickWand/MagickWand.h"
194 # if !defined(MAGICKWAND_WINDOWS_SUPPORT)
195 #  include <sys/time.h>
196 # if defined(MAGICKCORE_HAVE_SYS_TIMES_H)
197 #  include <sys/times.h>
198 # endif
199 # if defined(MAGICKCORE_HAVE_SYS_RESOURCE_H)
200 #  include <sys/resource.h>
201 # endif
202 # if defined(MAGICKCORE_HAVE_SYS_MMAN_H)
203 #  include <sys/mman.h>
204 # endif
205 # if defined(MAGICKCORE_HAVE_SYS_SENDFILE_H)
206 #  include <sys/sendfile.h>
207 # endif
208 #endif
209 #else
210 # include <types.h>
211 # include <stat.h>
212 #endif
213 
214 #if defined(S_IRUSR) && defined(S_IWUSR)
215 # define S_MODE (S_IRUSR | S_IWUSR)
216 #elif defined (MAGICKWAND_WINDOWS_SUPPORT)
217 # define S_MODE (_S_IREAD | _S_IWRITE)
218 #else
219 # define S_MODE  0600
220 #endif
221 
222 #if defined(MAGICKWAND_WINDOWS_SUPPORT)
223 # include "MagickCore/nt-base.h"
224 #endif
225 
226 #undef HAVE_CONFIG_H
227 #undef gamma
228 #undef index
229 #undef pipe
230 #undef y1
231 
232 /*
233   Review these platform specific definitions.
234 */
235 #if defined(MAGICKWAND_POSIX_SUPPORT) && !defined(__OS2__)
236 # define DirectorySeparator  "/"
237 # define DirectoryListSeparator  ':'
238 # define EditorOptions  " -title \"Edit Image Comment\" -e vi"
239 # define Exit  exit
240 # define IsBasenameSeparator(c)  ((c) == '/' ? MagickTrue : MagickFalse)
241 # define X11_PREFERENCES_PATH  "~/."
242 # define ProcessPendingEvents(text)
243 # define ReadCommandlLine(argc,argv)
244 # define SetNotifyHandlers
245 #else
246 # if defined(__OS2__)
247 #   define DirectorySeparator  "\\"
248 #   define DirectoryListSeparator  ';'
249 # define EditorOptions  " -title \"Edit Image Comment\" -e vi"
250 # define Exit  exit
251 #  define IsBasenameSeparator(c) \
252   (((c) == '/') || ((c) == '\\') ? MagickTrue : MagickFalse)
253 # define PreferencesDefaults  "~\."
254 # define ProcessPendingEvents(text)
255 # define ReadCommandlLine(argc,argv)
256 # define SetNotifyHandlers
257 #endif
258 # if defined(MAGICKWAND_WINDOWS_SUPPORT)
259 #  define DirectorySeparator  "\\"
260 #  define DirectoryListSeparator  ';'
261 #  define EditorOptions ""
262 #  define IsBasenameSeparator(c) \
263   (((c) == '/') || ((c) == '\\') ? MagickTrue : MagickFalse)
264 #  define ProcessPendingEvents(text)
265 #  if !defined(X11_PREFERENCES_PATH)
266 #    define X11_PREFERENCES_PATH  "~\\."
267 #  endif
268 #  define ReadCommandlLine(argc,argv)
269 #  define SetNotifyHandlers \
270     SetErrorHandler(NTErrorHandler); \
271     SetWarningHandler(NTWarningHandler)
272 # endif
273 
274 #endif
275 
276 /*
277   Define system symbols if not already defined.
278 */
279 #if !defined(STDIN_FILENO)
280 #define STDIN_FILENO  0x00
281 #endif
282 
283 #if !defined(O_BINARY)
284 #define O_BINARY  0x00
285 #endif
286 
287 #if !defined(PATH_MAX)
288 #define PATH_MAX  4096
289 #endif
290 
291 /*
292   Magick defines.
293 */
294 #define MAGICK_SSIZE_MAX  (SSIZE_MAX)
295 #define MAGICK_SSIZE_MIN  (-(SSIZE_MAX)-1)
296 #if defined(_MSC_VER)
297 # define DisableMSCWarning(nr) __pragma(warning(push)) \
298   __pragma(warning(disable:nr))
299 # define RestoreMSCWarning __pragma(warning(pop))
300 #else
301 # define DisableMSCWarning(nr)
302 # define RestoreMSCWarning
303 #endif
304 
305 #if defined(__cplusplus) || defined(c_plusplus)
306 }
307 #endif
308 
309 #endif
310