home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / cbase.zip / CBASE10B.ZIP / CBASE.ZIP / CBGETKCU.C < prev    next >
Text File  |  1989-11-08  |  2KB  |  92 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "cbgetkcu.c    1.2 - 89/11/08" */
  5.  
  6. #include <blkio.h>
  7. #include <btree.h>
  8. #include <errno.h>
  9. /*#include <string.h>*/
  10. #include "cbase_.h"
  11.  
  12. /*man---------------------------------------------------------------------------
  13. NAME
  14.      cbgetkcur - get cbase key cursor
  15.  
  16. SYNOPSIS
  17.      #include <cbase.h>
  18.  
  19.      int cbgetkcur(cbp, field, cbkpos_p)
  20.      cbase_t *cbp;
  21.      int field;
  22.      cbkpos_t *cbkpos_p;
  23.  
  24. DESCRIPTION
  25.      The cbgetkcur function gets the position of the key cursor of the
  26.      specified field in cbase cbp.  The cursor position is returned in
  27.      the location pointed to by cbkpos_p.
  28.  
  29.      cbgetkcur will fail if one or more of the following is true:
  30.  
  31.      [EINVAL]       cbp is not a valid cbase pointer.
  32.      [EINVAL]       field is not a valid field number for
  33.                     cbase cbp.
  34.      [EINVAL]       cbkpos_p is the NULL pointer.
  35.      [CBELOCK]      cbp is not locked.
  36.      [CBENOPEN]     cbp is not open.
  37.  
  38. SEE ALSO
  39.      cbgetrcur, cbsetkcur.
  40.  
  41. DIAGNOSTICS
  42.      Upon successful completion, a value of 0 is returned.  Otherwise,
  43.      a value of -1 is returned, and errno set to indicate the error.
  44.  
  45. ------------------------------------------------------------------------------*/
  46. int cbgetkcur(cbp, field, cbkpos_p)
  47. cbase_t *cbp;
  48. int field;
  49. cbkpos_t *cbkpos_p;
  50. {
  51.     btpos_t btpos;
  52.  
  53.     /* initialize storage */
  54.     memset(&btpos, 0, sizeof(btpos));
  55.  
  56.     /* validate arguments */
  57.     if (!cb_valid(cbp) || (cbkpos_p == NULL)) {
  58.         errno = EINVAL;
  59.         return -1;
  60.     }
  61.  
  62.     /* check if not open */
  63.     if (!(cbp->flags & CBOPEN)) {
  64.         errno = CBENOPEN;
  65.         return -1;
  66.     }
  67.  
  68.     /* validate arguments */
  69.     if ((field < 0) || (field >= cbp->fldc)) {
  70.         errno = EINVAL;
  71.         return -1;
  72.     }
  73.  
  74.     /* check if not locked */
  75.     if (!(cbp->flags & CBLOCKS)) {
  76.         errno = CBELOCK;
  77.         return -1;
  78.     }
  79.  
  80.     /* get key cursor position */
  81.     if (btgetcur(cbp->btpv[field], &btpos) == -1) {
  82.         CBEPRINT;
  83.         return -1;
  84.     }
  85.  
  86.     /* load return argument */
  87.     memcpy(cbkpos_p, &btpos, sizeof(cbkpos_t));
  88.  
  89.     errno = 0;
  90.     return 0;
  91. }
  92.