List Info

Thread: export xmlTextReaderSetup() function




export xmlTextReaderSetup() function
user name
2007-01-03 03:07:53
I have a tiny patch that exports xmlTextReaderSetup()
function. I need it for chaining xmlParserInputBuffers
(in-place compression + encryption + ...). W/o this
function, xmlNewTextReader() function is pretty much
useless ;)

Is it OK to check it in CVS?

Thanks,
Aleksey


diff -ur include/libxml/xmlreader.h
include/libxml/xmlreader.h
--- include/libxml/xmlreader.h	2006-01-04 02:36:37.000000000
-0800
+++ include/libxml/xmlreader.h	2007-01-02 18:36:22.115928000
-0800
 -113,9
+113,15 
 	                                         const char *URI);
 XMLPUBFUN xmlTextReaderPtr XMLCALL	
 			xmlNewTextReaderFilename(const char *URI);
+
 XMLPUBFUN void XMLCALL			
 			xmlFreeTextReader	(xmlTextReaderPtr reader);
 
+XMLPUBFUN int XMLCALL			
+            xmlTextReaderSetup(xmlTextReaderPtr reader,
+                   xmlParserInputBufferPtr input, const
char *URL,
+                   const char *encoding, int options);
+
 /*
  * Iterators
  */
diff -ur win32/libxml2.def.src win32/libxml2.def.src
--- win32/libxml2.def.src	2006-02-23 14:04:52.000000000
-0800
+++ win32/libxml2.def.src	2007-01-02 18:33:33.463417600
-0800
 -1949,6
+1949,7 
 xmlTextReaderSetParserProp
 xmlTextReaderSetSchema
 xmlTextReaderSetStructuredErrorHandler
+xmlTextReaderSetup
 xmlTextReaderStandalone
 xmlTextReaderValue
 xmlTextReaderXmlLang
diff -ur xmlreader.c xmlreader.c
--- xmlreader.c	2007-01-02 14:41:43.190924800 -0800
+++ xmlreader.c	2007-01-02 18:31:01.995617600 -0800
 -4855,7
+4855,7 
  * 
  * Returns 0 in case of success and -1 in case of error.
  */
-static int
+int
 xmlTextReaderSetup(xmlTextReaderPtr reader,
                    xmlParserInputBufferPtr input, const
char *URL,
                    const char *encoding, int options)
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
export xmlTextReaderSetup() function
user name
2007-01-03 12:28:34
On Tue, Jan 02, 2007 at 07:07:53PM -0800, Aleksey Sanin
wrote:
> I have a tiny patch that exports xmlTextReaderSetup()
> function. I need it for chaining xmlParserInputBuffers
> (in-place compression + encryption + ...). W/o this
> function, xmlNewTextReader() function is pretty much
> useless ;)

  Can you write an example showing the use then, I'm a bit
lost I admit 

> Is it OK to check it in CVS?

  Yes except that CVs was replaced with SVN (Subversion) and
I didn't
yet tried to look how to hook in the new infrastructure. I
think there are
pages on gnome.org about it to babystep the process 

Daniel

-- 
Red Hat Virtualization group http://redhat.com/v
irtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillardredhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ |
Rpmfind RPM search engine  http://rpmfind.net/
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
export xmlTextReaderSetup() function
user name
2007-01-03 15:18:43
>   Can you write an example showing the use then, I'm a
bit lost I admit 

Sure 
This is pretty long one but ....

