mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
Core:POP3: MIMEHeader parser
git-svn-id: svn://ultimatepp.org/upp/trunk@7182 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
525830b75f
commit
aef45f2d04
4 changed files with 57 additions and 3 deletions
|
|
@ -195,3 +195,48 @@ String InetMessage::Part::Decode() const
|
|||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
bool MIMEHeader::Parse(const char *s)
|
||||
{
|
||||
value.Clear();
|
||||
param.Clear();
|
||||
CParser p(s);
|
||||
try {
|
||||
CParser p(s);
|
||||
const char *b = p.GetPtr();
|
||||
while(!p.IsEof() && !p.IsChar(';'))
|
||||
p.SkipTerm();
|
||||
value = TrimBoth(String(b, p.GetPtr()));
|
||||
while(!p.IsEof()) {
|
||||
if(p.Char(';') && p.IsId()) {
|
||||
const char *b = p.GetPtr();
|
||||
while(!p.IsEof() && !p.IsChar(';') && !p.IsChar('='))
|
||||
p.SkipTerm();
|
||||
String id = TrimBoth(String(b, p.GetPtr()));
|
||||
String val;
|
||||
if(p.Char('='))
|
||||
if(p.IsString())
|
||||
val = p.ReadString();
|
||||
else {
|
||||
const char *b = p.GetPtr();
|
||||
while(!p.IsEof() && !p.IsChar(';'))
|
||||
p.SkipTerm();
|
||||
val = TrimBoth(String(b, p.GetPtr()));
|
||||
}
|
||||
param.Add(id, val);
|
||||
}
|
||||
else
|
||||
p.SkipTerm();
|
||||
}
|
||||
}
|
||||
catch(CParser::Error) {}
|
||||
return value.GetCount();
|
||||
}
|
||||
|
||||
String MIMEHeader::ToString() const
|
||||
{
|
||||
String r = value;
|
||||
for(int i = 0; i < param.GetCount(); i++)
|
||||
r << "; " << param.GetKey(i) << '=' << AsCString(param[i]);
|
||||
return r;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,4 +75,15 @@ private:
|
|||
bool ReadPart(Stream& ss, int parent, int level);
|
||||
};
|
||||
|
||||
struct MIMEHeader {
|
||||
String value;
|
||||
VectorMap<String, String> param;
|
||||
|
||||
String operator[](const char *id) const { return param.Get(id, Null); }
|
||||
String operator~() const { return value; }
|
||||
|
||||
bool Parse(const char *s);
|
||||
String ToString() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
description "Post Office Protocol, version 3 encapsulation. Author: İsmail Yılmaz\377";
|
||||
|
||||
uses
|
||||
Core,
|
||||
Core/SSL;
|
||||
Core;
|
||||
|
||||
file
|
||||
POP3.h,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#ifndef _Core_POP3_icpp_init_stub
|
||||
#define _Core_POP3_icpp_init_stub
|
||||
#include "Core/init"
|
||||
#include "Core/SSL/init"
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue