summaryrefslogtreecommitdiff
path: root/src/perl/perl-core.c
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-10-20 13:19:25 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-10-20 13:19:25 +0000
commita5b32b70a7db8ce41a37d9ee6fdef85300130351 (patch)
treee02a223f3a9fe2e84148a7de6cc282560476f14a /src/perl/perl-core.c
parent476b5ec863c49bb9a85eda23fbba31cf0d3a443c (diff)
downloadirssi-a5b32b70a7db8ce41a37d9ee6fdef85300130351.zip
Added API version check between perl module and perl libs.
perl_scripts_deinit() now destroys all dynamically loaded libraries (Irssi, Irssi::Irc, Irssi::UI too) so /UNLOAD perl should now release more memory, this also makes /unload perl, /load perl work again. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1859 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/perl/perl-core.c')
-rw-r--r--src/perl/perl-core.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/perl/perl-core.c b/src/perl/perl-core.c
index 914f6eff..d319be04 100644
--- a/src/perl/perl-core.c
+++ b/src/perl/perl-core.c
@@ -41,6 +41,8 @@ extern void xs_init(void);
GSList *perl_scripts;
PerlInterpreter *my_perl;
+static int print_script_errors;
+
#define IS_PERL_SCRIPT(file) \
(strlen(file) > 3 && strcmp(file+strlen(file)-3, ".pl") == 0)
@@ -112,9 +114,14 @@ void perl_scripts_deinit(void)
while (perl_scripts != NULL)
perl_script_destroy(perl_scripts->data);
+ signal_emit("perl scripts deinit", 0);
+
perl_signals_stop();
perl_sources_stop();
- perl_common_stop();
+ perl_common_stop();
+
+ /* Unload all perl libraries loaded with dynaloader */
+ perl_eval_pv("foreach my $lib (@DynaLoader::dl_librefs) { DynaLoader::dl_unload_file($lib); }", TRUE);
/* perl interpreter */
perl_destruct(my_perl);
@@ -320,6 +327,18 @@ char *perl_script_get_path(const char *name)
return path;
}
+/* If core should handle printing script errors */
+void perl_core_print_script_error(int print)
+{
+ print_script_errors = print;
+}
+
+/* Returns the perl module's API version. */
+int perl_get_api_version(void)
+{
+ return IRSSI_PERL_API_VERSION;
+}
+
static void perl_scripts_autorun(void)
{
DIR *dirp;
@@ -348,8 +367,18 @@ static void perl_scripts_autorun(void)
g_free(path);
}
-static void sig_script_error(PERL_SCRIPT_REC *script)
+static void sig_script_error(PERL_SCRIPT_REC *script, const char *error)
{
+ char *str;
+
+ if (print_script_errors) {
+ str = g_strdup_printf("Script '%s' error:",
+ script == NULL ? "??" : script->name);
+ signal_emit("gui dialog", 2, "error", str);
+ signal_emit("gui dialog", 2, "error", error);
+ g_free(str);
+ }
+
if (script != NULL) {
perl_script_destroy(script);
signal_stop();
@@ -358,6 +387,8 @@ static void sig_script_error(PERL_SCRIPT_REC *script)
void perl_core_init(void)
{
+ print_script_errors = 1;
+
PL_perl_destruct_level = 1;
perl_signals_init();
signal_add_last("script error", (SIGNAL_FUNC) sig_script_error);