/*
* xmlmodule.c : basic API for dynamic module loading added 2.6.17
*
* See Copyright for the status of this software.
*
* joelwreed@comcast.net
*
*/
#define IN_LIBXML
#include "libxml.h"
#include <string.h>
#include <libxml/xmlmemory.h>
#include <libxml/xmlerror.h>
#include <libxml/xmlmodule.h>
#ifdef LIBXML_MODULES_ENABLED
struct _xmlModule {
unsigned char *name;
void *handle;
};
static void *xmlModulePlatformOpen(const char *name);
static int xmlModulePlatformClose(void *handle);
/************************************************************************
* *
* module memory error handler *
* *
************************************************************************/
/**
* xmlModuleErrMemory:
* @extra: extra information
*
* Handle an out of memory condition
*/
static void
{
}
"Memory allocation failed : %s\n", extra);
}
/**
* xmlModuleOpen:
* @name: the module name
* @options: a set of xmlModuleOption
*
* TODO: options are not yet implemented.
*
* Returns a handle for the module or NULL in case of error
*/
{
return (NULL);
}
return(NULL);
}
return (module);
}
/**
* 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 0 if the symbol was found, or -1 in case of error
*/
int
{
return rc;
}
if (rc == -1) {
"failed to find symbol: %s\n",
return rc;
}
return rc;
}
/**
* xmlModuleClose:
* @module: the module handle
*
* The close operations unload the associated module and free the
* data associated to the module.
*
* Returns 0 in case of success, -1 in case of argument error and -2
*/
int
{
int rc;
return -1;
}
if (rc != 0) {
return -2;
}
return (rc);
}
/**
* xmlModuleFree:
* @module: the module handle
*
* The free operations free the data associated to the module
* but does not unload the associated shared library which may still
* be in use.
*
* Returns 0 in case of success, -1 in case of argument error
*/
int
{
return -1;
}
return (0);
}
#ifdef HAVE_DLOPEN
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#endif
#ifndef RTLD_GLOBAL /* For Tru64 UNIX 4.0 */
#define RTLD_GLOBAL 0
#endif
/**
* xmlModulePlatformOpen:
* @name: path to the module
*
* returns a handle on success, and zero on error.
*/
static void *
{
}
/*
* xmlModulePlatformClose:
* @handle: handle to the module
*
* returns 0 on success, and non-zero on error.
*/
static int
{
}
/*
* xmlModulePlatformSymbol:
* returns 0 on success and the loaded symbol in result, and -1 on error.
*/
static int
{
return -1;
}
return 0;
}
#else /* ! HAVE_DLOPEN */
#ifdef HAVE_SHLLOAD /* HAVE_SHLLOAD */
#ifdef HAVE_DL_H
#include <dl.h>
#endif
/*
* xmlModulePlatformOpen:
* returns a handle on success, and zero on error.
*/
static void *
{
}
/*
* xmlModulePlatformClose:
* returns 0 on success, and non-zero on error.
*/
static int
{
return shl_unload(handle);
}
/*
* xmlModulePlatformSymbol:
* returns 0 on success and the loaded symbol in result, and -1 on error.
*/
static int
{
int rc;
errno = 0;
return rc;
}
#endif /* HAVE_SHLLOAD */
#endif /* ! HAVE_DLOPEN */
#ifdef _WIN32
#include <windows.h>
/*
* xmlModulePlatformOpen:
* returns a handle on success, and zero on error.
*/
static void *
{
return LoadLibrary(name);
}
/*
* xmlModulePlatformClose:
* returns 0 on success, and non-zero on error.
*/
static int
{
int rc;
return (0 == rc);
}
/*
* xmlModulePlatformSymbol:
* returns 0 on success and the loaded symbol in result, and -1 on error.
*/
static int
{
}
#endif /* _WIN32 */
#ifdef HAVE_BEOS
/*
* xmlModulePlatformOpen:
* beos api info: http://www.beunited.org/bebook/The%20Kernel%20Kit/Images.html
* returns a handle on success, and zero on error.
*/
static void *
{
return (void *) load_add_on(name);
}
/*
* xmlModulePlatformClose:
* beos api info: http://www.beunited.org/bebook/The%20Kernel%20Kit/Images.html
* returns 0 on success, and non-zero on error.
*/
static int
{
return 0;
else
return -1;
}
/*
* xmlModulePlatformSymbol:
* beos api info: http://www.beunited.org/bebook/The%20Kernel%20Kit/Images.html
* returns 0 on success and the loaded symbol in result, and -1 on error.
*/
static int
{
}
#endif /* HAVE_BEOS */
#ifdef HAVE_OS2
#include <os2.h>
/*
* xmlModulePlatformOpen:
* os2 api info: http://www.edm2.com/os2api/Dos/DosLoadModule.html
* returns a handle on success, and zero on error.
*/
static void *
{
void *handle;
int rc;
if (rc)
return 0;
else
return (handle);
}
/*
* xmlModulePlatformClose:
* os2 api info: http://www.edm2.com/os2api/Dos/DosFreeModule.html
* returns 0 on success, and non-zero on error.
*/
static int
{
return DosFreeModule(handle);
}
/*
* xmlModulePlatformSymbol:
* os2 api info: http://www.edm2.com/os2api/Dos/DosQueryProcAddr.html
* returns 0 on success and the loaded symbol in result, and -1 on error.
*/
static int
{
int rc;
}
#endif /* HAVE_OS2 */
#define bottom_xmlmodule
#include "elfgcchack.h"
#endif /* LIBXML_MODULES_ENABLED */