libxml-ruby 2.8.0 → 3.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. checksums.yaml +5 -5
  2. data/HISTORY +842 -775
  3. data/LICENSE +20 -20
  4. data/MANIFEST +166 -166
  5. data/README.rdoc +217 -184
  6. data/Rakefile +90 -78
  7. data/ext/libxml/extconf.h +3 -0
  8. data/ext/libxml/extconf.rb +61 -116
  9. data/ext/libxml/libxml.c +80 -76
  10. data/ext/libxml/ruby_libxml.h +67 -75
  11. data/ext/libxml/ruby_xml.c +933 -893
  12. data/ext/libxml/ruby_xml.h +10 -10
  13. data/ext/libxml/ruby_xml_attr.c +333 -333
  14. data/ext/libxml/ruby_xml_attr.h +12 -12
  15. data/ext/libxml/ruby_xml_attr_decl.c +153 -153
  16. data/ext/libxml/ruby_xml_attr_decl.h +11 -11
  17. data/ext/libxml/ruby_xml_attributes.c +275 -275
  18. data/ext/libxml/ruby_xml_attributes.h +15 -15
  19. data/ext/libxml/ruby_xml_cbg.c +85 -85
  20. data/ext/libxml/ruby_xml_document.c +1123 -1147
  21. data/ext/libxml/ruby_xml_document.h +11 -11
  22. data/ext/libxml/ruby_xml_dtd.c +248 -268
  23. data/ext/libxml/ruby_xml_dtd.h +9 -9
  24. data/ext/libxml/ruby_xml_encoding.c +250 -260
  25. data/ext/libxml/ruby_xml_encoding.h +16 -19
  26. data/ext/libxml/ruby_xml_error.c +996 -996
  27. data/ext/libxml/ruby_xml_error.h +12 -12
  28. data/ext/libxml/ruby_xml_html_parser.c +89 -92
  29. data/ext/libxml/ruby_xml_html_parser.h +10 -10
  30. data/ext/libxml/ruby_xml_html_parser_context.c +337 -338
  31. data/ext/libxml/ruby_xml_html_parser_context.h +10 -10
  32. data/ext/libxml/ruby_xml_html_parser_options.c +46 -46
  33. data/ext/libxml/ruby_xml_html_parser_options.h +10 -10
  34. data/ext/libxml/ruby_xml_input_cbg.c +191 -191
  35. data/ext/libxml/ruby_xml_input_cbg.h +20 -20
  36. data/ext/libxml/ruby_xml_io.c +47 -50
  37. data/ext/libxml/ruby_xml_io.h +10 -10
  38. data/ext/libxml/ruby_xml_namespace.c +153 -153
  39. data/ext/libxml/ruby_xml_namespace.h +10 -10
  40. data/ext/libxml/ruby_xml_namespaces.c +293 -293
  41. data/ext/libxml/ruby_xml_namespaces.h +9 -9
  42. data/ext/libxml/ruby_xml_node.c +1402 -1452
  43. data/ext/libxml/ruby_xml_node.h +13 -11
  44. data/ext/libxml/ruby_xml_parser.c +91 -94
  45. data/ext/libxml/ruby_xml_parser.h +12 -12
  46. data/ext/libxml/ruby_xml_parser_context.c +999 -1001
  47. data/ext/libxml/ruby_xml_parser_context.h +10 -10
  48. data/ext/libxml/ruby_xml_parser_options.c +66 -66
  49. data/ext/libxml/ruby_xml_parser_options.h +12 -12
  50. data/ext/libxml/ruby_xml_reader.c +1239 -1228
  51. data/ext/libxml/ruby_xml_reader.h +17 -17
  52. data/ext/libxml/ruby_xml_relaxng.c +110 -111
  53. data/ext/libxml/ruby_xml_relaxng.h +10 -10
  54. data/ext/libxml/ruby_xml_sax2_handler.c +326 -328
  55. data/ext/libxml/ruby_xml_sax2_handler.h +10 -10
  56. data/ext/libxml/ruby_xml_sax_parser.c +116 -120
  57. data/ext/libxml/ruby_xml_sax_parser.h +10 -10
  58. data/ext/libxml/ruby_xml_schema.c +278 -301
  59. data/ext/libxml/ruby_xml_schema.h +809 -809
  60. data/ext/libxml/ruby_xml_schema_attribute.c +109 -109
  61. data/ext/libxml/ruby_xml_schema_attribute.h +15 -15
  62. data/ext/libxml/ruby_xml_schema_element.c +95 -94
  63. data/ext/libxml/ruby_xml_schema_element.h +14 -14
  64. data/ext/libxml/ruby_xml_schema_facet.c +52 -52
  65. data/ext/libxml/ruby_xml_schema_facet.h +13 -13
  66. data/ext/libxml/ruby_xml_schema_type.c +232 -259
  67. data/ext/libxml/ruby_xml_schema_type.h +9 -9
  68. data/ext/libxml/ruby_xml_version.h +9 -9
  69. data/ext/libxml/ruby_xml_writer.c +1133 -1137
  70. data/ext/libxml/ruby_xml_writer.h +10 -10
  71. data/ext/libxml/ruby_xml_xinclude.c +16 -16
  72. data/ext/libxml/ruby_xml_xinclude.h +11 -11
  73. data/ext/libxml/ruby_xml_xpath.c +194 -188
  74. data/ext/libxml/ruby_xml_xpath.h +13 -13
  75. data/ext/libxml/ruby_xml_xpath_context.c +360 -361
  76. data/ext/libxml/ruby_xml_xpath_context.h +9 -9
  77. data/ext/libxml/ruby_xml_xpath_expression.c +81 -81
  78. data/ext/libxml/ruby_xml_xpath_expression.h +10 -10
  79. data/ext/libxml/ruby_xml_xpath_object.c +338 -335
  80. data/ext/libxml/ruby_xml_xpath_object.h +17 -17
  81. data/ext/libxml/ruby_xml_xpointer.c +99 -99
  82. data/ext/libxml/ruby_xml_xpointer.h +11 -11
  83. data/ext/vc/libxml_ruby.sln +17 -15
  84. data/lib/libxml-ruby.rb +30 -0
  85. data/lib/libxml.rb +3 -33
  86. data/lib/libxml/node.rb +2 -78
  87. data/lib/libxml/parser.rb +0 -266
  88. data/lib/libxml/sax_parser.rb +0 -17
  89. data/lib/libxml/schema.rb +47 -66
  90. data/lib/libxml/schema/attribute.rb +19 -19
  91. data/lib/libxml/schema/element.rb +19 -27
  92. data/lib/libxml/schema/type.rb +21 -29
  93. data/libxml-ruby.gemspec +48 -44
  94. data/script/benchmark/depixelate +634 -634
  95. data/script/benchmark/hamlet.xml +9054 -9054
  96. data/script/benchmark/parsecount +170 -170
  97. data/script/benchmark/throughput +41 -41
  98. data/script/test +6 -6
  99. data/setup.rb +0 -1
  100. data/test/c14n/given/example-1.xml +14 -14
  101. data/test/c14n/given/example-2.xml +11 -11
  102. data/test/c14n/given/example-3.xml +18 -18
  103. data/test/c14n/given/example-4.xml +9 -9
  104. data/test/c14n/given/example-5.xml +12 -12
  105. data/test/c14n/given/example-6.xml +2 -2
  106. data/test/c14n/given/example-7.xml +11 -11
  107. data/test/c14n/given/example-8.xml +11 -11
  108. data/test/c14n/given/example-8.xpath +9 -9
  109. data/test/c14n/result/1-1-without-comments/example-1 +3 -3
  110. data/test/c14n/result/1-1-without-comments/example-2 +10 -10
  111. data/test/c14n/result/1-1-without-comments/example-3 +13 -13
  112. data/test/c14n/result/1-1-without-comments/example-4 +8 -8
  113. data/test/c14n/result/1-1-without-comments/example-5 +2 -2
  114. data/test/c14n/result/with-comments/example-1 +5 -5
  115. data/test/c14n/result/with-comments/example-2 +10 -10
  116. data/test/c14n/result/with-comments/example-3 +13 -13
  117. data/test/c14n/result/with-comments/example-4 +8 -8
  118. data/test/c14n/result/with-comments/example-5 +3 -3
  119. data/test/c14n/result/without-comments/example-1 +3 -3
  120. data/test/c14n/result/without-comments/example-2 +10 -10
  121. data/test/c14n/result/without-comments/example-3 +13 -13
  122. data/test/c14n/result/without-comments/example-4 +8 -8
  123. data/test/c14n/result/without-comments/example-5 +2 -2
  124. data/test/model/atom.xml +12 -12
  125. data/test/model/bands.iso-8859-1.xml +4 -4
  126. data/test/model/bands.utf-8.xml +4 -4
  127. data/test/model/bands.xml +4 -4
  128. data/test/model/books.xml +153 -153
  129. data/test/model/cwm_1_0.xml +11336 -0
  130. data/test/model/merge_bug_data.xml +58 -58
  131. data/test/model/ruby-lang.html +238 -238
  132. data/test/model/rubynet.xml +79 -79
  133. data/test/model/shiporder.rnc +28 -28
  134. data/test/model/shiporder.rng +86 -86
  135. data/test/model/shiporder.xml +22 -22
  136. data/test/model/shiporder.xsd +39 -39
  137. data/test/model/soap.xml +27 -27
  138. data/test/model/xinclude.xml +4 -4
  139. data/test/test.xml +2 -0
  140. data/test/{tc_attr.rb → test_attr.rb} +23 -25
  141. data/test/{tc_attr_decl.rb → test_attr_decl.rb} +13 -14
  142. data/test/{tc_attributes.rb → test_attributes.rb} +11 -18
  143. data/test/{tc_canonicalize.rb → test_canonicalize.rb} +36 -41
  144. data/test/test_deprecated_require.rb +12 -0
  145. data/test/{tc_document.rb → test_document.rb} +32 -27
  146. data/test/test_document_write.rb +146 -0
  147. data/test/{tc_dtd.rb → test_dtd.rb} +28 -29
  148. data/test/{tc_encoding.rb → test_encoding.rb} +129 -126
  149. data/test/{tc_encoding_sax.rb → test_encoding_sax.rb} +7 -6
  150. data/test/test_error.rb +178 -0
  151. data/test/test_helper.rb +3 -10
  152. data/test/test_html_parser.rb +162 -0
  153. data/test/test_html_parser_context.rb +23 -0
  154. data/test/test_namespace.rb +60 -0
  155. data/test/{tc_namespaces.rb → test_namespaces.rb} +34 -44
  156. data/test/{tc_node.rb → test_node.rb} +68 -47
  157. data/test/{tc_node_cdata.rb → test_node_cdata.rb} +12 -13
  158. data/test/{tc_node_comment.rb → test_node_comment.rb} +7 -8
  159. data/test/{tc_node_copy.rb → test_node_copy.rb} +4 -6
  160. data/test/{tc_node_edit.rb → test_node_edit.rb} +23 -41
  161. data/test/{tc_node_pi.rb → test_node_pi.rb} +37 -40
  162. data/test/{tc_node_text.rb → test_node_text.rb} +10 -12
  163. data/test/{tc_node_write.rb → test_node_write.rb} +18 -29
  164. data/test/test_node_xlink.rb +28 -0
  165. data/test/test_parser.rb +324 -0
  166. data/test/{tc_parser_context.rb → test_parser_context.rb} +41 -42
  167. data/test/{tc_properties.rb → test_properties.rb} +6 -7
  168. data/test/test_reader.rb +363 -0
  169. data/test/test_relaxng.rb +53 -0
  170. data/test/{tc_sax_parser.rb → test_sax_parser.rb} +36 -37
  171. data/test/{tc_schema.rb → test_schema.rb} +43 -37
  172. data/test/test_suite.rb +38 -40
  173. data/test/{tc_traversal.rb → test_traversal.rb} +5 -6
  174. data/test/{tc_writer.rb → test_writer.rb} +468 -448
  175. data/test/{tc_xinclude.rb → test_xinclude.rb} +4 -5
  176. data/test/test_xml.rb +262 -0
  177. data/test/{tc_xpath.rb → test_xpath.rb} +31 -32
  178. data/test/{tc_xpath_context.rb → test_xpath_context.rb} +8 -9
  179. data/test/test_xpath_expression.rb +37 -0
  180. data/test/{tc_xpointer.rb → test_xpointer.rb} +16 -18
  181. metadata +117 -95
  182. data/lib/libxml/ns.rb +0 -22
  183. data/lib/libxml/properties.rb +0 -23
  184. data/lib/libxml/reader.rb +0 -29
  185. data/lib/libxml/xpath_object.rb +0 -16
  186. data/test/etc_doc_to_s.rb +0 -21
  187. data/test/ets_doc_file.rb +0 -17
  188. data/test/ets_doc_to_s.rb +0 -23
  189. data/test/ets_gpx.rb +0 -28
  190. data/test/ets_node_gc.rb +0 -23
  191. data/test/ets_test.xml +0 -2
  192. data/test/ets_tsr.rb +0 -11
  193. data/test/tc_deprecated_require.rb +0 -13
  194. data/test/tc_document_write.rb +0 -196
  195. data/test/tc_error.rb +0 -180
  196. data/test/tc_html_parser.rb +0 -153
  197. data/test/tc_html_parser_context.rb +0 -24
  198. data/test/tc_namespace.rb +0 -62
  199. data/test/tc_node_xlink.rb +0 -29
  200. data/test/tc_parser.rb +0 -381
  201. data/test/tc_reader.rb +0 -400
  202. data/test/tc_relaxng.rb +0 -54
  203. data/test/tc_xml.rb +0 -226
  204. data/test/tc_xpath_expression.rb +0 -38
