Postfix3.3.1
総合概要
データ構造
ファイル
ファイル一覧
大域各種
postfix-3.3.1
src
global
domain_list.c
[詳解]
1
/*++
2
/* NAME
3
/* domain_list 3
4
/* SUMMARY
5
/* match a host or domain name against a pattern list
6
/* SYNOPSIS
7
/* #include <domain_list.h>
8
/*
9
/* DOMAIN_LIST *domain_list_init(pname, flags, pattern_list)
10
/* const char *pname;
11
/* int flags;
12
/* const char *pattern_list;
13
/*
14
/* int domain_list_match(list, name)
15
/* DOMAIN_LIST *list;
16
/* const char *name;
17
/*
18
/* void domain_list_free(list)
19
/* DOMAIN_LIST *list;
20
/* DESCRIPTION
21
/* This is a convenience wrapper around the match_list module.
22
/*
23
/* This module implements tests for list membership of a host or
24
/* domain name.
25
/*
26
/* Patterns are separated by whitespace and/or commas. A pattern
27
/* is either a string, a file name (in which case the contents
28
/* of the file are substituted for the file name) or a type:name
29
/* lookup table specification.
30
/*
31
/* A host name matches a domain list when its name appears in the
32
/* list of domain patterns, or when any of its parent domains appears
33
/* in the list of domain patterns. The matching process is case
34
/* insensitive. In order to reverse the result, precede a
35
/* pattern with an exclamation point (!).
36
/*
37
/* domain_list_init() performs initializations. The pname
38
/* argument specifies error reporting context. The flags argument
39
/* is the bit-wise OR of zero or more of the following:
40
/* .IP MATCH_FLAG_PARENT
41
/* The hostname pattern foo.com matches itself and any name below
42
/* the domain foo.com. If this flag is cleared, foo.com matches itself
43
/* only, and .foo.com matches any name below the domain foo.com.
44
/* .IP MATCH_FLAG_RETURN
45
/* Request that domain_list_match() logs a warning and returns
46
/* zero, with list->error set to a non-zero dictionary error
47
/* code, instead of raising a fatal error.
48
/* .PP
49
/* Specify MATCH_FLAG_NONE to request none of the above.
50
/* The last argument is a list of domain patterns, or the name of
51
/* a file containing domain patterns.
52
/*
53
/* domain_list_match() matches the specified host or domain name
54
/* against the specified pattern list.
55
/*
56
/* domain_list_free() releases storage allocated by domain_list_init().
57
/* DIAGNOSTICS
58
/* Fatal error: unable to open or read a domain_list file; invalid
59
/* domain_list pattern.
60
/* SEE ALSO
61
/* match_list(3) generic list matching
62
/* match_ops(3) match hosts by name or by address
63
/* LICENSE
64
/* .ad
65
/* .fi
66
/* The Secure Mailer license must be distributed with this software.
67
/* AUTHOR(S)
68
/* Wietse Venema
69
/* IBM T.J. Watson Research
70
/* P.O. Box 704
71
/* Yorktown Heights, NY 10598, USA
72
/*--*/
73
74
/* System library. */
75
76
#include <
sys_defs.h
>
77
78
/* Utility library. */
79
80
#include <
match_list.h
>
81
82
/* Global library. */
83
84
#include "
domain_list.h
"
85
86
#ifdef TEST
87
88
#include <stdlib.h>
89
#include <unistd.h>
90
#include <
msg.h
>
91
#include <
vstream.h
>
92
#include <
msg_vstream.h
>
93
#include <
dict.h
>
94
#include <
stringops.h
>
/* util_utf8_enable */
95
96
static
void
usage(
char
*progname)
97
{
98
msg_fatal
(
"usage: %s [-v] patterns hostname"
, progname);
99
}
100
101
int
main
(
int
argc,
char
**argv)
102
{
103
DOMAIN_LIST
*list;
104
char
*host;
105
int
ch;
106
107
msg_vstream_init
(argv[0],
VSTREAM_ERR
);
108
109
while
((ch =
GETOPT
(argc, argv,
"v"
)) > 0) {
110
switch
(ch) {
111
case
'v'
:
112
msg_verbose
++;
113
break
;
114
default
:
115
usage(argv[0]);
116
}
117
}
118
if
(argc != optind + 2)
119
usage(argv[0]);
120
dict_allow_surrogate
= 1;
121
util_utf8_enable
= 1;
122
list =
domain_list_init
(
"command line"
,
MATCH_FLAG_PARENT
123
|
MATCH_FLAG_RETURN
, argv[optind]);
124
host = argv[optind + 1];
125
vstream_printf
(
"%s: %s\n"
, host,
domain_list_match
(list, host) ?
126
"YES"
: list->error == 0 ?
"NO"
:
"ERROR"
);
127
vstream_fflush
(
VSTREAM_OUT
);
128
domain_list_free
(list);
129
return
(0);
130
}
131
132
#endif
msg_verbose
int msg_verbose
Definition:
msg.c:177
MATCH_FLAG_RETURN
#define MATCH_FLAG_RETURN
Definition:
match_list.h:40
msg_vstream.h
VSTREAM_OUT
#define VSTREAM_OUT
Definition:
vstream.h:67
domain_list_match
#define domain_list_match
Definition:
domain_list.h:26
main
int main(int argc, char **argv)
Definition:
anvil.c:1010
dict.h
DOMAIN_LIST
#define DOMAIN_LIST
Definition:
domain_list.h:22
domain_list.h
stringops.h
domain_list_free
#define domain_list_free
Definition:
domain_list.h:27
MATCH_FLAG_PARENT
#define MATCH_FLAG_PARENT
Definition:
match_list.h:39
dict_allow_surrogate
int dict_allow_surrogate
Definition:
dict_surrogate.c:130
vstream_printf
VSTREAM * vstream_printf(const char *fmt,...)
Definition:
vstream.c:1335
msg.h
sys_defs.h
msg_fatal
NORETURN msg_fatal(const char *fmt,...)
Definition:
msg.c:249
domain_list_init
#define domain_list_init(o, f, p)
Definition:
domain_list.h:24
match_list.h
vstream_fflush
int vstream_fflush(VSTREAM *stream)
Definition:
vstream.c:1257
GETOPT
#define GETOPT(argc, argv, str)
Definition:
sys_defs.h:1313
vstream.h
msg_vstream_init
void msg_vstream_init(const char *name, VSTREAM *vp)
Definition:
msg_vstream.c:77
util_utf8_enable
int util_utf8_enable
Definition:
printable.c:47
VSTREAM_ERR
#define VSTREAM_ERR
Definition:
vstream.h:68
2018年11月10日(土) 18時59分37秒作成 - Postfix3.3.1 / 構成:
1.8.9.1