acl/lib_acl_cpp/include/acl_cpp/mime/mime.hpp

459 lines
11 KiB
C++
Raw Normal View History

#pragma once
#include "acl_cpp/acl_cpp_define.hpp"
#include <list>
#include <string>
#include "acl_cpp/mime/mime_head.hpp"
struct MIME_STATE;
namespace acl {
class string;
class mime_node;
class mime_attach;
class mime_body;
class mime_image;
class ifstream;
class fstream;
class ACL_CPP_API mime
{
public:
mime();
~mime();
/////////////////////////////////////////////////////////////////////
// <20><><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>صĺ<D8B5><C4BA><EFBFBD>
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬһ<EFBFBD><EFBFBD>MIME<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ, <EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>ô˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮ǰ
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>, <EFBFBD><EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD>ε<EFBFBD><EFBFBD>øú<EFBFBD><EFBFBD><EFBFBD><EFBFBD>޺<EFBFBD>, <EFBFBD><EFBFBD>Ϊ<EFBFBD>˲<EFBFBD>Ӱ<EFBFBD><EFBFBD>
* Ч<EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>øý<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>øú<EFBFBD><EFBFBD><EFBFBD>
*/
mime& reset(void);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߿<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
void primary_head_finish(void);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ô˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD>ʼ<EFBFBD>ͷ<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {bool} <EFBFBD>Ƿ<EFBFBD><EFBFBD>ʼ<EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
bool primary_head_ok() const;
/**
* <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> reset() <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD>״̬
* @param path {const char*} <EFBFBD>ʼ<EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, Ҳ<EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><EFBFBD><EFBFBD> save_xxx <EFBFBD><EFBFBD><EFBFBD>صĽӿ<EFBFBD>
*/
void update_begin(const char* path);
/**
* <EFBFBD><EFBFBD><EFBFBD>ô˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>ͷ, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD>
* <EFBFBD>ӿڽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> update_end() <EFBFBD>ӿڼ<EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ
* <EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>ϵص<EFBFBD><EFBFBD>ô˺<EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> true <EFBFBD><EFBFBD>ʾ multipart <EFBFBD><EFBFBD>ʽ
* <EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> multipart <EFBFBD><EFBFBD>ʽ<EFBFBD>ʼ<EFBFBD>, <EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܻ<EFBFBD><EFBFBD>ط<EFBFBD> true,
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>
* @param data {const char*} <EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>ͷҲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
* @param len {size_t} data <EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> multipart <EFBFBD>ʼ<EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD> true <EFBFBD><EFBFBD>ʾ<EFBFBD>÷<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
* <EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD> multipart <EFBFBD>ʼ<EFBFBD>, <EFBFBD>÷<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>ԶΪ false, û<EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>
* ע<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> update_end <EFBFBD><EFBFBD><EFBFBD><EFBFBD>֪ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
bool update(const char* data, size_t len);
/**
* <EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô˺<EFBFBD><EFBFBD><EFBFBD>
*/
void update_end(void);
/**
* <EFBFBD><EFBFBD><EFBFBD>ô˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>
* @param file_path {const char*} <EFBFBD>ʼ<EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD>
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> false ˵<EFBFBD><EFBFBD>Դ<EFBFBD>ʼ<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
bool parse(const char* file_path);
/**
* <EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
* @param out {fstream&} Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {bool} <EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
*/
bool save_as(fstream& out);
/**
* <EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
* @param file_path {const char*} Ŀ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
* @return {bool} <EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
*/
bool save_as(const char* file_path);
/**
* <EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϻ󣬰<EFBFBD><EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>ķ<EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD>̣<EFBFBD>
* <EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򿪸<EFBFBD> html ҳ<EFBFBD><EFBFBD>
* @param path {const char*} ҳ<EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD>
* @param filename {const char*} Ŀ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
* @param enableDecode {bool} ת<EFBFBD><EFBFBD>ʱ<EFBFBD>Ƿ<EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><EFBFBD><EFBFBD>
* @param toCharset {const char*} Ŀ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
* @param off {off_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {bool} <EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
*/
bool save_mail(const char* path, const char* filename,
bool enableDecode = true, const char* toCharset = "gb2312",
off_t off = 0);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD>
* @param htmlFirst {bool} <EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD>HTML<EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD>HTML<EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>
* @param enableDecode {bool} ת<EFBFBD><EFBFBD>ʱ<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD>Ľ<EFBFBD><EFBFBD>н<EFBFBD><EFBFBD><EFBFBD>
* @param toCharset {const char*} Ŀ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
* @param off {off_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {mime_body*} <EFBFBD><EFBFBD>δ<EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򷵻<EFBFBD> NULL
*/
mime_body* get_body_node(bool htmlFirst, bool enableDecode = true,
const char* toCharset = "gb2312", off_t off = 0);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD> mime <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
* @param enableDecode {bool} ת<EFBFBD><EFBFBD>ʱ<EFBFBD>Ƿ<EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><EFBFBD><EFBFBD>
* @param toCharset {const char*} Ŀ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
* @param off {off_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {const std::list<mime_node*>&}
*/
const std::list<mime_node*>& get_mime_nodes(bool enableDecode = true,
const char* toCharset = "gb2312", off_t off = 0);
/**
* <EFBFBD><EFBFBD><EFBFBD>ø<EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
* @param enableDecode {bool} ת<EFBFBD><EFBFBD>ʱ<EFBFBD>Ƿ<EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><EFBFBD><EFBFBD>
* @param toCharset {const char*} Ŀ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
* @param off {off_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {const std::list<mime_attach*>&}
*/
const std::list<mime_attach*>& get_attachments(bool enableDecode = true,
const char* toCharset = "gb2312", off_t off = 0);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD>б<EFBFBD>
* @param enableDecode {bool} ת<EFBFBD><EFBFBD>ʱ<EFBFBD>Ƿ<EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><EFBFBD><EFBFBD>
* @param toCharset {const char*} Ŀ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
* @param off {off_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {const std::list<mime_image*>&}
*/
const std::list<mime_image*>& get_images(bool enableDecode = true,
const char* toCharset = "gb2312", off_t off = 0);
mime_image* get_image(const char* cld, bool enableDecode = true,
const char* toCharset = "gb2312", off_t off = 0);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>MIME<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param save_path {const char*} <EFBFBD> MIME <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD>
* @param decode {bool} <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD>Ľ<EFBFBD><EFBFBD>н<EFBFBD><EFBFBD><EFBFBD>
*/
void mime_debug(const char* save_path, bool decode = true);
/////////////////////////////////////////////////////////////////////
// <20><><EFBFBD>ʼ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD>صĺ<D8B5><C4BA><EFBFBD>
/**
* <EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param addr {const char*} <EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ַ
* @return {mime&}
*/
mime& set_sender(const char* addr)
{
m_primaryHeader.set_returnpath(addr);
return (*this);
}
/**
* <EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: From: zhengshuxin@51iker.com
* @param addr {const char*} <EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ַ
* @return {mime&}
*/
mime& set_from(const char* addr)
{
m_primaryHeader.set_from(addr);
return (*this);
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ص<EFBFBD>ַ: Reply-To: zhengshuxin@51iker.com
* @param addr {const char*} <EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ַ
* @return {mime&}
*/
mime& set_replyto(const char* addr)
{
m_primaryHeader.set_replyto(addr);
return (*this);
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ Return-Path: <zhengshuxin@51iker.com>
* @param addr {const char*} <EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ַ
* @return {mime&}
*/
mime& set_returnpath(const char* addr)
{
m_primaryHeader.set_returnpath(addr);
return (*this);
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Subject: test
* @param s {const char*} <EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {mime&}
*/
mime& set_subject(const char* s)
{
m_primaryHeader.set_subject(s);
return (*this);
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: To: <zhengshuxin@51iker.com>
* @param addr {const char*} <EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ַ
* @return {mime&}
*/
mime& add_to(const char* addr)
{
m_primaryHeader.add_to(addr);
return (*this);
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CC: <zhengshuxin@51iker.com>
* @param addr {const char* addr} <EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ַ
* @return {mime&}
*/
mime& add_cc(const char* addr)
{
m_primaryHeader.add_cc(addr);
return (*this);
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: BCC: <zhengshuxin@51iker.com>
* @param addr {const char* addr} <EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ַ
* @return {mime&}
*/
mime& add_bcc(const char* addr)
{
m_primaryHeader.add_bcc(addr);
return (*this);
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CC: <zhengshuxin@51iker.com>
* @param addr {const char* addr} <EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ַ
* @return {mime&}
*/
mime& add_rcpt(const char* addr)
{
m_primaryHeader.add_rcpt(addr);
return (*this);
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>
* @param name {const char*} <EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD>
* @param value {const char*} <EFBFBD>ֶ<EFBFBD>ֵ
* @return {mime&}
*/
mime& add_header(const char* name, const char* value)
{
m_primaryHeader.add_header(name, value);
return (*this);
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: Content-Type: text/plain
* @param ctype {size_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param stype {size_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {mime&}
*/
mime& set_type(size_t ctype, size_t stype)
{
m_primaryHeader.set_type(ctype, stype);
return (*this);
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD>ķָ<EFBFBD><EFBFBD><EFBFBD>
* @param s {const char*} <EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>
* @return {mime&}
*/
mime& set_boundary(const char* s)
{
m_primaryHeader.set_boundary(s);
return (*this);
}
/**
* <EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {const string&} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
* (<EFBFBD><EFBFBD><EFBFBD><EFBFBD> string::empty()) <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾû<EFBFBD>д<EFBFBD><EFBFBD>ֶ<EFBFBD>
*/
const string& sender(void) const
{
return (m_primaryHeader.sender());
}
/**
* <EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {const string&} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
* (<EFBFBD><EFBFBD><EFBFBD><EFBFBD> string::empty()) <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾû<EFBFBD>д<EFBFBD><EFBFBD>ֶ<EFBFBD>
*/
const string& from(void) const
{
return (m_primaryHeader.from());
}
/**
* <EFBFBD><EFBFBD><EFBFBD>ûظ<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ַ
* @return {const string&} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
* (<EFBFBD><EFBFBD><EFBFBD><EFBFBD> string::empty()) <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾû<EFBFBD>д<EFBFBD><EFBFBD>ֶ<EFBFBD>
*/
const string& replyto(void) const
{
return (m_primaryHeader.replyto());
}
/**
* <EFBFBD><EFBFBD><EFBFBD>ûظ<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ַ
* @return {const string&} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
* (<EFBFBD><EFBFBD><EFBFBD><EFBFBD> string::empty()) <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾû<EFBFBD>д<EFBFBD><EFBFBD>ֶ<EFBFBD>
*/
const string& returnpath(void) const
{
return (m_primaryHeader.returnpath());
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {const string&} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
* (<EFBFBD><EFBFBD><EFBFBD><EFBFBD> string::empty()) <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾû<EFBFBD>д<EFBFBD><EFBFBD>ֶ<EFBFBD>
*/
const string& subject(void) const
{
return (m_primaryHeader.subject());
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>: To: xxx@xxx.com
* @return {const std::list<char*>&) <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
* (<EFBFBD><EFBFBD><EFBFBD><EFBFBD> std::list<char*>::empty()) <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾû<EFBFBD>д<EFBFBD><EFBFBD>ֶ<EFBFBD>
*/
const std::list<char*>& to_list(void) const
{
return (m_primaryHeader.to_list());
}
/**
* <EFBFBD><EFBFBD><EFBFBD>ó<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>: To: xxx@xxx.com
* @return {const std::list<char*>&) <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
* (<EFBFBD><EFBFBD><EFBFBD><EFBFBD> std::list<char*>::empty()) <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾû<EFBFBD>д<EFBFBD><EFBFBD>ֶ<EFBFBD>
*/
const std::list<char*>& cc_list(void) const
{
return (m_primaryHeader.cc_list());
}
/**
* <EFBFBD><EFBFBD><EFBFBD>ð<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>: To: xxx@xxx.com
* @return {const std::list<char*>&) <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
* (<EFBFBD><EFBFBD><EFBFBD><EFBFBD> std::list<char*>::empty()) <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾû<EFBFBD>д<EFBFBD><EFBFBD>ֶ<EFBFBD>
*/
const std::list<char*>& bcc_list(void) const
{
return (m_primaryHeader.bcc_list());
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>:
* To: xxx@xxx.xxx, CC: xxx@xxx.xxx, BCC: xxx@xxx.xxx
* @return {const std::list<char*>&) <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>
* (<EFBFBD><EFBFBD><EFBFBD><EFBFBD> std::list<char*>::empty()) <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾû<EFBFBD>д<EFBFBD><EFBFBD>ֶ<EFBFBD>
*/
const std::list<char*>& rcpt_list(void) const
{
return (m_primaryHeader.rcpt_list());
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>ͷ<EFBFBD>ĸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD>б<EFBFBD>
* @return {const std::list<HEADER*>&)
*/
const std::list<HEADER*>& header_list(void) const
{
return (m_primaryHeader.header_list());
}
/**
* <EFBFBD><EFBFBD>ѯ<EFBFBD>ʼ<EFBFBD>ͷ<EFBFBD><EFBFBD>Ӧ<EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>ֵ
* @param name {const char*} <EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD>
* @return {const char*} <EFBFBD>ֶ<EFBFBD>ֵ, Ϊ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
const char* header_value(const char* name) const
{
return (m_primaryHeader.header_value(name));
}
/**
* <EFBFBD><EFBFBD>ѯ<EFBFBD>ʼ<EFBFBD>ͷ<EFBFBD><EFBFBD>Ӧ<EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param name {const char*} <EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD>
* @param values {std::list<const char*>*} <EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {int} <EFBFBD>ֶ<EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD>ϵĸ<EFBFBD><EFBFBD><EFBFBD>
*/
int header_values(const char* name, std::list<const char*>* values) const
{
return (m_primaryHeader.header_values(name, values));
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>ͷ<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD> Content-Type: text/html <EFBFBD>е<EFBFBD> text <EFBFBD>ֶ<EFBFBD>
* @return {const char*} <EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD>طǿ<EFBFBD>ֵ
*/
const char* get_ctype() const
{
return m_primaryHeader.get_ctype();
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>ͷ<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD> Content-Type: text/html <EFBFBD>е<EFBFBD> html <EFBFBD>ֶ<EFBFBD>
* @return {const char*} <EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD>طǿ<EFBFBD>ֵ
*/
const char* get_stype() const
{
return m_primaryHeader.get_stype();
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>ͷ
* @return {const mime_head&}
*/
const mime_head& primary_header(void) const
{
return (m_primaryHeader);
}
private:
mime_head m_primaryHeader;
MIME_STATE* m_pMimeState;
bool m_bPrimaryHeadFinish;
char* m_pFilePath;
mime_body* m_pBody;
std::list<mime_node*>* m_pNodes;
std::list<mime_attach*>* m_pAttaches;
std::list<mime_image*>* m_pImages;
};
} // namespace acl