Bincimap 2.0.16
Easy Imapping
Loading...
Searching...
No Matches
mime.h
Go to the documentation of this file.
1
7#ifndef mime_h_included
8#define mime_h_included
9#include <string>
10#include <vector>
11#include <map>
12#include <stdio.h>
13
14namespace Binc {
15 //----------------------------------------------------------------------
16 class HeaderItem {
17 private:
18 mutable std::string key;
19 mutable std::string value;
20
21 public:
22 inline const std::string &getKey(void) const { return key; }
23 inline const std::string &getValue(void) const { return value; }
24
25 //--
26 HeaderItem(void);
27 HeaderItem(const std::string &key, const std::string &value);
28 };
29
30 //----------------------------------------------------------------------
31 class Header {
32 private:
33 mutable std::vector<HeaderItem> content;
34
35 public:
36 bool getFirstHeader(const std::string &key, HeaderItem &dest) const;
37 bool getAllHeaders(const std::string &key, std::vector<HeaderItem> &dest) const;
38 void add(const std::string &name, const std::string &content);
39 void clear(void) const;
40
41 //--
42 Header(void);
43 ~Header(void);
44 };
45
46 //----------------------------------------------------------------------
47 class IODevice;
48 class MimeDocument;
49 class MimePart {
50 protected:
51 public:
52 mutable bool multipart;
53 mutable bool messagerfc822;
54 mutable std::string subtype;
55 mutable std::string boundary;
56
57 mutable unsigned int headerstartoffsetcrlf;
58 mutable unsigned int headerlength;
59
60 mutable unsigned int bodystartoffsetcrlf;
61 mutable unsigned int bodylength;
62 mutable unsigned int nlines;
63 mutable unsigned int nbodylines;
64 mutable unsigned int size;
65
66 public:
67 enum FetchType {
71 };
72
73 mutable Header h;
74
75 mutable std::vector<MimePart> members;
76
77 inline const std::string &getSubType(void) const { return subtype; }
78 inline bool isMultipart(void) const { return multipart; }
79 inline bool isMessageRFC822(void) const { return messagerfc822; }
80 inline unsigned int getSize(void) const { return bodylength; }
81 inline unsigned int getNofLines(void) const { return nlines; }
82 inline unsigned int getNofBodyLines(void) const { return nbodylines; }
83 inline unsigned int getBodyLength(void) const { return bodylength; }
84 inline unsigned int getBodyStartOffset(void) const { return bodystartoffsetcrlf; }
85
86 void printBody(int fd, Binc::IODevice &output, unsigned int startoffset, unsigned int length) const;
87 void printHeader(int fd, Binc::IODevice &output, std::vector<std::string> headers,
88 bool includeheaders, unsigned int startoffset, unsigned int length, std::string &storage) const;
89 void printDoc(int fd, Binc::IODevice &output, unsigned int startoffset, unsigned int length) const;
90 virtual void clear(void) const;
91
92 const MimePart *getPart(const std::string &findpart, std::string genpart, FetchType fetchType = FetchBody) const;
93 virtual int parseOnlyHeader(const std::string &toboundary) const;
94 virtual int parseFull(const std::string &toboundary, int &boundarysize) const;
95
96 MimePart(void);
97 virtual ~MimePart(void);
98 };
99
100 //----------------------------------------------------------------------
101 class MimeDocument : public MimePart {
102 private:
103 mutable bool headerIsParsed;
104 mutable bool allIsParsed;
105
106 public:
107 void parseOnlyHeader(int fd) const;
108 void parseFull(int fd) const;
109 void clear(void) const;
110
111 inline bool isHeaderParsed(void) { return headerIsParsed; }
112 inline bool isAllParsed(void) { return allIsParsed; }
113
114 //--
115 MimeDocument(void);
116 ~MimeDocument(void);
117 };
118
119};
120
121#endif
void clear(void) const
Definition: mime.cc:125
Header(void)
Definition: mime.cc:79
~Header(void)
Definition: mime.cc:84
bool getAllHeaders(const std::string &key, std::vector< HeaderItem > &dest) const
Definition: mime.cc:108
void add(const std::string &name, const std::string &content)
Definition: mime.cc:131
bool getFirstHeader(const std::string &key, HeaderItem &dest) const
Definition: mime.cc:89
const std::string & getKey(void) const
Definition: mime.h:22
HeaderItem(const std::string &key, const std::string &value)
HeaderItem(void)
Definition: mime.cc:67
const std::string & getValue(void) const
Definition: mime.h:23
The IODevice class provides a framework for reading and writing to device.
Definition: iodevice.h:31
bool isAllParsed(void)
Definition: mime.h:112
void parseFull(int fd) const
void clear(void) const
Definition: mime.cc:35
bool isHeaderParsed(void)
Definition: mime.h:111
~MimeDocument(void)
Definition: mime.cc:30
MimeDocument(void)
Definition: mime.cc:23
void parseOnlyHeader(int fd) const
bool isMessageRFC822(void) const
Definition: mime.h:79
void printBody(int fd, Binc::IODevice &output, unsigned int startoffset, unsigned int length) const
virtual int parseFull(const std::string &toboundary, int &boundarysize) const
virtual void clear(void) const
Definition: mime.cc:44
unsigned int headerstartoffsetcrlf
Definition: mime.h:57
unsigned int getBodyStartOffset(void) const
Definition: mime.h:84
unsigned int nbodylines
Definition: mime.h:63
std::vector< MimePart > members
Definition: mime.h:75
unsigned int getNofBodyLines(void) const
Definition: mime.h:82
MimePart(void)
Definition: mime.cc:51
virtual ~MimePart(void)
Definition: mime.cc:62
Header h
Definition: mime.h:73
bool multipart
Definition: mime.h:52
void printHeader(int fd, Binc::IODevice &output, std::vector< std::string > headers, bool includeheaders, unsigned int startoffset, unsigned int length, std::string &storage) const
bool messagerfc822
Definition: mime.h:53
std::string subtype
Definition: mime.h:54
std::string boundary
Definition: mime.h:55
unsigned int getBodyLength(void) const
Definition: mime.h:83
virtual int parseOnlyHeader(const std::string &toboundary) const
unsigned int bodylength
Definition: mime.h:61
unsigned int bodystartoffsetcrlf
Definition: mime.h:60
bool isMultipart(void) const
Definition: mime.h:78
unsigned int getSize(void) const
Definition: mime.h:80
unsigned int size
Definition: mime.h:64
unsigned int getNofLines(void) const
Definition: mime.h:81
const MimePart * getPart(const std::string &findpart, std::string genpart, FetchType fetchType=FetchBody) const
Definition: mime-getpart.cc:23
unsigned int headerlength
Definition: mime.h:58
unsigned int nlines
Definition: mime.h:62
const std::string & getSubType(void) const
Definition: mime.h:77
void printDoc(int fd, Binc::IODevice &output, unsigned int startoffset, unsigned int length) const
@ FetchHeader
Definition: mime.h:69
@ FetchMime
Definition: mime.h:70
@ FetchBody
Definition: mime.h:68
Definition: bincimapd.cc:9