"Fossies" - the Fresh Open Source Software Archive 
Member "recoll-1.26.3/bincimapmime/mime.cc" (4 Sep 2019, 4242 Bytes) of package /linux/privat/recoll-1.26.3.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "mime.cc" see the
Fossies "Dox" file reference documentation.
1 /* -*- mode:c++;c-basic-offset:2 -*- */
2 /* --------------------------------------------------------------------
3 * Filename:
4 * mime.cc
5 *
6 * Description:
7 * Implementation of main mime parser components
8 * --------------------------------------------------------------------
9 * Copyright 2002-2005 Andreas Aardal Hanssen
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * --------------------------------------------------------------------
25 */
26 #include <string.h>
27 #include <ctype.h>
28 #include <stdio.h>
29 #include <errno.h>
30
31 #include <string>
32 #include <vector>
33 #include <map>
34 #include <exception>
35 #include <iostream>
36 #ifndef NO_NAMESPACES
37 using namespace ::std;
38 #endif /* NO_NAMESPACES */
39
40
41 #include "mime.h"
42 #include "convert.h"
43 #include "mime-inputsource.h"
44
45 //------------------------------------------------------------------------
46 Binc::MimeDocument::MimeDocument(void)
47 {
48 allIsParsed = false;
49 headerIsParsed = false;
50 doc_mimeSource = 0;
51 }
52
53 //------------------------------------------------------------------------
54 Binc::MimeDocument::~MimeDocument(void)
55 {
56 delete doc_mimeSource;
57 doc_mimeSource = 0;
58 }
59
60 //------------------------------------------------------------------------
61 void Binc::MimeDocument::clear(void)
62 {
63 members.clear();
64 h.clear();
65 headerIsParsed = false;
66 allIsParsed = false;
67 delete doc_mimeSource;
68 doc_mimeSource = 0;
69 }
70
71 //------------------------------------------------------------------------
72 void Binc::MimePart::clear(void)
73 {
74 members.clear();
75 h.clear();
76 mimeSource = 0;
77 }
78
79 //------------------------------------------------------------------------
80 Binc::MimePart::MimePart(void)
81 {
82 size = 0;
83 messagerfc822 = false;
84 multipart = false;
85
86 nlines = 0;
87 nbodylines = 0;
88 mimeSource = 0;
89 }
90
91 //------------------------------------------------------------------------
92 Binc::MimePart::~MimePart(void)
93 {
94 }
95
96 //------------------------------------------------------------------------
97 Binc::HeaderItem::HeaderItem(void)
98 {
99 }
100
101 //------------------------------------------------------------------------
102 Binc::HeaderItem::HeaderItem(const string &key, const string &value)
103 {
104 this->key = key;
105 this->value = value;
106 }
107
108 //------------------------------------------------------------------------
109 Binc::Header::Header(void)
110 {
111 }
112
113 //------------------------------------------------------------------------
114 Binc::Header::~Header(void)
115 {
116 }
117
118 //------------------------------------------------------------------------
119 bool Binc::Header::getFirstHeader(const string &key, HeaderItem &dest) const
120 {
121 string k = key;
122 lowercase(k);
123
124 for (vector<HeaderItem>::const_iterator i = content.begin();
125 i != content.end(); ++i) {
126 string tmp = (*i).getKey();
127 lowercase(tmp);
128
129 if (tmp == k) {
130 dest = *i;
131 return true;
132 }
133 }
134 return false;
135 }
136
137 //------------------------------------------------------------------------
138 bool Binc::Header::getAllHeaders(const string &key, vector<HeaderItem> &dest) const
139 {
140 string k = key;
141 lowercase(k);
142
143 for (vector<HeaderItem>::const_iterator i = content.begin();
144 i != content.end(); ++i) {
145 string tmp = (*i).getKey();
146 lowercase(tmp);
147 if (tmp == k)
148 dest.push_back(*i);
149 }
150
151 return (dest.size() != 0);
152 }
153
154 //------------------------------------------------------------------------
155 void Binc::Header::clear(void)
156 {
157 content.clear();
158 }
159
160 //------------------------------------------------------------------------
161 void Binc::Header::add(const string &key, const string &value)
162 {
163 content.push_back(HeaderItem(key, value));
164 }