1284194Sdelphij/* 2284194Sdelphij * Copyright (C) 1994-2005 The Free Software Foundation, Inc. 3284194Sdelphij * 4284194Sdelphij * This program is free software; you can redistribute it and/or modify 5284194Sdelphij * it under the terms of the GNU General Public License as published by 6284194Sdelphij * the Free Software Foundation; either version 2, or (at your option) 7284194Sdelphij * any later version. 8284194Sdelphij * 9284194Sdelphij * This program is distributed in the hope that it will be useful, 10284194Sdelphij * but WITHOUT ANY WARRANTY; without even the implied warranty of 11284194Sdelphij * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12284194Sdelphij * GNU General Public License for more details. 13284194Sdelphij */ 14284194Sdelphij 15284194Sdelphij#ifdef MY_NDBM 16284194Sdelphij 17284194Sdelphij#define DBLKSIZ 4096 18284194Sdelphij 19284194Sdelphijtypedef struct 20284194Sdelphij{ 21284194Sdelphij List *dbm_list; /* cached database */ 22284194Sdelphij Node *dbm_next; /* next key to return for nextkey() */ 23284194Sdelphij 24284194Sdelphij /* Name of the file to write to if modified is set. malloc'd. */ 25284194Sdelphij char *name; 26284194Sdelphij 27284194Sdelphij /* Nonzero if the database has been modified and dbm_close needs to 28284194Sdelphij write it out to disk. */ 29284194Sdelphij int modified; 30284194Sdelphij} DBM; 31284194Sdelphij 32284194Sdelphijtypedef struct 33284194Sdelphij{ 34284194Sdelphij char *dptr; 35284194Sdelphij int dsize; 36284194Sdelphij} datum; 37284194Sdelphij 38284194Sdelphij/* 39284194Sdelphij * So as not to conflict with other dbm_open, etc., routines that may 40284194Sdelphij * be included by someone's libc, all of my emulation routines are prefixed 41284194Sdelphij * by "my" and we define the "standard" ones to be "my" ones here. 42284194Sdelphij */ 43284194Sdelphij#define dbm_open mydbm_open 44284194Sdelphij#define dbm_close mydbm_close 45284194Sdelphij#define dbm_fetch mydbm_fetch 46284194Sdelphij#define dbm_firstkey mydbm_firstkey 47284194Sdelphij#define dbm_nextkey mydbm_nextkey 48284194Sdelphij#define dbm_store mydbm_store 49284194Sdelphij#define DBM_INSERT 0 50284194Sdelphij#define DBM_REPLACE 1 51284194Sdelphij 52284194SdelphijDBM *mydbm_open PROTO((char *file, int flags, int mode)); 53284194Sdelphijvoid mydbm_close PROTO((DBM * db)); 54284194Sdelphijdatum mydbm_fetch PROTO((DBM * db, datum key)); 55284194Sdelphijdatum mydbm_firstkey PROTO((DBM * db)); 56284194Sdelphijdatum mydbm_nextkey PROTO((DBM * db)); 57284194Sdelphijextern int mydbm_store PROTO ((DBM *, datum, datum, int)); 58284194Sdelphij 59284194Sdelphij#endif /* MY_NDBM */ 60284194Sdelphij