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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
|
MODULE = Mail::Rspamd PACKAGE = Mail::Rspamd::Message PREFIX = rspamd_message_
Mail::Rspamd::Message
rspamd_message_new(Class, pretty_headers = FALSE)
char * Class
gboolean pretty_headers
CODE:
RETVAL = g_mime_message_new (pretty_headers);
plist = g_list_prepend(plist, RETVAL);
OUTPUT:
RETVAL
void
DESTROY(message)
Mail::Rspamd::Message message
CODE:
if (g_list_find(plist,message)) {
g_mime_object_unref (GMIME_OBJECT (message));
plist = g_list_remove(plist, message);
}
void
rspamd_message_add_recipient(message, type, name, address)
Mail::Rspamd::Message message
char * type
const char * name
const char * address
CODE:
#ifndef GMIME24
g_mime_message_add_recipient (message, type, name, address);
#else
if (!g_strcasecmp (type, "to")) {
g_mime_message_add_recipient (message, GMIME_RECIPIENT_TYPE_TO, name, address);
}
else if (!g_strcasecmp (type, "cc")) {
g_mime_message_add_recipient (message, GMIME_RECIPIENT_TYPE_CC, name, address);
}
else if (!g_strcasecmp (type, "bcc")) {
g_mime_message_add_recipient (message, GMIME_RECIPIENT_TYPE_BCC, name, address);
}
#endif
void
rspamd_message_add_recipients_from_string(message, type, recipients)
Mail::Rspamd::Message message
char * type
const char * recipients
CODE:
#ifndef GMIME24
g_mime_message_add_recipients_from_string (message, type, recipients);
#else
/* XXX: add code here */
XSRETURN_UNDEF;
#endif
AV *
rspamd_message_get_recipients(message, type)
Mail::Rspamd::Message message
const char * type
PREINIT:
InternetAddressList * rcpt;
AV * retav;
int i;
CODE:
retav = newAV();
#ifndef GMIME24
rcpt = (InternetAddressList *)g_mime_message_get_recipients (message, type);
while (rcpt) {
SV * address = newSViv(0);
sv_setref_pv(address, "Mail::Rspamd::InternetAddress", (Mail__Rspamd__InternetAddress)(rcpt->address));
av_push(retav, address);
rcpt = rcpt->next;
}
#else
if (!g_strcasecmp (type, "to")) {
rcpt = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO);
}
else if (!g_strcasecmp (type, "cc")) {
rcpt = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_CC);
}
else if (!g_strcasecmp (type, "bcc")) {
rcpt = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_BCC);
}
i = internet_address_list_length (rcpt);
while (i > 0) {
SV * address = newSViv(0);
sv_setref_pv(address, "Mail::Rspamd::InternetAddress", (Mail__Rspamd__InternetAddress)internet_address_list_get_address(rcpt, i));
av_push(retav, address);
-- i;
}
#endif
RETVAL = retav;
OUTPUT:
RETVAL
void
interface_m_set (message, value)
Mail::Rspamd::Message message
char * value
INTERFACE_MACRO:
XSINTERFACE_FUNC
XSINTERFACE_FUNC_RSPAMD_MESSAGE_SET
INTERFACE:
set_subject
set_message_id
set_reply_to
set_sender
const char *
interface_m_get (message)
Mail::Rspamd::Message message
INTERFACE_MACRO:
XSINTERFACE_FUNC
XSINTERFACE_FUNC_RSPAMD_MESSAGE_SET
INTERFACE:
get_subject
get_message_id
get_reply_to
get_sender
# date
void
rspamd_message_set_date (message, date, gmt_offset)
Mail::Rspamd::Message message
time_t date
int gmt_offset
CODE:
g_mime_message_set_date (message, date, gmt_offset);
void
rspamd_message_set_date_from_string (message, str)
Mail::Rspamd::Message message
const char * str
PREINIT:
time_t date;
int offset = 0;
CODE:
date = g_mime_utils_header_decode_date (str, &offset);
g_mime_message_set_date (message, date, offset);
void
rspamd_message_get_date (message)
Mail::Rspamd::Message message
PREINIT:
time_t date;
int gmt_offset;
I32 gimme = GIMME_V;
char * str;
PPCODE:
if (gimme == G_SCALAR) {
#ifdef GMIME24
str = g_mime_message_get_date_as_string (message);
#else
str = g_mime_message_get_date_string (message);
#endif
if (str) {
XPUSHs (sv_2mortal (newSVpv (str,0)));
g_free (str);
}
} else if (gimme == G_ARRAY) {
g_mime_message_get_date (message, &date, &gmt_offset);
XPUSHs (sv_2mortal (newSVnv (date)));
XPUSHs (sv_2mortal (newSViv (gmt_offset)));
}
void
rspamd_message_set_header (message, field, value)
Mail::Rspamd::Message message
const char * field
const char * value
CODE:
#ifdef GMIME24
g_mime_object_set_header (GMIME_OBJECT (message), field, value);
#else
g_mime_message_set_header (message, field, value);
#endif
void
rspamd_message_remove_header (message, field)
Mail::Rspamd::Message message
const char * field
CODE:
#ifdef GMIME24
g_mime_object_remove_header (GMIME_OBJECT (message), field);
#else
g_mime_message_remove_header (message, field);
#endif
void
rspamd_message_add_header (message, field, value)
Mail::Rspamd::Message message
const char * field
const char * value
CODE:
#ifdef GMIME24
g_mime_object_set_header (GMIME_OBJECT (message), field, value);
#else
g_mime_message_set_header (message, field, value);
#endif
const char *
rspamd_message_get_header (message, field)
Mail::Rspamd::Message message
const char * field
CODE:
#ifdef GMIME24
RETVAL = g_mime_object_get_header (GMIME_OBJECT (message), field);
#else
RETVAL = g_mime_message_get_header (message, field);
#endif
OUTPUT:
RETVAL
void
rspamd_message_set_mime_part (message, mime_part)
Mail::Rspamd::Message message
Mail::Rspamd::Object mime_part
CODE:
g_mime_message_set_mime_part (message, GMIME_OBJECT (mime_part));
plist = g_list_remove (plist, mime_part);
#if !defined(GMIME24)
SV *
rspamd_message_get_body (message, want_plain = 1, is_html = 0)
CASE: items == 1
Mail::Rspamd::Message message
PREINIT:
gboolean want_plain = 1;
gboolean is_html;
char * textdata;
CODE:
textdata = g_mime_message_get_body (message, want_plain, &is_html);
if (textdata == NULL)
XSRETURN_UNDEF;
RETVAL = newSVpv (textdata, 0);
g_free (textdata);
OUTPUT:
RETVAL
CASE: items == 2
Mail::Rspamd::Message message
gboolean want_plain
PREINIT:
gboolean is_html;
char * textdata;
CODE:
textdata = g_mime_message_get_body (message, want_plain, &is_html);
if (textdata == NULL)
XSRETURN_UNDEF;
RETVAL = newSVpv (textdata, 0);
g_free (textdata);
OUTPUT:
RETVAL
CASE: items == 3
Mail::Rspamd::Message message
gboolean want_plain
gboolean &is_html
PREINIT:
char * textdata;
CODE:
textdata = g_mime_message_get_body (message, want_plain, &is_html);
if (textdata == NULL) {
RETVAL = &PL_sv_undef;
}
RETVAL = newSVpv (textdata, 0);
g_free (textdata);
OUTPUT:
is_html
RETVAL
#endif
SV *
rspamd_message_get_headers(message)
Mail::Rspamd::Message message
PREINIT:
char * textdata;
CODE:
#ifdef GMIME24
textdata = g_mime_object_get_headers (GMIME_OBJECT (message));
#else
textdata = g_mime_message_get_headers (message);
#endif
if (textdata == NULL) {
RETVAL = &PL_sv_undef;
}
RETVAL = newSVpv (textdata, 0);
g_free (textdata);
OUTPUT:
RETVAL
void
rspamd_message_foreach_part (message, callback, svdata)
Mail::Rspamd::Message message
SV * callback
SV * svdata
PREINIT:
struct _user_data_sv *data;
CODE:
data = g_new0 (struct _user_data_sv, 1);
data->svuser_data = newSVsv (svdata);
data->svfunc = newSVsv (callback);
g_mime_message_foreach_part (message, call_sub_foreach, data);
g_free (data);
SV *
get_mime_part(message)
Mail::Rspamd::Message message
PREINIT:
GMimeObject * mime_object;
CODE:
if (message->mime_part != NULL) {
RETVAL = newSViv(4);
mime_object = GMIME_OBJECT (message->mime_part);
if (GMIME_IS_PART(mime_object)) {
sv_setref_pv(RETVAL, "Mail::Rspamd::Part", (Mail__Rspamd__Part)mime_object);
} else {
plist = g_list_prepend(plist, RETVAL);
}
g_mime_object_ref( mime_object );
} else {
RETVAL = &PL_sv_undef;
}
OUTPUT:
RETVAL
|