Sync usage with man page.
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / src / global / dsn_mask.c
blob83f7ad09e92a0940815daa81ed20f25e2c75915c
1 /* $NetBSD$ */
3 /*++
4 /* NAME
5 /* dsn_mask 3
6 /* SUMMARY
7 /* DSN embedding in SMTP
8 /* SYNOPSIS
9 /* #include <dsn_mask.h>
11 /* int dsn_notify_mask(str)
12 /* const char *str;
14 /* const char *dsn_notify_str(mask)
15 /* int mask;
17 /* int dsn_ret_code(str)
18 /* const char *str;
20 /* const char *dsn_ret_str(code)
21 /* int mask;
22 /* DESCRIPTION
23 /* dsn_ret_code() converts the parameters of a MAIL FROM ..
24 /* RET option to internal form.
26 /* dsn_ret_str() converts internal form to the representation
27 /* used in the MAIL FROM .. RET command. The result is in
28 /* stable and static memory.
30 /* dsn_notify_mask() converts the parameters of a RCPT TO ..
31 /* NOTIFY option to internal form.
33 /* dsn_notify_str() converts internal form to the representation
34 /* used in the MAIL FROM .. NOTIFY command. The result is in
35 /* volatile memory and is clobbered whenever str_name_mask()
36 /* is called.
38 /* Arguments:
39 /* .IP str
40 /* Information received with the MAIL FROM or RCPT TO command.
41 /* .IP mask
42 /* Internal representation.
43 /* DIAGNOSTICS
44 /* dsn_ret_code() and dsn_notify_mask() return 0 when the string
45 /* specifies an invalid request.
47 /* dsn_ret_str() and dsn_notify_str() abort on failure.
48 /* LICENSE
49 /* .ad
50 /* .fi
51 /* The Secure Mailer license must be distributed with this software.
52 /* AUTHOR(S)
53 /* Wietse Venema
54 /* IBM T.J. Watson Research
55 /* P.O. Box 704
56 /* Yorktown Heights, NY 10598, USA
57 /*--*/
60 /* System library. */
62 #include <sys_defs.h>
64 /* Utility library. */
66 #include <name_code.h>
67 #include <name_mask.h>
68 #include <msg.h>
70 /* Global library. */
72 #include <dsn_mask.h>
74 /* Application-specific. */
76 static const NAME_MASK dsn_notify_table[] = {
77 "NEVER", DSN_NOTIFY_NEVER,
78 "SUCCESS", DSN_NOTIFY_SUCCESS,
79 "FAILURE", DSN_NOTIFY_FAILURE,
80 "DELAY", DSN_NOTIFY_DELAY,
81 0, 0,
84 static const NAME_CODE dsn_ret_table[] = {
85 "FULL", DSN_RET_FULL,
86 "HDRS", DSN_RET_HDRS,
87 0, 0,
90 /* dsn_ret_code - string to mask */
92 int dsn_ret_code(const char *str)
94 return (name_code(dsn_ret_table, NAME_CODE_FLAG_NONE, str));
97 /* dsn_ret_str - mask to string */
99 const char *dsn_ret_str(int code)
101 const char *cp ;
103 if ((cp = str_name_code(dsn_ret_table, code)) == 0)
104 msg_panic("dsn_ret_str: unknown code %d", code);
105 return (cp);
108 /* dsn_notify_mask - string to mask */
110 int dsn_notify_mask(const char *str)
112 int mask = name_mask_opt("DSN NOTIFY command", dsn_notify_table,
113 str, NAME_MASK_ANY_CASE | NAME_MASK_RETURN);
115 return (DSN_NOTIFY_OK(mask) ? mask : 0);
118 /* dsn_notify_str - mask to string */
120 const char *dsn_notify_str(int mask)
122 return (str_name_mask_opt((VSTRING *) 0, "DSN NOTIFY command",
123 dsn_notify_table, mask,
124 NAME_MASK_FATAL | NAME_MASK_COMMA));