Bincimap 2.0.16
Easy Imapping
Loading...
Searching...
No Matches
mime-getpart.cc
Go to the documentation of this file.
1
7#include "mime.h"
8#include "convert.h"
9#include <string>
10#include <vector>
11#include <map>
12#include <exception>
13#include <iostream>
14
15#include <string.h>
16#include <ctype.h>
17#include <stdio.h>
18#include <errno.h>
19
20using namespace ::std;
21
22//------------------------------------------------------------------------
23const Binc::MimePart *Binc::MimePart::getPart(const string &findpart,
24 string genpart, FetchType fetchType) const
25{
26 if (findpart == genpart)
27 return this;
28
29 if (isMultipart()) {
30 if (members.size() != 0) {
31 vector<MimePart>::const_iterator i = members.begin();
32 int part = 1;
33 while (i != members.end()) {
34 BincStream ss;
35 ss << genpart;
36 if (genpart != "")
37 ss << ".";
38 ss << part;
39
40 const MimePart *m;
41 if ((m = (*i).getPart(findpart, ss.str())) != 0) {
42 if (fetchType == FetchHeader && m->isMessageRFC822())
43 m = &m->members[0];
44 return m;
45 }
46
47 ++i;
48 ++part;
49 }
50 }
51 } else if (isMessageRFC822()) {
52 if (members.size() == 1) {
53 const MimePart *m = members[0].getPart(findpart, genpart);
54 return m;
55 } else {
56 return 0;
57 }
58 } else {
59 // Singlepart
60 if (genpart != "")
61 genpart += ".";
62 genpart += "1";
63
64 if (findpart == genpart)
65 return this;
66 }
67
68 return 0;
69}
const std::string & str(void) const
Definition: convert.cc:58
bool isMessageRFC822(void) const
Definition: mime.h:79
std::vector< MimePart > members
Definition: mime.h:75
bool isMultipart(void) const
Definition: mime.h:78
const MimePart * getPart(const std::string &findpart, std::string genpart, FetchType fetchType=FetchBody) const
Definition: mime-getpart.cc:23
@ FetchHeader
Definition: mime.h:69
Declaration of miscellaneous convertion functions.
Declaration of main mime parser components.