home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Press 1997 July
/
Sezamfile97_1.iso
/
msdos
/
c
/
cbase11.a03
/
CBASE11.ZIP
/
MAN
/
BTREE.MAN
< prev
next >
Wrap
Text File
|
1993-01-01
|
9KB
|
285 lines
NAME
btsetcur - set btree cursor
SYNOPSIS
#include <btree.h>
int btsetcur(btp, btposp)
btree_t *btp;
const btpos_t *btposp;
DESCRIPTION
The btsetcur function sets the current cursor position for btree
btp to the value in btposp. btposp should point to a cursor
value saved previously with btgetcur. If btposp is the NULL
pointer, the cursor is set to null. It is important to remember
that a btree position is not valid after an insertion, deletion,
or unlock.
btsetcur will fail if one or more of the following is true:
[EINVAL] btp is not a valid btree pointer.
[BTELOCK] btp is not locked.
[BTENKEY] btposp points to an invalid cursor value.
[BTENOPEN] btp is not open.
SEE ALSO
btgetcur.
DIAGNOSTICS
Upon successful completion, a value of 0 is returned. Otherwise,
a value of -1 is returned, and errno set to indicate the error.
NAME
btsetvbuf - assign buffering to a btree
SYNOPSIS
#include <btree.h>
int btsetvbuf(btp, buf, bufcnt)
btree_t *btp;
void *buf;
size_t bufcnt;
DESCRIPTION
The btsetvbuf function is used to assign buffering to a btree.
bufcnt specifies the number of btree nodes to be buffered. If
bufcnt has a value of zero, the btree will be completely
unbuffered. If buf is not the NULL pointer, the storage area it
points to will be used instead of one automatically allocated for
buffering.
The size of the storage area needed can be obtained using the
BTBUFSIZE() macro:
char buf[BTBUFSIZE(M, KEYSIZE, BUFCNT)];
btsetvbuf(btp, buf, BUFCNT);
where M is the degree of the btree, KEYSIZE is the size of the
keys int the btree, and BUFCNT is the number of nodes to buffer.
Any previously buffered data is flushed before installing the new
buffer area, so btsetvbuf may be called more than once. This
allows the buffer size to be varied with the file size.
btsetvbuf will fail if one or more of the following is true:
[EINVAL] btp is not a valid btree.
[ENOMEM] Not enough memory is available for the calling
process to allocate.
[BTENOPEN] btp is not open.
SEE ALSO
btsetbuf, btsync.
DIAGNOSTICS
Upon successful completion, a value of 0 is returned. Otherwise,
a value of -1 is returned, and errno set to indicate the error.
NAME
btsync - btree synchronize
SYNOPSIS
#include <btree.h>
int btsync(btp);
btree_t *btp;
DESCRIPTION
The btsync function causes any buffered data for the named btree
to be written to the file. The btree remains open and the buffer
contents remain intact.
btsync will fail if one or more of the following is true:
[EINVAL] btp is not a valid btree pointer.
[BTENOPEN] btp is not open.
SEE ALSO
btclose, btlock, btsetbuf, btsetvbuf.
DIAGNOSTICS
Upon successful completion, a value of 0 is returned. Otherwise,
a value of -1 is returned, and errno set to indicate the error.
NAME
btnext - next btree key
SYNOPSIS
#include <btree.h>
int btnext(btp)
btree_t *btp;
DESCRIPTION
The btnext function advances the cursor of btree btp to the next
key. If cursor is currently null, it will be advanced to the
first key. If the cursor is currently on the last key, it will
advance to null. If the tree is empty, the cursor will remain on
null.
btnext will fail if one or more of the following is true:
[EINVAL] btp is not a valid btree pointer.
[BTELOCK] btp is not locked.
[BTENOPEN] btp is not open.
SEE ALSO
btcursor, btfirst, btlast, btprev.
DIAGNOSTICS
Upon successful completion, a value of 0 is returned. Otherwise,
a value of -1 is returned, and errno set to indicate the error.
NAME
btopen - open a btree
SYNOPSIS
btree_t *btopen(filename, type, fldc, fldv)
const char *filename;
const char *type;
int fldc;
const btfield_t fldv[];
DESCRIPTION
The btopen function opens the file named by filename as a btree.
A pointer to the btree_t control structure associated with the
file is returned.
type is a character string having one of the following values:
"r" open for reading
"r+" open for update (reading and writing)
See btcreate for explanation of the field count fldc and the
field definition list fldv.
btopen will fail if one or more of the following is true:
[EINVAL] filename is the NULL pointer.
[EINVAL] type is not "r" or "r+".
[EINVAL] fldc is less than 1.
[EINVAL] fldv is the NULL pointer.
[EINVAL] fldv contains an invalid field definition.
[ENOENT] The named btree file does not exist.
[BTEMFILE] Too many open btrees. The maximum is defined as
BTOPEN_MAX in <btree.h>.
SEE ALSO
btclose, btcreate.
DIAGNOSTICS
On failure btopen returns a NULL pointer, and errno is set to
indicate the error.
NOTES
The same field count and field definition list with which the
btree was created must be used each time the btree is opened.
Otherwise the results are undefined.
NAME
btprev - previous btree key
SYNOPSIS
#include <btree.h>
int btprev(btp)
btree_t *btp;
DESCRIPTION
The btprev function retreats the cursor of btree btp to the
previous key. If cursor is currently null, it will be moved to
the last key. If the cursor is currently on the last key, it
will move to null. If the tree is empty, the cursor will remain
on null.
btprev will fail if one or more of the following is true:
[EINVAL] btp is not a valid btree pointer.
[BTELOCK] btp is not locked.
[BTENOPEN] btp is not open.
SEE ALSO
btcursor, btfirst, btlast, btnext.
DIAGNOSTICS
Upon successful completion, a value of 0 is returned. Otherwise,
a value of -1 is returned, and errno set to indicate the error.
NAME
btsearch - search a btree
SYNOPSIS
#include <btree.h>
int btsearch(btp, buf)
btree_t *btp;
const void *buf;
DESCRIPTION
The btsearch function searches the btree btp for the key pointed
to by buf. If it is found, the cursor is set to the location of
the key and 1 is returned. If it is not found, the cursor is set
to the next higher key and 0 is returned.
btsearch will fail if one or more of the following is true:
[EINVAL] btp is not a valid btree pointer.
[EINVAL] buf is the NULL pointer.
[BTELOCK] btp is not read locked.
SEE ALSO
btdelcur, btdelete, btinsert.
DIAGNOSTICS
Upon successful completion, a value of 1 is returned if the key
was found or a value of 0 if it was not found. On failure, a
value of -1 is returned, and errno set to indicate the error.
NAME
btsetbuf - assign buffering to a btree
SYNOPSIS
#include <btree.h>
int btsetbuf(btp, buf)
btree_t *btp;
void *buf;
DESCRIPTION
The btsetbuf function causes the storage area pointed to by buf
to be used by the btree associated with btree pointer btp instead
of an automatically allocated buffer area. If buf is the NULL
pointer, btp will be completely unbuffered.
The size of the storage area needed can be obtained using the
BTBUFSIZE() macro:
char buf[BTBUFSIZE(M, KEYSIZE, BTBUFCNT)];
btsetbuf(btp, buf);
where M is the degree of the btree, KEYSIZE is the size of the
keys int the btree, and BTBUFCNT is the default number of nodes
buffered when a btree is opened. BTBUFCNT is defined in
<btree.h>. If the number of nodes buffered has been changed using
btsetvbuf, then that number should be used in place of BTBUFCNT.
btsetbuf may be called at any time after opening the btree,
before and after it is read or written; the buffers are flushed
before installing the new buffer area.
btsetbuf will fail if one or more of the following is true:
[EINVAL] btp is not a valid btree pointer.
[BTENBUF] buf is not the NULL pointer and btp
is not buffered.
[BTENOPEN] btp is not open.
SEE ALSO
btsetvbuf, btsync.
DIAGNOSTICS
Upon successful completion, a value of 0 is returned. Otherwise,
a value of -1 is returned, and errno set to indicate the error.