summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorLuzhenping <luzhenping@acoinfo.com>2016-03-18 11:58:59 (GMT)
committer Luzhenping <luzhenping@acoinfo.com>2016-03-18 11:58:59 (GMT)
commit72dc12cca756390c6547bc0d286f85302d1e171a (patch)
tree3b30d9a1a3c64d36dd5f8488154461d1e9698c62
parent7ee78a6c0f52c0e8bee57a8c0ed0deb99e38157b (diff)
downloadlibxemail-72dc12cca756390c6547bc0d286f85302d1e171a.zip
libxemail-72dc12cca756390c6547bc0d286f85302d1e171a.tar.gz
libxemail-72dc12cca756390c6547bc0d286f85302d1e171a.tar.bz2
Added example code.
-rw-r--r--Makefile.arm23
-rw-r--r--Makefile.mips20
-rw-r--r--example/sendemail.c61
-rw-r--r--include/xemail.h76
-rw-r--r--src/xemail.c976
5 files changed, 625 insertions, 531 deletions
diff --git a/Makefile.arm b/Makefile.arm
index c916a6e..689bb7b 100644
--- a/Makefile.arm
+++ b/Makefile.arm
@@ -53,6 +53,9 @@ LD = $(TOOLCHAIN_PREFIX)g++
SRCS = \
src/xemail.c
+EXAMPLE_SRCS = \
+example/sendemail.c
+
#*********************************************************************************************************
# build path
#*********************************************************************************************************
@@ -72,12 +75,17 @@ DEPPATH = $(OUTPATH)/dep
LIB = $(OUTPATH)/libxemail.a
DLL = $(OUTPATH)/libxemail.so
+EXE = $(OUTPATH)/sendemail
+
#*********************************************************************************************************
# objects
#*********************************************************************************************************
OBJS = $(addprefix $(OBJPATH)/, $(addsuffix .o, $(basename $(SRCS))))
DEPS = $(addprefix $(DEPPATH)/, $(addsuffix .d, $(basename $(SRCS))))
+E_OBJS = $(addprefix $(OBJPATH)/, $(addsuffix .o, $(basename $(EXAMPLE_SRCS))))
+E_DEPS = $(addprefix $(DEPPATH)/, $(addsuffix .d, $(basename $(EXAMPLE_SRCS))))
+
#*********************************************************************************************************
# include path
#*********************************************************************************************************
@@ -98,12 +106,16 @@ DSYMBOL += -DSYLIXOS_LIB
# depend dynamic library
#*********************************************************************************************************
DEPEND_DLL = -lcurl
+SYS_DEPEND_DLL = -lvpmpdm -lxemail
#*********************************************************************************************************
# depend dynamic library search path
#*********************************************************************************************************
DEPEND_DLL_PATH = -L"../libcurl/$(OUTDIR)"
+SYS_DEPEND_DLL_PATH = -L"$(SYLIXOS_BASE_PATH)/libsylixos/$(OUTDIR)"
+SYS_DEPEND_DLL_PATH += -L"$(OUTDIR)"
+
#*********************************************************************************************************
# compiler optimize
#*********************************************************************************************************
@@ -137,8 +149,8 @@ COMPILE.cxx = $(CXX) $(CXXFLAGS)
#*********************************************************************************************************
# target
#*********************************************************************************************************
-all: $(LIB) $(DLL)
- @echo create "$(LIB) $(DLL)" success.
+all: $(LIB) $(DLL) $(EXE)
+ @echo create "$(LIB) $(DLL) $(EXE)" success.
#*********************************************************************************************************
# include depends
@@ -188,11 +200,15 @@ $(LIB): $(OBJS)
$(AR) $(ARFLAGS) $(LIB) $(OBJS)
#*********************************************************************************************************
-# link libxemail.so object files
+# link libxemail.so sendemail object files
#*********************************************************************************************************
$(DLL): $(OBJS)
$(LD) $(CPUFLAGS) -nostdlib -fPIC -shared -o $(DLL) $(OBJS) \
$(DEPEND_DLL_PATH) $(DEPEND_DLL) -lm -lgcc
+
+$(EXE): $(OBJS)
+ $(LD) $(CPUFLAGS) -nostdlib -fPIC -shared -o $(EXE) $(OBJS) \
+ $(SYS_DEPEND_DLL_PATH) $(SYS_DEPEND_DLL) -lm -lgcc
#*********************************************************************************************************
# clean
@@ -206,6 +222,7 @@ $(DLL): $(OBJS)
clean:
-rm -rf $(LIB)
-rm -rf $(DLL)
+ -rm -rf $(EXE)
-rm -rf $(OBJS)
-rm -rf $(OBJPATH)
-rm -rf $(DEPPATH)
diff --git a/Makefile.mips b/Makefile.mips
index c883947..e7a1a64 100644
--- a/Makefile.mips
+++ b/Makefile.mips
@@ -53,6 +53,9 @@ LD = $(TOOLCHAIN_PREFIX)g++
SRCS = \
src/xemail.c
+EXAMPLE_SRCS = \
+example/sendemail.c
+
#*********************************************************************************************************
# build path
#*********************************************************************************************************
@@ -72,12 +75,17 @@ DEPPATH = $(OUTPATH)/dep
LIB = $(OUTPATH)/libxemail.a
DLL = $(OUTPATH)/libxemail.so
+EXE = $(OUTPATH)/sendemail
+
#*********************************************************************************************************
# objects
#*********************************************************************************************************
OBJS = $(addprefix $(OBJPATH)/, $(addsuffix .o, $(basename $(SRCS))))
DEPS = $(addprefix $(DEPPATH)/, $(addsuffix .d, $(basename $(SRCS))))
+E_OBJS = $(addprefix $(OBJPATH)/, $(addsuffix .o, $(basename $(EXAMPLE_SRCS))))
+E_DEPS = $(addprefix $(DEPPATH)/, $(addsuffix .d, $(basename $(EXAMPLE_SRCS))))
+
#*********************************************************************************************************
# include path
#*********************************************************************************************************
@@ -98,12 +106,16 @@ DSYMBOL += -DSYLIXOS_LIB
# depend dynamic library
#*********************************************************************************************************
DEPEND_DLL = -lcurl
+SYS_DEPEND_DLL = -lvpmpdm -lxemail
#*********************************************************************************************************
# depend dynamic library search path
#*********************************************************************************************************
DEPEND_DLL_PATH = -L"../libcurl/$(OUTDIR)"
+SYS_DEPEND_DLL_PATH = -L"$(SYLIXOS_BASE_PATH)/libsylixos/$(OUTDIR)"
+SYS_DEPEND_DLL_PATH += -L"$(OUTDIR)"
+
#*********************************************************************************************************
# compiler optimize
#*********************************************************************************************************
@@ -137,8 +149,8 @@ COMPILE.cxx = $(CXX) $(CXXFLAGS)
#*********************************************************************************************************
# target
#*********************************************************************************************************
-all: $(LIB) $(DLL)
- @echo create "$(LIB) $(DLL)" success.
+all: $(LIB) $(DLL) $(EXE)
+ @echo create "$(LIB) $(DLL) $(EXE)" success.
#*********************************************************************************************************
# include depends
@@ -194,6 +206,9 @@ $(DLL): $(OBJS)
$(LD) $(CPUFLAGS) -fPIC -mabicalls -shared -o $(DLL) $(OBJS) \
$(DEPEND_DLL_PATH) $(DEPEND_DLL) -lm -lgcc
+$(EXE): $(OBJS)
+ $(LD) $(CPUFLAGS) -mabicalls -fPIC -shared -o $(EXE) $(OBJS) \
+ $(SYS_DEPEND_DLL_PATH) $(SYS_DEPEND_DLL) -lm -lgcc
#*********************************************************************************************************
# clean
#*********************************************************************************************************
@@ -206,6 +221,7 @@ $(DLL): $(OBJS)
clean:
-rm -rf $(LIB)
-rm -rf $(DLL)
+ -rm -rf $(EXE)
-rm -rf $(OBJS)
-rm -rf $(OBJPATH)
-rm -rf $(DEPPATH)
diff --git a/example/sendemail.c b/example/sendemail.c
new file mode 100644
index 0000000..674d504
--- /dev/null
+++ b/example/sendemail.c
@@ -0,0 +1,61 @@
+/*********************************************************************************************************
+**
+** 中国软件开源组织
+**
+** 嵌入式实时操作系统
+**
+** SylixOS(TM) LW : long wing
+**
+** Copyright All Rights Reserved
+**
+**--------------文件信息--------------------------------------------------------------------------------
+**
+** 文 件 名: sendemail.c
+**
+** 创 建 人: Lu.Zhenping (卢振平)
+**
+** 文件创建日期: 2015 年 05 月 12 日
+**
+** 描 述: 发送邮件
+*********************************************************************************************************/
+#include <SylixOS.h>
+#include "xemail.h"
+
+#define FROM "xxx@xxx.com"
+#define SMTPSERVER "xxx.163.com"
+#define TO "xxx@qq.com"
+#define USERNAME "xxxx"
+#define PASSWORD "xxxx"
+/*********************************************************************************************************
+** 函数名称: zemailErrorHandle
+** 功能描述: email 获得错误值
+** 输 入 : iError : 错误号
+** 输 出 : 错误号
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+int main (int argc, char *argv[])
+{
+ PXEMAIL pxemail;
+
+ pxemail = xemailCreate(FROM, "Test xemail");
+ if (!pxemail) {
+ fprintf(stderr, "Create email failed.\n");
+ return (-1);
+ }
+
+ xemailAddTO(pxemail, TO);
+
+ xemailSetMailBody(pxemail, "This is a test mail.");
+
+ xemailDebugMode(pxemail, stderr);
+ xemailSend(pxemail, SMTPSERVER, USERNAME, PASSWORD);
+
+ xemailDestroy(pxemail);
+
+ return (0);
+}
+/*********************************************************************************************************
+ 宏定义
+*********************************************************************************************************/
+
diff --git a/include/xemail.h b/include/xemail.h
index 0281759..5fc1768 100644
--- a/include/xemail.h
+++ b/include/xemail.h
@@ -10,13 +10,13 @@
**
**--------------文件信息--------------------------------------------------------------------------------
**
-** 文 件 名: z-email.h
+** 文 件 名: xemail.h
**
** 创 建 人: Lu.Zhenping (卢振平)
**
** 文件创建日期: 2015 年 05 月 12 日
**
-** 描 述: zthsoft email 库
+** 描 述: xemail 库
*********************************************************************************************************/
#ifndef __XEMAIL_H
#define __XEMAIL_H
@@ -27,116 +27,116 @@
/*********************************************************************************************************
外部指针声明
*********************************************************************************************************/
-typedef struct zthsoft_email *PZEMAIL;
+typedef struct xemail_email *PXEMAIL;
/*********************************************************************************************************
外部指针声明
*********************************************************************************************************/
-typedef PVOID (*zemailOpenFn)(PVOID pvData);
-typedef size_t (*zemailReadFn)(PVOID pvHandle, PVOID pvBuf, size_t stLen);
-typedef VOID (*zemailCloseFn)(PVOID pvHandle);
-typedef VOID (*zemailFreeDataFn)(PVOID pvData);
+typedef PVOID (*xemailOpenFn)(PVOID pvData);
+typedef size_t (*xemailReadFn)(PVOID pvHandle, PVOID pvBuf, size_t stLen);
+typedef VOID (*xemailCloseFn)(PVOID pvHandle);
+typedef VOID (*xemailFreeDataFn)(PVOID pvData);
/*********************************************************************************************************
** 函数名称: xemailSetFrom
** 功能描述: email 添加附件
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailSetFrom (PZEMAIL pzemail, PCHAR pcFrom);
+VOID xemailSetFrom (PXEMAIL pxemail, PCHAR pcFrom);
/*********************************************************************************************************
** 函数名称: xemailGetFrom
** 功能描述: email 添加附件
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-PCHAR xemailGetFrom (PZEMAIL pzemail);
+PCHAR xemailGetFrom (PXEMAIL pxemail);
/*********************************************************************************************************
** 函数名称: xemailAddBCC
** 功能描述: email 增加隐秘抄送者 (BCC: )
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailAddBCC(PZEMAIL pzemail, PCHAR pcBCC);
+VOID xemailAddBCC(PXEMAIL pxemail, PCHAR pcBCC);
/*********************************************************************************************************
** 函数名称: xemailAddCC
** 功能描述: email 增加抄送者 (CC: )
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailAddCC(PZEMAIL pzemail, PCHAR pcCC);
+VOID xemailAddCC(PXEMAIL pxemail, PCHAR pcCC);
/*********************************************************************************************************
** 函数名称: xemailAddTO
** 功能描述: email 增加接收者 (TO: )
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** pcTo : 接收者字符串
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailAddTO(PZEMAIL pzemail, PCHAR pcTo);
+VOID xemailAddTO(PXEMAIL pxemail, PCHAR pcTo);
/*********************************************************************************************************
** 函数名称: xemailSetSubject
** 功能描述: email 添加附件
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailSetSubject(PZEMAIL pzemail, PCHAR pcSubject);
+VOID xemailSetSubject(PXEMAIL pxemail, PCHAR pcSubject);
/*********************************************************************************************************
** 函数名称: xemailGetSubject
** 功能描述: email 添加附件
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-PCHAR xemailGetSubject(PZEMAIL pzemail);
+PCHAR xemailGetSubject(PXEMAIL pxemail);
/*********************************************************************************************************
** 函数名称: xemailAddHeader
** 功能描述: email 添加附件
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailAddHeader(PZEMAIL pzemail, PCHAR pcHeader);
+VOID xemailAddHeader(PXEMAIL pxemail, PCHAR pcHeader);
/*********************************************************************************************************
** 函数名称: xemailSetMailBody
** 功能描述: email 添加附件
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailSetMailBody(PZEMAIL pzemail, PCHAR pcBody);
+VOID xemailSetMailBody(PXEMAIL pxemail, PCHAR pcBody);
/*********************************************************************************************************
** 函数名称: xemailAddMailBodyByType
** 功能描述: 设置指定类型的邮件内容(如: "text/html" 类型的内容)
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailAddMailBodyByType(PZEMAIL pzemail,
+VOID xemailAddMailBodyByType(PXEMAIL pxemail,
PCHAR pcMimeType,
PCHAR pcData,
size_t stLen,
@@ -145,32 +145,32 @@ VOID xemailAddMailBodyByType(PZEMAIL pzemail,
/*********************************************************************************************************
** 函数名称: xemailAddAttachmentFile
** 功能描述: email 添加附件
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailAddAttachmentFile(PZEMAIL pzemail, PCHAR pcPath, PCHAR pcMime);
+VOID xemailAddAttachmentFile(PXEMAIL pxemail, PCHAR pcPath, PCHAR pcMime);
/*********************************************************************************************************
** 函数名称: xemailDelAttachmentFile
** 功能描述: email 添加附件
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailDelAttachmentFile(PZEMAIL pzemail, PCHAR pcPath);
+VOID xemailDelAttachmentFile(PXEMAIL pxemail, PCHAR pcPath);
/*********************************************************************************************************
** 函数名称: xemailDestroy
** 功能描述: email 销毁主函数
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailDestroy(PZEMAIL pzemail);
+VOID xemailDestroy(PXEMAIL pxemail);
/*********************************************************************************************************
** 函数名称: xemailCreate
@@ -181,12 +181,12 @@ VOID xemailDestroy(PZEMAIL pzemail);
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-PZEMAIL xemailCreate(PCHAR pcFrom, PCHAR pcSubject);
+PXEMAIL xemailCreate(PCHAR pcFrom, PCHAR pcSubject);
/*********************************************************************************************************
** 函数名称: xemailSend
** 功能描述: email 发送主函数
-** 输 入 : pzemail : EMAIL 主结构
+** 输 入 : pxemail : EMAIL 主结构
** pcSmtpServer : smtp server
** pcUserName : 用户名
** pcPassword : 密码
@@ -194,18 +194,18 @@ PZEMAIL xemailCreate(PCHAR pcFrom, PCHAR pcSubject);
** 全局变量:
** 调用模块: CURL 库
*********************************************************************************************************/
-INT xemailSend(PZEMAIL pzemail, PCHAR pcSmtpServer, PCHAR pcUserName, PCHAR pcPassword);
+INT xemailSend(PXEMAIL pxemail, PCHAR pcSmtpServer, PCHAR pcUserName, PCHAR pcPassword);
/*********************************************************************************************************
** 函数名称: xemailDebugMode
** 功能描述: 开启 DEBUG 模式
-** 输 入 : pzemail : EMAIL 结构
+** 输 入 : pxemail : EMAIL 结构
** fp : log 输出文件
** 输 出 : 版本
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailDebugMode(PZEMAIL pzemail, FILE *fp);
+VOID xemailDebugMode(PXEMAIL pxemail, FILE *fp);
/*********************************************************************************************************
** 函数名称: xemailVersion
diff --git a/src/xemail.c b/src/xemail.c
index a7b0980..72d38b4 100644
--- a/src/xemail.c
+++ b/src/xemail.c
@@ -16,7 +16,7 @@
**
** 文件创建日期: 2015 年 05 月 12 日
**
-** 描 述: zthsoft email 库
+** 描 述: xemail 库
*********************************************************************************************************/
#include <SylixOS.h>
#include <stdio.h>
@@ -30,110 +30,110 @@
/*********************************************************************************************************
宏定义
*********************************************************************************************************/
-#define ZEMAIL_VERSION "xemail-0.1.0rc"
-#define ZEMAIL_NEWLINE "\r\n"
-#define ZEMAIL_NEWLINE_LEN (2)
-#define ZEMAIL_MIME_LINE_WIDTH (72)
-#define ZEMAIL_BODY_BUFFER_SIZE (256)
-#define ZEMAIL_DEFAULT_MIME_TYPE ("text/plain")
-
-#define ZEMAIL_LOCK()
-#define ZEMAIL_UNLOCK()
-#define ZEMAIL_SAFTFREE(a) \
+#define XEMAIL_VERSION "xemail-0.1.0rc"
+#define XEMAIL_NEWLINE "\r\n"
+#define XEMAIL_NEWLINE_LEN (2)
+#define XEMAIL_MIME_LINE_WIDTH (72)
+#define XEMAIL_BODY_BUFFER_SIZE (256)
+#define XEMAIL_DEFAULT_MIME_TYPE ("text/plain")
+
+#define XEMAIL_LOCK()
+#define XEMAIL_UNLOCK()
+#define XEMAIL_SAFTFREE(a) \
if (a) {\
free(a); \
}
#if Z_DBG > 0
-#define ZEMAIL_DBG(fmt, arg...) \
+#define XEMAIL_DBG(fmt, arg...) \
fprintf(stdout, "%s:%d "fmt, __func__, __LINE__, ##arg)
#else
-#define ZEMAIL_DBG(fmt, arg...)
+#define XEMAIL_DBG(fmt, arg...)
#endif
-#define ZEMAIL_ERR(fmt, arg...) \
+#define XEMAIL_ERR(fmt, arg...) \
fprintf(stderr, "%s:%d"fmt, __func__, __LINE__, ##arg)
/*********************************************************************************************************
- ZEMAIL 错误号定义
+ XEMAIL 错误号定义
*********************************************************************************************************/
enum {
- ZEMAIL_NO_ERR = ERROR_NONE,
- ZEMAIL_MEMORY_ALLOC_ERR,
- ZEMAIL_VAL_INVALID,
+ XEMAIL_NO_ERR = ERROR_NONE,
+ XEMAIL_MEMORY_ALLOC_ERR,
+ XEMAIL_VAL_INVALID,
};
/*********************************************************************************************************
状态定义
*********************************************************************************************************/
typedef enum {
- ZEMAIL_INIT, /* email 初始化状态 */
- ZEMAIL_HEADER, /* 读取邮件头 */
- ZEMAIL_BODY, /* 读取邮件体 */
- ZEMAIL_BODY_DONE,
- ZEMAIL_ATTACHMENT, /* 读取附件        */
- ZEMAIL_END,
- ZEMAIL_DONE,
-} ZEMAIL_STATE;
+ XEMAIL_INIT, /* email 初始化状态 */
+ XEMAIL_HEADER, /* 读取邮件头 */
+ XEMAIL_BODY, /* 读取邮件体 */
+ XEMAIL_BODY_DONE,
+ XEMAIL_ATTACHMENT, /* 读取附件        */
+ XEMAIL_END,
+ XEMAIL_DONE,
+} XEMAIL_STATE;
/*********************************************************************************************************
LIST 结构体定义
*********************************************************************************************************/
-typedef struct zthsoft_info {
- struct zthsoft_info *ZEMAILINFO_next;
- PCHAR ZEMAILINFO_pcData;
-} ZEMAILINFO, *PZEMAILINFO;
+typedef struct xemail_info {
+ struct xemail_info *XEMAILINFO_next;
+ PCHAR XEMAILINFO_pcData;
+} XEMAILINFO, *PXEMAILINFO;
/*********************************************************************************************************
附件结构体定义
*********************************************************************************************************/
-typedef struct zthsoft_attachment {
- struct zthsoft_attachment *ZEMAILATTACH_next;
- PCHAR ZEMAILATTACH_pcFileName;
- PCHAR ZEMAILATTACH_pcMimeType;
- PVOID ZEMAILATTACH_pvFileData;
-
- PVOID ZEMAILATTACH_pvHandle;
- zemailOpenFn ZEMAILATTACH_open;
- zemailReadFn ZEMAILATTACH_read;
- zemailCloseFn ZEMAILATTACH_close;
- zemailFreeDataFn ZEMAILATTACH_free;
-} ZEMAILATTACH, *PZEMAILATTACH;
+typedef struct xemail_attachment {
+ struct xemail_attachment *XEMAILATTACH_next;
+ PCHAR XEMAILATTACH_pcFileName;
+ PCHAR XEMAILATTACH_pcMimeType;
+ PVOID XEMAILATTACH_pvFileData;
+
+ PVOID XEMAILATTACH_pvHandle;
+ xemailOpenFn XEMAILATTACH_open;
+ xemailReadFn XEMAILATTACH_read;
+ xemailCloseFn XEMAILATTACH_close;
+ xemailFreeDataFn XEMAILATTACH_free;
+} XEMAILATTACH, *PXEMAILATTACH;
/*********************************************************************************************************
附件结构体定义
*********************************************************************************************************/
-typedef struct zthsoft_memory {
- PCHAR ZEMAILM_pcData;
- size_t ZEMAILM_stLen;
- INT ZEMAILM_iMustFree;
-} ZEMAILM;
-
-typedef struct zthsoft_handle {
- PCHAR ZEMAILH_pcData;
- size_t ZEMAILH_stLen; /* 数据总长度 */
- size_t ZEMAILH_stPos; /* 当前读写的位置 */
-} ZEMAILH;
+typedef struct xemail_memory {
+ PCHAR XEMAILM_pcData;
+ size_t XEMAILM_stLen;
+ INT XEMAILM_iMustFree;
+} XEMAILM;
+
+typedef struct xemail_handle {
+ PCHAR XEMAILH_pcData;
+ size_t XEMAILH_stLen; /* 数据总长度 */
+ size_t XEMAILH_stPos; /* 当前读写的位置 */
+} XEMAILH;
/*********************************************************************************************************
主结构体定义
*********************************************************************************************************/
-typedef struct zthsoft_email {
- ZEMAIL_STATE ZEMAIL_state; /* 状态 */
- time_t ZEMAIL_tTimestamp; /* 时间戳 */
- PCHAR ZEMAIL_pcFrom; /* 邮件发送者 */
-
- PZEMAILINFO ZEMAIL_plineHeaderto; /* 接受者链头 */
- PZEMAILINFO ZEMAIL_plineHeadercc; /* 抄送者链头 */
- PZEMAILINFO ZEMAIL_plineHeaderbcc; /* 密送者链头 */
- PZEMAILATTACH ZEMAIL_plineHeaderBody; /* 消息体链头 */
- PZEMAILATTACH ZEMAIL_plineHeaderAttach; /* 附件链头 */
- PZEMAILATTACH ZEMAIL_plineHeaderCurrAttach; /* 当前要发送的链头 */
-
- PCHAR ZEMAIL_pcSubject; /* 主题 */
- PCHAR ZEMAIL_pcHeader; /* 邮件头 */
- PCHAR ZEMAIL_pcMimeBoundaryPart; /* mime 边界分割符 */
- PCHAR ZEMAIL_pcMimeBoundaryBody;
- PCHAR ZEMAIL_pcMailBuff; /* 临时缓冲区         */
- INT ZEMAIL_iMailBuffLen; /* 缓冲区长度 */
- CHAR ZEMAIL_cDtable[64];
- FILE *ZEMAIL_fp; /* DEBUG 输出 */
-} ZEMAIL;
+typedef struct xemail_email {
+ XEMAIL_STATE XEMAIL_state; /* 状态 */
+ time_t XEMAIL_tTimestamp; /* 时间戳 */
+ PCHAR XEMAIL_pcFrom; /* 邮件发送者 */
+
+ PXEMAILINFO XEMAIL_plineHeaderto; /* 接受者链头 */
+ PXEMAILINFO XEMAIL_plineHeadercc; /* 抄送者链头 */
+ PXEMAILINFO XEMAIL_plineHeaderbcc; /* 密送者链头 */
+ PXEMAILATTACH XEMAIL_plineHeaderBody; /* 消息体链头 */
+ PXEMAILATTACH XEMAIL_plineHeaderAttach; /* 附件链头 */
+ PXEMAILATTACH XEMAIL_plineHeaderCurrAttach; /* 当前要发送的链头 */
+
+ PCHAR XEMAIL_pcSubject; /* 主题 */
+ PCHAR XEMAIL_pcHeader; /* 邮件头 */
+ PCHAR XEMAIL_pcMimeBoundaryPart; /* mime 边界分割符 */
+ PCHAR XEMAIL_pcMimeBoundaryBody;
+ PCHAR XEMAIL_pcMailBuff; /* 临时缓冲区         */
+ INT XEMAIL_iMailBuffLen; /* 缓冲区长度 */
+ CHAR XEMAIL_cDtable[64];
+ FILE *XEMAIL_fp; /* DEBUG 输出 */
+} XEMAIL;
/*********************************************************************************************************
** 函数名称: __randZeros
** 功能描述: 0字符产生随机数
@@ -190,10 +190,10 @@ static PCHAR __stringAppend (PCHAR *ppcDest, PCHAR pcSrc)
*********************************************************************************************************/
VOID __stringFree (PCHAR pcStr)
{
- ZEMAIL_SAFTFREE(pcStr);
+ XEMAIL_SAFTFREE(pcStr);
}
/*********************************************************************************************************
-** 函数名称: __zemailInfoListAdd
+** 函数名称: __xemailInfoListAdd
** 功能描述: email信息增加
** 输 入 : pplistlineHeader : 链表头
** pcStr : 需要追加的字符串
@@ -201,27 +201,27 @@ VOID __stringFree (PCHAR pcStr)
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-INT __zemailInfoListAdd (PZEMAILINFO *pplistlineHeader, PCHAR pcStr)
+INT __xemailInfoListAdd (PXEMAILINFO *pplistlineHeader, PCHAR pcStr)
{
- PZEMAILINFO *pzemailinfo = pplistlineHeader;
+ PXEMAILINFO *pxemailinfo = pplistlineHeader;
- while (*pzemailinfo) {
- pzemailinfo = &(*pzemailinfo)->ZEMAILINFO_next;
+ while (*pxemailinfo) {
+ pxemailinfo = &(*pxemailinfo)->XEMAILINFO_next;
}
- *pzemailinfo = (PZEMAILINFO)malloc(sizeof(ZEMAILINFO));
- if (!*pzemailinfo) {
- ZEMAIL_ERR("Add %s failed.\n", pcStr);
+ *pxemailinfo = (PXEMAILINFO)malloc(sizeof(XEMAILINFO));
+ if (!*pxemailinfo) {
+ XEMAIL_ERR("Add %s failed.\n", pcStr);
return (PX_ERROR);
}
- (*pzemailinfo)->ZEMAILINFO_next = LW_NULL;
- (*pzemailinfo)->ZEMAILINFO_pcData = pcStr ? strdup(pcStr) : LW_NULL;
+ (*pxemailinfo)->XEMAILINFO_next = LW_NULL;
+ (*pxemailinfo)->XEMAILINFO_pcData = pcStr ? strdup(pcStr) : LW_NULL;
return (ERROR_NONE);
}
/*********************************************************************************************************
-** 函数名称: __zemailInfoListDel
+** 函数名称: __xemailInfoListDel
** 功能描述: 删除信息链
** 输 入 : plistlineHeader : 链头
** pcInfo : 邮件信息
@@ -229,25 +229,25 @@ INT __zemailInfoListAdd (PZEMAILINFO *pplistlineHeader, PCHAR pcStr)
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID __zemailInfoListDel (PZEMAILINFO *pplistlineHeader, PCHAR pcInfo)
+VOID __xemailInfoListDel (PXEMAILINFO *pplistlineHeader, PCHAR pcInfo)
{
- PZEMAILINFO pzemailinfo = *pplistlineHeader;
- PZEMAILINFO q;
+ PXEMAILINFO pxemailinfo = *pplistlineHeader;
+ PXEMAILINFO q;
INT iFind = 0;
- while (pzemailinfo) {
- q = pzemailinfo;
- pzemailinfo = q->ZEMAILINFO_next;
+ while (pxemailinfo) {
+ q = pxemailinfo;
+ pxemailinfo = q->XEMAILINFO_next;
if (pcInfo) {
- if (strcmp(q->ZEMAILINFO_pcData, pcInfo)) {
+ if (strcmp(q->XEMAILINFO_pcData, pcInfo)) {
continue;
} else {
iFind = 1;
}
}
- ZEMAIL_SAFTFREE(q->ZEMAILINFO_pcData);
+ XEMAIL_SAFTFREE(q->XEMAILINFO_pcData);
free(q);
if (iFind) {
@@ -256,28 +256,28 @@ VOID __zemailInfoListDel (PZEMAILINFO *pplistlineHeader, PCHAR pcInfo)
}
}
/*********************************************************************************************************
-** 函数名称: __zemailInfoListConcatenate
+** 函数名称: __xemailInfoListConcatenate
** 功能描述: 组装邮件信息(如:<example@163.com> )
** 输 入 : plistlineHeader : 链头
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-PCHAR __zemailInfoListConcatenate (PZEMAILINFO plistlineHeader)
+PCHAR __xemailInfoListConcatenate (PXEMAILINFO plistlineHeader)
{
- PZEMAILINFO pzemailinfo = plistlineHeader;
+ PXEMAILINFO pxemailinfo = plistlineHeader;
PCHAR pcResult = LW_NULL;
- while (pzemailinfo) {
- if (pzemailinfo->ZEMAILINFO_pcData && *(pzemailinfo->ZEMAILINFO_pcData)) {
+ while (pxemailinfo) {
+ if (pxemailinfo->XEMAILINFO_pcData && *(pxemailinfo->XEMAILINFO_pcData)) {
if (pcResult) {
- __stringAppend(&pcResult, "."ZEMAIL_NEWLINE"\t");
+ __stringAppend(&pcResult, "."XEMAIL_NEWLINE"\t");
}
__stringAppend(&pcResult, "<");
- __stringAppend(&pcResult, pzemailinfo->ZEMAILINFO_pcData);
+ __stringAppend(&pcResult, pxemailinfo->XEMAILINFO_pcData);
__stringAppend(&pcResult, ">");
}
- pzemailinfo = pzemailinfo->ZEMAILINFO_next;
+ pxemailinfo = pxemailinfo->XEMAILINFO_next;
}
return (pcResult);
@@ -297,36 +297,36 @@ PCHAR __zemailInfoListConcatenate (PZEMAILINFO plistlineHeader)
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-INT __attachmentListAdd (PZEMAILATTACH *pplistlineHeader,
+INT __attachmentListAdd (PXEMAILATTACH *pplistlineHeader,
PCHAR pcFileName,
PCHAR pcMimeType,
PVOID pvFileData,
- zemailOpenFn pfnOpen,
- zemailReadFn pfnRead,
- zemailCloseFn pfnClose,
- zemailFreeDataFn pfnFree)
+ xemailOpenFn pfnOpen,
+ xemailReadFn pfnRead,
+ xemailCloseFn pfnClose,
+ xemailFreeDataFn pfnFree)
{
- PZEMAILATTACH *ppzemailattach = pplistlineHeader;
+ PXEMAILATTACH *ppxemailattach = pplistlineHeader;
- while (*ppzemailattach) {
- ppzemailattach = &((*ppzemailattach)->ZEMAILATTACH_next);
+ while (*ppxemailattach) {
+ ppxemailattach = &((*ppxemailattach)->XEMAILATTACH_next);
}
- *ppzemailattach = (PZEMAILATTACH)malloc(sizeof(ZEMAILATTACH));
- if (!*ppzemailattach) {
- ZEMAIL_ERR("Alloc attachment memory failed.\n");
+ *ppxemailattach = (PXEMAILATTACH)malloc(sizeof(XEMAILATTACH));
+ if (!*ppxemailattach) {
+ XEMAIL_ERR("Alloc attachment memory failed.\n");
return (PX_ERROR);
}
- (*ppzemailattach)->ZEMAILATTACH_pcFileName = strdup(pcFileName ? pcFileName : "UNNAME");
- (*ppzemailattach)->ZEMAILATTACH_pcMimeType = pcMimeType ? strdup(pcMimeType) : LW_NULL;
- (*ppzemailattach)->ZEMAILATTACH_pvFileData = pvFileData;
- (*ppzemailattach)->ZEMAILATTACH_pvHandle = LW_NULL;
- (*ppzemailattach)->ZEMAILATTACH_open = pfnOpen;
- (*ppzemailattach)->ZEMAILATTACH_read = pfnRead;
- (*ppzemailattach)->ZEMAILATTACH_close = pfnClose;
- (*ppzemailattach)->ZEMAILATTACH_free = pfnFree;
- (*ppzemailattach)->ZEMAILATTACH_next = LW_NULL;
+ (*ppxemailattach)->XEMAILATTACH_pcFileName = strdup(pcFileName ? pcFileName : "UNNAME");
+ (*ppxemailattach)->XEMAILATTACH_pcMimeType = pcMimeType ? strdup(pcMimeType) : LW_NULL;
+ (*ppxemailattach)->XEMAILATTACH_pvFileData = pvFileData;
+ (*ppxemailattach)->XEMAILATTACH_pvHandle = LW_NULL;
+ (*ppxemailattach)->XEMAILATTACH_open = pfnOpen;
+ (*ppxemailattach)->XEMAILATTACH_read = pfnRead;
+ (*ppxemailattach)->XEMAILATTACH_close = pfnClose;
+ (*ppxemailattach)->XEMAILATTACH_free = pfnFree;
+ (*ppxemailattach)->XEMAILATTACH_next = LW_NULL;
return (ERROR_NONE);
}
@@ -339,41 +339,41 @@ INT __attachmentListAdd (PZEMAILATTACH *pplistlineHeader,
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static VOID __attachmentListDel (PZEMAILATTACH *pplistlineHeader, PCHAR pcFileName)
+static VOID __attachmentListDel (PXEMAILATTACH *pplistlineHeader, PCHAR pcFileName)
{
- PZEMAILATTACH pzemailattach = *pplistlineHeader;
- PZEMAILATTACH q;
+ PXEMAILATTACH pxemailattach = *pplistlineHeader;
+ PXEMAILATTACH q;
INT iFind = 0;
- while (pzemailattach) {
- q = pzemailattach;
- pzemailattach = pzemailattach->ZEMAILATTACH_next;
+ while (pxemailattach) {
+ q = pxemailattach;
+ pxemailattach = pxemailattach->XEMAILATTACH_next;
if (pcFileName) {
- if (strcmp(q->ZEMAILATTACH_pcFileName, pcFileName)) {
+ if (strcmp(q->XEMAILATTACH_pcFileName, pcFileName)) {
continue;
} else {
iFind = 1;
}
}
- if (q->ZEMAILATTACH_pvHandle) {
- if (q->ZEMAILATTACH_close) {
- q->ZEMAILATTACH_close(q->ZEMAILATTACH_pvHandle);
+ if (q->XEMAILATTACH_pvHandle) {
+ if (q->XEMAILATTACH_close) {
+ q->XEMAILATTACH_close(q->XEMAILATTACH_pvHandle);
}
- q->ZEMAILATTACH_pvHandle = LW_NULL;
+ q->XEMAILATTACH_pvHandle = LW_NULL;
}
- if (q->ZEMAILATTACH_pvFileData) {
- if (q->ZEMAILATTACH_free) {
- q->ZEMAILATTACH_free(q->ZEMAILATTACH_pvFileData);
+ if (q->XEMAILATTACH_pvFileData) {
+ if (q->XEMAILATTACH_free) {
+ q->XEMAILATTACH_free(q->XEMAILATTACH_pvFileData);
} else {
- free(q->ZEMAILATTACH_pvFileData);
+ free(q->XEMAILATTACH_pvFileData);
}
}
- ZEMAIL_SAFTFREE(q->ZEMAILATTACH_pcMimeType);
- ZEMAIL_SAFTFREE(q->ZEMAILATTACH_pcFileName);
+ XEMAIL_SAFTFREE(q->XEMAILATTACH_pcMimeType);
+ XEMAIL_SAFTFREE(q->XEMAILATTACH_pcFileName);
free(q);
if (iFind) {
@@ -400,7 +400,7 @@ static PVOID __attachmentOpenFile (PVOID pcFileName)
/*********************************************************************************************************
** 函数名称: __attachmentReadFile
** 功能描述: email 添加附件
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 字节
** 全局变量:
** 调用模块:
@@ -412,7 +412,7 @@ static size_t __attachmentReadFile (PVOID pvHandle, PVOID pvBuf, size_t stLen)
/*********************************************************************************************************
** 函数名称: __attachmentCloseFile
** 功能描述: email 添加附件
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
@@ -427,19 +427,19 @@ static VOID __attachmentCloseFile (PVOID pvHandle)
** 函数名称: __attachmentAddFile
** 功能描述: email 添加附件
** 输 入 : pplistlineHeader : 链头
-** pzemail : email 结构
+** pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static INT __attachmentAddFile (PZEMAILATTACH *pplistlineHeader,
+static INT __attachmentAddFile (PXEMAILATTACH *pplistlineHeader,
PCHAR pcPath,
PCHAR pcMimeType)
{
PCHAR pcBasename;
pcBasename = basename(pcPath);
- ZEMAIL_DBG("basename:%s\n", pcBasename);
+ XEMAIL_DBG("basename:%s\n", pcBasename);
return __attachmentListAdd(pplistlineHeader,
pcBasename,
@@ -460,28 +460,28 @@ static INT __attachmentAddFile (PZEMAILATTACH *pplistlineHeader,
*********************************************************************************************************/
static PVOID __attachmentOpenMemory (PVOID pvData)
{
- ZEMAILM *pzemailData;
- ZEMAILH *pzemailhandle;
+ XEMAILM *pxemailData;
+ XEMAILH *pxemailhandle;
if (!pvData) {
return (LW_NULL);
}
- pzemailData = (ZEMAILM *)pvData;
- if (!pzemailData->ZEMAILM_pcData) {
+ pxemailData = (XEMAILM *)pvData;
+ if (!pxemailData->XEMAILM_pcData) {
return (LW_NULL);
}
- pzemailhandle = (ZEMAILH *)malloc(sizeof(ZEMAILH));
- if (!pzemailhandle) {
+ pxemailhandle = (XEMAILH *)malloc(sizeof(XEMAILH));
+ if (!pxemailhandle) {
return (LW_NULL);
}
- pzemailhandle->ZEMAILH_pcData = pzemailData->ZEMAILM_pcData;
- pzemailhandle->ZEMAILH_stLen = pzemailData->ZEMAILM_stLen;
- pzemailhandle->ZEMAILH_stPos = 0;
+ pxemailhandle->XEMAILH_pcData = pxemailData->XEMAILM_pcData;
+ pxemailhandle->XEMAILH_stLen = pxemailData->XEMAILM_stLen;
+ pxemailhandle->XEMAILH_stPos = 0;
- return (pzemailhandle);
+ return (pxemailhandle);
}
/*********************************************************************************************************
** 函数名称: __attachmentReadMemory
@@ -495,13 +495,13 @@ static PVOID __attachmentOpenMemory (PVOID pvData)
*********************************************************************************************************/
static size_t __attachmentReadMemory (PVOID pvHandle, PVOID pvBuf, size_t stLen)
{
- ZEMAILH *pzemailhandle = (ZEMAILH *)pvHandle;
- size_t stReadLen = (pzemailhandle->ZEMAILH_stLen - pzemailhandle->ZEMAILH_stPos) > stLen ?
- stLen : pzemailhandle->ZEMAILH_stLen - pzemailhandle->ZEMAILH_stPos;
+ XEMAILH *pxemailhandle = (XEMAILH *)pvHandle;
+ size_t stReadLen = (pxemailhandle->XEMAILH_stLen - pxemailhandle->XEMAILH_stPos) > stLen ?
+ stLen : pxemailhandle->XEMAILH_stLen - pxemailhandle->XEMAILH_stPos;
- memcpy(pvBuf, pzemailhandle->ZEMAILH_pcData + pzemailhandle->ZEMAILH_stPos, stReadLen);
+ memcpy(pvBuf, pxemailhandle->XEMAILH_pcData + pxemailhandle->XEMAILH_stPos, stReadLen);
- pzemailhandle->ZEMAILH_stPos += stReadLen;
+ pxemailhandle->XEMAILH_stPos += stReadLen;
return (stReadLen);
}
@@ -515,7 +515,7 @@ static size_t __attachmentReadMemory (PVOID pvHandle, PVOID pvBuf, size_t stL
*********************************************************************************************************/
static VOID __attachmentCloseMemory (PVOID pvHandle)
{
- ZEMAIL_SAFTFREE(pvHandle);
+ XEMAIL_SAFTFREE(pvHandle);
}
/*********************************************************************************************************
** 函数名称: __attachmentFreeMemory
@@ -527,14 +527,14 @@ static VOID __attachmentCloseMemory (PVOID pvHandle)
*********************************************************************************************************/
static VOID __attachmentFreeMemory (PVOID pvData)
{
- ZEMAILM *pzemailData;
+ XEMAILM *pxemailData;
- pzemailData = (ZEMAILM *)pvData;
- if (pzemailData) {
- if (pzemailData->ZEMAILM_iMustFree) {
- ZEMAIL_SAFTFREE(pzemailData->ZEMAILM_pcData);
+ pxemailData = (XEMAILM *)pvData;
+ if (pxemailData) {
+ if (pxemailData->XEMAILM_iMustFree) {
+ XEMAIL_SAFTFREE(pxemailData->XEMAILM_pcData);
}
- free(pzemailData);
+ free(pxemailData);
}
}
/*********************************************************************************************************
@@ -550,28 +550,28 @@ static VOID __attachmentFreeMemory (PVOID pvData)
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static INT __mailAddTextBody (PZEMAILATTACH *pplistlineHeader,
+static INT __mailAddTextBody (PXEMAILATTACH *pplistlineHeader,
PCHAR pcFileName,
PCHAR pcMimeType,
PVOID pcFileData,
size_t stLen,
INT iMustFree)
{
- ZEMAILM *pzemailData;
+ XEMAILM *pxemailData;
- pzemailData = (ZEMAILM *)malloc(sizeof(ZEMAILM));
- if (!pzemailData) {
+ pxemailData = (XEMAILM *)malloc(sizeof(XEMAILM));
+ if (!pxemailData) {
return (PX_ERROR);
}
- pzemailData->ZEMAILM_pcData = pcFileData;
- pzemailData->ZEMAILM_stLen = stLen;
- pzemailData->ZEMAILM_iMustFree = iMustFree;
+ pxemailData->XEMAILM_pcData = pcFileData;
+ pxemailData->XEMAILM_stLen = stLen;
+ pxemailData->XEMAILM_iMustFree = iMustFree;
return (__attachmentListAdd(pplistlineHeader,
pcFileName,
pcMimeType,
- (PVOID)pzemailData,
+ (PVOID)pxemailData,
__attachmentOpenMemory,
__attachmentReadMemory,
__attachmentCloseMemory,
@@ -590,250 +590,250 @@ static INT __mailAddTextBody (PZEMAILATTACH *pplistlineHeader,
*********************************************************************************************************/
static size_t __GetEmailContent (PVOID pvPtr, size_t stSize, size_t stBlock, PVOID pvUsrptr)
{
- PZEMAIL pzemail = (PZEMAIL)pvUsrptr;
+ PXEMAIL pxemail = (PXEMAIL)pvUsrptr;
if (!(stSize * stBlock)) {
return (0);
}
- if (pzemail->ZEMAIL_state == ZEMAIL_INIT) {
- ZEMAIL_SAFTFREE(pzemail->ZEMAIL_pcMailBuff);
- pzemail->ZEMAIL_pcMailBuff = LW_NULL;
- pzemail->ZEMAIL_iMailBuffLen = 0;
- ZEMAIL_SAFTFREE(pzemail->ZEMAIL_pcMimeBoundaryBody);
- pzemail->ZEMAIL_pcMimeBoundaryBody = LW_NULL;
- ZEMAIL_SAFTFREE(pzemail->ZEMAIL_pcMimeBoundaryPart);
- pzemail->ZEMAIL_pcMimeBoundaryPart = LW_NULL;
- pzemail->ZEMAIL_plineHeaderCurrAttach = pzemail->ZEMAIL_plineHeaderBody;
- pzemail->ZEMAIL_state++;
+ if (pxemail->XEMAIL_state == XEMAIL_INIT) {
+ XEMAIL_SAFTFREE(pxemail->XEMAIL_pcMailBuff);
+ pxemail->XEMAIL_pcMailBuff = LW_NULL;
+ pxemail->XEMAIL_iMailBuffLen = 0;
+ XEMAIL_SAFTFREE(pxemail->XEMAIL_pcMimeBoundaryBody);
+ pxemail->XEMAIL_pcMimeBoundaryBody = LW_NULL;
+ XEMAIL_SAFTFREE(pxemail->XEMAIL_pcMimeBoundaryPart);
+ pxemail->XEMAIL_pcMimeBoundaryPart = LW_NULL;
+ pxemail->XEMAIL_plineHeaderCurrAttach = pxemail->XEMAIL_plineHeaderBody;
+ pxemail->XEMAIL_state++;
}
- while (pzemail->ZEMAIL_iMailBuffLen == 0) {
- if ((!pzemail->ZEMAIL_iMailBuffLen) && pzemail->ZEMAIL_state == ZEMAIL_HEADER) {
+ while (pxemail->XEMAIL_iMailBuffLen == 0) {
+ if ((!pxemail->XEMAIL_iMailBuffLen) && pxemail->XEMAIL_state == XEMAIL_HEADER) {
PCHAR *ppc;
PCHAR ppcT;
- ppc = &pzemail->ZEMAIL_pcMailBuff;
- __stringAppend(ppc, "Zthsoft email "ZEMAIL_VERSION ZEMAIL_NEWLINE);
- if (pzemail->ZEMAIL_tTimestamp != 0) {
+ ppc = &pxemail->XEMAIL_pcMailBuff;
+ __stringAppend(ppc, "Zthsoft email "XEMAIL_VERSION XEMAIL_NEWLINE);
+ if (pxemail->XEMAIL_tTimestamp != 0) {
CHAR cTime[64];
if (strftime(cTime, sizeof(cTime), "%a, %d %b %Y %H:%M:%S",
- localtime(&pzemail->ZEMAIL_tTimestamp))) {
+ localtime(&pxemail->XEMAIL_tTimestamp))) {
__stringAppend(ppc, "Date: ");
__stringAppend(ppc, cTime);
- __stringAppend(ppc, ZEMAIL_NEWLINE);
+ __stringAppend(ppc, XEMAIL_NEWLINE);
}
}
/*
* From:
*/
- if (pzemail->ZEMAIL_pcFrom) {
+ if (pxemail->XEMAIL_pcFrom) {
__stringAppend(ppc, "From: <");
- __stringAppend(ppc, pzemail->ZEMAIL_pcFrom);
- __stringAppend(ppc, ">"ZEMAIL_NEWLINE);
+ __stringAppend(ppc, pxemail->XEMAIL_pcFrom);
+ __stringAppend(ppc, ">"XEMAIL_NEWLINE);
}
/*
* To:
*/
- if ((ppcT = __zemailInfoListConcatenate(pzemail->ZEMAIL_plineHeaderto))) {
+ if ((ppcT = __xemailInfoListConcatenate(pxemail->XEMAIL_plineHeaderto))) {
__stringAppend(ppc, "To: ");
__stringAppend(ppc, ppcT);
- __stringAppend(ppc, ZEMAIL_NEWLINE);
- ZEMAIL_SAFTFREE(ppcT);
+ __stringAppend(ppc, XEMAIL_NEWLINE);
+ XEMAIL_SAFTFREE(ppcT);
}
/*
* Cc:
*/
- if ((ppcT = __zemailInfoListConcatenate(pzemail->ZEMAIL_plineHeadercc))) {
+ if ((ppcT = __xemailInfoListConcatenate(pxemail->XEMAIL_plineHeadercc))) {
__stringAppend(ppc, "Cc: ");
__stringAppend(ppc, ppcT);
- __stringAppend(ppc, ZEMAIL_NEWLINE);
- ZEMAIL_SAFTFREE(ppcT);
+ __stringAppend(ppc, XEMAIL_NEWLINE);
+ XEMAIL_SAFTFREE(ppcT);
}
/*
* Subject:
*/
- if (pzemail->ZEMAIL_pcSubject) {
+ if (pxemail->XEMAIL_pcSubject) {
__stringAppend(ppc, "Subject: ");
- __stringAppend(ppc, pzemail->ZEMAIL_pcSubject);
- __stringAppend(ppc, ZEMAIL_NEWLINE);
+ __stringAppend(ppc, pxemail->XEMAIL_pcSubject);
+ __stringAppend(ppc, XEMAIL_NEWLINE);
}
/*
* Header
*/
- if (pzemail->ZEMAIL_pcHeader) {
- __stringAppend(ppc, pzemail->ZEMAIL_pcHeader);
+ if (pxemail->XEMAIL_pcHeader) {
+ __stringAppend(ppc, pxemail->XEMAIL_pcHeader);
}
/*
* 存在附件
*/
- if (pzemail->ZEMAIL_plineHeaderAttach) {
- __stringAppend(ppc, "MIME-Version: 1.0"ZEMAIL_NEWLINE);
- pzemail->ZEMAIL_pcMimeBoundaryPart =
+ if (pxemail->XEMAIL_plineHeaderAttach) {
+ __stringAppend(ppc, "MIME-Version: 1.0"XEMAIL_NEWLINE);
+ pxemail->XEMAIL_pcMimeBoundaryPart =
__randZeros(strdup("=PART=SEPARATOR=_0000_0000_0000_0000_0000_0000_="));
__stringAppend(ppc, "Content-Type: multipart/mixed; boundary=\"");
- __stringAppend(ppc, pzemail->ZEMAIL_pcMimeBoundaryPart);
- __stringAppend(ppc, "\"" ZEMAIL_NEWLINE ZEMAIL_NEWLINE
+ __stringAppend(ppc, pxemail->XEMAIL_pcMimeBoundaryPart);
+ __stringAppend(ppc, "\"" XEMAIL_NEWLINE XEMAIL_NEWLINE
"This is a multipart message in MIME format."
- ZEMAIL_NEWLINE ZEMAIL_NEWLINE "--");
- __stringAppend(ppc, pzemail->ZEMAIL_pcMimeBoundaryPart);
- __stringAppend(ppc, ZEMAIL_NEWLINE);
+ XEMAIL_NEWLINE XEMAIL_NEWLINE "--");
+ __stringAppend(ppc, pxemail->XEMAIL_pcMimeBoundaryPart);
+ __stringAppend(ppc, XEMAIL_NEWLINE);
}
/*
* 存在邮件体
*/
- if (pzemail->ZEMAIL_plineHeaderBody &&
- pzemail->ZEMAIL_plineHeaderBody->ZEMAILATTACH_next) {
- pzemail->ZEMAIL_pcMimeBoundaryBody =
+ if (pxemail->XEMAIL_plineHeaderBody &&
+ pxemail->XEMAIL_plineHeaderBody->XEMAILATTACH_next) {
+ pxemail->XEMAIL_pcMimeBoundaryBody =
__randZeros(strdup("=BODY=SEPARATOR=_0000_0000_0000_0000_0000_0000_="));
__stringAppend(ppc, "Content-Type: multipart/alternative; boundary=\"");
- __stringAppend(ppc, pzemail->ZEMAIL_pcMimeBoundaryBody);
- __stringAppend(ppc, ZEMAIL_NEWLINE);
+ __stringAppend(ppc, pxemail->XEMAIL_pcMimeBoundaryBody);
+ __stringAppend(ppc, XEMAIL_NEWLINE);
}
- pzemail->ZEMAIL_iMailBuffLen = strlen(pzemail->ZEMAIL_pcMailBuff);
- pzemail->ZEMAIL_state++;
+ pxemail->XEMAIL_iMailBuffLen = strlen(pxemail->XEMAIL_pcMailBuff);
+ pxemail->XEMAIL_state++;
}
- if ((!pzemail->ZEMAIL_iMailBuffLen) && pzemail->ZEMAIL_state == ZEMAIL_BODY) {
+ if ((!pxemail->XEMAIL_iMailBuffLen) && pxemail->XEMAIL_state == XEMAIL_BODY) {
/*
* 首先解析 BODY 如果存在.
*/
- if (pzemail->ZEMAIL_plineHeaderCurrAttach) {
- if (!pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_pvHandle) {
- while (pzemail->ZEMAIL_plineHeaderCurrAttach) {
- if ((pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_pvHandle =
- pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_open
- (pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_pvFileData))) {
+ if (pxemail->XEMAIL_plineHeaderCurrAttach) {
+ if (!pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_pvHandle) {
+ while (pxemail->XEMAIL_plineHeaderCurrAttach) {
+ if ((pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_pvHandle =
+ pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_open
+ (pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_pvFileData))) {
break;
}
- pzemail->ZEMAIL_plineHeaderCurrAttach =
- pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_next;
+ pxemail->XEMAIL_plineHeaderCurrAttach =
+ pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_next;
}
- if (!pzemail->ZEMAIL_plineHeaderCurrAttach) {
- pzemail->ZEMAIL_plineHeaderCurrAttach = pzemail->ZEMAIL_plineHeaderAttach;
- pzemail->ZEMAIL_state++;
+ if (!pxemail->XEMAIL_plineHeaderCurrAttach) {
+ pxemail->XEMAIL_plineHeaderCurrAttach = pxemail->XEMAIL_plineHeaderAttach;
+ pxemail->XEMAIL_state++;
}
- if (pzemail->ZEMAIL_plineHeaderCurrAttach &&
- pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_pvHandle) {
- pzemail->ZEMAIL_pcMailBuff = LW_NULL;
- if (pzemail->ZEMAIL_pcMimeBoundaryBody) {
- pzemail->ZEMAIL_pcMailBuff =
- __stringAppend(&pzemail->ZEMAIL_pcMailBuff, ZEMAIL_NEWLINE "--");
- pzemail->ZEMAIL_pcMailBuff =
- __stringAppend(&pzemail->ZEMAIL_pcMailBuff,
- pzemail->ZEMAIL_pcMimeBoundaryBody);
- pzemail->ZEMAIL_pcMailBuff =
- __stringAppend(&pzemail->ZEMAIL_pcMailBuff, ZEMAIL_NEWLINE);
+ if (pxemail->XEMAIL_plineHeaderCurrAttach &&
+ pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_pvHandle) {
+ pxemail->XEMAIL_pcMailBuff = LW_NULL;
+ if (pxemail->XEMAIL_pcMimeBoundaryBody) {
+ pxemail->XEMAIL_pcMailBuff =
+ __stringAppend(&pxemail->XEMAIL_pcMailBuff, XEMAIL_NEWLINE "--");
+ pxemail->XEMAIL_pcMailBuff =
+ __stringAppend(&pxemail->XEMAIL_pcMailBuff,
+ pxemail->XEMAIL_pcMimeBoundaryBody);
+ pxemail->XEMAIL_pcMailBuff =
+ __stringAppend(&pxemail->XEMAIL_pcMailBuff, XEMAIL_NEWLINE);
}
- pzemail->ZEMAIL_pcMailBuff =
- __stringAppend(&pzemail->ZEMAIL_pcMailBuff, "Content-Type: ");
- pzemail->ZEMAIL_pcMailBuff =
- __stringAppend(&pzemail->ZEMAIL_pcMailBuff,
- (pzemail->ZEMAIL_plineHeaderBody &&
- pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_pcFileName ?
- pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_pcFileName :
- ZEMAIL_DEFAULT_MIME_TYPE));
- pzemail->ZEMAIL_pcMailBuff =
- __stringAppend(&pzemail->ZEMAIL_pcMailBuff,
- ZEMAIL_NEWLINE "Content-Transfer-Encoding: 8bit"
- ZEMAIL_NEWLINE "Content-Disposition: inline"
- ZEMAIL_NEWLINE ZEMAIL_NEWLINE);
- pzemail->ZEMAIL_iMailBuffLen = strlen(pzemail->ZEMAIL_pcMailBuff);
+ pxemail->XEMAIL_pcMailBuff =
+ __stringAppend(&pxemail->XEMAIL_pcMailBuff, "Content-Type: ");
+ pxemail->XEMAIL_pcMailBuff =
+ __stringAppend(&pxemail->XEMAIL_pcMailBuff,
+ (pxemail->XEMAIL_plineHeaderBody &&
+ pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_pcFileName ?
+ pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_pcFileName :
+ XEMAIL_DEFAULT_MIME_TYPE));
+ pxemail->XEMAIL_pcMailBuff =
+ __stringAppend(&pxemail->XEMAIL_pcMailBuff,
+ XEMAIL_NEWLINE "Content-Transfer-Encoding: 8bit"
+ XEMAIL_NEWLINE "Content-Disposition: inline"
+ XEMAIL_NEWLINE XEMAIL_NEWLINE);
+ pxemail->XEMAIL_iMailBuffLen = strlen(pxemail->XEMAIL_pcMailBuff);
}
}
- if (!pzemail->ZEMAIL_iMailBuffLen && pzemail->ZEMAIL_plineHeaderCurrAttach &&
- pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_pvHandle) {
- pzemail->ZEMAIL_pcMailBuff = malloc(ZEMAIL_BODY_BUFFER_SIZE);
- pzemail->ZEMAIL_iMailBuffLen =
- pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_read
- (pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_pvHandle,
- pzemail->ZEMAIL_pcMailBuff, ZEMAIL_BODY_BUFFER_SIZE);
- if (!pzemail->ZEMAIL_pcMailBuff || pzemail->ZEMAIL_iMailBuffLen <= 0) {
- pzemail->ZEMAIL_iMailBuffLen = 0;
- if (pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_close) {
- pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_close
- (pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_pvHandle);
+ if (!pxemail->XEMAIL_iMailBuffLen && pxemail->XEMAIL_plineHeaderCurrAttach &&
+ pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_pvHandle) {
+ pxemail->XEMAIL_pcMailBuff = malloc(XEMAIL_BODY_BUFFER_SIZE);
+ pxemail->XEMAIL_iMailBuffLen =
+ pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_read
+ (pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_pvHandle,
+ pxemail->XEMAIL_pcMailBuff, XEMAIL_BODY_BUFFER_SIZE);
+ if (!pxemail->XEMAIL_pcMailBuff || pxemail->XEMAIL_iMailBuffLen <= 0) {
+ pxemail->XEMAIL_iMailBuffLen = 0;
+ if (pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_close) {
+ pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_close
+ (pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_pvHandle);
}
- pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_pvHandle = LW_NULL;
- pzemail->ZEMAIL_plineHeaderCurrAttach =
- pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_next;
+ pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_pvHandle = LW_NULL;
+ pxemail->XEMAIL_plineHeaderCurrAttach =
+ pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_next;
}
}
} else {
/*
* 否则解析附件.
*/
- pzemail->ZEMAIL_plineHeaderCurrAttach = pzemail->ZEMAIL_plineHeaderAttach;
- pzemail->ZEMAIL_state++;
+ pxemail->XEMAIL_plineHeaderCurrAttach = pxemail->XEMAIL_plineHeaderAttach;
+ pxemail->XEMAIL_state++;
}
}
- if ((!pzemail->ZEMAIL_iMailBuffLen) && pzemail->ZEMAIL_state == ZEMAIL_BODY_DONE) {
- pzemail->ZEMAIL_pcMailBuff = NULL;
- if (pzemail->ZEMAIL_pcMimeBoundaryBody) {
- pzemail->ZEMAIL_pcMailBuff = __stringAppend(&pzemail->ZEMAIL_pcMailBuff, ZEMAIL_NEWLINE "--");
- pzemail->ZEMAIL_pcMailBuff = __stringAppend(&pzemail->ZEMAIL_pcMailBuff, pzemail->ZEMAIL_pcMimeBoundaryBody);
- pzemail->ZEMAIL_pcMailBuff = __stringAppend(&pzemail->ZEMAIL_pcMailBuff, "--" ZEMAIL_NEWLINE);
- pzemail->ZEMAIL_iMailBuffLen = strlen(pzemail->ZEMAIL_pcMailBuff);
- free(pzemail->ZEMAIL_pcMimeBoundaryBody);
- pzemail->ZEMAIL_pcMimeBoundaryBody = NULL;
+ if ((!pxemail->XEMAIL_iMailBuffLen) && pxemail->XEMAIL_state == XEMAIL_BODY_DONE) {
+ pxemail->XEMAIL_pcMailBuff = NULL;
+ if (pxemail->XEMAIL_pcMimeBoundaryBody) {
+ pxemail->XEMAIL_pcMailBuff = __stringAppend(&pxemail->XEMAIL_pcMailBuff, XEMAIL_NEWLINE "--");
+ pxemail->XEMAIL_pcMailBuff = __stringAppend(&pxemail->XEMAIL_pcMailBuff, pxemail->XEMAIL_pcMimeBoundaryBody);
+ pxemail->XEMAIL_pcMailBuff = __stringAppend(&pxemail->XEMAIL_pcMailBuff, "--" XEMAIL_NEWLINE);
+ pxemail->XEMAIL_iMailBuffLen = strlen(pxemail->XEMAIL_pcMailBuff);
+ free(pxemail->XEMAIL_pcMimeBoundaryBody);
+ pxemail->XEMAIL_pcMimeBoundaryBody = NULL;
}
- pzemail->ZEMAIL_state++;
+ pxemail->XEMAIL_state++;
}
- if ((!pzemail->ZEMAIL_iMailBuffLen) && pzemail->ZEMAIL_state == ZEMAIL_ATTACHMENT) {
- if (pzemail->ZEMAIL_plineHeaderCurrAttach) {
- if (!pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_pvHandle) {
- while (pzemail->ZEMAIL_plineHeaderCurrAttach) {
- if ((pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_pvHandle =
- pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_open
- (pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_pvFileData))) {
+ if ((!pxemail->XEMAIL_iMailBuffLen) && pxemail->XEMAIL_state == XEMAIL_ATTACHMENT) {
+ if (pxemail->XEMAIL_plineHeaderCurrAttach) {
+ if (!pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_pvHandle) {
+ while (pxemail->XEMAIL_plineHeaderCurrAttach) {
+ if ((pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_pvHandle =
+ pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_open
+ (pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_pvFileData))) {
break;
}
- pzemail->ZEMAIL_plineHeaderCurrAttach =
- pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_next;
+ pxemail->XEMAIL_plineHeaderCurrAttach =
+ pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_next;
}
- if (pzemail->ZEMAIL_plineHeaderCurrAttach &&
- pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_pvHandle) {
- pzemail->ZEMAIL_pcMailBuff = LW_NULL;
- if (pzemail->ZEMAIL_pcMimeBoundaryPart) {
- pzemail->ZEMAIL_pcMailBuff =
- __stringAppend(&pzemail->ZEMAIL_pcMailBuff, ZEMAIL_NEWLINE "--");
- pzemail->ZEMAIL_pcMailBuff =
- __stringAppend(&pzemail->ZEMAIL_pcMailBuff, pzemail->ZEMAIL_pcMimeBoundaryPart);
- pzemail->ZEMAIL_pcMailBuff =
- __stringAppend(&pzemail->ZEMAIL_pcMailBuff, ZEMAIL_NEWLINE);
+ if (pxemail->XEMAIL_plineHeaderCurrAttach &&
+ pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_pvHandle) {
+ pxemail->XEMAIL_pcMailBuff = LW_NULL;
+ if (pxemail->XEMAIL_pcMimeBoundaryPart) {
+ pxemail->XEMAIL_pcMailBuff =
+ __stringAppend(&pxemail->XEMAIL_pcMailBuff, XEMAIL_NEWLINE "--");
+ pxemail->XEMAIL_pcMailBuff =
+ __stringAppend(&pxemail->XEMAIL_pcMailBuff, pxemail->XEMAIL_pcMimeBoundaryPart);
+ pxemail->XEMAIL_pcMailBuff =
+ __stringAppend(&pxemail->XEMAIL_pcMailBuff, XEMAIL_NEWLINE);
}
- pzemail->ZEMAIL_pcMailBuff =
- __stringAppend(&pzemail->ZEMAIL_pcMailBuff, "Content-Type: ");
- pzemail->ZEMAIL_pcMailBuff =
- __stringAppend(&pzemail->ZEMAIL_pcMailBuff,
- (pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_pcMimeType ?
- pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_pcMimeType :
+ pxemail->XEMAIL_pcMailBuff =
+ __stringAppend(&pxemail->XEMAIL_pcMailBuff, "Content-Type: ");
+ pxemail->XEMAIL_pcMailBuff =
+ __stringAppend(&pxemail->XEMAIL_pcMailBuff,
+ (pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_pcMimeType ?
+ pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_pcMimeType :
"application/octet-stream"));
- pzemail->ZEMAIL_pcMailBuff =
- __stringAppend(&pzemail->ZEMAIL_pcMailBuff, "; Name=\"");
- pzemail->ZEMAIL_pcMailBuff =
- __stringAppend(&pzemail->ZEMAIL_pcMailBuff,
- pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_pcFileName);
- pzemail->ZEMAIL_pcMailBuff =
- __stringAppend(&pzemail->ZEMAIL_pcMailBuff, "\""
- ZEMAIL_NEWLINE "Content-Transfer-Encoding: base64"
- ZEMAIL_NEWLINE ZEMAIL_NEWLINE);
- pzemail->ZEMAIL_iMailBuffLen = strlen(pzemail->ZEMAIL_pcMailBuff);
+ pxemail->XEMAIL_pcMailBuff =
+ __stringAppend(&pxemail->XEMAIL_pcMailBuff, "; Name=\"");
+ pxemail->XEMAIL_pcMailBuff =
+ __stringAppend(&pxemail->XEMAIL_pcMailBuff,
+ pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_pcFileName);
+ pxemail->XEMAIL_pcMailBuff =
+ __stringAppend(&pxemail->XEMAIL_pcMailBuff, "\""
+ XEMAIL_NEWLINE "Content-Transfer-Encoding: base64"
+ XEMAIL_NEWLINE XEMAIL_NEWLINE);
+ pxemail->XEMAIL_iMailBuffLen = strlen(pxemail->XEMAIL_pcMailBuff);
}
} else {
size_t n = 0;
@@ -841,23 +841,23 @@ static size_t __GetEmailContent (PVOID pvPtr, size_t stSize, size_t stBlock, P
unsigned char igroup[3] = {0, 0, 0};
unsigned char ogroup[4];
- pzemail->ZEMAIL_iMailBuffLen = 0;
- if ((pzemail->ZEMAIL_pcMailBuff =
- (char*)malloc(ZEMAIL_MIME_LINE_WIDTH + ZEMAIL_NEWLINE_LEN + 1)) ==
+ pxemail->XEMAIL_iMailBuffLen = 0;
+ if ((pxemail->XEMAIL_pcMailBuff =
+ (char*)malloc(XEMAIL_MIME_LINE_WIDTH + XEMAIL_NEWLINE_LEN + 1)) ==
NULL) {
n = 0;
} else {
- while (mimelinepos < ZEMAIL_MIME_LINE_WIDTH &&
- (n = pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_read
- (pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_pvHandle,
+ while (mimelinepos < XEMAIL_MIME_LINE_WIDTH &&
+ (n = pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_read
+ (pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_pvHandle,
igroup, 3)) > 0) {
/*
* code data
*/
- ogroup[0] = pzemail->ZEMAIL_cDtable[igroup[0] >> 2];
- ogroup[1] = pzemail->ZEMAIL_cDtable[((igroup[0] & 3) << 4) | (igroup[1] >> 4)];
- ogroup[2] = pzemail->ZEMAIL_cDtable[((igroup[1] & 0xF) << 2) | (igroup[2] >> 6)];
- ogroup[3] = pzemail->ZEMAIL_cDtable[igroup[2] & 0x3F];
+ ogroup[0] = pxemail->XEMAIL_cDtable[igroup[0] >> 2];
+ ogroup[1] = pxemail->XEMAIL_cDtable[((igroup[0] & 3) << 4) | (igroup[1] >> 4)];
+ ogroup[2] = pxemail->XEMAIL_cDtable[((igroup[1] & 0xF) << 2) | (igroup[2] >> 6)];
+ ogroup[3] = pxemail->XEMAIL_cDtable[igroup[2] & 0x3F];
/*
* padd with "=" characters if less than 3 characters were read
*/
@@ -867,75 +867,75 @@ static size_t __GetEmailContent (PVOID pvPtr, size_t stSize, size_t stBlock, P
ogroup[2] = '=';
}
- memcpy(pzemail->ZEMAIL_pcMailBuff + mimelinepos, ogroup, 4);
- pzemail->ZEMAIL_iMailBuffLen += 4;
+ memcpy(pxemail->XEMAIL_pcMailBuff + mimelinepos, ogroup, 4);
+ pxemail->XEMAIL_iMailBuffLen += 4;
mimelinepos += 4;
}
if (mimelinepos > 0) {
- memcpy(pzemail->ZEMAIL_pcMailBuff + mimelinepos, ZEMAIL_NEWLINE, ZEMAIL_NEWLINE_LEN);
- pzemail->ZEMAIL_iMailBuffLen += ZEMAIL_NEWLINE_LEN;
+ memcpy(pxemail->XEMAIL_pcMailBuff + mimelinepos, XEMAIL_NEWLINE, XEMAIL_NEWLINE_LEN);
+ pxemail->XEMAIL_iMailBuffLen += XEMAIL_NEWLINE_LEN;
}
}
if (n <= 0) {
/*
* end of file
*/
- if (pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_close) {
- pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_close
- (pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_pvHandle);
+ if (pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_close) {
+ pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_close
+ (pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_pvHandle);
} else {
- ZEMAIL_SAFTFREE(pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_pvHandle);
+ XEMAIL_SAFTFREE(pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_pvHandle);
}
- pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_pvHandle = NULL;
- pzemail->ZEMAIL_plineHeaderCurrAttach =
- pzemail->ZEMAIL_plineHeaderCurrAttach->ZEMAILATTACH_next;
+ pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_pvHandle = NULL;
+ pxemail->XEMAIL_plineHeaderCurrAttach =
+ pxemail->XEMAIL_plineHeaderCurrAttach->XEMAILATTACH_next;
}
}
} else {
- pzemail->ZEMAIL_state++;
+ pxemail->XEMAIL_state++;
}
}
- if ((!pzemail->ZEMAIL_iMailBuffLen) && pzemail->ZEMAIL_state == ZEMAIL_END) {
- pzemail->ZEMAIL_pcMailBuff = NULL;
- pzemail->ZEMAIL_iMailBuffLen = 0;
- if (pzemail->ZEMAIL_pcMimeBoundaryPart) {
- pzemail->ZEMAIL_pcMailBuff = __stringAppend(&pzemail->ZEMAIL_pcMailBuff, ZEMAIL_NEWLINE "--");
- pzemail->ZEMAIL_pcMailBuff = __stringAppend(&pzemail->ZEMAIL_pcMailBuff, pzemail->ZEMAIL_pcMimeBoundaryPart);
- pzemail->ZEMAIL_pcMailBuff = __stringAppend(&pzemail->ZEMAIL_pcMailBuff, "--" ZEMAIL_NEWLINE);
- pzemail->ZEMAIL_iMailBuffLen = strlen(pzemail->ZEMAIL_pcMailBuff);
- ZEMAIL_SAFTFREE(pzemail->ZEMAIL_pcMimeBoundaryPart);
- pzemail->ZEMAIL_pcMimeBoundaryPart = NULL;
+ if ((!pxemail->XEMAIL_iMailBuffLen) && pxemail->XEMAIL_state == XEMAIL_END) {
+ pxemail->XEMAIL_pcMailBuff = NULL;
+ pxemail->XEMAIL_iMailBuffLen = 0;
+ if (pxemail->XEMAIL_pcMimeBoundaryPart) {
+ pxemail->XEMAIL_pcMailBuff = __stringAppend(&pxemail->XEMAIL_pcMailBuff, XEMAIL_NEWLINE "--");
+ pxemail->XEMAIL_pcMailBuff = __stringAppend(&pxemail->XEMAIL_pcMailBuff, pxemail->XEMAIL_pcMimeBoundaryPart);
+ pxemail->XEMAIL_pcMailBuff = __stringAppend(&pxemail->XEMAIL_pcMailBuff, "--" XEMAIL_NEWLINE);
+ pxemail->XEMAIL_iMailBuffLen = strlen(pxemail->XEMAIL_pcMailBuff);
+ XEMAIL_SAFTFREE(pxemail->XEMAIL_pcMimeBoundaryPart);
+ pxemail->XEMAIL_pcMimeBoundaryPart = NULL;
}
- pzemail->ZEMAIL_state++;
+ pxemail->XEMAIL_state++;
}
- if ((!pzemail->ZEMAIL_iMailBuffLen) && pzemail->ZEMAIL_state == ZEMAIL_DONE) {
+ if ((!pxemail->XEMAIL_iMailBuffLen) && pxemail->XEMAIL_state == XEMAIL_DONE) {
break;
}
}
- if (pzemail->ZEMAIL_iMailBuffLen > 0) {
- INT iLen = (pzemail->ZEMAIL_iMailBuffLen >= stSize * stBlock) ?
- (stSize * stBlock) : pzemail->ZEMAIL_iMailBuffLen;
+ if (pxemail->XEMAIL_iMailBuffLen > 0) {
+ INT iLen = (pxemail->XEMAIL_iMailBuffLen >= stSize * stBlock) ?
+ (stSize * stBlock) : pxemail->XEMAIL_iMailBuffLen;
- memcpy(pvPtr, pzemail->ZEMAIL_pcMailBuff, iLen);
+ memcpy(pvPtr, pxemail->XEMAIL_pcMailBuff, iLen);
- if (iLen < pzemail->ZEMAIL_iMailBuffLen) {
- pzemail->ZEMAIL_pcMailBuff = memmove(pzemail->ZEMAIL_pcMailBuff,
- pzemail->ZEMAIL_pcMailBuff + iLen,
- pzemail->ZEMAIL_iMailBuffLen - iLen);
- pzemail->ZEMAIL_iMailBuffLen -= iLen;
+ if (iLen < pxemail->XEMAIL_iMailBuffLen) {
+ pxemail->XEMAIL_pcMailBuff = memmove(pxemail->XEMAIL_pcMailBuff,
+ pxemail->XEMAIL_pcMailBuff + iLen,
+ pxemail->XEMAIL_iMailBuffLen - iLen);
+ pxemail->XEMAIL_iMailBuffLen -= iLen;
} else {
- ZEMAIL_SAFTFREE(pzemail->ZEMAIL_pcMailBuff);
- pzemail->ZEMAIL_pcMailBuff = LW_NULL;
- pzemail->ZEMAIL_iMailBuffLen = 0;
+ XEMAIL_SAFTFREE(pxemail->XEMAIL_pcMailBuff);
+ pxemail->XEMAIL_pcMailBuff = LW_NULL;
+ pxemail->XEMAIL_iMailBuffLen = 0;
}
return (iLen);
}
- pzemail->ZEMAIL_state = ZEMAIL_INIT;
+ pxemail->XEMAIL_state = XEMAIL_INIT;
return (0);
}
/*********************************************************************************************************
@@ -947,12 +947,12 @@ static size_t __GetEmailContent (PVOID pvPtr, size_t stSize, size_t stBlock, P
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static VOID __attachmentDelFile (PZEMAILATTACH *plistlineHeader, PCHAR pcPath)
+static VOID __attachmentDelFile (PXEMAILATTACH *plistlineHeader, PCHAR pcPath)
{
PCHAR pcBasename;
pcBasename = basename(pcPath);
- ZEMAIL_DBG("basename:%s\n", pcBasename);
+ XEMAIL_DBG("basename:%s\n", pcBasename);
__attachmentListDel(plistlineHeader, pcBasename);
}
@@ -982,7 +982,7 @@ static PCHAR __stringAddAngleBrackets (PCHAR pcStr)
return (pcResult);
}
/*********************************************************************************************************
-** 函数名称: __zemailAppendInfoToCurl
+** 函数名称: __xemailAppendInfoToCurl
** 功能描述: email 添加附件
** 输 入 : plineHeader : 链头
** pprecpt : CURL 链
@@ -990,21 +990,21 @@ static PCHAR __stringAddAngleBrackets (PCHAR pcStr)
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static VOID __zemailAppendInfoToCurl (PZEMAILINFO *plineHeader,
+static VOID __xemailAppendInfoToCurl (PXEMAILINFO *plineHeader,
struct curl_slist **pprecpt)
{
- PZEMAILINFO pzemailinfo = *plineHeader;
- PZEMAILINFO q;
+ PXEMAILINFO pxemailinfo = *plineHeader;
+ PXEMAILINFO q;
PCHAR pcAddr;
- while (pzemailinfo) {
- q = pzemailinfo;
- pzemailinfo = pzemailinfo->ZEMAILINFO_next;
+ while (pxemailinfo) {
+ q = pxemailinfo;
+ pxemailinfo = pxemailinfo->XEMAILINFO_next;
- if (q->ZEMAILINFO_pcData) {
- pcAddr = __stringAddAngleBrackets(q->ZEMAILINFO_pcData);
+ if (q->XEMAILINFO_pcData) {
+ pcAddr = __stringAddAngleBrackets(q->XEMAILINFO_pcData);
*pprecpt = curl_slist_append(*pprecpt, pcAddr);
- ZEMAIL_SAFTFREE(pcAddr);
+ XEMAIL_SAFTFREE(pcAddr);
}
}
}
@@ -1014,209 +1014,209 @@ static VOID __zemailAppendInfoToCurl (PZEMAILINFO *plineHeader,
/*********************************************************************************************************
** 函数名称: xemailSetFrom
** 功能描述: email 添加附件
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailSetFrom (PZEMAIL pzemail, PCHAR pcFrom)
+VOID xemailSetFrom (PXEMAIL pxemail, PCHAR pcFrom)
{
- ZEMAIL_SAFTFREE(pzemail->ZEMAIL_pcFrom);
- pzemail->ZEMAIL_pcFrom = pcFrom ? strdup(pcFrom) : LW_NULL;
+ XEMAIL_SAFTFREE(pxemail->XEMAIL_pcFrom);
+ pxemail->XEMAIL_pcFrom = pcFrom ? strdup(pcFrom) : LW_NULL;
}
/*********************************************************************************************************
** 函数名称: xemailGetFrom
** 功能描述: email 添加附件
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-PCHAR xemailGetFrom (PZEMAIL pzemail)
+PCHAR xemailGetFrom (PXEMAIL pxemail)
{
- if (!pzemail) {
+ if (!pxemail) {
return (LW_NULL);
}
- return (pzemail->ZEMAIL_pcFrom);
+ return (pxemail->XEMAIL_pcFrom);
}
/*********************************************************************************************************
** 函数名称: xemailAddBCC
** 功能描述: email 增加隐秘抄送者 (BCC: )
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailAddBCC (PZEMAIL pzemail, PCHAR pcBCC)
+VOID xemailAddBCC (PXEMAIL pxemail, PCHAR pcBCC)
{
- __zemailInfoListAdd(&pzemail->ZEMAIL_plineHeaderbcc, pcBCC);
+ __xemailInfoListAdd(&pxemail->XEMAIL_plineHeaderbcc, pcBCC);
}
/*********************************************************************************************************
** 函数名称: xemailAddCC
** 功能描述: email 增加抄送者 (CC: )
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailAddCC (PZEMAIL pzemail, PCHAR pcCC)
+VOID xemailAddCC (PXEMAIL pxemail, PCHAR pcCC)
{
- __zemailInfoListAdd(&pzemail->ZEMAIL_plineHeadercc, pcCC);
+ __xemailInfoListAdd(&pxemail->XEMAIL_plineHeadercc, pcCC);
}
/*********************************************************************************************************
** 函数名称: xemailAddTO
** 功能描述: email 增加接收者 (TO: )
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** pcTo : 接收者字符串
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailAddTO (PZEMAIL pzemail, PCHAR pcTo)
+VOID xemailAddTO (PXEMAIL pxemail, PCHAR pcTo)
{
- __zemailInfoListAdd(&pzemail->ZEMAIL_plineHeaderto, pcTo);
+ __xemailInfoListAdd(&pxemail->XEMAIL_plineHeaderto, pcTo);
}
/*********************************************************************************************************
** 函数名称: xemailSetSubject
** 功能描述: email 添加附件
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailSetSubject (PZEMAIL pzemail, PCHAR pcSubject)
+VOID xemailSetSubject (PXEMAIL pxemail, PCHAR pcSubject)
{
- ZEMAIL_SAFTFREE(pzemail->ZEMAIL_pcSubject);
- pzemail->ZEMAIL_pcSubject = pcSubject ? strdup(pcSubject) : LW_NULL;
+ XEMAIL_SAFTFREE(pxemail->XEMAIL_pcSubject);
+ pxemail->XEMAIL_pcSubject = pcSubject ? strdup(pcSubject) : LW_NULL;
}
/*********************************************************************************************************
** 函数名称: xemailGetSubject
** 功能描述: email 添加附件
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-PCHAR xemailGetSubject (PZEMAIL pzemail)
+PCHAR xemailGetSubject (PXEMAIL pxemail)
{
- if (!pzemail) {
+ if (!pxemail) {
return (LW_NULL);
}
- return (pzemail->ZEMAIL_pcSubject);
+ return (pxemail->XEMAIL_pcSubject);
}
/*********************************************************************************************************
** 函数名称: xemailAddHeader
** 功能描述: email 添加附件
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailAddHeader (PZEMAIL pzemail, PCHAR pcHeader)
+VOID xemailAddHeader (PXEMAIL pxemail, PCHAR pcHeader)
{
- if (!pzemail) {
+ if (!pxemail) {
return;
}
- __stringAppend(&pzemail->ZEMAIL_pcHeader, pcHeader);
- __stringAppend(&pzemail->ZEMAIL_pcHeader, ZEMAIL_NEWLINE);
+ __stringAppend(&pxemail->XEMAIL_pcHeader, pcHeader);
+ __stringAppend(&pxemail->XEMAIL_pcHeader, XEMAIL_NEWLINE);
}
/*********************************************************************************************************
** 函数名称: xemailSetMailBody
** 功能描述: email 添加附件
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailSetMailBody (PZEMAIL pzemail, PCHAR pcBody)
+VOID xemailSetMailBody (PXEMAIL pxemail, PCHAR pcBody)
{
- if (!pzemail) {
+ if (!pxemail) {
return;
}
- if (pzemail->ZEMAIL_plineHeaderBody) {
- __attachmentListDel(&pzemail->ZEMAIL_plineHeaderBody, LW_NULL);
+ if (pxemail->XEMAIL_plineHeaderBody) {
+ __attachmentListDel(&pxemail->XEMAIL_plineHeaderBody, LW_NULL);
}
if (pcBody) {
- __mailAddTextBody(&pzemail->ZEMAIL_plineHeaderBody,
- ZEMAIL_DEFAULT_MIME_TYPE,
- ZEMAIL_DEFAULT_MIME_TYPE,
+ __mailAddTextBody(&pxemail->XEMAIL_plineHeaderBody,
+ XEMAIL_DEFAULT_MIME_TYPE,
+ XEMAIL_DEFAULT_MIME_TYPE,
(PVOID)strdup(pcBody), strlen(pcBody), 1);
}
}
/*********************************************************************************************************
** 函数名称: xemailAddMailBodyByType
** 功能描述: 设置指定类型的邮件内容(如: "text/html" 类型的内容)
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailAddMailBodyByType (PZEMAIL pzemail,
+VOID xemailAddMailBodyByType (PXEMAIL pxemail,
PCHAR pcMimeType,
PCHAR pcData,
size_t stLen,
INT iMustFree)
{
- __mailAddTextBody(&pzemail->ZEMAIL_plineHeaderBody,
- (pcMimeType ? pcMimeType : ZEMAIL_DEFAULT_MIME_TYPE),
- (pcMimeType ? pcMimeType : ZEMAIL_DEFAULT_MIME_TYPE),
+ __mailAddTextBody(&pxemail->XEMAIL_plineHeaderBody,
+ (pcMimeType ? pcMimeType : XEMAIL_DEFAULT_MIME_TYPE),
+ (pcMimeType ? pcMimeType : XEMAIL_DEFAULT_MIME_TYPE),
(PVOID)strdup(pcData), stLen, iMustFree);
}
/*********************************************************************************************************
** 函数名称: xemailAddAttachmentFile
** 功能描述: email 添加附件
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailAddAttachmentFile (PZEMAIL pzemail, PCHAR pcPath, PCHAR pcMime)
+VOID xemailAddAttachmentFile (PXEMAIL pxemail, PCHAR pcPath, PCHAR pcMime)
{
- __attachmentAddFile(&pzemail->ZEMAIL_plineHeaderAttach, pcPath, pcMime);
+ __attachmentAddFile(&pxemail->XEMAIL_plineHeaderAttach, pcPath, pcMime);
}
/*********************************************************************************************************
** 函数名称: xemailDelAttachmentFile
** 功能描述: email 添加附件
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailDelAttachmentFile (PZEMAIL pzemail, PCHAR pcPath)
+VOID xemailDelAttachmentFile (PXEMAIL pxemail, PCHAR pcPath)
{
- __attachmentDelFile(&pzemail->ZEMAIL_plineHeaderAttach, pcPath);
+ __attachmentDelFile(&pxemail->XEMAIL_plineHeaderAttach, pcPath);
}
/*********************************************************************************************************
** 函数名称: xemailDestroy
** 功能描述: email 销毁主函数
-** 输 入 : pzemail : email 结构
+** 输 入 : pxemail : email 结构
** 输 出 : 错误号
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailDestroy (PZEMAIL pzemail)
+VOID xemailDestroy (PXEMAIL pxemail)
{
- if (!pzemail) {
+ if (!pxemail) {
return;
}
- ZEMAIL_SAFTFREE(pzemail->ZEMAIL_pcFrom);
- __zemailInfoListDel(&pzemail->ZEMAIL_plineHeaderto, LW_NULL);
- __zemailInfoListDel(&pzemail->ZEMAIL_plineHeadercc, LW_NULL);
- __zemailInfoListDel(&pzemail->ZEMAIL_plineHeaderbcc, LW_NULL);
- ZEMAIL_SAFTFREE(pzemail->ZEMAIL_pcSubject);
- ZEMAIL_SAFTFREE(pzemail->ZEMAIL_pcHeader);
- __attachmentListDel(&pzemail->ZEMAIL_plineHeaderBody, LW_NULL);
- __attachmentListDel(&pzemail->ZEMAIL_plineHeaderAttach, LW_NULL);
- ZEMAIL_SAFTFREE(pzemail->ZEMAIL_pcMailBuff);
- ZEMAIL_SAFTFREE(pzemail->ZEMAIL_pcMimeBoundaryPart);
- ZEMAIL_SAFTFREE(pzemail->ZEMAIL_pcMimeBoundaryBody);
- ZEMAIL_SAFTFREE(pzemail);
+ XEMAIL_SAFTFREE(pxemail->XEMAIL_pcFrom);
+ __xemailInfoListDel(&pxemail->XEMAIL_plineHeaderto, LW_NULL);
+ __xemailInfoListDel(&pxemail->XEMAIL_plineHeadercc, LW_NULL);
+ __xemailInfoListDel(&pxemail->XEMAIL_plineHeaderbcc, LW_NULL);
+ XEMAIL_SAFTFREE(pxemail->XEMAIL_pcSubject);
+ XEMAIL_SAFTFREE(pxemail->XEMAIL_pcHeader);
+ __attachmentListDel(&pxemail->XEMAIL_plineHeaderBody, LW_NULL);
+ __attachmentListDel(&pxemail->XEMAIL_plineHeaderAttach, LW_NULL);
+ XEMAIL_SAFTFREE(pxemail->XEMAIL_pcMailBuff);
+ XEMAIL_SAFTFREE(pxemail->XEMAIL_pcMimeBoundaryPart);
+ XEMAIL_SAFTFREE(pxemail->XEMAIL_pcMimeBoundaryBody);
+ XEMAIL_SAFTFREE(pxemail);
}
/*********************************************************************************************************
** 函数名称: xemailCreate
@@ -1227,54 +1227,54 @@ VOID xemailDestroy (PZEMAIL pzemail)
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-PZEMAIL xemailCreate (PCHAR pcFrom, PCHAR pcSubject)
+PXEMAIL xemailCreate (PCHAR pcFrom, PCHAR pcSubject)
{
- PZEMAIL pzemail;
+ PXEMAIL pxemail;
INT i;
- pzemail = (PZEMAIL)malloc(sizeof(ZEMAIL));
- if (!pzemail) {
- ZEMAIL_ERR("Z-email alloc memory failed.\n");
+ pxemail = (PXEMAIL)malloc(sizeof(XEMAIL));
+ if (!pxemail) {
+ XEMAIL_ERR("x-email alloc memory failed.\n");
return (LW_NULL);
}
- pzemail->ZEMAIL_state = ZEMAIL_INIT;
- pzemail->ZEMAIL_tTimestamp = time(LW_NULL);
- pzemail->ZEMAIL_pcFrom = pcFrom ? strdup(pcFrom) : LW_NULL;
- pzemail->ZEMAIL_pcSubject = pcSubject ? strdup(pcSubject) : LW_NULL;
- pzemail->ZEMAIL_plineHeaderto = LW_NULL;
- pzemail->ZEMAIL_plineHeadercc = LW_NULL;
- pzemail->ZEMAIL_plineHeaderbcc = LW_NULL;
- pzemail->ZEMAIL_plineHeaderCurrAttach = LW_NULL;
- pzemail->ZEMAIL_plineHeaderBody = LW_NULL;
- pzemail->ZEMAIL_plineHeaderAttach = LW_NULL;
- pzemail->ZEMAIL_pcMailBuff = LW_NULL;
- pzemail->ZEMAIL_iMailBuffLen = 0;
- pzemail->ZEMAIL_pcMimeBoundaryBody = LW_NULL;
- pzemail->ZEMAIL_pcMimeBoundaryPart = LW_NULL;
- pzemail->ZEMAIL_pcHeader = LW_NULL;
- pzemail->ZEMAIL_fp = LW_NULL;
+ pxemail->XEMAIL_state = XEMAIL_INIT;
+ pxemail->XEMAIL_tTimestamp = time(LW_NULL);
+ pxemail->XEMAIL_pcFrom = pcFrom ? strdup(pcFrom) : LW_NULL;
+ pxemail->XEMAIL_pcSubject = pcSubject ? strdup(pcSubject) : LW_NULL;
+ pxemail->XEMAIL_plineHeaderto = LW_NULL;
+ pxemail->XEMAIL_plineHeadercc = LW_NULL;
+ pxemail->XEMAIL_plineHeaderbcc = LW_NULL;
+ pxemail->XEMAIL_plineHeaderCurrAttach = LW_NULL;
+ pxemail->XEMAIL_plineHeaderBody = LW_NULL;
+ pxemail->XEMAIL_plineHeaderAttach = LW_NULL;
+ pxemail->XEMAIL_pcMailBuff = LW_NULL;
+ pxemail->XEMAIL_iMailBuffLen = 0;
+ pxemail->XEMAIL_pcMimeBoundaryBody = LW_NULL;
+ pxemail->XEMAIL_pcMimeBoundaryPart = LW_NULL;
+ pxemail->XEMAIL_pcHeader = LW_NULL;
+ pxemail->XEMAIL_fp = LW_NULL;
for (i = 0; i < 26; i++) {
- pzemail->ZEMAIL_cDtable[i] = 'A' + i;
- pzemail->ZEMAIL_cDtable[i + 26] = 'a' + i;
+ pxemail->XEMAIL_cDtable[i] = 'A' + i;
+ pxemail->XEMAIL_cDtable[i + 26] = 'a' + i;
}
for (i = 0; i < 10; i++) {
- pzemail->ZEMAIL_cDtable[52 + i] = '0' + i;
+ pxemail->XEMAIL_cDtable[52 + i] = '0' + i;
}
- pzemail->ZEMAIL_cDtable[62] = '+';
- pzemail->ZEMAIL_cDtable[63] = '/';
+ pxemail->XEMAIL_cDtable[62] = '+';
+ pxemail->XEMAIL_cDtable[63] = '/';
srand(time(LW_NULL));
- return (pzemail);
+ return (pxemail);
}
/*********************************************************************************************************
** 函数名称: xemailSend
** 功能描述: email 发送主函数
-** 输 入 : pzemail : EMAIL 主结构
+** 输 入 : pxemail : EMAIL 主结构
** pcSmtpServer : smtp server
** pcUserName : 用户名
** pcPassword : 密码
@@ -1282,7 +1282,7 @@ PZEMAIL xemailCreate (PCHAR pcFrom, PCHAR pcSubject)
** 全局变量:
** 调用模块: CURL 库
*********************************************************************************************************/
-INT xemailSend (PZEMAIL pzemail, PCHAR pcSmtpServer, PCHAR pcUserName, PCHAR pcPassword)
+INT xemailSend (PXEMAIL pxemail, PCHAR pcSmtpServer, PCHAR pcUserName, PCHAR pcPassword)
{
CURL *curl;
CURLcode result = CURLE_FAILED_INIT;
@@ -1300,12 +1300,12 @@ INT xemailSend (PZEMAIL pzemail, PCHAR pcSmtpServer, PCHAR pcUserName, PCHAR
snprintf(pcAddr, iLen, "smtp://%s", pcSmtpServer);
curl_easy_setopt(curl, CURLOPT_URL, pcAddr);
- ZEMAIL_SAFTFREE(pcAddr);
+ XEMAIL_SAFTFREE(pcAddr);
- if (pzemail->ZEMAIL_pcFrom) {
- pcAddr = __stringAddAngleBrackets(pzemail->ZEMAIL_pcFrom);
+ if (pxemail->XEMAIL_pcFrom) {
+ pcAddr = __stringAddAngleBrackets(pxemail->XEMAIL_pcFrom);
curl_easy_setopt(curl, CURLOPT_MAIL_FROM, pcAddr);
- ZEMAIL_SAFTFREE(pcAddr);
+ XEMAIL_SAFTFREE(pcAddr);
}
if (pcUserName) {
@@ -1316,18 +1316,18 @@ INT xemailSend (PZEMAIL pzemail, PCHAR pcSmtpServer, PCHAR pcUserName, PCHAR
curl_easy_setopt(curl, CURLOPT_PASSWORD, pcPassword);
}
- __zemailAppendInfoToCurl(&pzemail->ZEMAIL_plineHeaderto, &recipients);
- __zemailAppendInfoToCurl(&pzemail->ZEMAIL_plineHeadercc, &recipients);
- __zemailAppendInfoToCurl(&pzemail->ZEMAIL_plineHeaderbcc, &recipients);
+ __xemailAppendInfoToCurl(&pxemail->XEMAIL_plineHeaderto, &recipients);
+ __xemailAppendInfoToCurl(&pxemail->XEMAIL_plineHeadercc, &recipients);
+ __xemailAppendInfoToCurl(&pxemail->XEMAIL_plineHeaderbcc, &recipients);
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, __GetEmailContent);
- curl_easy_setopt(curl, CURLOPT_READDATA, pzemail);
+ curl_easy_setopt(curl, CURLOPT_READDATA, pxemail);
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
- if (pzemail->ZEMAIL_fp) {
+ if (pxemail->XEMAIL_fp) {
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
- curl_easy_setopt(curl, CURLOPT_STDERR, pzemail->ZEMAIL_fp);
+ curl_easy_setopt(curl, CURLOPT_STDERR, pxemail->XEMAIL_fp);
}
result = curl_easy_perform(curl);
@@ -1340,23 +1340,23 @@ INT xemailSend (PZEMAIL pzemail, PCHAR pcSmtpServer, PCHAR pcUserName, PCHAR
/*********************************************************************************************************
** 函数名称: xemailDebugMode
** 功能描述: 开启 DEBUG 模式
-** 输 入 : pzemail : EMAIL 结构
+** 输 入 : pxemail : EMAIL 结构
** fp : log 输出文件
** 输 出 : 版本
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-VOID xemailDebugMode (PZEMAIL pzemail, FILE *fp)
+VOID xemailDebugMode (PXEMAIL pxemail, FILE *fp)
{
- if (!pzemail) {
+ if (!pxemail) {
return;
}
- pzemail->ZEMAIL_fp = fp;
+ pxemail->XEMAIL_fp = fp;
}
/*********************************************************************************************************
** 函数名称: xemailVersion
-** 功能描述: 获得 Z-email 版本
+** 功能描述: 获得 xemail 版本
** 输 入 : NONE
** 输 出 : 版本
** 全局变量:
@@ -1364,7 +1364,7 @@ VOID xemailDebugMode (PZEMAIL pzemail, FILE *fp)
*********************************************************************************************************/
PCHAR xemailVersion (VOID)
{
- return (ZEMAIL_VERSION);
+ return (XEMAIL_VERSION);
}
/*********************************************************************************************************
END