Mercurial > pidgin.yaz
annotate plugins/perl/perl.c @ 6328:cbe2f320c214
[gaim-migrate @ 6827]
Updated the Rename Group dialog to be more like the old one.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Tue, 29 Jul 2003 05:59:58 +0000 |
parents | 1049dd7e976e |
children | 8f94cce8faa5 |
rev | line source |
---|---|
5205 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 * This was taken almost exactly from X-Chat. The power of the GPL. | |
21 * Translated from X-Chat to Gaim by Eric Warmenhoven. | |
22 * Originally by Erik Scrafford <eriks@chilisoft.com>. | |
23 * X-Chat Copyright (C) 1998 Peter Zelezny. | |
24 * | |
25 */ | |
6235 | 26 |
27 #ifdef HAVE_CONFIG_H | |
28 #include <config.h> | |
29 #endif | |
30 | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
31 #ifdef DEBUG |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
32 # undef DEBUG |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
33 #endif |
5205 | 34 |
35 #undef PACKAGE | |
36 | |
37 #define group perl_group | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
38 |
5205 | 39 #ifdef _WIN32 |
40 /* This took me an age to figure out.. without this __declspec(dllimport) | |
41 * will be ignored. | |
42 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
43 # define HASATTRIBUTE |
5205 | 44 #endif |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
45 |
5205 | 46 #include <EXTERN.h> |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
47 |
5205 | 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 | 50 #endif |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
51 |
5205 | 52 #include <perl.h> |
53 #include <XSUB.h> | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
54 |
5205 | 55 #ifndef _WIN32 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
56 # include <sys/mman.h> |
5205 | 57 #endif |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
58 |
5205 | 59 #undef PACKAGE |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
60 |
5205 | 61 #ifndef _WIN32 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
62 # include <dirent.h> |
5205 | 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 | 66 #endif |
67 | |
68 #undef group | |
69 | |
70 /* perl module support */ | |
71 #ifdef OLD_PERL | |
72 extern void boot_DynaLoader _((CV * cv)); | |
73 #else | |
74 extern void boot_DynaLoader _((pTHX_ CV * cv)); /* perl is so wacky */ | |
75 #endif | |
76 | |
77 #undef _ | |
78 #ifdef DEBUG | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
79 # undef DEBUG |
5205 | 80 #endif |
81 #ifdef _WIN32 | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
82 # undef pipe |
5205 | 83 #endif |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
84 |
5912
b3c412884a22
[gaim-migrate @ 6344]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5873
diff
changeset
|
85 #ifdef _WIN32 |
b3c412884a22
[gaim-migrate @ 6344]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5873
diff
changeset
|
86 #define _WIN32DEP_H_ |
b3c412884a22
[gaim-migrate @ 6344]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5873
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 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
90 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
91 #include "prpl.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
92 #include "notify.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
93 #include "server.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
94 #include "sound.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
95 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
96 #include "ui.h" |
5205 | 97 |
98 #ifndef call_pv | |
99 # define call_pv(i,j) perl_call_pv((i), (j)) | |
100 #endif | |
101 | |
102 #define PERL_PLUGIN_ID "core-perl" | |
103 | |
104 struct perlscript { | |
105 char *name; | |
106 char *version; | |
107 char *shutdowncallback; /* bleh */ | |
108 GaimPlugin *plug; | |
109 }; | |
110 | |
111 struct _perl_event_handlers { | |
112 char *event_type; | |
113 char *handler_name; | |
114 GaimPlugin *plug; | |
115 }; | |
116 | |
117 struct _perl_timeout_handlers { | |
118 char *handler_name; | |
119 char *handler_args; | |
120 gint iotag; | |
121 GaimPlugin *plug; | |
122 }; | |
123 | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5408
diff
changeset
|
124 static GaimPlugin *my_plugin = NULL; |
5205 | 125 static GList *perl_list = NULL; |
126 static GList *perl_timeout_handlers = NULL; | |
127 static GList *perl_event_handlers = NULL; | |
128 static PerlInterpreter *my_perl = NULL; | |
129 static void perl_init(); | |
130 | |
131 /* dealing with gaim */ | |
132 XS(XS_GAIM_register); /* set up hooks for script */ | |
133 XS(XS_GAIM_get_info); /* version, last to attempt signon, protocol */ | |
134 XS(XS_GAIM_print); /* lemme figure this one out... */ | |
135 XS(XS_GAIM_write_to_conv); /* write into conversation window */ | |
136 | |
137 /* list stuff */ | |
138 XS(XS_GAIM_buddy_list); /* all buddies */ | |
139 XS(XS_GAIM_online_list); /* online buddies */ | |
140 | |
141 /* server stuff */ | |
142 XS(XS_GAIM_command); /* send command to server */ | |
143 XS(XS_GAIM_user_info); /* given name, return struct buddy members */ | |
144 XS(XS_GAIM_print_to_conv); /* send message to someone */ | |
145 XS(XS_GAIM_print_to_chat); /* send message to chat room */ | |
146 XS(XS_GAIM_serv_send_im); /* send message to someone (but do not display) */ | |
147 | |
148 /* handler commands */ | |
149 XS(XS_GAIM_add_event_handler); /* when servers talk */ | |
150 XS(XS_GAIM_remove_event_handler); /* remove a handler */ | |
151 XS(XS_GAIM_add_timeout_handler); /* figure it out */ | |
152 | |
153 /* play sound */ | |
154 XS(XS_GAIM_play_sound); /*play a sound */ | |
155 | |
156 static void | |
157 #ifdef OLD_PERL | |
158 xs_init() | |
159 #else | |
160 xs_init(pTHX) | |
161 #endif | |
162 { | |
163 char *file = __FILE__; | |
164 | |
165 /* This one allows dynamic loading of perl modules in perl | |
166 scripts by the 'use perlmod;' construction*/ | |
167 newXS ("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); | |
168 | |
169 /* load up all the custom Gaim perl functions */ | |
170 newXS ("GAIM::register", XS_GAIM_register, "GAIM"); | |
171 newXS ("GAIM::get_info", XS_GAIM_get_info, "GAIM"); | |
172 newXS ("GAIM::print", XS_GAIM_print, "GAIM"); | |
173 newXS ("GAIM::write_to_conv", XS_GAIM_write_to_conv, "GAIM"); | |
174 | |
175 newXS ("GAIM::buddy_list", XS_GAIM_buddy_list, "GAIM"); | |
176 newXS ("GAIM::online_list", XS_GAIM_online_list, "GAIM"); | |
177 | |
178 newXS ("GAIM::command", XS_GAIM_command, "GAIM"); | |
179 newXS ("GAIM::user_info", XS_GAIM_user_info, "GAIM"); | |
180 newXS ("GAIM::print_to_conv", XS_GAIM_print_to_conv, "GAIM"); | |
181 newXS ("GAIM::print_to_chat", XS_GAIM_print_to_chat, "GAIM"); | |
182 newXS ("GAIM::serv_send_im", XS_GAIM_serv_send_im, "GAIM"); | |
183 | |
184 newXS ("GAIM::add_event_handler", XS_GAIM_add_event_handler, "GAIM"); | |
185 newXS ("GAIM::remove_event_handler", XS_GAIM_remove_event_handler, "GAIM"); | |
186 newXS ("GAIM::add_timeout_handler", XS_GAIM_add_timeout_handler, "GAIM"); | |
187 | |
188 newXS ("GAIM::play_sound", XS_GAIM_play_sound, "GAIM"); | |
189 } | |
190 | |
191 static char * | |
192 escape_quotes(const char *buf) | |
193 { | |
194 static char *tmp_buf = NULL; | |
195 const char *i; | |
196 char *j; | |
197 | |
198 if (tmp_buf) | |
199 g_free(tmp_buf); | |
200 | |
201 tmp_buf = g_malloc(strlen(buf) * 2 + 1); | |
202 | |
203 for (i = buf, j = tmp_buf; *i; i++, j++) { | |
204 if (*i == '\'' || *i == '\\') | |
205 *j++ = '\\'; | |
206 | |
207 *j = *i; | |
208 } | |
209 | |
210 *j = '\0'; | |
211 | |
212 return tmp_buf; | |
213 } | |
214 | |
215 /* | |
216 2003/02/06: execute_perl modified by Mark Doliner <mark@kingant.net> | |
217 Pass parameters by pushing them onto the stack rather than | |
218 passing an array of strings. This way, perl scripts can | |
219 modify the parameters and we can get the changed values | |
220 and then shoot ourselves. I mean, uh, use them. | |
221 | |
222 2001/06/14: execute_perl replaced by Martin Persson <mep@passagen.se> | |
223 previous use of perl_eval leaked memory, replaced with | |
224 a version that uses perl_call instead | |
225 | |
226 30/11/2002: execute_perl modified by Eric Timme <timothy@voidnet.com> | |
227 args changed to char** so that we can have preparsed | |
228 arguments again, and many headaches ensued! This essentially | |
229 means we replaced one hacked method with a messier hacked | |
230 method out of perceived necessity. Formerly execute_perl | |
231 required a single char_ptr, and it would insert it into an | |
232 array of character pointers and NULL terminate the new array. | |
233 Now we have to pass in pre-terminated character pointer arrays | |
234 to accomodate functions that want to pass in multiple arguments. | |
235 | |
236 Previously arguments were preparsed because an argument list | |
237 was constructed in the form 'arg one','arg two' and was | |
238 executed via a call like &funcname(arglist) (see .59.x), so | |
239 the arglist was magically pre-parsed because of the method. | |
240 With Martin Persson's change to perl_call we now need to | |
241 use a null terminated list of character pointers for arguments | |
242 if we wish them to be parsed. Lacking a better way to allow | |
243 for both single arguments and many I created a NULL terminated | |
244 array in every function that called execute_perl and passed | |
245 that list into the function. In the former version a single | |
246 character pointer was passed in, and was placed into an array | |
247 of character pointers with two elements, with a NULL element | |
248 tacked onto the back, but this method no longer seemed prudent. | |
249 | |
250 Enhancements in the future might be to get rid of pre-declaring | |
251 the array sizes? I am not comfortable enough with this | |
252 subject to attempt it myself and hope it to stand the test | |
253 of time. | |
254 */ | |
255 | |
256 static int | |
257 execute_perl(const char *function, int argc, char **args) | |
258 { | |
259 int count = 0, i, ret_value = 1; | |
260 SV *sv_args[argc]; | |
261 STRLEN na; | |
262 | |
263 /* | |
264 * Set up the perl environment, push arguments onto the | |
265 * perl stack, then call the given function | |
266 */ | |
267 dSP; | |
268 ENTER; | |
269 SAVETMPS; | |
270 PUSHMARK(sp); | |
271 | |
272 for (i = 0; i < argc; i++) { | |
273 if (args[i]) { | |
274 sv_args[i] = sv_2mortal(newSVpv(args[i], 0)); | |
275 XPUSHs(sv_args[i]); | |
276 } | |
277 } | |
278 | |
279 PUTBACK; | |
280 count = call_pv(function, G_EVAL | G_SCALAR); | |
281 SPAGAIN; | |
282 | |
283 /* | |
284 * Check for "die," make sure we have 1 argument, and set our | |
285 * return value. | |
286 */ | |
287 if (SvTRUE(ERRSV)) { | |
5227
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
288 gaim_debug(GAIM_DEBUG_ERROR, "perl", |
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
289 "Perl function %s exited abnormally: %s\n", |
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
290 function, SvPV(ERRSV, na)); |
5205 | 291 POPs; |
292 } | |
293 else if (count != 1) { | |
294 /* | |
295 * This should NEVER happen. G_SCALAR ensures that we WILL | |
296 * have 1 parameter. | |
297 */ | |
5227
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
298 gaim_debug(GAIM_DEBUG_ERROR, "perl", |
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
299 "Perl error from %s: expected 1 return value, " |
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
300 "but got %d\n", function, count); |
5205 | 301 } |
302 else | |
303 ret_value = POPi; | |
304 | |
305 /* Check for changed arguments */ | |
306 for (i = 0; i < argc; i++) { | |
307 if (args[i] && strcmp(args[i], SvPVX(sv_args[i]))) { | |
308 /* | |
309 * Shizzel. So the perl script changed one of the parameters, | |
310 * and we want this change to affect the original parameters. | |
311 * args[i] is just a tempory little list of pointers. We don't | |
312 * want to free args[i] here because the new parameter doesn't | |
313 * overwrite the data that args[i] points to. That is done by | |
314 * the function that called execute_perl. I'm not explaining this | |
315 * very well. See, it's aggregate... Oh, but if 2 perl scripts | |
316 * both modify the data, _that's_ a memleak. This is really kind | |
317 * of hackish. I should fix it. Look how long this comment is. | |
318 * Holy crap. | |
319 */ | |
320 args[i] = g_strdup(SvPV(sv_args[i], na)); | |
321 } | |
322 } | |
323 | |
324 PUTBACK; | |
325 FREETMPS; | |
326 LEAVE; | |
327 | |
328 return ret_value; | |
329 } | |
330 | |
331 static void | |
332 perl_unload_file(GaimPlugin *plug) | |
333 { | |
334 char *atmp[2] = { "", NULL }; | |
335 struct perlscript *scp = NULL; | |
336 struct _perl_timeout_handlers *thn; | |
337 struct _perl_event_handlers *ehn; | |
338 GList *pl; | |
339 | |
340 for (pl = perl_list; pl != NULL; pl = pl->next) { | |
341 scp = pl->data; | |
342 | |
343 if (scp->plug == plug) { | |
344 perl_list = g_list_remove(perl_list, scp); | |
345 | |
346 if (scp->shutdowncallback[0]) | |
347 execute_perl(scp->shutdowncallback, 1, atmp); | |
348 | |
349 g_free(scp->name); | |
350 g_free(scp->version); | |
351 g_free(scp->shutdowncallback); | |
352 g_free(scp); | |
353 | |
354 break; | |
355 } | |
356 } | |
357 | |
358 for (pl = perl_timeout_handlers; pl != NULL; pl = pl->next) { | |
359 thn = pl->data; | |
360 | |
361 if (thn && thn->plug == plug) { | |
362 perl_timeout_handlers = g_list_remove(perl_timeout_handlers, thn); | |
363 | |
364 g_source_remove(thn->iotag); | |
365 g_free(thn->handler_args); | |
366 g_free(thn->handler_name); | |
367 g_free(thn); | |
368 } | |
369 } | |
370 | |
371 for (pl = perl_event_handlers; pl != NULL; pl = pl->next) { | |
372 ehn = pl->data; | |
373 | |
374 if (ehn && ehn->plug == plug) { | |
375 perl_event_handlers = g_list_remove(perl_event_handlers, ehn); | |
376 | |
377 g_free(ehn->event_type); | |
378 g_free(ehn->handler_name); | |
379 g_free(ehn); | |
380 } | |
381 } | |
382 } | |
383 | |
384 static int | |
385 perl_load_file(char *script_name, GaimPlugin *plugin) | |
386 { | |
387 char *atmp[2] = { script_name, NULL }; | |
388 GList *s; | |
389 struct perlscript *scp; | |
390 int ret; | |
391 | |
392 if (my_perl == NULL) | |
393 perl_init(); | |
394 | |
395 plugin->handle = plugin->path; | |
396 | |
397 ret = execute_perl("load_n_eval", 1, atmp); | |
398 | |
399 for (s = perl_list; s != NULL; s = s->next) { | |
400 scp = s->data; | |
401 | |
402 if (!strcmp(scp->name, plugin->info->name) && | |
403 !strcmp(scp->version, plugin->info->version)) { | |
404 | |
405 break; | |
406 } | |
407 } | |
408 | |
409 if (!s) { | |
410 plugin->error = g_strdup(_("GAIM::register not called with " | |
411 "proper arguments. Consult PERL-HOWTO.")); | |
412 | |
413 return 0; | |
414 } | |
415 | |
416 return ret; | |
417 } | |
418 | |
419 static void | |
420 perl_init(void) | |
421 { | |
422 /* changed the name of the variable from load_file to | |
423 perl_definitions since now it does much more than defining | |
424 the load_file sub. Moreover, deplaced the initialisation to | |
425 the xs_init function. (TheHobbit)*/ | |
426 char *perl_args[] = { "", "-e", "0", "-w" }; | |
427 char perl_definitions[] = | |
428 { | |
429 /* We use to function one to load a file the other to | |
430 execute the string obtained from the first and holding | |
431 the file conents. This allows to have a realy local $/ | |
432 without introducing temp variables to hold the old | |
433 value. Just a question of style:) */ | |
434 "sub load_file{" | |
435 "my $f_name=shift;" | |
436 "local $/=undef;" | |
437 "open FH,$f_name or return \"__FAILED__\";" | |
438 "$_=<FH>;" | |
439 "close FH;" | |
440 "return $_;" | |
441 "}" | |
442 "sub load_n_eval{" | |
443 "my $f_name=shift;" | |
444 "my $strin=load_file($f_name);" | |
445 "return 2 if($strin eq \"__FAILED__\");" | |
446 "eval $strin;" | |
447 "if($@){" | |
448 /*" #something went wrong\n"*/ | |
449 "GAIM::print(\"Errors loading file $f_name:\\n\",\"$@\");" | |
450 "return 1;" | |
451 "}" | |
452 "return 0;" | |
453 "}" | |
454 }; | |
455 | |
456 my_perl = perl_alloc(); | |
457 perl_construct(my_perl); | |
458 #ifdef DEBUG | |
459 perl_parse(my_perl, xs_init, 4, perl_args, NULL); | |
460 #else | |
461 perl_parse(my_perl, xs_init, 3, perl_args, NULL); | |
462 #endif | |
463 #ifdef HAVE_PERL_EVAL_PV | |
464 eval_pv(perl_definitions, TRUE); | |
465 #else | |
466 perl_eval_pv(perl_definitions, TRUE); /* deprecated */ | |
467 #endif | |
468 } | |
469 | |
470 static void | |
471 perl_end(void) | |
472 { | |
473 char *atmp[2] = { "", NULL }; | |
474 struct perlscript *scp; | |
475 struct _perl_timeout_handlers *thn; | |
476 struct _perl_event_handlers *ehn; | |
477 | |
478 while (perl_list) { | |
479 scp = perl_list->data; | |
480 perl_list = g_list_remove(perl_list, scp); | |
481 | |
482 if (scp->shutdowncallback[0]) | |
483 execute_perl(scp->shutdowncallback, 1, atmp); | |
484 | |
485 g_free(scp->name); | |
486 g_free(scp->version); | |
487 g_free(scp->shutdowncallback); | |
488 g_free(scp); | |
489 } | |
490 | |
491 while (perl_timeout_handlers) { | |
492 thn = perl_timeout_handlers->data; | |
493 perl_timeout_handlers = g_list_remove(perl_timeout_handlers, thn); | |
494 g_source_remove(thn->iotag); | |
495 g_free(thn->handler_args); | |
496 g_free(thn->handler_name); | |
497 g_free(thn); | |
498 } | |
499 | |
500 while (perl_event_handlers) { | |
501 ehn = perl_event_handlers->data; | |
502 perl_event_handlers = g_list_remove(perl_event_handlers, ehn); | |
503 g_free(ehn->event_type); | |
504 g_free(ehn->handler_name); | |
505 g_free(ehn); | |
506 } | |
507 | |
508 if (my_perl != NULL) { | |
509 perl_destruct(my_perl); | |
510 perl_free(my_perl); | |
511 my_perl = NULL; | |
512 } | |
513 } | |
514 | |
515 XS (XS_GAIM_register) | |
516 { | |
517 char *name, *ver, *callback, *unused; /* exactly like X-Chat, eh? :) */ | |
518 unsigned int junk; | |
519 struct perlscript *scp; | |
520 GaimPlugin *plug = NULL; | |
521 GList *pl; | |
522 | |
523 dXSARGS; | |
524 items = 0; | |
525 | |
526 name = SvPV(ST(0), junk); | |
527 ver = SvPV(ST(1), junk); | |
528 callback = SvPV(ST(2), junk); | |
529 unused = SvPV(ST(3), junk); | |
530 | |
5227
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
531 gaim_debug(GAIM_DEBUG_INFO, "perl", |
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
532 "GAIM::register(%s, %s)\n", name, ver); |
5205 | 533 |
534 for (pl = gaim_plugins_get_all(); pl != NULL; pl = pl->next) { | |
535 plug = pl->data; | |
536 | |
537 if (!strcmp(name, plug->info->name) && | |
538 !strcmp(ver, plug->info->version)) { | |
539 | |
540 break; | |
541 } | |
542 | |
543 plug = NULL; | |
544 } | |
545 | |
546 if (plug) { | |
547 scp = g_new0(struct perlscript, 1); | |
548 scp->name = g_strdup(name); | |
549 scp->version = g_strdup(ver); | |
550 scp->shutdowncallback = g_strdup(callback); | |
551 scp->plug = plug; | |
552 perl_list = g_list_append(perl_list, scp); | |
553 XST_mPV(0, plug->path); | |
554 } | |
555 else | |
556 XST_mPV(0, NULL); | |
557 | |
558 XSRETURN (1); | |
559 } | |
560 | |
561 XS (XS_GAIM_get_info) | |
562 { | |
563 int i = 0; | |
564 dXSARGS; | |
565 items = 0; | |
566 | |
567 switch(SvIV(ST(0))) { | |
568 case 0: | |
569 XST_mPV(0, VERSION); | |
570 i = 1; | |
571 break; | |
572 | |
573 case 1: | |
574 { | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
575 GList *c = gaim_connections_get_all(); |
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
576 GaimConnection *gc; |
5205 | 577 |
578 while (c) { | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
579 gc = (GaimConnection *)c->data; |
5205 | 580 XST_mIV(i++, (guint)gc); |
581 c = c->next; | |
582 } | |
583 } | |
584 break; | |
585 | |
586 case 2: | |
587 { | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
588 GaimConnection *gc = |
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
589 (GaimConnection *)SvIV(ST(1)); |
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
590 GaimAccount *account = gaim_connection_get_account(gc); |
5205 | 591 |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
592 if (g_list_find(gaim_connections_get_all(), gc)) |
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
593 XST_mIV(i++, gaim_account_get_protocol(account)); |
5205 | 594 else |
595 XST_mIV(i++, -1); | |
596 } | |
597 break; | |
598 | |
599 case 3: | |
600 { | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
601 GaimConnection *gc = |
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
602 (GaimConnection *)SvIV(ST(1)); |
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
603 GaimAccount *account = gaim_connection_get_account(gc); |
5205 | 604 |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
605 if (g_list_find(gaim_connections_get_all(), gc)) |
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
606 XST_mPV(i++, gaim_account_get_username(account)); |
5205 | 607 else |
608 XST_mPV(i++, ""); | |
609 } | |
610 break; | |
611 | |
612 case 4: | |
613 { | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
614 GaimConnection *gc = |
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
615 (GaimConnection *)SvIV(ST(1)); |
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
616 GaimAccount *account = gaim_connection_get_account(gc); |
5205 | 617 |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
618 if (g_list_find(gaim_connections_get_all(), gc)) |
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
619 XST_mIV(i++, g_list_index(gaim_accounts_get_all(), |
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
620 account)); |
5205 | 621 else |
622 XST_mIV(i++, -1); | |
623 } | |
624 break; | |
625 | |
626 case 5: | |
627 { | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
628 GList *a = gaim_accounts_get_all(); |
5205 | 629 while (a) { |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
630 GaimAccount *account = a->data; |
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
631 XST_mPV(i++, gaim_account_get_username(account)); |
5205 | 632 a = a->next; |
633 } | |
634 } | |
635 break; | |
636 | |
637 case 6: | |
638 { | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
639 GList *a = gaim_accounts_get_all(); |
5205 | 640 while (a) { |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
641 GaimAccount *account = a->data; |
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
642 XST_mIV(i++, gaim_account_get_protocol(account)); |
5205 | 643 a = a->next; |
644 } | |
645 } | |
646 break; | |
647 | |
648 case 7: | |
649 { | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
650 GaimConnection *gc = |
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
651 (GaimConnection *)SvIV(ST(1)); |
5205 | 652 |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
653 if (g_list_find(gaim_connections_get_all(), gc)) |
5205 | 654 XST_mPV(i++, gc->prpl->info->name); |
655 else | |
656 XST_mPV(i++, "Unknown"); | |
657 } | |
658 break; | |
659 | |
660 default: | |
661 XST_mPV(0, "Error2"); | |
662 i = 1; | |
663 } | |
664 | |
665 XSRETURN(i); | |
666 } | |
667 | |
668 XS (XS_GAIM_print) | |
669 { | |
670 char *title; | |
671 char *message; | |
672 unsigned int junk; | |
673 dXSARGS; | |
674 items = 0; | |
675 | |
676 title = SvPV(ST(0), junk); | |
677 message = SvPV(ST(1), junk); | |
5445
ad9b6e65713b
[gaim-migrate @ 5827]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
678 gaim_notify_info(my_plugin, NULL, title, message); |
5205 | 679 XSRETURN(0); |
680 } | |
681 | |
682 XS (XS_GAIM_buddy_list) | |
683 { | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
684 GaimConnection *gc; |
5205 | 685 struct buddy *buddy; |
686 struct group *g; | |
687 GaimBlistNode *gnode,*bnode; | |
688 int i = 0; | |
689 dXSARGS; | |
690 items = 0; | |
691 | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
692 gc = (GaimConnection *)SvIV(ST(0)); |
5205 | 693 |
694 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { | |
695 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
696 continue; | |
697 g = (struct group *)gnode; | |
698 for(bnode = gnode->child; bnode; bnode = bnode->next) { | |
699 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
700 continue; | |
701 buddy = (struct buddy *)bnode; | |
702 if(buddy->account == gc->account) | |
703 XST_mPV(i++, buddy->name); | |
704 } | |
705 } | |
706 XSRETURN(i); | |
707 } | |
708 | |
709 XS (XS_GAIM_online_list) | |
710 { | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
711 GaimConnection *gc; |
5205 | 712 struct buddy *b; |
713 struct group *g; | |
714 GaimBlistNode *gnode,*bnode; | |
715 int i = 0; | |
716 dXSARGS; | |
717 items = 0; | |
718 | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
719 gc = (GaimConnection *)SvIV(ST(0)); |
5205 | 720 |
721 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { | |
722 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
723 continue; | |
724 g = (struct group *)gnode; | |
725 for(bnode = gnode->child; bnode; bnode = bnode->next) { | |
726 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
727 continue; | |
728 b = (struct buddy *)bnode; | |
729 if (b->account == gc->account && GAIM_BUDDY_IS_ONLINE(b)) XST_mPV(i++, b->name); | |
730 } | |
731 } | |
732 XSRETURN(i); | |
733 } | |
734 | |
735 XS (XS_GAIM_command) | |
736 { | |
737 unsigned int junk; | |
738 char *command = NULL; | |
739 dXSARGS; | |
740 items = 0; | |
741 | |
742 command = SvPV(ST(0), junk); | |
743 if (!command) XSRETURN(0); | |
744 if (!strncasecmp(command, "signon", 6)) { | |
745 int index = SvIV(ST(1)); | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
746 if (g_list_nth_data(gaim_accounts_get_all(), index)) |
6036 | 747 gaim_account_connect(g_list_nth_data(gaim_accounts_get_all(), index)); |
5205 | 748 } else if (!strncasecmp(command, "signoff", 7)) { |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
749 GaimConnection *gc = (GaimConnection *)SvIV(ST(1)); |
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
750 if (g_list_find(gaim_connections_get_all(), gc)) |
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
751 gaim_connection_disconnect(gc); |
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
752 else |
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
753 gaim_connections_disconnect_all(); |
5205 | 754 } else if (!strncasecmp(command, "info", 4)) { |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
755 GaimConnection *gc = (GaimConnection *)SvIV(ST(1)); |
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
756 if (g_list_find(gaim_connections_get_all(), gc)) |
5205 | 757 serv_set_info(gc, SvPV(ST(2), junk)); |
758 } else if (!strncasecmp(command, "away", 4)) { | |
759 char *message = SvPV(ST(1), junk); | |
760 static struct away_message a; | |
761 g_snprintf(a.message, sizeof(a.message), "%s", message); | |
762 do_away_message(NULL, &a); | |
763 } else if (!strncasecmp(command, "back", 4)) { | |
5775 | 764 do_im_back(NULL, NULL); |
5205 | 765 } else if (!strncasecmp(command, "idle", 4)) { |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
766 GList *c = gaim_connections_get_all(); |
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
767 GaimConnection *gc; |
5205 | 768 |
769 while (c) { | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
770 gc = (GaimConnection *)c->data; |
5205 | 771 serv_set_idle(gc, SvIV(ST(1))); |
772 c = c->next; | |
773 } | |
774 } else if (!strncasecmp(command, "warn", 4)) { | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
775 GList *c = gaim_connections_get_all(); |
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
776 GaimConnection *gc; |
5205 | 777 |
778 while (c) { | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
779 gc = (GaimConnection *)c->data; |
5205 | 780 serv_warn(gc, SvPV(ST(1), junk), SvIV(ST(2))); |
781 c = c->next; | |
782 } | |
783 } | |
784 | |
785 XSRETURN(0); | |
786 } | |
787 | |
788 XS (XS_GAIM_user_info) | |
789 { | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
790 GaimConnection *gc; |
5205 | 791 unsigned int junk; |
792 struct buddy *buddy = NULL; | |
793 dXSARGS; | |
794 items = 0; | |
795 | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
796 gc = (GaimConnection *)SvIV(ST(0)); |
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
797 if (g_list_find(gaim_connections_get_all(), gc)) |
5205 | 798 buddy = gaim_find_buddy(gc->account, SvPV(ST(1), junk)); |
799 | |
800 if (!buddy) | |
801 XSRETURN(0); | |
802 XST_mPV(0, buddy->name); | |
803 XST_mPV(1, gaim_get_buddy_alias(buddy)); | |
804 XST_mPV(2, GAIM_BUDDY_IS_ONLINE(buddy) ? "Online" : "Offline"); | |
805 XST_mIV(3, buddy->evil); | |
806 XST_mIV(4, buddy->signon); | |
807 XST_mIV(5, buddy->idle); | |
808 XSRETURN(6); | |
809 } | |
810 | |
811 XS (XS_GAIM_write_to_conv) | |
812 { | |
813 char *nick, *who, *what; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5586
diff
changeset
|
814 GaimConversation *c; |
5205 | 815 int junk; |
816 int send, wflags; | |
817 dXSARGS; | |
818 items = 0; | |
819 | |
820 nick = SvPV(ST(0), junk); | |
821 send = SvIV(ST(1)); | |
822 what = SvPV(ST(2), junk); | |
823 who = SvPV(ST(3), junk); | |
824 | |
825 if (!*who) who=NULL; | |
826 | |
827 switch (send) { | |
828 case 0: wflags=WFLAG_SEND; break; | |
829 case 1: wflags=WFLAG_RECV; break; | |
830 case 2: wflags=WFLAG_SYSTEM; break; | |
831 default: wflags=WFLAG_RECV; | |
832 } | |
833 | |
834 c = gaim_find_conversation(nick); | |
835 | |
836 if (!c) | |
837 c = gaim_conversation_new(GAIM_CONV_IM, NULL, nick); | |
838 | |
839 gaim_conversation_write(c, who, what, -1, wflags, time(NULL)); | |
840 XSRETURN(0); | |
841 } | |
842 | |
843 XS (XS_GAIM_serv_send_im) | |
844 { | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
845 GaimConnection *gc; |
5205 | 846 char *nick, *what; |
847 int isauto; | |
848 int junk; | |
849 dXSARGS; | |
850 items = 0; | |
851 | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
852 gc = (GaimConnection *)SvIV(ST(0)); |
5205 | 853 nick = SvPV(ST(1), junk); |
854 what = SvPV(ST(2), junk); | |
855 isauto = SvIV(ST(3)); | |
856 | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
857 if (!g_list_find(gaim_connections_get_all(), gc)) { |
5205 | 858 XSRETURN(0); |
859 return; | |
860 } | |
861 serv_send_im(gc, nick, what, -1, isauto); | |
862 XSRETURN(0); | |
863 } | |
864 | |
865 XS (XS_GAIM_print_to_conv) | |
866 { | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
867 GaimConnection *gc; |
5205 | 868 char *nick, *what; |
869 int isauto; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5586
diff
changeset
|
870 GaimConversation *c; |
5205 | 871 unsigned int junk; |
872 dXSARGS; | |
873 items = 0; | |
874 | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
875 gc = (GaimConnection *)SvIV(ST(0)); |
5205 | 876 nick = SvPV(ST(1), junk); |
877 what = SvPV(ST(2), junk); | |
878 isauto = SvIV(ST(3)); | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
879 if (!g_list_find(gaim_connections_get_all(), gc)) { |
5205 | 880 XSRETURN(0); |
881 return; | |
882 } | |
883 | |
884 c = gaim_find_conversation(nick); | |
885 | |
886 if (!c) | |
887 c = gaim_conversation_new(GAIM_CONV_IM, gc->account, nick); | |
888 else | |
889 gaim_conversation_set_account(c, gc->account); | |
890 | |
891 gaim_conversation_write(c, NULL, what, -1, | |
892 (WFLAG_SEND | (isauto ? WFLAG_AUTO : 0)), time(NULL)); | |
893 serv_send_im(gc, nick, what, -1, isauto ? IM_FLAG_AWAY : 0); | |
894 XSRETURN(0); | |
895 } | |
896 | |
897 | |
898 | |
899 XS (XS_GAIM_print_to_chat) | |
900 { | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
901 GaimConnection *gc; |
5205 | 902 int id; |
903 char *what; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5586
diff
changeset
|
904 GaimConversation *b = NULL; |
5205 | 905 GSList *bcs; |
906 unsigned int junk; | |
907 dXSARGS; | |
908 items = 0; | |
909 | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
910 gc = (GaimConnection *)SvIV(ST(0)); |
5205 | 911 id = SvIV(ST(1)); |
912 what = SvPV(ST(2), junk); | |
913 | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
914 if (!g_list_find(gaim_connections_get_all(), gc)) { |
5205 | 915 XSRETURN(0); |
916 return; | |
917 } | |
918 bcs = gc->buddy_chats; | |
919 while (bcs) { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5586
diff
changeset
|
920 b = (GaimConversation *)bcs->data; |
5205 | 921 |
922 if (gaim_chat_get_id(gaim_conversation_get_chat_data(b)) == id) | |
923 break; | |
924 bcs = bcs->next; | |
925 b = NULL; | |
926 } | |
927 if (b) | |
928 serv_chat_send(gc, id, what); | |
929 XSRETURN(0); | |
930 } | |
931 | |
932 static int | |
933 perl_event(GaimEvent event, void *unused, va_list args) | |
934 { | |
935 char *buf[5] = { NULL, NULL, NULL, NULL, NULL }; /* Maximum of 5 args */ | |
936 void *arg1 = NULL, *arg2 = NULL, *arg3 = NULL, *arg4 = NULL, *arg5 = NULL; | |
937 char tmpbuf1[16], tmpbuf2[16], tmpbuf3[1]; | |
938 GList *handler; | |
939 struct _perl_event_handlers *data; | |
940 int handler_return; | |
941 | |
942 arg1 = va_arg(args, void *); | |
943 arg2 = va_arg(args, void *); | |
944 arg3 = va_arg(args, void *); | |
945 arg4 = va_arg(args, void *); | |
946 arg5 = va_arg(args, void *); | |
947 | |
948 tmpbuf1[0] = '\0'; | |
949 tmpbuf2[0] = '\0'; | |
950 tmpbuf3[0] = '\0'; | |
951 | |
952 /* Make a pretty array of char*'s with which to call perl functions */ | |
953 switch (event) { | |
5408
2af3224b329a
[gaim-migrate @ 5784]
Christian Hammond <chipx86@chipx86.com>
parents:
5227
diff
changeset
|
954 case event_connecting: |
5205 | 955 case event_signon: |
956 case event_signoff: | |
957 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); | |
958 buf[0] = tmpbuf1; | |
959 break; | |
960 case event_away: | |
961 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); | |
962 buf[0] = tmpbuf1; | |
5586
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
963 buf[1] = ((GaimConnection *)arg1)->away ? |
cde28f5c47d4
[gaim-migrate @ 5990]
Christian Hammond <chipx86@chipx86.com>
parents:
5470
diff
changeset
|
964 ((GaimConnection *)arg1)->away : tmpbuf2; |
5205 | 965 break; |
966 case event_im_recv: | |
967 if (!*(char**)arg2 || !*(char**)arg3) return 1; | |
968 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); | |
969 buf[0] = tmpbuf1; | |
970 buf[1] = *(char **)arg2; | |
971 buf[2] = *(char **)arg3; | |
972 break; | |
973 case event_im_send: | |
974 if (!*(char**)arg3) return 1; | |
975 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); | |
976 buf[0] = tmpbuf1; | |
977 buf[1] = arg2 ? arg2 : tmpbuf3; | |
978 buf[2] = *(char **)arg3; | |
979 break; | |
980 case event_buddy_signon: | |
981 case event_buddy_signoff: | |
982 case event_set_info: | |
983 case event_buddy_away: | |
984 case event_buddy_back: | |
985 case event_buddy_idle: | |
986 case event_buddy_unidle: | |
987 case event_got_typing: | |
988 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); | |
989 buf[0] = tmpbuf1; | |
990 buf[1] = arg2; | |
991 break; | |
992 case event_chat_invited: | |
993 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); | |
994 buf[0] = tmpbuf1; | |
995 buf[1] = arg2; | |
996 buf[2] = arg3; | |
997 buf[3] = arg4; | |
998 break; | |
999 case event_chat_join: | |
1000 case event_chat_buddy_join: | |
1001 case event_chat_buddy_leave: | |
1002 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); | |
1003 buf[0] = tmpbuf1; | |
1004 g_snprintf(tmpbuf2, 16, "%d", (int)arg2); | |
1005 buf[1] = tmpbuf2; | |
1006 buf[2] = arg3; | |
1007 break; | |
1008 case event_chat_leave: | |
1009 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); | |
1010 buf[0] = tmpbuf1; | |
1011 g_snprintf(tmpbuf2, 16, "%d", (int)arg2); | |
1012 buf[1] = tmpbuf2; | |
1013 break; | |
1014 case event_chat_recv: | |
1015 if (!*(char**)arg3 || !*(char**)arg4) return 1; | |
1016 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); | |
1017 buf[0] = tmpbuf1; | |
1018 g_snprintf(tmpbuf2, 16, "%d", (int)arg2); | |
1019 buf[1] = tmpbuf2; | |
1020 buf[2] = *(char **)arg3; | |
1021 buf[3] = *(char **)arg4; | |
1022 break; | |
1023 case event_chat_send_invite: | |
1024 if (!*(char**)arg4) return 1; | |
1025 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); | |
1026 buf[0] = tmpbuf1; | |
1027 g_snprintf(tmpbuf2, 16, "%d", (int)arg2); | |
1028 buf[1] = tmpbuf2; | |
1029 buf[2] = arg3; | |
1030 buf[3] = *(char **)arg4; | |
1031 break; | |
1032 case event_chat_send: | |
1033 if (!*(char**)arg3) return 1; | |
1034 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); | |
1035 buf[0] = tmpbuf1; | |
1036 g_snprintf(tmpbuf2, 16, "%d", (int)arg2); | |
1037 buf[1] = tmpbuf2; | |
1038 buf[2] = *(char **)arg3; | |
1039 break; | |
1040 case event_warned: | |
1041 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); | |
1042 buf[0] = tmpbuf1; | |
1043 buf[1] = arg2 ? arg2 : tmpbuf3; | |
1044 g_snprintf(tmpbuf2, 16, "%d", (int)arg3); | |
1045 buf[2] = tmpbuf2; | |
1046 break; | |
1047 case event_quit: | |
1048 case event_blist_update: | |
1049 buf[0] = tmpbuf3; | |
1050 break; | |
1051 case event_new_conversation: | |
1052 case event_del_conversation: | |
6100 | 1053 case event_conversation_switch: |
5205 | 1054 buf[0] = arg1; |
1055 break; | |
1056 case event_im_displayed_sent: | |
1057 if (!*(char**)arg3) return 1; | |
1058 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); | |
1059 buf[0] = tmpbuf1; | |
1060 buf[1] = arg2; | |
1061 buf[2] = *(char **)arg3; | |
1062 break; | |
1063 case event_im_displayed_rcvd: | |
1064 g_snprintf(tmpbuf1, 16, "%lu", (unsigned long)arg1); | |
1065 buf[0] = tmpbuf1; | |
1066 buf[1] = arg2; | |
1067 buf[2] = arg3 ? arg3 : tmpbuf3; | |
1068 break; | |
1069 case event_draw_menu: | |
1070 /* we can't handle this usefully without gtk/perl bindings */ | |
1071 return 0; | |
1072 default: | |
5227
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1073 gaim_debug(GAIM_DEBUG_WARNING, "perl", |
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1074 "Someone forgot to handle %s in the perl binding\n", |
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1075 gaim_event_get_name(event)); |
5205 | 1076 return 0; |
1077 } | |
1078 | |
1079 /* Call any applicable functions */ | |
1080 for (handler = perl_event_handlers; | |
1081 handler != NULL; | |
1082 handler = handler->next) { | |
1083 | |
1084 data = handler->data; | |
1085 | |
1086 if (!strcmp(gaim_event_get_name(event), data->event_type)) { | |
1087 | |
1088 handler_return = execute_perl(data->handler_name, 5, buf); | |
1089 | |
1090 if (handler_return) | |
1091 return handler_return; | |
1092 } | |
1093 } | |
1094 | |
1095 /* Now make changes from perl scripts affect the real data */ | |
1096 switch (event) { | |
1097 case event_im_recv: | |
1098 if (buf[1] != *(char **)arg2) { | |
1099 free(*(char **)arg2); | |
1100 *(char **)arg2 = buf[1]; | |
1101 } | |
1102 if (buf[2] != *(char **)arg3) { | |
1103 free(*(char **)arg3); | |
1104 *(char **)arg3 = buf[2]; | |
1105 } | |
1106 break; | |
1107 case event_im_send: | |
1108 if (buf[2] != *(char **)arg3) { | |
1109 free(*(char **)arg3); | |
1110 *(char **)arg3 = buf[2]; | |
1111 } | |
1112 break; | |
1113 case event_chat_recv: | |
1114 if (buf[2] != *(char **)arg3) { | |
1115 free(*(char **)arg3); | |
1116 *(char **)arg3 = buf[2]; | |
1117 } | |
1118 if (buf[3] != *(char **)arg4) { | |
1119 free(*(char **)arg4); | |
1120 *(char **)arg4 = buf[3]; | |
1121 } | |
1122 break; | |
1123 case event_chat_send_invite: | |
1124 if (buf[3] != *(char **)arg4) { | |
1125 free(*(char **)arg4); | |
1126 *(char **)arg4 = buf[3]; | |
1127 } | |
1128 break; | |
1129 case event_chat_send: | |
1130 if (buf[2] != *(char **)arg3) { | |
1131 free(*(char **)arg3); | |
1132 *(char **)arg3 = buf[2]; | |
1133 } | |
1134 break; | |
1135 case event_im_displayed_sent: | |
1136 if (buf[2] != *(char **)arg3) { | |
1137 free(*(char **)arg3); | |
1138 *(char **)arg3 = buf[2]; | |
1139 } | |
1140 break; | |
1141 default: | |
1142 break; | |
1143 } | |
1144 | |
1145 return 0; | |
1146 } | |
1147 | |
1148 XS (XS_GAIM_add_event_handler) | |
1149 { | |
1150 unsigned int junk; | |
1151 struct _perl_event_handlers *handler; | |
1152 char *handle; | |
1153 GaimPlugin *plug; | |
1154 GList *p; | |
1155 dXSARGS; | |
1156 items = 0; | |
1157 | |
1158 handle = SvPV(ST(0), junk); | |
1159 | |
1160 for (p = gaim_plugins_get_all(); p != NULL; p = p->next) { | |
1161 plug = p->data; | |
1162 | |
1163 if (!strcmp(handle, plug->path)) | |
1164 break; | |
1165 } | |
1166 | |
1167 if (p) { | |
1168 handler = g_new0(struct _perl_event_handlers, 1); | |
1169 handler->event_type = g_strdup(SvPV(ST(1), junk)); | |
1170 handler->handler_name = g_strdup(SvPV(ST(2), junk)); | |
1171 handler->plug = plug; | |
1172 perl_event_handlers = g_list_append(perl_event_handlers, handler); | |
5227
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1173 gaim_debug(GAIM_DEBUG_INFO, "perl", |
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1174 "Registered perl event handler for %s\n", |
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1175 handler->event_type); |
5205 | 1176 } else { |
5227
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1177 gaim_debug(GAIM_DEBUG_ERROR, "perl", |
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1178 "Invalid handle (%s) registering perl event handler\n", |
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1179 handle); |
5205 | 1180 } |
1181 | |
1182 XSRETURN_EMPTY; | |
1183 } | |
1184 | |
1185 XS (XS_GAIM_remove_event_handler) | |
1186 { | |
1187 unsigned int junk; | |
1188 struct _perl_event_handlers *ehn; | |
1189 GList *cur = perl_event_handlers; | |
1190 dXSARGS; | |
1191 items = 0; | |
1192 | |
1193 while (cur) { | |
1194 GList *next = cur->next; | |
1195 ehn = cur->data; | |
1196 | |
1197 if (!strcmp(ehn->event_type, SvPV(ST(0), junk)) && | |
1198 !strcmp(ehn->handler_name, SvPV(ST(1), junk))) | |
1199 { | |
1200 perl_event_handlers = g_list_remove(perl_event_handlers, ehn); | |
1201 g_free(ehn->event_type); | |
1202 g_free(ehn->handler_name); | |
1203 g_free(ehn); | |
1204 } | |
1205 | |
1206 cur = next; | |
1207 } | |
1208 } | |
1209 | |
1210 static int | |
1211 perl_timeout(gpointer data) | |
1212 { | |
1213 char *atmp[2] = { NULL, NULL }; | |
1214 struct _perl_timeout_handlers *handler = data; | |
1215 | |
1216 atmp[0] = escape_quotes(handler->handler_args); | |
1217 execute_perl(handler->handler_name, 1, atmp); | |
1218 | |
1219 perl_timeout_handlers = g_list_remove(perl_timeout_handlers, handler); | |
1220 g_free(handler->handler_args); | |
1221 g_free(handler->handler_name); | |
1222 g_free(handler); | |
1223 | |
1224 return 0; /* returning zero removes the timeout handler */ | |
1225 } | |
1226 | |
1227 XS (XS_GAIM_add_timeout_handler) | |
1228 { | |
1229 unsigned int junk; | |
1230 long timeout; | |
1231 struct _perl_timeout_handlers *handler; | |
1232 char *handle; | |
1233 GaimPlugin *plug; | |
1234 GList *p; | |
1235 | |
1236 dXSARGS; | |
1237 items = 0; | |
1238 | |
1239 handle = SvPV(ST(0), junk); | |
1240 | |
1241 for (p = gaim_plugins_get_all(); p != NULL; p = p->next) { | |
1242 plug = p->data; | |
1243 | |
1244 if (!strcmp(handle, plug->path)) | |
1245 break; | |
1246 } | |
1247 | |
1248 if (p) { | |
1249 handler = g_new0(struct _perl_timeout_handlers, 1); | |
1250 timeout = 1000 * SvIV(ST(1)); | |
5227
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1251 gaim_debug(GAIM_DEBUG_INFO, "perl", |
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1252 "Adding timeout for %ld seconds.\n", timeout/1000); |
5205 | 1253 handler->plug = plug; |
1254 handler->handler_name = g_strdup(SvPV(ST(2), junk)); | |
1255 handler->handler_args = g_strdup(SvPV(ST(3), junk)); | |
1256 perl_timeout_handlers = g_list_append(perl_timeout_handlers, handler); | |
1257 handler->iotag = g_timeout_add(timeout, perl_timeout, handler); | |
1258 } else { | |
5227
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1259 gaim_debug(GAIM_DEBUG_ERROR, "perl", |
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1260 "Invalid handle (%s) in adding perl timeout handler.", |
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
1261 handle); |
5205 | 1262 } |
1263 XSRETURN_EMPTY; | |
1264 } | |
1265 | |
1266 XS (XS_GAIM_play_sound) | |
1267 { | |
1268 int id; | |
1269 dXSARGS; | |
1270 | |
1271 items = 0; | |
1272 | |
1273 id = SvIV(ST(0)); | |
1274 | |
1275 gaim_sound_play_event(id); | |
1276 | |
1277 XSRETURN_EMPTY; | |
1278 } | |
1279 | |
1280 static gboolean | |
1281 probe_perl_plugin(GaimPlugin *plugin) | |
1282 { | |
1283 /* XXX This would be much faster if I didn't create a new | |
1284 * PerlInterpreter every time I probed a plugin */ | |
1285 | |
1286 GaimPluginInfo *info; | |
1287 PerlInterpreter *prober = perl_alloc(); | |
1288 char *argv[] = {"", plugin->path }; | |
1289 int count; | |
1290 gboolean status = TRUE; | |
1291 | |
1292 perl_construct(prober); | |
5922 | 1293 perl_parse(prober, xs_init, 2, argv, NULL); |
5205 | 1294 |
1295 { | |
1296 dSP; | |
1297 ENTER; | |
1298 SAVETMPS; | |
1299 PUSHMARK(SP); | |
1300 | |
1301 count = perl_call_pv("description", G_NOARGS | G_ARRAY | G_EVAL); | |
1302 SPAGAIN; | |
1303 | |
1304 if (count == 6) { | |
1305 info = g_new0(GaimPluginInfo, 1); | |
1306 | |
1307 info->api_version = 2; | |
1308 info->type = GAIM_PLUGIN_STANDARD; | |
1309 | |
1310 info->dependencies = g_list_append(info->dependencies, | |
1311 PERL_PLUGIN_ID); | |
1312 | |
1313 POPp; /* iconfile */ | |
1314 | |
1315 info->homepage = g_strdup(POPp); | |
1316 info->author = g_strdup(POPp); | |
1317 info->description = g_strdup(POPp); | |
1318 info->version = g_strdup(POPp); | |
1319 info->name = g_strdup(POPp); | |
1320 | |
1321 plugin->info = info; | |
1322 | |
1323 if (!gaim_plugin_register(plugin)) | |
1324 status = FALSE; | |
1325 } | |
1326 else | |
1327 status = FALSE; | |
1328 | |
1329 PUTBACK; | |
1330 FREETMPS; | |
1331 LEAVE; | |
1332 } | |
1333 | |
1334 perl_destruct(prober); | |
1335 perl_free(prober); | |
1336 | |
1337 return status; | |
1338 } | |
1339 | |
1340 static gboolean | |
1341 load_perl_plugin(GaimPlugin *plugin) | |
1342 { | |
1343 perl_load_file(plugin->path, plugin); | |
1344 | |
1345 return TRUE; | |
1346 } | |
1347 | |
1348 static gboolean | |
1349 unload_perl_plugin(GaimPlugin *plugin) | |
1350 { | |
1351 perl_unload_file(plugin); | |
1352 | |
1353 return TRUE; | |
1354 } | |
1355 | |
1356 static void | |
1357 destroy_perl_plugin(GaimPlugin *plugin) | |
1358 { | |
1359 if (plugin->info != NULL) { | |
1360 g_free(plugin->info->name); | |
1361 g_free(plugin->info->version); | |
1362 g_free(plugin->info->description); | |
1363 g_free(plugin->info->author); | |
1364 g_free(plugin->info->homepage); | |
1365 } | |
1366 } | |
1367 | |
1368 static gboolean | |
1369 plugin_unload(GaimPlugin *plugin) | |
1370 { | |
1371 perl_end(); | |
1372 | |
1373 return TRUE; | |
1374 } | |
1375 | |
1376 static GaimPluginLoaderInfo loader_info = | |
1377 { | |
1378 NULL, /**< exts */ | |
1379 | |
1380 probe_perl_plugin, /**< probe */ | |
1381 load_perl_plugin, /**< load */ | |
1382 unload_perl_plugin, /**< unload */ | |
1383 destroy_perl_plugin, /**< destroy */ | |
1384 perl_event /**< broadcast */ | |
1385 }; | |
1386 | |
1387 static GaimPluginInfo info = | |
1388 { | |
1389 2, /**< api_version */ | |
1390 GAIM_PLUGIN_LOADER, /**< type */ | |
1391 NULL, /**< ui_requirement */ | |
1392 0, /**< flags */ | |
1393 NULL, /**< dependencies */ | |
1394 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
1395 | |
1396 PERL_PLUGIN_ID, /**< id */ | |
1397 N_("Perl Plugin Loader"), /**< name */ | |
1398 VERSION, /**< version */ | |
1399 N_("Provides support for loading perl plugins."), /**< summary */ | |
1400 N_("Provides support for loading perl plugins."), /**< description */ | |
1401 "Christian Hammond <chipx86@gnupdate.org>", /**< author */ | |
1402 WEBSITE, /**< homepage */ | |
1403 | |
1404 NULL, /**< load */ | |
1405 plugin_unload, /**< unload */ | |
1406 NULL, /**< destroy */ | |
1407 | |
1408 NULL, /**< ui_info */ | |
1409 &loader_info /**< extra_info */ | |
1410 }; | |
1411 | |
1412 static void | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5775
diff
changeset
|
1413 init_plugin(GaimPlugin *plugin) |
5205 | 1414 { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5408
diff
changeset
|
1415 my_plugin = plugin; |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5408
diff
changeset
|
1416 |
5205 | 1417 loader_info.exts = g_list_append(loader_info.exts, "pl"); |
1418 } | |
1419 | |
6063 | 1420 GAIM_INIT_PLUGIN(perl, init_plugin, info) |