/*
 *  Copyright (C) 2004 Morten Fjord-Larsen
 *
 *  $Id: encstream.h,v 1.1.1.1 2004/04/26 23:58:48 fjord Exp $
 *
 *  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 Library 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 ENCSTREAM_H
#define ENCSTREAM_H

#include <openssl/evp.h>

typedef struct encstream {
    FILE *file;
    EVP_CIPHER_CTX ctx;
    char buffer[EVP_MAX_BLOCK_LENGTH];
    int buflen;
} encstream;

struct encstream *	encstream_open(const char *path, 
			               const char *mode,
				       const char *password, 
				       int do_encrypt);
int 			encstream_close(encstream *es);
char *			encstream_gets(char *s, int size, encstream *es);
int 			encstream_read(char *buffer,size_t size,encstream *es);
int 			encstream_write(const char *buf, 
					size_t size, 
					encstream *es);
int 			encstream_puts(const char *s, encstream *es);
int 			encstream_printf(encstream *es, const char *format,...);

#define			encstream_eof(es) (feof(es->file))
#define 		encstream_error(es) (ferror(es->file))

#endif /* ENCSTREAM_H */
