xref: /php-src/ext/dom/xpath_callbacks.h (revision 90785dd8)
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: Niels Dossche <nielsdos@php.net>                            |
14    +----------------------------------------------------------------------+
15 */
16 
17 #ifndef PHP_DOM_XPATH_CALLBACKS_H
18 #define PHP_DOM_XPATH_CALLBACKS_H
19 
20 #if defined(HAVE_LIBXML) && defined(HAVE_DOM)
21 
22 #include <libxml/xpathInternals.h>
23 #include "xml_common.h"
24 
25 typedef enum {
26 	PHP_DOM_REG_FUNC_MODE_NONE = 0,
27 	PHP_DOM_REG_FUNC_MODE_ALL,
28 	PHP_DOM_REG_FUNC_MODE_SET,
29 } php_dom_register_functions_mode;
30 
31 typedef enum {
32 	PHP_DOM_XPATH_EVALUATE_NODESET_TO_STRING,
33 	PHP_DOM_XPATH_EVALUATE_NODESET_TO_NODESET,
34 } php_dom_xpath_nodeset_evaluation_mode;
35 
36 typedef void (*php_dom_xpath_callbacks_proxy_factory)(xmlNodePtr node, zval *proxy, dom_object *intern, xmlXPathParserContextPtr ctxt);
37 typedef void (*php_dom_xpath_callbacks_register_func_ctx)(void *ctxt, const zend_string *ns, const zend_string *name);
38 
39 typedef struct {
40 	HashTable functions;
41 	php_dom_register_functions_mode mode;
42 } php_dom_xpath_callback_ns;
43 
44 typedef struct {
45 	php_dom_xpath_callback_ns *php_ns;
46 	HashTable *namespaces;
47 	HashTable *node_list;
48 } php_dom_xpath_callbacks;
49 
50 typedef enum {
51 	PHP_DOM_XPATH_CALLBACK_NAME_VALIDATE_NULLS,
52 	PHP_DOM_XPATH_CALLBACK_NAME_VALIDATE_NCNAME,
53 } php_dom_xpath_callback_name_validation;
54 
55 PHP_DOM_EXPORT void php_dom_xpath_callbacks_ctor(php_dom_xpath_callbacks *registry);
56 PHP_DOM_EXPORT void php_dom_xpath_callbacks_dtor(php_dom_xpath_callbacks *registry);
57 PHP_DOM_EXPORT void php_dom_xpath_callbacks_clean_node_list(php_dom_xpath_callbacks *registry);
58 PHP_DOM_EXPORT void php_dom_xpath_callbacks_clean_argument_stack(xmlXPathParserContextPtr ctxt, uint32_t num_args);
59 PHP_DOM_EXPORT void php_dom_xpath_callbacks_get_gc(php_dom_xpath_callbacks *registry, zend_get_gc_buffer *gc_buffer);
60 PHP_DOM_EXPORT HashTable *php_dom_xpath_callbacks_get_gc_for_whole_object(php_dom_xpath_callbacks *registry, zend_object *object, zval **table, int *n);
61 PHP_DOM_EXPORT void php_dom_xpath_callbacks_delayed_lib_registration(const php_dom_xpath_callbacks* registry, void *ctxt, php_dom_xpath_callbacks_register_func_ctx register_func);
62 PHP_DOM_EXPORT zend_result php_dom_xpath_callbacks_update_method_handler(php_dom_xpath_callbacks* registry, xmlXPathContextPtr ctxt, zend_string *ns, zend_string *name, const HashTable *callable_ht, php_dom_xpath_callback_name_validation name_validation, php_dom_xpath_callbacks_register_func_ctx register_func);
63 PHP_DOM_EXPORT zend_result php_dom_xpath_callbacks_update_single_method_handler(php_dom_xpath_callbacks* registry, xmlXPathContextPtr ctxt, zend_string *ns, zend_string *name, const zend_fcall_info_cache *fcc, php_dom_xpath_callback_name_validation name_validation, php_dom_xpath_callbacks_register_func_ctx register_func);
64 PHP_DOM_EXPORT zend_result php_dom_xpath_callbacks_call_php_ns(php_dom_xpath_callbacks *xpath_callbacks, xmlXPathParserContextPtr ctxt, int num_args, php_dom_xpath_nodeset_evaluation_mode evaluation_mode, dom_object *intern, php_dom_xpath_callbacks_proxy_factory proxy_factory);
65 PHP_DOM_EXPORT zend_result php_dom_xpath_callbacks_call_custom_ns(php_dom_xpath_callbacks *xpath_callbacks, xmlXPathParserContextPtr ctxt, int num_args, php_dom_xpath_nodeset_evaluation_mode evaluation_mode, dom_object *intern, php_dom_xpath_callbacks_proxy_factory proxy_factory);
66 
67 #endif
68 #endif
69