Locating data for the previous key in sequence

#include "btree.h"

int btselp(BTA* btact, char* key, char* data, int dsize, int* rsize);

The btselp function locates and returns the previous key and data record in the file associated with the btact context pointer. Before using btselp, a call to btsel or btpos must be made to initialise the position within the B Tree. Calls to btseln may be freely intermingled with calls to btselp.

Both key and data are character pointers. The dsize parameter must contain the maximum number of bytes to be returned. The caller should ensure that the data pointer refers to an area of memory of at least dsize bytes. The actual number of bytes returned is returned in rsize. Even if the data record contains more than dsize bytes, only dsize bytes will be returned. If the data record is successfully retrieved (even partially), btselp returns zero.

If no previous key exists, btselp will return the error code QNOKEY.

An application program can determine the number of bytes occupied by a data record through the btrecs function.

A non-zero return from btseln indicates an error occurred.