| OLD | NEW |
| 1 /* | 1 /* |
| 2 * xmlmodule.c : basic API for dynamic module loading added 2.6.17 | 2 * xmlmodule.c : basic API for dynamic module loading added 2.6.17 |
| 3 * | 3 * |
| 4 * See Copyright for the status of this software. | 4 * See Copyright for the status of this software. |
| 5 * | 5 * |
| 6 * joelwreed@comcast.net | 6 * joelwreed@comcast.net |
| 7 * | 7 * |
| 8 * http://www.fortran-2000.com/ArnaudRecipes/sharedlib.html | 8 * http://www.fortran-2000.com/ArnaudRecipes/sharedlib.html |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 unsigned char *name; | 23 unsigned char *name; |
| 24 void *handle; | 24 void *handle; |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 static void *xmlModulePlatformOpen(const char *name); | 27 static void *xmlModulePlatformOpen(const char *name); |
| 28 static int xmlModulePlatformClose(void *handle); | 28 static int xmlModulePlatformClose(void *handle); |
| 29 static int xmlModulePlatformSymbol(void *handle, const char *name, void **result
); | 29 static int xmlModulePlatformSymbol(void *handle, const char *name, void **result
); |
| 30 | 30 |
| 31 /************************************************************************ | 31 /************************************************************************ |
| 32 * * | 32 * * |
| 33 * » » module memory error handler» » » » * | 33 *» » module memory error handler» » » » * |
| 34 * * | 34 * * |
| 35 ************************************************************************/ | 35 ************************************************************************/ |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * xmlModuleErrMemory: | 38 * xmlModuleErrMemory: |
| 39 * @extra: extra information | 39 * @extra: extra information |
| 40 * | 40 * |
| 41 * Handle an out of memory condition | 41 * Handle an out of memory condition |
| 42 */ | 42 */ |
| 43 static void | 43 static void |
| (...skipping 10 matching lines...) Expand all Loading... |
| 54 name, NULL, 0, 0, | 54 name, NULL, 0, 0, |
| 55 "Memory allocation failed : %s\n", extra); | 55 "Memory allocation failed : %s\n", extra); |
| 56 } | 56 } |
| 57 | 57 |
| 58 /** | 58 /** |
| 59 * xmlModuleOpen: | 59 * xmlModuleOpen: |
| 60 * @name: the module name | 60 * @name: the module name |
| 61 * @options: a set of xmlModuleOption | 61 * @options: a set of xmlModuleOption |
| 62 * | 62 * |
| 63 * Opens a module/shared library given its name or path | 63 * Opens a module/shared library given its name or path |
| 64 * NOTE: that due to portability issues, behaviour can only be |
| 65 * guaranteed with @name using ASCII. We canot guarantee that |
| 66 * an UTF-8 string would work, which is why name is a const char * |
| 67 * and not a const xmlChar * . |
| 64 * TODO: options are not yet implemented. | 68 * TODO: options are not yet implemented. |
| 65 * | 69 * |
| 66 * Returns a handle for the module or NULL in case of error | 70 * Returns a handle for the module or NULL in case of error |
| 67 */ | 71 */ |
| 68 xmlModulePtr | 72 xmlModulePtr |
| 69 xmlModuleOpen(const char *name, int options ATTRIBUTE_UNUSED) | 73 xmlModuleOpen(const char *name, int options ATTRIBUTE_UNUSED) |
| 70 { | 74 { |
| 71 xmlModulePtr module; | 75 xmlModulePtr module; |
| 72 | 76 |
| 73 module = (xmlModulePtr) xmlMalloc(sizeof(xmlModule)); | 77 module = (xmlModulePtr) xmlMalloc(sizeof(xmlModule)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 92 return (module); | 96 return (module); |
| 93 } | 97 } |
| 94 | 98 |
| 95 /** | 99 /** |
| 96 * xmlModuleSymbol: | 100 * xmlModuleSymbol: |
| 97 * @module: the module | 101 * @module: the module |
| 98 * @name: the name of the symbol | 102 * @name: the name of the symbol |
| 99 * @symbol: the resulting symbol address | 103 * @symbol: the resulting symbol address |
| 100 * | 104 * |
| 101 * Lookup for a symbol address in the given module | 105 * Lookup for a symbol address in the given module |
| 106 * NOTE: that due to portability issues, behaviour can only be |
| 107 * guaranteed with @name using ASCII. We canot guarantee that |
| 108 * an UTF-8 string would work, which is why name is a const char * |
| 109 * and not a const xmlChar * . |
| 102 * | 110 * |
| 103 * Returns 0 if the symbol was found, or -1 in case of error | 111 * Returns 0 if the symbol was found, or -1 in case of error |
| 104 */ | 112 */ |
| 105 int | 113 int |
| 106 xmlModuleSymbol(xmlModulePtr module, const char *name, void **symbol) | 114 xmlModuleSymbol(xmlModulePtr module, const char *name, void **symbol) |
| 107 { | 115 { |
| 108 int rc = -1; | 116 int rc = -1; |
| 109 » | 117 |
| 110 if ((NULL == module) || (symbol == NULL)) { | 118 if ((NULL == module) || (symbol == NULL) || (name == NULL)) { |
| 111 __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_MODULE, | 119 __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_MODULE, |
| 112 XML_MODULE_OPEN, XML_ERR_FATAL, NULL, 0, 0, | 120 XML_MODULE_OPEN, XML_ERR_FATAL, NULL, 0, 0, |
| 113 NULL, NULL, 0, 0, "null parameter\n"); | 121 NULL, NULL, 0, 0, "null parameter\n"); |
| 114 return rc; | 122 return rc; |
| 115 } | 123 } |
| 116 | 124 |
| 117 rc = xmlModulePlatformSymbol(module->handle, name, symbol); | 125 rc = xmlModulePlatformSymbol(module->handle, name, symbol); |
| 118 | 126 |
| 119 if (rc == -1) { | 127 if (rc == -1) { |
| 120 __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_MODULE, | 128 __xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_MODULE, |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 | 327 |
| 320 /* | 328 /* |
| 321 * xmlModulePlatformSymbol: | 329 * xmlModulePlatformSymbol: |
| 322 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base
/getprocaddress.asp | 330 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base
/getprocaddress.asp |
| 323 * returns 0 on success and the loaded symbol in result, and -1 on error. | 331 * returns 0 on success and the loaded symbol in result, and -1 on error. |
| 324 */ | 332 */ |
| 325 | 333 |
| 326 static int | 334 static int |
| 327 xmlModulePlatformSymbol(void *handle, const char *name, void **symbol) | 335 xmlModulePlatformSymbol(void *handle, const char *name, void **symbol) |
| 328 { | 336 { |
| 337 #ifdef _WIN32_WCE |
| 338 /* |
| 339 * GetProcAddressA seems only available on WinCE |
| 340 */ |
| 341 *symbol = GetProcAddressA(handle, name); |
| 342 #else |
| 329 *symbol = GetProcAddress(handle, name); | 343 *symbol = GetProcAddress(handle, name); |
| 344 #endif |
| 330 return (NULL == *symbol) ? -1 : 0; | 345 return (NULL == *symbol) ? -1 : 0; |
| 331 } | 346 } |
| 332 | 347 |
| 333 #endif /* _WIN32 */ | 348 #endif /* _WIN32 */ |
| 334 | 349 |
| 335 #ifdef HAVE_BEOS | 350 #ifdef HAVE_BEOS |
| 336 | 351 |
| 337 #include <kernel/image.h> | 352 #include <kernel/image.h> |
| 338 | 353 |
| 339 /* | 354 /* |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 rc = DosQueryProcAddr(handle, 0, name, symbol); | 451 rc = DosQueryProcAddr(handle, 0, name, symbol); |
| 437 | 452 |
| 438 return (rc == NO_ERROR) ? 0 : -1; | 453 return (rc == NO_ERROR) ? 0 : -1; |
| 439 } | 454 } |
| 440 | 455 |
| 441 #endif /* HAVE_OS2 */ | 456 #endif /* HAVE_OS2 */ |
| 442 | 457 |
| 443 #define bottom_xmlmodule | 458 #define bottom_xmlmodule |
| 444 #include "elfgcchack.h" | 459 #include "elfgcchack.h" |
| 445 #endif /* LIBXML_MODULES_ENABLED */ | 460 #endif /* LIBXML_MODULES_ENABLED */ |
| OLD | NEW |