Imported Debian patch 0.66.1-1
[hcoop/debian/courier-authlib.git] / libs / rfc822 / rfc2047.h
CommitLineData
d9898ee8 1#ifndef rfc2047_h
2#define rfc2047_h
3
4#include <stdlib.h>
5/*
8d138742 6** Copyright 1998 - 2009 Double Precision, Inc. See COPYING for
d9898ee8 7** distribution information.
8*/
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14
d9898ee8 15
8d138742 16struct unicode_info;
d9898ee8 17
18/*
8d138742
CE
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.
d9898ee8 23*/
24
8d138742
CE
25int 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);
d9898ee8 32
33/*
8d138742
CE
34** rfc2047_print_unicodeaddr is like rfc822_print, except that it converts
35** RFC 2047 MIME encoding to 8 bit text.
d9898ee8 36*/
37
38struct rfc822a;
39
8d138742
CE
40int 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);
d9898ee8 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
53char *rfc2047_encode_str(const char *str, const char *charset,
54 int (*qp_allow)(char c) /* See below */);
55
d9898ee8 56
57/* Potential arguments for qp_allow */
58
59int rfc2047_qp_allow_any(char); /* Any character */
60int rfc2047_qp_allow_comment(char); /* Any character except () */
61int rfc2047_qp_allow_word(char); /* See RFC2047, bottom of page 7 */
62
63
8d138742
CE
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*/
71char *rfc2047_encode_header_tobuf(const char *name, /* Header name */
72 const char *header, /* Header's contents */
73 const char *charset);
74
d9898ee8 75/*
8d138742
CE
76** rfc2047_encode_header_addr allocates a buffer, and MIME-encodes an
77** RFC822 address header.
d9898ee8 78**
79*/
8d138742
CE
80char *rfc2047_encode_header_addr(const struct rfc822a *a,
81 const char *charset);
d9898ee8 82
83#ifdef __cplusplus
84}
85#endif
86
87#endif