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
|
/* This file is part of Mailfromd. -*- c -*-
Copyright (C) 2007-2008, 2010-2011, 2015 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "spf.h"
MF_VAR(spf_explanation, STRING);
MF_VAR(spf_mechanism, STRING);
MF_VAR(spf_ttl, NUMBER);
MF_VAR(spf_explanation_prefix, STRING);
MF_DSEXP_SUPPRESS([<update_spf_vars>],[<
static void
update_spf_vars(eval_environ_t env, spf_answer_t *ans)
{
MF_VAR_SET_STRING(spf_explanation, ans->exp_text);
MF_VAR_SET_STRING(spf_mechanism, ans->mech);
MF_VAR_REF(spf_ttl, ulong, ans->ttl);
}
>])
MF_DSEXP
MF_DEFUN(spf_check_host, NUMBER, STRING ip, STRING domain, STRING sender,
STRING helo_domain, STRING my_domain)
{
spf_result res;
spf_query_t q;
spf_answer_t ans;
q.ipstr = ip;
q.domain = domain;
q.sender = sender;
q.helo_domain = helo_domain;
q.my_domain = my_domain;
q.exp_prefix = MF_VAR_STRING(spf_explanation_prefix);
res = spf_check_host(&q, &ans);
update_spf_vars(env, &ans);
spf_answer_free(&ans);
MF_RETURN(res);
}
END
MF_DSEXP
MF_DEFUN(spf_test_record, NUMBER, STRING record,
STRING ip, STRING domain, STRING sender,
STRING helo_domain, STRING my_domain)
{
spf_result res;
spf_query_t q;
spf_answer_t ans;
q.ipstr = ip;
q.domain = domain;
q.sender = sender;
q.helo_domain = helo_domain;
q.my_domain = my_domain;
q.exp_prefix = MF_VAR_STRING(spf_explanation_prefix);
res = spf_test_record(record, &q, &ans);
update_spf_vars(env, &ans);
spf_answer_free(&ans);
MF_RETURN(res);
}
END
MF_INIT
|