Class: LibXML::XML::InputCallbacks
- Inherits:
-
Object
- Object
- LibXML::XML::InputCallbacks
- Defined in:
- ext/libxml/ruby_xml_input_cbg.c,
ext/libxml/ruby_xml_input_cbg.c
Overview
Support for adding custom scheme handlers.
Class Method Summary collapse
-
.add_scheme ⇒ Object
No documentation available.
-
.register ⇒ Object
Register a new set of I/O callback for handling parser input.
-
.remove_scheme ⇒ Object
No documentation available.
Class Method Details
.add_scheme ⇒ Object
No documentation available.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'ext/libxml/ruby_xml_input_cbg.c', line 103
static VALUE input_callbacks_add_scheme(VALUE self, VALUE scheme_name,
VALUE class)
{
ic_scheme *scheme;
Check_Type(scheme_name, T_STRING);
scheme = (ic_scheme*) malloc(sizeof(ic_scheme));
scheme->next_scheme = 0;
scheme->scheme_name = strdup(StringValuePtr(scheme_name)); /* TODO alloc, dealloc */
scheme->name_len = strlen(scheme->scheme_name);
scheme->class = class; /* TODO alloc, dealloc */
//fprintf( stderr, "registered: %s, %d, %s\n", scheme->scheme_name, scheme->name_len, scheme->class );
if (0 == first_scheme)
first_scheme = scheme;
else
{
ic_scheme *pos;
pos = first_scheme;
while (0 != pos->next_scheme)
pos = pos->next_scheme;
pos->next_scheme = scheme;
}
return (Qtrue);
}
|
.register ⇒ Object
Register a new set of I/O callback for handling parser input.
91 92 93 94 95 |
# File 'ext/libxml/ruby_xml_input_cbg.c', line 91
static VALUE input_callbacks_register_input_callbacks()
{
xmlRegisterInputCallbacks(ic_match, ic_open, ic_read, ic_close);
return (Qtrue);
}
|
.remove_scheme ⇒ Object
No documentation available.
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'ext/libxml/ruby_xml_input_cbg.c', line 138
static VALUE input_callbacks_remove_scheme(VALUE self, VALUE scheme_name)
{
char *name;
ic_scheme *save_scheme, *scheme;
Check_Type(scheme_name, T_STRING);
name = StringValuePtr(scheme_name);
if (0 == first_scheme)
return Qfalse;
if (!strncmp(name, first_scheme->scheme_name, first_scheme->name_len))
{
save_scheme = first_scheme->next_scheme;
ruby_xfree(first_scheme->scheme_name);
ruby_xfree(first_scheme);
first_scheme = save_scheme;
return Qtrue;
}
scheme = first_scheme;
while (0 != scheme->next_scheme)
{
if (!strncmp(name, scheme->next_scheme->scheme_name,
scheme->next_scheme->name_len))
{
save_scheme = scheme->next_scheme->next_scheme;
ruby_xfree(scheme->next_scheme->scheme_name);
ruby_xfree(scheme->next_scheme);
scheme->next_scheme = save_scheme;
return Qtrue;
}
scheme = scheme->next_scheme;
}
return Qfalse;
}
|