comparison src/perl.c @ 560:cf3da01f451c

[gaim-migrate @ 570] Perl! (not yet. and i copied X-Chat almost directly) committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 31 Jul 2000 19:44:49 +0000
parents
children 9b36c91cce26
comparison
equal deleted inserted replaced
559:e51624d1749a 560:cf3da01f451c
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
29 #undef PACKAGE /* no idea why, just following X-Chat */
30
31 /* #ifdef USE_PERL */
32 #if 0 /* this isn't ready for prime-time yet. not even the 3-am shows. */
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
48 static PerlInterpreter *my_perl = NULL;
49
50 XS (XS_AIM_register); /* so far so good */
51 XS (XS_AIM_add_message_handler); /* um... */
52 XS (XS_AIM_add_command_handler); /* once again, um... */
53 XS (XS_AIM_add_print_handler); /* can i really do this? */
54 XS (XS_AIM_add_timeout_handler); /* ok, this i can do */
55 XS (XS_AIM_print); /* how am i going to do this */
56 XS (XS_AIM_print_with_channel); /* FIXME! this needs to be renamed */
57 XS (XS_AIM_send_raw); /* this i can do for toc, but for oscar... ? */
58 XS (XS_AIM_command); /* this should be easier */
59 XS (XS_AIM_command_with_server); /* FIXME: this should probably be removed */
60 XS (XS_AIM_channel_list); /* probably return conversation list */
61 XS (XS_AIM_server_list); /* huh? does this apply? */
62 XS (XS_AIM_user_list); /* return the buddy list */
63 XS (XS_AIM_user_info); /* we'll see.... */
64 XS (XS_AIM_ignore_list); /* deny list? */
65 XS (XS_AIM_dcc_list); /* wha? */
66 XS (XS_AIM_get_info); /* this i can do too */
67
68 void perl_init(int autoload)
69 {
70 char *perl_args[] = {"", "-e", "0"};
71 char load_file[] =
72 "sub load_file()\n"
73 "{\n"
74 " (my $file_name) = @_;\n"
75 " open FH, $file_name or return 2;\n"
76 " local($/) = undef;\n"
77 " $file = <FH>;\n"
78 " close FH;\n"
79 " eval $file;\n"
80 " eval $file if $@;\n"
81 " return 1 if $@;\n"
82 " return 0;\n"
83 "}";
84
85 my_perl = perl_alloc();
86 perl_construct(my_perl);
87 perl_parse(my_perl, NULL, 3, perl_args, NULL);
88 #ifndef HAVE_PERL_EVAL_PV
89 perl_eval_pv(load_file, TRUE);
90 #else
91 Perl_eval_pv(load_file, TRUE);
92 #endif
93
94 newXS("AIM::register", XS_AIM_register, "AIM");
95 newXS("AIM::add_message_handler", XS_AIM_add_message_handler, "AIM");
96 newXS("AIM::add_command_handler", XS_AIM_add_command_handler, "AIM");
97 newXS("AIM::add_print_handler", XS_AIM_add_print_handler, "AIM");
98 newXS("AIM::add_timeout_handler", XS_AIM_add_timeout_handler, "AIM");
99 newXS("AIM::print", XS_AIM_print, "AIM");
100 newXS("AIM::print_with_channel", XS_AIM_print_with_channel, "AIM");
101 newXS("AIM::send_raw", XS_AIM_send_raw, "AIM");
102 newXS("AIM::command", XS_AIM_command, "AIM");
103 newXS("AIM::command_with_server", XS_AIM_command_with_server, "AIM");
104 newXS("AIM::channel_list", XS_AIM_channel_list, "AIM");
105 newXS("AIM::server_list", XS_AIM_server_list, "AIM");
106 newXS("AIM::user_list", XS_AIM_user_list, "AIM");
107 newXS("AIM::user_info", XS_AIM_user_info, "AIM");
108 newXS("AIM::ignore_list", XS_AIM_ignore_list, "AIM");
109 newXS("AIM::dcc_list", XS_AIM_dcc_list, "AIM");
110 newXS("AIM::get_info", XS_AIM_get_info, "AIM");
111
112 /* FIXME */
113 if (autoload) {
114 /* for each *.pl in ~/.gaim/scripts (whatever), autoload file */
115 }
116 }
117
118 void perl_end()
119 {
120 if (my_perl != NULL) {
121 perl_destruct(my_perl);
122 perl_free(my_perl);
123 my_perl = NULL;
124 }
125 }
126
127 #endif /* USE_PERL */