home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frostbyte's 1980s DOS Shareware Collection
/
floppyshareware.zip
/
floppyshareware
/
DOOG
/
CBASE09.ZIP
/
CBASE.ZIP
/
CBGETKCU.C
< prev
next >
Wrap
Text File
|
1989-08-31
|
2KB
|
95 lines
/* Copyright (c) 1989 Citadel */
/* All Rights Reserved */
/* #ident "cbgetkcu.c 1.1 - 89/08/31" */
#include <blkio.h>
#include <btree.h>
#include <errno.h>
/* #include <string.h> */
#include "cbase_.h"
/*man---------------------------------------------------------------------------
NAME
cbgetkcur - get cbase key cursor
SYNOPSIS
#include <cbase.h>
int cbgetkcur(cbp, field, cbkpos_p)
cbase_t *cbp;
int field;
cbkpos_t *cbkpos_p;
DESCRIPTION
The cbgetkcur function gets the position of a key cursor for cbase
cbp into the location pointed to by cbkpos_p.
field is the field for which to get the key cursor.
cbgetkcur will fail if one or more of the following is true:
[EINVAL] cbp is not a valid cbase pointer.
[EINVAL] field is less than 1 or greater than
the number of fields defined for cbp.
[EINVAL] cbkpos_p is the NULL pointer.
[CBELOCK] cbp is not locked.
[CBENOPEN] cbp is not open.
SEE ALSO
cbgetrcur, cbsetkcur.
DIAGNOSTICS
Upon successful completion, a value of 0 is returned. Otherwise, a
value of -1 is returned, and errno set to indicate the error.
------------------------------------------------------------------------------*/
int cbgetkcur(cbp, field, cbkpos_p)
cbase_t * cbp;
int field;
cbkpos_t * cbkpos_p;
{
int rs = 0;
btpos_t btpos;
errno = 0;
/* initialize storage */
memset((void *)&btpos, 0, sizeof(btpos));
/* validate arguments */
if ((!cb_valid(cbp)) || (cbkpos_p == NULL)) {
errno = EINVAL;
return -1;
}
if ((field < 1) || (field > cbp->fldcnt)) {
errno = EINVAL;
return -1;
}
/* check if not open */
if (!(cbp->flags & CBOPEN)) {
errno = CBENOPEN;
return -1;
}
/* check if not locked */
if (!(cbp->flags & CBLOCKS)) {
errno = CBELOCK;
return -1;
}
/* get key cursor position */
rs = btgetcur(cbp->btp[field - 1], &btpos);
if (rs == -1) {
CBEPRINT;
return -1;
}
/* load return argument */
memcpy((void *)cbkpos_p, (void *)&btpos, sizeof(cbkpos_t));
errno = 0;
return 0;
}