/*
 *  Copyright (C) 2004 Morten Fjord-Larsen
 *
 *  $Id: passwordfile.h,v 1.2 2004/06/17 14:31:32 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 PASSWORDFILE_H
#define PASSWORDFILE_H

#include <glib.h>
#include "encstream.h"

typedef struct password_file_entry 
{
    gchar *title;
    gchar *username;
    gchar *password;
    gchar *url;
    time_t creation_time;
    time_t modification_time;
    time_t expiration_time;
    gchar *description;
} password_file_entry;

#define password_file_eof(es) encstream_eof(es)

/* Opens a password file for reading */
encstream *password_file_openr(const gchar *filename,
	       		       const gchar *password,
			       GError **error);

/* Reads an entry from the password file. */
int password_file_read_entry(encstream *es,
      			     password_file_entry *entry,
			     GError **error);

/* Write a password entry to the given stream */
void password_file_write_entry(encstream *es, 
			       password_file_entry *entry,
			       GError **error);

/* Closes a password file */
void password_file_close(encstream *es, GError **error);

/* Opens a password file for writing. */
encstream *password_file_openw(const gchar *filename,
			       const gchar *password, 
			       GError **error);

/* Creates a new password file. */
void password_file_create(const gchar *filename,
			  const gchar *password, 
			  GError **error);

/* Destroy a password file entry. */
void password_file_entry_destroy(password_file_entry *entry);

/* Does a backup of the password file. */
void password_file_backup(const gchar *filename, GError **error);

#endif /* PASSWORDFILE_H */
