libxml-ruby 0.9.4-x86-mswin32-60 → 0.9.5-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/CHANGES +22 -0
  2. data/README +3 -1
  3. data/ext/libxml/cbg.c +86 -76
  4. data/ext/libxml/extconf.rb +2 -1
  5. data/ext/libxml/libxml.c +899 -885
  6. data/ext/libxml/ruby_libxml.h +65 -70
  7. data/ext/libxml/ruby_xml_attr.c +485 -500
  8. data/ext/libxml/ruby_xml_attributes.c +107 -106
  9. data/ext/libxml/ruby_xml_document.c +355 -356
  10. data/ext/libxml/ruby_xml_dtd.c +119 -117
  11. data/ext/libxml/ruby_xml_error.c +1112 -581
  12. data/ext/libxml/ruby_xml_html_parser.c +35 -34
  13. data/ext/libxml/ruby_xml_input.c +182 -187
  14. data/ext/libxml/ruby_xml_input_cbg.c +197 -179
  15. data/ext/libxml/ruby_xml_node.c +1529 -1566
  16. data/ext/libxml/ruby_xml_node.h +2 -2
  17. data/ext/libxml/ruby_xml_ns.c +150 -156
  18. data/ext/libxml/ruby_xml_parser.c +37 -36
  19. data/ext/libxml/ruby_xml_parser_context.c +657 -659
  20. data/ext/libxml/ruby_xml_reader.c +203 -209
  21. data/ext/libxml/ruby_xml_relaxng.c +29 -25
  22. data/ext/libxml/ruby_xml_sax_parser.c +33 -32
  23. data/ext/libxml/ruby_xml_schema.c +165 -161
  24. data/ext/libxml/ruby_xml_state.c +19 -21
  25. data/ext/libxml/ruby_xml_xinclude.c +24 -25
  26. data/ext/libxml/ruby_xml_xpath.c +108 -108
  27. data/ext/libxml/ruby_xml_xpath_context.c +305 -293
  28. data/ext/libxml/ruby_xml_xpath_expression.c +24 -24
  29. data/ext/libxml/ruby_xml_xpath_object.c +89 -96
  30. data/ext/libxml/ruby_xml_xpointer.c +107 -109
  31. data/ext/libxml/ruby_xml_xpointer.h +13 -13
  32. data/ext/libxml/version.h +2 -2
  33. data/ext/mingw/Rakefile +1 -1
  34. data/ext/mingw/libxml_ruby.dll.a +0 -0
  35. data/ext/mingw/libxml_ruby.so +0 -0
  36. data/ext/vc/libxml_ruby.vcproj +1 -1
  37. data/lib/libxml/error.rb +4 -4
  38. data/test/tc_node_edit.rb +14 -2
  39. data/test/tc_node_text.rb +9 -9
  40. metadata +2 -2
data/CHANGES CHANGED
@@ -1,5 +1,27 @@
1
1
  (See log/ChangeLog for more detailed changes derived directly from source control.)
2
2
 
3
+ == 0.9.5 / 2008-11-29 Charlie Savage
4
+
5
+ * Ruby 1.9.1 preview release compatability (Felipe Contreras)
6
+
7
+ * Update Node#remove! to return the removed node and to set
8
+ its document to nil. This allows the node to be either
9
+ moved to another document, another part of the same document
10
+ or to be freed on the next garbage collection once its
11
+ references have gone out of scope.
12
+
13
+ * Fix bug where XPathExpression#compile mistakenly overwrote
14
+ RegExp#compile.
15
+
16
+ * Update Node to use standard ruby allocators and initializers.
17
+
18
+ * Update HTML parser to be more forgiving of invalid documents.
19
+
20
+ * Update include paths for Darwin Ports on OS X.
21
+
22
+ * Updated C code base to use BSD/Allman style
23
+
24
+
3
25
  == 0.9.4 / 2008-11-24 Charlie Savage
4
26
 
5
27
  * Update HTML parser so that it can read files, strings and io
data/README CHANGED
@@ -33,7 +33,9 @@ If you are running Windows, make sure to install the Win32 RubyGem
33
33
  which includes an already built binary file. The binary is built
34
34
  against libxml2 version 2.7.2 and iconv version 1.11. Both of these
35
35
  are also included as pre-built binaries, and should be put either in
36
- the libxml/lib directory or on the Windows path.
36
+ the libxml/lib directory or on the Windows path. Due to a bug
37
+ in ruby-gems, you cannot install the gem to a path that contains
38
+ spaces (see http://rubyforge.org/tracker/?func=detail&aid=23003&group_id=126&atid=577).
37
39
 
38
40
  The Windows binaries are built with MingW and include libxml-ruby,
39
41
  libxml2 and iconv. The gem also includes a Microsoft VC++ 2008
@@ -1,76 +1,86 @@
1
- #include <string.h>
2
- #include <libxml/xmlIO.h>
3
- #include "ruby.h"
4
-
5
- /*
6
- int xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc,
7
- xmlInputOpenCallback openFunc,
8
- xmlInputReadCallback readFunc,
9
- xmlInputCloseCallback closeFunc);
10
-
11
-
12
- int (*xmlInputMatchCallback) (char const *filename);
13
- void* (*xmlInputOpenCallback) (char const *filename);
14
- int (*xmlInputReadCallback) (void *context,
15
- char *buffer,
16
- int len);
17
- int (*xmlInputCloseCallback) (void *context);
18
- */
19
-
20
- typedef struct deb_doc_context {
21
- char *buffer;
22
- char *bpos;
23
- int remaining;
24
- } deb_doc_context;
25
-
26
- int deb_Match (char const *filename) {
27
- fprintf( stderr, "deb_Match: %s\n", filename );
28
- if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "deb://", 6)) {
29
- return(1);
30
- }
31
- return(0);
32
- }
33
-
34
- void* deb_Open (char const *filename) {
35
- deb_doc_context *deb_doc;
36
- VALUE res;
37
-
38
- deb_doc = (deb_doc_context*)malloc( sizeof(deb_doc_context) );
39
-
40
- res = rb_funcall( rb_funcall( rb_mKernel, rb_intern("const_get"), 1, rb_str_new2("DEBSystem") ),
41
- rb_intern("document_query"), 1, rb_str_new2(filename));
42
- deb_doc->buffer = strdup( StringValuePtr(res) );
43
- //deb_doc->buffer = strdup("<serepes>serepes</serepes>");
44
-
45
- deb_doc->bpos = deb_doc->buffer;
46
- deb_doc->remaining = strlen(deb_doc->buffer);
47
- return deb_doc;
48
- }
49
-
50
- int deb_Read (void *context, char *buffer, int len) {
51
- deb_doc_context *deb_doc;
52
- int ret_len;
53
- deb_doc = (deb_doc_context*)context;
54
-
55
- if (len >= deb_doc->remaining) {
56
- ret_len = deb_doc->remaining;
57
- } else {
58
- ret_len = len;
59
- }
60
- deb_doc->remaining -= ret_len;
61
- strncpy( buffer, deb_doc->bpos, ret_len );
62
- deb_doc->bpos += ret_len;
63
-
64
- return ret_len;
65
- }
66
-
67
- int deb_Close (void *context) {
68
- free( ((deb_doc_context*)context)->buffer );
69
- free( context );
70
- return 1;
71
- }
72
-
73
-
74
- void deb_register_cbg() {
75
- xmlRegisterInputCallbacks( deb_Match, deb_Open, deb_Read, deb_Close );
76
- }
1
+ #include <string.h>
2
+ #include <libxml/xmlIO.h>
3
+ #include "ruby.h"
4
+
5
+ /*
6
+ int xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc,
7
+ xmlInputOpenCallback openFunc,
8
+ xmlInputReadCallback readFunc,
9
+ xmlInputCloseCallback closeFunc);
10
+
11
+
12
+ int (*xmlInputMatchCallback) (char const *filename);
13
+ void* (*xmlInputOpenCallback) (char const *filename);
14
+ int (*xmlInputReadCallback) (void *context,
15
+ char *buffer,
16
+ int len);
17
+ int (*xmlInputCloseCallback) (void *context);
18
+ */
19
+
20
+ typedef struct deb_doc_context
21
+ {
22
+ char *buffer;
23
+ char *bpos;
24
+ int remaining;
25
+ } deb_doc_context;
26
+
27
+ int deb_Match(char const *filename)
28
+ {
29
+ fprintf(stderr, "deb_Match: %s\n", filename);
30
+ if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "deb://", 6))
31
+ {
32
+ return (1);
33
+ }
34
+ return (0);
35
+ }
36
+
37
+ void* deb_Open(char const *filename)
38
+ {
39
+ deb_doc_context *deb_doc;
40
+ VALUE res;
41
+
42
+ deb_doc = (deb_doc_context*) malloc(sizeof(deb_doc_context));
43
+
44
+ res = rb_funcall(rb_funcall(rb_mKernel, rb_intern("const_get"), 1,
45
+ rb_str_new2("DEBSystem")), rb_intern("document_query"), 1, rb_str_new2(
46
+ filename));
47
+ deb_doc->buffer = strdup(StringValuePtr(res));
48
+ //deb_doc->buffer = strdup("<serepes>serepes</serepes>");
49
+
50
+ deb_doc->bpos = deb_doc->buffer;
51
+ deb_doc->remaining = strlen(deb_doc->buffer);
52
+ return deb_doc;
53
+ }
54
+
55
+ int deb_Read(void *context, char *buffer, int len)
56
+ {
57
+ deb_doc_context *deb_doc;
58
+ int ret_len;
59
+ deb_doc = (deb_doc_context*) context;
60
+
61
+ if (len >= deb_doc->remaining)
62
+ {
63
+ ret_len = deb_doc->remaining;
64
+ }
65
+ else
66
+ {
67
+ ret_len = len;
68
+ }
69
+ deb_doc->remaining -= ret_len;
70
+ strncpy(buffer, deb_doc->bpos, ret_len);
71
+ deb_doc->bpos += ret_len;
72
+
73
+ return ret_len;
74
+ }
75
+
76
+ int deb_Close(void *context)
77
+ {
78
+ free(((deb_doc_context*) context)->buffer);
79
+ free(context);
80
+ return 1;
81
+ }
82
+
83
+ void deb_register_cbg()
84
+ {
85
+ xmlRegisterInputCallbacks(deb_Match, deb_Open, deb_Read, deb_Close);
86
+ }
@@ -79,7 +79,8 @@ unless (have_library('xml2', 'xmlParseDoc') or
79
79
  find_library('xml2', 'xmlParseDoc', '/opt/lib', '/usr/local/lib', '/usr/lib')) and
