COHERENT manpages

This page displays the COHERENT manpage for nextkey() [Retrieve the next record from a DBM data base].

List of available manpages
Index


nextkey() -- DBM Function (libgdbm)

Retrieve the next record from a DBM data base
#include <dbm.h>
datum nextkey ()

Function nextkey()  retrieves the next  record from the  currently open DBM
data  base.   The data  base  must first  have  been opened  by  a call  to
dbminit(),  and  the first  record  within  the data  base  must have  been
retrieved by a call to firstkey().

nextkey()  returns a  pointer to  the  retrieved record.   If no  record is
available (i.e.,  every record has already been retrieved),  or if an error
occurred, field dptr within the returned record is initialized to NULL.

You  can use  this function  with function firstkey()  to walk  through the
entire contents of a DBM data base.  For example:

    for(key=firstkey(); key.dptr!=NULL; key=nextkey(key))

Please  note that  the hashing  algorithm used  the DBM  functions dictates
which  record is  ``next'' within  the data  base.  A  loop that  uses this
function plus  the function firstkey() will retrieve  every record from the
data  base; however,  the records  probably will  not be  in the  order you
expect.

See Also


Notes

For  a statement  of copyright  and  permissions on  this routine,  see the
Lexicon entry for libgdbm.