This repository has been archived on 2023-08-12. You can view files and clone it. You cannot open issues or pull requests or push a commit.
2017-10-11 09:48:27 -04:00
|
|
|
#include <nntpchan/mime.hpp>
|
2017-10-09 11:48:10 -04:00
|
|
|
|
|
|
|
|
namespace nntpchan
|
|
|
|
|
{
|
2017-10-17 10:29:56 -04:00
|
|
|
bool ReadHeader(const FileHandle_ptr &file, RawHeader &header)
|
|
|
|
|
{
|
|
|
|
|
std::string line;
|
|
|
|
|
while (std::getline(*file, line) && !(line == "\r" || line == ""))
|
2017-10-09 11:48:10 -04:00
|
|
|
{
|
2017-10-17 10:29:56 -04: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-09 11:48:10 -04:00
|
|
|
{
|
2017-10-17 10:29:56 -04:00
|
|
|
k = line.substr(0, idx);
|
|
|
|
|
v = line.substr(idx + 2, endidx);
|
|
|
|
|
header[k] = v;
|
2017-10-09 11:48:10 -04:00
|
|
|
}
|
|
|
|
|
}
|
2017-10-17 10:29:56 -04:00
|
|
|
return file->good();
|
|
|
|
|
}
|
2017-10-09 11:48:10 -04:00
|
|
|
}
|