Mercurial > pidgin.yaz
annotate src/perl.c @ 578:a0636d0d9ee2
[gaim-migrate @ 588]
added group add button. need pixmaps.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 02 Aug 2000 02:28:45 +0000 |
parents | aa9a8bcddd80 |
children | 7b501c39a6ee |
rev | line source |
---|---|
560 | 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 * | |
24 */ | |
25 | |
26 #ifdef HAVE_CONFIG_H | |
27 #include "../config.h" | |
28 #endif | |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
29 #undef PACKAGE |
560 | 30 |
577
aa9a8bcddd80
[gaim-migrate @ 587]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
573
diff
changeset
|
31 /*#ifdef USE_PERL /**/ |
aa9a8bcddd80
[gaim-migrate @ 587]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
573
diff
changeset
|
32 #if 0 /**/ |
560 | 33 |
34 #include <EXTERN.h> | |
35 #ifndef _SEM_SEMUN_UNDEFINED | |
36 #define HAS_UNION_SEMUN | |
37 #endif | |
38 #include <perl.h> | |
39 #include <XSUB.h> | |
40 #include <sys/mman.h> | |
41 #include <sys/types.h> | |
42 #include <sys/stat.h> | |
43 #include <fcntl.h> | |
44 #undef PACKAGE | |
45 #include <stdio.h> | |
46 #include "gaim.h" | |
47 | |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
48 struct perlscript { |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
49 char *name; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
50 char *version; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
51 char *shutdowncallback; /* bleh */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
52 }; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
53 |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
54 struct _perl_timeout_handlers { |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
55 char *handler_name; |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
56 gint iotag; |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
57 }; |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
58 |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
59 static GList *perl_list = NULL; |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
60 static GList *perl_timeout_handlers = NULL; |
560 | 61 static PerlInterpreter *my_perl = NULL; |
62 | |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
63 XS (XS_AIM_register); /* so far so good */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
64 /* XS (XS_AIM_add_message_handler); /* um... */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
65 /* XS (XS_AIM_add_command_handler); /* once again, um... */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
66 /* XS (XS_AIM_add_print_handler); /* can i really do this? */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
67 XS (XS_AIM_add_timeout_handler); /* ok, this i can do */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
68 /* XS (XS_AIM_print); /* how am i going to do this */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
69 /* XS (XS_AIM_print_with_channel); /* print_to_conversation? */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
70 /* XS (XS_AIM_send_raw); /* this i can do for toc, but for oscar... ? */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
71 XS (XS_AIM_command); /* this should be easier */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
72 /* XS (XS_AIM_command_with_server); /* FIXME: this should probably be removed */ |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
73 XS (XS_AIM_channel_list); /* probably return conversation list (online buddies?) */ |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
74 /* XS (XS_AIM_server_list); /* huh? does this apply? */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
75 XS (XS_AIM_user_list); /* return the buddy list */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
76 /* XS (XS_AIM_user_info); /* we'll see.... */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
77 XS (XS_AIM_ignore_list); /* deny list? */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
78 /* XS (XS_AIM_dcc_list); /* wha? */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
79 XS (XS_AIM_get_info); /* this i can do too */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
80 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
81 /* perl module support */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
82 extern void xs_init _((void)); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
83 extern void boot_DynaLoader _((CV * cv)); /* perl is so wacky */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
84 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
85 void xs_init() |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
86 { |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
87 char *file = __FILE__; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
88 newXS ("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
89 } |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
90 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
91 static char *escape_quotes(char *buf) |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
92 { |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
93 static char *tmp_buf = NULL; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
94 char *i, *j; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
95 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
96 if (tmp_buf) |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
97 g_free(tmp_buf); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
98 tmp_buf = g_malloc(strlen(buf) * 2 + 1); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
99 for (i = buf, j = tmp_buf; *i; i++, j++) { |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
100 if (*i == '\'' || *i == '\\') |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
101 *j++ = '\\'; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
102 *j = *i; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
103 } |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
104 *j = '\0'; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
105 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
106 return (tmp_buf); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
107 } |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
108 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
109 static SV *execute_perl(char *function, char *args) |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
110 { |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
111 static char *perl_cmd = NULL; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
112 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
113 if (perl_cmd) |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
114 g_free(perl_cmd); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
115 perl_cmd = g_malloc(strlen(function) + strlen(args) + 2 + 10); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
116 sprintf(perl_cmd, "&%s('%s')", function, escape_quotes(args)); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
117 #ifndef HAVE_PERL_EVAL_PV |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
118 return (perl_eval_pv(perl_cmd, TRUE)); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
119 #else |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
120 return (Perl_eval_pv(perl_cmd, TRUE)); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
121 #endif |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
122 } |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
123 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
124 int perl_load_file(char *script_name) |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
125 { |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
126 SV *return_val; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
127 return_val = execute_perl("load_file", script_name); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
128 return SvNV (return_val); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
129 } |
560 | 130 |
131 void perl_init(int autoload) | |
132 { | |
133 char *perl_args[] = {"", "-e", "0"}; | |
134 char load_file[] = | |
135 "sub load_file()\n" | |
136 "{\n" | |
137 " (my $file_name) = @_;\n" | |
138 " open FH, $file_name or return 2;\n" | |
139 " local($/) = undef;\n" | |
140 " $file = <FH>;\n" | |
141 " close FH;\n" | |
142 " eval $file;\n" | |
143 " eval $file if $@;\n" | |
144 " return 1 if $@;\n" | |
145 " return 0;\n" | |
146 "}"; | |
147 | |
148 my_perl = perl_alloc(); | |
149 perl_construct(my_perl); | |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
150 perl_parse(my_perl, xs_init, 4, perl_args, NULL); |
560 | 151 #ifndef HAVE_PERL_EVAL_PV |
152 perl_eval_pv(load_file, TRUE); | |
153 #else | |
154 Perl_eval_pv(load_file, TRUE); | |
155 #endif | |
156 | |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
157 newXS ("AIM::register", XS_AIM_register, "AIM"); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
158 /* newXS ("AIM::add_message_handler", XS_AIM_add_message_handler, "AIM"); */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
159 /* newXS ("AIM::add_command_handler", XS_AIM_add_command_handler, "AIM"); */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
160 /* newXS ("AIM::add_print_handler", XS_AIM_add_print_handler, "AIM"); */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
161 newXS ("AIM::add_timeout_handler", XS_AIM_add_timeout_handler, "AIM"); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
162 /* newXS ("AIM::print", XS_AIM_print, "AIM"); */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
163 /* newXS ("AIM::print_with_channel", XS_AIM_print_with_channel, "AIM"); */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
164 /* newXS ("AIM::send_raw", XS_AIM_send_raw, "AIM"); */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
165 newXS ("AIM::command", XS_AIM_command, "AIM"); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
166 /* newXS ("AIM::command_with_server", XS_AIM_command_with_server, "AIM"); */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
167 newXS ("AIM::channel_list", XS_AIM_channel_list, "AIM"); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
168 /* newXS ("AIM::server_list", XS_AIM_server_list, "AIM"); */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
169 newXS ("AIM::user_list", XS_AIM_user_list, "AIM"); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
170 /* newXS ("AIM::user_info", XS_AIM_user_info, "AIM"); */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
171 newXS ("AIM::ignore_list", XS_AIM_ignore_list, "AIM"); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
172 /* newXS ("AIM::dcc_list", XS_AIM_dcc_list, "AIM"); */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
173 newXS ("AIM::get_info", XS_AIM_get_info, "AIM"); |
560 | 174 |
175 /* FIXME */ | |
176 if (autoload) { | |
177 /* for each *.pl in ~/.gaim/scripts (whatever), autoload file */ | |
178 } | |
179 } | |
180 | |
181 void perl_end() | |
182 { | |
565
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
183 struct perlscript *scp; |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
184 struct _perl_timeout_handlers *thn; |
565
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
185 |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
186 while (perl_list) { |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
187 scp = perl_list->data; |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
188 perl_list = g_list_remove(perl_list, scp); |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
189 if (scp->shutdowncallback[0]) |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
190 execute_perl(scp->shutdowncallback, ""); |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
191 g_free(scp->name); |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
192 g_free(scp->version); |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
193 g_free(scp->shutdowncallback); |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
194 g_free(scp); |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
195 } |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
196 |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
197 while (perl_timeout_handlers) { |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
198 thn = perl_timeout_handlers->data; |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
199 perl_timeout_handlers = g_list_remove(perl_timeout_handlers, thn); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
200 gtk_timeout_remove(thn->iotag); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
201 g_free(thn->handler_name); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
202 g_free(thn); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
203 } |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
204 |
560 | 205 if (my_perl != NULL) { |
206 perl_destruct(my_perl); | |
207 perl_free(my_perl); | |
208 my_perl = NULL; | |
209 } | |
210 } | |
211 | |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
212 XS (XS_AIM_register) |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
213 { |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
214 char *name, *ver, *callback, *unused; /* exactly like X-Chat, eh? :) */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
215 int junk; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
216 struct perlscript *scp; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
217 dXSARGS; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
218 items = 0; |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
219 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
220 name = SvPV (ST (0), junk); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
221 ver = SvPV (ST (1), junk); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
222 callback = SvPV (ST (2), junk); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
223 unused = SvPV (ST (3), junk); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
224 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
225 scp = g_new0(struct perlscript, 1); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
226 scp->name = g_strdup(name); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
227 scp->version = g_strdup(ver); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
228 scp->shutdowncallback = g_strdup(callback); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
229 perl_list = g_list_append(perl_list, scp); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
230 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
231 XST_mPV (0, VERSION); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
232 XSRETURN (1); |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
233 } |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
234 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
235 /* XS (XS_AIM_add_message_handler); /* um... */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
236 /* XS (XS_AIM_add_command_handler); /* once again, um... */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
237 /* XS (XS_AIM_add_print_handler); /* can i really do this? */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
238 |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
239 static int perl_timeout(struct _perl_timeout_handlers *handler) |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
240 { |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
241 execute_perl(handler->handler_name, ""); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
242 perl_timeout_handlers = g_list_remove(perl_timeout_handlers, handler); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
243 g_free(handler->handler_name); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
244 g_free(handler); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
245 |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
246 return 0; /* returning zero removes the timeout handler */ |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
247 } |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
248 |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
249 XS (XS_AIM_add_timeout_handler) |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
250 { |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
251 int junk; |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
252 long timeout; |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
253 struct _perl_timeout_handlers *handler; |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
254 dXSARGS; |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
255 items = 0; |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
256 |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
257 handler = g_new0(struct _perl_timeout_handlers, 1); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
258 timeout = atol(SvPV(ST(0), junk)); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
259 handler->handler_name = g_strdup(SvPV(ST(1), junk)); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
260 perl_timeout_handlers = g_list_append(perl_timeout_handlers, handler); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
261 handler->iotag = gtk_timeout_add(timeout, (GtkFunction)perl_timeout, handler); |
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
262 XSRETURN_EMPTY; |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
263 } |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
264 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
265 /* XS (XS_AIM_print); /* how am i going to do this */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
266 /* XS (XS_AIM_print_with_channel); /* print_to_conversation? */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
267 /* XS (XS_AIM_send_raw); /* this i can do for toc, but for oscar... ? */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
268 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
269 XS (XS_AIM_command) |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
270 { |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
271 } |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
272 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
273 /* XS (XS_AIM_command_with_server); /* FIXME: this should probably be removed */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
274 |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
275 XS (XS_AIM_channel_list) /* online buddies? */ |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
276 { |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
277 } |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
278 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
279 /* XS (XS_AIM_server_list); /* huh? does this apply? */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
280 |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
281 XS (XS_AIM_user_list) /* buddy list */ |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
282 { |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
283 } |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
284 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
285 /* XS (XS_AIM_user_info); /* we'll see.... */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
286 |
573
9566a53cde23
[gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
565
diff
changeset
|
287 XS (XS_AIM_ignore_list) /* deny list */ |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
288 { |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
289 } |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
290 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
291 /* XS (XS_AIM_dcc_list); /* wha? */ |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
292 |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
293 XS (XS_AIM_get_info) |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
294 { |
565
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
295 int junk; |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
296 dXSARGS; |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
297 items = 0; |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
298 |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
299 switch(atoi(SvPV(ST(0), junk))) { |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
300 case 0: |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
301 XST_mPV(0, VERSION); |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
302 break; |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
303 case 1: |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
304 XST_mPV(0, current_user->username); |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
305 break; |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
306 default: |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
307 XST_mPV(0, "Error2"); |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
308 } |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
309 |
7209b474bdc3
[gaim-migrate @ 575]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
562
diff
changeset
|
310 XSRETURN(1); |
561
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
311 } |
9b36c91cce26
[gaim-migrate @ 571]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
560
diff
changeset
|
312 |
560 | 313 #endif /* USE_PERL */ |