File: libxml.c

package info (click to toggle)
ruby-mkrf 0.2.3+dfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,752 kB
  • ctags: 4,291
  • sloc: ansic: 12,494; ruby: 6,984; sh: 790; yacc: 374; makefile: 57; cpp: 10
file content (86 lines) | stat: -rw-r--r-- 2,235 bytes parent folder | download | duplicates (2)
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
/* $Id: libxml.c,v 1.2 2006/04/17 13:30:22 roscopeco Exp $ */

/* 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;

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 */
  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");
  xmlInitParser();

  mXML = rb_define_module("XML");

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

  ruby_init_parser();
  ruby_init_xml_parser_context();
  ruby_init_xml_attr();
  ruby_init_xml_attribute();
  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_input_callbacks(); /* MUFF */
  ruby_init_xml_dtd();         /* MUFF */
  ruby_init_xml_schema();      /* MUFF */

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