annotate plugins/perl/perl.c @ 9906:e98e97f99df3

[gaim-migrate @ 10798] (16:12:41) SimGuy: LSchiere: you should update the AUTHORS file when you change the about dialog committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Sat, 28 Aug 2004 20:10:47 +0000
parents 7cd7da72c872
children f8e395a054e2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /*
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * gaim
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 *
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
4 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org>
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * (at your option) any later version.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * GNU General Public License for more details.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 */
6235
1049dd7e976e [gaim-migrate @ 6728]
Mark Doliner <mark@kingant.net>
parents: 6100
diff changeset
20 #ifdef HAVE_CONFIG_H
1049dd7e976e [gaim-migrate @ 6728]
Mark Doliner <mark@kingant.net>
parents: 6100
diff changeset
21 #include <config.h>
8138
3e8592b95f68 [gaim-migrate @ 8844]
Christian Hammond <chipx86@chipx86.com>
parents: 8095
diff changeset
22 # ifdef HAVE_LIMITS_H
3e8592b95f68 [gaim-migrate @ 8844]
Christian Hammond <chipx86@chipx86.com>
parents: 8095
diff changeset
23 # include <limits.h>
3e8592b95f68 [gaim-migrate @ 8844]
Christian Hammond <chipx86@chipx86.com>
parents: 8095
diff changeset
24 # ifndef NAME_MAX
3e8592b95f68 [gaim-migrate @ 8844]
Christian Hammond <chipx86@chipx86.com>
parents: 8095
diff changeset
25 # define NAME_MAX _POSIX_NAME_MAX
3e8592b95f68 [gaim-migrate @ 8844]
Christian Hammond <chipx86@chipx86.com>
parents: 8095
diff changeset
26 # endif
3e8592b95f68 [gaim-migrate @ 8844]
Christian Hammond <chipx86@chipx86.com>
parents: 8095
diff changeset
27 # endif
6235
1049dd7e976e [gaim-migrate @ 6728]
Mark Doliner <mark@kingant.net>
parents: 6100
diff changeset
28 #endif
1049dd7e976e [gaim-migrate @ 6728]
Mark Doliner <mark@kingant.net>
parents: 6100
diff changeset
29
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
30 #ifdef DEBUG
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
31 # undef DEBUG
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
32 #endif
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34 #undef PACKAGE
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
36
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37 #define group perl_group
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
38
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 #ifdef _WIN32
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40 /* This took me an age to figure out.. without this __declspec(dllimport)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 * will be ignored.
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42 */
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
43 # define HASATTRIBUTE
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44 #endif
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
45
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46 #include <EXTERN.h>
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
47
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 #ifndef _SEM_SEMUN_UNDEFINED
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
49 # define HAS_UNION_SEMUN
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 #endif
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
51
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 #include <perl.h>
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 #include <XSUB.h>
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
54
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 #ifndef _WIN32
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
56 # include <sys/mman.h>
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57 #endif
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
58
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 #undef PACKAGE
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
60
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 #ifndef _WIN32
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
62 # include <dirent.h>
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 #else
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
64 /* We're using perl's win32 port of this */
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
65 # define dirent direct
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66 #endif
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 #undef group
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70 /* perl module support */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 #ifdef OLD_PERL
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 extern void boot_DynaLoader _((CV * cv));
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73 #else
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 extern void boot_DynaLoader _((pTHX_ CV * cv)); /* perl is so wacky */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75 #endif
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 #undef _
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78 #ifdef DEBUG
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
79 # undef DEBUG
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 #endif
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 #ifdef _WIN32
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
82 # undef pipe
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 #endif
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
84
6575
87a0fb97d3b9 [gaim-migrate @ 7097]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6549
diff changeset
85 #ifdef _WIN32
87a0fb97d3b9 [gaim-migrate @ 7097]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6549
diff changeset
86 #define _WIN32DEP_H_
87a0fb97d3b9 [gaim-migrate @ 7097]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6549
diff changeset
87 #endif
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
88 #include "internal.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
89 #include "debug.h"
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
90 #include "plugin.h"
6531
7c42b8ca3222 [gaim-migrate @ 7048]
Christian Hammond <chipx86@chipx86.com>
parents: 6527
diff changeset
91 #include "signals.h"
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92
6526
e162c765fe21 [gaim-migrate @ 7043]
Christian Hammond <chipx86@chipx86.com>
parents: 6525
diff changeset
93 #include "perl-common.h"
6522
0c5233faceb8 [gaim-migrate @ 7039]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
94 #include "perl-handlers.h"
0c5233faceb8 [gaim-migrate @ 7039]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
95
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96 #define PERL_PLUGIN_ID "core-perl"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
98 typedef struct
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
99 {
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
100 GaimPlugin *plugin;
6636
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
101 char *package;
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
102 char *load_sub;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
103 char *unload_sub;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
105 } GaimPerlScript;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
108 PerlInterpreter *my_perl = NULL;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 static void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111 #ifdef OLD_PERL
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 xs_init()
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 #else
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 xs_init(pTHX)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115 #endif
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117 char *file = __FILE__;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119 /* This one allows dynamic loading of perl modules in perl
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120 scripts by the 'use perlmod;' construction*/
6636
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
121 newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
124
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
125 static void
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
126 perl_init(void)
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
127 {
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
128 /* changed the name of the variable from load_file to
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
129 perl_definitions since now it does much more than defining
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
130 the load_file sub. Moreover, deplaced the initialisation to
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
131 the xs_init function. (TheHobbit)*/
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
132 char *perl_args[] = { "", "-e", "0", "-w" };
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
133 char perl_definitions[] =
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
134 {
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
135 /* We use to function one to load a file the other to
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
136 execute the string obtained from the first and holding
8735
92cbf9713795 [gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents: 8138
diff changeset
137 the file contents. This allows to have a really local $/
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
138 without introducing temp variables to hold the old
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
139 value. Just a question of style:) */
6636
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
140 "package Gaim::PerlLoader;"
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
141 "use Symbol;"
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
142
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
143 "sub load_file {"
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
144 "my $f_name=shift;"
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
145 "local $/=undef;"
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
146 "open FH,$f_name or return \"__FAILED__\";"
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
147 "$_=<FH>;"
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
148 "close FH;"
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
149 "return $_;"
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
150 "}"
6636
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
151
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
152 "sub destroy_package {"
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
153 "eval { $_[0]->UNLOAD() if $_[0]->can('UNLOAD'); };"
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
154 "Symbol::delete_package($_[0]);"
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
155 "}"
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
156
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
157 "sub load_n_eval {"
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
158 "my ($f_name, $package) = @_;"
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
159 "destroy_package($package);"
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
160 "my $strin=load_file($f_name);"
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
161 "return 2 if($strin eq \"__FAILED__\");"
6636
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
162 "my $eval = qq{package $package; $strin;};"
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
163
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
164 "{"
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
165 " eval $eval;"
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
166 "}"
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
167
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
168 "if($@) {"
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
169 /*" #something went wrong\n"*/
6636
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
170 "die(\"Errors loading file $f_name: $@\");"
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
171 "}"
6636
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
172
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
173 "return 0;"
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
174 "}"
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
175 };
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
176
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
177 my_perl = perl_alloc();
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
178 perl_construct(my_perl);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
179 #ifdef DEBUG
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
180 perl_parse(my_perl, xs_init, 4, perl_args, NULL);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
181 #else
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
182 perl_parse(my_perl, xs_init, 3, perl_args, NULL);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
183 #endif
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
184 #ifdef HAVE_PERL_EVAL_PV
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
185 eval_pv(perl_definitions, TRUE);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
186 #else
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
187 perl_eval_pv(perl_definitions, TRUE); /* deprecated */
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
188 #endif
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
189
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
190 perl_run(my_perl);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193 static void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
194 perl_end(void)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195 {
6520
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
196 if (my_perl == NULL)
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
197 return;
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
198
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
199 perl_eval_pv(
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
200 "foreach my $lib (@DynaLoader::dl_modules) {"
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
201 "if ($lib =~ /^Gaim\\b/) {"
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
202 "$lib .= '::deinit();';"
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
203 "eval $lib;"
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
204 "}"
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
205 "}",
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
206 TRUE);
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
207
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
208 perl_destruct(my_perl);
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
209 perl_free(my_perl);
2e2593d95121 [gaim-migrate @ 7037]
Christian Hammond <chipx86@chipx86.com>
parents: 6508
diff changeset
210 my_perl = NULL;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
213 void
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
214 gaim_perl_callXS(void (*subaddr)(pTHX_ CV *cv), CV *cv, SV **mark)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215 {
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
216 dSP;
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
217
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
218 PUSHMARK(mark);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
219 (*subaddr)(aTHX_ cv);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
221 PUTBACK;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223
6636
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
224 static void
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
225 normalize_script_name(char *name)
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
226 {
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
227 char *c;
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
228
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
229 c = strrchr(name, '.');
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
230
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
231 if (c != NULL)
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
232 *c = '\0';
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
233
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
234 for (c = name; *c != '\0'; c++)
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
235 {
8095
4396d1088273 [gaim-migrate @ 8794]
Luke Schierer <lschiere@pidgin.im>
parents: 6678
diff changeset
236 if (*c != '_' && !g_ascii_isalnum(*c))
6636
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
237 *c = '_';
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
238 }
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
239 }
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
240
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
241 static gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
242 probe_perl_plugin(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244 /* XXX This would be much faster if I didn't create a new
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245 * PerlInterpreter every time I probed a plugin */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246 PerlInterpreter *prober = perl_alloc();
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
247 char *argv[] = {"", plugin->path };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
248 gboolean status = TRUE;
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
249 HV *plugin_info;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 perl_construct(prober);
5922
83507b72ae6d [gaim-migrate @ 6362]
Luke Schierer <lschiere@pidgin.im>
parents: 5912
diff changeset
252 perl_parse(prober, xs_init, 2, argv, NULL);
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
253 perl_run(prober);
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
254
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
255 plugin_info = perl_get_hv("PLUGIN_INFO", FALSE);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
256
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
257 if (plugin_info == NULL)
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
258 status = FALSE;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
259 else if (!hv_exists(plugin_info, "perl_api_version",
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
260 strlen("perl_api_version")) ||
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
261 !hv_exists(plugin_info, "name", strlen("name")) ||
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
262 !hv_exists(plugin_info, "load", strlen("load")))
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
263 {
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
264 /* Not a valid plugin. */
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
265
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
266 status = FALSE;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
267 }
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
268 else
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
269 {
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
270 SV **key;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
271 int perl_api_ver;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
272
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
273 key = hv_fetch(plugin_info, "perl_api_version",
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
274 strlen("perl_api_version"), 0);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
275
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
276 perl_api_ver = SvIV(*key);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
277
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
278 if (perl_api_ver != 2)
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
279 status = FALSE;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
280 else
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
281 {
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
282 GaimPluginInfo *info;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
283 GaimPerlScript *gps;
6636
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
284 char *basename;
6678
eb95f31fa4eb [gaim-migrate @ 7203]
Christian Hammond <chipx86@chipx86.com>
parents: 6636
diff changeset
285 STRLEN len;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
286
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
287 gaim_debug(GAIM_DEBUG_INFO, "perl", "Found plugin info\n");
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
288
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
289 info = g_new0(GaimPluginInfo, 1);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
290 gps = g_new0(GaimPerlScript, 1);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
291
8761
10caa1ec2dc4 [gaim-migrate @ 9516]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
292 info->api_version = GAIM_PLUGIN_API_VERSION;
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
293 info->type = GAIM_PLUGIN_STANDARD;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
294
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
295 info->dependencies = g_list_append(info->dependencies,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
296 PERL_PLUGIN_ID);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
297
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
298 gps->plugin = plugin;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
299
6636
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
300 basename = g_path_get_basename(plugin->path);
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
301 normalize_script_name(basename);
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
302 gps->package = g_strdup_printf("Gaim::Script::%s", basename);
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
303 g_free(basename);
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
304
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
305 /* We know this one exists. */
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
306 key = hv_fetch(plugin_info, "name", strlen("name"), 0);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
307 info->name = g_strdup(SvPV(*key, len));
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
308
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
309 if ((key = hv_fetch(plugin_info, "url", strlen("url"), 0)))
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
310 info->homepage = g_strdup(SvPV(*key, len));
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
311
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
312 if ((key = hv_fetch(plugin_info, "author", strlen("author"), 0)))
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
313 info->author = g_strdup(SvPV(*key, len));
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
314
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
315 if ((key = hv_fetch(plugin_info, "summary",
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
316 strlen("summary"), 0)))
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
317 info->summary = g_strdup(SvPV(*key, len));
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
318
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
319 if ((key = hv_fetch(plugin_info, "description",
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
320 strlen("description"), 0)))
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
321 info->description = g_strdup(SvPV(*key, len));
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
322
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
323 if ((key = hv_fetch(plugin_info, "version", strlen("version"), 0)))
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
324 info->version = g_strdup(SvPV(*key, len));
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
325
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
326 if ((key = hv_fetch(plugin_info, "load", strlen("load"), 0)))
6636
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
327 gps->load_sub = g_strdup_printf("%s::%s", gps->package,
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
328 SvPV(*key, len));
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
329
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
330 if ((key = hv_fetch(plugin_info, "unload", strlen("unload"), 0)))
6636
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
331 gps->unload_sub = g_strdup_printf("%s::%s", gps->package,
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
332 SvPV(*key, len));
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
333
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
334 plugin->info = info;
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
335 info->extra_info = gps;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
336
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
337 status = gaim_plugin_register(plugin);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
338 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
339 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
340
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
341 perl_destruct(prober);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
342 perl_free(prober);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
343
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
344 return status;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
345 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
346
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
347 static gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
348 load_perl_plugin(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
349 {
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
350 GaimPerlScript *gps = (GaimPerlScript *)plugin->info->extra_info;
6636
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
351 char *atmp[3] = { plugin->path, NULL, NULL };
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
352
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
353 if (gps == NULL || gps->load_sub == NULL)
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
354 return FALSE;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
355
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
356 gaim_debug(GAIM_DEBUG_INFO, "perl", "Loading perl script\n");
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
357
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
358 if (my_perl == NULL)
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
359 perl_init();
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
360
6636
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
361 plugin->handle = gps;
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
362
6636
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
363 atmp[1] = gps->package;
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
364
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
365 execute_perl("Gaim::PerlLoader::load_n_eval", 2, atmp);
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
366
6536
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
367 {
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
368 dSP;
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
369 ENTER;
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
370 SAVETMPS;
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
371 PUSHMARK(sp);
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
372 XPUSHs(sv_2mortal(gaim_perl_bless_object(plugin, "Gaim::Plugin")));
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
373 PUTBACK;
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
374
6536
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
375 perl_call_pv(gps->load_sub, G_EVAL | G_SCALAR);
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
376 SPAGAIN;
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
377
6536
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
378 if (SvTRUE(ERRSV)) {
6678
eb95f31fa4eb [gaim-migrate @ 7203]
Christian Hammond <chipx86@chipx86.com>
parents: 6636
diff changeset
379 STRLEN len;
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
380
6536
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
381 gaim_debug(GAIM_DEBUG_ERROR, "perl",
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
382 "Perl function %s exited abnormally: %s\n",
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
383 gps->load_sub, SvPV(ERRSV, len));
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
384 }
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
385
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
386 PUTBACK;
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
387 FREETMPS;
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
388 LEAVE;
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
389 }
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
390
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
391 return TRUE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
392 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
393
6636
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
394 static void
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
395 destroy_package(const char *package)
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
396 {
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
397 dSP;
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
398
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
399 ENTER;
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
400 SAVETMPS;
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
401
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
402 PUSHMARK(SP);
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
403 XPUSHs(sv_2mortal(newSVpv(package, strlen(package))));
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
404 PUTBACK;
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
405
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
406 perl_call_pv("Gaim::PerlLoader::destroy_package",
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
407 G_VOID | G_EVAL | G_DISCARD);
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
408
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
409 SPAGAIN;
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
410
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
411 PUTBACK;
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
412 FREETMPS;
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
413 LEAVE;
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
414 }
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
415
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
416 static gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
417 unload_perl_plugin(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
418 {
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
419 GaimPerlScript *gps = (GaimPerlScript *)plugin->info->extra_info;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
420
9578
7cd7da72c872 [gaim-migrate @ 10421]
Christian Hammond <chipx86@chipx86.com>
parents: 8993
diff changeset
421 if (gps == NULL)
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
422 return FALSE;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
423
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
424 gaim_debug(GAIM_DEBUG_INFO, "perl", "Unloading perl script\n");
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
425
9578
7cd7da72c872 [gaim-migrate @ 10421]
Christian Hammond <chipx86@chipx86.com>
parents: 8993
diff changeset
426 if (gps->unload_sub != NULL)
6536
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
427 {
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
428 dSP;
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
429 ENTER;
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
430 SAVETMPS;
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
431 PUSHMARK(sp);
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
432 XPUSHs(sv_2mortal(gaim_perl_bless_object(plugin, "Gaim::Plugin")));
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
433 PUTBACK;
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
434
6536
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
435 perl_call_pv(gps->unload_sub, G_EVAL | G_SCALAR);
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
436 SPAGAIN;
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
437
6536
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
438 if (SvTRUE(ERRSV)) {
6678
eb95f31fa4eb [gaim-migrate @ 7203]
Christian Hammond <chipx86@chipx86.com>
parents: 6636
diff changeset
439 STRLEN len;
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
440
6536
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
441 gaim_debug(GAIM_DEBUG_ERROR, "perl",
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
442 "Perl function %s exited abnormally: %s\n",
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
443 gps->load_sub, SvPV(ERRSV, len));
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
444 }
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
445
6536
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
446 PUTBACK;
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
447 FREETMPS;
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
448 LEAVE;
9767117bc47e [gaim-migrate @ 7053]
Christian Hammond <chipx86@chipx86.com>
parents: 6531
diff changeset
449 }
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
450
6549
ed796f756237 [gaim-migrate @ 7071]
Christian Hammond <chipx86@chipx86.com>
parents: 6536
diff changeset
451 gaim_perl_signal_clear_for_plugin(plugin);
6522
0c5233faceb8 [gaim-migrate @ 7039]
Christian Hammond <chipx86@chipx86.com>
parents: 6520
diff changeset
452 gaim_perl_timeout_clear_for_plugin(plugin);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
453
6636
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
454 destroy_package(gps->package);
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
455
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
456 return TRUE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
457 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
458
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
459 static void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
460 destroy_perl_plugin(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
461 {
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
462 if (plugin->info != NULL)
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
463 {
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
464 GaimPerlScript *gps;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
465
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
466 if (plugin->info->name != NULL)
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
467 g_free(plugin->info->name);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
468
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
469 if (plugin->info->version != NULL)
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
470 g_free(plugin->info->version);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
471
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
472 if (plugin->info->summary != NULL)
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
473 g_free(plugin->info->summary);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
474
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
475 if (plugin->info->description != NULL)
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
476 g_free(plugin->info->description);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
477
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
478 if (plugin->info->author != NULL)
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
479 g_free(plugin->info->author);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
480
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
481 if (plugin->info->homepage != NULL)
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
482 g_free(plugin->info->homepage);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
483
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
484 gps = (GaimPerlScript *)plugin->info->extra_info;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
485
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
486 if (gps != NULL)
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
487 {
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
488 if (gps->load_sub != NULL)
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
489 g_free(gps->load_sub);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
490
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
491 if (gps->unload_sub != NULL)
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
492 g_free(gps->unload_sub);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
493
6636
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
494 if (gps->package != NULL)
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
495 g_free(gps->package);
452c62a92963 [gaim-migrate @ 7161]
Christian Hammond <chipx86@chipx86.com>
parents: 6575
diff changeset
496
6508
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
497 g_free(gps);
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
498 plugin->info->extra_info = NULL;
cbd24b37350d [gaim-migrate @ 7025]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
499 }
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
500 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
501 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
502
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
503 static gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
504 plugin_unload(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
505 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
506 perl_end();
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
507
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
508 return TRUE;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
509 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
510
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
511 static GaimPluginLoaderInfo loader_info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
512 {
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
513 GAIM_LOADER_API_VERSION, /**< api_version */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
514 NULL, /**< exts */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
515
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
516 probe_perl_plugin, /**< probe */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
517 load_perl_plugin, /**< load */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
518 unload_perl_plugin, /**< unload */
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
519 destroy_perl_plugin /**< destroy */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
520 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
521
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
522 static GaimPluginInfo info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
523 {
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8735
diff changeset
524 GAIM_PLUGIN_API_VERSION, /**< api_version */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
525 GAIM_PLUGIN_LOADER, /**< type */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
526 NULL, /**< ui_requirement */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
527 0, /**< flags */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
528 NULL, /**< dependencies */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
529 GAIM_PRIORITY_DEFAULT, /**< priority */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
530
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
531 PERL_PLUGIN_ID, /**< id */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
532 N_("Perl Plugin Loader"), /**< name */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
533 VERSION, /**< version */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
534 N_("Provides support for loading perl plugins."), /**< summary */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
535 N_("Provides support for loading perl plugins."), /**< description */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
536 "Christian Hammond <chipx86@gnupdate.org>", /**< author */
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 6235
diff changeset
537 GAIM_WEBSITE, /**< homepage */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
538
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
539 NULL, /**< load */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
540 plugin_unload, /**< unload */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
541 NULL, /**< destroy */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
542
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
543 NULL, /**< ui_info */
8993
294ae6548d4e [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8761
diff changeset
544 &loader_info, /**< extra_info */
294ae6548d4e [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8761
diff changeset
545 NULL,
294ae6548d4e [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8761
diff changeset
546 NULL
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
547 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
548
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
549 static void
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5775
diff changeset
550 init_plugin(GaimPlugin *plugin)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
551 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
552 loader_info.exts = g_list_append(loader_info.exts, "pl");
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
553 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
554
6063
5239a3b4ab33 [gaim-migrate @ 6513]
Nathan Walp <nwalp@pidgin.im>
parents: 6036
diff changeset
555 GAIM_INIT_PLUGIN(perl, init_plugin, info)