centreon-plugins/contrib/cwrapper_perl.c

30 lines
719 B
C
Raw Normal View History

2017-08-11 11:30:03 +02:00
#include <EXTERN.h>
#include <perl.h>
static PerlInterpreter *my_perl;
static void xs_init (pTHX);
EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
EXTERN_C void xs_init(pTHX)
{
char *file = __FILE__;
/* DynaLoader is a special case */
newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
}
int main (int argc, char **argv, char **env)
2017-08-11 16:44:20 +02:00
{
int exitstatus = 0;
2017-08-11 11:30:03 +02:00
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, xs_init, argc, argv, (char **)NULL);
2017-08-11 16:44:20 +02:00
exitstatus = perl_run(my_perl);
2017-08-11 11:30:03 +02:00
perl_destruct(my_perl);
perl_free(my_perl);
PERL_SYS_TERM();
2017-08-11 16:44:20 +02:00
exit(exitstatus);
2017-08-11 11:30:03 +02:00
}