Switch to unified view

a/src/utils/mimeparse.h b/src/utils/mimeparse.h
...
...
15
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
15
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16
 */
16
 */
17
#ifndef _MIME_H_INCLUDED_
17
#ifndef _MIME_H_INCLUDED_
18
#define _MIME_H_INCLUDED_
18
#define _MIME_H_INCLUDED_
19
/*
19
/*
20
Mime definitions RFC to 4-9-2006:
20
  Mime definitions RFC to 4-9-2006:
21
21
22
2045 Multipurpose Internet Mail Extensions (MIME) Part One: Format of
22
  2045 Multipurpose Internet Mail Extensions (MIME) Part One: Format of
23
     Internet Message Bodies. N. Freed, N. Borenstein. November 1996.
23
  Internet Message Bodies. N. Freed, N. Borenstein. November 1996.
24
     (Format: TXT=72932 bytes) (Obsoletes RFC1521, RFC1522, RFC1590)
24
  (Format: TXT=72932 bytes) (Obsoletes RFC1521, RFC1522, RFC1590)
25
     (Updated by RFC2184, RFC2231) (Status: DRAFT STANDARD)
25
  (Updated by RFC2184, RFC2231) (Status: DRAFT STANDARD)
26
26
27
2046 Multipurpose Internet Mail Extensions (MIME) Part Two: Media
27
  2046 Multipurpose Internet Mail Extensions (MIME) Part Two: Media
28
     Types. N. Freed, N. Borenstein. November 1996. (Format: TXT=105854
28
  Types. N. Freed, N. Borenstein. November 1996. (Format: TXT=105854
29
     bytes) (Obsoletes RFC1521, RFC1522, RFC1590) (Updated by RFC2646,
29
  bytes) (Obsoletes RFC1521, RFC1522, RFC1590) (Updated by RFC2646,
30
     RFC3798) (Status: DRAFT STANDARD)
30
  RFC3798) (Status: DRAFT STANDARD)
31
31
32
2047 MIME (Multipurpose Internet Mail Extensions) Part Three: Message
32
  2047 MIME (Multipurpose Internet Mail Extensions) Part Three: Message
33
     Header Extensions for Non-ASCII Text. K. Moore. November 1996.
33
  Header Extensions for Non-ASCII Text. K. Moore. November 1996.
34
     (Format: TXT=33262 bytes) (Obsoletes RFC1521, RFC1522, RFC1590)
34
  (Format: TXT=33262 bytes) (Obsoletes RFC1521, RFC1522, RFC1590)
35
     (Updated by RFC2184, RFC2231) (Status: DRAFT STANDARD)
35
  (Updated by RFC2184, RFC2231) (Status: DRAFT STANDARD)
36
36
37
2183 Communicating Presentation Information in Internet Messages: The
37
  2183 Communicating Presentation Information in Internet Messages: The
38
     Content-Disposition Header Field. R. Troost, S. Dorner, K. Moore,
38
  Content-Disposition Header Field. R. Troost, S. Dorner, K. Moore,
39
     Ed.. August 1997. (Format: TXT=23150 bytes) (Updates RFC1806)
39
  Ed.. August 1997. (Format: TXT=23150 bytes) (Updates RFC1806)
40
     (Updated by RFC2184, RFC2231) (Status: PROPOSED STANDARD)
40
  (Updated by RFC2184, RFC2231) (Status: PROPOSED STANDARD)
41
41
42
2231 MIME Parameter Value and Encoded Word Extensions: Character Sets,
42
  2231 MIME Parameter Value and Encoded Word Extensions: Character Sets,
43
     Languages, and Continuations. N. Freed, K. Moore. November 1997.
43
  Languages, and Continuations. N. Freed, K. Moore. November 1997.
44
     (Format: TXT=19280 bytes) (Obsoletes RFC2184) (Updates RFC2045,
44
  (Format: TXT=19280 bytes) (Obsoletes RFC2184) (Updates RFC2045,
45
     RFC2047, RFC2183) (Status: PROPOSED STANDARD)
45
  RFC2047, RFC2183) (Status: PROPOSED STANDARD)
46
*/
46
*/
47
47
48
48
49
#include <time.h>
49
#include <time.h>
50
50
51
#include <string>
51
#include <string>
52
#include <map>
52
#include <map>
53
53
54
#include "base64.h"
54
#include "base64.h"
55
55
56
#ifndef NO_NAMESPACES
57
using std::string;
58
#endif
59
60
/** A class to represent a MIME header value with parameters */
56
/** A class to represent a MIME header value with parameters */
61
class MimeHeaderValue {
57
class MimeHeaderValue {
62
 public:
58
public:
63
    string value;
59
    std::string value;
64
    std::map<string, string> params;
60
    std::map<std::string, std::string> params;
65
};
61
};
66
62
67
/** 
63
/** 
68
 * Parse MIME Content-type and Content-disposition value
64
 * Parse MIME Content-type and Content-disposition value
69
 *
65
 *
70
 * @param in the input string should be like: value; pn1=pv1; pn2=pv2. 
66
 * @param in the input string should be like: value; pn1=pv1; pn2=pv2. 
71
 *   Example: text/plain; charset="iso-8859-1" 
67
 *   Example: text/plain; charset="iso-8859-1" 
72
 */
