1 #ifndef	rfc2047_h
2 #define	rfc2047_h
3 
4 #include	<stdlib.h>
5 /*
6 ** Copyright 1998 - 2009 Double Precision, Inc.  See COPYING for
7 ** distribution information.
8 */
9 
10 #ifdef  __cplusplus
11 extern "C" {
12 #endif
13 
14 
15 
16 struct unicode_info;
17 
18 /*
19 ** Raw RFC 2047 parser.
20 **
21 ** rfc2047_decoder() repeatedly invokes the callback function, passing it
22 ** the decoded RFC 2047 string that's given as an argument.
23 */
24 
25 int rfc2047_decoder(const char *text,
26 		    void (*callback)(const char *chset,
27 				     const char *lang,
28 				     const char *content,
29 				     size_t cnt,
30 				     void *dummy),
31 		    void *ptr);
32 
33 /*
34 ** rfc2047_print_unicodeaddr is like rfc822_print, except that it converts
35 ** RFC 2047 MIME encoding to 8 bit text.
36 */
37 
38 struct rfc822a;
39 
40 int rfc2047_print_unicodeaddr(const struct rfc822a *a,
41 			      const char *charset,
42 			      void (*print_func)(char, void *),
43 			      void (*print_separator)(const char *, void *),
44 			      void *ptr);
45 
46 
47 /*
48 ** And now, let's encode something with RFC 2047.  Encode the following
49 ** string in the indicated character set, into a malloced buffer.  Returns 0
50 ** if malloc failed.
51 */
52 
53 char *rfc2047_encode_str(const char *str, const char *charset,
54 			 int (*qp_allow)(char c) /* See below */);
55 
56 
57 /* Potential arguments for qp_allow */
58 
59 int rfc2047_qp_allow_any(char); /* Any character */
60 int rfc2047_qp_allow_comment(char); /* Any character except () */
61 int rfc2047_qp_allow_word(char); /* See RFC2047, bottom of page 7 */
62 
63 
64 
65 /*
66 ** rfc2047_encode_header allocates a buffer, and MIME-encodes a header.
67 **
68 ** The name of the header, passed as the first parameter, should be
69 ** "From", "To", "Subject", etc... It is not included in the encoded contents.
70 */
71 char *rfc2047_encode_header_tobuf(const char *name, /* Header name */
72 				  const char *header, /* Header's contents */
73 				  const char *charset);
74 
75 /*
76 ** rfc2047_encode_header_addr allocates a buffer, and MIME-encodes an
77 ** RFC822 address header.
78 **
79 */
80 char *rfc2047_encode_header_addr(const struct rfc822a *a,
81 				 const char *charset);
82 
83 #ifdef  __cplusplus
84 }
85 #endif
86 
87 #endif
88