1/*	$NetBSD: match_parent_style.c,v 1.2 2017/02/14 01:16:45 christos Exp $	*/
2
3/*++
4/* NAME
5/*	match_parent_style 3
6/* SUMMARY
7/*	parent domain matching control
8/* SYNOPSIS
9/*	#include <match_parent_style.h>
10/*
11/*	int	match_parent_style(name)
12/*	const char *name;
13/* DESCRIPTION
14/*	This module queries configuration parameters for the policy that
15/*	controls how wild-card parent domain names are used by various
16/*	postfix lookup mechanisms.
17/*
18/*	match_parent_style() looks up "name" in the
19/*	parent_domain_matches_subdomain configuration parameter
20/*	and returns either MATCH_FLAG_PARENT (parent domain matches
21/*	subdomains) or MATCH_FLAG_NONE.
22/* DIAGNOSTICS
23/*	Fatal error: out of memory, name listed under both parent wild card
24/*	matching policies.
25/* SEE ALSO
26/*	string_list(3) plain string matching
27/*	domain_list(3) match host name patterns
28/*	namadr_list(3) match host name/address patterns
29/* LICENSE
30/* .ad
31/* .fi
32/*	The Secure Mailer license must be distributed with this software.
33/* AUTHOR(S)
34/*	Wietse Venema
35/*	IBM T.J. Watson Research
36/*	P.O. Box 704
37/*	Yorktown Heights, NY 10598, USA
38/*--*/
39
40/* System library. */
41
42#include <sys_defs.h>
43
44/* Utility library. */
45
46/* Global library. */
47
48#include <string_list.h>
49#include <mail_params.h>
50#include <match_parent_style.h>
51
52/* Application-specific. */
53
54static STRING_LIST *match_par_dom_list;
55
56int     match_parent_style(const char *name)
57{
58    int     result;
59
60    /*
61     * Initialize on the fly.
62     */
63    if (match_par_dom_list == 0)
64	match_par_dom_list =
65	    string_list_init(VAR_PAR_DOM_MATCH, MATCH_FLAG_NONE,
66			     var_par_dom_match);
67
68    /*
69     * Look up the parent domain matching policy.
70     */
71    if (string_list_match(match_par_dom_list, name))
72	result = MATCH_FLAG_PARENT;
73    else
74	result = 0;
75    return (result);
76}
77