📄 dbm.3x
字号:
.TH DBM 3X .SH NAMEdbminit, fetch, store, delete, firstkey, nextkey \- data base subroutines.SH SYNOPSIS.nf.PP.B "typedef struct { char *dptr; int dsize; } 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 DESCRIPTIONThese functions maintainkey/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 filesystem accesses.The functions are obtained with the loader option.BR \-ldbm ..PP.IR Key sand.IR content saredescribed by the.I datumtypedef.A.I datumspecifies a string of.I dsizebytes pointed to by.I dptr.Arbitrary binary data, as well as normalASCII strings, are allowed.The data base is stored in two files.One file is a directory containing a bit mapand has `.dir' as its suffix.The second file contains all data andhas `.pag' as its suffix..PPBefore a database can be accessed,it must be opened by.I dbminit.At the time of this call,the files.IB file .dirand.IB file .pagmust exist.(An empty database is created bycreating zero-length`.dir' and `.pag' files.).PPOnce open,the data stored under a key isaccessed by.I fetchand data is placed under a keyby.IR store .A key (and its associated contents)is deleted by.IR delete .A linear pass through all keys in a databasemay be made,in an (apparently) random order,by use of.I firstkeyand.IR nextkey ..I Firstkeywill return the first keyin the database.With any key.I nextkeywill return the next key in the database.This code will traverse the data base:.PP for(key=firstkey(); key.dptr!=NULL; key=nextkey(key)).SH DIAGNOSTICSAll functions that return an.I intindicate errors with negative values.A zero return indicates ok.Routines that return a.I datumindicate errors with a null (0).I dptr..SH BUGSThe`.pag'file will contain holes sothat 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 (cp, cat, tp, tar, ar)without filling in the holes..PP.I Dptrpointers returnedby these subroutinespoint into static storagethat is changed by subsequent calls..PPThe sum of the sizes ofakey/content pair must not exceedthe internal block size(currently 512 bytes).Moreover all key/content pairs that hashtogether must fit on a single block..I Storewill return an error in the event thata disk block fills with inseparable data..PP.I Deletedoes not physically reclaim file space,although it does make it available for reuse..PPThe order of keys presented by.I firstkeyand.I nextkeydepends on a hashing function, not on anythinginteresting.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -