qulogic/gplugin
Clone
Summary
Browse
Changes
Graph
this appears to maybe be working.. ish?
feature/perl-loader
2015-10-12, Gary Kramlich
7655920e36f5
this appears to maybe be working.. ish?
/*
* Copyright (C) 2011-2015 Gary Kramlich <grim@reaperworld.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GPLUGIN_PERL_DEFS_H
#define GPLUGIN_PERL_DEFS_H
#include
<glib.h>
const
gchar
gplugin_perl_definitions
[]
=
{
"package GPlugin::PerlLoader;"
"use Symbol;"
"sub load_file {"
"my $filename = shift;"
"local $/ = undef;"
"open FH, $filename or return
\"
__FAILED__
\"
;"
"$_ = <FH>;"
"close FH;"
"return $_;"
"}"
"sub destroy_package {"
"eval { $_[0]->UNLOAD() if $_[0]->can('UNLOAD'); };"
"Symbol::delete_package($_[0]);"
"}"
"sub eval_file {"
"my ($filename, $package) = @_;"
"destroy_package($package);"
"my $res = load_file($filename);"
"return 2 if($res eq
\"
__FAILED__
\"
);"
"my $eval = qq{package $package; $res;};"
"{"
"die(
\"
Errors loading file $file_name: $@
\"
);"
"}"
"return 0;"
"}"
};
#endif
/* GPLUGIN_PERL_DEFS_H */