
Contents of /Public_Parser_XML2-1.42/RelaxNG.c:
/* Generated from "RelaxNG.cmod" by precompile.pike
*
* Do NOT edit this file.
*/
#undef PRECOMPILE_API_VERSION
#define PRECOMPILE_API_VERSION 2
#line 1 "RelaxNG.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: RelaxNG.cmod,v 1.4 2005-07-20 21:08:14 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 <hww3@riverweb.com>
*
* 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:
*
*
*/
#define THIS_IS_XML2_RELAXNG 1
#include "xml2.h"
/*! @module Public
*/
/*! @module Parser
*/
/*! @module XML2
*/
/*! @class RelaxNG
*!
*! a Relax-NG validator.
*!
*/
#ifdef HAVE_LIBXML_RELAXNG_H
#undef class_RelaxNG_defined
#define class_RelaxNG_defined
struct program *RelaxNG_program=NULL;
static int RelaxNG_program_fun_num=-1;
#undef var_object_data_RelaxNG_defined
#define var_object_data_RelaxNG_defined
#undef var_node_RelaxNG_defined
#define var_node_RelaxNG_defined
#undef THIS
#define THIS ((struct RelaxNG_struct *)(Pike_interpreter.frame_pointer->current_storage))
#undef THIS_RELAXNG
#define THIS_RELAXNG ((struct RelaxNG_struct *)(Pike_interpreter.frame_pointer->current_storage))
#undef OBJ2_RELAXNG
#define OBJ2_RELAXNG(o) ((struct RelaxNG_struct *)(o->storage+RelaxNG_storage_offset))
#undef GET_RELAXNG_STORAGE
#define GET_RELAXNG_STORAGE ((struct RelaxNG_struct *)(o->storage+RelaxNG_storage_offset)
static ptrdiff_t RelaxNG_storage_offset;
struct RelaxNG_struct {
#ifdef var_object_data_RelaxNG_defined
#line 81 "RelaxNG.cmod"
RELAXNG_OBJECT_DATA * object_data;
#endif /* var_object_data_RelaxNG_defined */
#ifdef var_node_RelaxNG_defined
struct object * node;
#endif /* var_node_RelaxNG_defined */
};
/*! @decl int validate_doc(Node node)
*!
*! Validates an XML document.
*!
*! @returns
*! 0 if the document is valid, a positive error code number otherwise
*! and -1 in case of internal or API error.
*!
*/
#define f_RelaxNG_validate_doc_defined
ptrdiff_t f_RelaxNG_validate_doc_fun_num = 0;
void f_RelaxNG_validate_doc(INT32 args) {
#line 94 "RelaxNG.cmod"
struct object * node;
#line 94 "RelaxNG.cmod"
if(args != 1) wrong_number_of_args_error("validate_doc",args,1);
#line 94 "RelaxNG.cmod"
if(Pike_sp[0-1].type != PIKE_T_OBJECT) SIMPLE_BAD_ARG_ERROR("validate_doc",1,"object");
#line 94 "RelaxNG.cmod"
debug_malloc_pass(node=Pike_sp[0-1].u.object);
{
xmlDocPtr doc;
xmlRelaxNGValidCtxtPtr validator;
int res;
CHECK_NODE_PASSED(node);
doc = OBJ2_NODE(node)->object_data->node->doc;
if(doc == NULL)
{
pop_stack();
Pike_error("The Node object passed is not part of a larger XML document.\n");
}
validator = xmlRelaxNGNewValidCtxt(THIS->object_data->valid);
/*
xmlRelaxNGSetValidErrors(validator, relaxng_error_handler,
relaxng_warning_handler, NULL);
*/
xmlRelaxNGSetValidErrors(validator, relaxng_error_handler,
relaxng_warning_handler, NULL);
res = xmlRelaxNGValidateDoc(validator, doc);
pop_stack();
push_int(res);
return;
}
}
#define f_RelaxNG_create_defined
ptrdiff_t f_RelaxNG_create_fun_num = 0;
void f_RelaxNG_create(INT32 args) {
#line 130 "RelaxNG.cmod"
if(args != 0) wrong_number_of_args_error("create",args,0);
{
}
}
#undef internal_init_RelaxNG_defined
#define internal_init_RelaxNG_defined
#undef RelaxNG_event_handler_defined
#define RelaxNG_event_handler_defined
static void init_RelaxNG_struct(void)
#line 136 "RelaxNG.cmod"
{
RELAXNG_OBJECT_DATA * relaxng;
relaxng = malloc(sizeof(RELAXNG_OBJECT_DATA));
if(relaxng == NULL)
Pike_error("relaxng_init: out of memory.\n");
relaxng->context = NULL;
relaxng->valid = NULL;
THIS->object_data = relaxng;
}
#undef internal_exit_RelaxNG_defined
#define internal_exit_RelaxNG_defined
#undef RelaxNG_event_handler_defined
#define RelaxNG_event_handler_defined
static void exit_RelaxNG_struct(void)
#line 151 "RelaxNG.cmod"
{
if((* THIS->object_data->refs)==1)
{
if(THIS->object_data->context != NULL)
{
xmlRelaxNGFreeParserCtxt(THIS->object_data->context);
}
if(THIS->object_data->valid != NULL)
{
xmlRelaxNGFree(THIS->object_data->valid);
}
}
else
{
(*( THIS->object_data->refs)) --;
}
if(THIS->node != NULL)
{
/* FIXME: this is a memory leak!!! */
/* free_object(THIS->node); */
}
if(THIS->object_data)
free(THIS->object_data);
}
#ifdef RelaxNG_event_handler_defined
static void RelaxNG_event_handler(int ev) {
switch(ev) {
#ifdef internal_init_RelaxNG_defined
case PROG_EVENT_INIT: init_RelaxNG_struct(); break;
#endif /* internal_init_RelaxNG_defined */
#ifdef internal_exit_RelaxNG_defined
case PROG_EVENT_EXIT: exit_RelaxNG_struct(); break;
#endif /* internal_exit_RelaxNG_defined */
default: break;
}
}
#endif /* RelaxNG_event_handler_defined */
#line 186 "RelaxNG.cmod"
#endif /* HAVE_LIBXML_RELAXNG_H */
/*! @endclass
*!
*/
/*! @endmodule
*!
*/
/*! @endmodule
*!
*/
/*! @endmodule
*!
*/
void pike_init_xml2_relaxng(void)
{
#ifdef class_RelaxNG_defined
#ifdef PROG_RELAXNG_ID
#line 78 "RelaxNG.cmod"
START_NEW_PROGRAM_ID(RELAXNG);
#else
#line 78 "RelaxNG.cmod"
start_new_program();
#endif /* PROG_RELAXNG_ID */
#ifndef tObjImpl_RELAXNG
#undef tObjImpl_RELAXNG
#define tObjImpl_RELAXNG tObj
#endif /* tObjImpl_RELAXNG */
#ifdef THIS_RELAXNG
RelaxNG_storage_offset = ADD_STORAGE(struct RelaxNG_struct);
#endif /* THIS_RELAXNG */
#ifdef var_node_RelaxNG_defined
PIKE_MAP_VARIABLE("node", RelaxNG_storage_offset + OFFSETOF(RelaxNG_struct, node),
tObj, PIKE_T_OBJECT, 0);
#endif /* var_node_RelaxNG_defined */
#ifdef RelaxNG_event_handler_defined
pike_set_prog_event_callback(RelaxNG_event_handler);
#endif /* RelaxNG_event_handler_defined */
#ifdef f_RelaxNG_validate_doc_defined
f_RelaxNG_validate_doc_fun_num =
#line 94 "RelaxNG.cmod"
ADD_FUNCTION2("validate_doc", f_RelaxNG_validate_doc, tFunc(tObj,"\10\200\0\0\0\177\377\377\377"), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);
#endif /* f_RelaxNG_validate_doc_defined */
#ifdef f_RelaxNG_create_defined
f_RelaxNG_create_fun_num =
#line 130 "RelaxNG.cmod"
ADD_FUNCTION2("create", f_RelaxNG_create, tFunc(tNone,tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);
#endif /* f_RelaxNG_create_defined */
#line 78 "RelaxNG.cmod"
RelaxNG_program=end_program();
#line 78 "RelaxNG.cmod"
RelaxNG_program_fun_num=add_program_constant("RelaxNG",RelaxNG_program,0);
#endif /* class_RelaxNG_defined */
#line 207 "RelaxNG.cmod"
}
void pike_exit_xml2_relaxng(void)
{
#ifdef class_RelaxNG_defined
if(RelaxNG_program) {
#line 78 "RelaxNG.cmod"
free_program(RelaxNG_program);
RelaxNG_program=0;
}
#endif /* class_RelaxNG_defined */
#line 212 "RelaxNG.cmod"
}