68
 */
73
extern bool parseMimeHeaderValue(const string& in, MimeHeaderValue& psd);
69
extern bool parseMimeHeaderValue(const std::string& in, MimeHeaderValue& psd);
74
70
75
/** 
71
/** 
76
 * Quoted printable decoding. Doubles up as rfc2231 decoder, hence the esc 
72
 * Quoted Printable decoding. 
73
 *
74
 * Doubles up as rfc2231 decoder, with the help of the hence the @param esc 
75
 * parameter.
77
 * RFC2045 Quoted printable uses '=' , rfc2331 uses '%'. The two encodings are
76
 * RFC2045 Quoted Printable uses '=' , RFC2331 uses '%'. The two encodings are
78
 * otherwise similar.
77
 * otherwise similar.
79
 */
78
 */
80
extern bool qp_decode(const string& in, string &out, char esc = '=');
79
extern bool qp_decode(const std::string& in, std::string &out, char esc = '=');
81
80
82
/** Decode an Internet mail field value encoded according to rfc2047 
81
/** Decode an Internet mail field value encoded according to rfc2047 
83
 *
82
 *
84
 * Example input:  Some words =?iso-8859-1?Q?RE=A0=3A_Smoke_Tests?= more input
83
 * Example input:  Some words =?iso-8859-1?Q?RE=A0=3A_Smoke_Tests?= more input
85
 * 
84
 * 
...
...
88
 * is sometimes used anyway...
87
 * is sometimes used anyway...
89
 * 
88
 * 
90
 * @param in input string, ascii with rfc2047 markup
89
 * @param in input string, ascii with rfc2047 markup
91
 * @return out output string encoded in utf-8
90
 * @return out output string encoded in utf-8
92
 */
91
 */
93
extern bool rfc2047_decode(const string& in, string &out);
92
extern bool rfc2047_decode(const std::string& in, std::string &out);
94
93
95
94
96
/** Decode RFC2822 date to unix time (gmt secs from 1970
95
/** Decode RFC2822 date to unix time (gmt secs from 1970)
97
 *
96
 *
98
 * @param dt date string (the part after Date: )
97
 * @param dt date string (the part after Date: )
99
 * @return unix time
98
 * @return unix time
100
 */
99
 */
101
time_t rfc2822DateToUxTime(const string& dt);
100
time_t rfc2822DateToUxTime(const std::string& dt);
102
101
103
#endif /* _MIME_H_INCLUDED_ */
102
#endif /* _MIME_H_INCLUDED_ */