comparison src/perl.c @ 4298:cddb50734169

[gaim-migrate @ 4552] faceprint cleans up after my messes committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Sat, 11 Jan 2003 19:59:27 +0000
parents a614423c648f
children 0c68d402f59f
comparison
equal deleted inserted replaced
4297:650454171e0e 4298:cddb50734169
64 #include <string.h> 64 #include <string.h>
65 65
66 #undef group 66 #undef group
67 67
68 /* perl module support */ 68 /* perl module support */
69 extern void xs_init _((void)); 69 #ifdef OLD_PERL
70 extern void boot_DynaLoader _((CV * cv)); /* perl is so wacky */ 70 extern void boot_DynaLoader _((CV * cv));
71 #else
72 extern void boot_DynaLoader _((pTHX_ CV * cv)); /* perl is so wacky */
73 #endif
71 74
72 #undef _ 75 #undef _
73 #ifdef DEBUG 76 #ifdef DEBUG
74 #undef DEBUG 77 #undef DEBUG
75 #endif 78 #endif
128 XS(XS_GAIM_add_timeout_handler); /* figure it out */ 131 XS(XS_GAIM_add_timeout_handler); /* figure it out */
129 132
130 /* play sound */ 133 /* play sound */
131 XS(XS_GAIM_play_sound); /*play a sound*/ 134 XS(XS_GAIM_play_sound); /*play a sound*/
132 135
133 void xs_init() 136 static void
137 #ifdef OLD_PERL
138 xs_init()
139 #else
140 xs_init(pTHX)
141 #endif
134 { 142 {
135 char *file = __FILE__; 143 char *file = __FILE__;
136 144
137 /* This one allows dynamic loading of perl modules in perl 145 /* This one allows dynamic loading of perl modules in perl
138 scripts by the 'use perlmod;' construction*/ 146 scripts by the 'use perlmod;' construction*/
139 newXS ("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); 147 newXS ("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
140 148
141 /* load up all the custom Gaim perl functions */ 149 /* load up all the custom Gaim perl functions */
142 newXS ("GAIM::register", XS_GAIM_register, "GAIM"); 150 newXS ("GAIM::register", XS_GAIM_register, "GAIM");
143 newXS ("GAIM::get_info", XS_GAIM_get_info, "GAIM"); 151 newXS ("GAIM::get_info", XS_GAIM_get_info, "GAIM");
144 newXS ("GAIM::print", XS_GAIM_print, "GAIM"); 152 newXS ("GAIM::print", XS_GAIM_print, "GAIM");
145 newXS ("GAIM::write_to_conv", XS_GAIM_write_to_conv, "GAIM"); 153 newXS ("GAIM::write_to_conv", XS_GAIM_write_to_conv, "GAIM");
253 struct _perl_timeout_handlers *thn; 261 struct _perl_timeout_handlers *thn;
254 struct _perl_event_handlers *ehn; 262 struct _perl_event_handlers *ehn;
255 263
256 GList *pl = perl_list; 264 GList *pl = perl_list;
257 265
258 debug_printf("Unloading %s\n", plug->handle); 266 debug_printf("Unloading %s\n", plug->path);
259 while (pl) { 267 while (pl) {
260 scp = pl->data; 268 scp = pl->data;
261 if (scp->plug == plug) { 269 if (scp->plug == plug) {
262 perl_list = g_list_remove(perl_list, scp); 270 perl_list = g_list_remove(perl_list, scp);
263 if (scp->shutdowncallback[0]) 271 if (scp->shutdowncallback[0])
302 } 310 }
303 311
304 int perl_load_file(char *script_name) 312 int perl_load_file(char *script_name)
305 { 313 {
306 char *atmp[2] = { script_name, NULL }; /* see execute_perl --et */ 314 char *atmp[2] = { script_name, NULL }; /* see execute_perl --et */
307 struct gaim_plugin *plug; 315 struct gaim_plugin *plug = NULL;
308 GList *p = probed_plugins; 316 GList *p = probed_plugins;
309 GList *s; 317 GList *s;
310 struct perlscript *scp; 318 struct perlscript *scp;
311 int ret; 319 int ret;
312 320
346 354
347 plug->error[0] = '\0'; 355 plug->error[0] = '\0';
348 return ret; 356 return ret;
349 } 357 }
350 358
351 struct gaim_plugin *probe_perl(const char *filename) { 359 struct gaim_plugin *probe_perl(char *filename) {
352 360
353 /* XXX This woulld be much faster if I didn't create a new 361 /* XXX This woulld be much faster if I didn't create a new
354 * PerlInterpreter every time I probed a plugin */ 362 * PerlInterpreter every time I probed a plugin */
355 363
356 PerlInterpreter *prober = perl_alloc(); 364 PerlInterpreter *prober = perl_alloc();
486 XS (XS_GAIM_register) 494 XS (XS_GAIM_register)
487 { 495 {
488 char *name, *ver, *callback, *unused; /* exactly like X-Chat, eh? :) */ 496 char *name, *ver, *callback, *unused; /* exactly like X-Chat, eh? :) */
489 unsigned int junk; 497 unsigned int junk;
490 struct perlscript *scp; 498 struct perlscript *scp;
491 struct gaim_plugin *plug; 499 struct gaim_plugin *plug = NULL;
492 GList *pl = plugins; 500 GList *pl = plugins;
493 501
494 dXSARGS; 502 dXSARGS;
495 items = 0; 503 items = 0;
496 504
497 name = SvPV (ST (0), junk); 505 name = SvPV (ST (0), junk);
498 ver = SvPV (ST (1), junk); 506 ver = SvPV (ST (1), junk);
879 /* 5 for max 4 arguments =\ Note, if you change the above, 887 /* 5 for max 4 arguments =\ Note, if you change the above,
880 * change the two loops at the bottom that free up memory */ 888 * change the two loops at the bottom that free up memory */
881 889
882 GList *handler; 890 GList *handler;
883 struct _perl_event_handlers *data; 891 struct _perl_event_handlers *data;
884 SV *handler_return; 892 int handler_return;
885 int i=0; /* necessary counter variable? --et */ 893 int i=0; /* necessary counter variable? --et */
886 894
887 switch (event) { 895 switch (event) {
888 case event_signon: 896 case event_signon:
889 case event_signoff: 897 case event_signoff:
1088 { 1096 {
1089 unsigned int junk; 1097 unsigned int junk;
1090 struct _perl_event_handlers *ehn; 1098 struct _perl_event_handlers *ehn;
1091 GList *cur = perl_event_handlers; 1099 GList *cur = perl_event_handlers;
1092 dXSARGS; 1100 dXSARGS;
1101 items = 0;
1093 1102
1094 while (cur) { 1103 while (cur) {
1095 GList *next = cur->next; 1104 GList *next = cur->next;
1096 ehn = cur->data; 1105 ehn = cur->data;
1097 1106
1145 } 1154 }
1146 1155
1147 if (p) { 1156 if (p) {
1148 handler = g_new0(struct _perl_timeout_handlers, 1); 1157 handler = g_new0(struct _perl_timeout_handlers, 1);
1149 timeout = 1000 * SvIV(ST(1)); 1158 timeout = 1000 * SvIV(ST(1));
1150 debug_printf("Adding timeout for %d seconds.\n", timeout/1000); 1159 debug_printf("Adding timeout for %ld seconds.\n", timeout/1000);
1151 handler->plug = plug; 1160 handler->plug = plug;
1152 handler->handler_name = g_strdup(SvPV(ST(2), junk)); 1161 handler->handler_name = g_strdup(SvPV(ST(2), junk));
1153 handler->handler_args = g_strdup(SvPV(ST(3), junk)); 1162 handler->handler_args = g_strdup(SvPV(ST(3), junk));
1154 perl_timeout_handlers = g_list_append(perl_timeout_handlers, handler); 1163 perl_timeout_handlers = g_list_append(perl_timeout_handlers, handler);
1155 handler->iotag = g_timeout_add(timeout, perl_timeout, handler); 1164 handler->iotag = g_timeout_add(timeout, perl_timeout, handler);
1162 XS (XS_GAIM_play_sound) 1171 XS (XS_GAIM_play_sound)
1163 { 1172 {
1164 int id; 1173 int id;
1165 dXSARGS; 1174 dXSARGS;
1166 1175
1176 items = 0;
1177
1167 id = SvIV(ST(0)); 1178 id = SvIV(ST(0));
1168 1179
1169 play_sound(id); 1180 play_sound(id);
1170 1181
1171 XSRETURN_EMPTY; 1182 XSRETURN_EMPTY;