6 ** Copyright 1998 - 2009 Double Precision, Inc. See COPYING for
7 ** distribution information.
15 static const char rfc2047_h_rcsid
[]="$Id: rfc2047.h,v 1.12 2009/11/14 21:15:43 mrsam Exp $";
20 ** Raw RFC 2047 parser.
22 ** rfc2047_decoder() repeatedly invokes the callback function, passing it
23 ** the decoded RFC 2047 string that's given as an argument.
26 int rfc2047_decoder(const char *text
,
27 void (*callback
)(const char *chset
,
35 ** rfc2047_print_unicodeaddr is like rfc822_print, except that it converts
36 ** RFC 2047 MIME encoding to 8 bit text.
41 int rfc2047_print_unicodeaddr(const struct rfc822a
*a
,
43 void (*print_func
)(char, void *),
44 void (*print_separator
)(const char *, void *),
49 ** And now, let's encode something with RFC 2047. Encode the following
50 ** string in the indicated character set, into a malloced buffer. Returns 0
54 char *rfc2047_encode_str(const char *str
, const char *charset
,
55 int (*qp_allow
)(char c
) /* See below */);
58 ** If you can live with the encoded text being generated on the fly, use
59 ** rfc2047_encode_callback, which calls a callback function, instead of
60 ** dynamically allocating memory.
63 int rfc2047_encode_callback(const char *str
, /* String to encode */
64 const char *charset
, /* Native charset */
65 int (*qp_allow
)(char c
),
66 /* Return true if c can appear in QP-encoded
68 int (*cb_func
)(const char *, size_t, void *),
69 /* Callback function. */
71 /* Passthrough arg to callback_function */
74 /* Potential arguments for qp_allow */
76 int rfc2047_qp_allow_any(char); /* Any character */
77 int rfc2047_qp_allow_comment(char); /* Any character except () */
78 int rfc2047_qp_allow_word(char); /* See RFC2047, bottom of page 7 */
83 ** rfc2047_encode_header allocates a buffer, and MIME-encodes a header.
85 ** The name of the header, passed as the first parameter, should be
86 ** "From", "To", "Subject", etc... It is not included in the encoded contents.
88 char *rfc2047_encode_header_tobuf(const char *name
, /* Header name */
89 const char *header
, /* Header's contents */
93 ** rfc2047_encode_header_addr allocates a buffer, and MIME-encodes an
94 ** RFC822 address header.
97 char *rfc2047_encode_header_addr(const struct rfc822a
*a
,