diff --git a/uppsrc/Core/POP3/InetMessage.cpp b/uppsrc/Core/POP3/InetMessage.cpp index 6b85ecf99..35d952608 100644 --- a/uppsrc/Core/POP3/InetMessage.cpp +++ b/uppsrc/Core/POP3/InetMessage.cpp @@ -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; +} diff --git a/uppsrc/Core/POP3/POP3.h b/uppsrc/Core/POP3/POP3.h index a3c772c06..4842c59c6 100644 --- a/uppsrc/Core/POP3/POP3.h +++ b/uppsrc/Core/POP3/POP3.h @@ -75,4 +75,15 @@ private: bool ReadPart(Stream& ss, int parent, int level); }; +struct MIMEHeader { + String value; + VectorMap 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 diff --git a/uppsrc/Core/POP3/POP3.upp b/uppsrc/Core/POP3/POP3.upp index e5d5b852a..bea310c1c 100644 --- a/uppsrc/Core/POP3/POP3.upp +++ b/uppsrc/Core/POP3/POP3.upp @@ -1,8 +1,7 @@ description "Post Office Protocol, version 3 encapsulation. Author: İsmail Yılmaz\377"; uses - Core, - Core/SSL; + Core; file POP3.h, diff --git a/uppsrc/Core/POP3/init b/uppsrc/Core/POP3/init index 35aef293f..edcf08949 100644 --- a/uppsrc/Core/POP3/init +++ b/uppsrc/Core/POP3/init @@ -1,5 +1,4 @@ #ifndef _Core_POP3_icpp_init_stub #define _Core_POP3_icpp_init_stub #include "Core/init" -#include "Core/SSL/init" #endif