Home modules.gotpike.org
Username: Password: [Create Account]
[Forgot Password?]

Modules

ADT
Database
GTK2
GUI
IP
PiJAX
Public
Sql
Stdio
Subversion
System
Tools
Xosd
lua
v4l2
wx

Recent Changes

Public.Parser.XML2 1.50
Public.ZeroMQ 1.1
Public.Template.Mustache 1.0
Public.Protocols.XMPP 1.4
Sql.Provider.jdbc 1.0

Popular Downloads

Public.Parser.JSON2 1.0
Public.Parser.JSON 0.2
GTK2 2.23
Public.Web.FCGI 1.8
Public.Parser.XML2 1.48


Module Information
Public.Parser.XML2
Viewing contents of Public_Parser_XML2-1.20/XML2.c

/* Generated from "XML2.cmod" by precompile.pike
 *
 * Do NOT edit this file.
 */

#undef PRECOMPILE_API_VERSION
#define PRECOMPILE_API_VERSION 2


#line 1 "XML2.cmod"
/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * $Id: XML2.cmod,v 1.77 2005/07/14 14:08:21 hww3 Exp $
 */

/*
 * File licensing and authorship information block.
 *
 * Version: MPL 1.1/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Initial Developer of the Original Code is
 *
 * Bill Welliver 
 *
 * Portions created by the Initial Developer are Copyright (C) Bill Welliver
 * All Rights Reserved.
 *
 * Contributor(s):
 *
 * Alternatively, the contents of this file may be used under the terms of
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of the LGPL, and not to allow others to use your version
 * of this file under the terms of the MPL, indicate your decision by
 * deleting the provisions above and replace them with the notice
 * and other provisions required by the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL or the LGPL.
 *
 * Significant Contributors to this file are:
 *
 *
 */

#include "xml2.h"

  int docloader_num = -1;

/*! @module Public
 */

/*! @module Parser
 */

/*! @module XML2
 */

/*
  
    start of Public.Parser.XML2 module functions

*/

static void
xmlDetectSAX2(xmlParserCtxtPtr ctxt) {
    if (ctxt == NULL) return;
#ifdef LIBXML_SAX1_ENABLED 
    if ((ctxt->sax) &&  (ctxt->sax->initialized == XML_SAX2_MAGIC) &&
        ((ctxt->sax->startElementNs != NULL) ||
         (ctxt->sax->endElementNs != NULL))) ctxt->sax2 = 1;
#else
    ctxt->sax2 = 1;
#endif /* LIBXML_SAX1_ENABLED */
 
    ctxt->str_xml = xmlDictLookup(ctxt->dict, BAD_CAST "xml", 3);
    ctxt->str_xmlns = xmlDictLookup(ctxt->dict, BAD_CAST "xmlns", 5);
    ctxt->str_xml_ns = xmlDictLookup(ctxt->dict, XML_XML_NAMESPACE, 36);
    if ((ctxt->str_xml==NULL) || (ctxt->str_xmlns==NULL) ||
                (ctxt->str_xml_ns == NULL)) {
        xmlErrMemory(ctxt, NULL);
    }
}



#undef var_docloader_defined
#define var_docloader_defined

#undef var_object_data_defined
#define var_object_data_defined

#undef THIS
#define THIS ((struct _struct *)(Pike_interpreter.frame_pointer->current_storage))

#undef THIS_
#define THIS_ ((struct _struct *)(Pike_interpreter.frame_pointer->current_storage))

#undef OBJ2_
#define OBJ2_(o) ((struct _struct *)(o->storage+_storage_offset))

#undef GET__STORAGE
#define GET__STORAGE ((struct _struct *)(o->storage+_storage_offset)
static ptrdiff_t _storage_offset;
struct _struct {

#ifdef var_docloader_defined
  struct svalue docloader;

#endif /* var_docloader_defined */

#ifdef var_object_data_defined
#line 101 "XML2.cmod"
PARSER_OBJECT_DATA * object_data;
#endif /* var_object_data_defined */
};
#define f_create_defined
ptrdiff_t f_create_fun_num = 0;
void f_create(INT32 args) {
#line 103 "XML2.cmod"
if(args != 0) wrong_number_of_args_error("create",args,0);
{
  THIS->object_data->docloader_num = docloader_num;

}

}
/*! @decl array(Node) select_xpath_nodes(string xpath, object node)
 *!
 *! selects nodes based on an XPath query and returns the result.
 */
