/***************************************************************************** POPular -- A POP3 server and proxy for large mail systems $Id: io.h,v 1.11 2002/11/28 13:56:03 sqrt Exp $ http://www.remote.org/jochen/mail/popular/ ****************************************************************************** Copyright (C) 1999-2002 Jochen Topf This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA *****************************************************************************/ #ifndef _POPULAR_IO_H #define _POPULAR_IO_H typedef enum { iot_plain, /* normal plain vanilla socket */ iot_tls /* TLS used on this IO contect */ } io_type_t; #define IO_BUFLEN 16384 struct io_ctx { io_type_t io_type; /* type of this IO context */ int io_fd; /* file descriptor for this IO context */ int io_nullcheck; /* check for null bytes on this ctx? */ int io_timeout; /* timeout in seconds on this ctx */ const char *io_desc; /* description for debugging */ char io_ibuf[IO_BUFLEN]; /* input buffer */ char *io_bufptr; /* pointer into buffer where data begins */ char io_obuf[IO_BUFLEN]; /* output buffer */ struct virt_serv *io_vserv; /* virtual server if applicable */ #ifdef USE_TLS SSL *io_tls; /* TLS connection context */ #endif }; struct io_ctx *io_init(io_type_t iot, int fd, const char *desc, int nullcheck, int timeout, struct virt_serv *vserv); int io_destroy(struct io_ctx *ioc); int io_pending(struct io_ctx *ioc); ssize_t io_sysread(struct io_ctx *ioc, char *buf, size_t count); ssize_t io_read(struct io_ctx *ioc, char *buf, size_t count); char *io_readln(struct io_ctx *ioc); ssize_t io_syswrite(struct io_ctx *ioc, const char *buf, size_t count); int io_write(struct io_ctx *ioc, const char *string); int io_writeln(struct io_ctx *ioc, const char *string); int io_buf_write(struct io_ctx *ioc, const char *string); int io_buf_writeln(struct io_ctx *ioc, const char *string); int io_buf_flush(struct io_ctx *ioc); int io_buf_printf(struct io_ctx *ioc, const char *format, ...); #ifdef USE_TLS struct io_ctx *io_tls_init(struct io_ctx *ioc); int io_tls_seed_prng(const char *filename, int bytes); void io_tls_main_setup(void); int io_tls_vserv_setup(const char *tlsdir, int allowsslv2, struct virt_serv *vs); void io_tls_vserv_shutdown(struct virt_serv *vs); #endif #endif /* _POPULAR_IO_H */ /** THE END *****************************************************************/