studio.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. /*
  2. Copyright 1999 ImageMagick Studio LLC, a non-profit organization
  3. dedicated to making software imaging solutions freely available.
  4. You may not use this file except in compliance with the License. You may
  5. obtain a copy of the License at
  6. https://imagemagick.org/script/license.php
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. MagickCore private application programming interface declarations.
  13. */
  14. #ifndef MAGICKCORE_STUDIO_H
  15. #define MAGICKCORE_STUDIO_H
  16. #if defined(__cplusplus) || defined(c_plusplus)
  17. extern "C" {
  18. #endif
  19. #if defined(WIN32) || defined(WIN64)
  20. # define MAGICKCORE_WINDOWS_SUPPORT
  21. #else
  22. # define MAGICKCORE_POSIX_SUPPORT
  23. #endif
  24. #define MAGICKCORE_IMPLEMENTATION 1
  25. #if !defined(MAGICKCORE_CONFIG_H)
  26. # define MAGICKCORE_CONFIG_H
  27. # if !defined(vms) && !defined(macintosh)
  28. # include "magick/magick-config.h"
  29. # else
  30. # include "magick-config.h"
  31. # endif
  32. #if defined(MAGICKCORE__FILE_OFFSET_BITS) && !defined(_FILE_OFFSET_BITS)
  33. # define _FILE_OFFSET_BITS MAGICKCORE__FILE_OFFSET_BITS
  34. #endif
  35. #if defined(_magickcore_const) && !defined(const)
  36. # define const _magickcore_const
  37. #endif
  38. #if defined(_magickcore_inline) && !defined(inline)
  39. # define inline _magickcore_inline
  40. #endif
  41. # if defined(__cplusplus) || defined(c_plusplus)
  42. # undef inline
  43. # endif
  44. #endif
  45. #if defined(MAGICKCORE_NAMESPACE_PREFIX)
  46. # include "magick/methods.h"
  47. #endif
  48. #if !defined(const)
  49. # define STDC
  50. #endif
  51. /* Define to 1 if assertions should be disabled. */
  52. #if defined(MAGICKCORE_NDEBUG)
  53. #define NDEBUG 1
  54. #endif
  55. #include <stdarg.h>
  56. #include <stdio.h>
  57. #if defined(MAGICKCORE_HAVE_SYS_STAT_H)
  58. # include <sys/stat.h>
  59. #endif
  60. #if defined(MAGICKCORE_STDC_HEADERS)
  61. # include <stdlib.h>
  62. # include <stddef.h>
  63. #else
  64. # if defined(MAGICKCORE_HAVE_STDLIB_H)
  65. # include <stdlib.h>
  66. # endif
  67. #endif
  68. #if !defined(magick_restrict)
  69. # if !defined(_magickcore_restrict)
  70. # define magick_restrict restrict
  71. # else
  72. # define magick_restrict _magickcore_restrict
  73. # endif
  74. #endif
  75. #if defined(MAGICKCORE_HAVE_STRING_H)
  76. # if !defined(STDC_HEADERS) && defined(MAGICKCORE_HAVE_MEMORY_H)
  77. # include <memory.h>
  78. # endif
  79. # include <string.h>
  80. #endif
  81. #if defined(MAGICKCORE_HAVE_STRINGS_H)
  82. # include <strings.h>
  83. #endif
  84. #if defined(MAGICKCORE_HAVE_INTTYPES_H)
  85. # include <inttypes.h>
  86. #endif
  87. #if defined(MAGICKCORE_HAVE_STDINT_H)
  88. # include <stdint.h>
  89. #endif
  90. #if defined(MAGICKCORE_HAVE_UNISTD_H)
  91. # include <unistd.h>
  92. #endif
  93. #if defined(MAGICKCORE_WINDOWS_SUPPORT) && defined(_DEBUG)
  94. #define _CRTDBG_MAP_ALLOC
  95. #endif
  96. #if defined(MAGICKCORE_WINDOWS_SUPPORT)
  97. # include <io.h>
  98. #if !defined(__CYGWIN__)
  99. # include <direct.h>
  100. #endif
  101. # if !defined(MAGICKCORE_HAVE_STRERROR)
  102. # define HAVE_STRERROR
  103. # endif
  104. #endif
  105. #include <ctype.h>
  106. #include <locale.h>
  107. #include <errno.h>
  108. #include <fcntl.h>
  109. #include <math.h>
  110. #include <time.h>
  111. #include <limits.h>
  112. #include <signal.h>
  113. #include <assert.h>
  114. #if defined(MAGICKCORE_HAVE_XLOCALE_H)
  115. # include <xlocale.h>
  116. #endif
  117. #if defined(MAGICKCORE_THREAD_SUPPORT)
  118. # include <pthread.h>
  119. #endif
  120. #if defined(MAGICKCORE_WINDOWS_SUPPORT)
  121. #if !defined(__CYGWIN__)
  122. #include <winsock2.h>
  123. #include <ws2tcpip.h>
  124. #endif
  125. #include <windows.h>
  126. #ifdef _MSC_VER
  127. #pragma comment (lib, "ws2_32.lib")
  128. #endif
  129. #endif
  130. #if defined(MAGICKCORE_HAVE_SYS_SYSLIMITS_H)
  131. # include <sys/syslimits.h>
  132. #endif
  133. #if defined(MAGICKCORE_HAVE_ARM_LIMITS_H)
  134. # include <arm/limits.h>
  135. #endif
  136. #if defined(MAGICKCORE_HAVE_CL_CL_H) && !defined(MAGICK_PIXEL_RGBA)
  137. # define MAGICKCORE_OPENCL_SUPPORT 1
  138. #endif
  139. #if defined(MAGICKCORE_HAVE_OPENCL_CL_H) && !defined(MAGICK_PIXEL_RGBA)
  140. # define MAGICKCORE_OPENCL_SUPPORT 1
  141. #endif
  142. #if defined(_OPENMP) && ((_OPENMP >= 200203) || defined(__OPENCC__))
  143. # include <omp.h>
  144. # define MAGICKCORE_OPENMP_SUPPORT 1
  145. #endif
  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. #if defined(MAGICKCORE_HAVE_PWRITE) && defined(MAGICKCORE_HAVE_DECL_PWRITE) && !MAGICKCORE_HAVE_DECL_PWRITE
  150. ssize_t pwrite(int,const void *,size_t,off_t);
  151. #endif
  152. #if defined(MAGICKCORE_HAVE_STRLCPY) && defined(MAGICKCORE_HAVE_DECL_STRLCPY) && !MAGICKCORE_HAVE_DECL_STRLCPY
  153. extern size_t strlcpy(char *,const char *,size_t);
  154. #endif
  155. #if defined(MAGICKCORE_HAVE_VSNPRINTF) && defined(MAGICKCORE_HAVE_DECL_VSNPRINTF) && !MAGICKCORE_HAVE_DECL_VSNPRINTF
  156. extern int vsnprintf(char *,size_t,const char *,va_list);
  157. #endif
  158. #include "magick/method-attribute.h"
  159. #if defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(MAGICKCORE_POSIX_SUPPORT)
  160. # include <sys/types.h>
  161. # include <sys/stat.h>
  162. # if defined(MAGICKCORE_POSIX_SUPPORT)
  163. # if defined(MAGICKCORE_HAVE_SYS_NDIR_H) || defined(MAGICKCORE_HAVE_SYS_DIR_H) || defined(MAGICKCORE_HAVE_NDIR_H)
  164. # define dirent direct
  165. # define NAMLEN(dirent) (dirent)->d_namlen
  166. # if defined(MAGICKCORE_HAVE_SYS_NDIR_H)
  167. # include <sys/ndir.h>
  168. # endif
  169. # if defined(MAGICKCORE_HAVE_SYS_DIR_H)
  170. # include <sys/dir.h>
  171. # endif
  172. # if defined(MAGICKCORE_HAVE_NDIR_H)
  173. # include <ndir.h>
  174. # endif
  175. # else
  176. # include <dirent.h>
  177. # define NAMLEN(dirent) strlen((dirent)->d_name)
  178. # endif
  179. # include <sys/wait.h>
  180. # include <pwd.h>
  181. # endif
  182. # if !defined(S_ISDIR)
  183. # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
  184. # endif
  185. # if !defined(S_ISREG)
  186. # define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
  187. # endif
  188. # include "magick/magick-type.h"
  189. # if !defined(MAGICKCORE_WINDOWS_SUPPORT)
  190. # include <sys/time.h>
  191. # if defined(MAGICKCORE_HAVE_SYS_TIMES_H)
  192. # include <sys/times.h>
  193. # endif
  194. # if defined(MAGICKCORE_HAVE_SYS_RESOURCE_H)
  195. # include <sys/resource.h>
  196. # endif
  197. # if defined(MAGICKCORE_HAVE_SYS_MMAN_H)
  198. # include <sys/mman.h>
  199. # endif
  200. # if defined(MAGICKCORE_HAVE_SYS_SENDFILE_H)
  201. # include <sys/sendfile.h>
  202. # endif
  203. # if defined(MAGICKCORE_HAVE_SYS_SOCKET_H)
  204. # include <sys/socket.h>
  205. # endif
  206. # if defined(MAGICKCORE_HAVE_SYS_UIO_H)
  207. # include <sys/uio.h>
  208. # endif
  209. #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
  220. # include "magick/magick-type.h"
  221. #endif
  222. #if defined(S_IRUSR) && defined(S_IWUSR)
  223. # define S_MODE (S_IRUSR | S_IWUSR)
  224. #elif defined (MAGICKCORE_WINDOWS_SUPPORT)
  225. # define S_MODE (_S_IREAD | _S_IWRITE)
  226. #else
  227. # define S_MODE 0600
  228. #endif
  229. #if defined(MAGICKCORE_WINDOWS_SUPPORT)
  230. # include "magick/nt-base.h"
  231. #endif
  232. #if defined(macintosh)
  233. # include "magick/mac.h"
  234. #endif
  235. #if defined(vms)
  236. # include "magick/vms.h"
  237. #endif
  238. #undef HAVE_CONFIG_H
  239. #undef gamma
  240. #undef index
  241. #undef pipe
  242. #undef y1
  243. /*
  244. Review these platform specific definitions.
  245. */
  246. #if ( defined(MAGICKCORE_POSIX_SUPPORT) && !defined(__OS2__) ) && !defined( __VMS )
  247. # define DirectorySeparator "/"
  248. # define DirectoryListSeparator ':'
  249. # define EditorOptions " -title \"Edit Image Comment\" -e vi"
  250. # define Exit exit
  251. # define IsBasenameSeparator(c) ((c) == '/' ? MagickTrue : MagickFalse)
  252. # define X11_PREFERENCES_PATH "~/."
  253. # define ProcessPendingEvents(text)
  254. # define ReadCommandlLine(argc,argv)
  255. # define SetNotifyHandlers
  256. #else
  257. # if defined(vms)
  258. # define X11_APPLICATION_PATH "decw$system_defaults:"
  259. # define DirectorySeparator ""
  260. # define DirectoryListSeparator ';'
  261. # define EditorOptions ""
  262. # define Exit exit
  263. # define IsBasenameSeparator(c) \
  264. (((c) == ']') || ((c) == ':') || ((c) == '/') ? MagickTrue : MagickFalse)
  265. # define MAGICKCORE_LIBRARY_ABSOLUTE_PATH "sys$login:"
  266. # define MAGICKCORE_SHARE_PATH "sys$login:"
  267. # define X11_PREFERENCES_PATH "decw$user_defaults:"
  268. # define ProcessPendingEvents(text)
  269. # define ReadCommandlLine(argc,argv)
  270. # define SetNotifyHandlers
  271. # endif
  272. # if defined(__OS2__)
  273. # define DirectorySeparator "\\"
  274. # define DirectoryListSeparator ';'
  275. # define EditorOptions " -title \"Edit Image Comment\" -e vi"
  276. # define Exit exit
  277. # define IsBasenameSeparator(c) \
  278. (((c) == '/') || ((c) == '\\') ? MagickTrue : MagickFalse)
  279. # define PreferencesDefaults "~\."
  280. # define ProcessPendingEvents(text)
  281. # define ReadCommandlLine(argc,argv)
  282. # define SetNotifyHandlers
  283. #endif
  284. # if defined(macintosh)
  285. # define X11_APPLICATION_PATH "/usr/lib/X11/app-defaults/"
  286. # define DirectorySeparator ":"
  287. # define DirectoryListSeparator ';'
  288. # define EditorOptions ""
  289. # define IsBasenameSeparator(c) ((c) == ':' ? MagickTrue : MagickFalse)
  290. # define MAGICKCORE_LIBRARY_ABSOLUTE_PATH ""
  291. # define MAGICKCORE_SHARE_PATH ""
  292. # define X11_PREFERENCES_PATH "~/."
  293. # if defined(DISABLE_SIOUX)
  294. # define ReadCommandlLine(argc,argv)
  295. # define SetNotifyHandlers \
  296. SetFatalErrorHandler(MacFatalErrorHandler); \
  297. SetErrorHandler(MACErrorHandler); \
  298. SetWarningHandler(MACWarningHandler)
  299. # else
  300. # define ReadCommandlLine(argc,argv) argc=ccommand(argv); puts(MagickVersion);
  301. # define SetNotifyHandlers \
  302. SetErrorHandler(MACErrorHandler); \
  303. SetWarningHandler(MACWarningHandler)
  304. # endif
  305. # endif
  306. # if defined(MAGICKCORE_WINDOWS_SUPPORT)
  307. # define DirectorySeparator "\\"
  308. # define DirectoryListSeparator ';'
  309. # define EditorOptions ""
  310. # define IsBasenameSeparator(c) \
  311. (((c) == '/') || ((c) == '\\') ? MagickTrue : MagickFalse)
  312. # define ProcessPendingEvents(text)
  313. # if !defined(X11_PREFERENCES_PATH)
  314. # define X11_PREFERENCES_PATH "~\\."
  315. # endif
  316. # define ReadCommandlLine(argc,argv)
  317. # define SetNotifyHandlers \
  318. SetErrorHandler(NTErrorHandler); \
  319. SetWarningHandler(NTWarningHandler)
  320. # if !defined(MAGICKCORE_HAVE_TIFFCONF_H)
  321. # define HAVE_TIFFCONF_H
  322. # endif
  323. # endif
  324. #endif
  325. /*
  326. Define system symbols if not already defined.
  327. */
  328. #if !defined(STDIN_FILENO)
  329. #define STDIN_FILENO 0x00
  330. #endif
  331. #if !defined(O_BINARY)
  332. #define O_BINARY 0x00
  333. #endif
  334. #if !defined(PATH_MAX)
  335. #define PATH_MAX 4096
  336. #endif
  337. #if defined(MAGICKCORE_LTDL_DELEGATE) || (defined(MAGICKCORE_WINDOWS_SUPPORT) && defined(_DLL) && !defined(_LIB))
  338. # define MAGICKCORE_MODULES_SUPPORT
  339. #endif
  340. #if defined(_MAGICKMOD_)
  341. # undef MAGICKCORE_BUILD_MODULES
  342. # define MAGICKCORE_BUILD_MODULES
  343. #endif
  344. /*
  345. Magick defines.
  346. */
  347. #define MagickMaxRecursionDepth 600
  348. #define Swap(x,y) ((x)^=(y), (y)^=(x), (x)^=(y))
  349. #if defined(_MSC_VER)
  350. # define DisableMSCWarning(nr) __pragma(warning(push)) \
  351. __pragma(warning(disable:nr))
  352. # define RestoreMSCWarning __pragma(warning(pop))
  353. #else
  354. # define DisableMSCWarning(nr)
  355. # define RestoreMSCWarning
  356. #endif
  357. #if defined(__cplusplus) || defined(c_plusplus)
  358. }
  359. #endif
  360. #endif