?? maildecoder.h
字號:
// =============================================================
// Multi-Purpose Internet Mail Extensions decoder
//
// Purpose: converts a mime encoded e-mail message from
// a string and converts to a tree structure.
//
// This file is part of Eplug
//
// Copyright (c) 2002 - 2003 Pylon Software
// =============================================================
#ifndef MAILDECODER_H
#define MAILDECODER_H
#ifndef _STRING_
#include <string>
#endif
#ifndef _VECTOR_
#include <vector>
#endif
// -------------------------------------------------------------
enum MimeEnum {
MIME_UNKNOWN,
MIME_RETURNPATH,
MIME_MESSAGEID,
MIME_FROM,
MIME_TO,
MIME_CC,
MIME_SUBJECT,
MIME_DATE,
MIME_VERSION,
MIME_CONTENTTYPE,
MIME_CONTENTTRANSFERENCODING,
MIME_CONTENTDISPOSITION,
};
struct Mime {
std::string m_s;
MimeEnum m_mime;
Mime(const std::string &s, MimeEnum mime) :
m_s(s),
m_mime(mime) {
}
};
struct BlockHeading {
std::string m_return_path;
std::string m_message_id;
std::string m_from;
std::string m_to;
std::string m_cc;
std::string m_subject;
std::string m_mime_version;
std::string m_date;
std::string m_content_type;
std::string m_content_encoding;
std::string m_content_disposition;
std::string m_boundary;
std::string m_charset;
std::string m_filename;
};
struct MailBlock {
BlockHeading heading;
std::string content;
};
struct MailSection {
MailSection *parent;
std::vector<MailSection *> children;
std::vector<MailBlock *> content;
~MailSection() {
for (unsigned i = 0; i < content.size(); ++i)
delete content[i];
for (unsigned j = 0; j < children.size(); ++j)
delete children[j];
}
};
// -------------------------------------------------------------
class MailDecoder {
public :
MailDecoder();
bool open(std::string mail_content);
void close();
~MailDecoder();
private :
void BeginSection();
void EndSection();
void NewBlock();
void SkipWhite();
void CopyHeading(BlockHeading &a, BlockHeading &b);
private :
MimeEnum MatchMimeString(std::string s);
std::string GetFieldName();
std::string GatherParameters();
std::string DeQuoteString(std::string &s);
std::string ReadLine();
void DecodeHeadingSection(BlockHeading &heading);
void DecodeMailSection(BlockHeading &heading);
void DecodeParameters(MimeEnum mime, std::string ¶ms, BlockHeading &heading, std::string *attribute);
private :
void LogMailContents();
void LogMailContents(FILE *f, MailSection *block);
private :
std::string m_raw_text;
unsigned m_pos;
unsigned m_section_pos;
MailSection *m_decoded;
MailSection *m_current_section;
MailBlock *m_current_block;
};
#endif //!MAILDECODER_H
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -