libxml-ruby 2.8.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/HISTORY +15 -0
- data/README.rdoc +7 -7
- data/Rakefile +80 -78
- data/ext/libxml/extconf.h +4 -0
- data/ext/libxml/extconf.rb +57 -116
- data/ext/libxml/libxml.c +4 -0
- data/ext/libxml/ruby_xml.c +977 -893
- data/ext/libxml/ruby_xml.h +20 -10
- data/ext/libxml/ruby_xml_attr.c +333 -333
- data/ext/libxml/ruby_xml_attr_decl.c +2 -2
- data/ext/libxml/ruby_xml_cbg.c +85 -85
- data/ext/libxml/ruby_xml_document.c +1133 -1147
- data/ext/libxml/ruby_xml_dtd.c +261 -268
- data/ext/libxml/ruby_xml_encoding.c +262 -260
- data/ext/libxml/ruby_xml_encoding.h +19 -19
- data/ext/libxml/ruby_xml_html_parser_context.c +337 -338
- data/ext/libxml/ruby_xml_input_cbg.c +191 -191
- data/ext/libxml/ruby_xml_io.c +52 -50
- data/ext/libxml/ruby_xml_namespace.c +2 -2
- data/ext/libxml/ruby_xml_node.c +1446 -1452
- data/ext/libxml/ruby_xml_parser_context.c +999 -1001
- data/ext/libxml/ruby_xml_reader.c +1226 -1228
- data/ext/libxml/ruby_xml_relaxng.c +110 -111
- data/ext/libxml/ruby_xml_sax2_handler.c +326 -328
- data/ext/libxml/ruby_xml_schema.c +300 -301
- data/ext/libxml/ruby_xml_version.h +3 -3
- data/ext/libxml/ruby_xml_writer.c +14 -15
- data/ext/libxml/ruby_xml_xpath.c +188 -188
- data/ext/libxml/ruby_xml_xpath_context.c +360 -361
- data/ext/libxml/ruby_xml_xpath_object.c +335 -335
- data/libxml-ruby.gemspec +47 -44
- data/test/tc_attr.rb +5 -7
- data/test/tc_attr_decl.rb +5 -6
- data/test/tc_attributes.rb +1 -2
- data/test/tc_canonicalize.rb +1 -2
- data/test/tc_deprecated_require.rb +1 -2
- data/test/tc_document.rb +4 -5
- data/test/tc_document_write.rb +2 -3
- data/test/tc_dtd.rb +4 -5
- data/test/tc_encoding.rb +126 -126
- data/test/tc_encoding_sax.rb +4 -3
- data/test/tc_error.rb +14 -15
- data/test/tc_html_parser.rb +15 -7
- data/test/tc_html_parser_context.rb +1 -2
- data/test/tc_namespace.rb +2 -3
- data/test/tc_namespaces.rb +5 -6
- data/test/tc_node.rb +2 -3
- data/test/tc_node_cdata.rb +2 -3
- data/test/tc_node_comment.rb +1 -2
- data/test/tc_node_copy.rb +1 -2
- data/test/tc_node_edit.rb +5 -7
- data/test/tc_node_pi.rb +1 -2
- data/test/tc_node_text.rb +2 -3
- data/test/tc_node_write.rb +2 -3
- data/test/tc_node_xlink.rb +1 -2
- data/test/tc_parser.rb +18 -24
- data/test/tc_parser_context.rb +6 -7
- data/test/tc_properties.rb +1 -2
- data/test/tc_reader.rb +9 -10
- data/test/tc_relaxng.rb +4 -5
- data/test/tc_sax_parser.rb +9 -10
- data/test/tc_schema.rb +4 -5
- data/test/tc_traversal.rb +1 -2
- data/test/tc_writer.rb +1 -2
- data/test/tc_xinclude.rb +1 -2
- data/test/tc_xml.rb +1 -2
- data/test/tc_xpath.rb +8 -9
- data/test/tc_xpath_context.rb +3 -4
- data/test/tc_xpath_expression.rb +3 -4
- data/test/tc_xpointer.rb +1 -3
- data/test/test_helper.rb +3 -1
- data/test/test_suite.rb +0 -1
- metadata +47 -11
- data/test/etc_doc_to_s.rb +0 -21
- data/test/ets_doc_file.rb +0 -17
- data/test/ets_doc_to_s.rb +0 -23
- data/test/ets_gpx.rb +0 -28
- data/test/ets_node_gc.rb +0 -23
- data/test/ets_test.xml +0 -2
- data/test/ets_tsr.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19bae1f5824f98a959ddf6f19674ac0f2a750388
|
4
|
+
data.tar.gz: 8a2003b0eed642100d6520306a3cf609b739b2a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 730aeb8b63e92c5b362853b34df0e0cd84b502d5425f29a55722f74ddb1e98eabdc29f53d66bf5434460d96fe415e3e03c52aa3f3a024fb358f6b9d16bc7576e
|
7
|
+
data.tar.gz: a1585ebfe236cfa867b2a936836fb828783fe6d839d2ab03f45bd8ecaa77abec080a5e6480ce5357674de4803888fa0257db27b30d50fe3f9a3951f504ad14a9
|
data/HISTORY
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
= Release History
|
2
2
|
|
3
|
+
== 2.9.0 / 2016-06-13 Charlie Savage
|
4
|
+
|
5
|
+
* Revamp libxml-ruby's memory management to not cause crashes when used with Nokogiri (James Laird-Wah)
|
6
|
+
* Fix garbage collection issue that sometimes caused the library to hang (Charlie Savage)
|
7
|
+
* Improved multi-threading support (Charlie Savage)
|
8
|
+
* Fix crash sometimes caused by a xml node being being freed twice (Charlie Savage)
|
9
|
+
* Fix memory leak when setting the text content of a node (Charlie Savage)
|
10
|
+
* Set a default task in the Rakefile - use "test" (Robert Haines)
|
11
|
+
* Add "hanna_gudao" gem and add "rake-compiler" to develpoment dependencies (Robert Haines)
|
12
|
+
* Use Process.getrlimit instead of `ulimit` in the tests (Robert Haines)
|
13
|
+
* Build on smartos (Steven Williamson)
|
14
|
+
* Fix compiler warnings (Charlie Savage)
|
15
|
+
* Add Xcode project for easier debugging on OSX (Charlie Savage)
|
16
|
+
* Switch from unit test to minitest (Charlie Savage)
|
17
|
+
|
3
18
|
== 2.8.0 / 2015-01-09 Charlie Savage
|
4
19
|
|
5
20
|
* Use RbConfig instead of Config in extconf.rb (Robert Haines)
|
data/README.rdoc
CHANGED
@@ -31,8 +31,8 @@ The easiest way to install libxml-ruby is via Ruby Gems. To install:
|
|
31
31
|
|
32
32
|
If you are running Windows, make sure to install the Win32 RubyGem
|
33
33
|
which includes prebuilt extensions for Ruby 1.8, 1.9 and 2.0 preview. These
|
34
|
-
extensions are built
|
35
|
-
iconv version 1.
|
34
|
+
extensions are built using MinGW64 and libxml2 version 2.9.3,
|
35
|
+
iconv version 1.14 and zlib version 1.2.8. Note these binaries
|
36
36
|
are available in the lib\libs directory. To use them, put them
|
37
37
|
someplace on your path.
|
38
38
|
|
@@ -114,8 +114,8 @@ For simplicity's sake, the documentation uses the xml module in its examples.
|
|
114
114
|
|
115
115
|
== Memory Management
|
116
116
|
libxml-ruby automatically manages memory associated with the
|
117
|
-
underlying libxml2 library.
|
118
|
-
your code must handle.
|
117
|
+
underlying libxml2 library. There is however one corner case that
|
118
|
+
your code must handle. If a node is imported into a document, but not
|
119
119
|
added to the document, a segmentation fault may occur on program termination.
|
120
120
|
|
121
121
|
# Do NOT do this
|
@@ -124,8 +124,8 @@ added to the document, a segmentation fault may occur on program termination.
|
|
124
124
|
doc2 = XML::Document.string("test2")
|
125
125
|
node = doc2.import(doc1.root)
|
126
126
|
|
127
|
-
If doc2 is freed before
|
128
|
-
|
127
|
+
If doc2 is freed before the node a segmentation fault will occur since
|
128
|
+
the node references the document. To avoid this, simply make sure to add the
|
129
129
|
node to the document:
|
130
130
|
|
131
131
|
# DO this instead
|
@@ -133,7 +133,7 @@ node to the document:
|
|
133
133
|
doc2 = XML::Document.string("test2")
|
134
134
|
doc2.root << doc2.import(doc1.root)
|
135
135
|
|
136
|
-
Alternatively, you can call
|
136
|
+
Alternatively, you can call node.remove! to disassociate the node from doc2.
|
137
137
|
|
138
138
|
== Threading
|
139
139
|
libxml-ruby fully supports native, background Ruby threads. This of course
|
data/Rakefile
CHANGED
@@ -1,79 +1,81 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "rubygems"
|
4
|
-
require "rake/extensiontask"
|
5
|
-
require "rake/testtask"
|
6
|
-
require "rubygems/package_task"
|
7
|
-
require "rdoc/task"
|
8
|
-
require "yaml"
|
9
|
-
|
10
|
-
GEM_NAME = "libxml-ruby"
|
11
|
-
SO_NAME = "libxml_ruby"
|
12
|
-
|
13
|
-
# Read the spec file
|
14
|
-
spec = Gem::Specification.load("#{GEM_NAME}.gemspec")
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
ext.
|
21
|
-
ext.
|
22
|
-
ext.
|
23
|
-
ext.
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
win_spec
|
41
|
-
win_spec.
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
RDoc
|
56
|
-
|
57
|
-
|
58
|
-
rdoc.
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
rdoc.
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
'ext
|
69
|
-
'
|
70
|
-
'
|
71
|
-
'
|
72
|
-
'
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "rake/extensiontask"
|
5
|
+
require "rake/testtask"
|
6
|
+
require "rubygems/package_task"
|
7
|
+
require "rdoc/task"
|
8
|
+
require "yaml"
|
9
|
+
|
10
|
+
GEM_NAME = "libxml-ruby"
|
11
|
+
SO_NAME = "libxml_ruby"
|
12
|
+
|
13
|
+
# Read the spec file
|
14
|
+
spec = Gem::Specification.load("#{GEM_NAME}.gemspec")
|
15
|
+
|
16
|
+
task :default => [:test]
|
17
|
+
|
18
|
+
# Setup compile tasks
|
19
|
+
Rake::ExtensionTask.new do |ext|
|
20
|
+
ext.gem_spec = spec
|
21
|
+
ext.name = SO_NAME
|
22
|
+
ext.ext_dir = "ext/libxml"
|
23
|
+
ext.lib_dir = "lib/#{RUBY_VERSION.sub(/\.\d$/, '')}"
|
24
|
+
ext.config_options << "--with-xml2-include=C:/msys64/mingw64/include/libxml2"
|
25
|
+
ext.config_options << "--with-zlib-dir=C:/msys64/mingw64"
|
26
|
+
end
|
27
|
+
|
28
|
+
# Setup generic gem
|
29
|
+
Gem::PackageTask.new(spec) do |pkg|
|
30
|
+
pkg.package_dir = 'pkg'
|
31
|
+
pkg.need_tar = false
|
32
|
+
end
|
33
|
+
|
34
|
+
# Setup Windows Gem
|
35
|
+
if RUBY_PLATFORM.match(/win32|mingw32/)
|
36
|
+
binaries = (FileList['lib/**/*.so',
|
37
|
+
'lib/**/*dll'])
|
38
|
+
|
39
|
+
# Windows specification
|
40
|
+
win_spec = spec.clone
|
41
|
+
win_spec.platform = Gem::Platform::CURRENT
|
42
|
+
win_spec.files += binaries.to_a
|
43
|
+
win_spec.instance_variable_set(:@cache_file, nil)
|
44
|
+
|
45
|
+
# Unset extensions
|
46
|
+
win_spec.extensions = nil
|
47
|
+
|
48
|
+
# Rake task to build the windows package
|
49
|
+
Gem::PackageTask.new(win_spec) do |pkg|
|
50
|
+
pkg.package_dir = 'pkg'
|
51
|
+
pkg.need_tar = false
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# RDoc Task
|
56
|
+
desc 'Generate rdoc documentation'
|
57
|
+
RDoc::Task.new("rdoc") do |rdoc|
|
58
|
+
rdoc.rdoc_dir = 'website/_site/rdoc'
|
59
|
+
rdoc.title = 'LibXML'
|
60
|
+
rdoc.generator = 'hanna'
|
61
|
+
|
62
|
+
# Show source inline with line numbers
|
63
|
+
rdoc.options << '--line-numbers'
|
64
|
+
rdoc.options << '--charset=utf-8'
|
65
|
+
# Make the readme file the start page for the generated html
|
66
|
+
rdoc.main = 'README.rdoc'
|
67
|
+
rdoc.rdoc_files.include('doc/*.rdoc',
|
68
|
+
'ext/**/libxml.c',
|
69
|
+
'ext/**/ruby_xml.c',
|
70
|
+
'ext/**/*.c',
|
71
|
+
'lib/**/*.rb',
|
72
|
+
'README.rdoc',
|
73
|
+
'HISTORY',
|
74
|
+
'LICENSE')
|
75
|
+
end
|
76
|
+
|
77
|
+
# Test Task
|
78
|
+
Rake::TestTask.new do |t|
|
79
|
+
t.libs << "test"
|
80
|
+
t.verbose = true
|
79
81
|
end
|
data/ext/libxml/extconf.rb
CHANGED
@@ -1,116 +1,57 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require '
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
dir_config('
|
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
|
-
Install the libiconv or try passing one of the following options
|
60
|
-
to extconf.rb:
|
61
|
-
|
62
|
-
--with-iconv-dir=/path/to/iconv
|
63
|
-
--with-iconv-lib=/path/to/iconv/lib
|
64
|
-
--with-iconv-include=/path/to/iconv/include
|
65
|
-
EOL
|
66
|
-
end
|
67
|
-
|
68
|
-
if (xc = with_config('xml2-config')) or RUBY_PLATFORM.match(/darwin/i) then
|
69
|
-
xc = 'xml2-config' if xc == true or xc.nil?
|
70
|
-
cflags = `#{xc} --cflags`.chomp
|
71
|
-
if $? != 0
|
72
|
-
cflags = nil
|
73
|
-
else
|
74
|
-
libs = `#{xc} --libs`.chomp
|
75
|
-
if $? != 0
|
76
|
-
libs = nil
|
77
|
-
else
|
78
|
-
$CFLAGS += ' ' + cflags
|
79
|
-
$libs = libs + " " + $libs
|
80
|
-
end
|
81
|
-
end
|
82
|
-
else
|
83
|
-
dir_config('xml2')
|
84
|
-
end
|
85
|
-
|
86
|
-
unless (have_library('xml2', 'xmlParseDoc') or
|
87
|
-
have_library('libxml2', 'xmlParseDoc') or
|
88
|
-
find_library('xml2', 'xmlParseDoc', '/opt/lib', '/usr/local/lib', '/usr/lib')) and
|
89
|
-
(have_header('libxml/xmlversion.h') or
|
90
|
-
find_header('libxml/xmlversion.h',
|
91
|
-
'/opt/include/libxml2',
|
92
|
-
'/usr/local/include/libxml2',
|
93
|
-
'/usr/include/libxml2'))
|
94
|
-
crash(<<EOL)
|
95
|
-
need libxml2.
|
96
|
-
|
97
|
-
Install the library or try one of the following options to extconf.rb:
|
98
|
-
|
99
|
-
--with-xml2-config=/path/to/xml2-config
|
100
|
-
--with-xml2-dir=/path/to/libxml2
|
101
|
-
--with-xml2-lib=/path/to/libxml2/lib
|
102
|
-
--with-xml2-include=/path/to/libxml2/include
|
103
|
-
EOL
|
104
|
-
end
|
105
|
-
|
106
|
-
have_func('rb_io_bufwrite', 'ruby/io.h')
|
107
|
-
|
108
|
-
# For FreeBSD add /usr/local/include
|
109
|
-
$INCFLAGS << " -I/usr/local/include"
|
110
|
-
|
111
|
-
$CFLAGS << ' ' << $INCFLAGS
|
112
|
-
|
113
|
-
#$INSTALLFILES = [["libxml.rb", "$(RUBYLIBDIR)", "../xml"]]
|
114
|
-
|
115
|
-
create_header()
|
116
|
-
create_makefile('libxml_ruby')
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'mkmf'
|
4
|
+
|
5
|
+
def crash(str)
|
6
|
+
printf(" extconf failure: %s\n", str)
|
7
|
+
exit 1
|
8
|
+
end
|
9
|
+
|
10
|
+
xc = with_config('xml2-config')
|
11
|
+
if xc
|
12
|
+
cflags = `#{xc} --cflags`.chomp
|
13
|
+
if $? != 0
|
14
|
+
cflags = nil
|
15
|
+
else
|
16
|
+
libs = `#{xc} --libs`.chomp
|
17
|
+
if $? != 0
|
18
|
+
libs = nil
|
19
|
+
else
|
20
|
+
$CFLAGS += ' ' + cflags
|
21
|
+
$libs = libs + " " + $libs
|
22
|
+
end
|
23
|
+
end
|
24
|
+
else
|
25
|
+
dir_config('xml2')
|
26
|
+
end
|
27
|
+
|
28
|
+
unless find_header('libxml/xmlversion.h',
|
29
|
+
'/opt/include/libxml2',
|
30
|
+
'/opt/local/include/libxml2',
|
31
|
+
'/usr/local/include/libxml2',
|
32
|
+
'/usr/include/libxml2') &&
|
33
|
+
find_library('xml2', 'xmlParseDoc',
|
34
|
+
'/opt/lib',
|
35
|
+
'/opt/local/lib',
|
36
|
+
'/usr/local/lib',
|
37
|
+
'/usr/lib')
|
38
|
+
crash(<<EOL)
|
39
|
+
need libxml2.
|
40
|
+
|
41
|
+
Install the library or try one of the following options to extconf.rb:
|
42
|
+
|
43
|
+
--with-xml2-config=/path/to/xml2-config
|
44
|
+
--with-xml2-dir=/path/to/libxml2
|
45
|
+
--with-xml2-lib=/path/to/libxml2/lib
|
46
|
+
--with-xml2-include=/path/to/libxml2/include
|
47
|
+
EOL
|
48
|
+
end
|
49
|
+
|
50
|
+
have_func('rb_io_bufwrite', 'ruby/io.h')
|
51
|
+
|
52
|
+
# For FreeBSD add /usr/local/include
|
53
|
+
$INCFLAGS << " -I/usr/local/include"
|
54
|
+
$CFLAGS << ' ' << $INCFLAGS
|
55
|
+
|
56
|
+
create_header()
|
57
|
+
create_makefile('libxml_ruby')
|
data/ext/libxml/libxml.c
CHANGED
@@ -39,6 +39,10 @@ void Init_libxml_ruby(void)
|
|
39
39
|
* Refer to the README file to get started and the LICENSE file for
|
40
40
|
* copyright and distribution information.
|
41
41
|
*/
|
42
|
+
|
43
|
+
// Seutp for threading. http://xmlsoft.org/threads.html
|
44
|
+
xmlInitParser();
|
45
|
+
|
42
46
|
mLibXML = rb_define_module("LibXML");
|
43
47
|
|
44
48
|
rxml_init_memory();
|
data/ext/libxml/ruby_xml.c
CHANGED
@@ -1,893 +1,977 @@
|
|
1
|
-
#include "ruby_libxml.h"
|
2
|
-
#include "ruby_xml.h"
|
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
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
*
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
*
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
#
|
323
|
-
|
324
|
-
#
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
#
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
*
|
352
|
-
*
|
353
|
-
*
|
354
|
-
*
|
355
|
-
*/
|
356
|
-
static VALUE
|
357
|
-
{
|
358
|
-
#ifdef
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
*
|
414
|
-
*
|
415
|
-
*
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
if (
|
421
|
-
|
422
|
-
else
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
}
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
*
|
509
|
-
*
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
*
|
589
|
-
*
|
590
|
-
*
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
*
|
634
|
-
*
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
else
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
*
|
652
|
-
*
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
{
|
658
|
-
|
659
|
-
return (
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
return (
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
*
|
686
|
-
*
|
687
|
-
*
|
688
|
-
*
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
return(
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
1
|
+
#include "ruby_libxml.h"
|
2
|
+
#include "ruby_xml.h"
|
3
|
+
|
4
|
+
static struct st_table *private_pointers;
|
5
|
+
|
6
|
+
static int registered = 0; // Constant to track what nodes have been registered
|
7
|
+
|
8
|
+
void rxml_register(void *xnode, VALUE value) {
|
9
|
+
st_insert(private_pointers, (st_data_t)xnode, (st_data_t)value);
|
10
|
+
}
|
11
|
+
|
12
|
+
void rxml_register_node(xmlNodePtr xnode, VALUE value) {
|
13
|
+
if (rxml_lookup_node(xnode) == Qnil) {
|
14
|
+
xnode->_private = ®istered;
|
15
|
+
rxml_register(xnode, value);
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
void rxml_register_doc(xmlDocPtr xdoc, VALUE value) {
|
20
|
+
if (rxml_lookup_doc(xdoc) == Qnil) {
|
21
|
+
xdoc->_private = ®istered;
|
22
|
+
rxml_register(xdoc, value);
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
void rxml_register_dtd(xmlDtdPtr xdtd, VALUE value) {
|
27
|
+
if (rxml_lookup_dtd(xdtd) == Qnil) {
|
28
|
+
xdtd->_private = ®istered;
|
29
|
+
rxml_register(xdtd, value);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
void rxml_unregister(void *xnode) {
|
34
|
+
st_delete(private_pointers, (st_data_t*)&xnode, NULL);
|
35
|
+
}
|
36
|
+
|
37
|
+
void rxml_unregister_node(xmlNodePtr xnode) {
|
38
|
+
if (xnode->_private == ®istered) {
|
39
|
+
xnode->_private = NULL;
|
40
|
+
rxml_unregister(xnode);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
void rxml_unregister_doc(xmlDocPtr xdoc) {
|
45
|
+
if (xdoc->_private == ®istered) {
|
46
|
+
xdoc->_private = NULL;
|
47
|
+
rxml_unregister(xdoc);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
void rxml_unregister_dtd(xmlDtdPtr xdtd) {
|
52
|
+
if (xdtd->_private == ®istered) {
|
53
|
+
xdtd->_private = NULL;
|
54
|
+
rxml_unregister(xdtd);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
VALUE rxml_lookup(void *pointer) {
|
59
|
+
st_data_t result = 0;
|
60
|
+
int ret = st_lookup(private_pointers, (st_data_t)pointer, &result);
|
61
|
+
return ret ? (VALUE)result : Qnil;
|
62
|
+
}
|
63
|
+
|
64
|
+
VALUE rxml_lookup_node(xmlNodePtr xnode) {
|
65
|
+
if (!xnode || xnode->_private != ®istered)
|
66
|
+
return Qnil;
|
67
|
+
|
68
|
+
return rxml_lookup(xnode);
|
69
|
+
}
|
70
|
+
|
71
|
+
VALUE rxml_lookup_doc(xmlDocPtr xdoc) {
|
72
|
+
if (!xdoc || xdoc->_private != ®istered)
|
73
|
+
return Qnil;
|
74
|
+
|
75
|
+
return rxml_lookup(xdoc);
|
76
|
+
}
|
77
|
+
|
78
|
+
VALUE rxml_lookup_dtd(xmlDtdPtr xdtd) {
|
79
|
+
if (!xdtd || xdtd->_private != ®istered)
|
80
|
+
return Qnil;
|
81
|
+
|
82
|
+
return rxml_lookup(xdtd);
|
83
|
+
}
|
84
|
+
|
85
|
+
VALUE mXML;
|
86
|
+
|
87
|
+
/*
|
88
|
+
* call-seq:
|
89
|
+
* XML.catalog_dump -> true
|
90
|
+
*
|
91
|
+
* Dump all the global catalog content stdout.
|
92
|
+
*/
|
93
|
+
static VALUE rxml_catalog_dump(VALUE self)
|
94
|
+
{
|
95
|
+
xmlCatalogDump(stdout);
|
96
|
+
return (Qtrue);
|
97
|
+
}
|
98
|
+
|
99
|
+
/*
|
100
|
+
* call-seq:
|
101
|
+
* XML.catalog_remove(catalog) -> true
|
102
|
+
*
|
103
|
+
* Remove the specified resource catalog.
|
104
|
+
*/
|
105
|
+
static VALUE rxml_catalog_remove(VALUE self, VALUE cat)
|
106
|
+
{
|
107
|
+
Check_Type(cat, T_STRING);
|
108
|
+
xmlCatalogRemove((xmlChar *) StringValuePtr(cat));
|
109
|
+
return (Qtrue);
|
110
|
+
}
|
111
|
+
|
112
|
+
/*
|
113
|
+
* call-seq:
|
114
|
+
* XML.check_lib_versions -> true
|
115
|
+
*
|
116
|
+
* Check LIBXML version matches version the bindings
|
117
|
+
* were compiled to. Throws an exception if not.
|
118
|
+
*/
|
119
|
+
static VALUE rxml_check_lib_versions(VALUE klass)
|
120
|
+
{
|
121
|
+
xmlCheckVersion(LIBXML_VERSION);
|
122
|
+
return (Qtrue);
|
123
|
+
}
|
124
|
+
|
125
|
+
/*
|
126
|
+
* call-seq:
|
127
|
+
* XML.enabled_automata? -> (true|false)
|
128
|
+
*
|
129
|
+
* Determine whether libxml regexp automata support is enabled.
|
130
|
+
*/
|
131
|
+
static VALUE rxml_enabled_automata_q(VALUE klass)
|
132
|
+
{
|
133
|
+
#ifdef LIBXML_AUTOMATA_ENABLED
|
134
|
+
return(Qtrue);
|
135
|
+
#else
|
136
|
+
return (Qfalse);
|
137
|
+
#endif
|
138
|
+
}
|
139
|
+
|
140
|
+
/*
|
141
|
+
* call-seq:
|
142
|
+
* XML.enabled_c14n? -> (true|false)
|
143
|
+
*
|
144
|
+
* Determine whether libxml 'canonical XML' support is enabled.
|
145
|
+
* See "Canonical XML" (http://www.w3.org/TR/xml-c14n)
|
146
|
+
*/
|
147
|
+
static VALUE rxml_enabled_c14n_q(VALUE klass)
|
148
|
+
{
|
149
|
+
#ifdef LIBXML_C14N_ENABLED
|
150
|
+
return(Qtrue);
|
151
|
+
#else
|
152
|
+
return (Qfalse);
|
153
|
+
#endif
|
154
|
+
}
|
155
|
+
|
156
|
+
/*
|
157
|
+
* call-seq:
|
158
|
+
* XML.enabled_catalog? -> (true|false)
|
159
|
+
*
|
160
|
+
* Determine whether libxml resource catalog support is enabled.
|
161
|
+
*/
|
162
|
+
static VALUE rxml_enabled_catalog_q(VALUE klass)
|
163
|
+
{
|
164
|
+
#ifdef LIBXML_CATALOG_ENABLED
|
165
|
+
return(Qtrue);
|
166
|
+
#else
|
167
|
+
return (Qfalse);
|
168
|
+
#endif
|
169
|
+
}
|
170
|
+
|
171
|
+
/*
|
172
|
+
* call-seq:
|
173
|
+
* XML.enabled_debug? -> (true|false)
|
174
|
+
*
|
175
|
+
* Determine whether libxml debugging support is enabled.
|
176
|
+
*/
|
177
|
+
static VALUE rxml_enabled_debug_q(VALUE klass)
|
178
|
+
{
|
179
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
180
|
+
return(Qtrue);
|
181
|
+
#else
|
182
|
+
return (Qfalse);
|
183
|
+
#endif
|
184
|
+
}
|
185
|
+
|
186
|
+
/*
|
187
|
+
* call-seq:
|
188
|
+
* XML.enabled_docbook? -> (true|false)
|
189
|
+
*
|
190
|
+
* Determine whether libxml docbook support is enabled.
|
191
|
+
*/
|
192
|
+
static VALUE rxml_enabled_docbook_q(VALUE klass)
|
193
|
+
{
|
194
|
+
#ifdef LIBXML_DOCB_ENABLED
|
195
|
+
return(Qtrue);
|
196
|
+
#else
|
197
|
+
return (Qfalse);
|
198
|
+
#endif
|
199
|
+
}
|
200
|
+
|
201
|
+
/*
|
202
|
+
* call-seq:
|
203
|
+
* XML.enabled_ftp? -> (true|false)
|
204
|
+
*
|
205
|
+
* Determine whether libxml ftp client support is enabled.
|
206
|
+
*/
|
207
|
+
static VALUE rxml_enabled_ftp_q(VALUE klass)
|
208
|
+
{
|
209
|
+
#ifdef LIBXML_FTP_ENABLED
|
210
|
+
return(Qtrue);
|
211
|
+
#else
|
212
|
+
return (Qfalse);
|
213
|
+
#endif
|
214
|
+
}
|
215
|
+
|
216
|
+
/*
|
217
|
+
* call-seq:
|
218
|
+
* XML.enabled_http? -> (true|false)
|
219
|
+
*
|
220
|
+
* Determine whether libxml http client support is enabled.
|
221
|
+
*/
|
222
|
+
static VALUE rxml_enabled_http_q(VALUE klass)
|
223
|
+
{
|
224
|
+
#ifdef LIBXML_HTTP_ENABLED
|
225
|
+
return(Qtrue);
|
226
|
+
#else
|
227
|
+
return (Qfalse);
|
228
|
+
#endif
|
229
|
+
}
|
230
|
+
|
231
|
+
/*
|
232
|
+
* call-seq:
|
233
|
+
* XML.enabled_html? -> (true|false)
|
234
|
+
*
|
235
|
+
* Determine whether libxml html support is enabled.
|
236
|
+
*/
|
237
|
+
static VALUE rxml_enabled_html_q(VALUE klass)
|
238
|
+
{
|
239
|
+
#ifdef LIBXML_HTML_ENABLED
|
240
|
+
return(Qtrue);
|
241
|
+
#else
|
242
|
+
return (Qfalse);
|
243
|
+
#endif
|
244
|
+
}
|
245
|
+
|
246
|
+
/*
|
247
|
+
* call-seq:
|
248
|
+
* XML.enabled_iconv? -> (true|false)
|
249
|
+
*
|
250
|
+
* Determine whether libxml iconv support is enabled.
|
251
|
+
*/
|
252
|
+
static VALUE rxml_enabled_iconv_q(VALUE klass)
|
253
|
+
{
|
254
|
+
#ifdef LIBXML_ICONV_ENABLED
|
255
|
+
return(Qtrue);
|
256
|
+
#else
|
257
|
+
return (Qfalse);
|
258
|
+
#endif
|
259
|
+
}
|
260
|
+
|
261
|
+
/*
|
262
|
+
* call-seq:
|
263
|
+
* XML.enabled_memory_debug? -> (true|false)
|
264
|
+
*
|
265
|
+
* Determine whether libxml memory location debugging support
|
266
|
+
* is enabled.
|
267
|
+
*/
|
268
|
+
static VALUE rxml_enabled_memory_debug_location_q(VALUE klass)
|
269
|
+
{
|
270
|
+
#ifdef DEBUG_MEMORY_LOCATION
|
271
|
+
return(Qtrue);
|
272
|
+
#else
|
273
|
+
return (Qfalse);
|
274
|
+
#endif
|
275
|
+
}
|
276
|
+
|
277
|
+
/*
|
278
|
+
* call-seq:
|
279
|
+
* XML.enabled_regexp? -> (true|false)
|
280
|
+
*
|
281
|
+
* Determine whether libxml regular expression support is enabled.
|
282
|
+
*/
|
283
|
+
static VALUE rxml_enabled_regexp_q(VALUE klass)
|
284
|
+
{
|
285
|
+
#ifdef LIBXML_REGEXP_ENABLED
|
286
|
+
return(Qtrue);
|
287
|
+
#else
|
288
|
+
return (Qfalse);
|
289
|
+
#endif
|
290
|
+
}
|
291
|
+
|
292
|
+
/*
|
293
|
+
* call-seq:
|
294
|
+
* XML.enabled_schemas? -> (true|false)
|
295
|
+
*
|
296
|
+
* Determine whether libxml schema support is enabled.
|
297
|
+
*/
|
298
|
+
static VALUE rxml_enabled_schemas_q(VALUE klass)
|
299
|
+
{
|
300
|
+
#ifdef LIBXML_SCHEMAS_ENABLED
|
301
|
+
return(Qtrue);
|
302
|
+
#else
|
303
|
+
return (Qfalse);
|
304
|
+
#endif
|
305
|
+
}
|
306
|
+
|
307
|
+
/*
|
308
|
+
* call-seq:
|
309
|
+
* XML.enabled_thread? -> (true|false)
|
310
|
+
*
|
311
|
+
* Determine whether thread-safe semantics support for libxml is enabled and
|
312
|
+
* is used by this ruby extension. Threading support in libxml uses pthread
|
313
|
+
* on Unix-like systems and Win32 threads on Windows.
|
314
|
+
*/
|
315
|
+
static VALUE rxml_enabled_thread_q(VALUE klass)
|
316
|
+
{
|
317
|
+
/* This won't be defined unless this code is compiled with _REENTRANT or __MT__
|
318
|
+
* defined or the compiler is in C99 mode.
|
319
|
+
*
|
320
|
+
* Note the relevant portion libxml/xmlversion.h on a thread-enabled build:
|
321
|
+
*
|
322
|
+
* #if defined(_REENTRANT) || defined(__MT__) || \
|
323
|
+
* (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE - 0 >= 199506L))
|
324
|
+
* #define LIBXML_THREAD_ENABLED
|
325
|
+
* #endif
|
326
|
+
*
|
327
|
+
*/
|
328
|
+
#ifdef LIBXML_THREAD_ENABLED
|
329
|
+
return(Qtrue);
|
330
|
+
#else
|
331
|
+
return (Qfalse);
|
332
|
+
#endif
|
333
|
+
}
|
334
|
+
|
335
|
+
/*
|
336
|
+
* call-seq:
|
337
|
+
* XML.enabled_unicode? -> (true|false)
|
338
|
+
*
|
339
|
+
* Determine whether libxml unicode support is enabled.
|
340
|
+
*/
|
341
|
+
static VALUE rxml_enabled_unicode_q(VALUE klass)
|
342
|
+
{
|
343
|
+
#ifdef LIBXML_UNICODE_ENABLED
|
344
|
+
return(Qtrue);
|
345
|
+
#else
|
346
|
+
return (Qfalse);
|
347
|
+
#endif
|
348
|
+
}
|
349
|
+
|
350
|
+
/*
|
351
|
+
* call-seq:
|
352
|
+
* XML.enabled_xinclude? -> (true|false)
|
353
|
+
*
|
354
|
+
* Determine whether libxml xinclude support is enabled.
|
355
|
+
*/
|
356
|
+
static VALUE rxml_enabled_xinclude_q(VALUE klass)
|
357
|
+
{
|
358
|
+
#ifdef LIBXML_XINCLUDE_ENABLED
|
359
|
+
return(Qtrue);
|
360
|
+
#else
|
361
|
+
return (Qfalse);
|
362
|
+
#endif
|
363
|
+
}
|
364
|
+
|
365
|
+
/*
|
366
|
+
* call-seq:
|
367
|
+
* XML.enabled_xpath? -> (true|false)
|
368
|
+
*
|
369
|
+
* Determine whether libxml xpath support is enabled.
|
370
|
+
*/
|
371
|
+
static VALUE rxml_enabled_xpath_q(VALUE klass)
|
372
|
+
{
|
373
|
+
#ifdef LIBXML_XPATH_ENABLED
|
374
|
+
return(Qtrue);
|
375
|
+
#else
|
376
|
+
return (Qfalse);
|
377
|
+
#endif
|
378
|
+
}
|
379
|
+
|
380
|
+
/*
|
381
|
+
* call-seq:
|
382
|
+
* XML.enabled_xpointer? -> (true|false)
|
383
|
+
*
|
384
|
+
* Determine whether libxml xpointer support is enabled.
|
385
|
+
*/
|
386
|
+
static VALUE rxml_enabled_xpointer_q(VALUE klass)
|
387
|
+
{
|
388
|
+
#ifdef LIBXML_XPTR_ENABLED
|
389
|
+
return(Qtrue);
|
390
|
+
#else
|
391
|
+
return (Qfalse);
|
392
|
+
#endif
|
393
|
+
}
|
394
|
+
|
395
|
+
/*
|
396
|
+
* call-seq:
|
397
|
+
* XML.enabled_zlib? -> (true|false)
|
398
|
+
*
|
399
|
+
* Determine whether libxml zlib support is enabled.
|
400
|
+
*/
|
401
|
+
static VALUE rxml_enabled_zlib_q(VALUE klass)
|
402
|
+
{
|
403
|
+
#ifdef HAVE_ZLIB_H
|
404
|
+
return(Qtrue);
|
405
|
+
#else
|
406
|
+
return (Qfalse);
|
407
|
+
#endif
|
408
|
+
}
|
409
|
+
|
410
|
+
/*
|
411
|
+
* call-seq:
|
412
|
+
* XML.debug_entities -> (true|false)
|
413
|
+
*
|
414
|
+
* Determine whether included-entity debugging is enabled.
|
415
|
+
* (Requires Libxml to be compiled with debugging support)
|
416
|
+
*/
|
417
|
+
static VALUE rxml_debug_entities_get(VALUE klass)
|
418
|
+
{
|
419
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
420
|
+
if (xmlParserDebugEntities)
|
421
|
+
return(Qtrue);
|
422
|
+
else
|
423
|
+
return(Qfalse);
|
424
|
+
#else
|
425
|
+
rb_warn("libxml was compiled with debugging turned off");
|
426
|
+
return (Qfalse);
|
427
|
+
#endif
|
428
|
+
}
|
429
|
+
|
430
|
+
/*
|
431
|
+
* call-seq:
|
432
|
+
* XML.debug_entities = true|false
|
433
|
+
*
|
434
|
+
* Enable or disable included-entity debugging.
|
435
|
+
* (Requires Libxml to be compiled with debugging support)
|
436
|
+
*/
|
437
|
+
static VALUE rxml_debug_entities_set(VALUE klass, VALUE value)
|
438
|
+
{
|
439
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
440
|
+
if (value == Qfalse)
|
441
|
+
{
|
442
|
+
xmlParserDebugEntities = 0;
|
443
|
+
return(Qfalse);
|
444
|
+
}
|
445
|
+
else
|
446
|
+
{
|
447
|
+
xmlParserDebugEntities = 1;
|
448
|
+
return(Qtrue);
|
449
|
+
}
|
450
|
+
#else
|
451
|
+
rb_warn("libxml was compiled with debugging turned off");
|
452
|
+
#endif
|
453
|
+
}
|
454
|
+
|
455
|
+
/*
|
456
|
+
* call-seq:
|
457
|
+
* XML.default_keep_blanks -> (true|false)
|
458
|
+
*
|
459
|
+
* Determine whether parsers retain whitespace by default.
|
460
|
+
*/
|
461
|
+
static VALUE rxml_default_keep_blanks_get(VALUE klass)
|
462
|
+
{
|
463
|
+
if (xmlKeepBlanksDefaultValue)
|
464
|
+
return (Qtrue);
|
465
|
+
else
|
466
|
+
return (Qfalse);
|
467
|
+
}
|
468
|
+
|
469
|
+
/*
|
470
|
+
* call-seq:
|
471
|
+
* XML.default_keep_blanks = true|false
|
472
|
+
*
|
473
|
+
* Controls whether parsers retain whitespace by default.
|
474
|
+
*/
|
475
|
+
static VALUE rxml_default_keep_blanks_set(VALUE klass, VALUE value)
|
476
|
+
{
|
477
|
+
if (value == Qfalse)
|
478
|
+
{
|
479
|
+
xmlKeepBlanksDefaultValue = 0;
|
480
|
+
return (Qfalse);
|
481
|
+
}
|
482
|
+
else if (value == Qtrue)
|
483
|
+
{
|
484
|
+
xmlKeepBlanksDefaultValue = 1;
|
485
|
+
return (Qtrue);
|
486
|
+
}
|
487
|
+
else
|
488
|
+
{
|
489
|
+
rb_raise(rb_eArgError, "Invalid argument, must be a boolean");
|
490
|
+
}
|
491
|
+
}
|
492
|
+
|
493
|
+
/*
|
494
|
+
* call-seq:
|
495
|
+
* XML.default_load_external_dtd -> (true|false)
|
496
|
+
*
|
497
|
+
* Determine whether parsers load external DTDs by default.
|
498
|
+
*/
|
499
|
+
static VALUE rxml_default_load_external_dtd_get(VALUE klass)
|
500
|
+
{
|
501
|
+
if (xmlLoadExtDtdDefaultValue)
|
502
|
+
return (Qtrue);
|
503
|
+
else
|
504
|
+
return (Qfalse);
|
505
|
+
}
|
506
|
+
|
507
|
+
/*
|
508
|
+
* call-seq:
|
509
|
+
* XML.default_load_external_dtd = true|false
|
510
|
+
*
|
511
|
+
* Controls whether parsers load external DTDs by default.
|
512
|
+
*/
|
513
|
+
static VALUE rxml_default_load_external_dtd_set(VALUE klass, VALUE value)
|
514
|
+
{
|
515
|
+
if (value == Qfalse)
|
516
|
+
{
|
517
|
+
xmlLoadExtDtdDefaultValue = 0;
|
518
|
+
return (Qfalse);
|
519
|
+
}
|
520
|
+
else
|
521
|
+
{
|
522
|
+
xmlLoadExtDtdDefaultValue = 1;
|
523
|
+
return (Qtrue);
|
524
|
+
}
|
525
|
+
}
|
526
|
+
|
527
|
+
/*
|
528
|
+
* call-seq:
|
529
|
+
* XML.default_line_numbers -> (true|false)
|
530
|
+
*
|
531
|
+
* Determine whether parsers retain line-numbers by default.
|
532
|
+
*/
|
533
|
+
static VALUE rxml_default_line_numbers_get(VALUE klass)
|
534
|
+
{
|
535
|
+
if (xmlLineNumbersDefaultValue)
|
536
|
+
return (Qtrue);
|
537
|
+
else
|
538
|
+
return (Qfalse);
|
539
|
+
}
|
540
|
+
|
541
|
+
/*
|
542
|
+
* call-seq:
|
543
|
+
* XML.default_line_numbers = true|false
|
544
|
+
*
|
545
|
+
* Controls whether parsers retain line-numbers by default.
|
546
|
+
*/
|
547
|
+
static VALUE rxml_default_line_numbers_set(VALUE klass, VALUE value)
|
548
|
+
{
|
549
|
+
if (value == Qfalse)
|
550
|
+
{
|
551
|
+
xmlLineNumbersDefault(0);
|
552
|
+
return (Qfalse);
|
553
|
+
}
|
554
|
+
else
|
555
|
+
{
|
556
|
+
xmlLineNumbersDefault(1);
|
557
|
+
return (Qtrue);
|
558
|
+
}
|
559
|
+
}
|
560
|
+
|
561
|
+
int rxml_libxml_default_options()
|
562
|
+
{
|
563
|
+
int options = 0;
|
564
|
+
|
565
|
+
if (xmlLoadExtDtdDefaultValue)
|
566
|
+
options |= XML_PARSE_DTDLOAD;
|
567
|
+
|
568
|
+
if (xmlDoValidityCheckingDefaultValue)
|
569
|
+
options |= XML_PARSE_DTDVALID;
|
570
|
+
|
571
|
+
if (!xmlKeepBlanksDefaultValue)
|
572
|
+
options |= XML_PARSE_NOBLANKS;
|
573
|
+
|
574
|
+
if (xmlSubstituteEntitiesDefaultValue)
|
575
|
+
options |= XML_PARSE_NOENT;
|
576
|
+
|
577
|
+
if (!xmlGetWarningsDefaultValue)
|
578
|
+
options |= XML_PARSE_NOWARNING;
|
579
|
+
|
580
|
+
if (xmlPedanticParserDefaultValue)
|
581
|
+
options |= XML_PARSE_PEDANTIC;
|
582
|
+
|
583
|
+
return options;
|
584
|
+
}
|
585
|
+
|
586
|
+
/*
|
587
|
+
* call-seq:
|
588
|
+
* XML.default_options -> int
|
589
|
+
*
|
590
|
+
* Returns an integer that summarize libxml2's default options.
|
591
|
+
*/
|
592
|
+
static VALUE rxml_default_options_get(VALUE klass)
|
593
|
+
{
|
594
|
+
int options = rxml_libxml_default_options();
|
595
|
+
return INT2NUM(options);
|
596
|
+
}
|
597
|
+
|
598
|
+
/*
|
599
|
+
* call-seq:
|
600
|
+
* XML.default_pedantic_parser -> (true|false)
|
601
|
+
*
|
602
|
+
* Determine whether parsers are pedantic by default.
|
603
|
+
*/
|
604
|
+
static VALUE rxml_default_pedantic_parser_get(VALUE klass)
|
605
|
+
{
|
606
|
+
if (xmlPedanticParserDefaultValue)
|
607
|
+
return (Qtrue);
|
608
|
+
else
|
609
|
+
return (Qfalse);
|
610
|
+
}
|
611
|
+
|
612
|
+
/*
|
613
|
+
* call-seq:
|
614
|
+
* XML.default_pedantic_parser = true|false
|
615
|
+
*
|
616
|
+
* Controls whether parsers are pedantic by default.
|
617
|
+
*/
|
618
|
+
static VALUE rxml_default_pedantic_parser_set(VALUE klass, VALUE value)
|
619
|
+
{
|
620
|
+
if (value == Qfalse)
|
621
|
+
{
|
622
|
+
xmlPedanticParserDefault(0);
|
623
|
+
return (Qfalse);
|
624
|
+
}
|
625
|
+
else
|
626
|
+
{
|
627
|
+
xmlPedanticParserDefault(1);
|
628
|
+
return (Qtrue);
|
629
|
+
}
|
630
|
+
}
|
631
|
+
|
632
|
+
/*
|
633
|
+
* call-seq:
|
634
|
+
* XML.default_substitute_entities -> (true|false)
|
635
|
+
*
|
636
|
+
* Determine whether parsers perform inline entity substitution
|
637
|
+
* (for external entities) by default.
|
638
|
+
*/
|
639
|
+
static VALUE rxml_default_substitute_entities_get(VALUE klass)
|
640
|
+
{
|
641
|
+
if (xmlSubstituteEntitiesDefaultValue)
|
642
|
+
return (Qtrue);
|
643
|
+
else
|
644
|
+
return (Qfalse);
|
645
|
+
}
|
646
|
+
|
647
|
+
/*
|
648
|
+
* call-seq:
|
649
|
+
* XML.default_substitute_entities = true|false
|
650
|
+
*
|
651
|
+
* Controls whether parsers perform inline entity substitution
|
652
|
+
* (for external entities) by default.
|
653
|
+
*/
|
654
|
+
static VALUE rxml_default_substitute_entities_set(VALUE klass, VALUE value)
|
655
|
+
{
|
656
|
+
if (value == Qfalse)
|
657
|
+
{
|
658
|
+
xmlSubstituteEntitiesDefault(0);
|
659
|
+
return (Qfalse);
|
660
|
+
}
|
661
|
+
else
|
662
|
+
{
|
663
|
+
xmlSubstituteEntitiesDefault(1);
|
664
|
+
return (Qtrue);
|
665
|
+
}
|
666
|
+
}
|
667
|
+
|
668
|
+
/*
|
669
|
+
* call-seq:
|
670
|
+
* XML.default_tree_indent_string -> "string"
|
671
|
+
*
|
672
|
+
* Obtain the default string used by parsers to indent the XML tree
|
673
|
+
* for output.
|
674
|
+
*/
|
675
|
+
static VALUE rxml_default_tree_indent_string_get(VALUE klass)
|
676
|
+
{
|
677
|
+
if (xmlTreeIndentString == NULL)
|
678
|
+
return (Qnil);
|
679
|
+
else
|
680
|
+
return (rb_str_new2(xmlTreeIndentString));
|
681
|
+
}
|
682
|
+
|
683
|
+
/*
|
684
|
+
* call-seq:
|
685
|
+
* XML.default_tree_indent_string = "string"
|
686
|
+
*
|
687
|
+
* Set the default string used by parsers to indent the XML tree
|
688
|
+
* for output.
|
689
|
+
*/
|
690
|
+
static VALUE rxml_default_tree_indent_string_set(VALUE klass, VALUE string)
|
691
|
+
{
|
692
|
+
Check_Type(string, T_STRING);
|
693
|
+
xmlTreeIndentString = (const char *)xmlStrdup((xmlChar *)StringValuePtr(string));
|
694
|
+
return (string);
|
695
|
+
}
|
696
|
+
|
697
|
+
/*
|
698
|
+
* call-seq:
|
699
|
+
* XML.default_validity_checking -> (true|false)
|
700
|
+
*
|
701
|
+
* Determine whether parsers perform XML validation by default.
|
702
|
+
*/
|
703
|
+
static VALUE rxml_default_validity_checking_get(VALUE klass)
|
704
|
+
{
|
705
|
+
if (xmlDoValidityCheckingDefaultValue)
|
706
|
+
return (Qtrue);
|
707
|
+
else
|
708
|
+
return (Qfalse);
|
709
|
+
}
|
710
|
+
|
711
|
+
/*
|
712
|
+
* call-seq:
|
713
|
+
* XML.default_validity_checking = true|false
|
714
|
+
*
|
715
|
+
* Controls whether parsers perform XML validation by default.
|
716
|
+
*/
|
717
|
+
static VALUE rxml_default_validity_checking_set(VALUE klass, VALUE value)
|
718
|
+
{
|
719
|
+
if (value == Qfalse)
|
720
|
+
{
|
721
|
+
xmlDoValidityCheckingDefaultValue = 0;
|
722
|
+
return (Qfalse);
|
723
|
+
}
|
724
|
+
else
|
725
|
+
{
|
726
|
+
xmlDoValidityCheckingDefaultValue = 1;
|
727
|
+
return (Qtrue);
|
728
|
+
}
|
729
|
+
}
|
730
|
+
|
731
|
+
/*
|
732
|
+
* call-seq:
|
733
|
+
* XML.default_warnings -> (true|false)
|
734
|
+
*
|
735
|
+
* Determine whether parsers output warnings by default.
|
736
|
+
*/
|
737
|
+
static VALUE rxml_default_warnings_get(VALUE klass)
|
738
|
+
{
|
739
|
+
if (xmlGetWarningsDefaultValue)
|
740
|
+
return (Qtrue);
|
741
|
+
else
|
742
|
+
return (Qfalse);
|
743
|
+
}
|
744
|
+
|
745
|
+
/*
|
746
|
+
* call-seq:
|
747
|
+
* XML.default_warnings = true|false
|
748
|
+
*
|
749
|
+
* Controls whether parsers output warnings by default.
|
750
|
+
*/
|
751
|
+
static VALUE rxml_default_warnings_set(VALUE klass, VALUE value)
|
752
|
+
{
|
753
|
+
if (value == Qfalse)
|
754
|
+
{
|
755
|
+
xmlGetWarningsDefaultValue = 0;
|
756
|
+
return (Qfalse);
|
757
|
+
}
|
758
|
+
else
|
759
|
+
{
|
760
|
+
xmlGetWarningsDefaultValue = 1;
|
761
|
+
return (Qtrue);
|
762
|
+
}
|
763
|
+
}
|
764
|
+
|
765
|
+
/*
|
766
|
+
* call-seq:
|
767
|
+
* XML.default_compression -> (true|false)
|
768
|
+
*
|
769
|
+
* Determine whether parsers use Zlib compression by default
|
770
|
+
* (requires libxml to be compiled with Zlib support).
|
771
|
+
*/
|
772
|
+
static VALUE rxml_default_compression_get(VALUE klass)
|
773
|
+
{
|
774
|
+
#ifdef HAVE_ZLIB_H
|
775
|
+
return(INT2FIX(xmlGetCompressMode()));
|
776
|
+
#else
|
777
|
+
rb_warn("libxml was compiled without zlib support");
|
778
|
+
return (Qfalse);
|
779
|
+
#endif
|
780
|
+
}
|
781
|
+
|
782
|
+
/*
|
783
|
+
* call-seq:
|
784
|
+
* XML.default_compression = true|false
|
785
|
+
*
|
786
|
+
* Controls whether parsers use Zlib compression by default
|
787
|
+
* (requires libxml to be compiled with Zlib support).
|
788
|
+
*/
|
789
|
+
static VALUE rxml_default_compression_set(VALUE klass, VALUE num)
|
790
|
+
{
|
791
|
+
#ifdef HAVE_ZLIB_H
|
792
|
+
Check_Type(num, T_FIXNUM);
|
793
|
+
xmlSetCompressMode(FIX2INT(num));
|
794
|
+
return(num);
|
795
|
+
#else
|
796
|
+
rb_warn("libxml was compiled without zlib support");
|
797
|
+
return (Qfalse);
|
798
|
+
#endif
|
799
|
+
}
|
800
|
+
|
801
|
+
/*
|
802
|
+
* call-seq:
|
803
|
+
* XML.features -> ["feature", ..., "feature"]
|
804
|
+
*
|
805
|
+
* Obtains an array of strings representing features supported
|
806
|
+
* (and enabled) by the installed libxml.
|
807
|
+
*/
|
808
|
+
static VALUE rxml_features(VALUE klass)
|
809
|
+
{
|
810
|
+
VALUE arr, str;
|
811
|
+
int i, len = MAX_LIBXML_FEATURES_LEN;
|
812
|
+
char **list = NULL;
|
813
|
+
|
814
|
+
list = ALLOC_N(char *,MAX_LIBXML_FEATURES_LEN);
|
815
|
+
MEMZERO(list, char *, MAX_LIBXML_FEATURES_LEN);
|
816
|
+
|
817
|
+
arr = rb_ary_new();
|
818
|
+
if (xmlGetFeaturesList(&len, (const char **) list) == -1)
|
819
|
+
return Qnil;
|
820
|
+
|
821
|
+
for (i = 0; i < len; i++)
|
822
|
+
{
|
823
|
+
str = rb_str_new2((const char *) list[i]);
|
824
|
+
rb_gc_unregister_address(&str);
|
825
|
+
rb_ary_push(arr, str);
|
826
|
+
}
|
827
|
+
|
828
|
+
if (len == MAX_LIBXML_FEATURES_LEN)
|
829
|
+
rb_warn(
|
830
|
+
"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");
|
831
|
+
|
832
|
+
ruby_xfree(list);
|
833
|
+
return (arr);
|
834
|
+
}
|
835
|
+
|
836
|
+
/*
|
837
|
+
* call-seq:
|
838
|
+
* XML.indent_tree_output -> (true|false)
|
839
|
+
*
|
840
|
+
* Determines whether XML output will be indented
|
841
|
+
* (using the string supplied to +default_indent_tree_string+)
|
842
|
+
*/
|
843
|
+
static VALUE rxml_indent_tree_output_get(VALUE klass)
|
844
|
+
{
|
845
|
+
if (xmlIndentTreeOutput)
|
846
|
+
return (Qtrue);
|
847
|
+
else
|
848
|
+
return (Qfalse);
|
849
|
+
}
|
850
|
+
|
851
|
+
/*
|
852
|
+
* call-seq:
|
853
|
+
* XML.indent_tree_output = true|false
|
854
|
+
*
|
855
|
+
* Controls whether XML output will be indented
|
856
|
+
* (using the string supplied to +default_indent_tree_string+)
|
857
|
+
*/
|
858
|
+
static VALUE rxml_indent_tree_output_set(VALUE klass, VALUE value)
|
859
|
+
{
|
860
|
+
if (value == Qtrue)
|
861
|
+
{
|
862
|
+
xmlIndentTreeOutput = 1;
|
863
|
+
return (Qtrue);
|
864
|
+
}
|
865
|
+
else if (value == Qfalse)
|
866
|
+
{
|
867
|
+
xmlIndentTreeOutput = 0;
|
868
|
+
return (Qfalse);
|
869
|
+
}
|
870
|
+
else
|
871
|
+
{
|
872
|
+
rb_raise(rb_eArgError, "Invalid argument, must be boolean");
|
873
|
+
}
|
874
|
+
}
|
875
|
+
|
876
|
+
/*
|
877
|
+
* call-seq:
|
878
|
+
* XML.memory_dump -> (true|false)
|
879
|
+
*
|
880
|
+
* Perform a parser memory dump (requires memory debugging
|
881
|
+
* support in libxml).
|
882
|
+
*/
|
883
|
+
static VALUE rxml_memory_dump(VALUE self)
|
884
|
+
{
|
885
|
+
#ifdef DEBUG_MEMORY_LOCATION
|
886
|
+
xmlMemoryDump();
|
887
|
+
return(Qtrue);
|
888
|
+
#else
|
889
|
+
rb_warn("libxml was compiled without memory debugging support");
|
890
|
+
return (Qfalse);
|
891
|
+
#endif
|
892
|
+
}
|
893
|
+
|
894
|
+
/*
|
895
|
+
* call-seq:
|
896
|
+
* XML.memory_used -> num_bytes
|
897
|
+
*
|
898
|
+
* Perform a parser memory dump (requires memory debugging
|
899
|
+
* support in libxml).
|
900
|
+
*/
|
901
|
+
static VALUE rxml_memory_used(VALUE self)
|
902
|
+
{
|
903
|
+
#ifdef DEBUG_MEMORY_LOCATION
|
904
|
+
return(INT2NUM(xmlMemUsed()));
|
905
|
+
#else
|
906
|
+
rb_warn("libxml was compiled without memory debugging support");
|
907
|
+
return (Qfalse);
|
908
|
+
#endif
|
909
|
+
}
|
910
|
+
|
911
|
+
/* The libxml gem provides Ruby language bindings for GNOME's Libxml2
|
912
|
+
* XML toolkit. Refer to the README file to get started
|
913
|
+
* and the LICENSE file for copyright and distribution information.
|
914
|
+
*/
|
915
|
+
|
916
|
+
void rxml_init_xml(void)
|
917
|
+
{
|
918
|
+
/* Create a hashtable suitable for pointer keys */
|
919
|
+
private_pointers = st_init_numtable();
|
920
|
+
|
921
|
+
mXML = rb_define_module_under(mLibXML, "XML");
|
922
|
+
|
923
|
+
/* Constants */
|
924
|
+
rb_define_const(mXML, "LIBXML_VERSION", rb_str_new2(LIBXML_DOTTED_VERSION));
|
925
|
+
rb_define_const(mXML, "VERSION", rb_str_new2(RUBY_LIBXML_VERSION));
|
926
|
+
rb_define_const(mXML, "VERNUM", INT2NUM(RUBY_LIBXML_VERNUM));
|
927
|
+
rb_define_const(mXML, "XML_NAMESPACE", rb_str_new2((const char*) XML_XML_NAMESPACE));
|
928
|
+
|
929
|
+
rb_define_module_function(mXML, "enabled_automata?", rxml_enabled_automata_q, 0);
|
930
|
+
rb_define_module_function(mXML, "enabled_c14n?", rxml_enabled_c14n_q, 0);
|
931
|
+
rb_define_module_function(mXML, "enabled_catalog?", rxml_enabled_catalog_q, 0);
|
932
|
+
rb_define_module_function(mXML, "enabled_debug?", rxml_enabled_debug_q, 0);
|
933
|
+
rb_define_module_function(mXML, "enabled_docbook?", rxml_enabled_docbook_q, 0);
|
934
|
+
rb_define_module_function(mXML, "enabled_ftp?", rxml_enabled_ftp_q, 0);
|
935
|
+
rb_define_module_function(mXML, "enabled_http?", rxml_enabled_http_q, 0);
|
936
|
+
rb_define_module_function(mXML, "enabled_html?", rxml_enabled_html_q, 0);
|
937
|
+
rb_define_module_function(mXML, "enabled_iconv?", rxml_enabled_iconv_q, 0);
|
938
|
+
rb_define_module_function(mXML, "enabled_memory_debug?", rxml_enabled_memory_debug_location_q, 0);
|
939
|
+
rb_define_module_function(mXML, "enabled_regexp?", rxml_enabled_regexp_q, 0);
|
940
|
+
rb_define_module_function(mXML, "enabled_schemas?", rxml_enabled_schemas_q, 0);
|
941
|
+
rb_define_module_function(mXML, "enabled_thread?", rxml_enabled_thread_q, 0);
|
942
|
+
rb_define_module_function(mXML, "enabled_unicode?", rxml_enabled_unicode_q, 0);
|
943
|
+
rb_define_module_function(mXML, "enabled_xinclude?", rxml_enabled_xinclude_q, 0);
|
944
|
+
rb_define_module_function(mXML, "enabled_xpath?", rxml_enabled_xpath_q, 0);
|
945
|
+
rb_define_module_function(mXML, "enabled_xpointer?", rxml_enabled_xpointer_q, 0);
|
946
|
+
rb_define_module_function(mXML, "enabled_zlib?", rxml_enabled_zlib_q, 0);
|
947
|
+
|
948
|
+
rb_define_module_function(mXML, "catalog_dump", rxml_catalog_dump, 0);
|
949
|
+
rb_define_module_function(mXML, "catalog_remove", rxml_catalog_remove, 1);
|
950
|
+
rb_define_module_function(mXML, "check_lib_versions", rxml_check_lib_versions, 0);
|
951
|
+
rb_define_module_function(mXML, "debug_entities", rxml_debug_entities_get, 0);
|
952
|
+
rb_define_module_function(mXML, "debug_entities=", rxml_debug_entities_set, 1);
|
953
|
+
rb_define_module_function(mXML, "default_compression", rxml_default_compression_get, 0);
|
954
|
+
rb_define_module_function(mXML, "default_compression=", rxml_default_compression_set, 1);
|
955
|
+
rb_define_module_function(mXML, "default_keep_blanks", rxml_default_keep_blanks_get, 0);
|
956
|
+
rb_define_module_function(mXML, "default_keep_blanks=", rxml_default_keep_blanks_set, 1);
|
957
|
+
rb_define_module_function(mXML, "default_load_external_dtd", rxml_default_load_external_dtd_get, 0);
|
958
|
+
rb_define_module_function(mXML, "default_load_external_dtd=", rxml_default_load_external_dtd_set, 1);
|
959
|
+
rb_define_module_function(mXML, "default_line_numbers", rxml_default_line_numbers_get, 0);
|
960
|
+
rb_define_module_function(mXML, "default_line_numbers=", rxml_default_line_numbers_set, 1);
|
961
|
+
rb_define_module_function(mXML, "default_options", rxml_default_options_get, 0);
|
962
|
+
rb_define_module_function(mXML, "default_pedantic_parser", rxml_default_pedantic_parser_get, 0);
|
963
|
+
rb_define_module_function(mXML, "default_pedantic_parser=", rxml_default_pedantic_parser_set, 1);
|
964
|
+
rb_define_module_function(mXML, "default_substitute_entities", rxml_default_substitute_entities_get, 0);
|
965
|
+
rb_define_module_function(mXML, "default_substitute_entities=", rxml_default_substitute_entities_set, 1);
|
966
|
+
rb_define_module_function(mXML, "default_tree_indent_string", rxml_default_tree_indent_string_get, 0);
|
967
|
+
rb_define_module_function(mXML, "default_tree_indent_string=", rxml_default_tree_indent_string_set, 1);
|
968
|
+
rb_define_module_function(mXML, "default_validity_checking", rxml_default_validity_checking_get, 0);
|
969
|
+
rb_define_module_function(mXML, "default_validity_checking=", rxml_default_validity_checking_set, 1);
|
970
|
+
rb_define_module_function(mXML, "default_warnings", rxml_default_warnings_get, 0);
|
971
|
+
rb_define_module_function(mXML, "default_warnings=", rxml_default_warnings_set, 1);
|
972
|
+
rb_define_module_function(mXML, "features", rxml_features, 0);
|
973
|
+
rb_define_module_function(mXML, "indent_tree_output", rxml_indent_tree_output_get, 0);
|
974
|
+
rb_define_module_function(mXML, "indent_tree_output=", rxml_indent_tree_output_set, 1);
|
975
|
+
rb_define_module_function(mXML, "memory_dump", rxml_memory_dump, 0);
|
976
|
+
rb_define_module_function(mXML, "memory_used", rxml_memory_used, 0);
|
977
|
+
}
|