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
|
/* This file is part of Mailfromd. -*- c -*-
Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 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 "filenames.h" /* For DEFAULT_FROM_ADDRESS */
MF_VAR(rcpt_count, NUMBER);
MF_VAR(milter_client_family, NUMBER, SYM_PRECIOUS);
MF_VAR(milter_client_address, STRING, SYM_PRECIOUS);
MF_VAR(milter_server_family, NUMBER, SYM_PRECIOUS);
MF_VAR(milter_server_address, STRING, SYM_PRECIOUS);
MF_VAR(milter_server_id, STRING, SYM_PRECIOUS);
MF_VAR(sendmail_header_count, NUMBER, SYM_PRECIOUS);
/* Functions to access %rcpt_count */
unsigned long
get_rcpt_count(eval_environ_t env)
{
return MF_VAR_REF(rcpt_count, long);
}
void
clear_rcpt_count(eval_environ_t env)
{
MF_VAR_REF(rcpt_count, long, 0);
}
void
incr_rcpt_count(eval_environ_t env)
{
MF_VAR_INC(rcpt_count);
}
/* Same for sendmail_header_count */
unsigned long
get_sendmail_header_count(eval_environ_t env)
{
return MF_VAR_REF(sendmail_header_count, long);
}
void
set_sendmail_header_count(eval_environ_t env, unsigned long v)
{
MF_VAR_REF(sendmail_header_count, ulong, v);
}
/* define_milter_address name */
m4_define([<define_milter_address>],[<
MF_DSEXP_SUPPRESS([<set_milter_$1_address>],
[<void
set_milter_$1_address(eval_environ_t env, milter_sockaddr_t *addr,
socklen_t len)
{
char *path;
switch (addr->sa.sa_family) {
case PF_INET:
MF_VAR_REF(milter_$1_family, long, MFAM_INET);
MF_VAR_SET_STRING(milter_$1_address,
inet_ntoa(addr->sin.sin_addr));
break;
#ifdef GACOPYZ_IPV6
case PF_INET6: {
char hostbuf[NI_MAXHOST];
MF_VAR_REF(milter_$1_family, long, MFAM_INET6);
if (getnameinfo(&addr->sa, sizeof(addr->sin6),
hostbuf, sizeof hostbuf,
NULL, 0,
NI_NUMERICHOST|NI_NUMERICSERV))
hostbuf[0] = 0;
MF_VAR_SET_STRING(milter_$1_address, hostbuf);
break;
}
#endif
case PF_UNIX:
MF_VAR_REF(milter_$1_family, long, MFAM_UNIX);
if (len == sizeof (addr->sa.sa_family))
path = "";
else
path = addr->sunix.sun_path;
MF_VAR_SET_STRING(milter_$1_address, path);
break;
default:
/* FIXME */
MF_VAR_REF(milter_$1_family, long, (long)addr->sa.sa_family);
}
}
>])>])
define_milter_address(server)
define_milter_address(client)
MF_DSEXP_SUPPRESS([<set_milter_server_id>],[<
void
set_milter_server_id(eval_environ_t env, const char *id)
{
MF_VAR_SET_STRING(milter_server_id, id ? id : "");
}
>])
MF_INIT
|