(gdbm.info.gz) Fetch
Info Catalog
(gdbm.info.gz) Store
(gdbm.info.gz) Top
(gdbm.info.gz) Delete
7 Searching for records in the database.
****************************************
-- gdbm interface: datum gdbm_fetch (GDBM_FILE DBF, datum KEY)
Looks up a given KEY and returns the information associated with
it. The `dptr' field in the structure that is returned points to a
memory block allocated by `malloc'. It is the caller's
responsibility to free it when no longer needed.
If the `dptr' is `NULL', no data was found.
The parameters are:
DBF
The pointer returned by `gdbm_open'.
KEY
The search key.
An example of using this function:
content = gdbm_fetch (dbf, key);
if (content.dptr == NULL)
{
fprintf(stderr, "key not found\n");
}
else
{
/* do something with content.dptr */
}
You may also search for a particular key without retrieving it:
-- gdbm interface: int gdbm_exists (GDBM_FILE DBF, datum KEY)
Returns `true' (`1') if the KEY exists in DBF and `false' (`0')
otherwise.
The parameters are:
DBF
The pointer returned by `gdbm_open'.
KEY
The search key.
Info Catalog
(gdbm.info.gz) Store
(gdbm.info.gz) Top
(gdbm.info.gz) Delete
automatically generated by
info2html