xref: /PHP-7.0/ext/xsl/php_xsl.h (revision 478f119a)
1 /*
2   +----------------------------------------------------------------------+
3   | PHP Version 7                                                        |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 1997-2017 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 /* $Id$ */
20 
21 #ifndef PHP_XSL_H
22 #define PHP_XSL_H
23 
24 extern zend_module_entry xsl_module_entry;
25 #define phpext_xsl_ptr &xsl_module_entry
26 
27 #include "php_version.h"
28 #define PHP_XSL_VERSION PHP_VERSION
29 
30 #ifdef ZTS
31 #include "TSRM.h"
32 #endif
33 
34 #include <libxslt/xsltconfig.h>
35 #include <libxslt/xsltInternals.h>
36 #include <libxslt/xsltutils.h>
37 #include <libxslt/transform.h>
38 #include <libxslt/security.h>
39 #if HAVE_XSL_EXSLT
40 #include <libexslt/exslt.h>
41 #include <libexslt/exsltconfig.h>
42 #endif
43 
44 #include "../dom/xml_common.h"
45 #include "xsl_fe.h"
46 
47 #include <libxslt/extensions.h>
48 #include <libxml/xpathInternals.h>
49 
50 #define XSL_SECPREF_NONE 0
51 #define XSL_SECPREF_READ_FILE 2
52 #define XSL_SECPREF_WRITE_FILE 4
53 #define XSL_SECPREF_CREATE_DIRECTORY 8
54 #define XSL_SECPREF_READ_NETWORK 16
55 #define XSL_SECPREF_WRITE_NETWORK 32
56 /* Default == disable all write access ==  XSL_SECPREF_WRITE_NETWORK | XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE */
57 #define XSL_SECPREF_DEFAULT 44
58 
59 typedef struct _xsl_object {
60 	void *ptr;
61 	HashTable *prop_handler;
62 	zval handle;
63 	HashTable *parameter;
64 	int hasKeys;
65 	int registerPhpFunctions;
66 	HashTable *registered_phpfunctions;
67 	HashTable *node_list;
68 	php_libxml_node_object *doc;
69 	char *profiling;
70 	zend_long securityPrefs;
71 	int securityPrefsSet;
72 	zend_object  std;
73 } xsl_object;
74 
php_xsl_fetch_object(zend_object * obj)75 static inline xsl_object *php_xsl_fetch_object(zend_object *obj) {
76 	return (xsl_object *)((char*)(obj) - XtOffsetOf(xsl_object, std));
77 }
78 
79 #define Z_XSL_P(zv) php_xsl_fetch_object(Z_OBJ_P((zv)))
80 
81 void php_xsl_set_object(zval *wrapper, void *obj);
82 void xsl_objects_free_storage(zend_object *object);
83 void php_xsl_create_object(xsltStylesheetPtr obj, zval *wrapper_in, zval *return_value );
84 
85 void xsl_ext_function_string_php(xmlXPathParserContextPtr ctxt, int nargs);
86 void xsl_ext_function_object_php(xmlXPathParserContextPtr ctxt, int nargs);
87 
88 #define REGISTER_XSL_CLASS(ce, name, parent_ce, funcs, entry) \
89 INIT_CLASS_ENTRY(ce, name, funcs); \
90 ce.create_object = xsl_objects_new; \
91 entry = zend_register_internal_class_ex(&ce, parent_ce);
92 
93 #define XSL_DOMOBJ_NEW(zval, obj, ret) \
94 	zval = php_xsl_create_object(obj, ret, zval, return_value); \
95 	if (ZVAL_IS_NULL(zval)) { \
96 		php_error_docref(NULL, E_WARNING, "Cannot create required DOM object"); \
97 		RETURN_FALSE; \
98 	}
99 
100 
101 PHP_MINIT_FUNCTION(xsl);
102 PHP_MSHUTDOWN_FUNCTION(xsl);
103 PHP_RINIT_FUNCTION(xsl);
104 PHP_RSHUTDOWN_FUNCTION(xsl);
105 PHP_MINFO_FUNCTION(xsl);
106 
107 
108 /*
109   	Declare any global variables you may need between the BEGIN
110 	and END macros here:
111 
112 ZEND_BEGIN_MODULE_GLOBALS(xsl)
113 	long  global_value;
114 	char *global_string;
115 ZEND_END_MODULE_GLOBALS(xsl)
116 */
117 
118 /* In every utility function you add that needs to use variables
119    in php_xsl_globals, call TSRM_FETCH(); after declaring other
120    variables used by that function, or better yet, pass in
121    after the last function argument and declare your utility function
122    with after the last declared argument.  Always refer to
123    the globals in your function as XSL_G(variable).  You are
124    encouraged to rename these macros something shorter, see
125    examples in any other php module directory.
126 */
127 
128 #ifdef ZTS
129 #define XSL_G(v) TSRMG(xsl_globals_id, zend_xsl_globals *, v)
130 #else
131 #define XSL_G(v) (xsl_globals.v)
132 #endif
133 
134 #endif	/* PHP_XSL_H */
135 
136 
137 /*
138  * Local variables:
139  * tab-width: 4
140  * c-basic-offset: 4
141  * End:
142  * vim600: noet sw=4 ts=4 fdm=marker
143  * vim<600: noet sw=4 ts=4
144  */
145