*** /dev/null Sat Nov 23 01:07:12 2024
--- - Sat Nov 23 01:07:15 2024
***************
*** 0 ****
--- 1,52 ----
+ #ifndef __LMTP_H__
+ #define __LMTP_H__
+
+ #include <sys/types.h>
+ #include <sys/uio.h>
+ #include <unistd.h>
+ #include <fcntl.h>
+
+ struct lmtp_st;
+ typedef struct lmtp_st lmtp_t;
+
+ typedef struct {
+ int (*select)(int nfds, fd_set *rfds, fd_set *wrfds, fd_set *efds, struct timeval *t);
+ ssize_t (*read) (int fd, void *buf, size_t nbytes);
+ ssize_t (*write) (int fd, const void *buf, size_t nbytes);
+ } lmtp_io_t;
+
+ typedef struct {
+ char *verb;
+ char *msg;
+ } lmtp_req_t;
+
+ typedef struct {
+ int rc;
+ char *dsn;
+ char *msg;
+ } lmtp_res_t;
+
+ typedef enum {
+ LMTP_OK,
+ LMTP_ERR_SYSTEM, /* see errno */
+ LMTP_ERR_INVALID_VERB
+ } lmtp_rc_t;
+
+ typedef enum {
+ LMTP_TYPE_SINGLELINE,
+ LMTP_TYPE_MULTILINE
+ } lmtp_type_t;
+
+ typedef lmtp_rc_t (*lmtp_cb_t)(lmtp_io_t *io, lmtp_req_t *req, lmtp_res_t *res, void *ctx);
+
+ lmtp_t *lmtp_create (int rfd, int wfd, lmtp_io_t *io);
+ void lmtp_destroy (lmtp_t *lmtp);
+ lmtp_rc_t lmtp_request (lmtp_t *lmtp, lmtp_req_t *req);
+ lmtp_rc_t lmtp_result (lmtp_t *lmtp, lmtp_res_t *res);
+ char **lmtp_message (lmtp_t *lmtp, char *verb);
+ void lmtp_reset (lmtp_t *lmtp);
+ char *lmtp_error (lmtp_t *lmtp, lmtp_rc_t rc);
+ lmtp_cb_t lmtp_register(lmtp_t *lmtp, char *verb, lmtp_type_t type, lmtp_cb_t *cb, void *ctx);
+ lmtp_rc_t lmtp_loop (lmtp_t *lmtp);
+
+ #endif /* __LMTP_H__ */
|