1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 12:25:09 +03:00
libxml2/testModule.c
Daniel Veillard 48df9613ba fixed namespace bug in push mode reported by Rob Richards added it to the
* parser.c: fixed namespace bug in push mode reported by
  Rob Richards
* test/ns6 result//ns6*: added it to the regression tests
* xmlmodule.c testModule.c include/libxml/xmlmodule.h:
  added an extra option argument to module opening and defined
  a couple of flags to the API.
Daniel
2005-01-04 21:50:05 +00:00

72 lines
1.6 KiB
C

/*
* testModule.c : a small tester program for xmlModule
*
* See Copyright for the status of this software.
*
* joelwreed@comcast.net
*/
#include "libxml.h"
#ifdef LIBXML_MODULES_ENABLED
#include <libxml/xmlversion.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <libxml/xmlmemory.h>
#include <libxml/debugXML.h>
#include <libxml/xmlmodule.h>
#ifdef _WIN32
#define MODULE_PATH "."
#include <stdlib.h> /* for _MAX_PATH */
#define PATH_MAX _MAX_PATH
#else
#define MODULE_PATH ".libs"
#endif
typedef int (*hello_world_t)(void);
int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
xmlChar filename[PATH_MAX];
xmlModulePtr module = NULL;
hello_world_t hello_world = NULL;
/* build the module filename, and confirm the module exists */
xmlStrPrintf(filename, sizeof(filename),
(const xmlChar*) "%s/testdso%s",
(const xmlChar*)MODULE_PATH,
(const xmlChar*)LIBXML_MODULE_EXTENSION);
module = xmlModuleOpen((const char*)filename, 0);
if (module)
{
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);
}
xmlMemoryDump();
return(0);
}
#else
#include <stdio.h>
int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
printf("%s : Module support not compiled in\n", argv[0]);
return(0);
}
#endif /* LIBXML_SCHEMAS_ENABLED */