/***** **** *** ** *  *   *    *     *       *     *   *  * ** *** **** *****\

    logresolve 2.0 - http://www.uunet.ca/~tomr/progs/logresolve/

    lr-dbm.h - persistent DBM (pDBM) cache 2.0d1

    Tom Rathborne - tomr@uunet.ca - http://www.uunet.ca/~tomr/

\***** **** *** ** *  *   *    *     *       *     *   *  * ** *** **** *****/

#ifndef LR_DBM_H
#define LR_DBM_H

#include "logresolve.h"
#include "lr-nsrec.h"

#include <stdio.h>
#include <ndbm.h>

/*
 * nameservice dbm file
 *   mode     - LR_CLOSED, LR_READ, LR_WRITE
 *   lockfile - lockfile handle for concurrency
 *   dbf      - actual DBM file handle
 */

struct nsdbm {
    int mode;
    int lockfile;
    DBM *dbf;
};

/*
 * pdbm_lookup - gets record from pDBM - mode must be LR_READ
 */

struct nsrec *pdbm_lookup(struct nsdbm *db, unsigned char ipnum[4]);

/*
 * pdbm_insert - inserts record into pDBM - mode must be LR_WRITE
 */

void pdbm_insert(struct nsdbm *db, struct nsrec *record);

/*
 * pdbm_open - open a logresolve pDBM
 */

struct nsdbm *pdbm_open(char *dbfname, char *lockname, int mode);

/*
 * pdbm_close - close a logresolve pDBM
 */

int pdbm_close(struct nsdbm *db);

#endif

/*** end of lr-dbm.h ***/
