2005-01-04 18:10:22 +03:00
/*
* testModule . c : a small tester program for xmlModule
*
* See Copyright for the status of this software .
*
* joelwreed @ comcast . net
*/
2024-06-15 20:13:08 +03:00
# include "libxml.h"
2023-09-21 01:44:50 +03:00
# include <stdio.h>
2005-01-04 18:10:22 +03:00
# include <libxml/xmlversion.h>
2023-09-21 01:44:50 +03:00
# ifdef LIBXML_MODULES_ENABLED
2005-01-04 18:10:22 +03:00
# include <limits.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 */
2005-04-07 00:42:35 +04:00
# ifndef __MINGW32__
2005-01-04 18:10:22 +03:00
# define PATH_MAX _MAX_PATH
2005-04-07 00:42:35 +04:00
# endif
2005-01-04 18:10:22 +03:00
# else
# define MODULE_PATH ".libs"
# endif
2008-02-25 18:44:43 +03:00
/* Used for SCO Openserver*/
# ifndef PATH_MAX
# ifdef _POSIX_PATH_MAX
# define PATH_MAX _POSIX_PATH_MAX
# else
# define PATH_MAX 4096
# endif
# endif
2005-01-05 00:50:05 +03:00
typedef int ( * hello_world_t ) ( void ) ;
2012-09-11 09:26:36 +04:00
2005-01-04 18:10:22 +03:00
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 */
2005-01-05 00:50:05 +03:00
xmlStrPrintf ( filename , sizeof ( filename ) ,
2016-05-13 10:13:17 +03:00
" %s/testdso%s " ,
2005-01-04 23:18:14 +03:00
( const xmlChar * ) MODULE_PATH ,
2022-12-06 17:33:32 +03:00
( const xmlChar * ) LIBXML_MODULE_EXTENSION ) ;
2005-01-04 18:10:22 +03:00
2005-01-05 00:50:05 +03:00
module = xmlModuleOpen ( ( const char * ) filename , 0 ) ;
2022-12-06 17:33:32 +03:00
if ( module = = NULL ) {
fprintf ( stderr , " Failed to open module \n " ) ;
return ( 1 ) ;
}
2012-09-11 09:26:36 +04:00
2022-12-06 17:33:32 +03:00
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 ) ;
}
2005-01-04 18:10:22 +03:00
2022-12-06 17:33:32 +03:00
( * hello_world ) ( ) ;
xmlModuleClose ( module ) ;
2005-01-04 18:10:22 +03:00
return ( 0 ) ;
}
# else
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 */