acl/lib_protocol/include/smtp/smtp_client.h

207 lines
7.7 KiB
C
Raw Normal View History

#ifndef __SMTP_CLIENT_INCLUDE_H__
2014-11-19 00:25:21 +08:00
#define __SMTP_CLIENT_INCLUDE_H__
/* #include "lib_acl.h" */
2014-11-19 00:25:21 +08:00
#ifdef __cplusplus
extern "C" {
#endif
#ifdef SMTP_LIB
# ifndef SMTP_API
# define SMTP_API
# endif
#elif defined(SMTP_DLL) || defined(_WINDLL)
# if defined(SMTP_EXPORTS) || defined(protocol_EXPORTS)
# ifndef SMTP_API
# define SMTP_API __declspec(dllexport)
# endif
# elif !defined(SMTP_API)
2014-11-19 00:25:21 +08:00
# define SMTP_API __declspec(dllimport)
# endif
#elif !defined(SMTP_API)
# define SMTP_API
2014-11-19 00:25:21 +08:00
#endif
typedef struct SMTP_CLIENT {
ACL_VSTREAM *conn;
int smtp_code;
char* buf;
int size;
unsigned int flag;
#define SMTP_FLAG_PIPELINING (1 << 0)
#define SMTP_FLAG_AUTH (1 << 1)
#define SMTP_FLAG_8BITMIME (1 << 2)
#define SMTP_FLAG_DSN (1 << 3)
#define SMTP_FLAG_VRFY (1 << 4)
#define SMTP_FLAG_ETRN (1 << 5)
#define SMTP_FLAG_SIZE (1 << 6)
int message_size_limit;
} SMTP_CLIENT;
/**
* SMTP
* @param addr {const char*} SMTP domain:port
* @param conn_timeout {int}
* @param rw_timeout {int} IO读写超时时间
* @param line_limit {int} SMTP
* @return {SMTP_CLIENT*} NULL
2014-11-19 00:25:21 +08:00
*/
SMTP_API SMTP_CLIENT *smtp_open(const char *addr, int conn_timeout,
int rw_timeout, int line_limit);
/**
* smtp_open SMTP
* @param client {SMTP_CLIENT*} SMTP
2014-11-19 00:25:21 +08:00
*/
SMTP_API void smtp_close(SMTP_CLIENT *client);
/**
* SMTP
* @param client {SMTP_CLIENT*} SMTP
* @return {int} 0 (SMTP_CLIENT::smtp_code
* SMTP_CLIENT::buf )
2014-11-19 00:25:21 +08:00
*/
SMTP_API int smtp_get_banner(SMTP_CLIENT *client);
/**
* SMTP HELO/EHLO
* @param client {SMTP_CLIENT*} SMTP
* @param name {const char*}
* @param ehlo {int} 0 使 EHLO使 HELO
* @return {int} 0 (SMTP_CLIENT::smtp_code
* SMTP_CLIENT::buf )
2014-11-19 00:25:21 +08:00
*/
SMTP_API int smtp_greet(SMTP_CLIENT *client, const char* name, int ehlo);
/**
* SMTP HELO
* @param client {SMTP_CLIENT*} SMTP
* @param helo {const char*}
* @return {int} 0 (SMTP_CLIENT::smtp_code
* SMTP_CLIENT::buf )
2014-11-19 00:25:21 +08:00
*/
SMTP_API int smtp_helo(SMTP_CLIENT *client, const char *helo);
/**
* SMTP EHLO
* @param client {SMTP_CLIENT*} SMTP
* @param ehlo {const char*}
* @return {int} 0 (SMTP_CLIENT::smtp_code
* SMTP_CLIENT::buf )
2014-11-19 00:25:21 +08:00
*/
SMTP_API int smtp_ehlo(SMTP_CLIENT *client, const char *ehlo);
/**
* SMTP
* @param client {SMTP_CLIENT*} SMTP
* @param user {const char*} SMTP
* @param pass {const char*} SMTP
* @return {int} 0 (SMTP_CLIENT::smtp_code
* SMTP_CLIENT::buf )
2014-11-19 00:25:21 +08:00
*/
SMTP_API int smtp_auth(SMTP_CLIENT *client, const char *user, const char *pass);
/**
* SMTP MAIL FROM
* @param client {SMTP_CLIENT*} SMTP
* @param from {const char*}
* @return {int} 0 (SMTP_CLIENT::smtp_code
* SMTP_CLIENT::buf )
2014-11-19 00:25:21 +08:00
*/
SMTP_API int smtp_mail(SMTP_CLIENT *client, const char *from);
/**
* SMTP RCPT TO
* @param client {SMTP_CLIENT*} SMTP
* @param to {const char*}
* @return {int} 0 (SMTP_CLIENT::smtp_code
* SMTP_CLIENT::buf )
2014-11-19 00:25:21 +08:00
*/
SMTP_API int smtp_rcpt(SMTP_CLIENT *client, const char *to);
/**
* SMTP DATA
* @param client {SMTP_CLIENT*} SMTP
* @return {int} 0 (SMTP_CLIENT::smtp_code
* SMTP_CLIENT::buf )
2014-11-19 00:25:21 +08:00
*/
SMTP_API int smtp_data(SMTP_CLIENT *client);
/**
* SMTP
* @param client {SMTP_CLIENT*} SMTP
* @param src {const char*} MIME
* @param len {size_t} src
* @return {int} 0 (SMTP_CLIENT::smtp_code
* SMTP_CLIENT::buf )
2014-11-19 00:25:21 +08:00
*/
SMTP_API int smtp_send(SMTP_CLIENT *client, const char* src, size_t len);
/**
* SMTP
* @param client {SMTP_CLIENT*} SMTP
* @param fmt {const char*}
* @param ...
* @return {int} 0 (SMTP_CLIENT::smtp_code
* SMTP_CLIENT::buf )
2014-11-19 00:25:21 +08:00
*/
SMTP_API int smtp_printf(SMTP_CLIENT *client, const char* fmt, ...);
/**
* SMTP
* @param client {SMTP_CLIENT*} SMTP
* @return {int} 0 (SMTP_CLIENT::smtp_code
* SMTP_CLIENT::buf )
2014-11-19 00:25:21 +08:00
*/
SMTP_API int smtp_data_end(SMTP_CLIENT *client);
/**
* SMTP
* @param client {SMTP_CLIENT*} SMTP
* @param filepath {const char*}
* @return {int} 0 (SMTP_CLIENT::smtp_code
* SMTP_CLIENT::buf )
2014-11-19 00:25:21 +08:00
*/
SMTP_API int smtp_send_file(SMTP_CLIENT *client, const char *filepath);
/**
* SMTP
* @param client {SMTP_CLIENT*} SMTP
* @param int {ACL_VSTREAM*}
* @return {int} 0 (SMTP_CLIENT::smtp_code
* SMTP_CLIENT::buf )
2014-11-19 00:25:21 +08:00
*/
SMTP_API int smtp_send_stream(SMTP_CLIENT *client, ACL_VSTREAM *in);
/**
* SMTP 退(QUIT)
* @param client {SMTP_CLIENT*} SMTP
* @return {int} 0 (SMTP_CLIENT::smtp_code
* SMTP_CLIENT::buf )
2014-11-19 00:25:21 +08:00
*/
SMTP_API int smtp_quit(SMTP_CLIENT *client);
/**
* SMTP NOOP
* @param client {SMTP_CLIENT*} SMTP
* @return {int} 0 (SMTP_CLIENT::smtp_code
* SMTP_CLIENT::buf )
2014-11-19 00:25:21 +08:00
*/
SMTP_API int smtp_noop(SMTP_CLIENT *client);
/**
* SMTP RSET
* @param client {SMTP_CLIENT*} SMTP
* @return {int} 0 (SMTP_CLIENT::smtp_code
* SMTP_CLIENT::buf )
2014-11-19 00:25:21 +08:00
*/
SMTP_API int smtp_rset(SMTP_CLIENT *client);
#ifdef __cplusplus
}
#endif
#endif