2014-11-19 00:25:21 +08:00
|
|
|
|
#pragma once
|
|
|
|
|
#include "acl_cpp/acl_cpp_define.hpp"
|
|
|
|
|
#include <list>
|
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
|
|
namespace acl {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ַ
|
|
|
|
|
*/
|
|
|
|
|
struct rfc822_addr
|
|
|
|
|
{
|
|
|
|
|
char* addr; // <20>ʼ<EFBFBD><CABC><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>ʽΪ<CABD><CEAA> xxx@xxx.xxx
|
|
|
|
|
char* comment; // <20>ʼ<EFBFBD><CABC><EFBFBD>ע
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
tzone_gmt,
|
|
|
|
|
tzone_cst
|
|
|
|
|
} tzone_t;
|
|
|
|
|
|
|
|
|
|
class ACL_CPP_API rfc822
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
rfc822();
|
|
|
|
|
~rfc822();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <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>磺
|
|
|
|
|
* 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>ʽ
|
|
|
|
|
* @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>
|
|
|
|
|
*/
|
|
|
|
|
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>ʽ
|
|
|
|
|
* @param t {time_t}
|
|
|
|
|
* @param out {char*} <EFBFBD>洢ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param size {size_t} out <EFBFBD>ռ<EFBFBD><EFBFBD><EFBFBD>С
|
|
|
|
|
*/
|
|
|
|
|
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>ʽ
|
|
|
|
|
* @param t {time_t}
|
|
|
|
|
* @param out {char*} <EFBFBD>洢ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param size {size_t} out <EFBFBD>ռ<EFBFBD><EFBFBD><EFBFBD>С
|
|
|
|
|
*/
|
|
|
|
|
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>:
|
|
|
|
|
* "=?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>;"
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* @param to_charset {const char*} Ŀ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>磺gbk, gb18030, utf-8
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {const std::list<rfc822_addr*>&} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
2015-09-08 17:21:04 +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>ַ
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* @param to_charset {const char*} Ŀ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>磺gbk, gb18030, utf-8
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @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>淶
|
|
|
|
|
*/
|
2015-09-08 17:21:04 +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>ַ
|
|
|
|
|
* @return {bool}
|
|
|
|
|
*/
|
|
|
|
|
bool check_addr(const char* in);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
std::list<rfc822_addr*> addrs_;
|
|
|
|
|
|
|
|
|
|
void reset();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|