#include "mlp_perl.h" mlp_perl_library::mlp_perl_library(mlp_context *ctx, mlp_runtime *rt, const char *name, const void *opts) : mlp_library(ctx, rt, name, opts) { PerlInterpreter *my_perl = ((mlp_perl_runtime *)rt)->_get_my_perl() ; ctx->clear_error() ; if (name != NULL){ int len = strlen(name) ; if (opts != NULL){ len += strlen((char *)opts) ; } char *buf = (char *)malloc((len + 32) * sizeof(char)) ; sprintf(buf, "use %s %s ;", name, (opts != NULL ? (char *)opts : "")) ; eval_pv(buf, FALSE) ; if (SvTRUE(ERRSV)){ STRLEN n_a ; ctx->set_error(MLP_LIBRARY_ERROR, "Can't load perl library %s: %s\n", name, SvPV(ERRSV, n_a)) ; free(buf) ; return ; } mlp_debug(2, "Perl library %s loaded", name) ; free(buf) ; } } mlp_perl_library::~mlp_perl_library(){ } mlp_function *mlp_perl_library::get_function(mlp_context *ctx, mlp_type rtype, const char *name, mlp_prototype proto){ ctx->clear_error() ; return new mlp_perl_function(ctx, rt, this, rtype, name, proto) ; } void mlp_perl_library::destroy(mlp_context *ctx){ ctx->clear_error() ; mlp_library::destroy(ctx) ; }