ANSI
[unix-history] / usr / src / include / ndbm.h
index 21b69e6..5c56e67 100644 (file)
@@ -1,50 +1,45 @@
-/*      ndbm.h     4.3     84/08/28     */
-
-/*
- * Hashed key data base library.
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Margo Seltzer.
+ *
+ * %sccs.include.redist.c%
+ *
+ *     @(#)ndbm.h      5.5 (Berkeley) %G%
  */
  */
-#define PBLKSIZ 1024
-#define DBLKSIZ 4096
 
 
-typedef struct {
-       int     dbm_dirf;                /* open directory file */
-       int     dbm_pagf;                /* open page file */
-       int     dbm_flags;              /* flags, see below */
-       long    dbm_maxbno;              /* last ``block'' in page file */
-       long    dbm_bitno;
-       long    dbm_hmask;
-       long    dbm_blkno;               /* current page to read/write */
-       long    dbm_pagbno;              /* current page in pagbuf */
-       char    dbm_pagbuf[PBLKSIZ];     /* page file block buffer */
-       long    dbm_dirbno;              /* current block in dirbuf */
-       char    dbm_dirbuf[DBLKSIZ];     /* directory file block buffer */
-} DBM;
+#include <sys/cdefs.h>
+#include <db.h>
 
 
-#define _DBM_RDONLY    0x1     /* data base open read-only */
-#define _DBM_IOERR     0x2     /* data base I/O error */
+/* Map dbm interface onto db(3). */
+#define DBM_RDONLY     O_RDONLY
 
 
-#define dbm_rdonly(db) ((db)->dbm_flags & _DBM_RDONLY)
+/* Flags to dbm_store(). */
+#define DBM_INSERT      0
+#define DBM_REPLACE     1
 
 
-#define dbm_error(db)  ((db)->dbm_flags & _DBM_IOERR)
-       /* use this one at your own risk! */
-#define dbm_clearerr(db)       ((db)->dbm_flags &= ~_DBM_IOERR)
+/*
+ * The db(3) support for ndbm(3) always appends this suffix to the
+ * file name to avoid overwriting the user's original database.
+ */
+#define        DBM_SUFFIX      ".db"
 
 typedef struct {
 
 typedef struct {
-       char    *dptr;
-       int     dsize;
+       char *dptr;
+       int dsize;
 } datum;
 
 } datum;
 
-/*
- * flags to dbm_store()
- */
-#define DBM_INSERT     0
-#define DBM_REPLACE    1
-
-DBM     *dbm_open();
-void    dbm_close();
-datum   dbm_fetch();
-datum   dbm_firstkey();
-datum   dbm_nextkey();
-long    dbm_forder();
-int     dbm_delete();
-int     dbm_store();
+typedef DB DBM;
+
+__BEGIN_DECLS
+void    dbm_close __P((DBM *));
+int     dbm_delete __P((DBM *, datum));
+datum   dbm_fetch __P((DBM *, datum));
+datum   dbm_firstkey __P((DBM *));
+long    dbm_forder __P((DBM *, datum));
+datum   dbm_nextkey __P((DBM *));
+DBM    *dbm_open __P((const char *, int, int));
+int     dbm_store __P((DBM *, datum, datum, int));
+__END_DECLS