summaryrefslogtreecommitdiff
path: root/static/v10/man3/dbm.3
diff options
context:
space:
mode:
Diffstat (limited to 'static/v10/man3/dbm.3')
-rw-r--r--static/v10/man3/dbm.3144
1 files changed, 144 insertions, 0 deletions
diff --git a/static/v10/man3/dbm.3 b/static/v10/man3/dbm.3
new file mode 100644
index 00000000..3653f441
--- /dev/null
+++ b/static/v10/man3/dbm.3
@@ -0,0 +1,144 @@
+.TH DBM 3X
+.CT 2 data_man
+.SH NAME
+dbminit, fetch, store, delete, firstkey, nextkey \(mi database subroutines
+.SH SYNOPSIS
+.nf
+.B dbminit(file)
+.B char *file;
+.PP
+.B datum fetch(key)
+.B datum key;
+.PP
+.B store(key, value)
+.B datum key, value;
+.PP
+.B delete(key)
+.B datum key;
+.PP
+.B datum firstkey()
+.PP
+.B datum nextkey(key)
+.B datum key;
+.SH DESCRIPTION
+These functions maintain
+key/value pairs (each pair is a
+.IR datum )
+in a data base.
+The functions will handle very large databases
+in one or two file system accesses per key.
+The functions are loaded
+with
+.IR ld (1)
+option
+.BR -ldbm .
+A datum is defined as
+.IP
+.EX
+.ta \w'typedef 'u +\w'struct 'u
+typedef struct {
+ char *dptr;
+ int dsize;
+} datum;
+.EE
+.PP
+A
+.B datum
+object specifies a string of
+.B dsize
+bytes pointed to by
+.BR dptr .
+Arbitrary binary data, as well as normal
+ASCII strings, are allowed.
+The data base is stored in two files.
+One file is a directory containing a bit map
+and has
+.L .dir
+as its suffix.
+The second file contains all data and
+has
+.L .pag
+as its suffix.
+.PP
+Before a database can be accessed,
+it must be opened by
+.I dbminit.
+At the time of this call,
+the files
+.IB file .dir
+and
+.IB file .pag
+must exist.
+(An empty database has empty
+.L .dir
+and
+.L .pag
+files.)
+.PP
+The value associated with a key is
+retrieved by
+.I fetch
+and assigned by
+.IR store .
+A key and its associated value
+are deleted by
+.IR delete .
+A linear pass through all keys in a database
+may be made,
+in random order,
+by use of
+.I firstkey
+and
+.IR nextkey .
+.I Firstkey
+will return the first key
+in the database.
+With any key
+.I nextkey
+will return the next key in the database.
+This code will traverse the data base:
+.IP
+.L
+for(key = firstkey(); key.dptr != NULL; key = nextkey(key))
+.SH SEE ALSO
+.IR cbt (3)
+.SH DIAGNOSTICS
+All functions that return integers
+indicate errors with negative values.
+A zero return indicates success.
+Routines that return a
+.B datum
+indicate errors with zero
+.BR dptr .
+.SH BUGS
+The
+.L .pag
+file contains holes;
+its apparent size is about
+four times its actual content.
+These files cannot be copied
+by normal means
+.RI ( cat (1),
+.IR tar (1),
+.IR cpio (1),
+.IR ar (1))
+without filling in the holes.
+.br
+Pointers returned
+by these subroutines
+refer to static data
+that is changed by subsequent calls.
+.br
+The sum of the sizes of
+a
+key/value pair must not exceed
+a fixed internal block size.
+Moreover all key/value pairs that hash
+together must fit on a single block.
+.I Store
+will return an error in the event that
+a disk block fills with inseparable data.
+.br
+.I Delete
+does not physically reclaim file space,
+although it does make it available for reuse.