Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 |
both |
#define _XOPEN_SOURCE_EXTENDED 1
#include <ndbm.h>
datum dbm_firstkey(DBM *db);
for (key = dbm_firstkey(db); key.dptr !=NULL; key = dbm_nextkey(db))
That is, establish positioning to the beginning by use of the dbm_firstkey()
function, then loop doing dbm_nextkey() function calls until a NULL dptr is
returned in the datum.The returned dptr is valid only until the next dbm_ operation by this thread.
Special behavior for z/OS® UNIX Services: In a multithreaded environment, the dbm_firstkey() function returns a pointer to data that is thread-specific. In addition, each thread maintains its own positioning information for dbm_nextkey() operations. However, other threads making modifications to the database, for example using dbm_store() or dbm_delete() can cause unpredictable results for threads executing dbm_nextkey(), including keys retrieved multiple times or not at all. The application must reset positioning to the beginning using dbm_firstkey() if another thread has done a modification to the database.
If successful, dbm_firstkey() returns the datum containing a pointer to the key dptr, and the key length dsize.
If unsuccessful, dbm_firstkey() returns a NULL pointer in dptr and returns the error value in errno. Also, the database error indicator may be set.