Archived
1
0
This repository has been archived on 2023-08-12. You can view files and clone it, but cannot push or open issues or pull requests.
nntpchan/contrib/backends/nntpchan-daemon/libnntpchan/mime.cpp

27 lines
538 B
C++
Raw Permalink Normal View History

2017-10-11 18:48:27 +05:00
#include <nntpchan/mime.hpp>
namespace nntpchan
{
2017-10-17 19:29:56 +05:00
bool ReadHeader(const FileHandle_ptr &file, RawHeader &header)
{
std::string line;
while (std::getline(*file, line) && !(line == "\r" || line == ""))
{
2017-10-17 19:29:56 +05:00
std::string k, v;
auto idx = line.find(": ");
auto endidx = line.size() - 1;
while (line[endidx] == '\r')
--endidx;
if (idx != std::string::npos && idx + 2 < endidx)
{
2017-10-17 19:29:56 +05:00
k = line.substr(0, idx);
v = line.substr(idx + 2, endidx);
header[k] = v;
}
}
2017-10-17 19:29:56 +05:00
return file->good();
}
}