1 #ifndef rfc2047_h 2 #define rfc2047_h 3 4 /* 5 ** Copyright 1998 - 2000 Double Precision, Inc. See COPYING for 6 ** distribution information. 7 */ 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 14 static const char rfc2047_h_rcsid[]="$Id$"; 15 16 extern int rfc2047_decode(const char *text, 17 int (*func)(const char *, int, const char *, void *), 18 void *arg); 19 20 extern char *rfc2047_decode_simple(const char *text); 21 22 extern char *rfc2047_decode_enhanced(const char *text, const char *mychset); 23 24 /* 25 ** If libunicode.a is available, like rfc2047_decode_enhanced, but attempt to 26 ** convert to my preferred charset. 27 */ 28 29 struct unicode_info; 30 31 extern char *rfc2047_decode_unicode(const char *text, 32 const struct unicode_info *mychset, 33 int options); 34 35 #define RFC2047_DECODE_DISCARD 1 36 /* options: Discard unknown charsets from decoded string. */ 37 #define RFC2047_DECODE_ABORT 2 38 /* options: Abort if we encounter an unknown charset, errno=EINVAL */ 39 40 41 42 43 /* 44 ** rfc2047_print is like rfc822_print, except that it converts RFC 2047 45 ** MIME encoding to 8 bit text. 46 */ 47 48 struct rfc822a; 49 50 void rfc2047_print(const struct rfc822a *a, 51 const char *charset, 52 void (*print_func)(char, void *), 53 void (*print_separator)(const char *, void *), void *); 54 55 /* 56 ** And now, let's encode something with RFC 2047. Encode the following 57 ** string in the indicated character set, into a malloced buffer. Returns 0 58 ** if malloc failed. 59 */ 60 61 char *rfc2047_encode_str(const char *str, const char *charset); 62 63 /* 64 ** If you can live with the encoded text being generated on the fly, use 65 ** rfc2047_encode_callback, which calls a callback function, instead of 66 ** dynamically allocating memory. 67 */ 68 69 int rfc2047_encode_callback(const char *str, const char *charset, 70 int (*func)(const char *, size_t, void *), void *arg); 71 72 /* 73 ** rfc2047_encode_header allocates a buffer, and MIME-encodes an RFC822 header 74 ** 75 */ 76 char *rfc2047_encode_header(const struct rfc822a *a, 77 const char *charset); 78 79 #ifdef __cplusplus 80 } 81 #endif 82 83 #endif 84