Back to index

courier  0.68.2
rfc2047.h
Go to the documentation of this file.
00001 #ifndef       rfc2047_h
00002 #define       rfc2047_h
00003 
00004 #include      <stdlib.h>
00005 /*
00006 ** Copyright 1998 - 2009 Double Precision, Inc.  See COPYING for
00007 ** distribution information.
00008 */
00009 
00010 #ifdef  __cplusplus
00011 extern "C" {
00012 #endif
00013 
00014 
00015 
00016 struct unicode_info;
00017 
00018 /*
00019 ** Raw RFC 2047 parser.
00020 **
00021 ** rfc2047_decoder() repeatedly invokes the callback function, passing it
00022 ** the decoded RFC 2047 string that's given as an argument.
00023 */
00024 
00025 int rfc2047_decoder(const char *text,
00026                   void (*callback)(const char *chset,
00027                                  const char *lang,
00028                                  const char *content,
00029                                  size_t cnt,
00030                                  void *dummy),
00031                   void *ptr);
00032 
00033 /*
00034 ** rfc2047_print_unicodeaddr is like rfc822_print, except that it converts
00035 ** RFC 2047 MIME encoding to 8 bit text.
00036 */
00037 
00038 struct rfc822a;
00039 
00040 int rfc2047_print_unicodeaddr(const struct rfc822a *a,
00041                            const char *charset,
00042                            void (*print_func)(char, void *),
00043                            void (*print_separator)(const char *, void *),
00044                            void *ptr);
00045 
00046 
00047 /*
00048 ** And now, let's encode something with RFC 2047.  Encode the following
00049 ** string in the indicated character set, into a malloced buffer.  Returns 0
00050 ** if malloc failed.
00051 */
00052 
00053 char *rfc2047_encode_str(const char *str, const char *charset,
00054                       int (*qp_allow)(char c) /* See below */);
00055 
00056 
00057 /* Potential arguments for qp_allow */
00058 
00059 int rfc2047_qp_allow_any(char); /* Any character */
00060 int rfc2047_qp_allow_comment(char); /* Any character except () */
00061 int rfc2047_qp_allow_word(char); /* See RFC2047, bottom of page 7 */
00062 
00063 
00064 
00065 /*
00066 ** rfc2047_encode_header allocates a buffer, and MIME-encodes a header.
00067 **
00068 ** The name of the header, passed as the first parameter, should be
00069 ** "From", "To", "Subject", etc... It is not included in the encoded contents.
00070 */
00071 char *rfc2047_encode_header_tobuf(const char *name, /* Header name */
00072                               const char *header, /* Header's contents */
00073                               const char *charset);
00074 
00075 /*
00076 ** rfc2047_encode_header_addr allocates a buffer, and MIME-encodes an
00077 ** RFC822 address header.
00078 **
00079 */
00080 char *rfc2047_encode_header_addr(const struct rfc822a *a,
00081                              const char *charset);
00082 
00083 #ifdef  __cplusplus
00084 }
00085 #endif
00086 
00087 #endif