code: 9ferno

ref: 600bbfe4aaa9ad0f73d8d73eef1b7670e5f7d3a3
dir: /module/dbm.m/

View raw version
Dbm: module
{
	PATH: con "/dis/lib/dbm.dis";

	Datum:	type array of byte;

	Dbf: adt {
		create:	fn(file: string, perm: int): ref Dbf;
		open:	fn(file: string, flags: int): ref Dbf;

		fetch:	fn(db: self ref Dbf, key: Datum): Datum;
		delete:	fn(db: self ref Dbf, key: Datum): int;
		store:	fn(db: self ref Dbf, key: Datum, dat: Datum, replace: int): int;
		firstkey:	fn(db: self ref Dbf): Datum;
		nextkey:	fn(db: self ref Dbf, key: Datum): Datum;

		flush:	fn(db: self ref Dbf);

		isrdonly:	fn(db: self ref Dbf): int;

		dirf:	ref Sys->FD;	# directory
		pagf:	ref Sys->FD;	# page
		flags:	int;
		maxbno:	int;	# last `bno' in page file
		bitno:	int;
		hmask:	int;
		blkno:	int;	# current page to read/write
		pagbno:	int;	# current page in pagbuf
		pagbuf:	array of byte;	# [PBLKSIZ]
		dirbno:	int;	# current block in dirbuf
		dirbuf:	array of byte;	# [DBLKSIZ]
	};

	init:	fn();
};