libxml-ruby 0.9.5-x86-mswin32-60 → 0.9.6-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +28 -0
- data/README +8 -12
- data/ext/libxml/cbg.c +86 -86
- data/ext/libxml/libxml.c +875 -899
- data/ext/libxml/ruby_libxml.h +91 -65
- data/ext/libxml/ruby_xml_attr.c +485 -485
- data/ext/libxml/ruby_xml_attr.h +3 -3
- data/ext/libxml/ruby_xml_attributes.h +2 -2
- data/ext/libxml/ruby_xml_document.c +124 -307
- data/ext/libxml/ruby_xml_document.h +3 -3
- data/ext/libxml/ruby_xml_dtd.c +119 -119
- data/ext/libxml/ruby_xml_dtd.h +2 -2
- data/ext/libxml/ruby_xml_error.c +1 -1
- data/ext/libxml/ruby_xml_error.h +2 -2
- data/ext/libxml/ruby_xml_html_parser.c +119 -119
- data/ext/libxml/ruby_xml_html_parser.h +3 -3
- data/ext/libxml/ruby_xml_input.c +13 -11
- data/ext/libxml/ruby_xml_input.h +3 -3
- data/ext/libxml/ruby_xml_input_cbg.c +197 -197
- data/ext/libxml/ruby_xml_namespace.c +158 -0
- data/ext/libxml/ruby_xml_namespace.h +12 -0
- data/ext/libxml/ruby_xml_namespaces.c +303 -0
- data/ext/libxml/{ruby_xml_ns.h → ruby_xml_namespaces.h} +4 -5
- data/ext/libxml/ruby_xml_node.c +88 -293
- data/ext/libxml/ruby_xml_node.h +4 -4
- data/ext/libxml/ruby_xml_parser.c +152 -152
- data/ext/libxml/ruby_xml_parser.h +3 -3
- data/ext/libxml/ruby_xml_parser_context.c +630 -657
- data/ext/libxml/ruby_xml_parser_context.h +3 -3
- data/ext/libxml/ruby_xml_reader.c +899 -904
- data/ext/libxml/ruby_xml_reader.h +2 -2
- data/ext/libxml/ruby_xml_relaxng.h +2 -2
- data/ext/libxml/ruby_xml_sax_parser.c +175 -175
- data/ext/libxml/ruby_xml_sax_parser.h +3 -3
- data/ext/libxml/ruby_xml_schema.c +165 -165
- data/ext/libxml/ruby_xml_schema.h +2 -2
- data/ext/libxml/ruby_xml_state.h +2 -2
- data/ext/libxml/ruby_xml_xinclude.c +24 -24
- data/ext/libxml/ruby_xml_xinclude.h +3 -3
- data/ext/libxml/ruby_xml_xpath.c +108 -108
- data/ext/libxml/ruby_xml_xpath.h +3 -3
- data/ext/libxml/ruby_xml_xpath_context.c +84 -35
- data/ext/libxml/ruby_xml_xpath_context.h +3 -3
- data/ext/libxml/ruby_xml_xpath_expression.c +5 -7
- data/ext/libxml/ruby_xml_xpath_expression.h +2 -2
- data/ext/libxml/ruby_xml_xpath_object.c +7 -7
- data/ext/libxml/ruby_xml_xpath_object.h +2 -2
- data/ext/libxml/ruby_xml_xpointer.c +107 -107
- data/ext/libxml/ruby_xml_xpointer.h +3 -3
- data/ext/libxml/version.h +2 -2
- data/ext/mingw/libxml_ruby.dll.a +0 -0
- data/ext/mingw/libxml_ruby.so +0 -0
- data/ext/vc/libxml_ruby.vcproj +13 -5
- data/lib/libxml.rb +4 -1
- data/lib/libxml/document.rb +40 -6
- data/lib/libxml/hpricot.rb +76 -76
- data/lib/libxml/namespace.rb +60 -0
- data/lib/libxml/namespaces.rb +36 -0
- data/lib/libxml/node.rb +90 -26
- data/lib/libxml/ns.rb +20 -0
- data/test/model/bands.xml +5 -0
- data/test/tc_attributes.rb +1 -1
- data/test/tc_document.rb +24 -41
- data/test/tc_document_write.rb +87 -115
- data/test/tc_namespace.rb +59 -0
- data/test/tc_namespaces.rb +174 -0
- data/test/tc_node.rb +41 -33
- data/test/tc_node_copy.rb +1 -1
- data/test/tc_node_edit.rb +6 -0
- data/test/tc_node_write.rb +76 -0
- data/test/tc_xinclude.rb +2 -9
- data/test/tc_xpath.rb +38 -11
- data/test/test_suite.rb +3 -1
- metadata +16 -9
- data/ext/libxml/ruby_xml_ns.c +0 -150
- data/test/ets_copy_bug.rb +0 -21
- data/test/ets_copy_bug3.rb +0 -38
- data/test/model/default_validation_bug.rb +0 -0
- data/test/tc_ns.rb +0 -18
@@ -1,9 +1,9 @@
|
|
1
|
-
/* $Id: ruby_xml_html_parser.h
|
1
|
+
/* $Id: ruby_xml_html_parser.h 666 2008-12-07 00:16:50Z cfis $ */
|
2
2
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
4
4
|
|
5
|
-
#ifndef
|
6
|
-
#define
|
5
|
+
#ifndef __RXML_HTML_PARSER__
|
6
|
+
#define __RXML_HTML_PARSER__
|
7
7
|
|
8
8
|
extern int rxml_html_parser_count;
|
9
9
|
extern VALUE cXMLHTMLParser;
|
data/ext/libxml/ruby_xml_input.c
CHANGED
@@ -90,7 +90,7 @@ int rxml_read_callback(void *context, char *buffer, int len)
|
|
90
90
|
* Converts an encoding contstant defined on the XML::Input
|
91
91
|
* class to its text representation.
|
92
92
|
*/
|
93
|
-
VALUE rxml_input_encoding_to_s(VALUE
|
93
|
+
VALUE rxml_input_encoding_to_s(VALUE klass, VALUE encoding)
|
94
94
|
{
|
95
95
|
char* encodingStr = NULL;
|
96
96
|
|
@@ -168,6 +168,8 @@ VALUE rxml_input_encoding_to_s(VALUE self, VALUE encoding)
|
|
168
168
|
case XML_CHAR_ENCODING_ASCII:
|
169
169
|
encodingStr = "ASCII";
|
170
170
|
break;
|
171
|
+
default:
|
172
|
+
rb_raise(rb_eArgError, "Unknown encoding.");
|
171
173
|
}
|
172
174
|
|
173
175
|
return rb_str_new2(encodingStr);
|
@@ -181,6 +183,7 @@ VALUE rxml_input_encoding_to_s(VALUE self, VALUE encoding)
|
|
181
183
|
*/
|
182
184
|
static VALUE rxml_input_initialize(VALUE self)
|
183
185
|
{
|
186
|
+
rb_ivar_set(self, BASE_URL_ATTR, Qnil);
|
184
187
|
rb_ivar_set(self, ENCODING_ATTR, INT2NUM(XML_CHAR_ENCODING_UTF8));
|
185
188
|
return self;
|
186
189
|
}
|
@@ -285,21 +288,20 @@ void ruby_init_xml_input(void)
|
|
285
288
|
READ_METHOD = rb_intern("read");
|
286
289
|
|
287
290
|
cXMLInput = rb_define_class_under(mXML, "Input", rb_cObject);
|
288
|
-
rb_define_singleton_method(cXMLInput, "encoding_to_s",
|
289
|
-
rxml_input_encoding_to_s, 1);
|
291
|
+
rb_define_singleton_method(cXMLInput, "encoding_to_s", rxml_input_encoding_to_s, 1);
|
290
292
|
|
291
293
|
rb_define_const(cXMLInput, "UNDEFINED", INT2NUM(XPATH_UNDEFINED));
|
292
294
|
rb_define_const(cXMLInput, "ERROR", INT2NUM(XML_CHAR_ENCODING_ERROR)); /* No char encoding detected */
|
293
295
|
rb_define_const(cXMLInput, "NONE", INT2NUM(XML_CHAR_ENCODING_NONE)); /* No char encoding detected */
|
294
|
-
rb_define_const(cXMLInput, "
|
295
|
-
rb_define_const(cXMLInput, "
|
296
|
-
rb_define_const(cXMLInput, "
|
297
|
-
rb_define_const(cXMLInput, "
|
298
|
-
rb_define_const(cXMLInput, "
|
296
|
+
rb_define_const(cXMLInput, "UTF_8", INT2NUM(XML_CHAR_ENCODING_UTF8)); /* UTF-8 */
|
297
|
+
rb_define_const(cXMLInput, "UTF_16LE", INT2NUM(XML_CHAR_ENCODING_UTF16LE)); /* UTF-16 little endian */
|
298
|
+
rb_define_const(cXMLInput, "UTF_16BE", INT2NUM(XML_CHAR_ENCODING_UTF16BE)); /* UTF-16 big endian */
|
299
|
+
rb_define_const(cXMLInput, "UCS_4LE", INT2NUM(XML_CHAR_ENCODING_UCS4LE)); /* UCS-4 little endian */
|
300
|
+
rb_define_const(cXMLInput, "UCS_4BE", INT2NUM(XML_CHAR_ENCODING_UCS4BE)); /* UCS-4 big endian */
|
299
301
|
rb_define_const(cXMLInput, "EBCDIC", INT2NUM(XML_CHAR_ENCODING_EBCDIC)); /* EBCDIC uh! */
|
300
|
-
rb_define_const(cXMLInput, "
|
301
|
-
rb_define_const(cXMLInput, "
|
302
|
-
rb_define_const(cXMLInput, "
|
302
|
+
rb_define_const(cXMLInput, "UCS_4_2143", INT2NUM(XML_CHAR_ENCODING_UCS4_2143)); /* UCS-4 unusual ordering */
|
303
|
+
rb_define_const(cXMLInput, "UCS_4_3412", INT2NUM(XML_CHAR_ENCODING_UCS4_3412)); /* UCS-4 unusual ordering */
|
304
|
+
rb_define_const(cXMLInput, "UCS_2", INT2NUM(XML_CHAR_ENCODING_UCS2)); /* UCS-2 */
|
303
305
|
rb_define_const(cXMLInput, "ISO_8859_1", INT2NUM(XML_CHAR_ENCODING_8859_1)); /* ISO-8859-1 ISO Latin 1 */
|
304
306
|
rb_define_const(cXMLInput, "ISO_8859_2", INT2NUM(XML_CHAR_ENCODING_8859_2)); /* ISO-8859-2 ISO Latin 2 */
|
305
307
|
rb_define_const(cXMLInput, "ISO_8859_3", INT2NUM(XML_CHAR_ENCODING_8859_3)); /* ISO-8859-3 */
|
data/ext/libxml/ruby_xml_input.h
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
4
4
|
|
5
|
-
#ifndef
|
6
|
-
#define
|
5
|
+
#ifndef __RXML_INPUT__
|
6
|
+
#define __RXML_INPUT__
|
7
7
|
|
8
8
|
extern VALUE cXMLInput;
|
9
9
|
|
@@ -15,6 +15,6 @@ extern ID STRING_ATTR;
|
|
15
15
|
|
16
16
|
void ruby_init_xml_input();
|
17
17
|
int rxml_read_callback(void *context, char *buffer, int len);
|
18
|
-
VALUE rxml_input_encoding_to_s(VALUE
|
18
|
+
VALUE rxml_input_encoding_to_s(VALUE klass, VALUE encoding);
|
19
19
|
|
20
20
|
#endif
|
@@ -1,197 +1,197 @@
|
|
1
|
-
/* Author: Martin Povolny (xpovolny@fi.muni.cz) */
|
2
|
-
|
3
|
-
#include "ruby_libxml.h"
|
4
|
-
#include "ruby_xml_input_cbg.h"
|
5
|
-
|
6
|
-
/* Document-class: LibXML::XML::InputCallbacks
|
7
|
-
*
|
8
|
-
* Support for adding custom scheme handlers. */
|
9
|
-
|
10
|
-
static ic_scheme *first_scheme = 0;
|
11
|
-
|
12
|
-
int ic_match(char const *filename)
|
13
|
-
{
|
14
|
-
ic_scheme *scheme;
|
15
|
-
|
16
|
-
//fprintf( stderr, "ic_match: %s\n", filename );
|
17
|
-
|
18
|
-
scheme = first_scheme;
|
19
|
-
while (0 != scheme)
|
20
|
-
{
|
21
|
-
if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST scheme->scheme_name, scheme->name_len))
|
22
|
-
{
|
23
|
-
return 1;
|
24
|
-
}
|
25
|
-
scheme = scheme->next_scheme;
|
26
|
-
}
|
27
|
-
return 0;
|
28
|
-
}
|
29
|
-
|
30
|
-
void* ic_open(char const *filename)
|
31
|
-
{
|
32
|
-
ic_doc_context *ic_doc;
|
33
|
-
ic_scheme *scheme;
|
34
|
-
VALUE res;
|
35
|
-
|
36
|
-
scheme = first_scheme;
|
37
|
-
while (0 != scheme)
|
38
|
-
{
|
39
|
-
if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST scheme->scheme_name, scheme->name_len))
|
40
|
-
{
|
41
|
-
ic_doc = (ic_doc_context*) malloc(sizeof(ic_doc_context));
|
42
|
-
|
43
|
-
res = rb_funcall(scheme->class, rb_intern("document_query"), 1,
|
44
|
-
rb_str_new2(filename));
|
45
|
-
|
46
|
-
ic_doc->buffer = strdup(StringValuePtr(res));
|
47
|
-
|
48
|
-
ic_doc->bpos = ic_doc->buffer;
|
49
|
-
ic_doc->remaining = strlen(ic_doc->buffer);
|
50
|
-
return ic_doc;
|
51
|
-
}
|
52
|
-
scheme = scheme->next_scheme;
|
53
|
-
}
|
54
|
-
return 0;
|
55
|
-
}
|
56
|
-
|
57
|
-
int ic_read(void *context, char *buffer, int len)
|
58
|
-
{
|
59
|
-
ic_doc_context *ic_doc;
|
60
|
-
int ret_len;
|
61
|
-
ic_doc = (ic_doc_context*) context;
|
62
|
-
|
63
|
-
if (len >= ic_doc->remaining)
|
64
|
-
{
|
65
|
-
ret_len = ic_doc->remaining;
|
66
|
-
}
|
67
|
-
else
|
68
|
-
{
|
69
|
-
ret_len = len;
|
70
|
-
}
|
71
|
-
ic_doc->remaining -= ret_len;
|
72
|
-
strncpy(buffer, ic_doc->bpos, ret_len);
|
73
|
-
ic_doc->bpos += ret_len;
|
74
|
-
|
75
|
-
return ret_len;
|
76
|
-
}
|
77
|
-
|
78
|
-
int ic_close(void *context)
|
79
|
-
{
|
80
|
-
ruby_xfree(((ic_doc_context*) context)->buffer);
|
81
|
-
ruby_xfree(context);
|
82
|
-
return 1;
|
83
|
-
}
|
84
|
-
|
85
|
-
/*
|
86
|
-
* call-seq:
|
87
|
-
* register
|
88
|
-
*
|
89
|
-
* Register a new set of I/O callback for handling parser input.
|
90
|
-
*/
|
91
|
-
static VALUE input_callbacks_register_input_callbacks()
|
92
|
-
{
|
93
|
-
xmlRegisterInputCallbacks(ic_match, ic_open, ic_read, ic_close);
|
94
|
-
return (Qtrue);
|
95
|
-
}
|
96
|
-
|
97
|
-
/*
|
98
|
-
* call-seq:
|
99
|
-
* add_scheme
|
100
|
-
*
|
101
|
-
* No documentation available.
|
102
|
-
*/
|
103
|
-
static VALUE input_callbacks_add_scheme(VALUE self, VALUE scheme_name,
|
104
|
-
VALUE class)
|
105
|
-
{
|
106
|
-
ic_scheme *scheme;
|
107
|
-
|
108
|
-
Check_Type(scheme_name, T_STRING);
|
109
|
-
|
110
|
-
scheme = (ic_scheme*) malloc(sizeof(ic_scheme));
|
111
|
-
scheme->next_scheme = 0;
|
112
|
-
scheme->scheme_name = strdup(StringValuePtr(scheme_name)); /* TODO alloc, dealloc */
|
113
|
-
scheme->name_len = strlen(scheme->scheme_name);
|
114
|
-
scheme->class = class; /* TODO alloc, dealloc */
|
115
|
-
|
116
|
-
//fprintf( stderr, "registered: %s, %d, %s\n", scheme->scheme_name, scheme->name_len, scheme->class );
|
117
|
-
|
118
|
-
if (0 == first_scheme)
|
119
|
-
first_scheme = scheme;
|
120
|
-
else
|
121
|
-
{
|
122
|
-
ic_scheme *pos;
|
123
|
-
pos = first_scheme;
|
124
|
-
while (0 != pos->next_scheme)
|
125
|
-
pos = pos->next_scheme;
|
126
|
-
pos->next_scheme = scheme;
|
127
|
-
}
|
128
|
-
|
129
|
-
return (Qtrue);
|
130
|
-
}
|
131
|
-
|
132
|
-
/*
|
133
|
-
* call-seq:
|
134
|
-
* remove_scheme
|
135
|
-
*
|
136
|
-
* No documentation available.
|
137
|
-
*/
|
138
|
-
static VALUE input_callbacks_remove_scheme(VALUE self, VALUE scheme_name)
|
139
|
-
{
|
140
|
-
char *name;
|
141
|
-
ic_scheme *save_scheme, *scheme;
|
142
|
-
|
143
|
-
Check_Type(scheme_name, T_STRING);
|
144
|
-
name = StringValuePtr(scheme_name);
|
145
|
-
|
146
|
-
if (0 == first_scheme)
|
147
|
-
return Qfalse;
|
148
|
-
|
149
|
-
if (!strncmp(name, first_scheme->scheme_name, first_scheme->name_len))
|
150
|
-
{
|
151
|
-
save_scheme = first_scheme->next_scheme;
|
152
|
-
|
153
|
-
ruby_xfree(first_scheme->scheme_name);
|
154
|
-
ruby_xfree(first_scheme);
|
155
|
-
|
156
|
-
first_scheme = save_scheme;
|
157
|
-
return Qtrue;
|
158
|
-
}
|
159
|
-
|
160
|
-
scheme = first_scheme;
|
161
|
-
while (0 != scheme->next_scheme)
|
162
|
-
{
|
163
|
-
if (!strncmp(name, scheme->next_scheme->scheme_name,
|
164
|
-
scheme->next_scheme->name_len))
|
165
|
-
{
|
166
|
-
save_scheme = scheme->next_scheme->next_scheme;
|
167
|
-
|
168
|
-
ruby_xfree(scheme->next_scheme->scheme_name);
|
169
|
-
ruby_xfree(scheme->next_scheme);
|
170
|
-
|
171
|
-
scheme->next_scheme = save_scheme;
|
172
|
-
return Qtrue;
|
173
|
-
}
|
174
|
-
scheme = scheme->next_scheme;
|
175
|
-
}
|
176
|
-
return Qfalse;
|
177
|
-
}
|
178
|
-
|
179
|
-
// Rdoc needs to know
|
180
|
-
#ifdef RDOC_NEVER_DEFINED
|
181
|
-
mLibXML = rb_define_module("LibXML");
|
182
|
-
mXML = rb_define_module_under(mLibXML, "XML");
|
183
|
-
#endif
|
184
|
-
|
185
|
-
void ruby_init_input_callbacks(void)
|
186
|
-
{
|
187
|
-
VALUE cInputCallbacks;
|
188
|
-
cInputCallbacks = rb_define_class_under(mXML, "InputCallbacks", rb_cObject);
|
189
|
-
|
190
|
-
/* Class Methods */
|
191
|
-
rb_define_singleton_method(cInputCallbacks, "register",
|
192
|
-
input_callbacks_register_input_callbacks, 0);
|
193
|
-
rb_define_singleton_method(cInputCallbacks, "add_scheme",
|
194
|
-
input_callbacks_add_scheme, 2);
|
195
|
-
rb_define_singleton_method(cInputCallbacks, "remove_scheme",
|
196
|
-
input_callbacks_remove_scheme, 1);
|
197
|
-
}
|
1
|
+
/* Author: Martin Povolny (xpovolny@fi.muni.cz) */
|
2
|
+
|
3
|
+
#include "ruby_libxml.h"
|
4
|
+
#include "ruby_xml_input_cbg.h"
|
5
|
+
|
6
|
+
/* Document-class: LibXML::XML::InputCallbacks
|
7
|
+
*
|
8
|
+
* Support for adding custom scheme handlers. */
|
9
|
+
|
10
|
+
static ic_scheme *first_scheme = 0;
|
11
|
+
|
12
|
+
int ic_match(char const *filename)
|
13
|
+
{
|
14
|
+
ic_scheme *scheme;
|
15
|
+
|
16
|
+
//fprintf( stderr, "ic_match: %s\n", filename );
|
17
|
+
|
18
|
+
scheme = first_scheme;
|
19
|
+
while (0 != scheme)
|
20
|
+
{
|
21
|
+
if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST scheme->scheme_name, scheme->name_len))
|
22
|
+
{
|
23
|
+
return 1;
|
24
|
+
}
|
25
|
+
scheme = scheme->next_scheme;
|
26
|
+
}
|
27
|
+
return 0;
|
28
|
+
}
|
29
|
+
|
30
|
+
void* ic_open(char const *filename)
|
31
|
+
{
|
32
|
+
ic_doc_context *ic_doc;
|
33
|
+
ic_scheme *scheme;
|
34
|
+
VALUE res;
|
35
|
+
|
36
|
+
scheme = first_scheme;
|
37
|
+
while (0 != scheme)
|
38
|
+
{
|
39
|
+
if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST scheme->scheme_name, scheme->name_len))
|
40
|
+
{
|
41
|
+
ic_doc = (ic_doc_context*) malloc(sizeof(ic_doc_context));
|
42
|
+
|
43
|
+
res = rb_funcall(scheme->class, rb_intern("document_query"), 1,
|
44
|
+
rb_str_new2(filename));
|
45
|
+
|
46
|
+
ic_doc->buffer = strdup(StringValuePtr(res));
|
47
|
+
|
48
|
+
ic_doc->bpos = ic_doc->buffer;
|
49
|
+
ic_doc->remaining = strlen(ic_doc->buffer);
|
50
|
+
return ic_doc;
|
51
|
+
}
|
52
|
+
scheme = scheme->next_scheme;
|
53
|
+
}
|
54
|
+
return 0;
|
55
|
+
}
|
56
|
+
|
57
|
+
int ic_read(void *context, char *buffer, int len)
|
58
|
+
{
|
59
|
+
ic_doc_context *ic_doc;
|
60
|
+
int ret_len;
|
61
|
+
ic_doc = (ic_doc_context*) context;
|
62
|
+
|
63
|
+
if (len >= ic_doc->remaining)
|
64
|
+
{
|
65
|
+
ret_len = ic_doc->remaining;
|
66
|
+
}
|
67
|
+
else
|
68
|
+
{
|
69
|
+
ret_len = len;
|
70
|
+
}
|
71
|
+
ic_doc->remaining -= ret_len;
|
72
|
+
strncpy(buffer, ic_doc->bpos, ret_len);
|
73
|
+
ic_doc->bpos += ret_len;
|
74
|
+
|
75
|
+
return ret_len;
|
76
|
+
}
|
77
|
+
|
78
|
+
int ic_close(void *context)
|
79
|
+
{
|
80
|
+
ruby_xfree(((ic_doc_context*) context)->buffer);
|
81
|
+
ruby_xfree(context);
|
82
|
+
return 1;
|
83
|
+
}
|
84
|
+
|
85
|
+
/*
|
86
|
+
* call-seq:
|
87
|
+
* register
|
88
|
+
*
|
89
|
+
* Register a new set of I/O callback for handling parser input.
|
90
|
+
*/
|
91
|
+
static VALUE input_callbacks_register_input_callbacks()
|
92
|
+
{
|
93
|
+
xmlRegisterInputCallbacks(ic_match, ic_open, ic_read, ic_close);
|
94
|
+
return (Qtrue);
|
95
|
+
}
|
96
|
+
|
97
|
+
/*
|
98
|
+
* call-seq:
|
99
|
+
* add_scheme
|
100
|
+
*
|
101
|
+
* No documentation available.
|
102
|
+
*/
|
103
|
+
static VALUE input_callbacks_add_scheme(VALUE self, VALUE scheme_name,
|
104
|
+
VALUE class)
|
105
|
+
{
|
106
|
+
ic_scheme *scheme;
|
107
|
+
|
108
|
+
Check_Type(scheme_name, T_STRING);
|
109
|
+
|
110
|
+
scheme = (ic_scheme*) malloc(sizeof(ic_scheme));
|
111
|
+
scheme->next_scheme = 0;
|
112
|
+
scheme->scheme_name = strdup(StringValuePtr(scheme_name)); /* TODO alloc, dealloc */
|
113
|
+
scheme->name_len = strlen(scheme->scheme_name);
|
114
|
+
scheme->class = class; /* TODO alloc, dealloc */
|
115
|
+
|
116
|
+
//fprintf( stderr, "registered: %s, %d, %s\n", scheme->scheme_name, scheme->name_len, scheme->class );
|
117
|
+
|
118
|
+
if (0 == first_scheme)
|
119
|
+
first_scheme = scheme;
|
120
|
+
else
|
121
|
+
{
|
122
|
+
ic_scheme *pos;
|
123
|
+
pos = first_scheme;
|
124
|
+
while (0 != pos->next_scheme)
|
125
|
+
pos = pos->next_scheme;
|
126
|
+
pos->next_scheme = scheme;
|
127
|
+
}
|
128
|
+
|
129
|
+
return (Qtrue);
|
130
|
+
}
|
131
|
+
|
132
|
+
/*
|
133
|
+
* call-seq:
|
134
|
+
* remove_scheme
|
135
|
+
*
|
136
|
+
* No documentation available.
|
137
|
+
*/
|
138
|
+
static VALUE input_callbacks_remove_scheme(VALUE self, VALUE scheme_name)
|
139
|
+
{
|
140
|
+
char *name;
|
141
|
+
ic_scheme *save_scheme, *scheme;
|
142
|
+
|
143
|
+
Check_Type(scheme_name, T_STRING);
|
144
|
+
name = StringValuePtr(scheme_name);
|
145
|
+
|
146
|
+
if (0 == first_scheme)
|
147
|
+
return Qfalse;
|
148
|
+
|
149
|
+
if (!strncmp(name, first_scheme->scheme_name, first_scheme->name_len))
|
150
|
+
{
|
151
|
+
save_scheme = first_scheme->next_scheme;
|
152
|
+
|
153
|
+
ruby_xfree(first_scheme->scheme_name);
|
154
|
+
ruby_xfree(first_scheme);
|
155
|
+
|
156
|
+
first_scheme = save_scheme;
|
157
|
+
return Qtrue;
|
158
|
+
}
|
159
|
+
|
160
|
+
scheme = first_scheme;
|
161
|
+
while (0 != scheme->next_scheme)
|
162
|
+
{
|
163
|
+
if (!strncmp(name, scheme->next_scheme->scheme_name,
|
164
|
+
scheme->next_scheme->name_len))
|
165
|
+
{
|
166
|
+
save_scheme = scheme->next_scheme->next_scheme;
|
167
|
+
|
168
|
+
ruby_xfree(scheme->next_scheme->scheme_name);
|
169
|
+
ruby_xfree(scheme->next_scheme);
|
170
|
+
|
171
|
+
scheme->next_scheme = save_scheme;
|
172
|
+
return Qtrue;
|
173
|
+
}
|
174
|
+
scheme = scheme->next_scheme;
|
175
|
+
}
|
176
|
+
return Qfalse;
|
177
|
+
}
|
178
|
+
|
179
|
+
// Rdoc needs to know
|
180
|
+
#ifdef RDOC_NEVER_DEFINED
|
181
|
+
mLibXML = rb_define_module("LibXML");
|
182
|
+
mXML = rb_define_module_under(mLibXML, "XML");
|
183
|
+
#endif
|
184
|
+
|
185
|
+
void ruby_init_input_callbacks(void)
|
186
|
+
{
|
187
|
+
VALUE cInputCallbacks;
|
188
|
+
cInputCallbacks = rb_define_class_under(mXML, "InputCallbacks", rb_cObject);
|
189
|
+
|
190
|
+
/* Class Methods */
|
191
|
+
rb_define_singleton_method(cInputCallbacks, "register",
|
192
|
+
input_callbacks_register_input_callbacks, 0);
|
193
|
+
rb_define_singleton_method(cInputCallbacks, "add_scheme",
|
194
|
+
input_callbacks_add_scheme, 2);
|
195
|
+
rb_define_singleton_method(cInputCallbacks, "remove_scheme",
|
196
|
+
input_callbacks_remove_scheme, 1);
|
197
|
+
}
|