mkrf 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/MIT-LICENSE +7 -0
- data/README +54 -0
- data/Rakefile +107 -0
- data/lib/mkrf.rb +4 -0
- data/lib/mkrf/availability.rb +219 -0
- data/lib/mkrf/generator.rb +146 -0
- data/test/abstract_unit.rb +4 -0
- data/test/fixtures/down_a_directory/header_down_a_directory.h +1 -0
- data/test/fixtures/stdmkrf.h +1 -0
- data/test/sample_files/libtrivial/Rakefile +31 -0
- data/test/sample_files/libtrivial/extconf.rb +3 -0
- data/test/sample_files/libtrivial/lib/libtrivial.c +5 -0
- data/test/sample_files/libtrivial/lib/libtrivial.o +0 -0
- data/test/sample_files/libtrivial/libtrivial_so.bundle +0 -0
- data/test/sample_files/libtrivial/mkrf.log +1 -0
- data/test/sample_files/libxml-ruby-0.3.8/CHANGELOG +74 -0
- data/test/sample_files/libxml-ruby-0.3.8/LICENSE +22 -0
- data/test/sample_files/libxml-ruby-0.3.8/README +144 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/cbg.c +76 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/extconf.rb +49 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.c +86 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.h +82 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.rb +107 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/mkrf.log +1 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/old_extconf.rb +95 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.c +372 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.c +224 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.c +1159 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.h +27 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.c +168 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.h +17 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.c +167 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.c +2139 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.h +28 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.c +248 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.h +26 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.c +153 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.c +1417 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.h +31 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.c +715 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.h +22 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.c +426 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.h +52 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.c +142 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.h +16 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.c +43 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.h +12 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.c +20 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.h +13 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.c +363 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.h +24 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.c +125 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.h +24 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.c +100 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.h +27 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.c +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.h +18 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/sax_parser_callbacks.inc +202 -0
- data/test/sample_files/syck-0.55/CHANGELOG +186 -0
- data/test/sample_files/syck-0.55/COPYING +54 -0
- data/test/sample_files/syck-0.55/Makefile +582 -0
- data/test/sample_files/syck-0.55/Makefile.am +5 -0
- data/test/sample_files/syck-0.55/Makefile.in +582 -0
- data/test/sample_files/syck-0.55/README +105 -0
- data/test/sample_files/syck-0.55/README.BYTECODE +484 -0
- data/test/sample_files/syck-0.55/README.EXT +444 -0
- data/test/sample_files/syck-0.55/RELEASE +123 -0
- data/test/sample_files/syck-0.55/TODO +25 -0
- data/test/sample_files/syck-0.55/aclocal.m4 +883 -0
- data/test/sample_files/syck-0.55/bootstrap +7 -0
- data/test/sample_files/syck-0.55/config.h +79 -0
- data/test/sample_files/syck-0.55/config.h.in +78 -0
- data/test/sample_files/syck-0.55/config.status +1197 -0
- data/test/sample_files/syck-0.55/config/README +14 -0
- data/test/sample_files/syck-0.55/config/depcomp +529 -0
- data/test/sample_files/syck-0.55/config/install-sh +323 -0
- data/test/sample_files/syck-0.55/config/missing +357 -0
- data/test/sample_files/syck-0.55/configure +6728 -0
- data/test/sample_files/syck-0.55/configure.in +36 -0
- data/test/sample_files/syck-0.55/ext/ruby/CHANGELOG +303 -0
- data/test/sample_files/syck-0.55/ext/ruby/README +400 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/MANIFEST +1 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/bytecode.c +1170 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/emitter.c +1224 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/extconf.rb +10 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.c +1894 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.h +79 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/handler.c +174 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/implicit.c +2989 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/mkrf.log +1 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/node.c +407 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/rubyext.c +2385 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.c +504 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.h +458 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/token.c +2707 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/yaml2byte.c +250 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/yamlbyte.h +170 -0
- data/test/sample_files/syck-0.55/ext/ruby/install.rb +1022 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/okay.rb +161 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/okay/news.rb +69 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/okay/rpc.rb +434 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml.rb +436 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/baseemitter.rb +247 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/basenode.rb +216 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/compat.rb +26 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/constants.rb +45 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/dbm.rb +111 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/emitter.rb +107 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/encoding.rb +33 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/error.rb +34 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/rubytypes.rb +438 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/store.rb +29 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/stream.rb +40 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/stringio.rb +83 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/syck.rb +19 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/tag.rb +86 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/types.rb +188 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/yamlnode.rb +54 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/ypath.rb +52 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yod.rb +1168 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-modules.rb +27 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-sample.rb +336 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-validate.rb +341 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayRpc-client.rb +51 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayRpc-server.rb +85 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/yaml-sortHashKeys.rb +128 -0
- data/test/sample_files/syck-0.55/ext/ruby/tests/basic.rb +1653 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsAnchorAlias.yml +51 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBasicTests.yml +282 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBlockMapping.yml +78 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBlockSequence.yml +0 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsDocumentSeparator.yml +102 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsErrorTests.yml +23 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsFlowCollections.yml +73 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsFoldedScalars.yml +215 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsMapInSeq.yml +0 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsNullsAndEmpties.yml +66 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsRubyTests.yml +182 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsSpecificationExamples.yml +2699 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsTypeTransfers.yml +265 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsYpath.yml +221 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/cookbook.rb +159 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/index.yml +10 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/yts.rb +193 -0
- data/test/sample_files/syck-0.55/lib/Makefile +497 -0
- data/test/sample_files/syck-0.55/lib/Makefile.am +27 -0
- data/test/sample_files/syck-0.55/lib/Makefile.in +497 -0
- data/test/sample_files/syck-0.55/lib/bytecode.c +1170 -0
- data/test/sample_files/syck-0.55/lib/bytecode.re +525 -0
- data/test/sample_files/syck-0.55/lib/emitter.c +1224 -0
- data/test/sample_files/syck-0.55/lib/gram.c +1894 -0
- data/test/sample_files/syck-0.55/lib/gram.h +79 -0
- data/test/sample_files/syck-0.55/lib/gram.output +2005 -0
- data/test/sample_files/syck-0.55/lib/gram.y +481 -0
- data/test/sample_files/syck-0.55/lib/handler.c +174 -0
- data/test/sample_files/syck-0.55/lib/implicit.c +2989 -0
- data/test/sample_files/syck-0.55/lib/implicit.re +206 -0
- data/test/sample_files/syck-0.55/lib/node.c +407 -0
- data/test/sample_files/syck-0.55/lib/syck.c +504 -0
- data/test/sample_files/syck-0.55/lib/syck.h +458 -0
- data/test/sample_files/syck-0.55/lib/syck_st.c +577 -0
- data/test/sample_files/syck-0.55/lib/syck_st.h +46 -0
- data/test/sample_files/syck-0.55/lib/token.c +2707 -0
- data/test/sample_files/syck-0.55/lib/token.re +1139 -0
- data/test/sample_files/syck-0.55/lib/yaml2byte.c +250 -0
- data/test/sample_files/syck-0.55/lib/yamlbyte.h +170 -0
- data/test/sample_files/syck-0.55/stamp-h1 +1 -0
- data/test/sample_files/syck-0.55/tests/Basic.c +141 -0
- data/test/sample_files/syck-0.55/tests/CuTest.c +294 -0
- data/test/sample_files/syck-0.55/tests/CuTest.h +84 -0
- data/test/sample_files/syck-0.55/tests/Emit.c +87 -0
- data/test/sample_files/syck-0.55/tests/Makefile +480 -0
- data/test/sample_files/syck-0.55/tests/Makefile.am +13 -0
- data/test/sample_files/syck-0.55/tests/Makefile.in +480 -0
- data/test/sample_files/syck-0.55/tests/Parse.c +208 -0
- data/test/sample_files/syck-0.55/tests/YTS.c +2310 -0
- data/test/sample_files/syck-0.55/tests/YTS.c.erb +326 -0
- data/test/sample_files/syck-0.55/tests/YTS.c.rb +44 -0
- data/test/test_availability.rb +68 -0
- data/test/test_generator.rb +74 -0
- metadata +252 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
/* $Id: ruby_xml_ns.h,v 1.1 2006/02/21 20:40:16 roscopeco Exp $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#ifndef __RUBY_XML_NS__
|
6
|
+
#define __RUBY_XML_NS__
|
7
|
+
|
8
|
+
extern VALUE cXMLNS;
|
9
|
+
|
10
|
+
typedef struct ruby_xml_ns {
|
11
|
+
xmlNsPtr ns;
|
12
|
+
int is_ptr;
|
13
|
+
VALUE xd;
|
14
|
+
} ruby_xml_ns;
|
15
|
+
|
16
|
+
void ruby_xml_ns_free(ruby_xml_ns *rxn);
|
17
|
+
void ruby_init_xml_ns(void);
|
18
|
+
VALUE ruby_xml_ns_new(VALUE class, VALUE xd, xmlNsPtr ns);
|
19
|
+
VALUE ruby_xml_ns_new2(VALUE class, VALUE xd, xmlNsPtr ns);
|
20
|
+
VALUE ruby_xml_ns_name_get(VALUE self);
|
21
|
+
#endif
|
@@ -0,0 +1,1417 @@
|
|
1
|
+
/* $Id: ruby_xml_parser.c,v 1.3 2006/03/27 20:49:19 roscopeco Exp $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#include "libxml.h"
|
6
|
+
|
7
|
+
static VALUE libxml_xmlRubyErrorProc = Qnil;
|
8
|
+
static int id_call;
|
9
|
+
|
10
|
+
int ruby_xml_parser_count = 0;
|
11
|
+
VALUE cXMLParser;
|
12
|
+
VALUE eXMLParserParseError;
|
13
|
+
|
14
|
+
static int
|
15
|
+
ctxtRead(FILE *f, char * buf, int len) {
|
16
|
+
return(fread(buf, 1, len, f));
|
17
|
+
}
|
18
|
+
|
19
|
+
/*
|
20
|
+
* call-seq:
|
21
|
+
* XML::Parser.catalog_dump => true
|
22
|
+
*
|
23
|
+
* Dump the parser resource catalogs to stdout.
|
24
|
+
*/
|
25
|
+
VALUE
|
26
|
+
ruby_xml_parser_catalog_dump(VALUE self) {
|
27
|
+
xmlCatalogDump(stdout);
|
28
|
+
return(Qtrue);
|
29
|
+
}
|
30
|
+
|
31
|
+
|
32
|
+
/*
|
33
|
+
* call-seq:
|
34
|
+
* XML::Parser.catalog_remove(catalog) => true
|
35
|
+
*
|
36
|
+
* Remove the specified resource catalog.
|
37
|
+
*/
|
38
|
+
VALUE
|
39
|
+
ruby_xml_parser_catalog_remove(VALUE self, VALUE cat) {
|
40
|
+
Check_Type(cat, T_STRING);
|
41
|
+
xmlCatalogRemove((xmlChar *)StringValuePtr(cat));
|
42
|
+
return(Qtrue);
|
43
|
+
}
|
44
|
+
|
45
|
+
|
46
|
+
/*
|
47
|
+
* call-seq:
|
48
|
+
* XML::Parser.check_lib_versions => true
|
49
|
+
*
|
50
|
+
* Check LIBXML version matches version the bindings
|
51
|
+
* were compiled to. Throws an exception if not.
|
52
|
+
*/
|
53
|
+
VALUE
|
54
|
+
ruby_xml_parser_check_lib_versions(VALUE class) {
|
55
|
+
xmlCheckVersion(LIBXML_VERSION);
|
56
|
+
return(Qtrue);
|
57
|
+
}
|
58
|
+
|
59
|
+
|
60
|
+
/*
|
61
|
+
* call-seq:
|
62
|
+
* XML::Parser.enabled_automata? => (true|false)
|
63
|
+
*
|
64
|
+
* Determine whether libxml regexp automata support is enabled.
|
65
|
+
*/
|
66
|
+
VALUE
|
67
|
+
ruby_xml_parser_enabled_automata_q(VALUE class) {
|
68
|
+
#ifdef LIBXML_AUTOMATA_ENABLED
|
69
|
+
return(Qtrue);
|
70
|
+
#else
|
71
|
+
return(Qfalse);
|
72
|
+
#endif
|
73
|
+
}
|
74
|
+
|
75
|
+
|
76
|
+
/*
|
77
|
+
* call-seq:
|
78
|
+
* XML::Parser.enabled_c14n? => (true|false)
|
79
|
+
*
|
80
|
+
* Determine whether libxml 'canonical XML' support is enabled.
|
81
|
+
* See "Canonical XML" (http://www.w3.org/TR/xml-c14n)
|
82
|
+
*/
|
83
|
+
VALUE
|
84
|
+
ruby_xml_parser_enabled_c14n_q(VALUE class) {
|
85
|
+
#ifdef LIBXML_C14N_ENABLED
|
86
|
+
return(Qtrue);
|
87
|
+
#else
|
88
|
+
return(Qfalse);
|
89
|
+
#endif
|
90
|
+
}
|
91
|
+
|
92
|
+
|
93
|
+
/*
|
94
|
+
* call-seq:
|
95
|
+
* XML::Parser.enabled_catalog? => (true|false)
|
96
|
+
*
|
97
|
+
* Determine whether libxml resource catalog support is enabled.
|
98
|
+
*/
|
99
|
+
VALUE
|
100
|
+
ruby_xml_parser_enabled_catalog_q(VALUE class) {
|
101
|
+
#ifdef LIBXML_CATALOG_ENABLED
|
102
|
+
return(Qtrue);
|
103
|
+
#else
|
104
|
+
return(Qfalse);
|
105
|
+
#endif
|
106
|
+
}
|
107
|
+
|
108
|
+
|
109
|
+
/*
|
110
|
+
* call-seq:
|
111
|
+
* XML::Parser.enabled_debug? => (true|false)
|
112
|
+
*
|
113
|
+
* Determine whether libxml debugging support is enabled.
|
114
|
+
*/
|
115
|
+
VALUE
|
116
|
+
ruby_xml_parser_enabled_debug_q(VALUE class) {
|
117
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
118
|
+
return(Qtrue);
|
119
|
+
#else
|
120
|
+
return(Qfalse);
|
121
|
+
#endif
|
122
|
+
}
|
123
|
+
|
124
|
+
|
125
|
+
/*
|
126
|
+
* call-seq:
|
127
|
+
* XML::Parser.enabled_docbook? => (true|false)
|
128
|
+
*
|
129
|
+
* Determine whether libxml docbook support is enabled.
|
130
|
+
*/
|
131
|
+
VALUE
|
132
|
+
ruby_xml_parser_enabled_docbook_q(VALUE class) {
|
133
|
+
#ifdef LIBXML_DOCB_ENABLED
|
134
|
+
return(Qtrue);
|
135
|
+
#else
|
136
|
+
return(Qfalse);
|
137
|
+
#endif
|
138
|
+
}
|
139
|
+
|
140
|
+
|
141
|
+
/*
|
142
|
+
* call-seq:
|
143
|
+
* XML::Parser.enabled_ftp? => (true|false)
|
144
|
+
*
|
145
|
+
* Determine whether libxml ftp client support is enabled.
|
146
|
+
*/
|
147
|
+
VALUE
|
148
|
+
ruby_xml_parser_enabled_ftp_q(VALUE class) {
|
149
|
+
#ifdef LIBXML_FTP_ENABLED
|
150
|
+
return(Qtrue);
|
151
|
+
#else
|
152
|
+
return(Qfalse);
|
153
|
+
#endif
|
154
|
+
}
|
155
|
+
|
156
|
+
|
157
|
+
/*
|
158
|
+
* call-seq:
|
159
|
+
* XML::Parser.enabled_http? => (true|false)
|
160
|
+
*
|
161
|
+
* Determine whether libxml http client support is enabled.
|
162
|
+
*/
|
163
|
+
VALUE
|
164
|
+
ruby_xml_parser_enabled_http_q(VALUE class) {
|
165
|
+
#ifdef LIBXML_HTTP_ENABLED
|
166
|
+
return(Qtrue);
|
167
|
+
#else
|
168
|
+
return(Qfalse);
|
169
|
+
#endif
|
170
|
+
}
|
171
|
+
|
172
|
+
|
173
|
+
/*
|
174
|
+
* call-seq:
|
175
|
+
* XML::Parser.enabled_html? => (true|false)
|
176
|
+
*
|
177
|
+
* Determine whether libxml html support is enabled.
|
178
|
+
*/
|
179
|
+
VALUE
|
180
|
+
ruby_xml_parser_enabled_html_q(VALUE class) {
|
181
|
+
#ifdef LIBXML_HTML_ENABLED
|
182
|
+
return(Qtrue);
|
183
|
+
#else
|
184
|
+
return(Qfalse);
|
185
|
+
#endif
|
186
|
+
}
|
187
|
+
|
188
|
+
|
189
|
+
/*
|
190
|
+
* call-seq:
|
191
|
+
* XML::Parser.enabled_iconv? => (true|false)
|
192
|
+
*
|
193
|
+
* Determine whether libxml iconv support is enabled.
|
194
|
+
*/
|
195
|
+
VALUE
|
196
|
+
ruby_xml_parser_enabled_iconv_q(VALUE class) {
|
197
|
+
#ifdef LIBXML_ICONV_ENABLED
|
198
|
+
return(Qtrue);
|
199
|
+
#else
|
200
|
+
return(Qfalse);
|
201
|
+
#endif
|
202
|
+
}
|
203
|
+
|
204
|
+
|
205
|
+
/*
|
206
|
+
* call-seq:
|
207
|
+
* XML::Parser.enabled_memory_debug? => (true|false)
|
208
|
+
*
|
209
|
+
* Determine whether libxml memory location debugging support
|
210
|
+
* is enabled.
|
211
|
+
*/
|
212
|
+
VALUE
|
213
|
+
ruby_xml_parser_enabled_memory_debug_location_q(VALUE class) {
|
214
|
+
#ifdef DEBUG_MEMORY_LOCATION
|
215
|
+
return(Qtrue);
|
216
|
+
#else
|
217
|
+
return(Qfalse);
|
218
|
+
#endif
|
219
|
+
}
|
220
|
+
|
221
|
+
|
222
|
+
/*
|
223
|
+
* call-seq:
|
224
|
+
* XML::Parser.enabled_regexp? => (true|false)
|
225
|
+
*
|
226
|
+
* Determine whether libxml regular expression support is enabled.
|
227
|
+
*/
|
228
|
+
VALUE
|
229
|
+
ruby_xml_parser_enabled_regexp_q(VALUE class) {
|
230
|
+
#ifdef LIBXML_REGEXP_ENABLED
|
231
|
+
return(Qtrue);
|
232
|
+
#else
|
233
|
+
return(Qfalse);
|
234
|
+
#endif
|
235
|
+
}
|
236
|
+
|
237
|
+
|
238
|
+
/*
|
239
|
+
* call-seq:
|
240
|
+
* XML::Parser.enabled_schemas? => (true|false)
|
241
|
+
*
|
242
|
+
* Determine whether libxml schema support is enabled.
|
243
|
+
*/
|
244
|
+
VALUE
|
245
|
+
ruby_xml_parser_enabled_schemas_q(VALUE class) {
|
246
|
+
#ifdef LIBXML_SCHEMAS_ENABLED
|
247
|
+
return(Qtrue);
|
248
|
+
#else
|
249
|
+
return(Qfalse);
|
250
|
+
#endif
|
251
|
+
}
|
252
|
+
|
253
|
+
|
254
|
+
/*
|
255
|
+
* call-seq:
|
256
|
+
* XML::Parser.enabled_thread? => (true|false)
|
257
|
+
*
|
258
|
+
* Determine whether libxml thread-safe semantics support
|
259
|
+
* is enabled (I think?).
|
260
|
+
*/
|
261
|
+
VALUE
|
262
|
+
ruby_xml_parser_enabled_thread_q(VALUE class) {
|
263
|
+
#ifdef LIBXML_THREAD_ENABLED
|
264
|
+
return(Qtrue);
|
265
|
+
#else
|
266
|
+
return(Qfalse);
|
267
|
+
#endif
|
268
|
+
}
|
269
|
+
|
270
|
+
|
271
|
+
/*
|
272
|
+
* call-seq:
|
273
|
+
* XML::Parser.enabled_unicode? => (true|false)
|
274
|
+
*
|
275
|
+
* Determine whether libxml unicode support is enabled.
|
276
|
+
*/
|
277
|
+
VALUE
|
278
|
+
ruby_xml_parser_enabled_unicode_q(VALUE class) {
|
279
|
+
#ifdef LIBXML_UNICODE_ENABLED
|
280
|
+
return(Qtrue);
|
281
|
+
#else
|
282
|
+
return(Qfalse);
|
283
|
+
#endif
|
284
|
+
}
|
285
|
+
|
286
|
+
|
287
|
+
/*
|
288
|
+
* call-seq:
|
289
|
+
* XML::Parser.enabled_xinclude? => (true|false)
|
290
|
+
*
|
291
|
+
* Determine whether libxml xinclude support is enabled.
|
292
|
+
*/
|
293
|
+
VALUE
|
294
|
+
ruby_xml_parser_enabled_xinclude_q(VALUE class) {
|
295
|
+
#ifdef LIBXML_XINCLUDE_ENABLED
|
296
|
+
return(Qtrue);
|
297
|
+
#else
|
298
|
+
return(Qfalse);
|
299
|
+
#endif
|
300
|
+
}
|
301
|
+
|
302
|
+
|
303
|
+
/*
|
304
|
+
* call-seq:
|
305
|
+
* XML::Parser.enabled_xpath? => (true|false)
|
306
|
+
*
|
307
|
+
* Determine whether libxml xpath support is enabled.
|
308
|
+
*/
|
309
|
+
VALUE
|
310
|
+
ruby_xml_parser_enabled_xpath_q(VALUE class) {
|
311
|
+
#ifdef LIBXML_XPATH_ENABLED
|
312
|
+
return(Qtrue);
|
313
|
+
#else
|
314
|
+
return(Qfalse);
|
315
|
+
#endif
|
316
|
+
}
|
317
|
+
|
318
|
+
|
319
|
+
/*
|
320
|
+
* call-seq:
|
321
|
+
* XML::Parser.enabled_xpointer? => (true|false)
|
322
|
+
*
|
323
|
+
* Determine whether libxml xpointer support is enabled.
|
324
|
+
*/
|
325
|
+
VALUE
|
326
|
+
ruby_xml_parser_enabled_xpointer_q(VALUE class) {
|
327
|
+
#ifdef LIBXML_XPTR_ENABLED
|
328
|
+
return(Qtrue);
|
329
|
+
#else
|
330
|
+
return(Qfalse);
|
331
|
+
#endif
|
332
|
+
}
|
333
|
+
|
334
|
+
|
335
|
+
/*
|
336
|
+
* call-seq:
|
337
|
+
* XML::Parser.enabled_zlib? => (true|false)
|
338
|
+
*
|
339
|
+
* Determine whether libxml zlib support is enabled.
|
340
|
+
*/
|
341
|
+
VALUE
|
342
|
+
ruby_xml_parser_enabled_zlib_q(VALUE class) {
|
343
|
+
#ifdef HAVE_ZLIB_H
|
344
|
+
return(Qtrue);
|
345
|
+
#else
|
346
|
+
return(Qfalse);
|
347
|
+
#endif
|
348
|
+
}
|
349
|
+
|
350
|
+
|
351
|
+
/*
|
352
|
+
* call-seq:
|
353
|
+
* XML::Parser.debug_entities => (true|false)
|
354
|
+
*
|
355
|
+
* Determine whether included-entity debugging is enabled.
|
356
|
+
* (Requires Libxml to be compiled with debugging support)
|
357
|
+
*/
|
358
|
+
VALUE
|
359
|
+
ruby_xml_parser_debug_entities_get(VALUE class) {
|
360
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
361
|
+
if (xmlParserDebugEntities)
|
362
|
+
return(Qtrue);
|
363
|
+
else
|
364
|
+
return(Qfalse);
|
365
|
+
#else
|
366
|
+
rb_warn("libxml was compiled with debugging turned off");
|
367
|
+
return(Qfalse);
|
368
|
+
#endif
|
369
|
+
}
|
370
|
+
|
371
|
+
|
372
|
+
/*
|
373
|
+
* call-seq:
|
374
|
+
* XML::Parser.debug_entities = true|false
|
375
|
+
*
|
376
|
+
* Enable or disable included-entity debugging.
|
377
|
+
* (Requires Libxml to be compiled with debugging support)
|
378
|
+
*/
|
379
|
+
VALUE
|
380
|
+
ruby_xml_parser_debug_entities_set(VALUE class, VALUE bool) {
|
381
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
382
|
+
if (TYPE(bool) == T_FALSE) {
|
383
|
+
xmlParserDebugEntities = 0;
|
384
|
+
return(Qfalse);
|
385
|
+
} else {
|
386
|
+
xmlParserDebugEntities = 1;
|
387
|
+
return(Qtrue);
|
388
|
+
}
|
389
|
+
#else
|
390
|
+
rb_warn("libxml was compiled with debugging turned off");
|
391
|
+
#endif
|
392
|
+
}
|
393
|
+
|
394
|
+
|
395
|
+
/*
|
396
|
+
* call-seq:
|
397
|
+
* XML::Parser.default_keep_blanks => (true|false)
|
398
|
+
*
|
399
|
+
* Determine whether parsers retain whitespace by default.
|
400
|
+
*/
|
401
|
+
VALUE
|
402
|
+
ruby_xml_parser_default_keep_blanks_get(VALUE class) {
|
403
|
+
if (xmlKeepBlanksDefaultValue)
|
404
|
+
return(Qtrue);
|
405
|
+
else
|
406
|
+
return(Qfalse);
|
407
|
+
}
|
408
|
+
|
409
|
+
|
410
|
+
/*
|
411
|
+
* call-seq:
|
412
|
+
* XML::Parser.default_keep_blanks = true|false
|
413
|
+
*
|
414
|
+
* Controls whether parsers retain whitespace by default.
|
415
|
+
*/
|
416
|
+
VALUE
|
417
|
+
ruby_xml_parser_default_keep_blanks_set(VALUE class, VALUE bool) {
|
418
|
+
if (TYPE(bool) == T_FALSE) {
|
419
|
+
xmlKeepBlanksDefaultValue = 0;
|
420
|
+
return(Qfalse);
|
421
|
+
} else if (TYPE(bool) == T_TRUE) {
|
422
|
+
xmlKeepBlanksDefaultValue = 1;
|
423
|
+
return(Qtrue);
|
424
|
+
} else {
|
425
|
+
rb_raise(rb_eArgError, "invalid argument, must be a boolean");
|
426
|
+
}
|
427
|
+
}
|
428
|
+
|
429
|
+
|
430
|
+
/*
|
431
|
+
* call-seq:
|
432
|
+
* XML::Parser.default_load_external_dtd => (true|false)
|
433
|
+
*
|
434
|
+
* Determine whether parsers load external DTDs by default.
|
435
|
+
*/
|
436
|
+
VALUE
|
437
|
+
ruby_xml_parser_default_load_external_dtd_get(VALUE class) {
|
438
|
+
if (xmlSubstituteEntitiesDefaultValue)
|
439
|
+
return(Qtrue);
|
440
|
+
else
|
441
|
+
return(Qfalse);
|
442
|
+
}
|
443
|
+
|
444
|
+
|
445
|
+
/*
|
446
|
+
* call-seq:
|
447
|
+
* XML::Parser.default_load_external_dtd = true|false
|
448
|
+
*
|
449
|
+
* Controls whether parsers load external DTDs by default.
|
450
|
+
*/
|
451
|
+
VALUE
|
452
|
+
ruby_xml_parser_default_load_external_dtd_set(VALUE class, VALUE bool) {
|
453
|
+
if (TYPE(bool) == T_FALSE) {
|
454
|
+
xmlLoadExtDtdDefaultValue = 0;
|
455
|
+
return(Qfalse);
|
456
|
+
} else {
|
457
|
+
xmlLoadExtDtdDefaultValue = 1;
|
458
|
+
return(Qtrue);
|
459
|
+
}
|
460
|
+
}
|
461
|
+
|
462
|
+
|
463
|
+
/*
|
464
|
+
* call-seq:
|
465
|
+
* XML::Parser.default_line_numbers => (true|false)
|
466
|
+
*
|
467
|
+
* Determine whether parsers retain line-numbers by default.
|
468
|
+
*/
|
469
|
+
VALUE
|
470
|
+
ruby_xml_parser_default_line_numbers_get(VALUE class) {
|
471
|
+
if (xmlLineNumbersDefaultValue)
|
472
|
+
return(Qtrue);
|
473
|
+
else
|
474
|
+
return(Qfalse);
|
475
|
+
}
|
476
|
+
|
477
|
+
|
478
|
+
/*
|
479
|
+
* call-seq:
|
480
|
+
* XML::Parser.default_line_numbers = true|false
|
481
|
+
*
|
482
|
+
* Controls whether parsers retain line-numbers by default.
|
483
|
+
*/
|
484
|
+
VALUE
|
485
|
+
ruby_xml_parser_default_line_numbers_set(VALUE class, VALUE bool) {
|
486
|
+
if (TYPE(bool) == T_FALSE) {
|
487
|
+
xmlLineNumbersDefault(0);
|
488
|
+
return(Qfalse);
|
489
|
+
} else {
|
490
|
+
xmlLineNumbersDefault(1);
|
491
|
+
return(Qtrue);
|
492
|
+
}
|
493
|
+
}
|
494
|
+
|
495
|
+
|
496
|
+
/*
|
497
|
+
* call-seq:
|
498
|
+
* XML::Parser.default_pedantic_parser => (true|false)
|
499
|
+
*
|
500
|
+
* Determine whether parsers are pedantic by default.
|
501
|
+
*/
|
502
|
+
VALUE
|
503
|
+
ruby_xml_parser_default_pedantic_parser_get(VALUE class) {
|
504
|
+
if (xmlPedanticParserDefaultValue)
|
505
|
+
return(Qtrue);
|
506
|
+
else
|
507
|
+
return(Qfalse);
|
508
|
+
}
|
509
|
+
|
510
|
+
|
511
|
+
/*
|
512
|
+
* call-seq:
|
513
|
+
* XML::Parser.default_pedantic_parser = true|false
|
514
|
+
*
|
515
|
+
* Controls whether parsers are pedantic by default.
|
516
|
+
*/
|
517
|
+
VALUE
|
518
|
+
ruby_xml_parser_default_pedantic_parser_set(VALUE class, VALUE bool) {
|
519
|
+
if (TYPE(bool) == T_FALSE) {
|
520
|
+
xmlPedanticParserDefault(0);
|
521
|
+
return(Qfalse);
|
522
|
+
} else {
|
523
|
+
xmlPedanticParserDefault(1);
|
524
|
+
return(Qtrue);
|
525
|
+
}
|
526
|
+
}
|
527
|
+
|
528
|
+
|
529
|
+
/*
|
530
|
+
* call-seq:
|
531
|
+
* XML::Parser.default_substitute_entities => (true|false)
|
532
|
+
*
|
533
|
+
* Determine whether parsers perform inline entity substitution
|
534
|
+
* (for external entities) by default.
|
535
|
+
*/
|
536
|
+
VALUE
|
537
|
+
ruby_xml_parser_default_substitute_entities_get(VALUE class) {
|
538
|
+
if (xmlSubstituteEntitiesDefaultValue)
|
539
|
+
return(Qtrue);
|
540
|
+
else
|
541
|
+
return(Qfalse);
|
542
|
+
}
|
543
|
+
|
544
|
+
|
545
|
+
/*
|
546
|
+
* call-seq:
|
547
|
+
* XML::Parser.default_substitute_entities = true|false
|
548
|
+
*
|
549
|
+
* Controls whether parsers perform inline entity substitution
|
550
|
+
* (for external entities) by default.
|
551
|
+
*/
|
552
|
+
VALUE
|
553
|
+
ruby_xml_parser_default_substitute_entities_set(VALUE class, VALUE bool) {
|
554
|
+
if (TYPE(bool) == T_FALSE) {
|
555
|
+
xmlSubstituteEntitiesDefault(0);
|
556
|
+
return(Qfalse);
|
557
|
+
} else {
|
558
|
+
xmlSubstituteEntitiesDefault(1);
|
559
|
+
return(Qtrue);
|
560
|
+
}
|
561
|
+
}
|
562
|
+
|
563
|
+
|
564
|
+
/*
|
565
|
+
* call-seq:
|
566
|
+
* XML::Parser.default_tree_indent_string => "string"
|
567
|
+
*
|
568
|
+
* Obtain the default string used by parsers to indent the XML tree
|
569
|
+
* for output.
|
570
|
+
*/
|
571
|
+
VALUE
|
572
|
+
ruby_xml_parser_default_tree_indent_string_get(VALUE class) {
|
573
|
+
if (xmlTreeIndentString == NULL)
|
574
|
+
return(Qnil);
|
575
|
+
else
|
576
|
+
return(rb_str_new2(xmlTreeIndentString));
|
577
|
+
}
|
578
|
+
|
579
|
+
|
580
|
+
/*
|
581
|
+
* call-seq:
|
582
|
+
* XML::Parser.default_tree_indent_string = "string"
|
583
|
+
*
|
584
|
+
* Set the default string used by parsers to indent the XML tree
|
585
|
+
* for output.
|
586
|
+
*/
|
587
|
+
VALUE
|
588
|
+
ruby_xml_parser_default_tree_indent_string_set(VALUE class, VALUE string) {
|
589
|
+
Check_Type(string, T_STRING);
|
590
|
+
xmlTreeIndentString = ruby_strdup(StringValuePtr(string));
|
591
|
+
return(string);
|
592
|
+
}
|
593
|
+
|
594
|
+
|
595
|
+
/*
|
596
|
+
* call-seq:
|
597
|
+
* XML::Parser.default_validity_checking => (true|false)
|
598
|
+
*
|
599
|
+
* Determine whether parsers perform XML validation by default.
|
600
|
+
*/
|
601
|
+
VALUE
|
602
|
+
ruby_xml_parser_default_validity_checking_get(VALUE class) {
|
603
|
+
if (xmlDoValidityCheckingDefaultValue)
|
604
|
+
return(Qtrue);
|
605
|
+
else
|
606
|
+
return(Qfalse);
|
607
|
+
}
|
608
|
+
|
609
|
+
|
610
|
+
/*
|
611
|
+
* call-seq:
|
612
|
+
* XML::Parser.default_validity_checking = true|false
|
613
|
+
*
|
614
|
+
* Controls whether parsers perform XML validation by default.
|
615
|
+
*/
|
616
|
+
VALUE
|
617
|
+
ruby_xml_parser_default_validity_checking_set(VALUE class, VALUE bool) {
|
618
|
+
if (TYPE(bool) == T_FALSE) {
|
619
|
+
xmlDoValidityCheckingDefaultValue = 0;
|
620
|
+
return(Qfalse);
|
621
|
+
} else {
|
622
|
+
xmlDoValidityCheckingDefaultValue = 1;
|
623
|
+
return(Qtrue);
|
624
|
+
}
|
625
|
+
}
|
626
|
+
|
627
|
+
|
628
|
+
/*
|
629
|
+
* call-seq:
|
630
|
+
* XML::Parser.default_warnings => (true|false)
|
631
|
+
*
|
632
|
+
* Determine whether parsers output warnings by default.
|
633
|
+
*/
|
634
|
+
VALUE
|
635
|
+
ruby_xml_parser_default_warnings_get(VALUE class) {
|
636
|
+
if (xmlGetWarningsDefaultValue)
|
637
|
+
return(Qtrue);
|
638
|
+
else
|
639
|
+
return(Qfalse);
|
640
|
+
}
|
641
|
+
|
642
|
+
|
643
|
+
/*
|
644
|
+
* call-seq:
|
645
|
+
* XML::Parser.default_warnings = true|false
|
646
|
+
*
|
647
|
+
* Controls whether parsers output warnings by default.
|
648
|
+
*/
|
649
|
+
VALUE
|
650
|
+
ruby_xml_parser_default_warnings_set(VALUE class, VALUE bool) {
|
651
|
+
if (TYPE(bool) == T_FALSE) {
|
652
|
+
xmlGetWarningsDefaultValue = 0;
|
653
|
+
return(Qfalse);
|
654
|
+
} else {
|
655
|
+
xmlGetWarningsDefaultValue = 1;
|
656
|
+
return(Qtrue);
|
657
|
+
}
|
658
|
+
}
|
659
|
+
|
660
|
+
|
661
|
+
/*
|
662
|
+
* call-seq:
|
663
|
+
* XML::Parser.default_compression => (true|false)
|
664
|
+
*
|
665
|
+
* Determine whether parsers use Zlib compression by default
|
666
|
+
* (requires libxml to be compiled with Zlib support).
|
667
|
+
*/
|
668
|
+
VALUE
|
669
|
+
ruby_xml_parser_default_compression_get(VALUE class) {
|
670
|
+
#ifdef HAVE_ZLIB_H
|
671
|
+
return(INT2FIX(xmlGetCompressMode()));
|
672
|
+
#else
|
673
|
+
rb_warn("libxml was compiled without zlib support");
|
674
|
+
return(Qfalse);
|
675
|
+
#endif
|
676
|
+
}
|
677
|
+
|
678
|
+
|
679
|
+
/*
|
680
|
+
* call-seq:
|
681
|
+
* XML::Parser.default_compression = true|false
|
682
|
+
*
|
683
|
+
* Controls whether parsers use Zlib compression by default
|
684
|
+
* (requires libxml to be compiled with Zlib support).
|
685
|
+
*/
|
686
|
+
VALUE
|
687
|
+
ruby_xml_parser_default_compression_set(VALUE class, VALUE num) {
|
688
|
+
#ifdef HAVE_ZLIB_H
|
689
|
+
Check_Type(num, T_FIXNUM);
|
690
|
+
xmlSetCompressMode(FIX2INT(num));
|
691
|
+
return(num);
|
692
|
+
#else
|
693
|
+
rb_warn("libxml was compiled without zlib support");
|
694
|
+
return(Qfalse);
|
695
|
+
#endif
|
696
|
+
}
|
697
|
+
|
698
|
+
|
699
|
+
/*
|
700
|
+
* call-seq:
|
701
|
+
* XML::Parser.features => ["feature", ..., "feature"]
|
702
|
+
*
|
703
|
+
* Obtains an array of strings representing features supported
|
704
|
+
* (and enabled) by the installed libxml.
|
705
|
+
*/
|
706
|
+
VALUE
|
707
|
+
ruby_xml_parser_features(VALUE class) {
|
708
|
+
VALUE arr, str;
|
709
|
+
int i, len = MAX_LIBXML_FEATURES_LEN;
|
710
|
+
char **list = NULL;
|
711
|
+
|
712
|
+
list = ALLOC_N(char *,MAX_LIBXML_FEATURES_LEN);
|
713
|
+
MEMZERO(list, char *, MAX_LIBXML_FEATURES_LEN);
|
714
|
+
|
715
|
+
arr = rb_ary_new();
|
716
|
+
if (xmlGetFeaturesList(&len, (const char **)list) == -1)
|
717
|
+
return Qnil;
|
718
|
+
|
719
|
+
for (i = 0; i < len; i++) {
|
720
|
+
str = rb_str_new2((const char *)list[i]);
|
721
|
+
rb_gc_unregister_address(&str);
|
722
|
+
rb_ary_push(arr, str);
|
723
|
+
}
|
724
|
+
|
725
|
+
if (len == MAX_LIBXML_FEATURES_LEN)
|
726
|
+
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");
|
727
|
+
|
728
|
+
ruby_xfree(list);
|
729
|
+
return(arr);
|
730
|
+
}
|
731
|
+
|
732
|
+
|
733
|
+
/*
|
734
|
+
* call-seq:
|
735
|
+
* parser.filename => "filename"
|
736
|
+
*
|
737
|
+
* Obtain the filename this parser will read from.
|
738
|
+
*/
|
739
|
+
VALUE
|
740
|
+
ruby_xml_parser_filename_get(VALUE self) {
|
741
|
+
ruby_xml_parser *rxp;
|
742
|
+
rx_file_data *data;
|
743
|
+
|
744
|
+
Data_Get_Struct(self, ruby_xml_parser, rxp);
|
745
|
+
if (rxp->data == NULL)
|
746
|
+
return(Qnil);
|
747
|
+
|
748
|
+
if (rxp->data_type != RUBY_LIBXML_SRC_TYPE_FILE)
|
749
|
+
return(Qnil);
|
750
|
+
|
751
|
+
data = (rx_file_data *)rxp->data;
|
752
|
+
return(data->filename);
|
753
|
+
}
|
754
|
+
|
755
|
+
|
756
|
+
/*
|
757
|
+
* call-seq:
|
758
|
+
* parser.filename = "filename"
|
759
|
+
*
|
760
|
+
* Set the filename this parser will read from.
|
761
|
+
*/
|
762
|
+
VALUE
|
763
|
+
ruby_xml_parser_filename_set(VALUE self, VALUE filename) {
|
764
|
+
ruby_xml_parser *rxp;
|
765
|
+
ruby_xml_parser_context *rxpc;
|
766
|
+
rx_file_data *data;
|
767
|
+
|
768
|
+
Check_Type(filename, T_STRING);
|
769
|
+
Data_Get_Struct(self, ruby_xml_parser, rxp);
|
770
|
+
|
771
|
+
if (rxp->data_type == RUBY_LIBXML_SRC_TYPE_NULL) {
|
772
|
+
if (rxp->data != NULL)
|
773
|
+
rb_fatal("crap, this should be null");
|
774
|
+
|
775
|
+
rxp->data_type = RUBY_LIBXML_SRC_TYPE_FILE;
|
776
|
+
data = ALLOC(rx_file_data);
|
777
|
+
rxp->data = data;
|
778
|
+
} else if (rxp->data_type != RUBY_LIBXML_SRC_TYPE_FILE) {
|
779
|
+
return(Qnil);
|
780
|
+
}
|
781
|
+
|
782
|
+
rxp->ctxt = ruby_xml_parser_context_new3();
|
783
|
+
data = (rx_file_data *)rxp->data;
|
784
|
+
data->filename = filename;
|
785
|
+
|
786
|
+
Data_Get_Struct(rxp->ctxt, ruby_xml_parser_context, rxpc);
|
787
|
+
rxpc->ctxt = xmlCreateFileParserCtxt(StringValuePtr(filename));
|
788
|
+
if (rxpc->ctxt == NULL)
|
789
|
+
rb_sys_fail(StringValuePtr(filename));
|
790
|
+
|
791
|
+
return(data->filename);
|
792
|
+
}
|
793
|
+
|
794
|
+
|
795
|
+
void
|
796
|
+
ruby_xml_parser_free(ruby_xml_parser *rxp) {
|
797
|
+
void *data;
|
798
|
+
|
799
|
+
ruby_xml_parser_count--;
|
800
|
+
if (ruby_xml_parser_count == 0)
|
801
|
+
xmlCleanupParser();
|
802
|
+
|
803
|
+
switch(rxp->data_type) {
|
804
|
+
case RUBY_LIBXML_SRC_TYPE_NULL:
|
805
|
+
break;
|
806
|
+
case RUBY_LIBXML_SRC_TYPE_FILE:
|
807
|
+
data = (void *)(rx_file_data *)rxp->data;
|
808
|
+
free((rx_file_data *)data);
|
809
|
+
break;
|
810
|
+
case RUBY_LIBXML_SRC_TYPE_STRING:
|
811
|
+
data = (void *)(rx_string_data *)rxp->data;
|
812
|
+
free((rx_string_data *)data);
|
813
|
+
break;
|
814
|
+
case RUBY_LIBXML_SRC_TYPE_IO:
|
815
|
+
data = (void *)(rx_io_data *)rxp->data;
|
816
|
+
free((rx_io_data *)data);
|
817
|
+
break;
|
818
|
+
default:
|
819
|
+
rb_fatal("Unknown data type, %d", rxp->data_type);
|
820
|
+
}
|
821
|
+
|
822
|
+
free(rxp);
|
823
|
+
}
|
824
|
+
|
825
|
+
|
826
|
+
/*
|
827
|
+
* call-seq:
|
828
|
+
* XML::Parser.indent_tree_output => (true|false)
|
829
|
+
*
|
830
|
+
* Determines whether XML output will be indented
|
831
|
+
* (using the string supplied to +default_indent_tree_string+)
|
832
|
+
*/
|
833
|
+
VALUE
|
834
|
+
ruby_xml_parser_indent_tree_output_get(VALUE class) {
|
835
|
+
if (xmlIndentTreeOutput)
|
836
|
+
return(Qtrue);
|
837
|
+
else
|
838
|
+
return(Qfalse);
|
839
|
+
}
|
840
|
+
|
841
|
+
|
842
|
+
/*
|
843
|
+
* call-seq:
|
844
|
+
* XML::Parser.indent_tree_output = true|false
|
845
|
+
*
|
846
|
+
* Controls whether XML output will be indented
|
847
|
+
* (using the string supplied to +default_indent_tree_string+)
|
848
|
+
*/
|
849
|
+
VALUE
|
850
|
+
ruby_xml_parser_indent_tree_output_set(VALUE class, VALUE bool) {
|
851
|
+
if (TYPE(bool) == T_TRUE) {
|
852
|
+
xmlIndentTreeOutput = 1;
|
853
|
+
return(Qtrue);
|
854
|
+
} else if (TYPE(bool) == T_FALSE) {
|
855
|
+
xmlIndentTreeOutput = 0;
|
856
|
+
return(Qfalse);
|
857
|
+
} else {
|
858
|
+
rb_raise(rb_eArgError, "invalid argument, must be boolean");
|
859
|
+
}
|
860
|
+
}
|
861
|
+
|
862
|
+
|
863
|
+
/*
|
864
|
+
* call-seq:
|
865
|
+
* parser.io => IO
|
866
|
+
*
|
867
|
+
* Obtain the IO instance this parser works with.
|
868
|
+
*/
|
869
|
+
VALUE
|
870
|
+
ruby_xml_parser_io_get(VALUE self, VALUE io) {
|
871
|
+
ruby_xml_parser *rxp;
|
872
|
+
rx_io_data *data;
|
873
|
+
|
874
|
+
Data_Get_Struct(self, ruby_xml_parser, rxp);
|
875
|
+
|
876
|
+
if (rxp->data_type == RUBY_LIBXML_SRC_TYPE_NULL ||
|
877
|
+
rxp->data_type != RUBY_LIBXML_SRC_TYPE_IO ||
|
878
|
+
rxp->data == NULL)
|
879
|
+
return(Qnil);
|
880
|
+
|
881
|
+
data = (rx_io_data *)rxp->data;
|
882
|
+
|
883
|
+
return(data->io);
|
884
|
+
}
|
885
|
+
|
886
|
+
|
887
|
+
/*
|
888
|
+
* call-seq:
|
889
|
+
* parser.io = IO
|
890
|
+
*
|
891
|
+
* Set the IO instance this parser works with.
|
892
|
+
*/
|
893
|
+
VALUE
|
894
|
+
ruby_xml_parser_io_set(VALUE self, VALUE io) {
|
895
|
+
ruby_xml_parser *rxp;
|
896
|
+
ruby_xml_parser_context *rxpc;
|
897
|
+
rx_io_data *data;
|
898
|
+
OpenFile *fptr;
|
899
|
+
FILE *f;
|
900
|
+
|
901
|
+
if (!rb_obj_is_kind_of(io, rb_cIO))
|
902
|
+
rb_raise(rb_eTypeError, "need an IO object");
|
903
|
+
|
904
|
+
Data_Get_Struct(self, ruby_xml_parser, rxp);
|
905
|
+
|
906
|
+
if (rxp->data_type == RUBY_LIBXML_SRC_TYPE_NULL) {
|
907
|
+
if (rxp->data != NULL)
|
908
|
+
rb_fatal("crap, this should be null");
|
909
|
+
|
910
|
+
rxp->data_type = RUBY_LIBXML_SRC_TYPE_IO;
|
911
|
+
data = ALLOC(rx_io_data);
|
912
|
+
rxp->data = data;
|
913
|
+
} else if (rxp->data_type != RUBY_LIBXML_SRC_TYPE_IO) {
|
914
|
+
return(Qnil);
|
915
|
+
}
|
916
|
+
|
917
|
+
rxp->ctxt = ruby_xml_parser_context_new3();
|
918
|
+
data = (rx_io_data *)rxp->data;
|
919
|
+
data->io = io;
|
920
|
+
|
921
|
+
GetOpenFile(io, fptr);
|
922
|
+
rb_io_check_readable(fptr);
|
923
|
+
f = GetWriteFile(fptr);
|
924
|
+
|
925
|
+
Data_Get_Struct(rxp->ctxt, ruby_xml_parser_context, rxpc);
|
926
|
+
rxpc->ctxt = xmlCreateIOParserCtxt(NULL, NULL,
|
927
|
+
(xmlInputReadCallback) ctxtRead,
|
928
|
+
NULL, f, XML_CHAR_ENCODING_NONE);
|
929
|
+
if (NIL_P(rxpc->ctxt))
|
930
|
+
rb_sys_fail(0);
|
931
|
+
|
932
|
+
return(data->io);
|
933
|
+
}
|
934
|
+
|
935
|
+
|
936
|
+
void
|
937
|
+
ruby_xml_parser_mark(ruby_xml_parser *rxp) {
|
938
|
+
if (rxp == NULL) return;
|
939
|
+
if (!NIL_P(rxp->ctxt)) rb_gc_mark(rxp->ctxt);
|
940
|
+
|
941
|
+
switch(rxp->data_type) {
|
942
|
+
case RUBY_LIBXML_SRC_TYPE_NULL:
|
943
|
+
break;
|
944
|
+
case RUBY_LIBXML_SRC_TYPE_FILE:
|
945
|
+
if (!NIL_P(((rx_file_data *)rxp->data)->filename))
|
946
|
+
rb_gc_mark(((rx_file_data *)rxp->data)->filename);
|
947
|
+
break;
|
948
|
+
case RUBY_LIBXML_SRC_TYPE_STRING:
|
949
|
+
if (!NIL_P(((rx_string_data *)rxp->data)->str))
|
950
|
+
rb_gc_mark(((rx_string_data *)rxp->data)->str);
|
951
|
+
break;
|
952
|
+
case RUBY_LIBXML_SRC_TYPE_IO:
|
953
|
+
if (!NIL_P(((rx_io_data *)rxp->data)->io))
|
954
|
+
rb_gc_mark(((rx_io_data *)rxp->data)->io);
|
955
|
+
break;
|
956
|
+
default:
|
957
|
+
rb_fatal("unknown datatype: %d", rxp->data_type);
|
958
|
+
}
|
959
|
+
}
|
960
|
+
|
961
|
+
|
962
|
+
/*
|
963
|
+
* call-seq:
|
964
|
+
* XML::Parser.memory_dump => (true|false)
|
965
|
+
*
|
966
|
+
* Perform a parser memory dump (requires memory debugging
|
967
|
+
* support in libxml).
|
968
|
+
*/
|
969
|
+
VALUE
|
970
|
+
ruby_xml_parser_memory_dump(VALUE self) {
|
971
|
+
#ifdef DEBUG_MEMORY_LOCATION
|
972
|
+
xmlMemoryDump();
|
973
|
+
return(Qtrue);
|
974
|
+
#else
|
975
|
+
rb_warn("libxml was compiled without memory debugging support");
|
976
|
+
return(Qfalse);
|
977
|
+
#endif
|
978
|
+
}
|
979
|
+
|
980
|
+
|
981
|
+
/*
|
982
|
+
* call-seq:
|
983
|
+
* XML::Parser.memory_used => num_bytes
|
984
|
+
*
|
985
|
+
* Perform a parser memory dump (requires memory debugging
|
986
|
+
* support in libxml).
|
987
|
+
*/
|
988
|
+
VALUE
|
989
|
+
ruby_xml_parser_memory_used(VALUE self) {
|
990
|
+
#ifdef DEBUG_MEMORY_LOCATION
|
991
|
+
return(INT2NUM(xmlMemUsed()));
|
992
|
+
#else
|
993
|
+
rb_warn("libxml was compiled without memory debugging support");
|
994
|
+
return(Qfalse);
|
995
|
+
#endif
|
996
|
+
}
|
997
|
+
|
998
|
+
|
999
|
+
/*
|
1000
|
+
* call-seq:
|
1001
|
+
* XML::Parser.new => parser
|
1002
|
+
*
|
1003
|
+
* Create a new parser instance with no pre-determined source.
|
1004
|
+
*/
|
1005
|
+
VALUE
|
1006
|
+
ruby_xml_parser_new(VALUE class) {
|
1007
|
+
ruby_xml_parser *rxp;
|
1008
|
+
|
1009
|
+
ruby_xml_parser_count++;
|
1010
|
+
rxp = ALLOC(ruby_xml_parser);
|
1011
|
+
rxp->ctxt = Qnil;
|
1012
|
+
rxp->data_type = RUBY_LIBXML_SRC_TYPE_NULL;
|
1013
|
+
rxp->data = NULL;
|
1014
|
+
rxp->parsed = 0;
|
1015
|
+
|
1016
|
+
return(Data_Wrap_Struct(class, ruby_xml_parser_mark,
|
1017
|
+
ruby_xml_parser_free, rxp));
|
1018
|
+
}
|
1019
|
+
|
1020
|
+
|
1021
|
+
/*
|
1022
|
+
* call-seq:
|
1023
|
+
* XML::Parser.file => parser
|
1024
|
+
*
|
1025
|
+
* Create a new parser instance that will read the specified file.
|
1026
|
+
*/
|
1027
|
+
VALUE
|
1028
|
+
ruby_xml_parser_new_file(VALUE class, VALUE filename) {
|
1029
|
+
VALUE obj;
|
1030
|
+
ruby_xml_parser *rxp;
|
1031
|
+
rx_file_data *data;
|
1032
|
+
|
1033
|
+
obj = ruby_xml_parser_new(class);
|
1034
|
+
Data_Get_Struct(obj, ruby_xml_parser, rxp);
|
1035
|
+
|
1036
|
+
data = ALLOC(rx_file_data);
|
1037
|
+
rxp->data_type = RUBY_LIBXML_SRC_TYPE_FILE;
|
1038
|
+
rxp->data = data;
|
1039
|
+
|
1040
|
+
ruby_xml_parser_filename_set(obj, filename);
|
1041
|
+
|
1042
|
+
return(obj);
|
1043
|
+
}
|
1044
|
+
|
1045
|
+
|
1046
|
+
/*
|
1047
|
+
* call-seq:
|
1048
|
+
* XML::Parser.io => parser
|
1049
|
+
*
|
1050
|
+
* Create a new parser instance that will read from the
|
1051
|
+
* specified IO object.
|
1052
|
+
*/
|
1053
|
+
VALUE
|
1054
|
+
ruby_xml_parser_new_io(VALUE class, VALUE io) {
|
1055
|
+
VALUE obj;
|
1056
|
+
ruby_xml_parser *rxp;
|
1057
|
+
rx_io_data *data;
|
1058
|
+
|
1059
|
+
obj = ruby_xml_parser_new(class);
|
1060
|
+
Data_Get_Struct(obj, ruby_xml_parser, rxp);
|
1061
|
+
|
1062
|
+
data = ALLOC(rx_io_data);
|
1063
|
+
rxp->data_type = RUBY_LIBXML_SRC_TYPE_IO;
|
1064
|
+
rxp->data = data;
|
1065
|
+
|
1066
|
+
ruby_xml_parser_io_set(obj, io);
|
1067
|
+
|
1068
|
+
return(obj);
|
1069
|
+
}
|
1070
|
+
|
1071
|
+
|
1072
|
+
/*
|
1073
|
+
* call-seq:
|
1074
|
+
* XML::Parser.string => parser
|
1075
|
+
*
|
1076
|
+
* Create a new parser instance that will parse the given
|
1077
|
+
* string.
|
1078
|
+
*/
|
1079
|
+
VALUE
|
1080
|
+
ruby_xml_parser_new_string(VALUE class, VALUE str) {
|
1081
|
+
VALUE obj;
|
1082
|
+
ruby_xml_parser *rxp;
|
1083
|
+
rx_string_data *data;
|
1084
|
+
|
1085
|
+
obj = ruby_xml_parser_new(class);
|
1086
|
+
Data_Get_Struct(obj, ruby_xml_parser, rxp);
|
1087
|
+
|
1088
|
+
data = ALLOC(rx_string_data);
|
1089
|
+
rxp->data_type = RUBY_LIBXML_SRC_TYPE_STRING;
|
1090
|
+
rxp->data = data;
|
1091
|
+
|
1092
|
+
ruby_xml_parser_str_set(obj, str);
|
1093
|
+
|
1094
|
+
return(obj);
|
1095
|
+
}
|
1096
|
+
|
1097
|
+
|
1098
|
+
/*
|
1099
|
+
* call-seq:
|
1100
|
+
* parser.parse => document
|
1101
|
+
*
|
1102
|
+
* Parse the input XML and create an XML::Document with
|
1103
|
+
* it's content. If an error occurs, XML::Parser::ParseError
|
1104
|
+
* is thrown.
|
1105
|
+
*/
|
1106
|
+
VALUE
|
1107
|
+
ruby_xml_parser_parse(VALUE self) {
|
1108
|
+
ruby_xml_document *rxd;
|
1109
|
+
ruby_xml_parser *rxp;
|
1110
|
+
ruby_xml_parser_context *rxpc;
|
1111
|
+
xmlDocPtr xdp;
|
1112
|
+
VALUE doc;
|
1113
|
+
|
1114
|
+
Data_Get_Struct(self, ruby_xml_parser, rxp);
|
1115
|
+
|
1116
|
+
switch (rxp->data_type) {
|
1117
|
+
case RUBY_LIBXML_SRC_TYPE_NULL:
|
1118
|
+
return(Qnil);
|
1119
|
+
case RUBY_LIBXML_SRC_TYPE_STRING:
|
1120
|
+
case RUBY_LIBXML_SRC_TYPE_FILE:
|
1121
|
+
case RUBY_LIBXML_SRC_TYPE_IO:
|
1122
|
+
Data_Get_Struct(rxp->ctxt, ruby_xml_parser_context, rxpc);
|
1123
|
+
if (xmlParseDocument(rxpc->ctxt) == -1) {
|
1124
|
+
xmlFreeDoc(rxpc->ctxt->myDoc);
|
1125
|
+
rb_raise(eXMLParserParseError, "Document didn't parse");
|
1126
|
+
}
|
1127
|
+
|
1128
|
+
xdp = rxpc->ctxt->myDoc;
|
1129
|
+
if (!rxpc->ctxt->wellFormed) {
|
1130
|
+
xmlFreeDoc(xdp);
|
1131
|
+
xdp = NULL;
|
1132
|
+
rb_raise(eXMLParserParseError, "Document did not contain well-formed XML");
|
1133
|
+
} else {
|
1134
|
+
rxp->parsed = 1;
|
1135
|
+
}
|
1136
|
+
|
1137
|
+
doc = ruby_xml_document_new(cXMLDocument, xdp);
|
1138
|
+
Data_Get_Struct(doc, ruby_xml_document, rxd);
|
1139
|
+
rxd->is_ptr = 0;
|
1140
|
+
rxd->doc = xdp;
|
1141
|
+
break;
|
1142
|
+
default:
|
1143
|
+
rb_fatal("Unknown data type, %d", rxp->data_type);
|
1144
|
+
}
|
1145
|
+
|
1146
|
+
return(doc);
|
1147
|
+
}
|
1148
|
+
|
1149
|
+
|
1150
|
+
/*
|
1151
|
+
* call-seq:
|
1152
|
+
* parser.context => context
|
1153
|
+
*
|
1154
|
+
* Obtain the XML::Parser::Context associated with this
|
1155
|
+
* parser.
|
1156
|
+
*/
|
1157
|
+
VALUE
|
1158
|
+
ruby_xml_parser_parser_context_get(VALUE self) {
|
1159
|
+
ruby_xml_parser *rxp;
|
1160
|
+
|
1161
|
+
Data_Get_Struct(self, ruby_xml_parser, rxp);
|
1162
|
+
if (rxp->ctxt == Qnil)
|
1163
|
+
return(Qnil);
|
1164
|
+
else
|
1165
|
+
return(rxp->ctxt);
|
1166
|
+
}
|
1167
|
+
|
1168
|
+
|
1169
|
+
/*
|
1170
|
+
* call-seq:
|
1171
|
+
* parser.string => "string"
|
1172
|
+
*
|
1173
|
+
* Obtain the string this parser works with.
|
1174
|
+
*/
|
1175
|
+
VALUE
|
1176
|
+
ruby_xml_parser_str_get(VALUE self) {
|
1177
|
+
ruby_xml_parser *rxp;
|
1178
|
+
rx_string_data *data;
|
1179
|
+
|
1180
|
+
Data_Get_Struct(self, ruby_xml_parser, rxp);
|
1181
|
+
if (rxp->data == NULL || rxp->data_type != RUBY_LIBXML_SRC_TYPE_STRING)
|
1182
|
+
return(Qnil);
|
1183
|
+
|
1184
|
+
data = (rx_string_data *)rxp->data;
|
1185
|
+
return(data->str);
|
1186
|
+
}
|
1187
|
+
|
1188
|
+
|
1189
|
+
/*
|
1190
|
+
* call-seq:
|
1191
|
+
* parser.string = "string"
|
1192
|
+
*
|
1193
|
+
* Set the string this parser works with.
|
1194
|
+
*/
|
1195
|
+
VALUE
|
1196
|
+
ruby_xml_parser_str_set(VALUE self, VALUE str) {
|
1197
|
+
ruby_xml_parser *rxp;
|
1198
|
+
ruby_xml_parser_context *rxpc;
|
1199
|
+
rx_string_data *data;
|
1200
|
+
|
1201
|
+
Check_Type(str, T_STRING);
|
1202
|
+
Data_Get_Struct(self, ruby_xml_parser, rxp);
|
1203
|
+
|
1204
|
+
if (rxp->data_type == RUBY_LIBXML_SRC_TYPE_NULL) {
|
1205
|
+
rxp->data_type = RUBY_LIBXML_SRC_TYPE_STRING;
|
1206
|
+
data = ALLOC(rx_string_data);
|
1207
|
+
rxp->data = data;
|
1208
|
+
} else if (rxp->data_type != RUBY_LIBXML_SRC_TYPE_STRING) {
|
1209
|
+
return(Qnil);
|
1210
|
+
}
|
1211
|
+
|
1212
|
+
rxp->ctxt = ruby_xml_parser_context_new3();
|
1213
|
+
data = (rx_string_data *)rxp->data;
|
1214
|
+
data->str = str;
|
1215
|
+
|
1216
|
+
Data_Get_Struct(rxp->ctxt, ruby_xml_parser_context, rxpc);
|
1217
|
+
rxpc->ctxt = xmlCreateMemoryParserCtxt(StringValuePtr(data->str), RSTRING(data->str)->len);
|
1218
|
+
|
1219
|
+
return(data->str);
|
1220
|
+
}
|
1221
|
+
|
1222
|
+
/*
|
1223
|
+
* call-seq:
|
1224
|
+
* XML::Parser.register_error_handler(lambda { |msg| ... }) => old_handler
|
1225
|
+
* XML::Parser.register_error_handler(nil) => old_handler
|
1226
|
+
*
|
1227
|
+
* Register the attached block as the handler for parser errors.
|
1228
|
+
* A message describing parse errors is passed to the block.
|
1229
|
+
* Libxml passes error messages to the handler in parts, one per call.
|
1230
|
+
* A typical error results in six calls to this proc, with arguments:
|
1231
|
+
*
|
1232
|
+
* "Entity: line 1: ",
|
1233
|
+
* "parser ",
|
1234
|
+
* "error : ",
|
1235
|
+
* "Opening and ending tag mismatch: foo line 1 and foz\n",
|
1236
|
+
* "<foo><bar/></foz>\n",
|
1237
|
+
* " ^\n"
|
1238
|
+
*
|
1239
|
+
* Note that the error handler is shared by all threads.
|
1240
|
+
*/
|
1241
|
+
VALUE
|
1242
|
+
ruby_xml_parser_registerErrorHandler(VALUE self, VALUE proc) {
|
1243
|
+
VALUE old_block = libxml_xmlRubyErrorProc;
|
1244
|
+
libxml_xmlRubyErrorProc = proc;
|
1245
|
+
return(old_block);
|
1246
|
+
}
|
1247
|
+
|
1248
|
+
static void
|
1249
|
+
libxml_xmlErrorFuncHandler(ATTRIBUTE_UNUSED void *ctx, const char *msg, ...)
|
1250
|
+
{
|
1251
|
+
va_list ap;
|
1252
|
+
char str[1000];
|
1253
|
+
VALUE rstr;
|
1254
|
+
|
1255
|
+
if (libxml_xmlRubyErrorProc == Qnil) {
|
1256
|
+
va_start(ap, msg);
|
1257
|
+
vfprintf(stderr, msg, ap);
|
1258
|
+
va_end(ap);
|
1259
|
+
} else {
|
1260
|
+
va_start(ap, msg);
|
1261
|
+
if (vsnprintf(str, 999, msg, ap) >= 998) str[999] = 0;
|
1262
|
+
va_end(ap);
|
1263
|
+
|
1264
|
+
rstr = rb_str_new2(str);
|
1265
|
+
rb_funcall2(libxml_xmlRubyErrorProc, id_call, 1, &rstr);
|
1266
|
+
}
|
1267
|
+
}
|
1268
|
+
|
1269
|
+
/* #define RUBY_XML_PARSER_ENABLED_INIT(func, method) \
|
1270
|
+
rb_define_singleton_method(cXMLParser, method, \
|
1271
|
+
ruby_xml_parser_enabled_##func##_q, 0); */
|
1272
|
+
|
1273
|
+
///#include "cbg.c"
|
1274
|
+
///
|
1275
|
+
///VALUE ruby_register_deb(VALUE self) {
|
1276
|
+
/// deb_register_cbg();
|
1277
|
+
/// return(Qtrue);
|
1278
|
+
///}
|
1279
|
+
|
1280
|
+
// Rdoc needs to know
|
1281
|
+
#ifdef RDOC_NEVER_DEFINED
|
1282
|
+
mXML = rb_define_module("XML");
|
1283
|
+
#endif
|
1284
|
+
|
1285
|
+
void
|
1286
|
+
ruby_init_parser(void) {
|
1287
|
+
|
1288
|
+
cXMLParser = rb_define_class_under(mXML, "Parser", rb_cObject);
|
1289
|
+
eXMLParserParseError = rb_define_class_under(cXMLParser, "ParseError",
|
1290
|
+
rb_eRuntimeError);
|
1291
|
+
|
1292
|
+
/* Constants */
|
1293
|
+
rb_define_const(cXMLParser, "LIBXML_VERSION",
|
1294
|
+
rb_str_new2(LIBXML_DOTTED_VERSION));
|
1295
|
+
rb_define_const(cXMLParser, "VERSION", rb_str_new2(RUBY_LIBXML_VERSION));
|
1296
|
+
rb_define_const(cXMLParser, "VERNUM", INT2NUM(RUBY_LIBXML_VERNUM));
|
1297
|
+
|
1298
|
+
/* Question-esqe Class Methods */
|
1299
|
+
/* RDoc won't have them defined by a macro... */
|
1300
|
+
rb_define_singleton_method(cXMLParser, "enabled_automata?",
|
1301
|
+
ruby_xml_parser_enabled_automata_q, 0);
|
1302
|
+
rb_define_singleton_method(cXMLParser, "enabled_c14n?",
|
1303
|
+
ruby_xml_parser_enabled_c14n_q, 0);
|
1304
|
+
rb_define_singleton_method(cXMLParser, "enabled_catalog?",
|
1305
|
+
ruby_xml_parser_enabled_catalog_q, 0);
|
1306
|
+
rb_define_singleton_method(cXMLParser, "enabled_debug?",
|
1307
|
+
ruby_xml_parser_enabled_debug_q, 0);
|
1308
|
+
rb_define_singleton_method(cXMLParser, "enabled_docbook?",
|
1309
|
+
ruby_xml_parser_enabled_docbook_q, 0);
|
1310
|
+
rb_define_singleton_method(cXMLParser, "enabled_ftp?",
|
1311
|
+
ruby_xml_parser_enabled_ftp_q, 0);
|
1312
|
+
rb_define_singleton_method(cXMLParser, "enabled_http?",
|
1313
|
+
ruby_xml_parser_enabled_http_q, 0);
|
1314
|
+
rb_define_singleton_method(cXMLParser, "enabled_html?",
|
1315
|
+
ruby_xml_parser_enabled_html_q, 0);
|
1316
|
+
rb_define_singleton_method(cXMLParser, "enabled_iconv?",
|
1317
|
+
ruby_xml_parser_enabled_iconv_q, 0);
|
1318
|
+
rb_define_singleton_method(cXMLParser, "enabled_memory_debug?",
|
1319
|
+
ruby_xml_parser_enabled_memory_debug_location_q, 0);
|
1320
|
+
rb_define_singleton_method(cXMLParser, "enabled_regexp?",
|
1321
|
+
ruby_xml_parser_enabled_regexp_q, 0);
|
1322
|
+
rb_define_singleton_method(cXMLParser, "enabled_schemas?",
|
1323
|
+
ruby_xml_parser_enabled_schemas_q, 0);
|
1324
|
+
rb_define_singleton_method(cXMLParser, "enabled_thread?",
|
1325
|
+
ruby_xml_parser_enabled_thread_q, 0);
|
1326
|
+
rb_define_singleton_method(cXMLParser, "enabled_unicode?",
|
1327
|
+
ruby_xml_parser_enabled_unicode_q, 0);
|
1328
|
+
rb_define_singleton_method(cXMLParser, "enabled_xinclude?",
|
1329
|
+
ruby_xml_parser_enabled_xinclude_q, 0);
|
1330
|
+
rb_define_singleton_method(cXMLParser, "enabled_xpath?",
|
1331
|
+
ruby_xml_parser_enabled_xpath_q, 0);
|
1332
|
+
rb_define_singleton_method(cXMLParser, "enabled_xpointer?",
|
1333
|
+
ruby_xml_parser_enabled_xpointer_q, 0);
|
1334
|
+
rb_define_singleton_method(cXMLParser, "enabled_zlib?",
|
1335
|
+
ruby_xml_parser_enabled_zlib_q, 0);
|
1336
|
+
|
1337
|
+
/* Other Class Methods */
|
1338
|
+
/// rb_define_singleton_method(cXMLParser, "register_deb",
|
1339
|
+
/// ruby_register_deb, 0);
|
1340
|
+
|
1341
|
+
// TODO Maybe a set of 'xxxx_catalog' aliases might be more Ruby?
|
1342
|
+
rb_define_singleton_method(cXMLParser, "catalog_dump",
|
1343
|
+
ruby_xml_parser_catalog_dump, 0);
|
1344
|
+
rb_define_singleton_method(cXMLParser, "catalog_remove",
|
1345
|
+
ruby_xml_parser_catalog_remove, 1);
|
1346
|
+
rb_define_singleton_method(cXMLParser, "check_lib_versions",
|
1347
|
+
ruby_xml_parser_check_lib_versions, 0);
|
1348
|
+
|
1349
|
+
// TODO should this be debug_entities_q / debug_entities_set?
|
1350
|
+
// should all these default attribute pairs work that way?
|
1351
|
+
rb_define_singleton_method(cXMLParser, "debug_entities",
|
1352
|
+
ruby_xml_parser_debug_entities_get, 0);
|
1353
|
+
rb_define_singleton_method(cXMLParser, "debug_entities=",
|
1354
|
+
ruby_xml_parser_debug_entities_set, 1);
|
1355
|
+
rb_define_singleton_method(cXMLParser, "default_compression",
|
1356
|
+
ruby_xml_parser_default_compression_get, 0);
|
1357
|
+
rb_define_singleton_method(cXMLParser, "default_compression=",
|
1358
|
+
ruby_xml_parser_default_compression_set, 1);
|
1359
|
+
rb_define_singleton_method(cXMLParser, "default_keep_blanks",
|
1360
|
+
ruby_xml_parser_default_keep_blanks_get, 0);
|
1361
|
+
rb_define_singleton_method(cXMLParser, "default_keep_blanks=",
|
1362
|
+
ruby_xml_parser_default_keep_blanks_set, 1);
|
1363
|
+
rb_define_singleton_method(cXMLParser, "default_load_external_dtd",
|
1364
|
+
ruby_xml_parser_default_load_external_dtd_set, 0);
|
1365
|
+
rb_define_singleton_method(cXMLParser, "default_load_external_dtd=",
|
1366
|
+
ruby_xml_parser_default_load_external_dtd_get, 1);
|
1367
|
+
rb_define_singleton_method(cXMLParser, "default_line_numbers",
|
1368
|
+
ruby_xml_parser_default_line_numbers_get, 0);
|
1369
|
+
rb_define_singleton_method(cXMLParser, "default_line_numbers=",
|
1370
|
+
ruby_xml_parser_default_line_numbers_set, 1);
|
1371
|
+
rb_define_singleton_method(cXMLParser, "default_pedantic_parser",
|
1372
|
+
ruby_xml_parser_default_pedantic_parser_get, 0);
|
1373
|
+
rb_define_singleton_method(cXMLParser, "default_pedantic_parser=",
|
1374
|
+
ruby_xml_parser_default_pedantic_parser_set, 1);
|
1375
|
+
rb_define_singleton_method(cXMLParser, "default_substitute_entities",
|
1376
|
+
ruby_xml_parser_default_substitute_entities_get, 0);
|
1377
|
+
rb_define_singleton_method(cXMLParser, "default_substitute_entities=",
|
1378
|
+
ruby_xml_parser_default_substitute_entities_set, 1);
|
1379
|
+
rb_define_singleton_method(cXMLParser, "default_tree_indent_string",
|
1380
|
+
ruby_xml_parser_default_tree_indent_string_get, 0);
|
1381
|
+
rb_define_singleton_method(cXMLParser, "default_tree_indent_string=",
|
1382
|
+
ruby_xml_parser_default_tree_indent_string_set, 1);
|
1383
|
+
rb_define_singleton_method(cXMLParser, "default_validity_checking",
|
1384
|
+
ruby_xml_parser_default_validity_checking_get, 0);
|
1385
|
+
rb_define_singleton_method(cXMLParser, "default_validity_checking=",
|
1386
|
+
ruby_xml_parser_default_validity_checking_set, 1);
|
1387
|
+
rb_define_singleton_method(cXMLParser, "default_warnings",
|
1388
|
+
ruby_xml_parser_default_warnings_get, 0);
|
1389
|
+
rb_define_singleton_method(cXMLParser, "default_warnings=",
|
1390
|
+
ruby_xml_parser_default_warnings_set, 1);
|
1391
|
+
|
1392
|
+
rb_define_singleton_method(cXMLParser, "features", ruby_xml_parser_features, 0);
|
1393
|
+
rb_define_singleton_method(cXMLParser, "file", ruby_xml_parser_new_file, 1);
|
1394
|
+
rb_define_singleton_method(cXMLParser, "indent_tree_output", ruby_xml_parser_indent_tree_output_get, 0);
|
1395
|
+
rb_define_singleton_method(cXMLParser, "indent_tree_output=", ruby_xml_parser_indent_tree_output_set, 1);
|
1396
|
+
rb_define_singleton_method(cXMLParser, "io", ruby_xml_parser_new_io, 1);
|
1397
|
+
rb_define_singleton_method(cXMLParser, "memory_dump",
|
1398
|
+
ruby_xml_parser_memory_dump, 0);
|
1399
|
+
rb_define_singleton_method(cXMLParser, "memory_used",
|
1400
|
+
ruby_xml_parser_memory_used, 0);
|
1401
|
+
rb_define_singleton_method(cXMLParser, "new", ruby_xml_parser_new, 0);
|
1402
|
+
rb_define_singleton_method(cXMLParser, "string", ruby_xml_parser_new_string, 1);
|
1403
|
+
rb_define_singleton_method(cXMLParser, "register_error_handler", ruby_xml_parser_registerErrorHandler, 1);
|
1404
|
+
rb_define_method(cXMLParser, "filename", ruby_xml_parser_filename_get, 0);
|
1405
|
+
rb_define_method(cXMLParser, "filename=", ruby_xml_parser_filename_set, 1);
|
1406
|
+
rb_define_method(cXMLParser, "io", ruby_xml_parser_io_get, 0);
|
1407
|
+
rb_define_method(cXMLParser, "io=", ruby_xml_parser_io_set, 1);
|
1408
|
+
rb_define_method(cXMLParser, "parse", ruby_xml_parser_parse, 0);
|
1409
|
+
rb_define_method(cXMLParser, "parser_context", ruby_xml_parser_parser_context_get, 0);
|
1410
|
+
rb_define_method(cXMLParser, "string", ruby_xml_parser_str_get, 0);
|
1411
|
+
rb_define_method(cXMLParser, "string=", ruby_xml_parser_str_set, 1);
|
1412
|
+
|
1413
|
+
// set up error handling
|
1414
|
+
xmlSetGenericErrorFunc(NULL, libxml_xmlErrorFuncHandler);
|
1415
|
+
xmlThrDefSetGenericErrorFunc(NULL, libxml_xmlErrorFuncHandler);
|
1416
|
+
id_call = rb_intern("call");
|
1417
|
+
}
|