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