#include /* from the Perl distribution */ #include /* from the Perl distribution */ #include #include static PerlInterpreter *my_perl; /*** The Perl interpreter ***/ void say( char *m ) { printf("I am say: %s", m ); } XS(XS_Module_say); /* prototype to pass -Wmissing-prototypes */ XS(XS_Module_say) { dXSARGS; if (items != 1) Perl_croak(aTHX_ "Usage: Module::say(message)"); { char * message = (char *)SvPV_nolen(ST(0)); say(message); } XSRETURN_EMPTY; } #ifdef __cplusplus extern "C" #endif XS(boot_Module); /* prototype to pass -Wmissing-prototypes */ XS(boot_Module) { dXSARGS; char* file = __FILE__; XS_VERSION_BOOTCHECK ; newXS("Module::say", XS_Module_say, file); XSRETURN_YES; } int main(int argc, char **argv, char **env) { char *embedding = { "", "-e", "0" }; PERL_SYS_INIT3(&argc,&argv,&env); my_perl = perl_alloc(); perl_construct(my_perl); PL_exit_flags |= PERL_EXIT_DESTRUCT_END; perl_parse(my_perl, NULL, argc, argv, (char **)NULL); perl_run(my_perl); perl_destruct(my_perl); perl_free(my_perl); PERL_SYS_TERM(); }