OSSP CVS Repository

ossp - ossp-pkg/lmtp2nntp/lmtp.h 1.2
Not logged in
[Honeypot]  [Browse]  [Directory]  [Home]  [Login
[Reports]  [Search]  [Ticket]  [Timeline

ossp-pkg/lmtp2nntp/lmtp.h 1.2

#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;         /* verb found */
    char *msg;          /* wholly message including verb */
} lmtp_req_t;

typedef struct {
    char *statuscode;   /* digit digit digit NUL */
    char *dsncode;      /* digit dot digit dot digit NUL */
    char *statusmsg;    /* message with >=0*NLs, not terminating with NL. NUL */
} lmtp_res_t;

typedef enum {
    LMTP_EOF,           /* eof */
    LMTP_ERR_SYSTEM,    /* see errno */
    LMTP_ERR_MEM,       /* dynamic memory allocation failed */
    LMTP_ERR_OVERFLOW,  /* static allocated memory exhausted */
    LMTP_ERR_VERB,      /* search for verb failed */
    LMTP_ERR_ARG,       /* invalid arg was passed to function */
    LMTP_ERR_UNKNOWN    /* guru meditation */
} lmtp_rc_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_readline(lmtp_t *lmtp, char *buf, size_t buflen);
lmtp_rc_t   lmtp_readmsg (lmtp_t *lmtp, char *buf, size_t buflen);
lmtp_rc_t   lmtp_request (lmtp_t *lmtp, lmtp_req_t *req);
lmtp_rc_t   lmtp_response(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_rc_t   lmtp_register(lmtp_t *lmtp, char *verb, lmtp_cb_t cb, void *ctx, lmtp_cb_t *oldcb, void **oldctx);
lmtp_rc_t   lmtp_loop    (lmtp_t *lmtp);

#endif /* __LMTP_H__ */

CVSTrac 2.0.1