92 static int is_822_dot_string(
const char *local_part,
const char *end,
int flags)
105 if (local_part == end || local_part[0] == 0 || local_part[0] ==
'.')
107 for (cp = local_part; cp < end && (ch = *(
unsigned char *) cp) != 0; cp++) {
108 if (ch ==
'.' && (cp + 1) < end && cp[1] ==
'.')
116 if (ch ==
'(' || ch ==
')'
117 || ch ==
'<' || ch ==
'>'
119 || ch ==
';' || ch ==
':'
120 || ch ==
'\\' || ch ==
'"'
121 || ch ==
'[' || ch ==
']')
131 static VSTRING *make_822_quoted_string(
VSTRING *dst,
const char *local_part,
132 const char *end,
int flags)
142 for (cp = local_part; cp < end && (ch = *(
unsigned char *) cp) != 0; cp++) {
144 || ch ==
'"' || ch ==
'\\' || ch ==
'\r')
166 if (mbox[0] ==
'@' && (colon = strchr(mbox,
':')) != 0)
171 || (end = strrchr(start,
'@')) == 0)
172 end = start + strlen(start);
175 if (is_822_dot_string(start, end, flags)) {
192 const char *bare_at_src;
193 int bare_at_dst_pos = -1;
196 if (mbox[0] ==
'@' && (colon = strchr(mbox,
':')) != 0) {
204 for (cp = start; *cp; cp++) {
206 in_quote = !in_quote;
208 }
else if (*cp ==
'@') {
213 }
else if (*cp ==
'\\') {
221 if (bare_at_dst_pos >= 0) {
244 #define STR vstring_str
246 int main(
int unused_argc,
char **argv)
261 }
else if (strcmp(cmd,
"quote") == 0) {
264 }
else if (strcmp(cmd,
"quote_with_flags") == 0) {
275 }
else if (strcmp(cmd,
"unquote") == 0) {
279 msg_warn(
"unknown command: %s", cmd);
#define QUOTE_FLAG_8BITCLEAN
#define vstring_fgets_nonl(s, p)
const char * quote_flags_to_string(VSTRING *res_buf, int quote_flags_mask)
int main(int argc, char **argv)
VSTRING * vstring_strncat(VSTRING *vp, const char *src, ssize_t len)
VSTRING * unquote_822_local(VSTRING *dst, const char *mbox)
VSTRING * vstring_truncate(VSTRING *vp, ssize_t len)
char * mystrtok(char **src, const char *sep)
#define QUOTE_FLAG_EXPOSE_AT
#define VSTRING_TERMINATE(vp)
VSTRING * quote_822_local_flags(VSTRING *dst, const char *mbox, int flags)
#define VSTRING_ADDCH(vp, ch)
#define QUOTE_FLAG_BARE_LOCALPART
VSTREAM * vstream_printf(const char *fmt,...)
#define VSTRING_RESET(vp)
void msg_warn(const char *fmt,...)
VSTRING * vstring_alloc(ssize_t len)
int quote_flags_from_string(const char *quote_flags_string)
int vstream_fflush(VSTREAM *stream)
#define quote_822_local(dst, src)
VSTRING * vstring_free(VSTRING *vp)
VSTRING * vstring_strncpy(VSTRING *vp, const char *src, ssize_t len)
#define QUOTE_FLAG_APPEND
VSTRING * vstring_strcat(VSTRING *vp, const char *src)