File: libxml.c

package info (click to toggle)
libxml-ruby 0.5.2.0-3%2Blenny1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 652 kB
  • ctags: 875
  • sloc: ansic: 5,874; ruby: 1,524; xml: 144; makefile: 9
file content (92 lines) | stat: -rw-r--r-- 2,352 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* $Id: libxml.c 189 2007-09-26 15:04:47Z danj $ */

/* Please see the LICENSE file for copyright and distribution information */

#include "libxml.h"

/* Ruby's util.h has ruby_strdup */
#include "util.h"

#ifdef xmlMalloc
#undef xmlMalloc
#endif
#ifdef xmlRealloc
#undef xmlRealloc
#endif
#ifdef xmlMemStrdup
#undef xmlMemStrdup
#endif
#ifdef xmlMemFree
#undef xmlMemFree
#endif

#ifdef RubyMemMalloc
#undef RubyMemMalloc
#endif
#ifdef RubyMemRealloc
#undef RubyMemRealloc
#endif
#ifdef RubyMemStrdup
#undef RubyMemStrdup
#endif
#ifdef RubyMemFree
#undef RubyMemFree
#endif

#define RubyMemFree     ruby_xfree
#define RubyMemRealloc  ruby_xrealloc
#define RubyMemMalloc   ruby_xmalloc
#define RubyMemStrdup   ruby_strdup

VALUE mXML;
VALUE eXMLError;

static xmlFreeFunc freeFunc = NULL;
static xmlMallocFunc mallocFunc = NULL;
static xmlReallocFunc reallocFunc = NULL;
static xmlStrdupFunc strdupFunc = NULL;

void
Init_libxml_so(void) {
  /* Some libxml memory goo that should be done before anything else */
#ifdef NONE
  xmlMemGet((xmlFreeFunc *) & freeFunc,
            (xmlMallocFunc *) & mallocFunc,
            (xmlReallocFunc *) & reallocFunc,
            (xmlStrdupFunc *) & strdupFunc);

  if (xmlMemSetup((xmlFreeFunc)RubyMemFree, (xmlMallocFunc)RubyMemMalloc,
                  (xmlReallocFunc)RubyMemRealloc, (xmlStrdupFunc)RubyMemStrdup) != 0)
    rb_fatal("could not install the memory handlers for libxml");
#endif
  xmlInitParser();

  mXML = rb_define_module("XML");
  eXMLError = rb_define_class_under(mXML, "Error", rb_eRuntimeError);

  rb_define_const(mXML, "XML_NAMESPACE", rb_str_new2((const char*)XML_XML_NAMESPACE));

  ruby_init_state();
  ruby_init_parser();  
  ruby_init_xml_parser_context();
  ruby_init_xml_attr();
  ruby_init_xml_document();
  ruby_init_xml_node();
  ruby_init_xml_node_set();
  ruby_init_xml_ns();
  ruby_init_xml_sax_parser();
  ruby_init_xml_tree();
  ruby_init_xml_xinclude();
  ruby_init_xml_xpath();
  ruby_init_xml_xpath_context();
  ruby_init_xml_xpointer();
  ruby_init_xml_xpointer_context();
  ruby_init_html_parser();
  ruby_init_input_callbacks(); 
  ruby_init_xml_dtd();         
  ruby_init_xml_schema();      
  ruby_init_xml_reader();      

  ruby_xml_parser_default_substitute_entities_set(cXMLParser, Qtrue);
  ruby_xml_parser_default_load_external_dtd_set(cXMLParser, Qtrue);
}