80
80
  (have_header('libxml/xmlversion.h') or
81
81
  find_header('libxml/xmlversion.h',
82
- "#{CONFIG['prefix']}/include",
82
+ "#{CONFIG['prefix']}/include",
83
+ "#{CONFIG['prefix']}/include/libxml2",
83
84
  '/opt/include/libxml2',
84
85
  '/usr/local/include/libxml2',
85
86
  '/usr/include/libxml2'))
@@ -1,885 +1,899 @@
1
- /* $Id: libxml.c 615 2008-11-22 08:36:27Z cfis $ */
2
-
3
- /* Please see the LICENSE file for copyright and distribution information */
4
-
5
- #include "ruby_libxml.h"
6
-
7
- VALUE mLibXML;
8
- VALUE mXML;
9
-
10
-
11
- /*
12
- * call-seq:
13
- * XML.catalog_dump -> true
14
- *
15
- * Dump all the global catalog content stdout.
16
- */
17
- static VALUE
18
- rxml_catalog_dump(VALUE self) {
19
- xmlCatalogDump(stdout);
20
- return(Qtrue);
21
- }
22
-
23
-
24
- /*
25
- * call-seq:
26
- * XML.catalog_remove(catalog) -> true
27
- *
28
- * Remove the specified resource catalog.
29
- */
30
- static VALUE
31
- rxml_catalog_remove(VALUE self, VALUE cat) {
32
- Check_Type(cat, T_STRING);
33
- xmlCatalogRemove((xmlChar *)StringValuePtr(cat));
34
- return(Qtrue);
35
- }
36
-
37
-
38
- /*
39
- * call-seq:
40
- * XML.check_lib_versions -> true
41
- *
42
- * Check LIBXML version matches version the bindings
43
- * were compiled to. Throws an exception if not.
44
- */
45
- static VALUE
46
- rxml_check_lib_versions(VALUE class) {
47
- xmlCheckVersion(LIBXML_VERSION);
48
- return(Qtrue);
49
- }
50
-
51
-
52
- /*
53
- * call-seq:
54
- * XML.enabled_automata? -> (true|false)
55
- *
56
- * Determine whether libxml regexp automata support is enabled.
57
- */
58
- static VALUE
59
- rxml_enabled_automata_q(VALUE class) {
60
- #ifdef LIBXML_AUTOMATA_ENABLED
61
- return(Qtrue);
62
- #else
63
- return(Qfalse);
64
- #endif
65
- }
66
-
67
-
68
- /*
69
- * call-seq:
70
- * XML.enabled_c14n? -> (true|false)
71
- *
72
- * Determine whether libxml 'canonical XML' support is enabled.
73
- * See "Canonical XML" (http://www.w3.org/TR/xml-c14n)
74
- */
75
- static VALUE
76
- rxml_enabled_c14n_q(VALUE class) {
77
- #ifdef LIBXML_C14N_ENABLED
78
- return(Qtrue);
79
- #else
80
- return(Qfalse);
81
- #endif
82
- }
83
-
84
-
85
- /*
86
- * call-seq:
87
- * XML.enabled_catalog? -> (true|false)
88
- *
89
- * Determine whether libxml resource catalog support is enabled.
90
- */
91
- static VALUE
92
- rxml_enabled_catalog_q(VALUE class) {
93
- #ifdef LIBXML_CATALOG_ENABLED
94
- return(Qtrue);
95
- #else
96
- return(Qfalse);
97
- #endif
98
- }
99
-
100
-
101
- /*
102
- * call-seq:
103
- * XML.enabled_debug? -> (true|false)
104
- *
105
- * Determine whether libxml debugging support is enabled.
106
- */
107
- static VALUE
108
- rxml_enabled_debug_q(VALUE class) {
109
- #ifdef LIBXML_DEBUG_ENABLED
110
- return(Qtrue);
111
- #else
112
- return(Qfalse);
113
- #endif
114
- }
115
-
116
-
117
- /*
118
- * call-seq:
119
- * XML.enabled_docbook? -> (true|false)
120
- *
121
- * Determine whether libxml docbook support is enabled.
122
- */
123
- static VALUE
124
- rxml_enabled_docbook_q(VALUE class) {
125
- #ifdef LIBXML_DOCB_ENABLED
126
- return(Qtrue);
127
- #else
128
- return(Qfalse);
129
- #endif
130
- }
131
-
132
-
133
- /*
134
- * call-seq:
135
- * XML.enabled_ftp? -> (true|false)
136
- *
137
- * Determine whether libxml ftp client support is enabled.
138
- */
139
- static VALUE
140
- rxml_enabled_ftp_q(VALUE class) {
141
- #ifdef LIBXML_FTP_ENABLED
142
- return(Qtrue);
143
- #else
144
- return(Qfalse);
145
- #endif
146
- }
147
-
148
-
149
- /*
150
- * call-seq:
151
- * XML.enabled_http? -> (true|false)
152
- *
153
- * Determine whether libxml http client support is enabled.
154
- */
155
- static VALUE
156
- rxml_enabled_http_q(VALUE class) {
157
- #ifdef LIBXML_HTTP_ENABLED
158
- return(Qtrue);
159
- #else
160
- return(Qfalse);
161
- #endif
162
- }
163
-
164
-
165
- /*
166
- * call-seq:
167
- * XML.enabled_html? -> (true|false)
168
- *
169
- * Determine whether libxml html support is enabled.
170
- */
171
- static VALUE
172
- rxml_enabled_html_q(VALUE class) {
173
- #ifdef LIBXML_HTML_ENABLED
174
- return(Qtrue);
175
- #else
176
- return(Qfalse);
177
- #endif
178
- }
179
-
180
-
181
- /*
182
- * call-seq:
183
- * XML.enabled_iconv? -> (true|false)
184
- *
185
- * Determine whether libxml iconv support is enabled.
186
- */
187
- static VALUE
188
- rxml_enabled_iconv_q(VALUE class) {
189
- #ifdef LIBXML_ICONV_ENABLED
190
- return(Qtrue);
191
- #else
192
- return(Qfalse);
193
- #endif
194
- }
195
-
196
-
197
- /*
198
- * call-seq:
199
- * XML.enabled_memory_debug? -> (true|false)
200
- *
201
- * Determine whether libxml memory location debugging support
202
- * is enabled.
203
- */
204
- static VALUE
205
- rxml_enabled_memory_debug_location_q(VALUE class) {
206
- #ifdef DEBUG_MEMORY_LOCATION
207
- return(Qtrue);
208
- #else
209
- return(Qfalse);
210
- #endif
211
- }
212
-
213
-
214
- /*
215
- * call-seq:
216
- * XML.enabled_regexp? -> (true|false)
217
- *
218
- * Determine whether libxml regular expression support is enabled.
219
- */
220
- static VALUE
221
- rxml_enabled_regexp_q(VALUE class) {
222
- #ifdef LIBXML_REGEXP_ENABLED
223
- return(Qtrue);
224
- #else
225
- return(Qfalse);
226
- #endif
227
- }
228
-
229
-
230
- /*
231
- * call-seq:
232
- * XML.enabled_schemas? -> (true|false)
233
- *
234
- * Determine whether libxml schema support is enabled.
235
- */
236
- static VALUE
237
- rxml_enabled_schemas_q(VALUE class) {
238
- #ifdef LIBXML_SCHEMAS_ENABLED
239
- return(Qtrue);
240
- #else
241
- return(Qfalse);
242
- #endif
243
- }
244
-
245
-
246
- /*
247
- * call-seq:
248
- * XML.enabled_thread? -> (true|false)
249
- *
250
- * Determine whether libxml thread-safe semantics support
251
- * is enabled (I think?).
252
- */
253
- static VALUE
254
- rxml_enabled_thread_q(VALUE class) {
255
- #ifdef LIBXML_THREAD_ENABLED
256
- return(Qtrue);
257
- #else
258
- return(Qfalse);
259
- #endif
260
- }
261
-
262
-
263
- /*
264
- * call-seq:
265
- * XML.enabled_unicode? -> (true|false)
266
- *
267
- * Determine whether libxml unicode support is enabled.
268
- */
269
- static VALUE
270
- rxml_enabled_unicode_q(VALUE class) {
271
- #ifdef LIBXML_UNICODE_ENABLED
272
- return(Qtrue);
273
- #else
274
- return(Qfalse);
275
- #endif
276
- }
277
-
278
-
279
- /*
280
- * call-seq:
281
- * XML.enabled_xinclude? -> (true|false)
282
- *
283
- * Determine whether libxml xinclude support is enabled.
284
- */
285
- static VALUE
286
- rxml_enabled_xinclude_q(VALUE class) {
287
- #ifdef LIBXML_XINCLUDE_ENABLED
288
- return(Qtrue);
289
- #else
290
- return(Qfalse);
291
- #endif
292
- }
293
-
294
-
295
- /*
296
- * call-seq:
297
- * XML.enabled_xpath? -> (true|false)
298
- *
299
- * Determine whether libxml xpath support is enabled.
300
- */
301
- static VALUE
302
- rxml_enabled_xpath_q(VALUE class) {
303
- #ifdef LIBXML_XPATH_ENABLED
304
- return(Qtrue);
305
- #else
306
- return(Qfalse);
307
- #endif
308
- }
309
-
310
-
311
- /*
312
- * call-seq:
313
- * XML.enabled_xpointer? -> (true|false)
314
- *
315
- * Determine whether libxml xpointer support is enabled.
316
- */
317
- static VALUE
318
- rxml_enabled_xpointer_q(VALUE class) {
319
- #ifdef LIBXML_XPTR_ENABLED
320
- return(Qtrue);
321
- #else
322
- return(Qfalse);
323
- #endif
324
- }
325
-
326
-
327
- /*
328
- * call-seq:
329
- * XML.enabled_zlib? -> (true|false)
330
- *
331
- * Determine whether libxml zlib support is enabled.
332
- */
333
- static VALUE
334
- rxml_enabled_zlib_q(VALUE class) {
335
- #ifdef HAVE_ZLIB_H
336
- return(Qtrue);
337
- #else
338
- return(Qfalse);
339
- #endif
340
- }
341
-
342
-
343
- /*
344
- * call-seq:
345
- * XML.debug_entities -> (true|false)
346
- *
347
- * Determine whether included-entity debugging is enabled.
348
- * (Requires Libxml to be compiled with debugging support)
349
- */
350
- static VALUE
351
- rxml_debug_entities_get(VALUE class) {
352
- #ifdef LIBXML_DEBUG_ENABLED
353
- if (xmlParserDebugEntities)
354
- return(Qtrue);
355
- else
356
- return(Qfalse);
357
- #else
358
- rb_warn("libxml was compiled with debugging turned off");
359
- return(Qfalse);
360
- #endif
361
- }
362
-
363
-
364
- /*
365
- * call-seq:
366
- * XML.debug_entities = true|false
367
- *
368
- * Enable or disable included-entity debugging.
369
- * (Requires Libxml to be compiled with debugging support)
370
- */
371
- static VALUE
372
- rxml_debug_entities_set(VALUE class, VALUE bool) {
373
- #ifdef LIBXML_DEBUG_ENABLED
374
- if (TYPE(bool) == T_FALSE) {
375
- xmlParserDebugEntities = 0;
376
- return(Qfalse);
377
- } else {
378
- xmlParserDebugEntities = 1;
379
- return(Qtrue);
380
- }
381
- #else
382
- rb_warn("libxml was compiled with debugging turned off");
383
- #endif
384
- }
385
-
386
-
387
- /*
388
- * call-seq:
389
- * XML.default_keep_blanks -> (true|false)
390
- *
391
- * Determine whether parsers retain whitespace by default.
392
- */
393
- static VALUE
394
- rxml_default_keep_blanks_get(VALUE class) {
395
- if (xmlKeepBlanksDefaultValue)
396
- return(Qtrue);
397
- else
398
- return(Qfalse);
399
- }
400
-
401
-
402
- /*
403
- * call-seq:
404
- * XML.default_keep_blanks = true|false
405
- *
406
- * Controls whether parsers retain whitespace by default.
407
- */
408
- static VALUE
409
- rxml_default_keep_blanks_set(VALUE class, VALUE bool) {
410
- if (TYPE(bool) == T_FALSE) {
411
- xmlKeepBlanksDefaultValue = 0;
412
- return(Qfalse);
413
- } else if (TYPE(bool) == T_TRUE) {
414
- xmlKeepBlanksDefaultValue = 1;
415
- return(Qtrue);
416
- } else {
417
- rb_raise(rb_eArgError, "Invalid argument, must be a boolean");
418
- }
419
- }
420
-
421
-
422
- /*
423
- * call-seq:
424
- * XML.default_load_external_dtd -> (true|false)
425
- *
426
- * Determine whether parsers load external DTDs by default.
427
- */
428
- static VALUE
429
- rxml_default_load_external_dtd_get(VALUE class) {
430
- if (xmlLoadExtDtdDefaultValue)
431
- return(Qtrue);
432
- else
433
- return(Qfalse);
434
- }
435
-
436
-
437
- /*
438
- * call-seq:
439
- * XML.default_load_external_dtd = true|false
440
- *
441
- * Controls whether parsers load external DTDs by default.
442
- */
443
- static VALUE
444
- rxml_default_load_external_dtd_set(VALUE class, VALUE bool) {
445
- if (TYPE(bool) == T_FALSE) {
446
- xmlLoadExtDtdDefaultValue = 0;
447
- return(Qfalse);
448
- } else {
449
- xmlLoadExtDtdDefaultValue = 1;
450
- return(Qtrue);
451
- }
452
- }
453
-
454
-
455
- /*
456
- * call-seq:
457
- * XML.default_line_numbers -> (true|false)
458
- *
459
- * Determine whether parsers retain line-numbers by default.
460
- */
461
- static VALUE
462
- rxml_default_line_numbers_get(VALUE class) {
463
- if (xmlLineNumbersDefaultValue)
464
- return(Qtrue);
465
- else
466
- return(Qfalse);
467
- }
468
-
469
-
470
- /*
471
- * call-seq:
472
- * XML.default_line_numbers = true|false
473
- *
474
- * Controls whether parsers retain line-numbers by default.
475
- */
476
- static VALUE
477
- rxml_default_line_numbers_set(VALUE class, VALUE bool) {
478
- if (TYPE(bool) == T_FALSE) {
479
- xmlLineNumbersDefault(0);
480
- return(Qfalse);
481
- } else {
482
- xmlLineNumbersDefault(1);
483
- return(Qtrue);
484
- }
485
- }
486
-
487
-
488
- /*
489
- * call-seq:
490
- * XML.default_pedantic_parser -> (true|false)
491
- *
492
- * Determine whether parsers are pedantic by default.
493
- */
494
- static VALUE
495
- rxml_default_pedantic_parser_get(VALUE class) {
496
- if (xmlPedanticParserDefaultValue)
497
- return(Qtrue);
498
- else
499
- return(Qfalse);
500
- }
501
-
502
-
503
- /*
504
- * call-seq:
505
- * XML.default_pedantic_parser = true|false
506
- *
507
- * Controls whether parsers are pedantic by default.
508
- */
509
- static VALUE
510
- rxml_default_pedantic_parser_set(VALUE class, VALUE bool) {
511
- if (TYPE(bool) == T_FALSE) {
512
- xmlPedanticParserDefault(0);
513
- return(Qfalse);
514
- } else {
515
- xmlPedanticParserDefault(1);
516
- return(Qtrue);
517
- }
518
- }
519
-
520
-
521
- /*
522
- * call-seq:
523
- * XML.default_substitute_entities -> (true|false)
524
- *
525
- * Determine whether parsers perform inline entity substitution
526
- * (for external entities) by default.
527
- */
528
- static VALUE
529
- rxml_default_substitute_entities_get(VALUE class) {
530
- if (xmlSubstituteEntitiesDefaultValue)
531
- return(Qtrue);
532
- else
533
- return(Qfalse);
534
- }
535
-
536
-
537
- /*
538
- * call-seq:
539
- * XML.default_substitute_entities = true|false
540
- *
541
- * Controls whether parsers perform inline entity substitution
542
- * (for external entities) by default.
543
- */
544
- static VALUE
545
- rxml_default_substitute_entities_set(VALUE class, VALUE bool) {
546
- if (TYPE(bool) == T_FALSE) {
547
- xmlSubstituteEntitiesDefault(0);
548
- return(Qfalse);
549
- } else {
550
- xmlSubstituteEntitiesDefault(1);
551
- return(Qtrue);
552
- }
553
- }
554
-
555
-
556
- /*
557
- * call-seq:
558
- * XML.default_tree_indent_string -> "string"
559
- *
560
- * Obtain the default string used by parsers to indent the XML tree
561
- * for output.
562
- */
563
- static VALUE
564
- rxml_default_tree_indent_string_get(VALUE class) {
565
- if (xmlTreeIndentString == NULL)
566
- return(Qnil);
567
- else
568
- return(rb_str_new2(xmlTreeIndentString));
569
- }
570
-
571
-
572
- /*
573
- * call-seq:
574
- * XML.default_tree_indent_string = "string"
575
- *
576
- * Set the default string used by parsers to indent the XML tree
577
- * for output.
578
- */
579
- static VALUE
580
- rxml_default_tree_indent_string_set(VALUE class, VALUE string) {
581
- Check_Type(string, T_STRING);
582
- xmlTreeIndentString = xmlStrdup(StringValuePtr(string));
583
- return(string);
584
- }
585
-
586
-
587
- /*
588
- * call-seq:
589
- * XML.default_validity_checking -> (true|false)
590
- *
591
- * Determine whether parsers perform XML validation by default.
592
- */
593
- static VALUE
594
- rxml_default_validity_checking_get(VALUE class) {
595
- if (xmlDoValidityCheckingDefaultValue)
596
- return(Qtrue);
597
- else
598
- return(Qfalse);
599
- }
600
-
601
-
602
- /*
603
- * call-seq:
604
- * XML.default_validity_checking = true|false
605
- *
606
- * Controls whether parsers perform XML validation by default.
607
- */
608
- static VALUE
609
- rxml_default_validity_checking_set(VALUE class, VALUE bool) {
610
- if (TYPE(bool) == T_FALSE) {
611
- xmlDoValidityCheckingDefaultValue = 0;
612
- return(Qfalse);
613
- } else {
614
- xmlDoValidityCheckingDefaultValue = 1;
615
- return(Qtrue);
616
- }
617
- }
618
-
619
-
620
- /*
621
- * call-seq:
622
- * XML.default_warnings -> (true|false)
623
- *
624
- * Determine whether parsers output warnings by default.
625
- */
626
- static VALUE
627
- rxml_default_warnings_get(VALUE class) {
628
- if (xmlGetWarningsDefaultValue)
629
- return(Qtrue);
630
- else
631
- return(Qfalse);
632
- }
633
-
634
-
635
- /*
636
- * call-seq:
637
- * XML.default_warnings = true|false
638
- *
639
- * Controls whether parsers output warnings by default.
640
- */
641
- static VALUE
642
- rxml_default_warnings_set(VALUE class, VALUE bool) {
643
- if (TYPE(bool) == T_FALSE) {
644
- xmlGetWarningsDefaultValue = 0;
645
- return(Qfalse);
646
- } else {
647
- xmlGetWarningsDefaultValue = 1;
648
- return(Qtrue);
649
- }
650
- }
651
-
652
-
653
- /*
654
- * call-seq:
655
- * XML.default_compression -> (true|false)
656
- *
657
- * Determine whether parsers use Zlib compression by default
658
- * (requires libxml to be compiled with Zlib support).
659
- */
660
- static VALUE
661
- rxml_default_compression_get(VALUE class) {
662
- #ifdef HAVE_ZLIB_H
663
- return(INT2FIX(xmlGetCompressMode()));
664
- #else
665
- rb_warn("libxml was compiled without zlib support");
666
- return(Qfalse);
667
- #endif
668
- }
669
-
670
-
671
- /*
672
- * call-seq:
673
- * XML.default_compression = true|false
674
- *
675
- * Controls whether parsers use Zlib compression by default
676
- * (requires libxml to be compiled with Zlib support).
677
- */
678
- static VALUE
679
- rxml_default_compression_set(VALUE class, VALUE num) {
680
- #ifdef HAVE_ZLIB_H
681
- Check_Type(num, T_FIXNUM);
682
- xmlSetCompressMode(FIX2INT(num));
683
- return(num);
684
- #else
685
- rb_warn("libxml was compiled without zlib support");
686
- return(Qfalse);
687
- #endif
688
- }
689
-
690
-
691
- /*
692
- * call-seq:
693
- * XML.features -> ["feature", ..., "feature"]
694
- *
695
- * Obtains an array of strings representing features supported
696
- * (and enabled) by the installed libxml.
697
- */
698
- static VALUE
699
- rxml_features(VALUE class) {
700
- VALUE arr, str;
701
- int i, len = MAX_LIBXML_FEATURES_LEN;
702
- char **list = NULL;
703
-
704
- list = ALLOC_N(char *,MAX_LIBXML_FEATURES_LEN);
705
- MEMZERO(list, char *, MAX_LIBXML_FEATURES_LEN);
706
-
707
- arr = rb_ary_new();
708
- if (xmlGetFeaturesList(&len, (const char **)list) == -1)
709
- return Qnil;
710
-
711
- for (i = 0; i < len; i++) {
712
- str = rb_str_new2((const char *)list[i]);
713
- rb_gc_unregister_address(&str);
714
- rb_ary_push(arr, str);
715
- }
716
-
717
- if (len == MAX_LIBXML_FEATURES_LEN)
718
- rb_warn("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");
719
-
720
- ruby_xfree(list);
721
- return(arr);
722
- }
723
-
724
-
725
- /*
726
- * call-seq:
727
- * XML.indent_tree_output -> (true|false)
728
- *
729
- * Determines whether XML output will be indented
730
- * (using the string supplied to +default_indent_tree_string+)
731
- */
732
- static VALUE
733
- rxml_indent_tree_output_get(VALUE class) {
734
- if (xmlIndentTreeOutput)
735
- return(Qtrue);
736
- else
737
- return(Qfalse);
738
- }
739
-
740
-
741
- /*
742
- * call-seq:
743
- * XML.indent_tree_output = true|false
744
- *
745
- * Controls whether XML output will be indented
746
- * (using the string supplied to +default_indent_tree_string+)
747
- */
748
- static VALUE
749
- rxml_indent_tree_output_set(VALUE class, VALUE bool) {
750
- if (TYPE(bool) == T_TRUE) {
751
- xmlIndentTreeOutput = 1;
752
- return(Qtrue);
753
- } else if (TYPE(bool) == T_FALSE) {
754
- xmlIndentTreeOutput = 0;
755
- return(Qfalse);
756
- } else {
757
- rb_raise(rb_eArgError, "Invalid argument, must be boolean");
758
- }
759
- }
760
-
761
- /*
762
- * call-seq:
763
- * XML.memory_dump -> (true|false)
764
- *
765
- * Perform a parser memory dump (requires memory debugging
766
- * support in libxml).
767
- */
768
- static VALUE
769
- rxml_memory_dump(VALUE self) {
770
- #ifdef DEBUG_MEMORY_LOCATION
771
- xmlMemoryDump();
772
- return(Qtrue);
773
- #else
774
- rb_warn("libxml was compiled without memory debugging support");
775
- return(Qfalse);
776
- #endif
777
- }
778
-
779
-
780
- /*
781
- * call-seq:
782
- * XML.memory_used -> num_bytes
783
- *
784
- * Perform a parser memory dump (requires memory debugging
785
- * support in libxml).
786
- */
787
- static VALUE
788
- rxml_memory_used(VALUE self) {
789
- #ifdef DEBUG_MEMORY_LOCATION
790
- return(INT2NUM(xmlMemUsed()));
791
- #else
792
- rb_warn("libxml was compiled without memory debugging support");
793
- return(Qfalse);
794
- #endif
795
- }
796
-
797
- #if defined(_WIN32)
798
- __declspec(dllexport)
799
- #endif
800
- void
801
- Init_libxml_ruby(void) {
802
- mLibXML = rb_define_module("LibXML");
803
- mXML = rb_define_module_under(mLibXML, "XML");
804
-
805
- /* Constants */
806
- rb_define_const(mXML, "LIBXML_VERSION", rb_str_new2(LIBXML_DOTTED_VERSION));
807
- rb_define_const(mXML, "VERSION", rb_str_new2(RUBY_LIBXML_VERSION));
808
- rb_define_const(mXML, "VERNUM", INT2NUM(RUBY_LIBXML_VERNUM));
809
- rb_define_const(mXML, "XML_NAMESPACE", rb_str_new2((const char*)XML_XML_NAMESPACE));
810
-
811
- rb_define_module_function(mXML, "enabled_automata?", rxml_enabled_automata_q, 0);
812
- rb_define_module_function(mXML, "enabled_c14n?", rxml_enabled_c14n_q, 0);
813
- rb_define_module_function(mXML, "enabled_catalog?", rxml_enabled_catalog_q, 0);
814
- rb_define_module_function(mXML, "enabled_debug?", rxml_enabled_debug_q, 0);
815
- rb_define_module_function(mXML, "enabled_docbook?", rxml_enabled_docbook_q, 0);
816
- rb_define_module_function(mXML, "enabled_ftp?", rxml_enabled_ftp_q, 0);
817
- rb_define_module_function(mXML, "enabled_http?", rxml_enabled_http_q, 0);
818
- rb_define_module_function(mXML, "enabled_html?", rxml_enabled_html_q, 0);
819
- rb_define_module_function(mXML, "enabled_iconv?", rxml_enabled_iconv_q, 0);
820
- rb_define_module_function(mXML, "enabled_memory_debug?", rxml_enabled_memory_debug_location_q, 0);
821
- rb_define_module_function(mXML, "enabled_regexp?", rxml_enabled_regexp_q, 0);
822
- rb_define_module_function(mXML, "enabled_schemas?", rxml_enabled_schemas_q, 0);
823
- rb_define_module_function(mXML, "enabled_thread?", rxml_enabled_thread_q, 0);
824
- rb_define_module_function(mXML, "enabled_unicode?", rxml_enabled_unicode_q, 0);
825
- rb_define_module_function(mXML, "enabled_xinclude?", rxml_enabled_xinclude_q, 0);
826
- rb_define_module_function(mXML, "enabled_xpath?", rxml_enabled_xpath_q, 0);
827
- rb_define_module_function(mXML, "enabled_xpointer?", rxml_enabled_xpointer_q, 0);
828
- rb_define_module_function(mXML, "enabled_zlib?", rxml_enabled_zlib_q, 0);
829
-
830
- rb_define_module_function(mXML, "catalog_dump", rxml_catalog_dump, 0);
831
- rb_define_module_function(mXML, "catalog_remove", rxml_catalog_remove, 1);
832
- rb_define_module_function(mXML, "check_lib_versions", rxml_check_lib_versions, 0);
833
- rb_define_module_function(mXML, "debug_entities", rxml_debug_entities_get, 0);
834
- rb_define_module_function(mXML, "debug_entities=", rxml_debug_entities_set, 1);
835
- rb_define_module_function(mXML, "default_compression", rxml_default_compression_get, 0);
836
- rb_define_module_function(mXML, "default_compression=", rxml_default_compression_set, 1);
837
- rb_define_module_function(mXML, "default_keep_blanks", rxml_default_keep_blanks_get, 0);
838
- rb_define_module_function(mXML, "default_keep_blanks=", rxml_default_keep_blanks_set, 1);
839
- rb_define_module_function(mXML, "default_load_external_dtd", rxml_default_load_external_dtd_get, 0);
840
- rb_define_module_function(mXML, "default_load_external_dtd=", rxml_default_load_external_dtd_set, 1);
841
- rb_define_module_function(mXML, "default_line_numbers", rxml_default_line_numbers_get, 0);
842
- rb_define_module_function(mXML, "default_line_numbers=", rxml_default_line_numbers_set, 1);
843
- rb_define_module_function(mXML, "default_pedantic_parser", rxml_default_pedantic_parser_get, 0);
844
- rb_define_module_function(mXML, "default_pedantic_parser=", rxml_default_pedantic_parser_set, 1);
845
- rb_define_module_function(mXML, "default_substitute_entities", rxml_default_substitute_entities_get, 0);
846
- rb_define_module_function(mXML, "default_substitute_entities=", rxml_default_substitute_entities_set, 1);
847
- rb_define_module_function(mXML, "default_tree_indent_string", rxml_default_tree_indent_string_get, 0);
848
- rb_define_module_function(mXML, "default_tree_indent_string=", rxml_default_tree_indent_string_set, 1);
849
- rb_define_module_function(mXML, "default_validity_checking", rxml_default_validity_checking_get, 0);
850
- rb_define_module_function(mXML, "default_validity_checking=", rxml_default_validity_checking_set, 1);
851
- rb_define_module_function(mXML, "default_warnings", rxml_default_warnings_get, 0);
852
- rb_define_module_function(mXML, "default_warnings=", rxml_default_warnings_set, 1);
853
- rb_define_module_function(mXML, "features", rxml_features, 0);
854
- rb_define_module_function(mXML, "indent_tree_output", rxml_indent_tree_output_get, 0);
855
- rb_define_module_function(mXML, "indent_tree_output=", rxml_indent_tree_output_set, 1);
856
- rb_define_module_function(mXML, "memory_dump", rxml_memory_dump, 0);
857
- rb_define_module_function(mXML, "memory_used", rxml_memory_used, 0);
858
-
859
- /* Now initialize all the other modules */
860
- ruby_init_xml_error();
861
- ruby_init_xml_input();
862
- ruby_init_state();
863
- ruby_init_parser();
864
- ruby_init_xml_parser_context();
865
- ruby_init_xml_node();
866
- ruby_init_xml_attributes();
867
- ruby_init_xml_attr();
868
- ruby_init_xml_document();
869
- ruby_init_xml_ns();
870
- ruby_init_xml_sax_parser();
871
- ruby_init_xml_xinclude();
872
- ruby_init_xml_xpath();
873
- ruby_init_xml_xpath_context();
874
- ruby_init_xml_xpath_expression();
875
- ruby_init_xml_xpointer();
876
- ruby_init_html_parser();
877
- ruby_init_input_callbacks();
878
- ruby_init_xml_dtd();
879
- ruby_init_xml_schema();
880
- ruby_init_xml_relaxng();
881
- ruby_init_xml_reader();
882
-
883
- rxml_default_substitute_entities_set(mXML, Qtrue);
884
- rxml_default_load_external_dtd_set(mXML, Qtrue);
885
- }
1
+ /* $Id: libxml.c 650 2008-11-30 03:40:22Z cfis $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #include "ruby_libxml.h"
6
+
7
+ VALUE mLibXML;
8
+ VALUE mXML;
9
+
10
+ /*
11
+ * call-seq:
12
+ * XML.catalog_dump -> true
13
+ *
14
+ * Dump all the global catalog content stdout.
15
+ */
16
+ static VALUE rxml_catalog_dump(VALUE self)
17
+ {
18
+ xmlCatalogDump(stdout);
19
+ return (Qtrue);
20
+ }
21
+
22
+ /*
23
+ * call-seq:
24
+ * XML.catalog_remove(catalog) -> true
25
+ *
26
+ * Remove the specified resource catalog.
27
+ */
28
+ static VALUE rxml_catalog_remove(VALUE self, VALUE cat)
29
+ {
30
+ Check_Type(cat, T_STRING);
31
+ xmlCatalogRemove((xmlChar *) StringValuePtr(cat));
32
+ return (Qtrue);
33
+ }
34
+
35
+ /*
36
+ * call-seq:
37
+ * XML.check_lib_versions -> true
38
+ *
39
+ * Check LIBXML version matches version the bindings
40
+ * were compiled to. Throws an exception if not.
41
+ */
42
+ static VALUE rxml_check_lib_versions(VALUE class)
43
+ {
44
+ xmlCheckVersion(LIBXML_VERSION);
45
+ return (Qtrue);
46
+ }
47
+
48
+ /*
49
+ * call-seq:
50
+ * XML.enabled_automata? -> (true|false)
51
+ *
52
+ * Determine whether libxml regexp automata support is enabled.
53
+ */
54
+ static VALUE rxml_enabled_automata_q(VALUE class)
55
+ {
56
+ #ifdef LIBXML_AUTOMATA_ENABLED
57
+ return(Qtrue);
58
+ #else
59
+ return (Qfalse);
60
+ #endif
61
+ }
62
+
63
+ /*
64
+ * call-seq:
65
+ * XML.enabled_c14n? -> (true|false)
66
+ *
67
+ * Determine whether libxml 'canonical XML' support is enabled.
68
+ * See "Canonical XML" (http://www.w3.org/TR/xml-c14n)
69
+ */
70
+ static VALUE rxml_enabled_c14n_q(VALUE class)
71
+ {
72
+ #ifdef LIBXML_C14N_ENABLED
73
+ return(Qtrue);
74
+ #else
75
+ return (Qfalse);
76
+ #endif
77
+ }
78
+
79
+ /*
80
+ * call-seq:
81
+ * XML.enabled_catalog? -> (true|false)
82
+ *
83
+ * Determine whether libxml resource catalog support is enabled.
84
+ */
85
+ static VALUE rxml_enabled_catalog_q(VALUE class)
86
+ {
87
+ #ifdef LIBXML_CATALOG_ENABLED
88
+ return(Qtrue);
89
+ #else
90
+ return (Qfalse);
91
+ #endif
92
+ }
93
+
94
+ /*
95
+ * call-seq:
96
+ * XML.enabled_debug? -> (true|false)
97
+ *
98
+ * Determine whether libxml debugging support is enabled.
99
+ */
100
+ static VALUE rxml_enabled_debug_q(VALUE class)
101
+ {
102
+ #ifdef LIBXML_DEBUG_ENABLED
103
+ return(Qtrue);
104
+ #else
105
+ return (Qfalse);
106
+ #endif
107
+ }
108
+
109
+ /*
110
+ * call-seq:
111
+ * XML.enabled_docbook? -> (true|false)
112
+ *
113
+ * Determine whether libxml docbook support is enabled.
114
+ */
115
+ static VALUE rxml_enabled_docbook_q(VALUE class)
116
+ {
117
+ #ifdef LIBXML_DOCB_ENABLED
118
+ return(Qtrue);
119
+ #else
120
+ return (Qfalse);
121
+ #endif
122
+ }
123
+
124
+ /*
125
+ * call-seq:
126
+ * XML.enabled_ftp? -> (true|false)
127
+ *
128
+ * Determine whether libxml ftp client support is enabled.
129
+ */
130
+ static VALUE rxml_enabled_ftp_q(VALUE class)
131
+ {
132
+ #ifdef LIBXML_FTP_ENABLED
133
+ return(Qtrue);
134
+ #else
135
+ return (Qfalse);
136
+ #endif
137
+ }
138
+
139
+ /*
140
+ * call-seq:
141
+ * XML.enabled_http? -> (true|false)
142
+ *
143
+ * Determine whether libxml http client support is enabled.
144
+ */
145
+ static VALUE rxml_enabled_http_q(VALUE class)
146
+ {
147
+ #ifdef LIBXML_HTTP_ENABLED
148
+ return(Qtrue);
149
+ #else
150
+ return (Qfalse);
151
+ #endif
152
+ }
153
+
154
+ /*
155
+ * call-seq:
156
+ * XML.enabled_html? -> (true|false)
157
+ *
158
+ * Determine whether libxml html support is enabled.
159
+ */
160
+ static VALUE rxml_enabled_html_q(VALUE class)
161
+ {
162
+ #ifdef LIBXML_HTML_ENABLED
163
+ return(Qtrue);
164
+ #else
165
+ return (Qfalse);
166
+ #endif
167
+ }
168
+
169
+ /*
170
+ * call-seq:
171
+ * XML.enabled_iconv? -> (true|false)
172
+ *
173
+ * Determine whether libxml iconv support is enabled.
174
+ */
175
+ static VALUE rxml_enabled_iconv_q(VALUE class)
176
+ {
177
+ #ifdef LIBXML_ICONV_ENABLED
178
+ return(Qtrue);
179
+ #else
180
+ return (Qfalse);
181
+ #endif
182
+ }
183
+
184
+ /*
185
+ * call-seq:
186
+ * XML.enabled_memory_debug? -> (true|false)
187
+ *
188
+ * Determine whether libxml memory location debugging support
189
+ * is enabled.
190
+ */
191
+ static VALUE rxml_enabled_memory_debug_location_q(VALUE class)
192
+ {
193
+ #ifdef DEBUG_MEMORY_LOCATION
194
+ return(Qtrue);
195
+ #else
196
+ return (Qfalse);
197
+ #endif
198
+ }
199
+
200
+ /*
201
+ * call-seq:
202
+ * XML.enabled_regexp? -> (true|false)
203
+ *
204
+ * Determine whether libxml regular expression support is enabled.
205
+ */
206
+ static VALUE rxml_enabled_regexp_q(VALUE class)
207
+ {
208
+ #ifdef LIBXML_REGEXP_ENABLED
209
+ return(Qtrue);
210
+ #else
211
+ return (Qfalse);
212
+ #endif
213
+ }
214
+
215
+ /*
216
+ * call-seq:
217
+ * XML.enabled_schemas? -> (true|false)
218
+ *
219
+ * Determine whether libxml schema support is enabled.
220
+ */
221
+ static VALUE rxml_enabled_schemas_q(VALUE class)
222
+ {
223
+ #ifdef LIBXML_SCHEMAS_ENABLED
224
+ return(Qtrue);
225
+ #else
226
+ return (Qfalse);
227
+ #endif
228
+ }
229
+
230
+ /*
231
+ * call-seq:
232
+ * XML.enabled_thread? -> (true|false)
233
+ *
234
+ * Determine whether libxml thread-safe semantics support
235
+ * is enabled (I think?).
236
+ */
237
+ static VALUE rxml_enabled_thread_q(VALUE class)
238
+ {
239
+ #ifdef LIBXML_THREAD_ENABLED
240
+ return(Qtrue);
241
+ #else
242
+ return (Qfalse);
243
+ #endif
244
+ }
245
+
246
+ /*
247
+ * call-seq:
248
+ * XML.enabled_unicode? -> (true|false)
249
+ *
250
+ * Determine whether libxml unicode support is enabled.
251
+ */
252
+ static VALUE rxml_enabled_unicode_q(VALUE class)
253
+ {
254
+ #ifdef LIBXML_UNICODE_ENABLED
255
+ return(Qtrue);
256
+ #else
257
+ return (Qfalse);
258
+ #endif
259
+ }
260
+
261
+ /*
262
+ * call-seq:
263
+ * XML.enabled_xinclude? -> (true|false)
264
+ *
265
+ * Determine whether libxml xinclude support is enabled.
266
+ */
267
+ static VALUE rxml_enabled_xinclude_q(VALUE class)
268
+ {
269
+ #ifdef LIBXML_XINCLUDE_ENABLED
270
+ return(Qtrue);
271
+ #else
272
+ return (Qfalse);
273
+ #endif
274
+ }
275
+
276
+ /*
277
+ * call-seq:
278
+ * XML.enabled_xpath? -> (true|false)
279
+ *
280
+ * Determine whether libxml xpath support is enabled.
281
+ */
282
+ static VALUE rxml_enabled_xpath_q(VALUE class)
283
+ {
284
+ #ifdef LIBXML_XPATH_ENABLED
285
+ return(Qtrue);
286
+ #else
287
+ return (Qfalse);
288
+ #endif
289
+ }
290
+
291
+ /*
292
+ * call-seq:
293
+ * XML.enabled_xpointer? -> (true|false)
294
+ *
295
+ * Determine whether libxml xpointer support is enabled.
296
+ */
297
+ static VALUE rxml_enabled_xpointer_q(VALUE class)
298
+ {
299
+ #ifdef LIBXML_XPTR_ENABLED
300
+ return(Qtrue);
301
+ #else
302
+ return (Qfalse);
303
+ #endif
304
+ }
305
+
306
+ /*
307
+ * call-seq:
308
+ * XML.enabled_zlib? -> (true|false)
309
+ *
310
+ * Determine whether libxml zlib support is enabled.
311
+ */
312
+ static VALUE rxml_enabled_zlib_q(VALUE class)
313
+ {
314
+ #ifdef HAVE_ZLIB_H
315
+ return(Qtrue);
316
+ #else
317
+ return (Qfalse);
318
+ #endif
319
+ }
320
+
321
+ /*
322
+ * call-seq:
323
+ * XML.debug_entities -> (true|false)
324
+ *
325
+ * Determine whether included-entity debugging is enabled.
326
+ * (Requires Libxml to be compiled with debugging support)
327
+ */
328
+ static VALUE rxml_debug_entities_get(VALUE class)
329
+ {
330
+ #ifdef LIBXML_DEBUG_ENABLED
331
+ if (xmlParserDebugEntities)
332
+ return(Qtrue);
333
+ else
334
+ return(Qfalse);
335
+ #else
336
+ rb_warn("libxml was compiled with debugging turned off");
337
+ return (Qfalse);
338
+ #endif
339
+ }
340
+
341
+ /*
342
+ * call-seq:
343
+ * XML.debug_entities = true|false
344
+ *
345
+ * Enable or disable included-entity debugging.
346
+ * (Requires Libxml to be compiled with debugging support)
347
+ */
348
+ static VALUE rxml_debug_entities_set(VALUE class, VALUE bool)
349
+ {
350
+ #ifdef LIBXML_DEBUG_ENABLED
351
+ if (TYPE(bool) == T_FALSE)
352
+ {
353
+ xmlParserDebugEntities = 0;
354
+ return(Qfalse);
355
+ }
356
+ else
357
+ {
358
+ xmlParserDebugEntities = 1;
359
+ return(Qtrue);
360
+ }
361
+ #else
362
+ rb_warn("libxml was compiled with debugging turned off");
363
+ #endif
364
+ }
365
+
366
+ /*
367
+ * call-seq:
368
+ * XML.default_keep_blanks -> (true|false)
369
+ *
370
+ * Determine whether parsers retain whitespace by default.
371
+ */
372
+ static VALUE rxml_default_keep_blanks_get(VALUE class)
373
+ {
374
+ if (xmlKeepBlanksDefaultValue)
375
+ return (Qtrue);
376
+ else
377
+ return (Qfalse);
378
+ }
379
+
380
+ /*
381
+ * call-seq:
382
+ * XML.default_keep_blanks = true|false
383
+ *
384
+ * Controls whether parsers retain whitespace by default.
385
+ */
386
+ static VALUE rxml_default_keep_blanks_set(VALUE class, VALUE bool)
387
+ {
388
+ if (TYPE(bool) == T_FALSE)
389
+ {
390
+ xmlKeepBlanksDefaultValue = 0;
391
+ return (Qfalse);
392
+ }
393
+ else if (TYPE(bool) == T_TRUE)
394
+ {
395
+ xmlKeepBlanksDefaultValue = 1;
396
+ return (Qtrue);
397
+ }
398
+ else
399
+ {
400
+ rb_raise(rb_eArgError, "Invalid argument, must be a boolean");
401
+ }
402
+ }
403
+
404
+ /*
405
+ * call-seq:
406
+ * XML.default_load_external_dtd -> (true|false)
407
+ *
408
+ * Determine whether parsers load external DTDs by default.
409
+ */
410
+ static VALUE rxml_default_load_external_dtd_get(VALUE class)
411
+ {
412
+ if (xmlLoadExtDtdDefaultValue)
413
+ return (Qtrue);
414
+ else
415
+ return (Qfalse);
416
+ }
417
+
418
+ /*
419
+ * call-seq:
420
+ * XML.default_load_external_dtd = true|false
421
+ *
422
+ * Controls whether parsers load external DTDs by default.
423
+ */
424
+ static VALUE rxml_default_load_external_dtd_set(VALUE class, VALUE bool)
425
+ {
426
+ if (TYPE(bool) == T_FALSE)
427
+ {
428
+ xmlLoadExtDtdDefaultValue = 0;
429
+ return (Qfalse);
430
+ }
431
+ else
432
+ {
433
+ xmlLoadExtDtdDefaultValue = 1;
434
+ return (Qtrue);
435
+ }
436
+ }
437
+
438
+ /*
439
+ * call-seq:
440
+ * XML.default_line_numbers -> (true|false)
441
+ *
442
+ * Determine whether parsers retain line-numbers by default.
443
+ */
444
+ static VALUE rxml_default_line_numbers_get(VALUE class)
445
+ {
446
+ if (xmlLineNumbersDefaultValue)
447
+ return (Qtrue);
448
+ else
449
+ return (Qfalse);
450
+ }
451
+
452
+ /*
453
+ * call-seq:
454
+ * XML.default_line_numbers = true|false
455
+ *
456
+ * Controls whether parsers retain line-numbers by default.
457
+ */
458
+ static VALUE rxml_default_line_numbers_set(VALUE class, VALUE bool)
459
+ {
460
+ if (TYPE(bool) == T_FALSE)
461
+ {
462
+ xmlLineNumbersDefault(0);
463
+ return (Qfalse);
464
+ }
465
+ else
466
+ {
467
+ xmlLineNumbersDefault(1);
468
+ return (Qtrue);
469
+ }
470
+ }
471
+
472
+ /*
473
+ * call-seq:
474
+ * XML.default_pedantic_parser -> (true|false)
475
+ *
476
+ * Determine whether parsers are pedantic by default.
477
+ */
478
+ static VALUE rxml_default_pedantic_parser_get(VALUE class)
479
+ {
480
+ if (xmlPedanticParserDefaultValue)
481
+ return (Qtrue);
482
+ else
483
+ return (Qfalse);
484
+ }
485
+
486
+ /*
487
+ * call-seq:
488
+ * XML.default_pedantic_parser = true|false
489
+ *
490
+ * Controls whether parsers are pedantic by default.
491
+ */
492
+ static VALUE rxml_default_pedantic_parser_set(VALUE class, VALUE bool)
493
+ {
494
+ if (TYPE(bool) == T_FALSE)
495
+ {
496
+ xmlPedanticParserDefault(0);
497
+ return (Qfalse);
498
+ }
499
+ else
500
+ {
501
+ xmlPedanticParserDefault(1);
502
+ return (Qtrue);
503
+ }
504
+ }
505
+
506
+ /*
507
+ * call-seq:
508
+ * XML.default_substitute_entities -> (true|false)
509
+ *
510
+ * Determine whether parsers perform inline entity substitution
511
+ * (for external entities) by default.
512
+ */
513
+ static VALUE rxml_default_substitute_entities_get(VALUE class)
514
+ {
515
+ if (xmlSubstituteEntitiesDefaultValue)
516
+ return (Qtrue);
517
+ else
518
+ return (Qfalse);
519
+ }
520
+
521
+ /*
522
+ * call-seq:
523
+ * XML.default_substitute_entities = true|false
524
+ *
525
+ * Controls whether parsers perform inline entity substitution
526
+ * (for external entities) by default.
527
+ */
528
+ static VALUE rxml_default_substitute_entities_set(VALUE class, VALUE bool)
529
+ {
530
+ if (TYPE(bool) == T_FALSE)
531
+ {
532
+ xmlSubstituteEntitiesDefault(0);
533
+ return (Qfalse);
534
+ }
535
+ else
536
+ {
537
+ xmlSubstituteEntitiesDefault(1);
538
+ return (Qtrue);
539
+ }
540
+ }
541
+
542
+ /*
543
+ * call-seq:
544
+ * XML.default_tree_indent_string -> "string"
545
+ *
546
+ * Obtain the default string used by parsers to indent the XML tree
547
+ * for output.
548
+ */
549
+ static VALUE rxml_default_tree_indent_string_get(VALUE class)
550
+ {
551
+ if (xmlTreeIndentString == NULL)
552
+ return (Qnil);
553
+ else
554
+ return (rb_str_new2(xmlTreeIndentString));
555
+ }
556
+
557
+ /*
558
+ * call-seq:
559
+ * XML.default_tree_indent_string = "string"
560
+ *
561
+ * Set the default string used by parsers to indent the XML tree
562
+ * for output.
563
+ */
564
+ static VALUE rxml_default_tree_indent_string_set(VALUE class, VALUE string)
565
+ {
566
+ Check_Type(string, T_STRING);
567
+ xmlTreeIndentString = xmlStrdup(StringValuePtr(string));
568
+ return (string);
569
+ }
570
+
571
+ /*
572
+ * call-seq:
573
+ * XML.default_validity_checking -> (true|false)
574
+ *
575
+ * Determine whether parsers perform XML validation by default.
576
+ */
577
+ static VALUE rxml_default_validity_checking_get(VALUE class)
578
+ {
579
+ if (xmlDoValidityCheckingDefaultValue)
580
+ return (Qtrue);
581
+ else
582
+ return (Qfalse);
583
+ }
584
+
585
+ /*
586
+ * call-seq:
587
+ * XML.default_validity_checking = true|false
588
+ *
589
+ * Controls whether parsers perform XML validation by default.
590
+ */
591
+ static VALUE rxml_default_validity_checking_set(VALUE class, VALUE bool)
592
+ {
593
+ if (TYPE(bool) == T_FALSE)
594
+ {
595
+ xmlDoValidityCheckingDefaultValue = 0;
596
+ return (Qfalse);
597
+ }
598
+ else
599
+ {
600
+ xmlDoValidityCheckingDefaultValue = 1;
601
+ return (Qtrue);
602
+ }
603
+ }
604
+
605
+ /*
606
+ * call-seq:
607
+ * XML.default_warnings -> (true|false)
608
+ *
609
+ * Determine whether parsers output warnings by default.
610
+ */
611
+ static VALUE rxml_default_warnings_get(VALUE class)
612
+ {
613
+ if (xmlGetWarningsDefaultValue)
614
+ return (Qtrue);
615
+ else
616
+ return (Qfalse);
617
+ }
618
+
619
+ /*
620
+ * call-seq:
621
+ * XML.default_warnings = true|false
622
+ *
623
+ * Controls whether parsers output warnings by default.
624
+ */
625
+ static VALUE rxml_default_warnings_set(VALUE class, VALUE bool)
626
+ {
627
+ if (TYPE(bool) == T_FALSE)
628
+ {
629
+ xmlGetWarningsDefaultValue = 0;
630
+ return (Qfalse);
631
+ }
632
+ else
633
+ {
634
+ xmlGetWarningsDefaultValue = 1;
635
+ return (Qtrue);
636
+ }
637
+ }
638
+
639
+ /*
640
+ * call-seq:
641
+ * XML.default_compression -> (true|false)
642
+ *
643
+ * Determine whether parsers use Zlib compression by default
644
+ * (requires libxml to be compiled with Zlib support).
645
+ */
646
+ static VALUE rxml_default_compression_get(VALUE class)
647
+ {
648
+ #ifdef HAVE_ZLIB_H
649
+ return(INT2FIX(xmlGetCompressMode()));
650
+ #else
651
+ rb_warn("libxml was compiled without zlib support");
652
+ return (Qfalse);
653
+ #endif
654
+ }
655
+
656
+ /*
657
+ * call-seq:
658
+ * XML.default_compression = true|false
659
+ *
660
+ * Controls whether parsers use Zlib compression by default
661
+ * (requires libxml to be compiled with Zlib support).
662
+ */
663
+ static VALUE rxml_default_compression_set(VALUE class, VALUE num)
664
+ {
665
+ #ifdef HAVE_ZLIB_H
666
+ Check_Type(num, T_FIXNUM);
667
+ xmlSetCompressMode(FIX2INT(num));
668
+ return(num);
669
+ #else
670
+ rb_warn("libxml was compiled without zlib support");
671
+ return (Qfalse);
672
+ #endif
673
+ }
674
+
675
+ /*
676
+ * call-seq:
677
+ * XML.features -> ["feature", ..., "feature"]
678
+ *
679
+ * Obtains an array of strings representing features supported
680
+ * (and enabled) by the installed libxml.
681
+ */
682
+ static VALUE rxml_features(VALUE class)
683
+ {
684
+ VALUE arr, str;
685
+ int i, len = MAX_LIBXML_FEATURES_LEN;
686
+ char **list = NULL;
687
+
688
+ list = ALLOC_N(char *,MAX_LIBXML_FEATURES_LEN);
689
+ MEMZERO(list, char *, MAX_LIBXML_FEATURES_LEN);
690
+
691
+ arr = rb_ary_new();
692
+ if (xmlGetFeaturesList(&len, (const char **) list) == -1)
693
+ return Qnil;
694
+
695
+ for (i = 0; i < len; i++)
696
+ {
697
+ str = rb_str_new2((const char *) list[i]);
698
+ rb_gc_unregister_address(&str);
699
+ rb_ary_push(arr, str);
700
+ }
701
+
702
+ if (len == MAX_LIBXML_FEATURES_LEN)
703
+ rb_warn(
704
+ "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");
705
+
706
+ ruby_xfree(list);
707
+ return (arr);
708
+ }
709
+
710
+ /*
711
+ * call-seq:
712
+ * XML.indent_tree_output -> (true|false)
713
+ *
714
+ * Determines whether XML output will be indented
715
+ * (using the string supplied to +default_indent_tree_string+)
716
+ */
717
+ static VALUE rxml_indent_tree_output_get(VALUE class)
718
+ {
719
+ if (xmlIndentTreeOutput)
720
+ return (Qtrue);
721
+ else
722
+ return (Qfalse);
723
+ }
724
+
725
+ /*
726
+ * call-seq:
727
+ * XML.indent_tree_output = true|false
728
+ *
729
+ * Controls whether XML output will be indented
730
+ * (using the string supplied to +default_indent_tree_string+)
731
+ */
732
+ static VALUE rxml_indent_tree_output_set(VALUE class, VALUE bool)
733
+ {
734
+ if (TYPE(bool) == T_TRUE)
735
+ {
736
+ xmlIndentTreeOutput = 1;
737
+ return (Qtrue);
738
+ }
739
+ else if (TYPE(bool) == T_FALSE)
740
+ {
741
+ xmlIndentTreeOutput = 0;
742
+ return (Qfalse);
743
+ }
744
+ else
745
+ {
746
+ rb_raise(rb_eArgError, "Invalid argument, must be boolean");
747
+ }
748
+ }
749
+
750
+ /*
751
+ * call-seq:
752
+ * XML.memory_dump -> (true|false)
753
+ *
754
+ * Perform a parser memory dump (requires memory debugging
755
+ * support in libxml).
756
+ */
757
+ static VALUE rxml_memory_dump(VALUE self)
758
+ {
759
+ #ifdef DEBUG_MEMORY_LOCATION
760
+ xmlMemoryDump();
761
+ return(Qtrue);
762
+ #else
763
+ rb_warn("libxml was compiled without memory debugging support");
764
+ return (Qfalse);
765
+ #endif
766
+ }
767
+
768
+ /*
769
+ * call-seq:
770
+ * XML.memory_used -> num_bytes
771
+ *
772
+ * Perform a parser memory dump (requires memory debugging
773
+ * support in libxml).
774
+ */
775
+ static VALUE rxml_memory_used(VALUE self)
776
+ {
777
+ #ifdef DEBUG_MEMORY_LOCATION
778
+ return(INT2NUM(xmlMemUsed()));
779
+ #else
780
+ rb_warn("libxml was compiled without memory debugging support");
781
+ return (Qfalse);
782
+ #endif
783
+ }
784
+
785
+ #if defined(_WIN32)
786
+ __declspec(dllexport)
787
+ #endif
788
+ void Init_libxml_ruby(void)
789
+ {
790
+ mLibXML = rb_define_module("LibXML");
791
+ mXML = rb_define_module_under(mLibXML, "XML");
792
+
793
+ /* Constants */
794
+ rb_define_const(mXML, "LIBXML_VERSION", rb_str_new2(LIBXML_DOTTED_VERSION));
795
+ rb_define_const(mXML, "VERSION", rb_str_new2(RUBY_LIBXML_VERSION));
796
+ rb_define_const(mXML, "VERNUM", INT2NUM(RUBY_LIBXML_VERNUM));
797
+ rb_define_const(mXML, "XML_NAMESPACE", rb_str_new2(
798
+ (const char*) XML_XML_NAMESPACE));
799
+
800
+ rb_define_module_function(mXML, "enabled_automata?", rxml_enabled_automata_q,
801
+ 0);
802
+ rb_define_module_function(mXML, "enabled_c14n?", rxml_enabled_c14n_q, 0);
803
+ rb_define_module_function(mXML, "enabled_catalog?", rxml_enabled_catalog_q, 0);
804
+ rb_define_module_function(mXML, "enabled_debug?", rxml_enabled_debug_q, 0);
805
+ rb_define_module_function(mXML, "enabled_docbook?", rxml_enabled_docbook_q, 0);
806
+ rb_define_module_function(mXML, "enabled_ftp?", rxml_enabled_ftp_q, 0);
807
+ rb_define_module_function(mXML, "enabled_http?", rxml_enabled_http_q, 0);
808
+ rb_define_module_function(mXML, "enabled_html?", rxml_enabled_html_q, 0);
809
+ rb_define_module_function(mXML, "enabled_iconv?", rxml_enabled_iconv_q, 0);
810
+ rb_define_module_function(mXML, "enabled_memory_debug?",
811
+ rxml_enabled_memory_debug_location_q, 0);
812
+ rb_define_module_function(mXML, "enabled_regexp?", rxml_enabled_regexp_q, 0);
813
+ rb_define_module_function(mXML, "enabled_schemas?", rxml_enabled_schemas_q, 0);
814
+ rb_define_module_function(mXML, "enabled_thread?", rxml_enabled_thread_q, 0);
815
+ rb_define_module_function(mXML, "enabled_unicode?", rxml_enabled_unicode_q, 0);
816
+ rb_define_module_function(mXML, "enabled_xinclude?", rxml_enabled_xinclude_q,
817
+ 0);
818
+ rb_define_module_function(mXML, "enabled_xpath?", rxml_enabled_xpath_q, 0);
819
+ rb_define_module_function(mXML, "enabled_xpointer?", rxml_enabled_xpointer_q,
820
+ 0);
821
+ rb_define_module_function(mXML, "enabled_zlib?", rxml_enabled_zlib_q, 0);
822
+
823
+ rb_define_module_function(mXML, "catalog_dump", rxml_catalog_dump, 0);
824
+ rb_define_module_function(mXML, "catalog_remove", rxml_catalog_remove, 1);
825
+ rb_define_module_function(mXML, "check_lib_versions",
826
+ rxml_check_lib_versions, 0);
827
+ rb_define_module_function(mXML, "debug_entities", rxml_debug_entities_get, 0);
828
+ rb_define_module_function(mXML, "debug_entities=", rxml_debug_entities_set, 1);
829
+ rb_define_module_function(mXML, "default_compression",
830
+ rxml_default_compression_get, 0);
831
+ rb_define_module_function(mXML, "default_compression=",
832
+ rxml_default_compression_set, 1);
833
+ rb_define_module_function(mXML, "default_keep_blanks",
834
+ rxml_default_keep_blanks_get, 0);
835
+ rb_define_module_function(mXML, "default_keep_blanks=",
836
+ rxml_default_keep_blanks_set, 1);
837
+ rb_define_module_function(mXML, "default_load_external_dtd",
838
+ rxml_default_load_external_dtd_get, 0);
839
+ rb_define_module_function(mXML, "default_load_external_dtd=",
840
+ rxml_default_load_external_dtd_set, 1);
841
+ rb_define_module_function(mXML, "default_line_numbers",
842
+ rxml_default_line_numbers_get, 0);
843
+ rb_define_module_function(mXML, "default_line_numbers=",
844
+ rxml_default_line_numbers_set, 1);
845
+ rb_define_module_function(mXML, "default_pedantic_parser",
846
+ rxml_default_pedantic_parser_get, 0);
847
+ rb_define_module_function(mXML, "default_pedantic_parser=",
848
+ rxml_default_pedantic_parser_set, 1);
849
+ rb_define_module_function(mXML, "default_substitute_entities",
850
+ rxml_default_substitute_entities_get, 0);
851
+ rb_define_module_function(mXML, "default_substitute_entities=",
852
+ rxml_default_substitute_entities_set, 1);
853
+ rb_define_module_function(mXML, "default_tree_indent_string",
854
+ rxml_default_tree_indent_string_get, 0);
855
+ rb_define_module_function(mXML, "default_tree_indent_string=",
856
+ rxml_default_tree_indent_string_set, 1);
857
+ rb_define_module_function(mXML, "default_validity_checking",
858
+ rxml_default_validity_checking_get, 0);
859
+ rb_define_module_function(mXML, "default_validity_checking=",
860
+ rxml_default_validity_checking_set, 1);
861
+ rb_define_module_function(mXML, "default_warnings",
862
+ rxml_default_warnings_get, 0);
863
+ rb_define_module_function(mXML, "default_warnings=",
864
+ rxml_default_warnings_set, 1);
865
+ rb_define_module_function(mXML, "features", rxml_features, 0);
866
+ rb_define_module_function(mXML, "indent_tree_output",
867
+ rxml_indent_tree_output_get, 0);
868
+ rb_define_module_function(mXML, "indent_tree_output=",
869
+ rxml_indent_tree_output_set, 1);
870
+ rb_define_module_function(mXML, "memory_dump", rxml_memory_dump, 0);
871
+ rb_define_module_function(mXML, "memory_used", rxml_memory_used, 0);
872
+
873
+ /* Now initialize all the other modules */
874
+ ruby_init_xml_error();
875
+ ruby_init_xml_input();
876
+ ruby_init_state();
877
+ ruby_init_parser();
878
+ ruby_init_xml_parser_context();
879
+ ruby_init_xml_node();
880
+ ruby_init_xml_attributes();
881
+ ruby_init_xml_attr();
882
+ ruby_init_xml_document();
883
+ ruby_init_xml_ns();
884
+ ruby_init_xml_sax_parser();
885
+ ruby_init_xml_xinclude();
886
+ ruby_init_xml_xpath();
887
+ ruby_init_xml_xpath_context();
888
+ ruby_init_xml_xpath_expression();
889
+ ruby_init_xml_xpointer();
890
+ ruby_init_html_parser();
891
+ ruby_init_input_callbacks();
892
+ ruby_init_xml_dtd();
893
+ ruby_init_xml_schema();
894
+ ruby_init_xml_relaxng();
895
+ ruby_init_xml_reader();
896
+
897
+ rxml_default_substitute_entities_set(mXML, Qtrue);
898
+ rxml_default_load_external_dtd_set(mXML, Qtrue);
899
+ }