/*
 * $Id: eb838b0e285a3dd0f24b702d8ef43ebed217873b $
 *
 * This file is part of nsmtp.
 *
 * Copyright (c) 2007, 2008 Niklas Olmes <niklas@noxa.de>
 *                          http://www.nevm.de/nsmtp/
 *                          NEVM-RIPE
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License Version 2
 * as published by the Free Software Foundation.
 *
 * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#ifndef HAD_LIBNSMTP_SMTP_H
#define HAD_LIBNSMTP_SMTP_H

#include <openssl/ssl.h>

#define MAX_SIZE	100*1024*1024
#define MAX_RECIPIENTS	30

typedef struct smtp_ctx {
	int client;
	char *conn_id;
	const char *client_rn;
	const char *client_ip;
	int esmtp;
	int errors;
	int noops;
	char *helo;
	char *from;
	char **rcpts;
	char **defers;
	char *data;
	char *lmid;
	const char *server;
	time_t spooltime;
	int relay;
	size_t size;
	void *mmap;
	int mmapfd;
	int exploded;
	char *authinfo;
	char *recvdinfo;
	char *sslinfo;
	char *spfinfo;
	char *spfsmtp;
	SSL *ssl;
	char *s_buf;
	size_t s_buf_size;
	size_t s_buf_off;
	size_t s_buf_len;
} SMTP_CTX;

void init_smtp_sighandlers(void);

SMTP_CTX *init_smtp_ctx(void);
void reset_smtp_ctx(SMTP_CTX *);
void destroy_smtp_ctx(SMTP_CTX *);
char *make_mid(const SMTP_CTX *);
char *make_822time(time_t);
int data_writeout(const SMTP_CTX *, const void *, size_t);
int smtp_writeout(const SMTP_CTX *, const char *, ...);
void smtp_close(SMTP_CTX *);
ssize_t smtp_getline(SMTP_CTX *, char *, size_t, int);

void remove_empty_rcpts(char **);

#endif
