7 /* name/address list membership
9 /* #include <namadr_list.h>
11 /* NAMADR_LIST *namadr_list_init(flags, pattern_list)
13 /* const char *pattern_list;
15 /* int namadr_list_match(list, name, addr)
20 /* void namadr_list_free(list)
23 /* This is a convenience wrapper around the match_list module.
25 /* This module implements tests for list membership of a
26 /* hostname or network address.
28 /* A list pattern specifies a host name, a domain name,
29 /* an internet address, or a network/mask pattern, where the
30 /* mask specifies the number of bits in the network part.
31 /* When a pattern specifies a file name, its contents are
32 /* substituted for the file name; when a pattern is a
33 /* type:name table specification, table lookup is used
35 /* Patterns are separated by whitespace and/or commas. In
36 /* order to reverse the result, precede a pattern with an
37 /* exclamation point (!).
39 /* A host matches a list when its name or address matches
40 /* a pattern, or when any of its parent domains matches a
41 /* pattern. The matching process is case insensitive.
43 /* namadr_list_init() performs initializations. The first
44 /* argument is the bit-wise OR of zero or more of the
47 /* .IP MATCH_FLAG_PARENT
48 /* The hostname pattern foo.com matches itself and any name below
49 /* the domain foo.com. If this flag is cleared, foo.com matches itself
50 /* only, and .foo.com matches any name below the domain foo.com.
52 /* Specify MATCH_FLAG_NONE to request none of the above.
53 /* The second argument is a list of patterns, or the absolute
54 /* pathname of a file with patterns.
56 /* namadr_list_match() matches the specified host name and
57 /* address against the specified list of patterns.
59 /* namadr_list_free() releases storage allocated by namadr_list_init().
61 /* Fatal errors: unable to open or read a pattern file; invalid
62 /* pattern. Panic: interface violations.
64 /* match_list(3) generic list matching
65 /* match_ops(3) match host by name or by address
69 /* The Secure Mailer license must be distributed with this software.
72 /* IBM T.J. Watson Research
74 /* Yorktown Heights, NY 10598, USA
81 /* Utility library. */
83 #include <match_list.h>
87 #include "namadr_list.h"
95 #include <msg_vstream.h>
97 static void usage(char *progname
)
99 msg_fatal("usage: %s [-v] pattern_list hostname address", progname
);
102 int main(int argc
, char **argv
)
109 msg_vstream_init(argv
[0], VSTREAM_ERR
);
111 while ((ch
= GETOPT(argc
, argv
, "v")) > 0) {
120 if (argc
!= optind
+ 3)
122 list
= namadr_list_init(MATCH_FLAG_PARENT
, argv
[optind
]);
123 host
= argv
[optind
+ 1];
124 addr
= argv
[optind
+ 2];
125 vstream_printf("%s/%s: %s\n", host
, addr
,
126 namadr_list_match(list
, host
, addr
) ?
128 vstream_fflush(VSTREAM_OUT
);
129 namadr_list_free(list
);