/*
 * **    spasm - The spasm anti-spam milter
 * **    Copyright (C) 2002-2004 Sean Hanson <aradia@theasylum.org>
 * **
 * **    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 _EXTERN_H
#define _EXTERN_H

#ifdef USE_BERKELEY_DB
  #include <db4/db.h>
#endif

struct spasm_list {
    char *entry;
    char *strval;
    int value;
    struct spasm_list *next;
};

char *sp_strcat(char *a, char *b);

#ifdef USE_BERKELEY_DB
int sp_db_open(DB *db, DB_TXN *txnid, const char *file, const char *database, DBTYPE type, u_int32_t flags, int mode);
extern char* db_lookup_entry(char *dbfile, char *key);
extern void db_insert_entry(char *dbfile, char *key, char *value);
struct spasm_list* db_dump_entries(char *dbfile, int vals);
#endif

/* Database Independent Functions */
int spasm_verify_filters(char *username);
int spasm_lookup_filter(char *username, char *entry);
struct spasm_list* spasm_get_filters(char *username);
void spasm_set_filter(char *username, char *entry, int value);

int spasm_lookup_bl(char *blacklist, char *entry);
struct spasm_list* spasm_get_bl(char *blacklist);
void spasm_insert_bl(char *blacklist, char *entry, char *val);
void spasm_delete_bl(char *blacklist, char *entry);
int spasm_create_bl(char *blacklist, struct spasm_list *entries);

int spasm_lookup_wl(char *username, char *entry);
struct spasm_list* spasm_get_wl(char *username);
void spasm_insert_wl(char *username, char *entry, char *val);
void spasm_delete_wl(char *username, char *entry);

struct spasm_list* spasm_get_re(char *dbname);
void spasm_insert_re(char *dbname, char *entry);
void spasm_delete_re(char *dbname, char *entry);
/* End DB Independent Functions */

/* Internal Error Function */
#define USE_PRINTF 0
#define USE_SYSLOG 1
#define USE_CURSES 2
void spasm_error(int syslevel, char *errstr, ...);

#endif /* _EXTERN_H */