#define f_select_xpath_nodes_defined
ptrdiff_t f_select_xpath_nodes_fun_num = 0;
void f_select_xpath_nodes(INT32 args) {
#line 113 "XML2.cmod"
struct pike_string * xpath;
#line 113 "XML2.cmod"
struct object * node;
#line 113 "XML2.cmod"
if(args != 2) wrong_number_of_args_error("select_xpath_nodes",args,2);
#line 113 "XML2.cmod"
if(Pike_sp[0-2].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("select_xpath_nodes",1,"string");
#line 113 "XML2.cmod"
debug_malloc_pass(xpath=Pike_sp[0-2].u.string);
#line 113 "XML2.cmod"
if(Pike_sp[1-2].type != PIKE_T_OBJECT) SIMPLE_BAD_ARG_ERROR("select_xpath_nodes",2,"object");
#line 113 "XML2.cmod"
debug_malloc_pass(node=Pike_sp[1-2].u.object);
{
  xmlXPathContextPtr xpathCtx;
  xmlXPathObjectPtr xpathObj;
  xmlNodeSetPtr set;
  xmlNodePtr xn;
  struct object * o;
  int num_nodes = 0;

  CHECK_NODE_PASSED(node);
printf("xpath\n");
  if(OBJ2_NODE(node)->object_data->node == NULL)
  { 
    pop_n_elems(2);
    Pike_error("Node not initialized.\n");
  }

  xpathCtx = xmlXPathNewContext(OBJ2_NODE(node)->object_data->node->doc);
  if(xpathCtx == NULL)
  {
    pop_n_elems(2);
    Pike_error("Unable to create new XPath context.\n");
  }
  xpathObj = xmlXPathEvalExpression((xmlChar *)xpath->str, xpathCtx);
  if(xpathObj == NULL) {  
    pop_n_elems(2);
    xmlXPathFreeContext(xpathCtx);
    Pike_error("Unable to evaluate the XPath expression.\n");
  }

  /* now we should generate an array from the node set. */
  set = xpathObj->nodesetval;


  if(set == NULL)
  {
printf("no nodes!\n");
    pop_n_elems(2);
    push_int(0);
    xmlXPathFreeContext(xpathCtx);
    xmlXPathFreeObject(xpathObj);
    return;
  }  

  pop_n_elems(2);

  if(set->nodeNr > 0)
  {
  xn = set->nodeTab[0];
    if(xn != NULL && set->nodeNr > 0) do
    {
      struct Node_struct * ns;
      NODE_OBJECT_DATA * od;
printf("lookin at a node.\n");
      apply(Pike_fp->current_object, "Node", 0);
      ns = OBJ2_NODE((Pike_sp[0-1].u.object));
      od = (NODE_OBJECT_DATA *)(ns->object_data);

      od->node=xn;
      od->refs = OBJ2_NODE(node)->object_data->refs;
    
      (* od->refs)++;

      num_nodes++;
      xn = set->nodeTab[num_nodes];
    } 
    while (((num_nodes +1) <= set->nodeNr) && xn != NULL);

printf("num_nodes: %d\n", num_nodes);

    if(num_nodes>0) {
      f_aggregate(num_nodes);
    }
  }
  else push_int(0);

  xmlXPathFreeContext(xpathCtx);
  xmlXPathFreeObject(xpathObj);

  return;
}

}
/*! @decl void set_xslt_docloader(function f) 
 *!
 *! sets the xslt loader function. this is global for the process.
 *!
 *! the callout should have the following signature:
 *!
 *!  Node f(string uri, int options, int type)
 *!
 *!  where: 
 *!    uri is the URI of the document to load
 *!    options are a set of xmlParserOption
 *!    the xsltLoadType indicating the kind of loading required
 */
#define f_set_xslt_docloader_defined
ptrdiff_t f_set_xslt_docloader_fun_num = 0;
void f_set_xslt_docloader(INT32 args) {
#line 208 "XML2.cmod"
struct svalue * f;
#line 208 "XML2.cmod"
if(args != 1) wrong_number_of_args_error("set_xslt_docloader",args,1);
#line 208 "XML2.cmod"
if(Pike_sp[0-1].type != PIKE_T_FUNCTION) SIMPLE_BAD_ARG_ERROR("set_xslt_docloader",1,"function");
#line 208 "XML2.cmod"
f=Pike_sp+0-1; dmalloc_touch_svalue(Pike_sp+0-1);
{
  assign_svalue(&(THIS->docloader), f);
#ifdef HAVE_XSLTSETLOADERFUNC
#else
  Pike_error("set_docloader not available. upgrade your libxslt.\n");
#endif
}

}
/*! @decl void clear_xslt_docloader()
 *!
 *! clears the system wide docloader callout, if one was set.
 *!
 */
#define f_clear_xslt_docloader_defined
ptrdiff_t f_clear_xslt_docloader_fun_num = 0;
void f_clear_xslt_docloader(INT32 args) {
#line 222 "XML2.cmod"
if(args != 0) wrong_number_of_args_error("clear_xslt_docloader",args,0);
{
  push_int(0);
  assign_svalue(&(THIS->docloader), Pike_sp-1);
  pop_stack();
#ifdef HAVE_XSLTSETLOADERFUNC
#else
  Pike_error("set_docloader not available. upgrade your libxslt.\n");
#endif
}

}
/*! @decl void set_xml_parser_options(int options)
 *!
 *! sets parser options. 
 *! 
 *! @param options
 *!   a bitwise or of @[Public.Parser.XML2.Constants] options 
 *!   where valid options start with PARSE_. 
 */
#define f_set_xml_parser_options_defined
ptrdiff_t f_set_xml_parser_options_fun_num = 0;
void f_set_xml_parser_options(INT32 args) {
#line 241 "XML2.cmod"
INT_TYPE options;
#line 241 "XML2.cmod"
if(args != 1) wrong_number_of_args_error("set_xml_parser_options",args,1);
#line 241 "XML2.cmod"
if(Pike_sp[0-1].type != PIKE_T_INT) SIMPLE_BAD_ARG_ERROR("set_xml_parser_options",1,"int");
options=Pike_sp[0-1].u.integer;
#line 242 "XML2.cmod"
{
  THIS->object_data->xml_parser_options = options;
  pop_stack();
}

}
/*! @decl void set_html_parser_options(int options)
 *!
 *! sets parser options. 
 *! 
 *! @param options
 *!   a bitwise or of @[Public.Parser.XML2.Constants] options 
 *!   where valid options start with PARSE_. 
 */
#define f_set_html_parser_options_defined
ptrdiff_t f_set_html_parser_options_fun_num = 0;
void f_set_html_parser_options(INT32 args) {
#line 255 "XML2.cmod"
INT_TYPE options;
#line 255 "XML2.cmod"
if(args != 1) wrong_number_of_args_error("set_html_parser_options",args,1);
#line 255 "XML2.cmod"
if(Pike_sp[0-1].type != PIKE_T_INT) SIMPLE_BAD_ARG_ERROR("set_html_parser_options",1,"int");
options=Pike_sp[0-1].u.integer;
#line 256 "XML2.cmod"
{
  THIS->object_data->html_parser_options = options;
  pop_stack();
}

}
/*! @decl int substituteEntitiesDefault(int def)
 */
#define f_substituteEntitiesDefault_defined
ptrdiff_t f_substituteEntitiesDefault_fun_num = 0;
void f_substituteEntitiesDefault(INT32 args) {
#line 263 "XML2.cmod"
INT_TYPE def;
#line 263 "XML2.cmod"
if(args != 1) wrong_number_of_args_error("substituteEntitiesDefault",args,1);
#line 263 "XML2.cmod"
if(Pike_sp[0-1].type != PIKE_T_INT) SIMPLE_BAD_ARG_ERROR("substituteEntitiesDefault",1,"int");
def=Pike_sp[0-1].u.integer;
#line 264 "XML2.cmod"
{
  def = def ? 1 : 0;

  pop_n_elems(args);

  xmlSubstituteEntitiesDefault(def);

  push_int(def);
}

}
#line 274 "XML2.cmod"
/* @decl int keepBlanksDefault(int def)
 */
#define f_keepBlanksDefault_defined
ptrdiff_t f_keepBlanksDefault_fun_num = 0;
void f_keepBlanksDefault(INT32 args) {
#line 276 "XML2.cmod"
INT_TYPE def;
#line 276 "XML2.cmod"
if(args != 1) wrong_number_of_args_error("keepBlanksDefault",args,1);
#line 276 "XML2.cmod"
if(Pike_sp[0-1].type != PIKE_T_INT) SIMPLE_BAD_ARG_ERROR("keepBlanksDefault",1,"int");
def=Pike_sp[0-1].u.integer;
#line 277 "XML2.cmod"
{
  def = def ? 1 : 0;

  pop_n_elems(args);

  push_int(xmlKeepBlanksDefault(def));
}

}
/*!  @decl string utf8_to_html(string str)
 *!
 */
#define f_utf8_to_html_defined
ptrdiff_t f_utf8_to_html_fun_num = 0;
void f_utf8_to_html(INT32 args) {
#line 288 "XML2.cmod"
struct pike_string * str;
#line 288 "XML2.cmod"
if(args != 1) wrong_number_of_args_error("utf8_to_html",args,1);
#line 288 "XML2.cmod"
if(Pike_sp[0-1].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("utf8_to_html",1,"string");
#line 288 "XML2.cmod"
debug_malloc_pass(str=Pike_sp[0-1].u.string);
{
  char *html = NULL;
  int outlen, inlen;

  outlen = str->len << 1;
  html = (char*)malloc(outlen + 1);
  if (!html)
    Pike_error("Out of memory");

  inlen = str->len;
  if ( UTF8ToHtml(html, &outlen, str->str, &inlen) < 0 ) {
    free(html);
    Pike_error("Cannot convert to html!");
  }
  html[outlen] = '\0';
  pop_n_elems(args);
  push_text(html);
  free(html);
}


}
/*!  @decl string utf8_to_isolat1(string str)
 *!
 */
#define f_utf8_to_isolat1_defined
ptrdiff_t f_utf8_to_isolat1_fun_num = 0;
void f_utf8_to_isolat1(INT32 args) {
#line 313 "XML2.cmod"
struct pike_string * str;
#line 313 "XML2.cmod"
if(args != 1) wrong_number_of_args_error("utf8_to_isolat1",args,1);
#line 313 "XML2.cmod"
if(Pike_sp[0-1].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("utf8_to_isolat1",1,"string");
#line 313 "XML2.cmod"
debug_malloc_pass(str=Pike_sp[0-1].u.string);
{
  char *html = NULL;
  int outlen, inlen;

  outlen = str->len << 1;
  html = (char*)malloc(outlen + 1);
  if (!html)
    Pike_error("Out of memory");

  inlen = str->len;
  if ( UTF8Toisolat1(html, &outlen, str->str, &inlen) < 0 ) {
    free(html);
    Pike_error("Cannot convert to isolat1!");
  }
  html[outlen] = '\0';
  pop_n_elems(args);
  push_text(html);
  free(html);
}

}
/*! @decl int utf8_check(string str)
 *!
 */
#define f_utf8_check_defined
ptrdiff_t f_utf8_check_fun_num = 0;
void f_utf8_check(INT32 args) {
#line 337 "XML2.cmod"
struct pike_string * str;
#line 337 "XML2.cmod"
if(args != 1) wrong_number_of_args_error("utf8_check",args,1);
#line 337 "XML2.cmod"
if(Pike_sp[0-1].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("utf8_check",1,"string");
#line 337 "XML2.cmod"
debug_malloc_pass(str=Pike_sp[0-1].u.string);
{
  int result;

  result = xmlCheckUTF8(str->str);
  pop_n_elems(args);
  push_int(result);
}

}
/*! @decl array(int) get_encodings()
 *!
 *! gets the list of available character encoders.
 *!
 *! @returns
 *!  an array of available encoder identifiers.
 *!
 */
#define f_get_encodings_defined
ptrdiff_t f_get_encodings_fun_num = 0;
void f_get_encodings(INT32 args) {
#line 354 "XML2.cmod"
if(args != 0) wrong_number_of_args_error("get_encodings",args,0);
{
   int num = 0;
   int cur = 0;
   int upper_limit = 25;
   xmlCharEncodingHandlerPtr encoder;

   for (cur = 0; cur < upper_limit; cur++)
   {
     encoder = xmlGetCharEncodingHandler((xmlCharEncoding)cur);
     if(encoder != NULL)
     {
       push_int(cur);
       num++;
       xmlFree(encoder);
     }
   }
   f_aggregate(num);
   return;  
}

}
/*!  @decl string get_encoding_name(int e)
 *!
 */
#define f_get_encoding_name_defined
ptrdiff_t f_get_encoding_name_fun_num = 0;
void f_get_encoding_name(INT32 args) {
#line 378 "XML2.cmod"
INT_TYPE e;
#line 378 "XML2.cmod"
if(args != 1) wrong_number_of_args_error("get_encoding_name",args,1);
#line 378 "XML2.cmod"
if(Pike_sp[0-1].type != PIKE_T_INT) SIMPLE_BAD_ARG_ERROR("get_encoding_name",1,"int");
e=Pike_sp[0-1].u.integer;
#line 379 "XML2.cmod"
{
  const char * enc = NULL;

  enc = xmlGetCharEncodingName(e);

  if(enc != NULL)
    push_text(enc);

  else 
     push_int(0);
}

}
/*!  @decl string get_encoding_alias(string e)
 *!
 */
#define f_get_encoding_alias_defined
ptrdiff_t f_get_encoding_alias_fun_num = 0;
void f_get_encoding_alias(INT32 args) {
#line 394 "XML2.cmod"
struct pike_string * e;
#line 394 "XML2.cmod"
if(args != 1) wrong_number_of_args_error("get_encoding_alias",args,1);
#line 394 "XML2.cmod"
if(Pike_sp[0-1].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("get_encoding_alias",1,"string");
#line 394 "XML2.cmod"
debug_malloc_pass(e=Pike_sp[0-1].u.string);
{
  const char * enc = NULL;

  enc = xmlGetEncodingAlias(e->str);

  if(enc != NULL)
    push_text(enc);
  else 
     push_int(0);
}

}
/*! @decl string render_xml(Node n)
 *!   Renders a node tree as an XML string. The entire document tree will 
 *!  be rendered. To render a portion of a tree, use @[Node.render_xml].
 *!
 *!   @param n
 *!     a Node object for a given XML document.
 *!
 */
#define f_render_xml_defined
ptrdiff_t f_render_xml_fun_num = 0;
void f_render_xml(INT32 args) {
#line 414 "XML2.cmod"
struct object * n;
#line 414 "XML2.cmod"
if(args != 1) wrong_number_of_args_error("render_xml",args,1);
#line 414 "XML2.cmod"
if(Pike_sp[0-1].type != PIKE_T_OBJECT) SIMPLE_BAD_ARG_ERROR("render_xml",1,"object");
#line 414 "XML2.cmod"
debug_malloc_pass(n=Pike_sp[0-1].u.object);
{
  int dumped;
  xmlChar * buf;
  char * str;
  int bufsize;

  CHECK_NODE_PASSED(n);

/*  check_node_created(); */
  if(OBJ2_NODE(n)->object_data->node == NULL)
  { 
    Pike_error("Node not initialized.\n");
  }

  xmlDocDumpFormatMemory(OBJ2_NODE(n)->object_data->node->doc, &buf, &bufsize, 1);

  if(buf!=NULL)
  {
    str = (char *)xmlStrdup(buf);
    xmlFree(buf);
    push_text(str);
  }  
  else
  {
    push_int(0);
  }
}

}
/*! @decl string render_html(Node n)
 *!   Renders a node tree as an HTML string. The entire document tree will 
 *!  be rendered. To render a portion of a tree, use @[Node.render_html].
 *!
 *!   @param n
 *!     a Node object for a given HTML document.
 *!
 */
#define f_render_html_defined
ptrdiff_t f_render_html_fun_num = 0;
void f_render_html(INT32 args) {
#line 451 "XML2.cmod"
struct object * n;
#line 451 "XML2.cmod"
if(args != 1) wrong_number_of_args_error("render_html",args,1);
#line 451 "XML2.cmod"
if(Pike_sp[0-1].type != PIKE_T_OBJECT) SIMPLE_BAD_ARG_ERROR("render_html",1,"object");
#line 451 "XML2.cmod"
debug_malloc_pass(n=Pike_sp[0-1].u.object);
{
  int dumped;
  xmlChar * buf;
  char * str;
  int bufsize;

  CHECK_NODE_PASSED(n);

/*  check_node_created(); */
  if(OBJ2_NODE(n)->object_data->node == NULL)
  { 
    Pike_error("Node not initialized.\n");
  }

  htmlDocDumpMemory(OBJ2_NODE(n)->object_data->node->doc, &buf, &bufsize, 1);

  if(buf!=NULL)
  {
    str = (char *)xmlStrdup(buf);
    xmlFree(buf);
    push_text(str);
  }  
  else
  {
    push_int(0);
  }
}

}
#line 480 "XML2.cmod"
void my_generic_error(void * userData, xmlErrorPtr error)
{
  char err[255];

  snprintf(err, 255, "Public.Parser.XML error: %d, message: %s", 
             error->level, error->message);
  push_text(err);

  f_werror(1);
}

/*! @decl Node recover_xml(string xml)
 *!   Parse an string containing XML, even if it is not Well Formed.
 *!  @param xml
 *!   String containing XML data to parse.
 *!
 *!  @returns
 *!    a @[Node] object containing the root of the tree.
 */
#define f_parse_xml_force_defined
ptrdiff_t f_parse_xml_force_fun_num = 0;
void f_parse_xml_force(INT32 args) {
#line 499 "XML2.cmod"
struct pike_string * xml;
#line 499 "XML2.cmod"
if(args != 1) wrong_number_of_args_error("parse_xml_force",args,1);
#line 499 "XML2.cmod"
if(Pike_sp[0-1].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("parse_xml_force",1,"string");
#line 499 "XML2.cmod"
debug_malloc_pass(xml=Pike_sp[0-1].u.string);
{
  xmlDocPtr doc;
  xmlNodePtr node;
  struct Node_struct * ns;
  NODE_OBJECT_DATA * od;

  doc = xmlRecoverMemory(xml->str, xml->len);

  if(doc == NULL)
  {
    pop_n_elems(2);
    Pike_error("Unable to parse XML.\n");
  }  

  node = xmlDocGetRootElement(doc);
  if(node == NULL)
  {
    pop_n_elems(2);
    xmlFreeDoc(doc);
    Pike_error("Unable to find Root Node.\n");
  }

  /* ok, we have a parsed file. now let's turn it into a real live pike object. */

  pop_n_elems(2);

  apply(Pike_fp->current_object, "Node", 0);
  
  ns = OBJ2_NODE((Pike_sp[0-1].u.object));
  od = (NODE_OBJECT_DATA *)(ns->object_data);

  od->refs = malloc(sizeof(INT32));
  (* od->refs)=1;
  od->node = node;
}

}
#line 536 "XML2.cmod"
xmlParserInputPtr my_entity_loader(const char * URL, const char * ID,
   xmlParserCtxtPtr context)
{
  printf("request for entity %s\n", URL);
  return NULL; 
}

/*! @decl Node parse_xml(string xml, string|void name, string|void encoding)
 *!   Parse an string containing XML.
 *!  @param xml
 *!   String containing XML data to parse.
 *!  @param name
 *!   String containing name/URI of file.
 *!
 *!  @returns
 *!    a @[Node] object containing the root of the tree.
 */
#define f_parse_xml_1_defined
ptrdiff_t f_parse_xml_1_fun_num = 0;
void f_parse_xml_1(INT32 args) {
#line 553 "XML2.cmod"
struct pike_string * xml;
#line 553 "XML2.cmod"
struct pike_string * name;
#line 553 "XML2.cmod"
struct pike_string * encoding;
#line 553 "XML2.cmod"
if(args != 3) wrong_number_of_args_error("parse_xml",args,3);
#line 553 "XML2.cmod"
if(Pike_sp[0-3].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("parse_xml",1,"string");
#line 553 "XML2.cmod"
debug_malloc_pass(xml=Pike_sp[0-3].u.string);
#line 553 "XML2.cmod"
if(Pike_sp[1-3].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("parse_xml",2,"string");
#line 553 "XML2.cmod"
debug_malloc_pass(name=Pike_sp[1-3].u.string);
#line 553 "XML2.cmod"
if(Pike_sp[2-3].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("parse_xml",3,"string");
#line 553 "XML2.cmod"
debug_malloc_pass(encoding=Pike_sp[2-3].u.string);
{
  xmlDocPtr doc;

  entity_loader = my_entity_loader;

  /*  xmlSetExternalEntityLoader(entity_loader); */

  generic_handler = my_generic_error;
  /* xmlSetStructuredErrorFunc((void *)err_ctx, generic_handler); */

  doc = xmlReadMemory(xml->str, xml->len, name->str, 
                      (const char *)encoding->str, 
                      THIS->object_data->xml_parser_options);

  handle_parsed_tree(doc, args);
}

}
#line 571 "XML2.cmod"
xmlEntityPtr my_xml_getent(void * ctx, const xmlChar * name)
{
    xmlEntityPtr ent;
    
    if(strcmp(name, "boo") != 0)
    {
      printf("somebody else's entity: %s!\n", name);
      return xmlSAX2GetEntity(ctx, name);
     }
    ent = xmlMalloc(sizeof(xmlEntity)); 
    if(ent == NULL) printf("unable to allocate entity storage.\n");
        
    memset(ent, 0, sizeof(xmlEntity));
      
    ent->type = XML_ENTITY_DECL;
    ent->etype = XML_INTERNAL_GENERAL_ENTITY;
    ent->name = xmlStrdup(name);   
    ent->content = xmlStrdup(name);
        
    return ent;

}

#define f_parse_xml_sax_defined
ptrdiff_t f_parse_xml_sax_fun_num = 0;
void f_parse_xml_sax(INT32 args) {
#line 594 "XML2.cmod"
struct pike_string * xml;
#line 594 "XML2.cmod"
struct pike_string * name;
#line 594 "XML2.cmod"
struct pike_string * encoding;
#line 594 "XML2.cmod"
if(args != 3) wrong_number_of_args_error("parse_xml_sax",args,3);
#line 594 "XML2.cmod"
if(Pike_sp[0-3].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("parse_xml_sax",1,"string");
#line 594 "XML2.cmod"
debug_malloc_pass(xml=Pike_sp[0-3].u.string);
#line 594 "XML2.cmod"
if(Pike_sp[1-3].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("parse_xml_sax",2,"string");
#line 594 "XML2.cmod"
debug_malloc_pass(name=Pike_sp[1-3].u.string);
#line 594 "XML2.cmod"
if(Pike_sp[2-3].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("parse_xml_sax",3,"string");
#line 594 "XML2.cmod"
debug_malloc_pass(encoding=Pike_sp[2-3].u.string);
{
  xmlDocPtr doc;
  xmlSAXHandler * sax;
  xmlParserCtxtPtr ctxt;

  ctxt = xmlCreateMemoryParserCtxt(xml->str, xml->len);

  if(ctxt == NULL) Pike_error("unable to allocate context.\n");

  sax = xmlMalloc(sizeof(xmlSAXHandler));
  xmlSAXVersion(sax, 2);
  sax->getEntity = my_xml_getent;  

  if(ctxt->sax != NULL)
    xmlFree(ctxt->sax);

  ctxt->sax = sax;

  xmlDetectSAX2(ctxt);
  ctxt->recovery = 0;
/*  ctxt->replaceEntities = 0; */

  xmlParseDocument(ctxt);
  /*  entity_loader = my_entity_loader; */
  /*  xmlSetExternalEntityLoader(entity_loader); */

  generic_handler = my_generic_error;
  /* xmlSetStructuredErrorFunc((void *)err_ctx, generic_handler); */

  doc = ctxt->myDoc;

   if (sax != NULL)
        ctxt->sax = NULL;
    xmlFreeParserCtxt(ctxt);

  handle_parsed_tree(doc, args);
}

}
#line 633 "XML2.cmod"
void handle_parsed_tree(xmlDocPtr doc, INT32 args)
{
  xmlNodePtr node;
  struct Node_struct * ns;
  NODE_OBJECT_DATA * od;
  char * err_ctx = "parse_xml";

  if(doc == NULL)
  {
    pop_n_elems(args);
    Pike_error("Unable to parse XML.\n");
  }  

  node = xmlDocGetRootElement(doc);
  if(node == NULL)
  {
    pop_n_elems(args);
    xmlFreeDoc(doc);
    Pike_error("Unable to find Root Node.\n");
  }

  /* ok, we have a parsed file. now let's turn it into a real live pike object. */

  pop_n_elems(args);

  apply(Pike_fp->current_object, "Node", 0);
  
  ns = OBJ2_NODE((Pike_sp[0-1].u.object));
  od = (NODE_OBJECT_DATA *)(ns->object_data);

  od->refs = malloc(sizeof(INT32));
  (* od->refs)=1;
  od->node = node;
}

#define f_parse_xml_2_defined
ptrdiff_t f_parse_xml_2_fun_num = 0;
void f_parse_xml_2(INT32 args) {
#line 668 "XML2.cmod"
struct pike_string * xml;
#line 668 "XML2.cmod"
struct pike_string * name;
#line 668 "XML2.cmod"
if(args != 2) wrong_number_of_args_error("parse_xml",args,2);
#line 668 "XML2.cmod"
if(Pike_sp[0-2].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("parse_xml",1,"string");
#line 668 "XML2.cmod"
debug_malloc_pass(xml=Pike_sp[0-2].u.string);
#line 668 "XML2.cmod"
if(Pike_sp[1-2].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("parse_xml",2,"string");
#line 668 "XML2.cmod"
debug_malloc_pass(name=Pike_sp[1-2].u.string);
{
  xmlDocPtr doc;

  entity_loader = my_entity_loader;

  /*  xmlSetExternalEntityLoader(entity_loader); */

  generic_handler = my_generic_error;

  /*xmlSetStructuredErrorFunc((void *)err_ctx, generic_handler); */

  doc = xmlReadMemory(xml->str, xml->len, name->str, 
                      NULL, 
                      THIS->object_data->xml_parser_options);

  handle_parsed_tree(doc, args);
  
}

}
#define f_parse_xml_3_defined
ptrdiff_t f_parse_xml_3_fun_num = 0;
void f_parse_xml_3(INT32 args) {
#line 688 "XML2.cmod"
struct pike_string * xml;
#line 688 "XML2.cmod"
if(args != 1) wrong_number_of_args_error("parse_xml",args,1);
#line 688 "XML2.cmod"
if(Pike_sp[0-1].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("parse_xml",1,"string");
#line 688 "XML2.cmod"
debug_malloc_pass(xml=Pike_sp[0-1].u.string);
{
  push_text("noname.xml");
  f_parse_xml(2);
}

}

#if defined(f_parse_xml_1_defined) || defined(f_parse_xml_2_defined) || defined(f_parse_xml_3_defined)
#define f_parse_xml_defined
ptrdiff_t f_parse_xml_fun_num = 0;
void f_parse_xml(INT32 args) {
  switch(args) {
   case 1:

#ifdef f_parse_xml_3_defined
    f_parse_xml_3(args);
    return;

#endif /* f_parse_xml_3_defined */
    break;
   case 2:

#ifdef f_parse_xml_2_defined
    f_parse_xml_2(args);
    return;

#endif /* f_parse_xml_2_defined */
    break;
   case 3:

#ifdef f_parse_xml_1_defined
    f_parse_xml_1(args);
    return;

#endif /* f_parse_xml_1_defined */
    break;
   default:
    wrong_number_of_args_error("parse_xml",args,1);
  }
}

#endif /* f_parse_xml_1_defined, f_parse_xml_2_defined, f_parse_xml_3_defined */
/*! @decl Node parse_html(string html, string|void name, string|void encoding)
 *!   Parse an string containing HTML.
 *!  @param html
 *!   String containing HTML data to parse.
 *!  @param name
 *!   String containing name/URI of file.
 *!
 *!  @returns
 *!    a @[Node] object containing the root of the tree.
 */
#define f_parse_html_1_defined
ptrdiff_t f_parse_html_1_fun_num = 0;
void f_parse_html_1(INT32 args) {
#line 704 "XML2.cmod"
struct pike_string * html;
#line 704 "XML2.cmod"
struct pike_string * name;
#line 704 "XML2.cmod"
struct pike_string * encoding;
#line 704 "XML2.cmod"
if(args != 3) wrong_number_of_args_error("parse_html",args,3);
#line 704 "XML2.cmod"
if(Pike_sp[0-3].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("parse_html",1,"string");
#line 704 "XML2.cmod"
debug_malloc_pass(html=Pike_sp[0-3].u.string);
#line 704 "XML2.cmod"
if(Pike_sp[1-3].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("parse_html",2,"string");
#line 704 "XML2.cmod"
debug_malloc_pass(name=Pike_sp[1-3].u.string);
#line 704 "XML2.cmod"
if(Pike_sp[2-3].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("parse_html",3,"string");
#line 704 "XML2.cmod"
debug_malloc_pass(encoding=Pike_sp[2-3].u.string);
{
  xmlDocPtr doc;

  entity_loader = my_entity_loader;

  /*  xmlSetExternalEntityLoader(entity_loader); */

  generic_handler = my_generic_error;
  /* xmlSetStructuredErrorFunc((void *)err_ctx, generic_handler); */

  doc = htmlReadMemory(html->str, html->len, name->str, 
                      (const char *)encoding->str, 
                      THIS->object_data->html_parser_options);

  handle_parsed_tree(doc, args);
}

}
#define f_parse_html_2_defined
ptrdiff_t f_parse_html_2_fun_num = 0;
void f_parse_html_2(INT32 args) {
#line 722 "XML2.cmod"
struct pike_string * html;
#line 722 "XML2.cmod"
struct pike_string * name;
#line 722 "XML2.cmod"
if(args != 2) wrong_number_of_args_error("parse_html",args,2);
#line 722 "XML2.cmod"
if(Pike_sp[0-2].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("parse_html",1,"string");
#line 722 "XML2.cmod"
debug_malloc_pass(html=Pike_sp[0-2].u.string);
#line 722 "XML2.cmod"
if(Pike_sp[1-2].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("parse_html",2,"string");
#line 722 "XML2.cmod"
debug_malloc_pass(name=Pike_sp[1-2].u.string);
{
  xmlDocPtr doc;

  entity_loader = my_entity_loader;

  /*  xmlSetExternalEntityLoader(entity_loader); */

  generic_handler = my_generic_error;
  /* xmlSetStructuredErrorFunc((void *)err_ctx, generic_handler); */

  doc = htmlReadMemory(html->str, html->len, name->str, 
                      NULL, 
                      THIS->object_data->html_parser_options);

  handle_parsed_tree(doc, args);
  
}

}
#define f_parse_html_3_defined
ptrdiff_t f_parse_html_3_fun_num = 0;
void f_parse_html_3(INT32 args) {
#line 741 "XML2.cmod"
struct pike_string * html;
#line 741 "XML2.cmod"
if(args != 1) wrong_number_of_args_error("parse_html",args,1);
#line 741 "XML2.cmod"
if(Pike_sp[0-1].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("parse_html",1,"string");
#line 741 "XML2.cmod"
debug_malloc_pass(html=Pike_sp[0-1].u.string);
{
  push_text("noname.html");
  f_parse_html(2);
}

}

#if defined(f_parse_html_1_defined) || defined(f_parse_html_2_defined) || defined(f_parse_html_3_defined)
#define f_parse_html_defined
ptrdiff_t f_parse_html_fun_num = 0;
void f_parse_html(INT32 args) {
  switch(args) {
   case 1:

#ifdef f_parse_html_3_defined
    f_parse_html_3(args);
    return;

#endif /* f_parse_html_3_defined */
    break;
   case 2:

#ifdef f_parse_html_2_defined
    f_parse_html_2(args);
    return;

#endif /* f_parse_html_2_defined */
    break;
   case 3:

#ifdef f_parse_html_1_defined
    f_parse_html_1(args);
    return;

#endif /* f_parse_html_1_defined */
    break;
   default:
    wrong_number_of_args_error("parse_html",args,1);
  }
}

#endif /* f_parse_html_1_defined, f_parse_html_2_defined, f_parse_html_3_defined */
/*! @decl Node new_xml(string version)
 *!   Create a new XML document with a root node.
 *!
 *!  @param version
 *!     the version of XML to create
 *!  @param root_name
 *!      the name of the root node
 *!  @returns
 *!    a @[Node] object containing the root of the tree.
 */
#define f_new_xml_defined
ptrdiff_t f_new_xml_fun_num = 0;
void f_new_xml(INT32 args) {
#line 757 "XML2.cmod"
struct pike_string * version;
#line 757 "XML2.cmod"
struct pike_string * root_name;
#line 757 "XML2.cmod"
if(args != 2) wrong_number_of_args_error("new_xml",args,2);
#line 757 "XML2.cmod"
if(Pike_sp[0-2].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("new_xml",1,"string");
#line 757 "XML2.cmod"
debug_malloc_pass(version=Pike_sp[0-2].u.string);
#line 757 "XML2.cmod"
if(Pike_sp[1-2].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("new_xml",2,"string");
#line 757 "XML2.cmod"
debug_malloc_pass(root_name=Pike_sp[1-2].u.string);
{
  xmlDocPtr doc;
  xmlNodePtr node;
  struct Node_struct * ns;
  NODE_OBJECT_DATA * od;

  doc = xmlNewDoc(version->str);

  if(doc == NULL)
  {
    Pike_error("Unable to create new XML document.\n");
  }  
  node = xmlNewNode(NULL, (xmlChar *)root_name->str);
  xmlDocSetRootElement(doc, node);
  if(node == NULL)
  {
    xmlFreeDoc(doc);
    Pike_error("Unable to find Root Node.\n");
  }

  /* ok, we have a parsed file. now let's turn it into a real live pike object. */

  pop_stack();

  apply(Pike_fp->current_object, "Node", 0);
  
  ns = OBJ2_NODE((Pike_sp[0-1].u.object));
  od = (NODE_OBJECT_DATA *)(ns->object_data);

  od->refs = malloc(sizeof(INT32));
  (* od->refs)=1;
  od->node = node;
}

}
/*! @decl Node parse_xslt(string xslt, string|void name)
/*! @decl Node parse_xslt(Node xslt)
 *!   Parse a string containing an XSLT stylesheet.
 *!
 *!  @param name
 *!   String containing name/URI of file.
 *!
 *!  @returns
 *!    a @[Stylesheet] object containing the parsed stylesheet.
 */
#define f_parse_xslt_1_defined
ptrdiff_t f_parse_xslt_1_fun_num = 0;
void f_parse_xslt_1(INT32 args) {
#line 802 "XML2.cmod"
struct pike_string * xslt;
#line 802 "XML2.cmod"
if(args != 1) wrong_number_of_args_error("parse_xslt",args,1);
#line 802 "XML2.cmod"
if(Pike_sp[0-1].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("parse_xslt",1,"string");
#line 802 "XML2.cmod"
debug_malloc_pass(xslt=Pike_sp[0-1].u.string);
{
  push_text("noname.xsl");
  f_parse_xslt(2);
}

}
#define f_parse_xslt_2_defined
ptrdiff_t f_parse_xslt_2_fun_num = 0;
void f_parse_xslt_2(INT32 args) {
#line 808 "XML2.cmod"
struct object * xslt;
#line 808 "XML2.cmod"
if(args != 1) wrong_number_of_args_error("parse_xslt",args,1);
#line 808 "XML2.cmod"
if(Pike_sp[0-1].type != PIKE_T_OBJECT) SIMPLE_BAD_ARG_ERROR("parse_xslt",1,"object");
#line 808 "XML2.cmod"
debug_malloc_pass(xslt=Pike_sp[0-1].u.object);
{
  CHECK_NODE_PASSED(xslt);

  handle_parse_stylesheet(args);

}

}
#define f_parse_xslt_3_defined
ptrdiff_t f_parse_xslt_3_fun_num = 0;
void f_parse_xslt_3(INT32 args) {
#line 816 "XML2.cmod"
struct pike_string * xslt;
#line 816 "XML2.cmod"
struct pike_string * name;
#line 816 "XML2.cmod"
if(args != 2) wrong_number_of_args_error("parse_xslt",args,2);
#line 816 "XML2.cmod"
if(Pike_sp[0-2].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("parse_xslt",1,"string");
#line 816 "XML2.cmod"
debug_malloc_pass(xslt=Pike_sp[0-2].u.string);
#line 816 "XML2.cmod"
if(Pike_sp[1-2].type != PIKE_T_STRING) SIMPLE_BAD_ARG_ERROR("parse_xslt",2,"string");
#line 816 "XML2.cmod"
debug_malloc_pass(name=Pike_sp[1-2].u.string);
{
  /* first, we must parse the xml file. conveniently, we have a function */
  /* that does that already! */
  f_parse_xml(2);

  handle_parse_stylesheet(args);
}

}

#if defined(f_parse_xslt_1_defined) || defined(f_parse_xslt_2_defined) || defined(f_parse_xslt_3_defined)
#define f_parse_xslt_defined
ptrdiff_t f_parse_xslt_fun_num = 0;
void f_parse_xslt(INT32 args) {
  switch(args) {
   case 1:
    switch(Pike_sp[0-1].type) {
     case PIKE_T_STRING:

#ifdef f_parse_xslt_1_defined
      f_parse_xslt_1(args);
      return;

#endif /* f_parse_xslt_1_defined */
      break;
     case PIKE_T_OBJECT:

#ifdef f_parse_xslt_2_defined
      f_parse_xslt_2(args);
      return;

#endif /* f_parse_xslt_2_defined */
      break;
     default:
      SIMPLE_BAD_ARG_ERROR("parse_xslt",1,"string|object");
    }
   case 2:

#ifdef f_parse_xslt_3_defined
    f_parse_xslt_3(args);
    return;

#endif /* f_parse_xslt_3_defined */
    break;
   default:
    wrong_number_of_args_error("parse_xslt",args,1);
  }
}

#endif /* f_parse_xslt_1_defined, f_parse_xslt_2_defined, f_parse_xslt_3_defined */
#line 825 "XML2.cmod"
void handle_parse_stylesheet(INT32 args)
{
  struct object * node_obj = NULL;
  xsltStylesheetPtr sty = NULL;
  xmlDocPtr doc = NULL;
  struct Stylesheet_struct * ss;
  STYLESHEET_OBJECT_DATA * od;

  /* we're going to hang on to the node object. */
  node_obj = Pike_sp[0-1].u.object;
  add_ref(node_obj);

  doc = OBJ2_NODE(node_obj)->object_data->node->doc;

  if(doc==NULL)
  {
    pop_stack();
    Pike_error("whoa, horsie! we don't have an xml document!\n");
  }

  sty = xsltParseStylesheetDoc(doc);

  if(sty == NULL)
  {
    pop_stack();
    Pike_error("Unable to parse stylesheet node.\n");
  }  

  /* ok, we have a parsed sheet. now let's turn it into a real live pike object. */

  pop_stack();

  apply(Pike_fp->current_object, "Stylesheet", 0);
  
  ss = OBJ2_STYLESHEET((Pike_sp[0-1].u.object));
  od = (STYLESHEET_OBJECT_DATA *)(ss->object_data);

  od->refs = malloc(sizeof(INT32));
  (* od->refs)=1;

  /* TODO: not sure if this is a leak, but we need it to prevent the 
     xmlNode from being freed a second time at the pike Node's destruction  
     (the Stylesheet will free that itself. Note that this is a tricky 
     subject... since the two are linked, perhaps we should call 
     Node.destroy() when the Stylesheet is destroyed... */
  *(OBJ2_NODE(node_obj)->object_data->refs)++;
  od->stylesheet = sty;
  ss->node = node_obj;
}


#undef extra_defined
#define extra_defined

#undef internal_init_defined
#define internal_init_defined

#undef event_handler_defined
#define event_handler_defined
static void init_struct(void)
#line 899 "XML2.cmod"
{
  PARSER_OBJECT_DATA * dta;

  dta = (PARSER_OBJECT_DATA*)malloc(sizeof(PARSER_OBJECT_DATA));
  if(dta == NULL)
  {
    Pike_error("xml2_init: unable to allocate memory.\n");
  }

  dta->xml_parser_options = 0;
  dta->html_parser_options = 0;
  THIS->object_data = dta;
 
  LIBXML_TEST_VERSION
}


#undef internal_exit_defined
#define internal_exit_defined

#undef event_handler_defined
#define event_handler_defined
static void exit_struct(void)
#line 916 "XML2.cmod"
{

  pike_exit_xml2_xmlreader();
  pike_exit_xml2_stylesheet();
  pike_exit_xml2_sax();
  pike_exit_xml2_node();
  pike_exit_xml2_html();
  pike_exit_xml2_constants();
  
#ifdef HAVE_XSLT
xsltCleanupGlobals();
#endif /* HAVE_XSLT */

  xmlCleanupParser();
}

/*! @endmodule
 */

/*! @endmodule
 */

/*! @endmodule
 */




#ifdef event_handler_defined
static void event_handler(int ev) {
  switch(ev) {

#ifdef internal_init_defined
  case PROG_EVENT_INIT: init_struct(); break;

#endif /* internal_init_defined */

#ifdef internal_exit_defined
  case PROG_EVENT_EXIT: exit_struct(); break;

#endif /* internal_exit_defined */
  default: break; 
  }
}

#endif /* event_handler_defined */
PIKE_MODULE_INIT {

#ifdef THIS_
  _storage_offset = ADD_STORAGE(struct _struct);
#endif /* THIS_ */

#ifdef var_docloader_defined
  PIKE_MAP_VARIABLE("docloader", _storage_offset + OFFSETOF(_struct, docloader),
                    tFuncV(tNone,tMix,tAny), PIKE_T_MIXED, 0);
#endif /* var_docloader_defined */

#ifdef extra_defined
#line 876 "XML2.cmod"
{
  struct pike_string * ps;
  char * err_ctx = "parse_xml";

  add_string_constant("__version", "1.20", 0);
  add_string_constant("__author", "Bill Welliver ", 0);

  generic_handler = my_generic_error;
  xmlSetStructuredErrorFunc((void *)err_ctx, generic_handler);

  MAKE_CONST_STRING(ps, "docloader");
  docloader_num = isidentifier(ps);

  pike_init_xml2_constants();
  pike_init_xml2_html();
  pike_init_xml2_node();
  pike_init_xml2_sax();
  pike_init_xml2_stylesheet();
  pike_init_xml2_xmlreader();

}


#endif /* extra_defined */

#ifdef event_handler_defined
  pike_set_prog_event_callback(event_handler);

#endif /* event_handler_defined */

#ifdef f_create_defined
  f_create_fun_num =
#line 103 "XML2.cmod"
    ADD_FUNCTION2("create", f_create, tFunc(tNone,tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_create_defined */

#ifdef f_select_xpath_nodes_defined
  f_select_xpath_nodes_fun_num =
#line 113 "XML2.cmod"
    ADD_FUNCTION2("select_xpath_nodes", f_select_xpath_nodes, tFunc(tString tObj,tArray), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_select_xpath_nodes_defined */

#ifdef f_set_xslt_docloader_defined
  f_set_xslt_docloader_fun_num =
#line 208 "XML2.cmod"
    ADD_FUNCTION2("set_xslt_docloader", f_set_xslt_docloader, tFunc(tFuncV(tNone,tMix,tAny),tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_set_xslt_docloader_defined */

#ifdef f_clear_xslt_docloader_defined
  f_clear_xslt_docloader_fun_num =
#line 222 "XML2.cmod"
    ADD_FUNCTION2("clear_xslt_docloader", f_clear_xslt_docloader, tFunc(tNone,tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_clear_xslt_docloader_defined */

#ifdef f_set_xml_parser_options_defined
  f_set_xml_parser_options_fun_num =
#line 241 "XML2.cmod"
    ADD_FUNCTION2("set_xml_parser_options", f_set_xml_parser_options, tFunc("\10\200\0\0\0\177\377\377\377",tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_set_xml_parser_options_defined */

#ifdef f_set_html_parser_options_defined
  f_set_html_parser_options_fun_num =
#line 255 "XML2.cmod"
    ADD_FUNCTION2("set_html_parser_options", f_set_html_parser_options, tFunc("\10\200\0\0\0\177\377\377\377",tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_set_html_parser_options_defined */

#ifdef f_substituteEntitiesDefault_defined
  f_substituteEntitiesDefault_fun_num =
#line 263 "XML2.cmod"
    ADD_FUNCTION2("substituteEntitiesDefault", f_substituteEntitiesDefault, tFunc("\10\200\0\0\0\177\377\377\377","\10\200\0\0\0\177\377\377\377"), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_substituteEntitiesDefault_defined */

#ifdef f_keepBlanksDefault_defined
  f_keepBlanksDefault_fun_num =
#line 276 "XML2.cmod"
    ADD_FUNCTION2("keepBlanksDefault", f_keepBlanksDefault, tFunc("\10\200\0\0\0\177\377\377\377","\10\200\0\0\0\177\377\377\377"), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_keepBlanksDefault_defined */

#ifdef f_utf8_to_html_defined
  f_utf8_to_html_fun_num =
#line 288 "XML2.cmod"
    ADD_FUNCTION2("utf8_to_html", f_utf8_to_html, tFunc(tString,tString), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_utf8_to_html_defined */

#ifdef f_utf8_to_isolat1_defined
  f_utf8_to_isolat1_fun_num =
#line 313 "XML2.cmod"
    ADD_FUNCTION2("utf8_to_isolat1", f_utf8_to_isolat1, tFunc(tString,tString), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_utf8_to_isolat1_defined */

#ifdef f_utf8_check_defined
  f_utf8_check_fun_num =
#line 337 "XML2.cmod"
    ADD_FUNCTION2("utf8_check", f_utf8_check, tFunc(tString,"\10\200\0\0\0\177\377\377\377"), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_utf8_check_defined */

#ifdef f_get_encodings_defined
  f_get_encodings_fun_num =
#line 354 "XML2.cmod"
    ADD_FUNCTION2("get_encodings", f_get_encodings, tFunc(tNone,tArray), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_get_encodings_defined */

#ifdef f_get_encoding_name_defined
  f_get_encoding_name_fun_num =
#line 378 "XML2.cmod"
    ADD_FUNCTION2("get_encoding_name", f_get_encoding_name, tFunc("\10\200\0\0\0\177\377\377\377",tString), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_get_encoding_name_defined */

#ifdef f_get_encoding_alias_defined
  f_get_encoding_alias_fun_num =
#line 394 "XML2.cmod"
    ADD_FUNCTION2("get_encoding_alias", f_get_encoding_alias, tFunc(tString,tString), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_get_encoding_alias_defined */

#ifdef f_render_xml_defined
  f_render_xml_fun_num =
#line 414 "XML2.cmod"
    ADD_FUNCTION2("render_xml", f_render_xml, tFunc(tObj,tString), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_render_xml_defined */

#ifdef f_render_html_defined
  f_render_html_fun_num =
#line 451 "XML2.cmod"
    ADD_FUNCTION2("render_html", f_render_html, tFunc(tObj,tString), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_render_html_defined */

#ifdef f_parse_xml_force_defined
  f_parse_xml_force_fun_num =
#line 499 "XML2.cmod"
    ADD_FUNCTION2("parse_xml_force", f_parse_xml_force, tFunc(tString,tObj), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_parse_xml_force_defined */

#ifdef f_parse_xml_sax_defined
  f_parse_xml_sax_fun_num =
#line 594 "XML2.cmod"
    ADD_FUNCTION2("parse_xml_sax", f_parse_xml_sax, tFunc(tString tString tString,tObj), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_parse_xml_sax_defined */

#ifdef f_parse_xml_defined
  f_parse_xml_fun_num =
#line 688 "XML2.cmod"
    ADD_FUNCTION2("parse_xml", f_parse_xml, tOr3(tFunc(tString tString tString,tObj),tFunc(tString tString,tObj),tFunc(tString,tObj)), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_parse_xml_defined */

#ifdef f_parse_html_defined
  f_parse_html_fun_num =
#line 741 "XML2.cmod"
    ADD_FUNCTION2("parse_html", f_parse_html, tOr3(tFunc(tString tString tString,tObj),tFunc(tString tString,tObj),tFunc(tString,tObj)), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_parse_html_defined */

#ifdef f_new_xml_defined
  f_new_xml_fun_num =
#line 757 "XML2.cmod"
    ADD_FUNCTION2("new_xml", f_new_xml, tFunc(tString tString,tObj), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_new_xml_defined */

#ifdef f_parse_xslt_defined
  f_parse_xslt_fun_num =
#line 816 "XML2.cmod"
    ADD_FUNCTION2("parse_xslt", f_parse_xslt, tOr3(tFunc(tString,tObj),tFunc(tObj,tObj),tFunc(tString tString,tObj)), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_parse_xslt_defined */
}
PIKE_MODULE_EXIT {
}


gotpike.org | Copyright © 2004 - 2019 | Pike is a trademark of Department of Computer and Information Science, Linköping University