/usr/include/bobcat/mailheaders is in libbobcat-dev 4.04.00-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | #ifndef INCLUDED_BOBCAT_MAILHEADERS_
#define INCLUDED_BOBCAT_MAILHEADERS_
#include <istream>
#include <string>
#include <vector>
#include <bobcat/string>
namespace FBB
{
class MailHeaders
{
public:
typedef std::vector<std::string>::const_iterator const_iterator;
typedef std::vector<std::string>::const_reverse_iterator
const_reverse_iterator;
enum Mode
{
DONT_READ,
READ
};
enum Match
{
FAIL,
INITIAL,
PARTIAL,
FULL,
caseInsensitive,
CASE_INITIAL = caseInsensitive,
CASE_PARTIAL,
CASE_FULL,
lastMatch = CASE_FULL
};
private:
enum Size
{
SIZEOFMATCH = lastMatch + 1,
};
std::vector<std::string> d_lines;
std::istream &d_in;
std::string d_hdr;
Match d_match;
public:
class const_hdr_iterator:
public std::iterator<std::input_iterator_tag,
std::string const>
{
friend MailHeaders;
typedef bool(*Comparator)(std::string const &header,
std::string const &key);
MailHeaders const *d_mh;
std::string d_key;
Comparator d_comparator;
const_iterator d_current;
static Comparator s_comparator[];
const_hdr_iterator(MailHeaders const *mailHeaders,
const_iterator begin);
const_iterator lookup(const_iterator const &old) const;
const_iterator lookdown(const_iterator const &old) const;
static bool fail(std::string const &hdr, // .f
std::string const &key);
static bool initial(std::string const &hdr, // .f
std::string const &key);
static bool partial(std::string const &hdr, // .f
std::string const &key);
static bool full(std::string const &hdr, // .f
std::string const &key);
static bool caseInitial(std::string const &hdr, // .f
std::string const &key);
static bool casePartial(std::string const &hdr, // .f
std::string const &key);
static bool caseFull(std::string const &hdr, // .f
std::string const &key);
public:
const_hdr_iterator &operator++(); // opinc.f
const_hdr_iterator &operator--(); // opdec.f
const_hdr_iterator operator++(int); // oppostinc.f
// not used, but potentially available in consthdropdec.cc
// const_hdr_iterator operator--(int);
bool operator==(const_hdr_iterator const &other) // opeq.f
const;
bool operator!=(const_hdr_iterator const &other) // opneq.f
const;
std::string const &operator*() const; // opstar.f
std::string const *operator->() const; // oparrow.f
};
typedef std::reverse_iterator<const_hdr_iterator>
const_reverse_hdr_iterator;
explicit MailHeaders(std::istream &in, Mode mode = READ);
MailHeaders(MailHeaders &&tmp);
MailHeaders &operator=(MailHeaders &&tmp);
void read();
void setHeaderIterator(char const *header, Match match = FULL); // .f
const_hdr_iterator beginh() const; // .f
const_hdr_iterator endh() const; // .f
const_reverse_hdr_iterator rbeginh() const; // .f
const_reverse_hdr_iterator rendh() const; // .f
// available from vector<string>:
size_t size() const; // .f
std::string const &operator[](size_t idx) const; // opindex.f
const_iterator begin() const; // .f
const_iterator end() const; // .f
const_reverse_iterator rbegin() const; // .f
const_reverse_iterator rend() const; // .f
};
inline MailHeaders::const_iterator MailHeaders::begin() const
{
return d_lines.begin();
}
inline MailHeaders::const_hdr_iterator MailHeaders::beginh() const
{
return const_hdr_iterator(this, begin());
// returns iterator over all headers
// matching d_hdr by the d_match type
}
inline MailHeaders::const_iterator MailHeaders::end() const
{
return d_lines.end();
}
inline MailHeaders::const_hdr_iterator MailHeaders::endh() const
{
// returns address of the sentinel
return const_hdr_iterator(this, end());
}
inline std::string const &MailHeaders::operator[](size_t idx) const
{
return d_lines[idx];
}
inline MailHeaders::const_reverse_iterator MailHeaders::rbegin() const
{
return d_lines.rbegin();
}
inline MailHeaders::const_reverse_hdr_iterator MailHeaders::rbeginh() const
{
return const_reverse_hdr_iterator(endh());
}
inline MailHeaders::const_reverse_iterator MailHeaders::rend() const
{
return d_lines.rend();
}
inline MailHeaders::const_reverse_hdr_iterator MailHeaders::rendh() const
{
return const_reverse_hdr_iterator(beginh());
}
inline void MailHeaders::setHeaderIterator(char const *header, Match match)
{
d_hdr = header;
d_match = match;
}
inline size_t MailHeaders::size() const
{
return d_lines.size();
}
inline std::string const *MailHeaders::const_hdr_iterator::operator->() const
{
return &*d_current;
}
inline MailHeaders::const_hdr_iterator
&MailHeaders::const_hdr_iterator::operator--()
{
d_current = lookdown(d_current);
return *this;
}
inline bool MailHeaders::const_hdr_iterator::operator==(
const_hdr_iterator const &other) const
{
return d_current == other.d_current;
}
inline MailHeaders::const_hdr_iterator
&MailHeaders::const_hdr_iterator::operator++()
{
d_current = lookup(++d_current);
return *this;
}
inline bool MailHeaders::const_hdr_iterator::operator!=(
const_hdr_iterator const &other) const
{
return d_current != other.d_current;
}
inline MailHeaders::const_hdr_iterator
MailHeaders::const_hdr_iterator::operator++(int)
{
return const_hdr_iterator(d_mh, d_current++);
}
inline std::string const &MailHeaders::const_hdr_iterator::operator*() const
{
return *d_current;
}
} // FBB
#endif
|