Finding a key

#include "btree.h"

int bfndky(BTA* btact, char* key, BTint* value);

The bfndky function searches for a key in the current root of the file associated with the btact context pointer. The key, a character string, is passed as a pointer in key. If the key is found, the associated value will be returned in the integer location identified by value. value is declared as a BTint, which is normally a typedef for int, but with Large File Support will be a typedef for long long.

If the key is found, bfndky returns zero. If the key is not found, bfndky will return an error code of QNOKEY.

Whether or not the key is located, the B Tree context is left at the next highest key within the B Tree file. A call to bnxtky will return this key. The function bprvky may be called to return the previous key.

If the current root supports duplicate keys (enabled by a call to btdups, and the target of the bfndky function has duplicates, the context of the B Tree index is positioned at the start of the duplicate key set.

A non-zero return from bfndky indicates an error occurred during the key location process.