]> granicus.if.org Git - php/commitdiff
Empty HEAD of domxml, hyperwave, xslt
authorSascha Schumann <sas@php.net>
Tue, 24 Jun 2003 13:56:57 +0000 (13:56 +0000)
committerSascha Schumann <sas@php.net>
Tue, 24 Jun 2003 13:56:57 +0000 (13:56 +0000)
51 files changed:
ext/domxml/CREDITS [deleted file]
ext/domxml/EXPERIMENTAL [deleted file]
ext/domxml/TODO [deleted file]
ext/domxml/config.m4 [deleted file]
ext/domxml/domxml.dsp [deleted file]
ext/domxml/php_domxml.c [deleted file]
ext/domxml/php_domxml.h [deleted file]
ext/domxml/tests/domxml001.phpt [deleted file]
ext/domxml/tests/domxml002.phpt [deleted file]
ext/domxml/tests/domxml_test.inc [deleted file]
ext/domxml/tests/skipif.inc [deleted file]
ext/domxml/tests/xmldoc.phpt [deleted file]
ext/hyperwave/CREDITS [deleted file]
ext/hyperwave/config.m4 [deleted file]
ext/hyperwave/debug.h [deleted file]
ext/hyperwave/hg_comm.c [deleted file]
ext/hyperwave/hg_comm.h [deleted file]
ext/hyperwave/hw.c [deleted file]
ext/hyperwave/hw_error.h [deleted file]
ext/hyperwave/hyperwave.dsp [deleted file]
ext/hyperwave/php_hyperwave.h [deleted file]
ext/xslt/README.XSLT-BACKENDS [deleted file]
ext/xslt/TODO [deleted file]
ext/xslt/config.m4 [deleted file]
ext/xslt/php_sablot.h [deleted file]
ext/xslt/php_xslt.h [deleted file]
ext/xslt/sablot.c [deleted file]
ext/xslt/tests/args.xsl [deleted file]
ext/xslt/tests/bug17791.phpt [deleted file]
ext/xslt/tests/bug17931.phpt [deleted file]
ext/xslt/tests/bug20177.phpt [deleted file]
ext/xslt/tests/bug20518.phpt [deleted file]
ext/xslt/tests/param.xsl [deleted file]
ext/xslt/tests/public.xml [deleted file]
ext/xslt/tests/qa.dtd [deleted file]
ext/xslt/tests/skipif.inc [deleted file]
ext/xslt/tests/test.xml [deleted file]
ext/xslt/tests/xslt-001.phpt [deleted file]
ext/xslt/tests/xslt.phpt [deleted file]
ext/xslt/tests/xslt_backend_info.phpt [deleted file]
ext/xslt/tests/xslt_getopt.phpt [deleted file]
ext/xslt/tests/xslt_process-001.phpt [deleted file]
ext/xslt/tests/xslt_process-002.phpt [deleted file]
ext/xslt/tests/xslt_set_object.phpt [deleted file]
ext/xslt/tests/xslt_set_object.xsl [deleted file]
ext/xslt/tests/xslt_set_scheme_handlers-001.phpt [deleted file]
ext/xslt/tests/xslt_set_scheme_handlers-002.phpt [deleted file]
ext/xslt/tests/xslt_set_scheme_handlers-003.phpt [deleted file]
ext/xslt/tests/xslt_setopt.phpt [deleted file]
ext/xslt/xslt.c [deleted file]
ext/xslt/xslt.dsp [deleted file]

diff --git a/ext/domxml/CREDITS b/ext/domxml/CREDITS
deleted file mode 100644 (file)
index cd360ea..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-domxml
-Uwe Steinmann, Christian Stocker
diff --git a/ext/domxml/EXPERIMENTAL b/ext/domxml/EXPERIMENTAL
deleted file mode 100644 (file)
index 6443e99..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-this extension is experimental,
-its functions may change their names 
-or move to extension all together 
-so do not rely to much on them 
-you have been warned!
diff --git a/ext/domxml/TODO b/ext/domxml/TODO
deleted file mode 100644 (file)
index 1237d1a..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-1) Implement the following list entries and thier destructors:
-       le_domxmlnotationp
-
-2) Use ZEND_FETCH_RESOURCE() macros instead of custom functions.
-3) Implement those classes we really want, kill all of the rest.
-4) Remove debug code (many calls to fprintf()).
-5) Make 1st arg always be the object. This is currently half-and-half, or so.
-6) Take a hard look at startup/shutdown code. This is really running slower than
-       it ought to be.
-7) Fix the many, many memory leaks.
-8) Modify new_child to allow creation of attribute, cdata, dtd, etc nodes.
-9) implement schema support (libxml2 has it)
-10) implement scheme handlers (like in ext/xslt), should be possible with xmlRegisterInputCallbacks
-11) implement real sax support
-       - input (building of dom-tree with sax-events) is almost finished
-       - started with generating of sax-events from file/string (chregu)
-       - generating sax-events from dom-tree is a more tricky one (see mailinglist of libxml2)
-12) error reporting for xslt methods
-13) (DONE long time ago) add possibility to use relative xpath queries
-14) implement $dom->free() for freeing documents from memory
-15) implement get_element_by_tagname_ns (and improve namespace support in general)
-
-
diff --git a/ext/domxml/config.m4 b/ext/domxml/config.m4
deleted file mode 100644 (file)
index 74bc452..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-dnl
-dnl $Id$
-dnl
-
-AC_DEFUN(PHP_DOM_XSLT_CHECK_VERSION,[
-  old_CPPFLAGS=$CPPFLAGS
-  CPPFLAGS=-I$DOMXSLT_DIR/include
-  AC_MSG_CHECKING(for libxslt version)
-  AC_EGREP_CPP(yes,[
-#include <libxslt/xsltconfig.h>
-#if LIBXSLT_VERSION >= 10018
-  yes
-#endif
-  ],[
-    AC_MSG_RESULT(>= 1.0.18)
-  ],[
-    AC_MSG_ERROR(libxslt version 1.0.18 or greater required.)
-  ])
-  CPPFLAGS=$old_CPPFLAGS
-])
-
-AC_DEFUN(PHP_DOM_EXSLT_CHECK_VERSION,[
-  old_CPPFLAGS=$CPPFLAGS
-  CPPFLAGS=-I$DOMEXSLT_DIR/include
-  AC_MSG_CHECKING(for libexslt version)
-  AC_EGREP_CPP(yes,[
-#include <libexslt/exsltconfig.h>
-#if LIBEXSLT_VERSION >= 600
-  yes
-#endif
-  ],[
-    AC_MSG_RESULT(>= 1.0.18)
-  ],[
-    AC_MSG_ERROR(libxslt version 1.0.18 or greater required.)
-  ])
-  CPPFLAGS=$old_CPPFLAGS
-])
-
-PHP_ARG_WITH(dom, for old deprecated DOM support,
-[  --with-dom[=DIR]        Old deprecated DOM support (requires libxml >= 2.4.14).
-                          DIR is the libxml install directory.])
-
-if test "$PHP_DOM" != "no" -a "$PHP_DOM5" != "no"; then
-    AC_MSG_ERROR([Either use deprecated dom or new dom5 extension.])
-fi
-
-if test "$PHP_DOM" != "no"; then
-
-  PHP_LIBXML_DIR=$PHP_DOM
-
-  PHP_SETUP_LIBXML(DOMXML_SHARED_LIBADD, [
-    AC_DEFINE(HAVE_DOMXML,1,[ ])
-    PHP_NEW_EXTENSION(domxml, php_domxml.c, $ext_shared)
-    PHP_SUBST(DOMXML_SHARED_LIBADD)
-  ], [
-    AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.])
-  ])
-fi
-
-PHP_ARG_WITH(dom-xslt, for DOM XSLT support,
-[  --with-dom-xslt[=DIR]     DOMXML: Include DOM XSLT support (requires libxslt >= 1.0.18).
-                            DIR is the libxslt install directory.], no, no)
-
-if test "$PHP_DOM_XSLT" != "no"; then
-
-  if test "$PHP_DOM" = "no"; then
-    AC_MSG_ERROR([DOMXSLT requires DOMXML. Use --with-dom[=DIR]])
-  fi
-  
-  if test -r "$PHP_DOM_XSLT/include/libxslt/transform.h"; then
-    DOMXSLT_DIR=$PHP_DOM_XSLT
-  else
-    for i in $PHP_LIBXML_DIR /usr/local /usr; do
-      test -r $i/include/libxslt/transform.h && DOMXSLT_DIR=$i
-    done
-  fi
-
-  if test -z "$DOMXSLT_DIR"; then
-    AC_MSG_RESULT(not found)
-    AC_MSG_ERROR(Please reinstall the libxslt >= 1.0.18 distribution)
-  fi
-
-  PHP_DOM_XSLT_CHECK_VERSION
-
-  PHP_ADD_LIBRARY_WITH_PATH(xslt, $DOMXSLT_DIR/lib, DOMXML_SHARED_LIBADD)
-  PHP_ADD_INCLUDE($DOMXSLT_DIR/include)
-
-  if test -f $PHP_LIBXML_DIR/lib/libxsltbreakpoint.a -o -f $PHP_LIBXML_DIR/lib/libxsltbreakpoint.$SHLIB_SUFFIX_NAME; then
-    PHP_ADD_LIBRARY_WITH_PATH(xsltbreakpoint, $PHP_LIBXML_DIR/lib, DOMXML_SHARED_LIBADD)
-  fi
-
-  AC_DEFINE(HAVE_DOMXSLT,1,[ ])
-fi
-
-
-PHP_ARG_WITH(dom-exslt, for DOM EXSLT support,
-[  --with-dom-exslt[=DIR]    DOMXML: Include DOM EXSLT support (requires libxslt >= 1.0.18).
-                            DIR is the libexslt install directory.], no, no)
-
-if test "$PHP_DOM_EXSLT" != "no"; then
-
-  if test "$PHP_DOM" = "no"; then
-    AC_MSG_ERROR([DOMEXSLT requires DOMXML. Use --with-dom[=DIR]])
-  fi
-
-  if test "$PHP_DOM_XSLT" = "no"; then
-    AC_MSG_ERROR([DOMEXSLT requires DOMXSLT. Use --with-dom-xslt[=DIR]])
-  fi
-  
-  if test -r $PHP_DOM_EXSLT/include/libexslt/exslt.h; then
-    DOMEXSLT_DIR=$PHP_DOM_EXSLT
-  else
-    for i in $PHP_LIBXML_DIR /usr/local /usr; do
-      test -r $i/include/libexslt/exslt.h && DOMEXSLT_DIR=$i
-    done
-  fi
-
-  if test -z "$DOMEXSLT_DIR"; then
-    AC_MSG_RESULT(not found)
-    AC_MSG_ERROR(Please reinstall the libxslt >= 1.0.18 distribution)
-  fi
-
-  PHP_DOM_EXSLT_CHECK_VERSION
-
-  PHP_ADD_LIBRARY_WITH_PATH(exslt, $DOMEXSLT_DIR/lib, DOMXML_SHARED_LIBADD)
-  PHP_ADD_INCLUDE($DOMEXSLT_DIR/include)
-  AC_DEFINE(HAVE_DOMEXSLT,1,[ ])
-  PHP_SUBST(DOMXML_SHARED_LIBADD)
-fi
diff --git a/ext/domxml/domxml.dsp b/ext/domxml/domxml.dsp
deleted file mode 100644 (file)
index 4cbb63d..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-# Microsoft Developer Studio Project File - Name="domxml" - Package Owner=<4>\r
-# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
-# ** DO NOT EDIT **\r
-\r
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102\r
-\r
-CFG=domxml - Win32 Release_TS\r
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
-!MESSAGE use the Export Makefile command and run\r
-!MESSAGE \r
-!MESSAGE NMAKE /f "domxml.mak".\r
-!MESSAGE \r
-!MESSAGE You can specify a configuration when running NMAKE\r
-!MESSAGE by defining the macro CFG on the command line. For example:\r
-!MESSAGE \r
-!MESSAGE NMAKE /f "domxml.mak" CFG="domxml - Win32 Release_TS"\r
-!MESSAGE \r
-!MESSAGE Possible choices for configuration are:\r
-!MESSAGE \r
-!MESSAGE "domxml - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")\r
-!MESSAGE "domxml - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")\r
-!MESSAGE \r
-\r
-# Begin Project\r
-# PROP AllowPerConfigDependencies 0\r
-# PROP Scc_ProjName ""\r
-# PROP Scc_LocalPath ""\r
-CPP=cl.exe\r
-MTL=midl.exe\r
-RSC=rc.exe\r
-\r
-!IF  "$(CFG)" == "domxml - Win32 Release_TS"\r
-\r
-# PROP BASE Use_MFC 0\r
-# PROP BASE Use_Debug_Libraries 0\r
-# PROP BASE Output_Dir "Release_TS"\r
-# PROP BASE Intermediate_Dir "Release_TS"\r
-# PROP BASE Ignore_Export_Lib 0\r
-# PROP BASE Target_Dir ""\r
-# PROP Use_MFC 0\r
-# PROP Use_Debug_Libraries 0\r
-# PROP Output_Dir "Release_TS"\r
-# PROP Intermediate_Dir "Release_TS"\r
-# PROP Ignore_Export_Lib 0\r
-# PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\..\Zend" /I "..\..\..\TSRM" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL_DOMXML" /D ZTS=1 /YX /FD /c\r
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DOMXML_EXPORTS" /D "COMPILE_DL_DOMXML" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_DOMXML=1 /D HAVE_DOMXSLT=1 /D LIBXML_THREAD_ENABLED=1 /YX /FD /c\r
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
-# ADD BASE RSC /l 0x406 /d "NDEBUG"\r
-# ADD RSC /l 0x406 /d "NDEBUG"\r
-BSC32=bscmake.exe\r
-# ADD BASE BSC32 /nologo\r
-# ADD BSC32 /nologo\r
-LINK32=link.exe\r
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts.lib /nologo /dll /machine:I386\r
-# ADD LINK32 wsock32.lib php4ts.lib libxml2.lib libxslt.lib iconv.lib resolv.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_domxml.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" /libpath:"..\..\..\bindlib_w32\Release" /libpath:"..\..\..\php_build\lib\libxslt"\r
-# SUBTRACT LINK32 /pdb:none\r
-\r
-!ELSEIF  "$(CFG)" == "domxml - Win32 Debug_TS"\r
-\r
-# PROP BASE Use_MFC 0\r
-# PROP BASE Use_Debug_Libraries 0\r
-# PROP BASE Output_Dir "Debug_TS"\r
-# PROP BASE Intermediate_Dir "Debug_TS"\r
-# PROP BASE Ignore_Export_Lib 0\r
-# PROP BASE Target_Dir ""\r
-# PROP Use_MFC 0\r
-# PROP Use_Debug_Libraries 0\r
-# PROP Output_Dir "Debug_TS"\r
-# PROP Intermediate_Dir "Debug_TS"\r
-# PROP Ignore_Export_Lib 0\r
-# PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "mssql-70" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL_DOMXML" /D ZTS=1 /YX /FD /c\r
-# ADD CPP /nologo /MDd /W3 /GX /ZI /Od /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DOMXML_EXPORTS" /D "COMPILE_DL_DOMXML" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_DOMXML=1 /D HAVE_DOMXSLT=1 /D LIBXML_THREAD_ENABLED=1 /FR /YX /FD /c\r
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
-# ADD BASE RSC /l 0x406 /d "NDEBUG"\r
-# ADD RSC /l 0x406 /d "NDEBUG"\r
-BSC32=bscmake.exe\r
-# ADD BASE BSC32 /nologo\r
-# ADD BSC32 /nologo\r
-LINK32=link.exe\r
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts.lib /nologo /dll /machine:I386\r
-# ADD LINK32 php4ts_debug.lib libxml2.lib libxslt.lib iconv.lib resolv.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /debug /machine:I386 /out:"..\..\Debug_TS/php_domxml.dll" /libpath:"..\..\Debug_TS" /libpath:"..\..\..\bindlib_w32\Release" /libpath:"..\..\..\php_build\lib\libxslt"\r
-\r
-!ENDIF \r
-\r
-# Begin Target\r
-\r
-# Name "domxml - Win32 Release_TS"\r
-# Name "domxml - Win32 Debug_TS"\r
-# Begin Group "Source Files"\r
-\r
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
-# Begin Source File\r
-\r
-SOURCE=.\php_domxml.c\r
-# End Source File\r
-# End Group\r
-# Begin Group "Header Files"\r
-\r
-# PROP Default_Filter "h;hpp;hxx;hm;inl"\r
-# Begin Source File\r
-\r
-SOURCE=.\php_domxml.h\r
-# End Source File\r
-# End Group\r
-# Begin Group "Resource Files"\r
-\r
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
-# End Group\r
-# End Target\r
-# End Project\r
diff --git a/ext/domxml/php_domxml.c b/ext/domxml/php_domxml.c
deleted file mode 100644 (file)
index a00ecb9..0000000
+++ /dev/null
@@ -1,5665 +0,0 @@
-/*
-   +----------------------------------------------------------------------+
-   | PHP Version 4                                                        |
-   +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2003 The PHP Group                                |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 3.0 of the PHP license,       |
-   | that is bundled with this package in the file LICENSE, and is        |
-   | available through the world-wide-web at the following url:           |
-   | http://www.php.net/license/3_0.txt.                                  |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@php.net so we can mail you a copy immediately.               |
-   +----------------------------------------------------------------------+
-   | Author: Uwe Steinmann <steinm@php.net>                               |
-   +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-/* TODO
- * - Support Notation Nodes
- * */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "php.h"
-#include "ext/standard/php_rand.h"
-#include "php_domxml.h"
-
-#if HAVE_DOMXML
-#include "ext/standard/info.h"
-#define PHP_XPATH 1
-#define PHP_XPTR 2
-
-/* General macros used by domxml */
-#define DOMXML_IS_TYPE(zval, ce)                                       (zval && Z_TYPE_P(zval) == IS_OBJECT && Z_OBJCE_P(zval)->refcount == ce->refcount)
-
-#define DOMXML_DOMOBJ_NEW(zval, obj, ret)                      if (NULL == (zval = php_domobject_new(obj, ret, zval TSRMLS_CC))) { \
-                                                                                                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create required DOM object"); \
-                                                                                                               RETURN_FALSE; \
-                                                                                                       }
-
-#define DOMXML_RET_ZVAL(zval)                                          SEPARATE_ZVAL(&zval); \
-                                                                                                       *return_value = *zval; \
-                                                                                                       FREE_ZVAL(zval);
-
-#define DOMXML_RET_OBJ(zval, obj, ret)                         DOMXML_DOMOBJ_NEW(zval, obj, ret); \
-                                                                                                       DOMXML_RET_ZVAL(zval);
-
-#define DOMXML_GET_THIS(zval)                                          if (NULL == (zval = getThis())) { \
-                                                                                                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Underlying object missing"); \
-                                                                                                               RETURN_FALSE; \
-                                                                                                       }
-
-#define DOMXML_GET_OBJ(ret, zval, le)                          if (NULL == (ret = php_dom_get_object(zval, le, 0 TSRMLS_CC))) { \
-                                                                                                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot fetch DOM object"); \
-                                                                                                               RETURN_FALSE; \
-                                                                                                       }
-
-#define DOMXML_GET_THIS_OBJ(ret, zval, le)                     DOMXML_GET_THIS(zval); \
-                                                                                                       DOMXML_GET_OBJ(ret, zval, le);
-
-#define DOMXML_NO_ARGS()                                                       if (ZEND_NUM_ARGS() != 0) { \
-                                                                                                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expects exactly 0 parameters, %d given", ZEND_NUM_ARGS()); \
-                                                                                                               return; \
-                                                                                                       }
-
-#define DOMXML_NOT_IMPLEMENTED()                                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not yet implemented"); \
-                                                                                                       return;
-
-/* WARNING: The number of parameters is actually the
- * number of passed variables to zend_parse_parameters(),
- * *NOT* the number of parameters expected by the PHP function. */
-#define DOMXML_PARAM_NONE(ret, zval, le)                       if (NULL == (zval = getThis())) { \
-                                                                                                               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zval) == FAILURE) { \
-                                                                                                                       return; \
-                                                                                                               } \
-                                                                                                       } \
-                                                                                                       DOMXML_GET_OBJ(ret, zval, le);
-
-#define DOMXML_PARAM_ONE(ret, zval, le, s, p1) if (NULL == (zval = getThis())) { \
-                                                                                                               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o"s, &zval, p1) == FAILURE) { \
-                                                                                                                       return; \
-                                                                                                               } \
-                                                                                                       } else { \
-                                                                                                               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, p1) == FAILURE) { \
-                                                                                                                       return; \
-                                                                                                               } \
-                                                                                                       } \
-                                                                                                       DOMXML_GET_OBJ(ret, zval, le);
-
-#define DOMXML_PARAM_TWO(ret, zval, le, s, p1, p2)     if (NULL == (zval = getThis())) { \
-                                                                                                               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o"s, &zval, p1, p2) == FAILURE) { \
-                                                                                                                       return; \
-                                                                                                               } \
-                                                                                                       } else { \
-                                                                                                               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, p1, p2) == FAILURE) { \
-                                                                                                                       return; \
-                                                                                                               } \
-                                                                                                       } \
-                                                                                                       DOMXML_GET_OBJ(ret, zval, le);
-
-#define DOMXML_PARAM_THREE(ret, zval, le, s, p1, p2, p3)               if (NULL == (zval = getThis())) { \
-                                                                                                                                       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o"s, &zval, p1, p2, p3) == FAILURE) { \
-                                                                                                                                               return; \
-                                                                                                                                       } \
-                                                                                                                               } else { \
-                                                                                                                                       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, p1, p2, p3) == FAILURE) { \
-                                                                                                                                               return; \
-                                                                                                                                       } \
-                                                                                                                               } \
-                                                                                                                               DOMXML_GET_OBJ(ret, zval, le);
-
-
-#define DOMXML_PARAM_FOUR(ret, zval, le, s, p1, p2, p3, p4)            if (NULL == (zval = getThis())) { \
-                                                                                                                                       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o"s, &zval, p1, p2, p3, p4) == FAILURE) { \
-                                                                                                                                               return; \
-                                                                                                                                       } \
-                                                                                                                               } else { \
-                                                                                                                                       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, p1, p2, p3, p4) == FAILURE) { \
-                                                                                                                                               return; \
-                                                                                                                                       } \
-                                                                                                                               } \
-                                                                                                                               DOMXML_GET_OBJ(ret, zval, le);
-
-#define DOMXML_PARAM_SIX(ret, zval, le, s, p1, p2, p3, p4, p5, p6)             if (NULL == (zval = getThis())) { \
-                                                                                                                                       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o"s, &zval, p1, p2, p3, p4, p5, p6) == FAILURE) { \
-                                                                                                                                               return; \
-                                                                                                                                       } \
-                                                                                                                               } else { \
-                                                                                                                                       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, p1, p2, p3, p4, p5, p6) == FAILURE) { \
-                                                                                                                                               return; \
-                                                                                                                                       } \
-                                                                                                                               } \
-                                                                                                                               DOMXML_GET_OBJ(ret, zval, le);
-
-#define DOMXML_LOAD_PARSING  0
-#define DOMXML_LOAD_VALIDATING 1
-#define DOMXML_LOAD_RECOVERING 2
-#define DOMXML_LOAD_SUBSTITUTE_ENTITIES 4
-#define DOMXML_LOAD_COMPLETE_ATTRS 8
-#define DOMXML_LOAD_DONT_KEEP_BLANKS 16
-static int le_domxmldocp;
-static int le_domxmldoctypep;
-static int le_domxmldtdp;
-static int le_domxmlnodep;
-static int le_domxmlelementp;
-static int le_domxmlattrp;
-static int le_domxmlcdatap;
-static int le_domxmltextp;
-static int le_domxmlpip;
-static int le_domxmldocumentfragmentp;
-static int le_domxmlcommentp;
-static int le_domxmlnotationp;
-static int le_domxmlparserp;
-
-/*static int le_domxmlentityp;*/
-static int le_domxmlentityrefp;
-/*static int le_domxmlnsp;*/
-
-#if HAVE_DOMXSLT
-static int le_domxsltstylesheetp;
-#endif
-static void domxml_error(void *ctx, const char *msg, ...);
-static void domxml_error_ext(void *ctx, const char *msg, ...);
-static void domxml_error_validate(void *ctx, const char *msg, ...);
-static xmlDocPtr php_dom_xmlSAXParse(xmlSAXHandlerPtr sax, const char *buffer, int size, int recovery, void *data);
-
-#if defined(LIBXML_XPATH_ENABLED)
-static int le_xpathctxp;
-static int le_xpathobjectp;
-#endif
-
-zend_class_entry *domxmldoc_class_entry;
-zend_class_entry *domxmldoctype_class_entry;
-zend_class_entry *domxmlelement_class_entry;
-zend_class_entry *domxmldtd_class_entry;
-zend_class_entry *domxmlnode_class_entry;
-zend_class_entry *domxmlattr_class_entry;
-zend_class_entry *domxmlcdata_class_entry;
-zend_class_entry *domxmltext_class_entry;
-zend_class_entry *domxmlpi_class_entry;
-zend_class_entry *domxmldocumentfragment_class_entry;
-zend_class_entry *domxmlcomment_class_entry;
-zend_class_entry *domxmlnotation_class_entry;
-zend_class_entry *domxmlentity_class_entry;
-zend_class_entry *domxmlentityref_class_entry;
-zend_class_entry *domxmlns_class_entry;
-zend_class_entry *domxmlparser_class_entry;
-#if defined(LIBXML_XPATH_ENABLED)
-zend_class_entry *xpathctx_class_entry;
-zend_class_entry *xpathobject_class_entry;
-#endif
-#if HAVE_DOMXSLT
-zend_class_entry *domxsltstylesheet_class_entry;
-#endif
-
-static int node_attributes(zval **attributes, xmlNode *nodep TSRMLS_DC);
-static int node_children(zval **children, xmlNode *nodep TSRMLS_DC);
-
-static unsigned char first_args_force_ref[]  = { 1, BYREF_FORCE };
-static unsigned char second_args_force_ref[] = { 2, BYREF_NONE, BYREF_FORCE };
-static unsigned char third_args_force_ref[]  = { 3, BYREF_NONE, BYREF_NONE, BYREF_FORCE };
-
-static zend_function_entry domxml_functions[] = {
-       PHP_FE(domxml_version,                                                                                          NULL)
-       PHP_FE(xmldoc,                                                                                                          third_args_force_ref)
-       PHP_FALIAS(domxml_open_mem,                                                                                     xmldoc, third_args_force_ref)
-       PHP_FE(xmldocfile,                                                                                                      third_args_force_ref)
-       PHP_FALIAS(domxml_open_file,                                                                            xmldocfile,     third_args_force_ref)
-#if defined(LIBXML_HTML_ENABLED)
-       PHP_FE(html_doc,                                                                                                        NULL)
-       PHP_FE(html_doc_file,                                                                                           NULL)
-#endif
-       PHP_FE(domxml_xmltree,                                                                                          NULL)
-       PHP_FALIAS(xmltree,                                                                     domxml_xmltree, NULL)
-       PHP_FE(domxml_substitute_entities_default,                                                      NULL)
-       PHP_FE(domxml_doc_document_element,                                                                     NULL)
-       PHP_FE(domxml_doc_add_root,                                                                                     NULL)
-       PHP_FE(domxml_doc_set_root,                                                                                     NULL)
-       PHP_FE(domxml_dump_mem,                                                                                         NULL)
-       PHP_FE(domxml_dump_mem_file,                                                                            NULL)
-       PHP_FE(domxml_dump_node,                                                                                        NULL)
-#if defined(LIBXML_HTML_ENABLED)
-       PHP_FE(domxml_html_dump_mem,                                                                            NULL)
-#endif
-       PHP_FE(domxml_node_attributes,                                                                          NULL)
-       PHP_FE(domxml_elem_get_attribute,                                                                       NULL)
-       PHP_FE(domxml_elem_set_attribute,                                                                       NULL)
-       PHP_FE(domxml_node_children,                                                                            NULL)
-       PHP_FE(domxml_node_has_attributes,                                                                      NULL)
-       PHP_FE(domxml_node_new_child,                                                                           NULL)
-       PHP_FE(domxml_node,                                                                                                     NULL)
-       PHP_FE(domxml_node_unlink_node,                                                                         NULL)
-       PHP_FE(domxml_node_set_content,                                                                         NULL)
-       PHP_FE(domxml_node_get_content,                                                                         NULL)
-       PHP_FE(domxml_node_add_namespace,                                                                       NULL)
-       PHP_FE(domxml_node_set_namespace,                                                                       NULL)
-       PHP_FE(domxml_new_xmldoc,                                                                                       NULL)
-       PHP_FALIAS(domxml_new_doc,                                              domxml_new_xmldoc,      NULL)
-       PHP_FE(domxml_parser,                                                                                           NULL)
-       PHP_FE(domxml_parser_add_chunk,                                                                         NULL)
-       PHP_FE(domxml_parser_end,                                                                                       NULL)
-       PHP_FE(domxml_parser_start_element,                                                                     NULL)
-       PHP_FE(domxml_parser_end_element,                                                                       NULL)
-       PHP_FE(domxml_parser_comment,                                                                           NULL)
-       PHP_FE(domxml_parser_characters,                                                                        NULL)
-       PHP_FE(domxml_parser_entity_reference,                                                          NULL)
-       PHP_FE(domxml_parser_processing_instruction,                                            NULL)
-       PHP_FE(domxml_parser_cdata_section,                                                                     NULL)
-       PHP_FE(domxml_parser_namespace_decl,                                                            NULL)
-       PHP_FE(domxml_parser_start_document,                                                            NULL)
-       PHP_FE(domxml_parser_end_document,                                                                      NULL)
-       PHP_FE(domxml_parser_get_document,                                                                      NULL)
-
-#if defined(LIBXML_XPATH_ENABLED)
-       PHP_FE(xpath_new_context,                                                                                       NULL)
-       PHP_FE(xpath_eval,                                                                                                      NULL)
-       PHP_FE(xpath_eval_expression,                                                                           NULL)
-       PHP_FE(xpath_register_ns,                                                                                       NULL)
-       PHP_FE(xpath_register_ns_auto,                                                                          NULL)   
-       PHP_FE(domxml_doc_get_elements_by_tagname,                                                      NULL)
-#endif
-
-       PHP_FE(domxml_doc_get_element_by_id,                                                            NULL)
-
-#if defined(LIBXML_XPTR_ENABLED)
-       PHP_FE(xptr_new_context,                                                                                        NULL)
-       PHP_FE(xptr_eval,                                                                                                       NULL)
-#endif
-#if HAVE_DOMXSLT
-       PHP_FE(domxml_xslt_version,                                                                                     NULL)
-       PHP_FE(domxml_xslt_stylesheet,                                                                          NULL)
-       PHP_FE(domxml_xslt_stylesheet_doc,                                                                      NULL)
-       PHP_FE(domxml_xslt_stylesheet_file,                                                                     NULL)
-       PHP_FE(domxml_xslt_process,                                                                                     NULL)
-       PHP_FE(domxml_xslt_result_dump_mem,                                                                     NULL)
-       PHP_FE(domxml_xslt_result_dump_file,                                                            NULL)
-#endif
-
-       PHP_FALIAS(domxml_add_root,                     domxml_doc_add_root,                    NULL)
-       PHP_FALIAS(domxml_doc_get_root,         domxml_doc_document_element,    NULL)
-       PHP_FALIAS(domxml_root,                         domxml_doc_document_element,    NULL)
-       PHP_FALIAS(domxml_attributes,           domxml_node_attributes,                 NULL)
-       PHP_FALIAS(domxml_get_attribute,        domxml_elem_get_attribute,              NULL)
-       PHP_FALIAS(domxml_getattr,                      domxml_elem_get_attribute,              NULL)
-       PHP_FALIAS(domxml_set_attribute,        domxml_elem_set_attribute,              NULL)
-       PHP_FALIAS(domxml_setattr,                      domxml_elem_set_attribute,              NULL)
-       PHP_FALIAS(domxml_children,                     domxml_node_children,                   NULL)
-       PHP_FALIAS(domxml_new_child,            domxml_node_new_child,                  NULL)
-       PHP_FALIAS(domxml_unlink_node,          domxml_node_unlink_node,                NULL)
-       PHP_FALIAS(set_content,                         domxml_node_set_content,                NULL)
-       PHP_FALIAS(new_xmldoc,                          domxml_new_xmldoc,                              NULL)
-       PHP_FALIAS(domxml_dumpmem,                      domxml_dump_mem,                                NULL)
-       PHP_FE(domxml_doc_validate,                                                                                     second_args_force_ref)
-       PHP_FE(domxml_doc_xinclude,                                                                                     NULL)
-       {NULL, NULL, NULL}
-};
-
-
-static function_entry php_domxmldoc_class_functions[] = {
-       PHP_FALIAS(domdocument,                         xmldoc,                                                 NULL)
-       PHP_FALIAS(doctype,                             domxml_doc_doctype,                     NULL)
-       PHP_FALIAS(implementation,                      domxml_doc_implementation,              NULL)
-       PHP_FALIAS(document_element,            domxml_doc_document_element,    NULL)
-       PHP_FALIAS(create_element,                      domxml_doc_create_element,              NULL)
-       PHP_FALIAS(create_element_ns,           domxml_doc_create_element_ns,   NULL)
-       PHP_FALIAS(create_text_node,            domxml_doc_create_text_node,    NULL)
-       PHP_FALIAS(create_comment,                      domxml_doc_create_comment,              NULL)
-       PHP_FALIAS(create_attribute,            domxml_doc_create_attribute,    NULL)
-       PHP_FALIAS(create_cdata_section,        domxml_doc_create_cdata_section,        NULL)
-       PHP_FALIAS(create_entity_reference,     domxml_doc_create_entity_reference,     NULL)
-       PHP_FALIAS(create_processing_instruction,       domxml_doc_create_processing_instruction,       NULL)
-       PHP_FALIAS(create_document_fragment,    domxml_doc_create_document_fragment,    NULL)
-       PHP_FALIAS(get_elements_by_tagname,     domxml_doc_get_elements_by_tagname,     NULL)
-       PHP_FALIAS(get_element_by_id,           domxml_doc_get_element_by_id,   NULL)
-       PHP_FALIAS(free,                                        domxml_doc_free_doc,                    NULL)
-       /* Everything below this comment is none DOM compliant */
-       /* children is deprecated because it is inherited from DomNode */
-/*     PHP_FALIAS(children,                            domxml_node_children,                   NULL) */
-       PHP_FALIAS(add_root,                            domxml_doc_add_root,                    NULL)
-       PHP_FALIAS(set_root,                            domxml_doc_set_root,                    NULL)
-       PHP_FALIAS(get_root,                            domxml_doc_document_element,    NULL)
-       PHP_FALIAS(root,                                        domxml_doc_document_element,    NULL)
-       PHP_FALIAS(imported_node,                       domxml_doc_imported_node,               NULL)
-       PHP_FALIAS(dtd,                                         domxml_intdtd,                                  NULL)
-       PHP_FALIAS(ids,                                         domxml_doc_ids,                                 NULL)
-       PHP_FALIAS(dumpmem,                                     domxml_dump_mem,                                NULL)
-       PHP_FALIAS(dump_mem,                            domxml_dump_mem,                                NULL)
-       PHP_FALIAS(dump_mem_file,                       domxml_dump_mem_file,                   NULL)
-       PHP_FALIAS(dump_file,                           domxml_dump_mem_file,                   NULL)
-#if defined(LIBXML_HTML_ENABLED)
-       PHP_FALIAS(html_dump_mem,                       domxml_html_dump_mem,                   NULL)
-#endif
-#if defined(LIBXML_XPATH_ENABLED)
-       PHP_FALIAS(xpath_init,                          xpath_init,                                             NULL)
-       PHP_FALIAS(xpath_new_context,           xpath_new_context,                              NULL)
-       PHP_FALIAS(xptr_new_context,            xptr_new_context,                               NULL)
-#endif
-       PHP_FALIAS(validate,                            domxml_doc_validate,                    first_args_force_ref)
-       PHP_FALIAS(xinclude,                            domxml_doc_xinclude,                    NULL)
-
-       {NULL, NULL, NULL}
-};
-
-static function_entry php_domxmlparser_class_functions[] = {
-       PHP_FALIAS(add_chunk,                                   domxml_parser_add_chunk,                NULL)
-       PHP_FALIAS(end,                                                 domxml_parser_end,                              NULL)
-       PHP_FALIAS(set_keep_blanks,                             domxml_parser_set_keep_blanks,  NULL)
-       PHP_FALIAS(start_element,                               domxml_parser_start_element,    NULL)
-       PHP_FALIAS(end_element,                                 domxml_parser_end_element,              NULL)
-       PHP_FALIAS(characters,                                  domxml_parser_characters,               NULL)
-       PHP_FALIAS(entity_reference,                    domxml_parser_entity_reference, NULL)
-       PHP_FALIAS(processing_instruction,              domxml_parser_processing_instruction,   NULL)
-       PHP_FALIAS(cdata_section,                               domxml_parser_cdata_section,    NULL)
-       PHP_FALIAS(comment,                                             domxml_parser_comment,                  NULL)
-       PHP_FALIAS(namespace_decl,                              domxml_parser_namespace_decl,   NULL)
-       PHP_FALIAS(start_document,                              domxml_parser_start_document,   NULL)
-       PHP_FALIAS(end_document,                                domxml_parser_end_document,             NULL)
-       PHP_FALIAS(get_document,                                domxml_parser_get_document,             NULL)
-
-       {NULL, NULL, NULL}
-};
-
-static function_entry php_domxmldoctype_class_functions[] = {
-       PHP_FALIAS(name,                                        domxml_doctype_name,                    NULL)
-       PHP_FALIAS(entities,                            domxml_doctype_entities,                NULL)
-       PHP_FALIAS(notations,                           domxml_doctype_notations,               NULL)
-       PHP_FALIAS(system_id,                           domxml_doctype_system_id,               NULL)
-       PHP_FALIAS(public_id,                           domxml_doctype_public_id,               NULL)
-/*
-       PHP_FALIAS(internal_subset,                     domxml_doctype_internal_subset, NULL)
-*/
-       {NULL, NULL, NULL}
-};
-
-static zend_function_entry php_domxmldtd_class_functions[] = {
-       {NULL, NULL, NULL}
-};
-
-static zend_function_entry php_domxmlnode_class_functions[] = {
-       PHP_FALIAS(domnode,                                     domxml_node,                                    NULL)
-       PHP_FALIAS(node_name,                           domxml_node_name,                               NULL)
-       PHP_FALIAS(node_type,                           domxml_node_type,                               NULL)
-       PHP_FALIAS(node_value,                          domxml_node_value,                              NULL)
-       PHP_FALIAS(first_child,                         domxml_node_first_child,                NULL)
-       PHP_FALIAS(last_child,                          domxml_node_last_child,                 NULL)
-       PHP_FALIAS(children,                            domxml_node_children,                   NULL)
-       PHP_FALIAS(child_nodes,                         domxml_node_children,                   NULL)
-       PHP_FALIAS(previous_sibling,            domxml_node_previous_sibling,   NULL)
-       PHP_FALIAS(next_sibling,                        domxml_node_next_sibling,               NULL)
-       PHP_FALIAS(has_child_nodes,                     domxml_node_has_child_nodes,    NULL)
-       PHP_FALIAS(parent,                                      domxml_node_parent,                             NULL)
-       PHP_FALIAS(parent_node,                         domxml_node_parent,                             NULL)
-       PHP_FALIAS(insert_before,                       domxml_node_insert_before,              NULL)
-       PHP_FALIAS(append_child,                        domxml_node_append_child,               NULL)
-       PHP_FALIAS(remove_child,                        domxml_node_remove_child,               NULL)
-       PHP_FALIAS(replace_child,                       domxml_node_replace_child,              NULL)
-       PHP_FALIAS(owner_document,                      domxml_node_owner_document,             NULL)
-       PHP_FALIAS(new_child,                           domxml_node_new_child,                  NULL)
-       PHP_FALIAS(attributes,                          domxml_node_attributes,                 NULL)
-       PHP_FALIAS(has_attributes,                      domxml_node_has_attributes,             NULL)
-       PHP_FALIAS(prefix,                                      domxml_node_prefix,                             NULL)
-       PHP_FALIAS(namespace_uri,                       domxml_node_namespace_uri,              NULL)
-       PHP_FALIAS(clone_node,                          domxml_clone_node,                              NULL)
-/* Non DOM functions start here */
-       PHP_FALIAS(add_namespace,                       domxml_node_add_namespace,              NULL)
-       PHP_FALIAS(set_namespace,                       domxml_node_set_namespace,              NULL)
-       PHP_FALIAS(add_child,                           domxml_node_append_child,               NULL)
-       PHP_FALIAS(append_sibling,                      domxml_node_append_sibling,             NULL)
-       PHP_FALIAS(node,                                        domxml_node,                                    NULL)
-       PHP_FALIAS(unlink,                                      domxml_node_unlink_node,                NULL)
-       PHP_FALIAS(unlink_node,                         domxml_node_unlink_node,                NULL)
-       PHP_FALIAS(replace_node,                        domxml_node_replace_node,               NULL)
-       PHP_FALIAS(set_content,                         domxml_node_set_content,                NULL)
-       PHP_FALIAS(get_content,                         domxml_node_get_content,                NULL)
-       PHP_FALIAS(text_concat,                         domxml_node_text_concat,                NULL)
-       PHP_FALIAS(set_name,                            domxml_node_set_name,                   NULL)
-       PHP_FALIAS(get_path,                            domxml_node_get_path,                   NULL)
-       PHP_FALIAS(is_blank_node,                       domxml_is_blank_node,                   NULL)
-       PHP_FALIAS(dump_node,                           domxml_dump_node,                               NULL)
-       {NULL, NULL, NULL}
-};
-
-static zend_function_entry php_domxmlelement_class_functions[] = {
-       PHP_FALIAS(domelement,                          domxml_doc_create_element,              NULL)
-       PHP_FALIAS(name,                                        domxml_elem_tagname,                    NULL)
-       PHP_FALIAS(tagname,                                     domxml_elem_tagname,                    NULL)
-       PHP_FALIAS(get_attribute,                       domxml_elem_get_attribute,              NULL)
-       PHP_FALIAS(set_attribute,                       domxml_elem_set_attribute,              NULL)
-       PHP_FALIAS(remove_attribute,            domxml_elem_remove_attribute,   NULL)
-       PHP_FALIAS(get_attribute_node,          domxml_elem_get_attribute_node, NULL)
-       PHP_FALIAS(set_attribute_node,          domxml_elem_set_attribute_node, NULL)
-#if defined(LIBXML_XPATH_ENABLED)                      
-       PHP_FALIAS(get_elements_by_tagname,     domxml_elem_get_elements_by_tagname,    NULL)
-#endif
-       PHP_FALIAS(has_attribute,       domxml_elem_has_attribute,      NULL)
-       {NULL, NULL, NULL}
-};
-
-static zend_function_entry php_domxmlcdata_class_functions[] = {
-       PHP_FALIAS(domcdata,                            domxml_doc_create_cdata_section,NULL)
-       PHP_FALIAS(length,                                      domxml_cdata_length,                    NULL)
-       {NULL, NULL, NULL}
-};
-
-static zend_function_entry php_domxmltext_class_functions[] = {
-       PHP_FALIAS(domtext,                                     domxml_doc_create_text_node,    NULL)
-       {NULL, NULL, NULL}
-};
-
-static zend_function_entry php_domxmlcomment_class_functions[] = {
-       PHP_FALIAS(domcomment,                          domxml_doc_create_comment,              NULL)
-       {NULL, NULL, NULL}
-};
-
-static zend_function_entry php_domxmlnotation_class_functions[] = {
-       PHP_FALIAS(public_id,                           domxml_notation_public_id,              NULL)
-       PHP_FALIAS(system_id,                           domxml_notation_system_id,              NULL)
-       {NULL, NULL, NULL}
-};
-
-static zend_function_entry php_domxmlentityref_class_functions[] = {
-       PHP_FALIAS(domentityreference,          domxml_doc_create_entity_reference,     NULL)
-       {NULL, NULL, NULL}
-};
-
-static zend_function_entry php_domxmlentity_class_functions[] = {
-/*
-       PHP_FALIAS(public_id,                           domxml_entity_public_id,                NULL)
-       PHP_FALIAS(system_id,                           domxml_entity_system_id,                NULL)
-       PHP_FALIAS(notation_name,                       domxml_entity_notation_name,    NULL)
-*/
-       {NULL, NULL, NULL}
-};
-
-static zend_function_entry php_domxmlpi_class_functions[] = {
-       PHP_FALIAS(domprocessinginstruction, domxml_doc_create_processing_instruction, NULL)
-       PHP_FALIAS(target,                                      domxml_pi_target,                               NULL)
-       PHP_FALIAS(data,                                        domxml_pi_data,                                 NULL)
-       {NULL, NULL, NULL}
-};
-
-static zend_function_entry php_domxmldocumentfragment_class_functions[] = {
-               PHP_FALIAS(open_mem,                                    domxml_document_fragment_open_mem,                              NULL)
-               {NULL, NULL, NULL}
-};
-
-#if defined(LIBXML_XPATH_ENABLED)
-static zend_function_entry php_xpathctx_class_functions[] = {
-       PHP_FALIAS(xpath_eval,                          xpath_eval,                                             NULL)
-       PHP_FALIAS(xpath_eval_expression,       xpath_eval_expression,                  NULL)
-       PHP_FALIAS(xpath_register_ns,           xpath_register_ns,                              NULL)
-       PHP_FALIAS(xpath_register_ns_auto,      xpath_register_ns_auto,                 NULL)                   
-       {NULL, NULL, NULL}
-};
-
-static zend_function_entry php_xpathobject_class_functions[] = {
-       {NULL, NULL, NULL}
-};
-#endif
-
-static zend_function_entry php_domxmlattr_class_functions[] = {
-       PHP_FALIAS(domattribute,                        domxml_doc_create_attribute,    NULL)
-       /* DOM_XML Consistent calls */
-       PHP_FALIAS(node_name,                           domxml_attr_name,                               NULL)
-       PHP_FALIAS(node_value,                          domxml_attr_value,                              NULL)
-       PHP_FALIAS(node_specified,                      domxml_attr_specified,                  NULL)
-       /* W3C compliant calls */
-       PHP_FALIAS(name,                                        domxml_attr_name,                               NULL)
-       PHP_FALIAS(value,                                       domxml_attr_value,                              NULL)
-       PHP_FALIAS(specified,                           domxml_attr_specified,                  NULL)
-       PHP_FALIAS(set_value,                           domxml_attr_set_value,                  NULL)
-/*
-       PHP_FALIAS(owner_element,                       domxml_attr_owner_element,              NULL)
-*/
-       {NULL, NULL, NULL}
-};
-
-static zend_function_entry php_domxmlns_class_functions[] = {
-       {NULL, NULL, NULL}
-};
-
-#if HAVE_DOMXSLT
-static zend_function_entry php_domxsltstylesheet_class_functions[] = {
-/* TODO: maybe some more methods? */
-       PHP_FALIAS(process,                                     domxml_xslt_process,                    NULL)
-       PHP_FALIAS(result_dump_mem,                     domxml_xslt_result_dump_mem,    NULL)
-       PHP_FALIAS(result_dump_file,                    domxml_xslt_result_dump_file,   NULL)
-       {NULL, NULL, NULL}
-};
-#endif
-
-zend_module_entry domxml_module_entry = {
-       STANDARD_MODULE_HEADER,
-       "domxml",
-       domxml_functions,
-       PHP_MINIT(domxml),
-       PHP_MSHUTDOWN(domxml),
-       NULL,
-       NULL,
-       PHP_MINFO(domxml),
-       DOMXML_API_VERSION, /* Extension versionnumber */
-       STANDARD_MODULE_PROPERTIES
-};
-
-#ifdef COMPILE_DL_DOMXML
-ZEND_GET_MODULE(domxml)
-#endif
-
-static void dom_object_set_data(void *obj, zval *wrapper)
-{
-/*
-       char tmp[20];
-       sprintf(tmp, "%08X", obj);
-       fprintf(stderr, "Adding %s to hash\n", tmp);
-*/
-       ((xmlNodePtr) obj)->_private = wrapper;
-}
-
-static zval *dom_object_get_data(void *obj)
-{
-/*     char tmp[20];
-       sprintf(tmp, "%08X", obj);
-       fprintf(stderr, "Trying getting %s from object ...", tmp);
-       if (((xmlNodePtr) obj)->_private) {
-               fprintf(stderr, " found\n");
-       } else {
-               fprintf(stderr, " not found\n");
-       }
-*/
-       return ((zval *) (((xmlNodePtr) obj)->_private));
-}
-
-static inline void node_wrapper_dtor(xmlNodePtr node)
-{
-       zval *wrapper;
-       int refcount = 0;
-
-       /* FIXME: type check probably unnecessary here? */
-       if (!node) { /* || Z_TYPE_P(node) == XML_DTD_NODE) */
-               return;
-       }
-
-       wrapper = dom_object_get_data(node);
-
-       if (wrapper != NULL ) {
-               refcount = wrapper->refcount;
-               zval_ptr_dtor(&wrapper);
-
-               /* only set it to null, if refcount was 1 before, otherwise it has still needed references */
-               if (refcount == 1) {
-                       dom_object_set_data(node, NULL);
-               }
-       }
-
-}
-
-
-/*     This function should only be used when freeing nodes 
-       as dependant objects are destroyed */
-static inline void node_wrapper_free(xmlNodePtr node TSRMLS_DC)
-{
-       zval *wrapper, **handle;
-       int type, refcount = 0;
-
-       if (!node) {
-               return;
-       }
-
-       wrapper = dom_object_get_data(node);
-       if (wrapper != NULL ) {
-               /* All references need to be destroyed */
-               if (zend_hash_index_find(Z_OBJPROP_P(wrapper), 0, (void **) &handle) == SUCCESS) {
-                       if (zend_list_find(Z_LVAL_PP(handle), &type)) {
-                               zend_list_delete(Z_LVAL_PP(handle));
-                       }
-               } else {
-                       refcount = wrapper->refcount;
-                       zval_ptr_dtor(&wrapper);
-
-                       /* only set it to null, if refcount was 1 before, otherwise it has still needed references */
-                       if (refcount == 1) {
-                               dom_object_set_data(node, NULL);
-                       }
-               }
-       }
-
-}
-
-static inline void attr_list_wrapper_dtor(xmlAttrPtr attr)
-{
-       while (attr != NULL) {
-               /* Attribute nodes contain children which can be accessed */
-               node_wrapper_dtor((xmlNodePtr) attr);
-               attr = attr->next;
-       }
-}
-
-/*     destroyref is a bool indicating if all registered objects for nodes 
-       within the tree should be destroyed */
-static inline void node_list_wrapper_dtor(xmlNodePtr node, int destroyref TSRMLS_DC)
-{
-       while (node != NULL) {
-               node_list_wrapper_dtor(node->children, destroyref TSRMLS_CC);
-               switch (node->type) {
-                       /* Skip property freeing for the following types */
-                       case XML_ATTRIBUTE_DECL:
-                       case XML_DTD_NODE:
-                       case XML_ENTITY_DECL:
-                       case XML_ATTRIBUTE_NODE:
-                               break;
-                       default:
-                               /*      Attribute Nodes contain accessible children
-                                       Call this function with the propert list
-                               attr_list_wrapper_dtor(node->properties);  */
-                               node_list_wrapper_dtor((xmlNodePtr) node->properties, destroyref TSRMLS_CC);
-               }
-
-               if (destroyref == 1) {
-                       node_wrapper_free(node TSRMLS_CC);
-               } else {
-                       node_wrapper_dtor(node);
-               }
-
-               node = node->next;
-       }
-}
-
-/*     Navigate through the tree and unlink nodes which are referenced by objects */
-static inline void node_list_unlink(xmlNodePtr node)
-{
-       zval *wrapper;
-
-       while (node != NULL) {
-
-               wrapper = dom_object_get_data(node);
-
-               if (wrapper != NULL ) {
-                       /* This node is referenced so no need to check children */
-                       xmlUnlinkNode(node);
-               } else {
-                       node_list_unlink(node->children);
-
-                       switch (node->type) {
-                               /* Skip property freeing for the following types */
-                               case XML_ATTRIBUTE_DECL:
-                               case XML_DTD_NODE:
-                               case XML_ENTITY_DECL:
-                               case XML_ATTRIBUTE_NODE:
-                                       break;
-                               default:
-                                       node_list_unlink((xmlNodePtr) node->properties);
-                       }
-               }
-
-               node = node->next;
-       }
-}
-
-static xmlNodeSetPtr php_get_elements_by_tagname(xmlNodePtr n, xmlChar* name, xmlNodeSet *rv )
-{
-       xmlNodePtr cld = NULL;
-       /* TODO
-          Namespace support
-        */
-       if (n != NULL && name != NULL) {
-               cld = n->children;
-               while (cld != NULL) {
-                       if (xmlStrcmp( name, cld->name) == 0) {
-                               if (rv == NULL) {
-                                       rv = xmlXPathNodeSetCreate(cld);
-                               } else {
-                                       xmlXPathNodeSetAdd(rv, cld);
-                               }
-                       }
-                       rv = php_get_elements_by_tagname(cld, name, rv);
-                       cld = cld->next;
-               }
-       }
-       return rv;
-}
-
-static void php_free_xml_doc(zend_rsrc_list_entry *rsrc TSRMLS_DC)
-{
-       xmlDoc *doc = (xmlDoc *) rsrc->ptr;
-
-       if (doc) {
-               node_list_wrapper_dtor(doc->children, 1 TSRMLS_CC);
-               node_wrapper_dtor((xmlNodePtr) doc);
-               xmlFreeDoc(doc);
-       }
-}
-
-static void php_free_xml_node(zend_rsrc_list_entry *rsrc TSRMLS_DC)
-{
-       xmlNodePtr node = (xmlNodePtr) rsrc->ptr;
-
-       /* if node has no parent, it will not be freed by php_free_xml_doc, so do it here
-       and for all children as well. */
-       if (node->parent == NULL) {
-               /* Attribute Nodes ccontain accessible children 
-               attr_list_wrapper_dtor(node->properties); */
-               xmlSetTreeDoc(node, NULL);
-               node_list_wrapper_dtor((xmlNodePtr) node->properties, 1 TSRMLS_CC);
-               node_list_wrapper_dtor(node->children, 1 TSRMLS_CC);
-               node_wrapper_dtor(node);
-               xmlFreeNode(node);
-       } else {
-               node_wrapper_dtor(node);
-       }
-}
-
-static void php_free_xml_attr(zend_rsrc_list_entry *rsrc TSRMLS_DC)
-{
-       xmlNodePtr node = (xmlNodePtr) rsrc->ptr;
-       if (node->parent == NULL) {
-               /* Attribute Nodes contain accessible children */
-               node_list_wrapper_dtor(node->children, 1 TSRMLS_CC);
-               node_wrapper_dtor(node);
-               xmlFreeProp((xmlAttrPtr) node);
-       } else {
-               node_wrapper_dtor(node);
-       }
-}
-
-#if defined(LIBXML_XPATH_ENABLED)
-static void php_free_xpath_context(zend_rsrc_list_entry *rsrc TSRMLS_DC)
-{
-       xmlXPathContextPtr ctx = (xmlXPathContextPtr) rsrc->ptr;
-       if (ctx) {
-               if (ctx->user) {
-                       zval *wrapper = ctx->user;
-                       zval_ptr_dtor(&wrapper);
-               }
-               xmlXPathFreeContext(ctx);
-       }
-}
-#endif
-
-static void php_free_xml_parser(zend_rsrc_list_entry *rsrc TSRMLS_DC)
-{
-       xmlParserCtxtPtr parser = (xmlParserCtxtPtr) rsrc->ptr;
-
-       if (parser) {
-               zval *wrapper = dom_object_get_data(parser);
-               zval_ptr_dtor(&wrapper);
-               xmlFreeParserCtxt(parser);
-       }
-}
-
-
-#if HAVE_DOMXSLT
-static void xsltstylesheet_set_data(void *obj, zval *wrapper)
-{
-       ((xsltStylesheetPtr) obj)->_private = wrapper;
-}
-
-static zval *xsltstylesheet_get_data(void *obj)
-{
-       return ((zval *) (((xsltStylesheetPtr) obj)->_private));
-}
-
-static void php_free_xslt_stylesheet(zend_rsrc_list_entry *rsrc TSRMLS_DC)
-{
-       xsltStylesheetPtr sheet = (xsltStylesheetPtr) rsrc->ptr;
-       zval *wrapper;
-       int refcount = 0;
-
-       if (sheet) {
-               wrapper = xsltstylesheet_get_data(sheet);
-
-               if (wrapper != NULL ) {
-                       refcount = wrapper->refcount;
-                       zval_ptr_dtor(&wrapper);
-
-                       /* only set it to null, if refcount was 1 before, otherwise it has still needed references */
-                       if (refcount == 1) {
-                               xsltstylesheet_set_data(sheet, NULL);
-                       }
-               }
-               xsltFreeStylesheet(sheet);
-       }
-}
-
-void *php_xsltstylesheet_get_object(zval *wrapper, int rsrc_type1, int rsrc_type2 TSRMLS_DC)
-{
-       void *obj;
-       zval **handle;
-       int type;
-
-       if (NULL == wrapper) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "xsltstylesheet_get_object() invalid wrapper object passed");
-               return NULL;
-       }
-
-       if (Z_TYPE_P(wrapper) != IS_OBJECT) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "wrapper is not an object");
-               return NULL;
-       }
-
-       if (zend_hash_index_find(Z_OBJPROP_P(wrapper), 0, (void **) &handle) == FAILURE) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Underlying object missing");
-               return NULL;
-       }
-
-       obj = zend_list_find(Z_LVAL_PP(handle), &type);
-       if (!obj || ((type != rsrc_type1) && (type != rsrc_type2))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Underlying object missing or of invalid type");
-               return NULL;
-       }
-
-       return obj;
-}
-
-static void php_xsltstylesheet_set_object(zval *wrapper, void *obj, int rsrc_type TSRMLS_DC)
-{
-       zval *handle, *addr;
-
-       MAKE_STD_ZVAL(handle);
-       Z_TYPE_P(handle) = IS_LONG;
-       Z_LVAL_P(handle) = zend_list_insert(obj, rsrc_type);
-
-       MAKE_STD_ZVAL(addr);
-       Z_TYPE_P(addr) = IS_LONG;
-       Z_LVAL_P(addr) = (long) obj;
-
-       zend_hash_index_update(Z_OBJPROP_P(wrapper), 0, &handle, sizeof(zval *), NULL);
-       zend_hash_index_update(Z_OBJPROP_P(wrapper), 1, &addr, sizeof(zval *), NULL);
-       zval_add_ref(&wrapper);
-       xsltstylesheet_set_data(obj, wrapper);
-}
-#endif  /* HAVE_DOMXSLT */
-
-void *php_xpath_get_object(zval *wrapper, int rsrc_type1, int rsrc_type2 TSRMLS_DC)
-{
-       void *obj;
-       zval **handle;
-       int type;
-
-       if (NULL == wrapper) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "php_xpath_get_object() invalid wrapper object passed");
-               return NULL;
-       }
-
-       if (Z_TYPE_P(wrapper) != IS_OBJECT) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "wrapper is not an object");
-               return NULL;
-       }
-
-       if (zend_hash_index_find(Z_OBJPROP_P(wrapper), 0, (void **) &handle) == FAILURE) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Underlying object missing");
-               return NULL;
-       }
-
-       obj = zend_list_find(Z_LVAL_PP(handle), &type);
-       if (!obj || ((type != rsrc_type1) && (type != rsrc_type2))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Underlying object missing or of invalid type");
-               return NULL;
-       }
-
-       return obj;
-}
-
-static zval *php_xpathobject_new(xmlXPathObjectPtr obj, int *found TSRMLS_DC)
-{
-       zval *wrapper;
-
-       MAKE_STD_ZVAL(wrapper);
-       object_init_ex(wrapper, xpathobject_class_entry);
-       return (wrapper);
-}
-
-void *php_xpath_get_context(zval *wrapper, int rsrc_type1, int rsrc_type2 TSRMLS_DC)
-{
-       void *obj;
-       zval **handle;
-       int type;
-
-       if (NULL == wrapper) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "php_xpath_get_context() invalid wrapper object passed");
-               return NULL;
-       }
-
-       if (Z_TYPE_P(wrapper) != IS_OBJECT) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "wrapper is not an object");
-               return NULL;
-       }
-
-       if (zend_hash_index_find(Z_OBJPROP_P(wrapper), 0, (void **) &handle) ==
-               FAILURE) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Underlying object missing");
-               return NULL;
-       }
-
-       obj = zend_list_find(Z_LVAL_PP(handle), &type);
-       if (!obj || ((type != rsrc_type1) && (type != rsrc_type2))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Underlying object missing or of invalid type");
-               return NULL;
-       }
-
-       return obj;
-}
-
-static void xpath_context_set_data(void *obj, zval *wrapper)
-{
-/*
-       char tmp[20];
-       sprintf(tmp, "%08X", obj);
-       fprintf(stderr, "Adding %s to hash\n", tmp);
-*/
-       ((xmlXPathContextPtr) obj)->user = (void *) wrapper;
-}
-
-static zval *xpath_context_get_data(void *obj)
-{
-/*
-       char tmp[20];
-       sprintf(tmp, "%08X", obj);
-       fprintf(stderr, "Trying getting %s from hash ...", tmp);
-       if (((xmlXPathContextPtr) obj)->user) {
-               fprintf(stderr, " found\n");
-       } else {
-               fprintf(stderr, " not found\n");
-       }
-*/
-       return ((zval *) (((xmlXPathContextPtr) obj)->user));
-}
-
-static void php_xpath_set_context(zval *wrapper, void *obj, int rsrc_type TSRMLS_DC)
-{
-       zval *handle, *addr;
-
-       MAKE_STD_ZVAL(handle);
-       Z_TYPE_P(handle) = IS_LONG;
-       Z_LVAL_P(handle) = zend_list_insert(obj, rsrc_type);
-
-       MAKE_STD_ZVAL(addr);
-       Z_TYPE_P(addr) = IS_LONG;
-       Z_LVAL_P(addr) = (long) obj;
-
-       zend_hash_index_update(Z_OBJPROP_P(wrapper), 0, &handle, sizeof(zval *), NULL);
-       zend_hash_index_update(Z_OBJPROP_P(wrapper), 1, &addr, sizeof(zval *), NULL);
-       zval_add_ref(&wrapper);
-       xpath_context_set_data(obj, wrapper);
-}
-
-static zval *php_xpathcontext_new(xmlXPathContextPtr obj, int *found TSRMLS_DC)
-{
-       zval *wrapper;
-       int rsrc_type;
-
-               *found = 0;
-
-       if (!obj) {
-               MAKE_STD_ZVAL(wrapper);
-               ZVAL_NULL(wrapper);
-               return wrapper;
-       }
-
-       if ((wrapper = (zval *) xpath_context_get_data((void *) obj))) {
-               zval_add_ref(&wrapper);
-               *found = 1;
-               return wrapper;
-       }
-
-       MAKE_STD_ZVAL(wrapper);
-/*
-       fprintf(stderr, "Adding new XPath Context\n");
-*/
-       object_init_ex(wrapper, xpathctx_class_entry);
-       rsrc_type = le_xpathctxp;
-       php_xpath_set_context(wrapper, (void *) obj, rsrc_type TSRMLS_CC);
-
-       return (wrapper);
-}
-
-/* helper functions for xmlparser stuff */
-static void xmlparser_set_data(void *obj, zval *wrapper)
-{
-       ((xmlParserCtxtPtr) obj)->_private = wrapper;
-}
-
-
-static void php_xmlparser_set_object(zval *wrapper, void *obj, int rsrc_type TSRMLS_DC)
-{
-       zval *handle, *addr;
-
-       MAKE_STD_ZVAL(handle);
-       Z_TYPE_P(handle) = IS_LONG;
-       Z_LVAL_P(handle) = zend_list_insert(obj, rsrc_type);
-
-       MAKE_STD_ZVAL(addr);
-       Z_TYPE_P(addr) = IS_LONG;
-       Z_LVAL_P(addr) = (long) obj;
-
-       zend_hash_index_update(Z_OBJPROP_P(wrapper), 0, &handle, sizeof(zval *), NULL);
-       zend_hash_index_update(Z_OBJPROP_P(wrapper), 1, &addr, sizeof(zval *), NULL);
-       zval_add_ref(&wrapper);
-       xmlparser_set_data(obj, wrapper);
-}
-
-
-static zval *php_xmlparser_new(xmlParserCtxtPtr obj, int *found TSRMLS_DC)
-{
-       zval *wrapper;
-       int rsrc_type;
-
-               *found = 0;
-
-       if (!obj) {
-               MAKE_STD_ZVAL(wrapper);
-               ZVAL_NULL(wrapper);
-               return wrapper;
-       }
-
-       MAKE_STD_ZVAL(wrapper);
-       object_init_ex(wrapper, domxmlparser_class_entry);
-       rsrc_type = le_domxmlparserp;
-       php_xmlparser_set_object(wrapper, (void *) obj, rsrc_type TSRMLS_CC);
-
-       return (wrapper);
-}
-
-/* {{{ php_xmlparser_make_params()
-   Translates a PHP array to a xmlparser parameters array */
-static char **php_xmlparser_make_params(zval *idvars TSRMLS_DC)
-{
-       HashTable *parht;
-       int parsize;
-       zval **value;
-       char *expr, *string_key = NULL;
-       ulong num_key;
-       char **params = NULL;
-       int i = 0;
-
-       parht = HASH_OF(idvars);
-       parsize = (2 * zend_hash_num_elements(parht) + 1) * sizeof(char *);
-       params = (char **)emalloc(parsize);
-       memset((char *)params, 0, parsize);
-
-       for (zend_hash_internal_pointer_reset(parht);
-               zend_hash_get_current_data(parht, (void **)&value) == SUCCESS;
-               zend_hash_move_forward(parht)) {
-
-               if (zend_hash_get_current_key(parht, &string_key, &num_key, 1) != HASH_KEY_IS_STRING) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid argument or parameter array");
-                       return NULL;
-               } else {
-                       if (Z_TYPE_PP(value) != IS_STRING) {
-                               SEPARATE_ZVAL(value);
-                               convert_to_string(*value);
-                       }
-                       expr = Z_STRVAL_PP(value);
-       
-                       if (expr) {
-                               params[i++] = string_key;
-                               params[i++] = expr;
-                       }
-               }
-       }
-
-       params[i++] = NULL;
-
-       return params;
-}
-/* }}} */
-/* end parser stuff */
-
-void *php_dom_get_object(zval *wrapper, int rsrc_type1, int rsrc_type2 TSRMLS_DC)
-{
-       void *obj;
-       zval **handle;
-       int type;
-
-       if (NULL == wrapper) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "php_dom_get_object() invalid wrapper object passed");
-               return NULL;
-       }
-
-       if (Z_TYPE_P(wrapper) != IS_OBJECT) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "wrapper is not an object");
-               return NULL;
-       }
-
-       if (zend_hash_index_find(Z_OBJPROP_P(wrapper), 0, (void **) &handle) == FAILURE) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Underlying object missing");
-               return NULL;
-       }
-
-       obj = zend_list_find(Z_LVAL_PP(handle), &type);
-
-/* The following test should be replaced with search in all parents */
-       if (!obj) {             /* || ((type != rsrc_type1) && (type != rsrc_type2))) { */
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Underlying object missing or of invalid type");
-               return NULL;
-       }
-
-       return obj;
-}
-
-
-static void php_dom_set_object(zval *wrapper, void *obj, int rsrc_type TSRMLS_DC)
-{
-       zval *handle, *addr;
-
-       MAKE_STD_ZVAL(handle);
-       Z_TYPE_P(handle) = IS_LONG;
-       Z_LVAL_P(handle) = zend_list_insert(obj, rsrc_type);
-
-       MAKE_STD_ZVAL(addr);
-       Z_TYPE_P(addr) = IS_LONG;
-       Z_LVAL_P(addr) = (long) obj;
-
-       zend_hash_index_update(Z_OBJPROP_P(wrapper), 0, &handle, sizeof(zval *), NULL);
-       zend_hash_index_update(Z_OBJPROP_P(wrapper), 1, &addr, sizeof(zval *), NULL);
-       zval_add_ref(&wrapper);
-       dom_object_set_data(obj, wrapper);
-}
-
-PHPAPI zval *php_domobject_new(xmlNodePtr obj, int *found, zval *wrapper_in  TSRMLS_DC)
-{
-       zval *wrapper;
-       char *content;
-       int rsrc_type;
-
-       *found = 0;
-
-       if (!obj) {
-               if (!wrapper_in) {
-                       MAKE_STD_ZVAL(wrapper);
-               } else {
-                       wrapper = wrapper_in;
-               }
-               ZVAL_NULL(wrapper);
-               return wrapper;
-       }
-
-       if ((wrapper = (zval *) dom_object_get_data((void *) obj))) {
-               zval_add_ref(&wrapper);
-               *found = 1;
-               return wrapper;
-       }
-
-       if (!wrapper_in) {
-               MAKE_STD_ZVAL(wrapper);
-       } else {
-               wrapper = wrapper_in;
-       }
-
-       switch (Z_TYPE_P(obj)) {
-
-               case XML_ELEMENT_NODE: {
-                       xmlNodePtr nodep = obj;
-                       if (!wrapper_in) {
-                               object_init_ex(wrapper, domxmlelement_class_entry);
-                       }
-                       rsrc_type = le_domxmlelementp;
-                       add_property_long(wrapper, "type", Z_TYPE_P(nodep));
-                       add_property_stringl(wrapper, "tagname", (char *) nodep->name, strlen(nodep->name), 1);
-                       break;
-               }
-
-               case XML_TEXT_NODE: {
-                       xmlNodePtr nodep = obj;
-                       if (!wrapper_in) {
-                               object_init_ex(wrapper, domxmltext_class_entry);
-                       }
-                       rsrc_type = le_domxmltextp;
-                       content = xmlNodeGetContent(nodep);
-                       add_property_long(wrapper, "type", Z_TYPE_P(nodep));
-                       add_property_stringl(wrapper, "name", "#text", 5, 1);
-                       if (content) {
-                               add_property_stringl(wrapper, "content", (char *) content, strlen(content), 1);
-                       }
-                       xmlFree(content);
-                       break;
-               }
-
-               case XML_COMMENT_NODE: {
-                       xmlNodePtr nodep = obj;
-                       if (!wrapper_in) {
-                               object_init_ex(wrapper, domxmlcomment_class_entry);
-                       }
-                       rsrc_type = le_domxmlcommentp;
-                       content = xmlNodeGetContent(nodep);
-                       if (content) {
-                               add_property_long(wrapper, "type", Z_TYPE_P(nodep));
-                               add_property_stringl(wrapper, "name", "#comment", 8, 1);
-                               add_property_stringl(wrapper, "content", (char *) content, strlen(content), 1);
-                               xmlFree(content);
-                       }
-                       break;
-               }
-
-               case XML_PI_NODE: {
-                       xmlNodePtr nodep = obj;
-                       if (!wrapper_in) {
-                               object_init_ex(wrapper, domxmlpi_class_entry);
-                       }
-                       rsrc_type = le_domxmlpip;
-                       content = xmlNodeGetContent(nodep);
-                       add_property_stringl(wrapper, "name", (char *) nodep->name, strlen(nodep->name), 1);
-                       if (content) {
-                               add_property_stringl(wrapper, "value", (char *) content, strlen(content), 1);
-                               xmlFree(content);
-                       }
-                       break;
-               }
-
-               case XML_ENTITY_REF_NODE: {
-                       xmlNodePtr nodep = obj;
-                       if (!wrapper_in) {
-                               object_init_ex(wrapper, domxmlentityref_class_entry);
-                       }
-                       rsrc_type = le_domxmlentityrefp;
-                       add_property_stringl(wrapper, "name", (char *) nodep->name, strlen(nodep->name), 1);
-                       break;
-               }
-
-               case XML_ENTITY_DECL:
-               case XML_ELEMENT_DECL: {
-                       xmlNodePtr nodep = obj;
-                       if (!wrapper_in) {
-                               object_init_ex(wrapper, domxmlnode_class_entry);
-                       }
-                       rsrc_type = le_domxmlnodep;
-                       add_property_long(wrapper, "type", Z_TYPE_P(nodep));
-                       add_property_stringl(wrapper, "name", (char *) nodep->name, strlen(nodep->name), 1);
-                       if (Z_TYPE_P(obj) == XML_ENTITY_REF_NODE) {
-                               content = xmlNodeGetContent(nodep);
-                               if (content) {
-                                       add_property_stringl(wrapper, "content", (char *) content, strlen(content), 1);
-                                       xmlFree(content);
-                               }
-                       }
-                       break;
-               }
-
-               case XML_ATTRIBUTE_NODE: {
-                       xmlAttrPtr attrp = (xmlAttrPtr) obj;
-                       if (!wrapper_in) {
-                               object_init_ex(wrapper, domxmlattr_class_entry);
-                       }
-                       rsrc_type = le_domxmlattrp;
-                       add_property_long(wrapper, "type", Z_TYPE_P(attrp));
-                       add_property_stringl(wrapper, "name", (char *) attrp->name, strlen(attrp->name), 1);
-                       content = xmlNodeGetContent((xmlNodePtr) attrp);
-                       if (content) {
-                               add_property_stringl(wrapper, "value", (char *) content, strlen(content), 1);
-                               xmlFree(content);
-                       }
-                       break;
-               }
-
-               case XML_DOCUMENT_NODE:
-               case XML_HTML_DOCUMENT_NODE: {
-                       xmlDocPtr docp = (xmlDocPtr) obj;
-                       if (!wrapper_in) {
-                               object_init_ex(wrapper, domxmldoc_class_entry);
-                       }
-                       rsrc_type = le_domxmldocp;
-                       if (docp->name) {
-                               add_property_stringl(wrapper, "name", (char *) docp->name, strlen(docp->name), 1);
-                       } else {
-                               add_property_stringl(wrapper, "name", "#document", 9, 1);
-                       }
-                       if (docp->URL) {
-                               add_property_stringl(wrapper, "url", (char *) docp->URL, strlen(docp->URL), 1);
-                       } else {
-                               add_property_stringl(wrapper, "url", "", 0, 1);
-                       }
-                       if (docp->version) {
-                               add_property_stringl(wrapper, "version", (char *) docp->version, strlen(docp->version), 1);
-                       } else {
-                               add_property_stringl(wrapper, "version", "", 0, 1);
-                       }
-                       if (docp->encoding) {
-                               add_property_stringl(wrapper, "encoding", (char *) docp->encoding, strlen(docp->encoding), 1);
-                       }
-                       add_property_long(wrapper, "standalone", docp->standalone);
-                       add_property_long(wrapper, "type", Z_TYPE_P(docp));
-                       add_property_long(wrapper, "compression", docp->compression);
-                       add_property_long(wrapper, "charset", docp->charset);
-                       break;
-               }
-
-               case XML_DOCUMENT_FRAG_NODE:
-               {
-                       xmlNodePtr nodep = obj;
-                       if(!wrapper_in)
-                               object_init_ex(wrapper, domxmldocumentfragment_class_entry);
-                       add_property_stringl(wrapper, "name", "#document-fragment", 18, 1);
-                       rsrc_type = le_domxmldocumentfragmentp;
-                       add_property_long(wrapper, "type", Z_TYPE_P(nodep));
-                       break;
-               }
-               
-               /* FIXME: nodes of type XML_DTD_NODE used to be domxmldtd_class_entry.
-                * but the DOM Standard doesn't have a DomDtd class. The DocumentType
-                * class seems to be want we need and the libxml dtd functions are
-                * very much like the methods of DocumentType. I wonder what exactly
-                * is the difference between XML_DTD_NODE and XML_DOCUMENT_TYPE_NODE.
-                * Something like
-                * <!DOCTYPE chapter SYSTEM '/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd'
-                * [ <!ENTITY sp \"spanish\">
-                * ]>
-                * is considered a DTD by libxml, but from the DOM perspective it
-                * rather is a DocumentType
-                */
-               case XML_DTD_NODE:
-               case XML_DOCUMENT_TYPE_NODE: {
-                       xmlDtdPtr dtd = (xmlDtdPtr) obj;
-                       if (!wrapper_in) {
-                               object_init_ex(wrapper, domxmldoctype_class_entry);
-                       }
-/*                     rsrc_type = le_domxmldtdp; */
-                       rsrc_type = le_domxmldoctypep;
-/*                     add_property_long(wrapper, "type", Z_TYPE_P(dtd)); */
-                       add_property_long(wrapper, "type", XML_DOCUMENT_TYPE_NODE);
-                       if (dtd->ExternalID) {
-                               add_property_string(wrapper, "publicId", (char *) dtd->ExternalID, 1);
-                       } else {
-                               add_property_string(wrapper, "publicId", "", 1);
-                       }
-                       if (dtd->SystemID) {
-                               add_property_string(wrapper, "systemId", (char *) dtd->SystemID, 1);
-                       } else {
-                               add_property_string(wrapper, "systemId", "", 1);
-                       }
-                       if (dtd->name) {
-                               add_property_string(wrapper, "name", (char *) dtd->name, 1);
-                       }
-                       break;
-               }
-
-               case XML_CDATA_SECTION_NODE: {
-                       xmlNodePtr nodep = obj;
-                       if (!wrapper_in) {
-                               object_init_ex(wrapper, domxmlcdata_class_entry);
-                       }
-                       rsrc_type = le_domxmlcdatap;
-                       content = xmlNodeGetContent(nodep);
-                       add_property_long(wrapper, "type", Z_TYPE_P(nodep));
-                       if (content) {
-                               add_property_stringl(wrapper, "content", (char *) content, strlen(content), 1);
-                               xmlFree(content);
-                       }
-                       break;
-               }
-
-               default:
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported node type: %d\n", Z_TYPE_P(obj));
-                       FREE_ZVAL(wrapper);
-                       return NULL;
-       }
-
-       php_dom_set_object(wrapper, (void *) obj, rsrc_type TSRMLS_CC);
-       return (wrapper);
-}
-
-static void domxml_error(void *ctx, const char *msg, ...)
-{
-       char buf[1024];
-       va_list ap;
-       TSRMLS_FETCH();
-
-       va_start(ap, msg);
-       vsnprintf(buf, 1024, msg, ap);
-       va_end(ap);
-       php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", buf);
-}
-
-static void domxml_error_ext(void *ctx, const char *msg, ...)
-{
-       xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
-       xmlParserInputPtr input = NULL;
-       char buf[1024];
-       va_list ap;
-       TSRMLS_FETCH();
-
-       va_start(ap, msg);
-       vsnprintf(buf, 1024, msg, ap);
-       va_end(ap);
-
-       if (ctxt != NULL && ctxt->_private != NULL) {
-               zval *errormessages;
-               MAKE_STD_ZVAL(errormessages);
-
-               array_init(errormessages);
-               add_assoc_string(errormessages,"errormessage",buf,1);                           
-               input = ctxt->input;
-               if (ctxt->name) {
-                       add_assoc_string(errormessages,"nodename",ctxt->name,1); 
-               }
-               if (input != NULL) {
-                       add_assoc_long(errormessages,"line",input->line);
-                       add_assoc_long(errormessages,"col",input->col);
-                       if (input->filename != NULL) {
-                               add_assoc_string(errormessages,"directory",(char *) input->directory,1);                                
-                               add_assoc_string(errormessages,"file",(char *) input->filename,1);
-                       }
-               }
-               add_next_index_zval(ctxt->_private,errormessages);
-       }
-       php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", buf);
-       
-}
-
-static void domxml_error_validate(void *ctx, const char *msg, ...)
-{
-       domxml_ErrorCtxt *ctxt ;
-       char buf[1024];
-       va_list ap;
-       TSRMLS_FETCH();
-
-       va_start(ap, msg);
-       vsnprintf(buf, 1024, msg, ap);
-       va_end(ap);
-       ctxt  = (domxml_ErrorCtxt*) ctx;
-
-       if (ctxt != NULL && ctxt->errors != NULL) {
-               zval *errormessages;
-               MAKE_STD_ZVAL(errormessages);
-               array_init(errormessages);
-               if (ctxt->parser != NULL) {
-                       if (ctxt->parser->name) {
-                               add_assoc_string(errormessages,"nodename",ctxt->parser->name,1); 
-                       }
-
-                       if (ctxt->parser->input != NULL) {
-                       add_assoc_long(errormessages,"line",ctxt->parser->input->line);
-                       add_assoc_long(errormessages,"col",ctxt->parser->input->col);
-                               if (ctxt->parser->input->filename != NULL) {
-                                       add_assoc_string(errormessages,"directory",(char *) ctxt->parser->input->directory,1);                          
-                                       add_assoc_string(errormessages,"file",(char *) ctxt->parser->input->filename,1);
-                               }
-                       }
-               }
-               
-               if (ctxt->valid->node != NULL)
-               {
-                       /*php_error_docref(NULL TSRMLS_CC, E_WARNING,"Nodename %s",(char *) ctxt->valid->name);
-
-                       node = *ctxt->node;*/
-               }
-               add_assoc_string(errormessages,"errormessage",buf,1);                      
-               add_next_index_zval(ctxt->errors,errormessages);
-       }
-
-       php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", buf);
-       
-}
-
-xmlDocPtr php_dom_xmlSAXParse(xmlSAXHandlerPtr sax, const char *buffer, int size, int recovery, void *data)
-{
-       xmlDocPtr ret;
-       xmlParserCtxtPtr ctxt;
-       domxml_ErrorCtxt errorCtxt;
-       char *directory = NULL;
-
-       xmlInitParser();
-
-       /* if size == -1, we assume, it's a filename not a inmemory xml doc */
-       if (size == -1) {
-               ctxt = (xmlParserCtxt *) xmlCreateFileParserCtxt(buffer);
-       } else {
-               ctxt = (xmlParserCtxt *) xmlCreateMemoryParserCtxt((xmlChar *) buffer, size);
-       }
-       
-       if (ctxt == NULL) {
-               return(NULL);
-       }
-
-       if (sax != NULL) {
-               if (ctxt->sax != NULL) {
-                       xmlFree(ctxt->sax);
-               }
-               ctxt->sax = sax;
-       }
-       if (data!=NULL) {
-               ctxt->_private=data;
-       }
-
-       /* store directory name */
-       if (size == -1) {
-               if ((ctxt->directory == NULL) && (directory == NULL)) {
-                       directory = xmlParserGetDirectory(buffer);
-               }
-               if ((ctxt->directory == NULL) && (directory != NULL)) {
-                       ctxt->directory = (char *) xmlStrdup((xmlChar *) directory);
-               }
-       }
-       errorCtxt.valid = &ctxt->vctxt;
-       errorCtxt.errors = data;
-       errorCtxt.parser = ctxt;   
-
-       ctxt->sax->error = domxml_error_ext;
-       ctxt->sax->warning = domxml_error_ext;
-       ctxt->vctxt.userData = (void *) &errorCtxt;
-       ctxt->vctxt.error    = (xmlValidityErrorFunc) domxml_error_validate;
-       ctxt->vctxt.warning  = (xmlValidityWarningFunc) domxml_error_validate; 
-
-       xmlParseDocument(ctxt);
-
-       if ((ctxt->wellFormed) || recovery) {
-               ret = ctxt->myDoc;
-       } else {
-               ret = NULL;
-               xmlFreeDoc(ctxt->myDoc);
-               ctxt->myDoc = NULL;
-       }
-
-       if (sax != NULL) {
-               ctxt->sax = NULL;
-       }
-
-       xmlFreeParserCtxt(ctxt);
-
-       return(ret);
-}
-
-PHP_MSHUTDOWN_FUNCTION(domxml)
-{
-#if HAVE_DOMXSLT
-       xsltCleanupGlobals();
-#endif
-       xmlCleanupParser();
-       
-/*     If you want do find memleaks in this module, compile libxml2 with --with-mem-debug and
-       uncomment the following line, this will tell you the amount of not freed memory
-       and the total used memory into apaches error_log  */
-/*  xmlMemoryDump();*/
-
-       return SUCCESS;
-}
-
-PHP_MINIT_FUNCTION(domxml)
-{
-       zend_class_entry ce;
-
-       le_domxmlnodep = zend_register_list_destructors_ex(php_free_xml_node, NULL, "domnode", module_number);
-       le_domxmlcommentp = zend_register_list_destructors_ex(php_free_xml_node, NULL, "domcomment", module_number);
-       le_domxmltextp = zend_register_list_destructors_ex(php_free_xml_node, NULL, "domtext", module_number);
-       le_domxmlattrp = zend_register_list_destructors_ex(php_free_xml_attr, NULL, "domattribute", module_number);
-       le_domxmlelementp =     zend_register_list_destructors_ex(php_free_xml_node, NULL, "domelement", module_number);
-       le_domxmldtdp = zend_register_list_destructors_ex(php_free_xml_node, NULL, "domdtd", module_number);
-       le_domxmlcdatap = zend_register_list_destructors_ex(php_free_xml_node, NULL, "domcdata", module_number);
-       le_domxmlentityrefp = zend_register_list_destructors_ex(php_free_xml_node, NULL, "domentityref", module_number);
-       le_domxmlpip = zend_register_list_destructors_ex(php_free_xml_node, NULL, "dompi", module_number);
-       le_domxmldocumentfragmentp = zend_register_list_destructors_ex(php_free_xml_node, NULL, "domdocumentfragment", module_number);
-       le_domxmlparserp =      zend_register_list_destructors_ex(php_free_xml_parser, NULL, "domparser", module_number);
-       le_domxmldoctypep = zend_register_list_destructors_ex(php_free_xml_node, NULL, "domdocumenttype", module_number);
-       le_domxmldocp = zend_register_list_destructors_ex(php_free_xml_doc, NULL, "domdocument", module_number);
-       /* Freeing the document contains freeing the complete tree.
-          Therefore nodes, attributes etc. may not be freed seperately.
-          Moved to end of list to support loading via dl()
-       */
-       /* Not yet initialized le_*s */
-       le_domxmlnotationp  = -10003;
-
-#if defined(LIBXML_XPATH_ENABLED)
-       le_xpathctxp = zend_register_list_destructors_ex(php_free_xpath_context, NULL, "xpathcontext", module_number);
-       le_xpathobjectp = zend_register_list_destructors_ex(NULL, NULL, "xpathobject", module_number);
-#endif
-
-/*     le_domxmlnsp = register_list_destructors(NULL, NULL); */
-
-#if HAVE_DOMXSLT
-       le_domxsltstylesheetp = zend_register_list_destructors_ex(php_free_xslt_stylesheet, NULL, "xsltstylesheet", module_number);
-#endif
-
-       INIT_OVERLOADED_CLASS_ENTRY(ce, "domnode", php_domxmlnode_class_functions, NULL, NULL, NULL);
-       domxmlnode_class_entry = zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC);
-
-       INIT_OVERLOADED_CLASS_ENTRY(ce, "domdocument", php_domxmldoc_class_functions, NULL, NULL, NULL);
-       domxmldoc_class_entry = zend_register_internal_class_ex(&ce, domxmlnode_class_entry, NULL TSRMLS_CC);
-
-       INIT_OVERLOADED_CLASS_ENTRY(ce, "domparser", php_domxmlparser_class_functions, NULL, NULL, NULL);
-       domxmlparser_class_entry = zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC);
-
-       INIT_OVERLOADED_CLASS_ENTRY(ce, "domdocumenttype", php_domxmldoctype_class_functions, NULL,     NULL, NULL);
-       domxmldoctype_class_entry = zend_register_internal_class_ex(&ce, domxmlnode_class_entry, NULL TSRMLS_CC);
-
-       INIT_OVERLOADED_CLASS_ENTRY(ce, "dtd", php_domxmldtd_class_functions, NULL, NULL, NULL);
-       domxmldtd_class_entry = zend_register_internal_class_ex(&ce, domxmlnode_class_entry, NULL TSRMLS_CC);
-
-       INIT_OVERLOADED_CLASS_ENTRY(ce, "domelement", php_domxmlelement_class_functions, NULL, NULL, NULL);
-       domxmlelement_class_entry = zend_register_internal_class_ex(&ce, domxmlnode_class_entry, NULL TSRMLS_CC);
-
-       INIT_OVERLOADED_CLASS_ENTRY(ce, "domattribute", php_domxmlattr_class_functions, NULL, NULL, NULL);
-       domxmlattr_class_entry = zend_register_internal_class_ex(&ce, domxmlnode_class_entry, NULL TSRMLS_CC);
-
-       INIT_OVERLOADED_CLASS_ENTRY(ce, "domcdata", php_domxmlcdata_class_functions, NULL, NULL, NULL);
-       domxmlcdata_class_entry = zend_register_internal_class_ex(&ce, domxmlnode_class_entry, NULL TSRMLS_CC);
-
-       INIT_OVERLOADED_CLASS_ENTRY(ce, "domtext", php_domxmltext_class_functions, NULL, NULL, NULL);
-       domxmltext_class_entry = zend_register_internal_class_ex(&ce, domxmlcdata_class_entry, NULL TSRMLS_CC);
-
-       INIT_OVERLOADED_CLASS_ENTRY(ce, "domcomment", php_domxmlcomment_class_functions, NULL, NULL, NULL);
-       domxmlcomment_class_entry = zend_register_internal_class_ex(&ce, domxmlcdata_class_entry, NULL TSRMLS_CC);
-
-       INIT_OVERLOADED_CLASS_ENTRY(ce, "domprocessinginstruction", php_domxmlpi_class_functions, NULL, NULL, NULL);
-       domxmlpi_class_entry = zend_register_internal_class_ex(&ce, domxmlnode_class_entry, NULL TSRMLS_CC);
-
-       INIT_OVERLOADED_CLASS_ENTRY(ce, "domdocumentfragment", php_domxmldocumentfragment_class_functions, NULL, NULL, NULL);
-       domxmldocumentfragment_class_entry = zend_register_internal_class_ex(&ce, domxmlnode_class_entry, NULL TSRMLS_CC);
-
-       INIT_OVERLOADED_CLASS_ENTRY(ce, "domnotation", php_domxmlnotation_class_functions, NULL, NULL, NULL);
-       domxmlnotation_class_entry = zend_register_internal_class_ex(&ce, domxmlnode_class_entry, NULL TSRMLS_CC);
-
-       INIT_OVERLOADED_CLASS_ENTRY(ce, "domentity", php_domxmlentity_class_functions, NULL, NULL, NULL);
-       domxmlentity_class_entry = zend_register_internal_class_ex(&ce, domxmlnode_class_entry, NULL TSRMLS_CC);
-
-       INIT_OVERLOADED_CLASS_ENTRY(ce, "domentityreference", php_domxmlentityref_class_functions, NULL, NULL, NULL);
-       domxmlentityref_class_entry = zend_register_internal_class_ex(&ce, domxmlnode_class_entry, NULL TSRMLS_CC);
-
-       INIT_OVERLOADED_CLASS_ENTRY(ce, "domnamespace", php_domxmlns_class_functions, NULL, NULL, NULL);
-       domxmlns_class_entry = zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC);
-
-#if defined(LIBXML_XPATH_ENABLED)
-       INIT_OVERLOADED_CLASS_ENTRY(ce, "XPathContext", php_xpathctx_class_functions, NULL, NULL, NULL);
-       xpathctx_class_entry = zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC);
-
-       INIT_OVERLOADED_CLASS_ENTRY(ce, "XPathObject", php_xpathobject_class_functions, NULL, NULL, NULL);
-       xpathobject_class_entry = zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC);
-#endif
-
-#if HAVE_DOMXSLT
-       INIT_OVERLOADED_CLASS_ENTRY(ce, "XsltStylesheet", php_domxsltstylesheet_class_functions, NULL, NULL, NULL);
-       domxsltstylesheet_class_entry = zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC);
-#endif
-
-       REGISTER_LONG_CONSTANT("XML_ELEMENT_NODE",                      XML_ELEMENT_NODE,                       CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_NODE",            XML_ATTRIBUTE_NODE,                     CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_TEXT_NODE",                         XML_TEXT_NODE,                          CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_CDATA_SECTION_NODE",        XML_CDATA_SECTION_NODE,         CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_ENTITY_REF_NODE",           XML_ENTITY_REF_NODE,            CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_ENTITY_NODE",                       XML_ENTITY_NODE,                        CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_PI_NODE",                           XML_PI_NODE,                            CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_COMMENT_NODE",                      XML_COMMENT_NODE,                       CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_DOCUMENT_NODE",                     XML_DOCUMENT_NODE,                      CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_DOCUMENT_TYPE_NODE",        XML_DOCUMENT_TYPE_NODE,         CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_DOCUMENT_FRAG_NODE",        XML_DOCUMENT_FRAG_NODE,         CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_NOTATION_NODE",                     XML_NOTATION_NODE,                      CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_HTML_DOCUMENT_NODE",        XML_HTML_DOCUMENT_NODE,         CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_DTD_NODE",                          XML_DTD_NODE,                           CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_ELEMENT_DECL_NODE",         XML_ELEMENT_DECL,                       CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_DECL_NODE",       XML_ATTRIBUTE_DECL,                     CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_ENTITY_DECL_NODE",          XML_ENTITY_DECL,                        CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_NAMESPACE_DECL_NODE",       XML_NAMESPACE_DECL,                     CONST_CS | CONST_PERSISTENT);
-#ifdef XML_GLOBAL_NAMESPACE
-       REGISTER_LONG_CONSTANT("XML_GLOBAL_NAMESPACE",          XML_GLOBAL_NAMESPACE,           CONST_CS | CONST_PERSISTENT);
-#endif
-       REGISTER_LONG_CONSTANT("XML_LOCAL_NAMESPACE",           XML_LOCAL_NAMESPACE,            CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_CDATA",           XML_ATTRIBUTE_CDATA,            CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_ID",                      XML_ATTRIBUTE_ID,                       CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_IDREF",           XML_ATTRIBUTE_IDREF,            CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_IDREFS",          XML_ATTRIBUTE_IDREFS,           CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_ENTITY",          XML_ATTRIBUTE_ENTITIES,         CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_NMTOKEN",         XML_ATTRIBUTE_NMTOKEN,          CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_NMTOKENS",        XML_ATTRIBUTE_NMTOKENS,         CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_ENUMERATION",     XML_ATTRIBUTE_ENUMERATION,      CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_NOTATION",        XML_ATTRIBUTE_NOTATION,         CONST_CS | CONST_PERSISTENT);
-
-#if defined(LIBXML_XPATH_ENABLED)
-       REGISTER_LONG_CONSTANT("XPATH_UNDEFINED",                       XPATH_UNDEFINED,                        CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XPATH_NODESET",                         XPATH_NODESET,                          CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XPATH_BOOLEAN",                         XPATH_BOOLEAN,                          CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XPATH_NUMBER",                          XPATH_NUMBER,                           CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XPATH_STRING",                          XPATH_STRING,                           CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XPATH_POINT",                           XPATH_POINT,                            CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XPATH_RANGE",                           XPATH_RANGE,                            CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XPATH_LOCATIONSET",                     XPATH_LOCATIONSET,                      CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XPATH_USERS",                           XPATH_USERS,                            CONST_CS | CONST_PERSISTENT);
-#endif
-
-       REGISTER_LONG_CONSTANT("DOMXML_LOAD_PARSING",           DOMXML_LOAD_PARSING,            CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("DOMXML_LOAD_VALIDATING",        DOMXML_LOAD_VALIDATING,         CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("DOMXML_LOAD_RECOVERING",        DOMXML_LOAD_RECOVERING,         CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("DOMXML_LOAD_SUBSTITUTE_ENTITIES",       DOMXML_LOAD_SUBSTITUTE_ENTITIES,                CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("DOMXML_LOAD_COMPLETE_ATTRS",DOMXML_LOAD_COMPLETE_ATTRS,         CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("DOMXML_LOAD_DONT_KEEP_BLANKS",DOMXML_LOAD_DONT_KEEP_BLANKS,             CONST_CS | CONST_PERSISTENT);
-       xmlSetGenericErrorFunc(xmlGenericErrorContext, (xmlGenericErrorFunc)domxml_error);
-#if HAVE_DOMXSLT
-       xsltSetGenericErrorFunc(xsltGenericErrorContext, (xmlGenericErrorFunc)domxml_error);
-#if HAVE_DOMEXSLT
-       exsltRegisterAll();
-#endif
-#endif
-
-       return SUCCESS;
-}
-/* }}} */
-
-/* {{{ proto int domxml_test(int id)
-   Unity function for testing */
-PHP_FUNCTION(domxml_test)
-{
-       zval **id;
-
-       if (ZEND_NUM_ARGS() != 1 || (zend_get_parameters_ex(1, &id) == FAILURE)) {
-               WRONG_PARAM_COUNT;
-       }
-
-       convert_to_long_ex(id);
-       RETURN_LONG(Z_LVAL_PP(id));
-}
-/* }}} */
-
-/* {{{ PHP_MINFO_FUNCTION(domxml)
- */
-PHP_MINFO_FUNCTION(domxml)
-{
-       /* don't know why that line was commented out in the previous version, so i left it (cmv) */
-       php_info_print_table_start();
-       php_info_print_table_row(2, "DOM/XML", "enabled");
-       php_info_print_table_row(2, "DOM/XML API Version", DOMXML_API_VERSION);
-/*     php_info_print_table_row(2, "libxml Version", LIBXML_DOTTED_VERSION); */
-       php_info_print_table_row(2, "libxml Version", xmlParserVersion);
-#if defined(LIBXML_HTML_ENABLED)
-       php_info_print_table_row(2, "HTML Support", "enabled");
-#endif
-#if defined(LIBXML_XPATH_ENABLED)
-       php_info_print_table_row(2, "XPath Support", "enabled");
-#endif
-#if defined(LIBXML_XPTR_ENABLED)
-       php_info_print_table_row(2, "XPointer Support", "enabled");
-#endif
-#if HAVE_DOMXSLT
-       {
-       char buffer[128];
-       int major, minor, subminor;
-
-       php_info_print_table_row(2, "DOM/XSLT", "enabled");
-/*     php_info_print_table_row(2, "libxslt Version", LIBXSLT_DOTTED_VERSION); */
-       major = xsltLibxsltVersion/10000;
-       minor = (xsltLibxsltVersion - major * 10000) / 100;
-       subminor = (xsltLibxsltVersion - major * 10000 - minor * 100);
-       snprintf(buffer, 128, "%d.%d.%d", major, minor, subminor);
-       php_info_print_table_row(2, "libxslt Version", buffer);
-       major = xsltLibxmlVersion/10000;
-       minor = (xsltLibxmlVersion - major * 10000) / 100;
-       subminor = (xsltLibxmlVersion - major * 10000 - minor * 100);
-       snprintf(buffer, 128, "%d.%d.%d", major, minor, subminor);
-       php_info_print_table_row(2, "libxslt compiled against libxml Version", buffer);
-       }
-#if HAVE_DOMEXSLT
-       php_info_print_table_row(2, "DOM/EXSLT", "enabled");
-       php_info_print_table_row(2, "libexslt Version", LIBEXSLT_DOTTED_VERSION);
-#endif
-#endif
-
-       php_info_print_table_end();
-}
-/* }}} */
-
-/* {{{ Methods of Class DomAttribute */
-
-/* {{{ proto array domxml_attr_name(void)
-   Returns list of attribute names
-   Notice: domxml_node_name() does exactly the same for attribute-nodes,
-   is this function here still needed, or would an alias be enough? */
-PHP_FUNCTION(domxml_attr_name)
-{
-       zval *id;
-       xmlAttrPtr attrp;
-
-       DOMXML_GET_THIS_OBJ(attrp, id,le_domxmlattrp);
-
-       DOMXML_NO_ARGS();
-
-       RETURN_STRING((char *) (attrp->name), 1);
-}
-/* }}} */
-
-/* {{{ proto array domxml_attr_value(void)
-   Returns list of attribute names */
-PHP_FUNCTION(domxml_attr_value)
-{
-       zval *id;
-       xmlAttrPtr attrp;
-       xmlChar *content;
-
-       DOMXML_GET_THIS_OBJ(attrp, id, le_domxmlattrp);
-
-       DOMXML_NO_ARGS();
-
-       /* RETURN_STRING((char *) xmlNodeGetContent((xmlNodePtr) attrp), 1); */
-       if ((content = xmlNodeGetContent((xmlNodePtr) attrp)) != NULL) {
-               RETVAL_STRING(content,1);
-       } else {
-               RETURN_EMPTY_STRING();
-       }
-       xmlFree(content);
-}
-/* }}} */
-
-/* {{{ proto bool domxml_attr_set_value(string content)
-   Set value of attribute */
-PHP_FUNCTION(domxml_attr_set_value)
-{
-       zval *id;
-       xmlAttrPtr attrp;
-       int content_len;
-       char *content;
-
-       DOMXML_PARAM_TWO(attrp, id, le_domxmlattrp, "s", &content, &content_len);
-
-       /*      If attribute has children unlink referenced nodes
-               Spec indicates that content is to be overwritten and not appended
-               xmlNodeSetContentLen will take care of removing and freeing the rest */
-       if (attrp->children) {
-               node_list_unlink(((xmlNodePtr) attrp) ->children);
-       }
-       xmlNodeSetContentLen((xmlNodePtr) attrp, content, content_len);
-       RETURN_TRUE;
-
-}
-/* }}} */
-
-/* {{{ proto array domxml_attr_specified(void)
-   Returns list of attribute names */
-PHP_FUNCTION(domxml_attr_specified)
-{
-       zval *id;
-       xmlAttrPtr attrp;
-
-       DOMXML_NOT_IMPLEMENTED();
-
-       id = getThis();
-       attrp = php_dom_get_object(id, le_domxmlattrp, 0 TSRMLS_CC);
-
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* End of Methods DomAttr }}} */
-
-
-/* {{{ Methods of Class DomProcessingInstruction */
-
-/* {{{ proto array domxml_pi_target(void)
-   Returns target of pi */
-PHP_FUNCTION(domxml_pi_target)
-{
-       zval *id;
-       xmlNodePtr nodep;
-
-       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlpip);
-
-       DOMXML_NO_ARGS();
-
-       RETURN_STRING((char *) nodep->name, 1);
-}
-/* }}} */
-
-/* {{{ proto array domxml_pi_data(void)
-   Returns data of pi */
-PHP_FUNCTION(domxml_pi_data)
-{
-       zval *id;
-       xmlNodePtr nodep;
-       xmlChar *content;
-
-       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlpip);
-
-       DOMXML_NO_ARGS();
-
-       /* RETURN_STRING(xmlNodeGetContent(nodep), 1); */
-       if ((content = xmlNodeGetContent(nodep)) != NULL) {
-               RETVAL_STRING(content,1);
-       } else {
-               RETURN_EMPTY_STRING();
-       }
-       xmlFree(content);
-}
-/* }}} */
-
-/* End of Methods of DomProcessingInstruction }}} */
-
-
-/* {{{ Methods of Class DomCData */
-
-/* {{{ proto array domxml_cdata_length(void)
-   Returns list of attribute names */
-PHP_FUNCTION(domxml_cdata_length)
-{
-       zval *id;
-       xmlNodePtr nodep;
-
-       DOMXML_NOT_IMPLEMENTED();
-
-       id = getThis();
-       nodep = php_dom_get_object(id, le_domxmlcdatap, 0 TSRMLS_CC);
-
-       RETURN_LONG(1);
-}
-/* }}} */
-
-/* End of Methods DomCDdata }}} */
-
-
-/* {{{ Methods of Class DomNode */
-
-/* {{{ proto object domxml_node(string name)
-   Creates node */
-PHP_FUNCTION(domxml_node)
-{
-       zval *rv = NULL;
-       xmlNode *node;
-       int ret, name_len;
-       char *name;
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len)  == FAILURE) {
-               return;
-       }
-
-       node = xmlNewNode(NULL, name);
-       if (!node) {
-               RETURN_FALSE;
-       }
-
-       if (DOMXML_IS_TYPE(getThis(), domxmlnode_class_entry)) {
-               DOMXML_DOMOBJ_NEW(getThis(), node, &ret);
-       } else {
-               DOMXML_RET_OBJ(rv, node, &ret);
-       }
-}
-/* }}} */
-
-/* {{{ proto object domxml_node_name(void)
-   Returns name of node */
-PHP_FUNCTION(domxml_node_name)
-{
-       zval *id;
-       xmlNode *n;
-       int fullQName = 0;
-       const char *str = NULL;
-
-       DOMXML_PARAM_ONE(n, id, le_domxmlnodep,"|b",&fullQName);
-
-       switch (Z_TYPE_P(n)) {
-               case XML_ELEMENT_NODE:
-                       if (fullQName && n->ns && n->ns->prefix) {
-                               /* there is maybe a better way of doing this...*/
-                               char *tmpstr;
-                               tmpstr = (char*) emalloc((strlen(n->ns->prefix)+strlen(n->name))  * sizeof(char)) ;
-                               sprintf(tmpstr,"%s:%s", (char*) n->ns->prefix, (char*) n->name);
-                               str = strdup(tmpstr);
-                               efree(tmpstr);
-                       } else {
-                               str = n->name;
-                       }
-                       break;
-
-               case XML_TEXT_NODE:
-                       str = "#text";
-                       break;
-
-               case XML_ATTRIBUTE_NODE:
-                       str = n->name;
-                       break;
-
-               case XML_CDATA_SECTION_NODE:
-                       str = "#cdata-section";
-                       break;
-
-               case XML_ENTITY_REF_NODE:
-                       str = n->name;
-                       break;
-
-               case XML_ENTITY_NODE:
-                       str = NULL;
-                       break;
-
-               case XML_PI_NODE:
-                       str = n->name;
-                       break;
-
-               case XML_COMMENT_NODE:
-                       str = "#comment";
-                       break;
-
-               case XML_DOCUMENT_NODE:
-                       str = "#document";
-                       break;
-
-               case XML_DOCUMENT_FRAG_NODE:
-                       str = "#document-fragment";
-                       break;
-
-               default:
-                       str = NULL;
-                       break;
-       }
-
-       if (str != NULL) {
-               RETURN_STRING((char *) str, 1);
-       } else {
-               RETURN_EMPTY_STRING();
-       }
-}
-/* }}} */
-
-/* {{{ proto object domxml_node_value(void)
-   Returns name of value */
-PHP_FUNCTION(domxml_node_value)
-{
-       zval *id;
-       xmlNode *n;
-       char *str = NULL;
-
-       DOMXML_GET_THIS_OBJ(n, id, le_domxmlnodep);
-
-       DOMXML_NO_ARGS();
-
-       switch (Z_TYPE_P(n)) {
-               case XML_TEXT_NODE:
-               case XML_COMMENT_NODE:
-               case XML_CDATA_SECTION_NODE:
-               case XML_PI_NODE:
-                       str = n->content;
-                       break;
-               default:
-                       str = NULL;
-                       break;
-       }
-       if (str != NULL) {
-               RETURN_STRING((char *) str, 1);
-       } else {
-               RETURN_EMPTY_STRING();
-       }
-}
-/* }}} */
-
-/* {{{ proto bool domxml_is_blank_node(void)
-   Returns true if node is blank */
-PHP_FUNCTION(domxml_is_blank_node)
-{
-       zval *id;
-       xmlNode *n;
-
-       DOMXML_GET_THIS_OBJ(n, id, le_domxmlnodep);
-
-       DOMXML_NO_ARGS();
-
-       if (xmlIsBlankNode(n)) {
-               RETURN_TRUE;
-       } else {
-               RETURN_FALSE;
-       }
-}
-/* }}} */
-
-/* {{{ proto int domxml_node_type(void)
-   Returns the type of the node */
-PHP_FUNCTION(domxml_node_type)
-{
-       zval *id;
-       xmlNode *node;
-
-       DOMXML_GET_THIS_OBJ(node, id, le_domxmlnodep);
-
-       DOMXML_NO_ARGS();
-
-       RETURN_LONG(node->type);
-}
-/* }}} */
-
-/* {{{ proto object domxml_clone_node([bool deep])
-   Clones a node */
-PHP_FUNCTION(domxml_clone_node)
-{
-       zval *rv = NULL;
-       zval *id;
-       xmlNode *n, *node;
-       int ret; 
-       long recursive = 0;
-
-       DOMXML_GET_THIS_OBJ(n, id, le_domxmlnodep);
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &recursive) == FAILURE) {
-               return;
-       }
-
-       node = xmlCopyNode(n, recursive);
-       if (!node) {
-               RETURN_FALSE;
-       }
-
-       DOMXML_RET_OBJ(rv, node, &ret);
-}
-/* }}} */
-
-/* {{{ proto object domxml_node_first_child(void)
-   Returns first child from list of children */
-PHP_FUNCTION(domxml_node_first_child)
-{
-       zval *id, *rv = NULL;
-       xmlNode *nodep, *first;
-       int ret;
-
-       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep);
-
-       DOMXML_NO_ARGS();
-
-       first = nodep->children;
-       if (!first) {
-               return;
-       }
-
-       DOMXML_RET_OBJ(rv, first, &ret);
-}
-/* }}} */
-
-/* {{{ proto object domxml_node_last_child(void)
-   Returns last child from list of children */
-PHP_FUNCTION(domxml_node_last_child)
-{
-       zval *id, *rv = NULL;
-       xmlNode *nodep, *last;
-       int ret;
-
-       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep);
-
-       DOMXML_NO_ARGS();
-
-       last = nodep->last;
-       if (!last) {
-               return;
-       }
-
-       DOMXML_RET_OBJ(rv, last, &ret);
-}
-/* }}} */
-
-/* {{{ proto object domxml_node_next_sibling(void)
-   Returns next child from list of children */
-PHP_FUNCTION(domxml_node_next_sibling)
-{
-       zval *id, *rv = NULL;
-       xmlNode *nodep, *first;
-       int ret;
-
-       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep);
-
-       DOMXML_NO_ARGS();
-
-       first = nodep->next;
-       if (!first) {
-               rv = NULL;
-               return;
-       }
-
-       DOMXML_RET_OBJ(rv, first, &ret);
-}
-/* }}} */
-
-/* {{{ proto object domxml_node_previous_sibling(void)
-   Returns previous child from list of children */
-PHP_FUNCTION(domxml_node_previous_sibling)
-{
-       zval *id, *rv = NULL;
-       xmlNode *nodep, *first;
-       int ret;
-
-       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep);
-
-       DOMXML_NO_ARGS();
-
-       first = nodep->prev;
-       if (!first) {
-               rv = NULL;
-               return;
-       }
-
-       DOMXML_RET_OBJ(rv, first, &ret);
-}
-/* }}} */
-
-/* {{{ proto object domxml_node_owner_document(void)
-   Returns document this node belongs to */
-PHP_FUNCTION(domxml_node_owner_document)
-{
-       zval *id, *rv = NULL;
-       xmlNode *nodep;
-       xmlDocPtr docp;
-       int ret;
-
-       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep);
-
-       DOMXML_NO_ARGS();
-
-       docp = nodep->doc;
-       if (!docp) {
-               RETURN_FALSE;
-       }
-
-       DOMXML_RET_OBJ(rv, (xmlNodePtr) docp, &ret);
-}
-/* }}} */
-
-/* {{{ proto object domxml_node_has_child_nodes(void)
-   Returns true if node has children */
-PHP_FUNCTION(domxml_node_has_child_nodes)
-{
-       zval *id;
-       xmlNode *nodep;
-
-       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep);
-
-       DOMXML_NO_ARGS();
-
-       if (nodep->children) {
-               RETURN_TRUE;
-       } else {
-               RETURN_FALSE;
-       }
-}
-/* }}} */
-
-/* {{{ proto object domxml_node_has_attributes(void)
-   Returns true if node has attributes */
-PHP_FUNCTION(domxml_node_has_attributes)
-{
-       zval *id;
-       xmlNode *nodep;
-
-       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep);
-
-       DOMXML_NO_ARGS();
-
-       if (Z_TYPE_P(nodep) != XML_ELEMENT_NODE) {
-               RETURN_FALSE;
-       }
-
-       if (nodep->properties) {
-               RETURN_TRUE;
-       } else {
-               RETURN_FALSE;
-       }
-}
-/* }}} */
-
-/* {{{ proto string domxml_node_prefix(void)
-   Returns namespace prefix of node */
-PHP_FUNCTION(domxml_node_prefix)
-{
-       zval *id;
-       xmlNode *nodep;
-       xmlNsPtr ns;
-
-       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep);
-
-       DOMXML_NO_ARGS();
-
-       ns = nodep->ns;
-       if (!ns) {
-               RETURN_EMPTY_STRING();
-       }
-
-       if (ns->prefix) {
-               RETURN_STRING((char *) (ns->prefix), 1);
-       } else {
-               RETURN_EMPTY_STRING();
-       }
-}
-/* }}} */
-
-/* {{{ proto string domxml_node_namespace_uri(void)
-   Returns namespace uri of node */
-PHP_FUNCTION(domxml_node_namespace_uri)
-{
-       zval *id;
-       xmlNode *nodep;
-       xmlNsPtr ns;
-
-       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep);
-
-       DOMXML_NO_ARGS();
-
-       ns = nodep->ns;
-       if (!ns) {
-               /* return NULL if no ns is given...*/
-               return;
-       }
-
-       if (ns->href) {
-               RETURN_STRING((char *) (ns->href), 1);
-       } else {
-               RETURN_EMPTY_STRING();
-       }
-}
-/* }}} */
-
-/* {{{ proto string domxml_node_get_path(void)
-   Returns the path of the node in the document */
-PHP_FUNCTION(domxml_node_get_path)
-{
-       zval *id;
-       xmlNodePtr nodep;
-       xmlChar *path;
-
-       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep);
-
-       DOMXML_NO_ARGS();
-
-       path = xmlGetNodePath(nodep);
-       if (!path) {
-               RETURN_FALSE;
-       }
-       RETVAL_STRING((char *)path, 1);
-       xmlFree(path);
-}
-
-/* {{{ proto object domxml_node_parent(void)
-   Returns parent of node */
-PHP_FUNCTION(domxml_node_parent)
-{
-       zval *id, *rv = NULL;
-       xmlNode *nodep, *last;
-       int ret;
-
-       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep);
-
-       DOMXML_NO_ARGS();
-
-       last = nodep->parent;
-       if (!last) {
-               return;
-       }
-
-       DOMXML_RET_OBJ(rv, last, &ret);
-}
-/* }}} */
-
-/* {{{ proto array domxml_node_children(void)
-   Returns list of children nodes */
-PHP_FUNCTION(domxml_node_children)
-{
-       zval *id;
-       xmlNode *nodep, *last;
-       int ret;
-
-       DOMXML_PARAM_NONE(nodep, id, le_domxmlnodep);
-
-       /* Even if the nodep is a XML_DOCUMENT_NODE the type is at the
-          same position.
-        */
-       if ((Z_TYPE_P(nodep) == XML_DOCUMENT_NODE) || (Z_TYPE_P(nodep) == XML_HTML_DOCUMENT_NODE)) {
-               last = ((xmlDoc *) nodep)->children;
-       } else {
-               last = nodep->children;
-       }
-
-       array_init(return_value);
-       
-       if (last) {
-               while (last) {
-                       zval *child;
-                       child = php_domobject_new(last, &ret, NULL TSRMLS_CC);
-                       add_next_index_zval(return_value, child);
-                       last = last->next;
-               }
-       }
-}
-/* }}} */
-
-/* {{{ proto void domxml_node_unlink_node([object node])
-   Deletes the node from tree, but not from memory*/
-PHP_FUNCTION(domxml_node_unlink_node)
-{
-       zval *id;
-       xmlNode *nodep;
-
-       DOMXML_PARAM_NONE(nodep, id, le_domxmlnodep);
-
-       xmlUnlinkNode(nodep);
-       /*      This causes a Segmentation Fault for some reason.  Removing
-               it allows the user to re-add the node at some other time, in
-               addition to fixing the segfault.  Node will be freed at
-               shutdown. */
-       /*xmlFreeNode(nodep);
-       zval_dtor(id);*/                        /* This is not enough because the children won't be deleted */
-}
-/* }}} */
-
-/* {{{ proto object domxml_node_replace_node(object domnode)
-   Replaces one node with another node */
-PHP_FUNCTION(domxml_node_replace_node)
-{
-       zval *id, *rv = NULL, *node;
-       xmlNodePtr repnode, nodep, old_repnode;
-       int ret;
-
-       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep);
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &node) == FAILURE) {
-               return;
-       }
-
-       DOMXML_GET_OBJ(repnode, node, le_domxmlnodep);
-
-       old_repnode = xmlReplaceNode(nodep, repnode);
-
-       DOMXML_RET_OBJ(rv, old_repnode, &ret);
-}
-/* }}} */
-
-/* {{{ proto object domxml_node_append_child(object domnode)
-   Adds node to list of children */
-PHP_FUNCTION(domxml_node_append_child)
-{
-       zval *id, *rv = NULL, *node;
-       xmlNodePtr child, parent, new_child = NULL;
-       int ret;
-
-       DOMXML_PARAM_ONE(parent, id, le_domxmlnodep, "o", &node);
-       
-       DOMXML_GET_OBJ(child, node, le_domxmlnodep);
-
-       if (child->type == XML_ATTRIBUTE_NODE) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't append attribute node");
-               RETURN_FALSE;
-       }
-
-       /* XXX:ls */
-       if (child == parent) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't append node to itself");
-               RETURN_FALSE;
-       }
-       
-       if (!(child->doc == NULL || child->doc == parent->doc)) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't append node, which is in a different document than the parent node");
-               RETURN_FALSE;
-       }
-       
-       /* first unlink node, if child is already in the tree */
-       if (child->doc == parent->doc && child->parent != NULL) {
-               xmlUnlinkNode(child);
-       }
-       
-       /*
-        * The following code is from libxml2/tree.c and a fix for bug #20209
-        * libxml does free textnodes, if there are adjacent TEXT nodes
-        * This is bad behaviour for domxml, since then we have have reference
-        * to undefined nodes. The idea here is, that we do this text comparison
-        * by ourself and not free the nodes. and only if libxml2 won't do any harm
-        * call the function from libxml2.
-        * The code is exactly the same as in libxml2, only xmlFreeNode was taken away.
-        */
-
-       if (child->type == XML_TEXT_NODE) {
-               if ((parent->type == XML_TEXT_NODE) &&
-                       (parent->content != NULL)) {
-                       xmlNodeAddContent(parent, child->content);
-                       new_child = parent;
-               }
-               if ((parent->last != NULL) && (parent->last->type == XML_TEXT_NODE) &&
-                       (parent->last->name == child->name)) {
-                       xmlNodeAddContent(parent->last, child->content);
-                       new_child = parent->last;
-               }
-       }
-       /* end libxml2 code */
-       if (child->type == XML_DOCUMENT_FRAG_NODE) {
-               new_child = xmlAddChildList(parent, child->children);
-               if (NULL != new_child) {
-                       /* the children are copied, not moved, but domstandard wants to move it 
-                          therefore we delete the reference here */
-                       child->children = NULL;
-               }
-       } else if (NULL == new_child) {
-               new_child = xmlAddChild(parent, child);
-       }
-
-       if (NULL == new_child) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't append node");
-               RETURN_FALSE;
-       } 
-
-       DOMXML_RET_OBJ(rv, new_child, &ret);
-}
-/* }}} */
-
-/* {{{ proto object domxml_node_append_sibling(object domnode)
-   Adds node to list of siblings */
-PHP_FUNCTION(domxml_node_append_sibling)
-{
-       zval *id, *rv = NULL, *node;
-       xmlNodePtr child, nodep, new_child;
-       int ret;
-
-       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep);
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &node) == FAILURE) {
-               return;
-       }
-
-       DOMXML_GET_OBJ(child, node, le_domxmlnodep);
-
-       if (child->type == XML_ATTRIBUTE_NODE) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't append attribute node");
-               RETURN_FALSE;
-       }
-
-       if (NULL == (new_child = xmlCopyNode(child, 1))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to clone node");
-               RETURN_FALSE;
-       }
-
-       /* FIXME reverted xmlAddChildList; crashes */
-       child = xmlAddSibling(nodep, new_child);
-
-       if (NULL == child) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't append node");
-               RETURN_FALSE;
-       }
-
-       DOMXML_RET_OBJ(rv, child, &ret);
-}
-/* }}} */
-
-/* {{{ proto object domxml_node_insert_before(object newnode, object refnode)
-   Adds node in list of nodes before given node */
-PHP_FUNCTION(domxml_node_insert_before)
-{
-       zval *id, *rv = NULL, *node, *ref;
-       xmlNodePtr child, new_child, parent, refp;
-       int ret;
-
-       DOMXML_PARAM_TWO(parent, id, le_domxmlnodep, "oo!", &node, &ref);
-
-       DOMXML_GET_OBJ(child, node, le_domxmlnodep);
-
-       new_child = NULL;
-
-       if (ref != NULL) {
-               DOMXML_GET_OBJ(refp, ref, le_domxmlnodep);
-               
-                /* 
-                 * The following code is from libxml2/tree.c 
-                 * libxml does free textnodes, if there are adjacent TEXT nodes
-                 * This is bad behaviour for domxml, since then we have have reference
-                 * to undefined nodes. The idea here is, that we do this text comparison
-                 * by ourself and not free the nodes. and only if libxml2 won't do any harm
-                 * call the function from libxml2.
-                 * The code is exactly the same as in libxml2, only xmlFreeNode was taken away.
-                 */
-
-               if (child->type == XML_TEXT_NODE) {
-                       if (refp->type == XML_TEXT_NODE) {
-                               xmlChar *tmp;
-
-                               tmp = xmlStrdup(child->content);
-                               tmp = xmlStrcat(tmp, refp->content);
-                               xmlNodeSetContent(refp, tmp);
-                               xmlFree(tmp);
-                               new_child = refp;
-                       }
-                       if ((refp->prev != NULL) && (refp->prev->type == XML_TEXT_NODE)
-                               && (refp->name == refp->prev->name)) {
-                               xmlNodeAddContent(refp->prev, child->content);
-                               new_child = refp->prev;
-                       }
-               }
-
-               if (new_child == NULL) {
-                       new_child = xmlAddPrevSibling(refp, child);
-               }
-       } else {
-               
-               if (child->type == XML_DOCUMENT_FRAG_NODE) {
-                       new_child = xmlAddChildList(parent, child->children);
-                       if (NULL != new_child) {
-                       /* the children are copied, not moved, but domstandard wants to move it 
-                          therefore we delete the reference here */
-                               
-                          child->children = NULL;
-                       }
-               } else {
-               
-                       /* first unlink node, if child is already a child of parent
-                               for some strange reason, this is needed
-                        */
-               
-                       if (child->parent == parent){
-                               xmlUnlinkNode(child);
-                       }
-               
-                       new_child = xmlAddChild(parent, child);
-               }
-       }
-               
-
-       if (NULL == new_child) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't add newnode as the previous sibling of refnode");
-               RETURN_FALSE;
-       }
-
-       DOMXML_RET_OBJ(rv, new_child, &ret);
-}
-/* }}} */
-
-/* {{{ proto object domxml_node_remove_child(object domnode)
-   Removes node from list of children */
-PHP_FUNCTION(domxml_node_remove_child)
-{
-       zval *id, *node;
-       xmlNodePtr children, child, nodep;
-       int ret;
-
-       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep);
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &node) == FAILURE) {
-               return;
-       }
-
-       DOMXML_GET_OBJ(child, node, le_domxmlnodep);
-
-       children = nodep->children;
-       if (!children) {
-               RETURN_FALSE;
-       }
-
-       while (children) {
-               if (children == child) {
-                       zval *rv = NULL;
-                       xmlUnlinkNode(child);
-                       DOMXML_RET_OBJ(rv, child, &ret);
-                       return;
-               }
-               children = children->next;
-       }
-       RETURN_FALSE
-}
-/* }}} */
-
-/* {{{ proto object domxml_node_replace_child(object newnode, object oldnode)
-   Replaces node in list of children */
-PHP_FUNCTION(domxml_node_replace_child)
-{
-       zval *id, *newnode, *oldnode;
-       xmlNodePtr children, newchild, oldchild, nodep;
-       int foundoldchild = 0;
-       int ret;
-
-       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep);
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "oo", &newnode, &oldnode) == FAILURE) {
-               return;
-       }
-
-       DOMXML_GET_OBJ(newchild, newnode, le_domxmlnodep);
-       DOMXML_GET_OBJ(oldchild, oldnode, le_domxmlnodep);
-
-       children = nodep->children;
-       if (!children) {
-               RETURN_FALSE;
-       }
-
-       /* check for the old child and wether the new child is already a child */
-       while (children) {
-               if (children == oldchild) {
-                       foundoldchild = 1;
-               }
-               children = children->next;
-       }
-       /* if the child to replace is existent and the new child isn't already
-        * a child, then do the replacement
-        */
-       if (foundoldchild) {
-               zval *rv = NULL;
-               xmlNodePtr node;
-               node = xmlReplaceNode(oldchild, newchild);
-               DOMXML_RET_OBJ(rv, oldchild, &ret);
-               return;
-       } else {
-               RETURN_FALSE;
-       }
-}
-/* }}} */
-
-/* {{{ proto bool domxml_node_set_name(string name)
-   Sets name of a node */
-PHP_FUNCTION(domxml_node_set_name)
-{
-       zval *id;
-       xmlNode *nodep;
-       int name_len;
-       char *name;
-
-       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep);
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
-               return;
-       }
-
-       xmlNodeSetName(nodep, name);
-
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto array domxml_node_attributes(void)
-   Returns list of attributes of node */
-PHP_FUNCTION(domxml_node_attributes)
-{
-       zval *id, *attrs;
-       xmlNode *nodep;
-       int ret;
-
-       DOMXML_PARAM_NONE(nodep, id, le_domxmlnodep);
-       ret = node_attributes(&attrs, nodep TSRMLS_CC);
-       if ( ret == -1) {
-               RETURN_NULL();
-       }
-
-       if ( ret > -1) {
-               *return_value = *attrs;
-               FREE_ZVAL(attrs);
-       } 
-}
-/* }}} */
-
-/* {{{ proto object domxml_node_new_child(string name, string content)
-   Adds child node to parent node */
-PHP_FUNCTION(domxml_node_new_child)
-{
-       zval *id, *rv = NULL;
-       xmlNodePtr child, nodep;
-       int ret, name_len, content_len;
-       char *name, *content = NULL;
-
-       DOMXML_PARAM_FOUR(nodep, id, le_domxmlnodep, "s|s", &name, &name_len, &content, &content_len);
-
-       child = xmlNewChild(nodep, NULL, name, content);
-
-       if (!child) {
-               RETURN_FALSE;
-       }
-
-       DOMXML_RET_OBJ(rv, child, &ret);
-}
-/* }}} */
-
-/* {{{ proto bool domxml_node_set_content(string content)
-   Sets content of a node */
-PHP_FUNCTION(domxml_node_set_content)
-{
-       zval *id;
-       xmlNode *nodep;
-       int content_len;
-       char *content;
-
-       DOMXML_PARAM_TWO(nodep, id, le_domxmlnodep, "s", &content, &content_len);
-
-       /* FIXME: another gotcha. If node has children, calling
-        * xmlNodeSetContent will remove the children -> we loose the zval's
-        * To prevent crash, append content if children are set
-        */
-       if (nodep->children) {
-               xmlNodeAddContentLen(nodep, content, content_len);
-       } else {
-               xmlNodeSetContentLen(nodep, content, content_len);
-       }
-
-       /* FIXME: Actually the property 'content' of the node has to be updated
-          as well. Since 'content' should disappear sooner or later and being
-          replaces by a function 'content()' I skip this for now
-        */
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto string domxml_node_get_content()
-   Gets content of a node.
-
-   "Read the value of a node, this can be either the text carried directly by
-this node if it's a TEXT node or the aggregate string of the values carried by
-this node child's (TEXT and ENTITY_REF). Entity references are substituted."
-   */
-PHP_FUNCTION(domxml_node_get_content)
-{
-       zval *id;
-       xmlNode *nodep;
-       xmlChar *mem;
-
-       DOMXML_PARAM_NONE(nodep, id, le_domxmlnodep);
-       mem = xmlNodeGetContent(nodep);
-       if (!mem) {
-               RETURN_FALSE;
-       }
-
-       RETVAL_STRING(mem,1);
-       xmlFree(mem);
-}
-/* }}} */
-
-
-/* End of Methods DomNode }}} */
-
-
-/* {{{ Methods of Class DomNotation */
-
-/* {{{ proto string domxml_notation_public_id(void)
-   Returns public id of notation node */
-PHP_FUNCTION(domxml_notation_public_id)
-{
-       zval *id;
-       xmlNotationPtr nodep;
-
-       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnotationp);
-
-       DOMXML_NO_ARGS();
-
-       if (nodep->PublicID) {
-               RETURN_STRING((char *) (nodep->PublicID), 1);
-       } else {
-               RETURN_EMPTY_STRING();
-       }
-}
-/* }}} */
-
-/* {{{ proto string domxml_notation_system_id(void)
-   Returns system ID of notation node */
-PHP_FUNCTION(domxml_notation_system_id)
-{
-       zval *id;
-       xmlNotationPtr nodep;
-
-       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnotationp);
-
-       DOMXML_NO_ARGS();
-
-       if (nodep->SystemID) {
-               RETURN_STRING((char *) (nodep->SystemID), 1);
-       } else {
-               RETURN_EMPTY_STRING();
-       }
-}
-/* }}} */
-
-/* End of Methods DomNotation }}} */
-
-
-/* {{{ Methods of Class DomElement */
-
-/* {{{ proto object domxml_element(string name)
-   Constructor of DomElement */
-PHP_FUNCTION(domxml_element)
-{
-       zval *rv = NULL;
-       xmlNode *node;
-       int ret, name_len;
-       char *name;
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
-               return;
-       }
-
-       node = xmlNewNode(NULL, name);
-       if (!node) {
-               RETURN_FALSE;
-       }
-
-       DOMXML_RET_OBJ(rv, node, &ret);
-}
-
-/* }}} */
-
-/* {{{ proto string domxml_elem_tagname(void)
-   Returns tag name of element node */
-PHP_FUNCTION(domxml_elem_tagname)
-{
-       zval *id;
-       xmlNode *nodep;
-
-       DOMXML_NO_ARGS();
-
-       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlelementp);
-
-       DOMXML_NO_ARGS();
-
-       RETURN_STRING((char *) (nodep->name), 1);
-}
-/* }}} */
-
-/* {{{ proto string domxml_elem_get_attribute(string attrname)
-   Returns value of given attribute */
-PHP_FUNCTION(domxml_elem_get_attribute)
-{
-       zval *id;
-       xmlNode *nodep;
-       char *name, *value;
-       int name_len;
-
-       DOMXML_PARAM_TWO(nodep, id, le_domxmlelementp, "s", &name, &name_len);
-
-       value = xmlGetProp(nodep, name);
-       if (!value) {
-               RETURN_EMPTY_STRING();
-       } else {
-               RETVAL_STRING(value, 1);
-               xmlFree(value);
-       }
-}
-/* }}} */
-
-/* {{{ proto bool domxml_elem_set_attribute(string attrname, string value)
-   Sets value of given attribute */
-PHP_FUNCTION(domxml_elem_set_attribute)
-{
-       zval *id, *rv = NULL;
-       xmlNode *nodep;
-       xmlAttr *attr;
-       int ret, name_len, value_len;
-       char *name, *value;
-
-       DOMXML_PARAM_FOUR(nodep, id, le_domxmlelementp, "ss", &name, &name_len, &value, &value_len);
-
-
-       /*      If attribute exists, all children nodes are freed by setprop 
-               unlink referenced children */
-       attr = xmlHasProp(nodep,name);
-       if (attr != NULL) {
-               node_list_unlink(attr->children);
-       }
-       attr = xmlSetProp(nodep, name, value);
-       if (!attr) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such attribute '%s'", name);
-               RETURN_FALSE;
-       }
-
-       DOMXML_RET_OBJ(rv, (xmlNodePtr) attr, &ret);
-}
-/* }}} */
-
-/* {{{ proto string domxml_elem_remove_attribute(string attrname)
-   Removes given attribute */
-PHP_FUNCTION(domxml_elem_remove_attribute)
-{
-       zval *id;
-       xmlNode *nodep;
-       xmlAttr *attrp;
-       int name_len;
-       char *name;
-
-       DOMXML_PARAM_TWO(nodep, id, le_domxmlelementp, "s", &name, &name_len);
-       attrp = xmlHasProp(nodep,name);
-       if (attrp == NULL) {
-               RETURN_FALSE;
-       }
-
-       /*      Check for registered nodes within attributes tree when attribute is not referenced  
-               Unlink dependant nodes and free attribute if not registered */
-       if (dom_object_get_data((xmlNodePtr) attrp) == NULL) {
-               node_list_unlink(attrp->children);
-               xmlUnlinkNode((xmlNodePtr) attrp);
-               xmlFreeProp(attrp);
-       } else {
-               xmlUnlinkNode((xmlNodePtr) attrp);
-       }
-
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto string domxml_elem_get_attribute_node(string attrname)
-   Returns value of given attribute */
-PHP_FUNCTION(domxml_elem_get_attribute_node)
-{
-       zval *id, *rv = NULL;
-       xmlNode *nodep;
-       xmlAttr  *attrp;
-       int name_len, ret;
-       char *name;
-
-       DOMXML_PARAM_TWO(nodep, id, le_domxmlelementp, "s", &name, &name_len);
-       attrp = xmlHasProp(nodep,name);
-       if (attrp == NULL) {
-               RETURN_FALSE;
-       }
-       DOMXML_RET_OBJ(rv, (xmlNodePtr) attrp, &ret);
-}
-/* }}} */
-
-/* {{{ proto bool domxml_elem_set_attribute_node(object attr)
-   Sets value of given attribute */
-PHP_FUNCTION(domxml_elem_set_attribute_node)
-{
-       zval *id, *node, *rv = NULL;
-       xmlNode *nodep;
-       xmlAttr *attrp, *newattrp, *existattrp;
-       int ret;
-
-       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep);
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &node) == FAILURE) {
-               return;
-       }
-
-       DOMXML_GET_OBJ(attrp, node, le_domxmlnodep);
-
-       if (attrp->type != XML_ATTRIBUTE_NODE) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attribute node is required");
-               RETURN_FALSE;
-       }
-
-       existattrp = xmlHasProp(nodep,attrp->name);
-       if (existattrp != NULL) {
-               /*      Check for registered nodes within attributes tree when attribute is not referenced 
-                       Unlink dependant nodes and free attribute if not registered */
-               if (dom_object_get_data((xmlNodePtr) existattrp) == NULL) {
-                       node_list_unlink(existattrp->children);
-                       xmlUnlinkNode((xmlNodePtr) existattrp);
-                       xmlFreeProp(existattrp);
-               } else {
-                       xmlUnlinkNode((xmlNodePtr) existattrp);
-               }
-       }
-
-       /* xmlCopyProp does not add the copy to the element node.
-               It does set the parent of the copy to the element node however */
-       newattrp = xmlCopyProp(nodep, attrp);
-       if (!newattrp) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such attribute '%s'", attrp->name);
-               RETURN_FALSE;
-       } else {
-               xmlAttr *prop;
-               prop = nodep->properties;
-               if (prop == NULL) {
-                       nodep->properties = newattrp;
-               } else {
-                       while (prop->next != NULL) {
-                               prop = prop->next;
-                       }
-                       prop->next = newattrp;
-                       newattrp->prev = prop;
-               }
-       }
-
-       DOMXML_RET_OBJ(rv, (xmlNodePtr) newattrp, &ret);
-}
-/* }}} */
-
-/* {{{ proto string domxml_elem_has_attribute(string attrname)
-   Checks for existenz given attribute */
-PHP_FUNCTION(domxml_elem_has_attribute)
-{
-       zval *id;
-       xmlNode *nodep;
-       char *name, *value;
-       int name_len;
-
-       DOMXML_PARAM_TWO(nodep, id, le_domxmlelementp, "s", &name, &name_len);
-
-       value = xmlGetProp(nodep, name);
-       if (!value) {
-               RETURN_FALSE;
-       } else {
-               xmlFree(value);
-               RETURN_TRUE;
-       }
-}
-/* }}} */
-
-#if defined(LIBXML_XPATH_ENABLED)
-/* {{{ proto string domxml_doc_get_elements_by_tagname(string tagname [,object xpathctx_handle] )
-   Returns array with nodes with given tagname in document or empty array, if not found*/
-PHP_FUNCTION(domxml_doc_get_elements_by_tagname)
-{
-       zval *id, *rv, *contextnode = NULL,*ctxpin = NULL;
-       xmlXPathContextPtr ctxp;
-       xmlDocPtr docp;
-
-       xmlXPathObjectPtr xpathobjp;
-       xmlNode *contextnodep;
-       int name_len;
-       int free_context = 0;
-       char *str,*name;
-
-       contextnode = NULL;
-       contextnodep = NULL;
-
-       DOMXML_PARAM_FOUR(docp, id, le_domxmldocp, "s|oo", &name, &name_len,&ctxpin,&contextnodep);
-
-       /* if no xpath_context was submitted, create a new one */
-       if (ctxpin == NULL) {
-               ctxp = xmlXPathNewContext(docp);
-               free_context = 1;
-       } else {
-               DOMXML_GET_OBJ(ctxp, ctxpin, le_xpathctxp);
-       }
-
-       if (contextnode) {
-               DOMXML_GET_OBJ(contextnodep, contextnode, le_domxmlnodep);
-       }
-       ctxp->node = contextnodep;
-       str = (char*) emalloc((name_len+3) * sizeof(char)) ;
-       sprintf(str ,"//%s",name);
-
-       xpathobjp = xmlXPathEval(str, ctxp);
-       efree(str);
-       ctxp->node = NULL;
-       if (!xpathobjp) {
-               RETURN_FALSE;
-       }
-       MAKE_STD_ZVAL(rv);
-
-       array_init(rv);
-
-       switch (Z_TYPE_P(xpathobjp)) {
-
-               case XPATH_NODESET:
-               {
-                       int i;
-                       xmlNodeSetPtr nodesetp;
-
-                       if (NULL == (nodesetp = xpathobjp->nodesetval)) {
-                               zval_dtor(rv);
-                               xmlXPathFreeObject (xpathobjp);
-                               if (free_context) {
-                                       xmlXPathFreeContext(ctxp);
-                               }
-                               RETURN_FALSE;
-                       }
-
-                       for (i = 0; i < nodesetp->nodeNr; i++) {
-                               xmlNodePtr node = nodesetp->nodeTab[i];
-                               zval *child;
-                               int retnode;
-
-                               /* construct a node object */
-                               child = php_domobject_new(node, &retnode, NULL TSRMLS_CC);
-                               zend_hash_next_index_insert(Z_ARRVAL_P(rv), &child, sizeof(zval *), NULL);
-                       }
-
-                       break;
-               }
-               default:
-                       break;
-       }
-
-       xmlXPathFreeObject(xpathobjp);
-       if (free_context) {
-               xmlXPathFreeContext(ctxp);
-       }
-       *return_value = *rv;
-       FREE_ZVAL(rv);
-}
-/* }}} */
-#endif
-
-typedef struct _idsIterator idsIterator;
-struct _idsIterator {
-       xmlChar *elementId;
-       xmlNode *element;
-};
-
-static void idsHashScanner(void *payload, void *data, xmlChar *name)
-{
-       idsIterator *priv = (idsIterator *) data;
-
-       if (priv->element == NULL && xmlStrEqual (name, priv->elementId)) {
-               priv->element = ((xmlNode *)((xmlID *)payload)->attr)->parent;
-       }
-}
-
-/* {{{ proto string domxml_doc_get_element_by_id(string id)
-   Returns element for given id or false if not found */
-PHP_FUNCTION(domxml_doc_get_element_by_id)
-{
-       zval *id, *rv = NULL;
-       xmlDocPtr docp;
-       idsIterator iter;
-       xmlHashTable *ids = NULL;
-       int retnode,idname_len;
-       char *idname;
-       
-       DOMXML_PARAM_TWO(docp, id, le_domxmldocp, "s", &idname, &idname_len);
-
-       ids = (xmlHashTable *) docp->ids;
-       if (ids) {
-               iter.elementId = (xmlChar *) idname;
-               iter.element = NULL;
-               xmlHashScan(ids, (void *)idsHashScanner, &iter);
-               rv = php_domobject_new(iter.element, &retnode, NULL TSRMLS_CC);
-               SEPARATE_ZVAL(&rv);
-               *return_value = *rv;
-               FREE_ZVAL(rv);
-       } else {
-               RETURN_FALSE;
-       }
-}
-/* }}} */
-
-/* {{{ proto string domxml_elem_get_elements_by_tagname(string tagname)
-   Returns array with nodes with given tagname in element or empty array, if not found */
-PHP_FUNCTION(domxml_elem_get_elements_by_tagname)
-{
-       zval *id,*rv;
-       xmlNode *nodep;
-       int name_len,i;
-       char *name;
-       xmlNodeSet *nodesetp = NULL;
-
-       DOMXML_PARAM_TWO(nodep, id, le_domxmlelementp, "s", &name, &name_len);
-
-       MAKE_STD_ZVAL(rv);
-
-       array_init(rv);
-
-       nodesetp = php_get_elements_by_tagname(nodep, name, NULL);
-
-       if (nodesetp) {
-               for (i = 0; i < nodesetp->nodeNr; i++) {
-                       xmlNodePtr node = nodesetp->nodeTab[i];
-                       zval *child;
-                       int retnode;
-
-                       child = php_domobject_new(node, &retnode, NULL TSRMLS_CC);
-                       zend_hash_next_index_insert(Z_ARRVAL_P(rv), &child, sizeof(zval *), NULL);
-               }
-       }
-       xmlXPathFreeNodeSet(nodesetp);
-       *return_value = *rv;
-       FREE_ZVAL(rv);
-
-}
-/* }}} */
-
-/* End of Methods DomElement }}} */
-
-
-/* {{{ Methods of Class DomDocumentType */
-
-/* {{{ proto array domxml_doctype_name(void)
-   Returns name of DocumentType */
-PHP_FUNCTION(domxml_doctype_name)
-{
-       zval *id;
-       xmlDtdPtr attrp;
-
-       DOMXML_NO_ARGS();
-
-       DOMXML_GET_THIS_OBJ(attrp, id, le_domxmldoctypep);
-
-       RETURN_STRING((char *) (attrp->name), 1);
-}
-/* }}} */
-
-/* {{{ proto array domxml_doctype_system_id(void)
-   Returns system id of DocumentType */
-PHP_FUNCTION(domxml_doctype_system_id)
-{
-       zval *id;
-       xmlDtdPtr attrp;
-
-       DOMXML_NO_ARGS();
-
-       DOMXML_GET_THIS_OBJ(attrp, id, le_domxmldoctypep);
-
-       if (attrp->SystemID) {
-               RETURN_STRING((char *) (attrp->SystemID), 1);
-       } else {
-               RETURN_EMPTY_STRING();
-       }
-}
-/* }}} */
-
-/* {{{ proto array domxml_doctype_public_id(void)
-   Returns public id of DocumentType */
-PHP_FUNCTION(domxml_doctype_public_id)
-{
-       zval *id;
-       xmlDtdPtr attrp;
-
-       DOMXML_NO_ARGS();
-
-       DOMXML_GET_THIS_OBJ(attrp, id, le_domxmldoctypep);
-
-       if (attrp->ExternalID) {
-               RETURN_STRING((char *) (attrp->ExternalID), 1);
-       } else {
-               RETURN_EMPTY_STRING();
-       }
-}
-/* }}} */
-
-/* {{{ proto array domxml_doctype_entities(void)
-   Returns list of entities */
-PHP_FUNCTION(domxml_doctype_entities)
-{
-       zval *id;
-       xmlNode *last;
-       xmlDtdPtr doctypep;
-       int ret;
-
-       DOMXML_NOT_IMPLEMENTED();
-
-       DOMXML_PARAM_NONE(doctypep, id, le_domxmldoctypep);
-
-       last = doctypep->entities;
-       if (!last) {
-               RETURN_FALSE;
-       }
-
-       array_init(return_value);
-
-       while (last) {
-               zval *child;
-               child = php_domobject_new(last, &ret, NULL TSRMLS_CC);
-               add_next_index_zval(return_value, child);
-               last = last->next;
-       }
-}
-/* }}} */
-
-/* {{{ proto array domxml_doctype_notations(void)
-   Returns list of notations */
-PHP_FUNCTION(domxml_doctype_notations)
-{
-       zval *id;
-       xmlNode *last;
-       xmlDtdPtr doctypep;
-       int ret;
-
-       DOMXML_NOT_IMPLEMENTED();
-
-       DOMXML_PARAM_NONE(doctypep, id, le_domxmldoctypep);
-
-       last = doctypep->notations;
-       if (!last) {
-               RETURN_FALSE;
-       }
-
-       array_init(return_value);
-
-       while (last) {
-               zval *child;
-               child = php_domobject_new(last, &ret, NULL TSRMLS_CC);
-               add_next_index_zval(return_value, child);
-               last = last->next;
-       }
-}
-/* }}} */
-
-/* End of Methods DomElementType }}} */
-
-
-/* {{{ Methods of Class DomDocument */
-
-/* {{{ proto object domxml_doc_doctype(void)
-   Returns DomDocumentType */
-PHP_FUNCTION(domxml_doc_doctype)
-{
-       zval *id, *rv = NULL;
-       xmlDtdPtr dtd;
-       xmlDocPtr docp;
-       int ret;
-
-       DOMXML_GET_THIS_OBJ(docp, id, le_domxmldocp);
-
-       DOMXML_NO_ARGS();
-
-       dtd = xmlGetIntSubset(docp);
-       if (!dtd) {
-               RETURN_FALSE;
-       }
-
-       DOMXML_RET_OBJ(rv, (xmlNodePtr) dtd, &ret);
-}
-/* }}} */
-
-/* {{{ proto object domxml_doc_implementation(void)
-   Returns DomeDOMImplementation */
-PHP_FUNCTION(domxml_doc_implementation)
-{
-/*     zval *id;
-       xmlDocPtr docp;*/
-
-       DOMXML_NOT_IMPLEMENTED();
-
-/*
-       DOMXML_GET_THIS_OBJ(docp, id, le_domxmldocp);
-
-       rv = php_domobject_new(node, &ret TSRMLS_CC);
-       SEPARATE_ZVAL(&rv);
-       *return_value = *rv;
-*/
-}
-/* }}} */
-
-/* {{{ proto object domxml_doc_document_element(int domnode)
-   Returns root node of document */
-PHP_FUNCTION(domxml_doc_document_element)
-{
-       zval *id, *rv = NULL;
-       xmlDoc *docp;
-       xmlNode *root;
-       int ret;
-
-       DOMXML_PARAM_NONE(docp, id, le_domxmldocp);
-
-       root = xmlDocGetRootElement(docp);
-       if (!root) {
-               RETURN_FALSE;
-       }
-
-       DOMXML_RET_OBJ(rv, root, &ret);
-}
-/* }}} */
-
-/* {{{ proto object domxml_doc_create_element(string name)
-   Creates new element node */
-PHP_FUNCTION(domxml_doc_create_element)
-{
-       zval *id, *rv = NULL;
-       xmlNode *node;
-       xmlDocPtr docp = NULL;
-       int ret, name_len;
-       char *name;
-
-       if (!DOMXML_IS_TYPE(getThis(), domxmlelement_class_entry)) {
-               DOMXML_GET_THIS_OBJ(docp, id, le_domxmldocp);
-       }
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
-               return;
-       }
-
-       node = xmlNewNode(NULL, name);
-       if (!node) {
-               RETURN_FALSE;
-       }
-       node->doc = docp;
-
-       if (DOMXML_IS_TYPE(getThis(), domxmlelement_class_entry)) {
-               DOMXML_DOMOBJ_NEW(getThis(), node, &ret);
-       } else {
-               DOMXML_RET_OBJ(rv, node, &ret);
-       }
-}
-/* }}} */
-
-/* {{{ proto object domxml_doc_create_element_ns(string uri, string name [, string prefix])
-   Creates new element node with a namespace */
-PHP_FUNCTION(domxml_doc_create_element_ns)
-{
-       zval *id, *rv = NULL;
-       xmlNode *node;
-       xmlNs   *nsptr;
-       xmlDocPtr docp = NULL;
-       int ret, name_len, uri_len, prefix_len=0;
-       char *name, *uri, *prefix;
-
-       DOMXML_PARAM_SIX(docp, id, le_domxmldocp, "ss|s", &uri, &uri_len, &name, &name_len, &prefix, &prefix_len);
-
-       nsptr = xmlSearchNsByHref(docp, xmlDocGetRootElement(docp), (xmlChar*) uri);
-       node = xmlNewNode(nsptr, name);
-
-       if (!node) {
-               RETURN_FALSE;
-       }
-       /* if no namespace with the same uri was found, we have to create a new one.
-        * I do this here with "a" + a random number. this is not very sophisticated,
-        * therefore if someone has a better idea in creating unique prefixes, here's your
-        * chance (a0,a1, etc would be good enough, this is the way mozilla does it). I'm
-        * to lazy right now to think of a better solution... 
-        */
-       if (nsptr == NULL) {
-               /* if there was a prefix provided, take that, otherwise generate a new one
-                        this is not w3c-like, since the have no option to provide a prefix, but
-                        i don't care :)
-               */
-               if (prefix_len == 0)
-               {       
-                       char prefixtmp[20];
-                       int random;
-                       random = (int) (10000.0*php_rand(TSRMLS_C)/(PHP_RAND_MAX));
-                       sprintf(prefixtmp, "a%d", random);
-                       prefix = prefixtmp;
-               }
-               nsptr = xmlNewNs(node, uri, prefix);
-               xmlSetNs(node, nsptr);
-       }
-       
-       node->doc = docp;
-
-       if (DOMXML_IS_TYPE(getThis(), domxmlelement_class_entry)) {
-               DOMXML_DOMOBJ_NEW(getThis(), node, &ret);
-       } else {
-               DOMXML_RET_OBJ(rv, node, &ret);
-       }
-}
-/* }}} */
-
-/* {{{ proto bool domxml_node_add_namespace(string uri, string prefix)
-   Adds a namespace declaration to a node */
-PHP_FUNCTION(domxml_node_add_namespace)
-{
-       zval *id;
-       xmlNode *nodep;
-       xmlNs   *nsptr;
-       int prefix_len, uri_len;
-       char *prefix, *uri;
-
-       DOMXML_PARAM_FOUR(nodep, id, le_domxmldocp, "ss", &uri, &uri_len, &prefix, &prefix_len);
-
-       if (NULL == (nsptr = xmlNewNs(nodep,uri,prefix))) {
-               RETURN_FALSE;
-       } else {
-               RETURN_TRUE;
-       }
-       
-}
-/* }}} */
-
-/* {{{ proto void domxml_node_set_namespace(string uri [, string prefix])
-   Sets the namespace of a node */
-PHP_FUNCTION(domxml_node_set_namespace)
-{
-       zval *id;
-       xmlNode *nodep;
-       xmlNs   *nsptr;
-       int prefix_len = 0, uri_len;
-       char *prefix, *uri;
-
-       DOMXML_PARAM_FOUR(nodep, id, le_domxmldocp, "s|s", &uri, &uri_len, &prefix, &prefix_len);
-
-       /* if node is in a document, search for an already existing namespace */
-       if (nodep->doc != NULL) {
-               if (nodep->type == XML_ATTRIBUTE_NODE) {
-                       nsptr = xmlSearchNsByHref(nodep->doc, nodep->parent, (xmlChar*) uri);
-               } else  {
-                       nsptr = xmlSearchNsByHref(nodep->doc, nodep, (xmlChar*) uri);
-               } 
-       } else {
-               nsptr = NULL;
-       }
-
-       /* if no namespace decleration was found in the parents of the node, generate one */
-       if (nsptr == NULL) {
-               /* if there was a prefix provided, take that, otherwise generate a new one */
-               if (prefix_len == 0) {  
-                       char prefixtmp[20];
-                       int random;
-                       random = (int) (10000.0*php_rand(TSRMLS_C)/(PHP_RAND_MAX));
-                       sprintf(prefixtmp, "a%d", random);
-                       prefix = prefixtmp;
-               }
-               if (nodep->type == XML_ATTRIBUTE_NODE) {
-                       nsptr = xmlNewNs(nodep->parent, uri, prefix);
-               } else {
-                       nsptr = xmlNewNs(nodep, uri, prefix);
-               }
-       }
-
-       xmlSetNs(nodep, nsptr);
-}
-/* }}} */
-
-/* {{{ proto object domxml_doc_create_text_node(string content)
-   Creates new text node */
-PHP_FUNCTION(domxml_doc_create_text_node)
-{
-       zval *id, *rv = NULL;
-       xmlNode *node;
-       xmlDocPtr docp = NULL;
-       int ret, content_len;
-       char *content;
-
-       if (!DOMXML_IS_TYPE(getThis(), domxmltext_class_entry)) {
-               DOMXML_GET_THIS_OBJ(docp, id, le_domxmldocp);
-       }
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &content, &content_len) == FAILURE) {
-               return;
-       }
-
-       node = xmlNewTextLen(content, content_len);
-       if (!node) {
-               RETURN_FALSE;
-       }
-       node->doc = docp;
-
-       if (DOMXML_IS_TYPE(getThis(), domxmltext_class_entry)) {
-               DOMXML_DOMOBJ_NEW(getThis(), node, &ret);
-       } else {
-               DOMXML_RET_OBJ(rv, node, &ret);
-       }
-}
-/* }}} */
-
-/* {{{ proto object domxml_doc_create_comment(string content)
-   Creates new comment node */
-PHP_FUNCTION(domxml_doc_create_comment)
-{
-       zval *id, *rv = NULL;
-       xmlNode *node;
-       xmlDocPtr docp = NULL;
-       int ret, content_len;
-       char *content;
-
-       if (!DOMXML_IS_TYPE(getThis(), domxmlcomment_class_entry)) {
-               DOMXML_GET_THIS_OBJ(docp, id, le_domxmldocp);
-       }
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &content, &content_len) == FAILURE) {
-               return;
-       }
-
-       node = xmlNewComment(content);
-       if (!node) {
-               RETURN_FALSE;
-       }
-       node->doc = docp;
-
-       if (DOMXML_IS_TYPE(getThis(), domxmlcomment_class_entry)) {
-               DOMXML_DOMOBJ_NEW(getThis(), node, &ret);
-       } else {
-               DOMXML_RET_OBJ(rv, node, &ret);
-       }
-}
-/* }}} */
-
-/* {{{ proto object domxml_doc_create_attribute(string name, string value)
-   Creates new attribute node */
-PHP_FUNCTION(domxml_doc_create_attribute)
-{
-       zval *id, *rv = NULL;
-       xmlAttrPtr node;
-       xmlDocPtr docp = NULL;
-       int ret, name_len, value_len;
-       char *name, *value;
-
-       if (!DOMXML_IS_TYPE(getThis(), domxmlattr_class_entry)) {
-               DOMXML_GET_THIS_OBJ(docp, id, le_domxmldocp);
-       }
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &name, &name_len, &value, &value_len) == FAILURE) {
-               return;
-       }
-
-       node = xmlNewProp(NULL, name, value);
-       if (!node) {
-               RETURN_FALSE;
-       }
-       node->doc = docp;
-
-       if (DOMXML_IS_TYPE(getThis(), domxmlattr_class_entry)) {
-               DOMXML_DOMOBJ_NEW(getThis(), (xmlNodePtr) node, &ret);
-       } else {
-               DOMXML_RET_OBJ(rv, (xmlNodePtr) node, &ret);
-       }
-}
-/* }}} */
-
-/* {{{ proto object domxml_doc_create_cdata_section(string content)
-   Creates new cdata node */
-PHP_FUNCTION(domxml_doc_create_cdata_section)
-{
-       zval *id, *rv = NULL;
-       xmlNode *node;
-       xmlDocPtr docp = NULL;
-       int ret, content_len;
-       char *content;
-
-       if (!DOMXML_IS_TYPE(getThis(), domxmlcdata_class_entry)) {
-               DOMXML_GET_THIS_OBJ(docp, id, le_domxmldocp);
-       }
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &content, &content_len) == FAILURE) {
-               return;
-       }
-
-       node = xmlNewCDataBlock(docp, content, content_len);
-       if (!node) {
-               RETURN_FALSE;
-       }
-       node->doc = docp;
-
-       if (DOMXML_IS_TYPE(getThis(), domxmlcdata_class_entry)) {
-               DOMXML_DOMOBJ_NEW(getThis(), node, &ret);
-       } else {
-               DOMXML_RET_OBJ(rv, node, &ret);
-       }
-}
-/* }}} */
-
-/* {{{ proto object domxml_doc_create_entity_reference(string name)
-   Creates new cdata node */
-PHP_FUNCTION(domxml_doc_create_entity_reference)
-{
-       zval *id, *rv = NULL;
-       xmlNode *node;
-       xmlDocPtr docp = NULL;
-       int ret, name_len;
-       char *name;
-
-       if (!DOMXML_IS_TYPE(getThis(), domxmlentityref_class_entry)) {
-               DOMXML_GET_THIS_OBJ(docp, id, le_domxmldocp);
-       }
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
-               return;
-       }
-       node = xmlNewReference(docp, name);
-       if (!node) {
-               RETURN_FALSE;
-       }
-       node->doc = docp;
-
-       if (DOMXML_IS_TYPE(getThis(), domxmlentityref_class_entry)) {
-               DOMXML_DOMOBJ_NEW(getThis(), node, &ret);
-       } else {
-               DOMXML_RET_OBJ(rv, node, &ret);
-       }
-}
-/* }}} */
-
-/* {{{ proto object domxml_doc_create_processing_instruction(string name)
-   Creates new processing_instruction node */
-PHP_FUNCTION(domxml_doc_create_processing_instruction)
-{
-       zval *id, *rv = NULL;
-       xmlNode *node;
-       xmlDocPtr docp = NULL;
-       int ret, name_len, content_len;
-       char *name, *content;
-
-       if (!DOMXML_IS_TYPE(getThis(), domxmlpi_class_entry)) {
-               DOMXML_GET_THIS_OBJ(docp, id, le_domxmldocp);
-       }
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &name, &name_len, &content, &content_len) == FAILURE) {
-               return;
-       }
-
-       node = xmlNewPI(name, content);
-       if (!node) {
-               RETURN_FALSE;
-       }
-       node->doc = docp;
-
-       if (DOMXML_IS_TYPE(getThis(), domxmlpi_class_entry)) {
-               DOMXML_DOMOBJ_NEW(getThis(), node, &ret);
-       } else {
-               DOMXML_RET_OBJ(rv, node, &ret);
-       }
-}
-/* }}} */
-
-/* {{{ proto object domxml_doc_create_document_fragement()
-   Creates new document fragement node */
-PHP_FUNCTION(domxml_doc_create_document_fragment)
-{
-       zval *id, *rv = NULL;
-       xmlNode *node;
-       xmlDocPtr docp = NULL;
-       int ret;
-
-       DOMXML_PARAM_NONE(docp, id, le_domxmldocumentfragmentp);
-       
-
-       node = xmlNewDocFragment (docp);
-       if (!node) {
-               RETURN_FALSE;
-       }
-       DOMXML_RET_OBJ(rv, node, &ret); 
-}
-/* }}} */
-
-/* {{{ proto bool domxml_document_framgent_open_mem(string buf)
-   Parses a string with a well-balanced XML-Fragment and appends it to the document-fragment */
-PHP_FUNCTION(domxml_document_fragment_open_mem)
-{
-       zval *id;
-       xmlNodePtr dfp = NULL, last = NULL;     
-       char *buf;
-       int ret, buf_len;
-       xmlNodePtr lst;
-       
-       DOMXML_PARAM_TWO(dfp, id, le_domxmldocumentfragmentp,"s",&buf, &buf_len);
-
-       ret = xmlParseBalancedChunkMemory(dfp->doc, NULL, NULL, 0, (xmlChar *) buf, &lst);
-       if (ret != 0) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input string is not balanced (well-formed)");   
-                       RETURN_FALSE;
-       }
-       
-       last = xmlAddChildList(dfp, lst);
-       
-       if (last == NULL) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not add child list");   
-                       RETURN_FALSE;
-       }
-       
-       RETURN_TRUE;
-}
-
-/* {{{ proto object domxml_doc_imported_node(object node, bool recursive)
-   Creates new element node */
-PHP_FUNCTION(domxml_doc_imported_node)
-{
-       zval *arg1, *id, *rv = NULL;
-       xmlNodePtr node, srcnode;
-       xmlDocPtr docp;
-       int ret; 
-       long recursive = 0;
-
-       DOMXML_GET_THIS_OBJ(docp, id, le_domxmldocp);
-
-       /* FIXME: which object type to expect? */
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|l", &arg1, &recursive) == FAILURE) {
-               return;
-       }
-
-       DOMXML_GET_OBJ(srcnode, arg1, le_domxmlnodep);
-
-       /* node = xmlCopyNode(srcnode, recursive); */
-       node = xmlDocCopyNode(srcnode, docp, recursive);
-       if (!node) {
-               RETURN_FALSE;
-       }
-       /* No longer need handled by xmlDocCopyNode
-       node->doc = docp;
-       */
-
-       DOMXML_RET_OBJ(rv, node, &ret);
-}
-/* }}} */
-
-/* {{{ proto object domxml_dtd(void)
-   Returns DTD of document */
-PHP_FUNCTION(domxml_intdtd)
-{
-       zval *id, *rv = NULL;
-       xmlDoc *docp;
-       xmlDtd *dtd;
-       int ret;
-
-       DOMXML_GET_THIS_OBJ(docp, id, le_domxmldocp);
-
-       dtd = xmlGetIntSubset(docp);
-       if (!dtd) {
-               RETURN_FALSE;
-       }
-
-       DOMXML_RET_OBJ(rv, (xmlNodePtr) dtd, &ret);
-}
-/* }}} */
-
-/* {{{ proto string domxml_dump_mem(object doc_handle [, int format][, encoding])
-   Dumps document into string and optionally formats it */
-PHP_FUNCTION(domxml_dump_mem)
-{
-       zval *id;
-       xmlDoc *docp;
-       xmlChar *mem;
-       int format = 0;
-       int size, keepblanks;
-       int encoding_len = 0;
-       char *encoding;
-
-
-       DOMXML_PARAM_THREE(docp, id, le_domxmldocp, "|ls", &format, &encoding, &encoding_len);
-       if (format) {
-               keepblanks = xmlKeepBlanksDefault(0);
-               if (encoding_len) {
-                       xmlDocDumpFormatMemoryEnc(docp, &mem, &size, encoding, format);
-               } else {
-                       xmlDocDumpFormatMemory(docp, &mem, &size, format);
-               }
-               xmlKeepBlanksDefault(keepblanks);
-       } else {
-               if (encoding_len) {
-                       xmlDocDumpMemoryEnc(docp, &mem, &size, encoding);
-               } else {
-                       xmlDocDumpMemory(docp, &mem, &size);
-               }
-       }
-
-       if (!size) {
-               RETURN_FALSE;
-       }
-       RETVAL_STRINGL(mem, size, 1);
-       xmlFree(mem);
-}
-/* }}} */
-
-/* {{{ proto int domxml_dump_mem_file(string filename [, int compressmode [, int format]])
-   Dumps document into file and uses compression if specified. Returns false on error, otherwise the length of the xml-document (uncompressed) */
-PHP_FUNCTION(domxml_dump_mem_file)
-{
-       zval *id;
-       xmlDoc *docp;
-       int file_len, bytes, keepblanks;
-       int format = 0;
-       int compressmode = 0;
-       char *file;
-
-       DOMXML_PARAM_FOUR(docp, id, le_domxmldocp, "s|ll", &file, &file_len, &compressmode, &format);
-
-       if ((PG(safe_mode) && (!php_checkuid(file, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(file TSRMLS_CC)) {
-               RETURN_FALSE;
-       }
-
-       xmlSetCompressMode(compressmode);
-
-       if (format) {
-               keepblanks = xmlKeepBlanksDefault(0);
-               bytes = xmlSaveFormatFile(file, docp, format);
-               xmlKeepBlanksDefault(keepblanks);
-       } else {
-               bytes = xmlSaveFile(file, docp);
-       }
-
-       if (bytes == -1) {
-               RETURN_FALSE;
-       }
-       RETURN_LONG(bytes);
-}
-/* }}} */
-
-/* {{{ proto string domxml_dump_node(object doc_handle, object node_handle [, int format [, int level]])
-   Dumps node into string */
-PHP_FUNCTION(domxml_dump_node)
-{
-       zval *id, *nodep;
-       xmlDocPtr docp;
-       xmlNodePtr elementp;
-       xmlChar *mem ;
-       xmlBufferPtr buf;
-       int level = 0;
-       int format = 0;
-
-       DOMXML_PARAM_THREE(docp, id, le_domxmldocp, "o|ll", &nodep, &format, &level);
-
-       DOMXML_GET_OBJ(elementp, nodep, le_domxmlnodep);
-
-       if (Z_TYPE_P(elementp) == XML_DOCUMENT_NODE || Z_TYPE_P(elementp) == XML_HTML_DOCUMENT_NODE ) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot dump element with a document node");
-               RETURN_FALSE;
-       }
-
-       if (docp->type != XML_DOCUMENT_NODE && docp->type != XML_HTML_DOCUMENT_NODE) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Object has to be a DomDocument Node");
-               RETURN_FALSE;
-       }
-
-       buf = xmlBufferCreate();
-       if (!buf) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not fetch buffer");
-               RETURN_FALSE;
-       }
-
-       xmlNodeDump(buf, docp, elementp, level, format);
-
-       mem = (xmlChar*) xmlBufferContent(buf);
-
-       if (!mem) {
-               xmlBufferFree(buf);
-               RETURN_FALSE;
-       }
-       RETVAL_STRING(mem,  1);
-
-       xmlBufferFree(buf);
-
-}
-/* }}} */
-
-/* {{{ idsHashScanner2(void *payload, void *data, xmlChar *name)
- */
-static void idsHashScanner2(void *payload, void *data, xmlChar *name)
-{
-       zval *return_value = (zval *) data;
-       zval *child;
-       int ret;
-       xmlNode *nodep;
-
-       TSRMLS_FETCH();
-
-       nodep = ((xmlNode *)((xmlID *)payload)->attr)->parent;
-       child = php_domobject_new(nodep, &ret, NULL TSRMLS_CC);
-       add_next_index_zval(return_value, child);
-}
-/* }}} */
-
-/* {{{ proto string domxml_doc_ids(object doc_handle)
-   Returns array of ids */
-PHP_FUNCTION(domxml_doc_ids)
-{
-       zval *id;
-       xmlDoc *docp;
-       xmlHashTable *ids = NULL;
-
-       DOMXML_GET_THIS_OBJ(docp, id, le_domxmldocp);
-
-       ids = docp->ids;
-
-       if (ids) {
-               array_init(return_value);
-               xmlHashScan(ids, (void *)idsHashScanner2, return_value);
-       } else {
-               RETURN_FALSE;
-       }
-}
-/* }}} */
-
-/* {{{ proto object xmldoc(string xmldoc[, int mode[, array error]])
-   Creates DOM object of XML document */
-PHP_FUNCTION(xmldoc)
-{
-       zval *rv = NULL;
-       xmlDoc *docp = NULL;
-       int ret; 
-       char *buffer;
-       int buffer_len;
-       long mode = 0;
-       int prevSubstValue;
-       int oldvalue =  xmlDoValidityCheckingDefaultValue;
-       int oldvalue_keepblanks;
-       int prevLoadExtDtdValue = xmlLoadExtDtdDefaultValue;
-       zval *errors ;
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lz", &buffer, &buffer_len, &mode, &errors) == FAILURE) {
-               return;
-       }
-/*     Either of the following line force validation */
-/*     xmlLoadExtDtdDefaultValue = XML_DETECT_IDS; */
-/*     xmlDoValidityCheckingDefaultValue = 1; */
-       if (ZEND_NUM_ARGS() == 3 ) {
-               zval_dtor(errors);
-               array_init(errors);
-       }
-        
-       if (mode & DOMXML_LOAD_DONT_KEEP_BLANKS) {
-               oldvalue_keepblanks  =  xmlKeepBlanksDefault(0);
-       } else {
-               oldvalue_keepblanks  =  xmlKeepBlanksDefault(1);
-       }
-
-       if (mode & DOMXML_LOAD_SUBSTITUTE_ENTITIES) {
-               prevSubstValue = xmlSubstituteEntitiesDefault (1);
-       } else {
-               prevSubstValue = xmlSubstituteEntitiesDefault (0);
-       }
-
-       if (mode & DOMXML_LOAD_COMPLETE_ATTRS) {
-               xmlLoadExtDtdDefaultValue |= XML_COMPLETE_ATTRS;
-       }
-
-       switch (mode & (DOMXML_LOAD_PARSING | DOMXML_LOAD_VALIDATING | DOMXML_LOAD_RECOVERING)) {
-               case DOMXML_LOAD_PARSING:
-                       xmlDoValidityCheckingDefaultValue = 0;
-                       if (ZEND_NUM_ARGS() == 3) {
-                               docp = php_dom_xmlSAXParse( NULL, (char *) buffer, buffer_len, 0 , errors);
-                       } else {
-                               docp = xmlParseDoc(buffer);
-                       }
-                       break;
-               case DOMXML_LOAD_VALIDATING:
-                       xmlDoValidityCheckingDefaultValue = 1;
-                       if (ZEND_NUM_ARGS() == 3) {
-                               docp = php_dom_xmlSAXParse(NULL, (char *) buffer, buffer_len, 0, errors);
-                       } else {
-                               docp = xmlParseDoc(buffer);
-                       }
-                       break;
-               case DOMXML_LOAD_RECOVERING:
-                       xmlDoValidityCheckingDefaultValue = 0;
-                       if (ZEND_NUM_ARGS() == 3) {
-                               docp = php_dom_xmlSAXParse(NULL, (char *) buffer, buffer_len, 1, errors);
-                       } else {
-                               docp = xmlRecoverDoc(buffer);
-                       }
-                       break;
-       }
-       xmlSubstituteEntitiesDefault (prevSubstValue);
-       xmlDoValidityCheckingDefaultValue = oldvalue;
-       xmlLoadExtDtdDefaultValue = prevLoadExtDtdValue;
-       xmlKeepBlanksDefault(oldvalue_keepblanks);
-
-       if (!docp) {
-               RETURN_FALSE;
-       }
-
-/*     dtd = xmlGetIntSubset(docp);
-       if (dtd) {
-               xmlParseDTD(dtd->ExternalID, dtd->SystemID);
-       }
-*/
-
-       if (DOMXML_IS_TYPE(getThis(), domxmldoc_class_entry)) {
-               DOMXML_DOMOBJ_NEW(getThis(), (xmlNodePtr) docp, &ret);
-       } else {
-               DOMXML_RET_OBJ(rv, (xmlNodePtr) docp, &ret);
-       }
-}
-/* }}} */
-
-/* {{{ proto object xmldocfile(string filename[, int mode[, array error])
-   Creates DOM object of XML document in file */
-PHP_FUNCTION(xmldocfile)
-{
-       zval *rv = NULL;
-       xmlDoc *docp = NULL;
-       int ret, file_len;
-       char *file;
-       long mode = 0;
-       int prevSubstValue;
-       int oldvalue =  xmlDoValidityCheckingDefaultValue;
-       int oldvalue_keepblanks;
-       zval *errors = NULL;
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lz", &file, &file_len, &mode,  &errors) == FAILURE) {
-               return;
-       }
-                       
-       if (ZEND_NUM_ARGS() == 3 ) {
-               zval_dtor(errors);
-               array_init(errors);
-       }
-        
-       if (mode & DOMXML_LOAD_DONT_KEEP_BLANKS) {
-               oldvalue_keepblanks  =  xmlKeepBlanksDefault(0);
-       } else {
-               oldvalue_keepblanks  =  xmlKeepBlanksDefault(1);
-       }
-
-       if (mode & DOMXML_LOAD_SUBSTITUTE_ENTITIES) {
-               prevSubstValue = xmlSubstituteEntitiesDefault (1);
-       } else {
-               prevSubstValue = xmlSubstituteEntitiesDefault (0);
-       }
-
-       if (mode & DOMXML_LOAD_COMPLETE_ATTRS) {
-               xmlLoadExtDtdDefaultValue |= XML_COMPLETE_ATTRS;
-       }
-
-       switch (mode & (DOMXML_LOAD_PARSING | DOMXML_LOAD_VALIDATING | DOMXML_LOAD_RECOVERING)) {
-               case DOMXML_LOAD_PARSING:
-                       xmlDoValidityCheckingDefaultValue = 0;
-                       if (ZEND_NUM_ARGS() == 3) {
-                               docp = php_dom_xmlSAXParse( NULL, (char *) file, -1 , 0 , errors);
-                       } else {
-                               docp = xmlParseFile(file);
-                       }
-                       break;
-               case DOMXML_LOAD_VALIDATING:
-                       xmlDoValidityCheckingDefaultValue = 1;
-                       if (ZEND_NUM_ARGS() == 3) {
-                               docp = php_dom_xmlSAXParse(NULL, (char *) file, -1, 0, errors);
-                       } else {
-                               docp = xmlParseFile(file);
-                       }
-                       break;
-               case DOMXML_LOAD_RECOVERING:
-                       xmlDoValidityCheckingDefaultValue = 0;
-                       if (ZEND_NUM_ARGS() == 3) {
-                               docp = php_dom_xmlSAXParse(NULL, (char*) file, -1, 1, errors);
-                       } else {
-                               docp = xmlRecoverFile(file);
-                       }
-                       break;
-       }
-       xmlSubstituteEntitiesDefault (prevSubstValue);
-       xmlDoValidityCheckingDefaultValue = oldvalue;
-       xmlKeepBlanksDefault(oldvalue_keepblanks);
-
-       if (!docp) {
-               RETURN_FALSE;
-       }
-
-
-       if (DOMXML_IS_TYPE(getThis(), domxmldoc_class_entry)) {
-               DOMXML_DOMOBJ_NEW(getThis(), (xmlNodePtr) docp, &ret);
-       } else {
-               DOMXML_RET_OBJ(rv, (xmlNodePtr) docp, &ret);
-       }
-
-}
-/* }}} */
-
-#if defined(LIBXML_HTML_ENABLED)
-/* {{{ proto string domxml_html_dump_mem([int doc_handle])
-   Dumps document into string as HTML */
-PHP_FUNCTION(domxml_html_dump_mem)
-{
-       zval *id;
-       xmlDoc *docp;
-       xmlChar *mem;
-       int size;
-
-       DOMXML_PARAM_NONE(docp, id, le_domxmldocp);
-
-       htmlDocDumpMemory(docp, &mem, &size);
-       if (!size) {
-               if (mem) {
-                       xmlFree(mem);
-               }
-               RETURN_FALSE;
-       }
-       RETVAL_STRINGL(mem, size, 1);
-       xmlFree(mem);
-}
-/* }}} */
-
-/* {{{ proto object html_doc(string html_doc [, bool from_file])
-   Creates DOM object of HTML document */
-PHP_FUNCTION(html_doc)
-{
-       zval *rv = NULL;
-       xmlDoc *docp;
-       int ret;
-       char *buffer;
-       int buffer_len;
-       zend_bool from_file = 0;
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &buffer, &buffer_len, &from_file) == FAILURE) {
-               return;
-       }
-
-       if (from_file) {
-               docp = htmlParseFile(buffer, NULL);
-       } else {
-               docp = htmlParseDoc(buffer, NULL);
-       }
-       if (!docp) {
-               RETURN_FALSE;
-       }
-
-       DOMXML_RET_OBJ(rv, (xmlNodePtr) docp, &ret);
-}
-/* }}} */
-
-/* {{{ proto object html_doc_file(string filename)
-   Creates DOM object of HTML document in file */
-PHP_FUNCTION(html_doc_file)
-{
-       zval *rv = NULL;
-       xmlDoc *docp;
-       int ret, file_len;
-       char *file;
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file, &file_len) == FAILURE) {
-               return;
-       }
-
-       docp = htmlParseFile(file, NULL);
-       if (!docp) {
-               RETURN_FALSE;
-       }
-
-       DOMXML_RET_OBJ(rv, (xmlNodePtr) docp, &ret);
-
-       add_property_resource(return_value, "doc", ret);
-       if (docp->name) {
-               add_property_stringl(return_value, "name", (char *) docp->name, strlen(docp->name), 1);
-       }
-       if (docp->URL) {
-               add_property_stringl(return_value, "url", (char *) docp->URL, strlen(docp->URL), 1);
-       }
-       if (docp->version) {
-               add_property_stringl(return_value, "version", (char *) docp->version, strlen(docp->version), 1);
-       }
-/*     add_property_stringl(return_value, "version", (char *) docp->version, strlen(docp->version), 1);*/
-       if (docp->encoding) {
-               add_property_stringl(return_value, "encoding", (char *) docp->encoding, strlen(docp->encoding), 1);
-       }
-       add_property_long(return_value, "standalone", docp->standalone);
-       add_property_long(return_value, "type", Z_TYPE_P(docp));
-       add_property_long(return_value, "compression", docp->compression);
-       add_property_long(return_value, "charset", docp->charset);
-       zend_list_addref(ret);
-}
-/* }}} */
-#endif  /* defined(LIBXML_HTML_ENABLED) */
-
-/* {{{ proto bool domxml_substitute_entities_default(bool enable)
-   Set and return the previous value for default entity support */
-PHP_FUNCTION(domxml_substitute_entities_default)
-{
-       zend_bool enable;
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &enable) == FAILURE) {
-               return;
-       }
-
-       RETURN_BOOL(xmlSubstituteEntitiesDefault(enable));
-}
-/* }}} */
-
-/* {{{ proto bool domxml_node_text_concat(string content)
-   Add string tocontent of a node */
-PHP_FUNCTION(domxml_node_text_concat)
-{
-       zval *id;
-       xmlNode *nodep;
-       char *content;
-       int content_len;
-
-       DOMXML_GET_THIS_OBJ(nodep, id, le_domxmlnodep);
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &content, &content_len) == FAILURE) {
-               return;
-       }
-
-       if (content_len) {
-               xmlTextConcat(nodep, content, content_len);
-       }
-
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto object domxml_add_root(string name)
-   Adds root node to document */
-PHP_FUNCTION(domxml_doc_add_root)
-{
-       zval *id, *rv = NULL;
-       xmlDoc *docp;
-       xmlNode *nodep, *root;
-       int ret, name_len;
-       char *name;
-
-       DOMXML_PARAM_TWO(docp, id, le_domxmldocp, "s", &name, &name_len);
-
-       nodep = xmlNewDocNode(docp, NULL, name, NULL);
-       if (!nodep) {
-               RETURN_FALSE;
-       }
-
-       if ((root = xmlDocSetRootElement(docp, nodep)) != NULL) {
-               /* Root node already unlinked from xmlDocSetRootElement */
-               if (dom_object_get_data(root) == NULL) {
-                       node_list_unlink(root->children);
-                       node_list_unlink((xmlNodePtr) root->properties);
-                       xmlFreeNode(root);
-               }
-       }
-
-       DOMXML_RET_OBJ(rv, nodep, &ret);
-}
-/* }}} */
-
-/* {{{ proto bool domxml_set_root(int domnode)
-   Sets root node of document */
-PHP_FUNCTION(domxml_doc_set_root)
-{
-       zval *id, *rv, *node;
-       xmlDoc *docp;
-       xmlNode *root;
-
-       DOMXML_PARAM_TWO(docp, id, le_domxmldocp, "o", &node, &rv);
-       DOMXML_GET_OBJ(root, node, le_domxmlnodep);
-
-       if (!root) {
-               RETURN_FALSE;
-       }
-
-       xmlDocSetRootElement(docp, root);
-
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool domxml_doc_validate(array &error)
-   Validates a DomDocument according to his DTD*/
-PHP_FUNCTION(domxml_doc_validate)
-{
-       zval *id;
-       xmlValidCtxt cvp;
-       xmlDoc *docp;
-       domxml_ErrorCtxt errorCtxt;
-       zval *errors ;
-       int oldvalue =  xmlDoValidityCheckingDefaultValue;
-
-       DOMXML_PARAM_ONE(docp, id, le_domxmldocp,"|z",&errors);
-       errorCtxt.valid = &cvp;
-
-       if (ZEND_NUM_ARGS() == 1) {
-               zval_dtor(errors);
-               array_init(errors);
-               errorCtxt.errors = errors;
-       } else {
-               errorCtxt.errors = NULL;
-       }
-
-       errorCtxt.parser = NULL;
-       xmlDoValidityCheckingDefaultValue = 1;
-       cvp.userData = (void *) &errorCtxt;
-       cvp.error    = (xmlValidityErrorFunc) domxml_error_validate;
-       cvp.warning  = (xmlValidityWarningFunc) domxml_error_validate;
-       if (docp->intSubset == NULL) {
-               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "No DTD given in XML-Document");
-       }
-
-       if (xmlValidateDocument(&cvp, docp)) {
-               RETVAL_TRUE;
-       } else {
-               RETVAL_FALSE;
-       }
-
-       xmlDoValidityCheckingDefaultValue = oldvalue;
-}
-/* }}} */
-
-/* {{{ proto object domxml_new_xmldoc(string version)
-   Creates new xmldoc */
-PHP_FUNCTION(domxml_new_xmldoc)
-{
-       zval *rv = NULL;
-       xmlDoc *docp;
-       int ret, buf_len;
-       char *buf;
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &buf, &buf_len) == FAILURE) {
-               return;
-       }
-
-       docp = xmlNewDoc(buf);
-       if (!docp) {
-               RETURN_FALSE;
-       }
-
-       DOMXML_RET_OBJ(rv, (xmlNodePtr) docp, &ret);
-}
-/* }}} */
-
-/* {{{ proto bool domxml_doc_free_doc()
-   Frees xmldoc and removed objects from hash */
-PHP_FUNCTION(domxml_doc_free_doc)
-{
-       zval *doc;
-       xmlNode *docp;
-
-       DOMXML_GET_THIS_OBJ(docp, doc, le_domxmldocp);
-
-       if (! (docp->type == XML_DOCUMENT_NODE || docp->type == XML_HTML_DOCUMENT_NODE) ) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "DomDocument is required");
-               RETURN_FALSE;
-       }
-
-       /* No need to do this as php_free_xml_doc will kill the children
-       node_list_wrapper_dtor(docp->children, 1 TSRMLS_CC);
-       node_list_wrapper_dtor((xmlNodePtr) docp->properties, 1 TSRMLS_CC);
-       */
-       node_wrapper_free(docp TSRMLS_CC);
-
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto object domxml_parser([string buf[,string filename]])
-   Creates new xmlparser */
-PHP_FUNCTION(domxml_parser)
-{
-       zval *rv;
-       xmlParserCtxtPtr parserp;
-       int ret, buf_len = 0;
-       char *buf = "";
-       char *filename = NULL;
-       int filename_len = 0;
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ss", &buf, &buf_len, &filename, &filename_len) == FAILURE) {
-               return;
-       }
-
-       parserp =  xmlCreatePushParserCtxt(NULL, NULL, buf, buf_len, filename);
-       if (!parserp) {
-               RETURN_FALSE;
-       }
-/*     parserp->loadsubset = XML_DETECT_IDS; */
-
-       rv = php_xmlparser_new(parserp, &ret TSRMLS_CC);
-       DOMXML_RET_ZVAL(rv);
-}
-/* }}} */
-
-/* {{{ proto bool domxml_parser_start_document()
-   starts a document*/
-PHP_FUNCTION(domxml_parser_start_document)
-{
-       zval *id;
-       xmlParserCtxtPtr parserp;
-       
-       DOMXML_PARAM_NONE(parserp, id, le_domxmlparserp);
-       startDocument(parserp);
-       
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool domxml_parser_end_document()
-   ends a document */
-PHP_FUNCTION(domxml_parser_end_document)
-{
-       zval *id;
-       xmlParserCtxtPtr parserp;
-       
-       DOMXML_PARAM_NONE(parserp, id, le_domxmlparserp);
-       endDocument(parserp);
-       
-}
-/* }}} */
-
-/* {{{ proto bool domxml_parser_start_element(string tagname, array attributes)
-   Starts an element and adds attributes*/
-PHP_FUNCTION(domxml_parser_start_element)
-{
-       zval *id,*params = NULL;
-       xmlParserCtxtPtr parserp;
-       char *tagname;
-       int tagname_len;
-       char **atts = NULL;
-               
-       DOMXML_PARAM_THREE(parserp, id, le_domxmlparserp,"s|a", &tagname, &tagname_len, &params);
-       if (params != NULL) {
-               atts = php_xmlparser_make_params(params TSRMLS_CC);
-       }
-       if (parserp->myDoc == NULL) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Document was not started");
-               RETURN_FALSE;
-       }
-       startElement(parserp, (xmlChar *) tagname,  (const xmlChar **) atts);
-       
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool domxml_parser_end_element(string tagname)
-   Ends an element */
-PHP_FUNCTION(domxml_parser_end_element)
-{
-       zval *id;
-       xmlParserCtxtPtr parserp;
-       char *tagname;
-       int tagname_len;
-       
-       DOMXML_PARAM_TWO(parserp, id, le_domxmlparserp,"s", &tagname, &tagname_len);
-
-       if (parserp->myDoc == NULL) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Document was not started");
-               RETURN_FALSE;
-       }
-
-       endElement(parserp, (xmlChar *) tagname);
-       
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool domxml_parser_comment(string comment)
-   Adds a comment */
-PHP_FUNCTION(domxml_parser_comment)
-{
-       zval *id;
-       xmlParserCtxtPtr parserp;
-       char *commentstring;
-       int commentstring_len;
-       
-       DOMXML_PARAM_TWO(parserp, id, le_domxmlparserp,"s", &commentstring, &commentstring_len);
-
-       if (parserp->myDoc == NULL) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Document was not started");
-               RETURN_FALSE;
-       }
-
-       comment(parserp, (xmlChar *) commentstring);
-       
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool domxml_parser_cdata_section(string chunk)
-   adds a cdata block */
-PHP_FUNCTION(domxml_parser_cdata_section)
-{
-       zval *id;
-       xmlParserCtxtPtr parserp;
-       char *chunk;
-       int chunk_len;
-       
-       DOMXML_PARAM_TWO(parserp, id, le_domxmlparserp,"s", &chunk, &chunk_len);
-
-       if (parserp->myDoc == NULL) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Document was not started");
-               RETURN_FALSE;
-       }
-
-       cdataBlock(parserp, (xmlChar *) chunk, chunk_len);
-       
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool domxml_parser_characters(string characters)
-   Adds characters */
-PHP_FUNCTION(domxml_parser_characters)
-{
-       zval *id;
-       xmlParserCtxtPtr parserp;
-       char *charactersstring;
-       int characters_len;
-       
-       DOMXML_PARAM_TWO(parserp, id, le_domxmlparserp,"s", &charactersstring, &characters_len);
-
-       if (parserp->myDoc == NULL) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Document was not started");
-               RETURN_FALSE;
-       }
-
-       characters(parserp, (xmlChar *) charactersstring, characters_len);
-       
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool domxml_parser_entity_reference(string reference)
-   Adds entity reference */
-PHP_FUNCTION(domxml_parser_entity_reference)
-{
-       zval *id;
-       xmlParserCtxtPtr parserp;
-       char *referencestring;
-       int reference_len;
-       
-       DOMXML_PARAM_TWO(parserp, id, le_domxmlparserp,"s", &referencestring, &reference_len);
-
-       if (parserp->myDoc == NULL) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Document was not started");
-               RETURN_FALSE;
-       }
-
-       reference(parserp, (xmlChar *) referencestring);
-       
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool domxml_parser_processing_instruction(string target, string data)
-   Adds processing instruction */
-PHP_FUNCTION(domxml_parser_processing_instruction)
-{
-       zval *id;
-       xmlParserCtxtPtr parserp;
-       char *data,*target;
-       int data_len, target_len;
-       
-       DOMXML_PARAM_FOUR(parserp, id, le_domxmlparserp,"ss", &target, &target_len, &data, &data_len);
-
-       if (parserp->myDoc == NULL) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Document was not started");
-               RETURN_FALSE;
-       }
-
-       processingInstruction(parserp, (xmlChar *) target, (xmlChar *) data);
-       
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool domxml_parser_namespace_decl(string href, string prefix)
-   Adds namespace declaration */
-PHP_FUNCTION(domxml_parser_namespace_decl)
-{
-       zval *id;
-       xmlParserCtxtPtr parserp;
-       char *href,*prefix;
-       int href_len, prefix_len;
-       
-       DOMXML_PARAM_FOUR(parserp, id, le_domxmlparserp,"ss", &href, &href_len, &prefix, &prefix_len);
-
-       if (parserp->myDoc == NULL) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Document was not started");
-               RETURN_FALSE;
-       }
-
-       namespaceDecl(parserp, (xmlChar *) href, (xmlChar *) prefix);
-       
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool domxml_parser_add_chunk(string chunk)
-   adds xml-chunk to parser */
-PHP_FUNCTION(domxml_parser_add_chunk)
-{
-       zval *id;
-       xmlParserCtxtPtr parserp;
-       char *chunk;
-       int chunk_len, error;
-
-       DOMXML_PARAM_TWO(parserp, id, le_domxmlparserp,"s", &chunk, &chunk_len);
-       error = xmlParseChunk(parserp, chunk, chunk_len , 0);
-       if (error != 0) {
-               RETURN_FALSE;
-       }
-
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto object domxml_parser_end([string chunk])
-   Ends parsing and returns DomDocument*/
-PHP_FUNCTION(domxml_parser_end)
-{
-       zval *id,*rv = NULL;
-       xmlParserCtxtPtr parserp;
-       char *chunk = NULL;
-       int chunk_len = 0, error;
-       int ret;
-
-
-       DOMXML_PARAM_TWO(parserp, id, le_domxmlparserp,"|s", &chunk, &chunk_len);
-       error = xmlParseChunk(parserp, chunk, chunk_len, 1);
-       if (error != 0) {
-               php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error: %d", error);
-               RETURN_FALSE;
-       }
-       if (parserp->myDoc != NULL) {
-               DOMXML_RET_OBJ(rv, (xmlNodePtr) parserp->myDoc, &ret);
-       } else {
-               RETVAL_FALSE
-       }
-}
-/* }}} */
-
-/* {{{ proto object domxml_parser_get_document()
-   Returns DomDocument from parser */
-PHP_FUNCTION(domxml_parser_get_document)
-{
-       zval *id,*rv = NULL;
-       xmlParserCtxtPtr parserp;
-       int ret;
-
-       DOMXML_PARAM_NONE(parserp, id, le_domxmlparserp);
-
-       if (parserp->myDoc != NULL) {
-               DOMXML_RET_OBJ(rv, (xmlNodePtr) parserp->myDoc, &ret);
-       } else {
-               RETVAL_FALSE
-       }
-}
-/* }}} */
-
-/* {{{ proto bool domxml_parser_set_keep_blanks(bool mode)
-   Determines how to handle blanks */
-PHP_FUNCTION(domxml_parser_set_keep_blanks)
-{
-       zval *id;
-       xmlParserCtxtPtr parserp;
-       zend_bool mode;
-
-       DOMXML_PARAM_ONE(parserp, id, le_domxmlparserp, "b", &mode);
-       parserp->keepBlanks = mode;
-
-       RETURN_TRUE;
-}
-/* }}} */
-
-#ifdef newcode
-/* {{{ proto int node_namespace([int node])
-   Returns list of namespaces */
-static int node_namespace(zval **attributes, xmlNode *nodep TSRMLS_DC)
-{
-       xmlNs *ns;
-
-       /* Get the children of the current node */
-       ns = nodep->ns;
-       if (!ns) {
-               return -1;
-       }
-
-       /* create an php array for the children */
-       MAKE_STD_ZVAL(*attributes);
-       array_init(*attributes);
-
-       while (ns) {
-               zval *pattr;
-               int ret;
-
-               pattr = php_domobject_new((xmlNodePtr) ns, &ret, NULL TSRMLS_CC);
-               SEPARATE_ZVAL(&pattr);
-
-/*             if (!ret) { */
-               if (ns->href) {
-                       add_property_stringl(pattr, "href", (char *) ns->href, strlen(ns->href), 1);
-               }
-               if (ns->prefix) {
-                       add_property_stringl(pattr, "prefix", (char *) ns->prefix, strlen(ns->prefix), 1);
-               }
-               add_property_long(pattr, "type", Z_TYPE_P(ns));
-/*             } */
-
-               zend_hash_next_index_insert(Z_ARRVAL_PP(attributes), &pattr, sizeof(zval *), NULL);
-               ns = ns->next;
-       }
-       return 0;
-}
-/* }}} */
-#endif
-
-/* We don't have a type zval. **attributes is also very unusual. */
-
-/* {{{ proto int node_attributes(zval **attributes, int node)
-   Returns list of children nodes */
-static int node_attributes(zval **attributes, xmlNode *nodep TSRMLS_DC)
-{
-       xmlAttr *attr;
-       int count = 0;
-
-       /* Get the children of the current node */
-       if (Z_TYPE_P(nodep) != XML_ELEMENT_NODE) {
-               return -1;
-       }
-       attr = nodep->properties;
-       if (!attr) {
-               return -2;
-       }
-
-       /* create an php array for the children */
-       MAKE_STD_ZVAL(*attributes);
-       array_init(*attributes);
-
-       while (attr) {
-               zval *pattr;
-               int ret;
-               xmlChar *content;
-
-               pattr = php_domobject_new((xmlNodePtr) attr, &ret, NULL TSRMLS_CC);
-               /** XXX FIXME XXX */
-/*             if (0 <= (n = node_children(&children, attr->children TSRMLS_CC))) {
-                       zend_hash_update(Z_OBJPROP_P(value), "children", sizeof("children"), (void *) &children, sizeof(zval *), NULL);
-               }
-*/             add_property_string(pattr, "name", (char *) (attr->name), 1);
-               content = xmlNodeGetContent((xmlNodePtr) attr);
-               add_property_string(pattr, "value", content, 1);
-               xmlFree(content);
-               zend_hash_next_index_insert(Z_ARRVAL_PP(attributes), &pattr, sizeof(zval *), NULL);
-               attr = attr->next;
-               count++;
-       }
-       return count;
-}
-/* }}} */
-
-/* {{{ proto int node_children([int node])
-   Returns list of children nodes */
-static int node_children(zval **children, xmlNode *nodep TSRMLS_DC)
-{
-       zval *mchildren, *attributes;
-       /* zval *namespace; */
-       xmlNode *last;
-       int count = 0;
-
-       /* Get the children of the current node */
-       last = nodep;
-       if (!last) {
-               return -1;
-       }
-
-       /* create an php array for the children */
-       MAKE_STD_ZVAL(*children);
-       array_init(*children);
-
-       while (last) {
-               zval *child;
-               int ret;
-
-               if (NULL != (child = php_domobject_new(last, &ret, NULL TSRMLS_CC))) {
-                       zend_hash_next_index_insert(Z_ARRVAL_PP(children), &child, sizeof(zval *), NULL);
-
-                       /* Get the namespace of the current node and add it as a property */
-                       /* XXX FIXME XXX */
-/*
-                       if (!node_namespace(&namespace, last)) {
-                               zend_hash_update(Z_OBJPROP_P(child), "namespace", sizeof("namespace"), (void *) &namespace, sizeof(zval *), NULL);
-                       }
-*/
-
-                       /* Get the attributes of the current node and add it as a property */
-                       if (node_attributes(&attributes, last TSRMLS_CC) >= 0) {
-                               zend_hash_update(Z_OBJPROP_P(child), "attributes", sizeof("attributes"), (void *) &attributes, sizeof(zval *), NULL);
-                       }
-
-                       /* Get recursively the children of the current node and add it as a property */
-                       if (node_children(&mchildren, last->children TSRMLS_CC) >= 0) {
-                               zend_hash_update(Z_OBJPROP_P(child), "children", sizeof("children"), (void *) &mchildren, sizeof(zval *), NULL);
-                       }
-
-                       count++;
-               }
-               last = last->next;
-       }
-       return count;
-}
-/* }}} */
-
-/* {{{ proto object domxml_xmltree(string xmltree)
-   Creates a tree of PHP objects from an XML document */
-PHP_FUNCTION(domxml_xmltree)
-{
-       zval *children, *rv = NULL;
-       xmlDoc *docp;
-       xmlNode *root;
-       int ret, buf_len;
-       char *buf;
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &buf, &buf_len) == FAILURE) {
-               return;
-       }
-
-       /* Create a new xml document */
-       docp = xmlParseDoc(buf);
-       if (!docp) {
-               RETURN_FALSE;
-       }
-
-       /* get the root and add as a property to the document */
-       root = docp->children;
-       if (!root) {
-               xmlFreeDoc(docp);
-               RETURN_FALSE;
-       }
-
-       DOMXML_RET_OBJ(rv, (xmlNodePtr) docp, &ret);
-
-       /* The root itself maybe an array. Though you may not have two Elements
-          as root, you may have a comment, pi and and element as root.
-          Thanks to Paul DuBois for pointing me at this.
-        */
-       if (node_children(&children, root TSRMLS_CC) >= 0) {
-               zend_hash_update(Z_OBJPROP_P(return_value), "children",sizeof("children"), (void *) &children, sizeof(zval *), NULL);
-       }
-/*     xmlFreeDoc(docp); */
-}
-/* }}} */
-
-#if defined(LIBXML_XPATH_ENABLED)
-/* {{{ proto bool xpath_init(void)
-   Initializing XPath environment */
-PHP_FUNCTION(xpath_init)
-{
-       if (ZEND_NUM_ARGS() != 0) {
-               WRONG_PARAM_COUNT;
-       }
-
-       xmlXPathInit();
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ php_xpathptr_new_context()
- */
-static void php_xpathptr_new_context(INTERNAL_FUNCTION_PARAMETERS, int mode)
-{
-       zval *id, *rv;
-       xmlXPathContextPtr ctx;
-       xmlDocPtr docp;
-       int ret;
-
-       DOMXML_PARAM_NONE(docp, id, le_domxmldocp);
-
-#if defined(LIBXML_XPTR_ENABLED)
-       if (mode == PHP_XPTR) {
-               ctx = xmlXPtrNewContext(docp, NULL, NULL);
-       } else
-#endif
-       {
-               ctx = xmlXPathNewContext(docp);
-       }
-       
-       if (!ctx) {
-               RETURN_FALSE;
-       }
-
-       rv = php_xpathcontext_new(ctx, &ret TSRMLS_CC);
-       DOMXML_RET_ZVAL(rv);
-}
-/* }}} */
-
-/* {{{ proto object xpath_new_context([int doc_handle])
-   Creates new XPath context */
-PHP_FUNCTION(xpath_new_context)
-{
-       php_xpathptr_new_context(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_XPATH);
-}
-/* }}} */
-
-/* {{{ proto object xptr_new_context([int doc_handle])
-   Creates new XPath context */
-PHP_FUNCTION(xptr_new_context)
-{
-       php_xpathptr_new_context(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_XPTR);
-}
-/* }}} */
-
-/* {{{ php_xpathptr_eval()
- */
-static void php_xpathptr_eval(INTERNAL_FUNCTION_PARAMETERS, int mode, int expr)
-{
-       zval *id, *rv, *contextnode = NULL;
-       xmlXPathContextPtr ctxp;
-       xmlXPathObjectPtr xpathobjp;
-       xmlNode *contextnodep;
-       int ret, str_len;
-       char *str;
-       contextnode = NULL;
-       contextnodep = NULL;
-
-       if (NULL == (id = getThis())) {
-               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "os|o", &id, &str, &str_len, &contextnode) == FAILURE) {
-                       return;
-               }
-       } else {
-               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|o", &str, &str_len, &contextnode) == FAILURE) {
-                       return;
-               }
-       }
-
-       ctxp = php_xpath_get_context(id, le_xpathctxp, 0 TSRMLS_CC);
-       if (!ctxp) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot fetch XPATH context");
-               RETURN_FALSE;
-       }
-
-       if (contextnode) {
-               DOMXML_GET_OBJ(contextnodep, contextnode, le_domxmlnodep);
-       }
-       ctxp->node = contextnodep;
-  
-#if defined(LIBXML_XPTR_ENABLED)
-       if (mode == PHP_XPTR) {
-               xpathobjp = xmlXPtrEval(BAD_CAST str, ctxp);
-       } else {
-#endif
-               if (expr) {
-                       xpathobjp = xmlXPathEvalExpression(str, ctxp);
-               } else {
-                       xpathobjp = xmlXPathEval(str, ctxp);
-               }
-#if defined(LIBXML_XPTR_ENABLED)
-       }
-#endif
-
-       ctxp->node = NULL;
-       if (!xpathobjp) {
-               RETURN_FALSE;
-       }
-
-       if (NULL == (rv = php_xpathobject_new(xpathobjp, &ret TSRMLS_CC))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create required XPATH objcet");
-               RETURN_FALSE;
-       }
-       SEPARATE_ZVAL(&rv);
-
-       add_property_long(rv, "type", Z_TYPE_P(xpathobjp));
-
-       switch (Z_TYPE_P(xpathobjp)) {
-
-               case XPATH_UNDEFINED:
-                       break;
-
-               case XPATH_NODESET: {
-                       int i;
-                       zval *arr;
-                       xmlNodeSetPtr nodesetp;
-
-                       MAKE_STD_ZVAL(arr);
-                       array_init(arr);
-
-                       if (NULL == (nodesetp = xpathobjp->nodesetval)) {
-                               zval_dtor(rv);
-                               RETURN_FALSE;
-                       }
-
-                       for (i = 0; i < nodesetp->nodeNr; i++) {
-                               xmlNodePtr node = nodesetp->nodeTab[i];
-                               zval *child;
-                               int retnode;
-
-                               /* construct a node object */
-                               child = php_domobject_new(node, &retnode, NULL TSRMLS_CC);
-                               zend_hash_next_index_insert(Z_ARRVAL_P(arr), &child, sizeof(zval *), NULL);
-                       }
-                       zend_hash_update(Z_OBJPROP_P(rv), "nodeset", sizeof("nodeset"), (void *) &arr, sizeof(zval *), NULL);
-                       break;
-               }
-
-               case XPATH_BOOLEAN:
-                       add_property_bool(rv, "value", xpathobjp->boolval);
-                       break;
-
-               case XPATH_NUMBER:
-                       add_property_double(rv, "value", xpathobjp->floatval);
-                       break;
-
-               case XPATH_STRING:
-                       add_property_string(rv, "value", xpathobjp->stringval, 1);
-                       break;
-
-               case XPATH_POINT:
-                       break;
-
-               case XPATH_RANGE:
-                       break;
-
-               case XPATH_LOCATIONSET:
-                       break;
-
-               case XPATH_USERS:
-                       break;
-
-               case XPATH_XSLT_TREE:
-                       break;
-       }
-
-       xmlXPathFreeObject(xpathobjp);
-       *return_value = *rv;
-       FREE_ZVAL(rv);
-}
-/* }}} */
-
-/* {{{ proto object xpath_eval([object xpathctx_handle,] string str)
-   Evaluates the XPath Location Path in the given string */
-PHP_FUNCTION(xpath_eval)
-{
-       php_xpathptr_eval(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_XPATH, 0);
-}
-/* }}} */
-
-/* {{{ proto object xpath_eval_expression([object xpathctx_handle,] string str)
-   Evaluates the XPath expression in the given string */
-PHP_FUNCTION(xpath_eval_expression)
-{
-       php_xpathptr_eval(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_XPATH, 1);
-}
-/* }}} */
-
-/* {{{ proto bool xpath_register_ns([object xpathctx_handle,] string namespace_prefix, string namespace_uri)
-       Registeres the given namespace in the passed XPath context */
-PHP_FUNCTION(xpath_register_ns)
-{
-       int prefix_len, uri_len, result;
-       xmlXPathContextPtr ctxp;
-       char *prefix, *uri;
-       zval *id;
-
-       DOMXML_PARAM_FOUR(ctxp, id, le_xpathctxp, "ss", &prefix, &prefix_len, &uri, &uri_len);
-
-       ctxp->node = NULL;
-
-       #ifdef CHREGU_0
-       /* this leads to memleaks... commenting it out, as it works for me without copying
-          it. chregu */
-       /*
-               this is a hack - libxml2 doesn't copy the URI, it simply uses the string
-               given in the parameter - which is normally deallocated after the function
-       */
-       uri_static = estrndup(uri, uri_len);
-       result = xmlXPathRegisterNs(ctxp, prefix, uri_static);
-       #endif
-       
-       result = xmlXPathRegisterNs(ctxp, prefix, uri);
-
-       if (0 == result) {
-               RETURN_TRUE;
-       }
-       RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto bool xpath_register_ns_auto([object xpathctx_handle,] [object contextnode])
-       Registeres the given namespace in the passed XPath context */
-PHP_FUNCTION(xpath_register_ns_auto)
-{
-       /* automatic namespace definitions registration.
-       it's only done for the context node
-       if you need namespaces defined in other nodes, 
-       you have to specify them explicitely with
-       xpath_register_ns();
-       */
-
-       zval *contextnode = NULL, *id;
-       xmlXPathContextPtr ctxp;
-       xmlNodePtr contextnodep;
-       xmlNsPtr *namespaces;   
-       int nsNr;
-                       
-       DOMXML_PARAM_ONE(ctxp, id, le_xpathctxp, "|o", &contextnode);
-
-       if (contextnode == NULL) {
-               namespaces = xmlGetNsList(ctxp->doc, xmlDocGetRootElement(ctxp->doc));
-       } else {
-               DOMXML_GET_OBJ(contextnodep, contextnode, le_domxmlnodep);
-               namespaces = xmlGetNsList(ctxp->doc, contextnodep);
-       }
-                               
-       nsNr = 0;
-       if (namespaces != NULL) {
-               while (namespaces[nsNr] != NULL) {
-                       xmlXPathRegisterNs(ctxp, namespaces[nsNr]->prefix, namespaces[nsNr]->href); 
-                       nsNr++;
-               }
-       }
-
-       RETURN_TRUE;
-}
-/* }}} */
-
-#endif /* defined(LIBXML_XPATH_ENABLED) */
-
-#if defined(LIBXML_XPTR_ENABLED)
-/* {{{ proto int xptr_eval([int xpathctx_handle,] string str)
-   Evaluates the XPtr Location Path in the given string */
-PHP_FUNCTION(xptr_eval)
-{
-       php_xpathptr_eval(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_XPTR, 0);
-}
-/* }}} */
-#endif /* LIBXML_XPTR_ENABLED */
-
-/* {{{ proto string domxml_version(void)
-   Get XML library version */
-PHP_FUNCTION(domxml_version)
-{
-       RETURN_STRING((char *) xmlParserVersion,1);
-}
-/* }}} */
-
-/* {{{ proto int domxml_doc_xinclude()
-   Substitutues xincludes in a DomDocument */
-PHP_FUNCTION(domxml_doc_xinclude)
-{
-       zval *id;
-       xmlDoc *docp;
-       int err; 
-       
-       DOMXML_PARAM_NONE(docp, id, le_domxmldocp);
-       
-       err = xmlXIncludeProcess (docp);
-       
-       if (err) {
-               RETVAL_LONG(err);
-       } else {
-               RETVAL_FALSE;
-       }
-}
-/* }}} */
-
-#if HAVE_DOMXSLT
-static zval *php_xsltstylesheet_new(xsltStylesheetPtr obj, int *found TSRMLS_DC)
-{
-       zval *wrapper;
-       int rsrc_type;
-
-       *found = 0;
-
-       if (!obj) {
-               MAKE_STD_ZVAL(wrapper);
-               ZVAL_NULL(wrapper);
-               return wrapper;
-       }
-
-       if ((wrapper = (zval *) dom_object_get_data((void *) obj))) {
-               zval_add_ref(&wrapper);
-               *found = 1;
-               return wrapper;
-       }
-
-       MAKE_STD_ZVAL(wrapper);
-
-       object_init_ex(wrapper, domxsltstylesheet_class_entry);
-       rsrc_type = le_domxsltstylesheetp;
-       php_xsltstylesheet_set_object(wrapper, (void *) obj, rsrc_type TSRMLS_CC);
-
-       return (wrapper);
-}
-
-/* {{{ proto object domxml_xslt_stylesheet(string xsltstylesheet)
-   Creates XSLT Stylesheet object from string */
-PHP_FUNCTION(domxml_xslt_stylesheet)
-{
-       zval *rv;
-       xmlDocPtr docp;
-       xsltStylesheetPtr sheetp;
-       int ret;
-       char *buffer;
-       int buffer_len;
-       int prevSubstValue, prevExtDtdValue;
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &buffer, &buffer_len) == FAILURE) {
-               RETURN_FALSE;
-       }
-
-       prevSubstValue = xmlSubstituteEntitiesDefault (1);
-       prevExtDtdValue = xmlLoadExtDtdDefaultValue;
-       xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
-
-       docp = xmlParseDoc(buffer);
-
-       xmlSubstituteEntitiesDefault (prevSubstValue);
-       xmlLoadExtDtdDefaultValue = prevExtDtdValue;
-
-       if (!docp) {
-               RETURN_FALSE;
-       }
-
-       sheetp = xsltParseStylesheetDoc(docp);
-
-       if (!sheetp) {
-               xmlFreeDoc(docp);
-               RETURN_FALSE;
-       }
-
-       rv = php_xsltstylesheet_new(sheetp, &ret TSRMLS_CC);
-       DOMXML_RET_ZVAL(rv);
-}
-/* }}} */
-
-/* {{{ proto object domxml_xslt_stylesheet_doc(object xmldoc)
-   Creates XSLT Stylesheet object from DOM Document object */
-PHP_FUNCTION(domxml_xslt_stylesheet_doc)
-{
-       zval *rv, *idxml;
-       xmlDocPtr docp;
-       xmlDocPtr newdocp;
-       xsltStylesheetPtr sheetp;
-       int ret;
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &idxml) == FAILURE) {
-               RETURN_FALSE;
-       }
-
-       DOMXML_GET_OBJ(docp, idxml, le_domxmldocp);
-
-       newdocp = xmlCopyDoc(docp, 1);
-
-       if (!newdocp) {
-               RETURN_FALSE;
-       }
-
-       sheetp = xsltParseStylesheetDoc(newdocp);
-
-       if (!sheetp) {
-               xmlFreeDoc(newdocp);
-               RETURN_FALSE;
-       }
-
-       rv = php_xsltstylesheet_new(sheetp, &ret TSRMLS_CC);
-       DOMXML_RET_ZVAL(rv);
-}
-/* }}} */
-
-/* {{{ proto object domxml_xslt_stylesheet_file(string filename)
-   Creates XSLT Stylesheet object from file */
-PHP_FUNCTION(domxml_xslt_stylesheet_file)
-{
-       zval *rv;
-       xsltStylesheetPtr sheetp;
-       int ret, file_len;
-       char *file;
-       int prevSubstValue, prevExtDtdValue;
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file, &file_len) == FAILURE) {
-               RETURN_FALSE;
-       }
-
-       prevSubstValue = xmlSubstituteEntitiesDefault (1);
-       prevExtDtdValue = xmlLoadExtDtdDefaultValue;
-       xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
-
-       sheetp = xsltParseStylesheetFile(file);
-
-       xmlSubstituteEntitiesDefault (prevSubstValue);
-       xmlLoadExtDtdDefaultValue = prevExtDtdValue;
-
-       if (!sheetp) {
-               RETURN_FALSE;
-       }
-
-       rv = php_xsltstylesheet_new(sheetp, &ret TSRMLS_CC);
-       DOMXML_RET_ZVAL(rv);
-}
-/* }}} */
-
-/* {{{ php_domxslt_string_to_xpathexpr()
-   Translates a string to a XPath Expression */
-static char *php_domxslt_string_to_xpathexpr(const char *str TSRMLS_DC)
-{
-       const xmlChar *string = (const xmlChar *)str;
-
-       xmlChar *value;
-       int str_len;
-       
-       str_len = xmlStrlen(string) + 3;
-       
-       if (xmlStrchr(string, '"')) {
-               if (xmlStrchr(string, '\'')) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create XPath expression (string contains both quote and double-quotes)");
-                       return NULL;
-               }
-               value = (xmlChar*) emalloc (str_len * sizeof(xmlChar) );
-               snprintf(value, str_len, "'%s'", string);
-       } else {
-               value = (xmlChar*) emalloc (str_len * sizeof(xmlChar) );
-               snprintf(value, str_len, "\"%s\"", string);
-       }
-
-       return (char *)value;
-}
-
-/* {{{ php_domxslt_make_params()
-   Translates a PHP array to a libxslt parameters array */
-static char **php_domxslt_make_params(zval *idvars, int xpath_params TSRMLS_DC)
-{
-       HashTable *parht;
-       int parsize;
-       zval **value;
-       char *xpath_expr, *string_key = NULL;
-       ulong num_key;
-       char **params = NULL;
-       int i = 0;
-
-       parht = HASH_OF(idvars);
-       parsize = (2 * zend_hash_num_elements(parht) + 1) * sizeof(char *);
-       params = (char **)emalloc(parsize);
-       memset((char *)params, 0, parsize);
-
-       for (zend_hash_internal_pointer_reset(parht);
-               zend_hash_get_current_data(parht, (void **)&value) == SUCCESS;
-               zend_hash_move_forward(parht)) {
-
-               if (zend_hash_get_current_key(parht, &string_key, &num_key, 1) != HASH_KEY_IS_STRING) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid argument or parameter array");
-                       return NULL;
-               } else {
-                       if (Z_TYPE_PP(value) != IS_STRING) {
-                               SEPARATE_ZVAL(value);
-                               convert_to_string(*value);
-                       }
-
-                       if (!xpath_params) {
-                               xpath_expr = php_domxslt_string_to_xpathexpr(Z_STRVAL_PP(value) TSRMLS_CC);
-                       } else {
-                               xpath_expr = Z_STRVAL_PP(value);
-                       }
-
-                       if (xpath_expr) {
-                               params[i++] = string_key;
-                               params[i++] = xpath_expr;
-                       }
-               }
-       }
-
-       params[i++] = NULL;
-
-       return params;
-}
-/* }}} */
-
-/* {{{ proto object domxml_xslt_process(object xslstylesheet, object xmldoc [, array xslt_parameters [, bool xpath_parameters [, string profileFilename]]])
-   Perform an XSLT transformation */
-PHP_FUNCTION(domxml_xslt_process)
-{
-/* TODO:
-       - test memory deallocation
-       - test other stuff
-       - check xsltsp->errors ???
-*/
-       zval *rv = NULL, *idxsl, *idxml, *idparams = NULL;
-       zend_bool xpath_params = 0;
-       xsltStylesheetPtr xsltstp;
-       xmlDocPtr xmldocp;
-       xmlDocPtr docp;
-       char **params = NULL;
-       int ret;
-       char *filename;
-       int filename_len = 0;
-
-       DOMXML_GET_THIS(idxsl);
-
-       xsltstp = php_xsltstylesheet_get_object(idxsl, le_domxsltstylesheetp, 0 TSRMLS_CC);
-       if (!xsltstp) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Underlying object missing");
-               RETURN_FALSE;
-       }
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|abs", &idxml, &idparams, &xpath_params, &filename, &filename_len) == FAILURE) {
-               RETURN_FALSE;
-       }
-
-       DOMXML_GET_OBJ(xmldocp, idxml, le_domxmldocp);
-
-       if (idparams) {
-               params = php_domxslt_make_params(idparams, xpath_params TSRMLS_CC);
-       }
-
-       if (filename_len) {
-               FILE *f;
-               f = fopen (filename,"w");
-               docp = xsltProfileStylesheet(xsltstp, xmldocp, (const char**)params, f);
-               fclose(f);
-       } else {
-               docp = xsltApplyStylesheet(xsltstp, xmldocp, (const char**)params);
-       }
-
-       if (params) {
-               efree(params);
-       }
-
-       if (!docp) {
-               RETURN_FALSE;
-       }
-
-       DOMXML_RET_OBJ(rv, (xmlNodePtr) docp, &ret);
-}
-/* }}} */
-
-/* {{{ proto string domxml_xslt_result_dump_mem(object xslstylesheet, object xmldoc)
-   output XSLT result to memory */
-PHP_FUNCTION(domxml_xslt_result_dump_mem)
-{
-       zval *idxsl, *idxml;
-       xsltStylesheetPtr xsltstp;
-       xmlDocPtr xmldocp;
-       xmlChar *doc_txt_ptr;
-       int doc_txt_len;
-       int ret;
-
-       DOMXML_GET_THIS(idxsl);
-
-       xsltstp = php_xsltstylesheet_get_object(idxsl, le_domxsltstylesheetp, 0 TSRMLS_CC);
-       if (!xsltstp) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Underlying object missing");
-               RETURN_FALSE;
-       }
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &idxml) == FAILURE) {
-               RETURN_FALSE;
-       }
-
-       DOMXML_GET_OBJ(xmldocp, idxml, le_domxmldocp);
-
-       ret = xsltSaveResultToString(&doc_txt_ptr, &doc_txt_len, xmldocp, xsltstp);
-
-       if (ret < 0) {
-               RETURN_FALSE;
-       }
-
-       if (doc_txt_ptr) {
-               RETVAL_STRINGL(doc_txt_ptr, doc_txt_len, 1);
-               xmlFree(doc_txt_ptr);
-       } else {
-               RETURN_EMPTY_STRING();
-       }
-}
-/* }}} */
-
-/* {{{ proto int domxml_xslt_result_dump_file(object xslstylesheet, object xmldoc, string filename[, int compression])
-   output XSLT result to File */
-PHP_FUNCTION(domxml_xslt_result_dump_file)
-{
-       zval *idxsl, *idxml;
-       xsltStylesheetPtr xsltstp;
-       xmlDocPtr xmldocp;
-       char *filename;
-       int filename_len;
-       int ret;
-       long compression = 0;
-
-       DOMXML_GET_THIS(idxsl);
-
-       xsltstp = php_xsltstylesheet_get_object(idxsl, le_domxsltstylesheetp, 0 TSRMLS_CC);
-       if (!xsltstp) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Underlying object missing");
-               RETURN_FALSE;
-       }
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "os|l", &idxml, &filename, &filename_len, &compression) == FAILURE) {
-               RETURN_FALSE;
-       }
-       if ((PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(filename TSRMLS_CC)) {
-               RETURN_FALSE;
-       }
-
-       DOMXML_GET_OBJ(xmldocp, idxml, le_domxmldocp);
-
-       ret = xsltSaveResultToFilename(filename, xmldocp, xsltstp, compression);
-
-       if (ret < 0) {
-               RETURN_FALSE;
-       }
-
-       RETURN_LONG(ret);
-}
-/* }}} */
-
-/* {{{ proto string domxml_xslt_version(void)
-   Get XSLT library version */
-PHP_FUNCTION(domxml_xslt_version)
-{
-       RETURN_LONG(xsltLibxsltVersion);
-}
-/* }}} */
-#endif /* HAVE_DOMXSLT */
-
-#endif /* HAVE_DOMXML */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/domxml/php_domxml.h b/ext/domxml/php_domxml.h
deleted file mode 100644 (file)
index f791598..0000000
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
-   +----------------------------------------------------------------------+
-   | PHP Version 4                                                        |
-   +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2003 The PHP Group                                |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 3.0 of the PHP license,       |
-   | that is bundled with this package in the file LICENSE, and is        |
-   | available through the world-wide-web at the following url:           |
-   | http://www.php.net/license/3_0.txt.                                  |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@php.net so we can mail you a copy immediately.               |
-   +----------------------------------------------------------------------+
-   | Author: Uwe Steinmann (Uwe.Steinmann@fernuni-hagen.de                |
-   +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifndef PHP_DOMXML_H
-#define PHP_DOMXML_H
-
-#if HAVE_DOMXML
-#include <libxml/parser.h>
-#include <libxml/parserInternals.h>
-#include <libxml/tree.h>
-#include <libxml/xmlerror.h>
-#include <libxml/xinclude.h>
-#if defined(LIBXML_HTML_ENABLED)
-#include <libxml/HTMLparser.h>
-#include <libxml/HTMLtree.h>
-#endif
-#if defined(LIBXML_XPATH_ENABLED)
-#include <libxml/xpath.h>
-#include <libxml/xpathInternals.h>
-#endif
-#if defined(LIBXML_XPTR_ENABLED)
-#include <libxml/xpointer.h>
-#endif
-#if HAVE_DOMXSLT
-#include <libxslt/xsltconfig.h>
-#include <libxslt/xsltInternals.h>
-#include <libxslt/xsltutils.h>
-#include <libxslt/transform.h>
-#if HAVE_DOMEXSLT
-#include <libexslt/exslt.h>
-#include <libexslt/exsltconfig.h>
-#endif
-#endif
-
-/* DOMXML API_VERSION, please bump it up, if you change anything in the API
-    therefore it's easier for the script-programmers to check, what's working how
-   Can be checked with phpversion("domxml");
-*/
-#define DOMXML_API_VERSION "20030407"
-
-extern zend_module_entry domxml_module_entry;
-#define domxml_module_ptr &domxml_module_entry
-
-#ifdef PHP_WIN32
-#ifdef PHPAPI
-#undef PHPAPI
-#endif
-#ifdef DOMXML_EXPORTS
-#define PHPAPI __declspec(dllexport)
-#else
-#define PHPAPI __declspec(dllimport)
-#endif /* DOMXML_EXPORTS */
-#endif /* PHP_WIN32 */
-
-PHPAPI zval *php_domobject_new(xmlNodePtr obj, int *found, zval* in TSRMLS_DC);
-
-/* directory functions */
-PHP_MINIT_FUNCTION(domxml);
-PHP_MSHUTDOWN_FUNCTION(domxml);
-PHP_MINFO_FUNCTION(domxml);
-PHP_FUNCTION(domxml_version);
-PHP_FUNCTION(xmldoc);
-PHP_FUNCTION(xmldocfile);
-#if defined(LIBXML_HTML_ENABLED)
-PHP_FUNCTION(html_doc);
-PHP_FUNCTION(html_doc_file);
-#endif
-PHP_FUNCTION(domxml_xmltree);
-PHP_FUNCTION(domxml_new_xmldoc);
-PHP_FUNCTION(domxml_substitute_entities_default);
-
-/* Class Document methods */
-PHP_FUNCTION(domxml_doc_doctype);
-PHP_FUNCTION(domxml_doc_implementation);
-PHP_FUNCTION(domxml_doc_create_element);
-PHP_FUNCTION(domxml_doc_create_element_ns);
-PHP_FUNCTION(domxml_doc_create_text_node);
-PHP_FUNCTION(domxml_doc_create_comment);
-PHP_FUNCTION(domxml_doc_create_processing_instruction);
-PHP_FUNCTION(domxml_doc_create_document_fragment);
-PHP_FUNCTION(domxml_doc_create_attribute);
-PHP_FUNCTION(domxml_doc_create_cdata_section);
-PHP_FUNCTION(domxml_doc_create_entity_reference);
-PHP_FUNCTION(domxml_doc_imported_node);
-PHP_FUNCTION(domxml_doc_add_root);
-PHP_FUNCTION(domxml_doc_document_element);
-PHP_FUNCTION(domxml_doc_set_root);
-PHP_FUNCTION(domxml_intdtd);
-PHP_FUNCTION(domxml_doc_ids);
-PHP_FUNCTION(domxml_dump_mem);
-PHP_FUNCTION(domxml_dump_mem_file);
-PHP_FUNCTION(domxml_dump_node);
-PHP_FUNCTION(domxml_doc_validate);
-PHP_FUNCTION(domxml_doc_xinclude);
-PHP_FUNCTION(domxml_doc_free_doc);
-#if defined(LIBXML_HTML_ENABLED)
-PHP_FUNCTION(domxml_html_dump_mem);
-#endif
-
-/* Class DocumentType methods */
-PHP_FUNCTION(domxml_doctype_name);
-PHP_FUNCTION(domxml_doctype_entities);
-PHP_FUNCTION(domxml_doctype_notations);
-PHP_FUNCTION(domxml_doctype_public_id);
-PHP_FUNCTION(domxml_doctype_system_id);
-PHP_FUNCTION(domxml_doctype_internal_subset);
-
-/* Class Notation methods */
-PHP_FUNCTION(domxml_notation_public_id);
-PHP_FUNCTION(domxml_notation_system_id);
-
-/* Class Node methods */
-PHP_FUNCTION(domxml_node_attributes);
-PHP_FUNCTION(domxml_node_children);
-PHP_FUNCTION(domxml_node_first_child);
-PHP_FUNCTION(domxml_node_last_child);
-PHP_FUNCTION(domxml_node_next_sibling);
-PHP_FUNCTION(domxml_node_previous_sibling);
-PHP_FUNCTION(domxml_node_owner_document);
-PHP_FUNCTION(domxml_node_insert_before);
-PHP_FUNCTION(domxml_node_append_sibling);
-PHP_FUNCTION(domxml_node_append_child);
-PHP_FUNCTION(domxml_node_remove_child);
-PHP_FUNCTION(domxml_node_replace_child);
-PHP_FUNCTION(domxml_node_has_attributes);
-PHP_FUNCTION(domxml_node_has_child_nodes);
-PHP_FUNCTION(domxml_node_parent);
-PHP_FUNCTION(domxml_node_prefix);
-PHP_FUNCTION(domxml_node_namespace_uri);
-PHP_FUNCTION(domxml_node_add_namespace);
-PHP_FUNCTION(domxml_node_set_namespace);
-PHP_FUNCTION(domxml_node);
-PHP_FUNCTION(domxml_clone_node);
-PHP_FUNCTION(domxml_node_unlink_node);
-PHP_FUNCTION(domxml_node_replace_node);
-PHP_FUNCTION(domxml_node_new_child);
-PHP_FUNCTION(domxml_node_set_content);
-PHP_FUNCTION(domxml_node_get_content);
-PHP_FUNCTION(domxml_node_text_concat);
-PHP_FUNCTION(domxml_node_set_name);
-PHP_FUNCTION(domxml_node_get_path);
-PHP_FUNCTION(domxml_node_name);
-PHP_FUNCTION(domxml_node_type);
-PHP_FUNCTION(domxml_node_value);
-PHP_FUNCTION(domxml_is_blank_node);
-
-/* Class Attribute methods */
-PHP_FUNCTION(domxml_attr_name);
-PHP_FUNCTION(domxml_attr_value);
-PHP_FUNCTION(domxml_attr_specified);
-PHP_FUNCTION(domxml_attr_set_value);
-
-/* Class Element methods */
-PHP_FUNCTION(domxml_elem_tagname);
-PHP_FUNCTION(domxml_elem_get_attribute);
-PHP_FUNCTION(domxml_elem_set_attribute);
-PHP_FUNCTION(domxml_elem_remove_attribute);
-PHP_FUNCTION(domxml_elem_get_attribute_node);
-PHP_FUNCTION(domxml_elem_set_attribute_node);
-PHP_FUNCTION(domxml_elem_get_elements_by_tagname);
-PHP_FUNCTION(domxml_elem_has_attribute);
-/* Class CData methods */
-PHP_FUNCTION(domxml_cdata_length);
-
-/* Class Notation methods */
-PHP_FUNCTION(domxml_notation_public_id);
-PHP_FUNCTION(domxml_notation_system_id);
-
-/* Class Entity methods */
-PHP_FUNCTION(domxml_entity_public_id);
-PHP_FUNCTION(domxml_entity_system_id);
-PHP_FUNCTION(domxml_entity_notation_name);
-
-/* Class ProcessingInstructions methods*/
-PHP_FUNCTION(domxml_pi_target);
-PHP_FUNCTION(domxml_pi_data);
-
-/* Class DocumentFragment methods */
-PHP_FUNCTION(domxml_document_fragment_open_mem);
-
-/* Class Parser methods */
-PHP_FUNCTION(domxml_parser);
-PHP_FUNCTION(domxml_parser_add_chunk);
-PHP_FUNCTION(domxml_parser_end);
-PHP_FUNCTION(domxml_parser_set_keep_blanks);
-PHP_FUNCTION(domxml_parser_start_element);
-PHP_FUNCTION(domxml_parser_end_element);
-PHP_FUNCTION(domxml_parser_characters);
-PHP_FUNCTION(domxml_parser_entity_reference);
-PHP_FUNCTION(domxml_parser_comment);
-PHP_FUNCTION(domxml_parser_cdata_section);
-PHP_FUNCTION(domxml_parser_namespace_decl);
-PHP_FUNCTION(domxml_parser_processing_instruction);
-PHP_FUNCTION(domxml_parser_start_document);
-PHP_FUNCTION(domxml_parser_end_document);
-PHP_FUNCTION(domxml_parser_get_document);
-
-/* Class XPathContext methods */
-#if defined(LIBXML_XPATH_ENABLED)
-PHP_FUNCTION(xpath_init);
-PHP_FUNCTION(xpath_new_context);
-PHP_FUNCTION(xpath_eval);
-PHP_FUNCTION(xpath_eval_expression);
-PHP_FUNCTION(xpath_register_ns);
-PHP_FUNCTION(xpath_register_ns_auto);
-PHP_FUNCTION(domxml_doc_get_elements_by_tagname);
-PHP_FUNCTION(domxml_doc_get_element_by_id);
-#endif
-#if defined(LIBXML_XPTR_ENABLED)
-PHP_FUNCTION(xptr_new_context);
-PHP_FUNCTION(xptr_eval);
-#endif
-PHP_FUNCTION(domxml_test);
-
-/* DOMXSLT functions */
-#if HAVE_DOMXSLT
-PHP_FUNCTION(domxml_xslt_stylesheet);
-PHP_FUNCTION(domxml_xslt_stylesheet_doc);
-PHP_FUNCTION(domxml_xslt_stylesheet_file);
-PHP_FUNCTION(domxml_xslt_process);
-PHP_FUNCTION(domxml_xslt_result_dump_mem);
-PHP_FUNCTION(domxml_xslt_result_dump_file);
-PHP_FUNCTION(domxml_xslt_version);
-#endif
-typedef struct {
-   zval *errors;
-   xmlValidCtxtPtr valid;
-   xmlParserCtxtPtr parser;
-} domxml_ErrorCtxt;
-#else
-#define domxml_module_ptr NULL
-
-#endif /* HAVE_DOMXML */
-#define phpext_domxml_ptr domxml_module_ptr
-
-#endif /* _PHP_DIR_H */
diff --git a/ext/domxml/tests/domxml001.phpt b/ext/domxml/tests/domxml001.phpt
deleted file mode 100644 (file)
index b4d27c7..0000000
+++ /dev/null
@@ -1,273 +0,0 @@
---TEST--
-Test 1: Accessing single node
---SKIPIF--
-<?php require_once('skipif.inc'); ?>
---FILE--
-<?php
-require_once("domxml_test.inc");
-
-echo "Test 1: accessing single nodes from php\n";
-$dom = xmldoc($xmlstr);
-if(!$dom) {
-  echo "Error while parsing the document\n";
-  exit;
-}
-
-// children() of of document would result in a memleak
-//$children = $dom->children();
-//print_node_list($children);
-
-echo "--------- root\n";
-$rootnode = $dom->root();
-print_node($rootnode);
-
-echo "--------- children of root\n";
-$children = $rootnode->children();
-print_node_list($children);
-
-// The last node should be identical with the last entry in the children array
-echo "--------- last\n";
-$last = $rootnode->last_child();
-print_node($last);
-
-// The parent of this last node is the root again
-echo "--------- parent\n";
-$parent = $last->parent();
-print_node($parent);
-
-// The children of this parent are the same children as one above
-echo "--------- children of parent\n";
-$children = $parent->children();
-print_node_list($children);
-
-echo "--------- creating a new attribute\n";
-//This is worthless
-//$attr = $dom->create_attribute("src", "picture.gif");
-//print_r($attr);
-
-//$rootnode->set_attribute_node($attr); /* Not implemented */
-$attr = $rootnode->set_attribute("src", "picture.gif");
-$attr = $rootnode->get_attribute("src");
-print_r($attr);
-print "\n";
-
-echo "--------- Get Attribute Node\n";
-$attr = $rootnode->get_attribute_node("src");
-print_node($attr);
-
-echo "--------- Remove Attribute Node\n";
-$attr = $rootnode->remove_attribute("src");
-print "Removed " . $attr . " attributes.\n";
-
-echo "--------- attributes of rootnode\n";
-$attrs = $rootnode->attributes();
-print_node_list($attrs);
-
-echo "--------- children of an attribute\n";
-$children = $attrs[0]->children();
-print_node_list($children);
-
-echo "--------- Add child to root\n";
-$newchild = $rootnode->new_child("Silly", "Symphony");
-print_node($newchild);
-print $dom->dumpmem();
-print "\n";
-
-echo "--------- Find element by tagname\n";
-echo "    Using dom\n";
-$children = $dom->get_elements_by_tagname("Silly");
-print_node_list($children);
-echo "    Using elem\n";
-$children = $rootnode->get_elements_by_tagname("Silly");
-print_node_list($children);
-
-echo "--------- Unlink Node\n";
-print_node($children[0]);
-//domxml_node_unlink_node($children[0]);
-$children[0]->unlink_node();
-print_node_list($rootnode->children());
-print $dom->dumpmem();
-
-echo "--------- Find element by id\n";
-print ("Not implemented\n");
-
-echo "--------- Check various node_name return values\n";
-print ("Not needed\n");
-
-?>
---EXPECT--
-Test 1: accessing single nodes from php
---------- root
-Node Name: chapter
-Node Type: 1
-Num Children: 4
-
---------- children of root
-Node Name: title
-Node Type: 1
-Num Children: 1
-Node Content: Title
-
-Node Name: #text
-Node Type: 3
-Num Children: 0
-Node Content: 
-
-
-Node Name: para
-Node Type: 1
-Num Children: 7
-
-Node Name: #text
-Node Type: 3
-Num Children: 0
-Node Content: 
-
-
---------- last
-Node Name: #text
-Node Type: 3
-Num Children: 0
-Node Content: 
-
-
---------- parent
-Node Name: chapter
-Node Type: 1
-Num Children: 4
-
---------- children of parent
-Node Name: title
-Node Type: 1
-Num Children: 1
-Node Content: Title
-
-Node Name: #text
-Node Type: 3
-Num Children: 0
-Node Content: 
-
-
-Node Name: para
-Node Type: 1
-Num Children: 7
-
-Node Name: #text
-Node Type: 3
-Num Children: 0
-Node Content: 
-
-
---------- creating a new attribute
-picture.gif
---------- Get Attribute Node
-Node Name: src
-Node Type: 2
-Num Children: 1
-Node Content: picture.gif
-
---------- Remove Attribute Node
-Removed 1 attributes.
---------- attributes of rootnode
-Node Name: language
-Node Type: 2
-Num Children: 1
-Node Content: en
-
---------- children of an attribute
-Node Name: #text
-Node Type: 3
-Num Children: 0
-Node Content: en
-
---------- Add child to root
-Node Name: Silly
-Node Type: 1
-Num Children: 1
-Node Content: Symphony
-
-<?xml version="1.0" standalone="yes"?>
-<!DOCTYPE chapter SYSTEM "/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd" [
-<!ENTITY sp "spanish">
-]>
-<!-- lsfj  -->
-<chapter language="en"><title language="en">Title</title>
-<para language="ge">
-&sp;
-<!-- comment -->
-<informaltable language="&sp;kkk">
-<tgroup cols="3">
-<tbody>
-<row><entry>a1</entry><entry morerows="1">b1</entry><entry>c1</entry></row>
-<row><entry>a2</entry><entry>c2</entry></row>
-<row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row>
-</tbody>
-</tgroup>
-</informaltable>
-</para>
-<Silly>Symphony</Silly></chapter>
-
---------- Find element by tagname
-    Using dom
-Node Name: Silly
-Node Type: 1
-Num Children: 1
-Node Content: Symphony
-
-    Using elem
-Node Name: Silly
-Node Type: 1
-Num Children: 1
-Node Content: Symphony
-
---------- Unlink Node
-Node Name: Silly
-Node Type: 1
-Num Children: 1
-Node Content: Symphony
-
-Node Name: title
-Node Type: 1
-Num Children: 1
-Node Content: Title
-
-Node Name: #text
-Node Type: 3
-Num Children: 0
-Node Content: 
-
-
-Node Name: para
-Node Type: 1
-Num Children: 7
-
-Node Name: #text
-Node Type: 3
-Num Children: 0
-Node Content: 
-
-
-<?xml version="1.0" standalone="yes"?>
-<!DOCTYPE chapter SYSTEM "/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd" [
-<!ENTITY sp "spanish">
-]>
-<!-- lsfj  -->
-<chapter language="en"><title language="en">Title</title>
-<para language="ge">
-&sp;
-<!-- comment -->
-<informaltable language="&sp;kkk">
-<tgroup cols="3">
-<tbody>
-<row><entry>a1</entry><entry morerows="1">b1</entry><entry>c1</entry></row>
-<row><entry>a2</entry><entry>c2</entry></row>
-<row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row>
-</tbody>
-</tgroup>
-</informaltable>
-</para>
-</chapter>
---------- Find element by id
-Not implemented
---------- Check various node_name return values
-Not needed
diff --git a/ext/domxml/tests/domxml002.phpt b/ext/domxml/tests/domxml002.phpt
deleted file mode 100644 (file)
index fa60f15..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
---TEST--
-Test 2: Memleak in accessing children() of document.
---SKIPIF--
-<?php require_once('skipif.inc'); ?>
---FILE--
-<?php
-require_once("domxml_test.inc");
-
-$dom = xmldoc($xmlstr);
-if(!$dom) {
-  die('Error while parsing the document');
-}
-
-$children = $dom->children();
-print_node_list($children);
-
-?>
---EXPECT--
-Node Name: 
-Node Type: 14
-Num Children: 1
-Node Content: 
-
-Node Name: #comment
-Node Type: 8
-Num Children: 0
-Node Content:  lsfj  
-
-Node Name: chapter
-Node Type: 1
-Num Children: 4
diff --git a/ext/domxml/tests/domxml_test.inc b/ext/domxml/tests/domxml_test.inc
deleted file mode 100644 (file)
index fa9b9e4..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<?PHP
-$xmlstr = "<?xml version='1.0' standalone='yes'?>
-<!DOCTYPE chapter SYSTEM '/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd'
-[ <!ENTITY sp \"spanish\">
-]>
-<!-- lsfj  -->
-<chapter language='en'><title language='en'>Title</title>
-<para language='ge'>
-&sp;
-<!-- comment -->
-<informaltable language='&sp;kkk'>
-<tgroup cols='3'>
-<tbody>
-<row><entry>a1</entry><entry morerows='1'>b1</entry><entry>c1</entry></row>
-<row><entry>a2</entry><entry>c2</entry></row>
-<row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row>
-</tbody>
-</tgroup>
-</informaltable>
-</para>
-</chapter> ";
-
-function print_node($node)
-{
-  print "Node Name: " . $node->node_name();
-  print "\nNode Type: " . $node->node_type();
-  print "\nNum Children: " . count($node->children());
-  if(count($node->children()) <= 1){
-    print "\nNode Content: " . $node->get_content();
-  }
-  print "\n\n";
-}
-
-function print_node_list($nodelist)
-{
-  foreach($nodelist as $node)
-  {
-    print_node($node);
-  }
-}
-
-?>
diff --git a/ext/domxml/tests/skipif.inc b/ext/domxml/tests/skipif.inc
deleted file mode 100644 (file)
index 8498b5b..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<?php
-       if (!extension_loaded('domxml')) die('skip domxml extension not available');
-?>
diff --git a/ext/domxml/tests/xmldoc.phpt b/ext/domxml/tests/xmldoc.phpt
deleted file mode 100644 (file)
index 439f137..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
---TEST--
-xmldoc()
---SKIPIF--
-<?php require_once('skipif.inc'); ?>
---FILE--
-<?php
-require_once("domxml_test.inc");
-
-$dom = xmldoc($xmlstr);
-if(!$dom) {
-  die('Error while parsing the document');
-}
-var_dump($dom);
-?>
---EXPECTF--
-object(domdocument)#%d (9) {
-  ["name"]=>
-  string(9) "#document"
-  ["url"]=>
-  string(0) ""
-  ["version"]=>
-  string(3) "1.0"
-  ["standalone"]=>
-  int(1)
-  ["type"]=>
-  int(9)
-  ["compression"]=>
-  int(-1)
-  ["charset"]=>
-  int(1)
-  [0]=>
-  int(5)
-  [1]=>
-  int(%d)
-}
diff --git a/ext/hyperwave/CREDITS b/ext/hyperwave/CREDITS
deleted file mode 100644 (file)
index b01b169..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-HyperWave
-Uwe Steinmann
diff --git a/ext/hyperwave/config.m4 b/ext/hyperwave/config.m4
deleted file mode 100644 (file)
index 9e5a31c..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-dnl
-dnl $Id$
-dnl
-
-AC_MSG_CHECKING(for Hyperwave support)
-AC_ARG_WITH(hyperwave,
-[  --with-hyperwave        Include Hyperwave support],
-[
-  if test "$withval" != "no"; then
-    AC_DEFINE(HYPERWAVE,1,[ ])
-    AC_MSG_RESULT(yes)
-    PHP_NEW_EXTENSION(hyperwave, hw.c hg_comm.c)
-  else
-    AC_DEFINE(HYPERWAVE,0,[ ])
-    AC_MSG_RESULT(no)
-  fi
-],[
-  AC_DEFINE(HYPERWAVE,0,[ ])
-  AC_MSG_RESULT(no)
-])
diff --git a/ext/hyperwave/debug.h b/ext/hyperwave/debug.h
deleted file mode 100644 (file)
index 5b72dbb..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
-/****************************************************************************
-*
-*          Copyright (C) 1991 Kendall Bennett.
-*              All rights reserved.
-*
-* Filename:    $RCSfile$
-* Version:    $Revision$
-*
-* Language:    ANSI C
-* Environment:  any
-*
-* Description:  General header file for portable code.
-*
-* $Id$
-*
-* Revision History:
-* -----------------
-*
-* $Log$
-* Revision 1.2  2000/07/02 23:46:41  sas
-* Change header protection macros to conform to standard.
-*
-* Draft 3 of IEEE 1003.1 200x, "2.2 The Compilation Environment"
-*
-*   All identifiers that begin with an underscore and either an uppercase
-*   letter or another underscore are always reserved for any use by the
-*   implementation.
-*
-* Revision 1.1  1999/04/21 23:37:47  ssb
-* moved db
-*
-* Revision 1.1.1.1  1999/04/07 21:03:29  zeev
-* PHP 4.0
-*
-* Revision 1.1.1.1  1999/03/17 04:29:10  andi
-* PHP4
-*
-* Revision 1.1.1.1  1998/12/21 07:56:22  andi
-* Trying to start the zend CVS tree
-*
-* Revision 1.1  1998/08/12 09:29:16  steinm
-* First version of Hyperwave module.
-*
-* Revision 1.6  92/03/15  12:51:48  kjb
-* Added MK_FP macro and ushort typedef.
-* 
-* Revision 1.5  91/10/28  03:17:33  kjb
-* Ported to the Iris.
-* 
-* Revision 1.4  91/09/26  15:29:02  kjb
-* Added stuff for the SGI Iris 4D.
-* 
-* Revision 1.3  91/09/26  10:07:04  kjb
-* Added general typedef stuff.
-* 
-* Revision 1.2  91/09/03  18:19:14  ROOT_DOS
-* Added a few defines that are supplied by <dir.h> for UNIX compatibility.
-*
-* Revision 1.1  91/08/16  13:19:06  ROOT_DOS
-* Initial revision
-*
-****************************************************************************/
-
-#ifndef  DEBUG_H
-#define  DEBUG_H
-
-#ifdef  DEBUG
-#    define D(x) x
-#else
-#    define D(x)
-#endif
-
-#define  PRIVATE  static
-#define  PUBLIC
-
-#ifdef   __MSDOS__        /* Compiling for MSDOS          */
-#    define MS(x) x
-#    define UX(x)
-#    define IR(x)
-#    define _8086    /* We know we have an 8086 type processor  */
-#if defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__)
-#    define LDATA
-#    define NULL  0L
-#else
-#    define NULL  0
-#endif
-#else  __MSDOS__
-#ifdef  __IRIS4D__        /* Compiling for the SGI Iris 4D    */
-#    define MS(x)
-#    define UX(x) x      /* The Iris is a UNIX machine      */
-#    define IR(x) x
-#    define O_BINARY 0    /* no binary input mode in UNIX open()  */
-#    define MAXFILE  255    /* These are defined in <dir.h>, but  */
-#    define MAXDIR  255    /* on UNIX machines, we just define    */
-#    define MAXPATH  255    /* them all to be the same size      */
-#    define far        /* Near and far do not exist under    */
-#    define near        /* UNIX or the Iris.          */
-#    define NULL ((void *)0)
-#else  __IRIS4D__        /* Assume UNIX compilation        */
-#    define MS(x)
-#    define UX(x) x
-#    define IR(x)
-#    define O_BINARY 0    /* no binary input mode in UNIX open()  */
-#    define MAXFILE  255    /* These are defined in <dir.h>, but  */
-#    define MAXDIR  255    /* on UNIX machines, we just define    */
-#    define MAXPATH  255    /* them all to be the same size      */
-#    define far        /* Near and far do not exist under    */
-#    define near        /* UNIX or the Iris.          */
-#    ifndef NULL
-#      define NULL ((void *)0)
-#    endif
-#endif  __IRIS4D__
-#endif  __MSDOS__
-
-/****************************************************************************
-*
-*  SEG(p)    Evaluates to the segment portion of an 8086 address.
-*  OFF(p)    Evaluates to the offset portion of an 8086 address.
-*  FP(s,o)    Creates a far pointer given a segment offset pair.
-*  PHYS(p)    Evaluates to a long holding a physical address
-*
-****************************************************************************/
-
-#ifdef  _8086
-#    define SEG(p)  ( ((unsigned *)&(void far *)(p))[1] )
-#    define OFF(p)  ( (unsigned)(p) )
-#    define FP(s,o)  ( (void far *)( ((unsigned long)s << 16) +  \
-              (unsigned long)o ))
-#    define PHYS(p)  ( (unsigned long)OFF(p) +            \
-              ((unsigned long)SEG(p) << 4))
-#else
-#    define PHYS(p)   (p)
-#endif  _8086
-
-/****************************************************************************
-*
-*  NUMELE(array)    Evaluates to the array size in elements
-*  LASTELE(array)    Evaluates to a pointer to the last element
-*  INBOUNDS(array,p)  Evaluates to true if p points into the array
-*  RANGE(a,b,c)    Evaluates to true if a <= b <= c
-*  max(a,b)      Evaluates to a or b, whichever is larger
-*  min(a,b)      Evaluates to a or b, whichever is smaller
-*  ABS(a)        Evaluates to the absolute value of a
-*  NBITS(type)      Returns the number of bits in a variable of the
-*            indicated type
-*  MAXINT        Evaluates to the value of the largest signed integer
-*
-****************************************************************************/
-
-#define  NUMELE(a)    (sizeof(a)/sizeof(*(a)))
-#define  LASTELE(a)    ((a) + (NUMELE(a)-1))
-#ifdef  LDATA
-#define  TOOHIGH(a, p)  ((long)PHYS(p) - (long)PHYS(a) > (long)(NUMELE(a)-1))
-#define  TOOLOW(a, p)    ((long)PHYS(p) - (long)PHYS(a) < 0)
-#else
-#define  TOOHIGH(a, p)  ((long)(p) - (long)(a) > (long)(NUMELE(a)-1))
-#define  TOOLOW(a, p)    ((long)(p) - (long)(a) < 0)
-#endif
-#define  INBOUNDS(a, p)  ( ! (TOOHIGH(a, p) || TOOLOW(a, p)) )
-
-#define  _IS(t, x) (((t)1 << (x)) != 0)  /* Evaluates true if the width of */
-                    /* variable of type t is < x.    */
-                    /* The != 0 assures that the      */
-                    /* answer is 1 or 0          */
-
-#define  NBITS(t) (4 * (1 + _IS(t, 4) + _IS(t, 8) + _IS(t, 12) + _IS(t, 16) \
-             + _IS(t, 20) + _IS(t, 24) + _IS(t, 28) + _IS(t, 32)))
-
-#define  MAXINT      (((unsigned)~0) >> 1)
-
-#ifndef  MAX
-#    define MAX(a, b)  ( ((a) > (b)) ? (a) : (b))
-#endif
-#ifndef  MIN
-#    define MIN(a, b) ( ((a) < (b)) ? (a) : (b))
-#endif
-#ifndef  ABS
-#    define ABS(a)  ((a) >= 0 ? (a) : -(a))
-#endif
-
-#define  RANGE(a, b, c)  ( (a) <= (b) && (b) <= (c) )
-
-/* General typedefs  */
-
-#ifndef  __GENDEFS
-#define  __GENDEFS
-typedef  void      *ptr;
-typedef void near    *nearptr;
-typedef  void far    *farptr;
-/*typedef  unsigned char  uchar;
-typedef  unsigned short  ushort;
-typedef  unsigned int  uint;
-typedef  unsigned long  ulong;*/
-typedef  int        bool;
-#endif  __GENDEFS
-
-/* Boolean truth values */
-
-#define  false    0
-#define  true    1
-#define  FALSE    0
-#define  TRUE    1
-#define  NO      0
-#define  YES      1
-
-#endif  /* DEBUG_H */
diff --git a/ext/hyperwave/hg_comm.c b/ext/hyperwave/hg_comm.c
deleted file mode 100644 (file)
index 488d9ce..0000000
+++ /dev/null
@@ -1,5841 +0,0 @@
-/*
-   +----------------------------------------------------------------------+
-   | PHP Version 4                                                        |
-   +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2003 The PHP Group                                |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 3.0 of the PHP license,       |
-   | that is bundled with this package in the file LICENSE, and is        |
-   | available through the world-wide-web at the following url:           |
-   | http://www.php.net/license/3_0.txt.                                  |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@php.net so we can mail you a copy immediately.               |
-   +----------------------------------------------------------------------+
-   | Author: Uwe Steinmann <Uwe.Steinmann@fernuni-hagen.de>               |
-   +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-/* #define HW_DEBUG */
-
-#include <stdlib.h>
-#include "php.h"
-#include "php_globals.h"
-#include "SAPI.h"
-
-#if HYPERWAVE
-
-#include <stdio.h>
-#include <string.h> 
-#include <sys/types.h>
-#ifdef PHP_WIN32
-# include <winsock2.h>
-# define EWOULDBLOCK WSAEWOULDBLOCK
-# define ETIMEDOUT WSAETIMEDOUT
-# define bcopy memcpy
-# define bzero(a, b) memset(a, 0, b)
-#else
-# include <sys/socket.h>
-# include <netinet/in.h>
-# include <netdb.h>
-# include <unistd.h>
-# include <sys/param.h>
-# include <arpa/inet.h>
-#endif
-#include <fcntl.h>
-#include <errno.h>
-#include "hg_comm.h"
-#include "ext/standard/head.h"
-
-/* Defining hw_optimize does optimize the send_objectbyidquery() function.
-   Instead of getting the complete return message including the objectrecords
-   with recv_hg_msg(), only the header of the return message is fetched.
-   The object records itself are fetched as they are needed straight from
-   the socket. This method requires less memory and is twice as fast because
-   reading from the net seems to be a bottleneck which has less impact if
-   the processing of the data is done in parallel.
-*/
-#define hw_optimize
-
-/* Define hw_less_server_stress does reduce the stress on the hw server, by
-   using send_objectbyidquery() instead of send_getobject() multiple times.
-   send_objectbyidquery() gets a bunch of object records with one message.
-   This also reduced the number of lines in the servers log files.
-   Unfortunately this is not faster unless hw_optimize is defined, because
-   getting object records with multiple send_getobject() is already optimized.
-   First all request messages for each object are send and the the answers
-   are read. This gives the server the possibility to answer request already
-   while more request are comming in.
-*/
-#define hw_less_server_stress
-
-static int set_nonblocking(int fd);
-/* static int set_blocking(int fd); */
-
-static int hg_read_exact(int sockfd, char *buf, int size);
-/* static int hg_read(int sockfd, char *buf, int size); */
-static int hg_write(int sockfd, char *buf, int size);
-
-static int   send_hg_msg(int sockfd, hg_msg *msg, int length);
-static void  build_msg_header(hg_msg *msg, int length, int version_msgid, int msg_type);
-static char *build_msg_int(char *buf, int val);
-static char *build_msg_str(char *buf, char *str);
-static int   swap(int val);
-
-
-int version      = HW_VERSION;
-/* F_DISTRIBUTED has the effect that all object ids are
-   virtual. This means whenever an object is requested a
-   new id is generated for this session. Wavemaster and
-   Harmony set this flag. How do I know? tcpdump tells
-   a lot if  the output is investigated. The bit is also
-   need to allow access on other server through the local
-   server. The hw_mapid() function won't work unless you
-   set F_DISTRIBUTED */
-/* int version      = HW_VERSION | F_DISTRIBUTED; */
-/* int version   = HW_VERSION | F_DISTRIBUTED | F_COMPRESSED; */
-static int msgid        =  1;
-static int sock_flags   = -1;
-static int non_blocking =  0;
-static int swap_on = 0;
-static int rtimeout = 40;
-static int wtimeout = 40;
-static int lowerror = 0;
-
-/***********************************************************************
-* Function fnInsStr()                                                  *
-*                                                                      *
-* Insert string in string at position. The old string will be freed    *
-* with efree!!! The new string is allocated with malloc.               *
-* Parameter: string *str: string in which insstr is to be inserted     *
-*            int pos: Position where string is to inserted (0=first)   *
-*            string *insstr: string to be inserted                     *
-* Return: pointer to new string or NULL. If NULL is returned the       *
-*         memory for the old string has not been freed.                *
-***********************************************************************/
-char *fnInsStr(char *str, int pos, char *insstr)
-{
-       char *newstr, *ptr;
-
-       if((str == NULL) || (insstr == NULL))
-               return NULL;
-       if(pos > (int)strlen(str))
-               return NULL;
-
-       if(insstr[0] == '\0')
-               return str;
-
-       if(NULL == (newstr = malloc(strlen(str) + strlen(insstr) + 1))) {
-               lowerror = LE_MALLOC;
-               return NULL;
-               }
-
-       ptr = newstr;
-       memcpy(newstr, str, pos);
-       ptr += pos;
-       strcpy(ptr, insstr);
-       ptr += strlen(insstr);
-       strcpy(ptr, str+pos);
-
-       free(str);
-       return newstr;
-}
-
-/***********************************************************************
-* Function fnAddAnchor()                                               *
-*                                                                      *
-* Inserts new anchor into anchor list.                                 *
-* Parameter: DLIST pList: Anchor list                                  *
-*            int objectID: object ID of Anchor                         *
-*            int start: start position                                 *
-*            int end: end position                                     *
-* Return: Pointer to new anchor, NULL if error                         *
-***********************************************************************/
-#ifdef newlist
-ANCHOR *fnAddAnchor(zend_llist *pAnchorList, 
-                    int objectID,
-                    int start, int end)
-#else
-ANCHOR *fnAddAnchor(DLIST *pAnchorList, 
-                    int objectID,
-                    int start, int end)
-#endif
-{
-       ANCHOR *cur_ptr;
-
-#ifdef newlist
-       ANCHOR **ptr;
-       if(NULL == (cur_ptr = (ANCHOR *) emalloc(sizeof(ANCHOR))))
-               return NULL;
-#else
-       if((cur_ptr = (ANCHOR *) dlst_newnode(sizeof(ANCHOR))) == NULL) {
-               return NULL;
-       }
-#endif
-
-       memset(cur_ptr, 0, sizeof(ANCHOR));
-       cur_ptr->start = start;
-       cur_ptr->end = end;
-       cur_ptr->id = objectID;
-       cur_ptr->destdocname = NULL;
-       cur_ptr->nameanchor = NULL;
-       cur_ptr->link = NULL;
-       cur_ptr->tagattr = NULL;
-       cur_ptr->htmlattr = NULL;
-       cur_ptr->codebase = NULL;
-       cur_ptr->code = NULL;
-       cur_ptr->keyword = NULL;
-       cur_ptr->fragment = NULL;
-
-#ifdef newlist
-       zend_llist_prepend_element(pAnchorList, &cur_ptr);
-       ptr = (ANCHOR **) zend_llist_get_first(pAnchorList);
-#else
-       dlst_insertafter(pAnchorList, cur_ptr, PHP_DLST_HEAD(pAnchorList));
-#endif
-
-       return(cur_ptr);
-}
-
-/***********************************************************************
-* Function fnDeleteAnchor()                                            *
-*                                                                      *
-* Inserts new anchor into anchor list.                                 *
-* Parameter: ptr: pointer to node                                      *
-* Return: void                                                         *
-***********************************************************************/
-#ifdef newlist
-void fnDeleteAnchor(void *ptr1)
-#else
-void fnDeleteAnchor(ANCHOR *ptr)
-#endif
-{
-#ifdef newlist
-       ANCHOR **ptr2, *ptr;
-       ptr2 = (ANCHOR **) ptr1;
-       ptr = *ptr2;
-#endif
-
-       if(ptr->destdocname) efree(ptr->destdocname);
-       if(ptr->nameanchor) efree(ptr->nameanchor);
-       if(ptr->link) efree(ptr->link);
-       if(ptr->tagattr) efree(ptr->tagattr);
-       if(ptr->htmlattr) efree(ptr->htmlattr);
-       if(ptr->codebase) efree(ptr->codebase);
-       if(ptr->code) efree(ptr->code);
-       if(ptr->keyword) efree(ptr->keyword);
-       if(ptr->fragment) efree(ptr->fragment);
-
-#ifdef newlist
-       efree(ptr);
-#else
-       dlst_freenode(ptr);
-#endif
-}
-
-/***********************************************************************
-* Function fnListAnchor()                                              *
-*                                                                      *
-* Lists all anchors in  anchor list.                                   *
-* Parameter: ptr: pointer to list                                      *
-* Return: void                                                         *
-***********************************************************************/
-#ifdef newlist
-void fnListAnchor(zend_llist *pAnchorList)
-#else
-void fnListAnchor(DLIST *pAnchorList)
-#endif
-{
-#ifdef newlist
-       ANCHOR *cur_ptr, **ptr;
-       ptr = (ANCHOR **) zend_llist_get_last(pAnchorList);
-       if(ptr)
-               cur_ptr = *ptr;
-       while(ptr) {
-               fprintf(stderr, "0x%X->0x%X ", (int) ptr, (int) cur_ptr);
-#else
-       ANCHOR *cur_ptr;
-       cur_ptr = (ANCHOR *) dlst_last(pAnchorList);
-       while(cur_ptr) {
-               fprintf(stderr, "0x%X ", (int) cur_ptr);
-#endif
-
-               fprintf(stderr, "%d, %d, %s, %s, %s, %s %s\n", cur_ptr->start,
-                                                          cur_ptr->end,
-                                                          cur_ptr->tanchor == 1 ? "src" : "dest",
-                                                          cur_ptr->destdocname,
-                                                          cur_ptr->nameanchor,
-                                                          cur_ptr->link,
-                                                          cur_ptr->tagattr);
-#ifdef newlist
-               ptr = (ANCHOR **) zend_llist_get_prev(pAnchorList);
-               if(ptr)
-                       cur_ptr = *ptr;
-#else
-               cur_ptr = (ANCHOR *) dlst_prev(cur_ptr);
-#endif
-       }
-}
-
-/***********************************************************************
-* Function fnCmpAnchors()                                              *
-*                                                                      *
-* Compares to Anchors by its start position                            *
-* Parameter: ANCHOR a1: First Anchor                                   *
-*            ANCHOR a2: Second Anchor                                  *
-* Return: As strcmp                                                    *
-***********************************************************************/
-#ifdef newlist
-int fnCmpAnchors(const void *e1, const void *e2 TSRMLS_DC)
-{
-       ANCHOR *a1, **aa1, *a2, **aa2;
-       zend_llist_element **ee1, **ee2;
-       ee1 = (zend_llist_element **) e1;
-       ee2 = (zend_llist_element **) e2;
-       aa1 = (ANCHOR **) (*ee1)->data;
-       aa2 = (ANCHOR **) (*ee2)->data;
-       a1 = *aa1;
-       a2 = *aa2;
-#else
-int fnCmpAnchors(ANCHOR *a1, ANCHOR *a2 TSRMLS_DC)
-{
-#endif
-       if(a1->start < a2->start)
-               return -1;
-       if(a1->start == a2->start) {
-               /* It's importent to check this case as well, because a link with
-               a bigger end has to be inserted first.
-               */
-               if(a1->end < a2->end)
-                       return -1;
-               /* If both start and end are equal (yes, it is possible)
-                  we will Src Anchor before a Dest anchor. There has been
-                  a case where an IMG was surrounded by a NAME which was
-                  surrounded by a HREF. In such a case the HREF doesn't
-                  work.
-               */
-               if(a1->end == a2->end) {
-                       if(a1->tanchor > a2->tanchor)
-                               return -1;
-               }
-       }
-
-       return 1;
-}
-
-/***********************************************************************
-* Function fnCreateAnchorList()                                        *
-* Uses either docofanchorrec or reldestrec to create a list of anchors *
-* depending on anchormode                                              *
-*                                                                      *
-* Returns a list of Anchors converted from an object record            *
-* Parameter: int objectID: the object for which the list is created    *
-*            char **anchors: object records of anchors                 *
-*            char **docofanchorrec: Name of destination absolut        *
-*            char **reldestrec: Name of destination relativ to current *
-*                               object                                 *
-*            int ancount: number of anchors                            *
-*            int anchormode: 0 = use absolut dest, else rel. dest      *
-* Return: List of Anchors, NULL if error                               *
-***********************************************************************/
-#ifdef newlist
-zend_llist *fnCreateAnchorList(hw_objectID objID, char **anchors, char **docofanchorrec, char **reldestrec, int ancount, int anchormode)
-#else
-DLIST *fnCreateAnchorList(hw_objectID objID, char **anchors, char **docofanchorrec, char **reldestrec, int ancount, int anchormode)
-#endif
-{
-       int start, end, i, destid, anchordestid, objectID;
-       ANCHOR *cur_ptr = NULL;
-#ifdef newlist
-       zend_llist *pAnchorList;
-       pAnchorList = (zend_llist *) emalloc(sizeof(zend_llist));
-       zend_llist_init(pAnchorList, sizeof(char *), fnDeleteAnchor, 0);
-#else
-       DLIST *pAnchorList = dlst_init();
-#endif
-
-       for(i=ancount-1; i>=0; i--) {
-               char *object = NULL;
-               char *docofanchorptr = NULL;
-               char *reldestptr = NULL;
-               char *str, *str1, link[200];
-
-               if(NULL != anchors[i]) {
-                       object = anchors[i];
-                       docofanchorptr = docofanchorrec[i];
-                       if(reldestrec) /* FIXME reldestrec may only be NULL if anchormode != 0 */
-                               reldestptr = reldestrec[i];
-       
-                       /* Determine Position. Doesn't matter if Src or Dest
-                          The Position field should always be there. Though there
-                          are case in which the position has no meaning, e.g. if
-                          a document is annotated and the annotation text doesn't
-                          contain a link of type annotation,
-                          In such a case the Position has the value 'invisible' */
-                       str = strstr(object, "Position");
-                       str += 9;
-                       if(((int) str != 9) && (0 != strncmp(str, "invisible", 9))) {
-                               sscanf(str, "0x%X 0x%X", &start, &end);
-               
-                               /* Determine ObjectID */
-                               objectID = 0;
-                               if(NULL != (str = strstr(object, "ObjectID"))) {
-                                       str += 9;
-                                       sscanf(str, "0x%X", &objectID);
-                               }
-               
-                               cur_ptr = fnAddAnchor(pAnchorList, objectID, start, end);
-               
-                               /* Determine Type of Anchor */
-                               str = strstr(object, "TAnchor");
-                               str += 8;
-                               if(*str == 'S') {
-                                       char destdocname[200];
-                                       char nameanchor[200];
-                                       cur_ptr->tanchor = 1;
-               
-                                       cur_ptr->destdocname = NULL;
-                                       if(NULL != (str = strstr(object, "Dest"))) {
-                                               char *tempptr;
-       
-                                               /* No need to care about the value of Dest, because we take the info
-                                                  from docofanchorptr.
-                                                  Since the anchor has a destination there are two possibilities.
-                                                  1. The destination is an anchor or
-                                                  2. or the destination is a document already.
-                                                  In both cases docofanchorptr has the proper info because GETDOCBYANCHOR
-                                                  is such a nice message.
-                                               */
-                                               switch(anchormode) {
-                                                       case 0:
-                                                               tempptr = docofanchorptr;
-                                                               break;
-                                                       default:
-                                                               tempptr = reldestptr;
-                                               }
-                                               if(NULL != tempptr) {
-                                                       destid = 0;
-                                                       if(NULL != (str = strstr(tempptr, "ObjectID="))) {
-                                                               str += 9;
-                                                               sscanf(str, "0x%X", &destid);
-                                                       }
-                                                       /* This is basically for NAME tags. There is no need
-                                                          to add the destname if it is the document itself.
-                                                       */
-/*                                                     if(destid == objID) {
-                                                               cur_ptr->destdocname = NULL;
-                                                       } else { */
-                                                               /* It's always nice to deal with names, so let's first check
-                                                                       for a name. If there is none we take the ObjectID.
-                                                               */
-                                                               if(NULL != (str = strstr(tempptr, "Name="))) {
-                                                                       str += 5;
-                                                               } else if(NULL != (str = strstr(tempptr, "ObjectID="))) {
-                                                                       str += 9;
-                                                               }
-                                                               if(sscanf(str, "%s\n", destdocname)) {
-                                                                       cur_ptr->destdocname = estrdup(destdocname);
-                                                               }
-/*                                                     } */
-                                               }
-                                       }
-               
-                                       /* Get the Id of the anchor destination and the document id that belongs
-                                          to that anchor. We need that soon in order to determine if the anchor
-                                          points to a document or a dest anchor in a document.
-                                       */
-                                       anchordestid = 0;
-                                       if(NULL != (str = strstr(object, "Dest="))) {
-                                               str += 5;
-                                               sscanf(str, "0x%X", &anchordestid);
-                                       }
-                                       
-                                       /* if anchordestid != destid then the destination is an anchor in a document whose
-                                          name (objectID) is already in destdocname. We will have to extend the link
-                                          by '#...'
-                                       */
-                                       cur_ptr->nameanchor = NULL;
-                                       if(anchordestid != destid) {
-                                               if(NULL != (str = strstr(object, "Dest="))) {
-                                                       str += 5;
-                                                       if(sscanf(str, "%s\n", nameanchor))
-                                                               cur_ptr->nameanchor = estrdup(nameanchor);
-                                               }
-                                       }
-               
-                                       if(!cur_ptr->destdocname) {
-                                               cur_ptr->link = NULL;
-                                               if(NULL != (str = strstr(object, "Hint=URL:"))) {
-                                                       str += 9;
-                                                       if(sscanf(str, "%s\n", link))
-                                                               cur_ptr->link = estrdup(link);
-                                               } else if(NULL != (str = strstr(object, "Hint="))) {
-                                                       str += 5;
-                                                       if(sscanf(str, "%s\n", link))
-                                                               cur_ptr->link = estrdup(link);
-                                               }
-                                       }
-               
-                                       cur_ptr->fragment = NULL;
-                                       if(NULL != (str = strstr(object, "Fragment="))) {
-                                               str += 9;
-                                               if(sscanf(str, "%s\n", link))
-                                                       cur_ptr->fragment = estrdup(link);
-                                       }
-               
-                                       {
-                                       char *htmlattr, *str2;
-                                       int offset;
-                                       str1 = object;
-                                       htmlattr = emalloc(strlen(object)); /* alloc mem big enough for htmlattr */
-                                       htmlattr[0] = '\0';
-                                       offset = 0;
-                                       while(NULL != (str = strstr(str1, "HtmlAttr="))) {
-                                               str += 9;
-                                               str1 = str;
-                                               while((*str1 != '\n') && (*str1 != '\0'))
-                                                       str1++;
-                                               /* Find the '=' in the HTML attr and make sure it is part of the
-                                                  attr and not somewhere in the objrec. */
-                                               if((NULL != (str2 = strchr(str, '='))) && (str2 < str1)) {
-                                                       str2++;
-                                                       strncpy(&htmlattr[offset], str, str2 - str);
-                                                       offset = offset + (str2 - str);
-                                                       htmlattr[offset++] = '"';
-                                                       strncpy(&htmlattr[offset], str2, str1 - str2);
-                                                       offset = offset + (str1 - str2);
-                                                       htmlattr[offset++] = '"';
-                                                       htmlattr[offset++] = ' ';
-                                                       htmlattr[offset] = '\0';
-                                               }
-                                       }
-                                       if(offset){
-                                               /* remove last space */
-                                               htmlattr[offset-1] = '\0';
-                                               cur_ptr->htmlattr = estrdup(htmlattr);
-                                       }
-                                       efree(htmlattr);
-                                       }
-               
-                                       if(NULL != (str = strstr(object, "LinkType="))) {
-                                               str += 9;
-                                               if(strncmp(str, "background", 10) == 0)
-                                                       cur_ptr->linktype=HW_BACKGROUND_LINK;
-                                               else
-                                               if(strncmp(str, "intagnodel", 10) == 0) { /* New type introduced by Uwe Steinmann 16.03.2001 */
-                                                       cur_ptr->linktype=HW_INTAGNODEL_LINK;
-                                                       cur_ptr->tagattr = NULL;
-                                                       if(NULL != (str = strstr(object, "TagAttr="))) {
-                                                               str += 8;
-                                                               str1 = str;
-                                                               while((*str1 != '\n') && (*str1 != '\0'))
-                                                                       str1++;
-                                                               cur_ptr->tagattr = emalloc(str1 - str + 1);
-                                                               memcpy(cur_ptr->tagattr, str, str1 - str);
-                                                               cur_ptr->tagattr[str1 - str] = '\0';
-                                                       }
-                                               } else
-                                               if(strncmp(str, "intag", 5) == 0) {
-                                                       cur_ptr->linktype=HW_INTAG_LINK;
-                                                       cur_ptr->tagattr = NULL;
-                                                       if(NULL != (str = strstr(object, "TagAttr="))) {
-                                                               str += 8;
-                                                               str1 = str;
-                                                               while((*str1 != '\n') && (*str1 != '\0'))
-                                                                       str1++;
-                                                               cur_ptr->tagattr = emalloc(str1 - str + 1);
-                                                               memcpy(cur_ptr->tagattr, str, str1 - str);
-                                                               cur_ptr->tagattr[str1 - str] = '\0';
-                                                       }
-                                               } else
-                                               if(strncmp(str, "applet", 6) == 0) {
-                                                       cur_ptr->linktype=HW_APPLET_LINK;
-                                                       cur_ptr->codebase = NULL;
-                                                       if(NULL != (str = strstr(object, "CodeBase="))) {
-                                                               str += 9;
-                                                               str1 = str;
-                                                               while((*str1 != '\n') && (*str1 != '\0'))
-                                                                       str1++;
-                                                               cur_ptr->codebase = emalloc(str1 - str + 1);
-                                                               memcpy(cur_ptr->codebase, str, str1 - str);
-                                                               cur_ptr->codebase[str1 - str] = '\0';
-                                                       }
-                                                       cur_ptr->code = NULL;
-                                                       if(NULL != (str = strstr(object, "Code="))) {
-                                                               str += 5;
-                                                               str1 = str;
-                                                               while((*str1 != '\n') && (*str1 != '\0'))
-                                                                       str1++;
-                                                               cur_ptr->code = emalloc(str1 - str + 1);
-                                                               memcpy(cur_ptr->code, str, str1 - str);
-                                                               cur_ptr->code[str1 - str] = '\0';
-                                                       }
-                                               } else
-                                                       cur_ptr->linktype=HW_DEFAULT_LINK;
-                                       } else
-                                               cur_ptr->linktype=HW_DEFAULT_LINK;
-               
-                               } else { /* Destination Anchor */
-                                       char nameanchor[200];
-               
-                                       cur_ptr->tanchor = 2;
-                                       cur_ptr->link = NULL;
-               
-                                       /* Here is the only additional info for the name attribute */
-                                       cur_ptr->nameanchor = NULL;
-                                       if(NULL != (str = strstr(object, "ObjectID="))) {
-                                               str += 9;
-                                               if(sscanf(str, "%s\n", nameanchor))
-                                                       cur_ptr->nameanchor = estrdup(nameanchor);
-                                       }
-               
-                                       cur_ptr->keyword = NULL;
-                                       if(NULL != (str = strstr(object, "Keyword="))) {
-                                               str += 8;
-                                               if(sscanf(str, "%s\n", nameanchor))
-                                                       cur_ptr->keyword = estrdup(nameanchor);
-                                       }
-               
-                               }
-               
-                       }
-                       /* free memory even if it is an invisible anchor */
-                       efree(anchors[i]);
-                       if(docofanchorrec[i]) efree(docofanchorrec[i]);
-                       if(reldestrec)
-                               if(reldestrec[i]) efree(reldestrec[i]);
-               }
-       }
-       return pAnchorList;
-}
-
-/***********************************************************************
-* Function fnInsAnchorsIntoText()                                      *
-*                                                                      *
-* Returns the text document with all anchors inserted form list        *
-* Parameter: char *text: text without anchors                          *
-*            DList *pAnchorList: list of anchors                       *
-* Return: Text with anchors                                            *
-***********************************************************************/
-#define BUFFERLEN 200
-#ifdef newlist
-char *fnInsAnchorsIntoText(char *text, zend_llist *pAnchorList, char **bodytag, char **urlprefix) {
-       ANCHOR **ptr;
-#else
-char *fnInsAnchorsIntoText(char *text, DLIST *pAnchorList, char **bodytag, char **urlprefix) {
-#endif
-       ANCHOR *cur_ptr;
-       char bgstr[BUFFERLEN], istr[BUFFERLEN];
-       char **scriptname;
-       char *newtext;
-       int offset = 0;
-       int laststart=0;
-       char emptystring[BUFFERLEN];
-       int i;
-       TSRMLS_FETCH();
-       
-       emptystring[0] = '\0';
-
-/* The following is very tricky and depends on how rewriting is setup on your webserver.
-   If you skip the scriptname in the url you will have to map each hyperwave name
-   to http://<hwname>. This may not always be a good idea. The best solution is
-   probably to provide a prefix for such
-   a case which is an optional parameter to hw_gettext() or hw_pipedocument().
-   FIXME: Currently, the variable SCRIPT_NAME is empty thouht SCRIPT_URL is
-   not. In our case this is OK, since as mentioned above it is better to have no
-   SCRIPT_NAME than to have if rewriting is on.
-*/
-       if(urlprefix) {
-               scriptname = urlprefix;
-       } else {
-               zval **script_name;
-               scriptname = emalloc(5*sizeof(char *));
-               if (zend_hash_find(&EG(symbol_table), "SCRIPT_NAME", sizeof("SCRIPT_NAME"), (void **) &script_name)==FAILURE)
-                       for(i=0; i<5; i++)
-                               scriptname[i] = (char *) &emptystring;
-               else {
-                       convert_to_string_ex(script_name);
-                       for(i=0; i<5; i++)
-                               scriptname[i] = Z_STRVAL_PP(script_name);
-               }
-
-#if 0
-#if APACHE
-               {
-               int j;
-               array_header *arr = table_elts(((request_rec *) SG(server_context))->subprocess_env);
-               table_entry *elts = (table_entry *)arr->elts;
-
-               for (j=0; j < arr->nelts; j++) {
-                       if((0 == strcmp(elts[j].key, "SCRIPT_NAME")) ||
-                          (0 == strcmp(elts[j].key, "SCRIPT_URL")))
-                       break;
-               }
-               scriptname = elts[j].val;
-               }
-#else
-               scriptname = getenv("SCRIPT_FILENAME");
-#endif
-#endif
-       }
-
-       newtext = text;
-       bgstr[0] = '\0';
-#ifdef newlist
-       zend_llist_sort(pAnchorList, (llist_compare_func_t) fnCmpAnchors TSRMLS_CC);
-       ptr = (ANCHOR **) zend_llist_get_last(pAnchorList);
-       if(ptr)
-               cur_ptr = *ptr;
-       while(NULL != ptr) {
-#else
-       dlst_mergesort(pAnchorList, fnCmpAnchors);
-       cur_ptr = (ANCHOR *) dlst_last(pAnchorList);
-       while(NULL != cur_ptr) {
-#endif
-
-               istr[0] = '\0';
-               if(cur_ptr->tanchor == 1) { /* Src Anchor */
-                       if(laststart >= cur_ptr->end)
-                               offset = 0;
-                       if((cur_ptr->link != NULL) && (cur_ptr->link[0] != '\0')) {
-                               /* The link is only set if the Link points to an external document */
-                               switch(cur_ptr->linktype) {
-                                       case HW_BACKGROUND_LINK:
-                                               snprintf(istr, BUFFERLEN, " background='%s'", cur_ptr->link);
-                                               break;
-                                       case HW_INTAG_LINK:
-                                               snprintf(istr, BUFFERLEN, " %s='%s'", cur_ptr->tagattr, cur_ptr->link);
-                                               offset -= 4; /* because there is no closing tag </A> */
-/*                                             laststart = cur_ptr->start; */
-                                               break;
-                                       case HW_INTAGNODEL_LINK:
-                                               snprintf(istr, BUFFERLEN, "%s", cur_ptr->link);
-                                               offset -= 4; /* because there is no closing tag </A> */
-/*                                             laststart = cur_ptr->start; */
-                                               break;
-                                       case HW_APPLET_LINK:
-                                               if(cur_ptr->codebase)
-                                                 snprintf(istr, BUFFERLEN, " CODEBASE='%s' CODE='%s'", cur_ptr->codebase, cur_ptr->code);
-                                               else
-                                                 snprintf(istr, BUFFERLEN, " CODEBASE='/' CODE='%s'", cur_ptr->code);
-                                               break;
-                                       default:
-                                               newtext = fnInsStr(newtext, cur_ptr->end+offset, "</A>");
-                                               if(cur_ptr->fragment)
-                                                       snprintf(istr, BUFFERLEN, "<A HREF='%s#%s'", cur_ptr->link, cur_ptr->fragment);
-                                               else
-                                                       snprintf(istr, BUFFERLEN, "<A HREF='%s'", cur_ptr->link);
-                                               if(cur_ptr->htmlattr) {
-                                                       strncat(istr, " ", BUFFERLEN - 1 - strlen(istr));
-                                                       strncat(istr, cur_ptr->htmlattr, BUFFERLEN - 1 - strlen(istr));
-                                               }
-                                               strncat(istr, ">", BUFFERLEN - 1 - strlen(istr));
-                               }
-                       } else {
-                               switch(cur_ptr->linktype) {
-                                       case HW_BACKGROUND_LINK:
-                                               if(NULL != cur_ptr->destdocname) {
-                                                       snprintf(istr, BUFFERLEN, " background='%s/%s'", scriptname[HW_BACKGROUND_LINK], cur_ptr->destdocname);
-                                               } else
-                                                       istr[0] = '\0';
-                                               break;
-                                       case HW_INTAG_LINK:
-                                               if(cur_ptr->fragment)
-                                                       snprintf(istr, BUFFERLEN, " %s='#%s'", cur_ptr->tagattr, cur_ptr->fragment);
-                                               else
-                                                       snprintf(istr, BUFFERLEN, " %s='%s/%s'", cur_ptr->tagattr, scriptname[HW_INTAG_LINK], cur_ptr->destdocname); 
-                                               offset -= 4; /* because there is no closing tag </A> */
-                                               break;
-                                       case HW_INTAGNODEL_LINK:
-                                               snprintf(istr, BUFFERLEN, "%s", cur_ptr->destdocname);
-                                               offset -= 4; /* because there is no closing tag </A> */
-                                               break;
-                                       case HW_APPLET_LINK:
-                                               if(cur_ptr->codebase)
-/*                                               snprintf(istr, BUFFERLEN, " CODEBASE='%s%s' CODE='%s'", scriptname == NULL ? "" : scriptname, cur_ptr->codebase, cur_ptr->code); */
-                                                 snprintf(istr, BUFFERLEN, " CODEBASE='%s%s' CODE='%s'", scriptname[HW_APPLET_LINK], cur_ptr->codebase, cur_ptr->code); 
-                                               else
-                                                 snprintf(istr, BUFFERLEN, " CODEBASE='/' CODE='%s'", cur_ptr->code);
-                                               break;
-                                       default:
-                                               newtext = fnInsStr(newtext, cur_ptr->end+offset, "</A>");
-
-                                               if(cur_ptr->nameanchor)
-                                                       snprintf(istr, BUFFERLEN, "<A HREF='%s/%s#%s'", scriptname[HW_DEFAULT_LINK], cur_ptr->destdocname, cur_ptr->nameanchor);
-                                               else if(cur_ptr->fragment)
-                                                       snprintf(istr, BUFFERLEN, "<A HREF=\"%s/%s#%s\"", scriptname[HW_DEFAULT_LINK], cur_ptr->destdocname, cur_ptr->fragment);
-                                               else
-                                                       snprintf(istr, BUFFERLEN, "<A HREF='%s/%s'", scriptname[HW_DEFAULT_LINK], cur_ptr->destdocname);
-
-                                               if(cur_ptr->htmlattr) {
-                                                       strncat(istr, " ", BUFFERLEN - 1 - strlen(istr));
-                                                       strncat(istr, cur_ptr->htmlattr, BUFFERLEN - 1 - strlen(istr));
-                                               }
-                                               strncat(istr, ">", BUFFERLEN - 1 - strlen(istr));
-                               }
-                       }
-               } else {
-                       if(laststart >= cur_ptr->end)
-                               offset = 0;
-                       newtext = fnInsStr(newtext, cur_ptr->end+offset, "</a>");
-
-                       /* If we have a keyword, we assume we had a fragment which has been used
-                          instead of the destdocname
-                       */
-                       if(cur_ptr->keyword)
-                               snprintf(istr, BUFFERLEN, "<A NAME='%s'>", cur_ptr->keyword);
-                       else if(cur_ptr->nameanchor)
-                               snprintf(istr, BUFFERLEN, "<A NAME='%s'>", cur_ptr->nameanchor);
-               }
-               newtext = fnInsStr(newtext, cur_ptr->start, istr);
-               /* In case there are several TAGS nested, we accumulate the offset
-                  You wonder what the 4 means? It's the length of </A> */
-               offset += strlen(istr) + 4;
-               laststart = cur_ptr->start;
-#ifdef newlist
-               ptr = (ANCHOR **) zend_llist_get_prev(pAnchorList);
-               if(ptr)
-                       cur_ptr = *ptr;
-#else
-               cur_ptr = (ANCHOR *) dlst_prev(cur_ptr);
-#endif
-       }
-       snprintf(istr, BUFFERLEN, "<BODY %s>", bgstr);
-       *bodytag = estrdup(istr);
-/*     if(scriptname != urlprefix) efree(scriptname); */
-       if(scriptname != NULL) efree(scriptname);
-       return(newtext);
-}
-#undef BUFFERLEN
-       
-/***********************************************************************
-* Function fnAttributeValue()                                          *
-*                                                                      *
-* Returns the value of an attribute                                    *
-* Parameter: char *object: object record                               *
-*            char *attrname: attribute name                            *
-* Return: char*: attribute value, NULL if name not found               *
-***********************************************************************/
-char *fnAttributeValue(char *object, char *attrname)
-{
-       char *str, *str1, *attrvalue;
-       int len;
-
-       str = strstr(object, attrname);
-       if(NULL == str)
-               return(NULL);
-       str += strlen(attrname);
-       str++;
-       str1 = str;
-       while((*str1 != '\0') && (*str1 != '\n'))
-               str1++;
-       len = str1 - str;
-       if(NULL == (attrvalue = emalloc(len+1))) {
-               lowerror = LE_MALLOC;
-               return NULL;
-               }
-       memcpy(attrvalue, str, len);
-       attrvalue[len] = '\0';
-       return(attrvalue);
-}
-
-/***********************************************************************
-* Function fnAttributeCompare()                                        *
-*                                                                      *
-* Checks if an attribute in an objrec has a certain value              *
-* Parameter: char *object: object record                               *
-*            char *attrname: attribute name                            *
-*            char *value: value of attribute                           *
-* Return: char*: as strcmp                                             *
-***********************************************************************/
-int fnAttributeCompare(char *object, char *attrname, char *value)
-{
-       char *str, *str1;
-       int len;
-
-       if((NULL == object) || (NULL == attrname) || (NULL == value))
-               return -2;
-
-       /* Find the attribute Name and make sure it is followed by
-          a '=' sign and preceded by a '\n';
-       */
-       str = strstr(object, attrname);
-       if((NULL == str) ||
-          (str[strlen(attrname)] != '=') ||
-          (str[-1] != '\n')) {
-               return(-2);
-       }
-       str += strlen(attrname); /* skip the attribute name */
-       str++; /* skip the equal sign */
-
-       /* Search for end of attribute value */
-       str1 = str;
-       while((*str1 != '\0') && (*str1 != '\n'))
-               str1++;
-       len = str1 - str;
-       return(strncmp(str, value, len));
-}
-
-/*********************************************************************
-* Function fnCOpenDataCon()                                          *
-*                                                                    *
-* Opens data connection on client side. This function is called      *
-* right after the client has requested any data from the server      *
-* Parameter: int sockfd: socket of control connection                *
-*            int *port: port of control und data connection          *
-* Return   : sockfd on success, <0 if error                          *
-*********************************************************************/
-static int fnCOpenDataCon(int sockfd, int *port)
-  {
-  int fd;
-  struct sockaddr_in  serv_addr;
-  int len;
-  int option = 1;
-
-/*  len = sizeof(com_addr);
-  if(getsockname(sockfd, (struct sockaddr *) &com_addr, &len) < 0)
-    {
-    return(-1);
-    }
-
-  *port = htons(com_addr.sin_port); */
-
-  /*
-  ** Open a TCP socket (an Internet stream socket)
-  */
-  if((fd = socket(AF_INET, SOCK_STREAM, 0)) == SOCK_ERR)
-    {
-    return(-1);
-    }
-
-  /*
-  ** Make sure that address may be reused
-  */
-#if defined(SUN) || defined(PHP_WIN32)
-  setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&option, sizeof(option));
-#else
-  setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option));
-#endif
-
-  /*
-  ** Open connection aktiv
-  ** Let bind() select a port number
-  */
-  bzero((char *) &serv_addr, sizeof(serv_addr));
-  if(bind(fd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
-    {
-    return(-1);
-    }
-
-  /*
-  ** Get the port number bind selected
-  */
-  len = sizeof (serv_addr);
-  if(getsockname(fd, (struct sockaddr *)&serv_addr, &len) < 0)
-    {
-    return(-1);
-    }
-  *port = ntohs(serv_addr.sin_port);
-
-  listen(fd, 5);
-
-  return(fd);
-  }
-
-/*======================================================================
- *
- *  Read/write routines with timeout detection.
- *
- *  Usage: write_to(fd, buffer, n, timeout)
- *          read_to(fd, buffer, n, timeout)
- *
- *  David Chavez
- *  Engineering Services & Software
- *  7841 New Salem Street
- *  San Diego, CA 92126
- *  USA
- *
- *  dec@essw.com
- *
- *====================================================================*/
-#ifdef PHP_WIN32
-#include <time.h>
-#else
-#include <sys/fcntl.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#endif
-#include <errno.h>
-#include <signal.h>
-
-#ifndef PHP_WIN32
-static sigset_t newmask, oldmask, zeromask;
-#endif
-
-static int set_noblock(int fd)
-{
-#ifdef PHP_WIN32
-       u_long argp=1;
-
-       return ioctlsocket (fd, FIONBIO , &argp); 
-#else
-
-       sigemptyset(&zeromask);
-       sigemptyset(&newmask);
-       sigaddset(&newmask, SIGHUP);
-       sigaddset(&newmask, SIGUSR1);
-       sigaddset(&newmask, SIGUSR2);
-       if (sigprocmask(SIG_BLOCK, &newmask, &oldmask) < 0) return -1;
-
-       return fcntl(fd, F_SETFL, O_NONBLOCK | O_NDELAY /* | FNBIO*/);
-#endif
-}
-
-int write_to(int fd, void *buffer, int n, int timeout)
-{
-       int nrem, nw=0;
-       char *bptr;
-       int  error=0;
-#if defined(SYSV) || defined(PHP_WIN32)
-       int    width = 20;
-#else
-       int    width = getdtablesize();
-#endif
-       fd_set writefds;
-       struct timeval select_timeout;
-
-       select_timeout.tv_sec = timeout;
-#ifdef PHP_WIN32
-       select_timeout.tv_usec = 0;
-#else /* is this just a typo? */
-       select_timeout.tv_usec = 0.;
-#endif
-
-       /*  Set fd to non-blocking  */
-
-       if (set_noblock(fd) != 0) return -1;
-
-       /*  Write to fd until no more can be written  */
-
-       FD_ZERO(&writefds);
-
-       FD_SET((unsigned int)fd, &writefds);
-       for( nrem = n, bptr = buffer; nrem;)
-               {
-               if(( error = select(width, 
-                                   (fd_set *) 0, 
-                                   &writefds, 
-                                    (fd_set *) 0, 
-                           &select_timeout)) <= 0 && errno != EINTR) break;
-    
-               if(errno != EINTR && ( nw = write(fd, bptr, nrem)) <= 0) {
-                       /*
-                        *  check for error number - and keep trying to
-                        *  write
-                        */
-                       if(errno == EWOULDBLOCK || errno == EAGAIN || errno == EINTR)
-                               {
-                               continue;
-                               }
-                       else
-                               {
-                               error = nw;
-                               break;
-                               }
-               } else {
-                       nrem -= nw;
-                       bptr += nw;
-               }
-       }
-#ifndef PHP_WIN32
-       if (sigprocmask(SIG_SETMASK, &oldmask, NULL) < 0) return -1;
-#endif
-       if( ! error ) {
-               errno = ETIMEDOUT;
-               return(-2);
-       } else if (error < 0) {
-               return(error);
-       } else {
-               return(n);
-       }
-}
-
-int read_to(int fd, char *buffer, int n, int timeout)
-  {
-  int nrem, nread, nr=0;
-  char *bptr;
-  int  error=0;
-
-#if defined(SYSV) || defined(PHP_WIN32)
-  int    width = 20;
-#else
-  int    width = getdtablesize();
-#endif
-  fd_set readfds;
-  struct timeval select_timeout;
-
-  select_timeout.tv_sec = timeout;
-#ifdef PHP_WIN32
-  select_timeout.tv_usec = 0;
-#else
-  select_timeout.tv_usec = 0.;
-#endif
-  
-  /*  Set fd to non-blocking  */
-
-  if (set_noblock(fd) != 0) return -1;
-
-  FD_ZERO(&readfds);
-
-  FD_SET((unsigned int)fd, &readfds);
-  
-  for( nrem = n, bptr = buffer, nread = 0; nrem;)
-    {
-    if(( error = select(width, 
-            &readfds, 
-            (fd_set *) 0, 
-            (fd_set *) 0, 
-            &select_timeout)) <= 0 && errno != EINTR) break;
-    
-    if(errno != EINTR && (nr =  read (fd, bptr, nrem)) < 0)
-      {
-      /*
-       *  check for error number - and keep trying to
-       *  read
-       */
-      if(errno == EWOULDBLOCK || errno == EAGAIN || errno == EINTR)
-        {
-        continue;
-        }
-      else
-        {
-        error = nr;
-        break;
-        }
-      }
-    else if(nr == 0)
-      {
-      break;
-      }
-    else
-      {
-      nread += nr;
-      bptr  += nr;
-      nrem  -= nr;
-      }
-    }
-
-#ifndef PHP_WIN32
-  if (sigprocmask(SIG_SETMASK, &oldmask, NULL) < 0) return -1;
-#endif
-  if( ! error )
-    {
-    errno = ETIMEDOUT;
-    return(-2);
-    }
-  else if ( error < 0) 
-    {
-    return(-1);
-    }
-  else
-    {
-    return(nread);
-    }
-  }
-
-void set_swap(int do_swap)
-{
-     swap_on = do_swap;
-}
-
-/***********************************************************************
-* Function open_hg_connection()                                        *
-*                                                                      *
-***********************************************************************/
-int open_hg_connection(char *server_name, int port)
-{
-       int sockfd;
-       int option = 1;
-       struct sockaddr_in server_addr;
-       struct hostent *hp;
-
-       if ( NULL == server_name )
-               return(-1);
-
-       if ( (hp = gethostbyname(server_name)) == NULL )  {
-               return(-2);
-       }
-
-       bzero((char *)&server_addr, sizeof(server_addr));
-       server_addr.sin_family = AF_INET;
-       if ( port != 0 )
-               server_addr.sin_port = htons(port);
-       else
-               server_addr.sin_port = htons(HG_SERVER_PORT); 
-/*     bcopy(hp->h_addr, (char *) &server_addr.sin_addr, hp->h_length); */
-       server_addr.sin_addr = *(struct in_addr *) hp->h_addr;
-
-       if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) == SOCK_ERR )  {
-               return(-3);
-       }
-
-#if defined(SUN) || defined(PHP_WIN32)
-       setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char *)&option, sizeof(option));
-#else
-       setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option));
-#endif /* SUN */
-
-       if (connect(sockfd, (struct sockaddr *) &server_addr, sizeof(server_addr)) < 0) {
-               HWSOCK_FCLOSE(sockfd);
-               return(-4);
-       } 
-
-#ifndef PHP_WIN32
-       if ( (sock_flags = fcntl(sockfd, F_GETFL, 0)) == -1 )
-#endif
-
-       if ( set_nonblocking(sockfd) == -1 )  {
-               HWSOCK_FCLOSE(sockfd);
-               return(-5);
-       }
-
-       return(sockfd);
-}
-
-
-/***********************************************************************
-* Function initialize_hg_connection()                                  *
-*                                                                      *
-***********************************************************************/
-int initialize_hg_connection(int sockfd, int *do_swap, int *version, char **userdata,  char **server_string, char *username, char *password)
-{
-       char buf, c;
-        char *tmp;
-       hg_msg *ready_msg, *retmsg, msg;
-       int i = 0x01;
-       int length;
-
-       *do_swap = 0;
-       buf = 'T';
-       if ( hg_write(sockfd, &buf, 1) == -1 )  {
-               return(-2);
-       }
-
-       if ( hg_read_exact(sockfd, &buf, 1) == -1 )  {
-               return(-3);
-       }
-       if ( buf == 'F' )  {
-               return(-4);
-       }
-       if ( buf != 'T' )  {
-               return(-5);
-       }
-
-       buf = c = ( *(char *)&i )  ? 'l' : 'B';
-       if ( hg_write(sockfd, &buf, 1) == -1 )  {
-               return(-6);
-       }
-       if ( hg_read_exact(sockfd, &buf, 1) == -1 )  {
-               return(-7);
-       }
-       if ( c != buf )  {
-               swap_on = 1;
-               *do_swap = 1;
-       } else {
-               swap_on = 0;
-               *do_swap = 0;
-       }
-
-       if ( send_ready(sockfd) == -1) {
-               return(-8);
-               }
-
-       /* Receive return from Ready message */
-       if ( (ready_msg = recv_ready(sockfd)) == NULL )  {
-               return(-9);
-       }   
-
-       if ((ready_msg->version_msgid & F_VERSION) < HW_VERSION)
-               return(-8);
-       *version = ready_msg->version_msgid;
-       *server_string = strdup(ready_msg->buf+4);
-       efree(ready_msg->buf);
-       efree(ready_msg);
-
-       /* If we have a username and password then do the identification. */
-       if((NULL != username) && (NULL != password)) {
-               length = HEADER_LENGTH + sizeof(int) + strlen(username) + 1 + strlen(password) + 1;
-
-               build_msg_header(&msg, length, msgid++, IDENTIFY_MESSAGE);
-
-               if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-
-               tmp = build_msg_int(msg.buf, 0);
-               tmp = build_msg_str(tmp, username);
-               tmp = build_msg_str(tmp, password);
-
-               if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-                       efree(msg.buf);
-                       return(-10);
-               }
-               efree(msg.buf);
-       }
-
-       if((NULL != username) && (NULL != password)) {
-               /* Receive return form identify message */
-               retmsg = recv_hg_msg(sockfd);
-               if ( retmsg == NULL )
-                       return(-11);
-
-               *userdata = retmsg->buf;
-               efree(retmsg);
-       }
-
-       return(0);
-}
-
-
-static int set_nonblocking(int fd)
-{
-#ifdef PHP_WIN32
-       unsigned int argp=0;
-
-/*     if ( sock_flags == -1 )
-               getsockopt (fd, SOL_SOCKET, optname, optval, optlen); 
-*/     if(ioctlsocket (fd, FIONBIO , &argp) == -1)
-               return(-1);
-#else
-       if ( sock_flags == -1 )
-               sock_flags = fcntl(fd, F_GETFL, 0);
-       if ( fcntl(fd, F_SETFL, O_NONBLOCK) == -1 )
-               return(-1);
-#endif
-       non_blocking = 1;
-       return(0);
-}
-
-
-/*
-static int set_blocking(int fd)
-{
-#ifdef PHP_WIN32
-       unsigned int argp=1;
-
-       if(ioctlsocket (fd, FIONBIO , &argp) == -1)
-               return(-1);
-#else
-       if ( fcntl(fd, F_SETFL, sock_flags) == -1 )
-               return(-1);
-#endif
-       return(0);
-}
-*/
-
-static int hg_read_exact(int sockfd, char *buf, int size)
-{
-       int len = 0;
-
-       len = read_to(sockfd, (void *) buf, size, rtimeout);
-       if ( len < 0 ) 
-               return -1;
-       return(len);
-}
-
-/*
-static int hg_read(int sockfd, char *buf, int size)
-{
-       int try = 0;
-       int len = 0;
-
-       if ( !non_blocking )
-               set_nonblocking(sockfd);  
-       while ( len == 0 )  {
-               len = recv(sockfd, (void *) buf, size, 0);
-               if ( len == -1 )  {
-                       if ( (errno == EAGAIN) || (errno == EWOULDBLOCK) )  {
-                               if ( ++try > 5 )
-                                       return(-1);
-                               php_sleep(1);
-                       } 
-                       else return(-1);
-               } 
-       }
-       return(len);
-}
-*/
-
-static int hg_write(int sockfd, char *buf, int size)
-{
-       int try = 0;
-       int len = 0;
-
-       if ( !non_blocking )
-               set_nonblocking(sockfd);  
-       while ( size > 0 )  {
-               len = send(sockfd, (void *) buf, size, 0);
-               if ( len == -1 )  {
-                       if ( (errno == EAGAIN) || (errno == EWOULDBLOCK) )  {
-                               if ( ++try > 5 )
-                                       return(-1);
-                               php_sleep(1);
-                       } 
-                       else return(-1);
-               } 
-               else  {
-                       size -= len;
-                       buf  += len;
-                       try   = 0;
-               }
-       }
-       return(0);
-}
-
-hg_msg *recv_hg_msg_head(int sockfd)
-{
-       hg_msg *msg;
-
-       if ( (msg = (hg_msg *)emalloc(sizeof(hg_msg))) == NULL )  {
-               lowerror = LE_MALLOC;
-               return(NULL);
-       }
-
-       if ( hg_read_exact(sockfd, (char *)&(msg->length), 4) == -1 )  {
-               efree(msg);
-               return(NULL);
-       }
-
-       if ( hg_read_exact(sockfd, (char *)&(msg->version_msgid), 4) == -1 )  {
-               efree(msg);
-               return(NULL);
-       }
-
-       if ( hg_read_exact(sockfd, (char *)&(msg->msg_type), 4) == -1 )  {
-               efree(msg);
-               return(NULL);
-       }
-
-#ifdef HW_DEBUG
-       php_printf("<b>   Recv msg: </b>type = %d -- id = %d<br />\n", msg->msg_type, msg->version_msgid);
-#endif
-       return(msg);
-}
-
-
-hg_msg *recv_hg_msg(int sockfd)
-{
-       hg_msg *msg;
-
-       if ( (msg = (hg_msg *)emalloc(sizeof(hg_msg))) == NULL )  {
-/*             php_printf("recv_hg_msg"); */
-               lowerror = LE_MALLOC;
-               return(NULL);
-       }
-
-       if ( hg_read_exact(sockfd, (char *)&(msg->length), 4) == -1 )  {
-/*             php_printf("recv_hg_msg: hg_read (1) returned -1\n"); */
-               efree(msg);
-               return(NULL);
-       }
-
-       if ( hg_read_exact(sockfd, (char *)&(msg->version_msgid), 4) == -1 )  {
-/*             php_printf("recv_hg_msg: hg_read (2) returned -1\n"); */
-               efree(msg);
-               return(NULL);
-       }
-
-       if ( hg_read_exact(sockfd, (char *)&(msg->msg_type), 4) == -1 )  {
-/*             php_printf("recv_hg_msg: hg_read (3) returned -1\n"); */
-               efree(msg);
-               return(NULL);
-       }
-
-       if ( msg->length > HEADER_LENGTH )  {
-               if ( (msg->buf = (char *) emalloc(msg->length-HEADER_LENGTH)) == NULL )  {
-/*                     php_printf("recv_hg_msg"); */
-                       lowerror = LE_MALLOC;
-                       efree(msg);
-                       return(NULL);
-               }
-               if ( hg_read_exact(sockfd, msg->buf, msg->length-HEADER_LENGTH) == -1 )  {
-/*                     php_printf("recv_hg_msg: hg_read (4) returned -1\n"); */
-                       efree(msg->buf);
-                       efree(msg);
-                       return(NULL);
-               }
-       }
-       else
-               msg->buf = NULL;  
-
-#ifdef HW_DEBUG
-       php_printf("<b>   Recv msg: </b>type = %d -- id = %d<br />\n", msg->msg_type, msg->version_msgid);
-#endif
-       return(msg);
-}
-
-
-hg_msg *recv_ready(int sockfd)
-{
-       hg_msg *ready_msg;
-
-       if ( (ready_msg = recv_hg_msg(sockfd)) == NULL )  {
-/*             php_printf("recv_ready: recv_hg_msg returned NULL\n"); */
-               return(NULL);
-       }    
-       if ( ready_msg->msg_type != READY_MESSAGE )  {
-/*             php_printf("recv_ready: recv_hg_msg returned wrong message: %d, %d  \n", ready_msg->length, ready_msg->msg_type); */
-               efree(ready_msg);
-               return(NULL);
-       }
-
-       return(ready_msg);
-}
-
-
-hg_msg *recv_command(int sockfd)
-{
-       hg_msg *comm_msg;
-
-       if ( (comm_msg = recv_hg_msg(sockfd)) == NULL )  {
-/*             fprintf(stderr, "recv_command: recv_hg_msg returned NULL\n"); */
-               return(NULL);
-       }
-       if ( comm_msg->msg_type != COMMAND_MESSAGE )  {
-/*             fprintf(stderr, "recv_command: recv_hg_msg returned wrong message\n"); */
-               return(NULL);
-       }
-
-       return(comm_msg);
-}
-
-int send_dummy(int sockfd, hw_objectID objectID, int msg_id, char **attributes)
-{
-       hg_msg msg, *retmsg;
-       int  length, error;
-       char *tmp;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msg_id++, msg_id);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL )  {
-               *attributes = NULL;
-               return(-1);
-       }
-
-       if(0 == (int) *(retmsg->buf)) {
-               *attributes = estrdup(retmsg->buf+sizeof(int));
-               efree(retmsg->buf);
-               efree(retmsg);
-       } else {
-               error = *((int *) retmsg->buf);
-               *attributes = NULL;
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-
-       return(0);
-}
-
-static int bh_send_deleteobject(int sockfd, hw_objectID objectID) {
-       hg_msg msg;
-       int  length;
-       char *tmp;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, DELETEOBJECT_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-       efree(msg.buf);
-
-       return(msgid-1);
-}
-
-static int uh_send_deleteobject(int sockfd) {
-       hg_msg *retmsg;
-       int  error;
-
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL )  {
-               return(-1);
-       }
-
-       if(NULL == retmsg->buf) {
-               efree(retmsg);
-               return -1;
-       }
-       error = *((int *) retmsg->buf);
-       efree(retmsg->buf);
-       efree(retmsg);
-       return(error);
-}
-
-int send_deleteobject(int sockfd, hw_objectID objectID)
-{
-       if(0 > bh_send_deleteobject(sockfd, objectID))
-               return -1;
-       return(uh_send_deleteobject(sockfd));
-}
-
-static int bh_send_changeobject(int sockfd, hw_objectID objectID, char *mod) {
-       hg_msg msg;
-       int  length;
-       char *tmp;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID) + strlen(mod) + 1;
-
-       build_msg_header(&msg, length, msgid++, CHANGEOBJECT_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-       tmp = build_msg_str(tmp, mod);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-       efree(msg.buf);
-
-       return(msgid-1);
-}
-
-static int uh_send_changeobject(int sockfd) {
-       hg_msg *retmsg;
-       int  error;
-
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL )  {
-               return(-1);
-       }
-
-       error = *((int *) retmsg->buf);
-       efree(retmsg->buf);
-       efree(retmsg);
-       return(error);
-}
-
-int send_changeobject(int sockfd, hw_objectID objectID, char *modification)
-{
-       if(0 > bh_send_changeobject(sockfd, objectID, modification))
-               return -1;
-       return(uh_send_changeobject(sockfd));
-}
-
-int send_groupchangeobject(int sockfd, hw_objectID objectID, char *modification)
-{
-       hw_objectID *childIDs;
-       int count, i, error;
-
-       if(0 == (error = send_lock(sockfd, objectID))) {
-               send_changeobject(sockfd, objectID, modification);
-               send_unlock(sockfd, objectID);
-       }/* else
-               fprintf(stderr, "Could not lock 0x%X (error = %d)\n", objectID, error); */
-
-       if(0 == send_children(sockfd, objectID, &childIDs, &count)) {
-/*             fprintf(stderr, "Changing Children of 0x%X\n", objectID); */
-               for(i=0; i<count; i++)
-                       if(0 > send_groupchangeobject(sockfd, childIDs[i], modification))
-/*                             fprintf(stderr, "Cannot change 0x%X\n", objectID) */;
-               if(childIDs)
-                       efree(childIDs);
-       }/*  else
-               fprintf(stderr, "No Children of 0x%X\n", objectID);  */
-       return(0);
-}
-
-static int bh_send_getobject(int sockfd, hw_objectID objectID) {
-       hg_msg msg;
-       int  length;
-       char *tmp;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, GETOBJECT_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-       efree(msg.buf);
-
-       return(msgid-1);
-}
-
-static int uh_send_getobject(int sockfd, char **attributes) {
-       hg_msg *retmsg;
-       int  error;
-
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL )  {
-               *attributes = NULL;
-               return(-1);
-       }
-
-       if(0 == (int) *(retmsg->buf)) {
-               *attributes = estrdup(retmsg->buf+sizeof(int));
-               efree(retmsg->buf);
-               efree(retmsg);
-       } else {
-               error = *((int *) retmsg->buf);
-               *attributes = NULL;
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-
-       return(0);
-}
-
-int send_getobject(int sockfd, hw_objectID objectID, char **attributes)
-{
-       if(0 > bh_send_getobject(sockfd, objectID))
-               return -1;
-       return(uh_send_getobject(sockfd, attributes));
-}
-
-int send_getandlock(int sockfd, hw_objectID objectID, char **attributes)
-{
-       hg_msg msg, *retmsg;
-       int  length, error;
-       char *tmp;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, GETANDLOCK_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL )  {
-               *attributes = NULL;
-               return(-1);
-       }
-
-       if(0 == (error = (int) *(retmsg->buf))) {
-               *attributes = estrdup(retmsg->buf+sizeof(int));
-       } else {
-               *attributes = NULL;
-       }
-
-       efree(retmsg->buf);
-       efree(retmsg);
-       return error;
-}
-
-int send_lock(int sockfd, hw_objectID objectID)
-{
-       hg_msg msg, *retmsg;
-       int  length, error;
-       char *tmp;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, GETANDLOCK_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL )  {
-               return(-1);
-       }
-
-       error = *((int *) retmsg->buf);
-
-       efree(retmsg->buf);
-       efree(retmsg);
-       return error;
-}
-
-int send_insertobject(int sockfd, char *objrec, char *parms, hw_objectID *objectID)
-{
-       hg_msg msg, *retmsg;
-       int  length, error;
-       char *tmp;
-       int *ptr;
-
-       length = HEADER_LENGTH + strlen(objrec) + 1 + strlen(parms) + 1;
-
-       build_msg_header(&msg, length, msgid++, INSERTOBJECT_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_str(msg.buf, objrec);
-       tmp = build_msg_str(tmp, parms);
-/*fprintf(stderr, "objrec = %s, parms = %s\n", objrec, parms); */
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL )  {
-               *objectID = 0;
-               return(-1);
-       }
-
-       ptr = (int *) retmsg->buf;
-       if(0 == (error = *ptr)) {
-               ptr++;
-               *objectID = *ptr;
-       } else {
-               *objectID = 0;
-       }
-       efree(retmsg->buf);
-       efree(retmsg);
-       return error;
-}
-
-int send_unlock(int sockfd, hw_objectID objectID)
-{
-       hg_msg msg;
-       int  length;
-       char *tmp;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, UNLOCK_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-
-       efree(msg.buf);
-       return 0;
-}
-
-int send_incollections(int sockfd, int retcol, int cobjids, hw_objectID *objectIDs, int ccollids, hw_objectID *collIDs, int *count, hw_objectID **retIDs)
-{
-       hg_msg msg, *retmsg;
-       int  length, error;
-       char *tmp;
-       int *ptr, *ptr1, i;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID) + (cobjids + ccollids) * sizeof(hw_objectID) + 2 * sizeof(int);
-
-       build_msg_header(&msg, length, msgid++, INCOLLECTIONS_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-               lowerror = LE_MALLOC;
-               return(-3);
-       }
-
-       tmp = build_msg_int(msg.buf, retcol);
-       tmp = build_msg_int(tmp, cobjids);
-       for(i=0; i<cobjids; i++)
-               tmp = build_msg_int(tmp, objectIDs[i]);
-       tmp = build_msg_int(tmp, ccollids);
-       for(i=0; i<ccollids; i++)
-               tmp = build_msg_int(tmp, collIDs[i]);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-2);
-       } 
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if(retmsg == NULL) {
-               return(-1);
-       }
-
-       ptr = (int *) retmsg->buf;
-       if(ptr == NULL) {
-               if(retmsg) efree(retmsg);
-               return -1;
-       }
-       if(*ptr++ == 0) {
-               *count = *ptr;
-               ptr++;
-               if(NULL != (*retIDs = emalloc(*count * sizeof(hw_objectID)))) {
-                       ptr1 = *retIDs;
-                       for(i=0; i<*count; ptr++, i++)
-                               ptr1[i] = *ptr;
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               } else {
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-       } else {
-               error = *((int *) retmsg->buf);
-               if(retmsg->buf) efree(retmsg->buf);
-               if(retmsg) efree(retmsg);
-               return error;
-       }
-       return(0);
-}
-
-
-int send_inscoll(int sockfd, hw_objectID objectID, char *objrec, hw_objectID *new_objectID)
-{
-       hg_msg msg, *retmsg;
-       int  length, error;
-       char *tmp;
-       int *ptr;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID) + strlen(objrec) + 1;
-
-       build_msg_header(&msg, length, msgid++, INSCOLL_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-               lowerror = LE_MALLOC;
-               return(-3);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-       tmp = build_msg_str(tmp, objrec);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-2);
-       } 
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if(retmsg == NULL) {
-               return(-1);
-       }
-
-       ptr = (int *) retmsg->buf;
-       if(0 != (error = *ptr)) {
-               efree(retmsg->buf);
-               efree(retmsg);
-               *new_objectID = 0;
-               return error;
-       }
-
-       ptr++;
-       *new_objectID = *ptr;
-       efree(retmsg->buf);
-       efree(retmsg);
-       return 0;
-}
-
-int send_insdoc(int sockfd, hw_objectID objectID, char *objrec, char *text, hw_objectID *new_objectID)
-{
-       hg_msg msg, *retmsg;
-       int  length, error;
-       char *tmp;
-       int *ptr;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID) + strlen(objrec) + 1;
-       if(text) {
-               length += strlen(text);
-               length++;
-       }
-
-       build_msg_header(&msg, length, msgid++, INSDOC_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-               lowerror = LE_MALLOC;
-               return(-3);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-       tmp = build_msg_str(tmp, objrec);
-       if(text)
-               tmp = build_msg_str(tmp, text);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-2);
-       } 
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if(retmsg == NULL) {
-               return(-1);
-       }
-
-       ptr = (int *) retmsg->buf;
-       if(0 != (error = *ptr)) {
-               efree(retmsg->buf);
-               efree(retmsg);
-               *new_objectID = 0;
-               return error;
-       }
-
-       ptr++;
-       *new_objectID = *ptr;
-       efree(retmsg->buf); 
-       efree(retmsg);
-       return 0;
-}
-
-int send_getdestforanchorsobj(int sockfd, char **anchorrec, char ***destrec, int count);
-int send_getreldestforanchorsobj(int sockfd, char **anchorrec, char ***reldestrec, int count, int rootID, int thisID);
-
-int send_gettext(int sockfd, hw_objectID objectID, int mode, int rootid, char **objattr, char **bodytag, char **text, int *count, char *urlprefix)
-{
-       hg_msg msg, *retmsg;
-       int  length, *ptr, ancount, error;
-       char *tmp, *attributes, *documenttype;
-       char **anchors;
-       int i;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, GETOBJECT_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       } 
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if(retmsg == NULL) {
-               attributes = NULL;
-               return(-1);
-       }
-
-       ptr = (int *) retmsg->buf;
-       if(*ptr == 0) {
-               attributes = estrdup(retmsg->buf+sizeof(int));
-               efree(retmsg->buf);
-               efree(retmsg);
-       } else {
-               error = *ptr;
-               attributes = NULL;
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-
-       length = HEADER_LENGTH + strlen(attributes) + 1;
-       build_msg_header(&msg, length, msgid++, GETTEXT_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_str(msg.buf, attributes);
-
-       documenttype = fnAttributeValue(attributes, "DocumentType");
-       *objattr = strdup(attributes);
-       efree(attributes);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if (retmsg == NULL) {
-               *text = NULL;
-               return(-1);
-       }
-
-       ptr = (int *) retmsg->buf;
-       if(*ptr == 0) {
-               ptr++;
-               *count = retmsg->length-HEADER_LENGTH-sizeof(int);
-               if(NULL != (*text = malloc(*count + 1))) {
-                       memcpy(*text, retmsg->buf+sizeof(int), *count);
-/*                     *text[*count] = 0; */
-               } else {
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-       } else {
-               error = *ptr;
-               efree(retmsg->buf);
-               efree(retmsg);
-               *text = NULL;
-               return(error);
-       }
-       efree(retmsg->buf);
-       efree(retmsg);
-
-       if((documenttype != NULL) && (strcmp(documenttype, "Image") != 0)) {
-               if(send_getanchorsobj(sockfd, objectID, &anchors, &ancount) == 0) {
-                       char **destrec, **reldestrec;
-#ifdef newlist
-                       zend_llist *pAnchorList;
-#else
-                       DLIST *pAnchorList;
-#endif
-
-                       /* Get dest as relative and absolut path */
-                       send_getdestforanchorsobj(sockfd, anchors, &destrec, ancount);
-                       send_getreldestforanchorsobj(sockfd, anchors, &reldestrec, ancount, rootid, objectID);
-                       pAnchorList = fnCreateAnchorList(objectID, anchors, destrec, reldestrec, ancount, mode);
-
-                       /* Free only the array, the objrecs has been freed in fnCreateAnchorList() */
-                       if(anchors) efree(anchors);
-                       if(destrec) efree(destrec);
-                       if(reldestrec) efree(reldestrec);
-
-                       if(pAnchorList != NULL) {
-                               char *newtext;
-                               char *body = NULL;
-                               char **prefixarray;
-
-                               prefixarray = emalloc(5*sizeof(char *));
-                               for(i=0; i<5; i++)
-                                       prefixarray[i] = urlprefix;
-
-                               newtext = fnInsAnchorsIntoText(*text, pAnchorList, &body, prefixarray);
-
-                               efree(prefixarray);
-#ifdef newlist
-                               zend_llist_destroy(pAnchorList);
-                               efree(pAnchorList);
-#else
-                               dlst_kill(pAnchorList, fnDeleteAnchor);
-#endif
-                               *bodytag = strdup(body);
-                               if(body) efree(body);
-                               *text = newtext;
-                               *count = strlen(newtext);
-                       }
-               }
-       }
-
-       if(documenttype) efree(documenttype);
-       return(0);
-}
-
-int send_insertanchors(char **text, int *count, char **anchors, char **destrec, int ancount, char **urlprefix, char **bodytag) {
-       char **reldestrec = NULL;
-       int mode = 0;
-       hw_objectID objectID = 0;
-#ifdef newlist
-       zend_llist *pAnchorList = NULL;
-#else
-       DLIST *pAnchorList = NULL;
-#endif
-       pAnchorList = fnCreateAnchorList(objectID, anchors, destrec, reldestrec, ancount, mode);
-
-       /* Free only the array, the objrecs has been freed in fnCreateAnchorList() */
-       if(anchors) efree(anchors);
-       if(destrec) efree(destrec);
-       if(reldestrec) efree(reldestrec);
-
-       if(pAnchorList != NULL) {
-               char *newtext;
-               char *body = NULL;
-
-               newtext = fnInsAnchorsIntoText(*text, pAnchorList, &body, urlprefix);
-
-#ifdef newlist
-               zend_llist_destroy(pAnchorList);
-               efree(pAnchorList);
-#else
-               dlst_kill(pAnchorList, fnDeleteAnchor);
-#endif
-               *bodytag = strdup(body);
-               if(body) efree(body);
-               *text = newtext;
-               *count = strlen(newtext);
-       }
-       return 0;
-}
-
-int send_edittext(int sockfd, char *objattr, char *text)
-{
-       hg_msg msg, *retmsg;
-       int  length, *ptr, error;
-       char *tmp, *path, *objid;
-       hw_objectID objectID; 
-
-       objid = fnAttributeValue(objattr, "ObjectID");
-       if(objid == NULL)
-               return(-1);
-       if(!sscanf(objid, "0x%x", &objectID))
-               return(-2);
-
-       path = fnAttributeValue(objattr, "Path");
-       if(path == NULL)
-               return(-3);
-
-       length = HEADER_LENGTH + sizeof(hw_objectID) + strlen(path) + 1 + 1 + strlen(text) + 1;
-       build_msg_header(&msg, length, msgid++, EDITTEXT_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-               lowerror = LE_MALLOC;
-               return(-4);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-       tmp = build_msg_str(tmp, path);
-       tmp = build_msg_str(tmp, "");
-       tmp = build_msg_str(tmp, text);
-
-       if(path) efree(path);
-       if(objid) efree(objid);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-5);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if (retmsg == NULL) {
-               *text = '\0';
-               return(-6);
-       }
-
-       ptr = (int *) retmsg->buf;
-       error = *ptr;
-       efree(retmsg->buf);
-       efree(retmsg);
-       return(error);
-}
-
-int send_getcgi(int sockfd, hw_objectID objectID, char *cgi_env_str, char **objattr, char **text, int *count)
-{
-       hg_msg msg, *retmsg;
-       int  length, *ptr, error, new_attr_len;
-       char *tmp, *attributes, *new_attr;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, GETOBJECT_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       } 
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if(retmsg == NULL) {
-               attributes = NULL;
-               return(-1);
-       }
-
-       ptr = (int *) retmsg->buf;
-       if(*ptr == 0) {
-               attributes = estrdup(retmsg->buf+sizeof(int));
-               efree(retmsg->buf);
-               efree(retmsg);
-       } else {
-               error = *ptr;
-               attributes = NULL;
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-
-        new_attr_len = strlen(attributes) + strlen(cgi_env_str) + 2;
-        new_attr = malloc(new_attr_len);
-        strcpy(new_attr, attributes);
-        strcat(new_attr, cgi_env_str);
-       length = HEADER_LENGTH + strlen(new_attr) + 1 + sizeof(int);
-       build_msg_header(&msg, length, msgid++, GETCGI_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_str(msg.buf, new_attr);
-       tmp = build_msg_int(tmp, 0);
-
-       *objattr = strdup(attributes);
-       efree(attributes);
-        free(new_attr);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if (retmsg == NULL) {
-               *text = NULL;
-               return(-1);
-       }
-
-       /* Attention: It looks like the documentation is not quite right.
-          According to the docs the buffer starts with an integer which
-          is followed by the output of the cgi script. This seems not to
-          be true. There is another integer right after the error.
-          The output of the cgi script is also preceded by the 'Content-type'
-          header. */
-       ptr = (int *) retmsg->buf;
-       if(*ptr++ == 1024) {
-               *count = *ptr++;
-               if(NULL != (*text = malloc(*count + 1))) {
-                       memcpy(*text, ptr, *count);
-               } else {
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-       } else {
-               error = *ptr + 1024;  /* move errors to >2024 */
-               efree(retmsg->buf);
-               efree(retmsg);
-               *text = NULL;
-               return(error);
-       }
-       efree(retmsg->buf);
-       efree(retmsg);
-
-       return(0);
-}
-
-int send_getremote(int sockfd, hw_objectID objectID, char **objattr, char **text, int *count)
-{
-       hg_msg msg, *retmsg;
-       int  length, *ptr, error;
-       char *tmp, *attributes;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, GETOBJECT_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       } 
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if(retmsg == NULL) {
-               attributes = NULL;
-               return(-1);
-       }
-
-       ptr = (int *) retmsg->buf;
-       if(*ptr == 0) {
-               attributes = estrdup(retmsg->buf+sizeof(int));
-               efree(retmsg->buf);
-               efree(retmsg);
-       } else {
-               error = *ptr;
-               attributes = NULL;
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-
-       length = HEADER_LENGTH + strlen(attributes) + 1 + sizeof(int);
-       build_msg_header(&msg, length, msgid++, GETREMOTE_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_str(msg.buf, attributes);
-       tmp = build_msg_int(tmp, 0);
-
-       *objattr = strdup(attributes);
-       efree(attributes);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if (retmsg == NULL) {
-               *text = NULL;
-               return(-1);
-       }
-
-       ptr = (int *) retmsg->buf;
-       if(*ptr == 1024) {
-               *count = retmsg->length-HEADER_LENGTH-sizeof(int)-sizeof(int);
-               if(NULL != (*text = malloc(*count + 1))) {
-                       memcpy(*text, ptr+2, *count);
-/*                     *text[*count] = 0; */
-               } else {
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-       } else {
-               error = *ptr + 1024;  /* move errors to >2024 */
-               efree(retmsg->buf);
-               efree(retmsg);
-               *text = NULL;
-               return(error);
-       }
-       efree(retmsg->buf);
-       efree(retmsg);
-
-       return(0);
-}
-
-int send_getremotechildren(int sockfd, char *attributes, char **text, int **childIDs, int *count)
-{
-       hg_msg msg, *retmsg;
-       int  length, *ptr, *ptr1, error;
-       char *tmp;
-
-/*     length = HEADER_LENGTH + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, GETOBJECT_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       } 
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if(retmsg == NULL) {
-               attributes = NULL;
-               return(-1);
-       }
-
-       ptr = (int *) retmsg->buf;
-       if(*ptr == 0) {
-               attributes = estrdup(retmsg->buf+sizeof(int));
-               efree(retmsg->buf);
-               efree(retmsg);
-       } else {
-               error = *ptr;
-               attributes = NULL;
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-*/
-       length = HEADER_LENGTH + strlen(attributes) + 1 + sizeof(int);
-       build_msg_header(&msg, length, msgid++, GETREMOTECHILDREN_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_str(msg.buf, attributes);
-       tmp = build_msg_int(tmp, 0);
-
-/*     efree(attributes); */ 
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if (retmsg == NULL) {
-               *childIDs = NULL;
-               return(-1);
-       }
-       ptr = (int *) retmsg->buf;
-       if(*ptr++ == 1024) {
-               int i, remlen, sum;
-               *count = *ptr;
-               ptr++;
-               if(NULL != (*childIDs = emalloc(*count * sizeof(hw_objectID)))) {
-                       ptr1 = *childIDs;
-                       sum = 0;
-                       for(i=0; i<*count; ptr++, i++) {
-                               ptr1[i] = *ptr;
-                               sum += *ptr;
-                       }
-               } else {
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-
-               remlen = retmsg->length - HEADER_LENGTH - *count * sizeof(int) - 2 * sizeof(int);
-/*ptr1[i-1] = remlen; */
-/*ptr1[i-2] = sum; */
-/*ptr1[i-3] = *count; */
-               if(NULL != (*text = emalloc(remlen + 1))) {
-                       memcpy(*text, ptr, remlen);
-               } else {
-                       efree(childIDs);
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-               efree(retmsg->buf);
-               efree(retmsg);
-       } else {
-               error = *((int *) retmsg->buf);
-               efree(retmsg->buf);
-               efree(retmsg);
-               *childIDs = NULL;
-               *text = NULL;
-               return error;
-       }
-       return(0);
-}
-
-int send_mvcpdocscollscoll(int sockfd, hw_objectID *objectIDs, int count, int from, int dest, int cpmv, int doccoll)
-{
-       hg_msg msg, *retmsg;
-       int  length, i, error;
-       char *tmp;
-
-       if(count <= 0)
-               return 0;
-
-       /*       HEADER_LENGTH + cpmv                + from                + dest                + count + nr of obj */
-       length = HEADER_LENGTH + sizeof(hw_objectID) + sizeof(hw_objectID) + sizeof(hw_objectID) + sizeof(hw_objectID) + count * sizeof(hw_objectID);
-
-       switch(doccoll) {
-               case DOCUMENT:
-                       build_msg_header(&msg, length, msgid++, MVCPDOCSCOLL_MESSAGE);
-                       break;
-               case COLLECTION:
-                       build_msg_header(&msg, length, msgid++, MVCPCOLLSCOLL_MESSAGE);
-                       break;
-       }
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, cpmv);
-       tmp = build_msg_int(tmp, from);
-       tmp = build_msg_int(tmp, dest);
-       tmp = build_msg_int(tmp, count);
-       for(i=0; i<count;i++)
-               tmp = build_msg_int(tmp, objectIDs[i]);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL )  {
-               return(-1);
-       }
-
-       error = *((int *) retmsg->buf);
-       efree(retmsg->buf);
-       efree(retmsg);
-       return(error);
-}
-
-int send_docbyanchor(int sockfd, hw_objectID objectID, hw_objectID *anchorID)
-{
-       hg_msg msg, *retmsg;
-       int  length, error;
-       char *tmp;
-       int *ptr;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, GETDOCBYANCHOR_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL )  {
-               return(-1);
-       }
-
-       ptr = (int *) retmsg->buf;
-       error = *ptr++;
-       if(error == 0) {
-               *anchorID = *ptr;
-       } else {
-               *anchorID = 0;
-       }
-       efree(retmsg->buf);
-       efree(retmsg);
-       return error;
-}
-
-int send_docbyanchorobj(int sockfd, hw_objectID objectID, char **objrec)
-{
-       hg_msg msg, *retmsg;
-       int  length, error;
-       char *tmp;
-       int *ptr, anchorID;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, GETDOCBYANCHOR_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL )  {
-               return(-1);
-       }
-
-       ptr = (int *) retmsg->buf;
-       error = *ptr++;
-       if(error == 0) {
-               anchorID = *ptr;
-       } else {
-               anchorID = 0;
-       }
-       efree(retmsg->buf);
-       efree(retmsg);
-
-       if(0 > bh_send_getobject(sockfd, anchorID))
-               return -1;
-       return(uh_send_getobject(sockfd, objrec));
-}
-
-int send_children(int sockfd, hw_objectID objectID, hw_objectID **childIDs, int *count)
-{
-       hg_msg msg, *retmsg;
-       int length, i, error;
-       char *tmp;
-       int *ptr, *ptr1;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, CHILDREN_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-
-       if (-1 == send_hg_msg(sockfd, &msg, length))  {
-               efree(msg.buf);
-               return(-2);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL )  {
-               return(-3);
-       }
-
-       ptr = (int *) retmsg->buf;
-       if(ptr == NULL) {
-               if(retmsg) efree(retmsg);
-               return -1;
-       }
-       if(*ptr++ == 0) {
-               *count = *ptr++;
-               if(NULL != (*childIDs = emalloc(*count * sizeof(hw_objectID)))) {
-                       ptr1 = *childIDs;
-                       for(i=0; i<*count; ptr++, i++)
-                               ptr1[i] = *ptr;
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               } else {
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-       } else {
-               error = *((int *) retmsg->buf);
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-
-       return(0);
-}
-
-int send_childrenobj(int sockfd, hw_objectID objectID, char ***childrec, int *count)
-{
-       hg_msg msg, *retmsg;
-       int  length, i, error;
-       char *tmp;
-       int *childIDs = NULL;
-       int *ptr;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, CHILDREN_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL )
-               return(-1);
-
-       ptr = (int *) retmsg->buf;
-       if(ptr == NULL) {
-               if(retmsg) efree(retmsg);
-               return -1;
-       }
-       if(*ptr++ == 0) {
-               *count = *ptr++;
-               if(NULL != (childIDs = emalloc(*count * sizeof(hw_objectID)))) {
-                       for(i=0; i<*count; ptr++, i++)
-                               childIDs[i] = *ptr;
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               } else {
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-       } else {
-               error = *((int *) retmsg->buf);
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-
-       /* Now get for each child collection the object record */
-#ifdef hw_less_server_stress
-  if(0 != send_objectbyidquery(sockfd, childIDs, count, NULL, childrec)) {
-               efree(childIDs);
-               return -2;
-       }
-       efree(childIDs);
-#else  
-       for(i=0; i<*count; i++) {
-               
-               length = HEADER_LENGTH + sizeof(hw_objectID);
-               build_msg_header(&msg, length, childIDs[i], GETOBJECT_MESSAGE);
-
-               if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-                       efree(childIDs);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-
-               tmp = build_msg_int(msg.buf, childIDs[i]);
-
-               if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-                       efree(childIDs);
-                       efree(msg.buf);
-                       return(-1);
-                       }
-
-               efree(msg.buf);
-       }
-       efree(childIDs);
-
-       if(NULL == (objptr = (char **) emalloc(*count * sizeof(hw_objrec *)))) {
-               /* if emalloc fails, get at least all remaining  messages from server */
-               for(i=0; i<*count; i++) {
-                       retmsg = recv_hg_msg(sockfd);
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               }
-               *childrec = NULL;
-               lowerror = LE_MALLOC;
-               return(-1);
-       } else {
-       *childrec = objptr;
-
-               for(i=0; i<*count; i++) {
-                       retmsg = recv_hg_msg(sockfd);
-                       if ( retmsg != NULL )  {
-                               if(0 == (int) *(retmsg->buf)) {
-                                       *objptr = estrdup(retmsg->buf+sizeof(int));
-                                       objptr++;
-                                       efree(retmsg->buf);
-                                       efree(retmsg);
-                               } else {
-                                       *objptr = NULL;
-                                       objptr++;
-                                       efree(retmsg->buf);
-                                       efree(retmsg);
-                               }
-                       }
-               }
-       }
-#endif
-       return(0);
-}
-
-int send_getchildcoll(int sockfd, hw_objectID objectID, hw_objectID **childIDs, int *count)
-{
-       hg_msg msg, *retmsg;
-       int  length, error;
-       char *tmp;
-       int *ptr, i, *ptr1;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, GETCHILDCOLL_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL )  {
-               return(-1);
-       }
-
-       ptr = (int *) retmsg->buf;
-       if(ptr == NULL) {
-               if(retmsg) efree(retmsg);
-               return -1;
-       }
-       if(*ptr++ == 0) {
-               *count = *ptr++;
-               if(NULL != (*childIDs = emalloc(*count * sizeof(hw_objectID)))) {
-                       ptr1 = *childIDs;
-                       for(i=0; i<*count; ptr++, i++)
-                               ptr1[i] = *ptr;
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               } else {
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-       } else {
-               error = *((int *) retmsg->buf);
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-
-       return(0);
-}
-
-int send_getchildcollobj(int sockfd, hw_objectID objectID, char ***childrec, int *count)
-{
-       hg_msg msg, *retmsg;
-       int  length, i, error;
-       char *tmp;
-       int *childIDs = NULL;
-       int *ptr;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, GETCHILDCOLL_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL )
-               return(-1);
-
-       ptr = (int *) retmsg->buf;
-       if(ptr == NULL) {
-               if(retmsg) efree(retmsg);
-               return -1;
-       }
-       if(*ptr++ == 0) {
-               *count = *ptr++;
-               if(NULL != (childIDs = emalloc(*count * sizeof(hw_objectID)))) {
-                       for(i=0; i<*count; ptr++, i++)
-                               childIDs[i] = *ptr;
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               } else {
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-       } else {
-               error = *((int *) retmsg->buf);
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-
-       /* Now get for each child collection the object record */
-#ifdef hw_less_server_stress
-  if(0 != send_objectbyidquery(sockfd, childIDs, count, NULL, childrec)) {
-               efree(childIDs);
-               return -2;
-       }
-       efree(childIDs);
-#else  
-       for(i=0; i<*count; i++) {
-               
-               length = HEADER_LENGTH + sizeof(hw_objectID);
-               build_msg_header(&msg, length, childIDs[i], GETOBJECT_MESSAGE);
-
-               if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-                       efree(childIDs);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-
-               tmp = build_msg_int(msg.buf, childIDs[i]);
-
-               if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-                       efree(childIDs);
-                       efree(msg.buf);
-                       return(-1);
-                       }
-
-               efree(msg.buf);
-       }
-       efree(childIDs);
-
-       if(NULL == (objptr = (char **) emalloc(*count * sizeof(hw_objrec *)))) {
-               /* if emalloc fails, get at least all remaining  messages from server */
-               for(i=0; i<*count; i++) {
-                       retmsg = recv_hg_msg(sockfd);
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               }
-               *childrec = NULL;
-               lowerror = LE_MALLOC;
-               return(-1);
-       } else {
-       *childrec = objptr;
-
-               for(i=0; i<*count; i++) {
-                       retmsg = recv_hg_msg(sockfd);
-                       if ( retmsg != NULL )  {
-                               if(0 == (int) *(retmsg->buf)) {
-                                       *objptr = estrdup(retmsg->buf+sizeof(int));
-                                       objptr++;
-                                       efree(retmsg->buf);
-                                       efree(retmsg);
-                               } else {
-                                       *objptr = NULL;
-                                       objptr++;
-                                       efree(retmsg->buf);
-                                       efree(retmsg);
-                               }
-                       }
-               }
-       }
-#endif
-       return(0);
-}
-
-int send_getchilddoccoll(int sockfd, hw_objectID objectID, hw_objectID **childIDs, int *count)
-{
-       hg_msg msg, *retmsg;
-       int  length, error;
-       char *tmp;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, GETCHILDDOCCOLL_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       } else {
-               efree(msg.buf);
-               retmsg = recv_hg_msg(sockfd);
-               if ( retmsg != NULL )  {
-                       int *ptr, i, *ptr1;
-
-                       ptr = (int *) retmsg->buf;
-                       if(ptr == NULL) {
-                               if(retmsg) efree(retmsg);
-                               return -1;
-                       }
-                       if(*ptr++ == 0) {
-                               *count = *ptr++;
-                               if(NULL != (*childIDs = emalloc(*count * sizeof(hw_objectID)))) {
-                                       ptr1 = *childIDs;
-                                       for(i=0; i<*count; ptr++, i++)
-                                               ptr1[i] = *ptr;
-                                       efree(retmsg->buf);
-                                       efree(retmsg);
-                               } else {
-                                       efree(retmsg->buf);
-                                       efree(retmsg);
-                                       lowerror = LE_MALLOC;
-                                       return(-1);
-                               }
-                       } else {
-                               error = *((int *) retmsg->buf);
-                               efree(retmsg->buf);
-                               efree(retmsg);
-                               return error;
-                       }
-               }
-       }
-
-       return(0);
-
-}
-
-int send_getchilddoccollobj(int sockfd, hw_objectID objectID, hw_objrec ***childrec, int *count)
-{
-       hg_msg msg, *retmsg;
-       int  length, error;
-       char *tmp;
-       int *childIDs = NULL;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, GETCHILDDOCCOLL_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-       efree(msg.buf);
-
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg != NULL )  {
-               int *ptr, i;
-
-               ptr = (int *) retmsg->buf;
-               if(ptr == NULL) {
-                       if(retmsg->buf) efree(retmsg->buf);
-                       return -1;
-               }
-               if(*ptr++ == 0) {
-                       *count = *ptr++;
-                       if(NULL != (childIDs = emalloc(*count * sizeof(hw_objectID)))) {
-                               for(i=0; i<*count; ptr++, i++)
-                                       childIDs[i] = *ptr;
-                               efree(retmsg->buf);
-                               efree(retmsg);
-                       } else {
-                               efree(retmsg->buf);
-                               efree(retmsg);
-                               lowerror = LE_MALLOC;
-                               return(-1);
-                       }
-               } else {
-                       error = *((int *) retmsg->buf);
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       return error;
-               }
-       }
-
-       /* Now get for each child collection the object record */
-#ifdef hw_less_server_stress
-  if(0 != send_objectbyidquery(sockfd, childIDs, count, NULL, childrec)) {
-               efree(childIDs);
-               return -2;
-       }
-       efree(childIDs);
-#else  
-       for(i=0; i<*count; i++) {
-               length = HEADER_LENGTH + sizeof(hw_objectID);
-               build_msg_header(&msg, length, childIDs[i], GETOBJECT_MESSAGE);
-
-               if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*                     perror("send_command"); */
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-
-               tmp = build_msg_int(msg.buf, childIDs[i]);
-
-               if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-                       efree(msg.buf);
-                       return(-1);
-                       }
-
-               efree(msg.buf);
-       }
-
-       if(NULL == (objptr = (char **) emalloc(*count * sizeof(hw_objrec *)))) {
-               /* if emalloc fails, get at least all remaining  messages from server */
-               for(i=0; i<*count; i++) {
-                       retmsg = recv_hg_msg(sockfd);
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               }
-               *childrec = NULL;
-               lowerror = LE_MALLOC;
-               return(-1);
-       } else {
-       *childrec = objptr;
-
-               for(i=0; i<*count; i++) {
-                       retmsg = recv_hg_msg(sockfd);
-                       if ( retmsg != NULL )  {
-                               if(0 == (int) *(retmsg->buf)) {
-                                       *objptr = estrdup(retmsg->buf+sizeof(int));
-                                       objptr++;
-                                       efree(retmsg->buf);
-                                       efree(retmsg);
-                               } else {
-                                       *objptr = NULL;
-                                       objptr++;
-                                       efree(retmsg->buf);
-                                       efree(retmsg);
-                               }
-                       }
-               }
-       }
-#endif
-       return(0);
-}
-
-int send_getanchors(int sockfd, hw_objectID objectID, int **anchorIDs, int *count)
-{
-       hg_msg msg, *retmsg;
-       int  length, error;
-       char *tmp;
-       int *ptr, i, *ptr1;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, GETANCHORS_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-       efree(msg.buf);
-
-       if (NULL == (retmsg = recv_hg_msg(sockfd)))
-          return(-1);
-
-       ptr = (int *) retmsg->buf;
-       if(ptr == NULL) {
-               if(retmsg) efree(retmsg);
-               return -1;
-       }
-       if(*ptr++ == 0) {
-               *count = *ptr++;
-               if(NULL != (*anchorIDs = emalloc(*count * sizeof(hw_objectID)))) {
-                       ptr1 = *anchorIDs;
-                       for(i=0; i<*count; ptr++, i++)
-                               ptr1[i] = *ptr;
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               } else {
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-       } else {
-               error = *((int *) retmsg->buf);
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-
-       return(0);
-}
-
-int send_getanchorsobj(int sockfd, hw_objectID objectID, char ***childrec, int *count)
-{
-       hg_msg msg, *retmsg;
-       int  length, error;
-       char *tmp;
-       int *ptr, i, *ptr1;
-       int *anchorIDs = NULL;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, 50, GETANCHORS_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-       efree(msg.buf);
-
-       if (NULL == (retmsg = recv_hg_msg(sockfd)))
-          return(-1);
-
-       ptr = (int *) retmsg->buf;
-       if(ptr == NULL) {
-               if(retmsg) efree(retmsg);
-               return -1;
-       }
-       if(*ptr++ == 0) {
-               *count = *ptr++;
-               if(NULL != (anchorIDs = emalloc(*count * sizeof(hw_objectID)))) {
-                       ptr1 = anchorIDs;
-                       for(i=0; i<*count; ptr++, i++)
-                               ptr1[i] = *ptr;
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               } else {
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-       } else {
-               error = *((int *) retmsg->buf);
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-
-       /* Now get for each anchor the object record */
-#ifdef hw_less_server_stress
-  if(0 != send_objectbyidquery(sockfd, anchorIDs, count, NULL, childrec)) {
-               efree(anchorIDs);
-               return -2;
-       }
-       efree(anchorIDs);
-#else
-       for(i=0; i<*count; i++) {
-               
-               length = HEADER_LENGTH + sizeof(hw_objectID);
-               build_msg_header(&msg, length, anchorIDs[i], GETOBJECT_MESSAGE);
-
-               if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*                     perror("send_command"); */
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-
-               tmp = build_msg_int(msg.buf, anchorIDs[i]);
-
-               if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-                       efree(msg.buf);
-                       return(-1);
-                       }
-
-               efree(msg.buf);
-       }
-       if(anchorIDs) efree(anchorIDs);
-
-       if(NULL == (objptr = (char **) emalloc(*count * sizeof(hw_objrec *)))) {
-               /* if emalloc fails, get at least all remaining  messages from server */
-               for(i=0; i<*count; i++) {
-                       retmsg = recv_hg_msg(sockfd);
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               }
-               *childrec = NULL;
-               lowerror = LE_MALLOC;
-               return(-1);
-       } else {
-       *childrec = objptr;
-
-               for(i=0; i<*count; i++) {
-                       retmsg = recv_hg_msg(sockfd);
-                       if ( retmsg != NULL )  {
-                               if(0 == (int) *(retmsg->buf)) {
-                                       *objptr = estrdup(retmsg->buf+sizeof(int));
-                                       objptr++;
-                                       efree(retmsg->buf);
-                                       efree(retmsg);
-                               } else {
-                                       *objptr = NULL;
-                                       objptr++;
-                                       efree(retmsg->buf);
-                                       efree(retmsg);
-                               }
-                       }
-               }
-       }
-#endif
-       return(0);
-}
-
-int send_getdestforanchorsobj(int sockfd, char **anchorrec, char ***destrec, int count)
-{
-       int i;
-       char *objptr, **destptr;
-       char *str;
-       int objectID;
-
-       if(NULL == (destptr = (char **) emalloc(count * sizeof(hw_objrec *)))) {
-               lowerror = LE_MALLOC;
-               return -1;
-               }
-
-       /* Now get for each anchor the object record of its destination */
-       for(i=0; i<count; i++) {
-               /* if you retrieve the anchors you sometimes get more than actually accessible.
-               */
-               if((NULL != anchorrec[i]) && (NULL != (str = fnAttributeValue(anchorrec[i], "Dest")))) {
-                       sscanf(str, "0x%x", &objectID);
-                       efree(str);
-
-                       /* Using send_docbyanchorobj() makes sense because the Destination can
-                          be both, an anchor or a document. If it is a document you get the
-                          objectrecord of that document. If it is an anchor the function
-                          graps the document which belongs to the anchor
-                          and you get also the objectrecord of that document.
-                       */
-                       if(0 > send_docbyanchorobj(sockfd, objectID, &objptr)) {
-                               efree(destptr);
-                               return -1;
-                       }
-                       destptr[i] = objptr;
-                       /* if we can't get the object rec of the dest, than this document
-                          is probably not accessible for us. For later functions simply
-                          set anchorrec[i] to NULL */
-                       if(destptr[i] == NULL) {
-                               if(anchorrec[i]) efree(anchorrec[i]);
-                               anchorrec[i] = NULL;
-                       }
-               } else {
-                       destptr[i] = NULL;
-               }
-       }
-       *destrec = destptr;
-
-       return(0);
-}
-
-int send_getreldestforanchorsobj(int sockfd, char **anchorrec, char ***reldestrec, int count, int rootID, int thisID)
-{
-       int i;
-       char *docofanchorptr, **reldestptr;
-       char *str;
-       int destobjectID;
-
-       if(NULL == (reldestptr = (char **) emalloc(count * sizeof(char *)))) {
-               lowerror = LE_MALLOC;
-               return -1;
-               }
-
-       /* Now get for each anchor the object record of its destination */
-       for(i=0; i<count; i++) {
-               /* if you retrieve the anchors you sometimes get more than actually accessible.
-               */
-               if((NULL != anchorrec[i]) && (NULL != (str = fnAttributeValue(anchorrec[i], "Dest")))) {
-                       sscanf(str, "0x%x", &destobjectID);
-                       efree(str);
-
-                       /* See note in send_getdestforanchorsobj() at same position in source code */
-                       if(0 > send_docbyanchorobj(sockfd, destobjectID, &docofanchorptr)) {
-                               efree(reldestptr);
-                               return -1;
-                       }
-
-                       reldestptr[i] = docofanchorptr;
-                       /* if we can't get the object rec of the dest, than this document
-                          is probably not accessible for us. For later functions simply
-                          set anchorrec[i] to NULL */
-                       if(reldestptr[i] == NULL) {
-                               if(anchorrec[i]) efree(anchorrec[i]);
-                               anchorrec[i] = NULL;
-                       } else {
-                               int j, *retthisIDs, *retdestIDs, equaltill, mincount, countthis, countdest, destdocid;
-                               char destdocname[200];
-                               char anchorstr[300];
-                               char temp[200];
-                               char *strptr;
-
-                               if(NULL != (str = strstr(docofanchorptr, "Name="))) {
-                                       str += 5;
-                                       sscanf(str, "%s\n", destdocname);
-                               }
-                               if(NULL != (str = strstr(docofanchorptr, "ObjectID="))) {
-                                       str += 9;
-                                       sscanf(str, "0x%X", &destdocid);
-                               }
-                               
-                               send_incollections(sockfd, 1, 1, &thisID, 1, &rootID, &countthis, &retthisIDs);
-                               send_incollections(sockfd, 1, 1, &destdocid, 1, &rootID, &countdest, &retdestIDs);
-
-/*
-fprintf(stderr, "%d: ", thisID);
-for(k=0; k<countthis; k++)
-       fprintf(stderr, "%d, ", retthisIDs[k]);
-fprintf(stderr, "\n");
-fprintf(stderr, "%d: ", destdocid);
-for(k=0; k<countdest; k++)
-       fprintf(stderr, "%d: %d, ", destdocid, retdestIDs[k]);
-fprintf(stderr, "\n");
-*/
-
-                               mincount = (countthis < countdest) ? countthis : countdest;
-                               for(j=0; (j<mincount) && (retthisIDs[j]==retdestIDs[j]); j++)
-                                       ;
-                               equaltill = j;
-                               strcpy(anchorstr, "Name=");
-                               for(j=equaltill; j<countthis; j++)
-                                       strcat(anchorstr, "../");
-                               strcat(anchorstr, "./");
-                               for(j=equaltill; j<countdest; j++) {
-                                       char *temprec, tempname[100];
-                                       send_getobject(sockfd, retdestIDs[j], &temprec);
-                                       if(NULL != (str = strstr(temprec, "Name="))) {
-                                               str += 5;
-                                               sscanf(str, "%s\n", tempname);
-                                       } else if(NULL != (str = strstr(temprec, "ObjectID="))) {
-                                               str += 9;
-                                               sscanf(str, "%s\n", tempname);
-                                       }
-
-                                       sprintf(temp, "%s", tempname);
-                                       strptr = temp;
-                                       while(*strptr != '\0') {
-                                               if(*strptr == '/')
-                                                       *strptr = '_';
-                                               strptr++;
-                                       }
-/* fprintf(stderr, "Adding '%s' to '%s'\n", temp, anchorstr); */
-                                       strcat(anchorstr, temp);
-                                       strcat(anchorstr, "/");
-/* fprintf(stderr, "Is now '%s'\n", anchorstr); */
-                                       efree(temprec);
-                               }
-                               /* if the anchor destination is a collection it may not be added anymore. */
-                               if(destdocid != retdestIDs[countdest-1]) {
-                                       strptr = destdocname;
-                                       while(*strptr != '\0') {
-                                               if(*strptr == '/')
-                                                       *strptr = '_';
-                                               strptr++;
-                                       }
-                                       strcat(anchorstr, destdocname);
-                               } else {
-                                       strcat(anchorstr, "index.html");
-                               }
-                               strcat(anchorstr, "\n");
-                               sprintf(temp, "ObjectID=0x%x", destdocid);
-                               strcat(anchorstr, temp);
-/* fprintf(stderr, "%s\n", anchorstr); */
-                               efree(retthisIDs);
-                               efree(retdestIDs);
-                               efree(reldestptr[i]);
-                               reldestptr[i] = estrdup(anchorstr);
-                       }
-               } else {
-                       reldestptr[i] = NULL;
-               }
-       }
-       *reldestrec = reldestptr;
-
-       return(0);
-}
-
-int fn_findpath(int sockfd, int *retIDs, int count, int id) {
-       int *pathIDs;
-       int *parentIDs, pcount, pid;
-       int u, j, i;
-       
-       if(NULL == (pathIDs = emalloc(count * sizeof(int)))) {
-               lowerror = LE_MALLOC;
-               return -1;
-       }
-       u = count-1;
-       pid = id;
-       pcount = 1;
-       /* FIXME but parentIDs is not set at this point, why checking it? */
-       while((u >= 0) && (pcount != 0) && (parentIDs != NULL) && (pid != 0)) {
-/*fprintf(stderr, "Get parents for %d\n", pid); */
-               if(0 != send_getparents(sockfd, pid, &parentIDs, &pcount)) {
-                       efree(pathIDs);
-                       return -1;
-               }
-               pid = 0;
-               for(i=0; i<pcount; i++) {
-                       for(j=0; j<count; j++) {
-                               if(parentIDs[i] == retIDs[j]) {
-                                       pathIDs[u--] = retIDs[j];
-                                       pid = retIDs[j];
-                               }
-                       }
-               }
-               if(pid == 0)
-                       fprintf(stderr, "parent not found in list\n");
-               if(parentIDs) efree(parentIDs);
-       }
-/*fprintf(stderr, "sorted path: "); */
-       for(i=0; i<count; i++) {
-               retIDs[i] = pathIDs[i];
-/*fprintf(stderr, "%d, ", retIDs[i]); */
-       }
-/*fprintf(stderr, "\n"); */
-       efree(pathIDs);
-       return 0;
-}
-
-/********************************************************************
-* function getrellink()                                             *
-*                                                                   *
-* Returns the link to point from document with ID sourceID to       *
-* document with id destID.                                          *
-********************************************************************/
-int getrellink(int sockfd, int rootID, int thisID, int destID, char **reldeststr) {
-       int i, j, k, *retthisIDs, *retdestIDs, equaltill, count, mincount, countthis, countdest;
-       char anchorstr[300];
-       char temp[200];
-       char *strptr;
-
-       send_incollections(sockfd, 1, 1, &thisID, 1, &rootID, &countthis, &retthisIDs);
-       send_incollections(sockfd, 1, 1, &destID, 1, &rootID, &countdest, &retdestIDs);
-
-
-fprintf(stderr, "%d: ", thisID);
-for(k=0; k<countthis; k++)
-       fprintf(stderr, "%d, ", retthisIDs[k]);
-fprintf(stderr, "\n");
-fprintf(stderr, "%d: ", destID);
-for(k=0; k<countdest; k++)
-       fprintf(stderr, "%d, ", retdestIDs[k]);
-fprintf(stderr, "\n");
-
-       /*
-       ** The message incollections returned a list of collections
-       ** in which the destID or thisID is contained. Unfortunately
-       ** this list ist not the path for the destID or thisID, but
-       ** a sorted list of collection IDs. If for example you are
-       ** looking for an ID 20 which has a path 1 -> 5 -> 4 -> 20
-       ** (this means: 20 is child of 4, 4 is child of 5, 5 is child
-       ** of 1) it will return 1, 4, 5 instead of 1, 5, 4
-       ** Consequently, we have to create the correct path, by checking
-       ** for the parents and identifying it in the list.
-       ** But there is another problem. If the id for which the list of
-       ** of collection is generated is a colletion itself, it will
-       ** show up in the list as well. In order to make the algorithmn
-       ** work proberly it has to be the last member of the list.
-       */
-       for(i=0; i<countdest; i++)
-               if(retdestIDs[i] == destID) {
-                       retdestIDs[i] = retdestIDs[countdest-1];
-                       retdestIDs[countdest-1] = destID;
-               }
-       count = (retdestIDs[countdest-1] == destID) ? countdest-1 : countdest;
-       if(0 != fn_findpath(sockfd, retdestIDs, count, destID)) {
-               efree(retthisIDs);
-               efree(retdestIDs);
-               return -1;
-       }
-       for(i=0; i<countthis; i++)
-               if(retthisIDs[i] == thisID) {
-                       retthisIDs[i] = retthisIDs[countthis-1];
-                       retthisIDs[countthis-1] = thisID;
-               }
-       count = (retthisIDs[countthis-1] == thisID) ? countthis-1 : countthis;
-       if(0 != fn_findpath(sockfd, retthisIDs, count, thisID)) {
-               efree(retthisIDs);
-               efree(retdestIDs);
-               return -1;
-       }
-
-       mincount = (countthis < countdest) ? countthis : countdest;
-fprintf(stderr, "mincount = %d\n", mincount);
-       for(j=0; (j<mincount) && (retthisIDs[j]==retdestIDs[j]); j++)
-               ;
-       equaltill = j;
-fprintf(stderr, "first unequal = %d\n", j);
-       strcpy(anchorstr, "");
-       for(j=equaltill; j<countthis; j++)
-               strcat(anchorstr, "../");
-       strcat(anchorstr, "./");
-       for(j=equaltill; j<countdest; j++) {
-               char *temprec, *str, tempname[100];
-               if(0 == send_getobject(sockfd, retdestIDs[j], &temprec)) {
-                       if(NULL != (str = strstr(temprec, "Name="))) {
-                               str += 5;
-                               sscanf(str, "%s\n", tempname);
-                       } else if(NULL != (str = strstr(temprec, "ObjectID="))) {
-                               str += 9;
-                               sscanf(str, "%s\n", tempname);
-                       }
-       
-                       sprintf(temp, "%s", tempname);
-                       strptr = temp;
-                       while(*strptr != '\0') {
-                               if(*strptr == '/')
-                                       *strptr = '_';
-                               strptr++;
-                       }
-fprintf(stderr, "Adding '%s' (%d) to '%s'\n", temp, retdestIDs[j], anchorstr);
-                       strcat(anchorstr, temp);
-                       strcat(anchorstr, "/");
-fprintf(stderr, "Is now '%s'\n", anchorstr);
-                       efree(temprec);
-               } else {
-                       strcat(anchorstr, "No access/");
-               }
-       }
-       /* if the anchor destination is a collection it may not be added anymore. */
-       if(destID != retdestIDs[countdest-1]) {
-               char destdocname[100], *str;
-               send_getobject(sockfd, destID, &str);
-               if(NULL != (strptr = strstr(str, "Name="))) {
-                       strptr += 5;
-                       sscanf(strptr, "%s\n", destdocname);
-               }
-               strptr = destdocname;
-               while(*strptr != '\0') {
-                       if(*strptr == '/')
-                               *strptr = '_';
-                       strptr++;
-               }
-               strcat(anchorstr, destdocname);
-               efree(str);
-       } else {
-/*             strcat(anchorstr, "index.html"); */
-       }
-/*fprintf(stderr, "%s\n", anchorstr); */
-       efree(retthisIDs);
-       efree(retdestIDs);
-       *reldeststr = estrdup(anchorstr);
-       return 0;
-}
-
-int send_identify(int sockfd, char *name, char *passwd, char **userdata) {
-       hg_msg msg, *retmsg;
-       int  length;
-       char *tmp;
-
-       length = HEADER_LENGTH + sizeof(int) + strlen(name) + 1 + strlen(passwd) + 1;
-
-       build_msg_header(&msg, length, msgid++, IDENTIFY_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, 0);
-       tmp = build_msg_str(tmp, name);
-       tmp = build_msg_str(tmp, passwd);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL )
-               return(-1);
-
-       *userdata = (char *) retmsg->buf;
-       efree(retmsg);
-
-       return(0);
-}
-
-int send_objectbyidquery(int sockfd, hw_objectID *IDs, int *count, char *query, char ***objrecs)
-{
-       hg_msg msg, *retmsg;
-       int  length;
-       char *tmp, *str;
-       int *ptr, i;
-       int *offsets, *childIDs;
-       char **childrec;
-
-       if(*count <= 0) {
-               *objrecs = emalloc(0);
-               return(0);
-       }
-       length = HEADER_LENGTH + sizeof(int) + sizeof(int) + *count * sizeof(hw_objectID);
-       if(query)
-               length = length + strlen(query) + 1;
-
-       build_msg_header(&msg, length, msgid++, OBJECTBYIDQUERY_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, 1);
-       tmp = build_msg_int(tmp, *count);
-       for(i=0; i<*count; i++)
-               tmp = build_msg_int(tmp, IDs[i]);
-       if(query)
-               tmp = build_msg_str(tmp, query);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-       efree(msg.buf);
-
-#ifdef hw_optimize
-       {
-       int hg_error;
-       int c, allc;
-
-       allc = 0;
-       retmsg = recv_hg_msg_head(sockfd);
-       if ( retmsg == NULL ) 
-               return(-1);
-       
-       /* read error field */
-       if ( (c = hg_read_exact(sockfd, (char *) &hg_error, 4)) == -1 ) {
-               if(retmsg) efree(retmsg);
-               return(-2);
-       }
-       allc += c;
-
-       if(hg_error) {
-               if(retmsg) efree(retmsg);
-               return(-3);
-       }
-
-       /* read count field */
-       if ( (c = hg_read_exact(sockfd, (char *) count, 4)) == -1 ) {
-               if(retmsg) efree(retmsg);
-               return(-2);
-       }
-       allc += c;
-
-       if(NULL != (childIDs = emalloc(*count * sizeof(hw_objectID)))) {
-               if((c = hg_read_exact(sockfd, (char *) childIDs, *count * sizeof(hw_objectID))) == -1) {
-                       efree(childIDs);
-                       if(retmsg) efree(retmsg);
-                       return(-3);
-               }
-       } else {
-               efree(retmsg);
-               lowerror = LE_MALLOC;
-               return(-4);
-       }
-       allc += c;
-
-       if(NULL != (offsets = emalloc(*count * sizeof(int)))) {
-               if((c = hg_read_exact(sockfd, (char *) offsets, *count * sizeof(int))) == -1) {
-                       efree(childIDs);
-                       efree(offsets);
-                       if(retmsg) efree(retmsg);
-                       return(-5);
-               }
-       } else {
-               efree(retmsg);
-               efree(childIDs);
-               lowerror = LE_MALLOC;
-               return(-6);
-       }  
-       allc += c;
-
-       str = (char *)ptr;
-       if(NULL == (childrec = (char **) emalloc(*count * sizeof(hw_objrec *)))) {
-               efree(offsets);
-               efree(childIDs);
-               efree(retmsg);
-               lowerror = LE_MALLOC;
-               return(-1);
-       } else {
-               for(i=0; i<*count; i++) {
-                       char *ptr;
-                       childrec[i] = emalloc(offsets[i] + 1);
-                       ptr = childrec[i];
-                       c = hg_read_exact(sockfd, (char *) ptr, offsets[i]);
-                       ptr[c] = '\0';
-                       allc += c;
-               }
-               /* Reading the trailing '\0' */
-               c = hg_read_exact(sockfd, (char *) &hg_error, 1);
-               *objrecs = childrec;
-       }
-       }
-#else
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL ) 
-               return(-1);
-
-       ptr = (int *) retmsg->buf;
-       if(ptr == NULL) {
-               if(retmsg) efree(retmsg);
-               return -1;
-       }
-       if(*ptr++ != 0) {
-               error = *((int *) retmsg->buf);
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-
-       *count = *ptr++;
-       if(NULL != (childIDs = emalloc(*count * sizeof(hw_objectID)))) {
-               ptr1 = childIDs;
-               for(i=0; i<*count; ptr++, i++)
-                       ptr1[i] = *ptr;
-               if(NULL != (offsets = emalloc(*count * sizeof(int)))) {
-                       ptr1 = offsets;
-                       for(i=0; i<*count; ptr++, i++)
-                               ptr1[i] = *ptr;
-               } else {
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       efree(childIDs);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-       } else {
-               efree(retmsg->buf);
-               efree(retmsg);
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       str = (char *)ptr;
-       if(NULL == (childrec = (char **) emalloc(*count * sizeof(hw_objrec *)))) {
-               efree(offsets);
-               efree(childIDs);
-               efree(retmsg->buf);
-               efree(retmsg);
-               lowerror = LE_MALLOC;
-               return(-1);
-       } else {
-               for(i=0; i<*count; i++) {
-                       char *ptr;
-                       childrec[i] = emalloc(offsets[i] + 1);
-                       ptr = childrec[i];
-                       memcpy(ptr, str, offsets[i]);
-                       ptr[offsets[i]] = '\0';
-                       str += offsets[i];
-               }
-               *objrecs = childrec;
-       }
-
-       efree(retmsg->buf);
-#endif
-
-       efree(retmsg);
-       efree(childIDs);
-       efree(offsets);
-       return(0);
-}
-
-int send_getobjbyquery(int sockfd, char *query, int maxhits, hw_objectID **childIDs, int *count)
-{
-       hg_msg msg, *retmsg;
-       int  length, error;
-       char *tmp;
-       int *ptr, i, *ptr1;
-
-       length = HEADER_LENGTH + strlen(query) + 1;
-
-       build_msg_header(&msg, length, msgid++, GETOBJBYQUERY_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_str(msg.buf, query);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL ) 
-               return(-1);
-
-       ptr = (int *) retmsg->buf;
-       if(ptr == NULL) {
-               if(retmsg) efree(retmsg);
-               return -1;
-       }
-       if(*ptr++ == 0) {
-               *count = (*ptr < maxhits) ? *ptr : maxhits;
-               ptr++;
-               if(NULL != (*childIDs = emalloc(*count * sizeof(hw_objectID)))) {
-                       ptr1 = *childIDs;
-                       for(i=0; i<*count; ptr++, i++)
-                               ptr1[i] = *ptr;
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               } else {
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-       } else {
-               error = *((int *) retmsg->buf);
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-       return(0);
-}
-
-int send_getobjbyqueryobj(int sockfd, char *query, int maxhits, char ***childrec, int *count)
-{
-       hg_msg msg, *retmsg;
-       int length, i, error;
-       char *tmp;
-       int *childIDs = NULL;
-       int *ptr, *ptr1;
-
-       length = HEADER_LENGTH + strlen(query) + 1;
-
-       build_msg_header(&msg, length, msgid++, GETOBJBYQUERY_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_str(msg.buf, query);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-2);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL ) 
-               return(-3);
-
-       ptr = (int *) retmsg->buf;
-       if(ptr == NULL) {
-               if(retmsg) efree(retmsg);
-               return -4;
-       }
-       if(*ptr++ == 0) {
-               *count = (*ptr < maxhits) ? *ptr : maxhits;
-               ptr++;
-               if(NULL != (childIDs = emalloc(*count * sizeof(hw_objectID)))) {
-                       ptr1 = childIDs;
-                       for(i=0; i<*count; ptr++, i++)
-                               ptr1[i] = *ptr;
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               } else {
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       lowerror = LE_MALLOC;
-                       return(-5);
-               }
-       } else {
-               error = *((int *) retmsg->buf);
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-
-       /* Now get for each child collection the object record */
-#ifdef hw_less_server_stress
-  if(0 != send_objectbyidquery(sockfd, childIDs, count, NULL, childrec)) {
-               efree(childIDs);
-               return -2;
-       }
-       efree(childIDs);
-#else
-       for(i=0; i<*count; i++) {
-               length = HEADER_LENGTH + sizeof(hw_objectID);
-               build_msg_header(&msg, length, childIDs[i], GETOBJECT_MESSAGE);
-
-               if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*                     perror("send_command"); */
-                       efree(childIDs);
-                       lowerror = LE_MALLOC;
-                       return(-6);
-               }
-
-               tmp = build_msg_int(msg.buf, childIDs[i]);
-
-               if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-                       efree(msg.buf);
-                       efree(childIDs);
-                       return(-7);
-                       }
-
-               efree(msg.buf);
-       }
-       efree(childIDs);
-
-       if(NULL == (objptr = (char **) emalloc(*count * sizeof(hw_objrec *)))) {
-               /* if emalloc fails, get at least all remaining  messages from server */
-               for(i=0; i<*count; i++) {
-                       retmsg = recv_hg_msg(sockfd);
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               }
-               *childrec = NULL;
-               lowerror = LE_MALLOC;
-               return(-8);
-       } else {
-               *childrec = objptr;
-
-               for(i=0; i<*count; i++) {
-                       retmsg = recv_hg_msg(sockfd);
-                       if ( retmsg != NULL )  {
-                               if(0 == (int) *(retmsg->buf)) {
-                                       *objptr = estrdup(retmsg->buf+sizeof(int));
-                                       objptr++;
-                                       efree(retmsg->buf);
-                                       efree(retmsg);
-                               } else {
-                                       *objptr = NULL;
-                                       objptr++;
-                                       efree(retmsg->buf);
-                                       efree(retmsg);
-                               }
-                       }
-               }
-       }
-#endif
-       return(0);
-}
-
-int send_getobjbyquerycoll(int sockfd, hw_objectID collID, char *query, int maxhits, hw_objectID **childIDs, int *count)
-{
-       hg_msg msg, *retmsg;
-       int  length, error;
-       char *tmp;
-       int *ptr, i, *ptr1;
-
-       length = HEADER_LENGTH + strlen(query) + 1 + sizeof(int) + sizeof(collID);
-
-       build_msg_header(&msg, length, msgid++, GETOBJBYQUERYCOLL_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, 1);
-       tmp = build_msg_int(tmp, collID);
-       tmp = build_msg_str(tmp, query);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL ) 
-               return(-1);
-
-       ptr = (int *) retmsg->buf;
-       if(ptr == NULL) {
-               if(retmsg) efree(retmsg);
-               return -1;
-       }
-       if(*ptr++ == 0) {
-               *count = (*ptr < maxhits) ? *ptr : maxhits;
-               ptr++;
-               if(NULL != (*childIDs = emalloc(*count * sizeof(hw_objectID)))) {
-                       ptr1 = *childIDs;
-                       for(i=0; i<*count; ptr++, i++)
-                               ptr1[i] = *ptr;
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               } else {
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-       } else {
-               error = *((int *) retmsg->buf);
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-       return(0);
-}
-
-int send_getobjbyquerycollobj(int sockfd, hw_objectID collID, char *query, int maxhits, char ***childrec, int *count)
-{
-       hg_msg msg, *retmsg;
-       int length, i, error;
-       char *tmp;
-       hw_objectID *childIDs = NULL;
-       int *ptr, *ptr1;
-
-       length = HEADER_LENGTH + strlen(query) + 1 + sizeof(int) + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, GETOBJBYQUERYCOLL_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, 1);
-       tmp = build_msg_int(tmp, collID);
-       tmp = build_msg_str(tmp, query);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       } 
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL )
-               return -1;
-
-       ptr = (int *) retmsg->buf;
-       if(ptr == NULL) {
-               if(retmsg) efree(retmsg);
-               return -1;
-       }
-       if(*ptr++ == 0) {
-               *count = (*ptr < maxhits) ? *ptr : maxhits;
-               ptr++;
-               if(NULL != (childIDs = emalloc(*count * sizeof(hw_objectID)))) {
-                       ptr1 = childIDs;
-                       for(i=0; i<*count; ptr++, i++)
-                               ptr1[i] = *ptr;
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               } else {
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-       } else {
-               error = *((int *) retmsg->buf);
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-
-       /* Now get for each child collection the object record */
-#ifdef hw_less_server_stress
-  if(0 != send_objectbyidquery(sockfd, childIDs, count, NULL, childrec)) {
-               if(childIDs) efree(childIDs);
-               return -2;
-       }
-       if(childIDs) efree(childIDs);
-#else
-       for(i=0; i<*count; i++) {
-               length = HEADER_LENGTH + sizeof(hw_objectID);
-               build_msg_header(&msg, length, childIDs[i], GETOBJECT_MESSAGE);
-
-               if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*                     perror("send_command"); */
-                       efree(childIDs);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-
-               tmp = build_msg_int(msg.buf, childIDs[i]);
-
-               if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-                       efree(msg.buf);
-                       efree(childIDs);
-                       return(-1);
-                       }
-
-               efree(msg.buf);
-       }
-       efree(childIDs);
-
-       if(NULL == (objptr = (char **) emalloc(*count * sizeof(hw_objrec *)))) {
-               /* if emalloc fails, get at least all remaining  messages from server */
-               for(i=0; i<*count; i++) {
-                       retmsg = recv_hg_msg(sockfd);
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               }
-       *childrec = NULL;
-               lowerror = LE_MALLOC;
-               return(-1);
-       } else {
-               *childrec = objptr;
-
-               for(i=0; i<*count; i++) {
-                       retmsg = recv_hg_msg(sockfd);
-                       if ( retmsg != NULL )  {
-                               if(0 == (int) *(retmsg->buf)) {
-                                       *objptr = estrdup(retmsg->buf+sizeof(int));
-                                       objptr++;
-                                       efree(retmsg->buf);
-                                       efree(retmsg);
-                               } else {
-                                       *objptr = NULL;
-                                       objptr++;
-                                       efree(retmsg->buf);
-                                       efree(retmsg);
-                               }
-                       }
-               }
-       }
-#endif
-       return(0);
-}
-
-int send_getobjbyftquery(int sockfd, char *query, int maxhits, hw_objectID **childIDs, float **weights, int *count)
-{
-       hg_msg msg, *retmsg;
-       int  length, error;
-       char *tmp;
-       int *ptr, i, *ptr1;
-       float *ptr2;
-
-       length = HEADER_LENGTH + strlen(query) + 1;
-
-       build_msg_header(&msg, length, msgid++, GETOBJBYFTQUERY_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_str(msg.buf, query);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL ) 
-               return(-1);
-
-       ptr = (int *) retmsg->buf;
-       if(ptr == NULL) {
-               if(retmsg) efree(retmsg);
-               return -1;
-       }
-       if(*ptr++ == 0) {
-               char *cptr, tmp[20];
-               float weight;
-               int j;
-               *count = (*ptr < maxhits) ? *ptr : maxhits;
-               ptr++;
-               if(NULL != (*childIDs = emalloc(*count * sizeof(hw_objectID)))) {
-                       ptr1 = *childIDs;
-                       if(NULL != (*weights = emalloc(*count * sizeof(float)))) {
-                               ptr2 = *weights;
-                               for(i=0; i<*count; i++) {
-                                       ptr1[i] = *ptr++; /* Object id */
-                                       cptr = (char *) ptr;
-                                       j = 0;
-                                       while(*cptr != ' ') {
-                                               tmp[j++] = *cptr++;
-                                       }
-                                       cptr++; /* Skip space after weight */
-                                       tmp[j] = '\0';
-                                       sscanf(tmp, "%f", &weight);
-                                       ptr2[i] = weight;
-                                       ptr = (int *) cptr;
-                                       ptr++; /* Skip 0-Integer after weight string */
-                               }
-                               efree(retmsg->buf);
-                               efree(retmsg);
-                       } else {
-                               efree(*childIDs);
-                               efree(retmsg->buf);
-                               efree(retmsg);
-                               lowerror = LE_MALLOC;
-                               return(-1);
-                       }
-               } else {
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-       } else {
-               error = *((int *) retmsg->buf);
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-       return(0);
-}
-
-int send_getobjbyftqueryobj(int sockfd, char *query, int maxhits, char ***childrec, float **weights, int *count)
-{
-       hg_msg msg, *retmsg;
-       int length, i, error;
-       char *tmp;
-       int *childIDs = NULL;
-       int *ptr, *ptr1;
-       float *ptr2;
-
-       length = HEADER_LENGTH + strlen(query) + 1;
-
-       build_msg_header(&msg, length, msgid++, GETOBJBYFTQUERY_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_str(msg.buf, query);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-2);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL ) 
-               return(-3);
-
-       ptr = (int *) retmsg->buf;
-       if(ptr == NULL) {
-               if(retmsg) efree(retmsg);
-               return -4;
-       }
-       if(*ptr++ == 0) {
-               char *cptr, tmp[20];
-               float weight;
-               int j;
-               *count = (*ptr < maxhits) ? *ptr : maxhits;
-               ptr++;
-               if(NULL != (childIDs = emalloc(*count * sizeof(hw_objectID)))) {
-                       ptr1 = childIDs;
-                       if(NULL != (*weights = emalloc(*count * sizeof(float)))) {
-                               ptr2 = *weights;
-                               for(i=0; i<*count; i++) {
-                                       ptr1[i] = *ptr++; /* Object id */
-                                       cptr = (char *) ptr;
-                                       j = 0;
-                                       while(*cptr != ' ') {
-                                               tmp[j++] = *cptr++;
-                                       }
-                                       cptr++; /* Skip space after weight */
-                                       tmp[j] = '\0';
-                                       sscanf(tmp, "%f", &weight);
-                                       ptr2[i] = weight;
-                                       ptr = (int *) cptr;
-                                       ptr++; /* Skip 0-Integer after weight string */
-                               }
-                               efree(retmsg->buf);
-                               efree(retmsg);
-                       } else {
-                               efree(childIDs);
-                               efree(retmsg->buf);
-                               efree(retmsg);
-                               lowerror = LE_MALLOC;
-                               return(-5);
-                       }
-               } else {
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       lowerror = LE_MALLOC;
-                       return(-5);
-               }
-       } else {
-               error = *((int *) retmsg->buf);
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-
-       /* Now get for each child collection the object record */
-#ifdef hw_less_server_stress
-  if(0 != send_objectbyidquery(sockfd, childIDs, count, NULL, childrec)) {
-               efree(childIDs);
-               efree(*weights);
-               return -2;
-       }
-       efree(childIDs);
-#else
-       for(i=0; i<*count; i++) {
-               length = HEADER_LENGTH + sizeof(hw_objectID);
-               build_msg_header(&msg, length, childIDs[i], GETOBJECT_MESSAGE);
-
-               if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-                       efree(childIDs);
-                       efree(*weights);
-                       lowerror = LE_MALLOC;
-                       return(-6);
-               }
-
-               tmp = build_msg_int(msg.buf, childIDs[i]);
-
-               if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-                       efree(msg.buf);
-                       efree(childIDs);
-                       efree(*weights);
-                       return(-7);
-                       }
-
-               efree(msg.buf);
-       }
-       efree(childIDs);
-
-       if(NULL == (objptr = (char **) emalloc(*count * sizeof(hw_objrec *)))) {
-               /* if emalloc fails, get at least all remaining  messages from server */
-               for(i=0; i<*count; i++) {
-                       retmsg = recv_hg_msg(sockfd);
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               }
-               *childrec = NULL;
-               lowerror = LE_MALLOC;
-               return(-8);
-       } else {
-               *childrec = objptr;
-
-               for(i=0; i<*count; i++) {
-                       retmsg = recv_hg_msg(sockfd);
-                       if ( retmsg != NULL )  {
-                               if(0 == (int) *(retmsg->buf)) {
-                                       *objptr = estrdup(retmsg->buf+sizeof(int));
-                                       objptr++;
-                                       efree(retmsg->buf);
-                                       efree(retmsg);
-                               } else {
-                                       *objptr = NULL;
-                                       objptr++;
-                                       efree(retmsg->buf);
-                                       efree(retmsg);
-                               }
-                       }
-               }
-       }
-#endif
-       return(0);
-}
-
-int send_getobjbyftquerycoll(int sockfd, hw_objectID collID, char *query, int maxhits, hw_objectID **childIDs, float **weights, int *count)
-{
-       hg_msg msg, *retmsg;
-       int  length, error;
-       char *tmp;
-       int *ptr, i, *ptr1;
-       float *ptr2;
-
-       length = HEADER_LENGTH + strlen(query) + 1 + sizeof(int) + sizeof(collID);
-
-       build_msg_header(&msg, length, msgid++, GETOBJBYFTQUERYCOLL_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, 1);
-       tmp = build_msg_int(tmp, collID);
-       tmp = build_msg_str(tmp, query);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL ) 
-               return(-1);
-
-       ptr = (int *) retmsg->buf;
-       if(ptr == NULL) {
-               if(retmsg) efree(retmsg);
-               return -1;
-       }
-       if(*ptr++ == 0) {
-               char *cptr, tmp[20];
-               float weight;
-               int j;
-               *count = (*ptr < maxhits) ? *ptr : maxhits;
-               ptr++;
-               if(NULL != (*childIDs = emalloc(*count * sizeof(hw_objectID)))) {
-                       ptr1 = *childIDs;
-                       if(NULL != (*weights = emalloc(*count * sizeof(float)))) {
-                               ptr2 = *weights;
-                               for(i=0; i<*count; i++) {
-                                       ptr1[i] = *ptr++; /* Object id */
-                                       cptr = (char *) ptr;
-                                       j = 0;
-                                       while(*cptr != ' ') {
-                                               tmp[j++] = *cptr++;
-                                       }
-                                       cptr++; /* Skip space after weight */
-                                       tmp[j] = '\0';
-                                       sscanf(tmp, "%f", &weight);
-                                       ptr2[i] = weight;
-                                       ptr = (int *) cptr;
-                                       ptr++; /* Skip 0-Integer after weight string */
-                               }
-                       } else {
-                               efree(*childIDs);
-                               efree(retmsg->buf);
-                               efree(retmsg);
-                               lowerror = LE_MALLOC;
-                               return(-1);
-                       }
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               } else {
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-       } else {
-               error = *((int *) retmsg->buf);
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-       return(0);
-}
-
-int send_getobjbyftquerycollobj(int sockfd, hw_objectID collID, char *query, int maxhits, char ***childrec, float **weights, int *count)
-{
-       hg_msg msg, *retmsg;
-       int length, i, error;
-       char *tmp;
-       hw_objectID *childIDs = NULL;
-       int *ptr, *ptr1;
-       float *ptr2;
-
-       length = HEADER_LENGTH + strlen(query) + 1 + sizeof(int) + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, GETOBJBYFTQUERYCOLL_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, 1);
-       tmp = build_msg_int(tmp, collID);
-       tmp = build_msg_str(tmp, query);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       } 
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL )
-               return -1;
-
-       ptr = (int *) retmsg->buf;
-       if(ptr == NULL) {
-               if(retmsg) efree(retmsg);
-               return -1;
-       }
-       if(*ptr++ == 0) {
-               char *cptr, tmp[20];
-               float weight;
-               int j;
-               *count = (*ptr < maxhits) ? *ptr : maxhits;
-               ptr++;
-               if(NULL != (childIDs = emalloc(*count * sizeof(hw_objectID)))) {
-                       ptr1 = childIDs;
-                       if(NULL != (*weights = emalloc(*count * sizeof(float)))) {
-                               ptr2 = *weights;
-                               for(i=0; i<*count; i++) {
-                                       ptr1[i] = *ptr++; /* Object id */
-                                       cptr = (char *) ptr;
-                                       j = 0;
-                                       while(*cptr != ' ') {
-                                               tmp[j++] = *cptr++;
-                                       }
-                                       cptr++; /* Skip space after weight */
-                                       tmp[j] = '\0';
-                                       sscanf(tmp, "%f", &weight);
-                                       ptr2[i] = weight;
-                                       ptr = (int *) cptr;
-                                       ptr++; /* Skip 0-Integer after weight string */
-                               }
-                               efree(retmsg->buf);
-                               efree(retmsg);
-                       } else {
-                               efree(childIDs);
-                               efree(retmsg->buf);
-                               efree(retmsg);
-                               lowerror = LE_MALLOC;
-                               return(-1);
-                       }
-               } else {
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-       } else {
-               error = *((int *) retmsg->buf);
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-
-       /* Now get for each child collection the object record */
-#ifdef hw_less_server_stress
-  if(0 != send_objectbyidquery(sockfd, childIDs, count, NULL, childrec)) {
-               if(childIDs) efree(childIDs);
-               if(*weights) efree(weights);
-               return -2;
-       }
-       if(childIDs) efree(childIDs);
-#else
-       for(i=0; i<*count; i++) {
-               length = HEADER_LENGTH + sizeof(hw_objectID);
-               build_msg_header(&msg, length, childIDs[i], GETOBJECT_MESSAGE);
-
-               if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*                     perror("send_command"); */
-                       efree(childIDs);
-                       efree(*weights);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-
-               tmp = build_msg_int(msg.buf, childIDs[i]);
-
-               if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-                       efree(msg.buf);
-                       efree(childIDs);
-                       efree(*weights);
-                       return(-1);
-                       }
-
-               efree(msg.buf);
-       }
-       efree(childIDs);
-
-       if(NULL == (objptr = (char **) emalloc(*count * sizeof(hw_objrec *)))) {
-               /* if emalloc fails, get at least all remaining  messages from server */
-               for(i=0; i<*count; i++) {
-                       retmsg = recv_hg_msg(sockfd);
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               }
-       *childrec = NULL;
-               lowerror = LE_MALLOC;
-               return(-1);
-       } else {
-               *childrec = objptr;
-
-               for(i=0; i<*count; i++) {
-                       retmsg = recv_hg_msg(sockfd);
-                       if ( retmsg != NULL )  {
-                               if(0 == (int) *(retmsg->buf)) {
-                                       *objptr = estrdup(retmsg->buf+sizeof(int));
-                                       objptr++;
-                                       efree(retmsg->buf);
-                                       efree(retmsg);
-                               } else {
-                                       *objptr = NULL;
-                                       objptr++;
-                                       efree(retmsg->buf);
-                                       efree(retmsg);
-                               }
-                       }
-               }
-       }
-#endif
-       return(0);
-}
-
-int send_getparents(int sockfd, hw_objectID objectID, hw_objectID **childIDs, int *count)
-{
-       hg_msg msg, *retmsg;
-       int length, i, error;
-       char *tmp;
-       int *ptr, *ptr1;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, GETPARENT_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-
-       if (-1 == send_hg_msg(sockfd, &msg, length))  {
-               efree(msg.buf);
-               return(-2);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL )  {
-               return(-3);
-       }
-
-       ptr = (int *) retmsg->buf;
-       if(ptr == NULL) {
-               if(retmsg) efree(retmsg);
-               return -1;
-       }
-       if(*ptr++ == 0) {
-               *count = *ptr++;
-               if(NULL != (*childIDs = emalloc(*count * sizeof(hw_objectID)))) {
-                       ptr1 = *childIDs;
-                       for(i=0; i<*count; ptr++, i++)
-                               ptr1[i] = *ptr;
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               } else {
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-       } else {
-               error = *((int *) retmsg->buf);
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-
-       return(0);
-}
-
-int send_getparentsobj(int sockfd, hw_objectID objectID, char ***childrec, int *count)
-{
-       hg_msg msg, *retmsg;
-       int length, i, error;
-       char *tmp;
-       hw_objectID *childIDs = NULL;
-       int *ptr;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, GETPARENT_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-
-       if (-1 == send_hg_msg(sockfd, &msg, length))  {
-               efree(msg.buf);
-               return(-1);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL )  {
-               return(-1);
-       }
-
-       ptr = (int *) retmsg->buf;
-       if(ptr == NULL) {
-               if(retmsg) efree(retmsg);
-               return -1;
-       }
-       if(*ptr++ == 0) {
-               *count = *ptr++;
-               if(NULL != (childIDs = emalloc(*count * sizeof(hw_objectID)))) {
-                       for(i=0; i<*count; ptr++, i++)
-                               childIDs[i] = *ptr;
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               } else {
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-       } else {
-               error = *((int *) retmsg->buf);
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-
-       /* Now get for each parent the object record */
-#ifdef hw_less_server_stress
-  if(0 != send_objectbyidquery(sockfd, childIDs, count, NULL, childrec)) {
-               efree(childIDs);
-               return -2;
-       }
-       efree(childIDs);
-#else
-       for(i=0; i<*count; i++) {
-               length = HEADER_LENGTH + sizeof(hw_objectID);
-               build_msg_header(&msg, length, childIDs[i], GETOBJECT_MESSAGE);
-
-               if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*                     perror("send_command"); */
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-
-               tmp = build_msg_int(msg.buf, childIDs[i]);
-
-               if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-                       efree(msg.buf);
-                       return(-1);
-                       }
-
-               efree(msg.buf);
-       }
-       efree(childIDs);
-
-       if(NULL == (objptr = (char **) emalloc(*count * sizeof(hw_objrec *)))) {
-               /* if emalloc fails, get at least all remaining  messages from server */
-               for(i=0; i<*count; i++) {
-                       retmsg = recv_hg_msg(sockfd);
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               }
-               *childrec = NULL;
-               lowerror = LE_MALLOC;
-               return(-1);
-       } else {
-               *childrec = objptr;
-
-               for(i=0; i<*count; i++) {
-                       retmsg = recv_hg_msg(sockfd);
-                       if ( retmsg != NULL )  {
-                               if(0 == (int) *(retmsg->buf)) {
-                                       *objptr = estrdup(retmsg->buf+sizeof(int));
-                                       objptr++;
-                                       efree(retmsg->buf);
-                                       efree(retmsg);
-                               } else {
-                                       *objptr = NULL;
-                                       objptr++;
-                                       efree(retmsg->buf);
-                                       efree(retmsg);
-                               }
-                       }
-               }
-       }
-#endif
-       return(0);
-}
-
-int send_pipedocument(int sockfd, char *host, hw_objectID objectID, int mode, int rootid, char **objattr, char **bodytag, char **text, int *count, char **urlprefix)
-{
-       hg_msg msg, *retmsg;
-       int     length, len;
-       char *tmp, header[80], *head_ptr, *sizestr;
-       struct sockaddr_in      serv_addr;
-       struct hostent      *hostptr;
-       char *hostip = NULL;
-       char *attributes = NULL;
-       char *documenttype;
-       char **anchors;
-       int newfd, fd, port, size, error, ancount;
-       int *ptr;
-
-       if(-1 == (fd = fnCOpenDataCon(sockfd, &port))) {
-                /* not set yet  efree(msg.buf); */
-                  return(-1);
-       }
-
-       /*
-       ** Get information about host
-       */
-       if(host) {
-               if((hostptr = gethostbyname(host)) == NULL) {
-                       HWSOCK_FCLOSE(fd);
-                       return(-2);
-               }
-       } else {
-               HWSOCK_FCLOSE(fd);
-               return(-2);
-       }
-        
-       switch(hostptr->h_addrtype) {
-               struct in_addr *ptr1;
-               case AF_INET:
-                       ptr1 = (struct in_addr *) hostptr->h_addr_list[0];
-                       hostip = inet_ntoa(*ptr1);
-                       break;
-               default:
-                       HWSOCK_FCLOSE(fd);
-                       return(-3);
-                       break;
-       }
-        
-       /* Bottom half of send_getobject */
-       if(0 > bh_send_getobject(sockfd, objectID)) {
-               HWSOCK_FCLOSE(fd);
-               return -4;
-       }
-
-       /* Upper half of send_getobject */
-       if(0 > (error = uh_send_getobject(sockfd, &attributes))) {
-               HWSOCK_FCLOSE(fd);
-               return error;
-       }
-
-       length = HEADER_LENGTH + sizeof(hw_objectID) + sizeof(int) + strlen(hostip) + 1 + strlen("Refno=0x12345678") + 1;
-       build_msg_header(&msg, length, msgid++, PIPEDOCUMENT_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-               if(attributes) efree(attributes);
-               lowerror = LE_MALLOC;
-               return(-5);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-       tmp = build_msg_int(tmp, port);
-       tmp = build_msg_str(tmp, hostip);
-       tmp = build_msg_str(tmp, "Refno=0x12345678");
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               if(attributes) efree(attributes);
-               efree(msg.buf);
-               HWSOCK_FCLOSE(fd);
-               return(-6);
-       }
-       efree(msg.buf);
-
-       /* Just check if the command was understood */
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL ) {
-               if(attributes) efree(attributes);
-               HWSOCK_FCLOSE(fd);
-               return(-7);
-       }
-
-       ptr = (int *) retmsg->buf;
-       if((ptr == NULL) || (*ptr != 0)) {
-               error = *ptr;
-               if(retmsg->buf) efree(retmsg->buf);
-               efree(retmsg);
-               if(attributes) efree(attributes);
-               HWSOCK_FCLOSE(fd);
-               return(error);
-       }
-
-       efree(retmsg->buf);
-       efree(retmsg);
-
-       /* passively open the data connection. The HG server is probably
-          already waiting for us.
-       */
-       len = sizeof(serv_addr);
-       if((newfd = accept(fd, (struct sockaddr *) &serv_addr, &len)) < 0) {
-/*             php_printf("client: can't open data connection to server\n"); */
-               if(attributes) efree(attributes);
-               HWSOCK_FCLOSE(fd);
-               return(-8);
-       } else {
-               HWSOCK_FCLOSE(fd);
-       }
-
-       /* First of all read the header */
-       head_ptr = header;
-       while((read_to(newfd, head_ptr, 1, rtimeout) == 1) && (*head_ptr != '\0')) {
-               head_ptr++;
-       }
-
-       /* Let's see how big the document is and read it into var text */
-       sizestr = strstr(header, "sz=");
-       if(sizestr) {
-               sizestr += 3;
-               sscanf(sizestr, "%d\n", &size);
-               *count = size;
-               if((size != 0) && (NULL != (*text = malloc(size+1)))) {
-                       read_to(newfd, *text, size, rtimeout);
-                (*text)[size] = '\0';
-               }
-       } else {
-               *text = NULL;
-       }
-
-       /* close the data connection */
-       HWSOCK_FCLOSE(newfd);
-
-       documenttype = fnAttributeValue(attributes, "DocumentType");
-
-       /* Make a copy with strdup (not estrdup), because we want to
-          keep the attributes in hw_document struct.
-       */
-       *objattr = strdup(attributes);
-       efree(attributes);
-
-       if((documenttype != NULL) && (!strcmp(documenttype, "text") != 0)) {
-               if(send_getanchorsobj(sockfd, objectID, &anchors, &ancount) == 0) {
-                       char **destrec, **reldestrec;
-#ifdef newlist
-                       zend_llist *pAnchorList = NULL;
-#else
-                       DLIST *pAnchorList = NULL;
-#endif
-
-                       /* Get dest as relative and absolut path */
-                       send_getdestforanchorsobj(sockfd, anchors, &destrec, ancount);
-                       send_getreldestforanchorsobj(sockfd, anchors, &reldestrec, ancount, rootid, objectID);
-                       pAnchorList = fnCreateAnchorList(objectID, anchors, destrec, reldestrec, ancount, mode);
-                       /* Free only the array, the objrecs has been freed in fnCreateAnchorList() */
-                       if(anchors) efree(anchors);
-                       if(destrec) efree(destrec);
-                       if(reldestrec) efree(reldestrec);
-
-                       if(pAnchorList != NULL) {
-                               char *newtext;
-                               char *body = NULL;
-
-                               newtext = fnInsAnchorsIntoText(*text, pAnchorList, &body, urlprefix);
-#ifdef newlist
-                               zend_llist_destroy(pAnchorList);
-                               efree(pAnchorList);
-#else
-                               dlst_kill(pAnchorList, fnDeleteAnchor);
-#endif
-                               *bodytag = strdup(body);
-                               if(body) efree(body);
-                               *text = newtext;
-                               *count = strlen(newtext);
-                       }
-               }
-       } else {
-               *bodytag = NULL;
-       }
-
-       if(documenttype) efree(documenttype);
-       return(0);
-}
-
-int send_pipecgi(int sockfd, char *host, hw_objectID objectID, char *cgi_env_str, char **objattr, char **text, int *count)
-{
-       hg_msg msg, *retmsg;
-       int     length, len, new_attr_len;
-       char *tmp, header[80], *head_ptr, *sizestr;
-       struct sockaddr_in      serv_addr;
-       struct hostent      *hostptr;
-       char *hostip = NULL;
-       char *attributes = NULL;
-       char *documenttype, *new_attr;
-       int newfd, fd, port, size, error;
-       int *ptr;
-
-       if(-1 == (fd = fnCOpenDataCon(sockfd, &port))) {
-                 /* not set yet? efree(msg.buf); */
-                  return(-1);
-       }
-
-       /*
-       ** Get information about host
-       */
-       if(host) {
-               if((hostptr = gethostbyname(host)) == NULL) {
-                       HWSOCK_FCLOSE(fd);
-                       return(-1);
-               }
-       } else {
-               HWSOCK_FCLOSE(fd);
-               return(-1);
-       }
-        
-       switch(hostptr->h_addrtype) {
-               struct in_addr *ptr1;
-               case AF_INET:
-                       ptr1 = (struct in_addr *) hostptr->h_addr_list[0];
-                       hostip = inet_ntoa(*ptr1);
-                       break;
-               default:
-/*                     php_printf(stderr, "unknown address type\n"); */
-                       break;
-       }
-        
-       /* Bottom half of send_getobject */
-       if(0 > bh_send_getobject(sockfd, objectID)) {
-               HWSOCK_FCLOSE(fd);
-               return -1;
-       }
-
-       /* Upper half of send_getobject */
-       if(0 > (error = uh_send_getobject(sockfd, &attributes))) {
-               HWSOCK_FCLOSE(fd);
-               return error;
-       }
-
-        new_attr_len = strlen(attributes) + strlen(cgi_env_str) + 2;
-        new_attr = malloc(new_attr_len);
-        strcpy(new_attr, attributes);
-        strcat(new_attr, cgi_env_str);
-       length = HEADER_LENGTH + strlen(new_attr) + 1 + sizeof(int) + strlen(hostip) + 1 + sizeof(int) + sizeof(int);
-       build_msg_header(&msg, length, msgid++, PIPECGI_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
-               if(attributes) efree(attributes);
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_str(msg.buf, hostip);
-       tmp = build_msg_int(tmp, port);
-       tmp = build_msg_str(tmp, new_attr);
-       tmp = build_msg_int(tmp, 1);
-       tmp = build_msg_int(tmp, 0x12345678);
-       free(new_attr);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               if(attributes) efree(attributes);
-               efree(msg.buf);
-               HWSOCK_FCLOSE(fd);
-               return(-1);
-       }
-       efree(msg.buf);
-
-       /* Just check if the command was understood */
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL ) {
-               if(attributes) efree(attributes);
-               HWSOCK_FCLOSE(fd);
-               return(-1);
-       }
-
-       ptr = (int *) retmsg->buf;
-       if((ptr == NULL) || (*ptr != 0)) {
-               if(retmsg->buf) efree(retmsg->buf);
-               efree(retmsg);
-               if(attributes) efree(attributes);
-               HWSOCK_FCLOSE(fd);
-               return(-1);
-       }
-
-       efree(retmsg->buf);
-       efree(retmsg);
-
-       /* passively open the data connection. The HG server is probably
-           already waiting for us.
-        */
-       len = sizeof(serv_addr);
-       if((newfd = accept(fd, (struct sockaddr *) &serv_addr, &len)) < 0) {
-               if(attributes) efree(attributes);
-               HWSOCK_FCLOSE(fd);
-               return(-1);
-       } else {
-               HWSOCK_FCLOSE(fd);
-       }
-
-       /* First of all read the header */
-       head_ptr = header;
-       while((read_to(newfd, head_ptr, 1, rtimeout) == 1) && (*head_ptr != '\0')) {
-               head_ptr++;
-       }
-
-       /* Let's see how big the document is and read it into var text */
-       sizestr = strstr(header, "sz=");
-       if(sizestr) {
-               sizestr += 3;
-               sscanf(sizestr, "%d\n", &size);
-               *count = size;
-               if((size != 0) && (NULL != (*text = malloc(size+1)))) {
-                 read_to(newfd, *text, size, rtimeout);
-               }
-       } else {
-               *text = NULL;
-       }
-
-       /* close the data connection */
-       HWSOCK_FCLOSE(newfd);
-
-       documenttype = fnAttributeValue(attributes, "DocumentType");
-
-       /* Make a copy with strdup (not estrdup), because we want to
-          keep the attributes in hw_document struct.
-       */
-       *objattr = strdup(attributes);
-       efree(attributes);
-
-       if(documenttype) efree(documenttype);
-       return(0);
-}
-
-int send_putdocument(int sockfd, char *host, hw_objectID parentID, char *objectRec, char *text, int count, hw_objectID *objectID)
-{
-       hg_msg msg, *retmsg;
-       int length, len;
-       char *tmp, header[80], parms[30], *head_ptr;
-       struct sockaddr_in serv_addr;
-       struct hostent *hostptr;
-       char *hostip = NULL;
-       int newfd, fd, port, error;
-       int *ptr;
-
-       /* First of all we have to insert the document record */
-        sprintf(parms, "Parent=0x%x", parentID);
-       length = HEADER_LENGTH + strlen(objectRec) + 1 + strlen(parms) + 1;
-
-       build_msg_header(&msg, length, msgid++, INSERTOBJECT_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_str(msg.buf, objectRec);
-       tmp = build_msg_str(tmp, parms);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-2);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL )  {
-               return(-3);
-       }
-
-       ptr = (int *) retmsg->buf;
-       if(0 == (error = *ptr)) {
-               ptr++;
-               *objectID = *ptr;
-       } else {
-               if(retmsg->buf) efree(retmsg->buf);
-               efree(retmsg);
-               return(error);
-       }
-
-       efree(retmsg->buf);
-       efree(retmsg);
-
-       /*
-       ** Get information about host
-       */
-       if(host) {
-               if((hostptr = gethostbyname(host)) == NULL) {
-                       /* close(fd); fd is not set yet */
-                       return(-4);
-               }
-       } else {
-               /* close(fd); fd is not set yet */
-               return(-5);
-       }
-        
-       switch(hostptr->h_addrtype) {
-               struct in_addr *ptr1;
-               case AF_INET:
-                       ptr1 = (struct in_addr *) hostptr->h_addr_list[0];
-                       hostip = inet_ntoa(*ptr1);
-                       break;
-               default:
-/*                     fprintf(stderr, "unknown address type\n"); */
-                       break;
-       }
-        
-       if(-1 == (fd = fnCOpenDataCon(sockfd, &port))) {
-                  efree(msg.buf);
-                  return(-6);
-       }
-
-       /* Start building the PUTDOCUMENT message. I works even if
-          the Refno is skipped. I guess the path can be omitted too. */
-       length = HEADER_LENGTH + sizeof(hw_objectID) + sizeof(int) + strlen(hostip) + 1 + strlen("Hyperwave") + 1+ strlen("Refno=0x12345678") + 1;
-
-       build_msg_header(&msg, length, msgid++, PUTDOCUMENT_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )        {
-               lowerror = LE_MALLOC;
-               return(-7);
-       }
-
-       tmp = build_msg_int(msg.buf, *objectID);
-       tmp = build_msg_int(tmp, port);
-       tmp = build_msg_str(tmp, hostip);
-       tmp = build_msg_str(tmp, "Hyperwave");
-       tmp = build_msg_str(tmp, "Refno=0x12345678");
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               HWSOCK_FCLOSE(fd);
-               return(-8);
-       }
-       efree(msg.buf);
-
-       /* passively open the data connection. The HG server is probably
-           already waiting for us.
-        */
-       len = sizeof(serv_addr);
-       if((newfd = accept(fd, (struct sockaddr *) &serv_addr, &len)) < 0) {
-               HWSOCK_FCLOSE(fd);
-               return(-9);
-       } else {
-               HWSOCK_FCLOSE(fd);
-       }
-
-       /* First of all write the header. According to the documentation
-          there should be a header first. Well, after some investigation
-          with tcpdump I found out, that Harmony and wavemaster don't
-          sent it. The also do not sent the Refno in the PUTDOCUMENT msg.
-          Anyway, we sent both. */
-       head_ptr = header;
-       sprintf(header, "HGHDR\nsz=%d\nref=12345678\n", count);
-       len = strlen(header) + 1;
-       if(len != write_to(newfd, header, len, wtimeout)) {
-               HWSOCK_FCLOSE(newfd);
-               return(-10);
-       }
-
-       /* And now the document */
-       if(count != write_to(newfd, text, count, wtimeout)) {
-               HWSOCK_FCLOSE(newfd);
-               return(-11);
-       }
-       
-       /* The data connection has to be close before the return
-          msg can be read. The server will not sent it before. */
-       HWSOCK_FCLOSE(newfd);
-
-       /* Just check if the command was understood */
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL ) {
-               HWSOCK_FCLOSE(fd);
-               return(-12);
-       }
-
-       ptr = (int *) retmsg->buf;
-       if((ptr == NULL) || (*ptr != 0)) {
-               if(retmsg->buf) efree(retmsg->buf);
-               efree(retmsg);
-               HWSOCK_FCLOSE(fd);
-               return(-13);
-       }
-
-       efree(retmsg->buf);
-       efree(retmsg);
-
-       return(0);
-}
-
-int send_getsrcbydest(int sockfd, hw_objectID objectID, char ***childrec, int *count)
-{
-       hg_msg msg, *retmsg;
-       int length, i, error;
-       char *tmp;
-       int *childIDs = NULL;
-       char **objptr;
-       int *ptr, *ptr1;
-
-       length = HEADER_LENGTH + sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, GETSRCBYDEST_MESSAGE);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, objectID);
-
-       if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-               efree(msg.buf);
-               return(-1);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL ) 
-               return(-1);
-
-       ptr = (int *) retmsg->buf;
-       if(ptr == NULL) {
-               if(retmsg) efree(retmsg);
-               return -1;
-       }
-       if(*ptr++ == 0) {
-               *count = *ptr;
-               ptr++;
-               if(NULL != (childIDs = emalloc(*count * sizeof(hw_objectID)))) {
-                       ptr1 = childIDs;
-                       for(i=0; i<*count; ptr++, i++)
-                               ptr1[i] = *ptr;
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               } else {
-                       efree(retmsg->buf);
-                       efree(retmsg);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-       } else {
-               error = *((int *) retmsg->buf);
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-
-       /* Now get for each source the object record */
-       for(i=0; i<*count; i++) {
-               length = HEADER_LENGTH + sizeof(hw_objectID);
-               build_msg_header(&msg, length, childIDs[i], GETOBJECT_MESSAGE);
-
-               if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*                     perror("send_command"); */
-                       efree(childIDs);
-                       lowerror = LE_MALLOC;
-                       return(-1);
-               }
-
-               tmp = build_msg_int(msg.buf, childIDs[i]);
-
-               if ( send_hg_msg(sockfd, &msg, length) == -1 )  {
-                       efree(childIDs);
-                       efree(msg.buf);
-                       return(-1);
-                       }
-
-               efree(msg.buf);
-       }
-       efree(childIDs);
-
-       if(NULL == (objptr = (char **) emalloc(*count * sizeof(hw_objrec *)))) {
-               /* if emalloc fails, get at least all remaining  messages from server */
-               for(i=0; i<*count; i++) {
-                       retmsg = recv_hg_msg(sockfd);
-                       efree(retmsg->buf);
-                       efree(retmsg);
-               }
-               *childrec = NULL;
-               lowerror = LE_MALLOC;
-               return(-1);
-       } else {
-               *childrec = objptr;
-
-               for(i=0; i<*count; i++) {
-                       retmsg = recv_hg_msg(sockfd);
-                       if ( retmsg != NULL )  {
-                               if(0 == (int) *(retmsg->buf)) {
-                                       *objptr = estrdup(retmsg->buf+sizeof(int));
-                                       objptr++;
-                                       efree(retmsg->buf);
-                                       efree(retmsg);
-                               } else {
-                                       *objptr = NULL;
-                                       objptr++;
-                                       efree(retmsg->buf);
-                                       efree(retmsg);
-                               }
-                       }
-               }
-       }
-
-       return(0);
-}
-
-int send_mapid(int sockfd, int servid, hw_objectID id, int *virtid)
-{
-       hg_msg msg, *retmsg;
-       int length, error;
-       char *tmp;
-       int *ptr;
-
-       length = HEADER_LENGTH + 2 * sizeof(hw_objectID);
-
-       build_msg_header(&msg, length, msgid++, HG_MAPID);
-
-       if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-       tmp = build_msg_int(msg.buf, servid);
-       tmp = build_msg_int(tmp, id);
-
-       if (-1 == send_hg_msg(sockfd, &msg, length))  {
-               efree(msg.buf);
-               return(-2);
-       }
-
-       efree(msg.buf);
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL )  {
-               return(-3);
-       }
-
-       ptr = (int *) retmsg->buf;
-       if(ptr == NULL) {
-               if(retmsg) efree(retmsg);
-               return -1;
-       }
-       if(*ptr++ == 0) {
-               *virtid = *ptr;
-       } else {
-               error = *((int *) retmsg->buf);
-               efree(retmsg->buf);
-               efree(retmsg);
-               return error;
-       }
-
-       return(0);
-}
-
-#define BUFFERLEN 200
-char *get_hw_info(hw_connection *conn) {
-       char temp[BUFFERLEN];
-       int len;
-       struct sockaddr_in serv_addr;
-
-       len = sizeof (serv_addr);
-       if(getsockname(conn->socket, (struct sockaddr *)&serv_addr, &len) < 0)
-               return(NULL);
-
-       snprintf(temp, BUFFERLEN, "%s, %s, %d, %s, %d, %d", conn->server_string, conn->hostname,
-                                      conn->version, conn->username,
-                                      serv_addr.sin_port, conn->swap_on);
-       return(estrdup(temp));
-}
-#undef BUFFERLEN
-
-static int send_hg_msg(int sockfd, hg_msg *msg, int length)
-{
-     char *buf, *tmp;
-
-#ifdef HW_DEBUG
-       php_printf("<b>Sending msg: </b>type = %d -- id = %d<br />\n", msg->msg_type, msg->version_msgid);
-#endif
-     if ( length < HEADER_LENGTH )  {
-/*          fprintf(stderr, "send_hg_msg: bad msg\n"); */
-          return(-1);
-     }
-
-     if ( (tmp = buf = (char *)emalloc(length)) == NULL )  {
-/*             perror("send_hg_msg"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-     }
-
-     memcpy(tmp, (char *) &(msg->length), 4);
-     tmp += 4;
-     memcpy(tmp, (char *) &(msg->version_msgid), 4);
-     tmp += 4;
-     memcpy(tmp, (char *) &(msg->msg_type), 4);
-     if ( msg->length > HEADER_LENGTH )  {
-          tmp += 4;
-          memcpy(tmp, msg->buf, length-HEADER_LENGTH);
-     }
-
-     if ( hg_write(sockfd, buf, length) == -1 )  {
-          efree(buf);
-          return(-1);
-     }
-
-     efree(buf);
-     return(0);
-}
-
-
-int send_ready(int sockfd)
-{
-     hg_msg ready_msg;
-
-     build_msg_header(&ready_msg, HEADER_LENGTH, version, READY_MESSAGE);
-     ready_msg.buf = NULL;
-
-     if ( send_hg_msg(sockfd, &ready_msg, HEADER_LENGTH) == -1 )  {
-          return(-1);
-     }
-
-     return(0);
-}
-
-
-int send_command(int sockfd, int command, char **answer)
-{
-       hg_msg comm_msg, *retmsg;
-       char *comm_str, *tmp;
-       int  respond = 1;
-       int  length;
-
-       if ( command == STAT_COMMAND )
-               comm_str = STAT_COMMAND_STR;
-       else
-               comm_str = WHO_COMMAND_STR;
-       length = HEADER_LENGTH + sizeof(respond) + strlen(comm_str) + 1;
-
-       build_msg_header(&comm_msg, length, msgid++, COMMAND_MESSAGE);
-
-       if ( (comm_msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL )  {
-/*             perror("send_command"); */
-               lowerror = LE_MALLOC;
-               return(-1);
-       }
-
-
-       tmp = build_msg_int(comm_msg.buf, respond);
-       tmp = build_msg_str(tmp, comm_str);
-
-
-       if ( send_hg_msg(sockfd, &comm_msg, length) == -1 )  {
-               efree(comm_msg.buf);
-               return(-1);
-       }
-       efree(comm_msg.buf);
-
-       /* Just check if the command was understood */
-       retmsg = recv_hg_msg(sockfd);
-       if ( retmsg == NULL ) {
-               return(-1);
-       }
-
-       *answer = retmsg->buf;
-       efree(retmsg);
-
-       return(0);
-}
-
-
-static void build_msg_header(hg_msg *msg, int length, int version_msgid, int msg_type)
-{
-     if ( swap_on )  {
-          msg->length  = swap(length);
-          msg->version_msgid = swap(version_msgid);
-          msg->msg_type  = swap(msg_type);
-     }
-     else  {
-          msg->length  = length;
-          msg->version_msgid = version_msgid;
-          msg->msg_type  = msg_type;
-     }
-}
-
-
-static char *build_msg_int(char *buf, int val) {
-       int tmp;
-
-#ifdef HW_DEBUG
-       php_printf("   Added int to header: <b>%d</b><br />\n", val);
-#endif
-       tmp = swap_on ? swap(val) : val;
-       memcpy(buf, (char *)&tmp, 4);
-
-       return(buf+4);
-}
-
-
-static char *build_msg_str(char *buf, char *str)
-{
-     int len = strlen(str)+1;
-
-#ifdef HW_DEBUG
-       php_printf("   Added str to header: <b>%s</b> (%d)<br />\n", str, strlen(str));
-#endif
-
-     memcpy(buf, str, len);
-
-     return(buf+len);
-}
-
-
-static int swap(int val)
-{
-     int tmp;
-
-     ((char*)&tmp)[0] = ((char*)&val)[3];
-     ((char*)&tmp)[1] = ((char*)&val)[2];
-     ((char*)&tmp)[2] = ((char*)&val)[1];
-     ((char*)&tmp)[3] = ((char*)&val)[0];
-
-     return(tmp);
-}
-
-
-void close_hg_connection(int sockfd)
-{
-       shutdown(sockfd, 2);
-       HWSOCK_FCLOSE(sockfd);
-}
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * End:
- */
-
diff --git a/ext/hyperwave/hg_comm.h b/ext/hyperwave/hg_comm.h
deleted file mode 100644 (file)
index 08a5065..0000000
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
-   +----------------------------------------------------------------------+
-   | PHP Version 4                                                        |
-   +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2003 The PHP Group                                |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 3.0 of the PHP license,       |
-   | that is bundled with this package in the file LICENSE, and is        |
-   | available through the world-wide-web at the following url:           |
-   | http://www.php.net/license/3_0.txt.                                  |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@php.net so we can mail you a copy immediately.               |
-   +----------------------------------------------------------------------+
-   | Author: Rasmus Lerdorf <rasmus@php.net>                              |
-   +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifndef HG_COMM_H
-#define HG_COMM_H
-
-#if HYPERWAVE
-
-#define newlist
-
-#include "hw_error.h"
-#ifdef newlist
-#else
-#include "dlist.h"
-#endif
-#define HG_SERVER_PORT   418
-
-#define F_DISTRIBUTED 0x80000000
-#define F_COMPRESSED  0x40000000
-#define F_VERSION     0x00003fff
-#define HW_VERSION    717L     /* 7.17 */
-
-#define HEADER_LENGTH 12
-
-#define STAT_COMMAND_STR  "stat"
-#define WHO_COMMAND_STR   "who"
-#define STAT_COMMAND      1
-#define WHO_COMMAND       2
-
-#define GETDOCBYANCHOR_MESSAGE        2
-#define GETCHILDCOLL_MESSAGE          3
-#define GETPARENT_MESSAGE             4
-#define GETCHILDDOCCOLL_MESSAGE       5
-#define GETOBJECT_MESSAGE             7
-#define GETANCHORS_MESSAGE            8
-#define GETOBJBYQUERY_MESSAGE         9
-#define GETOBJBYQUERYCOLL_MESSAGE    10
-#define OBJECTBYIDQUERY_MESSAGE      11
-#define GETTEXT_MESSAGE              12
-#define INSDOC_MESSAGE               14
-#define INSCOLL_MESSAGE              17
-#define GETSRCBYDEST_MESSAGE         19
-#define MVCPDOCSCOLL_MESSAGE         22
-#define MVCPCOLLSCOLL_MESSAGE        23
-#define IDENTIFY_MESSAGE             24
-#define READY_MESSAGE                25
-#define COMMAND_MESSAGE              26
-#define CHANGEOBJECT_MESSAGE         27
-#define EDITTEXT_MESSAGE             28
-#define GETANDLOCK_MESSAGE           29
-#define UNLOCK_MESSAGE               30
-#define INCOLLECTIONS_MESSAGE        31
-#define INSERTOBJECT_MESSAGE         32
-#define GETOBJBYFTQUERY_MESSAGE      34
-#define GETOBJBYFTQUERYCOLL_MESSAGE  35
-#define PIPEDOCUMENT_MESSAGE         36
-#define DELETEOBJECT_MESSAGE         37
-#define PUTDOCUMENT_MESSAGE          38
-#define GETREMOTE_MESSAGE            39
-#define GETREMOTECHILDREN_MESSAGE    40
-#define HG_MAPID                     43
-#define CHILDREN_MESSAGE             44
-#define GETCGI_MESSAGE               45
-#define PIPECGI_MESSAGE              46
-
-#define HW_DEFAULT_LINK               0
-#define HW_IMAGE_LINK                 1
-#define HW_BACKGROUND_LINK            2
-#define HW_INTAG_LINK                 3
-#define HW_APPLET_LINK                4
-#define HW_INTAGNODEL_LINK            5
-
-#define COPY                          0
-#define MOVE                          1
-#define DOCUMENT                      0
-#define COLLECTION                    1
-
-
-#ifdef PHP_WIN32
-# define SOCK_ERR INVALID_SOCKET
-# define SOCK_CONN_ERR SOCKET_ERROR
-# define HWSOCK_FCLOSE(s) closesocket(s)
-#else
-# define SOCK_ERR -1
-# define SOCK_CONN_ERR -1
-# define HWSOCK_FCLOSE(s) close(s)
-#endif
-
-
-/* Low error messages */
-#define LE_MALLOC                    -1
-
-typedef struct {
-       int id;                         /* object ID of anchor */
-       int tanchor;            /* Type of anchor. Can be 1=Src, 2=Dest */
-       int start;                      /* start of anchor */
-       int end;                                /* end of anchor */
-       char *nameanchor;                       /* name tag attribute of destination document */
-       /* if anchor is of type Src the following are used as well */
-       char *destdocname;                      /* name of destination document */
-       char *link;                     /* url for external destination */
-       int linktype;           /* type of link. see above */
-       char *tagattr;          /* more attributes of tag, like Border=0 */
-       char *htmlattr; /* */
-       char *codebase;         /* codebase of applet */
-       char *code;             /* code of applet */
-       char *fragment;         /* name link of Src */
-
-       /* if anchor is of type Dest the following are used as well */
-       char *keyword;          /* name link of Dest */
-       } ANCHOR;
-
-typedef struct  {
-     int  length;
-     int  version_msgid;
-     int  msg_type;
-     char *buf;
-} hg_msg;
-
-typedef struct {
-       int socket;
-       int swap_on;
-       int version;
-       char *server_string;
-        char *hostname;
-        char *username;
-       int lasterror;
-       int linkroot;
-} hw_connection;
-
-typedef int hw_objectID;
-typedef char hw_objrec;
-typedef float hw_float;
-
-#ifdef newlist
-void fnDeleteAnchor(void *ptr1);
-void fnListAnchor(zend_llist *pAnchorList);
-zend_llist *fnCreateAnchorList(hw_objectID objID, char **anchors, char **docofanchorrec, char **reldestrec, int ancount, int anchormode);
-char *fnInsAnchorsIntoText(char *text, zend_llist *pAnchorList, char **bodytag, char **urlprefix);
-int fnCmpAnchors(const void *e1, const void *e2 TSRMLS_DC);
-ANCHOR *fnAddAnchor(zend_llist *pAnchorList, int objectID, int start, int end);
-#else
-void fnDeleteAnchor(ANCHOR *ptr);
-void fnListAnchor(DLIST *pAnchorList);
-DLIST *fnCreateAnchorList(hw_objectID objID, char **anchors, char **docofanchorrec, char **reldestrec, int ancount, int anchormode);
-char *fnInsAnchorsIntoText(char *text, DLIST *pAnchorList, char **bodytag, char **urlprefix);
-int fnCmpAnchors(ANCHOR *a1, ANCHOR *a2 TSRMLS_DC);
-ANCHOR *fnAddAnchor(DLIST *pAnchorList, int objectID, int start, int end);
-#endif
-extern void set_swap(int do_swap);
-extern int  open_hg_connection(char *server_name, int port);
-extern void close_hg_connection(int sockfd);
-extern int initialize_hg_connection(int sockfd, int *do_swap, int *version, char **userdata, char **server_string, char *username, char *password);
-
-extern int send_ready(int sockfd);
-extern int send_command(int sockfd, int command, char **answer);
-
-extern hg_msg *recv_hg_msg(int sockfd);
-extern hg_msg *recv_ready(int sockfd);
-extern hg_msg *recv_command(int sockfd);
-
-extern char *fnInsStr(char *str, int pos, char *insstr);
-extern int fnAttributeCompare(char *object, char *attrname, char *value);
-extern char *fnAttributeValue(char *object, char *attrname);
-extern int getrellink(int sockfd, int rootID, int thisID, int destID, char **reldesstr);
-
-extern int send_deleteobject(int sockfd, hw_objectID objectID);
-extern int send_changeobject(int sockfd, hw_objectID objectID, char *mod);
-extern int send_groupchangeobject(int sockfd, hw_objectID objectID, char *mod);
-extern int send_getobject(int sockfd, hw_objectID objectID, char **attributes);
-extern int send_getandlock(int sockfd, hw_objectID objectID, char **attributes);
-extern int send_lock(int sockfd, hw_objectID objectID);
-extern int send_unlock(int sockfd, hw_objectID objectID);
-extern int send_gettext(int sockfd, hw_objectID objectID, int mode, int rootid, char **objattr, char **bodytag, char **text, int *count, char *urlprefix);
-extern int send_edittext(int sockfd, char *objattr, char *text);
-extern int send_getcgi(int sockfd, hw_objectID objectID, char *cgi_env_str, char **objattr, char **text, int *count);
-extern int send_getremote(int sockfd, hw_objectID objectID, char **objattr, char **text, int *count);
-extern int send_getremotechildren(int sockfd, char *attributes, char **text, int **childIDs, int *count);
-extern int send_docbyanchor(int sockfd, hw_objectID objectID, hw_objectID *anchorID);
-extern int send_docbyanchorobj(int sockfd, hw_objectID objectID, char **objrec);
-extern int send_mvcpdocscollscoll(int sockfd, hw_objectID *objectIDs, int count, int from, int dest, int cpmv, int docscoll);
-extern int send_childrenobj(int sockfd, hw_objectID objectID, char ***childrec, int *count);
-extern int send_getchildcoll(int sockfd, int objectID, hw_objectID **childIDs, int *count);
-extern int send_getchildcollobj(int sockfd, hw_objectID objectID, hw_objrec ***childrec, int *count);
-extern int send_getchilddoccoll(int sockfd, hw_objectID objectID, hw_objectID **childIDs, int *count);
-extern int send_getchilddoccollobj(int sockfd, hw_objectID objectID, hw_objrec ***childrec, int *count);
-extern int send_getanchors(int sockfd, hw_objectID objectID, hw_objectID **anchorIDs, int *count);
-extern int send_getanchorsobj(int sockfd, hw_objectID objectID, char ***childrec, int *count);
-extern int send_objectbyidquery(int sockfd, hw_objectID *IDs, int *count, char *query, char ***objrecs);
-extern int send_getobjbyquery(int sockfd, char *query, int maxhits, hw_objectID **childIDs, int *count);
-extern int send_getobjbyqueryobj(int sockfd, char *query, int maxhits, char ***childrec, int *count);
-extern int send_getobjbyquerycoll(int sockfd, hw_objectID collID, char *query, int maxhits, hw_objectID **childIDs, int *count);
-extern int send_getobjbyquerycollobj(int sockfd, hw_objectID collID, char *query, int maxhits, char ***childrec, int *count);
-extern int send_getobjbyftquery(int sockfd, char *query, int maxhits, hw_objectID **childIDs, float **weights, int *count);
-extern int send_getobjbyftqueryobj(int sockfd, char *query, int maxhits, char ***childrec, float **weights, int *count);
-extern int send_getobjbyftquerycoll(int sockfd, hw_objectID collID, char *query, int maxhits, hw_objectID **childIDs, float **weight, int *count);
-extern int send_getobjbyftquerycollobj(int sockfd, hw_objectID collID, char *query, int maxhits, char ***childrec, float **weight, int *count);
-extern int send_identify(int sockfd, char *name, char *passwd, char **userdata);
-extern int send_getparents(int sockfd, hw_objectID objectID, hw_objectID **childIDs, int *count);
-extern int send_children(int sockfd, hw_objectID objectID, hw_objectID **childIDs, int *count);
-extern int send_getparentsobj(int sockfd, hw_objectID objectID, char ***childrec, int *count);
-extern int send_pipedocument(int sockfd, char *hostname, hw_objectID objectID, int mode, int rootid, char** objattr, char **bodytag, char **text, int *count, char **urlprefix);
-extern int send_pipecgi(int sockfd, char *host, hw_objectID objectID, char *cgi_env_str, char **objattr, char **text, int *count);
-extern int send_putdocument(int sockfd, char *hostname, hw_objectID parentID, char *objectRec, char *text, int count, hw_objectID *objectID);
-extern int send_inscoll(int sockfd, hw_objectID objectID, char *objrec, hw_objectID *new_objectID);
-extern int send_insertobject(int sockfd, char *objrec, char *parms, hw_objectID *objectID);
-extern int send_insdoc(int sockfd, hw_objectID objectID, char *objrec, char *text, hw_objectID *new_objectID);
-extern int send_incollections(int sockfd, int retcol, int cobjids, hw_objectID *objectIDs, int ccollids, hw_objectID *collIDs, int *count, hw_objectID **retIDs);
-extern int send_getsrcbydest(int sockfd, hw_objectID objid, char ***childrec, int *count);
-extern int send_mapid(int sockfd, int servid, hw_objectID id, int *virtid);
-extern int send_dummy(int sockfd, hw_objectID objectID, int msgid, char **attributes);
-extern int send_insertanchors(char **text, int *count, char **anchors, char **destrec, int ancount, char **urlprefix, char **bodytag);
-extern char *get_hw_info(hw_connection *conn);
-
-#define send_mvcpdocscoll(sockfd, objectIDs, count, from, dest, mvcp) \
-               send_mvcpdocscollscoll(sockfd, objectIDs, count, from, dest, mvcp, DOCUMENT)
-#define send_mvcpcollscoll(sockfd, objectIDs, count, from, dest, mvcp) \
-               send_mvcpdocscollscoll(sockfd, objectIDs, count, from, dest, mvcp, COLLECTION)
-
-#endif
-#endif
diff --git a/ext/hyperwave/hw.c b/ext/hyperwave/hw.c
deleted file mode 100644 (file)
index 60f97de..0000000
+++ /dev/null
@@ -1,4081 +0,0 @@
-/*
-   +----------------------------------------------------------------------+
-   | PHP Version 4                                                        |
-   +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2003 The PHP Group                                |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 3.0 of the PHP license,       |
-   | that is bundled with this package in the file LICENSE, and is        |
-   | available through the world-wide-web at the following url:           |
-   | http://www.php.net/license/3_0.txt.                                  |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@php.net so we can mail you a copy immediately.               |
-   +----------------------------------------------------------------------+
-   | Author: Uwe Steinmann <Uwe.Steinmann@fernuni-hagen.de>               |
-   +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#include <stdlib.h>
-#include <errno.h>
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "php.h"
-#include "php_globals.h"
-#include "ext/standard/php_standard.h"
-#include "ext/standard/head.h"
-#include "ext/standard/info.h"
-#include "fopen_wrappers.h"
-#include "SAPI.h"
-
-#ifdef PHP_WIN32
-#include <winsock2.h>
-#endif
-
-#if HYPERWAVE
-
-#include "php_ini.h"
-#include "php_hyperwave.h"
-
-static int le_socketp, le_psocketp, le_document;
-
-/*hw_module php_hw_module;*/
-
-#define HW_ATTR_NONE   1
-#define HW_ATTR_LANG   2
-#define HW_ATTR_NR     3
-
-function_entry hw_functions[] = {
-       PHP_FE(hw_connect,                                                              NULL)
-       PHP_FE(hw_pconnect,                                                             NULL)
-       PHP_FE(hw_close,                                                                NULL)
-       PHP_FE(hw_root,                                                                 NULL)
-       PHP_FE(hw_info,                                                                 NULL)
-       PHP_FE(hw_connection_info,                                              NULL)
-       PHP_FE(hw_error,                                                                NULL)
-       PHP_FE(hw_errormsg,                                                             NULL)
-       PHP_FE(hw_getparentsobj,                                                NULL)
-       PHP_FE(hw_getparents,                                                   NULL)
-       PHP_FE(hw_children,                                                             NULL)
-       PHP_FE(hw_childrenobj,                                                  NULL)
-       PHP_FE(hw_getchildcoll,                                                 NULL)
-       PHP_FE(hw_getchildcollobj,                                              NULL)
-       PHP_FE(hw_getobject,                                                    NULL)
-       PHP_FE(hw_getandlock,                                                   NULL)
-       PHP_FE(hw_unlock,                                                               NULL)
-       PHP_FE(hw_gettext,                                                              NULL)
-       PHP_FE(hw_edittext,                                                             NULL)
-       PHP_FE(hw_getcgi,                                                               NULL)
-       PHP_FE(hw_getremote,                                                    NULL)
-       PHP_FE(hw_getremotechildren,                                    NULL)
-       PHP_FE(hw_pipedocument,                                                 NULL)
-       PHP_FE(hw_pipecgi,                                                              NULL)
-       PHP_FE(hw_insertdocument,                                               NULL)
-       PHP_FE(hw_mv,                                                                   NULL)
-       PHP_FE(hw_cp,                                                                   NULL)
-       PHP_FE(hw_deleteobject,                                                 NULL)
-       PHP_FE(hw_changeobject,                                                 NULL)
-       PHP_FE(hw_modifyobject,                                                 NULL)
-       PHP_FE(hw_docbyanchor,                                                  NULL)
-       PHP_FE(hw_docbyanchorobj,                                               NULL)
-       PHP_FE(hw_getobjectbyquery,                                             NULL)
-       PHP_FE(hw_getobjectbyqueryobj,                                  NULL)
-       PHP_FE(hw_getobjectbyquerycoll,                                 NULL)
-       PHP_FE(hw_getobjectbyquerycollobj,                              NULL)
-       PHP_FE(hw_getobjectbyftquery,                                           NULL)
-       PHP_FE(hw_getobjectbyftqueryobj,                                        NULL)
-       PHP_FE(hw_getobjectbyftquerycoll,                                       NULL)
-       PHP_FE(hw_getobjectbyftquerycollobj,                            NULL)
-       PHP_FE(hw_getchilddoccoll,                                              NULL)
-       PHP_FE(hw_getchilddoccollobj,                                   NULL)
-       PHP_FE(hw_getanchors,                                                   NULL)
-       PHP_FE(hw_getanchorsobj,                                                NULL)
-       PHP_FE(hw_getusername,                                                  NULL)
-       PHP_FE(hw_setlinkroot,                                                  NULL)
-       PHP_FE(hw_identify,                                                             NULL)
-       PHP_FE(hw_free_document,                                                NULL)
-       PHP_FE(hw_new_document,                                                 NULL)
-       PHP_FE(hw_new_document_from_file,                                                       NULL)
-       PHP_FE(hw_output_document,                                              NULL)
-       PHP_FE(hw_document_size,                                                NULL)
-       PHP_FE(hw_document_attributes,                                  NULL)
-       PHP_FE(hw_document_bodytag,                                             NULL)
-       PHP_FE(hw_document_content,                                             NULL)
-       PHP_FE(hw_document_setcontent,                                          NULL)
-       PHP_FE(hw_objrec2array,                                                 NULL)
-       PHP_FE(hw_array2objrec,                                                 NULL)
-       PHP_FE(hw_incollections,                                                NULL)
-       PHP_FE(hw_inscoll,                                                              NULL)
-       PHP_FE(hw_insertobject,                                                 NULL)
-       PHP_FE(hw_insdoc,                                                               NULL)
-       PHP_FE(hw_getsrcbydestobj,                                              NULL)
-       PHP_FE(hw_insertanchors,                                                        NULL)
-       PHP_FE(hw_getrellink,                                                   NULL)
-       PHP_FE(hw_who,                                                                  NULL)
-       PHP_FE(hw_stat,                                                                 NULL)
-       PHP_FE(hw_mapid,                                                                        NULL)
-       PHP_FE(hw_dummy,                                                                NULL)
-       {NULL, NULL, NULL}
-};
-
-zend_module_entry hw_module_entry = {
-       STANDARD_MODULE_HEADER,
-       "hyperwave", hw_functions, PHP_MINIT(hw), PHP_MSHUTDOWN(hw), NULL, NULL, PHP_MINFO(hw), NO_VERSION_YET, STANDARD_MODULE_PROPERTIES
-};
-
-/*
-#ifdef ZTS
-int hw_globals_id;
-#else
-PHP_HW_API php_hw_globals hw_globals;
-#endif
-*/
-
-ZEND_DECLARE_MODULE_GLOBALS(hw)
-
-#ifdef COMPILE_DL_HYPERWAVE
-ZEND_GET_MODULE(hw)
-#endif
-
-#define HW_FETCH_LINK(hw_zval) \
-       convert_to_long_ex(hw_zval); \
-       link = Z_LVAL_PP(hw_zval); \
-       ptr = (hw_connection *) zend_list_find(link, &type); \
-       if(!ptr || (type != le_socketp && type != le_psocketp)) { \
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find file identifier %d", link); \
-               RETURN_FALSE; \
-       }
-
-#define HW_FETCH_ID(hw_zval) \
-       convert_to_long_ex(hw_zval); \
-       id = Z_LVAL_PP(hw_zval); \
-       ptr = (hw_document *) zend_list_find(id, &type); \
-       if(!ptr || (type != le_document)) { \
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find file identifier %d", id); \
-               RETURN_FALSE; \
-       }
-
-void print_msg(hg_msg *msg, char *str, int txt);
-
-void _close_hw_link(zend_rsrc_list_entry *rsrc TSRMLS_DC)
-{
-       hw_connection *conn = (hw_connection *)rsrc->ptr;
-
-       if(conn->hostname)
-               free(conn->hostname);
-       if(conn->username)
-               free(conn->username);
-       close(conn->socket);
-       free(conn);
-       HwSG(num_links)--;
-}
-
-void _close_hw_plink(zend_rsrc_list_entry *rsrc TSRMLS_DC)
-{
-       hw_connection *conn = (hw_connection *)rsrc->ptr;
-
-       if(conn->hostname)
-               free(conn->hostname);
-       if(conn->username)
-               free(conn->username);
-       close(conn->socket);
-       free(conn);
-       HwSG(num_links)--;
-       HwSG(num_persistent)--;
-}
-
-void _free_hw_document(zend_rsrc_list_entry *rsrc TSRMLS_DC)
-{
-       hw_document *doc = (hw_document *)rsrc->ptr;
-       if(doc->data)
-               free(doc->data);
-       if(doc->attributes)
-               free(doc->attributes);
-       if(doc->bodytag)
-               free(doc->bodytag);
-       free(doc);
-}
-
-static void php_hw_init_globals(zend_hw_globals *hw_globals)
-{
-       hw_globals->num_persistent = 0;
-}
-
-static PHP_INI_MH(OnHyperwavePort)
-{
-       if (new_value==NULL) {
-               HwSG(default_port) = HG_SERVER_PORT;
-       } else {
-               HwSG(default_port) = atoi(new_value);
-       }
-       return SUCCESS;
-}
-
-PHP_INI_BEGIN()
-       STD_PHP_INI_ENTRY("hyperwave.allow_persistent", "0", PHP_INI_SYSTEM, OnUpdateLong, allow_persistent, zend_hw_globals, hw_globals)
-       PHP_INI_ENTRY("hyperwave.default_port", "418", PHP_INI_ALL,     OnHyperwavePort)
-PHP_INI_END()
-
-PHP_MINIT_FUNCTION(hw)
-{
-       ZEND_INIT_MODULE_GLOBALS(hw, php_hw_init_globals, NULL);
-
-       REGISTER_INI_ENTRIES();
-       le_socketp = zend_register_list_destructors_ex(_close_hw_link, NULL, "hyperwave link", module_number);
-       le_psocketp = zend_register_list_destructors_ex(NULL, _close_hw_plink, "hyperwave link persistent", module_number);
-       le_document = zend_register_list_destructors_ex(_free_hw_document, NULL, "hyperwave document", module_number);
-       Z_TYPE(hw_module_entry) = type;
-
-       REGISTER_LONG_CONSTANT("HW_ATTR_LANG", HW_ATTR_LANG, CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("HW_ATTR_NR", HW_ATTR_NR, CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("HW_ATTR_NONE", HW_ATTR_NONE, CONST_CS | CONST_PERSISTENT);
-       return SUCCESS;
-}
-
-PHP_MSHUTDOWN_FUNCTION(hw)
-{
-       UNREGISTER_INI_ENTRIES();
-       return SUCCESS;
-}
-
-/* {{{ make_return_objrec
- * creates an array in return value and frees all memory
- * Also adds as an assoc. array at the end of the return array with
- * statistics.
- */
-int make_return_objrec(pval **return_value, char **objrecs, int count)
-{
-       zval *stat_arr;
-       int i;
-       int hidden, collhead, fullcollhead, total;
-        int collheadnr, fullcollheadnr;
-
-       array_init(*return_value);
-
-       hidden = collhead = fullcollhead = total = 0;
-       collheadnr = fullcollheadnr = -1;
-       for(i=0; i<count; i++) {
-               /* Fill the array with entries. No need to free objrecs[i], since
-                * it is not duplicated in add_next_index_string().
-                */
-               if(NULL != objrecs[i]) {
-                       if(0 == fnAttributeCompare(objrecs[i], "PresentationHints", "Hidden"))
-                               hidden++;
-                       if(0 == fnAttributeCompare(objrecs[i], "PresentationHints", "CollectionHead")) {
-                               collhead++;
-                               collheadnr = total;
-                       }
-                       if(0 == fnAttributeCompare(objrecs[i], "PresentationHints", "FullCollectionHead")) {
-                               fullcollhead++;
-                               fullcollheadnr = total;
-                       }
-                       total++;
-                       add_next_index_string(*return_value, objrecs[i], 0);
-               }
-       }
-       efree(objrecs);
-
-       /* Array for statistics */
-       MAKE_STD_ZVAL(stat_arr);
-       array_init(stat_arr);
-
-       add_assoc_long(stat_arr, "Hidden", hidden);
-       add_assoc_long(stat_arr, "CollectionHead", collhead);
-       add_assoc_long(stat_arr, "FullCollectionHead", fullcollhead);
-       add_assoc_long(stat_arr, "Total", total);
-       add_assoc_long(stat_arr, "CollectionHeadNr", collheadnr);
-       add_assoc_long(stat_arr, "FullCollectionHeadNr", fullcollheadnr);
-
-       /* Add the stat array */
-       zend_hash_next_index_insert(Z_ARRVAL_PP(return_value), &stat_arr, sizeof(zval), NULL);
-
-       return 0;
-}
-/* }}} */
-
-/* {{{ make2_return_array_from_objrec
-** creates an array return value from object record
-*/
-int make2_return_array_from_objrec(pval **return_value, char *objrec, zval *sarr) {
-       char *attrname, *str, *temp, language[3];
-       zval *spec_arr;
-       char *strtok_buf = NULL;
-       
-       /* Create an array with an entry containing specs for each attribute
-          and fill in the specs for Title, Description, Keyword, Group.
-          If an array is passed as the last argument use it instead.
-        */
-       if(NULL != sarr) {
-               spec_arr = sarr;
-       } else {
-               MAKE_STD_ZVAL(spec_arr);
-               array_init(spec_arr);
-               add_assoc_long(spec_arr, "Title", HW_ATTR_LANG);
-               add_assoc_long(spec_arr, "Description", HW_ATTR_LANG);
-               add_assoc_long(spec_arr, "Keyword", HW_ATTR_LANG);
-               add_assoc_long(spec_arr, "Group", HW_ATTR_NONE);
-               add_assoc_long(spec_arr, "HtmlAttr", HW_ATTR_NONE);
-               add_assoc_long(spec_arr, "Parent", HW_ATTR_NONE);
-               add_assoc_long(spec_arr, "SQLStmt", HW_ATTR_NR);
-       }
-
-       array_init(*return_value);
-
-       /* Loop through the attributes of object record and check
-          if the attribute has a specification. If it has the value
-          is added to array in spec record. If not it is added straight
-          to the return_value array.
-       */
-       temp = estrdup(objrec);
-       attrname = php_strtok_r(temp, "\n", &strtok_buf);
-       while(attrname != NULL) {
-               zval *data, **dataptr;
-               long spec;
-               str = attrname;
-
-               /* Check if a specification is available.
-                  If it isn't available then insert the attribute as
-                  a string into the return array
-               */
-               while((*str != '=') && (*str != '\0'))
-                       str++;
-               *str = '\0';
-               str++;
-               if(zend_hash_find(Z_ARRVAL_P(spec_arr), attrname, strlen(attrname)+1, (void **) &dataptr) == FAILURE) {
-                       add_assoc_string(*return_value, attrname, str, 1);
-               } else {
-                       zval *newarr;
-                       data = *dataptr;
-                       spec = Z_LVAL_P(data);
-
-                       if(zend_hash_find(Z_ARRVAL_PP(return_value), attrname, strlen(attrname)+1, (void **) &dataptr) == FAILURE) {
-                               MAKE_STD_ZVAL(newarr);
-                               array_init(newarr);
-                               zend_hash_add(Z_ARRVAL_PP(return_value), attrname, strlen(attrname)+1, &newarr, sizeof(zval *), NULL);
-                       } else {
-                               newarr = *dataptr;
-                       }
-
-                       switch(spec) {
-                               case HW_ATTR_LANG:
-                                       if(str[2] == ':') {
-                                               str[2] = '\0';
-                                               strcpy(language, str);
-                                               str += 3;
-                                       } else
-                                               strcpy(language, "xx");
-
-                                       add_assoc_string(newarr, language, str, 1);
-                                       break;
-                               case HW_ATTR_NR:
-                                       if(str[1] == ':') {
-                                               str[1] = '\0';
-                                               strcpy(language, str);
-                                               str += 2;
-                                       } else
-                                               strcpy(language, "x");
-
-                                       add_assoc_string(newarr, language, str, 1);
-                                       break;
-                               case HW_ATTR_NONE:
-                                       add_next_index_string(newarr, str, 1);
-                                       break;
-                       }
-               }
-
-               attrname = php_strtok_r(NULL, "\n", &strtok_buf);
-       }
-       if(NULL == sarr){
-/*
-               spec_arr->refcount--;
-               zend_hash_destroy(Z_ARRVAL_P(spec_arr));
-               efree(Z_ARRVAL_P(spec_arr));
-*/
-               zval_dtor(spec_arr);
-               efree(spec_arr);
-       }
-       efree(temp);
-
-       return(0);
-}
-/* }}} */
-
-/* {{{ make_return_array_from_objrec
- */
-int make_return_array_from_objrec(pval **return_value, char *objrec) {
-       char *attrname, *str, *temp, language[3], *title;
-       int iTitle, iDesc, iKeyword, iGroup;
-       zval *title_arr;
-       zval *desc_arr;
-       zval *keyword_arr;
-       zval *group_arr;
-       int hasTitle = 0;
-       int hasDescription = 0;
-       int hasKeyword = 0;
-       int hasGroup = 0;
-       char *strtok_buf;
-
-       MAKE_STD_ZVAL(title_arr);
-       MAKE_STD_ZVAL(desc_arr);
-       MAKE_STD_ZVAL(keyword_arr);
-       MAKE_STD_ZVAL(group_arr);
-
-       array_init(*return_value);
-
-       /* Fill Array of titles, descriptions and keywords */
-       temp = estrdup(objrec);
-       attrname = php_strtok_r(temp, "\n", &strtok_buf);
-       while(attrname != NULL) {
-               str = attrname;
-               iTitle = 0;
-               iDesc = 0;
-               iKeyword = 0;
-               iGroup = 0;
-               if(0 == strncmp(attrname, "Title=", 6)) {
-                       if (hasTitle == 0) {
-                               return -1;
-                       }
-                       array_init(title_arr);
-                       hasTitle = 1;
-                       str += 6;
-                       iTitle = 1;
-               } else if(0 == strncmp(attrname, "Description=", 12)) {
-                       if (hasDescription == 0) {
-                               return -1;
-                       }
-                       array_init(desc_arr);
-                       hasDescription = 1;
-                       str += 12;
-                       iDesc = 1;
-               } else if(0 == strncmp(attrname, "Keyword=", 8)) {
-                       if (hasKeyword == 0) {
-                               return -1;
-                       }
-                       array_init(keyword_arr);
-                       hasKeyword = 1;
-                       str += 8;
-                       iKeyword = 1;
-               } else if(0 == strncmp(attrname, "Group=", 6)) {
-                       if (hasGroup == 0) {
-                               return -1;
-                       }
-                       array_init(group_arr);
-                       hasGroup = 1;
-                       str += 6;
-                       iGroup = 1;
-               } 
-               if(iTitle || iDesc || iKeyword) {       /* Poor error check if end of string */
-                       if(str[2] == ':') {
-                               str[2] = '\0';
-                               strcpy(language, str);
-                               str += 3;
-                       } else
-                               strcpy(language, "xx");
-
-                       title = str;
-                       if(iTitle)
-                               add_assoc_string(title_arr, language, title, 1);
-                       else if(iDesc)
-                               add_assoc_string(desc_arr, language, title, 1);
-                       else if(iKeyword)
-                               add_assoc_string(keyword_arr, language, title, 1);
-               } else if(iGroup) {
-                       if(iGroup)
-                               add_next_index_string(group_arr, str, 1);
-               }
-               attrname = php_strtok_r(NULL, "\n", &strtok_buf);
-       }
-       efree(temp);
-
-       /* Add the title array, if we have one */
-       if(hasTitle) {
-               zend_hash_update(Z_ARRVAL_PP(return_value), "Title", 6, &title_arr, sizeof(zval *), NULL);
-
-       } else {
-               efree(title_arr);
-       }
-
-
-       if(hasDescription) {
-       /* Add the description array, if we have one */
-               zend_hash_update(Z_ARRVAL_PP(return_value), "Description", 12, &desc_arr, sizeof(zval *), NULL);
-
-       } else {
-               efree(desc_arr);
-       }
-
-       if(hasKeyword) {
-       /* Add the keyword array, if we have one */
-               zend_hash_update(Z_ARRVAL_PP(return_value), "Keyword", 8, &keyword_arr, sizeof(zval *), NULL);
-
-       } else {
-               efree(keyword_arr);
-       }
-
-       if(hasGroup) {
-       /* Add the Group array, if we have one */
-               zend_hash_update(Z_ARRVAL_PP(return_value), "Group", 6, &group_arr, sizeof(zval *), NULL);
-
-       } else {
-               efree(group_arr);
-       }
-
-       /* All other attributes. Make a another copy first */
-       temp = estrdup(objrec);
-       attrname = php_strtok_r(temp, "\n", &strtok_buf);
-       while(attrname != NULL) {
-               str = attrname;
-               /* We don't want to insert titles, descr., keywords a second time */
-               if((0 != strncmp(attrname, "Title=", 6)) &&
-                  (0 != strncmp(attrname, "Description=", 12)) &&
-                  (0 != strncmp(attrname, "Group=", 6)) &&
-                  (0 != strncmp(attrname, "Keyword=", 8))) {
-                       while((*str != '=') && (*str != '\0'))
-                               str++;
-                       *str = '\0';
-                       str++;
-                       add_assoc_string(*return_value, attrname, str, 1);
-               }
-               attrname = php_strtok_r(NULL, "\n", &strtok_buf);
-       }
-       efree(temp);
-
-       return(0);
-}
-/* }}} */
-
-#define BUFFERLEN 1024
-/* {{{ make_objrec_from_array
- */
-static char * make_objrec_from_array(HashTable *lht, char delim) {
-       int i, count, keytype;
-       ulong idx;
-       uint length;
-       char *key, str[BUFFERLEN], *objrec = NULL;
-       zval *keydata, **keydataptr;
-
-       if(NULL == lht)
-               return NULL;
-
-       if(0 == (count = zend_hash_num_elements(lht)))
-               return NULL;
-
-       if(delim == 0)
-               delim = '=';
-
-       zend_hash_internal_pointer_reset(lht);
-       objrec = malloc(1);
-       *objrec = '\0';
-       for(i=0; i<count; i++) {
-               keytype = zend_hash_get_current_key_ex(lht, &key, &length, &idx, 0, NULL);
-/*             if(HASH_KEY_IS_STRING == keytype) { */
-                       zend_hash_get_current_data(lht, (void **) &keydataptr);
-                       keydata = *keydataptr;
-                       switch(Z_TYPE_P(keydata)) {
-                               case IS_STRING:
-                                       if(HASH_KEY_IS_STRING == keytype)
-                                               snprintf(str, BUFFERLEN, "%s%c%s\n", key, delim, Z_STRVAL_P(keydata));
-                                       else if(HASH_KEY_IS_LONG == keytype)
-                                               snprintf(str, BUFFERLEN, "%ld%c%s\n", idx, delim, Z_STRVAL_P(keydata));
-                                       else
-                                               snprintf(str, BUFFERLEN, "%s\n", Z_STRVAL_P(keydata));
-                                       break;
-                               case IS_LONG:
-                                       if(HASH_KEY_IS_STRING == keytype)
-                                               snprintf(str, BUFFERLEN, "%s%c0x%lX\n", key, delim, Z_LVAL_P(keydata));
-                                       else if(HASH_KEY_IS_LONG == keytype)
-                                               snprintf(str, BUFFERLEN, "%ld%c%s\n", idx, delim, Z_STRVAL_P(keydata));
-                                       else
-                                               snprintf(str, BUFFERLEN, "0x%lX\n", Z_LVAL_P(keydata));
-                                       break;
-                               case IS_ARRAY: {
-                                       int i, len, keylen, count;
-                                       char *strarr, *ptr, *ptr1;
-                                       count = zend_hash_num_elements(Z_ARRVAL_P(keydata));
-                                       if(count > 0) {
-                                               strarr = make_objrec_from_array(Z_ARRVAL_P(keydata), ':');
-                                               len = strlen(strarr) - 1;
-                                               keylen = strlen(key);
-                                               if(NULL == (ptr = malloc(len + 1 + count*(keylen+1)))) {
-                                                       free(objrec);
-                                                       return(NULL);
-                                               }
-                                               ptr1 = ptr;
-                                               *ptr1 = '\0';
-                                               strcpy(ptr1, key);
-                                               ptr1 += keylen;
-                                               *ptr1++ = '=';
-                                               for(i=0; i<len; i++) {
-                                                       *ptr1++ = strarr[i];
-                                                       if(strarr[i] == '\n') {
-                                                               strcpy(ptr1, key);
-                                                               ptr1 += keylen;
-                                                               *ptr1++ = '=';
-                                                       }/* else if(strarr[i] == '=')
-                                                               ptr1[-1] = ':'; */
-                                               }
-                                               *ptr1++ = '\n';
-                                               *ptr1 = '\0';
-                                               strlcpy(str, ptr, sizeof(str));
-                                       }
-                                       break;
-                               }
-                       }
-                       objrec = realloc(objrec, strlen(objrec)+strlen(str)+1);
-                       strcat(objrec, str);
-/*             } */
-               zend_hash_move_forward(lht);
-       }
-       return objrec;
-}
-/* }}} */
-#undef BUFFERLEN
-
-/* {{{ make_ints_from_array
- */
-static int * make_ints_from_array(HashTable *lht) {
-       int i, count;
-       int *objids = NULL;
-       zval **keydata;
-
-       if(NULL == lht)
-               return NULL;
-
-       if(0 == (count = zend_hash_num_elements(lht)))
-               return NULL;
-       
-       zend_hash_internal_pointer_reset(lht);
-       if(NULL == (objids = emalloc(count*sizeof(int))))
-               return NULL;
-       for(i=0; i<count; i++) {
-               zend_hash_get_current_data(lht, (void **) &keydata);
-               switch(Z_TYPE_PP(keydata)) {
-                       case IS_LONG:
-                               objids[i] = Z_LVAL_PP(keydata);
-                               break;
-                       default:
-                               objids[i] = 0;
-               }
-               zend_hash_move_forward(lht);
-       }
-       return objids;
-}
-/* }}} */
-
-/* {{{ make_strs_from_array
- */
-static char **make_strs_from_array(HashTable *arrht) {
-       char **carr = NULL;
-       char **ptr;
-       zval *data, **dataptr;
-
-       zend_hash_internal_pointer_reset(arrht);
-       if(NULL == (carr = emalloc(zend_hash_num_elements(arrht) * sizeof(char *))))
-               return(NULL);   
-       ptr = carr;
-
-       /* Iterate through hash */
-       while(zend_hash_get_current_data(arrht, (void **) &dataptr) == SUCCESS) {
-               data = *dataptr;
-               switch(Z_TYPE_P(data)) {
-                       case IS_STRING:
-                               *ptr = estrdup(Z_STRVAL_P(data));
-/*fprintf(stderr, "carr[] = %s\n", *ptr); */
-                               break;
-                       default:
-                               *ptr = NULL;
-               }
-               ptr++;
-
-               zend_hash_move_forward(arrht);
-       }
-       return(carr);
-}
-/* }}} */
-
-#define BUFFERLEN 30
-/* {{{ php_hw_do_connect
- */
-static void php_hw_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
-{
-       zval **argv[4];
-       int argc;
-       int sockfd;
-       int port = 0;
-       char *host = NULL;
-       char *userdata = NULL;
-       char *server_string = NULL;
-       char *username = NULL;
-       char *password = NULL;
-       char *hashed_details;
-       char *str = NULL;
-       char buffer[BUFFERLEN];
-       int hashed_details_length;
-       hw_connection *ptr;
-       int do_swap;
-       int version = 0;
-       
-       argc = ZEND_NUM_ARGS();
-       switch(argc) {
-               case 2:
-               case 4:
-                       if (zend_get_parameters_array_ex(argc, argv) == FAILURE) {
-                               WRONG_PARAM_COUNT;
-                       }
-                       break;
-               default:
-                       WRONG_PARAM_COUNT;
-       }
-
-       /* Host: */
-       convert_to_string_ex(argv[0]);
-       host = (char *) estrndup(Z_STRVAL_PP(argv[0]), Z_STRLEN_PP(argv[0]));
-
-       /* Port: */
-       convert_to_long_ex(argv[1]);
-       port = Z_LVAL_PP(argv[1]);
-
-       /* Username and Password */
-       if(argc > 2) {
-               /* Username */
-               convert_to_string_ex(argv[2]);
-               username = (char *) estrndup(Z_STRVAL_PP(argv[2]), Z_STRLEN_PP(argv[2]));
-               /* Password */
-               convert_to_string_ex(argv[3]);
-               password = (char *) estrndup(Z_STRVAL_PP(argv[3]), Z_STRLEN_PP(argv[3]));
-       }
-
-       /* Create identifier string for connection */
-       snprintf(buffer, BUFFERLEN, "%d", port);
-       hashed_details_length = strlen(host)+strlen(buffer)+8;
-       if(NULL == (hashed_details = (char *) emalloc(hashed_details_length+1))) {
-               if(host) efree(host);
-               if(password) efree(password);
-               if(username) efree(username);
-               php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not get memory for connection details");
-               RETURN_FALSE;
-       }
-       sprintf(hashed_details, "hw_%s_%d", host, port);
-
-       if (persistent) {
-               list_entry *le;
-
-               /* try to find if we already have this link in our persistent list */
-               if (zend_hash_find(&EG(persistent_list), hashed_details, hashed_details_length+1, (void **) &le)==FAILURE) {
-                       list_entry new_le;
-
-                       if (HwSG(max_links)!=-1 && HwSG(num_links)>=HwSG(max_links)) {
-                               php_error_docref(NULL TSRMLS_CC, E_ERROR, "Too many open links (%d)", HwSG(num_links));
-                               if(host) efree(host);
-                               if(username) efree(username);
-                               if(password) efree(password);
-                               efree(hashed_details);
-                               RETURN_FALSE;
-                       }
-                       if (HwSG(max_persistent!=-1) && HwSG(num_persistent)>=HwSG(max_persistent)) {
-                               php_error_docref(NULL TSRMLS_CC, E_ERROR, "Too many open persistent links (%d)", HwSG(num_persistent));
-                               if(host) efree(host);
-                               if(username) efree(username);
-                               if(password) efree(password);
-                               efree(hashed_details);
-                               RETURN_FALSE;
-                       }
-
-                       if ( (sockfd = open_hg_connection(host, port)) < 0 )  {
-                               php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not open connection to %s, Port: %d (retval=%d, errno=%d)", host, port, sockfd, errno);
-                               if(host) efree(host);
-                               if(username) efree(username);
-                               if(password) efree(password);
-                               efree(hashed_details);
-                               RETURN_FALSE;
-                               }
-       
-                       if(NULL == (ptr = malloc(sizeof(hw_connection)))) {
-                               php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not get memory for connection structure");
-                               if(host) efree(host);
-                               if(username) efree(username);
-                               if(password) efree(password);
-                               efree(hashed_details);
-                               RETURN_FALSE;
-                       }
-       
-                       if(0 != (ptr->lasterror = initialize_hg_connection(sockfd, &do_swap, &version, &userdata, &server_string, username, password))) {
-                               php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not initalize hyperwave connection");
-                               if(host) efree(host);
-                               if(username) efree(username);
-                               if(password) efree(password);
-                               if(userdata) efree(userdata);
-                               if(server_string) free(server_string);
-                               efree(hashed_details);
-                               RETURN_FALSE;
-                               }
-
-                       if(username) efree(username);
-                       if(password) efree(password);
-       
-                       ptr->version = version;
-                       ptr->server_string = server_string;
-                       ptr->socket = sockfd;
-                       ptr->swap_on = do_swap;
-                       ptr->linkroot = 0;
-                       ptr->hostname = strdup(host);
-                       ptr->username = strdup("anonymous");
-       
-                       new_le.ptr = (void *) ptr;
-                       Z_TYPE(new_le) = le_psocketp;
-
-                       if (zend_hash_update(&EG(persistent_list), hashed_details, hashed_details_length+1, (void *) &new_le, sizeof(list_entry), NULL)==FAILURE) {
-                               php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not hash table with connection details");
-                               if(host) efree(host);
-                               if(username) efree(username);
-                               if(password) efree(password);
-                               if(server_string) free(server_string);
-                               efree(hashed_details);
-                               RETURN_FALSE;
-                       }
-
-                       HwSG(num_links)++;
-                       HwSG(num_persistent)++;
-               } else {
-                       /*php_printf("Found already open connection\n"); */
-                       if (Z_TYPE_P(le) != le_psocketp) {
-                               RETURN_FALSE;
-                       }
-                       ptr = le->ptr;
-               }
-
-               Z_LVAL_P(return_value) = zend_list_insert(ptr, le_psocketp);
-               Z_TYPE_P(return_value) = IS_RESOURCE;
-       
-       } else {
-               list_entry *index_ptr, new_index_ptr;
-
-               /* first we check the hash for the hashed_details key.  if it exists,
-                * it should point us to the right offset where the actual hyperwave link sits.
-                * if it doesn't, open a new hyperwave link, add it to the resource list,
-                * and add a pointer to it with hashed_details as the key.
-                */
-               if (zend_hash_find(&EG(regular_list), hashed_details, hashed_details_length+1, (void **) &index_ptr)==SUCCESS) {
-                       int type, link;
-                       void *ptr;
-       
-                       if (Z_TYPE_P(index_ptr) != le_index_ptr) {
-                               RETURN_FALSE;
-                       }
-                       link = (int) index_ptr->ptr;
-                       ptr = (hw_connection *) zend_list_find(link, &type);   /* check if the link is still there */
-                       if(!ptr || (type!=le_socketp && type!=le_psocketp)) {
-                               Z_LVAL_P(return_value) = HwSG(default_link) = link;
-                               Z_TYPE_P(return_value) = IS_LONG;
-                               efree(hashed_details);
-                               if(username) efree(username);
-                               if(password) efree(password);
-                       if(host) efree(host);
-                               return;
-                       } else {
-                               zend_hash_del(&EG(regular_list), hashed_details, hashed_details_length+1);
-                       }
-               }
-       
-               if ( (sockfd = open_hg_connection(host, port)) < 0 )  {
-                       php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not open connection to %s, Port: %d (retval=%d", host, port, sockfd);
-                 if(host) efree(host);
-                       if(username) efree(username);
-                       if(password) efree(password);
-                       efree(hashed_details);
-                       RETURN_FALSE;
-                       }
-       
-               if(NULL == (ptr = malloc(sizeof(hw_connection)))) {
-                       if(host) efree(host);
-                       if(username) efree(username);
-                       if(password) efree(password);
-                       efree(hashed_details);
-                       RETURN_FALSE;
-               }
-       
-               if(0 != (ptr->lasterror = initialize_hg_connection(sockfd, &do_swap, &version, &userdata, &server_string, username, password))) {
-                       php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not initalize hyperwave connection");
-                       if(host) efree(host);
-                       if(username) efree(username);
-                       if(password) efree(password);
-                       if(userdata) efree(userdata);
-                       if(server_string) free(server_string);
-                       efree(hashed_details);
-                       RETURN_FALSE;
-                       }
-
-               if(username) efree(username);
-               if(password) efree(password);
-       
-               ptr->version = version;
-               ptr->server_string = server_string;
-               ptr->socket = sockfd;
-               ptr->swap_on = do_swap;
-               ptr->linkroot = 0;
-               ptr->hostname = strdup(host);
-               ptr->username = strdup("anonymous");
-       
-               Z_LVAL_P(return_value) = zend_list_insert(ptr, le_socketp);
-               Z_TYPE_P(return_value) = IS_RESOURCE;
-       
-               new_index_ptr.ptr = (void *) Z_LVAL_P(return_value);
-               Z_TYPE(new_index_ptr) = le_index_ptr;
-               if (zend_hash_update(&EG(regular_list), hashed_details, hashed_details_length+1, (void *) &new_index_ptr, sizeof(list_entry), NULL)==FAILURE) {
-                       php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not update connection details in hash table");
-                       if(host) efree(host);
-                       efree(hashed_details);
-                       RETURN_FALSE;
-               }
-       
-       }
-
-       efree(hashed_details);
-       if(host) efree(host);
-       HwSG(default_link)=Z_LVAL_P(return_value);
-
-       /* At this point we have a working connection. If userdata was given
-          we are also indentified.
-          If there is no userdata because hw_connect was called without username
-          and password, we don't evaluate userdata.
-       */
-       if(NULL == userdata)
-               return;
-
-       if(ptr->username) free(ptr->username);
-       str = userdata;
-       while((*str != 0) && (*str != ' '))
-               str++;
-       if(*str != '\0')
-               ptr->username = strdup(++str);
-       else
-               ptr->username = NULL;
-       efree(userdata);
-}
-/* }}} */
-#undef BUFFERLEN
-
-/* Start of user level functions */
-/* ***************************** */
-/* {{{ proto resource hw_connect(string host, int port [, string username [, string password]])
-   Connect to the Hyperwave server */
-PHP_FUNCTION(hw_connect)
-{
-       php_hw_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-/* {{{ proto resource hw_pconnect(string host, int port [, string username [, string password]])
-   Connect to the Hyperwave server persistent */
-PHP_FUNCTION(hw_pconnect)
-{
-       php_hw_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
-
-/* {{{ proto bool hw_close(resource link)
-   Close connection to Hyperwave server */
-PHP_FUNCTION(hw_close)
-{
-       zval **arg1;
-       int link, type;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       zend_list_delete(link);
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool hw_info(resource link)
-   Outputs info string */
-PHP_FUNCTION(hw_info)
-{
-       pval **arg1;
-       int link, type;
-       hw_connection *ptr;
-       char *str;
-
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       if(NULL != (str = get_hw_info(ptr))) {
-               /*
-               php_printf("%s\n", str);
-               efree(str);
-               */
-               Z_STRLEN_P(return_value) = strlen(str);
-               Z_STRVAL_P(return_value) = str;
-               Z_TYPE_P(return_value) = IS_STRING;
-               return;
-               }
-       RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto int hw_error(resource link)
-   Returns last error number */
-PHP_FUNCTION(hw_error)
-{
-       pval **arg1;
-       int link, type;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       RETURN_LONG(ptr->lasterror);
-}
-/* }}} */
-
-/* {{{ proto string hw_errormsg(resource link)
-   Returns last error message */
-PHP_FUNCTION(hw_errormsg)
-{
-       pval **arg1;
-       int link, type;
-       hw_connection *ptr;
-       char errstr[100];
-
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-
-       switch (ptr->lasterror) {
-               case 0:
-                       sprintf(errstr, "No error");
-                       break;
-               case NOACCESS:
-                       sprintf(errstr, "Access denied");
-                       break;
-               case NODOCS:
-                       sprintf(errstr, "No documents");
-                       break;
-               case NONAME:
-                       sprintf(errstr, "No collection name");
-                       break;
-               case NODOC:
-                       sprintf(errstr, "Object is not a document");
-                       break;
-               case NOOBJ:
-                       sprintf(errstr, "No object received");
-                       break;
-               case NOCOLLS:
-                       sprintf(errstr, "No collections received");
-                       break;
-               case DBSTUBNG:
-                       sprintf(errstr, "Connection to low-level database failed");
-                       break;
-               case NOTFOUND:
-                       sprintf(errstr, "Object not found");
-                       break;
-               case EXIST:
-                       sprintf(errstr, "Collection already exists");
-                       break;
-               case FATHERDEL:
-                       sprintf(errstr, "parent collection disappeared");
-                       break;
-               case FATHNOCOLL:
-                       sprintf(errstr, "parent collection not a collection");
-                       break;
-               case NOTEMPTY:
-                       sprintf(errstr, "Collection not empty");
-                       break;
-               case DESTNOCOLL:
-                       sprintf(errstr, "Destination not a collection");
-                       break;
-               case SRCEQDEST:
-                       sprintf(errstr, "Source equals destination");
-                       break;
-               case REQPEND:
-                       sprintf(errstr, "Request pending");
-                       break;
-               case TIMEOUT:
-                       sprintf(errstr, "Timeout");
-                       break;
-               case NAMENOTUNIQUE:
-                       sprintf(errstr, "Name not unique");
-                       break;
-               case WRITESTOPPED:
-                       sprintf(errstr, "Database now read-only; try again later");
-                       break;
-               case LOCKED:
-                       sprintf(errstr, "Object locked; try again later");
-                       break;
-               case CHANGEBASEFLD:
-                       sprintf(errstr, "Change of base-attribute");
-                       break;
-               case NOTREMOVED:
-                       sprintf(errstr, "Attribute not removed");
-                       break;
-               case FLDEXISTS:
-                       sprintf(errstr, "Attribute exists");
-                       break;
-               case CMDSYNTAX:
-                       sprintf(errstr, "Syntax error in command");
-                       break;
-               case NOLANGUAGE:
-                       sprintf(errstr, "No or unknown language specified");
-                       break;
-               case WRGTYPE:
-                       sprintf(errstr, "Wrong type in object");
-                       break;
-               case WRGVERSION:
-                       sprintf(errstr, "Client version too old");
-                       break;
-               case CONNECTION:
-                       sprintf(errstr, "No connection to other server");
-                       break;
-               case SYNC:
-                       sprintf(errstr, "Synchronization error");
-                       break;
-               case NOPATH:
-                       sprintf(errstr, "No path entry");
-                       break;
-               case WRGPATH:
-                       sprintf(errstr, "Wrong path entry");
-                       break;
-               case PASSWD:
-                       sprintf(errstr, "Wrong password (server-to-server server authentication)");
-                       break;
-               case LC_NO_MORE_USERS:
-                       sprintf(errstr, "No more users for license");
-                       break;
-               case LC_NO_MORE_DOCS:
-                       sprintf(errstr, "No more documents for this session and license");
-                       break;
-               case RSERV_NRESP:
-                       sprintf(errstr, "Remote server not responding");
-                       break;
-               case Q_OVERFLOW:
-                       sprintf(errstr, "Query overflow");
-                       break;
-               case USR_BREAK:
-                       sprintf(errstr, "Break by user");
-                       break;
-               case N_IMPL:
-                       sprintf(errstr, "Not implemented");
-                       break;
-               case WRG_VALUE:
-                       sprintf(errstr, "Wrong value");
-                       break;
-               case INSUFF_FUNDS:
-                       sprintf(errstr, "Insufficient funds");
-                       break;
-               case REORG:
-                       sprintf(errstr, "Reorganization in progress");
-                       break;
-               case USER_LIMIT:
-                       sprintf(errstr, "Limit of simultaneous users reached");
-                       break;
-               case FTCONNECT:
-                       sprintf(errstr, "No connection to fulltext server");
-                       break;
-               case FTTIMEOUT:
-                       sprintf(errstr, "Connection timed out");
-                       break;
-               case FTINDEX:
-                       sprintf(errstr, "Something wrong with fulltext index");
-                       break;
-               case FTSYNTAX:
-                       sprintf(errstr, "Query syntax error");
-                       break;
-               case REQUESTPENDING:
-                       sprintf(errstr, "Request pending");
-                       break;
-               case NOCONNECTION:
-                       sprintf(errstr, "No connection to document server");
-                       break;
-               case WRONGVERSION:
-                       sprintf(errstr, "Wrong protocol version");
-                       break;
-               case NOTINITIALIZED:
-                       sprintf(errstr, "Not initialized");
-                       break;
-               case BADREQUEST:
-                       sprintf(errstr, "Bad request");
-                       break;
-               case BADLRN:
-                       sprintf(errstr, "Bad document number");
-                       break;
-               case OPENSTORE_WRITE:
-                       sprintf(errstr, "Cannot write to local store");
-                       break;
-               case OPENSTORE_READ:
-                       sprintf(errstr, "Cannot read from local store");
-                       break;
-               case READSTORE:
-                       sprintf(errstr, "Store read error");
-                       break;
-               case WRITESTORE:
-                       sprintf(errstr, "Write error");
-                       break;
-               case CLOSESTORE:
-                       sprintf(errstr, "Close error");
-                       break;
-               case BADPATH:
-                       sprintf(errstr, "Bad path");
-                       break;
-               case NOPATHDC:
-                       sprintf(errstr, "No path");
-                       break;
-               case OPENFILE:
-                       sprintf(errstr, "Cannot open file");
-                       break;
-               case READFILE:
-                       sprintf(errstr, "Cannot read from file // same");
-                       break;
-               case WRITEFILE:
-                       sprintf(errstr, "Cannot write to file");
-                       break;
-               case CONNECTCLIENT:
-                       sprintf(errstr, "Could not connect to client");
-                       break;
-               case ACCEPT:
-                       sprintf(errstr, "Could not accept connection");
-                       break;
-               case READSOCKET:
-                       sprintf(errstr, "Could not read from socket");
-                       break;
-               case WRITESOCKET:
-                       sprintf(errstr, "Could not write to socket");
-                       break;
-               case TOOMUCHDATA:
-                       sprintf(errstr, "Received too much data");
-                       break;
-               case TOOFEWDATA:
-                       sprintf(errstr, "Received too few data // ...");
-                       break;
-               case NOTIMPLEMENTED:
-                       sprintf(errstr, "Not implemented");
-                       break;
-               case USERBREAK:
-                       sprintf(errstr, "User break");
-                       break;
-               case INTERNAL:
-                       sprintf(errstr, "Internal error");
-                       break;
-               case INVALIDOBJECT:
-                       sprintf(errstr, "Invalid object");
-                       break;
-               case JOBTIMEOUT:
-                       sprintf(errstr, "Job timed out");
-                       break;
-               case OPENPORT:
-                       sprintf(errstr, "Cannot open port // ... for several resons");
-                       break;
-               case NODATA:
-                       sprintf(errstr, "Received no data");
-                       break;
-               case NOPORT:
-                       sprintf(errstr, "No port to handle this request");
-                       break;
-               case NOTCACHED:
-                       sprintf(errstr, "Document not cached");
-                       break;
-               case BADCACHETYPE:
-                       sprintf(errstr, "Bad cache type");
-                       break;
-               case OPENCACHE_WRITE:
-                       sprintf(errstr, "Cannot write to cache");
-                       break;
-               case OPENCACHE_READ:
-                       sprintf(errstr, "Cannot read from cache // same");
-                       break;
-               case NOSOURCE:
-                       sprintf(errstr, "Do not know what to read");
-                       break;
-               case CLOSECACHE:
-                       sprintf(errstr, "Could not insert into cache");
-                       break;
-               case CONNECTREMOTE:
-                       sprintf(errstr, "Could not connect to remote server");
-                       break;
-               case LOCKREFUSED:
-                       sprintf(errstr, "Lock refused // could not lock the stores");
-                       break;
-               default:
-                       sprintf(errstr, "Unknown error: %d", ptr->lasterror);
-               }
-       RETURN_STRING(errstr, 1);
-}
-/* }}} */
-
-/* {{{ proto int hw_root(void)
-   Returns object id of root collection */
-PHP_FUNCTION(hw_root)
-{
-       if (ZEND_NUM_ARGS() != 0) {
-               WRONG_PARAM_COUNT;
-       }
-
-       Z_LVAL_P(return_value) = 0;
-       Z_TYPE_P(return_value) = IS_LONG;
-}
-/* }}} */
-
-/* {{{ php_hw_command
- */
-char *php_hw_command(INTERNAL_FUNCTION_PARAMETERS, int comm) {
-       pval **arg1;
-       int link, type;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
-               return NULL;
-       }
-       convert_to_long_ex(arg1);
-       link = Z_LVAL_PP(arg1);
-       ptr = (hw_connection *) zend_list_find(link, &type);
-       if(!ptr || (type != le_socketp && type != le_psocketp)) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find file identifier %d", link);
-               return NULL;
-       }
-
-       set_swap(ptr->swap_on);
-       {
-               char *object = NULL;
-               if (0 != (ptr->lasterror = send_command(ptr->socket, comm, &object))) {
-                       return NULL;
-               }
-               return object;
-       }
-       return NULL;
-}
-/* }}} */
-
-/* {{{ proto string hw_stat(resource link)
-   Returns status string */
-PHP_FUNCTION(hw_stat)
-{
-        char *object;
-
-       object = php_hw_command(INTERNAL_FUNCTION_PARAM_PASSTHRU, STAT_COMMAND);
-       if(object == NULL)
-               RETURN_FALSE;
-
-       Z_STRVAL_P(return_value) = object;
-       Z_STRLEN_P(return_value) = strlen(object);
-       Z_TYPE_P(return_value) = IS_STRING;
-}
-/* }}} */
-
-/* {{{ proto array hw_who(resource link)
-   Returns names and info of users loged in */
-PHP_FUNCTION(hw_who)
-{
-       zval *user_arr;
-        char *object, *ptr, *temp, *attrname;
-       int i;
-       char *strtok_buf;
-
-       object = php_hw_command(INTERNAL_FUNCTION_PARAM_PASSTHRU, WHO_COMMAND);
-       if(object == NULL)
-               RETURN_FALSE;
-
-       ptr = object;
-
-php_printf("%s\n", ptr);
-       /* Skip first two lines, they just contain:
-        Users in Database
-
-        */
-        while((*ptr != '\0') && (*ptr != '\n'))
-               ptr++;
-        while((*ptr != '\0') && (*ptr != '\n'))
-               ptr++;
-       if(*ptr == '\0') {
-               efree(object);
-               RETURN_FALSE;
-       }
-
-       array_init(return_value);
-
-       temp = estrdup(ptr);
-       attrname = php_strtok_r(temp, "\n", &strtok_buf);
-       i = 0;
-       while(attrname != NULL) {
-               char *name;
-
-               ALLOC_ZVAL(user_arr);
-               array_init(user_arr);
-
-               ptr = attrname;
-               if(*ptr++ == '*')
-                       add_assoc_long(user_arr, "self", 1);
-               else
-                       add_assoc_long(user_arr, "self", 0);
-                       
-               ptr++;
-               name = ptr;
-               while((*ptr != '\0') && (*ptr != ' '))
-                       ptr++;
-               *ptr = '\0';
-               add_assoc_string(user_arr, "id", name, 1);
-
-               ptr++;
-               name = ptr;
-               while((*ptr != '\0') && (*ptr != ' '))
-                       ptr++;
-               *ptr = '\0';
-               add_assoc_string(user_arr, "name", name, 1);
-
-               ptr++;
-               while((*ptr != '\0') && (*ptr == ' '))
-                       ptr++;
-
-               name = ptr;
-               while((*ptr != '\0') && (*ptr != ' '))
-                       ptr++;
-               *ptr = '\0';
-               add_assoc_string(user_arr, "system", name, 1);
-
-               ptr++;
-               while((*ptr != '\0') && (*ptr == ' '))
-                       ptr++;
-
-               name = ptr;
-               while((*ptr != '\0') && (*ptr != ' '))
-                       ptr++;
-               *ptr = '\0';
-               add_assoc_string(user_arr, "onSinceDate", name, 1);
-
-               ptr++;
-               while((*ptr != '\0') && (*ptr == ' '))
-                       ptr++;
-
-               name = ptr;
-               while((*ptr != '\0') && (*ptr != ' '))
-                       ptr++;
-               *ptr = '\0';
-               add_assoc_string(user_arr, "onSinceTime", name, 1);
-
-               ptr++;
-               while((*ptr != '\0') && (*ptr == ' '))
-                       ptr++;
-
-               name = ptr;
-               while((*ptr != '\0') && (*ptr != ' '))
-                       ptr++;
-               *ptr = '\0';
-               add_assoc_string(user_arr, "TotalTime", name, 1);
-
-               /* Add the user array */
-               zend_hash_index_update(Z_ARRVAL_P(return_value), i++, &user_arr, sizeof(pval), NULL);
-
-               attrname = php_strtok_r(NULL, "\n", &strtok_buf);
-       }
-       efree(temp);
-       efree(object);
-
-}
-/* }}} */
-
-/* {{{ proto string hw_dummy(resource link, int id, int msgid)
-   Hyperwave dummy function */
-PHP_FUNCTION(hw_dummy)
-{
-       pval **arg1, **arg2, **arg3;
-       int link, id, type, msg_id;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       convert_to_long_ex(arg2);
-       convert_to_long_ex(arg3);
-       id=Z_LVAL_PP(arg2);
-       msg_id=Z_LVAL_PP(arg3);
-       HW_FETCH_LINK(arg1);
-
-       set_swap(ptr->swap_on);
-       {
-       char *object = NULL;
-       if (0 != (ptr->lasterror = send_dummy(ptr->socket, id, msg_id, &object)))
-               RETURN_FALSE;
-
-php_printf("%s", object);
-       Z_STRVAL_P(return_value) = object;
-       Z_STRLEN_P(return_value) = strlen(object);
-       Z_TYPE_P(return_value) = IS_STRING;
-       }
-}
-/* }}} */
-
-/* {{{ proto mixed hw_getobject(resource link, int objid [, string query])
-   Returns object record  */
-PHP_FUNCTION(hw_getobject)
-{
-       pval **argv[3];
-       int argc, link, id, type, multi;
-       char *query;
-       hw_connection *ptr;
-
-       argc = ZEND_NUM_ARGS();
-       if(argc < 2 || argc > 3)
-               WRONG_PARAM_COUNT;
-       if (zend_get_parameters_array_ex(argc, argv) == FAILURE)
-               WRONG_PARAM_COUNT;
-
-       HW_FETCH_LINK(argv[0]);
-       if(Z_TYPE_PP(argv[1]) == IS_ARRAY) {
-               multi = 1;
-               convert_to_array_ex(argv[1]);
-       } else {
-               multi = 0;
-               convert_to_long_ex(argv[1]);
-       }
-
-       if(argc == 3) {
-               convert_to_string_ex(argv[2]);
-               query = Z_STRVAL_PP(argv[2]);
-       } else
-               query = NULL;
-
-       set_swap(ptr->swap_on);
-       if(multi) {
-               char **objects = NULL;
-               int count, *ids, i;
-               HashTable *lht;
-               zval **keydata;
-
-               lht = Z_ARRVAL_PP(argv[1]);
-               if(0 == (count = zend_hash_num_elements(lht))) {
-                       RETURN_FALSE;
-               }
-               ids = emalloc(count * sizeof(hw_objectID));
-
-               zend_hash_internal_pointer_reset(lht);
-               for(i=0; i<count; i++) {
-                       zend_hash_get_current_data(lht, (void **) &keydata);
-                       switch(Z_TYPE_PP(keydata)) {
-                               case IS_LONG:
-                                       ids[i] = Z_LVAL_PP(keydata);
-                                       break;
-                               default:
-                                       ids[i] = Z_LVAL_PP(keydata);
-                       }
-                       zend_hash_move_forward(lht);
-               }
-
-               if (0 != (ptr->lasterror = send_objectbyidquery(ptr->socket, ids, &count, query, &objects))) {
-                       efree(ids);
-                       RETURN_FALSE;
-                       }
-               efree(ids);
-               array_init(return_value);
-
-               for(i=0; i<count; i++) {
-                       add_index_string(return_value, i, objects[i], 0);
-               }
-               efree(objects);
-               
-       } else {
-               char *object = NULL;
-               id=Z_LVAL_PP(argv[1]);
-               if (0 != (ptr->lasterror = send_getobject(ptr->socket, id, &object)))
-                       RETURN_FALSE;
-
-               RETURN_STRING(object, 0);
-       }
-}
-/* }}} */
-
-/* {{{ proto int hw_insertobject(resource link, string objrec, string parms)
-   Inserts an object */
-PHP_FUNCTION(hw_insertobject)
-{
-       zval **arg1, **arg2, **arg3;
-       int link, type;
-       char *objrec, *parms;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_string_ex(arg2);
-       convert_to_string_ex(arg3);
-       objrec=Z_STRVAL_PP(arg2);
-       parms=Z_STRVAL_PP(arg3);
-
-       set_swap(ptr->swap_on);
-       {
-       int objid;
-       if (0 != (ptr->lasterror = send_insertobject(ptr->socket, objrec, parms, &objid)))
-               RETURN_FALSE;
-
-       RETURN_LONG(objid);
-       }
-}
-/* }}} */
-
-/* {{{ proto string hw_getandlock(resource link, int objid)
-   Returns object record and locks object */
-PHP_FUNCTION(hw_getandlock)
-{
-       zval **arg1, **arg2;
-       int link, id, type;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       id=Z_LVAL_PP(arg2);
-
-       set_swap(ptr->swap_on);
-       {
-       char *object = NULL;
-       if (0 != (ptr->lasterror = send_getandlock(ptr->socket, id, &object)))
-               RETURN_FALSE;
-
-       RETURN_STRING(object, 0);
-       }
-}
-/* }}} */
-
-/* {{{ proto bool hw_unlock(resource link, int objid)
-   Unlocks object */
-PHP_FUNCTION(hw_unlock)
-{
-       zval **arg1, **arg2;
-       int link, id, type;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       id=Z_LVAL_PP(arg2);
-
-       set_swap(ptr->swap_on);
-       if (0 != (ptr->lasterror = send_unlock(ptr->socket, id)))
-               RETURN_FALSE;
-
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool hw_deleteobject(resource link, int objid)
-   Deletes object */
-PHP_FUNCTION(hw_deleteobject)
-{
-       zval **arg1, **arg2;
-       int link, id, type;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       id=Z_LVAL_PP(arg2);
-
-       set_swap(ptr->swap_on);
-       if (0 != (ptr->lasterror = send_deleteobject(ptr->socket, id)))
-               RETURN_FALSE;
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto bool hw_changeobject(resource link, int objid, array attributes)
-   Changes attributes of an object (obsolete) */
-#define BUFFERLEN 200
-PHP_FUNCTION(hw_changeobject)
-{
-       zval **arg1, **arg2, **arg3;
-       int link, id, type, i;
-       hw_connection *ptr;
-       char *modification, *oldobjrec, buf[BUFFERLEN];
-       HashTable *newobjarr;
-
-       if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2); /* object ID */
-       convert_to_array_ex(arg3); /* Array with new attributes */
-       id=Z_LVAL_PP(arg2);
-       newobjarr=Z_ARRVAL_PP(arg3);
-
-       /* get the old object record */
-       if(0 != (ptr->lasterror = send_getandlock(ptr->socket, id, &oldobjrec)))
-               RETURN_FALSE;
-
-       zend_hash_internal_pointer_reset(newobjarr);
-       modification = strdup("");
-       for(i=0; i<zend_hash_num_elements(newobjarr); i++) {
-               char *key, *str, *str1, newattribute[BUFFERLEN];
-               pval *data, **dataptr;
-               int j, noinsert=1;
-               ulong ind;
-
-               zend_hash_get_current_key(newobjarr, &key, &ind, 0);
-               zend_hash_get_current_data(newobjarr, (void *) &dataptr);
-               data = *dataptr;
-               switch(Z_TYPE_P(data)) {
-                       case IS_STRING:
-                               if(strlen(Z_STRVAL_P(data)) == 0)
-                                       snprintf(newattribute, BUFFERLEN, "rem %s", key);
-                               else
-                                       snprintf(newattribute, BUFFERLEN, "add %s=%s", key, Z_STRVAL_P(data));
-                               noinsert = 0;
-                               break;
-                       default:
-                               newattribute[0] = '\0';
-               }
-               if(!noinsert) {
-                       modification = fnInsStr(modification, 0, "\\");
-                       modification = fnInsStr(modification, 0, newattribute);
-/*                     modification = fnInsStr(modification, 0, "add "); */
-
-                       /* Retrieve the old attribute from object record */
-                       if(NULL != (str = strstr(oldobjrec, key))) {
-                               str1 = str;
-                               j = 0;
-                               while((str1 != NULL) && (*str1 != '\n') && (j < BUFFERLEN-1)) {
-                                       buf[j++] = *str1++;
-                               }
-                               buf[j] = '\0';
-                               modification = fnInsStr(modification, 0, "\\");
-                               modification = fnInsStr(modification, 0, buf);
-                               modification = fnInsStr(modification, 0, "rem ");
-                       } 
-               }
-               zend_hash_move_forward(newobjarr);
-       }
-       efree(oldobjrec);
-
-       set_swap(ptr->swap_on);
-       modification[strlen(modification)-1] = '\0';
-       if (0 != (ptr->lasterror = send_changeobject(ptr->socket, id, modification))) {
-               free(modification);
-               send_unlock(ptr->socket, id);
-               RETURN_FALSE;
-       }
-       free(modification);
-       if (0 != (ptr->lasterror = send_unlock(ptr->socket, id))) {
-               RETURN_FALSE;
-       }
-       RETURN_TRUE;
-}
-#undef BUFFERLEN
-/* }}} */
-
-/* {{{ proto bool hw_modifyobject(resource link, int objid, array remattributes, array addattributes [, int mode])
-   Modifies attributes of an object */
-#define BUFFERLEN 200
-PHP_FUNCTION(hw_modifyobject)
-{
-       zval **argv[5];
-       int argc;
-       int link, id, type, i, mode;
-       hw_connection *ptr;
-       char *modification;
-       HashTable *remobjarr, *addobjarr;
-
-       argc = ZEND_NUM_ARGS();
-       if((argc > 5) || (argc < 4))
-               WRONG_PARAM_COUNT;
-
-       if (zend_get_parameters_array_ex(argc, argv) == FAILURE)
-       if(argc < 4) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(argv[0]);
-       convert_to_long_ex(argv[1]); /* object ID */
-       convert_to_array_ex(argv[2]); /* Array with attributes to remove */
-       convert_to_array_ex(argv[3]); /* Array with attributes to add */
-       if(argc == 5) {
-               convert_to_long_ex(argv[4]);
-               mode = Z_LVAL_PP(argv[4]);
-       } else
-               mode = 0;
-       id=Z_LVAL_PP(argv[1]);
-       remobjarr=Z_ARRVAL_PP(argv[2]);
-       addobjarr=Z_ARRVAL_PP(argv[3]);
-
-       modification = strdup("");
-       if(addobjarr != NULL) {
-               zend_hash_internal_pointer_reset(addobjarr);
-               for(i=0; i<zend_hash_num_elements(addobjarr); i++) {
-                       char *key, addattribute[BUFFERLEN];
-                       zval *data, **dataptr;
-                       int noinsert=1;
-                       ulong ind;
-
-                       zend_hash_get_current_key(addobjarr, &key, &ind, 0);
-                       zend_hash_get_current_data(addobjarr, (void *) &dataptr);
-                       data = *dataptr;
-                       switch(Z_TYPE_P(data)) {
-                               case IS_STRING:
-                                       if(strlen(Z_STRVAL_P(data)) > 0) {
-                                               snprintf(addattribute, BUFFERLEN, "add %s=%s", key, Z_STRVAL_P(data));
-/* fprintf(stderr, "add: %s\n", addattribute); */
-                                               noinsert = 0;
-                                       }
-                                       break;
-                               case IS_ARRAY: {
-                                       int i, len, keylen, count;
-                                       char *strarr, *ptr, *ptr1;
-                                       count = zend_hash_num_elements(Z_ARRVAL_P(data));
-                                       if(count > 0) {
-                                               strarr = make_objrec_from_array(Z_ARRVAL_P(data), ':');
-                                               len = strlen(strarr) - 1;
-                                               keylen = strlen(key);
-                                               if(NULL == (ptr = malloc(len + 1 + count*(keylen+1+4)))) {
-                                                       if(modification)
-                                                               free(modification);
-                                                       RETURN_FALSE;
-                                               }
-                                               ptr1 = ptr;
-                                               *ptr1 = '\0';
-                                               strcpy(ptr1, "add ");
-                                               ptr1 += 4;
-                                               strcpy(ptr1, key);
-                                               ptr1 += keylen;
-                                               *ptr1++ = '=';
-                                               for(i=0; i<len; i++) {
-                                                       *ptr1++ = strarr[i];
-                                                       if(strarr[i] == '\n') {
-                                                               ptr1[-1] = '\\';
-                                                               strcpy(ptr1, "add ");
-                                                               ptr1 += 4;
-                                                               strcpy(ptr1, key);
-                                                               ptr1 += keylen;
-                                                               *ptr1++ = '=';
-                                                       } /* else if(strarr[i] == '=')
-                                                               ptr1[-1] = ':'; */
-                                               }
-                                               *ptr1 = '\0';
-                                               strlcpy(addattribute, ptr, sizeof(addattribute));
-                                               noinsert = 0;
-                                       }
-                                       break;
-                               }
-                       }
-                       if(!noinsert) {
-                               modification = fnInsStr(modification, 0, "\\");
-                               modification = fnInsStr(modification, 0, addattribute);
-                       }
-                       zend_hash_move_forward(addobjarr);
-               }
-       }
-
-       if(remobjarr != NULL) {
-               int nr;
-               zend_hash_internal_pointer_reset(remobjarr);
-               nr = zend_hash_num_elements(remobjarr);
-               for(i=0; i<nr; i++) {
-                       char *key, remattribute[BUFFERLEN];
-                       zval *data, **dataptr;
-                       int noinsert=1;
-                       ulong ind;
-
-                       zend_hash_get_current_key(remobjarr, &key, &ind, 0);
-                       zend_hash_get_current_data(remobjarr, (void *) &dataptr);
-                       data = *dataptr;
-                       switch(Z_TYPE_P(data)) {
-                               case IS_STRING:
-                                       if(strlen(Z_STRVAL_P(data)) > 0) {
-                                               snprintf(remattribute, BUFFERLEN, "rem %s=%s", key, Z_STRVAL_P(data));
-                                               noinsert = 0;
-                                       } else {
-                                               snprintf(remattribute, BUFFERLEN, "rem %s", key);
-                                               noinsert = 0;
-                                       }
-                                       break;
-                               case IS_ARRAY: {
-                                       int i, len, keylen, count;
-                                       char *strarr, *ptr, *ptr1;
-                                       count = zend_hash_num_elements(Z_ARRVAL_P(data));
-                                       if(count > 0) {
-                                               strarr = make_objrec_from_array(Z_ARRVAL_P(data), ':');
-                                               len = strlen(strarr) - 1;
-                                               keylen = strlen(key);
-                                               if(NULL == (ptr = malloc(len + 1 + count*(keylen+1+4)))) {
-                                                       if(modification)
-                                                               free(modification);
-                                                       RETURN_FALSE;
-                                               }
-                                               ptr1 = ptr;
-                                               *ptr1 = '\0';
-                                               strcpy(ptr1, "rem ");
-                                               ptr1 += 4;
-                                               strcpy(ptr1, key);
-                                               ptr1 += keylen;
-                                               *ptr1++ = '=';
-                                               for(i=0; i<len; i++) {
-                                                       *ptr1++ = strarr[i];
-                                                       if(strarr[i] == '\n') {
-                                                               ptr1[-1] = '\\';
-                                                               strcpy(ptr1, "rem ");
-                                                               ptr1 += 4;
-                                                               strcpy(ptr1, key);
-                                                               ptr1 += keylen;
-                                                               *ptr1++ = '=';
-                                                       } /* else if(strarr[i] == '=')
-                                                               ptr1[-1] = ':'; */
-                                               }
-                                               *ptr1++ = '\n';
-                                               *ptr1 = '\0';
-                                               strlcpy(remattribute, ptr, sizeof(remattribute));
-                                               noinsert = 0;
-                                       }
-                                       break;
-                               }
-                       }
-                       if(!noinsert) {
-                               modification = fnInsStr(modification, 0, "\\");
-                               modification = fnInsStr(modification, 0, remattribute);
-                       }
-                       zend_hash_move_forward(remobjarr);
-               }
-       }
-
-       set_swap(ptr->swap_on);
-       modification[strlen(modification)-1] = '\0';
-       if(strlen(modification) == 0) {
-               ptr->lasterror = 0;
-               free(modification);
-               RETURN_TRUE;
-       }
-/*     fprintf(stderr, "modifyobject: %s\n", modification); */
-       switch(mode) {
-               case 0:
-                       if (0 == (ptr->lasterror = send_lock(ptr->socket, id))) {
-                               if (0 == (ptr->lasterror = send_changeobject(ptr->socket, id, modification))) {
-                                       if (0 != (ptr->lasterror = send_unlock(ptr->socket, id))) {
-                                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Aiii, Changeobject failed and couldn't unlock object (id = 0x%X)", id);
-                                               free(modification);
-                                               RETURN_FALSE;
-                                       }
-                                       free(modification);
-                                       RETURN_FALSE;
-                               } else {
-                                       send_unlock(ptr->socket, id);
-                                       free(modification);
-                                       RETURN_FALSE;
-                               }
-                       } else {
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not lock object (id = 0x%X)", id);
-                               free(modification);
-                               RETURN_FALSE;
-                       }
-                       break;
-               case 1:
-/* WARNING: send_groupchangobject() only works right, if each attribute
-   can be modified. Doing a changeobject recursively often tries to
-   modify objects which cannot be modified e.g. because an attribute cannot
-   be removed. In such a case no further modification on that object is done.
-   Doing a 'rem Rights\add Rights=R:a' will fail completely if the attribute
-   Rights is not there already. The object locking is done in send_groupchangeobject();
-*/
-                       if (0 != (ptr->lasterror = send_groupchangeobject(ptr->socket, id, modification))) {
-                               free(modification);
-                               RETURN_FALSE;
-                       }
-                       break;
-               default:
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Mode must be 0 or 1 (recursive)");
-       }
-       free(modification);
-       RETURN_TRUE;
-}
-#undef BUFFERLEN
-/* }}} */
-
-/* {{{ php_hw_mvcp
- */
-void php_hw_mvcp(INTERNAL_FUNCTION_PARAMETERS, int mvcp) {
-       zval **arg1, **arg2, **arg3, **arg4;
-       int link, type, dest=0, from=0, count;
-       HashTable *src_arr;
-       hw_connection *ptr;
-       int collIDcount, docIDcount, i, *docIDs, *collIDs;
-
-       switch(mvcp) {
-               case MOVE: /* Move also has fromID */
-                       if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE)
-                               WRONG_PARAM_COUNT;
-                       break;
-               case COPY:
-                       if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE)
-                               WRONG_PARAM_COUNT;
-                       break;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_array_ex(arg2);
-       convert_to_long_ex(arg3);
-       link=Z_LVAL_PP(arg1);
-       src_arr=Z_ARRVAL_PP(arg2);
-       switch(mvcp) {
-               case MOVE: /* Move also has fromID, which is arg3 --> arg4 becomes destID */
-                       convert_to_long_ex(arg4);
-                       from=Z_LVAL_PP(arg3);
-                       dest=Z_LVAL_PP(arg4);
-                       break;
-               case COPY: /* No fromID for Copy needed --> arg3 is destID */
-                       dest=Z_LVAL_PP(arg3);
-                       from = 0;
-                       break;
-       }
-
-       set_swap(ptr->swap_on);
-
-       count = zend_hash_num_elements(src_arr);
-       if(NULL == (collIDs = emalloc(count * sizeof(int)))) {
-               RETURN_FALSE;
-               }
-
-       if(NULL == (docIDs = emalloc(count * sizeof(int)))) {
-               efree(collIDs);
-               RETURN_FALSE;
-               }
-
-       collIDcount = docIDcount = 0;
-       zend_hash_internal_pointer_reset(src_arr);
-       for(i=0; i<count; i++) {
-               char *objrec;
-               zval *keydata, **keydataptr;
-               zend_hash_get_current_data(src_arr, (void **) &keydataptr);
-               keydata = *keydataptr;
-               if(Z_TYPE_P(keydata) == IS_LONG) {
-                       if(0 != (ptr->lasterror = send_getobject(ptr->socket, Z_LVAL_P(keydata), &objrec))) {
-                               efree(collIDs);
-                               efree(docIDs);
-                               RETURN_FALSE;
-                       }
-                       if(0 == fnAttributeCompare(objrec, "DocumentType", "collection"))
-                               collIDs[collIDcount++] = Z_LVAL_P(keydata);
-                       else
-                               docIDs[docIDcount++] = Z_LVAL_P(keydata);
-                       efree(objrec);
-               }
-               zend_hash_move_forward(src_arr);
-       }
-
-       if (0 != (ptr->lasterror = send_mvcpdocscoll(ptr->socket, docIDs, docIDcount, from, dest, mvcp))) {
-               efree(collIDs);
-               efree(docIDs);
-               RETURN_FALSE;
-       }
-
-       if (0 != (ptr->lasterror = send_mvcpcollscoll(ptr->socket, collIDs, collIDcount, from, dest, mvcp))) {
-               efree(collIDs);
-               efree(docIDs);
-               RETURN_FALSE;
-       }
-
-       efree(collIDs);
-       efree(docIDs);
-
-       RETURN_LONG(docIDcount + collIDcount);
-}
-/* }}} */
-
-/* {{{ proto int hw_mv(resource link, array objrec, int from, int dest)
-   Moves object */
-PHP_FUNCTION(hw_mv)
-{
-       php_hw_mvcp(INTERNAL_FUNCTION_PARAM_PASSTHRU, MOVE);
-}
-/* }}} */
-
-/* {{{ proto int hw_cp(resource link, array objrec, int dest)
-   Copies object */
-PHP_FUNCTION(hw_cp)
-{
-       php_hw_mvcp(INTERNAL_FUNCTION_PARAM_PASSTHRU, COPY);
-}
-/* }}} */
-
-/* {{{ proto int hw_gettext(resource link, int objid [, int rootid])
-   Returns text document. Links are relative to rootid if given */
-PHP_FUNCTION(hw_gettext)
-{
-       zval **argv[3];
-       int argc, link, id, type, mode;
-       int rootid = 0;
-       char *urlprefix;
-       hw_document *doc;
-       hw_connection *ptr;
-
-       argc = ZEND_NUM_ARGS();
-       if(argc > 3 || argc < 2 || (zend_get_parameters_array_ex(argc, argv) == FAILURE)) {
-               WRONG_PARAM_COUNT;
-       }       
-
-       HW_FETCH_LINK(argv[0]);
-       convert_to_long_ex(argv[1]);
-       mode = 0;
-       urlprefix = NULL;
-       if(argc == 3) {
-               switch(Z_TYPE_PP(argv[2])) {
-                       case IS_LONG:
-                               convert_to_long_ex(argv[2]);
-                               rootid = Z_LVAL_PP(argv[2]);
-                               mode = 1;
-                               break;
-                       case IS_STRING: 
-                               convert_to_string_ex(argv[2]);
-                               urlprefix = Z_STRVAL_PP(argv[2]);
-                               break;
-               }
-       }
-       id=Z_LVAL_PP(argv[1]);
-
-       set_swap(ptr->swap_on);
-       {
-       char *object = NULL;
-       char *attributes = NULL;
-       char *bodytag = NULL;
-       int count;
-       /* !!!! memory for object and attributes is allocated with malloc !!!! */
-       if (0 != (ptr->lasterror = send_gettext(ptr->socket, id, mode, rootid, &attributes, &bodytag, &object, &count, urlprefix)))
-               RETURN_FALSE;
-       doc = malloc(sizeof(hw_document));
-       doc->data = object;
-       doc->attributes = attributes;
-       doc->bodytag = bodytag;
-       doc->size = count;
-       Z_LVAL_P(return_value) = zend_list_insert(doc, le_document);
-       Z_TYPE_P(return_value) = IS_LONG;
-       }
-}
-/* }}} */
-
-/* {{{ proto bool hw_edittext(resource link, hwdoc doc)
-   Modifies text document */
-PHP_FUNCTION(hw_edittext)
-{
-       zval **arg1, **arg2;
-       int link, doc, type;
-       hw_connection *ptr;
-       hw_document *docptr;
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-
-       doc=Z_LVAL_PP(arg2);
-       docptr = zend_list_find(doc, &type);
-
-       if(!docptr || (type!=le_document)) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find document identifier %d", doc);
-               RETURN_FALSE;
-       }
-
-       set_swap(ptr->swap_on);
-       {
-       if (0 != (ptr->lasterror =  send_edittext(ptr->socket, docptr->attributes, docptr->data))) {
-               RETURN_FALSE;
-               }
-       }
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int hw_getcgi(resource link, int objid)
-   Returns the output of a CGI script */
-#define BUFFERLEN 1000
-/* FIX ME: The buffer cgi_env_str should be allocated dynamically */
-PHP_FUNCTION(hw_getcgi)
-{
-       zval **arg1, **arg2;
-       int link, id, type;
-       hw_document *doc;
-       hw_connection *ptr;
-       char cgi_env_str[BUFFERLEN];
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       id=Z_LVAL_PP(arg2);
-
-       set_swap(ptr->swap_on);
-       {
-       char *object = NULL;
-       char *attributes = NULL;
-       int count;
-
-       /* Here is another undocument function of Hyperwave.
-          If you call a cgi script with getcgi-message, you will
-          have to provide the complete cgi enviroment, since it is
-          only known to the webserver (or wavemaster). This is done
-          by extending the object record with the following incomplete
-          string. It should contain any enviroment variable a cgi script
-          requires.
-       */
-#ifdef PHP_WIN32
-       snprintf(cgi_env_str, BUFFERLEN, "CGI_REQUEST_METHOD=%s\nCGI_PATH_INFO=%s\nCGI_QUERY_STRING=%s",
-                            getenv("REQUEST_METHOD"),
-                            getenv("PATH_INFO"),
-                            getenv("QUERY_STRING"));
-#else
-       snprintf(cgi_env_str, BUFFERLEN, "CGI_REQUEST_METHOD=%s\nCGI_PATH_INFO=%s\nCGI_QUERY_STRING=%s",
-                            SG(request_info).request_method,
-                            SG(request_info).request_uri,
-                            SG(request_info).query_string);
-#endif
-       /* !!!! memory for object and attributes is allocated with malloc !!!! */
-       if (0 != (ptr->lasterror = send_getcgi(ptr->socket, id, cgi_env_str, &attributes, &object, &count)))
-               RETURN_FALSE;
-       doc = malloc(sizeof(hw_document));
-       doc->data = object;
-       doc->attributes = attributes;
-       doc->bodytag = NULL;
-       doc->size = count;
-       Z_LVAL_P(return_value) = zend_list_insert(doc, le_document);
-       Z_TYPE_P(return_value) = IS_LONG;
-       }
-}
-#undef BUFFERLEN
-/* }}} */
-
-/* {{{ proto int hw_getremote(resource link, int objid)
-   Returns the content of a remote document */
-PHP_FUNCTION(hw_getremote)
-{
-       zval **arg1, **arg2;
-       int link, id, type;
-       hw_document *doc;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       id=Z_LVAL_PP(arg2);
-
-       set_swap(ptr->swap_on);
-       {
-       char *object = NULL;
-       char *attributes = NULL;
-       int count;
-       /* !!!! memory for object and attributes is allocated with malloc !!!! */
-       if (0 != (ptr->lasterror = send_getremote(ptr->socket, id, &attributes, &object, &count)))
-               RETURN_FALSE;
-       doc = malloc(sizeof(hw_document));
-       doc->data = object;
-       doc->attributes = attributes;
-       doc->bodytag = NULL;
-       doc->size = count;
-       Z_LVAL_P(return_value) = zend_list_insert(doc, le_document);
-       Z_TYPE_P(return_value) = IS_LONG;
-       }
-}
-/* }}} */
-
-/* {{{ proto mixed hw_getremotechildren(resource link, string objrec)
-   Returns the remote document or an array of object records */
-PHP_FUNCTION(hw_getremotechildren)
-{
-       zval **arg1, **arg2;
-       int link, type, i;
-       hw_connection *ptr;
-       char *objrec;
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_string_ex(arg2);
-       objrec=Z_STRVAL_PP(arg2);
-
-       set_swap(ptr->swap_on);
-       {
-       int count, *offsets;
-       char *remainder, *ptr1;
-       if (0 != (ptr->lasterror = send_getremotechildren(ptr->socket, objrec, &remainder, &offsets, &count)))
-               RETURN_FALSE;
-
-/*
-for(i=0;i<count;i++)
-  php_printf("offset[%d] = %d--\n", i, offsets[i]);
-php_printf("count = %d, remainder = <HR>%s---<HR>", count, remainder);
-*/
-       /* The remainder depends on the number of returned objects and
-          whether the MimeType of the object to retrieve is set. If
-          the MimeType is set the result will start with the
-          HTTP header 'Content-type: mimetype', otherwise it will be
-          a list of object records and therefore starts with
-          'ObjectID=0'. In the first case the offset and count are somewhat
-          strange. Quite often count had a value of 6 which appears to be
-          meaningless, but if you sum up the offsets you get the length
-          of the remainder which is the lenght of the document.
-          The document must have been chopped up into 6 pieces, each ending
-          with 'ServerId=0xYYYYYYYY'.
-          In the second case the offset contains the lenght of
-          each object record; count contains the number of object records.
-          Even if a remote object has children
-          (several sql statements) but the MimeType is set, it will
-          return a document in the format of MimeType. On the other
-          hand a remote object does not have any children but just
-          returns a docuement will not be shown unless the MimeType
-          is set. It returns the pure object record of the object without
-          the SQLStatement attribute. Quite senseless.
-           Though, this behavior depends on how the hgi gateway in Hyperwave
-          is implemented.
-       */
-       if(strncmp(remainder, "ObjectID=0 ", 10)) {
-               hw_document *doc;
-               char *ptr;
-               int i, j, len;
-               /* For some reason there is always the string
-                  'SeverId=0xYYYYYYYY' at the end, so we cut it off.
-                  The document may as well be divided into several pieces
-                  and each of them has the ServerId at the end.
-                  The following will put the pieces back together and
-                  strip the ServerId. count contains the number of pieces.
-               */
-               for(i=0, len=0; i<count; i++)
-                       len += offsets[i]-18;
-/*fprintf(stderr, "len = %d\n", len); */
-               doc = malloc(sizeof(hw_document));
-               doc->data = malloc(len+1);
-               ptr = doc->data;
-               for(i=0, j=0; i<count; i++) {
-                       memcpy((char *)ptr, (char *)&remainder[j], offsets[i]-18);
-/*fprintf(stderr, "rem = %s\n", &remainder[j]); */
-                       j += offsets[i];
-                       ptr += offsets[i] - 18;
-               }
-               *ptr = '\0';
-               doc->attributes = strdup(objrec);
-               doc->bodytag = NULL;
-               doc->size = strlen(doc->data);
-               Z_LVAL_P(return_value) = zend_list_insert(doc, le_document);
-               Z_TYPE_P(return_value) = IS_LONG;
-       } else {
-               array_init(return_value);
-
-               ptr1 = remainder;
-               for(i=0; i<count; i++) {
-                       *(ptr1+offsets[i]-1) = '\0';
-                       add_index_string(return_value, i, ptr1, 1);
-                       ptr1 += offsets[i];
-               }
-       }
-
-       efree(offsets);
-       efree(remainder);
-       }
-}
-/* }}} */
-
-/* {{{ proto int hw_setlinkroot(resource link, int rootid)
-   Set the id to which links are calculated */
-PHP_FUNCTION(hw_setlinkroot)
-{
-       zval **arg1, **arg2;
-       int link, type, rootid;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       rootid = Z_LVAL_PP(arg2);
-
-       ptr->linkroot = rootid;
-       RETURN_LONG(rootid);
-}
-/* }}} */
-
-/* {{{ proto int hw_pipedocument(resource link, int objid [, array urlprefixes])
-   Returns document with links inserted. Optionally a array with five urlprefixes may be passed, which will be inserted for the different types of anchors. This should be a named array with the following keys: HW_DEFAULT_LINK, HW_IMAGE_LINK, HW_BACKGROUND_LINK, HW_INTAG_LINK, and HW_APPLET_LINK */
-PHP_FUNCTION(hw_pipedocument)
-{
-       zval **arg1, **arg2, **arg3;
-       int i, link, id, type, argc, mode;
-       int rootid = 0;
-       HashTable *prefixarray;
-       char **urlprefix;
-       hw_connection *ptr;
-       hw_document *doc;
-#if APACHE
-       server_rec *serv = ((request_rec *) SG(server_context))->server;
-#endif
-
-       argc = ZEND_NUM_ARGS();
-       switch(argc)
-       {
-       case 2:
-               if (zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE)
-                       WRONG_PARAM_COUNT;
-               break;
-       case 3:
-               if (zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE)
-                       WRONG_PARAM_COUNT;
-               break;
-       default:
-               WRONG_PARAM_COUNT;
-       }
-
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       
-       id=Z_LVAL_PP(arg2);
-
-       /* check for the array with urlprefixes */
-       if(argc == 3) {
-               convert_to_array_ex(arg3);
-               prefixarray =Z_ARRVAL_PP(arg3);
-               if((prefixarray == NULL) || (zend_hash_num_elements(prefixarray) != 5)) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "You must provide 5 urlprefixes (you have provided %d)", zend_hash_num_elements(prefixarray));
-                       RETURN_FALSE;
-               }
-
-               urlprefix = emalloc(5*sizeof(char *));
-               zend_hash_internal_pointer_reset(prefixarray);
-               for(i=0; i<5; i++) {
-                       char *key;
-                       zval *data, **dataptr;
-                       ulong ind;
-                       
-                       zend_hash_get_current_key(prefixarray, &key, &ind, 0);
-                       zend_hash_get_current_data(prefixarray, (void *) &dataptr);
-                       data = *dataptr;
-                       if (Z_TYPE_P(data) != IS_STRING) {
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s must be a String", key);
-                               RETURN_FALSE;
-                       } else if ( strcmp(key, "HW_DEFAULT_LINK") == 0 ) {
-                               urlprefix[HW_DEFAULT_LINK] = Z_STRVAL_P(data);
-                       } else if ( strcmp(key, "HW_IMAGE_LINK") == 0 ) {
-                               urlprefix[HW_IMAGE_LINK] = Z_STRVAL_P(data);
-                       } else if ( strcmp(key, "HW_BACKGROUND_LINK") == 0 ) {
-                               urlprefix[HW_BACKGROUND_LINK] = Z_STRVAL_P(data);
-                       } else if ( strcmp(key, "HW_INTAG_LINK") == 0 ) {
-                               urlprefix[HW_INTAG_LINK] = Z_STRVAL_P(data);
-                       } else if ( strcmp(key, "HW_APPLET_LINK") == 0 ) {
-                               urlprefix[HW_APPLET_LINK] = Z_STRVAL_P(data);
-                       } else {
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s is not a valid urlprefix", key);
-                               RETURN_FALSE;
-                       }
-                       zend_hash_move_forward(prefixarray);
-               }
-       } else {
-               urlprefix = NULL;
-       }
-
-       mode = 0;
-       if(ptr->linkroot > 0)
-               mode = 1;
-       rootid = ptr->linkroot;
-
-       set_swap(ptr->swap_on);
-       {
-       char *object = NULL;
-       char *attributes = NULL;
-       char *bodytag = NULL;
-       int count;
-       /* !!!! memory for object, bodytag and attributes is allocated with malloc !!!! */
-       if (0 != (ptr->lasterror =  send_pipedocument(ptr->socket,
-#if APACHE
-  serv->server_hostname,
-#else
-  getenv("HOSTNAME"),
-#endif
-   id, mode, rootid, &attributes, &bodytag, &object, &count, urlprefix)))
-               RETURN_FALSE;
-               
-       if(urlprefix) efree(urlprefix);
-
-       doc = malloc(sizeof(hw_document));
-       doc->data = object;
-       doc->attributes = attributes;
-       doc->bodytag = bodytag;
-       doc->size = count;
-/* fprintf(stderr, "size = %d\n", count); */
-       Z_LVAL_P(return_value) = zend_list_insert(doc, le_document);
-       Z_TYPE_P(return_value) = IS_LONG;
-       }
-}
-/* }}} */
-
-/* {{{ proto int hw_pipedocument(resource link, int objid)
-   Returns document */
-PHP_FUNCTION(hw_oldpipedocument)
-{
-       zval **argv[3];
-       int link, id, type, argc, mode;
-       int rootid = 0;
-       hw_connection *ptr;
-       hw_document *doc;
-#if APACHE
-       server_rec *serv = ((request_rec *) SG(server_context))->server;
-#endif
-
-       argc = ZEND_NUM_ARGS();
-       if(argc != 2 || (zend_get_parameters_array_ex(argc, argv) == FAILURE)) {
-               WRONG_PARAM_COUNT;
-       }
-
-       HW_FETCH_LINK(argv[0]);
-       convert_to_long_ex(argv[1]);
-/*     if(argc == 3) {
-               convert_to_long_ex(argv[2]);
-               rootid = Z_LVAL_PP(argv[2]);
-               if(rootid != 0)
-                       mode = 1;
-       }
-*/
-       id=Z_LVAL_PP(argv[1]);
-
-       mode = 0;
-       if(ptr->linkroot > 0)
-               mode = 1;
-       rootid = ptr->linkroot;
-
-       set_swap(ptr->swap_on);
-       {
-       char *object = NULL;
-       char *attributes = NULL;
-       char *bodytag = NULL;
-       int count;
-       /* !!!! memory for object, bodytag and attributes is allocated with malloc !!!! */
-       if (0 != (ptr->lasterror =  send_pipedocument(ptr->socket,
-#if APACHE
-  serv->server_hostname,
-#else
-  getenv("HOSTNAME"),
-#endif
-   id, mode, rootid, &attributes, &bodytag, &object, &count, NULL)))
-               RETURN_FALSE;
-
-       doc = malloc(sizeof(hw_document));
-       doc->data = object;
-       doc->attributes = attributes;
-       doc->bodytag = bodytag;
-       doc->size = count;
-/* fprintf(stderr, "size = %d\n", count); */
-       Z_LVAL_P(return_value) = zend_list_insert(doc, le_document);
-       Z_TYPE_P(return_value) = IS_LONG;
-       }
-}
-/* }}} */
-
-/* {{{ proto int hw_pipecgi(resource link, int objid)
-   Returns output of CGI script */
-#define BUFFERLEN 1000
-/* FIX ME: The buffer cgi_env_str should be allocated dynamically */
-PHP_FUNCTION(hw_pipecgi)
-{
-       zval **arg1, **arg2;
-       int link, id, type;
-       hw_connection *ptr;
-       hw_document *doc;
-       char cgi_env_str[1000];
-#if APACHE
-       server_rec *serv = ((request_rec *) SG(server_context))->server;
-#endif
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       id=Z_LVAL_PP(arg2);
-
-       set_swap(ptr->swap_on);
-       {
-       char *object = NULL;
-       char *attributes = NULL;
-       int count;
-
-#ifdef PHP_WIN32
-       snprintf(cgi_env_str, BUFFERLEN, "CGI_REQUEST_METHOD=%s\nCGI_PATH_INFO=%s\nCGI_QUERY_STRING=%s",
-                            getenv("REQUEST_METHOD"),
-                            getenv("PATH_INFO"),
-                            getenv("QUERY_STRING"));
-#else
-       snprintf(cgi_env_str, BUFFERLEN, "CGI_REQUEST_METHOD=%s\nCGI_PATH_INFO=%s\nCGI_QUERY_STRING=%s",
-                            SG(request_info).request_method,
-                            SG(request_info).request_uri,
-                            SG(request_info).query_string);
-#endif
-       /* !!!! memory for object, bodytag and attributes is allocated with malloc !!!! */
-       if (0 != (ptr->lasterror =  send_pipecgi(ptr->socket,
-#if APACHE
-  serv->server_hostname,
-#else
-  getenv("HOSTNAME"),
-#endif
-  id, cgi_env_str, &attributes, &object, &count)))
-               RETURN_FALSE;
-
-       doc = malloc(sizeof(hw_document));
-       doc->data = object;
-       doc->attributes = attributes;
-       doc->bodytag = NULL;
-       doc->size = count;
-       Z_LVAL_P(return_value) = zend_list_insert(doc, le_document);
-       Z_TYPE_P(return_value) = IS_LONG;
-       }
-}
-#undef BUFFERLEN
-/* }}} */
-
-/* {{{ proto int hw_insertdocument(resource link, int parentid, hwdoc doc) 
-   Insert new document */
-PHP_FUNCTION(hw_insertdocument)
-{
-       zval **arg1, **arg2, **arg3;
-       int link, id, doc, type;
-       hw_connection *ptr;
-       hw_document *docptr;
-       hw_objectID objid;
-#if APACHE
-       server_rec *serv = ((request_rec *) SG(server_context))->server;
-#endif
-
-       if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       convert_to_long_ex(arg3);
-       id=Z_LVAL_PP(arg2);
-
-       doc=Z_LVAL_PP(arg3);
-       docptr = zend_list_find(doc, &type);
-       if(!docptr || (type!=le_document)) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find document identifier %d", doc);
-               RETURN_FALSE;
-       }
-
-       set_swap(ptr->swap_on);
-       {
-       if (0 != (ptr->lasterror =  send_putdocument(ptr->socket,
-#if APACHE
-  serv->server_hostname,
-#else
-  getenv("HOSTNAME"),
-#endif
-             id, docptr->attributes, docptr->data, docptr->size, &objid))) {
-               RETURN_FALSE;
-               }
-       }
-       RETURN_LONG(objid);
-}
-/* }}} */
-
-/* {{{ proto int hw_new_document(string objrec, string data, int size)
-   Create a new document */
-PHP_FUNCTION(hw_new_document)
-{
-       zval **arg1, **arg2, **arg3;
-       char *ptr;
-       hw_document *doc;
-
-       if (ZEND_NUM_ARGS() != 3 || (zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE)) {
-               WRONG_PARAM_COUNT;
-       }
-       convert_to_string_ex(arg1);
-       convert_to_string_ex(arg2);
-       convert_to_long_ex(arg3);
-
-       doc = malloc(sizeof(hw_document));
-       if(NULL == doc)
-               RETURN_FALSE;
-       doc->data = malloc(Z_LVAL_PP(arg3)+1);
-       if(NULL == doc->data) {
-               free(doc);
-               RETURN_FALSE;
-       }
-       memcpy(doc->data, Z_STRVAL_PP(arg2), Z_LVAL_PP(arg3));
-       ptr = doc->data;
-       ptr[Z_LVAL_PP(arg3)] = '\0';
-       doc->attributes = strdup(Z_STRVAL_PP(arg1));
-       doc->bodytag = NULL;
-       doc->size = Z_LVAL_PP(arg3);
-       Z_LVAL_P(return_value) = zend_list_insert(doc, le_document);
-       Z_TYPE_P(return_value) = IS_LONG;
-}
-/* }}} */
-
-/* {{{ proto int hw_new_document_from_file(string objrec, string filename)
-   Create a new document from a file */
-PHP_FUNCTION(hw_new_document_from_file)
-{
-       pval **arg1, **arg2;
-       char *ptr;
-       php_stream *stream;
-       int use_include_path=0;
-       hw_document *doc;
-
-       if (ZEND_NUM_ARGS() != 2 || (zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE)) {
-               WRONG_PARAM_COUNT;
-       }
-
-       convert_to_string_ex(arg1);
-       convert_to_string_ex(arg2);
-
-       stream = php_stream_open_wrapper(Z_STRVAL_PP(arg2), "r", use_include_path|ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL);
-
-       if (stream == NULL)     {
-               RETURN_FALSE;
-       }
-
-       doc = malloc(sizeof(hw_document));
-       if(NULL == doc)
-               RETURN_FALSE;
-
-       doc->size = php_stream_copy_to_mem(stream, &doc->data, PHP_STREAM_COPY_ALL, 1);
-
-       php_stream_close(stream);
-
-       /* I'm not sure if it is necessary to add a '\0'. It depends on whether
-        * PHP-Strings has to be null terminated. doc->size doesn't count the
-        * '\0'.
-        */
-       doc->data = realloc(doc->data, doc->size+1);
-       ptr = doc->data;
-       ptr[doc->size] = '\0';
-       doc->attributes = strdup(Z_STRVAL_PP(arg1));
-       doc->bodytag = NULL;
-       Z_LVAL_P(return_value) = zend_list_insert(doc, le_document);
-       Z_TYPE_P(return_value) = IS_LONG;
-}
-/* }}} */
-
-/* {{{ proto bool hw_free_document(int doc)
-   Frees memory of document */
-PHP_FUNCTION(hw_free_document)
-{
-       zval **arg1;
-       int id, type;
-       hw_document *ptr;
-
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_ID(arg1);
-       zend_list_delete(id);
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto void hw_outputdocument(hwdoc doc)
-   An alias for hw_output_document */
-/* }}} */
-
-/* {{{ proto bool hw_output_document(hwdoc doc)
-   Prints document */
-PHP_FUNCTION(hw_output_document)
-{
-       zval **arg1;
-       int id, type;
-       hw_document *ptr;
-
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_ID(arg1);
-
-       php_write(ptr->data, ptr->size TSRMLS_CC);
-
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto string hw_documentbodytag(int doc [, string prefix])
-   An alias for hw_document_bodytag */
-/* }}} */
-
-/* {{{ proto string hw_document_bodytag(int doc [, string prefix])
-   Return bodytag prefixed by prefix */
-PHP_FUNCTION(hw_document_bodytag)
-{
-       zval **argv[2];
-       int id, type, argc;
-       hw_document *ptr;
-       char *temp, *str = NULL;
-
-       argc = ZEND_NUM_ARGS();
-       if(argc > 2 || argc < 1 || (zend_get_parameters_array_ex(argc, argv) == FAILURE)) {
-               WRONG_PARAM_COUNT;
-       }
-       
-       HW_FETCH_ID(argv[0]);
-
-       if(argc == 2) {
-               convert_to_string_ex(argv[1]);
-               str=Z_STRVAL_PP(argv[1]);
-       }
-
-       if(str != NULL) {
-               temp = emalloc(Z_STRLEN_PP(argv[1]) + strlen(ptr->bodytag) + 2);
-               strcpy(temp, ptr->bodytag);
-               strcpy(temp+strlen(ptr->bodytag)-1, str);
-               strcpy(temp+strlen(ptr->bodytag)-1+Z_STRLEN_PP(argv[1]), ">\n");
-               RETURN_STRING(temp, 0);
-       } else {
-/* fprintf(stderr, "hw_document_bodytag: %s (%s)\n", ptr->bodytag, ptr->attributes); */
-               if(ptr->bodytag) {
-                       RETURN_STRING(ptr->bodytag, 1);
-               } else {
-                       RETURN_EMPTY_STRING();
-               }
-       }
-}
-/* }}} */
-
-/* {{{ proto string hw_document_content(int doc)
-   Returns content of document */
-PHP_FUNCTION(hw_document_content)
-{
-       zval **arg1;
-       int id, type;
-       hw_document *ptr;
-
-       if (ZEND_NUM_ARGS() != 1 || (zend_get_parameters_ex(1, &arg1) == FAILURE)) {
-               RETURN_FALSE;
-       }
-       
-       HW_FETCH_ID(arg1);
-
-       RETURN_STRINGL(ptr->data, ptr->size, 1);
-}
-/* }}} */
-
-/* {{{ proto bool hw_document_setcontent(int doc, string content)
-   Sets/replaces content of document */
-PHP_FUNCTION(hw_document_setcontent)
-{
-       zval **arg1, **arg2;
-       int id, type;
-       hw_document *ptr;
-       char *str;
-
-       if (ZEND_NUM_ARGS() != 2 || (zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE)) {
-               WRONG_PARAM_COUNT;
-       }
-       
-       HW_FETCH_ID(arg1);
-       convert_to_string_ex(arg2);
-
-       str = ptr->data;
-       if(NULL != (ptr->data = strdup(Z_STRVAL_PP(arg2)))) {
-               ptr->size = strlen(ptr->data);
-               free(str);
-               RETURN_TRUE;
-       } else {
-               ptr->data = str;
-               RETURN_FALSE;
-       }
-}
-/* }}} */
-
-/* {{{ proto int hw_documentsize(int doc)
-   An alias for hw_document_size */
-/* }}} */
-
-/* {{{ proto int hw_document_size(int doc)
-   Returns size of document */
-PHP_FUNCTION(hw_document_size)
-{
-       zval **arg1;
-       int id, type;
-       hw_document *ptr;
-
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_ID(arg1);
-
-       RETURN_LONG(ptr->size);
-}
-/* }}} */
-
-/* {{{ proto string hw_documentattributes(int doc)
-   An alias for hw_document_attributes */
-/* }}} */
-
-/* {{{ proto string hw_document_attributes(int doc)
-   Returns object record of document */
-PHP_FUNCTION(hw_document_attributes)
-{
-       zval **arg1;
-       int id, type;
-       hw_document *ptr;
-
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_ID(arg1);
-
-       RETURN_STRING(ptr->attributes, 1);
-/*     make_return_array_from_objrec(&return_value, ptr->attributes); */
-}
-/* }}} */
-
-/* {{{ proto array hw_getparentsobj(resource link, int objid)
-   Returns array of parent object records */
-PHP_FUNCTION(hw_getparentsobj)
-{
-       zval **arg1, **arg2;
-       int link, id, type;
-       int count;
-       char  **childObjRecs = NULL;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       id=Z_LVAL_PP(arg2);
-
-       set_swap(ptr->swap_on);
-
-       if (0 != (ptr->lasterror = send_getparentsobj(ptr->socket, id, &childObjRecs, &count))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Command returned %d\n", ptr->lasterror);
-               RETURN_FALSE;
-       }
-
-       /* create return value and free all memory */
-       if( 0 > make_return_objrec(&return_value, childObjRecs, count))
-               RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto array hw_getparents(resource link, int objid)
-   Returns array of parent object ids */
-PHP_FUNCTION(hw_getparents)
-{
-       zval **arg1, **arg2;
-       int link, id, type;
-       int count;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       id=Z_LVAL_PP(arg2);
-
-       set_swap(ptr->swap_on);
-        {
-       int  *childIDs = NULL;
-       int i;
-
-       if (0 != (ptr->lasterror = send_getparents(ptr->socket, id, &childIDs, &count))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Command returned %d\n", ptr->lasterror);
-               RETURN_FALSE;
-       }
-
-       array_init(return_value);
-
-       for(i=0; i<count; i++) {
-               add_index_long(return_value, i, childIDs[i]);
-       }
-       efree(childIDs);
-       }
-
-}
-/* }}} */
-
-/* {{{ proto array hw_children(resource link, int objid)
-   Returns array of children object ids */
-PHP_FUNCTION(hw_children)
-{
-       zval **arg1, **arg2;
-       int link, id, type;
-       int count;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       id=Z_LVAL_PP(arg2);
-
-       set_swap(ptr->swap_on);
-       {
-       int  *childIDs = NULL;
-       int i;
-
-       if (0 != (ptr->lasterror = send_children(ptr->socket, id, &childIDs, &count))){
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Command returned %d\n", ptr->lasterror);
-               RETURN_FALSE;
-       }
-
-       array_init(return_value);
-
-       for(i=0; i<count; i++) {
-               add_index_long(return_value, i, childIDs[i]);
-       }
-       efree(childIDs);
-       }
-               
-}
-/* }}} */
-
-/* {{{ proto array hw_childrenobj(resource link, int objid)
-   Returns array of children object records */
-PHP_FUNCTION(hw_childrenobj)
-{
-       pval **arg1, **arg2;
-       int link, id, type;
-       int count;
-       char  **childObjRecs = NULL;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       id=Z_LVAL_PP(arg2);
-
-       set_swap(ptr->swap_on);
-
-       if (0 != (ptr->lasterror = send_childrenobj(ptr->socket, id, &childObjRecs, &count))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Command returned %d\n", ptr->lasterror);
-               RETURN_FALSE;
-       }
-
-       /* create return value and free all memory */
-       if( 0 > make_return_objrec(&return_value, childObjRecs, count))
-               RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto array hw_getchildcoll(resource link, int objid)
-   Returns array of child collection object ids */
-PHP_FUNCTION(hw_getchildcoll)
-{
-       pval **arg1, **arg2;
-       int link, id, type;
-       int count;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       id=Z_LVAL_PP(arg2);
-
-       set_swap(ptr->swap_on);
-       {
-       int  *childIDs = NULL;
-       int i;
-
-       if (0 != (ptr->lasterror = send_getchildcoll(ptr->socket, id, &childIDs, &count))){
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Command returned %d\n", ptr->lasterror);
-               RETURN_FALSE;
-       }
-
-       array_init(return_value);
-
-       for(i=0; i<count; i++) {
-               add_index_long(return_value, i, childIDs[i]);
-       }
-       efree(childIDs);
-       }
-               
-}
-/* }}} */
-
-/* {{{ proto array hw_getchildcollobj(resource link, int objid)
-   Returns array of child collection object records */
-PHP_FUNCTION(hw_getchildcollobj)
-{
-       pval **arg1, **arg2;
-       int link, id, type;
-       int count;
-       char  **childObjRecs = NULL;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       id=Z_LVAL_PP(arg2);
-
-       set_swap(ptr->swap_on);
-
-       if (0 != (ptr->lasterror = send_getchildcollobj(ptr->socket, id, &childObjRecs, &count))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Command returned %d\n", ptr->lasterror);
-               RETURN_FALSE;
-       }
-
-       /* create return value and free all memory */
-       if( 0 > make_return_objrec(&return_value, childObjRecs, count))
-               RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto int hw_docbyanchor(resource link, int anchorid)
-   Returns objid of document belonging to anchorid */
-PHP_FUNCTION(hw_docbyanchor)
-{
-       pval **arg1, **arg2;
-       int link, id, type;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(ht, 2, &arg1, &arg2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       id=Z_LVAL_PP(arg2);
-
-       set_swap(ptr->swap_on);
-       {
-       int objectID;
-       if (0 != (ptr->lasterror = send_docbyanchor(ptr->socket, id, &objectID)))
-               RETURN_FALSE;
-
-       RETURN_LONG(objectID);
-       }
-}
-/* }}} */
-
-/* {{{ proto array hw_docbyanchorobj(resource link, int anchorid)
-   Returns object record of document belonging to anchorid */
-PHP_FUNCTION(hw_docbyanchorobj)
-{
-       pval **arg1, **arg2;
-       int link, id, type;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       id=Z_LVAL_PP(arg2);
-
-       set_swap(ptr->swap_on);
-       {
-       char *object = NULL;
-       if (0 != (ptr->lasterror = send_docbyanchorobj(ptr->socket, id, &object)))
-               RETURN_FALSE;
-
-       RETURN_STRING(object, 0);
-       /*
-       make_return_array_from_objrec(&return_value, object);
-       efree(object);
-       */
-       }
-}
-/* }}} */
-
-/* {{{ proto array hw_getobjectbyquery(resource link, string query, int maxhits)
-   Search for query and return maxhits objids */
-PHP_FUNCTION(hw_getobjectbyquery)
-{
-       pval **arg1, **arg2, **arg3;
-       int link, type, maxhits;
-       char *query;
-       int count, i;
-       int  *childIDs = NULL;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_string_ex(arg2);
-       convert_to_long_ex(arg3);
-       query=Z_STRVAL_PP(arg2);
-       maxhits=Z_LVAL_PP(arg3);
-       if (maxhits < 0) maxhits=0x7FFFFFFF;
-
-       set_swap(ptr->swap_on);
-       if (0 != (ptr->lasterror = send_getobjbyquery(ptr->socket, query, maxhits, &childIDs, &count))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Command returned %d\n", ptr->lasterror);
-               RETURN_FALSE;
-       }
-
-       array_init(return_value);
-
-       for(i=0; i<count; i++)
-               add_index_long(return_value, i, childIDs[i]);
-       efree(childIDs);
-}
-/* }}} */
-
-/* {{{ proto array hw_getobjectbyqueryobj(resource link, string query, int maxhits)
-   Search for query and return maxhits object records */
-PHP_FUNCTION(hw_getobjectbyqueryobj)
-{
-       pval **arg1, **arg2, **arg3;
-       int link, type, maxhits;
-       char *query;
-       int count;
-       char  **childObjRecs = NULL;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_string_ex(arg2);
-       convert_to_long_ex(arg3);
-       query=Z_STRVAL_PP(arg2);
-       maxhits=Z_LVAL_PP(arg3);
-       if (maxhits < 0) maxhits=0x7FFFFFFF;
-
-       set_swap(ptr->swap_on);
-       if (0 != (ptr->lasterror = send_getobjbyqueryobj(ptr->socket, query, maxhits, &childObjRecs, &count))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Command returned %d\n", ptr->lasterror);
-               RETURN_FALSE;
-       }
-
-       /* create return value and free all memory */
-       if( 0 > make_return_objrec(&return_value, childObjRecs, count))
-               RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto array hw_getobjectbyquerycoll(resource link, int collid, string query, int maxhits)
-   Search for query in collection and return maxhits objids */
-PHP_FUNCTION(hw_getobjectbyquerycoll)
-{
-       pval **arg1, **arg2, **arg3, **arg4;
-       int link, id, type, maxhits;
-       char *query;
-       int count, i;
-       hw_connection *ptr;
-       int  *childIDs = NULL;
-
-       if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       convert_to_string_ex(arg3);
-       convert_to_long_ex(arg4);
-       id=Z_LVAL_PP(arg2);
-       query=Z_STRVAL_PP(arg3);
-       maxhits=Z_LVAL_PP(arg4);
-       if (maxhits < 0) maxhits=0x7FFFFFFF;
-
-       set_swap(ptr->swap_on);
-       if (0 != (ptr->lasterror = send_getobjbyquerycoll(ptr->socket, id, query, maxhits, &childIDs, &count))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Command returned %d\n", ptr->lasterror);
-               RETURN_FALSE;
-       }
-
-       array_init(return_value);
-
-       for(i=0; i<count; i++)
-               add_index_long(return_value, i, childIDs[i]);
-       efree(childIDs);
-}
-/* }}} */
-
-/* {{{ proto array hw_getobjectbyquerycollobj(resource link, int collid, string query, int maxhits)
-   Search for query in collection and return maxhits object records */
-PHP_FUNCTION(hw_getobjectbyquerycollobj)
-{
-       pval **arg1, **arg2, **arg3, **arg4;
-       int link, id, type, maxhits;
-       char *query;
-       int count;
-       hw_connection *ptr;
-       char  **childObjRecs = NULL;
-
-       if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       convert_to_string_ex(arg3);
-       convert_to_long_ex(arg4);
-       id=Z_LVAL_PP(arg2);
-       query=Z_STRVAL_PP(arg3);
-       maxhits=Z_LVAL_PP(arg4);
-       if (maxhits < 0) maxhits=0x7FFFFFFF;
-
-       set_swap(ptr->swap_on);
-       if (0 != (ptr->lasterror = send_getobjbyquerycollobj(ptr->socket, id, query, maxhits, &childObjRecs, &count))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Command returned %d\n", ptr->lasterror);
-               RETURN_FALSE;
-       }
-
-       /* create return value and free all memory */
-       if( 0 > make_return_objrec(&return_value, childObjRecs, count))
-               RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto array hw_getobjectbyftquery(resource link, string query, int maxhits)
-   Search for query as fulltext and return maxhits objids */
-PHP_FUNCTION(hw_getobjectbyftquery)
-{
-       pval **arg1, **arg2, **arg3;
-       int link, type, maxhits;
-       char *query;
-       int count, i;
-       int  *childIDs = NULL;
-       float *weights;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_string_ex(arg2);
-       convert_to_long_ex(arg3);
-       query=Z_STRVAL_PP(arg2);
-       maxhits=Z_LVAL_PP(arg3);
-       if (maxhits < 0) maxhits=0x7FFFFFFF;
-
-       set_swap(ptr->swap_on);
-       if (0 != (ptr->lasterror = send_getobjbyftquery(ptr->socket, query, maxhits, &childIDs, &weights, &count))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Command returned %d\n", ptr->lasterror);
-               RETURN_FALSE;
-       }
-
-       array_init(return_value) ;
-
-       for(i=0; i<count; i++)
-               add_index_long(return_value, i, childIDs[i]);
-       efree(childIDs);
-}
-/* }}} */
-
-/* {{{ proto array hw_getobjectbyftqueryobj(resource link, string query, int maxhits)
-   Search for query as fulltext and return maxhits object records */
-PHP_FUNCTION(hw_getobjectbyftqueryobj)
-{
-       pval **arg1, **arg2, **arg3;
-       int link, type, maxhits;
-       char *query;
-       int count;
-       char  **childObjRecs = NULL;
-       float *weights;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_string_ex(arg2);
-       convert_to_long_ex(arg3);
-       query=Z_STRVAL_PP(arg2);
-       maxhits=Z_LVAL_PP(arg3);
-       if (maxhits < 0) maxhits=0x7FFFFFFF;
-
-       set_swap(ptr->swap_on);
-       if (0 != (ptr->lasterror = send_getobjbyftqueryobj(ptr->socket, query, maxhits, &childObjRecs, &weights, &count))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Command returned %d\n", ptr->lasterror);
-               RETURN_FALSE;
-       }
-
-       /* create return value and free all memory */
-       if( 0 > make_return_objrec(&return_value, childObjRecs, count))
-               RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto array hw_getobjectbyftquerycoll(resource link, int collid, string query, int maxhits)
-   Search for fulltext query in collection and return maxhits objids */
-PHP_FUNCTION(hw_getobjectbyftquerycoll)
-{
-       pval **arg1, **arg2, **arg3, **arg4;
-       int link, id, type, maxhits;
-       char *query;
-       int count, i;
-       hw_connection *ptr;
-       int  *childIDs = NULL;
-       float *weights;
-
-       if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       convert_to_string_ex(arg3);
-       convert_to_long_ex(arg4);
-       id=Z_LVAL_PP(arg2);
-       query=Z_STRVAL_PP(arg3);
-       maxhits=Z_LVAL_PP(arg4);
-       if (maxhits < 0) maxhits=0x7FFFFFFF;
-
-       set_swap(ptr->swap_on);
-       if (0 != (ptr->lasterror = send_getobjbyftquerycoll(ptr->socket, id, query, maxhits, &childIDs, &weights, &count))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Command returned %d\n", ptr->lasterror);
-               RETURN_FALSE;
-       }
-
-       array_init(return_value);
-
-       for(i=0; i<count; i++)
-               add_index_long(return_value, i, childIDs[i]);
-       efree(childIDs);
-}
-/* }}} */
-
-/* {{{ proto array hw_getobjectbyftquerycollobj(resource link, int collid, string query, int maxhits)
-   Search for fulltext query in collection and return maxhits object records */
-PHP_FUNCTION(hw_getobjectbyftquerycollobj)
-{
-       pval **arg1, **arg2, **arg3, **arg4;
-       int link, id, type, maxhits;
-       char *query;
-       int count;
-       hw_connection *ptr;
-       char  **childObjRecs = NULL;
-       float *weights;
-
-       if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       convert_to_string_ex(arg3);
-       convert_to_long_ex(arg4);
-       id=Z_LVAL_PP(arg2);
-       query=Z_STRVAL_PP(arg3);
-       maxhits=Z_LVAL_PP(arg4);
-       if (maxhits < 0) maxhits=0x7FFFFFFF;
-
-       set_swap(ptr->swap_on);
-       if (0 != (ptr->lasterror = send_getobjbyftquerycollobj(ptr->socket, id, query, maxhits, &childObjRecs, &weights, &count))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Command returned %d\n", ptr->lasterror);
-               RETURN_FALSE;
-       }
-
-       /* create return value and free all memory */
-       if( 0 > make_return_objrec(&return_value, childObjRecs, count))
-               RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto array hw_getchilddoccoll(resource link, int objid)
-   Returns all children ids which are documents */
-PHP_FUNCTION(hw_getchilddoccoll)
-{
-       pval **arg1, **arg2;
-       int link, id, type;
-       int count, i;
-       int  *childIDs = NULL;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       id=Z_LVAL_PP(arg2);
-
-       set_swap(ptr->swap_on);
-       if (0 != (ptr->lasterror = send_getchilddoccoll(ptr->socket, id, &childIDs, &count))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Command returned %d\n", ptr->lasterror);
-               RETURN_FALSE;
-       }
-
-       array_init(return_value);
-
-       for(i=0; i<count; i++)
-               add_index_long(return_value, i, childIDs[i]);
-       efree(childIDs);
-}
-/* }}} */
-
-/* {{{ proto array hw_getchilddoccollobj(resource link, int objid)
-   Returns all children object records which are documents */
-PHP_FUNCTION(hw_getchilddoccollobj)
-{
-       pval **arg1, **arg2;
-       int link, id, type;
-       int count;
-       char  **childObjRecs = NULL;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       id=Z_LVAL_PP(arg2);
-
-       set_swap(ptr->swap_on);
-       if (0 != (ptr->lasterror = send_getchilddoccollobj(ptr->socket, id, &childObjRecs, &count))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Command returned %d\n", ptr->lasterror);
-               RETURN_FALSE;
-       }
-
-       /* create return value and free all memory */
-       if( 0 > make_return_objrec(&return_value, childObjRecs, count))
-               RETURN_FALSE;
-
-}
-/* }}} */
-
-/* {{{ proto array hw_getanchors(resource link, int objid)
-   Return all anchors of object */
-PHP_FUNCTION(hw_getanchors)
-{
-       pval **arg1, **arg2;
-       int link, id, type;
-       int count, i;
-       int  *anchorIDs = NULL;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       id=Z_LVAL_PP(arg2);
-
-       set_swap(ptr->swap_on);
-       if (0 != (ptr->lasterror = send_getanchors(ptr->socket, id, &anchorIDs, &count))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Command returned %d\n", ptr->lasterror);
-               RETURN_FALSE;
-       }
-
-       array_init(return_value);
-
-       for(i=0; i<count; i++)
-               add_index_long(return_value, i, anchorIDs[i]);
-       efree(anchorIDs);
-}
-/* }}} */
-
-/* {{{ proto array hw_getanchorsobj(resource link, int objid)
-   Return all object records of anchors of object */
-PHP_FUNCTION(hw_getanchorsobj)
-{
-       pval **arg1, **arg2;
-       int link, id, type;
-       int count;
-       char  **anchorObjRecs = NULL;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       id=Z_LVAL_PP(arg2);
-
-       set_swap(ptr->swap_on);
-       if (0 != (ptr->lasterror = send_getanchorsobj(ptr->socket, id, &anchorObjRecs, &count))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Command returned %d\n", ptr->lasterror);
-               RETURN_FALSE;
-       }
-
-       /* create return value and free all memory */
-       if( 0 > make_return_objrec(&return_value, anchorObjRecs, count))
-               RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto string hw_getusername(resource link)
-   Returns the current user name */
-PHP_FUNCTION(hw_getusername)
-{
-       pval **arg1;
-       int link, type;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-
-       Z_STRVAL_P(return_value) = estrdup(ptr->username);
-       Z_STRLEN_P(return_value) = strlen(ptr->username);
-       Z_TYPE_P(return_value) = IS_STRING;
-}
-/* }}} */
-
-/* {{{ proto void hw_identify(int link, string username, string password)
-   Identifies at Hyperwave server */
-PHP_FUNCTION(hw_identify)
-{
-       pval **arg1, **arg2, **arg3;
-       int link, type;
-       char *name, *passwd, *userdata;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_string_ex(arg2);
-       convert_to_string_ex(arg3);
-       name=Z_STRVAL_PP(arg2);
-       passwd=Z_STRVAL_PP(arg3);
-
-       set_swap(ptr->swap_on);
-       {
-       char *str;
-
-       if (0 != (ptr->lasterror = send_identify(ptr->socket, name, passwd, &userdata))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Command returned %d\n", ptr->lasterror);
-               if(ptr->username) free(ptr->username);
-               ptr->username = NULL;
-               RETURN_FALSE;
-       }
-
-       Z_STRVAL_P(return_value) = userdata;
-       Z_STRLEN_P(return_value) = strlen(userdata);
-       Z_TYPE_P(return_value) = IS_STRING;
-       if(ptr->username) free(ptr->username);
-       str = userdata;
-       while((*str != 0) && (*str != ' '))
-               str++;
-       if(*str != '\0')
-               ptr->username = strdup(++str);
-       else
-               ptr->username = NULL;
-       }
-}
-/* }}} */
-
-/* {{{ proto array hw_objrec2array(string objrec, [array format])
-   Returns object array of object record */
-PHP_FUNCTION(hw_objrec2array)
-{
-       zval **arg1, **arg2;
-
-       switch(ZEND_NUM_ARGS()) {
-               case 1:
-                       if(zend_get_parameters_ex(1, &arg1) == FAILURE)
-                               WRONG_PARAM_COUNT;
-                       convert_to_string_ex(arg1);
-                       make2_return_array_from_objrec(&return_value, Z_STRVAL_PP(arg1), NULL);
-                       break;
-               case 2:
-                       if(zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE)
-                               WRONG_PARAM_COUNT;
-                       convert_to_array_ex(arg2);
-                       convert_to_string_ex(arg1);
-                       make2_return_array_from_objrec(&return_value, Z_STRVAL_PP(arg1), *arg2);
-                       break;
-               default:
-                       WRONG_PARAM_COUNT;
-       }
-}
-/* }}} */
-
-/* {{{ proto string hw_array2objrec(array objarr)
-   Returns object record of object array */
-PHP_FUNCTION(hw_array2objrec)
-{
-       pval **arg1;
-       char *objrec, *retobj;
-
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       convert_to_array_ex(arg1);
-       objrec = make_objrec_from_array(Z_ARRVAL_PP(arg1), '=');
-       if(objrec) {
-               retobj = estrdup(objrec);
-               free(objrec);
-               RETURN_STRING(retobj, 0);
-       } else
-               RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto array hw_incollections(resource link, array objids, array collids, int para)
-   Returns object ids which are in collections */
-PHP_FUNCTION(hw_incollections)
-{
-       pval **arg1, **arg2, **arg3, **arg4;
-       int type, link, i;
-       hw_connection *ptr;
-       int cobjids, ccollids, *objectIDs, *collIDs, cretids, *retIDs, retcoll;
-
-       if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_array_ex(arg2);
-       convert_to_array_ex(arg3);
-       convert_to_long_ex(arg4);
-       retcoll=Z_LVAL_PP(arg4);
-
-       cobjids = zend_hash_num_elements(Z_ARRVAL_PP(arg2));
-       if(NULL == (objectIDs = make_ints_from_array(Z_ARRVAL_PP(arg2)))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not create Int Array from Array");
-               RETURN_FALSE;
-       }
-
-       ccollids = zend_hash_num_elements(Z_ARRVAL_PP(arg3));
-       if(NULL == (collIDs = make_ints_from_array(Z_ARRVAL_PP(arg3)))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not create Int Array from Array");
-               efree(objectIDs);
-               RETURN_FALSE;
-       }
-
-       set_swap(ptr->swap_on);
-       if (0 != (ptr->lasterror = send_incollections(ptr->socket, retcoll,
-                                                      cobjids, objectIDs,
-                                                      ccollids, collIDs,
-                                                      &cretids, &retIDs))) {
-               if(objectIDs) efree(objectIDs);
-               if(collIDs) efree(collIDs);
-               RETURN_FALSE;
-       }
-
-       if(objectIDs) efree(objectIDs);
-       if(collIDs) efree(collIDs);
-
-       array_init(return_value);
-
-       for(i=0; i<cretids; i++)
-               add_index_long(return_value, i, retIDs[i]);
-       efree(retIDs);
-
-}
-/* }}} */
-
-/* {{{ proto int hw_inscoll(resource link, int parentid, array objarr)
-   Inserts collection */
-PHP_FUNCTION(hw_inscoll)
-{
-       pval **arg1, **arg2, **arg3;
-       char *objrec;
-       int id, newid, type, link;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       convert_to_array_ex(arg3);
-       id=Z_LVAL_PP(arg2);
-
-       if(NULL == (objrec = make_objrec_from_array(Z_ARRVAL_PP(arg3), '='))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not create Object Record from Array");
-               RETURN_FALSE;
-       }
-
-       set_swap(ptr->swap_on);
-       if (0 != (ptr->lasterror = send_inscoll(ptr->socket, id, objrec, &newid))) {
-               if(objrec) free(objrec);
-               RETURN_FALSE;
-       }
-
-       if(objrec) free(objrec);
-       RETURN_LONG(newid);
-}
-/* }}} */
-
-/* {{{ proto int hw_insdoc(resource link, int parentid, string objrec [, string text])
-   Inserts document */
-PHP_FUNCTION(hw_insdoc)
-{
-       zval **argv[4];
-       char *objrec, *text;
-       int id, newid, type, link, argc;
-       hw_connection *ptr;
-
-       argc = ZEND_NUM_ARGS();
-       if((argc < 3) || (argc > 4))
-               WRONG_PARAM_COUNT;
-
-       if (zend_get_parameters_array_ex(argc, argv) == FAILURE)
-               WRONG_PARAM_COUNT;
-
-       HW_FETCH_LINK(argv[0]);
-       convert_to_long_ex(argv[1]);
-       convert_to_string_ex(argv[2]);
-       if(argc == 4) {
-               convert_to_string_ex(argv[3]);
-               text = Z_STRVAL_PP(argv[3]);
-       } else {
-               text = NULL;
-       }
-       id = Z_LVAL_PP(argv[1]);
-
-       set_swap(ptr->swap_on);
-        objrec = Z_STRVAL_PP(argv[2]);
-       if (0 != (ptr->lasterror = send_insdoc(ptr->socket, id, objrec, text, &newid))) {
-               RETURN_FALSE;
-       }
-
-       RETURN_LONG(newid);
-}
-/* }}} */
-
-/* {{{ proto int hw_getsrcbydestobj(resource link, int destid)
-   Returns object id of source docuent by destination anchor */
-PHP_FUNCTION(hw_getsrcbydestobj)
-{
-       pval **arg1, **arg2;
-       int link, type, id;
-       int count;
-       char  **childObjRecs = NULL;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       id=Z_LVAL_PP(arg2);
-
-       set_swap(ptr->swap_on);
-       if (0 != (ptr->lasterror = send_getsrcbydest(ptr->socket, id, &childObjRecs, &count))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Command returned %d", ptr->lasterror);
-               RETURN_FALSE;
-       }
-
-       /* create return value and free all memory */
-       if( 0 > make_return_objrec(&return_value, childObjRecs, count))
-               RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto int hw_mapid(resource link, int serverid, int destid)
-   Returns virtual object id of document on remote Hyperwave server */
-PHP_FUNCTION(hw_mapid)
-{
-       pval **arg1, **arg2, **arg3;
-       int link, type, servid, id, virtid;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       convert_to_long_ex(arg3);
-       servid=Z_LVAL_PP(arg2);
-       id=Z_LVAL_PP(arg3);
-
-       set_swap(ptr->swap_on);
-       if (0 != (ptr->lasterror = send_mapid(ptr->socket, servid, id, &virtid))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Command returned %d", ptr->lasterror);
-               RETURN_FALSE;
-       }
-       RETURN_LONG(virtid);
-}
-/* }}} */
-
-/* {{{ proto string hw_getrellink(resource link, int rootid, int sourceid, int destid)
-   Get link from source to dest relative to rootid */
-PHP_FUNCTION(hw_getrellink)
-{
-       pval **arg1, **arg2, **arg3, **arg4;
-       int link, type;
-       int rootid, destid, sourceid;
-       char *anchorstr;
-       hw_connection *ptr;
-
-       if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       convert_to_long_ex(arg2);
-       convert_to_long_ex(arg3);
-       convert_to_long_ex(arg4);
-       rootid=Z_LVAL_PP(arg2);
-       sourceid=Z_LVAL_PP(arg3);
-       destid=Z_LVAL_PP(arg4);
-
-       set_swap(ptr->swap_on);
-       if (0 != (ptr->lasterror = getrellink(ptr->socket, rootid, sourceid, destid, &anchorstr))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Command returned %d", ptr->lasterror);
-               RETURN_FALSE;
-       }
-
-       RETURN_STRING(anchorstr, 0);
-}
-/* }}} */
-       
-/* {{{ proto bool hw_insertanchors(int hwdoc, array anchorecs, array dest [, array urlprefixes])
-   Inserts only anchors into text */
-PHP_FUNCTION(hw_insertanchors)
-{
-       pval **arg1, **arg2, **arg3, **arg4;
-       hw_document *hwdoc;
-       int type, docid, error, argc, count;
-       char **anchorrecs;
-       char **dest;
-       char **urlprefix;
-       char *bodytag = NULL;
-       HashTable *arrht;
-       HashTable *prefixarray;
-
-       argc = ZEND_NUM_ARGS();
-       switch(argc)
-       {
-       case 3:
-               if (zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE)
-                       WRONG_PARAM_COUNT;
-               break;
-       case 4:
-               if (zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE)
-                       WRONG_PARAM_COUNT;
-               break;
-       default:
-               WRONG_PARAM_COUNT;
-       }
-
-       convert_to_long_ex(arg1);
-       convert_to_array_ex(arg2);
-       convert_to_array_ex(arg3);
-       docid=Z_LVAL_PP(arg1);
-       hwdoc = zend_list_find(docid, &type);
-       if(!hwdoc || (type!=le_document)) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find file identifier %d", docid);
-               RETURN_FALSE;
-       }
-
-       /* check for the array with urlprefixes */
-       if(argc == 4) {
-               int i;
-               convert_to_array_ex(arg4);
-               prefixarray =Z_ARRVAL_PP(arg4);
-               if((prefixarray == NULL) || (zend_hash_num_elements(prefixarray) != 5)) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "You must provide 5 urlprefixes (you have provided %d)", zend_hash_num_elements(prefixarray));
-                       RETURN_FALSE;
-               }
-
-               urlprefix = emalloc(5*sizeof(char *));
-               zend_hash_internal_pointer_reset(prefixarray);
-               for(i=0; i<5; i++) {
-                       char *key;
-                       zval *data, **dataptr;
-                       ulong ind;
-                       
-                       zend_hash_get_current_key(prefixarray, &key, &ind, 0);
-                       zend_hash_get_current_data(prefixarray, (void *) &dataptr);
-                       data = *dataptr;
-                       if (Z_TYPE_P(data) != IS_STRING) {
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s must be a String", key);
-                               RETURN_FALSE;
-                       } else if ( strcmp(key, "HW_DEFAULT_LINK") == 0 ) {
-                               urlprefix[HW_DEFAULT_LINK] = Z_STRVAL_P(data);
-                       } else if ( strcmp(key, "HW_IMAGE_LINK") == 0 ) {
-                               urlprefix[HW_IMAGE_LINK] = Z_STRVAL_P(data);
-                       } else if ( strcmp(key, "HW_BACKGROUND_LINK") == 0 ) {
-                               urlprefix[HW_BACKGROUND_LINK] = Z_STRVAL_P(data);
-                       } else if ( strcmp(key, "HW_INTAG_LINK") == 0 ) {
-                               urlprefix[HW_INTAG_LINK] = Z_STRVAL_P(data);
-                       } else if ( strcmp(key, "HW_APPLET_LINK") == 0 ) {
-                               urlprefix[HW_APPLET_LINK] = Z_STRVAL_P(data);
-                       } else {
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s is not a valid urlprefix", key);
-                               RETURN_FALSE;
-                       }
-                       zend_hash_move_forward(prefixarray);
-               }
-       } else {
-               urlprefix = NULL;
-       }
-
-       if(zend_hash_num_elements(Z_ARRVAL_PP(arg2)) != zend_hash_num_elements(Z_ARRVAL_PP(arg3))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unequal number of elements in arrays");
-               RETURN_FALSE;
-       }
-
-       /* Turn PHP-Array of strings into C-Array of strings */
-       arrht = Z_ARRVAL_PP(arg2);
-       anchorrecs = make_strs_from_array(arrht);
-       arrht = Z_ARRVAL_PP(arg3);
-       dest = make_strs_from_array(arrht);
-
-       if (0 != (error = send_insertanchors(&(hwdoc->data), &count, anchorrecs, dest, zend_hash_num_elements(arrht), urlprefix, &bodytag))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Command returned %d", error);
-               RETURN_FALSE;
-       }
-/*fprintf(stderr, "in hw_insertanchors: %s\n", hwdoc->attributes); */
-       hwdoc->size = count;
-       if(hwdoc->bodytag) free (hwdoc->bodytag);
-       hwdoc->bodytag = bodytag;
-
-       RETURN_TRUE;
-}
-/* }}} */
-       
-
-PHP_MINFO_FUNCTION(hw)
-{
-       php_info_print_table_start();
-       php_info_print_table_row(2, "Hyperwave Support", "enabled");
-       php_info_print_table_row(2, "HG-CSP Version", "7.17");
-       php_info_print_table_end();
-       DISPLAY_INI_ENTRIES();
-}
-
-/* {{{ proto void hw_connection_info(resource link)
-   Prints information about the connection to Hyperwave server */
-PHP_FUNCTION(hw_connection_info)
-{
-       pval **arg1;
-       hw_connection *ptr;
-       int link, type;
-
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       HW_FETCH_LINK(arg1);
-       
-       php_printf("Hyperwave Info:\nhost=%s,\nserver string=%s\nversion=%d\nswap=%d\n", ptr->hostname, ptr->server_string, ptr->version, ptr->swap_on);
-}
-/* }}} */
-
-void print_msg(hg_msg *msg, char *str, int txt)
-{
-     char *ptr;
-     int  i;
-
-     fprintf(stdout, "\nprint_msg: >>%s<<\n", str);
-     fprintf(stdout, "print_msg: length  = %d\n", msg->length);
-     fprintf(stdout, "print_msg: msgid = %d\n", msg->version_msgid);
-     fprintf(stdout, "print_msg: msg_type  = %d\n", msg->msg_type);
-     if ( msg->length > HEADER_LENGTH )  {
-          ptr = msg->buf;
-          for ( i = 0; i < msg->length-HEADER_LENGTH; i++ )  {
-               if ( *ptr == '\n' )
-                    fprintf(stdout, "%c", *ptr++);
-               else if ( iscntrl(*ptr) )
-                    {fprintf(stdout, "."); ptr++;}
-               else
-                    fprintf(stdout, "%c", *ptr++);
-          }
-     }
-     fprintf(stdout, "\n\n");
-}
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/ext/hyperwave/hw_error.h b/ext/hyperwave/hw_error.h
deleted file mode 100644 (file)
index 6757cca..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
-   +----------------------------------------------------------------------+
-   | PHP Version 4                                                        |
-   +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2003 The PHP Group                                |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 3.0 of the PHP license,       |
-   | that is bundled with this package in the file LICENSE, and is        |
-   | available through the world-wide-web at the following url:           |
-   | http://www.php.net/license/3_0.txt.                                  |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@php.net so we can mail you a copy immediately.               |
-   +----------------------------------------------------------------------+
-   | Authors: Rasmus Lerdorf <rasmus@php.net>                             |
-   +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifndef HW_ERROR_H
-#define HW_ERROR_H
-
-#if HYPERWAVE
-
-#define NOACCESS 1 /* Access denied */
-#define NODOCS 2 /* No documents */
-#define NONAME 3 /* No collection name */
-#define NODOC 4 /* Object is not a document */
-#define NOOBJ 5 /* No object received */
-#define NOCOLLS 6 /* No collections received */
-#define DBSTUBNG 7 /* Connection to low-level database failed */
-#define NOTFOUND 8 /* Object not found */
-#define EXIST 9 /* Collection already exists */
-#define FATHERDEL 10 /* parent collection disappeared */
-#define FATHNOCOLL 11 /* parent collection not a collection */
-#define NOTEMPTY 12 /* Collection not empty */
-#define DESTNOCOLL 13 /* Destination not a collection */
-#define SRCEQDEST 14 /* Source equals destination */
-#define REQPEND 15 /* Request pending */
-#define TIMEOUT 16 /* Timeout */
-#define NAMENOTUNIQUE 17 /* Name not unique */
-#define WRITESTOPPED 18 /* Database now read-only; try again later */
-#define LOCKED 19 /* Object locked; try again later */
-#define CHANGEBASEFLD 20 /* Change of base-attribute */
-#define NOTREMOVED 21 /* Attribute not removed */
-#define FLDEXISTS 22 /* Attribute exists */
-#define CMDSYNTAX 23 /* Syntax error in command */
-#define NOLANGUAGE 24 /* No or unknown language specified */
-#define WRGTYPE 25 /* Wrong type in object */
-#define WRGVERSION 26 /* Client version too old */
-#define CONNECTION 27 /* No connection to other server */
-#define SYNC 28 /* Synchronization error */
-#define NOPATH 29 /* No path entry */
-#define WRGPATH 30 /* Wrong path entry */
-#define PASSWD 31 /* Wrong password (server-to-server server authentication) */
-#define LC_NO_MORE_USERS 32 /* No more users for license */
-#define LC_NO_MORE_DOCS 33 /* No more documents for this session and license */
-#define RSERV_NRESP 34 /* Remote server not responding */
-#define Q_OVERFLOW 35 /* Query overflow */
-#define USR_BREAK 36 /* Break by user */
-#define N_IMPL 37 /* Not implemented */
-#define WRG_VALUE 38 /* Wrong value */
-#define INSUFF_FUNDS 39 /* Insufficient funds */
-#define REORG 40 /* Reorganization in progress */
-#define USER_LIMIT 41 /* Limit of simultaneous users reached */
-#define FTCONNECT 513 /* No connection to fulltext server */
-#define FTTIMEOUT 514 /* Connection timed out */
-#define FTINDEX 515 /* Something wrong with fulltext index */
-#define FTSYNTAX 516 /* Query syntax error */
-#define REQUESTPENDING 1025 /* Request pending */
-#define NOCONNECTION 1026 /* No connection to document server */
-#define WRONGVERSION 1027 /* Wrong protocol version */
-#define NOTINITIALIZED 1028 /* Not initialized */
-#define BADREQUEST 1029 /* Bad request */
-#define BADLRN 1030 /* Bad document number */
-#define OPENSTORE_WRITE 1031 /* Cannot write to local store */
-#define OPENSTORE_READ 1032 /* Cannot read from local store */
-#define READSTORE 1033 /* Store read error */
-#define WRITESTORE 1034 /* Write error */
-#define CLOSESTORE 1035 /* Close error */
-#define BADPATH 1036 /* Bad path */
-#define NOPATHDC 1037 /* No path */
-#define OPENFILE 1038 /* Cannot open file */
-#define READFILE 1039 /* Cannot read from file // same */
-#define WRITEFILE 1040 /* Cannot write to file */
-#define CONNECTCLIENT 1041 /* Could not connect to client */
-#define ACCEPT 1042 /* Could not accept connection */
-#define READSOCKET 1043 /* Could not read from socket */
-#define WRITESOCKET 1044 /* Could not write to socket */
-#define TOOMUCHDATA 1046 /* Received too much data */
-#define TOOFEWDATA 1047 /* Received too few data // ... */
-#define NOTIMPLEMENTED 1049 /* Not implemented */
-#define USERBREAK 1050 /* User break  */
-#define INTERNAL 1051 /* Internal error */
-#define INVALIDOBJECT 1052 /* Invalid object */
-#define JOBTIMEOUT 1053 /* Job timed out */
-#define OPENPORT 1054 /* Cannot open port // ... for several resons */
-#define NODATA 1055 /* Received no data  */
-#define NOPORT 1056 /* No port to handle this request */
-#define NOTCACHED 1057 /* Document not cached */
-#define BADCACHETYPE 1058 /* Bad cache type  */
-#define OPENCACHE_WRITE 1059 /* Cannot write to cache */
-#define OPENCACHE_READ 1060 /* Cannot read from cache // same */
-#define NOSOURCE 1061 /* Do not know what to read */
-#define CLOSECACHE 1062 /* Could not insert into cache  */
-#define CONNECTREMOTE 1063 /* Could not connect to remote server */
-#define LOCKREFUSED 1064 /* Lock refused // could not lock the stores */
-
-#endif
-#endif
diff --git a/ext/hyperwave/hyperwave.dsp b/ext/hyperwave/hyperwave.dsp
deleted file mode 100644 (file)
index 1ca7e52..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-# Microsoft Developer Studio Project File - Name="hyperwave" - Package Owner=<4>\r
-# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
-# ** DO NOT EDIT **\r
-\r
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102\r
-\r
-CFG=hyperwave - Win32 Debug_TS\r
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
-!MESSAGE use the Export Makefile command and run\r
-!MESSAGE \r
-!MESSAGE NMAKE /f "hyperwave.mak".\r
-!MESSAGE \r
-!MESSAGE You can specify a configuration when running NMAKE\r
-!MESSAGE by defining the macro CFG on the command line. For example:\r
-!MESSAGE \r
-!MESSAGE NMAKE /f "hyperwave.mak" CFG="hyperwave - Win32 Debug_TS"\r
-!MESSAGE \r
-!MESSAGE Possible choices for configuration are:\r
-!MESSAGE \r
-!MESSAGE "hyperwave - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")\r
-!MESSAGE "hyperwave - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")\r
-!MESSAGE \r
-\r
-# Begin Project\r
-# PROP AllowPerConfigDependencies 0\r
-# PROP Scc_ProjName ""\r
-# PROP Scc_LocalPath ""\r
-CPP=cl.exe\r
-MTL=midl.exe\r
-RSC=rc.exe\r
-\r
-!IF  "$(CFG)" == "hyperwave - Win32 Release_TS"\r
-\r
-# PROP BASE Use_MFC 0\r
-# PROP BASE Use_Debug_Libraries 0\r
-# PROP BASE Output_Dir "Release_TS"\r
-# PROP BASE Intermediate_Dir "Release_TS"\r
-# PROP BASE Target_Dir ""\r
-# PROP Use_MFC 0\r
-# PROP Use_Debug_Libraries 0\r
-# PROP Output_Dir "Release_TS"\r
-# PROP Intermediate_Dir "Release_TS"\r
-# PROP Ignore_Export_Lib 0\r
-# PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HYPERWAVE_EXPORTS" /YX /FD /c\r
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "WIN32" /D "PHP_EXPORTS" /D "COMPILE_DL_HYPERWAVE" /D ZTS=1 /D HYPERWAVE=1 /D ZEND_DEBUG=0 /D "NDEBUG" /D "_WINDOWS" /D "ZEND_WIN32" /D "PHP_WIN32" /YX /FD /c\r
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
-# ADD BASE RSC /l 0x407 /d "NDEBUG"\r
-# ADD RSC /l 0x407 /d "NDEBUG"\r
-BSC32=bscmake.exe\r
-# ADD BASE BSC32 /nologo\r
-# ADD BSC32 /nologo\r
-LINK32=link.exe\r
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386\r
-# ADD LINK32 php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_hyperwave.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline"\r
-\r
-!ELSEIF  "$(CFG)" == "hyperwave - Win32 Debug_TS"\r
-\r
-# PROP BASE Use_MFC 0\r
-# PROP BASE Use_Debug_Libraries 1\r
-# PROP BASE Output_Dir "Debug_TS"\r
-# PROP BASE Intermediate_Dir "Debug_TS"\r
-# PROP BASE Ignore_Export_Lib 0\r
-# PROP BASE Target_Dir ""\r
-# PROP Use_MFC 0\r
-# PROP Use_Debug_Libraries 1\r
-# PROP Output_Dir "Debug_TS"\r
-# PROP Intermediate_Dir "Debug_TS"\r
-# PROP Ignore_Export_Lib 0\r
-# PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "HYPERWAVE_EXPORTS" /YX /FD /GZ /c\r
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "PHP_EXPORTS" /D "COMPILE_DL_HYPERWAVE" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HYPERWAVE=1 /YX /FD /GZ /c\r
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32\r
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32\r
-# ADD BASE RSC /l 0x407 /d "_DEBUG"\r
-# ADD RSC /l 0x407 /d "_DEBUG"\r
-BSC32=bscmake.exe\r
-# ADD BASE BSC32 /nologo\r
-# ADD BSC32 /nologo\r
-LINK32=link.exe\r
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept\r
-# ADD LINK32 php4ts_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /dll /debug /machine:I386 /out:"..\..\Debug_TS/php_hyperwave.dll" /pdbtype:sept /libpath:"..\..\Debug_TS"\r
-\r
-!ENDIF \r
-\r
-# Begin Target\r
-\r
-# Name "hyperwave - Win32 Release_TS"\r
-# Name "hyperwave - Win32 Debug_TS"\r
-# Begin Group "Source Files"\r
-\r
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
-# Begin Source File\r
-\r
-SOURCE=.\hg_comm.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\hw.c\r
-# End Source File\r
-# End Group\r
-# Begin Group "Header Files"\r
-\r
-# PROP Default_Filter "h;hpp;hxx;hm;inl"\r
-# Begin Source File\r
-\r
-SOURCE=.\hg_comm.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\hw_error.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\php_hyperwave.h\r
-# End Source File\r
-# End Group\r
-# End Target\r
-# End Project\r
diff --git a/ext/hyperwave/php_hyperwave.h b/ext/hyperwave/php_hyperwave.h
deleted file mode 100644 (file)
index 5116b4a..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-/* 
-   +----------------------------------------------------------------------+
-   | PHP Version 4                                                        |
-   +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2003 The PHP Group                                |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 3.0 of the PHP license,       |
-   | that is bundled with this package in the file LICENSE, and is        |
-   | available through the world-wide-web at the following url:           |
-   | http://www.php.net/license/3_0.txt.                                  |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@php.net so we can mail you a copy immediately.               |
-   +----------------------------------------------------------------------+
-   | Author: Rasmus Lerdorf <rasmus@php.net>                              |
-   +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifndef PHP_HYPERWAVE_H
-#define PHP_HYPERWAVE_H
-
-#ifdef PHP_WIN32
-#define PHP_HW_API __declspec(dllexport)
-#else
-#define PHP_HW_API
-#endif
-
-#if HYPERWAVE
-#ifndef DLEXPORT
-#define DLEXPORT
-#endif
-
-#ifdef ZTS
-#include "TSRM.h"
-#endif
-
-#include "hg_comm.h"
-
-extern zend_module_entry hw_module_entry;
-#define hw_module_ptr &hw_module_entry
-
-typedef struct {
-       long default_link;
-       long default_port;
-       long num_links,num_persistent;
-       long max_links,max_persistent;
-       long allow_persistent;
-} zend_hw_globals;
-
-#ifdef ZTS
-# define HwSG(v) TSRMG(hw_globals_id, zend_hw_globals *, v)
-#else
-# define HwSG(v) (hw_globals.v)
-extern PHP_HW_API zend_hw_globals hw_globals;
-#endif
-
-/*extern hw_module php_hw_module;*/
-
-typedef struct {
-        int size;
-        char *data;
-        char *attributes;
-        char *bodytag;
-} hw_document;
-
-PHP_MINIT_FUNCTION(hw);
-PHP_MSHUTDOWN_FUNCTION(hw);
-PHP_MINFO_FUNCTION(hw);
-
-PHP_FUNCTION(hw_connect);
-PHP_FUNCTION(hw_pconnect);
-PHP_FUNCTION(hw_close);
-PHP_FUNCTION(hw_root);
-PHP_FUNCTION(hw_info);
-PHP_FUNCTION(hw_error);
-PHP_FUNCTION(hw_errormsg);
-PHP_FUNCTION(hw_mv);
-PHP_FUNCTION(hw_cp);
-PHP_FUNCTION(hw_deleteobject);
-PHP_FUNCTION(hw_changeobject);
-PHP_FUNCTION(hw_modifyobject);
-PHP_FUNCTION(hw_getparents);
-PHP_FUNCTION(hw_getparentsobj);
-PHP_FUNCTION(hw_children);
-PHP_FUNCTION(hw_childrenobj);
-PHP_FUNCTION(hw_getchildcoll);
-PHP_FUNCTION(hw_getchildcollobj);
-PHP_FUNCTION(hw_getobject);
-PHP_FUNCTION(hw_getandlock);
-PHP_FUNCTION(hw_unlock);
-PHP_FUNCTION(hw_gettext);
-PHP_FUNCTION(hw_edittext);
-PHP_FUNCTION(hw_getcgi);
-PHP_FUNCTION(hw_getremote);
-PHP_FUNCTION(hw_getremotechildren);
-PHP_FUNCTION(hw_pipedocument);
-PHP_FUNCTION(hw_pipecgi);
-PHP_FUNCTION(hw_insertdocument);
-PHP_FUNCTION(hw_docbyanchorobj);
-PHP_FUNCTION(hw_docbyanchor);
-PHP_FUNCTION(hw_getobjectbyquery);
-PHP_FUNCTION(hw_getobjectbyqueryobj);
-PHP_FUNCTION(hw_getobjectbyquerycoll);
-PHP_FUNCTION(hw_getobjectbyquerycollobj);
-PHP_FUNCTION(hw_getobjectbyftquery);
-PHP_FUNCTION(hw_getobjectbyftqueryobj);
-PHP_FUNCTION(hw_getobjectbyftquerycoll);
-PHP_FUNCTION(hw_getobjectbyftquerycollobj);
-PHP_FUNCTION(hw_getchilddoccoll);
-PHP_FUNCTION(hw_getchilddoccollobj);
-PHP_FUNCTION(hw_getanchors);
-PHP_FUNCTION(hw_getanchorsobj);
-PHP_FUNCTION(hw_getusername);
-PHP_FUNCTION(hw_setlinkroot);
-PHP_FUNCTION(hw_inscoll);
-PHP_FUNCTION(hw_incollections);
-PHP_FUNCTION(hw_insertobject);
-PHP_FUNCTION(hw_insdoc);
-PHP_FUNCTION(hw_identify);
-PHP_FUNCTION(hw_free_document);
-PHP_FUNCTION(hw_new_document);
-PHP_FUNCTION(hw_new_document_from_file);
-PHP_FUNCTION(hw_output_document);
-PHP_FUNCTION(hw_document_size);
-PHP_FUNCTION(hw_document_attributes);
-PHP_FUNCTION(hw_document_bodytag);
-PHP_FUNCTION(hw_document_content);
-PHP_FUNCTION(hw_document_setcontent);
-PHP_FUNCTION(hw_objrec2array);
-PHP_FUNCTION(hw_array2objrec);
-PHP_FUNCTION(hw_connection_info);
-PHP_FUNCTION(hw_getsrcbydestobj);
-PHP_FUNCTION(hw_insertanchors);
-PHP_FUNCTION(hw_getrellink);
-PHP_FUNCTION(hw_dummy);
-PHP_FUNCTION(hw_who);
-PHP_FUNCTION(hw_stat);
-PHP_FUNCTION(hw_mapid);
-
-#else
-#define hw_module_ptr NULL
-#endif /* HYPERWAVE */
-#define phpext_hyperwave_ptr hw_module_ptr
-#endif /* PHP_HYPERWAVE_H */
-
diff --git a/ext/xslt/README.XSLT-BACKENDS b/ext/xslt/README.XSLT-BACKENDS
deleted file mode 100644 (file)
index b779c95..0000000
+++ /dev/null
@@ -1,285 +0,0 @@
-+------------------------------------------------------------------------------+
-| CREATING XSLT BACKENDS                                                       |
-+------------------------------------------------------------------------------+
-
- Author(s): Sterling Hughes <sterling@php.net>
-
- Introduction
- -------------------------------------------------------------------------------
-     Truth be told, at this point in time there are about a zillion and two 
- different XSLT libraries, each with their own unique merits and faults.  If you 
- provide a Sablotron extension, people will clamor for a Xalan extension, if you
- provide a Xalan extension people will clamor for a libxslt extension.
-     In order to be as user friendly as possible, we try and provide the most
- options to the user.  At the same time we must try to keep a level of 
- consistency, so the user does not need to remember 15 different syntaxes, etc.
- for each XSLT extension, and when switching from XSLT backends, no changes in 
- the PHP code should be necessary (akin to the concept of a database independent
- api, but with XSLT libraries).
-     At the same time, you'll also notice that in some cases extensions seem to
- duplicate each others functionality.  All extensions need code for calling
- user-defined handlers, omitting debug messages, etc.  In the interests of
- laziness, we must also try to make these as minimal as possible.
-    Therefore, I've created a processor independent api for XSLT, aka, the XSLT
- extension (but doesn't "A processor independent API for XSLT" sound cooler?).
- It defines a set of functions which every XSLT backend must provide, as well
- as a syntax which those functions must adhere to.  Furthermore, the underlying
- code, provides a "library" if  you will, of code that is relevant to all XSLT
- extensions.
- The API
- -------------------------------------------------------------------------------
- Every extension must define the following functions:
-       - xslt_create()
-       - xslt_set_scheme_handlers()
-       - xslt_set_sax_handlers()
-       - xslt_set_error_handler()
-       - xslt_set_log()
-       - xslt_set_object()
-       - xslt_process()
-       - xslt_error()
-       - xslt_errno()
-       - xslt_free()
- These functions are common or implementable with every single XSLT library that 
- I've come across so far (at least every C library) and should there for be 
- defined by the extension.
- resource xslt_create(void)
- The XSLT create function allocates a new XSLT processor and returns a resource
- pointer to the XSLT processor.  It also handles any initialization that the 
- processor requires.
- void xslt_set_scheme_handlers(resource processor, array handlers)
- Registers the scheme handlers for the document (aka XPath handlers), given a 
- XSLT processor resource (allocated by xslt_create()) and an array in the 
- following format:
-    array(
-          "get_all" => function,
-          "open"    => function,
-          "get"     => function,
-          "put"     => function,
-          "close"   => function
-       )
- Where function is either a function name or an array in the following format:
-    array(&$obj, "method")
-
- Note:  You do not need to handle the array(&$obj, "method") syntax by yourself
-        as this is handled in the call_xslt_function() library function (and
-        more specifically, Zend's call_user_function_ex() function. 
- Note:  The given array does not need to contain all of the different scheme
-        handler elements (although it can), but it only needs to conform to 
-               the "handler" => "function" format described above.
-
- Each of the individual scheme handler functions called are in the formats 
- below:
-     string   get_all(resource processor, string scheme, string rest)
-        resource open(resource processor, string scheme, string rest)
-        int      get(resource processor, resource fp, string &data)
-        int      put(resource processor, resource fp, string data)
-        void     close(resource processor, resource fp)
-
-
- void xslt_set_sax_handlers(resource processor, array handlers)
- Registers the SAX handlers for the document, given a XSLT processor resource
- (allocated by xslt_create()) and an array in the following format:
-     array(
-           "document" => array(document_start_function,
-                                   document_end_function),
-               "element"  => array(element_start_function,
-                                   element_end_function),
-               "namespace" => array(namespace_start_function,
-                                    namespace_end_function),
-        "comment"   => function,
-               "pi"        => function,
-               "character" => function
-     )
-
- Where the functions follow the syntax described for the scheme handler 
- functions.
- Each of the individual SAX handler functions are in the format below:
-     void start_doc(resource processor)
-        void end_doc(resource processor)
-        void start_element(resource processor, string name, array attributes)
-        void end_element(resource processor, string name)
-        void start_namespace(resource processor, string prefix, string uri)
-        void end_namespace(resource processor, string prefix)
-        void comment(resource processor, string contents)
-        void pi(resource processor, string target, string contents)
-        void characters(resource processor, string contents)
-
-
- void xslt_set_error_handler(resource processor, function error_handler)
- This function sets the user defined error handler to be called when a 
- processing or any other type of error occurs.  It is given a XSLT 
- processor resource (allocated by xslt_create()) and an error function of
- the same syntax described for the scheme handler function.
- The user defined error handler as the following syntax:
- void error(resource processor, int level, int error, array info)
- void xslt_set_log(resource processor, string logname)
- Sets the XSLT log to record log information (processor messages, not errors).
- Its given a XSLT processor (allocated by xslt_create()) and a string containing
- the name of the log file.  If the string is "php://stderr" then the logging 
- should go to standard error (stderr).  Also the default place to send log 
- messages is standard error (if no log file is set).
- mixed xslt_process(resource processor,
-                    string xml,
-                                       string xsl[,
-                                       string result[,
-                                       array  arguments[,
-                                       array  parameters]]])
-
- This function performs the magic, it takes the user's data, performs the 
- transformation and depending on the context either saves the result to a file
- or returns the data to the user.
- To understand the way the xslt_process() function works, you must first 
- understand the concept of "argument buffers".  Argument buffers are equivalent
- to the concept of symlinks on a Unix system, take the following example:
- <?php
- /**
-  * $xml contains the contents of an XML file and $xsl contains
-  * the contents of an XSLT stylesheet
-  */ 
- $args = array("/_xml" => $xml,
-               "/_xsl" => $xsl);
- $xh = xslt_create();
- $data = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args);
- xslt_free($xh);
- print( "The results of the transformation were\n" );
- print( "<br>\n<hr>\n<br>" );
- print( $data );
- print( "<br>\n<hr>\n<br>" );
- ?>
- See what was done?  The argument buffer was declared ($args) and the different
- arguments were defined.  Then when the xslt_process() function was called 
- instead of giving the XML filename and XSLT filename we instead gave 
- "arguments", which correspond to the XML and XSLT data in the argument buffers.
- This concept is a bit foreign to some people, however, I find it the best way
- to handle processing xsl data.  If you're still having trouble with this, try 
- playing around with the sablotron backend a bit, you should be able to catch on
- pretty quickly.
- In order to use argument buffers, the XSLT extension provides a couple of easy
- to use API functions, you can use them as follows:
- {
-     zval      **arguments_zp;
-        char      **arguments_cp;
-        xslt_args  *arguments;
-     char       *types[] = { "file", "data" };
-        
-        /* Fetch the arguments from the user into a zval ** */
-        
-        /* Translate the zval array into a character array */
-        xslt_make_array(&arguments_cp, arguments_zp);
-        
-        /* Translate the character array into an xslt_arg * structure */
-        arguments = xslt_parse_arguments(arguments_cp);
-        
-        /* Print out the resulting xslt_arg * structure */
-        php_printf("XML type: %s\n",    types[arguments->xml.type]);
-        php_printf("XML data: %s\n",    arguments->xml.ptr);
-        PUTS("\n");
-        php_printf("XSLT type: %s\n",   types[arguments->xsl.type]);
-        php_printf("XSLT data: %s\n",   arguments->xsl.ptr);
-        PUTS("\n");
-        php_printf("Result type: %s\n", types[arguments->result.type]);
-        php_printf("Result data: %s\n", arguments->result.ptr);
-        PUTS("\n");
- }
- You can also test the "type" field by using the XSLT_IS_FILE and XSLT_IS_DATA
- constants.
- Anyway back to the syntax of the xslt_process() function.  The first argument
- to the xslt_process() function is a resource pointer to the XSLT processor to
- be used.  The second argument is either an "argument buffer" pointing to the 
- XML data or the name of a file containing the XML data.  The third argument is
- either an argument buffer pointing to the XSLT data or a file containing the
- XSLT data.  The fourth argument is optional, it either contains the name of the
- file to place the results of the transformation into, NULL or "arg:/_result", 
- in the latter 2 cases, the results of the transformation will be returned.  The
- fifth optional argument is the "argument buffer" itself, it is an associative
- PHP array of "argument_name" => "value" pairs, or NULL, if no arguments are to
- be passed.  The final optional argument is a set of parameters to pass to the 
- XSLT stylesheet.  The parameter argument is an associative array of 
- "parameter_name" => "value" pairs.
- string xslt_error(resource processor)
- The xslt_error() function returns the last error that occured, given a XSLT
- processor resource (allocated by xslt_create()).
- int xslt_errno(resource processor)
- The xslt_errno() function returns the last error number that occured given a 
- XSLT processor resource (allocated by xslt_create()).
- void xslt_free(resource processor)
- The xslt_free() function free's the given XSLT processor resource (allocated
- by xslt_create()).
- Config.m4
- -------------------------------------------------------------------------------
- The XSLT extension's "magic" really occurs in the config.m4 file.  Here you 
- must add a couple of things in order for your backend to be enabled.  Its a bit
- too complex to describe (but easy to implement and understand).  Take a look at 
- config.m4 (which is well commented) to see what is necessary.
- Makefile.in
- -------------------------------------------------------------------------------
- Simply add the source files for your backend to the LTLIBRARY_SOURCES variable
- and you're all set with this file.
- Conclusion
- -------------------------------------------------------------------------------
- Nobody's perfect, I'm sure I've made some mistakes while thinking this whole 
- thing through and I would be glad to hear from any of you who think I'm a 
- colossal moron and think you have a better way to do it.  Please e-mail at 
- sterling@php.net, this extension will only get better with feedback.
- With that said, the concepts here may take a little bit of time to sink in, I 
- know I've written a whole lot.  My suggestion to you, if you're planning on 
- writing an XSLT backend is simply to go off and implement, taking the api 
- section as a guide and making sure you match that api as closely as possible.
diff --git a/ext/xslt/TODO b/ext/xslt/TODO
deleted file mode 100644 (file)
index cf85d7c..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-To Do List
-
-This informal list is the working list for the php sablotron extension.  It is
-maintained and used by the people on sab-php@gingerall.cz.  See 
-http://www.gingerall.org/charlie/ga/xml/m_ml.xml for more information.
-
-The numbering of the items on the list does not imply priority.  Rather it is
-simply a means for efficient communication on the mailing lists.
-
-$Id$
-
-Short Term
-==========
-1. Add streams support for file paths in 4th and 5th arg of xslt_process
-2. Use zend_parse_parameters and related API's
-3. SDOM_* stuff which does xpath queries.
-       - Melvyn
-
-
-Long Term
-=========
-1. Documentation of the wide variety of functions now available.
-       - Roy Huggins
-2. remove TSRMLS_FETCH() and expand user_data parameter to forward the
-actual tsrmls value.
-       - suggested by Marcus Boerger
-
-3. Evaluate OO functions, ZE2
-       - All
-4. Prolly an API rewrite, for php5
-       - All
diff --git a/ext/xslt/config.m4 b/ext/xslt/config.m4
deleted file mode 100644 (file)
index e29e244..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-dnl
-dnl $Id$
-dnl
-dnl +------------------------------------------------------------------------------+
-dnl |  This is where the magic of the extension reallly is.  Depending on what     |
-dnl |  backend the user chooses, this script performs the magic                    |
-dnl +------------------------------------------------------------------------------+
-
-PHP_ARG_ENABLE(xslt, whether to enable xslt support,
-[  --enable-xslt           Enable xslt support.])
-
-PHP_ARG_WITH(xslt-sablot, for XSLT Sablotron backend,
-[  --with-xslt-sablot=DIR    XSLT: Enable the sablotron backend.], no, no)
-
-PHP_ARG_WITH(expat-dir, for libexpat dir for Sablotron XSL support,
-[  --with-expat-dir=DIR      XSLT: libexpat dir for Sablotron.], no, no)
-
-PHP_ARG_WITH(iconv-dir, for iconv dir for Sablotron XSL support,
-[  --with-iconv-dir=DIR      XSLT: iconv dir for Sablotron.], no, no)
-
-PHP_ARG_WITH(sablot-js, for JavaScript for Sablotron XSL support,
-[  --with-sablot-js=DIR      XSLT: enable JavaScript support for Sablotron.], no, no)
-
-
-if test "$PHP_XSLT" != "no"; then
-
-  PHP_NEW_EXTENSION(xslt, xslt.c sablot.c, $ext_shared)
-  PHP_SUBST(XSLT_SHARED_LIBADD)
-
-  if test "$PHP_XSLT_SABLOT" != "no"; then
-    XSLT_CHECK_DIR=$PHP_XSLT_SABLOT
-    XSLT_TEST_FILE=/include/sablot.h
-    XSLT_BACKEND_NAME=Sablotron
-    XSLT_LIBNAME=sablot
-  fi
-
-  if test -z "$XSLT_BACKEND_NAME"; then
-    AC_MSG_ERROR([No backend specified for XSLT extension.])
-  fi
-
-  condition="$XSLT_CHECK_DIR$XSLT_TEST_FILE"
-
-  if test -r $condition; then
-    XSLT_DIR=$XSLT_CHECK_DIR
-  else
-    AC_MSG_CHECKING(for $XSLT_BACKEND_NAME libraries in the default path)
-    for i in /usr /usr/local; do
-      condition="$i$XSLT_TEST_FILE"
-      if test -r $condition; then
-        XSLT_DIR=$i
-      fi
-    done
-    AC_MSG_RESULT(found in $XSLT_DIR)
-  fi
-
-  if test -z "$XSLT_DIR"; then
-    AC_MSG_ERROR([not found. Please re-install the $XSLT_BACKEND_NAME distribution.])
-  fi
-                                       
-  if test "$PHP_XSLT_SABLOT" != "no"; then
-    AC_MSG_CHECKING([for sablot-config])
-    if test -x $XSLT_DIR/bin/sablot-config ; then
-       AC_MSG_RESULT(found)
-       AC_DEFINE(HAVE_SABLOT_CONFIG, 1, [Whether the Sablotron config file is found])
-       dnl Use this script to register this information in phpinfo()
-       SABINF_CFLAGS=`$XSLT_DIR/bin/sablot-config --cflags`
-       SABINF_LIBS=`$XSLT_DIR/bin/sablot-config --libs`
-       SABINF_PREFIX=`$XSLT_DIR/bin/sablot-config --prefix`
-       SABINF_ALL="\"Cflags: $SABINF_CFLAGS\nLibs: $SABINF_LIBS\nPrefix: $SABINF_PREFIX\""
-       PHP_DEFINE(SAB_INFO, "$SABINF_ALL")
-    else
-       AC_MSG_RESULT(not found)
-    fi
-    AC_MSG_CHECKING([for Sablotron version])
-    old_CPPFLAGS=$CPPFLAGS
-    CPPFLAGS="$CPPFLAGS -I$XSLT_DIR/include"
-    AC_TRY_RUN([
-#include <stdlib.h>
-#include <sablot.h>
-
-int main ()
-{
-       double version;
-       version = atof(SAB_VERSION);
-       
-       if (version >= 0.96) {
-               exit(0);
-       }
-       exit(255);
-}
-    ],[
-      AC_MSG_RESULT([>= 0.96])
-    ],[
-      AC_MSG_ERROR([Sablotron version 0.96 or greater required.])
-    ])
-    CPPFLAGS=$old_CPPFLAGS
-
-    found_expat=no
-    for i in $PHP_EXPAT_DIR $XSLT_DIR /usr/local /usr; do
-      if test -f $i/lib/libexpat.a -o -f $i/lib/libexpat.$SHLIB_SUFFIX_NAME; then
-        AC_DEFINE(HAVE_LIBEXPAT2, 1, [ ])
-        PHP_ADD_INCLUDE($i/include)
-        PHP_ADD_LIBRARY_WITH_PATH(expat, $i/lib, XSLT_SHARED_LIBADD)
-        found_expat=yes
-        break
-      fi
-    done
-
-    if test "$found_expat" = "no"; then
-      AC_MSG_ERROR([expat not found. To build sablotron you need the expat library.])
-    fi
-
-    if test "$PHP_ICONV_DIR" != "no"; then
-      PHP_ICONV=$PHP_ICONV_DIR
-    fi
-
-    if test "$PHP_ICONV" = "no"; then
-      PHP_ICONV=yes
-    fi
-
-    PHP_SETUP_ICONV(XSLT_SHARED_LIBADD, [], [
-      AC_MSG_ERROR([iconv not found. To build sablotron you need the iconv library.])
-    ])
-     
-    if test "$PHP_SABLOT_JS" != "no"; then
-      for i in /usr/local /usr $PHP_SABLOT_JS; do
-        if test -f $i/lib/libjs.a -o -f $i/lib/libjs.$SHLIB_SUFFIX_NAME; then
-          PHP_SABLOT_JS_DIR=$i
-        fi
-      done
-
-      PHP_CHECK_LIBRARY(js, JS_GetRuntime,
-      [
-        PHP_ADD_LIBRARY_WITH_PATH(js, $PHP_SABLOT_JS_DIR/lib, XSLT_SHARED_LIBADD)
-      ], [
-        AC_MSG_ERROR([libjs not found. Please check config.log for more information.])
-      ], [
-        -L$PHP_SABLOT_JS_DIR/lib
-      ])
-    fi
-
-    PHP_CHECK_LIBRARY(sablot, SablotSetEncoding,
-    [
-      AC_DEFINE(HAVE_SABLOT_SET_ENCODING, 1, [ ])
-    ], [], [
-      -L$XSLT_DIR/lib
-    ])
-
-    dnl SablotSetOptions implemented in Sablotron CVS > 2002/10/31
-    PHP_CHECK_LIBRARY(sablot, SablotGetOptions,
-    [
-      AC_DEFINE(HAVE_SABLOT_GET_OPTIONS, 1, [Whether Sablotron supports SablotGetOptions])
-    ], [], [
-      -L$XSLT_DIR/lib
-    ])
-
-    AC_DEFINE(HAVE_SABLOT_BACKEND, 1, [ ])
-  fi
-
-  PHP_ADD_INCLUDE($XSLT_DIR/include)
-  PHP_ADD_LIBRARY_WITH_PATH($XSLT_LIBNAME, $XSLT_DIR/lib, XSLT_SHARED_LIBADD)
-
-  AC_DEFINE(HAVE_XSLT, 1, [ ])
-fi
diff --git a/ext/xslt/php_sablot.h b/ext/xslt/php_sablot.h
deleted file mode 100644 (file)
index 64b5f88..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
-   +----------------------------------------------------------------------+
-   | PHP Version 4                                                        |
-   +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2003 The PHP Group                                |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 3.0 of the PHP license,       |
-   | that is bundled with this package in the file LICENSE, and is        |
-   | available through the world-wide-web at the following url:           |
-   | http://www.php.net/license/3_0.txt.                                  |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@php.net so we can mail you a copy immediately.               |
-   +----------------------------------------------------------------------+
-   | Author: Sterling Hughes <sterling@php.net>                           |
-   +----------------------------------------------------------------------+
- */
-
-#ifndef PHP_XSLT_H
-#define PHP_XSLT_H
-
-#include "php.h"
-
-#if HAVE_SABLOT_BACKEND
-
-#include "php_xslt.h"
-
-#include <sablot.h>
-
-extern zend_module_entry xslt_module_entry;
-#define phpext_xslt_ptr &xslt_module_entry
-
-#ifdef PHP_WIN32
-#define PHP_XSLT_API __declspec(dllexport)
-#else
-#define PHP_XSLT_API
-#endif
-
-#define XSLT_SCHEME(handle)    ((handle)->handlers->scheme)
-#define XSLT_SAX(handle)       ((handle)->handlers->sax)
-#define XSLT_ERROR(handle)     ((handle)->handlers->error)
-
-#define XSLT_PROCESSOR(handle) ((handle)->processor.ptr)
-#define XSLT_SITUATION(handle)  ((handle)->processor.sit)
-
-#define XSLT_ERRNO(handle)     ((handle)->err->no)
-#define XSLT_ERRSTR(handle)    ((handle)->err->str)
-#define XSLT_LOG(handle)       ((handle)->err->log)
-#define XSLT_BASE_ISSET(handle) ((handle)->base_isset)
-
-#define XSLT_FUNCH_FREE(__var) if (__var) zval_ptr_dtor(&(__var)); 
-#define XSLT_REG_ERRMSG(msg, handle)   if (XSLT_ERRSTR(handle)) efree(XSLT_ERRSTR(handle)); \
-                                       XSLT_ERRSTR(handle) = estrdup(msg);
-#define XSLT_NO_INFO   "No information available."
-
-PHP_MINIT_FUNCTION(xslt);
-PHP_MINFO_FUNCTION(xslt);
-
-PHP_FUNCTION(xslt_create);
-PHP_FUNCTION(xslt_set_sax_handlers);
-PHP_FUNCTION(xslt_set_scheme_handlers);
-PHP_FUNCTION(xslt_set_error_handler);
-PHP_FUNCTION(xslt_set_base);
-PHP_FUNCTION(xslt_set_encoding);
-PHP_FUNCTION(xslt_set_log);
-PHP_FUNCTION(xslt_process);
-PHP_FUNCTION(xslt_error);
-PHP_FUNCTION(xslt_errno);
-PHP_FUNCTION(xslt_free);
-PHP_FUNCTION(xslt_set_object);
-PHP_FUNCTION(xslt_setopt);
-#ifdef HAVE_SABLOT_GET_OPTIONS
-PHP_FUNCTION(xslt_getopt);
-#endif
-PHP_FUNCTION(xslt_backend_version);
-PHP_FUNCTION(xslt_backend_name);
-PHP_FUNCTION(xslt_backend_info);
-
-struct scheme_handlers {
-       zval *sh_get_all;
-       zval *sh_open;
-       zval *sh_get;
-       zval *sh_put;
-       zval *sh_close;
-};
-
-struct sax_handlers {
-       zval *doc_start;
-       zval *element_start;
-       zval *element_end;
-       zval *namespace_start;
-       zval *namespace_end;
-       zval *comment;
-       zval *pi;
-       zval *characters;
-       zval *doc_end;
-};
-
-struct xslt_handlers {
-       struct scheme_handlers   scheme;
-       struct sax_handlers      sax;
-       zval                    *error;
-};
-
-struct xslt_processor {
-       SablotHandle ptr;
-       SablotSituation sit;
-       long         idx;
-};
-
-struct xslt_log {
-       char *path;
-       int   fd;
-       int   do_log;
-};
-
-struct xslt_error {
-       struct xslt_log  log;
-       char            *str;
-       int              no;
-};
-
-typedef struct {
-       struct xslt_handlers  *handlers;
-       struct xslt_processor  processor;
-       struct xslt_error     *err;
-       zval                  *object;
-       unsigned short         base_isset;
-} php_xslt;
-
-#else
-#define phpext_xslt_ptr NULL
-#endif
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/ext/xslt/php_xslt.h b/ext/xslt/php_xslt.h
deleted file mode 100644 (file)
index d5369b3..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-   +----------------------------------------------------------------------+
-   | PHP Version 4                                                        |
-   +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2003 The PHP Group                                |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 3.0 of the PHP license,       |
-   | that is bundled with this package in the file LICENSE, and is        |
-   | available through the world-wide-web at the following url:           |
-   | http://www.php.net/license/3_0.txt.                                  |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@php.net so we can mail you a copy immediately.               |
-   +----------------------------------------------------------------------+
-   | Author: Sterling Hughes <sterling@php.net>                           |
-   +----------------------------------------------------------------------+
- */
-
-#ifndef _PHP_XSLT_H
-#define _PHP_XSLT_H
-
-#include "php.h"
-#include "ext/standard/php_filestat.h"
-
-#ifdef HAVE_XSLT
-
-#define XSLT_OBJ(__func)       (&(__func)->obj)
-#define XSLT_FUNC(__func)      ((__func)->func)
-
-#define XSLT_IS_FILE 0
-#define XSLT_IS_DATA 1
-
-struct xslt_function {
-       zval *obj;
-       zval *func;
-};
-
-struct _xslt_argument {
-       char *ptr;
-       int type;
-};
-
-typedef struct {
-       struct _xslt_argument xml;
-       struct _xslt_argument xsl;
-       struct _xslt_argument result;
-} xslt_args;
-
-extern xslt_args *xslt_parse_arguments(char *, char *, char *, char **);
-extern void xslt_free_arguments(xslt_args *);
-
-extern void xslt_assign_handler(struct xslt_function **, zval **);
-extern void xslt_free_handler(struct xslt_function *);
-extern void xslt_call_function(char *, zval *, zval *, int, zval **, zval **);
-
-extern void xslt_debug(char *, char *, ...);
-
-extern void xslt_make_array(zval **zarr, char ***carr);
-extern void xslt_free_array(char **arr);
-
-#endif
-
-#endif
diff --git a/ext/xslt/sablot.c b/ext/xslt/sablot.c
deleted file mode 100644 (file)
index a55d2c4..0000000
+++ /dev/null
@@ -1,1821 +0,0 @@
-/*
-   +----------------------------------------------------------------------+
-   | PHP Version 4                                                        |
-   +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2003 The PHP Group                                |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 3.0 of the PHP license,       |
-   | that is bundled with this package in the file LICENSE, and is        |
-   | available through the world-wide-web at the following url:           |
-   | http://www.php.net/license/3_0.txt.                                  |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@php.net so we can mail you a copy immediately.               |
-   +----------------------------------------------------------------------+
-   | Authors: Sterling Hughes <sterling@php.net>                          |
-   |          David Viner <dviner@php.net>                                |
-   |          Lenar Lohmus <flex@php.net>                                 |
-   |          Melvyn Sopacua <msopacua@php.net>                           |
-   +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "php.h"
-#include "php_xslt.h"
-#include "php_sablot.h"
-#include "ext/standard/info.h"
-
-#if HAVE_SABLOT_BACKEND
-
-#ifdef HAVE_SABLOT_CONFIG
-#include "php_sab_info.h"
-#endif
-#include <sablot.h>
-
-#include <string.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-/* functions relating to handlers */
-static void register_sax_handler_pair(zval **, zval **, zval ** TSRMLS_DC);
-
-/* Free processor */
-static void free_processor(zend_rsrc_list_entry *rsrc TSRMLS_DC);
-
-/* Scheme handler functions */
-static int  scheme_getall(void *, SablotHandle, const char *, const char *, char **, int *);
-static int  scheme_freememory(void *, SablotHandle, char *);
-static int  scheme_open(void *, SablotHandle, const char *, const char *, int *);
-static int  scheme_get(void *, SablotHandle, int, char *, int *);
-static int  scheme_put(void *, SablotHandle, int, const char *, int *);
-static int  scheme_close(void *, SablotHandle, int);
-
-/* Sax handler functions */
-static SAX_RETURN sax_startdoc(void *, SablotHandle);
-static SAX_RETURN sax_startelement(void *, SablotHandle, const char *, const char **);
-static SAX_RETURN sax_endelement(void *, SablotHandle, const char *);
-static SAX_RETURN sax_startnamespace(void *, SablotHandle, const char *, const char *);
-static SAX_RETURN sax_endnamespace(void *, SablotHandle, const char *);
-static SAX_RETURN sax_comment(void *, SablotHandle, const char *);
-static SAX_RETURN sax_pi(void *, SablotHandle, const char *, const char *);
-static SAX_RETURN sax_characters(void *, SablotHandle, const char *, int);
-static SAX_RETURN sax_enddoc(void *, SablotHandle);
-
-/* Error handlers */
-static MH_ERROR error_makecode(void *, SablotHandle, int, unsigned short, unsigned short);
-static MH_ERROR error_log(void *, SablotHandle, MH_ERROR, MH_LEVEL, char **);
-static MH_ERROR error_print(void *, SablotHandle, MH_ERROR, MH_LEVEL, char **);
-
-/* Resource related */
-#define le_xslt_name "XSLT Processor"
-static int  le_xslt;
-
-/* {{{ xslt_functions[]
- */
-static unsigned char second_args_force_ref[] = { 2, BYREF_NONE, BYREF_FORCE };
-
-function_entry xslt_functions[] = {
-       PHP_FE(xslt_create,              NULL)
-       PHP_FE(xslt_set_sax_handlers,    NULL)
-       PHP_FE(xslt_set_scheme_handlers, NULL)
-       PHP_FE(xslt_set_error_handler,   NULL)
-       PHP_FE(xslt_set_base,            NULL)
-#ifdef HAVE_SABLOT_SET_ENCODING
-       PHP_FE(xslt_set_encoding,        NULL)
-#endif
-       PHP_FE(xslt_set_log,             NULL)
-       PHP_FE(xslt_process,             NULL)
-       PHP_FE(xslt_error,               NULL)
-       PHP_FE(xslt_errno,               NULL)
-       PHP_FE(xslt_free,                NULL)
-       PHP_FE(xslt_set_object,          second_args_force_ref)
-       PHP_FE(xslt_setopt,              NULL)
-#ifdef HAVE_SABLOT_GET_OPTIONS
-       PHP_FE(xslt_getopt,              NULL)
-#endif
-       PHP_FE(xslt_backend_version,     NULL)
-       PHP_FE(xslt_backend_name,        NULL)
-    PHP_FE(xslt_backend_info,        NULL)
-       {NULL, NULL, NULL}
-};
-/* }}} */
-
-/* {{{ xslt_module_entry
- */
-zend_module_entry xslt_module_entry = {
-       STANDARD_MODULE_HEADER,
-       "xslt",
-       xslt_functions,
-       PHP_MINIT(xslt),
-       NULL,
-       NULL,   
-       NULL,
-       PHP_MINFO(xslt),
-    NO_VERSION_YET,
-       STANDARD_MODULE_PROPERTIES
-};
-/* }}} */
-
-#ifdef COMPILE_DL_XSLT
-ZEND_GET_MODULE(xslt)
-#endif
-
-/* {{{ handler structs
-   A structure containing the sax handlers, automatically 
-   registered whether the user defines them or not */
-static SAXHandler sax_handlers = 
-{
-       sax_startdoc,
-       sax_startelement,
-       sax_endelement,
-       sax_startnamespace,
-       sax_endnamespace,
-       sax_comment,
-       sax_pi,
-       sax_characters,
-       sax_enddoc
-};
-
-/* Error handlers, automatically registered */
-static MessageHandler message_handler = {
-       error_makecode,
-       error_log,
-       error_print
-};
-
-/* Scheme handlers automatically registered */
-static SchemeHandler scheme_handler = {
-       scheme_getall,
-       scheme_freememory,
-       scheme_open,
-       scheme_get,
-       scheme_put,
-       scheme_close
-};
-/* }}} */
-
-/* {{{ PHP_MINIT_FUNCTION
- */
-PHP_MINIT_FUNCTION(xslt)
-{
-       le_xslt = zend_register_list_destructors_ex(free_processor, NULL, le_xslt_name, module_number);
-
-       /* Generic options, which can apply to 'all' xslt processors */
-       REGISTER_LONG_CONSTANT("XSLT_OPT_SILENT", SAB_NO_ERROR_REPORTING, CONST_CS | CONST_PERSISTENT);
-
-       /* Error constants, which are useful in userspace. */
-       REGISTER_LONG_CONSTANT("XSLT_ERR_UNSUPPORTED_SCHEME", SH_ERR_UNSUPPORTED_SCHEME, CONST_CS | CONST_PERSISTENT);
-       /* Sablotron specific options */
-       REGISTER_LONG_CONSTANT("XSLT_SABOPT_PARSE_PUBLIC_ENTITIES", SAB_PARSE_PUBLIC_ENTITIES, CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XSLT_SABOPT_DISABLE_ADDING_META", SAB_DISABLE_ADDING_META, CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XSLT_SABOPT_DISABLE_STRIPPING", SAB_DISABLE_STRIPPING, CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("XSLT_SABOPT_IGNORE_DOC_NOT_FOUND", SAB_IGNORE_DOC_NOT_FOUND, CONST_CS | CONST_PERSISTENT);
-/* hack: implemented at the same time, so should work.
-   Otherwise we need to check the enum type of SablotFlag in <sablot.h> */
-#ifdef HAVE_SABLOT_GET_OPTIONS
-       REGISTER_LONG_CONSTANT("XSLT_SABOPT_FILES_TO_HANDLER", SAB_FILES_TO_HANDLER, CONST_CS | CONST_PERSISTENT);
-#endif
-
-       return SUCCESS;
-}
-/* }}} */
-
-/* {{{ PHP_MINFO_FUNCTION
- */
-PHP_MINFO_FUNCTION(xslt)
-{
-       php_info_print_table_start();
-       php_info_print_table_row(2, "XSLT support", "enabled");
-       php_info_print_table_row(2, "Backend", "Sablotron");
-#ifdef SAB_VERSION
-       php_info_print_table_row(2, "Sablotron Version", SAB_VERSION);
-#endif
-#ifdef HAVE_SABLOT_CONFIG
-       php_info_print_table_row(2, "Sablotron Information", SAB_INFO);
-#endif
-       php_info_print_table_end();
-}
-/* }}} */
-
-/* {{{ proto resource xslt_create(void) 
-   Create a new XSLT processor */
-PHP_FUNCTION(xslt_create)
-{
-       php_xslt     *handle;      /* The php -> sablotron handle */
-       SablotHandle  processor;   /* The sablotron processor */
-       SablotSituation  sit;        /* The sablotron Situation handle */
-       int           error;       /* The error container */
-
-       /* Allocate the php-sablotron handle */
-       handle                   = ecalloc(1, sizeof(php_xslt));
-       handle->handlers         = ecalloc(1, sizeof(struct xslt_handlers));
-       handle->err              = ecalloc(1, sizeof(struct xslt_error));
-       handle->object           = NULL;
-       handle->base_isset       = 0;
-
-       XSLT_LOG(handle).path = NULL;
-
-       /* Allocate the actual processor itself, via sablotron */
-       SablotCreateSituation(&sit);
-       error = SablotCreateProcessorForSituation(sit, &processor);
-       if (error) {
-               XSLT_ERRNO(handle) = error;
-               RETURN_FALSE;
-       }
-
-       /* Save the processor and set the default handlers */
-       XSLT_PROCESSOR(handle) = processor;
-       XSLT_SITUATION(handle) = sit;
-       SablotRegHandler(XSLT_PROCESSOR(handle), HLR_SAX,     (void *) &sax_handlers,    (void *) handle);
-       SablotRegHandler(XSLT_PROCESSOR(handle), HLR_MESSAGE, (void *) &message_handler, (void *) handle);
-       SablotRegHandler(XSLT_PROCESSOR(handle), HLR_SCHEME,  (void *) &scheme_handler,  (void *) handle);
-
-       /* Register the processor as a resource and return it to the user */
-       ZEND_REGISTER_RESOURCE(return_value, handle, le_xslt);
-       
-       /* The resource index, save it for later use */
-       handle->processor.idx = Z_LVAL_P(return_value);
-}
-/* }}} */
-
-/* {{{ proto void xslt_set_sax_handlers(resource processor, array handlers)
-   Set the SAX handlers to be called when the XML document gets processed */
-PHP_FUNCTION(xslt_set_sax_handlers)
-{
-       zval       **processor_p,      /* Resource pointer to the php->sablotron handle */
-                  **sax_handlers_p,   /* Pointer to the sax handlers php array */
-                  **handler;          /* Individual handler, or handler pair */
-       HashTable   *sax_handlers;     /* PHP array of sax handlers */
-       php_xslt    *handle;           /* Pointer to a php_xslt handle */
-       char        *string_key;       /* String key for the hash */
-       ulong        num_key;          /* (unused) hash's numerical key */
-       int          key_type;         /* The type of the current hash key */
-
-       if (ZEND_NUM_ARGS() != 2 ||
-           zend_get_parameters_ex(2, &processor_p, &sax_handlers_p) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt);
-       
-       /* Convert the sax_handlers_p zval ** to a hash table we can process */
-       sax_handlers = HASH_OF(*sax_handlers_p);
-       if (!sax_handlers) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expecting an array as the second argument");
-               return;
-       }
-
-       /* Loop through the HashTable containing the SAX handlers */
-       for (zend_hash_internal_pointer_reset(sax_handlers);
-            zend_hash_get_current_data(sax_handlers, (void **) &handler) == SUCCESS;
-                zend_hash_move_forward(sax_handlers)) {
-
-               key_type = zend_hash_get_current_key(sax_handlers, &string_key, &num_key, 0);
-               if (key_type == HASH_KEY_IS_LONG) {
-                       convert_to_string_ex(handler);
-                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Skipping numerical index %d (with value %s)",
-                                 num_key, Z_STRVAL_PP(handler));
-                       continue;
-               }
-
-               /* Document handlers (document start, document end) */
-               if (strcasecmp(string_key, "document") == 0) {
-                       SEPARATE_ZVAL(handler);
-                       register_sax_handler_pair(&XSLT_SAX(handle).doc_start, 
-                                                 &XSLT_SAX(handle).doc_end, 
-                                                 handler TSRMLS_CC);
-               }
-               /* Element handlers, start of an element, and end of an element */
-               else if (strcasecmp(string_key, "element") == 0) {
-                       SEPARATE_ZVAL(handler);
-                       register_sax_handler_pair(&XSLT_SAX(handle).element_start, 
-                                                 &XSLT_SAX(handle).element_end, 
-                                                 handler TSRMLS_CC);
-               }
-               /* Namespace handlers, start of a namespace, end of a namespace */
-               else if (strcasecmp(string_key, "namespace") == 0) {
-                       SEPARATE_ZVAL(handler);
-                       register_sax_handler_pair(&XSLT_SAX(handle).namespace_start, 
-                                                 &XSLT_SAX(handle).namespace_end, 
-                                                 handler TSRMLS_CC);
-               }
-               /* Comment handlers, called when a comment is reached */
-               else if (strcasecmp(string_key, "comment") == 0) {
-                       XSLT_SAX(handle).comment = *handler;
-                       zval_add_ref(&XSLT_SAX(handle).comment);
-               }
-               /* Processing instructions handler called when processing instructions
-                  (<? ?>) */
-               else if (strcasecmp(string_key, "pi") == 0) {
-                       XSLT_SAX(handle).pi = *handler;
-                       zval_add_ref(&XSLT_SAX(handle).pi);
-               }
-               /* Character handler, called when data is found */
-               else if (strcasecmp(string_key, "character") == 0) {
-                       XSLT_SAX(handle).characters = *handler;
-                       zval_add_ref(&XSLT_SAX(handle).characters);
-               }
-               /* Invalid handler name, tsk, tsk, tsk :) */
-               else {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid option: %s", string_key);
-               }
-       }
-}
-/* }}} */
-
-/* {{{ proto void xslt_set_scheme_handlers(resource processor, array handlers)
-   Set the scheme handlers for the XSLT processor */
-PHP_FUNCTION(xslt_set_scheme_handlers)
-{
-       zval                   **processor_p,       /* Resource pointer to the php->sablotron handle */
-                              **scheme_handlers_p, /* Pointer to the scheme handler array */
-                              **handler;           /* Individual scheme handler */
-       zval                   **assign_handle;     /* The handler to assign to */
-       HashTable               *scheme_handlers;   /* Scheme handler array */
-       php_xslt                *handle;            /* php->sablotron handle */
-       char                    *string_key;        /* Hash key (string) */
-       ulong                    num_key;           /* (unused) Hash key (number) */
-       int                      key_type;          /* The type of the current key */
-
-       if (ZEND_NUM_ARGS() != 2 ||
-           zend_get_parameters_ex(2, &processor_p, &scheme_handlers_p) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt);
-
-       scheme_handlers = HASH_OF(*scheme_handlers_p);
-       if (!scheme_handlers) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "2nd argument must be an array");
-               return;
-       }
-
-       /* Loop through the scheme handlers array, setting the given
-          scheme handlers */
-       for (zend_hash_internal_pointer_reset(scheme_handlers);
-            zend_hash_get_current_data(scheme_handlers, (void **) &handler) == SUCCESS;
-            zend_hash_move_forward(scheme_handlers)) {
-
-               key_type = zend_hash_get_current_key(scheme_handlers, &string_key, &num_key, 0);
-               if (key_type == HASH_KEY_IS_LONG) {
-                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Numerical key %d (with value %s) being ignored",
-                                         num_key, Z_STRVAL_PP(handler));
-                       continue;
-               }
-
-               /* Open the URI and return the whole string */
-               if (strcasecmp(string_key, "get_all") == 0) {
-                       assign_handle = &XSLT_SCHEME(handle).sh_get_all;
-               }
-               /* Open the URI and return a handle */
-               else if (strcasecmp(string_key, "open") == 0) {
-                       assign_handle = &XSLT_SCHEME(handle).sh_open;
-               }
-               /* Retrieve data from the URI */
-               else if (strcasecmp(string_key, "get") == 0) {
-                       assign_handle = &XSLT_SCHEME(handle).sh_get;
-               }
-               /* Save data to the URI */
-               else if (strcasecmp(string_key, "put") == 0) {
-                       assign_handle = &XSLT_SCHEME(handle).sh_put;
-               }
-               /* Close the URI */
-               else if (strcasecmp(string_key, "close") == 0) {
-                       assign_handle = &XSLT_SCHEME(handle).sh_close;
-               }
-               /* Invalid handler name */
-               else {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid option '%s', skipping", string_key);
-                       continue;
-               }
-
-               *assign_handle = *handler;
-               zval_add_ref(assign_handle);
-       }
-}
-/* }}} */
-
-/* {{{ proto void xslt_set_error_handler(resource processor, mixed error_func)
-   Set the error handler, to be called when an XSLT error happens */
-PHP_FUNCTION(xslt_set_error_handler)
-{
-       zval      **processor_p,   /* Resource Pointer to a PHP-XSLT processor */
-                 **error_func;    /* Name of the user defined error function */
-       php_xslt   *handle;        /* A PHP-XSLT processor */
-       
-       if (ZEND_NUM_ARGS() != 2 ||
-           zend_get_parameters_ex(2, &processor_p, &error_func) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt);
-
-       XSLT_ERROR(handle) = *error_func;
-       zval_add_ref(&XSLT_ERROR(handle));
-}
-/* }}} */
-
-/* {{{ proto void xslt_set_base(resource processor, string base)
-   Sets the base URI for all XSLT transformations */
-PHP_FUNCTION(xslt_set_base)
-{
-       zval     **processor_p,  /* Resource Pointer to a PHP-XSLT processor */
-                **base;         /* The base URI for the transformation */
-       php_xslt  *handle;       /* A PHP-XSLT processor */
-
-       if (ZEND_NUM_ARGS() != 2 ||
-           zend_get_parameters_ex(2, &processor_p, &base) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt);
-       convert_to_string_ex(base);
-
-       /* Set the base */
-       SablotSetBase(XSLT_PROCESSOR(handle), Z_STRVAL_PP(base));
-       XSLT_BASE_ISSET(handle) = 1;
-}
-/* }}} */
-
-/* {{{ proto void xslt_set_encoding(resource processor, string encoding)
-   Set the output encoding for the current stylesheet */
-PHP_FUNCTION(xslt_set_encoding)
-{
-/* The user has to explicitly compile sablotron with sablotron 
-   encoding functions in order for SablotSetEncoding to be 
-   enabled.  config.m4 automatically checks for this... */
-
-#ifdef HAVE_SABLOT_SET_ENCODING
-       zval       **processor_p,  /* Resource Pointer to a PHP-XSLT processor */
-                  **encoding;     /* The encoding to use for the output */
-       php_xslt    *handle;       /* A PHP-XSLT processor */
-
-       if (ZEND_NUM_ARGS() != 2 ||
-           zend_get_parameters_ex(2, &processor_p, &encoding) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt);
-       convert_to_string_ex(encoding);
-
-       /* Set the encoding */
-       SablotSetEncoding(XSLT_PROCESSOR(handle), Z_STRVAL_PP(encoding));
-#endif
-
-}
-/* }}} */
-
-/* {{{ proto void xslt_set_log(resource processor, string logfile)
-   Set the log file to write the errors to (defaults to stderr) */
-PHP_FUNCTION(xslt_set_log)
-{
-       zval      **processor_p,             /* Resource pointer to a PHP-XSLT processor */
-                 **logfile;                 /* Path to the logfile */
-       php_xslt   *handle;                  /* A PHP-XSLT processor */
-       int         argc = ZEND_NUM_ARGS();  /* Argument count */
-
-       if (argc < 1 || argc > 2 ||
-           zend_get_parameters_ex(argc, &processor_p, &logfile) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt);
-       
-       if (Z_TYPE_PP(logfile) == IS_LONG || Z_TYPE_PP(logfile) == IS_BOOL || Z_TYPE_PP(logfile) == IS_DOUBLE) {
-               XSLT_LOG(handle).do_log = Z_LVAL_PP(logfile);
-               RETURN_NULL();
-       }
-       else {
-               convert_to_string_ex(logfile);
-       }
-
-       /* If the log file already exists, free it */
-       if (XSLT_LOG(handle).path) {
-               efree(XSLT_LOG(handle).path);
-       }
-       
-       /* Copy the path */
-       XSLT_LOG(handle).path = estrndup(Z_STRVAL_PP(logfile),
-                                        Z_STRLEN_PP(logfile));
-}
-/* }}} */
-
-/* {{{ proto string xslt_process(resource processor, string xml, string xslt[, mixed result[, array args[, array params]]])
-   Perform the xslt transformation */
-PHP_FUNCTION(xslt_process)
-{
-       zval       **processor_p,             /* Resource Pointer to a PHP-XSLT processor */
-                  **xml_p,                   /* A zval pointer to the XML data */
-                  **xslt_p,                  /* A zval pointer to the XSLT data */
-                  **result_p,                /* A zval pointer to the transformation results */
-                  **params_p,                /* A zval pointer to the XSLT parameters array */
-                  **args_p;                  /* A zval pointer to the XSLT arguments array */
-       php_xslt    *handle;                  /* A PHP-XSLT processor */
-       char       **params = NULL;           /* A Sablotron parameter array (derived from the zval parameter array) */
-       char       **args   = NULL;           /* A Sablotron argument array (derived from the zval argument array) */
-       char        *xslt;                    /* The XSLT stylesheet or argument buffer (pointer to xslt_p) */
-       char        *xml;                     /* The XML stylesheet or argument buffer (pointer to xml_p) */
-       char        *result;                  /* The result file or argument buffer */
-       int          argc = ZEND_NUM_ARGS();  /* The number of arguments given */
-       int          error;                   /* Our error container */
-       int          i;                       /* iterator for Situation */
-
-       if (argc < 3 || argc > 6 ||
-           zend_get_parameters_ex(argc, &processor_p, &xml_p, &xslt_p, &result_p, &args_p, &params_p) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-
-       ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt);
-       convert_to_string_ex(xml_p);
-       convert_to_string_ex(xslt_p);
-
-       xml  = Z_STRVAL_PP(xml_p);
-       xslt = Z_STRVAL_PP(xslt_p);
-
-       /* Well, no result file was given or result buffer, that means (guess what?)
-          we're returning the result yipp di doo! */
-       if (argc < 4 || Z_TYPE_PP(result_p) == IS_NULL) {
-               result = "arg:/_result";
-       }
-       /* The result buffer to place the data into, either a file or an argument buffer, etc. */
-       else {
-               convert_to_string_ex(result_p);
-               result = Z_STRVAL_PP(result_p);
-       }
-
-       /* Translate a PHP array into a Sablotron array */
-       if (argc > 4) {
-               xslt_make_array(args_p, &args);
-               /* Can return NULL */
-               if (args) {
-                       TSRMLS_FETCH();
-                       i=0;
-                       while (args[i]) {
-                               /* We can safely add args[i+1] since xslt_make_array sets args[i] to NULL if
-                                       a key on the array is missing. */
-                               /* For now, we don't care about the error. So don't store it. */
-                               SablotAddArgBuffer(XSLT_SITUATION(handle), XSLT_PROCESSOR(handle), args[i], args[i+1]);
-                               i += 2;
-                       }
-
-                       /* Since we have args passed, we need to set the base uri, so pull in executor
-                               globals and set the base, using the current filename, specifcally for the
-                               'arg' scheme */
-                       if(XSLT_BASE_ISSET(handle) == 0)
-                       {
-                               char *baseuri;
-                               spprintf(&baseuri, 0, "file://%s", zend_get_executed_filename(TSRMLS_C));
-                               SablotSetBaseForScheme(XSLT_PROCESSOR(handle), "arg", baseuri);
-
-                               if(baseuri)
-                                       efree(baseuri);
-                       }
-               }
-       }
-       
-       if (argc > 5) {
-               xslt_make_array(params_p, &params);
-               /* Can return NULL */
-               if (params) {
-                       i=0;
-                       while (params[i]) {
-                               SablotAddParam(XSLT_SITUATION(handle), XSLT_PROCESSOR(handle), params[i], params[i+1]);
-                               i += 2;
-                       }
-               }
-       }
-       
-       /* Perform transformation */
-       error = SablotRunProcessorGen(XSLT_SITUATION(handle), XSLT_PROCESSOR(handle), xslt, xml, result);
-       if (error) {
-               XSLT_ERRNO(handle) = error;
-
-               if (params) xslt_free_array(params);
-               if (args)   xslt_free_array(args);
-
-               RETURN_FALSE;
-       }
-
-       /* If the result buffer is specified, then we return the results of the XSLT
-          transformation */
-       if (!strcmp(result, "arg:/_result")) {
-               char *trans_result;
-
-               /* Fetch the result buffer into trans_result */
-               error = SablotGetResultArg(handle->processor.ptr, "arg:/_result", &trans_result);
-               if (error) {
-                       /* Save the error number */
-                       XSLT_ERRNO(handle) = error;
-                       
-                       /* Cleanup */
-                       if (params) xslt_free_array(params);
-                       if (args)   xslt_free_array(args);
-                       
-                       RETURN_FALSE;
-               }
-
-               RETVAL_STRING(trans_result, 1);
-               SablotFree(trans_result);
-       }
-       else {
-               RETVAL_TRUE;
-       }
-       
-       /* Cleanup */
-       if (params) xslt_free_array(params);
-       if (args)   xslt_free_array(args);
-}
-/* }}} */
-
-/* {{{ proto int xslt_errno(resource processor)
-   Error number */
-PHP_FUNCTION(xslt_errno)
-{
-       zval        **processor_p;   /* Resource pointer to a PHP-XSLT processor */
-       php_xslt     *handle;        /* A PHP-XSLT processor */
-
-       if (ZEND_NUM_ARGS() != 1 ||
-           zend_get_parameters_ex(1, &processor_p) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt);
-
-       RETURN_LONG(XSLT_ERRNO(handle));
-}
-/* }}} */
-
-/* {{{ proto string xslt_error(resource processor)
-   Error string */
-PHP_FUNCTION(xslt_error)
-{
-       zval      **processor_p;  /* Resource pointer to a PHP-XSLT processor */
-       php_xslt   *handle;       /* A PHP-XSLT processor */
-
-       if (ZEND_NUM_ARGS() != 1 ||
-           zend_get_parameters_ex(1, &processor_p) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt);
-
-       if (XSLT_ERRSTR(handle)) {
-               RETURN_STRING(XSLT_ERRSTR(handle), 1);  
-       } else {
-               RETURN_FALSE;
-       }
-}
-/* }}} */
-
-/* {{{ proto void xslt_free(resource processor)
-   Free the xslt processor up */
-PHP_FUNCTION(xslt_free)
-{
-       zval     **processor_p;   /* Resource pointer to a php-xslt processor */
-       php_xslt  *handle;        /* A PHP-XSLT processor */
-       
-       if (ZEND_NUM_ARGS() != 1 ||
-           zend_get_parameters_ex(1, &processor_p) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-       ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt);
-       
-       /* Remove the entry from the list */
-       zend_list_delete(Z_LVAL_PP(processor_p));
-}
-/* }}} */
-
-/* {{{ proto int xslt_set_object(resource parser, object obj)
-   sets the object in which to resolve callback functions */
-PHP_FUNCTION(xslt_set_object)
-{
-       zval      *processor_p;  /* Resource pointer to a PHP-XSLT processor */
-       zval      *myobj;        /* The object that will handle the callback */
-       php_xslt  *handle;       /* A PHP-XSLT processor */
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zo", &processor_p, &myobj) == FAILURE)
-               return;
-
-       ZEND_FETCH_RESOURCE(handle, php_xslt *, &processor_p, -1, le_xslt_name, le_xslt);
-
-       handle->object = myobj;
-
-       RETURN_TRUE;
-}
-/* }}} */
-
-/* {{{ proto int xslt_setopt(resource processor, int newmask)
-   Set options on a given xsl processor */
-PHP_FUNCTION(xslt_setopt)
-{
-       zval      **processor_p; /* Resource pointer to a PHP-XSLT processor */
-       zval      **zbitmask;    /* A bitmask created by through processor specific constants */
-       php_xslt  *handle;       /* A PHP-XSLT processor */
-       int       error;         /* Error return codes */
-       int       newmask;       /* New mask */
-#ifdef HAVE_SABLOT_GET_OPTIONS
-       int       prevmask;      /* Previous mask */
-#endif
-
-       if (ZEND_NUM_ARGS() != 2 ||
-               zend_get_parameters_ex(2, &processor_p, &zbitmask) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-
-       ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt);
-       convert_to_long_ex(zbitmask);
-
-       newmask = Z_LVAL_PP(zbitmask);
-       if (newmask < 0) {
-               php_error_docref("function.xslt-setopt" TSRMLS_CC, E_WARNING, "Invalid bitmask: %i", newmask);
-               RETURN_FALSE;
-       }
-
-#ifdef HAVE_SABLOT_GET_OPTIONS
-       prevmask = SablotGetOptions(XSLT_SITUATION(handle));
-#endif
-       error = SablotSetOptions(XSLT_SITUATION(handle), newmask);
-       if (error) {
-               /* FIXME: Need to analyze the return code to give a more verbose error description */
-               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Failed to set options");
-       }
-
-#ifdef HAVE_SABLOT_GET_OPTIONS
-       RETURN_LONG(prevmask);
-#else
-       RETURN_TRUE;
-#endif
-}
-
-/* }}} */
-
-#ifdef HAVE_SABLOT_GET_OPTIONS
-/* {{{ proto int xslt_getopt(resource processor)
-   Get options on a given xsl processor */
-PHP_FUNCTION(xslt_getopt)
-{
-       zval      **processor_p; /* Resource pointer to a PHP-XSLT processor */
-       php_xslt  *handle;       /* A PHP-XSLT processor */
-
-       if (ZEND_NUM_ARGS() != 1 ||
-               zend_get_parameters_ex(1, &processor_p) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-
-       ZEND_FETCH_RESOURCE(handle, php_xslt *, processor_p, -1, le_xslt_name, le_xslt);
-
-       RETURN_LONG(SablotGetOptions(XSLT_SITUATION(handle)));
-}
-
-/* }}} */
-#endif
-
-/* {{{ proto string xslt_backend_version()
-   Returns the version number of Sablotron (if available) */
-PHP_FUNCTION(xslt_backend_version)
-{
-#ifdef SAB_VERSION
-       RETURN_STRING(SAB_VERSION,1);
-#else
-       RETURN_FALSE;
-#endif 
-}
-/* }}} */
-
-/* {{{ proto string xslt_backend_name()
-   Returns the name of the Backend (here "Sablotron")*/
-PHP_FUNCTION(xslt_backend_name)
-{
-       RETURN_STRING("Sablotron",1);
-}
-/* }}} */
-
-/* {{{ proto string xslt_backend_info()
-   Returns the information on the compilation settings of the backend */
-PHP_FUNCTION(xslt_backend_info)
-{
-#ifdef HAVE_SABLOT_CONFIG
-       RETURN_STRING(SAB_INFO, strlen(SAB_INFO));
-#else
-       RETURN_STRING(XSLT_NO_INFO, strlen(XSLT_NO_INFO));
-#endif
-}
-/* }}} */
-/* {{{ free_processor()
-   Free an XSLT processor */
-static void free_processor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
-{
-       php_xslt *handle = (php_xslt *) rsrc->ptr;     /* A PHP-XSLT processor */
-       
-       /* Free the processor */
-       if (XSLT_PROCESSOR(handle)) {
-               SablotUnregHandler(XSLT_PROCESSOR(handle), HLR_MESSAGE, NULL, NULL);
-               SablotUnregHandler(XSLT_PROCESSOR(handle), HLR_SAX,     NULL, NULL);
-               SablotUnregHandler(XSLT_PROCESSOR(handle), HLR_SCHEME,  NULL, NULL);
-               SablotDestroyProcessor(XSLT_PROCESSOR(handle));
-               SablotDestroySituation(XSLT_SITUATION(handle));
-       }
-
-       /* Free Scheme handlers */
-       XSLT_FUNCH_FREE(XSLT_SCHEME(handle).sh_get_all);
-       XSLT_FUNCH_FREE(XSLT_SCHEME(handle).sh_open);
-       XSLT_FUNCH_FREE(XSLT_SCHEME(handle).sh_get);
-       XSLT_FUNCH_FREE(XSLT_SCHEME(handle).sh_put);
-       XSLT_FUNCH_FREE(XSLT_SCHEME(handle).sh_close);
-       /* Free SAX handlers */
-       XSLT_FUNCH_FREE(XSLT_SAX(handle).doc_start);
-       XSLT_FUNCH_FREE(XSLT_SAX(handle).element_start);
-       XSLT_FUNCH_FREE(XSLT_SAX(handle).element_end);
-       XSLT_FUNCH_FREE(XSLT_SAX(handle).namespace_start);
-       XSLT_FUNCH_FREE(XSLT_SAX(handle).namespace_end);
-       XSLT_FUNCH_FREE(XSLT_SAX(handle).comment);
-       XSLT_FUNCH_FREE(XSLT_SAX(handle).pi);
-       XSLT_FUNCH_FREE(XSLT_SAX(handle).characters);
-       XSLT_FUNCH_FREE(XSLT_SAX(handle).doc_end);
-       /* Free error handler */
-       XSLT_FUNCH_FREE(XSLT_ERROR(handle));
-
-       /* Free error message, if any */
-       if (XSLT_ERRSTR(handle)) {
-               efree(XSLT_ERRSTR(handle));
-       }
-
-       /* Close log file */
-       if (XSLT_LOG(handle).fd) {
-               close(XSLT_LOG(handle).fd);
-       }
-       
-       /* Free log file path */
-       if (XSLT_LOG(handle).path) {
-               efree(XSLT_LOG(handle).path);
-       }
-
-       /* Free up the handle */
-       efree(handle->handlers);
-       efree(handle->err);
-       efree(handle);
-}
-/* }}} */
-
-/* {{{ register_sax_handler_pair()
-   Register a pair of sax handlers */
-static void register_sax_handler_pair(zval **handler1, zval **handler2, zval **handler TSRMLS_DC)
-{
-       zval **current;   /* The current handler we're grabbing */
-       
-       /* Grab and assign handler 1 */
-       if (zend_hash_index_find(Z_ARRVAL_PP(handler), 0, (void **) &current) == SUCCESS) {
-               *handler1 = *current;
-               zval_add_ref(handler1);
-       }
-       else {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Wrong format of arguments");
-               return;
-       }
-       
-       /* Grab and assign handler 2 */
-       if (zend_hash_index_find(Z_ARRVAL_PP(handler), 1, (void **) &current) == SUCCESS) {
-               *handler2 = *current;
-               zval_add_ref(handler2);
-       }
-       else {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Wrong format of arguments");
-               return;
-       }
-}
-/* }}} */
-
-/* {{{ scheme_getall()
-   The getall scheme handler */
-static int scheme_getall(void *user_data, SablotHandle proc, const char *scheme, const char *rest, char **buffer, int *byte_count)
-{
-       zval       *argv[3];                           /* Arguments to the scheme getall function */
-       zval       *retval;                            /* Return value from the scheme getall function */
-       int        result;
-       php_xslt   *handle = (php_xslt *) user_data;   /* A PHP-XSLT processor */
-    TSRMLS_FETCH();
-    
-       /* If the scheme handler get all function doesn't
-          exist, exit out */
-       if (!XSLT_SCHEME(handle).sh_get_all) {
-               return 0;
-       }
-
-       /* Allocate and initialize */
-       MAKE_STD_ZVAL(argv[0]);
-       MAKE_STD_ZVAL(argv[1]);
-       MAKE_STD_ZVAL(argv[2]);
-
-       /* Argument 1: XSLT processor (resource)
-          Argument 2: Scheme         (string)
-          Argument 3: Rest           (string)
-        */
-       ZVAL_RESOURCE(argv[0], handle->processor.idx);
-       zend_list_addref(handle->processor.idx);
-       ZVAL_STRING(argv[1], (char *) scheme, 1);
-       ZVAL_STRING(argv[2], (char *) rest, 1);
-
-       xslt_call_function("scheme get all", XSLT_SCHEME(handle).sh_get_all, handle->object, 
-                          3, argv, &retval);
-
-       if (!retval) {
-               /* return failure */
-               return 1;
-       }
-
-       if ((Z_TYPE_P(retval) == IS_BOOL && Z_LVAL_P(retval) == 0) || (Z_TYPE_P(retval) == IS_NULL)) {
-               result = 1;
-       } else {
-               /* Convert the return value to string if needed */
-               if (Z_TYPE_P(retval) != IS_STRING)
-                       convert_to_string_ex(&retval);
-
-               /* Save the return value in the buffer (copying it) */
-               *buffer     = estrndup(Z_STRVAL_P(retval), Z_STRLEN_P(retval));
-               *byte_count = Z_STRLEN_P(retval);
-               result = 0;
-       }
-
-       /* Free return value */
-       zval_ptr_dtor(&retval);
-               
-       return result;
-}
-/* }}} */
-
-/* {{{ scheme_handler_is_registered()
-   Check to see if the scheme handler is registered with the user */
-static int scheme_handler_is_registered(php_xslt *handle)
-{
-       /* If one of the functions is exists, then scheme
-          handlers are registered */
-       if (XSLT_SCHEME(handle).sh_get_all  ||
-           XSLT_SCHEME(handle).sh_open     ||
-           XSLT_SCHEME(handle).sh_get      ||
-           XSLT_SCHEME(handle).sh_put      ||
-           XSLT_SCHEME(handle).sh_close)
-               return 1;
-       /* otherwise, no cigar */
-       else
-               return 0;
-}
-/* }}} */
-
-/* {{{ scheme_freememory()
-   Called when sablotron needs to free memory related to scheme handling */
-static int scheme_freememory(void *user_data, SablotHandle proc, char *buffer)
-{
-       /* If we don't have any scheme handler's registered, then emalloc() wasn't
-          used, and if emalloc() wasn't then efree shouldn't be used */
-       if (!scheme_handler_is_registered((php_xslt *) user_data)) {
-               return 0;
-       }
-
-       /* Free the memory using efree() and remove it from the register */
-       efree(buffer);
-       
-       return 0;
-}
-/* }}} */
-
-/* {{{ scheme_open()
-   Called when the URI needs to be opened */
-static int  scheme_open(void *user_data, SablotHandle proc, const char *scheme, const char *rest, int *fd)
-{
-       zval      *argv[3];                            /* Arguments to the scheme open function */
-       zval      *retval;                             /* The return value from the scheme open function */
-       php_xslt  *handle = (php_xslt *) user_data;    /* A PHP-XSLT processor */
-    TSRMLS_FETCH();
-    
-       /* If no open handler exists, let's exit */
-       if (!XSLT_SCHEME(handle).sh_open) {
-               return 0;
-       }
-
-       /* Allocate and initialize arguments */
-       MAKE_STD_ZVAL(argv[0]);
-       MAKE_STD_ZVAL(argv[1]);
-       MAKE_STD_ZVAL(argv[2]);
-
-       /* Argument 1: XSLT Processor (resource)
-          Argument 2: Scheme         (string)
-          Argument 3: Rest           (string)
-        */
-       ZVAL_RESOURCE(argv[0], handle->processor.idx);
-       zend_list_addref(handle->processor.idx);
-       ZVAL_STRING(argv[1], (char *) scheme, 1);
-       ZVAL_STRING(argv[2], (char *) rest, 1);
-       
-       /* Call the function */
-       xslt_call_function("scheme open", XSLT_SCHEME(handle).sh_open, handle->object,
-                          3, argv, &retval);
-
-       if (!retval) {
-               /* return failure */
-               return 1;
-       }
-
-       /* Return value is a resource pointer to an open file */
-       *fd = Z_LVAL_P(retval);
-               
-       /* Free it all up */
-       zval_ptr_dtor(&retval);
-
-       if (!*fd) {
-               /* return failure - unsupported scheme */
-               return SH_ERR_UNSUPPORTED_SCHEME;
-       }
-
-       /* return success */
-       return 0;
-}
-/* }}} */
-
-/* {{{ scheme_get()
-   Called when data needs to be fetched from the URI */
-static int  scheme_get(void *user_data, SablotHandle proc, int fd, char *buffer, int *byte_count)
-{
-       zval       *argv[3];                           /* Arguments to the scheme get function  */
-       zval       *retval;                            /* Return value from the scheme get function */
-       php_xslt   *handle = (php_xslt *) user_data;   /* A PHP-XSLT processor */
-    TSRMLS_FETCH();
-    
-       /* If no get handler exists, let's exit */
-       if (!XSLT_SCHEME(handle).sh_get) {
-               return 0;
-       }
-
-       /* Allocate and initialize arguments */
-       MAKE_STD_ZVAL(argv[0]);
-       MAKE_STD_ZVAL(argv[1]);
-       MAKE_STD_ZVAL(argv[2]);
-
-       /* Argument 1: XSLT Processor (resource)
-          Argument 2: File Pointer   (resource)
-          Argument 3: Data           (string)
-        */
-       ZVAL_RESOURCE(argv[0], handle->processor.idx);
-       zend_list_addref(handle->processor.idx);
-       ZVAL_RESOURCE(argv[1], fd);
-       zend_list_addref(fd);
-       ZVAL_STRINGL(argv[2], buffer, *byte_count, 0);
-       
-       /* Call the function */
-       xslt_call_function("scheme get", XSLT_SCHEME(handle).sh_get, handle->object,
-                          3, argv, &retval);
-       
-       if (!retval) {
-               /* return failure */
-               return 1;
-       }
-       
-       /* Returns the number of bytes read */
-       *byte_count = Z_LVAL_P(retval);
-
-       /* Free things up */
-       zval_ptr_dtor(&retval);
-
-       /* return success */
-       return 0;
-}
-/* }}} */
-
-/* {{{ scheme_put()
-   Called when data needs to be written */
-static int  scheme_put(void *user_data, SablotHandle proc, int fd, const char *buffer, int *byte_count)
-{
-       zval       *argv[3];                            /* Arguments to the scheme put function */
-       zval       *retval;                             /* Return value from the scheme put function */
-       php_xslt   *handle = (php_xslt *) user_data;    /* A PHP-XSLT processor */
-    TSRMLS_FETCH();
-    
-       /* If no put handler exists, let's exit */
-       if (!XSLT_SCHEME(handle).sh_put) {
-               return 0;
-       }
-       
-       /* Allocate and initialize arguments */
-       MAKE_STD_ZVAL(argv[0]);
-       MAKE_STD_ZVAL(argv[1]);
-       MAKE_STD_ZVAL(argv[2]);
-
-       /* Argument 1: XSLT processor (resource)
-          Argument 2: File pointer   (resource)
-          Argument 3: Data           (string)
-        */
-       ZVAL_RESOURCE(argv[0], handle->processor.idx);
-       zend_list_addref(handle->processor.idx);
-       ZVAL_RESOURCE(argv[1], fd);
-       zend_list_addref(fd);
-       ZVAL_STRINGL(argv[2], (char *) buffer, *byte_count, 1);
-       
-       /* Call the scheme put function already */
-       xslt_call_function("scheme put", XSLT_SCHEME(handle).sh_put, handle->object,
-                          3, argv, &retval);
-
-       if (!retval) {
-               /* return failure */
-               return 1;
-       }
-       
-       /* The return value is the number of bytes written */
-       *byte_count = Z_LVAL_P(retval);
-
-       /* Free everything up */
-       zval_ptr_dtor(&retval);
-
-       /* Return success */
-       return 0;
-}
-/* }}} */
-
-/* {{{ scheme_close()
-   Called when its time to close the fd */
-static int  scheme_close(void *user_data, SablotHandle proc, int fd)
-{
-       zval       *argv[2];                           /* Arguments to the scheme close function*/
-       zval       *retval;                            /* Return value from the scheme close function */
-       php_xslt   *handle = (php_xslt *) user_data;   /* A PHP-XSLT processor */
-    TSRMLS_FETCH();
-    
-       /* if no close handler exists, exit */
-       if (!XSLT_SCHEME(handle).sh_close) {
-               return 0;
-       }
-
-       /* Allocate and initialize arguments */
-       MAKE_STD_ZVAL(argv[0]);
-       MAKE_STD_ZVAL(argv[1]);
-
-       /* Argument 1: XSLT processor (resource)
-          Argument 2: File pointer   (resource)
-        */
-       ZVAL_RESOURCE(argv[0], handle->processor.idx);
-       zend_list_addref(handle->processor.idx);
-       ZVAL_RESOURCE(argv[1], fd);
-       zend_list_addref(fd);
-       
-       /* Call the scheme handler close function */
-       xslt_call_function("scheme close", XSLT_SCHEME(handle).sh_close, handle->object,
-                          2, argv, &retval);
-
-       if (!retval) {
-               /* return failure */
-               return 1;
-       }
-       
-       /* Free everything up */
-       zval_ptr_dtor(&retval);
-
-       /* Return success */
-       return 0;
-}
-/* }}} */
-
-/* {{{ sax_startdoc()
-   Called when the document starts to be processed */
-static SAX_RETURN sax_startdoc(void *ctx, SablotHandle processor)
-{
-       zval       *argv[1];                    /* Arguments to the sax start doc function */
-       zval       *retval;                     /* Return value from sax start doc function */
-       php_xslt   *handle = (php_xslt *) ctx;  /* A PHP-XSLT processor */
-    TSRMLS_FETCH();
-    
-       /* if no document start function exists, exit */
-       if (!XSLT_SAX(handle).doc_start) {
-               return;
-       }
-
-       /* Allocate and initialize arguments */
-       MAKE_STD_ZVAL(argv[0]);
-
-       /* Argument 1:  XSLT processor (resource) */
-       ZVAL_RESOURCE(argv[0], handle->processor.idx);
-       zend_list_addref(handle->processor.idx);
-       
-       /* Call the Sax start doc function */
-       xslt_call_function("sax start doc", XSLT_SAX(handle).doc_start, handle->object,
-                          1, argv, &retval);
-
-       /* Cleanup */
-       if (retval)
-               zval_ptr_dtor(&retval);
-}
-/* }}} */
-
-/* {{{ sax_startelement()
-   Called when an element is begun to be processed */
-static SAX_RETURN sax_startelement(void *ctx, SablotHandle processor,
-                                   const char  *name, 
-                                   const char **attr)
-{
-       zval       *argv[3];                     /* Arguments to the sax start element function */
-       zval       *retval;                      /* Return value from the sax start element function */
-       php_xslt   *handle = (php_xslt *) ctx;   /* A PHP-XSLT processor */
-       char      **p;                           /* Pointer to attributes */
-    TSRMLS_FETCH();
-    
-       /* If no element start function is found, exit */
-       if (!XSLT_SAX(handle).element_start) {
-               return;
-       }
-
-       /* Allocate and initialize arguments */
-       MAKE_STD_ZVAL(argv[0]);
-       MAKE_STD_ZVAL(argv[1]);
-       MAKE_STD_ZVAL(argv[2]);
-       array_init(argv[2]);
-
-       /* Argument 1: XSLT processor (resource)
-          Argument 2: Element name   (string)
-          Argument 3: Element attributes (array)
-        */
-       ZVAL_RESOURCE(argv[0], handle->processor.idx);
-       zend_list_addref(handle->processor.idx);
-       ZVAL_STRING(argv[1], (char *) name, 1);
-
-       /* loop through the attributes array, copying it onto our
-          php array */
-       p = (char **) attr;
-       while (p && *p) {
-               add_assoc_string(argv[2], *p, *(p + 1), 1);
-               p += 2;
-       }
-
-       /* Call the sax element start function */
-       xslt_call_function("sax start element", XSLT_SAX(handle).element_start,  handle->object,
-                          3, argv, &retval);
-       
-       /* Cleanup */
-       if (retval)
-               zval_ptr_dtor(&retval);
-}
-/* }}} */
-
-/* {{{ xslt_sax_endelement()
-   Called when an ending XML element is encountered */
-static SAX_RETURN sax_endelement(void *ctx, SablotHandle processor, const char *name)
-{
-       zval        *argv[2];                   /* Arguments to the sax end element function */
-       zval        *retval;                    /* Return value from the sax end element function */
-       php_xslt    *handle = (php_xslt *) ctx; /* A PHP-XSLT processor */
-    TSRMLS_FETCH();
-    
-       /* If no element end function exists, exit */
-       if (!XSLT_SAX(handle).element_end) {
-               return;
-       }
-       
-       /* Allocate and initialize arguments */
-       MAKE_STD_ZVAL(argv[0]);
-       MAKE_STD_ZVAL(argv[1]);
-
-       /* Argument 1: XSLT processor (resource)
-          Argument 2: Element name   (string)
-        */
-       ZVAL_RESOURCE(argv[0], handle->processor.idx);
-       zend_list_addref(handle->processor.idx);
-       ZVAL_STRING(argv[1], (char *) name, 1);
-
-       /* Call the sax end element function */
-       xslt_call_function("sax end element", XSLT_SAX(handle).element_end, handle->object,
-                          2, argv, &retval);
-       
-       /* Cleanup */
-       if (retval)
-               zval_ptr_dtor(&retval);
-}
-/* }}} */
-
-/* {{{ sax_startnamespace()
-   Called at the beginning of the parsing of a new namespace */
-static SAX_RETURN sax_startnamespace(void *ctx, SablotHandle processor, 
-                                     const char *prefix, 
-                                     const char *uri)
-{
-       zval       *argv[3];                    /* Arguments to the sax start namespace function */
-       zval       *retval;                     /* Return value from the sax start namespace function */
-       php_xslt   *handle = (php_xslt *) ctx;  /* A PHP-XSLT processor */
-    TSRMLS_FETCH();
-    
-       /* if no namespace start function exists, exit */
-       if (!XSLT_SAX(handle).namespace_start) {
-               return;
-       }
-       
-       /* Allocate and initialize arguments */
-       MAKE_STD_ZVAL(argv[0]);
-       MAKE_STD_ZVAL(argv[1]);
-       MAKE_STD_ZVAL(argv[2]);
-
-       /* Argument 1: XSLT processor (resource)
-          Argument 2: Prefix         (string)
-          Argument 3: URI            (string)
-        */
-       ZVAL_RESOURCE(argv[0], handle->processor.idx);
-       zend_list_addref(handle->processor.idx);
-       ZVAL_STRING(argv[1], (char *) prefix, 1);
-       ZVAL_STRING(argv[2], (char *) uri, 1);
-
-       /* Call the sax start namespace function */
-       xslt_call_function("sax start namespace", XSLT_SAX(handle).namespace_start, handle->object,
-                          3, argv, &retval);
-
-       /* Cleanup */
-       if (retval)
-               zval_ptr_dtor(&retval);
-}
-/* }}} */
-
-/* {{{ sax_endnamespace()
-   Called when a new namespace is finished being parsed */
-static SAX_RETURN sax_endnamespace(void *ctx, SablotHandle processor, const char *prefix)
-{
-       zval        *argv[2];                    /* Arguments to the sax end namespace function */
-       zval        *retval;                     /* Return value from the sax end namespace function */
-       php_xslt    *handle = (php_xslt *) ctx;  /* A PHP-XSLT processor */
-    TSRMLS_FETCH();
-    
-       /* If no namespace end function exists, exit */
-       if (!XSLT_SAX(handle).namespace_end) {
-               return;
-       }
-       
-       /* Allocate and initialize arguments */
-       MAKE_STD_ZVAL(argv[0]);
-       MAKE_STD_ZVAL(argv[1]);
-       
-       /* Argument 1: XSLT processor (resource)
-          Argument 2: Prefix         (string)
-        */
-       ZVAL_RESOURCE(argv[0], handle->processor.idx);
-       zend_list_addref(handle->processor.idx);
-       ZVAL_STRING(argv[1], (char *) prefix, 1);
-       
-       /* Call the sax end namespace function */
-       xslt_call_function("sax end namespace", XSLT_SAX(handle).namespace_end, handle->object,
-                          2, argv, &retval);
-       
-       /* Cleanup */
-       if (retval)
-               zval_ptr_dtor(&retval);
-}
-/* }}} */
-
-/* {{{ sax_comment()
-   Called when a comment is found */
-static SAX_RETURN sax_comment(void *ctx, SablotHandle processor, const char *contents)
-{
-       zval        *argv[2];                    /* Arguments to the sax comment function */
-       zval        *retval;                     /* Return value from the sax comment function */
-       php_xslt    *handle = (php_xslt *) ctx;  /* A PHP-XSLT processor */
-    TSRMLS_FETCH();
-    
-       /* if no comment function exists, exit */
-       if (!XSLT_SAX(handle).comment) {
-               return;
-       }
-       
-       /* Allocate and initialize arguments */
-       MAKE_STD_ZVAL(argv[0]);
-       MAKE_STD_ZVAL(argv[1]);
-       
-       /* Argument 1: XSLT processor   (resource)
-          Argument 2: Comment contents (string)
-        */
-       ZVAL_RESOURCE(argv[0], handle->processor.idx);
-       zend_list_addref(handle->processor.idx);
-       ZVAL_STRING(argv[1], (char *) contents, 1);
-       
-       /* Call the sax comment function */
-       xslt_call_function("sax comment", XSLT_SAX(handle).comment, handle->object,
-                          2, argv, &retval);
-       
-       /* Cleanup */
-       if (retval)
-               zval_ptr_dtor(&retval);
-}
-/* }}} */
-
-/* {{{ sax_pi()
-   Called when processing instructions are found */
-static SAX_RETURN sax_pi(void *ctx, SablotHandle processor,
-                         const char *target, 
-                         const char *contents)
-{
-       zval        *argv[3];                    /* Arguments to the sax processing instruction function */
-       zval        *retval;                     /* Return value from the sax processing instruction function */
-       php_xslt    *handle = (php_xslt *) ctx;  /* A PHP-XSLT processor */
-    TSRMLS_FETCH();
-    
-       /* If no processing instructions function exists, exit */
-       if (!XSLT_SAX(handle).pi) {
-               return;
-       }
-
-       /* Allocate and initialize arguments */
-       MAKE_STD_ZVAL(argv[0]);
-       MAKE_STD_ZVAL(argv[1]);
-       MAKE_STD_ZVAL(argv[2]);
-       
-       /* Argument 1: XSLT processor     (resource)
-          Argument 2: Target of the pi   (string)
-          Argument 3: Contents of the pi (string)
-        */
-       ZVAL_RESOURCE(argv[0], handle->processor.idx);
-       zend_list_addref(handle->processor.idx);
-       ZVAL_STRING(argv[1], (char *) target, 1);
-       ZVAL_STRING(argv[2], (char *) contents, 1);
-
-       /* Call processing instructions function */
-       xslt_call_function("sax processing instructions", XSLT_SAX(handle).pi, handle->object,
-                          3, argv, &retval);
-
-       /* Cleanup */
-       if (retval)
-               zval_ptr_dtor(&retval);
-}
-/* }}} */
-
-/* {{{ sax_characters()
-   Called when characters are come upon */
-static SAX_RETURN sax_characters(void *ctx, SablotHandle processor,
-                                 const char *contents, 
-                                 int length)
-{
-       zval         *argv[2];                    /* Arguments to the sax characters function */
-       zval         *retval;                     /* Return value to the sax characters function */
-       php_xslt     *handle = (php_xslt *) ctx;  /* A PHP-XSLT processor */
-    TSRMLS_FETCH();
-    
-       /* If no characters function exists, exit */
-       if (!XSLT_SAX(handle).characters) {
-               return;
-       }
-       
-       /* Allocate and initialize arguments */
-       MAKE_STD_ZVAL(argv[0]);
-       MAKE_STD_ZVAL(argv[1]);
-
-       /* Argument 1: XSLT processor (resource)
-          Argument 2: Contents       (string)
-        */
-       ZVAL_RESOURCE(argv[0], handle->processor.idx);
-       zend_list_addref(handle->processor.idx);
-       ZVAL_STRINGL(argv[1], (char *) contents, length, 1);
-
-       /* Call characters function */
-       xslt_call_function("sax characters", XSLT_SAX(handle).characters, handle->object,
-                          2, argv, &retval);
-       
-       /* Cleanup */
-       if (retval)
-               zval_ptr_dtor(&retval);
-}
-/* }}} */
-
-/* {{{ sax_enddoc()
-   Called when the document is finished being parsed */
-static SAX_RETURN sax_enddoc(void *ctx, SablotHandle processor)
-{
-       zval        *argv[1];                    /* Arguments to the end document function */
-       zval        *retval;                     /* Return value from the end document function */
-       php_xslt    *handle = (php_xslt *) ctx;  /* A PHP-XSLT processor */
-    TSRMLS_FETCH();
-    
-       /* If no end document function exists, exit */
-       if (!XSLT_SAX(handle).doc_end) {
-               return;
-       }
-       
-       /* Allocate and initialize arguments */
-       MAKE_STD_ZVAL(argv[0]);
-
-       /* Argument 1: XSLT Processor (resource)
-        */
-       ZVAL_RESOURCE(argv[0], handle->processor.idx);
-       zend_list_addref(handle->processor.idx);
-       
-       /* Call the function */
-       xslt_call_function("sax end doc", XSLT_SAX(handle).doc_end, handle->object,
-                          1, argv, &retval);
-       
-       /* Cleanup */
-       if (retval)
-               zval_ptr_dtor(&retval);
-}
-/* }}} */
-
-/* {{{ error_makecode()
-   Make the error code */
-static MH_ERROR error_makecode(void *user_data, SablotHandle proc, int severity, unsigned short facility, unsigned short code)
-{
-       return 0;
-}
-/* }}} */
-
-/* {{{ error_log()
-   Called when its time to log data */
-static MH_ERROR error_log(void *user_data, SablotHandle proc, MH_ERROR code, MH_LEVEL level, char **fields)
-{
-       php_xslt *handle = (php_xslt *) user_data;                                          /* A PHP-XSLT processor */
-       char     *errmsg  = NULL;                                                           /* Error message*/
-       char     *errtype = NULL;                                                           /* Error type */
-       char     *errline = NULL;                                                           /* Error line */
-       char     *msgbuf  = NULL;                                                           /* Message buffer */
-       char      msgformat[] = "Sablotron Message on line %s, level %s: %s\n"; /* Message format */
-       int       error = 0;                                                                /* Error container */
-    TSRMLS_FETCH();
-
-       if (!XSLT_LOG(handle).do_log)
-               return 0;
-       
-       /* Parse the error array */
-       /* Loop through the error array */
-       if (fields) {
-               while (*fields) {
-                       char *key;  /* Key to for the message */
-                       char *val;  /* The message itself */
-                       char *ptr;  /* Pointer to the location of the ':' (separator) */
-                       int   pos;  /* Position of the ':' (separator) */
-                       int   len;  /* Length of the string */
-
-                       len = strlen(*fields);
-
-                       /* Grab the separator's position */
-                       ptr = strchr(*fields, ':');
-                       if (!ptr) {
-                               continue;
-                       }
-                       pos = ptr - *fields;
-
-                       /* Allocate the key and value and copy the data onto them */
-                       key = emalloc(pos + 1);
-                       val = emalloc((len - pos) + 1);
-
-                       strlcpy(key, *fields, pos + 1);
-                       strlcpy(val, *fields + pos + 1, len - pos);
-
-                       /* Check to see whether or not we want to save the data */
-                       if (!strcmp(key, "msg")) {
-                               errmsg = estrndup(val, len - pos);
-                       }
-                       else if (!strcmp(key, "type")) {
-                               errtype = estrndup(val, len - pos);
-                       }
-                       else if (!strcmp(key, "line")) {
-                               errline = estrndup(val, len - pos);
-                       }
-                       /* Haven't seen this yet, but turning it on during dev, to see
-                               what we can encounter -- MRS
-                       else {
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Got key %s with val %s", key, val);
-                       }
-                       */
-                       
-                       /* Cleanup */
-                       if (key) efree(key);
-                       if (val) efree(val);
-
-                       /* Next key:value pair please :) */
-                       fields++;
-               }
-       }
-       
-       /* If no error line is given, then place none in the 
-          file */
-       if (!errline) {
-               errline = estrndup("none", sizeof("none") - 1);
-       }
-       
-       /* Default type is a log handle */
-       if (!errtype) {
-               errtype = estrndup("log", sizeof("log") - 1);
-       }
-       
-       /* No error message, no cry */
-       if (!errmsg) {
-               errmsg = estrndup("unknown error", sizeof("unknown error") - 1);
-       }
-       
-       /* Allocate the message buf and copy the data into it */
-       msgbuf = emalloc((sizeof(msgformat) - 6) +
-                        strlen(errmsg) +
-                        strlen(errline) +
-                        strlen(errtype) + 1);
-       sprintf(msgbuf, msgformat, errline, errtype, errmsg);
-
-       /* If the error is serious enough, copy it to our error buffer 
-          which will show up when someone calls the xslt_error() function */
-       if (level == MH_LEVEL_WARN  ||
-           level == MH_LEVEL_ERROR ||
-           level == MH_LEVEL_CRITICAL) {
-               XSLT_REG_ERRMSG(errmsg, handle);
-       }
-
-       /* If we haven't allocated and opened the file yet */
-       if (!XSLT_LOG(handle).fd) {
-               /* Lets open up a file */
-               if (XSLT_LOG(handle).path && strcmp(XSLT_LOG(handle).path, "php://stderr")) {
-                       /* open for append */
-                       XSLT_LOG(handle).fd = open(XSLT_LOG(handle).path, 
-                                                  O_WRONLY|O_CREAT|O_APPEND,
-                                                  S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR);
-                       if (XSLT_LOG(handle).fd == -1) {
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot open log file, %s [%d]: %s",
-                                         XSLT_LOG(handle).path, errno, strerror(errno));
-                               XSLT_LOG(handle).fd = 0;
-                       }
-               }
-               /* Default is stderr, or if the user provided "php://stderr" that's the
-                  stream */
-               else {
-                       XSLT_LOG(handle).fd = 2;
-               }
-       }
-       
-       /* Write the error to the file */
-       error = write(XSLT_LOG(handle).fd, msgbuf, strlen(msgbuf));
-       if (error == -1) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot write data to log file, %s, with fd, %d [%d]: %s",
-                         (XSLT_LOG(handle).path ? XSLT_LOG(handle).path : "stderr"),
-                         XSLT_LOG(handle).fd,
-                         errno,
-                         strerror(errno));
-               return 0;
-       }
-
-       /* Cleanup */
-       if (msgbuf)  efree(msgbuf);
-       if (errtype) efree(errtype);
-       if (errline) efree(errline);
-       if (errmsg)  efree(errmsg);
-       
-       return 0;
-}
-/* }}} */
-
-/* {{{ error_print()
-   Print out an error message or call the error handler */
-static MH_ERROR error_print(void *user_data, SablotHandle proc, MH_ERROR code, MH_LEVEL level, char **fields)
-{
-       php_xslt *handle = (php_xslt *) user_data;   /* A PHP-XSLT processor */
-       TSRMLS_FETCH();
-       
-       if (XSLT_ERROR(handle)) {
-               zval   *argv[4];   /* Arguments to the error function */
-               zval   *retval;    /* Return value from the error function */
-        
-               /* Allocate and initialize */
-               MAKE_STD_ZVAL(argv[0]);
-               MAKE_STD_ZVAL(argv[1]);
-               MAKE_STD_ZVAL(argv[2]);
-               MAKE_STD_ZVAL(argv[3]);
-               array_init(argv[3]);
-
-               /* Argument 1: XSLT Processor (resource)
-                  Argument 2: Error level    (long)
-                  Argument 3: Error code     (long)
-                  Argument 4: Error messages (array)
-                */
-               ZVAL_RESOURCE(argv[0], handle->processor.idx);
-               zend_list_addref(handle->processor.idx);
-               ZVAL_LONG(argv[1], level);
-               ZVAL_LONG(argv[2], code);
-
-               if (fields) {
-                       while (*fields) {
-                               char *key;  /* Key to for the message */
-                               char *val;  /* The message itself */
-                               char *ptr;  /* Pointer to the location of the ':' (separator) */
-                               int   pos;  /* Position of the ':' (separator) */
-                               int   len;  /* Length of the string */
-                               
-                               len = strlen(*fields);
-                       
-                               /* Grab the separator's position */
-                               ptr = strchr(*fields, ':');
-                               if (!ptr) {
-                                       continue;
-                               }
-                               pos = ptr - *fields;
-
-                               /* Allocate the key and value and copy the data onto them */
-                               key = emalloc(pos + 1);
-                               val = emalloc((len - pos) + 1);
-
-                               strlcpy(key, *fields, pos + 1);
-                               strlcpy(val, *fields + pos + 1, len - pos);
-
-                               /* Add it */                            
-                               add_assoc_stringl_ex(argv[3], key, pos + 1, val, len - pos - 1, 1);
-
-                               /* Cleanup */
-                               efree(key);
-                               efree(val);
-
-                               /* Next field please */
-                               fields++;
-                       }
-               }
-
-               /* Call the function */
-               xslt_call_function("error handler", XSLT_ERROR(handle), handle->object,
-                                  4, argv, &retval);
-
-               /* Free up */
-               if (retval)
-                       zval_ptr_dtor(&retval);
-       }
-       else {
-               char *errmsg  = NULL;                                  /* Error message */
-               char *errline = NULL;                                  /* Error line */
-               char *msgbuf  = NULL;                                  /* Message buffer */
-               char  msgformat[] = "Sablotron error on line %s: %s";  /* Message format */
-
-               /* If the error is not serious, exit out */
-               if (code == MH_LEVEL_WARN  || 
-                   code == MH_LEVEL_ERROR || 
-                   code == MH_LEVEL_CRITICAL) {
-                       return 0;
-               }
-
-               /* Loop through and extract the error message and the 
-                  error line */
-               if (fields) {
-                       while (fields && *fields) {
-                               char *key;  /* Key to for the message */
-                               char *val;  /* The message itself */
-                               char *ptr;  /* Pointer to the location of the ':' (separator) */
-                               int   pos;  /* Position of the ':' (separator) */
-                               int   len;  /* Length of the string */
-                       
-                               len = strlen(*fields);
-                       
-                               /* Grab the separator's position */
-                               ptr = strchr(*fields, ':');
-                               if (!ptr) {
-                                       continue;
-                               }
-                               pos = ptr - *fields;
-                       
-                               /* Allocate the key and value and copy the data onto them */
-                               key = emalloc(pos + 1);
-                               val = emalloc((len - pos) + 1);
-                       
-                               strlcpy(key, *fields, pos + 1);
-                               strlcpy(val, *fields + pos + 1, len - pos);
-                       
-                               /* Check to see whether or not we want to save the data */
-                               if (!strcmp(key, "msg")) {
-                                       errmsg = estrndup(val, len - pos);
-                               }
-                               else if (!strcmp(key, "line")) {
-                                       errline = estrndup(val, len - pos);
-                               }
-
-                               /* Cleanup */
-                               if (key) efree(key);
-                               if (val) efree(val);
-                       
-                               /* Next key:value pair please :) */
-                               fields++;
-                       }
-               }
-               
-               if (!errline) {
-                       errline = estrndup("none", sizeof("none") - 1);
-               }
-
-               if (!errmsg) {
-                       errmsg = estrndup("unkown error", sizeof("unkown error") - 1);
-               }
-
-               /* Allocate the message buffer and copy the data onto it */
-               msgbuf = emalloc((sizeof(msgformat) - 4) + strlen(errmsg) + strlen(errline) + 1);
-               sprintf(msgbuf, msgformat, errline, errmsg);
-
-               XSLT_REG_ERRMSG(errmsg, handle);
-
-               /* Output a warning */
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", msgbuf);
-
-               /* Cleanup */
-               efree(msgbuf);
-               efree(errmsg);
-               efree(errline);
-       }
-
-       return(0);
-}
-/* }}} */
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/xslt/tests/args.xsl b/ext/xslt/tests/args.xsl
deleted file mode 100755 (executable)
index 4ff140c..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-       <xsl:output encoding="ISO-8859-1" method="text" omit-xml-declaration="yes" />
-       <xsl:template match="/qa">
-               <xsl:apply-templates select="test" />
-       </xsl:template>
-       <xsl:template match="test[@type = 'simple']">
-               <xsl:value-of select="." />
-       </xsl:template>
-</xsl:stylesheet>
diff --git a/ext/xslt/tests/bug17791.phpt b/ext/xslt/tests/bug17791.phpt
deleted file mode 100644 (file)
index 0a9446e..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
---TEST--
-Pass long string to 'file' argument, bug #17791
---SKIPIF--
-<?php include("skipif.inc"); ?>
---FILE--
-<?php
-$xmlstring = str_repeat('x', 512);
-$xslstring = 'x';
-$xh = xslt_create();
-$result = @xslt_process($xh, $xmlstring, $xslstring);
-@xslt_free($xh);
-echo("OK");
-?>
---EXPECT--
-OK
diff --git a/ext/xslt/tests/bug17931.phpt b/ext/xslt/tests/bug17931.phpt
deleted file mode 100644 (file)
index a85dd06..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
---TEST--
-Pass object for xslt_error_handler, bug #17931
---SKIPIF--
-<?php include("skipif.inc"); ?>
---FILE--
-<?php
-class xsl {
-
-       function xsl() {
-               $this->_parser = xslt_create();
-       }
-       
-       function set_error() {
-               xslt_set_error_handler($this->_parser, array($this, 'xslt_trap_error'));
-               echo "OK";
-       }
-       
-       function xslt_trap_error($parser, $errorno, $level, $fields) {
-               return TRUE;
-       }
-       function clean() {
-               xslt_free($this->_parser);
-       }
-}
-
-$x = new xsl;
-// work-around for possible '$this does not exist' bug in constructor
-$x->set_error();
-$x->clean();
-?>
---EXPECT--
-OK
diff --git a/ext/xslt/tests/bug20177.phpt b/ext/xslt/tests/bug20177.phpt
deleted file mode 100644 (file)
index 3c1695b..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
---TEST--
-Relative and absolute arg handling
---SKIPIF--
-<?php
-include("skipif.inc");
-if(!function_exists('utf8_encode')) {
-       die("skip function utf8_encode() not available");
-}
-?>
---INI--
-magic_quotes_runtime=0
---FILE--
-<?php
-error_reporting(E_ALL);
-$xslfile = dirname(__FILE__) . '/args.xsl';
-$xslsheet = @implode('', @file($xslfile));
-$xmldata = '<?xml version="1.0" encoding="ISO-8859-1"?>';
-$xmldata .= '<!DOCTYPE qa SYSTEM "qa.dtd">' . "\n";
-$xmldata .='
-<qa>
-       <test type="simple">Test has passed</test>
-       <test type="complex" />
-</qa>';
-
-$xh = xslt_create();
-$result = xslt_process($xh, 'arg:/_xml', $xslfile, NULL, array('/_xml' => $xmldata));
-print "$result\n";
-$result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, array('/_xml' => $xmldata, '/_xsl' => $xslsheet));
-print "$result\n";
-xslt_free($xh);
-?>
---EXPECT--
-Test has passed
-Test has passed
diff --git a/ext/xslt/tests/bug20518.phpt b/ext/xslt/tests/bug20518.phpt
deleted file mode 100644 (file)
index bf0a8f9..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
---TEST--
-Don't override xslt_set_base (bug #20518)
---SKIPIF--
-<?php // vim600: syn=php ts=4 sw=4
-include("skipif.inc");
-mkdir(dirname(__FILE__) . '/tmp', 0777) or die("skip Cannot create working directory");
-?>
---INI--
-magic_quotes_runtime=0
---FILE--
-<?php
-error_reporting(E_ALL);
-copy(dirname(__FILE__) . '/qa.dtd', dirname(__FILE__) . '/tmp/qa.dtd');
-$xslfile = dirname(__FILE__) . '/args.xsl';
-$xslsheet = @implode('', @file($xslfile));
-$xmldata = '<?xml version="1.0" encoding="ISO-8859-1"?>';
-$xmldata .= '<!DOCTYPE qa SYSTEM "qa.dtd">' . "\n";
-$xmldata .='
-<qa>
-       <test type="simple">Test has passed</test>
-       <test type="complex" />
-</qa>';
-
-$xh = xslt_create();
-xslt_set_base($xh, 'file://' . dirname(__FILE__) . '/tmp/');
-$result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, array('/_xml' => $xmldata, '/_xsl' => $xslsheet));
-print "$result\n";
-xslt_free($xh);
-unlink(dirname(__FILE__) . '/tmp/qa.dtd');
-rmdir(dirname(__FILE__) . '/tmp');
-?>
---EXPECT--
-Test has passed
diff --git a/ext/xslt/tests/param.xsl b/ext/xslt/tests/param.xsl
deleted file mode 100644 (file)
index 64b78fa..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-       <xsl:output method="text" omit-xml-declaration="yes" encoding="ISO-8859-1" />
-       <xsl:param name="insertion">Test failed</xsl:param>
-       <xsl:template match="/qa">
-               <xsl:apply-templates select="test" />
-       </xsl:template>
-       <xsl:template match="test">
-               <xsl:choose>
-                       <xsl:when test="@type != 'simple'">
-                               <xsl:value-of select="$insertion" />
-                       </xsl:when>
-               </xsl:choose>
-       </xsl:template>
-</xsl:stylesheet>
diff --git a/ext/xslt/tests/public.xml b/ext/xslt/tests/public.xml
deleted file mode 100755 (executable)
index d5de9a8..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>\r
-<!DOCTYPE qa PUBLIC "-//PHP-QA//PHP Quality Assurance DTD //EN" "qa.dtd">\r
-<qa>\r
-       <test type="simple">PHP QA&reg;</test>\r
-</qa>\r
diff --git a/ext/xslt/tests/qa.dtd b/ext/xslt/tests/qa.dtd
deleted file mode 100755 (executable)
index 8b807ea..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!ELEMENT qa (test+)>
-<!ELEMENT test (#PCDATA)>
-<!ATTLIST test
-       type CDATA #IMPLIED
->
-<!ENTITY reg "&#174;">
diff --git a/ext/xslt/tests/skipif.inc b/ext/xslt/tests/skipif.inc
deleted file mode 100644 (file)
index 7cffae6..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<?php
-if(!extension_loaded("xslt")) {
-       die("skip xslt extension not available");
-}
-?>
diff --git a/ext/xslt/tests/test.xml b/ext/xslt/tests/test.xml
deleted file mode 100644 (file)
index f7c69d4..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<qa>
-       <test type="simple">Test has passed</test>
-       <test type="complex" />
-</qa>
diff --git a/ext/xslt/tests/xslt-001.phpt b/ext/xslt/tests/xslt-001.phpt
deleted file mode 100644 (file)
index eeb1c6d..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
---TEST--
-Memoryleak in error printing
---SKIPIF--
-<?php include("skipif.inc"); ?>
---INI--
-error_reporting=2047
-display_errors=0
-track_errors=1
---FILE--
-<?php
-$xmlfile = 'ext/xslt/tests/non-existent.xml';
-$xslfile = 'ext/xslt/tests/non-existent.xsl';
-
-$xh = xslt_create();
-$result = xslt_process($xh, $xmlfile, $xslfile, NULL);
-xslt_free($xh);
-
-echo $php_errormsg."\n";
-?>
---EXPECTF--
-Sablotron error on line none: cannot open file '%s/ext/xslt/tests/non-existent.xsl'
diff --git a/ext/xslt/tests/xslt.phpt b/ext/xslt/tests/xslt.phpt
deleted file mode 100644 (file)
index 3270c3f..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
---TEST--
-Check for xslt presence
---SKIPIF--
-<?php if (!extension_loaded("xslt")) print "skip"; ?>
---POST--
---GET--
---FILE--
-<?php 
-echo "xslt extension is available";
-?>
---EXPECT--
-xslt extension is available
\ No newline at end of file
diff --git a/ext/xslt/tests/xslt_backend_info.phpt b/ext/xslt/tests/xslt_backend_info.phpt
deleted file mode 100644 (file)
index 1fd849c..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
---TEST--
-xslt_backend_info: examples for detection of backend features
---SKIPIF--
-<?php // vim600: noet sw=4 ts=4 syn=php ai si tw=78
-include("skipif.inc");
-if(!function_exists('xslt_backend_info')) {
-       die("skip\n");
-}
-// Yeah-right-but-still
-if(xslt_backend_name() != "Sablotron") {
-       die("skip This test currently only supports Sablotron");
-}
-if("No information available." == xslt_backend_info()) {
-       die("skip Information could not be detected.");
-}
-?>
---FILE--
-<?php
-/*
- * Test xslt_backend_info: basically this test is provided as a how-to for
- * x-platform packages, which rely on certain features which may or may
- * not be available depending on what has been linked into the backend.
- */
-
-$tmp = explode("\n", xslt_backend_info());
-$info = array();
-foreach($tmp AS $line) {
-       list($key, $value) = explode(": ", $line, 2);
-       $info[strtolower($key)] = $value;
-}
-
-if(FALSE === strstr($info['libs'], " -lexpat")) {
-       die("You're configuration is missing expat, which conflicts with sanity.");
-}
-
-if(FALSE === strstr($info['libs'], " -liconv")) {
-       echo("You don't have iconv support\n");
-} else {
-       echo("You have iconv support\n");
-}
-if(FALSE === strstr($info['libs'], " -ljs")) {
-       echo("You don't have JavaScript support\n");
-} else {
-       echo("You have JavaScript support\n");
-}
-?>
---EXPECTREGEX--
-You (don't )?have iconv support
-You (don't )?have JavaScript support
diff --git a/ext/xslt/tests/xslt_getopt.phpt b/ext/xslt/tests/xslt_getopt.phpt
deleted file mode 100644 (file)
index a00a875..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
---TEST--
-xslt_getopt function
---SKIPIF--
-<?php
-include("skipif.inc");
-if(!function_exists('xslt_getopt')) {
-       die("skip\n");
-}
-?>
---FILE--
-<?php
-error_reporting(E_ALL);
-
-$xh = xslt_create();
-xslt_setopt($xh, XSLT_SABOPT_PARSE_PUBLIC_ENTITIES);
-if(xslt_getopt($xh) == XSLT_SABOPT_PARSE_PUBLIC_ENTITIES)
-       print("OK\n");
-else
-       var_dump(xslt_getopt($xh));
-
-xslt_setopt($xh, XSLT_SABOPT_PARSE_PUBLIC_ENTITIES | XSLT_SABOPT_DISABLE_ADDING_META);
-if(xslt_getopt($xh) == XSLT_SABOPT_PARSE_PUBLIC_ENTITIES | XSLT_SABOPT_DISABLE_ADDING_META)
-       print("OK\n");
-else
-       var_dump(xslt_getopt($xh));
-
-xslt_setopt($xh, xslt_getopt($xh) | XSLT_OPT_SILENT);
-if(xslt_getopt($xh) == XSLT_SABOPT_PARSE_PUBLIC_ENTITIES | XSLT_SABOPT_DISABLE_ADDING_META | XSLT_OPT_SILENT)
-       print("OK\n");
-else
-       var_dump(xslt_getopt($xh));
-xslt_free($xh);
-?>
---EXPECT--
-OK
-OK
-OK
diff --git a/ext/xslt/tests/xslt_process-001.phpt b/ext/xslt/tests/xslt_process-001.phpt
deleted file mode 100644 (file)
index 15f9cae..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
---TEST--
-Various ways to provide xml and xslt arguments and params
---SKIPIF--
-<?php
-include("skipif.inc");
-if(!function_exists('utf8_encode')) {
-       die("skip function utf8_encode() not available");
-}
-?>
---INI--
-magic_quotes_runtime=0
---FILE--
-<?php
-error_reporting(E_ALL);
-$xmlfile = 'ext/xslt/tests/test.xml';
-$xslfile = 'ext/xslt/tests/args.xsl';
-$xmldata = @implode('', @file($xmlfile));
-$xslsheet = @implode('', @file($xslfile));
-
-$xh = xslt_create();
-$result = xslt_process($xh, $xmlfile, $xslfile);
-print "$result\n";
-$result = xslt_process($xh, 'arg:/_xml', $xslfile, NULL, array('/_xml' => $xmldata));
-print "$result\n";
-$result = xslt_process($xh, $xmlfile, 'arg:/_xsl', NULL, array('/_xsl' => $xslsheet));
-print "$result\n";
-$result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, array('/_xml' => $xmldata, '/_xsl' => $xslsheet));
-print "$result\n";
-
-// The same, with params
-$xslfile = 'ext/xslt/tests/param.xsl';
-$xslsheet = implode('', file($xslfile));
-$params = array("Test has passed", "PHP QA®");
-
-foreach($params AS $val)
-{
-       $val = utf8_encode($val);
-       $result = xslt_process($xh, $xmlfile, $xslfile, NULL, NULL, array('insertion' => $val));
-       print "$result\n";
-       $result = xslt_process($xh, 'arg:/_xml', $xslfile, NULL, array('/_xml' => $xmldata), array('insertion' => $val));
-       print "$result\n";
-       $result = xslt_process($xh, $xmlfile, 'arg:/_xsl', NULL, array('/_xsl' => $xslsheet), array('insertion' => $val));
-       print "$result\n";
-       $result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, array('/_xml' => $xmldata, '/_xsl' => $xslsheet), array('insertion' => $val));
-       print "$result\n";
-}
-
-xslt_free($xh);
-?>
---EXPECT--
-Test has passed
-Test has passed
-Test has passed
-Test has passed
-Test has passed
-Test has passed
-Test has passed
-Test has passed
-PHP QA®
-PHP QA®
-PHP QA®
-PHP QA®
diff --git a/ext/xslt/tests/xslt_process-002.phpt b/ext/xslt/tests/xslt_process-002.phpt
deleted file mode 100644 (file)
index 7c6f14f..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
---TEST--
-Crash xslt_process with reused handler (this test may take a while)
---SKIPIF--
-<?php
-include("skipif.inc");
-if(!function_exists('utf8_encode')) {
-       die("skip\n");
-}
-?>
---FILE--
-<?php
-error_reporting(E_ALL);
-$xmlfile = 'ext/xslt/tests/test.xml';
-$xslfile = 'ext/xslt/tests/param.xsl';
-$xmldata = @implode('', @file($xmlfile));
-$xslsheet = @implode('', @file($xslfile));
-
-/*
- * Tested on a Cyrix 200MMX/128MB took 2 secs. Should be a reasonable margin.
- *
- * It's not meant as an actual speed test, but if it's slower than this,
- * there must be something significantly off in the php/sablot/expat trio.
- * Emulation OS's come to mind...
- */
-$want_time = 6;
-
-function make_param()
-{
-       $ret_val = '';
-       $numchars = mt_rand(2,16);
-       $illegal = array(0,256,512);
-       for($i=0;$i<$numchars;$i++)
-       {
-               $char=0;
-               while(in_array($char, $illegal))
-               {
-                       $char .= mt_rand(32, 512);
-               }
-               $ret_val .= chr($char);
-       }
-
-       return utf8_encode($ret_val);
-}
-
-function decode($string)
-{
-       $ret_val = '';
-       for($i=0; $i<strlen($string);$i++)
-       {
-               $ret_val .= ord(substr($string,$i,1)) . " ";
-       }
-       return $ret_val;
-}
-
-
-$xh = xslt_create();
-
-$t1 = time();
-for ($i=0; $i<50; $i++)
-{
-       $val = make_param();
-       $result = xslt_process($xh, $xmlfile, $xslfile, NULL, NULL, array('insertion' => $val));
-       if(!$result or $result != utf8_decode($val))
-               print "Failed $i / ".utf8_decode($val).": $result\n\tDecode: " . decode(utf8_decode($val)) . "\n" ;
-}
-print "OK\n";
-xslt_free($xh);
-$t2 = time();
-$op_time = $t2 - $t1;
-if($op_time > $want_time)
-       print "This test took more than $want_time seconds. Either you have a very slow / busy machine, or there's something very wrong with the speed. Your time: $op_time";
-?>
---EXPECT--
-OK
diff --git a/ext/xslt/tests/xslt_set_object.phpt b/ext/xslt/tests/xslt_set_object.phpt
deleted file mode 100644 (file)
index fdc0291..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
---TEST--
-xslt_set_object function
---SKIPIF--
-<?php
-include("skipif.inc");
-if(!function_exists('xslt_set_object')) {
-       die("skip function xslt_set_object() not available");
-}
-?>
---INI--
-magic_quotes_runtime=0
---FILE--
-<?php
-error_reporting(E_ALL);
-class XSLTTester
-{
-       var $_success = false;
-       var $_success2 = false;
-
-       function XSLTTester()
-       {}
-       
-       // this function will register this object as the
-       // callback object.
-       function test1($xmlfile,$xslfile)
-       {
-               $xh = xslt_create();
-               xslt_set_object($xh,$this);
-               $handlers = array('get_all'=> 'handle_getall');
-               xslt_set_scheme_handlers($xh,$handlers);
-               $res = xslt_process($xh,$xmlfile,$xslfile);
-               xslt_free($xh);
-               return 1;
-       }
-
-       // this function will pass this object as in set_scheme_handler
-       function test2($xmlfile,$xslfile)
-       {
-               $xh = xslt_create();
-               $handlers = array('get_all'=> array(&$this,'handle_getall2'));
-               xslt_set_scheme_handlers($xh,$handlers);
-               $res = xslt_process($xh,$xmlfile,$xslfile);
-               xslt_free($xh);
-               return 1;
-       }
-       function handle_getall($xh,$scheme,$rest)
-       {
-               $this->_success = true;
-               $rest = substr($rest,2);
-               return implode('', file('ext/xslt/tests/'.$rest));
-       }
-       function handle_getall2($xh,$scheme,$rest)
-       {
-               $this->_success2 = true;
-               $rest = substr($rest,2);
-               return implode('', file('ext/xslt/tests/'.$rest));
-       }
-       function testSucceeded()
-       {
-               return $this->_success;
-       }
-       function test2Succeeded()
-       {
-               return $this->_success2;
-       }
-}
-
-$xmlfile = 'ext/xslt/tests/test.xml';
-$xslfile = 'ext/xslt/tests/xslt_set_object.xsl';
-
-$testobj = new XSLTTester();
-$testobj->test1($xmlfile,$xslfile);
-
-$testobj->test2($xmlfile,$xslfile);
-
-if ($testobj->testSucceeded())
-       print "OK\n";
-else
-       print "FAILED\n";
-
-if ($testobj->test2Succeeded())
-       print "OK\n";
-else
-       print "FAILED\n";
-       
-?>
---EXPECT--
-OK
-OK
diff --git a/ext/xslt/tests/xslt_set_object.xsl b/ext/xslt/tests/xslt_set_object.xsl
deleted file mode 100644 (file)
index 9618f42..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:import href="http://param.xsl" />
-</xsl:stylesheet>
diff --git a/ext/xslt/tests/xslt_set_scheme_handlers-001.phpt b/ext/xslt/tests/xslt_set_scheme_handlers-001.phpt
deleted file mode 100644 (file)
index c8b7b23..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
---TEST--
-Set a non-existing scheme handler
---SKIPIF--
-<?php include("skipif.inc"); ?>
---FILE--
-<?php
-function bar()
-{
-       return 1;
-}
-$xh = xslt_create();
-$xmlstring = '<foo><barred /></foo>';
-$xslstring = '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/1999/XSL/Transform"><xsl:for-each select="/"><xsl:value-of select="document(\'bogus://foo\')" /></xsl:for-each></xsl:stylesheet>';
-xslt_set_scheme_handlers($xh, array('get_all' => 'foo'));
-$result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, array('/_xml' => $xmlstring, '/_xsl' => $xslstring));
-xslt_free($xh);
-echo("OK");
-?>
---EXPECT--
-OK
diff --git a/ext/xslt/tests/xslt_set_scheme_handlers-002.phpt b/ext/xslt/tests/xslt_set_scheme_handlers-002.phpt
deleted file mode 100644 (file)
index 3658b37..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
---TEST--
-Override Sablotron file handler
---SKIPIF--
-<?php
-include("skipif.inc");
-if(!defined("XSLT_SABOPT_FILES_TO_HANDLER")) {
-       die("skip Sab CVS > 20021031 needed");
-}
-?>
---INI--
-magic_quotes_runtime=0
---FILE--
-<?php
-function handle_files_all($xh, $proto, $rest_uri)
-{
-       $error = "Cannot resolve $proto:$rest_uri on handle $xh";
-
-       if($proto != 'file')
-               return $error;
-
-       $rest_uri = substr($rest_uri, 2); // strip protocol separators //
-       if(substr($rest_uri, 0, 1) == '/')
-       {
-               return (file_exists($rest_uri)) ? implode('', file($rest_uri)) : $error;
-       }
-       else
-       {
-               $f = dirname(__FILE__) . '/' . $rest_uri;
-               return (file_exists($f)) ? implode('', file($f)) : $error;
-       }
-}
-
-$xh = xslt_create();
-xslt_setopt($xh, XSLT_SABOPT_FILES_TO_HANDLER);
-$xmlstring='<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE qa SYSTEM "file://qa.dtd">
-<qa>
-       <test type="simple">PHP QA</test>
-</qa>';
-$xslstring='<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-       <xsl:output method="text" omit-xml-declaration="yes" encoding="ISO-8859-1" />
-       <xsl:param name="insertion">Test failed</xsl:param>
-       <xsl:template match="/qa">
-               <xsl:apply-templates select="test" />
-       </xsl:template>
-       <xsl:template match="test">
-               <xsl:value-of select="concat(@type, \': \', .)" />
-       </xsl:template>
-</xsl:stylesheet>';
-xslt_set_scheme_handlers($xh, array('get_all' => 'handle_files_all'));
-$result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, array('/_xml' => $xmlstring, '/_xsl' => $xslstring));
-echo $result;
-xslt_free($xh);
-?>
---EXPECT--
-simple: PHP QA
diff --git a/ext/xslt/tests/xslt_set_scheme_handlers-003.phpt b/ext/xslt/tests/xslt_set_scheme_handlers-003.phpt
deleted file mode 100644 (file)
index c5bca5c..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
---TEST--
-Core dump when returning FALSE in a handler
---SKIPIF--
-<?php
-include("skipif.inc");
-if(!defined("XSLT_SABOPT_FILES_TO_HANDLER")) {
-       die("skip Sablotron CVS > 20021031 needed");
-}
-?>
---INI--
-magic_quotes_runtime=0
---FILE--
-<?php
-function handle_files_all($xh, $proto, $rest_uri)
-{
-       return FALSE;
-}
-
-$xh = xslt_create();
-xslt_setopt($xh, XSLT_SABOPT_FILES_TO_HANDLER);
-$xmlstring='<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE qa SYSTEM "file://qa.dtd">
-<qa>
-       <test type="simple">PHP QA</test>
-</qa>';
-$xslstring='<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-       <xsl:output method="text" omit-xml-declaration="yes" encoding="ISO-8859-1" />
-       <xsl:param name="insertion">Test failed</xsl:param>
-       <xsl:template match="/qa">
-               <xsl:apply-templates select="test" />
-       </xsl:template>
-       <xsl:template match="test">
-               <xsl:value-of select="concat(@type, \': \', .)" />
-       </xsl:template>
-</xsl:stylesheet>';
-xslt_set_scheme_handlers($xh, array('get_all' => 'handle_files_all'));
-/* This is intended to be silent!
- * The result is known to be invalid, but if it doesn't core dump, the test
- * has succeeded. */
-$result = @xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, array('/_xml' => $xmlstring, '/_xsl' => $xslstring));
-echo "OK";
-xslt_free($xh);
-?>
---EXPECT--
-OK
-
diff --git a/ext/xslt/tests/xslt_setopt.phpt b/ext/xslt/tests/xslt_setopt.phpt
deleted file mode 100644 (file)
index ce45c46..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
---TEST--
-xslt_setopt function and public entities
---SKIPIF--
-<?php
-include("skipif.inc");
-if(!function_exists('xslt_setopt')) {
-       die("skip function xslt_setopt() is not available\n");
-}
-?>
---INI--
-magic_quotes_runtime=0
---FILE--
-<?php
-error_reporting(E_ALL);
-$xmlfile = dirname(__FILE__).'/public.xml';
-$xslfile = dirname(__FILE__).'/args.xsl';
-
-$xh = xslt_create();
-// Tell Sablotron to process public entities
-xslt_setopt($xh, XSLT_SABOPT_PARSE_PUBLIC_ENTITIES);
-
-$result = xslt_process($xh, $xmlfile, $xslfile);
-print "$result\n";
-
-$xslstring = implode('', file($xslfile));
-$xslstring = str_replace('method="text"', 'method="html"', $xslstring);
-$xslstring = str_replace('<xsl:value-of select="." />', '<html><head><title>foo</title></head><body><p><xsl:value-of select="." /></p></body></html>', $xslstring);
-// DEBUG: print $xslstring;
-
-xslt_setopt($xh, XSLT_SABOPT_PARSE_PUBLIC_ENTITIES | XSLT_SABOPT_DISABLE_ADDING_META);
-var_dump(xslt_process($xh, $xmlfile, 'arg:/_xsl', NULL, array('/_xsl' => $xslstring)));
-
-
-xslt_setopt($xh, XSLT_SABOPT_PARSE_PUBLIC_ENTITIES);
-var_dump(xslt_process($xh, $xmlfile, 'arg:/_xsl', NULL, array('/_xsl' => $xslstring)));
-// DEBUG: print "$result_meta\n";
-
-xslt_free($xh);
-?>
---EXPECT--
-PHP QA®
-string(95) "<html>
-  <head>
-    <title>foo</title>
-  </head>
-  <body>
-    <p>PHP QA®</p>
-  </body>
-</html>
-"
-string(172) "<html>
-  <head>
-    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
-    <title>foo</title>
-  </head>
-  <body>
-    <p>PHP QA®</p>
-  </body>
-</html>
-"
diff --git a/ext/xslt/xslt.c b/ext/xslt/xslt.c
deleted file mode 100644 (file)
index d92e3a2..0000000
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
-   +----------------------------------------------------------------------+
-   | PHP Version 4                                                        |
-   +----------------------------------------------------------------------+
-   | Copyright (c) 1997-2003 The PHP Group                                |
-   +----------------------------------------------------------------------+
-   | This source file is subject to version 3.0 of the PHP license,       |
-   | that is bundled with this package in the file LICENSE, and is        |
-   | available through the world-wide-web at the following url:           |
-   | http://www.php.net/license/3_0.txt.                                  |
-   | If you did not receive a copy of the PHP license and are unable to   |
-   | obtain it through the world-wide-web, please send a note to          |
-   | license@php.net so we can mail you a copy immediately.               |
-   +----------------------------------------------------------------------+
-   | Author: Sterling Hughes <sterling@php.net>                           |
-   +----------------------------------------------------------------------+
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "php.h"
-#include "php_xslt.h"
-
-#if HAVE_XSLT
-
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-
-#define XSLT_DEBUG 0
-
-/* {{{ xslt_debug() 
-   Output a debug message if debugging is enabled */
-extern void xslt_debug(char *function_name, char *format, ...)
-{
-#if DEBUG
-       va_list argv;
-       char    buffer[1024];
-
-    va_start(argv, format);
-       vsnprintf(buffer, sizeof(buffer) - 1, format, argv);
-    va_end(argv);
-
-       buffer[sizeof(buffer) - 1] = '\0';
-
-       php_printf("<b>XSLT Debug</b>: %s: %s<br />\n", 
-                  function_name, buffer);
-#endif
-}
-/* }}} */
-
-/* {{{ find_xslt_argument()
-   Find and return an xslt argument from the argument buffer */
-static char *_find_xslt_argument(const char **argv, const char *key)
-{
-       char  **ptr;                  /* Pointer to the passed char ** array */
-       char   *return_value = NULL;  /* Value to return from the function */
-
-    if (! argv)
-        return NULL;
-    
-       /* Loop through the array searching for the value */
-       ptr = (char **) argv;
-       while (*ptr) {
-               /* If we have a match, save the value and exit out */
-               if (! strcmp(*ptr, key)) {
-                       return_value = estrdup(*ptr);
-                       break;
-               }
-
-               ++ptr;
-       }
-
-       return return_value;
-}
-/* }}} */
-
-/* {{{ xslt_make_array() 
-   Make an XSLT array (char **) from a zval array (HashTable *) */
-extern void xslt_make_array(zval **zarr, char ***carr)
-{
-       zval      **current;
-       HashTable  *arr;
-       int         idx = 0;
-       TSRMLS_FETCH();
-
-       /* Skip a warning, when 'NULL' is provided as argument */
-       if ( Z_TYPE_PP(zarr) == IS_NULL)
-               return;
-
-       arr = HASH_OF(*zarr);
-       if (! arr) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid argument or parameter array");
-               return;
-       }
-
-       *carr = emalloc(((zend_hash_num_elements(arr) * 2) + 1) * sizeof(char *));
-
-       for (zend_hash_internal_pointer_reset(arr);
-            zend_hash_get_current_data(arr, (void **) &current) == SUCCESS;
-            zend_hash_move_forward(arr)) {
-               char  *string_key = NULL;
-               ulong  num_key;         
-               int    type;
-
-               SEPARATE_ZVAL(current);
-               convert_to_string_ex(current);
-
-               type = zend_hash_get_current_key(arr, &string_key, &num_key, 0);
-               if (type == HASH_KEY_IS_LONG) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid key value for argument or parameter array");
-                       /* Make the next index NULL, so it signals the end of the array
-                               this will protect against invalid arrays, like:
-                               array('foo'=>'bar', 'foobarred', 'oops') */
-                       (*carr)[idx] = NULL;
-                       return;
-               }
-
-               (*carr)[idx++] = estrdup(string_key);
-               (*carr)[idx++] = estrndup(Z_STRVAL_PP(current), Z_STRLEN_PP(current));
-       }
-
-       (*carr)[idx] = NULL;
-}
-/* }}} */
-
-/* {{{ xslt_free_array()
-   Free an xslt array built by xslt_make_array() */
-extern void xslt_free_array(char **arr)
-{
-       char **ptr = arr;
-
-       while (*ptr != NULL) {
-               efree(*ptr);
-               ptr++;
-       }
-
-       efree(arr);
-}
-/* }}} */
-
-/* {{{ xslt_parse_arguments()
-   Parse an XSLT argument buffer */
-extern xslt_args *xslt_parse_arguments(char  *xml, 
-                                       char  *xsl, 
-                                       char  *result, 
-                                       char **argv)
-{
-       xslt_args *return_value;  /* The value to return from the function */
-
-       return_value = emalloc(sizeof(xslt_args));
-
-       /* The xml argument */
-       if (! strncasecmp(xml, "arg:", 4)) {
-               char *key = xml + 5;
-
-               return_value->xml.type = XSLT_IS_DATA;
-               return_value->xml.ptr  = _find_xslt_argument((const char **) argv, 
-                                                            (const char *)  key);
-       }
-       else {
-               return_value->xml.type = XSLT_IS_FILE;
-               return_value->xml.ptr  = estrdup(xml);
-       }
-
-       /* The xslt arguments */
-       if (! strncasecmp(xsl, "arg:", 4)) {
-               char *key = xsl + 5;
-
-               return_value->xsl.type = XSLT_IS_DATA;
-               return_value->xsl.ptr  = _find_xslt_argument((const char **) argv, 
-                                                            (const char *)  key);
-       }
-       else {
-               return_value->xsl.type = XSLT_IS_FILE;
-               return_value->xsl.ptr  = estrdup(xsl);
-       }
-
-       /* The result argument */
-       if (! strncasecmp(result, "arg:", 4)) {
-               char *key = result + 5;
-
-               return_value->result.type = XSLT_IS_DATA;
-               return_value->result.ptr  = _find_xslt_argument((const char **) argv, 
-                                                               (const char *)  key);
-       }
-       else {
-               return_value->result.type = XSLT_IS_FILE;
-               return_value->result.ptr  = estrdup(result);
-       }
-
-       return return_value;
-}
-/* }}} */
-
-/* {{{ free_xslt_arguments()
-   Free's an XSLT argument list returned from parse_xslt_arguments() */
-extern void xslt_free_arguments(xslt_args *to_free)
-{
-       if (to_free->xml.ptr) {
-               efree(to_free->xml.ptr);
-       }
-       
-       if (to_free->xsl.ptr) {
-               efree(to_free->xsl.ptr);
-       }
-       
-       if (to_free->result.ptr) {
-               efree(to_free->result.ptr);
-       }
-       
-       efree(to_free);
-}
-/* }}} */
-
-/* {{{ call_xslt_function()
-   Call an XSLT handler */
-extern void xslt_call_function(char *name, 
-                               zval *function, 
-                               zval *object,
-                               int argc, 
-                               zval **user_args, 
-                               zval **retval)
-{
-       zval   ***argv;      /* Argument container, maps around for call_user_function_ex() */
-       int       error;     /* Error container */
-       int       idx;       /* Idx, when looping through and free'ing the arguments */
-       TSRMLS_FETCH();      /* For TS mode, fetch the executor globals */
-
-       argv = emalloc(argc * sizeof(zval **));
-       for (idx = 0; idx < argc; idx++) {
-               argv[idx] = &user_args[idx];
-       }
-       
-
-       /* Call the function (with object when appropriate)*/
-       if (object == NULL)
-       {
-               error = call_user_function_ex(EG(function_table),
-                                             NULL, function,
-                                             retval, argc, argv, 0, NULL TSRMLS_CC);
-       }
-       else
-       {
-               error = call_user_function_ex(EG(function_table),
-                                             &object, function,
-                                             retval, argc, argv, 0, NULL TSRMLS_CC);
-       }
-
-       if (error == FAILURE) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot call the %s handler: %s", 
-                         name, Z_STRVAL_P(function));
-       }
-
-       /* Cleanup arguments */
-       for (idx = 0; idx < argc; idx++) {
-               /* Decrease refcount and free if refcount is <= 0 */
-               zval_ptr_dtor(argv[idx]);
-       }
-
-       efree(argv);
-}
-/* }}} */
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/xslt/xslt.dsp b/ext/xslt/xslt.dsp
deleted file mode 100644 (file)
index 80ef1d6..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-# Microsoft Developer Studio Project File - Name="xslt" - Package Owner=<4>\r
-# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
-# ** DO NOT EDIT **\r
-\r
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102\r
-\r
-CFG=xslt - Win32 Debug_TS\r
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
-!MESSAGE use the Export Makefile command and run\r
-!MESSAGE \r
-!MESSAGE NMAKE /f "xslt.mak".\r
-!MESSAGE \r
-!MESSAGE You can specify a configuration when running NMAKE\r
-!MESSAGE by defining the macro CFG on the command line. For example:\r
-!MESSAGE \r
-!MESSAGE NMAKE /f "xslt.mak" CFG="xslt - Win32 Debug_TS"\r
-!MESSAGE \r
-!MESSAGE Possible choices for configuration are:\r
-!MESSAGE \r
-!MESSAGE "xslt - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")\r
-!MESSAGE "xslt - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")\r
-!MESSAGE \r
-\r
-# Begin Project\r
-# PROP AllowPerConfigDependencies 0\r
-# PROP Scc_ProjName ""\r
-# PROP Scc_LocalPath ""\r
-CPP=cl.exe\r
-MTL=midl.exe\r
-RSC=rc.exe\r
-\r
-!IF  "$(CFG)" == "xslt - Win32 Release_TS"\r
-\r
-# PROP BASE Use_MFC 0\r
-# PROP BASE Use_Debug_Libraries 0\r
-# PROP BASE Output_Dir "Release_TS"\r
-# PROP BASE Intermediate_Dir "Release_TS"\r
-# PROP BASE Target_Dir ""\r
-# PROP Use_MFC 0\r
-# PROP Use_Debug_Libraries 0\r
-# PROP Output_Dir "Release_TS"\r
-# PROP Intermediate_Dir "Release_TS"\r
-# PROP Ignore_Export_Lib 0\r
-# PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XSLT_EXPORTS" /YX /FD /c\r
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\main" /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\win32" /I "C:\Program Files\Sablot-0.96\include" /D "COMPILE_DL_XSLT" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_XSLT=1 /D "HAVE_SABLOT_BACKEND" /D "HAVE_SABLOT_SET_ENCODING" /YX /FD /c\r
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
-# ADD BASE RSC /l 0x407 /d "NDEBUG"\r
-# ADD RSC /l 0x407 /d "NDEBUG"\r
-BSC32=bscmake.exe\r
-# ADD BASE BSC32 /nologo\r
-# ADD BSC32 /nologo\r
-LINK32=link.exe\r
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386\r
-# ADD LINK32 kernel32.lib php4ts.lib sablot.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_xslt.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" /libpath:"C:\Program Files\Sablot-0.96\lib"\r
-\r
-!ELSEIF  "$(CFG)" == "xslt - Win32 Debug_TS"\r
-\r
-# PROP BASE Use_MFC 0\r
-# PROP BASE Use_Debug_Libraries 1\r
-# PROP BASE Output_Dir "Debug_TS"\r
-# PROP BASE Intermediate_Dir "Debug_TS"\r
-# PROP BASE Target_Dir ""\r
-# PROP Use_MFC 0\r
-# PROP Use_Debug_Libraries 1\r
-# PROP Output_Dir "Debug_TS"\r
-# PROP Intermediate_Dir "Debug_TS"\r
-# PROP Ignore_Export_Lib 0\r
-# PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XSLT_EXPORTS" /YX /FD /GZ /c\r
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /D ZEND_DEBUG=1 /D COMPILE_DL_XSLT=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_XSLT=1 /D "HAVE_SABLOT_BACKEND" /D "HAVE_SABLOT_SET_ENCODING" /YX /FD /GZ /c\r
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32\r
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32\r
-# ADD BASE RSC /l 0x407 /d "_DEBUG"\r
-# ADD RSC /l 0x407 /d "_DEBUG"\r
-BSC32=bscmake.exe\r
-# ADD BASE BSC32 /nologo\r
-# ADD BSC32 /nologo\r
-LINK32=link.exe\r
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept\r
-# ADD LINK32 kernel32.lib php4ts_debug.lib sablot.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"..\..\Debug_TS/php_xslt.dll" /pdbtype:sept /libpath:"..\..\Debug_TS"\r
-\r
-!ENDIF \r
-\r
-# Begin Target\r
-\r
-# Name "xslt - Win32 Release_TS"\r
-# Name "xslt - Win32 Debug_TS"\r
-# Begin Group "Source Files"\r
-\r
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
-# Begin Source File\r
-\r
-SOURCE=.\sablot.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\xslt.c\r
-# End Source File\r
-# End Group\r
-# Begin Group "Header Files"\r
-\r
-# PROP Default_Filter "h;hpp;hxx;hm;inl"\r
-# Begin Source File\r
-\r
-SOURCE=.\php_sablot.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\php_xslt.h\r
-# End Source File\r
-# End Group\r
-# End Target\r
-# End Project\r