xref: /netbsd-src/external/ibm-public/postfix/dist/src/util/name_mask.h (revision ff6d749d9964a9b179f9760ce6992137cffbaefe)
1 /*	$NetBSD: name_mask.h,v 1.1.1.2 2011/03/02 19:32:44 tron Exp $	*/
2 
3 #ifndef _NAME_MASK_H_INCLUDED_
4 #define _NAME_MASK_H_INCLUDED_
5 
6 /*++
7 /* NAME
8 /*	name_mask 3h
9 /* SUMMARY
10 /*	map names to bit mask
11 /* SYNOPSIS
12 /*	#include <name_mask.h>
13 /* DESCRIPTION
14 /* .nf
15 
16  /*
17   * Utility library.
18   */
19 #include <vstring.h>
20 
21  /*
22   * External interface.
23   */
24 typedef struct {
25     const char *name;
26     int     mask;
27 } NAME_MASK;
28 
29 #define NAME_MASK_FATAL	(1<<0)
30 #define NAME_MASK_ANY_CASE	(1<<1)
31 #define NAME_MASK_RETURN	(1<<2)
32 #define NAME_MASK_COMMA		(1<<3)
33 #define NAME_MASK_PIPE		(1<<4)
34 #define NAME_MASK_NUMBER	(1<<5)
35 #define NAME_MASK_WARN		(1<<6)
36 #define NAME_MASK_IGNORE	(1<<7)
37 
38 #define NAME_MASK_REQUIRED \
39     (NAME_MASK_FATAL | NAME_MASK_RETURN | NAME_MASK_WARN | NAME_MASK_IGNORE)
40 #define STR_NAME_MASK_REQUIRED	(NAME_MASK_REQUIRED | NAME_MASK_NUMBER)
41 
42 #define NAME_MASK_MATCH_REQ	NAME_MASK_FATAL
43 
44 #define NAME_MASK_NONE		0
45 #define NAME_MASK_DEFAULT	(NAME_MASK_FATAL)
46 #define NAME_MASK_DEFAULT_DELIM	", \t\r\n"
47 
48 #define name_mask_opt(tag, table, str, flags) \
49 	name_mask_delim_opt((tag), (table), (str), \
50 			    NAME_MASK_DEFAULT_DELIM, (flags))
51 #define name_mask(tag, table, str) \
52 	name_mask_opt((tag), (table), (str), NAME_MASK_DEFAULT)
53 #define str_name_mask(tag, table, mask) \
54 	str_name_mask_opt(((VSTRING *) 0), (tag), (table), (mask), NAME_MASK_DEFAULT)
55 
56 extern int name_mask_delim_opt(const char *, const NAME_MASK *, const char *, const char *, int);
57 extern const char *str_name_mask_opt(VSTRING *, const char *, const NAME_MASK *, int, int);
58 
59  /*
60   * "long" API
61   */
62 typedef struct {
63     const char *name;
64     long    mask;
65 } LONG_NAME_MASK;
66 
67 #define long_name_mask_opt(tag, table, str, flags) \
68 	long_name_mask_delim_opt((tag), (table), (str), NAME_MASK_DEFAULT_DELIM, (flags))
69 #define long_name_mask(tag, table, str) \
70 	long_name_mask_opt((tag), (table), (str), NAME_MASK_DEFAULT)
71 #define str_long_name_mask(tag, table, mask) \
72 	str_long_name_mask_opt(((VSTRING *) 0), (tag), (table), (mask), NAME_MASK_DEFAULT)
73 
74 extern long long_name_mask_delim_opt(const char *, const LONG_NAME_MASK *, const char *, const char *, int);
75 extern const char *str_long_name_mask_opt(VSTRING *, const char *, const LONG_NAME_MASK *, long, int);
76 
77 /* LICENSE
78 /* .ad
79 /* .fi
80 /*	The Secure Mailer license must be distributed with this software.
81 /* AUTHOR(S)
82 /*	Wietse Venema
83 /*	IBM T.J. Watson Research
84 /*	P.O. Box 704
85 /*	Yorktown Heights, NY 10598, USA
86 /*--*/
87 
88 #endif
89