xmlTextReaderPtr XmlReaderContext::CreateTextReader(
    	xmlParserInputBufferPtr input_buffer,
	const string& uri)
{
     assert(input_buffer);

     xmlParserInputBufferPtr input_buffer2 = input_buffer;
     if(HasEncryptKey()) {
         assert(!m_base64_input_buffer.get());
         assert(!m_encrypt_input_buffer.get());

         // insert base64 input buffer
         m_base64_input_buffer.reset(new 
Base64DecodeInputBuffer(input_buffer2));
         assert(m_base64_input_buffer.get());

         input_buffer2 = xmlParserInputBufferCreateIO(
                                
XmlInputReadFromBase64EncodeCallback,
                                
XmlInputCloseBase64EncodeCallback,
                                
m_base64_input_buffer.get(),
                                 XML_CHAR_ENCODING_NONE);

         if (input_buffer2 == NULL) {
             C8LOG_THROW(this, LogError, "Failed to
create base64 
decoder input buffer.") {
                 XmlErrorReport(c8log, xmlGetLastError());
             }
         }
         m_input_buffers.push_back(input_buffer2);

         // insert encrypt input buffer
         m_encrypt_input_buffer.reset(new 
EncryptInputBuffer(input_buffer2, GetEncryptKey()));
         assert(m_encrypt_input_buffer.get());

         input_buffer2 = xmlParserInputBufferCreateIO(
                                
XmlInputReadFromEncryptCallback,
                                
XmlInputCloseEncryptCallback,
                                
m_encrypt_input_buffer.get(),
                                 XML_CHAR_ENCODING_NONE);

         if (input_buffer2 == NULL) {
             C8LOG_THROW(this, LogError, "Failed to
create encrypt 
decoder input buffer.") {
                 XmlErrorReport(c8log, xmlGetLastError());
             }
         }
         m_input_buffers.push_back(input_buffer2);
     }

     xmlTextReaderPtr reader =
xmlNewTextReader(input_buffer2, uri.c_str());
     if (reader == NULL) {
         return NULL;
     }

     int options = (m_report_warnings ?
0:XML_PARSE_NOWARNING) |
               XML_PARSE_NOENT |
               XML_PARSE_PEDANTIC |
               XML_PARSE_NOCDATA;

     xmlTextReaderSetup(reader, NULL, uri.c_str(), NULL,
options);

     return reader;
}

>   Yes except that CVs was replaced with SVN
(Subversion) and I didn't
> yet tried to look how to hook in the new
infrastructure. I think there are
> pages on gnome.org about it to babystep the process 
> 

Oh...


Aleksey

_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
export xmlTextReaderSetup() function
user name
2007-01-03 15:49:48
On Wed, Jan 03, 2007 at 07:18:43AM -0800, Aleksey Sanin
wrote:
> >  Can you write an example showing the use then,
I'm a bit lost I admit 
> 
> Sure  This is
pretty long one but ....

  Hum, I see. The unfortunate thing is that you use
xmlParserInputBufferPtr
directly in your APIs, the normal way would be to use
xmlReaderForIO()
and let xmlreader handle it. The point is that
xmlTextReaderSetup() is
relatively 'internal' (the function block is kindof wrong,
misses params)
and the input gets consumed by it. But if really you think
xmlReaderForIO()
ain't proper, then go ahead. My experience is that
xmlParserInputBufferPtr is
complex and will confuse users  

> >  Yes except that CVs was replaced with SVN
(Subversion) and I didn't
> >yet tried to look how to hook in the new
infrastructure. I think there are
> >pages on gnome.org about it to babystep the process

> >
> 
> Oh...

  See http://deve
loper.gnome.org/tools/svn.html
just use
  svn co svn+ssh://alekseysvn.gnome.org/svn/libxml2/trunk libxml2
to get a fresh tree (assuming your login on gnome CVs was
aleksey 

Daniel

-- 
Red Hat Virtualization group http://redhat.com/v
irtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillardredhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ |
Rpmfind RPM search engine  http://rpmfind.net/
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
export xmlTextReaderSetup() function
user name
2007-01-03 19:00:52
 > But if really you think xmlReaderForIO() ain't proper,
then go ahead.
 > My experience is that xmlParserInputBufferPtr is
> complex and will confuse users  

I though about that  The reason
I decided to use
xmlParserInputBufferPtr is that I can get "free"
objects for parsing from memory, files, ...

Then I can add my specific layers (if needed). I agree
that xmlParserInputBufferPtr is not trivial to use
but I think I figured it out  I have the
source
code 
 

>   See http://deve
loper.gnome.org/tools/svn.html
> just use

Thanks! 

Aleksey
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )