Daniel Veillard | ce1648b | 2005-01-04 15:10:22 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 30 | typedef int (*hello_world_t)(); |
| 31 | |
| 32 | int 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 */ |
| 38 | xmlStrPrintf(filename, sizeof(filename), "%s/testdso%s", (const xmlChar*)MODULE_PATH, (const xmlChar*)LIBXML_MODULE_EXTENSION); |
| 39 | |
| 40 | module = xmlModuleOpen((const char*)filename); |
| 41 | if (module) |
| 42 | { |
| 43 | hello_world = (hello_world_t)xmlModuleSymbol(module, "hello_world"); |
| 44 | (*hello_world)(); |
| 45 | |
| 46 | xmlModuleClose(module); |
| 47 | } |
| 48 | |
| 49 | xmlMemoryDump(); |
| 50 | |
| 51 | return(0); |
| 52 | } |
| 53 | |
| 54 | #else |
| 55 | #include <stdio.h> |
| 56 | int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { |
| 57 | printf("%s : Module support not compiled in\n", argv[0]); |
| 58 | return(0); |
| 59 | } |
| 60 | #endif /* LIBXML_SCHEMAS_ENABLED */ |