xref: /PHP-7.4/ext/xsl/php_xsl.h (revision 5aa11762)
1 /*
2   +----------------------------------------------------------------------+
3   | PHP Version 7                                                        |
4   +----------------------------------------------------------------------+
5   | Copyright (c) The PHP Group                                          |
6   +----------------------------------------------------------------------+
7   | This source file is subject to version 3.01 of the PHP license,      |
8   | that is bundled with this package in the file LICENSE, and is        |
9   | available through the world-wide-web at the following url:           |
10   | http://www.php.net/license/3_01.txt                                  |
11   | If you did not receive a copy of the PHP license and are unable to   |
12   | obtain it through the world-wide-web, please send a note to          |
13   | license@php.net so we can mail you a copy immediately.               |
14   +----------------------------------------------------------------------+
15   | Author:                                                              |
16   +----------------------------------------------------------------------+
17 */
18 
19 #ifndef PHP_XSL_H
20 #define PHP_XSL_H
21 
22 extern zend_module_entry xsl_module_entry;
23 #define phpext_xsl_ptr &xsl_module_entry
24 
25 #include "php_version.h"
26 #define PHP_XSL_VERSION PHP_VERSION
27 
28 #ifdef ZTS
29 #include "TSRM.h"
30 #endif
31 
32 #include <libxslt/xsltconfig.h>
33 #include <libxslt/xsltInternals.h>
34 #include <libxslt/xsltutils.h>
35 #include <libxslt/transform.h>
36 #include <libxslt/security.h>
37 #if HAVE_XSL_EXSLT
38 #include <libexslt/exslt.h>
39 #include <libexslt/exsltconfig.h>
40 #endif
41 
42 #include "../dom/xml_common.h"
43 #include "xsl_fe.h"
44 
45 #include <libxslt/extensions.h>
46 #include <libxml/xpathInternals.h>
47 
48 #define XSL_SECPREF_NONE 0
49 #define XSL_SECPREF_READ_FILE 2
50 #define XSL_SECPREF_WRITE_FILE 4
51 #define XSL_SECPREF_CREATE_DIRECTORY 8
52 #define XSL_SECPREF_READ_NETWORK 16
53 #define XSL_SECPREF_WRITE_NETWORK 32
54 /* Default == disable all write access ==  XSL_SECPREF_WRITE_NETWORK | XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE */
55 #define XSL_SECPREF_DEFAULT 44
56 
57 typedef struct _xsl_object {
58 	void *ptr;
59 	HashTable *prop_handler;
60 	zval handle;
61 	HashTable *parameter;
62 	int hasKeys;
63 	int registerPhpFunctions;
64 	HashTable *registered_phpfunctions;
65 	HashTable *node_list;
66 	php_libxml_node_object *doc;
67 	char *profiling;
68 	zend_long securityPrefs;
69 	int securityPrefsSet;
70 	zend_object  std;
71 } xsl_object;
72 
php_xsl_fetch_object(zend_object * obj)73 static inline xsl_object *php_xsl_fetch_object(zend_object *obj) {
74 	return (xsl_object *)((char*)(obj) - XtOffsetOf(xsl_object, std));
75 }
76 
77 #define Z_XSL_P(zv) php_xsl_fetch_object(Z_OBJ_P((zv)))
78 
79 void php_xsl_set_object(zval *wrapper, void *obj);
80 void xsl_objects_free_storage(zend_object *object);
81 void php_xsl_create_object(xsltStylesheetPtr obj, zval *wrapper_in, zval *return_value );
82 
83 void xsl_ext_function_string_php(xmlXPathParserContextPtr ctxt, int nargs);
84 void xsl_ext_function_object_php(xmlXPathParserContextPtr ctxt, int nargs);
85 
86 #define REGISTER_XSL_CLASS(ce, name, parent_ce, funcs, entry) \
87 INIT_CLASS_ENTRY(ce, name, funcs); \
88 ce.create_object = xsl_objects_new; \
89 entry = zend_register_internal_class_ex(&ce, parent_ce);
90 
91 #define XSL_DOMOBJ_NEW(zval, obj, ret) \
92 	zval = php_xsl_create_object(obj, ret, zval, return_value); \
93 	if (ZVAL_IS_NULL(zval)) { \
94 		php_error_docref(NULL, E_WARNING, "Cannot create required DOM object"); \
95 		RETURN_FALSE; \
96 	}
97 
98 
99 PHP_MINIT_FUNCTION(xsl);
100 PHP_MSHUTDOWN_FUNCTION(xsl);
101 PHP_RINIT_FUNCTION(xsl);
102 PHP_RSHUTDOWN_FUNCTION(xsl);
103 PHP_MINFO_FUNCTION(xsl);
104 
105 #endif	/* PHP_XSL_H */
106