#ifdef USE_SASL_AUTH
#include <sasl.h>
#include <saslutil.h>
#endif
#include <vstream.h>
#include <vstring.h>
#include <argv.h>
#include <deliver_request.h>
typedef struct LMTP_STATE {
VSTREAM *src;
DELIVER_REQUEST *request;
struct LMTP_SESSION *session;
VSTRING *buffer;
VSTRING *scratch;
VSTRING *scratch2;
int status;
int features;
ARGV *history;
int error_mask;
#ifdef USE_SASL_AUTH
char *sasl_mechanism_list;
char *sasl_username;
char *sasl_passwd;
sasl_conn_t *sasl_conn;
VSTRING *sasl_encoded;
VSTRING *sasl_decoded;
sasl_callback_t *sasl_callbacks;
#endif
int sndbufsize;
int reuse;
} LMTP_STATE;
#define LMTP_FEATURE_ESMTP (1<<0)
#define LMTP_FEATURE_8BITMIME (1<<1)
#define LMTP_FEATURE_PIPELINING (1<<2)
#define LMTP_FEATURE_SIZE (1<<3)
#define LMTP_FEATURE_AUTH (1<<5)
#define LMTP_FEATURE_XFORWARD_NAME (1<<6)
#define LMTP_FEATURE_XFORWARD_ADDR (1<<7)
#define LMTP_FEATURE_XFORWARD_PROTO (1<<8)
#define LMTP_FEATURE_XFORWARD_HELO (1<<9)
extern int lmtp_errno;
typedef struct LMTP_SESSION {
VSTREAM *stream;
char *host;
char *addr;
char *namaddr;
char *dest;
} LMTP_SESSION;
extern LMTP_SESSION *lmtp_session_alloc(VSTREAM *, const char *, const char *, const char *);
extern LMTP_SESSION *lmtp_session_free(LMTP_SESSION *);
extern LMTP_SESSION *lmtp_connect(const char *, VSTRING *);
extern int lmtp_lhlo(LMTP_STATE *);
extern int lmtp_xfer(LMTP_STATE *);
extern int lmtp_quit(LMTP_STATE *);
extern int lmtp_rset(LMTP_STATE *);
typedef struct LMTP_RESP {
int code;
char *str;
VSTRING *buf;
} LMTP_RESP;
extern void PRINTFLIKE(2, 3) lmtp_chat_cmd(LMTP_STATE *, char *,...);
extern LMTP_RESP *lmtp_chat_resp(LMTP_STATE *);
extern void lmtp_chat_reset(LMTP_STATE *);
extern void lmtp_chat_notify(LMTP_STATE *);
extern int PRINTFLIKE(3, 4) lmtp_conn_fail(LMTP_STATE *, int, char *,...);
extern int PRINTFLIKE(3, 4) lmtp_site_fail(LMTP_STATE *, int, char *,...);
extern int PRINTFLIKE(3, 4) lmtp_mesg_fail(LMTP_STATE *, int, char *,...);
extern void PRINTFLIKE(4, 5) lmtp_rcpt_fail(LMTP_STATE *, int, RECIPIENT *, char *,...);
extern int lmtp_stream_except(LMTP_STATE *, int, char *);
extern LMTP_STATE *lmtp_state_alloc(void);
extern void lmtp_state_free(LMTP_STATE *);
#define LMTP_OK 0
#define LMTP_RETRY (-1)
#define LMTP_FAIL (-2)