#ifndef SDB_H
#define SDB_H

#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>

#define SDB_HASHLENGTH 251
#define SDB_KEY_REFERENCE 1
#define SDB_DATA_REFERENCE 2
#define SDB_FIRST 4
#define SDB_NOOVERWRITE 8

#ifndef TRUE
typedef int boolean;
#define TRUE 1
#define FALSE 0
#endif

typedef enum Sdb_hashtype
{
  SDB_PHONG,
  SDB_TOREK,
  SDB_TOREK_100
} Sdb_hashtype;

typedef struct Sdb_chainlink
{
   void *key_data;
   u_long key_size;
   boolean key_reference;
   void *data_data;
   u_long data_size;
   boolean data_reference;
   struct Sdb_chainlink *next;
} Sdb_chainlink;

typedef struct Sdb_datum
{
   void  *data;
   u_long size;
} Sdb_datum;

typedef struct Sdb
{
   int (*put) (struct Sdb *db, const struct Sdb_datum *key,
               struct Sdb_datum *data, const u_long flags);
   int (*get) (const struct Sdb *db, const struct Sdb_datum *key,
               struct Sdb_datum *data, const u_long flags);
   int (*del) (const struct Sdb *db, struct Sdb_datum *key,
               const u_long flags);
   int (*seq) (const struct Sdb *db, struct Sdb_datum *key,
               struct Sdb_datum *data, const u_long flags);
   int (*close) (struct Sdb *db);
   void (*stat) (const struct Sdb *db);
   u_short (*hash) (const struct Sdb *db,
                   const struct Sdb_datum *key);
   u_short hashlength;
   struct Sdb_chainlink **hashlist;
} Sdb;

struct Sdb *sdb_open(const u_short hashlength, const Sdb_hashtype hashtype);

#endif /* SDB_H */
