comparison plugins/perl/common/Util.xs @ 11290:b284c703d398

[gaim-migrate @ 13490] Did some house cleaning on the code finished up some of the "TODO" stuff that was left over from when I originally did the XSUBs. Furthermore, the dynamically loaded Perl package problems should be corrected now that the context is set before one of the concurrent perl interpreters is run. committer: Tailor Script <tailor@pidgin.im>
author John H. Kelm <johnkelm@gmail.com>
date Thu, 18 Aug 2005 01:35:14 +0000
parents 134d0001983d
children 52f27ffe68a5
comparison
equal deleted inserted replaced
11289:b633879e23f9 11290:b284c703d398
1
2
3 #include "module.h" 1 #include "module.h"
4 2
5 /* TODO 3 typedef struct {
6 4 char *cb;
7 void 5 } GaimPerlUrlData;
8 gaim_url_fetch(url, full, user_agent, http11, void *, char *, size_t), data) 6
9 const char *url 7 void gaim_perl_util_url_cb(void *data, const char *url_data, size_t size) {
10 gboolean full 8 GaimPerlUrlData *gpr = (GaimPerlUrlData *)data;
11 const char *user_agent 9 dSP;
12 gboolean http11 10 ENTER;
13 11 SAVETMPS;
14 const char * 12 PUSHMARK(sp);
15 size_t) 13
16 14 XPUSHs(sv_2mortal(newSVpv(url_data, 0)));
17 */ 15 PUTBACK;
18 16
19 /**********************XS Code for Account.xs*********************************/ 17 call_pv(gpr->cb, G_EVAL | G_SCALAR);
18 SPAGAIN;
19
20 PUTBACK;
21 FREETMPS;
22 LEAVE;
23 }
24
25
20 MODULE = Gaim::Util PACKAGE = Gaim::Util PREFIX = gaim_ 26 MODULE = Gaim::Util PACKAGE = Gaim::Util PREFIX = gaim_
21 PROTOTYPES: ENABLE 27 PROTOTYPES: ENABLE
22 28
29 void
30 gaim_url_fetch(handle, url, full, user_agent, http11, cb)
31 Gaim::Plugin handle
32 const char *url
33 gboolean full
34 const char *user_agent
35 gboolean http11
36 SV * cb
37 CODE:
38 GaimPerlUrlData *gpr;
39 STRLEN len;
40 char *basename, *package;
41
42 basename = g_path_get_basename(handle->path);
43 gaim_perl_normalize_script_name(basename);
44 package = g_strdup_printf("Gaim::Script::%s", basename);
45 gpr = g_new(GaimPerlUrlData, 1);
46
47 gpr->cb = g_strdup_printf("%s::%s", package, SvPV(cb, len));
48 gaim_url_fetch(url, full, user_agent, http11, gaim_perl_util_url_cb, gpr);
23 49
24 int 50 int
25 gaim_build_dir(path, mode) 51 gaim_build_dir(path, mode)
26 const char *path 52 const char *path
27 int mode 53 int mode