1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/*++
/* NAME
/* quote_flags 3
/* SUMMARY
/* quote rfc 821/822 local part
/* SYNOPSIS
/* #include <quote_flags.h>
/*
/* int quote_flags_from_string(const char *string)
/*
/* const char *quote_flags_to_string(VSTRING *res_buf, int mask)
/* DESCRIPTION
/* quote_flags_from_string() converts symbolic flag names into
/* the corresponding internal bitmask. This logs a warning and
/* returns zero if an unknown symbolic name is specified.
/*
/* quote_flags_to_string() converts from internal bitmask to
/* the corresponding symbolic names. This logs a warning and
/* returns a null pointer if an unknown bitmask is specified.
/*
/* Arguments:
/* .IP string
/* Symbolic representation of a quote_flags bitmask, for
/* example: \fB8bitclean | bare_localpart\fR. The conversion
/* is case-insensitive.
/* .IP res_buf
/* Storage for the quote_flags_to_string() result, which has
/* the same form as the string argument. If a null pointer is
/* specified, quote_flags_to_string() uses storage that is
/* overwritten with each call.
/* .IP mask
/* Binary representation of quote_flags.
/* DIAGNOSTICS
/* Fatal error: out of memory; or unknown bitmask name or value.
/* LICENSE
/* .ad
/* .fi
/* The Secure Mailer license must be distributed with this software.
/* AUTHOR(S)
/* Wietse Venema
/* Google, Inc.
/* 111 8th Avenue
/* New York, NY 10011, USA
/*--*/
/*
* System library.
*/
#include <sys_defs.h>
/*
* Utility library.
*/
#include <name_mask.h>
/*
* Global library.
*/
#include <quote_flags.h>
static const NAME_MASK quote_flags_table[] = {
"8bitclean", QUOTE_FLAG_8BITCLEAN,
"expose_at", QUOTE_FLAG_EXPOSE_AT,
"append", QUOTE_FLAG_APPEND,
"bare_localpart", QUOTE_FLAG_BARE_LOCALPART,
0,
};
/* quote_flags_from_string - symbolic quote flags to internal form */
int quote_flags_from_string(const char *quote_flags_string)
{
return (name_mask_delim_opt("quote_flags_from_string", quote_flags_table,
quote_flags_string, "|",
NAME_MASK_WARN | NAME_MASK_ANY_CASE));
}
/* quote_flags_to_string - internal form to symbolic quote flags */
const char *quote_flags_to_string(VSTRING *res_buf, int quote_flags_mask)
{
static VSTRING *my_buf;
if (res_buf == 0 && (res_buf = my_buf) == 0)
res_buf = my_buf = vstring_alloc(20);
return (str_name_mask_opt(res_buf, "quote_flags_to_string",
quote_flags_table, quote_flags_mask,
NAME_MASK_WARN | NAME_MASK_PIPE));
}
|