Back to index

php5  5.3.10
xpath.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: xpath.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 #define PHP_DOM_XPATH_QUERY 0
00031 #define PHP_DOM_XPATH_EVALUATE 1
00032 
00033 /*
00034 * class DOMXPath 
00035 */
00036 
00037 #if defined(LIBXML_XPATH_ENABLED)
00038 
00039 /* {{{ arginfo */
00040 ZEND_BEGIN_ARG_INFO_EX(arginfo_dom_xpath_construct, 0, 0, 1)
00041        ZEND_ARG_OBJ_INFO(0, doc, DOMDocument, 0)
00042 ZEND_END_ARG_INFO();
00043 
00044 ZEND_BEGIN_ARG_INFO_EX(arginfo_dom_xpath_register_ns, 0, 0, 2)
00045        ZEND_ARG_INFO(0, prefix)
00046        ZEND_ARG_INFO(0, uri)
00047 ZEND_END_ARG_INFO();
00048 
00049 ZEND_BEGIN_ARG_INFO_EX(arginfo_dom_xpath_query, 0, 0, 1)
00050        ZEND_ARG_INFO(0, expr)
00051        ZEND_ARG_OBJ_INFO(0, context, DOMNode, 1)
00052        ZEND_ARG_INFO(0, registerNodeNS)
00053 ZEND_END_ARG_INFO();
00054 
00055 ZEND_BEGIN_ARG_INFO_EX(arginfo_dom_xpath_evaluate, 0, 0, 1)
00056        ZEND_ARG_INFO(0, expr)
00057        ZEND_ARG_OBJ_INFO(0, context, DOMNode, 1)
00058        ZEND_ARG_INFO(0, registerNodeNS)
00059 ZEND_END_ARG_INFO();
00060 
00061 ZEND_BEGIN_ARG_INFO_EX(arginfo_dom_xpath_register_php_functions, 0, 0, 0)
00062 ZEND_END_ARG_INFO();
00063 /* }}} */
00064 
00065 const zend_function_entry php_dom_xpath_class_functions[] = {
00066        PHP_ME(domxpath, __construct, arginfo_dom_xpath_construct, ZEND_ACC_PUBLIC)
00067        PHP_FALIAS(registerNamespace, dom_xpath_register_ns, arginfo_dom_xpath_register_ns)
00068        PHP_FALIAS(query, dom_xpath_query, arginfo_dom_xpath_query)
00069        PHP_FALIAS(evaluate, dom_xpath_evaluate, arginfo_dom_xpath_evaluate)
00070        PHP_FALIAS(registerPhpFunctions, dom_xpath_register_php_functions, arginfo_dom_xpath_register_php_functions)
00071        PHP_FE_END
00072 };
00073 
00074 
00075 static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int type) /* {{{ */
00076 {
00077        zval **args;
00078        zval *retval;
00079        int result, i, ret;
00080        int error = 0;
00081        zend_fcall_info fci;
00082        zval handler;
00083        xmlXPathObjectPtr obj;
00084        char *str;
00085        char *callable = NULL;
00086        dom_xpath_object *intern;
00087        
00088        TSRMLS_FETCH();
00089 
00090        if (! zend_is_executing(TSRMLS_C)) {
00091               xmlGenericError(xmlGenericErrorContext,
00092               "xmlExtFunctionTest: Function called from outside of PHP\n");
00093               error = 1;
00094        } else {
00095               intern = (dom_xpath_object *) ctxt->context->userData;
00096               if (intern == NULL) {
00097                      xmlGenericError(xmlGenericErrorContext,
00098                      "xmlExtFunctionTest: failed to get the internal object\n");
00099                      error = 1;
00100               }
00101               else if (intern->registerPhpFunctions == 0) {
00102                      xmlGenericError(xmlGenericErrorContext,
00103                      "xmlExtFunctionTest: PHP Object did not register PHP functions\n");
00104                      error = 1;
00105               }
00106        }
00107        
00108        if (error == 1) {
00109               for (i = nargs - 1; i >= 0; i--) {
00110                      obj = valuePop(ctxt);
00111                      xmlXPathFreeObject(obj);
00112               }
00113               return;
00114        }
00115               
00116        fci.param_count = nargs - 1;
00117        if (fci.param_count > 0) {
00118               fci.params = safe_emalloc(fci.param_count, sizeof(zval**), 0);
00119               args = safe_emalloc(fci.param_count, sizeof(zval *), 0);
00120        }
00121        /* Reverse order to pop values off ctxt stack */
00122        for (i = nargs - 2; i >= 0; i--) {
00123               obj = valuePop(ctxt);
00124               MAKE_STD_ZVAL(args[i]);
00125               switch (obj->type) {
00126                      case XPATH_STRING:
00127                             ZVAL_STRING(args[i],  (char *)obj->stringval, 1);
00128                             break;
00129                      case XPATH_BOOLEAN:
00130                             ZVAL_BOOL(args[i],  obj->boolval);
00131                             break;
00132                      case XPATH_NUMBER:
00133                             ZVAL_DOUBLE(args[i], obj->floatval);
00134                             break;
00135                      case XPATH_NODESET:
00136                             if (type == 1) {
00137                                    str = (char *)xmlXPathCastToString(obj);
00138                                    ZVAL_STRING(args[i], str, 1);
00139                                    xmlFree(str);
00140                             } else if (type == 2) {
00141                                    int j;
00142                                    array_init(args[i]);
00143                                    if (obj->nodesetval && obj->nodesetval->nodeNr > 0) {
00144                                           for (j = 0; j < obj->nodesetval->nodeNr; j++) {
00145                                                  xmlNodePtr node = obj->nodesetval->nodeTab[j];
00146                                                  zval *child;
00147                                                  MAKE_STD_ZVAL(child);
00148                                                  /* not sure, if we need this... it's copied from xpath.c */
00149                                                  if (node->type == XML_NAMESPACE_DECL) {
00150                                                         xmlNsPtr curns;
00151                                                         xmlNodePtr nsparent;
00152                                                         
00153                                                         nsparent = node->_private;
00154                                                         curns = xmlNewNs(NULL, node->name, NULL);
00155                                                         if (node->children) {
00156                                                                curns->prefix = xmlStrdup((xmlChar *) node->children);
00157                                                         }
00158                                                         if (node->children) {
00159                                                                node = xmlNewDocNode(node->doc, NULL, (xmlChar *) node->children, node->name);
00160                                                         } else {
00161                                                                node = xmlNewDocNode(node->doc, NULL, (xmlChar *) "xmlns", node->name);
00162                                                         }
00163                                                         node->type = XML_NAMESPACE_DECL;
00164                                                         node->parent = nsparent;
00165                                                         node->ns = curns;
00166                                                  }
00167                                                  child = php_dom_create_object(node, &ret, NULL, child, (dom_object *)intern TSRMLS_CC);
00168                                                  add_next_index_zval(args[i], child);
00169                                           }
00170                                    }
00171                             }
00172                             break;
00173                      default:
00174                      ZVAL_STRING(args[i], (char *)xmlXPathCastToString(obj), 1);
00175               }
00176               xmlXPathFreeObject(obj);
00177               fci.params[i] = &args[i];
00178        }
00179        
00180        fci.size = sizeof(fci);
00181        fci.function_table = EG(function_table);
00182        
00183        obj = valuePop(ctxt);
00184        if (obj->stringval == NULL) {
00185               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Handler name must be a string");
00186               xmlXPathFreeObject(obj);
00187               if (fci.param_count > 0) {
00188                      for (i = 0; i < nargs - 1; i++) {
00189                             zval_ptr_dtor(&args[i]);
00190                      }
00191                      efree(args);
00192                      efree(fci.params);
00193               }
00194               return; 
00195        }
00196        INIT_PZVAL(&handler);
00197        ZVAL_STRING(&handler, obj->stringval, 1);
00198        xmlXPathFreeObject(obj);
00199 
00200        fci.function_name = &handler;
00201        fci.symbol_table = NULL;
00202        fci.object_ptr = NULL;
00203        fci.retval_ptr_ptr = &retval;
00204        fci.no_separation = 0;
00205 
00206        if (!zend_make_callable(&handler, &callable TSRMLS_CC)) {
00207               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call handler %s()", callable);
00208               
00209        } else if ( intern->registerPhpFunctions == 2 && zend_hash_exists(intern->registered_phpfunctions, callable, strlen(callable) + 1) == 0) { 
00210               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not allowed to call handler '%s()'.", callable);
00211               /* Push an empty string, so that we at least have an xslt result... */
00212               valuePush(ctxt, xmlXPathNewString((xmlChar *)""));
00213        } else {
00214               result = zend_call_function(&fci, NULL TSRMLS_CC);
00215               if (result == FAILURE) {
00216                      if (Z_TYPE(handler) == IS_STRING) {
00217                             php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call handler %s()", Z_STRVAL_P(&handler));
00218                      }
00219               /* retval is == NULL, when an exception occured, don't report anything, because PHP itself will handle that */
00220               } else if (retval == NULL) {
00221               } else {
00222                      if (retval->type == IS_OBJECT && instanceof_function( Z_OBJCE_P(retval), dom_node_class_entry TSRMLS_CC)) {
00223                             xmlNode *nodep;
00224                             dom_object *obj;
00225                             if (intern->node_list == NULL) {
00226                                    ALLOC_HASHTABLE(intern->node_list);
00227                                    zend_hash_init(intern->node_list, 0, NULL, ZVAL_PTR_DTOR, 0);
00228                             }
00229                             zval_add_ref(&retval);
00230                             zend_hash_next_index_insert(intern->node_list, &retval, sizeof(zval *), NULL);
00231                             obj = (dom_object *)zend_object_store_get_object(retval TSRMLS_CC);
00232                             nodep = dom_object_get_node(obj);
00233                             valuePush(ctxt, xmlXPathNewNodeSet(nodep));
00234                      } else if (retval->type == IS_BOOL) {
00235                             valuePush(ctxt, xmlXPathNewBoolean(retval->value.lval));
00236                      } else if (retval->type == IS_OBJECT) {
00237                             php_error_docref(NULL TSRMLS_CC, E_WARNING, "A PHP Object cannot be converted to a XPath-string");
00238                             valuePush(ctxt, xmlXPathNewString((xmlChar *)""));
00239                      } else {
00240                             convert_to_string_ex(&retval);
00241                             valuePush(ctxt, xmlXPathNewString( Z_STRVAL_P(retval)));
00242                      }
00243                      zval_ptr_dtor(&retval);
00244               }
00245        }
00246        efree(callable);
00247        zval_dtor(&handler);
00248        if (fci.param_count > 0) {
00249               for (i = 0; i < nargs - 1; i++) {
00250                      zval_ptr_dtor(&args[i]);
00251               }
00252               efree(args);
00253               efree(fci.params);
00254        }
00255 }
00256 /* }}} */
00257 
00258 static void dom_xpath_ext_function_string_php(xmlXPathParserContextPtr ctxt, int nargs) /* {{{ */
00259 {
00260        dom_xpath_ext_function_php(ctxt, nargs, 1);
00261 }
00262 /* }}} */
00263 
00264 static void dom_xpath_ext_function_object_php(xmlXPathParserContextPtr ctxt, int nargs) /* {{{ */
00265 {
00266        dom_xpath_ext_function_php(ctxt, nargs, 2);
00267 }
00268 /* }}} */
00269 
00270 /* {{{ proto void DOMXPath::__construct(DOMDocument doc) U */
00271 PHP_METHOD(domxpath, __construct)
00272 {
00273        zval *id, *doc;
00274        xmlDocPtr docp = NULL;
00275        dom_object *docobj;
00276        dom_xpath_object *intern;
00277        xmlXPathContextPtr ctx, oldctx;
00278        zend_error_handling error_handling;
00279 
00280        zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling TSRMLS_CC);
00281        if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &id, dom_xpath_class_entry, &doc, dom_document_class_entry) == FAILURE) {
00282               zend_restore_error_handling(&error_handling TSRMLS_CC);
00283               return;
00284        }
00285 
00286        zend_restore_error_handling(&error_handling TSRMLS_CC);
00287        DOM_GET_OBJ(docp, doc, xmlDocPtr, docobj);
00288 
00289        ctx = xmlXPathNewContext(docp);
00290        if (ctx == NULL) {
00291               php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
00292               RETURN_FALSE;
00293        }
00294 
00295        intern = (dom_xpath_object *)zend_object_store_get_object(id TSRMLS_CC);
00296        if (intern != NULL) {
00297               oldctx = (xmlXPathContextPtr)intern->ptr;
00298               if (oldctx != NULL) {
00299                      php_libxml_decrement_doc_ref((php_libxml_node_object *)intern TSRMLS_CC);
00300                      xmlXPathFreeContext(oldctx);
00301               }
00302 
00303               xmlXPathRegisterFuncNS (ctx, (const xmlChar *) "functionString",
00304                                       (const xmlChar *) "http://php.net/xpath",
00305                                       dom_xpath_ext_function_string_php);
00306               xmlXPathRegisterFuncNS (ctx, (const xmlChar *) "function",
00307                                       (const xmlChar *) "http://php.net/xpath",
00308                                       dom_xpath_ext_function_object_php);
00309 
00310               intern->ptr = ctx;
00311               ctx->userData = (void *)intern;
00312               intern->document = docobj->document;
00313               php_libxml_increment_doc_ref((php_libxml_node_object *)intern, docp TSRMLS_CC);
00314        }
00315 }
00316 /* }}} end DOMXPath::__construct */
00317 
00318 /* {{{ document DOMDocument*/
00319 int dom_xpath_document_read(dom_object *obj, zval **retval TSRMLS_DC)
00320 {
00321        xmlDoc *docp = NULL;
00322        xmlXPathContextPtr ctx;
00323        int ret;
00324 
00325        ctx = (xmlXPathContextPtr) obj->ptr;
00326 
00327        if (ctx) {
00328               docp = (xmlDocPtr) ctx->doc;
00329        }
00330 
00331        ALLOC_ZVAL(*retval);
00332        if (NULL == (*retval = php_dom_create_object((xmlNodePtr) docp, &ret, NULL, *retval, obj TSRMLS_CC))) {
00333               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create required DOM object");
00334               return FAILURE;
00335        }
00336        return SUCCESS;
00337 }
00338 /* }}} */
00339 
00340 /* {{{ proto boolean dom_xpath_register_ns(string prefix, string uri); */
00341 PHP_FUNCTION(dom_xpath_register_ns)
00342 {
00343        zval *id;
00344        xmlXPathContextPtr ctxp;
00345        int prefix_len, ns_uri_len;
00346        dom_xpath_object *intern;
00347        unsigned char *prefix, *ns_uri;
00348 
00349        if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oss", &id, dom_xpath_class_entry, &prefix, &prefix_len, &ns_uri, &ns_uri_len) == FAILURE) {
00350               return;
00351        }
00352 
00353        intern = (dom_xpath_object *)zend_object_store_get_object(id TSRMLS_CC);
00354 
00355        ctxp = (xmlXPathContextPtr) intern->ptr;
00356        if (ctxp == NULL) {
00357               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid XPath Context");
00358               RETURN_FALSE;
00359        }
00360 
00361        if (xmlXPathRegisterNs(ctxp, prefix, ns_uri) != 0) {
00362               RETURN_FALSE
00363        }
00364        RETURN_TRUE;
00365 }
00366 /* }}} */
00367 
00368 static void dom_xpath_iter(zval *baseobj, dom_object *intern) /* {{{ */
00369 {
00370        dom_nnodemap_object *mapptr;
00371 
00372        mapptr = (dom_nnodemap_object *)intern->ptr;
00373        mapptr->baseobjptr = baseobj;
00374        mapptr->nodetype = DOM_NODESET;
00375 
00376 }
00377 /* }}} */
00378 
00379 static void php_xpath_eval(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
00380 {
00381        zval *id, *retval, *context = NULL;
00382        xmlXPathContextPtr ctxp;
00383        xmlNodePtr nodep = NULL;
00384        xmlXPathObjectPtr xpathobjp;
00385        int expr_len, ret, nsnbr = 0, xpath_type;
00386        dom_xpath_object *intern;
00387        dom_object *nodeobj;
00388        char *expr;
00389        xmlDoc *docp = NULL;
00390        xmlNsPtr *ns = NULL;
00391        zend_bool register_node_ns = 1;
00392 
00393        if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|O!b", &id, dom_xpath_class_entry, &expr, &expr_len, &context, dom_node_class_entry, &register_node_ns) == FAILURE) {
00394               return;
00395        }
00396 
00397        intern = (dom_xpath_object *)zend_object_store_get_object(id TSRMLS_CC);
00398 
00399        ctxp = (xmlXPathContextPtr) intern->ptr;
00400        if (ctxp == NULL) {
00401               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid XPath Context");
00402               RETURN_FALSE;
00403        }
00404 
00405        docp = (xmlDocPtr) ctxp->doc;
00406        if (docp == NULL) {
00407               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid XPath Document Pointer");
00408               RETURN_FALSE;
00409        }
00410 
00411        if (context != NULL) {
00412               DOM_GET_OBJ(nodep, context, xmlNodePtr, nodeobj);
00413        }
00414 
00415        if (!nodep) {
00416               nodep = xmlDocGetRootElement(docp);
00417        }
00418 
00419        if (nodep && docp != nodep->doc) {
00420               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Node From Wrong Document");
00421               RETURN_FALSE;
00422        }
00423 
00424        ctxp->node = nodep;
00425 
00426        if (register_node_ns) {
00427               /* Register namespaces in the node */
00428               ns = xmlGetNsList(docp, nodep);
00429 
00430               if (ns != NULL) {
00431                      while (ns[nsnbr] != NULL)
00432                      nsnbr++;
00433               }
00434        }
00435 
00436 
00437     ctxp->namespaces = ns;
00438     ctxp->nsNr = nsnbr;
00439 
00440        xpathobjp = xmlXPathEvalExpression(expr, ctxp);
00441        ctxp->node = NULL;
00442 
00443        if (ns != NULL) {
00444               xmlFree(ns);
00445               ctxp->namespaces = NULL;
00446               ctxp->nsNr = 0;
00447        }
00448 
00449        if (! xpathobjp) {
00450               RETURN_FALSE;
00451        }
00452 
00453        if (type == PHP_DOM_XPATH_QUERY) {
00454               xpath_type = XPATH_NODESET;
00455        } else {
00456               xpath_type = xpathobjp->type;
00457        }
00458 
00459        switch (xpath_type) {
00460 
00461               case  XPATH_NODESET:
00462               {
00463                      int i;
00464                      xmlNodeSetPtr nodesetp;
00465 
00466                      MAKE_STD_ZVAL(retval);
00467                      array_init(retval);
00468 
00469                      if (xpathobjp->type == XPATH_NODESET && NULL != (nodesetp = xpathobjp->nodesetval)) {
00470 
00471                             for (i = 0; i < nodesetp->nodeNr; i++) {
00472                                    xmlNodePtr node = nodesetp->nodeTab[i];
00473                                    zval *child;
00474 
00475                                    MAKE_STD_ZVAL(child);
00476                                    
00477                                    if (node->type == XML_NAMESPACE_DECL) {
00478                                           xmlNsPtr curns;
00479                                           xmlNodePtr nsparent;
00480 
00481                                           nsparent = node->_private;
00482                                           curns = xmlNewNs(NULL, node->name, NULL);
00483                                           if (node->children) {
00484                                                  curns->prefix = xmlStrdup((char *) node->children);
00485                                           }
00486                                           if (node->children) {
00487                                                  node = xmlNewDocNode(docp, NULL, (char *) node->children, node->name);
00488                                           } else {
00489                                                  node = xmlNewDocNode(docp, NULL, "xmlns", node->name);
00490                                           }
00491                                           node->type = XML_NAMESPACE_DECL;
00492                                           node->parent = nsparent;
00493                                           node->ns = curns;
00494                                    }
00495                                    child = php_dom_create_object(node, &ret, NULL, child, (dom_object *)intern TSRMLS_CC);
00496                                    add_next_index_zval(retval, child);
00497                             }
00498                      }
00499                      php_dom_create_interator(return_value, DOM_NODELIST TSRMLS_CC);
00500                      nodeobj = (dom_object *)zend_objects_get_address(return_value TSRMLS_CC);
00501                      dom_xpath_iter(retval, nodeobj);
00502                      break;
00503               }
00504 
00505               case XPATH_BOOLEAN:
00506                      RETVAL_BOOL(xpathobjp->boolval);
00507                      break;
00508 
00509               case XPATH_NUMBER:
00510                      RETVAL_DOUBLE(xpathobjp->floatval)
00511                      break;
00512 
00513               case XPATH_STRING:
00514                      RETVAL_STRING(xpathobjp->stringval, 1);
00515                      break;
00516 
00517               default:
00518                      RETVAL_NULL();
00519                      break;
00520        }
00521 
00522        xmlXPathFreeObject(xpathobjp);
00523 }
00524 /* }}} */
00525 
00526 /* {{{ proto DOMNodeList dom_xpath_query(string expr [,DOMNode context [, boolean registerNodeNS]]); */
00527 PHP_FUNCTION(dom_xpath_query)
00528 {
00529        php_xpath_eval(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_DOM_XPATH_QUERY);
00530 }
00531 /* }}} end dom_xpath_query */
00532 
00533 /* {{{ proto mixed dom_xpath_evaluate(string expr [,DOMNode context [, boolean registerNodeNS]]); */
00534 PHP_FUNCTION(dom_xpath_evaluate)
00535 {
00536        php_xpath_eval(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_DOM_XPATH_EVALUATE);
00537 }
00538 /* }}} end dom_xpath_evaluate */
00539 
00540 /* {{{ proto void dom_xpath_register_php_functions() */
00541 PHP_FUNCTION(dom_xpath_register_php_functions)
00542 {
00543        zval *id;
00544        dom_xpath_object *intern;
00545        zval *array_value, **entry, *new_string;
00546        int  name_len = 0;
00547        char *name;
00548 
00549        DOM_GET_THIS(id);
00550        
00551        if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "a",  &array_value) == SUCCESS) {
00552               intern = (dom_xpath_object *)zend_object_store_get_object(id TSRMLS_CC);
00553               zend_hash_internal_pointer_reset(Z_ARRVAL_P(array_value));
00554 
00555               while (zend_hash_get_current_data(Z_ARRVAL_P(array_value), (void **)&entry) == SUCCESS) {
00556                      SEPARATE_ZVAL(entry);
00557                      convert_to_string_ex(entry);
00558 
00559                      MAKE_STD_ZVAL(new_string);
00560                      ZVAL_LONG(new_string,1);
00561               
00562                      zend_hash_update(intern->registered_phpfunctions, Z_STRVAL_PP(entry), Z_STRLEN_PP(entry) + 1, &new_string, sizeof(zval*), NULL);
00563                      zend_hash_move_forward(Z_ARRVAL_P(array_value));
00564               }
00565               intern->registerPhpFunctions = 2;
00566               RETURN_TRUE;
00567 
00568        } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "s",  &name, &name_len) == SUCCESS) {
00569               intern = (dom_xpath_object *)zend_object_store_get_object(id TSRMLS_CC);
00570               
00571               MAKE_STD_ZVAL(new_string);
00572               ZVAL_LONG(new_string,1);
00573               zend_hash_update(intern->registered_phpfunctions, name, name_len + 1, &new_string, sizeof(zval*), NULL);
00574               intern->registerPhpFunctions = 2;
00575               
00576        } else {
00577               intern = (dom_xpath_object *)zend_object_store_get_object(id TSRMLS_CC);
00578               intern->registerPhpFunctions = 1;
00579        }
00580        
00581 }
00582 /* }}} end dom_xpath_register_php_functions */
00583 
00584 #endif /* LIBXML_XPATH_ENABLED */
00585 
00586 #endif
00587 
00588 /*
00589  * Local variables:
00590  * tab-width: 4
00591  * c-basic-offset: 4
00592  * End:
00593  * vim600: noet sw=4 ts=4 fdm=marker
00594  * vim<600: noet sw=4 ts=4
00595  */