xref: /dflybsd-src/contrib/cvs-1.12/src/myndbm.h (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino /*
286d7f5d3SJohn Marino  * Copyright (C) 1994-2005 The Free Software Foundation, Inc.
386d7f5d3SJohn Marino  *
486d7f5d3SJohn Marino  * This program is free software; you can redistribute it and/or modify
586d7f5d3SJohn Marino  * it under the terms of the GNU General Public License as published by
686d7f5d3SJohn Marino  * the Free Software Foundation; either version 2, or (at your option)
786d7f5d3SJohn Marino  * any later version.
886d7f5d3SJohn Marino  *
986d7f5d3SJohn Marino  * This program is distributed in the hope that it will be useful,
1086d7f5d3SJohn Marino  * but WITHOUT ANY WARRANTY; without even the implied warranty of
1186d7f5d3SJohn Marino  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1286d7f5d3SJohn Marino  * GNU General Public License for more details.
1386d7f5d3SJohn Marino  */
1486d7f5d3SJohn Marino 
1586d7f5d3SJohn Marino #ifdef MY_NDBM
1686d7f5d3SJohn Marino 
1786d7f5d3SJohn Marino #define	DBLKSIZ	4096
1886d7f5d3SJohn Marino 
1986d7f5d3SJohn Marino typedef struct
2086d7f5d3SJohn Marino {
2186d7f5d3SJohn Marino     List *dbm_list;			/* cached database */
2286d7f5d3SJohn Marino     Node *dbm_next;			/* next key to return for nextkey() */
2386d7f5d3SJohn Marino 
2486d7f5d3SJohn Marino     /* Name of the file to write to if modified is set.  malloc'd.  */
2586d7f5d3SJohn Marino     char *name;
2686d7f5d3SJohn Marino 
2786d7f5d3SJohn Marino     /* Nonzero if the database has been modified and dbm_close needs to
2886d7f5d3SJohn Marino        write it out to disk.  */
2986d7f5d3SJohn Marino     int modified;
3086d7f5d3SJohn Marino } DBM;
3186d7f5d3SJohn Marino 
3286d7f5d3SJohn Marino typedef struct
3386d7f5d3SJohn Marino {
3486d7f5d3SJohn Marino     char *dptr;
3586d7f5d3SJohn Marino     int dsize;
3686d7f5d3SJohn Marino } datum;
3786d7f5d3SJohn Marino 
3886d7f5d3SJohn Marino /*
3986d7f5d3SJohn Marino  * So as not to conflict with other dbm_open, etc., routines that may
4086d7f5d3SJohn Marino  * be included by someone's libc, all of my emulation routines are prefixed
4186d7f5d3SJohn Marino  * by "my" and we define the "standard" ones to be "my" ones here.
4286d7f5d3SJohn Marino  */
4386d7f5d3SJohn Marino #define	dbm_open	mydbm_open
4486d7f5d3SJohn Marino #define	dbm_close	mydbm_close
4586d7f5d3SJohn Marino #define	dbm_fetch	mydbm_fetch
4686d7f5d3SJohn Marino #define	dbm_firstkey	mydbm_firstkey
4786d7f5d3SJohn Marino #define	dbm_nextkey	mydbm_nextkey
4886d7f5d3SJohn Marino #define dbm_store	mydbm_store
4986d7f5d3SJohn Marino #define  DBM_INSERT  0
5086d7f5d3SJohn Marino #define  DBM_REPLACE 1
5186d7f5d3SJohn Marino 
5286d7f5d3SJohn Marino DBM *mydbm_open (char *file, int flags, int mode);
5386d7f5d3SJohn Marino void mydbm_close (DBM * db);
5486d7f5d3SJohn Marino datum mydbm_fetch (DBM * db, datum key);
5586d7f5d3SJohn Marino datum mydbm_firstkey (DBM * db);
5686d7f5d3SJohn Marino datum mydbm_nextkey (DBM * db);
5786d7f5d3SJohn Marino extern int mydbm_store (DBM *, datum, datum, int);
5886d7f5d3SJohn Marino 
5986d7f5d3SJohn Marino #endif				/* MY_NDBM */
60