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 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) 22 extern "C" { 23 #endif 24 25 #if defined(WIN32) || defined(WIN64) 26 # define MAGICKCORE_WINDOWS_SUPPORT 27 #else 28 # define MAGICKCORE_POSIX_SUPPORT 29 #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) 36 # include "magick/magick-config.h" 37 # 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) 44 # define const _magickcore_const 45 #endif 46 #if defined(_magickcore_inline) && !defined(inline) 47 # define inline _magickcore_inline 48 #endif 49 # if defined(__cplusplus) || defined(c_plusplus) 50 # undef inline 51 # endif 52 #endif 53 54 #if defined(MAGICKCORE_NAMESPACE_PREFIX) 55 # include "magick/methods.h" 56 #endif 57 58 #if !defined(const) 59 # define STDC 60 #endif 61 62 #include <stdarg.h> 63 #include <stdio.h> 64 #if defined(MAGICKCORE_HAVE_SYS_STAT_H) 65 # include <sys/stat.h> 66 #endif 67 #if defined(MAGICKCORE_STDC_HEADERS) 68 # include <stdlib.h> 69 # include <stddef.h> 70 #else 71 # if defined(MAGICKCORE_HAVE_STDLIB_H) 72 # include <stdlib.h> 73 # endif 74 #endif 75 #if !defined(magick_restrict) 76 # if !defined(_magickcore_restrict) 77 # define magick_restrict restrict 78 # else 79 # define magick_restrict _magickcore_restrict 80 # endif 81 #endif 82 #if defined(MAGICKCORE_HAVE_STRING_H) 83 # if !defined(STDC_HEADERS) && defined(MAGICKCORE_HAVE_MEMORY_H) 84 # include <memory.h> 85 # endif 86 # include <string.h> 87 #endif 88 #if defined(MAGICKCORE_HAVE_STRINGS_H) 89 # include <strings.h> 90 #endif 91 #if defined(MAGICKCORE_HAVE_INTTYPES_H) 92 # include <inttypes.h> 93 #endif 94 #if defined(MAGICKCORE_HAVE_STDINT_H) 95 # include <stdint.h> 96 #endif 97 #if defined(MAGICKCORE_HAVE_UNISTD_H) 98 # include <unistd.h> 99 #endif 100 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && defined(_DEBUG) 101 #define _CRTDBG_MAP_ALLOC 102 #endif 103 #if defined(MAGICKCORE_WINDOWS_SUPPORT) 104 # include <io.h> 105 #if !defined(__CYGWIN__) 106 # include <direct.h> 107 #endif 108 # if !defined(MAGICKCORE_HAVE_STRERROR) 109 # define HAVE_STRERROR 110 # endif 111 #endif 112 113 #include <ctype.h> 114 #include <locale.h> 115 #include <errno.h> 116 #include <fcntl.h> 117 #include <math.h> 118 #include <time.h> 119 #include <limits.h> 120 #include <signal.h> 121 #include <assert.h> 122 123 #if defined(MAGICKCORE_HAVE_XLOCALE_H) 124 # include <xlocale.h> 125 #endif 126 #if defined(MAGICKCORE_THREAD_SUPPORT) 127 # include <pthread.h> 128 #endif 129 #if defined(MAGICKCORE_WINDOWS_SUPPORT) 130 #if !defined(__CYGWIN__) 131 #include <winsock2.h> 132 #include <ws2tcpip.h> 133 #endif 134 #include <windows.h> 135 #ifdef _MSC_VER 136 #pragma comment (lib, "ws2_32.lib") 137 #endif 138 #endif 139 #if defined(MAGICKCORE_HAVE_SYS_SYSLIMITS_H) 140 # include <sys/syslimits.h> 141 #endif 142 #if defined(MAGICKCORE_HAVE_ARM_LIMITS_H) 143 # include <arm/limits.h> 144 #endif 145 146 #if defined(MAGICKCORE_HAVE_CL_CL_H) && !defined(MAGICK_PIXEL_RGBA) 147 # include <CL/cl.h> 148 # define MAGICKCORE_OPENCL_SUPPORT 1 149 #endif 150 #if defined(MAGICKCORE_HAVE_OPENCL_CL_H) && !defined(MAGICK_PIXEL_RGBA) 151 # include <OpenCL/cl.h> 152 # define MAGICKCORE_OPENCL_SUPPORT 1 153 #endif 154 155 #if defined(_OPENMP) && ((_OPENMP >= 200203) || defined(__OPENCC__)) 156 # include <omp.h> 157 # define MAGICKCORE_OPENMP_SUPPORT 1 158 #endif 159 160 #if defined(MAGICKCORE_HAVE_PREAD) && defined(MAGICKCORE_HAVE_DECL_PREAD) && !MAGICKCORE_HAVE_DECL_PREAD 161 ssize_t pread(int,void *,size_t,off_t); 162 #endif 163 164 #if defined(MAGICKCORE_HAVE_PWRITE) && defined(MAGICKCORE_HAVE_DECL_PWRITE) && !MAGICKCORE_HAVE_DECL_PWRITE 165 ssize_t pwrite(int,const void *,size_t,off_t); 166 #endif 167 168 #if defined(MAGICKCORE_HAVE_STRLCPY) && defined(MAGICKCORE_HAVE_DECL_STRLCPY) && !MAGICKCORE_HAVE_DECL_STRLCPY 169 extern size_t strlcpy(char *,const char *,size_t); 170 #endif 171 172 #if defined(MAGICKCORE_HAVE_VSNPRINTF) && defined(MAGICKCORE_HAVE_DECL_VSNPRINTF) && !MAGICKCORE_HAVE_DECL_VSNPRINTF 173 extern int vsnprintf(char *,size_t,const char *,va_list); 174 #endif 175 176 #include "magick/method-attribute.h" 177 178 #if defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(MAGICKCORE_POSIX_SUPPORT) 179 # include <sys/types.h> 180 # include <sys/stat.h> 181 # if defined(MAGICKCORE_POSIX_SUPPORT) 182 # if defined(MAGICKCORE_HAVE_SYS_NDIR_H) || defined(MAGICKCORE_HAVE_SYS_DIR_H) || defined(MAGICKCORE_HAVE_NDIR_H) 183 # define dirent direct 184 # define NAMLEN(dirent) (dirent)->d_namlen 185 # if defined(MAGICKCORE_HAVE_SYS_NDIR_H) 186 # include <sys/ndir.h> 187 # endif 188 # if defined(MAGICKCORE_HAVE_SYS_DIR_H) 189 # include <sys/dir.h> 190 # endif 191 # if defined(MAGICKCORE_HAVE_NDIR_H) 192 # include <ndir.h> 193 # endif 194 # else 195 # include <dirent.h> 196 # define NAMLEN(dirent) strlen((dirent)->d_name) 197 # endif 198 # include <sys/wait.h> 199 # include <pwd.h> 200 # endif 201 # if !defined(S_ISDIR) 202 # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) 203 # endif 204 # if !defined(S_ISREG) 205 # define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) 206 # endif 207 # include "magick/magick-type.h" 208 # if !defined(MAGICKCORE_WINDOWS_SUPPORT) 209 # include <sys/time.h> 210 # if defined(MAGICKCORE_HAVE_SYS_TIMES_H) 211 # include <sys/times.h> 212 # endif 213 # if defined(MAGICKCORE_HAVE_SYS_RESOURCE_H) 214 # include <sys/resource.h> 215 # endif 216 # if defined(MAGICKCORE_HAVE_SYS_MMAN_H) 217 # include <sys/mman.h> 218 # endif 219 # if defined(MAGICKCORE_HAVE_SYS_SENDFILE_H) 220 # include <sys/sendfile.h> 221 # endif 222 # if defined(MAGICKCORE_HAVE_SYS_SOCKET_H) 223 # include <sys/socket.h> 224 # endif 225 # if defined(MAGICKCORE_HAVE_SYS_UIO_H) 226 # include <sys/uio.h> 227 # endif 228 #endif 229 #else 230 # include <types.h> 231 # include <stat.h> 232 # if defined(macintosh) 233 # if !defined(DISABLE_SIOUX) 234 # include <SIOUX.h> 235 # include <console.h> 236 # endif 237 # include <unix.h> 238 # endif 239 # include "magick/magick-type.h" 240 #endif 241 242 #if defined(S_IRUSR) && defined(S_IWUSR) 243 # define S_MODE (S_IRUSR | S_IWUSR) 244 #elif defined (MAGICKCORE_WINDOWS_SUPPORT) 245 # define S_MODE (_S_IREAD | _S_IWRITE) 246 #else 247 # define S_MODE 0600 248 #endif 249 250 #if defined(MAGICKCORE_WINDOWS_SUPPORT) 251 # include "magick/nt-base.h" 252 #endif 253 #if defined(macintosh) 254 # include "magick/mac.h" 255 #endif 256 #if defined(vms) 257 # include "magick/vms.h" 258 #endif 259 260 #undef HAVE_CONFIG_H 261 #undef gamma 262 #undef index 263 #undef pipe 264 #undef y1 265 266 /* 267 Review these platform specific definitions. 268 */ 269 #if ( defined(MAGICKCORE_POSIX_SUPPORT) && !defined(__OS2__) ) && !defined( __VMS ) 270 # define DirectorySeparator "/" 271 # define DirectoryListSeparator ':' 272 # define EditorOptions " -title \"Edit Image Comment\" -e vi" 273 # define Exit exit 274 # define IsBasenameSeparator(c) ((c) == '/' ? MagickTrue : MagickFalse) 275 # define X11_PREFERENCES_PATH "~/." 276 # define ProcessPendingEvents(text) 277 # define ReadCommandlLine(argc,argv) 278 # define SetNotifyHandlers 279 #else 280 # if defined(vms) 281 # define X11_APPLICATION_PATH "decw$system_defaults:" 282 # define DirectorySeparator "" 283 # define DirectoryListSeparator ';' 284 # define EditorOptions "" 285 # define Exit exit 286 # define IsBasenameSeparator(c) \ 287 (((c) == ']') || ((c) == ':') || ((c) == '/') ? MagickTrue : MagickFalse) 288 # define MAGICKCORE_LIBRARY_PATH "sys$login:" 289 # define MAGICKCORE_SHARE_PATH "sys$login:" 290 # define X11_PREFERENCES_PATH "decw$user_defaults:" 291 # define ProcessPendingEvents(text) 292 # define ReadCommandlLine(argc,argv) 293 # define SetNotifyHandlers 294 # endif 295 # if defined(__OS2__) 296 # define DirectorySeparator "\\" 297 # define DirectoryListSeparator ';' 298 # define EditorOptions " -title \"Edit Image Comment\" -e vi" 299 # define Exit exit 300 # define IsBasenameSeparator(c) \ 301 (((c) == '/') || ((c) == '\\') ? MagickTrue : MagickFalse) 302 # define PreferencesDefaults "~\." 303 # define ProcessPendingEvents(text) 304 # define ReadCommandlLine(argc,argv) 305 # define SetNotifyHandlers 306 #endif 307 # if defined(macintosh) 308 # define X11_APPLICATION_PATH "/usr/lib/X11/app-defaults/" 309 # define DirectorySeparator ":" 310 # define DirectoryListSeparator ';' 311 # define EditorOptions "" 312 # define IsBasenameSeparator(c) ((c) == ':' ? MagickTrue : MagickFalse) 313 # define MAGICKCORE_LIBRARY_PATH "" 314 # define MAGICKCORE_SHARE_PATH "" 315 # define X11_PREFERENCES_PATH "~/." 316 # if defined(DISABLE_SIOUX) 317 # define ReadCommandlLine(argc,argv) 318 # define SetNotifyHandlers \ 319 SetFatalErrorHandler(MacFatalErrorHandler); \ 320 SetErrorHandler(MACErrorHandler); \ 321 SetWarningHandler(MACWarningHandler) 322 # else 323 # define ReadCommandlLine(argc,argv) argc=ccommand(argv); puts(MagickVersion); 324 # define SetNotifyHandlers \ 325 SetErrorHandler(MACErrorHandler); \ 326 SetWarningHandler(MACWarningHandler) 327 # endif 328 # endif 329 # if defined(MAGICKCORE_WINDOWS_SUPPORT) 330 # define DirectorySeparator "\\" 331 # define DirectoryListSeparator ';' 332 # define EditorOptions "" 333 # define IsBasenameSeparator(c) \ 334 (((c) == '/') || ((c) == '\\') ? MagickTrue : MagickFalse) 335 # define ProcessPendingEvents(text) 336 # if !defined(X11_PREFERENCES_PATH) 337 # define X11_PREFERENCES_PATH "~\\." 338 # endif 339 # define ReadCommandlLine(argc,argv) 340 # define SetNotifyHandlers \ 341 SetErrorHandler(NTErrorHandler); \ 342 SetWarningHandler(NTWarningHandler) 343 # if !defined(MAGICKCORE_HAVE_TIFFCONF_H) 344 # define HAVE_TIFFCONF_H 345 # endif 346 # endif 347 348 #endif 349 350 /* 351 Define system symbols if not already defined. 352 */ 353 #if !defined(STDIN_FILENO) 354 #define STDIN_FILENO 0x00 355 #endif 356 357 #if !defined(O_BINARY) 358 #define O_BINARY 0x00 359 #endif 360 361 #if !defined(PATH_MAX) 362 #define PATH_MAX 4096 363 #endif 364 365 #if defined(MAGICKCORE_LTDL_DELEGATE) || (defined(MAGICKCORE_WINDOWS_SUPPORT) && defined(_DLL) && !defined(_LIB)) 366 # define MAGICKCORE_MODULES_SUPPORT 367 #endif 368 369 #if defined(_MAGICKMOD_) 370 # undef MAGICKCORE_BUILD_MODULES 371 # define MAGICKCORE_BUILD_MODULES 372 #endif 373 374 /* 375 Magick defines. 376 */ 377 #define MagickMaxRecursionDepth 600 378 #define MAGICK_SSIZE_MAX (SSIZE_MAX) 379 #define MAGICK_SSIZE_MIN (-(SSIZE_MAX)-1) 380 #define Swap(x,y) ((x)^=(y), (y)^=(x), (x)^=(y)) 381 #if defined(_MSC_VER) 382 # define DisableMSCWarning(nr) __pragma(warning(push)) \ 383 __pragma(warning(disable:nr)) 384 # define RestoreMSCWarning __pragma(warning(pop)) 385 #else 386 # define DisableMSCWarning(nr) 387 # define RestoreMSCWarning 388 #endif 389 390 #if defined(__cplusplus) || defined(c_plusplus) 391 } 392 #endif 393 394 #endif 395