blob: a878e0365b93205de4c6f58c92800f33bf1ddc16 [file] [log] [blame]
Daniel Veillardce1648b2005-01-04 15:10:22 +00001/*
2 * testModule.c : a small tester program for xmlModule
3 *
4 * See Copyright for the status of this software.
5 *
6 * joelwreed@comcast.net
7 */
8
9#include "libxml.h"
10#ifdef LIBXML_MODULES_ENABLED
11#include <libxml/xmlversion.h>
12
13#include <limits.h>
14#include <stdio.h>
15#include <string.h>
16#include <stdarg.h>
17
18#include <libxml/xmlmemory.h>
19#include <libxml/debugXML.h>
20#include <libxml/xmlmodule.h>
21
22#ifdef _WIN32
23#define MODULE_PATH "."
24#include <stdlib.h> /* for _MAX_PATH */
25#define PATH_MAX _MAX_PATH
26#else
27#define MODULE_PATH ".libs"
28#endif
29
30typedef int (*hello_world_t)();
31
32int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
33 xmlChar filename[PATH_MAX];
34 xmlModulePtr module = NULL;
35 hello_world_t hello_world = NULL;
36
37 /* build the module filename, and confirm the module exists */
Daniel Veillardbe076e92005-01-04 20:18:14 +000038 xmlStrPrintf(filename, sizeof(filename), "%s/testdso%s",
39 (const xmlChar*)MODULE_PATH,
40 (const xmlChar*)LIBXML_MODULE_EXTENSION);
Daniel Veillardce1648b2005-01-04 15:10:22 +000041
42 module = xmlModuleOpen((const char*)filename);
43 if (module)
44 {
Daniel Veillardbe076e92005-01-04 20:18:14 +000045 if (xmlModuleSymbol(module, "hello_world", (void **) &hello_world)) {
46 fprintf(stderr, "Failure to lookup\n");
47 return(1);
48 }
49 if (hello_world == NULL) {
50 fprintf(stderr, "Lookup returned NULL\n");
51 return(1);
52 }
53
Daniel Veillardce1648b2005-01-04 15:10:22 +000054 (*hello_world)();
55
56 xmlModuleClose(module);
57 }
58
59 xmlMemoryDump();
60
61 return(0);
62}
63
64#else
65#include <stdio.h>
66int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
67 printf("%s : Module support not compiled in\n", argv[0]);
68 return(0);
69}
70#endif /* LIBXML_SCHEMAS_ENABLED */