Back to index

php5  5.3.10
entityreference.c
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | PHP Version 5                                                        |
00004    +----------------------------------------------------------------------+
00005    | Copyright (c) 1997-2012 The PHP Group                                |
00006    +----------------------------------------------------------------------+
00007    | This source file is subject to version 3.01 of the PHP license,      |
00008    | that is bundled with this package in the file LICENSE, and is        |
00009    | available through the world-wide-web at the following url:           |
00010    | http://www.php.net/license/3_01.txt                                  |
00011    | If you did not receive a copy of the PHP license and are unable to   |
00012    | obtain it through the world-wide-web, please send a note to          |
00013    | license@php.net so we can mail you a copy immediately.               |
00014    +----------------------------------------------------------------------+
00015    | Authors: Christian Stocker <chregu@php.net>                          |
00016    |          Rob Richards <rrichards@php.net>                            |
00017    +----------------------------------------------------------------------+
00018 */
00019 
00020 /* $Id: entityreference.c 321634 2012-01-01 13:15:04Z felipe $ */
00021 
00022 #ifdef HAVE_CONFIG_H
00023 #include "config.h"
00024 #endif
00025 
00026 #include "php.h"
00027 #if HAVE_LIBXML && HAVE_DOM
00028 #include "php_dom.h"
00029 
00030 /* {{{ arginfo */
00031 ZEND_BEGIN_ARG_INFO_EX(arginfo_dom_entityreference_construct, 0, 0, 1)
00032        ZEND_ARG_INFO(0, name)
00033 ZEND_END_ARG_INFO();
00034 /* }}} */
00035 
00036 /*
00037 * class DOMEntityReference extends DOMNode 
00038 *
00039 * URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-11C98490
00040 * Since: 
00041 */
00042 
00043 const zend_function_entry php_dom_entityreference_class_functions[] = {
00044        PHP_ME(domentityreference, __construct, arginfo_dom_entityreference_construct, ZEND_ACC_PUBLIC)
00045        PHP_FE_END
00046 };
00047 
00048 /* {{{ proto void DOMEntityReference::__construct(string name); */
00049 PHP_METHOD(domentityreference, __construct)
00050 {
00051        zval *id;
00052        xmlNode *node;
00053        xmlNodePtr oldnode = NULL;
00054        dom_object *intern;
00055        char *name;
00056        int name_len, name_valid;
00057        zend_error_handling error_handling;
00058 
00059        zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling TSRMLS_CC);
00060        if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_entityreference_class_entry, &name, &name_len) == FAILURE) {
00061               zend_restore_error_handling(&error_handling TSRMLS_CC);
00062               return;
00063        }
00064 
00065        zend_restore_error_handling(&error_handling TSRMLS_CC);
00066 
00067        name_valid = xmlValidateName((xmlChar *) name, 0);
00068        if (name_valid != 0) {
00069               php_dom_throw_error(INVALID_CHARACTER_ERR, 1 TSRMLS_CC);
00070               RETURN_FALSE;
00071        }
00072 
00073        node = xmlNewReference(NULL, name);
00074 
00075        if (!node) {
00076               php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
00077               RETURN_FALSE;
00078        }
00079 
00080        intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
00081        if (intern != NULL) {
00082               oldnode = dom_object_get_node(intern);
00083               if (oldnode != NULL) {
00084                      php_libxml_node_free_resource(oldnode  TSRMLS_CC);
00085               }
00086               php_libxml_increment_node_ptr((php_libxml_node_object *)intern, node, (void *)intern TSRMLS_CC);
00087        }
00088 }
00089 /* }}} end DOMEntityReference::__construct */
00090 
00091 #endif
00092 
00093 /*
00094  * Local variables:
00095  * tab-width: 4
00096  * c-basic-offset: 4
00097  * End:
00098  * vim600: noet sw=4 ts=4 fdm=marker
00099  * vim<600: noet sw=4 ts=4
00100  */