2 ** Copyright 1998 - 2006 Double Precision, Inc.
3 ** See COPYING for distribution information.
12 static void print_func(char c
, void *p
)
18 static void print_separator(const char *s
, void *p
)
24 static struct rfc822t
*tokenize(const char *p
)
30 printf("Tokenize: %s\n", p
);
31 tp
=rfc822t_alloc_new(p
, NULL
, NULL
);
34 for (i
=0; i
<tp
->ntokens
; i
++)
36 buf
[0]=tp
->tokens
[i
].token
;
37 if (buf
[0] == '\0' || buf
[0] == '"' || buf
[0] == '(')
39 printf("%s: ", buf
[0] == '"' ? "Quote":
40 buf
[0] == '(' ? "Comment":"Atom");
41 if (fwrite(tp
->tokens
[i
].ptr
, tp
->tokens
[i
].len
, 1,
47 else printf("Token: %s\n", buf
[0] ? buf
:"atom");
52 static struct rfc822a
*doaddr(struct rfc822t
*t
)
54 struct rfc822a
*a
=rfc822a_alloc(t
);
58 rfc822_print(a
, print_func
, print_separator
, NULL
);
65 struct rfc822t
*t1
, *t2
, *t3
, *t4
, *t5
;
66 struct rfc822a
*a1
, *a2
, *a3
, *a4
, *a5
;
68 t1
=tokenize("nobody@example.com (Nobody (is) here\\) right)");
69 t2
=tokenize("Distribution list: nobody@example.com daemon@example.com");
70 t3
=tokenize("Mr Nobody <nobody@example.com>, Mr. Nobody <nobody@example.com>");
71 t4
=tokenize("nobody@example.com, <nobody@example.com>, Mr. Nobody <nobody@example.com>");
73 t5
=tokenize("=?UTF-8?Q?Test?= <nobody@example.com>, foo=bar <nobody@example.com>");
92 #define FIVEUTF8 "\xe2\x85\xa4"
94 #define FIVETIMES4 FIVEUTF8 FIVEUTF8 FIVEUTF8 FIVEUTF8
96 #define FIVETIMES16 FIVETIMES4 FIVETIMES4 FIVETIMES4 FIVETIMES4
98 #define FIVEMAX FIVETIMES16 FIVETIMES4 FIVETIMES4
101 char *p
=rfc2047_encode_str(FIVEMAX
, "utf-8",
102 rfc2047_qp_allow_any
);
112 char *p
=rfc2047_encode_str(FIVEMAX FIVEUTF8
, "utf-8",
113 rfc2047_qp_allow_any
);
123 char *p
=rfc2047_encode_str(FIVEMAX
"\xcc\x80", "utf-8",
124 rfc2047_qp_allow_any
);