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

107 lines
2.6 KiB
C++
Raw Normal View History

#pragma once
2017-06-02 14:47:24 +08:00
#include "../acl_cpp_define.hpp"
#include "../stdlib/noncopyable.hpp"
2014-11-19 00:25:21 +08:00
#include <list>
#include <time.h>
#if !defined(ACL_MIME_DISABLE)
2014-11-19 00:25:21 +08:00
namespace acl {
/**
* <EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ַ
2014-11-19 00:25:21 +08:00
*/
struct rfc822_addr
{
char* addr; // <20>ʼ<EFBFBD><CABC><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>ʽΪ<CABD><CEAA> xxx@xxx.xxx
char* comment; // <20>ʼ<EFBFBD><CABC><EFBFBD>ע
2014-11-19 00:25:21 +08:00
};
typedef enum
{
tzone_gmt,
tzone_cst
} tzone_t;
class ACL_CPP_API rfc822 : public noncopyable
2014-11-19 00:25:21 +08:00
{
public:
2019-07-07 13:27:58 +08:00
rfc822(void);
~rfc822(void);
2014-11-19 00:25:21 +08:00
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> RFC822 <EFBFBD><EFBFBD>׼<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
* @param in {const char*} ʱ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
* Wed, 11 May 2011 09:44:37 +0800 (CST)
* Wed, 11 May 2011 16:17:39 GMT
*/
time_t parse_date(const char *in);
/**
* <EFBFBD><EFBFBD><EFBFBD>ɷ<EFBFBD><EFBFBD><EFBFBD> RFC822 <EFBFBD><EFBFBD>׼<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
2014-11-19 00:25:21 +08:00
* @param t {time_t}
* @param out {char*} <EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param size {size_t} out <EFBFBD>ռ<EFBFBD><EFBFBD><EFBFBD>С
* @param zone {tzone_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
*/
void mkdate(time_t t, char* out, size_t size, tzone_t zone = tzone_cst);
/**
* <EFBFBD><EFBFBD><EFBFBD>ɶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
2014-11-19 00:25:21 +08:00
* @param t {time_t}
* @param out {char*} <EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param size {size_t} out <EFBFBD>ռ<EFBFBD><EFBFBD><EFBFBD>С
2014-11-19 00:25:21 +08:00
*/
void mkdate_cst(time_t t, char* out, size_t size);
/**
* <EFBFBD><EFBFBD><EFBFBD>ɸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
2014-11-19 00:25:21 +08:00
* @param t {time_t}
* @param out {char*} <EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param size {size_t} out <EFBFBD>ռ<EFBFBD><EFBFBD><EFBFBD>С
2014-11-19 00:25:21 +08:00
*/
void mkdate_gmt(time_t t, char* out, size_t size);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> RFC822 <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>
* RFC2047<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param in {const char*} RFC822 <EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
2014-11-19 00:25:21 +08:00
* "=?gb2312?B?1dSx+A==?= <zhaobing@51iker.com>;\r\n"
* "\t\"=?GB2312?B?t+vBosn6?=\" <fenglisheng@51iker.com>;\r\n"
* "\t\"zhengshuxin3\";\"zhengshuxin4\" <zhengshuxin2@51iker.com>;"
* "<xuganghui@51iker.com>;<wangwenquan@51iker.com>;"
* @param to_charset {const char*} Ŀ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>gbk, gb18030, utf-8
* @return {const std::list<rfc822_addr*>&} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
*/
const std::list<rfc822_addr*>& parse_addrs(const char* in,
const char* to_charset = "utf-8");
2014-11-19 00:25:21 +08:00
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> RFC822 <EFBFBD><EFBFBD>׼<EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>ͬʱ<EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD>Ͳ<EFBFBD><EFBFBD>ְ<EFBFBD>
* RFC2047 <EFBFBD><EFBFBD>׼<EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><EFBFBD><EFBFBD>
* @param in {const char*} RFC822 <EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ַ
* @param to_charset {const char*} Ŀ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>gbk, gb18030, utf-8
* @return {const rfc822_addr*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> NULL <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* RFC822 <EFBFBD>
2014-11-19 00:25:21 +08:00
*/
const rfc822_addr* parse_addr(const char* in,
const char* to_charset = "utf-8");
2014-11-19 00:25:21 +08:00
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>Ƿ<EFBFBD><EFBFBD>Ϸ<EFBFBD>
* @param in {const char*} RFC822 <EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ַ
2014-11-19 00:25:21 +08:00
* @return {bool}
*/
bool check_addr(const char* in);
private:
std::list<rfc822_addr*> addrs_;
2019-07-07 13:27:58 +08:00
void reset(void);
2014-11-19 00:25:21 +08:00
};
} // namespace acl
#endif // !defined(ACL_MIME_DISABLE)