xref: /PHP-8.0/ext/gd/php_gd.h (revision 340e2ead)
1 /*
2    +----------------------------------------------------------------------+
3    | Copyright (c) The PHP Group                                          |
4    +----------------------------------------------------------------------+
5    | This source file is subject to version 3.01 of the PHP license,      |
6    | that is bundled with this package in the file LICENSE, and is        |
7    | available through the world-wide-web at the following url:           |
8    | http://www.php.net/license/3_01.txt                                  |
9    | If you did not receive a copy of the PHP license and are unable to   |
10    | obtain it through the world-wide-web, please send a note to          |
11    | license@php.net so we can mail you a copy immediately.               |
12    +----------------------------------------------------------------------+
13    | Authors: Rasmus Lerdorf <rasmus@php.net>                             |
14    |          Stig Bakken <ssb@php.net>                                   |
15    +----------------------------------------------------------------------+
16 */
17 
18 #ifndef PHP_GD_H
19 #define PHP_GD_H
20 
21 #if defined(HAVE_LIBGD) || defined(HAVE_GD_BUNDLED)
22 
23 /* open_basedir and safe_mode checks */
24 #define PHP_GD_CHECK_OPEN_BASEDIR(filename, errormsg)                       \
25 	if (!filename || php_check_open_basedir(filename)) {      \
26 		php_error_docref(NULL, E_WARNING, errormsg);      \
27 		RETURN_FALSE;                                               \
28 	}
29 
30 #define PHP_GDIMG_TYPE_GIF      1
31 #define PHP_GDIMG_TYPE_PNG      2
32 #define PHP_GDIMG_TYPE_JPG      3
33 #define PHP_GDIMG_TYPE_WBM      4
34 #define PHP_GDIMG_TYPE_XBM      5
35 #define PHP_GDIMG_TYPE_XPM      6
36 #define PHP_GDIMG_TYPE_GD       8
37 #define PHP_GDIMG_TYPE_GD2      9
38 #define PHP_GDIMG_TYPE_GD2PART  10
39 #define PHP_GDIMG_TYPE_WEBP     11
40 #define PHP_GDIMG_TYPE_BMP      12
41 #define PHP_GDIMG_TYPE_TGA      13
42 
43 #define PHP_IMG_GIF    1
44 #define PHP_IMG_JPG    2
45 #define PHP_IMG_JPEG   2
46 #define PHP_IMG_PNG    4
47 #define PHP_IMG_WBMP   8
48 #define PHP_IMG_XPM   16
49 #define PHP_IMG_WEBP  32
50 #define PHP_IMG_BMP   64
51 #define PHP_IMG_TGA  128
52 
53 #ifdef PHP_WIN32
54 #	ifdef PHP_GD_EXPORTS
55 #		define PHP_GD_API __declspec(dllexport)
56 #	else
57 #		define PHP_GD_API __declspec(dllimport)
58 #	endif
59 #elif defined(__GNUC__) && __GNUC__ >= 4
60 #	define PHP_GD_API __attribute__ ((visibility("default")))
61 #else
62 #	define PHP_GD_API
63 #endif
64 
65 PHPAPI extern const char php_sig_gif[3];
66 PHPAPI extern const char php_sig_jpg[3];
67 PHPAPI extern const char php_sig_png[8];
68 PHPAPI extern const char php_sig_bmp[2];
69 PHPAPI extern const char php_sig_riff[4];
70 PHPAPI extern const char php_sig_webp[4];
71 
72 extern zend_module_entry gd_module_entry;
73 #define phpext_gd_ptr &gd_module_entry
74 
75 #include "php_version.h"
76 #define PHP_GD_VERSION PHP_VERSION
77 
78 /* gd.c functions */
79 PHP_MINFO_FUNCTION(gd);
80 PHP_MINIT_FUNCTION(gd);
81 PHP_MSHUTDOWN_FUNCTION(gd);
82 PHP_RSHUTDOWN_FUNCTION(gd);
83 
84 PHP_GD_API struct gdImageStruct *php_gd_libgdimageptr_from_zval_p(zval* zp);
85 
86 #else
87 
88 #define phpext_gd_ptr NULL
89 
90 #endif
91 
92 #endif /* PHP_GD_H */
93