[xml] proposal - adding dynamic library support to libxml2




I think there is significant advantage to adding the ability to
dynamically load modules into libxml2 (and also libxslt) that could
register I/O handlers, XSLT extensions, etc from xmllint/xsltproc.  Of
course this is a platform-specific mess but others do it so why can't we
:)

Attached is a proposed framework for accomplishing this along with an
implementation for win32.  I don't have the experience with other
platforms but I would imagine it wouldn't be that hard to plug those in.

For testing purposes I added a parameter to xmllint called --dynalib
that would load the specified library and call an init function.  Prior
to exiting xmllint calls a cleanup function that first calls a cleanup
function in each library (if present) and then unloads the library.  The
cleanup call should probably be moved into xmlCleanupParser() if
accepted.

Also added a parameter WITH_DYNALIB in xmlversion.h[.in] that would be a
compile time option for enabling this, though it will not cause an
problem to complile in the support on platforms that aren't yet
implemented.

A dynalib library would implement the functionality roughly like

#include <libxml/dynalib.h>

int XMLCALL XML_DYNALIB_INIT() {
        /* do whatever you need to do 
}

void XMLCALL XML_DUNALIB_TERM() {
        /* do whatever cleanup you need
}

This is not by any means production code and would likely go through API
changes but I wanted to share early with the list for discussion.

Attached is dynalib.h, dynalib.c, and a minimal patch to xmllint to use
the functionality.  This has been more or less tested on win32 and it
works but like I said this is really discussion code rather than
production code at this point.

Comments?



Attachment: xmllint.diff
Description: Binary data

Attachment: dynalib.c
Description: Binary data

Attachment: dynalib.h
Description: Binary data



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]