libxml-ruby 0.9.8-x86-mswin32-60 → 0.9.9-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/CHANGES +41 -1
  2. data/LICENSE +3 -4
  3. data/README +37 -24
  4. data/Rakefile +2 -2
  5. data/ext/libxml/extconf.rb +31 -12
  6. data/ext/libxml/libxml.c +56 -858
  7. data/ext/libxml/ruby_libxml.h +93 -96
  8. data/ext/libxml/ruby_xml.c +855 -0
  9. data/ext/libxml/ruby_xml.h +9 -0
  10. data/ext/libxml/ruby_xml_attr.c +3 -9
  11. data/ext/libxml/ruby_xml_attr.h +2 -2
  12. data/ext/libxml/ruby_xml_attr_decl.c +2 -8
  13. data/ext/libxml/ruby_xml_attr_decl.h +1 -1
  14. data/ext/libxml/ruby_xml_attributes.c +6 -8
  15. data/ext/libxml/ruby_xml_attributes.h +1 -1
  16. data/ext/libxml/ruby_xml_document.c +915 -895
  17. data/ext/libxml/ruby_xml_document.h +2 -2
  18. data/ext/libxml/ruby_xml_dtd.c +257 -136
  19. data/ext/libxml/ruby_xml_dtd.h +1 -1
  20. data/ext/libxml/ruby_xml_encoding.c +55 -37
  21. data/ext/libxml/ruby_xml_encoding.h +1 -1
  22. data/ext/libxml/ruby_xml_error.c +526 -1058
  23. data/ext/libxml/ruby_xml_error.h +1 -1
  24. data/ext/libxml/ruby_xml_html_parser.c +2 -8
  25. data/ext/libxml/ruby_xml_html_parser.h +2 -2
  26. data/ext/libxml/ruby_xml_html_parser_context.c +175 -145
  27. data/ext/libxml/ruby_xml_html_parser_context.h +1 -1
  28. data/ext/libxml/ruby_xml_html_parser_options.c +12 -20
  29. data/ext/libxml/ruby_xml_html_parser_options.h +1 -1
  30. data/ext/libxml/ruby_xml_input_cbg.c +2 -8
  31. data/ext/libxml/ruby_xml_input_cbg.h +1 -1
  32. data/ext/libxml/ruby_xml_namespace.c +2 -8
  33. data/ext/libxml/ruby_xml_namespace.h +2 -2
  34. data/ext/libxml/ruby_xml_namespaces.c +1 -9
  35. data/ext/libxml/ruby_xml_namespaces.h +1 -1
  36. data/ext/libxml/ruby_xml_node.c +182 -121
  37. data/ext/libxml/ruby_xml_node.h +2 -2
  38. data/ext/libxml/ruby_xml_parser.c +2 -8
  39. data/ext/libxml/ruby_xml_parser.h +2 -2
  40. data/ext/libxml/ruby_xml_parser_context.c +952 -901
  41. data/ext/libxml/ruby_xml_parser_context.h +2 -2
  42. data/ext/libxml/ruby_xml_parser_options.c +2 -9
  43. data/ext/libxml/ruby_xml_parser_options.h +1 -1
  44. data/ext/libxml/ruby_xml_reader.c +1002 -993
  45. data/ext/libxml/ruby_xml_reader.h +1 -1
  46. data/ext/libxml/ruby_xml_relaxng.c +1 -7
  47. data/ext/libxml/ruby_xml_relaxng.h +1 -1
  48. data/ext/libxml/ruby_xml_sax2_handler.c +2 -2
  49. data/ext/libxml/ruby_xml_sax2_handler.h +1 -1
  50. data/ext/libxml/ruby_xml_sax_parser.c +2 -8
  51. data/ext/libxml/ruby_xml_sax_parser.h +2 -2
  52. data/ext/libxml/ruby_xml_schema.c +1 -7
  53. data/ext/libxml/ruby_xml_schema.h +1 -1
  54. data/ext/libxml/{version.h → ruby_xml_version.h} +2 -2
  55. data/ext/libxml/ruby_xml_xinclude.c +2 -8
  56. data/ext/libxml/ruby_xml_xinclude.h +2 -2
  57. data/ext/libxml/ruby_xml_xpath.c +17 -18
  58. data/ext/libxml/ruby_xml_xpath.h +2 -2
  59. data/ext/libxml/ruby_xml_xpath_context.c +387 -389
  60. data/ext/libxml/ruby_xml_xpath_context.h +2 -2
  61. data/ext/libxml/ruby_xml_xpath_expression.c +18 -8
  62. data/ext/libxml/ruby_xml_xpath_expression.h +1 -1
  63. data/ext/libxml/ruby_xml_xpath_object.c +19 -8
  64. data/ext/libxml/ruby_xml_xpath_object.h +1 -1
  65. data/ext/libxml/ruby_xml_xpointer.c +2 -8
  66. data/ext/libxml/ruby_xml_xpointer.h +2 -2
  67. data/ext/mingw/libxml_ruby.dll.a +0 -0
  68. data/ext/mingw/libxml_ruby.so +0 -0
  69. data/ext/vc/libxml_ruby.sln +7 -1
  70. data/lib/libxml.rb +1 -12
  71. data/lib/libxml/attr.rb +0 -3
  72. data/lib/libxml/attr_decl.rb +0 -3
  73. data/lib/libxml/attributes.rb +0 -3
  74. data/lib/libxml/document.rb +31 -5
  75. data/lib/libxml/error.rb +8 -4
  76. data/lib/libxml/properties.rb +0 -5
  77. data/lib/libxml/sax_callbacks.rb +30 -19
  78. data/lib/libxml/tree.rb +0 -1
  79. data/lib/libxml/xpath_object.rb +0 -13
  80. data/test/model/definition.dtd +8 -0
  81. data/test/tc_attributes.rb +4 -1
  82. data/test/tc_document.rb +16 -0
  83. data/test/tc_dtd.rb +30 -2
  84. data/test/tc_html_parser.rb +55 -10
  85. data/test/tc_node.rb +67 -1
  86. data/test/tc_node_edit.rb +26 -6
  87. data/test/tc_node_text.rb +41 -23
  88. data/test/tc_parser.rb +50 -0
  89. data/test/tc_reader.rb +15 -0
  90. data/test/tc_relaxng.rb +1 -1
  91. data/test/tc_sax_parser.rb +37 -5
  92. data/test/tc_schema.rb +1 -1
  93. data/test/tc_xpath.rb +1 -0
  94. data/test/tc_xpath_expression.rb +4 -2
  95. metadata +6 -6
  96. data/ext/libxml/ruby_xml_state.c +0 -51
  97. data/ext/libxml/ruby_xml_state.h +0 -11
  98. data/ext/vc/libxml_ruby.vcproj +0 -460
@@ -1,96 +1,93 @@
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 "version.h"
7
-
8
- #include <ruby.h>
9
- #include <rubyio.h>
10
- #include <libxml/parser.h>
11
- #include <libxml/parserInternals.h>
12
- #include <libxml/debugXML.h>
13
- #include <libxml/xmlversion.h>
14
- #include <libxml/xmlmemory.h>
15
- #include <libxml/xpath.h>
16
- #include <libxml/valid.h>
17
- #include <libxml/catalog.h>
18
- #include <libxml/HTMLparser.h>
19
- #include <libxml/xmlreader.h>
20
-
21
- /* Needed for Ruby 1.8.5 */
22
- #ifndef RARRAY_LEN
23
- #define RARRAY_LEN(s) (RARRAY(s)->len)
24
- #endif
25
-
26
- /* Needed for Ruby 1.8.5 */
27
- #ifndef RARRAY_PTR
28
- #define RARRAY_PTR(s) (RARRAY(s)->ptr)
29
- #endif
30
-
31
- /* Needed for Ruby 1.8.5 */
32
- #ifndef RSTRING_LEN
33
- #define RSTRING_LEN(s) (RSTRING(s)->len)
34
- #endif
35
-
36
- /* Needed for Ruby 1.8.5 */
37
- #ifndef RSTRING_PTR
38
- #define RSTRING_PTR(s) (RSTRING(s)->ptr)
39
- #endif
40
-
41
- /* Needed prior to Ruby 1.9.1 */
42
- #ifndef RHASH_TBL
43
- #define RHASH_TBL(s) (RHASH(s)->tbl)
44
- #endif
45
-
46
- // not in Ruby 1.9
47
- #ifndef GetWriteFile
48
- #define GetWriteFile(fp) rb_io_stdio_file(fp)
49
- #define OpenFile rb_io_t
50
- #endif
51
-
52
- #ifdef LIBXML_DEBUG_ENABLED
53
- #include <libxml/xpathInternals.h>
54
- #endif
55
- #ifdef LIBXML_XINCLUDE_ENABLED
56
- #include <libxml/xinclude.h>
57
- #endif
58
- #ifdef LIBXML_XPTR_ENABLED
59
- #include <libxml/xpointer.h>
60
- #endif
61
-
62
- #include "ruby_xml_io.h"
63
- #include "ruby_xml_error.h"
64
- #include "ruby_xml_encoding.h"
65
- #include "ruby_xml_state.h"
66
- #include "ruby_xml_attributes.h"
67
- #include "ruby_xml_attr.h"
68
- #include "ruby_xml_attr_decl.h"
69
- #include "ruby_xml_document.h"
70
- #include "ruby_xml_node.h"
71
- #include "ruby_xml_namespace.h"
72
- #include "ruby_xml_namespaces.h"
73
- #include "ruby_xml_parser.h"
74
- #include "ruby_xml_parser_options.h"
75
- #include "ruby_xml_parser_context.h"
76
- #include "ruby_xml_html_parser.h"
77
- #include "ruby_xml_html_parser_options.h"
78
- #include "ruby_xml_html_parser_context.h"
79
- #include "ruby_xml_reader.h"
80
- #include "ruby_xml_sax2_handler.h"
81
- #include "ruby_xml_sax_parser.h"
82
- #include "ruby_xml_xinclude.h"
83
- #include "ruby_xml_xpath.h"
84
- #include "ruby_xml_xpath_expression.h"
85
- #include "ruby_xml_xpath_context.h"
86
- #include "ruby_xml_xpath_object.h"
87
- #include "ruby_xml_xpointer.h"
88
- #include "ruby_xml_input_cbg.h"
89
- #include "ruby_xml_dtd.h"
90
- #include "ruby_xml_schema.h"
91
- #include "ruby_xml_relaxng.h"
92
-
93
- extern VALUE mLibXML;
94
- extern VALUE mXML;
95
-
96
- #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
+
18
+ /* Needed for Ruby 1.8.5 */
19
+ #ifndef RARRAY_LEN
20
+ #define RARRAY_LEN(s) (RARRAY(s)->len)
21
+ #endif
22
+
23
+ /* Needed for Ruby 1.8.5 */
24
+ #ifndef RARRAY_PTR
25
+ #define RARRAY_PTR(s) (RARRAY(s)->ptr)
26
+ #endif
27
+
28
+ /* Needed for Ruby 1.8.5 */
29
+ #ifndef RSTRING_LEN
30
+ #define RSTRING_LEN(s) (RSTRING(s)->len)
31
+ #endif
32
+
33
+ /* Needed for Ruby 1.8.5 */
34
+ #ifndef RSTRING_PTR
35
+ #define RSTRING_PTR(s) (RSTRING(s)->ptr)
36
+ #endif
37
+
38
+ /* Needed prior to Ruby 1.9.1 */
39
+ #ifndef RHASH_TBL
40
+ #define RHASH_TBL(s) (RHASH(s)->tbl)
41
+ #endif
42
+
43
+ // not in Ruby 1.9
44
+ #ifndef GetWriteFile
45
+ #define GetWriteFile(fp) rb_io_stdio_file(fp)
46
+ #define OpenFile rb_io_t
47
+ #endif
48
+
49
+ #ifdef LIBXML_DEBUG_ENABLED
50
+ #include <libxml/xpathInternals.h>
51
+ #endif
52
+ #ifdef LIBXML_XINCLUDE_ENABLED
53
+ #include <libxml/xinclude.h>
54
+ #endif
55
+ #ifdef LIBXML_XPTR_ENABLED
56
+ #include <libxml/xpointer.h>
57
+ #endif
58
+
59
+ #include "ruby_xml_version.h"
60
+ #include "ruby_xml.h"
61
+ #include "ruby_xml_io.h"
62
+ #include "ruby_xml_error.h"
63
+ #include "ruby_xml_encoding.h"
64
+ #include "ruby_xml_attributes.h"
65
+ #include "ruby_xml_attr.h"
66
+ #include "ruby_xml_attr_decl.h"
67
+ #include "ruby_xml_document.h"
68
+ #include "ruby_xml_node.h"
69
+ #include "ruby_xml_namespace.h"
70
+ #include "ruby_xml_namespaces.h"
71
+ #include "ruby_xml_parser.h"
72
+ #include "ruby_xml_parser_options.h"
73
+ #include "ruby_xml_parser_context.h"
74
+ #include "ruby_xml_html_parser.h"
75
+ #include "ruby_xml_html_parser_options.h"
76
+ #include "ruby_xml_html_parser_context.h"
77
+ #include "ruby_xml_reader.h"
78
+ #include "ruby_xml_sax2_handler.h"
79
+ #include "ruby_xml_sax_parser.h"
80
+ #include "ruby_xml_xinclude.h"
81
+ #include "ruby_xml_xpath.h"
82
+ #include "ruby_xml_xpath_expression.h"
83
+ #include "ruby_xml_xpath_context.h"
84
+ #include "ruby_xml_xpath_object.h"
85
+ #include "ruby_xml_xpointer.h"
86
+ #include "ruby_xml_input_cbg.h"
87
+ #include "ruby_xml_dtd.h"
88
+ #include "ruby_xml_schema.h"
89
+ #include "ruby_xml_relaxng.h"
90
+
91
+ extern VALUE mLibXML;
92
+
93
+ #endif
@@ -0,0 +1,855 @@
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 class)
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 class)
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 class)
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 class)
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 class)
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 class)
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 class)
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 class)
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 class)
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 class)
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 class)
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 class)
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 class)
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 class)
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 class)
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 class)
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 class)
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 class)
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 class)
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 class)
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 class, 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 class)
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 class, 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 class)
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 class, 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 class)
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 class, 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
+ /*
481
+ * call-seq:
482
+ * XML.default_pedantic_parser -> (true|false)
483
+ *
484
+ * Determine whether parsers are pedantic by default.
485
+ */
486
+ static VALUE rxml_default_pedantic_parser_get(VALUE class)
487
+ {
488
+ if (xmlPedanticParserDefaultValue)
489
+ return (Qtrue);
490
+ else
491
+ return (Qfalse);
492
+ }
493
+
494
+ /*
495
+ * call-seq:
496
+ * XML.default_pedantic_parser = true|false
497
+ *
498
+ * Controls whether parsers are pedantic by default.
499
+ */
500
+ static VALUE rxml_default_pedantic_parser_set(VALUE class, VALUE bool)
501
+ {
502
+ if (TYPE(bool) == T_FALSE)
503
+ {
504
+ xmlPedanticParserDefault(0);
505
+ return (Qfalse);
506
+ }
507
+ else
508
+ {
509
+ xmlPedanticParserDefault(1);
510
+ return (Qtrue);
511
+ }
512
+ }
513
+
514
+ /*
515
+ * call-seq:
516
+ * XML.default_substitute_entities -> (true|false)
517
+ *
518
+ * Determine whether parsers perform inline entity substitution
519
+ * (for external entities) by default.
520
+ */
521
+ static VALUE rxml_default_substitute_entities_get(VALUE class)
522
+ {
523
+ if (xmlSubstituteEntitiesDefaultValue)
524
+ return (Qtrue);
525
+ else
526
+ return (Qfalse);
527
+ }
528
+
529
+ /*
530
+ * call-seq:
531
+ * XML.default_substitute_entities = true|false
532
+ *
533
+ * Controls whether parsers perform inline entity substitution
534
+ * (for external entities) by default.
535
+ */
536
+ static VALUE rxml_default_substitute_entities_set(VALUE class, VALUE bool)
537
+ {
538
+ if (bool == Qfalse)
539
+ {
540
+ xmlSubstituteEntitiesDefault(0);
541
+ return (Qfalse);
542
+ }
543
+ else
544
+ {
545
+ xmlSubstituteEntitiesDefault(1);
546
+ return (Qtrue);
547
+ }
548
+ }
549
+
550
+ /*
551
+ * call-seq:
552
+ * XML.default_tree_indent_string -> "string"
553
+ *
554
+ * Obtain the default string used by parsers to indent the XML tree
555
+ * for output.
556
+ */
557
+ static VALUE rxml_default_tree_indent_string_get(VALUE class)
558
+ {
559
+ if (xmlTreeIndentString == NULL)
560
+ return (Qnil);
561
+ else
562
+ return (rb_str_new2(xmlTreeIndentString));
563
+ }
564
+
565
+ /*
566
+ * call-seq:
567
+ * XML.default_tree_indent_string = "string"
568
+ *
569
+ * Set the default string used by parsers to indent the XML tree
570
+ * for output.
571
+ */
572
+ static VALUE rxml_default_tree_indent_string_set(VALUE class, VALUE string)
573
+ {
574
+ Check_Type(string, T_STRING);
575
+ xmlTreeIndentString = xmlStrdup((xmlChar *)StringValuePtr(string));
576
+ return (string);
577
+ }
578
+
579
+ /*
580
+ * call-seq:
581
+ * XML.default_validity_checking -> (true|false)
582
+ *
583
+ * Determine whether parsers perform XML validation by default.
584
+ */
585
+ static VALUE rxml_default_validity_checking_get(VALUE class)
586
+ {
587
+ if (xmlDoValidityCheckingDefaultValue)
588
+ return (Qtrue);
589
+ else
590
+ return (Qfalse);
591
+ }
592
+
593
+ /*
594
+ * call-seq:
595
+ * XML.default_validity_checking = true|false
596
+ *
597
+ * Controls whether parsers perform XML validation by default.
598
+ */
599
+ static VALUE rxml_default_validity_checking_set(VALUE class, VALUE bool)
600
+ {
601
+ if (TYPE(bool) == T_FALSE)
602
+ {
603
+ xmlDoValidityCheckingDefaultValue = 0;
604
+ return (Qfalse);
605
+ }
606
+ else
607
+ {
608
+ xmlDoValidityCheckingDefaultValue = 1;
609
+ return (Qtrue);
610
+ }
611
+ }
612
+
613
+ /*
614
+ * call-seq:
615
+ * XML.default_warnings -> (true|false)
616
+ *
617
+ * Determine whether parsers output warnings by default.
618
+ */
619
+ static VALUE rxml_default_warnings_get(VALUE class)
620
+ {
621
+ if (xmlGetWarningsDefaultValue)
622
+ return (Qtrue);
623
+ else
624
+ return (Qfalse);
625
+ }
626
+
627
+ /*
628
+ * call-seq:
629
+ * XML.default_warnings = true|false
630
+ *
631
+ * Controls whether parsers output warnings by default.
632
+ */
633
+ static VALUE rxml_default_warnings_set(VALUE class, VALUE bool)
634
+ {
635
+ if (TYPE(bool) == T_FALSE)
636
+ {
637
+ xmlGetWarningsDefaultValue = 0;
638
+ return (Qfalse);
639
+ }
640
+ else
641
+ {
642
+ xmlGetWarningsDefaultValue = 1;
643
+ return (Qtrue);
644
+ }
645
+ }
646
+
647
+ /*
648
+ * call-seq:
649
+ * XML.default_compression -> (true|false)
650
+ *
651
+ * Determine whether parsers use Zlib compression by default
652
+ * (requires libxml to be compiled with Zlib support).
653
+ */
654
+ static VALUE rxml_default_compression_get(VALUE class)
655
+ {
656
+ #ifdef HAVE_ZLIB_H
657
+ return(INT2FIX(xmlGetCompressMode()));
658
+ #else
659
+ rb_warn("libxml was compiled without zlib support");
660
+ return (Qfalse);
661
+ #endif
662
+ }
663
+
664
+ /*
665
+ * call-seq:
666
+ * XML.default_compression = true|false
667
+ *
668
+ * Controls whether parsers use Zlib compression by default
669
+ * (requires libxml to be compiled with Zlib support).
670
+ */
671
+ static VALUE rxml_default_compression_set(VALUE class, VALUE num)
672
+ {
673
+ #ifdef HAVE_ZLIB_H
674
+ Check_Type(num, T_FIXNUM);
675
+ xmlSetCompressMode(FIX2INT(num));
676
+ return(num);
677
+ #else
678
+ rb_warn("libxml was compiled without zlib support");
679
+ return (Qfalse);
680
+ #endif
681
+ }
682
+
683
+ /*
684
+ * call-seq:
685
+ * XML.features -> ["feature", ..., "feature"]
686
+ *
687
+ * Obtains an array of strings representing features supported
688
+ * (and enabled) by the installed libxml.
689
+ */
690
+ static VALUE rxml_features(VALUE class)
691
+ {
692
+ VALUE arr, str;
693
+ int i, len = MAX_LIBXML_FEATURES_LEN;
694
+ char **list = NULL;
695
+
696
+ list = ALLOC_N(char *,MAX_LIBXML_FEATURES_LEN);
697
+ MEMZERO(list, char *, MAX_LIBXML_FEATURES_LEN);
698
+
699
+ arr = rb_ary_new();
700
+ if (xmlGetFeaturesList(&len, (const char **) list) == -1)
701
+ return Qnil;
702
+
703
+ for (i = 0; i < len; i++)
704
+ {
705
+ str = rb_str_new2((const char *) list[i]);
706
+ rb_gc_unregister_address(&str);
707
+ rb_ary_push(arr, str);
708
+ }
709
+
710
+ if (len == MAX_LIBXML_FEATURES_LEN)
711
+ rb_warn(
712
+ "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");
713
+
714
+ ruby_xfree(list);
715
+ return (arr);
716
+ }
717
+
718
+ /*
719
+ * call-seq:
720
+ * XML.indent_tree_output -> (true|false)
721
+ *
722
+ * Determines whether XML output will be indented
723
+ * (using the string supplied to +default_indent_tree_string+)
724
+ */
725
+ static VALUE rxml_indent_tree_output_get(VALUE class)
726
+ {
727
+ if (xmlIndentTreeOutput)
728
+ return (Qtrue);
729
+ else
730
+ return (Qfalse);
731
+ }
732
+
733
+ /*
734
+ * call-seq:
735
+ * XML.indent_tree_output = true|false
736
+ *
737
+ * Controls whether XML output will be indented
738
+ * (using the string supplied to +default_indent_tree_string+)
739
+ */
740
+ static VALUE rxml_indent_tree_output_set(VALUE class, VALUE bool)
741
+ {
742
+ if (TYPE(bool) == T_TRUE)
743
+ {
744
+ xmlIndentTreeOutput = 1;
745
+ return (Qtrue);
746
+ }
747
+ else if (TYPE(bool) == T_FALSE)
748
+ {
749
+ xmlIndentTreeOutput = 0;
750
+ return (Qfalse);
751
+ }
752
+ else
753
+ {
754
+ rb_raise(rb_eArgError, "Invalid argument, must be boolean");
755
+ }
756
+ }
757
+
758
+ /*
759
+ * call-seq:
760
+ * XML.memory_dump -> (true|false)
761
+ *
762
+ * Perform a parser memory dump (requires memory debugging
763
+ * support in libxml).
764
+ */
765
+ static VALUE rxml_memory_dump(VALUE self)
766
+ {
767
+ #ifdef DEBUG_MEMORY_LOCATION
768
+ xmlMemoryDump();
769
+ return(Qtrue);
770
+ #else
771
+ rb_warn("libxml was compiled without memory debugging support");
772
+ return (Qfalse);
773
+ #endif
774
+ }
775
+
776
+ /*
777
+ * call-seq:
778
+ * XML.memory_used -> num_bytes
779
+ *
780
+ * Perform a parser memory dump (requires memory debugging
781
+ * support in libxml).
782
+ */
783
+ static VALUE rxml_memory_used(VALUE self)
784
+ {
785
+ #ifdef DEBUG_MEMORY_LOCATION
786
+ return(INT2NUM(xmlMemUsed()));
787
+ #else
788
+ rb_warn("libxml was compiled without memory debugging support");
789
+ return (Qfalse);
790
+ #endif
791
+ }
792
+
793
+ /* The libxml gem provides Ruby language bindings for GNOME's Libxml2
794
+ * XML toolkit. Refer to the README file to get started
795
+ * and the LICENSE file for copyright and distribution information.
796
+ */
797
+
798
+ void rxml_init_xml(void)
799
+ {
800
+ mXML = rb_define_module_under(mLibXML, "XML");
801
+
802
+ /* Constants */
803
+ rb_define_const(mXML, "LIBXML_VERSION", rb_str_new2(LIBXML_DOTTED_VERSION));
804
+ rb_define_const(mXML, "VERSION", rb_str_new2(RUBY_LIBXML_VERSION));
805
+ rb_define_const(mXML, "VERNUM", INT2NUM(RUBY_LIBXML_VERNUM));
806
+ rb_define_const(mXML, "XML_NAMESPACE", rb_str_new2((const char*) XML_XML_NAMESPACE));
807
+
808
+ rb_define_module_function(mXML, "enabled_automata?", rxml_enabled_automata_q, 0);
809
+ rb_define_module_function(mXML, "enabled_c14n?", rxml_enabled_c14n_q, 0);
810
+ rb_define_module_function(mXML, "enabled_catalog?", rxml_enabled_catalog_q, 0);
811
+ rb_define_module_function(mXML, "enabled_debug?", rxml_enabled_debug_q, 0);
812
+ rb_define_module_function(mXML, "enabled_docbook?", rxml_enabled_docbook_q, 0);
813
+ rb_define_module_function(mXML, "enabled_ftp?", rxml_enabled_ftp_q, 0);
814
+ rb_define_module_function(mXML, "enabled_http?", rxml_enabled_http_q, 0);
815
+ rb_define_module_function(mXML, "enabled_html?", rxml_enabled_html_q, 0);
816
+ rb_define_module_function(mXML, "enabled_iconv?", rxml_enabled_iconv_q, 0);
817
+ rb_define_module_function(mXML, "enabled_memory_debug?", rxml_enabled_memory_debug_location_q, 0);
818
+ rb_define_module_function(mXML, "enabled_regexp?", rxml_enabled_regexp_q, 0);
819
+ rb_define_module_function(mXML, "enabled_schemas?", rxml_enabled_schemas_q, 0);
820
+ rb_define_module_function(mXML, "enabled_thread?", rxml_enabled_thread_q, 0);
821
+ rb_define_module_function(mXML, "enabled_unicode?", rxml_enabled_unicode_q, 0);
822
+ rb_define_module_function(mXML, "enabled_xinclude?", rxml_enabled_xinclude_q, 0);
823
+ rb_define_module_function(mXML, "enabled_xpath?", rxml_enabled_xpath_q, 0);
824
+ rb_define_module_function(mXML, "enabled_xpointer?", rxml_enabled_xpointer_q, 0);
825
+ rb_define_module_function(mXML, "enabled_zlib?", rxml_enabled_zlib_q, 0);
826
+
827
+ rb_define_module_function(mXML, "catalog_dump", rxml_catalog_dump, 0);
828
+ rb_define_module_function(mXML, "catalog_remove", rxml_catalog_remove, 1);
829
+ rb_define_module_function(mXML, "check_lib_versions", rxml_check_lib_versions, 0);
830
+ rb_define_module_function(mXML, "debug_entities", rxml_debug_entities_get, 0);
831
+ rb_define_module_function(mXML, "debug_entities=", rxml_debug_entities_set, 1);
832
+ rb_define_module_function(mXML, "default_compression", rxml_default_compression_get, 0);
833
+ rb_define_module_function(mXML, "default_compression=", rxml_default_compression_set, 1);
834
+ rb_define_module_function(mXML, "default_keep_blanks", rxml_default_keep_blanks_get, 0);
835
+ rb_define_module_function(mXML, "default_keep_blanks=", rxml_default_keep_blanks_set, 1);
836
+ rb_define_module_function(mXML, "default_load_external_dtd", rxml_default_load_external_dtd_get, 0);
837
+ rb_define_module_function(mXML, "default_load_external_dtd=", rxml_default_load_external_dtd_set, 1);
838
+ rb_define_module_function(mXML, "default_line_numbers", rxml_default_line_numbers_get, 0);
839
+ rb_define_module_function(mXML, "default_line_numbers=", rxml_default_line_numbers_set, 1);
840
+ rb_define_module_function(mXML, "default_pedantic_parser", rxml_default_pedantic_parser_get, 0);
841
+ rb_define_module_function(mXML, "default_pedantic_parser=", rxml_default_pedantic_parser_set, 1);
842
+ rb_define_module_function(mXML, "default_substitute_entities", rxml_default_substitute_entities_get, 0);
843
+ rb_define_module_function(mXML, "default_substitute_entities=", rxml_default_substitute_entities_set, 1);
844
+ rb_define_module_function(mXML, "default_tree_indent_string", rxml_default_tree_indent_string_get, 0);
845
+ rb_define_module_function(mXML, "default_tree_indent_string=", rxml_default_tree_indent_string_set, 1);
846
+ rb_define_module_function(mXML, "default_validity_checking", rxml_default_validity_checking_get, 0);
847
+ rb_define_module_function(mXML, "default_validity_checking=", rxml_default_validity_checking_set, 1);
848
+ rb_define_module_function(mXML, "default_warnings", rxml_default_warnings_get, 0);
849
+ rb_define_module_function(mXML, "default_warnings=", rxml_default_warnings_set, 1);
850
+ rb_define_module_function(mXML, "features", rxml_features, 0);
851
+ rb_define_module_function(mXML, "indent_tree_output", rxml_indent_tree_output_get, 0);
852
+ rb_define_module_function(mXML, "indent_tree_output=", rxml_indent_tree_output_set, 1);
853
+ rb_define_module_function(mXML, "memory_dump", rxml_memory_dump, 0);
854
+ rb_define_module_function(mXML, "memory_used", rxml_memory_used, 0);
855
+ }