libxml-ruby 2.0.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +516 -0
- data/LICENSE +23 -0
- data/MANIFEST +165 -0
- data/README.rdoc +161 -0
- data/Rakefile +82 -0
- data/ext/libxml/extconf.rb +122 -0
- data/ext/libxml/libxml.c +93 -0
- data/ext/libxml/ruby_libxml.h +101 -0
- data/ext/libxml/ruby_xml.c +893 -0
- data/ext/libxml/ruby_xml.h +10 -0
- data/ext/libxml/ruby_xml_attr.c +352 -0
- data/ext/libxml/ruby_xml_attr.h +14 -0
- data/ext/libxml/ruby_xml_attr_decl.c +171 -0
- data/ext/libxml/ruby_xml_attr_decl.h +13 -0
- data/ext/libxml/ruby_xml_attributes.c +277 -0
- data/ext/libxml/ruby_xml_attributes.h +17 -0
- data/ext/libxml/ruby_xml_cbg.c +85 -0
- data/ext/libxml/ruby_xml_document.c +958 -0
- data/ext/libxml/ruby_xml_document.h +17 -0
- data/ext/libxml/ruby_xml_dtd.c +257 -0
- data/ext/libxml/ruby_xml_dtd.h +9 -0
- data/ext/libxml/ruby_xml_encoding.c +221 -0
- data/ext/libxml/ruby_xml_encoding.h +16 -0
- data/ext/libxml/ruby_xml_error.c +1004 -0
- data/ext/libxml/ruby_xml_error.h +14 -0
- data/ext/libxml/ruby_xml_html_parser.c +92 -0
- data/ext/libxml/ruby_xml_html_parser.h +12 -0
- data/ext/libxml/ruby_xml_html_parser_context.c +308 -0
- data/ext/libxml/ruby_xml_html_parser_context.h +12 -0
- data/ext/libxml/ruby_xml_html_parser_options.c +40 -0
- data/ext/libxml/ruby_xml_html_parser_options.h +12 -0
- data/ext/libxml/ruby_xml_input_cbg.c +191 -0
- data/ext/libxml/ruby_xml_input_cbg.h +20 -0
- data/ext/libxml/ruby_xml_io.c +30 -0
- data/ext/libxml/ruby_xml_io.h +9 -0
- data/ext/libxml/ruby_xml_namespace.c +170 -0
- data/ext/libxml/ruby_xml_namespace.h +12 -0
- data/ext/libxml/ruby_xml_namespaces.c +295 -0
- data/ext/libxml/ruby_xml_namespaces.h +11 -0
- data/ext/libxml/ruby_xml_node.c +1386 -0
- data/ext/libxml/ruby_xml_node.h +13 -0
- data/ext/libxml/ruby_xml_parser.c +94 -0
- data/ext/libxml/ruby_xml_parser.h +14 -0
- data/ext/libxml/ruby_xml_parser_context.c +982 -0
- data/ext/libxml/ruby_xml_parser_context.h +12 -0
- data/ext/libxml/ruby_xml_parser_options.c +68 -0
- data/ext/libxml/ruby_xml_parser_options.h +14 -0
- data/ext/libxml/ruby_xml_reader.c +1057 -0
- data/ext/libxml/ruby_xml_reader.h +14 -0
- data/ext/libxml/ruby_xml_relaxng.c +111 -0
- data/ext/libxml/ruby_xml_relaxng.h +10 -0
- data/ext/libxml/ruby_xml_sax2_handler.c +334 -0
- data/ext/libxml/ruby_xml_sax2_handler.h +12 -0
- data/ext/libxml/ruby_xml_sax_parser.c +136 -0
- data/ext/libxml/ruby_xml_sax_parser.h +12 -0
- data/ext/libxml/ruby_xml_schema.c +159 -0
- data/ext/libxml/ruby_xml_schema.h +11 -0
- data/ext/libxml/ruby_xml_version.h +9 -0
- data/ext/libxml/ruby_xml_xinclude.c +18 -0
- data/ext/libxml/ruby_xml_xinclude.h +13 -0
- data/ext/libxml/ruby_xml_xpath.c +107 -0
- data/ext/libxml/ruby_xml_xpath.h +12 -0
- data/ext/libxml/ruby_xml_xpath_context.c +390 -0
- data/ext/libxml/ruby_xml_xpath_context.h +11 -0
- data/ext/libxml/ruby_xml_xpath_expression.c +83 -0
- data/ext/libxml/ruby_xml_xpath_expression.h +12 -0
- data/ext/libxml/ruby_xml_xpath_object.c +336 -0
- data/ext/libxml/ruby_xml_xpath_object.h +19 -0
- data/ext/libxml/ruby_xml_xpointer.c +101 -0
- data/ext/libxml/ruby_xml_xpointer.h +13 -0
- data/ext/mingw/Rakefile +34 -0
- data/ext/mingw/build.rake +41 -0
- data/ext/vc/libxml_ruby.sln +26 -0
- data/lib/1.8/libxml_ruby.so +0 -0
- data/lib/1.9/libxml_ruby.so +0 -0
- data/lib/libxml.rb +30 -0
- data/lib/libxml/attr.rb +113 -0
- data/lib/libxml/attr_decl.rb +80 -0
- data/lib/libxml/attributes.rb +14 -0
- data/lib/libxml/document.rb +192 -0
- data/lib/libxml/error.rb +90 -0
- data/lib/libxml/hpricot.rb +78 -0
- data/lib/libxml/html_parser.rb +96 -0
- data/lib/libxml/namespace.rb +62 -0
- data/lib/libxml/namespaces.rb +38 -0
- data/lib/libxml/node.rb +399 -0
- data/lib/libxml/ns.rb +22 -0
- data/lib/libxml/parser.rb +367 -0
- data/lib/libxml/properties.rb +23 -0
- data/lib/libxml/reader.rb +29 -0
- data/lib/libxml/sax_callbacks.rb +180 -0
- data/lib/libxml/sax_parser.rb +58 -0
- data/lib/libxml/tree.rb +29 -0
- data/lib/libxml/xpath_object.rb +16 -0
- data/lib/xml.rb +16 -0
- data/lib/xml/libxml.rb +10 -0
- data/libxml-ruby.gemspec +50 -0
- data/script/benchmark/depixelate +634 -0
- data/script/benchmark/hamlet.xml +9055 -0
- data/script/benchmark/parsecount +170 -0
- data/script/benchmark/sock_entries.xml +507 -0
- data/script/benchmark/throughput +41 -0
- data/script/test +6 -0
- data/setup.rb +1585 -0
- data/test/etc_doc_to_s.rb +21 -0
- data/test/ets_doc_file.rb +17 -0
- data/test/ets_doc_to_s.rb +23 -0
- data/test/ets_gpx.rb +28 -0
- data/test/ets_node_gc.rb +23 -0
- data/test/ets_test.xml +2 -0
- data/test/ets_tsr.rb +11 -0
- data/test/model/atom.xml +13 -0
- data/test/model/bands.iso-8859-1.xml +5 -0
- data/test/model/bands.utf-8.xml +5 -0
- data/test/model/bands.xml +5 -0
- data/test/model/books.xml +146 -0
- data/test/model/merge_bug_data.xml +58 -0
- data/test/model/ruby-lang.html +238 -0
- data/test/model/rubynet.xml +79 -0
- data/test/model/rubynet_project +1 -0
- data/test/model/shiporder.rnc +28 -0
- data/test/model/shiporder.rng +86 -0
- data/test/model/shiporder.xml +23 -0
- data/test/model/shiporder.xsd +31 -0
- data/test/model/soap.xml +27 -0
- data/test/model/xinclude.xml +5 -0
- data/test/rb-magic-comment.rb +33 -0
- data/test/tc_attr.rb +181 -0
- data/test/tc_attr_decl.rb +133 -0
- data/test/tc_attributes.rb +135 -0
- data/test/tc_deprecated_require.rb +13 -0
- data/test/tc_document.rb +119 -0
- data/test/tc_document_write.rb +187 -0
- data/test/tc_dtd.rb +125 -0
- data/test/tc_error.rb +138 -0
- data/test/tc_html_parser.rb +140 -0
- data/test/tc_namespace.rb +62 -0
- data/test/tc_namespaces.rb +177 -0
- data/test/tc_node.rb +258 -0
- data/test/tc_node_cdata.rb +51 -0
- data/test/tc_node_comment.rb +33 -0
- data/test/tc_node_copy.rb +42 -0
- data/test/tc_node_edit.rb +160 -0
- data/test/tc_node_text.rb +71 -0
- data/test/tc_node_write.rb +108 -0
- data/test/tc_node_xlink.rb +29 -0
- data/test/tc_parser.rb +336 -0
- data/test/tc_parser_context.rb +189 -0
- data/test/tc_properties.rb +39 -0
- data/test/tc_reader.rb +298 -0
- data/test/tc_relaxng.rb +54 -0
- data/test/tc_sax_parser.rb +276 -0
- data/test/tc_schema.rb +53 -0
- data/test/tc_traversal.rb +222 -0
- data/test/tc_xinclude.rb +21 -0
- data/test/tc_xml.rb +226 -0
- data/test/tc_xpath.rb +195 -0
- data/test/tc_xpath_context.rb +80 -0
- data/test/tc_xpath_expression.rb +38 -0
- data/test/tc_xpointer.rb +74 -0
- data/test/test_helper.rb +14 -0
- data/test/test_suite.rb +39 -0
- metadata +254 -0
data/ext/libxml/libxml.c
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
#include "ruby_libxml.h"
|
2
|
+
|
3
|
+
#if RUBY_INTERN_H
|
4
|
+
#include <ruby/util.h>
|
5
|
+
#else
|
6
|
+
#include <util.h>
|
7
|
+
#endif
|
8
|
+
|
9
|
+
|
10
|
+
VALUE mLibXML;
|
11
|
+
|
12
|
+
static void rxml_init_memory(void)
|
13
|
+
{
|
14
|
+
/* Disable for now - broke attributes.
|
15
|
+
xmlGcMemSetup(
|
16
|
+
(xmlFreeFunc)ruby_xfree,
|
17
|
+
(xmlMallocFunc)ruby_xmalloc,
|
18
|
+
(xmlMallocFunc)ruby_xmalloc,
|
19
|
+
(xmlReallocFunc)ruby_xrealloc,
|
20
|
+
(xmlStrdupFunc)ruby_strdup
|
21
|
+
);*/
|
22
|
+
}
|
23
|
+
|
24
|
+
VALUE rxml_str_new2(const char* xstr, const char* xencoding)
|
25
|
+
{
|
26
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
27
|
+
if (xencoding)
|
28
|
+
{
|
29
|
+
xmlCharEncoding xmlEncoding = xmlParseCharEncoding(xencoding);
|
30
|
+
VALUE encoding = rxml_xml_encoding_to_rb_encoding(mXMLEncoding, xmlEncoding);
|
31
|
+
rb_encoding* xencodingPtr = (rb_encoding*) RDATA(encoding)->data;
|
32
|
+
return rb_external_str_new_with_enc(xstr, strlen(xstr), xencodingPtr);
|
33
|
+
}
|
34
|
+
#endif
|
35
|
+
return rb_str_new2(xstr);
|
36
|
+
}
|
37
|
+
|
38
|
+
|
39
|
+
#if defined(_WIN32)
|
40
|
+
__declspec(dllexport)
|
41
|
+
#endif
|
42
|
+
void Init_libxml_ruby(void)
|
43
|
+
{
|
44
|
+
/* The libxml gem provides Ruby language bindings for GNOME's Libxml2
|
45
|
+
* XML toolkit. To get started you may:
|
46
|
+
*
|
47
|
+
* require 'test_helper'
|
48
|
+
* document = XML::Document.new
|
49
|
+
*
|
50
|
+
* However, when creating an application or library you plan to
|
51
|
+
* redistribute, it is best to not add the LibXML module to the global
|
52
|
+
* namespace, in which case you can either write your code like this:
|
53
|
+
*
|
54
|
+
* require 'libxml'
|
55
|
+
* document = LibXML::XML::Document.new
|
56
|
+
*
|
57
|
+
* Refer to the README file to get started and the LICENSE file for
|
58
|
+
* copyright and distribution information.
|
59
|
+
*/
|
60
|
+
mLibXML = rb_define_module("LibXML");
|
61
|
+
|
62
|
+
rxml_init_memory();
|
63
|
+
rxml_init_xml();
|
64
|
+
rxml_init_io();
|
65
|
+
rxml_init_error();
|
66
|
+
rxml_init_encoding();
|
67
|
+
rxml_init_parser();
|
68
|
+
rxml_init_parser_context();
|
69
|
+
rxml_init_parser_options();
|
70
|
+
rxml_init_node();
|
71
|
+
rxml_init_attributes();
|
72
|
+
rxml_init_attr();
|
73
|
+
rxml_init_attr_decl();
|
74
|
+
rxml_init_document();
|
75
|
+
rxml_init_namespaces();
|
76
|
+
rxml_init_namespace();
|
77
|
+
rxml_init_sax_parser();
|
78
|
+
rxml_init_sax2_handler();
|
79
|
+
rxml_init_xinclude();
|
80
|
+
rxml_init_xpath();
|
81
|
+
rxml_init_xpath_object();
|
82
|
+
rxml_init_xpath_context();
|
83
|
+
rxml_init_xpath_expression();
|
84
|
+
rxml_init_xpointer();
|
85
|
+
rxml_init_html_parser();
|
86
|
+
rxml_init_html_parser_options();
|
87
|
+
rxml_init_html_parser_context();
|
88
|
+
rxml_init_input_callbacks();
|
89
|
+
rxml_init_dtd();
|
90
|
+
rxml_init_schema();
|
91
|
+
rxml_init_relaxng();
|
92
|
+
rxml_init_reader();
|
93
|
+
}
|
@@ -0,0 +1,101 @@
|
|
1
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
2
|
+
|
3
|
+
#ifndef __RUBY_LIBXML_H__
|
4
|
+
#define __RUBY_LIBXML_H__
|
5
|
+
|
6
|
+
#include <ruby.h>
|
7
|
+
#include <libxml/parser.h>
|
8
|
+
#include <libxml/parserInternals.h>
|
9
|
+
#include <libxml/debugXML.h>
|
10
|
+
#include <libxml/xmlversion.h>
|
11
|
+
#include <libxml/xmlmemory.h>
|
12
|
+
#include <libxml/xpath.h>
|
13
|
+
#include <libxml/valid.h>
|
14
|
+
#include <libxml/catalog.h>
|
15
|
+
#include <libxml/HTMLparser.h>
|
16
|
+
#include <libxml/xmlreader.h>
|
17
|
+
|
18
|
+
/* Needed for Ruby 1.8.5 */
|
19
|
+
#ifndef RARRAY_LEN
|
20
|
+
#define RARRAY_LEN(s) (RARRAY(s)->len)
|
21
|
+
#endif
|
22
|
+
|
23
|
+
/* Needed for Ruby 1.8.5 */
|
24
|
+
#ifndef RARRAY_PTR
|
25
|
+
#define RARRAY_PTR(s) (RARRAY(s)->ptr)
|
26
|
+
#endif
|
27
|
+
|
28
|
+
/* Needed for Ruby 1.8.5 */
|
29
|
+
#ifndef RSTRING_LEN
|
30
|
+
#define RSTRING_LEN(s) (RSTRING(s)->len)
|
31
|
+
#endif
|
32
|
+
|
33
|
+
/* Needed for Ruby 1.8.5 */
|
34
|
+
#ifndef RSTRING_PTR
|
35
|
+
#define RSTRING_PTR(s) (RSTRING(s)->ptr)
|
36
|
+
#endif
|
37
|
+
|
38
|
+
/* Needed prior to Ruby 1.9.1 */
|
39
|
+
#ifndef RHASH_TBL
|
40
|
+
#define RHASH_TBL(s) (RHASH(s)->tbl)
|
41
|
+
#endif
|
42
|
+
|
43
|
+
// Not in Ruby 1.9
|
44
|
+
#ifndef GetWriteFile
|
45
|
+
#define GetWriteFile(fp) rb_io_stdio_file(fp)
|
46
|
+
#define OpenFile rb_io_t
|
47
|
+
#endif
|
48
|
+
|
49
|
+
// Encoding support added in Ruby 1.9.*
|
50
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
51
|
+
#include <ruby/encoding.h>
|
52
|
+
#endif
|
53
|
+
|
54
|
+
// Ruby 1.8/1.9 encoding compatibility
|
55
|
+
VALUE rxml_str_new2(const char* xstr, const char* xencoding);
|
56
|
+
|
57
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
58
|
+
#include <libxml/xpathInternals.h>
|
59
|
+
#endif
|
60
|
+
#ifdef LIBXML_XINCLUDE_ENABLED
|
61
|
+
#include <libxml/xinclude.h>
|
62
|
+
#endif
|
63
|
+
#ifdef LIBXML_XPTR_ENABLED
|
64
|
+
#include <libxml/xpointer.h>
|
65
|
+
#endif
|
66
|
+
|
67
|
+
#include "ruby_xml_version.h"
|
68
|
+
#include "ruby_xml.h"
|
69
|
+
#include "ruby_xml_io.h"
|
70
|
+
#include "ruby_xml_error.h"
|
71
|
+
#include "ruby_xml_encoding.h"
|
72
|
+
#include "ruby_xml_attributes.h"
|
73
|
+
#include "ruby_xml_attr.h"
|
74
|
+
#include "ruby_xml_attr_decl.h"
|
75
|
+
#include "ruby_xml_document.h"
|
76
|
+
#include "ruby_xml_node.h"
|
77
|
+
#include "ruby_xml_namespace.h"
|
78
|
+
#include "ruby_xml_namespaces.h"
|
79
|
+
#include "ruby_xml_parser.h"
|
80
|
+
#include "ruby_xml_parser_options.h"
|
81
|
+
#include "ruby_xml_parser_context.h"
|
82
|
+
#include "ruby_xml_html_parser.h"
|
83
|
+
#include "ruby_xml_html_parser_options.h"
|
84
|
+
#include "ruby_xml_html_parser_context.h"
|
85
|
+
#include "ruby_xml_reader.h"
|
86
|
+
#include "ruby_xml_sax2_handler.h"
|
87
|
+
#include "ruby_xml_sax_parser.h"
|
88
|
+
#include "ruby_xml_xinclude.h"
|
89
|
+
#include "ruby_xml_xpath.h"
|
90
|
+
#include "ruby_xml_xpath_expression.h"
|
91
|
+
#include "ruby_xml_xpath_context.h"
|
92
|
+
#include "ruby_xml_xpath_object.h"
|
93
|
+
#include "ruby_xml_xpointer.h"
|
94
|
+
#include "ruby_xml_input_cbg.h"
|
95
|
+
#include "ruby_xml_dtd.h"
|
96
|
+
#include "ruby_xml_schema.h"
|
97
|
+
#include "ruby_xml_relaxng.h"
|
98
|
+
|
99
|
+
extern VALUE mLibXML;
|
100
|
+
|
101
|
+
#endif
|
@@ -0,0 +1,893 @@
|
|
1
|
+
#include "ruby_libxml.h"
|
2
|
+
#include "ruby_xml.h"
|
3
|
+
|
4
|
+
VALUE mXML;
|
5
|
+
|
6
|
+
/*
|
7
|
+
* call-seq:
|
8
|
+
* XML.catalog_dump -> true
|
9
|
+
*
|
10
|
+
* Dump all the global catalog content stdout.
|
11
|
+
*/
|
12
|
+
static VALUE rxml_catalog_dump(VALUE self)
|
13
|
+
{
|
14
|
+
xmlCatalogDump(stdout);
|
15
|
+
return (Qtrue);
|
16
|
+
}
|
17
|
+
|
18
|
+
/*
|
19
|
+
* call-seq:
|
20
|
+
* XML.catalog_remove(catalog) -> true
|
21
|
+
*
|
22
|
+
* Remove the specified resource catalog.
|
23
|
+
*/
|
24
|
+
static VALUE rxml_catalog_remove(VALUE self, VALUE cat)
|
25
|
+
{
|
26
|
+
Check_Type(cat, T_STRING);
|
27
|
+
xmlCatalogRemove((xmlChar *) StringValuePtr(cat));
|
28
|
+
return (Qtrue);
|
29
|
+
}
|
30
|
+
|
31
|
+
/*
|
32
|
+
* call-seq:
|
33
|
+
* XML.check_lib_versions -> true
|
34
|
+
*
|
35
|
+
* Check LIBXML version matches version the bindings
|
36
|
+
* were compiled to. Throws an exception if not.
|
37
|
+
*/
|
38
|
+
static VALUE rxml_check_lib_versions(VALUE klass)
|
39
|
+
{
|
40
|
+
xmlCheckVersion(LIBXML_VERSION);
|
41
|
+
return (Qtrue);
|
42
|
+
}
|
43
|
+
|
44
|
+
/*
|
45
|
+
* call-seq:
|
46
|
+
* XML.enabled_automata? -> (true|false)
|
47
|
+
*
|
48
|
+
* Determine whether libxml regexp automata support is enabled.
|
49
|
+
*/
|
50
|
+
static VALUE rxml_enabled_automata_q(VALUE klass)
|
51
|
+
{
|
52
|
+
#ifdef LIBXML_AUTOMATA_ENABLED
|
53
|
+
return(Qtrue);
|
54
|
+
#else
|
55
|
+
return (Qfalse);
|
56
|
+
#endif
|
57
|
+
}
|
58
|
+
|
59
|
+
/*
|
60
|
+
* call-seq:
|
61
|
+
* XML.enabled_c14n? -> (true|false)
|
62
|
+
*
|
63
|
+
* Determine whether libxml 'canonical XML' support is enabled.
|
64
|
+
* See "Canonical XML" (http://www.w3.org/TR/xml-c14n)
|
65
|
+
*/
|
66
|
+
static VALUE rxml_enabled_c14n_q(VALUE klass)
|
67
|
+
{
|
68
|
+
#ifdef LIBXML_C14N_ENABLED
|
69
|
+
return(Qtrue);
|
70
|
+
#else
|
71
|
+
return (Qfalse);
|
72
|
+
#endif
|
73
|
+
}
|
74
|
+
|
75
|
+
/*
|
76
|
+
* call-seq:
|
77
|
+
* XML.enabled_catalog? -> (true|false)
|
78
|
+
*
|
79
|
+
* Determine whether libxml resource catalog support is enabled.
|
80
|
+
*/
|
81
|
+
static VALUE rxml_enabled_catalog_q(VALUE klass)
|
82
|
+
{
|
83
|
+
#ifdef LIBXML_CATALOG_ENABLED
|
84
|
+
return(Qtrue);
|
85
|
+
#else
|
86
|
+
return (Qfalse);
|
87
|
+
#endif
|
88
|
+
}
|
89
|
+
|
90
|
+
/*
|
91
|
+
* call-seq:
|
92
|
+
* XML.enabled_debug? -> (true|false)
|
93
|
+
*
|
94
|
+
* Determine whether libxml debugging support is enabled.
|
95
|
+
*/
|
96
|
+
static VALUE rxml_enabled_debug_q(VALUE klass)
|
97
|
+
{
|
98
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
99
|
+
return(Qtrue);
|
100
|
+
#else
|
101
|
+
return (Qfalse);
|
102
|
+
#endif
|
103
|
+
}
|
104
|
+
|
105
|
+
/*
|
106
|
+
* call-seq:
|
107
|
+
* XML.enabled_docbook? -> (true|false)
|
108
|
+
*
|
109
|
+
* Determine whether libxml docbook support is enabled.
|
110
|
+
*/
|
111
|
+
static VALUE rxml_enabled_docbook_q(VALUE klass)
|
112
|
+
{
|
113
|
+
#ifdef LIBXML_DOCB_ENABLED
|
114
|
+
return(Qtrue);
|
115
|
+
#else
|
116
|
+
return (Qfalse);
|
117
|
+
#endif
|
118
|
+
}
|
119
|
+
|
120
|
+
/*
|
121
|
+
* call-seq:
|
122
|
+
* XML.enabled_ftp? -> (true|false)
|
123
|
+
*
|
124
|
+
* Determine whether libxml ftp client support is enabled.
|
125
|
+
*/
|
126
|
+
static VALUE rxml_enabled_ftp_q(VALUE klass)
|
127
|
+
{
|
128
|
+
#ifdef LIBXML_FTP_ENABLED
|
129
|
+
return(Qtrue);
|
130
|
+
#else
|
131
|
+
return (Qfalse);
|
132
|
+
#endif
|
133
|
+
}
|
134
|
+
|
135
|
+
/*
|
136
|
+
* call-seq:
|
137
|
+
* XML.enabled_http? -> (true|false)
|
138
|
+
*
|
139
|
+
* Determine whether libxml http client support is enabled.
|
140
|
+
*/
|
141
|
+
static VALUE rxml_enabled_http_q(VALUE klass)
|
142
|
+
{
|
143
|
+
#ifdef LIBXML_HTTP_ENABLED
|
144
|
+
return(Qtrue);
|
145
|
+
#else
|
146
|
+
return (Qfalse);
|
147
|
+
#endif
|
148
|
+
}
|
149
|
+
|
150
|
+
/*
|
151
|
+
* call-seq:
|
152
|
+
* XML.enabled_html? -> (true|false)
|
153
|
+
*
|
154
|
+
* Determine whether libxml html support is enabled.
|
155
|
+
*/
|
156
|
+
static VALUE rxml_enabled_html_q(VALUE klass)
|
157
|
+
{
|
158
|
+
#ifdef LIBXML_HTML_ENABLED
|
159
|
+
return(Qtrue);
|
160
|
+
#else
|
161
|
+
return (Qfalse);
|
162
|
+
#endif
|
163
|
+
}
|
164
|
+
|
165
|
+
/*
|
166
|
+
* call-seq:
|
167
|
+
* XML.enabled_iconv? -> (true|false)
|
168
|
+
*
|
169
|
+
* Determine whether libxml iconv support is enabled.
|
170
|
+
*/
|
171
|
+
static VALUE rxml_enabled_iconv_q(VALUE klass)
|
172
|
+
{
|
173
|
+
#ifdef LIBXML_ICONV_ENABLED
|
174
|
+
return(Qtrue);
|
175
|
+
#else
|
176
|
+
return (Qfalse);
|
177
|
+
#endif
|
178
|
+
}
|
179
|
+
|
180
|
+
/*
|
181
|
+
* call-seq:
|
182
|
+
* XML.enabled_memory_debug? -> (true|false)
|
183
|
+
*
|
184
|
+
* Determine whether libxml memory location debugging support
|
185
|
+
* is enabled.
|
186
|
+
*/
|
187
|
+
static VALUE rxml_enabled_memory_debug_location_q(VALUE klass)
|
188
|
+
{
|
189
|
+
#ifdef DEBUG_MEMORY_LOCATION
|
190
|
+
return(Qtrue);
|
191
|
+
#else
|
192
|
+
return (Qfalse);
|
193
|
+
#endif
|
194
|
+
}
|
195
|
+
|
196
|
+
/*
|
197
|
+
* call-seq:
|
198
|
+
* XML.enabled_regexp? -> (true|false)
|
199
|
+
*
|
200
|
+
* Determine whether libxml regular expression support is enabled.
|
201
|
+
*/
|
202
|
+
static VALUE rxml_enabled_regexp_q(VALUE klass)
|
203
|
+
{
|
204
|
+
#ifdef LIBXML_REGEXP_ENABLED
|
205
|
+
return(Qtrue);
|
206
|
+
#else
|
207
|
+
return (Qfalse);
|
208
|
+
#endif
|
209
|
+
}
|
210
|
+
|
211
|
+
/*
|
212
|
+
* call-seq:
|
213
|
+
* XML.enabled_schemas? -> (true|false)
|
214
|
+
*
|
215
|
+
* Determine whether libxml schema support is enabled.
|
216
|
+
*/
|
217
|
+
static VALUE rxml_enabled_schemas_q(VALUE klass)
|
218
|
+
{
|
219
|
+
#ifdef LIBXML_SCHEMAS_ENABLED
|
220
|
+
return(Qtrue);
|
221
|
+
#else
|
222
|
+
return (Qfalse);
|
223
|
+
#endif
|
224
|
+
}
|
225
|
+
|
226
|
+
/*
|
227
|
+
* call-seq:
|
228
|
+
* XML.enabled_thread? -> (true|false)
|
229
|
+
*
|
230
|
+
* Determine whether thread-safe semantics support for libxml is enabled and
|
231
|
+
* is used by this ruby extension. Threading support in libxml uses pthread
|
232
|
+
* on Unix-like systems and Win32 threads on Windows.
|
233
|
+
*/
|
234
|
+
static VALUE rxml_enabled_thread_q(VALUE klass)
|
235
|
+
{
|
236
|
+
/* This won't be defined unless this code is compiled with _REENTRANT or __MT__
|
237
|
+
* defined or the compiler is in C99 mode.
|
238
|
+
*
|
239
|
+
* Note the relevant portion libxml/xmlversion.h on a thread-enabled build:
|
240
|
+
*
|
241
|
+
* #if defined(_REENTRANT) || defined(__MT__) || \
|
242
|
+
* (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE - 0 >= 199506L))
|
243
|
+
* #define LIBXML_THREAD_ENABLED
|
244
|
+
* #endif
|
245
|
+
*
|
246
|
+
*/
|
247
|
+
#ifdef LIBXML_THREAD_ENABLED
|
248
|
+
return(Qtrue);
|
249
|
+
#else
|
250
|
+
return (Qfalse);
|
251
|
+
#endif
|
252
|
+
}
|
253
|
+
|
254
|
+
/*
|
255
|
+
* call-seq:
|
256
|
+
* XML.enabled_unicode? -> (true|false)
|
257
|
+
*
|
258
|
+
* Determine whether libxml unicode support is enabled.
|
259
|
+
*/
|
260
|
+
static VALUE rxml_enabled_unicode_q(VALUE klass)
|
261
|
+
{
|
262
|
+
#ifdef LIBXML_UNICODE_ENABLED
|
263
|
+
return(Qtrue);
|
264
|
+
#else
|
265
|
+
return (Qfalse);
|
266
|
+
#endif
|
267
|
+
}
|
268
|
+
|
269
|
+
/*
|
270
|
+
* call-seq:
|
271
|
+
* XML.enabled_xinclude? -> (true|false)
|
272
|
+
*
|
273
|
+
* Determine whether libxml xinclude support is enabled.
|
274
|
+
*/
|
275
|
+
static VALUE rxml_enabled_xinclude_q(VALUE klass)
|
276
|
+
{
|
277
|
+
#ifdef LIBXML_XINCLUDE_ENABLED
|
278
|
+
return(Qtrue);
|
279
|
+
#else
|
280
|
+
return (Qfalse);
|
281
|
+
#endif
|
282
|
+
}
|
283
|
+
|
284
|
+
/*
|
285
|
+
* call-seq:
|
286
|
+
* XML.enabled_xpath? -> (true|false)
|
287
|
+
*
|
288
|
+
* Determine whether libxml xpath support is enabled.
|
289
|
+
*/
|
290
|
+
static VALUE rxml_enabled_xpath_q(VALUE klass)
|
291
|
+
{
|
292
|
+
#ifdef LIBXML_XPATH_ENABLED
|
293
|
+
return(Qtrue);
|
294
|
+
#else
|
295
|
+
return (Qfalse);
|
296
|
+
#endif
|
297
|
+
}
|
298
|
+
|
299
|
+
/*
|
300
|
+
* call-seq:
|
301
|
+
* XML.enabled_xpointer? -> (true|false)
|
302
|
+
*
|
303
|
+
* Determine whether libxml xpointer support is enabled.
|
304
|
+
*/
|
305
|
+
static VALUE rxml_enabled_xpointer_q(VALUE klass)
|
306
|
+
{
|
307
|
+
#ifdef LIBXML_XPTR_ENABLED
|
308
|
+
return(Qtrue);
|
309
|
+
#else
|
310
|
+
return (Qfalse);
|
311
|
+
#endif
|
312
|
+
}
|
313
|
+
|
314
|
+
/*
|
315
|
+
* call-seq:
|
316
|
+
* XML.enabled_zlib? -> (true|false)
|
317
|
+
*
|
318
|
+
* Determine whether libxml zlib support is enabled.
|
319
|
+
*/
|
320
|
+
static VALUE rxml_enabled_zlib_q(VALUE klass)
|
321
|
+
{
|
322
|
+
#ifdef HAVE_ZLIB_H
|
323
|
+
return(Qtrue);
|
324
|
+
#else
|
325
|
+
return (Qfalse);
|
326
|
+
#endif
|
327
|
+
}
|
328
|
+
|
329
|
+
/*
|
330
|
+
* call-seq:
|
331
|
+
* XML.debug_entities -> (true|false)
|
332
|
+
*
|
333
|
+
* Determine whether included-entity debugging is enabled.
|
334
|
+
* (Requires Libxml to be compiled with debugging support)
|
335
|
+
*/
|
336
|
+
static VALUE rxml_debug_entities_get(VALUE klass)
|
337
|
+
{
|
338
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
339
|
+
if (xmlParserDebugEntities)
|
340
|
+
return(Qtrue);
|
341
|
+
else
|
342
|
+
return(Qfalse);
|
343
|
+
#else
|
344
|
+
rb_warn("libxml was compiled with debugging turned off");
|
345
|
+
return (Qfalse);
|
346
|
+
#endif
|
347
|
+
}
|
348
|
+
|
349
|
+
/*
|
350
|
+
* call-seq:
|
351
|
+
* XML.debug_entities = true|false
|
352
|
+
*
|
353
|
+
* Enable or disable included-entity debugging.
|
354
|
+
* (Requires Libxml to be compiled with debugging support)
|
355
|
+
*/
|
356
|
+
static VALUE rxml_debug_entities_set(VALUE klass, VALUE bool)
|
357
|
+
{
|
358
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
359
|
+
if (TYPE(bool) == T_FALSE)
|
360
|
+
{
|
361
|
+
xmlParserDebugEntities = 0;
|
362
|
+
return(Qfalse);
|
363
|
+
}
|
364
|
+
else
|
365
|
+
{
|
366
|
+
xmlParserDebugEntities = 1;
|
367
|
+
return(Qtrue);
|
368
|
+
}
|
369
|
+
#else
|
370
|
+
rb_warn("libxml was compiled with debugging turned off");
|
371
|
+
#endif
|
372
|
+
}
|
373
|
+
|
374
|
+
/*
|
375
|
+
* call-seq:
|
376
|
+
* XML.default_keep_blanks -> (true|false)
|
377
|
+
*
|
378
|
+
* Determine whether parsers retain whitespace by default.
|
379
|
+
*/
|
380
|
+
static VALUE rxml_default_keep_blanks_get(VALUE klass)
|
381
|
+
{
|
382
|
+
if (xmlKeepBlanksDefaultValue)
|
383
|
+
return (Qtrue);
|
384
|
+
else
|
385
|
+
return (Qfalse);
|
386
|
+
}
|
387
|
+
|
388
|
+
/*
|
389
|
+
* call-seq:
|
390
|
+
* XML.default_keep_blanks = true|false
|
391
|
+
*
|
392
|
+
* Controls whether parsers retain whitespace by default.
|
393
|
+
*/
|
394
|
+
static VALUE rxml_default_keep_blanks_set(VALUE klass, VALUE bool)
|
395
|
+
{
|
396
|
+
if (TYPE(bool) == T_FALSE)
|
397
|
+
{
|
398
|
+
xmlKeepBlanksDefaultValue = 0;
|
399
|
+
return (Qfalse);
|
400
|
+
}
|
401
|
+
else if (TYPE(bool) == T_TRUE)
|
402
|
+
{
|
403
|
+
xmlKeepBlanksDefaultValue = 1;
|
404
|
+
return (Qtrue);
|
405
|
+
}
|
406
|
+
else
|
407
|
+
{
|
408
|
+
rb_raise(rb_eArgError, "Invalid argument, must be a boolean");
|
409
|
+
}
|
410
|
+
}
|
411
|
+
|
412
|
+
/*
|
413
|
+
* call-seq:
|
414
|
+
* XML.default_load_external_dtd -> (true|false)
|
415
|
+
*
|
416
|
+
* Determine whether parsers load external DTDs by default.
|
417
|
+
*/
|
418
|
+
static VALUE rxml_default_load_external_dtd_get(VALUE klass)
|
419
|
+
{
|
420
|
+
if (xmlLoadExtDtdDefaultValue)
|
421
|
+
return (Qtrue);
|
422
|
+
else
|
423
|
+
return (Qfalse);
|
424
|
+
}
|
425
|
+
|
426
|
+
/*
|
427
|
+
* call-seq:
|
428
|
+
* XML.default_load_external_dtd = true|false
|
429
|
+
*
|
430
|
+
* Controls whether parsers load external DTDs by default.
|
431
|
+
*/
|
432
|
+
static VALUE rxml_default_load_external_dtd_set(VALUE klass, VALUE bool)
|
433
|
+
{
|
434
|
+
if (bool == Qfalse)
|
435
|
+
{
|
436
|
+
xmlLoadExtDtdDefaultValue = 0;
|
437
|
+
return (Qfalse);
|
438
|
+
}
|
439
|
+
else
|
440
|
+
{
|
441
|
+
xmlLoadExtDtdDefaultValue = 1;
|
442
|
+
return (Qtrue);
|
443
|
+
}
|
444
|
+
}
|
445
|
+
|
446
|
+
/*
|
447
|
+
* call-seq:
|
448
|
+
* XML.default_line_numbers -> (true|false)
|
449
|
+
*
|
450
|
+
* Determine whether parsers retain line-numbers by default.
|
451
|
+
*/
|
452
|
+
static VALUE rxml_default_line_numbers_get(VALUE klass)
|
453
|
+
{
|
454
|
+
if (xmlLineNumbersDefaultValue)
|
455
|
+
return (Qtrue);
|
456
|
+
else
|
457
|
+
return (Qfalse);
|
458
|
+
}
|
459
|
+
|
460
|
+
/*
|
461
|
+
* call-seq:
|
462
|
+
* XML.default_line_numbers = true|false
|
463
|
+
*
|
464
|
+
* Controls whether parsers retain line-numbers by default.
|
465
|
+
*/
|
466
|
+
static VALUE rxml_default_line_numbers_set(VALUE klass, VALUE bool)
|
467
|
+
{
|
468
|
+
if (TYPE(bool) == T_FALSE)
|
469
|
+
{
|
470
|
+
xmlLineNumbersDefault(0);
|
471
|
+
return (Qfalse);
|
472
|
+
}
|
473
|
+
else
|
474
|
+
{
|
475
|
+
xmlLineNumbersDefault(1);
|
476
|
+
return (Qtrue);
|
477
|
+
}
|
478
|
+
}
|
479
|
+
|
480
|
+
int rxml_libxml_default_options()
|
481
|
+
{
|
482
|
+
int options = 0;
|
483
|
+
|
484
|
+
if (xmlLoadExtDtdDefaultValue)
|
485
|
+
options |= XML_PARSE_DTDLOAD;
|
486
|
+
|
487
|
+
if (xmlDoValidityCheckingDefaultValue)
|
488
|
+
options |= XML_PARSE_DTDVALID;
|
489
|
+
|
490
|
+
if (!xmlKeepBlanksDefaultValue)
|
491
|
+
options |= XML_PARSE_NOBLANKS;
|
492
|
+
|
493
|
+
if (xmlSubstituteEntitiesDefaultValue)
|
494
|
+
options |= XML_PARSE_NOENT;
|
495
|
+
|
496
|
+
if (!xmlGetWarningsDefaultValue)
|
497
|
+
options |= XML_PARSE_NOWARNING;
|
498
|
+
|
499
|
+
if (xmlPedanticParserDefaultValue)
|
500
|
+
options |= XML_PARSE_PEDANTIC;
|
501
|
+
|
502
|
+
return options;
|
503
|
+
}
|
504
|
+
|
505
|
+
/*
|
506
|
+
* call-seq:
|
507
|
+
* XML.default_options -> int
|
508
|
+
*
|
509
|
+
* Returns an integer that summarize libxml2's default options.
|
510
|
+
*/
|
511
|
+
static VALUE rxml_default_options_get(VALUE klass)
|
512
|
+
{
|
513
|
+
int options = rxml_libxml_default_options();
|
514
|
+
return INT2NUM(options);
|
515
|
+
}
|
516
|
+
|
517
|
+
/*
|
518
|
+
* call-seq:
|
519
|
+
* XML.default_pedantic_parser -> (true|false)
|
520
|
+
*
|
521
|
+
* Determine whether parsers are pedantic by default.
|
522
|
+
*/
|
523
|
+
static VALUE rxml_default_pedantic_parser_get(VALUE klass)
|
524
|
+
{
|
525
|
+
if (xmlPedanticParserDefaultValue)
|
526
|
+
return (Qtrue);
|
527
|
+
else
|
528
|
+
return (Qfalse);
|
529
|
+
}
|
530
|
+
|
531
|
+
/*
|
532
|
+
* call-seq:
|
533
|
+
* XML.default_pedantic_parser = true|false
|
534
|
+
*
|
535
|
+
* Controls whether parsers are pedantic by default.
|
536
|
+
*/
|
537
|
+
static VALUE rxml_default_pedantic_parser_set(VALUE klass, VALUE bool)
|
538
|
+
{
|
539
|
+
if (TYPE(bool) == T_FALSE)
|
540
|
+
{
|
541
|
+
xmlPedanticParserDefault(0);
|
542
|
+
return (Qfalse);
|
543
|
+
}
|
544
|
+
else
|
545
|
+
{
|
546
|
+
xmlPedanticParserDefault(1);
|
547
|
+
return (Qtrue);
|
548
|
+
}
|
549
|
+
}
|
550
|
+
|
551
|
+
/*
|
552
|
+
* call-seq:
|
553
|
+
* XML.default_substitute_entities -> (true|false)
|
554
|
+
*
|
555
|
+
* Determine whether parsers perform inline entity substitution
|
556
|
+
* (for external entities) by default.
|
557
|
+
*/
|
558
|
+
static VALUE rxml_default_substitute_entities_get(VALUE klass)
|
559
|
+
{
|
560
|
+
if (xmlSubstituteEntitiesDefaultValue)
|
561
|
+
return (Qtrue);
|
562
|
+
else
|
563
|
+
return (Qfalse);
|
564
|
+
}
|
565
|
+
|
566
|
+
/*
|
567
|
+
* call-seq:
|
568
|
+
* XML.default_substitute_entities = true|false
|
569
|
+
*
|
570
|
+
* Controls whether parsers perform inline entity substitution
|
571
|
+
* (for external entities) by default.
|
572
|
+
*/
|
573
|
+
static VALUE rxml_default_substitute_entities_set(VALUE klass, VALUE bool)
|
574
|
+
{
|
575
|
+
if (bool == Qfalse)
|
576
|
+
{
|
577
|
+
xmlSubstituteEntitiesDefault(0);
|
578
|
+
return (Qfalse);
|
579
|
+
}
|
580
|
+
else
|
581
|
+
{
|
582
|
+
xmlSubstituteEntitiesDefault(1);
|
583
|
+
return (Qtrue);
|
584
|
+
}
|
585
|
+
}
|
586
|
+
|
587
|
+
/*
|
588
|
+
* call-seq:
|
589
|
+
* XML.default_tree_indent_string -> "string"
|
590
|
+
*
|
591
|
+
* Obtain the default string used by parsers to indent the XML tree
|
592
|
+
* for output.
|
593
|
+
*/
|
594
|
+
static VALUE rxml_default_tree_indent_string_get(VALUE klass)
|
595
|
+
{
|
596
|
+
if (xmlTreeIndentString == NULL)
|
597
|
+
return (Qnil);
|
598
|
+
else
|
599
|
+
return (rb_str_new2(xmlTreeIndentString));
|
600
|
+
}
|
601
|
+
|
602
|
+
/*
|
603
|
+
* call-seq:
|
604
|
+
* XML.default_tree_indent_string = "string"
|
605
|
+
*
|
606
|
+
* Set the default string used by parsers to indent the XML tree
|
607
|
+
* for output.
|
608
|
+
*/
|
609
|
+
static VALUE rxml_default_tree_indent_string_set(VALUE klass, VALUE string)
|
610
|
+
{
|
611
|
+
Check_Type(string, T_STRING);
|
612
|
+
xmlTreeIndentString = xmlStrdup((xmlChar *)StringValuePtr(string));
|
613
|
+
return (string);
|
614
|
+
}
|
615
|
+
|
616
|
+
/*
|
617
|
+
* call-seq:
|
618
|
+
* XML.default_validity_checking -> (true|false)
|
619
|
+
*
|
620
|
+
* Determine whether parsers perform XML validation by default.
|
621
|
+
*/
|
622
|
+
static VALUE rxml_default_validity_checking_get(VALUE klass)
|
623
|
+
{
|
624
|
+
if (xmlDoValidityCheckingDefaultValue)
|
625
|
+
return (Qtrue);
|
626
|
+
else
|
627
|
+
return (Qfalse);
|
628
|
+
}
|
629
|
+
|
630
|
+
/*
|
631
|
+
* call-seq:
|
632
|
+
* XML.default_validity_checking = true|false
|
633
|
+
*
|
634
|
+
* Controls whether parsers perform XML validation by default.
|
635
|
+
*/
|
636
|
+
static VALUE rxml_default_validity_checking_set(VALUE klass, VALUE bool)
|
637
|
+
{
|
638
|
+
if (TYPE(bool) == T_FALSE)
|
639
|
+
{
|
640
|
+
xmlDoValidityCheckingDefaultValue = 0;
|
641
|
+
return (Qfalse);
|
642
|
+
}
|
643
|
+
else
|
644
|
+
{
|
645
|
+
xmlDoValidityCheckingDefaultValue = 1;
|
646
|
+
return (Qtrue);
|
647
|
+
}
|
648
|
+
}
|
649
|
+
|
650
|
+
/*
|
651
|
+
* call-seq:
|
652
|
+
* XML.default_warnings -> (true|false)
|
653
|
+
*
|
654
|
+
* Determine whether parsers output warnings by default.
|
655
|
+
*/
|
656
|
+
static VALUE rxml_default_warnings_get(VALUE klass)
|
657
|
+
{
|
658
|
+
if (xmlGetWarningsDefaultValue)
|
659
|
+
return (Qtrue);
|
660
|
+
else
|
661
|
+
return (Qfalse);
|
662
|
+
}
|
663
|
+
|
664
|
+
/*
|
665
|
+
* call-seq:
|
666
|
+
* XML.default_warnings = true|false
|
667
|
+
*
|
668
|
+
* Controls whether parsers output warnings by default.
|
669
|
+
*/
|
670
|
+
static VALUE rxml_default_warnings_set(VALUE klass, VALUE bool)
|
671
|
+
{
|
672
|
+
if (TYPE(bool) == T_FALSE)
|
673
|
+
{
|
674
|
+
xmlGetWarningsDefaultValue = 0;
|
675
|
+
return (Qfalse);
|
676
|
+
}
|
677
|
+
else
|
678
|
+
{
|
679
|
+
xmlGetWarningsDefaultValue = 1;
|
680
|
+
return (Qtrue);
|
681
|
+
}
|
682
|
+
}
|
683
|
+
|
684
|
+
/*
|
685
|
+
* call-seq:
|
686
|
+
* XML.default_compression -> (true|false)
|
687
|
+
*
|
688
|
+
* Determine whether parsers use Zlib compression by default
|
689
|
+
* (requires libxml to be compiled with Zlib support).
|
690
|
+
*/
|
691
|
+
static VALUE rxml_default_compression_get(VALUE klass)
|
692
|
+
{
|
693
|
+
#ifdef HAVE_ZLIB_H
|
694
|
+
return(INT2FIX(xmlGetCompressMode()));
|
695
|
+
#else
|
696
|
+
rb_warn("libxml was compiled without zlib support");
|
697
|
+
return (Qfalse);
|
698
|
+
#endif
|
699
|
+
}
|
700
|
+
|
701
|
+
/*
|
702
|
+
* call-seq:
|
703
|
+
* XML.default_compression = true|false
|
704
|
+
*
|
705
|
+
* Controls whether parsers use Zlib compression by default
|
706
|
+
* (requires libxml to be compiled with Zlib support).
|
707
|
+
*/
|
708
|
+
static VALUE rxml_default_compression_set(VALUE klass, VALUE num)
|
709
|
+
{
|
710
|
+
#ifdef HAVE_ZLIB_H
|
711
|
+
Check_Type(num, T_FIXNUM);
|
712
|
+
xmlSetCompressMode(FIX2INT(num));
|
713
|
+
return(num);
|
714
|
+
#else
|
715
|
+
rb_warn("libxml was compiled without zlib support");
|
716
|
+
return (Qfalse);
|
717
|
+
#endif
|
718
|
+
}
|
719
|
+
|
720
|
+
/*
|
721
|
+
* call-seq:
|
722
|
+
* XML.features -> ["feature", ..., "feature"]
|
723
|
+
*
|
724
|
+
* Obtains an array of strings representing features supported
|
725
|
+
* (and enabled) by the installed libxml.
|
726
|
+
*/
|
727
|
+
static VALUE rxml_features(VALUE klass)
|
728
|
+
{
|
729
|
+
VALUE arr, str;
|
730
|
+
int i, len = MAX_LIBXML_FEATURES_LEN;
|
731
|
+
char **list = NULL;
|
732
|
+
|
733
|
+
list = ALLOC_N(char *,MAX_LIBXML_FEATURES_LEN);
|
734
|
+
MEMZERO(list, char *, MAX_LIBXML_FEATURES_LEN);
|
735
|
+
|
736
|
+
arr = rb_ary_new();
|
737
|
+
if (xmlGetFeaturesList(&len, (const char **) list) == -1)
|
738
|
+
return Qnil;
|
739
|
+
|
740
|
+
for (i = 0; i < len; i++)
|
741
|
+
{
|
742
|
+
str = rb_str_new2((const char *) list[i]);
|
743
|
+
rb_gc_unregister_address(&str);
|
744
|
+
rb_ary_push(arr, str);
|
745
|
+
}
|
746
|
+
|
747
|
+
if (len == MAX_LIBXML_FEATURES_LEN)
|
748
|
+
rb_warn(
|
749
|
+
"Please contact libxml-devel@rubyforge.org and ask to have the \"MAX_LIBXML_FEATURES_LEN increased\" because you could possibly be seeing an incomplete list");
|
750
|
+
|
751
|
+
ruby_xfree(list);
|
752
|
+
return (arr);
|
753
|
+
}
|
754
|
+
|
755
|
+
/*
|
756
|
+
* call-seq:
|
757
|
+
* XML.indent_tree_output -> (true|false)
|
758
|
+
*
|
759
|
+
* Determines whether XML output will be indented
|
760
|
+
* (using the string supplied to +default_indent_tree_string+)
|
761
|
+
*/
|
762
|
+
static VALUE rxml_indent_tree_output_get(VALUE klass)
|
763
|
+
{
|
764
|
+
if (xmlIndentTreeOutput)
|
765
|
+
return (Qtrue);
|
766
|
+
else
|
767
|
+
return (Qfalse);
|
768
|
+
}
|
769
|
+
|
770
|
+
/*
|
771
|
+
* call-seq:
|
772
|
+
* XML.indent_tree_output = true|false
|
773
|
+
*
|
774
|
+
* Controls whether XML output will be indented
|
775
|
+
* (using the string supplied to +default_indent_tree_string+)
|
776
|
+
*/
|
777
|
+
static VALUE rxml_indent_tree_output_set(VALUE klass, VALUE bool)
|
778
|
+
{
|
779
|
+
if (TYPE(bool) == T_TRUE)
|
780
|
+
{
|
781
|
+
xmlIndentTreeOutput = 1;
|
782
|
+
return (Qtrue);
|
783
|
+
}
|
784
|
+
else if (TYPE(bool) == T_FALSE)
|
785
|
+
{
|
786
|
+
xmlIndentTreeOutput = 0;
|
787
|
+
return (Qfalse);
|
788
|
+
}
|
789
|
+
else
|
790
|
+
{
|
791
|
+
rb_raise(rb_eArgError, "Invalid argument, must be boolean");
|
792
|
+
}
|
793
|
+
}
|
794
|
+
|
795
|
+
/*
|
796
|
+
* call-seq:
|
797
|
+
* XML.memory_dump -> (true|false)
|
798
|
+
*
|
799
|
+
* Perform a parser memory dump (requires memory debugging
|
800
|
+
* support in libxml).
|
801
|
+
*/
|
802
|
+
static VALUE rxml_memory_dump(VALUE self)
|
803
|
+
{
|
804
|
+
#ifdef DEBUG_MEMORY_LOCATION
|
805
|
+
xmlMemoryDump();
|
806
|
+
return(Qtrue);
|
807
|
+
#else
|
808
|
+
rb_warn("libxml was compiled without memory debugging support");
|
809
|
+
return (Qfalse);
|
810
|
+
#endif
|
811
|
+
}
|
812
|
+
|
813
|
+
/*
|
814
|
+
* call-seq:
|
815
|
+
* XML.memory_used -> num_bytes
|
816
|
+
*
|
817
|
+
* Perform a parser memory dump (requires memory debugging
|
818
|
+
* support in libxml).
|
819
|
+
*/
|
820
|
+
static VALUE rxml_memory_used(VALUE self)
|
821
|
+
{
|
822
|
+
#ifdef DEBUG_MEMORY_LOCATION
|
823
|
+
return(INT2NUM(xmlMemUsed()));
|
824
|
+
#else
|
825
|
+
rb_warn("libxml was compiled without memory debugging support");
|
826
|
+
return (Qfalse);
|
827
|
+
#endif
|
828
|
+
}
|
829
|
+
|
830
|
+
/* The libxml gem provides Ruby language bindings for GNOME's Libxml2
|
831
|
+
* XML toolkit. Refer to the README file to get started
|
832
|
+
* and the LICENSE file for copyright and distribution information.
|
833
|
+
*/
|
834
|
+
|
835
|
+
void rxml_init_xml(void)
|
836
|
+
{
|
837
|
+
mXML = rb_define_module_under(mLibXML, "XML");
|
838
|
+
|
839
|
+
/* Constants */
|
840
|
+
rb_define_const(mXML, "LIBXML_VERSION", rb_str_new2(LIBXML_DOTTED_VERSION));
|
841
|
+
rb_define_const(mXML, "VERSION", rb_str_new2(RUBY_LIBXML_VERSION));
|
842
|
+
rb_define_const(mXML, "VERNUM", INT2NUM(RUBY_LIBXML_VERNUM));
|
843
|
+
rb_define_const(mXML, "XML_NAMESPACE", rb_str_new2((const char*) XML_XML_NAMESPACE));
|
844
|
+
|
845
|
+
rb_define_module_function(mXML, "enabled_automata?", rxml_enabled_automata_q, 0);
|
846
|
+
rb_define_module_function(mXML, "enabled_c14n?", rxml_enabled_c14n_q, 0);
|
847
|
+
rb_define_module_function(mXML, "enabled_catalog?", rxml_enabled_catalog_q, 0);
|
848
|
+
rb_define_module_function(mXML, "enabled_debug?", rxml_enabled_debug_q, 0);
|
849
|
+
rb_define_module_function(mXML, "enabled_docbook?", rxml_enabled_docbook_q, 0);
|
850
|
+
rb_define_module_function(mXML, "enabled_ftp?", rxml_enabled_ftp_q, 0);
|
851
|
+
rb_define_module_function(mXML, "enabled_http?", rxml_enabled_http_q, 0);
|
852
|
+
rb_define_module_function(mXML, "enabled_html?", rxml_enabled_html_q, 0);
|
853
|
+
rb_define_module_function(mXML, "enabled_iconv?", rxml_enabled_iconv_q, 0);
|
854
|
+
rb_define_module_function(mXML, "enabled_memory_debug?", rxml_enabled_memory_debug_location_q, 0);
|
855
|
+
rb_define_module_function(mXML, "enabled_regexp?", rxml_enabled_regexp_q, 0);
|
856
|
+
rb_define_module_function(mXML, "enabled_schemas?", rxml_enabled_schemas_q, 0);
|
857
|
+
rb_define_module_function(mXML, "enabled_thread?", rxml_enabled_thread_q, 0);
|
858
|
+
rb_define_module_function(mXML, "enabled_unicode?", rxml_enabled_unicode_q, 0);
|
859
|
+
rb_define_module_function(mXML, "enabled_xinclude?", rxml_enabled_xinclude_q, 0);
|
860
|
+
rb_define_module_function(mXML, "enabled_xpath?", rxml_enabled_xpath_q, 0);
|
861
|
+
rb_define_module_function(mXML, "enabled_xpointer?", rxml_enabled_xpointer_q, 0);
|
862
|
+
rb_define_module_function(mXML, "enabled_zlib?", rxml_enabled_zlib_q, 0);
|
863
|
+
|
864
|
+
rb_define_module_function(mXML, "catalog_dump", rxml_catalog_dump, 0);
|
865
|
+
rb_define_module_function(mXML, "catalog_remove", rxml_catalog_remove, 1);
|
866
|
+
rb_define_module_function(mXML, "check_lib_versions", rxml_check_lib_versions, 0);
|
867
|
+
rb_define_module_function(mXML, "debug_entities", rxml_debug_entities_get, 0);
|
868
|
+
rb_define_module_function(mXML, "debug_entities=", rxml_debug_entities_set, 1);
|
869
|
+
rb_define_module_function(mXML, "default_compression", rxml_default_compression_get, 0);
|
870
|
+
rb_define_module_function(mXML, "default_compression=", rxml_default_compression_set, 1);
|
871
|
+
rb_define_module_function(mXML, "default_keep_blanks", rxml_default_keep_blanks_get, 0);
|
872
|
+
rb_define_module_function(mXML, "default_keep_blanks=", rxml_default_keep_blanks_set, 1);
|
873
|
+
rb_define_module_function(mXML, "default_load_external_dtd", rxml_default_load_external_dtd_get, 0);
|
874
|
+
rb_define_module_function(mXML, "default_load_external_dtd=", rxml_default_load_external_dtd_set, 1);
|
875
|
+
rb_define_module_function(mXML, "default_line_numbers", rxml_default_line_numbers_get, 0);
|
876
|
+
rb_define_module_function(mXML, "default_line_numbers=", rxml_default_line_numbers_set, 1);
|
877
|
+
rb_define_module_function(mXML, "default_options", rxml_default_options_get, 0);
|
878
|
+
rb_define_module_function(mXML, "default_pedantic_parser", rxml_default_pedantic_parser_get, 0);
|
879
|
+
rb_define_module_function(mXML, "default_pedantic_parser=", rxml_default_pedantic_parser_set, 1);
|
880
|
+
rb_define_module_function(mXML, "default_substitute_entities", rxml_default_substitute_entities_get, 0);
|
881
|
+
rb_define_module_function(mXML, "default_substitute_entities=", rxml_default_substitute_entities_set, 1);
|
882
|
+
rb_define_module_function(mXML, "default_tree_indent_string", rxml_default_tree_indent_string_get, 0);
|
883
|
+
rb_define_module_function(mXML, "default_tree_indent_string=", rxml_default_tree_indent_string_set, 1);
|
884
|
+
rb_define_module_function(mXML, "default_validity_checking", rxml_default_validity_checking_get, 0);
|
885
|
+
rb_define_module_function(mXML, "default_validity_checking=", rxml_default_validity_checking_set, 1);
|
886
|
+
rb_define_module_function(mXML, "default_warnings", rxml_default_warnings_get, 0);
|
887
|
+
rb_define_module_function(mXML, "default_warnings=", rxml_default_warnings_set, 1);
|
888
|
+
rb_define_module_function(mXML, "features", rxml_features, 0);
|
889
|
+
rb_define_module_function(mXML, "indent_tree_output", rxml_indent_tree_output_get, 0);
|
890
|
+
rb_define_module_function(mXML, "indent_tree_output=", rxml_indent_tree_output_set, 1);
|
891
|
+
rb_define_module_function(mXML, "memory_dump", rxml_memory_dump, 0);
|
892
|
+
rb_define_module_function(mXML, "memory_used", rxml_memory_used, 0);
|
893
|
+
}
|