#include <stdio.h>
#include <fcntl.h>
#include <gdbm.h>

main(int argc, char *argv[])
{
    GDBM_FILE dbp;
    datum key, val;
    

    dbp = gdbm_open(argv[1], 64, O_RDONLY, 0777, NULL);
    if (dbp == NULL)
    {
	perror("dbadd: dbm_open");
	exit(1);
    }

    key.dsize = strlen(argv[2]);
    key.dptr = argv[2];
    
    key = gdbm_nextkey(dbp, key);
    
    val = gdbm_fetch(dbp, key);
    printf("key = \"%.*s\", val = \"%.*s\"\n",
	   key.dsize, key.dptr,
	   val.dsize, val.dptr);
    
    gdbm_close(dbp);
    exit(0);
}
