2
This is the Free Pascal interface to the GDBM library routines.
3
Essentially, this is a translation of the gdbm.h header files, with some
6
The headers translated without any problems, the only thing that should
7
be taken into account is that the
8
GDBM_SYNC constant (for open flags) has been renamed to GDMB_DOSYNC
9
because it conflicts with the gdbm_sync function.
11
Be careful: the TDatum.dptr data pointer which is allocated by the
12
gdbm routines should be freed by the C free() call, NOT with the
13
pascal FreeMem() call.
15
A solution for this is to use the 'cmem' unit, which replaces the standard
16
FPC memory manager with the C memory manager. In that case, freemem()
17
may be used to free the dptr field of the TDatum record.
19
On top of the plain C header translations, The GDBM routines have been
20
overloaded with routines that accept plain strings as key or data
21
parameters. This means the following routines have been added:
23
function gdbm_open(Const para1:string; para2:longint; para3:longint; para4:longint; para5:TGDBMErrorCallBack ):PGDBM_FILE;
24
function gdbm_store(para1:PGDBM_FILE; Const para2:string; Const para3:string; para4:longint):Boolean;
25
function gdbm_fetch(para1:PGDBM_FILE; Const para2:string):string;
26
function gdbm_delete(para1:PGDBM_FILE; Const para2:string):boolean;
27
procedure gdbm_firstkey(para1:PGDBM_FILE; var key :string);
28
function gdbm_nextkey(para1:PGDBM_FILE; Const para2:string):string;
29
function gdbm_exists(para1:PGDBM_FILE; Const para2:string):boolean;
31
They are just the C routines, but with the TDatum type (a record)
32
replaced by a string. The routines take automatically care of memory
35
Functions that returned an integer to indicate success or failure have been
36
replaced by functions that return a boolean.
39
When using ansistrings, make sure the gdbm unit has been compiled
40
with the -Sh switch. The unit should work with both kinds of strings.
42
There are 2 test programs:
43
testgdbm tests the raw C header translation
44
testgdbm2 tests the String interface to the GDBM routines.
50
Michael. (Michael.VanCanneyt@Wisa.be)