Keyed Indexed Files

Recent Unix provides with the dbm or ndbm library for the management of keyed index files. Making use of this library, you can build a data base that is composed of many pairs of key and datum association. Following functions are defined in clib/ndbm.c. On Sun, it should be compiled by cc -c -Dsun4 -Bstatic, and loaded into EusLisp by (load "clib/ndbm" :ld-option "-lc").



dbm-open dbname mode flag [function]

Dbm-open must be called first to create a data base file, and to begin read/write operations to the data base. Dbname is the name of the data base. Actually, ndbm manager creates two files which have suffixes ".pag" and ".dir". Mode specifies file-open mode; 0 for read-only access, 1 for write-only, and 2 for read-write; also #x200 should be ored when you create the file at the first time. Flag gives access permission that is changed by chmod. #o666 or #o664 is good for flag. Dbm-open returns an integer that identifies the data base in the process. This value is used by other dbm functions to identify the data base. In other words, you can open several data bases at the same time.


dbm-store db key datum mode [function]

stores key-datum association in db. Db is an integer to identify the data base. Key and datum are strings. Mode is 0 (insert) or 1 (replace).


dbm-fetch db key [function]

retrieves datum that is associated with key in db.


k-okada 2013-05-21