1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
/*
* Perl XS module for interacting with rspamd
*
* vi:ts=4
*/
#include "../src/config.h"
#include <EXTERN.h>
#include <perl.h>
#include <XSUB.h>
#include "../src/main.h"
#include "../src/message.h"
#include "../src/cfg_file.h"
#include "../src/perl.h"
#include "../src/mem_pool.h"
#include "../src/fuzzy.h"
#define XSINTERFACE_FUNC_RSPAMD_MESSAGE_SET(cv,f) \
CvXSUBANY(cv).any_dptr = (void (*) (pTHX_ void*))(CAT2( g_mime_message_,f ))
#define XSINTERFACE_FUNC_RSPAMD_PART_SET(cv,f) \
CvXSUBANY(cv).any_dptr = (void (*) (pTHX_ void*))(CAT2( g_mime_part_,f ))
#define XSINTERFACE_FUNC_RSPAMD_IA_SET(cv,f) \
CvXSUBANY(cv).any_dptr = (void (*) (pTHX_ void*))(CAT2( internet_address_,f ))
struct raw_header {
struct raw_header *next;
char *name;
char *value;
};
typedef struct _GMimeHeader {
GHashTable *hash;
GHashTable *writers;
struct raw_header *headers;
} local_GMimeHeader;
/* enums */
#ifdef GMIME24
typedef GMimeContentEncoding Mail__Rspamd__PartEncodingType;
typedef int Mail__Rspamd__InternetAddressType;
#else
typedef InternetAddressType Mail__Rspamd__InternetAddressType;
typedef GMimePartEncodingType Mail__Rspamd__PartEncodingType;
#endif
/* C types */
typedef GMimeObject * Mail__Rspamd__Object;
typedef GMimeParam * Mail__Rspamd__Param;
typedef GMimePart * Mail__Rspamd__Part;
typedef struct mime_text_part * Mail__Rspamd__TextPart;
typedef GMimeParser * Mail__Rspamd__Parser;
typedef GMimeMultipart * Mail__Rspamd__MultiPart;
typedef GMimeMessage * Mail__Rspamd__Message;
typedef GMimeMessagePart * Mail__Rspamd__MessagePart;
typedef GMimeMessagePartial * Mail__Rspamd__MessagePartial;
typedef InternetAddress * Mail__Rspamd__InternetAddress;
#ifdef GMIME24
typedef GMimeContentDisposition * Mail__Rspamd__Disposition;
#else
typedef GMimeDisposition * Mail__Rspamd__Disposition;
#endif
typedef GMimeContentType * Mail__Rspamd__ContentType;
typedef GMimeCharset * Mail__Rspamd__Charset;
/*
* Declarations for message header hash array
*/
static gboolean
recipients_destroy (gpointer key, gpointer value, gpointer user_data)
{
InternetAddressList *recipients = value;
internet_address_list_destroy (recipients);
return TRUE;
}
typedef struct {
int keyindex; /* key index for firstkey */
char *fetchvalue; /* value for each() method fetched with FETCH */
Mail__Rspamd__Message objptr; /* any object pointer */
} hash_header;
typedef hash_header *Mail__Rspamd__Hash__Header;
/*
* Double linked list of perl allocated pointers (for DESTROY xsubs)
*/
static GList *plist = NULL;
/*
* Calling callback function for each mime part
*/
struct _user_data_sv {
SV * svfunc;
SV * svuser_data;
SV * svfunc_complete;
SV * svfunc_sizeout;
};
static void
call_sub_foreach(GMimeObject *mime_object, gpointer data)
{
SV * svpart;
SV * rvpart;
dSP ;
struct _user_data_sv *svdata;
svdata = (struct _user_data_sv *) data;
svpart = sv_newmortal ();
if (GMIME_IS_PART(mime_object)) {
rvpart = sv_setref_pv(svpart, "Mail::Rspamd::Part", (Mail__Rspamd__Part)mime_object);
} else {
rvpart = sv_setref_pv(svpart, "Mail::Rspamd::Object", mime_object);
}
PUSHMARK (sp);
XPUSHs (rvpart);
XPUSHs (sv_mortalcopy (svdata->svuser_data));
PUTBACK ;
if (svdata->svfunc) {
perl_call_sv (svdata->svfunc, G_DISCARD);
}
}
MODULE = Mail::Rspamd PACKAGE = Mail::Rspamd::Log PREFIX = rspamd_log_
PROTOTYPES: DISABLE
void
rspamd_log_log (level, str)
int level
const char *str
CODE:
g_log (G_LOG_DOMAIN, level, "%s", str);
MODULE = Mail::Rspamd PACKAGE = Mail::Rspamd
INCLUDE: Rspamd/Object.xs
INCLUDE: Rspamd/ContentType.xs
INCLUDE: Rspamd/Part.xs
INCLUDE: Rspamd/Message.xs
INCLUDE: Rspamd/InternetAddress.xs
INCLUDE: Rspamd/Hash.xs
INCLUDE: Rspamd/TextPart.xs
|