xref: /PHP-8.1/ext/gd/php_gd.h (revision cee33bab)
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    | https://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 #include "zend_string.h"
22 #include "php_streams.h"
23 
24 #if defined(HAVE_LIBGD) || defined(HAVE_GD_BUNDLED)
25 
26 /* open_basedir and safe_mode checks */
27 #define PHP_GD_CHECK_OPEN_BASEDIR(filename, errormsg)                       \
28 	if (!filename || php_check_open_basedir(filename)) {      \
29 		php_error_docref(NULL, E_WARNING, errormsg);      \
30 		RETURN_FALSE;                                               \
31 	}
32 
33 #define PHP_GDIMG_TYPE_GIF      1
34 #define PHP_GDIMG_TYPE_PNG      2
35 #define PHP_GDIMG_TYPE_JPG      3
36 #define PHP_GDIMG_TYPE_WBM      4
37 #define PHP_GDIMG_TYPE_XBM      5
38 #define PHP_GDIMG_TYPE_XPM      6
39 #define PHP_GDIMG_TYPE_GD       8
40 #define PHP_GDIMG_TYPE_GD2      9
41 #define PHP_GDIMG_TYPE_GD2PART  10
42 #define PHP_GDIMG_TYPE_WEBP     11
43 #define PHP_GDIMG_TYPE_BMP      12
44 #define PHP_GDIMG_TYPE_TGA      13
45 #define PHP_GDIMG_TYPE_AVIF     14
46 
47 #define PHP_IMG_GIF    1
48 #define PHP_IMG_JPG    2
49 #define PHP_IMG_JPEG   2
50 #define PHP_IMG_PNG    4
51 #define PHP_IMG_WBMP   8
52 #define PHP_IMG_XPM   16
53 #define PHP_IMG_WEBP  32
54 #define PHP_IMG_BMP   64
55 #define PHP_IMG_TGA  128
56 #define PHP_IMG_AVIF 256
57 
58 #ifdef PHP_WIN32
59 #	ifdef PHP_GD_EXPORTS
60 #		define PHP_GD_API __declspec(dllexport)
61 #	else
62 #		define PHP_GD_API __declspec(dllimport)
63 #	endif
64 #elif defined(__GNUC__) && __GNUC__ >= 4
65 #	define PHP_GD_API __attribute__ ((visibility("default")))
66 #else
67 #	define PHP_GD_API
68 #endif
69 
70 PHPAPI extern const char php_sig_gif[3];
71 PHPAPI extern const char php_sig_jpg[3];
72 PHPAPI extern const char php_sig_png[8];
73 PHPAPI extern const char php_sig_bmp[2];
74 PHPAPI extern const char php_sig_riff[4];
75 PHPAPI extern const char php_sig_webp[4];
76 PHPAPI extern const char php_sig_avif[4];
77 
78 extern zend_module_entry gd_module_entry;
79 #define phpext_gd_ptr &gd_module_entry
80 
81 #include "php_version.h"
82 #define PHP_GD_VERSION PHP_VERSION
83 
84 /* gd.c functions */
85 PHP_MINFO_FUNCTION(gd);
86 PHP_MINIT_FUNCTION(gd);
87 PHP_MSHUTDOWN_FUNCTION(gd);
88 PHP_RSHUTDOWN_FUNCTION(gd);
89 
90 PHP_GD_API struct gdImageStruct *php_gd_libgdimageptr_from_zval_p(zval* zp);
91 
92 #else
93 
94 #define phpext_gd_ptr NULL
95 
96 #endif
97 
98 #endif /* PHP_GD_H */
99