xref: /netbsd-src/external/ibm-public/postfix/dist/src/global/match_parent_style.c (revision a5847cc334d9a7029f6352b847e9e8d71a0f9e0c)
1 /*	$NetBSD: match_parent_style.c,v 1.1.1.1 2009/06/23 10:08:47 tron 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 
54 static STRING_LIST *match_par_dom_list;
55 
56 int     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(MATCH_FLAG_NONE, var_par_dom_match);
66 
67     /*
68      * Look up the parent domain matching policy.
69      */
70     if (string_list_match(match_par_dom_list, name))
71 	result = MATCH_FLAG_PARENT;
72     else
73 	result = 0;
74     return (result);
75 }
76