@@ -1,75 +1,67 @@
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
- #include <libxml/c14n.h>
18
-
19
- /* Needed prior to Ruby 1.9.1 */
20
- #ifndef RHASH_TBL
21
- #define RHASH_TBL(s) (RHASH(s)->tbl)
22
- #endif
23
-
24
- // Encoding support added in Ruby 1.9.*
25
- #ifdef HAVE_RUBY_ENCODING_H
26
- #include <ruby/encoding.h>
27
- #endif
28
-
29
- #ifdef LIBXML_DEBUG_ENABLED
30
- #include <libxml/xpathInternals.h>
31
- #endif
32
- #ifdef LIBXML_XINCLUDE_ENABLED
33
- #include <libxml/xinclude.h>
34
- #endif
35
- #ifdef LIBXML_XPTR_ENABLED
36
- #include <libxml/xpointer.h>
37
- #endif
38
-
39
- #include "ruby_xml_version.h"
40
- #include "ruby_xml.h"
41
- #include "ruby_xml_io.h"
42
- #include "ruby_xml_error.h"
43
- #include "ruby_xml_encoding.h"
44
- #include "ruby_xml_attributes.h"
45
- #include "ruby_xml_attr.h"
46
- #include "ruby_xml_attr_decl.h"
47
- #include "ruby_xml_document.h"
48
- #include "ruby_xml_node.h"
49
- #include "ruby_xml_namespace.h"
50
- #include "ruby_xml_namespaces.h"
51
- #include "ruby_xml_parser.h"
52
- #include "ruby_xml_parser_options.h"
53
- #include "ruby_xml_parser_context.h"
54
- #include "ruby_xml_html_parser.h"
55
- #include "ruby_xml_html_parser_options.h"
56
- #include "ruby_xml_html_parser_context.h"
57
- #include "ruby_xml_reader.h"
58
- #include "ruby_xml_writer.h"
59
- #include "ruby_xml_sax2_handler.h"
60
- #include "ruby_xml_sax_parser.h"
61
- #include "ruby_xml_writer.h"
62
- #include "ruby_xml_xinclude.h"
63
- #include "ruby_xml_xpath.h"
64
- #include "ruby_xml_xpath_expression.h"
65
- #include "ruby_xml_xpath_context.h"
66
- #include "ruby_xml_xpath_object.h"
67
- #include "ruby_xml_xpointer.h"
68
- #include "ruby_xml_input_cbg.h"
69
- #include "ruby_xml_dtd.h"
70
- #include "ruby_xml_schema.h"
71
- #include "ruby_xml_relaxng.h"
72
-
73
- extern VALUE mLibXML;
74
-
75
- #endif
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
+ #include <libxml/c14n.h>
18
+
19
+ #include <ruby/encoding.h>
20
+
21
+ #ifdef LIBXML_DEBUG_ENABLED
22
+ #include <libxml/xpathInternals.h>
23
+ #endif
24
+ #ifdef LIBXML_XINCLUDE_ENABLED
25
+ #include <libxml/xinclude.h>
26
+ #endif
27
+ #ifdef LIBXML_XPTR_ENABLED
28
+ #include <libxml/xpointer.h>
29
+ #endif
30
+
31
+ #include "ruby_xml_version.h"
32
+ #include "ruby_xml.h"
33
+ #include "ruby_xml_io.h"
34
+ #include "ruby_xml_error.h"
35
+ #include "ruby_xml_encoding.h"
36
+ #include "ruby_xml_attributes.h"
37
+ #include "ruby_xml_attr.h"
38
+ #include "ruby_xml_attr_decl.h"
39
+ #include "ruby_xml_document.h"
40
+ #include "ruby_xml_node.h"
41
+ #include "ruby_xml_namespace.h"
42
+ #include "ruby_xml_namespaces.h"
43
+ #include "ruby_xml_parser.h"
44
+ #include "ruby_xml_parser_options.h"
45
+ #include "ruby_xml_parser_context.h"
46
+ #include "ruby_xml_html_parser.h"
47
+ #include "ruby_xml_html_parser_options.h"
48
+ #include "ruby_xml_html_parser_context.h"
49
+ #include "ruby_xml_reader.h"
50
+ #include "ruby_xml_writer.h"
51
+ #include "ruby_xml_sax2_handler.h"
52
+ #include "ruby_xml_sax_parser.h"
53
+ #include "ruby_xml_writer.h"
54
+ #include "ruby_xml_xinclude.h"
55
+ #include "ruby_xml_xpath.h"
56
+ #include "ruby_xml_xpath_expression.h"
57
+ #include "ruby_xml_xpath_context.h"
58
+ #include "ruby_xml_xpath_object.h"
59
+ #include "ruby_xml_xpointer.h"
60
+ #include "ruby_xml_input_cbg.h"
61
+ #include "ruby_xml_dtd.h"
62
+ #include "ruby_xml_schema.h"
63
+ #include "ruby_xml_relaxng.h"
64
+
65
+ extern VALUE mLibXML;
66
+
67
+ #endif
@@ -1,893 +1,933 @@
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
- }
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 value)
357
+ {
358
+ #ifdef LIBXML_DEBUG_ENABLED
359
+ if (value == Qfalse)
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 value)
395
+ {
396
+ if (value == Qfalse)
397
+ {
398
+ xmlKeepBlanksDefaultValue = 0;
399
+ return (Qfalse);
400
+ }
401
+ else if (value == Qtrue)
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 value)
433
+ {
434
+ if (value == 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 value)
467
+ {
468
+ if (value == Qfalse)
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 value)
538
+ {
539
+ if (value == Qfalse)
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 value)
574
+ {
575
+ if (value == 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 = (const char *)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 value)
637
+ {
638
+ if (value == Qfalse)
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 value)
671
+ {
672
+ if (value == Qfalse)
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.default_save_no_empty_tags -> (true|false)
723
+ *
724
+ * Determine whether serializer outputs empty tags by default.
725
+ */
726
+ static VALUE rxml_default_save_no_empty_tags_get(VALUE klass)
727
+ {
728
+ if (xmlSaveNoEmptyTags)
729
+ return (Qtrue);
730
+ else
731
+ return (Qfalse);
732
+ }
733
+
734
+ /*
735
+ * call-seq:
736
+ * XML.default_save_no_empty_tags = true|false
737
+ *
738
+ * Controls whether serializer outputs empty tags by default.
739
+ */
740
+ static VALUE rxml_default_save_no_empty_tags_set(VALUE klass, VALUE value)
741
+ {
742
+ if (value == Qfalse)
743
+ {
744
+ xmlSaveNoEmptyTags = 0;
745
+ return (Qfalse);
746
+ }
747
+ else if (value == Qtrue)
748
+ {
749
+ xmlSaveNoEmptyTags = 1;
750
+ return (Qtrue);
751
+ }
752
+ else
753
+ {
754
+ rb_raise(rb_eArgError, "Invalid argument, must be a boolean");
755
+ }
756
+ }
757
+
758
+ /*
759
+ * call-seq:
760
+ * XML.features -> ["feature", ..., "feature"]
761
+ *
762
+ * Obtains an array of strings representing features supported
763
+ * (and enabled) by the installed libxml.
764
+ */
765
+ static VALUE rxml_features(VALUE klass)
766
+ {
767
+ VALUE arr, str;
768
+ int i, len = MAX_LIBXML_FEATURES_LEN;
769
+ char **list = NULL;
770
+
771
+ list = ALLOC_N(char *,MAX_LIBXML_FEATURES_LEN);
772
+ MEMZERO(list, char *, MAX_LIBXML_FEATURES_LEN);
773
+
774
+ arr = rb_ary_new();
775
+ if (xmlGetFeaturesList(&len, (const char **) list) == -1)
776
+ return Qnil;
777
+
778
+ for (i = 0; i < len; i++)
779
+ {
780
+ str = rb_str_new2((const char *) list[i]);
781
+ rb_gc_unregister_address(&str);
782
+ rb_ary_push(arr, str);
783
+ }
784
+
785
+ if (len == MAX_LIBXML_FEATURES_LEN)
786
+ rb_warn(
787
+ "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");
788
+
789
+ ruby_xfree(list);
790
+ return (arr);
791
+ }
792
+
793
+ /*
794
+ * call-seq:
795
+ * XML.indent_tree_output -> (true|false)
796
+ *
797
+ * Determines whether XML output will be indented
798
+ * (using the string supplied to +default_indent_tree_string+)
799
+ */
800
+ static VALUE rxml_indent_tree_output_get(VALUE klass)
801
+ {
802
+ if (xmlIndentTreeOutput)
803
+ return (Qtrue);
804
+ else
805
+ return (Qfalse);
806
+ }
807
+
808
+ /*
809
+ * call-seq:
810
+ * XML.indent_tree_output = true|false
811
+ *
812
+ * Controls whether XML output will be indented
813
+ * (using the string supplied to +default_indent_tree_string+)
814
+ */
815
+ static VALUE rxml_indent_tree_output_set(VALUE klass, VALUE value)
816
+ {
817
+ if (value == Qtrue)
818
+ {
819
+ xmlIndentTreeOutput = 1;
820
+ return (Qtrue);
821
+ }
822
+ else if (value == Qfalse)
823
+ {
824
+ xmlIndentTreeOutput = 0;
825
+ return (Qfalse);
826
+ }
827
+ else
828
+ {
829
+ rb_raise(rb_eArgError, "Invalid argument, must be boolean");
830
+ }
831
+ }
832
+
833
+ /*
834
+ * call-seq:
835
+ * XML.memory_dump -> (true|false)
836
+ *
837
+ * Perform a parser memory dump (requires memory debugging
838
+ * support in libxml).
839
+ */
840
+ static VALUE rxml_memory_dump(VALUE self)
841
+ {
842
+ #ifdef DEBUG_MEMORY_LOCATION
843
+ xmlMemoryDump();
844
+ return(Qtrue);
845
+ #else
846
+ rb_warn("libxml was compiled without memory debugging support");
847
+ return (Qfalse);
848
+ #endif
849
+ }
850
+
851
+ /*
852
+ * call-seq:
853
+ * XML.memory_used -> num_bytes
854
+ *
855
+ * Perform a parser memory dump (requires memory debugging
856
+ * support in libxml).
857
+ */
858
+ static VALUE rxml_memory_used(VALUE self)
859
+ {
860
+ #ifdef DEBUG_MEMORY_LOCATION
861
+ return(INT2NUM(xmlMemUsed()));
862
+ #else
863
+ rb_warn("libxml was compiled without memory debugging support");
864
+ return (Qfalse);
865
+ #endif
866
+ }
867
+
868
+ /* The libxml gem provides Ruby language bindings for GNOME's Libxml2
869
+ * XML toolkit. Refer to the README file to get started
870
+ * and the LICENSE file for copyright and distribution information.
871
+ */
872
+
873
+ void rxml_init_xml(void)
874
+ {
875
+ mXML = rb_define_module_under(mLibXML, "XML");
876
+
877
+ /* Constants */
878
+ rb_define_const(mXML, "LIBXML_VERSION", rb_str_new2(LIBXML_DOTTED_VERSION));
879
+ rb_define_const(mXML, "VERSION", rb_str_new2(RUBY_LIBXML_VERSION));
880
+ rb_define_const(mXML, "VERNUM", INT2NUM(RUBY_LIBXML_VERNUM));
881
+ rb_define_const(mXML, "XML_NAMESPACE", rb_str_new2((const char*) XML_XML_NAMESPACE));
882
+
883
+ rb_define_module_function(mXML, "enabled_automata?", rxml_enabled_automata_q, 0);
884
+ rb_define_module_function(mXML, "enabled_c14n?", rxml_enabled_c14n_q, 0);
885
+ rb_define_module_function(mXML, "enabled_catalog?", rxml_enabled_catalog_q, 0);
886
+ rb_define_module_function(mXML, "enabled_debug?", rxml_enabled_debug_q, 0);
887
+ rb_define_module_function(mXML, "enabled_docbook?", rxml_enabled_docbook_q, 0);
888
+ rb_define_module_function(mXML, "enabled_ftp?", rxml_enabled_ftp_q, 0);
889
+ rb_define_module_function(mXML, "enabled_http?", rxml_enabled_http_q, 0);
890
+ rb_define_module_function(mXML, "enabled_html?", rxml_enabled_html_q, 0);
891
+ rb_define_module_function(mXML, "enabled_iconv?", rxml_enabled_iconv_q, 0);
892
+ rb_define_module_function(mXML, "enabled_memory_debug?", rxml_enabled_memory_debug_location_q, 0);
893
+ rb_define_module_function(mXML, "enabled_regexp?", rxml_enabled_regexp_q, 0);
894
+ rb_define_module_function(mXML, "enabled_schemas?", rxml_enabled_schemas_q, 0);
895
+ rb_define_module_function(mXML, "enabled_thread?", rxml_enabled_thread_q, 0);
896
+ rb_define_module_function(mXML, "enabled_unicode?", rxml_enabled_unicode_q, 0);
897
+ rb_define_module_function(mXML, "enabled_xinclude?", rxml_enabled_xinclude_q, 0);
898
+ rb_define_module_function(mXML, "enabled_xpath?", rxml_enabled_xpath_q, 0);
899
+ rb_define_module_function(mXML, "enabled_xpointer?", rxml_enabled_xpointer_q, 0);
900
+ rb_define_module_function(mXML, "enabled_zlib?", rxml_enabled_zlib_q, 0);
901
+
902
+ rb_define_module_function(mXML, "catalog_dump", rxml_catalog_dump, 0);
903
+ rb_define_module_function(mXML, "catalog_remove", rxml_catalog_remove, 1);
904
+ rb_define_module_function(mXML, "check_lib_versions", rxml_check_lib_versions, 0);
905
+ rb_define_module_function(mXML, "debug_entities", rxml_debug_entities_get, 0);
906
+ rb_define_module_function(mXML, "debug_entities=", rxml_debug_entities_set, 1);
907
+ rb_define_module_function(mXML, "default_compression", rxml_default_compression_get, 0);
908
+ rb_define_module_function(mXML, "default_compression=", rxml_default_compression_set, 1);
909
+ rb_define_module_function(mXML, "default_keep_blanks", rxml_default_keep_blanks_get, 0);
910
+ rb_define_module_function(mXML, "default_keep_blanks=", rxml_default_keep_blanks_set, 1);
911
+ rb_define_module_function(mXML, "default_load_external_dtd", rxml_default_load_external_dtd_get, 0);
912
+ rb_define_module_function(mXML, "default_load_external_dtd=", rxml_default_load_external_dtd_set, 1);
913
+ rb_define_module_function(mXML, "default_line_numbers", rxml_default_line_numbers_get, 0);
914
+ rb_define_module_function(mXML, "default_line_numbers=", rxml_default_line_numbers_set, 1);
915
+ rb_define_module_function(mXML, "default_options", rxml_default_options_get, 0);
916
+ rb_define_module_function(mXML, "default_pedantic_parser", rxml_default_pedantic_parser_get, 0);
917
+ rb_define_module_function(mXML, "default_pedantic_parser=", rxml_default_pedantic_parser_set, 1);
918
+ rb_define_module_function(mXML, "default_substitute_entities", rxml_default_substitute_entities_get, 0);
919
+ rb_define_module_function(mXML, "default_substitute_entities=", rxml_default_substitute_entities_set, 1);
920
+ rb_define_module_function(mXML, "default_tree_indent_string", rxml_default_tree_indent_string_get, 0);
921
+ rb_define_module_function(mXML, "default_tree_indent_string=", rxml_default_tree_indent_string_set, 1);
922
+ rb_define_module_function(mXML, "default_validity_checking", rxml_default_validity_checking_get, 0);
923
+ rb_define_module_function(mXML, "default_validity_checking=", rxml_default_validity_checking_set, 1);
924
+ rb_define_module_function(mXML, "default_warnings", rxml_default_warnings_get, 0);
925
+ rb_define_module_function(mXML, "default_warnings=", rxml_default_warnings_set, 1);
926
+ rb_define_module_function(mXML, "default_save_no_empty_tags", rxml_default_save_no_empty_tags_get, 0);
927
+ rb_define_module_function(mXML, "default_save_no_empty_tags=", rxml_default_save_no_empty_tags_set, 1);
928
+ rb_define_module_function(mXML, "features", rxml_features, 0);
929
+ rb_define_module_function(mXML, "indent_tree_output", rxml_indent_tree_output_get, 0);
930
+ rb_define_module_function(mXML, "indent_tree_output=", rxml_indent_tree_output_set, 1);
931
+ rb_define_module_function(mXML, "memory_dump", rxml_memory_dump, 0);
932
+ rb_define_module_function(mXML, "memory_used", rxml_memory_used, 0);
933
+ }