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
*/
# 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 */
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 ,
( 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 ) ;
2005-01-04 18:10:22 +03:00
if ( module )
{
2005-01-04 23:18:14 +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 ) ;
}
2012-09-11 09:26:36 +04:00
2005-01-04 18:10:22 +03:00
( * 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 */