⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbm.3x

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 3X
字号:
.\" SCCSID: @(#)dbm.3x	8.1	9/11/90.TH dbm 3x .SH Namedbminit, fetch, store, delete, firstkey, nextkey \- data base subroutines.SH Syntax.nf.PP.B typedef struct {.B "	char *dptr;".B "	int dsize;".B } datum;.PP.B dbminit(file).B char *file;.PP.B datum fetch(key).B datum key;.PP.B store(key, content).B datum key, content;.PP.B delete(key).B datum key;.PP.B datum firstkey().PP.B datum nextkey(key).B datum key;.SH Description.NXR "dbm keyword".NXR "dbminit subroutine".NXR "fetch subroutine".NXR "store subroutine".NXR "delete subroutine".NXR "firstkey subroutine".NXR "nextkey subroutine".NXR "data base subroutine"These functions maintain key/content pairs in a data base.The functions will handle very large (a billion blocks)databases and will access a keyed itemin one or two file system accesses.The functions are obtained with the loader option.BR \-ldbm ..PP.IR Key sand.IR content sare described by the.I datumtypedef.  A.I datumspecifies a string of.I dsizebytes pointed to by.I 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 bitmap and has `.dir' as its suffix.The second file contains all data and has `.pag' as its suffix..PPBefore a database can be accessed, it must be opened by.PN dbminit .At the time of this call, the files.IB file .dirand.IB file .pagmust exist.(An empty database is created by creating zero-length`.dir' and `.pag' files.).PPOnce open, the data stored under a key is accessed by.PN fetchand data is placed under a key by.PN store .A key (and its associated contents) is deleted by.PN delete .A linear pass through all keys in a database may be made,in an (apparently) random order, by use of.PN firstkeyand.PN nextkey .The.PN firstkeywill return the first key in the database.  With any key.PN nextkeywill return the next key in the database.This code will traverse the data base:.EX 0for (key = firstkey(); key.dptr != NULL; key = nextkey(key)).EE.SH Restrictions.NXR "dbminit subroutine" "restrictions"The .PN \&.pag file will contain holes so that its apparent size is aboutfour times its actual content.  Older UNIX systems may create realfile blocks for these holes when touched.  These files cannot be copiedby normal means.Pn ( cp,.PN cat ,.PN tp ,.PN tar ,.PN ar )without filling in the holes..PPThe.I dptrpointers returned by these subroutines point into static storagethat is changed by subsequent calls..PPThe sum of the sizes of a key/content pair must not exceedthe internal block size (currently 1024 bytes).Moreover all key/content pairs that hash together must fiton a single block.  The.PN storewill return an error in the eventthat a disk block fills with inseparable data..PPThe.PN deletedoes not physically reclaim file space,although it does make it available for reuse..SH Return ValuesRoutines that return a.I datumindicate errors with a null (0).I dptr.All functions that return an.I intindicate errors with negative values.  A zero return indicates a successfulcompletion.  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -