#include #include #include XS(XS_iout); /* prototype to pass -Wmissing-prototypes */ XS(XS_iout) { dXSARGS; if (items != 1) croak("Usage: iout(str)"); { char *str = (char *)SvPV_nolen(ST(0)); printf(str); } XSRETURN(0); } #define PERL_ENTRY dSP; ENTER; SAVETMPS; PUSHMARK(SP); #define PERL_PRECALL PUTBACK; #define PERL_EXIT SPAGAIN; PUTBACK; FREETMPS; LEAVE; int main() { PerlInterpreter *my_perl = NULL; char *arg[] = { "", "-e", "" }; // Startup perl my_perl = perl_alloc(); perl_construct(my_perl); if (perl_parse(my_perl, NULL, 3, arg, (char **)NULL)) { return printf("Trouble opening perl parser\n"); } fprintf(stderr,"Evaluate builtin.pl\n"); { PERL_ENTRY; PERL_PRECALL; eval_pv("do 'builtin.pl'",G_VOID); PERL_EXIT; } fprintf(stderr,"Setup the XS routine\n"); newXSproto("iout",XS_iout,__FILE__,""); fprintf(stderr,"Call builtinInit\n"); { PERL_ENTRY; PERL_PRECALL; call_pv("builtinInit", G_DISCARD); PERL_EXIT; } fprintf(stderr,"Done\n"); perl_destruct(my_perl); perl_free(my_perl); return 1; }