Commit be076e9b authored by Daniel Veillard's avatar Daniel Veillard

applied patch from Bjorn Reese, plus some cleanups fixed the stylesheet to

* xmlmodule.c include/libxml/xmlmodule.h: applied patch from
  Bjorn Reese, plus some cleanups
* elfgcchack.h doc/elfgcchack.xsl: fixed the stylesheet to
  add the new header
* doc/* testapi.c: regenerated the API
Daniel
parent f6b71bd1
Tue Jan 4 21:16:05 CET 2005 Daniel Veillard <daniel@veillard.com>
* xmlmodule.c include/libxml/xmlmodule.h: applied patch from
Bjorn Reese, plus some cleanups
* elfgcchack.h doc/elfgcchack.xsl: fixed the stylesheet to
add the new header
* doc/* testapi.c: regenerated the API
Tue Jan 4 18:47:19 CET 2005 Daniel Veillard <daniel@veillard.com>
* configure.in: making DSO support an option
......
......@@ -109,7 +109,6 @@ A:link, A:visited, A:active { text-decoration: underline }
<a href="html/libxml-xmlmemory.html#xmlMallocLoc">xmlMallocLoc</a><br />
<a href="html/libxml-xmlmemory.html#xmlMemMalloc">xmlMemMalloc</a><br />
<a href="html/libxml-xmlmemory.html#xmlMemRealloc">xmlMemRealloc</a><br />
<a href="html/libxml-xmlmodule.html#xmlModuleSymbol">xmlModuleSymbol</a><br />
<a href="html/libxml-nanoftp.html#xmlNanoFTPConnectTo">xmlNanoFTPConnectTo</a><br />
<a href="html/libxml-nanoftp.html#xmlNanoFTPNewCtxt">xmlNanoFTPNewCtxt</a><br />
<a href="html/libxml-nanoftp.html#xmlNanoFTPOpen">xmlNanoFTPOpen</a><br />
......
......@@ -834,7 +834,8 @@ A:link, A:visited, A:active { text-decoration: underline }
<a href="html/libxml-xpathInternals.html#xmlXPathRegisterVariableLookup">xmlXPathRegisterVariableLookup</a><br />
<a href="html/libxml-xpath.html#xmlXPathVariableLookupFunc">xmlXPathVariableLookupFunc</a><br />
<a href="html/libxml-xpathInternals.html#xmlXPathWrapExternal">xmlXPathWrapExternal</a><br />
</p><h2>Type void **:</h2><p><a href="html/libxml-relaxng.html#xmlRelaxNGGetParserErrors">xmlRelaxNGGetParserErrors</a><br />
</p><h2>Type void **:</h2><p><a href="html/libxml-xmlmodule.html#xmlModuleSymbol">xmlModuleSymbol</a><br />
<a href="html/libxml-relaxng.html#xmlRelaxNGGetParserErrors">xmlRelaxNGGetParserErrors</a><br />
<a href="html/libxml-relaxng.html#xmlRelaxNGGetValidErrors">xmlRelaxNGGetValidErrors</a><br />
<a href="html/libxml-xmlschemas.html#xmlSchemaGetParserErrors">xmlSchemaGetParserErrors</a><br />
<a href="html/libxml-xmlschemas.html#xmlSchemaGetValidErrors">xmlSchemaGetValidErrors</a><br />
......
......@@ -60,6 +60,7 @@
#include "libxml/xpath.h"
#include "libxml/xpathInternals.h"
#include "libxml/xpointer.h"
#include "libxml/xmlmodule.h"
/* special hot spot not exported ones */
......
......@@ -16,7 +16,7 @@ The content of this structure is not made public by the API.
</pre><pre class="programlisting">int <a href="#xmlModuleClose">xmlModuleClose</a> (<a href="libxml-xmlmodule.html#xmlModulePtr">xmlModulePtr</a> module)</pre>
<pre class="programlisting">int <a href="#xmlModuleFree">xmlModuleFree</a> (<a href="libxml-xmlmodule.html#xmlModulePtr">xmlModulePtr</a> module)</pre>
<pre class="programlisting"><a href="libxml-xmlmodule.html#xmlModulePtr">xmlModulePtr</a> <a href="#xmlModuleOpen">xmlModuleOpen</a> (const char * name)</pre>
<pre class="programlisting">void * <a href="#xmlModuleSymbol">xmlModuleSymbol</a> (<a href="libxml-xmlmodule.html#xmlModulePtr">xmlModulePtr</a> module, <br /> const char * name)</pre>
<pre class="programlisting">int <a href="#xmlModuleSymbol">xmlModuleSymbol</a> (<a href="libxml-xmlmodule.html#xmlModulePtr">xmlModulePtr</a> module, <br /> const char * name, <br /> void ** symbol)</pre>
<h2>Description</h2>
<h3><a name="xmlModule" id="xmlModule">Structure xmlModule</a></h3><pre class="programlisting">Structure xmlModule<br />struct _xmlModule {
The content of this structure is not made public by the API.
......@@ -26,6 +26,6 @@ The content of this structure is not made public by the API.
</pre><p>The free operations free the data associated to the module but does not unload the associated shared library which may still be in use.</p>
<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>module</tt></i>:</span></td><td>the module handle</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>0 in case of success, -1 in case of argument error</td></tr></tbody></table></div><h3><a name="xmlModuleOpen" id="xmlModuleOpen"></a>Function: xmlModuleOpen</h3><pre class="programlisting"><a href="libxml-xmlmodule.html#xmlModulePtr">xmlModulePtr</a> xmlModuleOpen (const char * name)<br />
</pre><p>Opens a module/shared library given its name or path</p>
<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>name</tt></i>:</span></td><td>the module name</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a handle for the module or NULL in case of error</td></tr></tbody></table></div><h3><a name="xmlModuleSymbol" id="xmlModuleSymbol"></a>Function: xmlModuleSymbol</h3><pre class="programlisting">void * xmlModuleSymbol (<a href="libxml-xmlmodule.html#xmlModulePtr">xmlModulePtr</a> module, <br /> const char * name)<br />
<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>name</tt></i>:</span></td><td>the module name</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>a handle for the module or NULL in case of error</td></tr></tbody></table></div><h3><a name="xmlModuleSymbol" id="xmlModuleSymbol"></a>Function: xmlModuleSymbol</h3><pre class="programlisting">int xmlModuleSymbol (<a href="libxml-xmlmodule.html#xmlModulePtr">xmlModulePtr</a> module, <br /> const char * name, <br /> void ** symbol)<br />
</pre><p>Lookup for a symbol address in the given module</p>
<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>module</tt></i>:</span></td><td>the module</td></tr><tr><td><span class="term"><i><tt>name</tt></i>:</span></td><td>the name of the symbol</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>the pointer to the symbol object or NULL in case of error</td></tr></tbody></table></div><p><a href="../bugs.html">Daniel Veillard</a></p></td></tr></table></td></tr></table></td></tr></table></td></tr></table></td></tr></table></body></html>
<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>module</tt></i>:</span></td><td>the module</td></tr><tr><td><span class="term"><i><tt>name</tt></i>:</span></td><td>the name of the symbol</td></tr><tr><td><span class="term"><i><tt>symbol</tt></i>:</span></td><td>the resulting symbol address</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>0 if the symbol was found, or -1 in case of error</td></tr></tbody></table></div><p><a href="../bugs.html">Daniel Veillard</a></p></td></tr></table></td></tr></table></td></tr></table></td></tr></table></td></tr></table></body></html>
......@@ -10077,9 +10077,10 @@ actually an xmlCharEncoding'/>
<function name='xmlModuleSymbol' file='xmlmodule'>
<cond>defined(LIBXML_MODULES_ENABLED)</cond>
<info>Lookup for a symbol address in the given module</info>
<return type='void *' info='the pointer to the symbol object or NULL in case of error'/>
<return type='int' info='0 if the symbol was found, or -1 in case of error'/>
<arg name='module' type='xmlModulePtr' info='the module'/>
<arg name='name' type='const char *' info='the name of the symbol'/>
<arg name='symbol' type='void **' info='the resulting symbol address'/>
</function>
<function name='xmlMutexLock' file='threads'>
<info>xmlMutexLock() is used to lock a libxml2 token.</info>
......@@ -6686,7 +6686,6 @@
<ref name='xmlMallocLoc'/>
<ref name='xmlMemMalloc'/>
<ref name='xmlMemRealloc'/>
<ref name='xmlModuleSymbol'/>
<ref name='xmlNanoFTPConnectTo'/>
<ref name='xmlNanoFTPNewCtxt'/>
<ref name='xmlNanoFTPOpen'/>
......@@ -8179,6 +8178,7 @@
<ref name='xmlXPathWrapExternal'/>
</type>
<type name='void **'>
<ref name='xmlModuleSymbol'/>
<ref name='xmlRelaxNGGetParserErrors'/>
<ref name='xmlRelaxNGGetValidErrors'/>
<ref name='xmlSchemaGetParserErrors'/>
This diff is collapsed.
......@@ -37,7 +37,7 @@ extern "C" {
XMLPUBFUN xmlModulePtr XMLCALL xmlModuleOpen (const char *filename);
XMLPUBFUN void* XMLCALL xmlModuleSymbol (xmlModulePtr module, const char* name);
XMLPUBFUN int XMLCALL xmlModuleSymbol (xmlModulePtr module, const char* name, void **result);
XMLPUBFUN int XMLCALL xmlModuleClose (xmlModulePtr module);
......
......@@ -35,12 +35,22 @@ int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
hello_world_t hello_world = NULL;
/* build the module filename, and confirm the module exists */
xmlStrPrintf(filename, sizeof(filename), "%s/testdso%s", (const xmlChar*)MODULE_PATH, (const xmlChar*)LIBXML_MODULE_EXTENSION);
xmlStrPrintf(filename, sizeof(filename), "%s/testdso%s",
(const xmlChar*)MODULE_PATH,
(const xmlChar*)LIBXML_MODULE_EXTENSION);
module = xmlModuleOpen((const char*)filename);
if (module)
{
hello_world = (hello_world_t)xmlModuleSymbol(module, "hello_world");
if (xmlModuleSymbol(module, "hello_world", (void **) &hello_world)) {
fprintf(stderr, "Failure to lookup\n");
return(1);
}
if (hello_world == NULL) {
fprintf(stderr, "Lookup returned NULL\n");
return(1);
}
(*hello_world)();
xmlModuleClose(module);
......
......@@ -28275,23 +28275,28 @@ test_xmlModuleSymbol(void) {
#if defined(LIBXML_MODULES_ENABLED)
int mem_base;
void * ret_val;
int ret_val;
xmlModulePtr module; /* the module */
int n_module;
char * name; /* the name of the symbol */
int n_name;
void ** symbol; /* the resulting symbol address */
int n_symbol;
for (n_module = 0;n_module < gen_nb_xmlModulePtr;n_module++) {
for (n_name = 0;n_name < gen_nb_const_char_ptr;n_name++) {
for (n_symbol = 0;n_symbol < gen_nb_void_ptr_ptr;n_symbol++) {
mem_base = xmlMemBlocks();
module = gen_xmlModulePtr(n_module, 0);
name = gen_const_char_ptr(n_name, 1);
symbol = gen_void_ptr_ptr(n_symbol, 2);
ret_val = xmlModuleSymbol(module, (const char *)name);
desret_void_ptr(ret_val);
ret_val = xmlModuleSymbol(module, (const char *)name, symbol);
desret_int(ret_val);
call_tests++;
des_xmlModulePtr(n_module, module, 0);
des_const_char_ptr(n_name, (const char *)name, 1);
des_void_ptr_ptr(n_symbol, symbol, 2);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlModuleSymbol",
......@@ -28299,10 +28304,12 @@ test_xmlModuleSymbol(void) {
test_ret++;
printf(" %d", n_module);
printf(" %d", n_name);
printf(" %d", n_symbol);
printf("\n");
}
}
}
}
function_tests++;
#endif
......@@ -4,6 +4,8 @@
* See Copyright for the status of this software.
*
* joelwreed@comcast.net
*
* http://www.fortran-2000.com/ArnaudRecipes/sharedlib.html
*/
#define IN_LIBXML
......@@ -24,7 +26,7 @@ struct _xmlModule {
static void *xmlModulePlatformOpen(const char *name);
static int xmlModulePlatformClose(void *handle);
static void *xmlModulePlatformSymbol(void *handle, const char *name);
static int xmlModulePlatformSymbol(void *handle, const char *name, void **result);
/************************************************************************
* *
......@@ -92,34 +94,36 @@ xmlModuleOpen(const char *name)
* xmlModuleSymbol:
* @module: the module
* @name: the name of the symbol
* @symbol: the resulting symbol address
*
* Lookup for a symbol address in the given module
*
* Returns the pointer to the symbol object or NULL in case of error
* Returns 0 if the symbol was found, or -1 in case of error
*/
void *
xmlModuleSymbol(xmlModulePtr module, const char *name)
int
xmlModuleSymbol(xmlModulePtr module, const char *name, void **symbol)
{
void *symbol;
if (NULL == module) {
int rc = -1;
if ((NULL == module) || (symbol == NULL)) {
__xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_MODULE,
XML_MODULE_OPEN, XML_ERR_FATAL, NULL, 0, 0,
NULL, NULL, 0, 0, "null module pointer\n", 0);
return 0;
NULL, NULL, 0, 0, "null parameter\n");
return rc;
}
symbol = xmlModulePlatformSymbol(module->handle, name);
rc = xmlModulePlatformSymbol(module->handle, name, symbol);
if (symbol == 0) {
if (rc == -1) {
__xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_MODULE,
XML_MODULE_OPEN, XML_ERR_FATAL, NULL, 0, 0,
symbol, NULL, 0, 0,
"failed to find symbol: %s\n", 0);
return 0;
name, NULL, 0, 0,
"failed to find symbol: %s\n",
(name == NULL ? "NULL" : name));
return rc;
}
return (symbol);
return rc;
}
/**
......@@ -139,8 +143,8 @@ xmlModuleClose(xmlModulePtr module)
if (NULL == module) {
__xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_MODULE,
XML_MODULE_OPEN, XML_ERR_FATAL, NULL, 0, 0,
NULL, NULL, 0, 0, "null module pointer\n", 0);
XML_MODULE_CLOSE, XML_ERR_FATAL, NULL, 0, 0,
NULL, NULL, 0, 0, "null module pointer\n");
return -1;
}
......@@ -148,9 +152,9 @@ xmlModuleClose(xmlModulePtr module)
if (rc != 0) {
__xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_MODULE,
XML_MODULE_OPEN, XML_ERR_FATAL, NULL, 0, 0,
XML_MODULE_CLOSE, XML_ERR_FATAL, NULL, 0, 0,
(const char *) module->name, NULL, 0, 0,
"failed to close: %s\n", 0);
"failed to close: %s\n", module->name);
return -2;
}
......@@ -173,8 +177,8 @@ xmlModuleFree(xmlModulePtr module)
{
if (NULL == module) {
__xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_MODULE,
XML_MODULE_OPEN, XML_ERR_FATAL, NULL, 0, 0,
NULL, NULL, 0, 0, "null module pointer\n", 0);
XML_MODULE_CLOSE, XML_ERR_FATAL, NULL, 0, 0,
NULL, NULL, 0, 0, "null module pointer\n");
return -1;
}
......@@ -198,10 +202,7 @@ xmlModuleFree(xmlModulePtr module)
static void *
xmlModulePlatformOpen(const char *name)
{
void *handle;
handle = dlopen(name, RTLD_GLOBAL | RTLD_NOW);
return (handle);
return dlopen(name, RTLD_GLOBAL | RTLD_NOW);
}
/*
......@@ -214,24 +215,23 @@ xmlModulePlatformOpen(const char *name)
static int
xmlModulePlatformClose(void *handle)
{
int rc;
rc = dlclose(handle);
return (rc);
return dlclose(handle);
}
/*
* xmlModulePlatformSymbol:
* returns loaded symbol on success, and zero on error.
* http://www.opengroup.org/onlinepubs/009695399/functions/dlsym.html
* returns 0 on success and the loaded symbol in result, and -1 on error.
*/
static void *
xmlModulePlatformSymbol(void *handle, const char *name)
static int
xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
{
void *sym;
sym = dlsym(handle, name);
return (sym);
*symbol = dlsym(handle, name);
if (dlerror() != NULL) {
return -1;
}
return 0;
}
#endif /* HAVE_DLOPEN */
......@@ -246,10 +246,7 @@ xmlModulePlatformSymbol(void *handle, const char *name)
static void *
xmlModulePlatformOpen(const char *name)
{
void *handle;
handle = shl_load(name, BIND_IMMEDIATE, 0L);
return (handle);
return shl_load(name, BIND_IMMEDIATE, 0L);
}
/*
......@@ -260,29 +257,26 @@ xmlModulePlatformOpen(const char *name)
static int
xmlModulePlatformClose(void *handle)
{
int rc;
rc = shl_unload(handle);
return (rc);
return shl_unload(handle);
}
/*
* xmlModulePlatformSymbol:
* returns loaded symbol on success, and zero on error.
* http://docs.hp.com/en/B2355-90683/shl_load.3X.html
* returns 0 on success and the loaded symbol in result, and -1 on error.
*/
static void *
xmlModulePlatformSymbol(void *handle, const char *name)
static int
xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
{
void *sym;
int rc;
errno = 0;
rc = shl_findsym(handle, name, TYPE_PROCEDURE, &sym);
if (-1 == rc && 0 == errno) {
rc = shl_findsym(handle, sym, TYPE_DATA, &sym);
rc = shl_findsym(handle, name, TYPE_PROCEDURE, symbol);
if ((-1 == rc) && (0 == errno)) {
rc = shl_findsym(handle, name, TYPE_DATA, symbol);
}
return (sym);
return rc;
}
#endif /* HAVE_SHLLOAD */
......@@ -299,10 +293,7 @@ xmlModulePlatformSymbol(void *handle, const char *name)
static void *
xmlModulePlatformOpen(const char *name)
{
void *handle;
handle = LoadLibrary(name);
return (handle);
return LoadLibrary(name);
}
/*
......@@ -321,16 +312,15 @@ xmlModulePlatformClose(void *handle)
/*
* xmlModulePlatformSymbol:
* returns loaded symbol on success, and zero on error.
* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getprocaddress.asp
* returns 0 on success and the loaded symbol in result, and -1 on error.
*/
static void *
xmlModulePlatformSymbol(void *handle, const char *name)
static int
xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
{
void *sym;
sym = GetProcAddress(handle, name);
return (sym);
*symbol = GetProcAddress(handle, name);
return (NULL == *symbol) ? -1 : 0;
}
#endif /* _WIN32 */
......@@ -348,10 +338,7 @@ xmlModulePlatformSymbol(void *handle, const char *name)
static void *
xmlModulePlatformOpen(const char *name)
{
void *handle;
handle = (void *) load_add_on(name);
return (handle);
return (void *) load_add_on(name);
}
/*
......@@ -376,22 +363,17 @@ xmlModulePlatformClose(void *handle)
/*
* xmlModulePlatformSymbol:
* beos api info: http://www.beunited.org/bebook/The%20Kernel%20Kit/Images.html
* returns loaded symbol on success, and zero on error.
* returns 0 on success and the loaded symbol in result, and -1 on error.
*/
static void *
xmlModulePlatformSymbol(void *handle, const char *name)
static int
xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
{
void *sym;
status_t rc;
rc = get_image_symbol((image_id) handle, name, B_SYMBOL_TYPE_ANY,
&sym);
rc = get_image_symbol((image_id) handle, name, B_SYMBOL_TYPE_ANY, symbol);
if (rc == B_OK)
return sym;
else
return 0;
return (rc == B_OK) ? 0 : -1;
}
#endif /* HAVE_BEOS */
......@@ -409,11 +391,11 @@ xmlModulePlatformSymbol(void *handle, const char *name)
static void *
xmlModulePlatformOpen(const char *name)
{
char errbuf[255];
char errbuf[256];
void *handle;
int rc;
rc = DosLoadModule(errbuf, sizeof(errbuf), name, &handle);
rc = DosLoadModule(errbuf, sizeof(errbuf) - 1, name, &handle);
if (rc)
return 0;
......@@ -430,30 +412,23 @@ xmlModulePlatformOpen(const char *name)
static int
xmlModulePlatformClose(void *handle)
{
int rc;
rc = DosFreeModule(handle);
return (rc);
return DosFreeModule(handle);
}
/*
* xmlModulePlatformSymbol:
* os2 api info: http://www.edm2.com/os2api/Dos/DosQueryProcAddr.html
* returns loaded symbol on success, and zero on error.
* returns 0 on success and the loaded symbol in result, and -1 on error.
*/
static void *
xmlModulePlatformSymbol(void *handle, const char *name)
static int
xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
{
void *sym;
int rc;
rc = DosQueryProcAddr(handle, 0, name, &sym);
rc = DosQueryProcAddr(handle, 0, name, symbol);
if (rc)
return 0;
else
return (sym);
return (rc == NO_ERROR) ? 0 : -1;
}
#endif /* HAVE_OS2 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment