Switch to unified view

a/src/bincimapmime/mime.h b/src/bincimapmime/mime.h
...
...
33
#include <vector>
33
#include <vector>
34
#include <map>
34
#include <map>
35
#include <stdio.h>
35
#include <stdio.h>
36
36
37
namespace Binc {
37
namespace Binc {
38
39
  class MimeInputSource;
40
41
38
  //---------------------------------------------------------------------- 
42
  //---------------------------------------------------------------------- 
39
  class HeaderItem {
43
  class HeaderItem {
40
  private:
44
  private:
41
    mutable std::string key;
45
    mutable std::string key;
42
    mutable std::string value;
46
    mutable std::string value;
...
...
57
61
58
  public:
62
  public:
59
    bool getFirstHeader(const std::string &key, HeaderItem &dest) const;
63
    bool getFirstHeader(const std::string &key, HeaderItem &dest) const;
60
    bool getAllHeaders(const std::string &key, std::vector<HeaderItem> &dest) const;
64
    bool getAllHeaders(const std::string &key, std::vector<HeaderItem> &dest) const;
61
    void add(const std::string &name, const std::string &content);
65
    void add(const std::string &name, const std::string &content);
62
    void clear(void) const;
66
    void clear(void);
63
67
64
    //--
68
    //--
65
    Header(void);
69
    Header(void);
66
    ~Header(void);
70
    ~Header(void);
67
  };
71
  };
...
...
104
    inline unsigned int getNofLines(void) const { return nlines; }
108
    inline unsigned int getNofLines(void) const { return nlines; }
105
    inline unsigned int getNofBodyLines(void) const { return nbodylines; }
109
    inline unsigned int getNofBodyLines(void) const { return nbodylines; }
106
    inline unsigned int getBodyLength(void) const { return bodylength; }
110
    inline unsigned int getBodyLength(void) const { return bodylength; }
107
    inline unsigned int getBodyStartOffset(void) const { return bodystartoffsetcrlf; }
111
    inline unsigned int getBodyStartOffset(void) const { return bodystartoffsetcrlf; }
108
112
109
    void printBody(int fd, Binc::IODevice &output, unsigned int startoffset, unsigned int length) const;
113
    void printBody(Binc::IODevice &output, unsigned int startoffset, unsigned int length) const;
110
      void getBody(int fd, std::string& s, unsigned int startoffset, unsigned int length) const;
111
      void getBody(std::string& s, unsigned int startoffset, unsigned int length) const;
114
      void getBody(std::string& s, unsigned int startoffset, unsigned int length) const;
112
    void printHeader(int fd, Binc::IODevice &output, std::vector<std::string> headers, bool includeheaders, unsigned int startoffset, unsigned int length, std::string &storage) const;
113
    void printDoc(int fd, Binc::IODevice &output, unsigned int startoffset, unsigned int length) const;
114
    virtual void clear(void) const;
115
    virtual void clear(void);
115
116
116
    const MimePart *getPart(const std::string &findpart, std::string genpart, FetchType fetchType = FetchBody) const;
117
    virtual int doParseOnlyHeader(MimeInputSource *ms, 
117
    virtual int doParseOnlyHeader(const std::string &toboundary) const;
118
                const std::string &toboundary);
118
    virtual int doParseFull(const std::string &toboundary, int &boundarysize) const;
119
    virtual int doParseFull(MimeInputSource *ms, 
120
              const std::string &toboundary, int &boundarysize);
119
121
120
    MimePart(void);
122
    MimePart(void);
121
    virtual ~MimePart(void);
123
    virtual ~MimePart(void);
124
125
  private:
126
    MimeInputSource *mimeSource;
127
128
    bool parseOneHeaderLine(Binc::Header *header, unsigned int *nlines);
129
130
    bool skipUntilBoundary(const std::string &delimiter,
131
             unsigned int *nlines, bool *eof);
132
    inline void postBoundaryProcessing(bool *eof,
133
                     unsigned int *nlines,
134
                     int *boundarysize,
135
                     bool *foundendofpart);
136
      void parseMultipart(const std::string &boundary,
137
             const std::string &toboundary,
138
             bool *eof,
139
             unsigned int *nlines,
140
             int *boundarysize,
141
             bool *foundendofpart,
142
             unsigned int *bodylength,
143
            std::vector<Binc::MimePart> *members);
144
      void parseSinglePart(const std::string &toboundary,
145
              int *boundarysize,
146
              unsigned int *nbodylines,
147
              unsigned int *nlines,
148
              bool *eof, bool *foundendofpart,
149
             unsigned int *bodylength);
150
    void parseHeader(Binc::Header *header, unsigned int *nlines);
151
    void analyzeHeader(Binc::Header *header, bool *multipart,
152
             bool *messagerfc822, std::string *subtype,
153
             std::string *boundary);
154
    void parseMessageRFC822(std::vector<Binc::MimePart> *members,
155
              bool *foundendofpart,
156
              unsigned int *bodylength,
157
              unsigned int *nbodylines,
158
              const std::string &toboundary);
122
  };
159
  };
123
160
124
  //----------------------------------------------------------------------
161
  //----------------------------------------------------------------------
125
  class MimeDocument : public MimePart {
162
  class MimeDocument : public MimePart {
126
  private:
127
    mutable bool headerIsParsed;
128
    mutable bool allIsParsed;
129
130
  public:
163
  public:
131
    void parseOnlyHeader(int fd) const;
132
    void parseFull(int fd) const;
133
    void parseOnlyHeader(std::istream& s) const;
134
    void parseFull(std::istream& s) const;
135
    void clear(void) const;
136
    
137
    inline bool isHeaderParsed(void) { return headerIsParsed; }
138
    inline bool isAllParsed(void) { return allIsParsed; }
139
140
    //--
141
    MimeDocument(void);
164
    MimeDocument(void);
142
    ~MimeDocument(void);
165
    ~MimeDocument(void);
166
167
    void parseOnlyHeader(int fd);
168
    void parseFull(int fd);
169
    void parseOnlyHeader(std::istream& s);
170
    void parseFull(std::istream& s);
171
172
    void clear(void);
173
    
174
    bool isHeaderParsed(void) const 
175
    {
176
      return headerIsParsed; 
177
    }
178
    bool isAllParsed(void) const 
179
    { 
180
      return allIsParsed; 
181
    }
182
183
  private:
184
    bool headerIsParsed;
185
    bool allIsParsed;
186
    MimeInputSource *doc_mimeSource;
143
  };
187
  };
144
188
145
};
189
};
146
190
147
#endif
191
#endif