#include "EXTERN.h" #include "perl.h" #include "XSUB.h" MODULE = simple PACKAGE = simple PREFIX = tst_ BOOT: printf("Loading the 'simple' module!\n"); # barf(string) # This is a function that inserts "barf " before 'string' and "!" # after 'string' and then returns the results. void tst_barf(str = "") char* str CODE: { char barf[80]; if (strlen(str) > 80 - 6) str[80 - 6] = '\0'; sprintf(barf, "barf %s!", str); ST(0) = sv_newmortal(); sv_setpv(ST(0), barf); } # succ(n) # Returns the successor to 'n'. int tst_succ(n) int n CODE: RETVAL = n+1; OUTPUT: RETVAL # inc(n) # Will increase the value of 'n' one step and return the old value # of 'n'. # # Notice that when using several output variables together with # RETVAL, RETVAL has to be the last one listed! # # Stupid, but true. int tst_inc(n) int &n CODE: RETVAL = n++; OUTPUT: n RETVAL