6 ** Copyright 1998 - 2002 Double Precision, Inc. See COPYING for
7 ** distribution information.
15 static const char rfc2047_h_rcsid
[]="$Id: rfc2047.h,v 1.9 2007/03/01 04:32:04 mrsam Exp $";
17 extern int rfc2047_decode(const char *text
,
18 int (*func
)(const char *, int,
24 extern char *rfc2047_decode_simple(const char *text
);
26 extern char *rfc2047_decode_enhanced(const char *text
, const char *mychset
);
29 ** If libunicode.a is available, like rfc2047_decode_enhanced, but attempt to
30 ** convert to my preferred charset.
35 extern char *rfc2047_decode_unicode(const char *text
,
36 const struct unicode_info
*mychset
,
39 #define RFC2047_DECODE_DISCARD 1
40 /* options: Discard unknown charsets from decoded string. */
41 #define RFC2047_DECODE_ABORT 2
42 /* options: Abort if we encounter an unknown charset, errno=EINVAL */
43 #define RFC2047_DECODE_NOTAG 4
44 /* options: Do not tag unknown charset strings */
45 #define RFC2047_DECODE_REPLACE 8
46 /* options: Replace unknown characters */
49 ** rfc2047_print is like rfc822_print, except that it converts RFC 2047
50 ** MIME encoding to 8 bit text.
55 void rfc2047_print(const struct rfc822a
*a
,
57 void (*print_func
)(char, void *),
58 void (*print_separator
)(const char *, void *), void *);
60 void rfc2047_print_unicode(const struct rfc822a
*a
,
62 void (*print_func
)(char, void *),
63 void (*print_separator
)(const char *, void *),
69 ** And now, let's encode something with RFC 2047. Encode the following
70 ** string in the indicated character set, into a malloced buffer. Returns 0
74 char *rfc2047_encode_str(const char *str
, const char *charset
,
75 int (*qp_allow
)(char c
) /* See below */);
78 ** If you can live with the encoded text being generated on the fly, use
79 ** rfc2047_encode_callback, which calls a callback function, instead of
80 ** dynamically allocating memory.
83 int rfc2047_encode_callback(const char *str
, /* String to encode */
84 const char *charset
, /* Native charset */
85 int (*qp_allow
)(char c
),
86 /* Return true if c can appear in QP-encoded
88 int (*cb_func
)(const char *, size_t, void *),
89 /* Callback function. */
91 /* Passthrough arg to callback_function */
94 /* Potential arguments for qp_allow */
96 int rfc2047_qp_allow_any(char); /* Any character */
97 int rfc2047_qp_allow_comment(char); /* Any character except () */
98 int rfc2047_qp_allow_word(char); /* See RFC2047, bottom of page 7 */
102 ** rfc2047_encode_header allocates a buffer, and MIME-encodes an RFC822 header
105 char *rfc2047_encode_header(const struct rfc822a
*a
,
106 const char *charset
);