1 #ifndef _PURPLE_PERL_COMMON_H_
2 #define _PURPLE_PERL_COMMON_H_
3 
4 #include <glib.h>
5 #ifdef _WIN32
6 #undef pipe
7 #endif
8 
9 #define SILENT_NO_TAINT_SUPPORT 0
10 #define NO_TAINT_SUPPORT 0
11 
12 #include <EXTERN.h>
13 #include <perl.h>
14 #include <XSUB.h>
15 
16 /* XXX: perl defines it's own _ but I think it's safe to undef it */
17 #undef _
18 /* Dirty hack to prevent the win32 libc compat stuff from interfering with the Perl internal stuff */
19 #ifdef _WIN32
20 #define _WIN32DEP_H_
21 #endif
22 #include "internal.h"
23 #ifdef _WIN32
24 #undef _WIN32DEP_H_
25 #endif
26 #include "plugin.h"
27 #include "value.h"
28 
29 #define is_hvref(o) \
30 	((o) && SvROK(o) && SvRV(o) && (SvTYPE(SvRV(o)) == SVt_PVHV))
31 
32 #define hvref(o) \
33 	(is_hvref(o) ? (HV *)SvRV(o) : NULL);
34 
35 #define PURPLE_PERL_BOOT_PROTO(x) \
36 	void boot_Purple__##x(pTHX_ CV *cv);
37 
38 #define PURPLE_PERL_BOOT(x) \
39 	purple_perl_callXS(boot_Purple__##x, cv, mark)
40 
41 typedef struct
42 {
43 	PurplePlugin *plugin;
44 	char *package;
45 	char *load_sub;
46 	char *unload_sub;
47 	char *prefs_sub;
48 #ifdef PURPLE_GTKPERL
49 	char *gtk_prefs_sub;
50 #endif
51 	char *plugin_action_sub;
52 } PurplePerlScript;
53 
54 void purple_perl_normalize_script_name(char *name);
55 
56 SV *newSVGChar(const char *str);
57 
58 void purple_perl_callXS(void (*subaddr)(pTHX_ CV *cv), CV *cv, SV **mark);
59 void purple_perl_bless_plain(const char *stash, void *object);
60 SV *purple_perl_bless_object(void *object, const char *stash);
61 gboolean purple_perl_is_ref_object(SV *o);
62 void *purple_perl_ref_object(SV *o);
63 
64 int execute_perl(const char *function, int argc, char **args);
65 
66 #if 0
67 gboolean purple_perl_value_from_sv(PurpleValue *value, SV *sv);
68 SV *purple_perl_sv_from_value(const PurpleValue *value);
69 #endif
70 
71 void *purple_perl_data_from_sv(PurpleValue *value, SV *sv);
72 SV *purple_perl_sv_from_vargs(const PurpleValue *value, va_list *args,
73                             void ***copy_arg);
74 SV *purple_perl_sv_from_fun(PurplePlugin *plugin, SV *callback);
75 #endif /* _PURPLE_PERL_COMMON_H_ */
76