home *** CD-ROM | disk | FTP | other *** search
/ Frostbyte's 1980s DOS Shareware Collection / floppyshareware.zip / floppyshareware / DOOG / CBASE09.ZIP / CBASE.ZIP / CBGETRCU.C < prev    next >
Text File  |  1989-08-31  |  2KB  |  81 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "cbgetrcu.c    1.1 - 89/08/31" */
  5.  
  6. #include <blkio.h>
  7. #include <errno.h>
  8. #include <lseq.h>
  9. #include "cbase_.h"
  10.  
  11. /*man---------------------------------------------------------------------------
  12. NAME
  13.      cbgetrcur - get cbase record cursor
  14.  
  15. SYNOPSIS
  16.      #include <cbase.h>
  17.  
  18.      int cbgetrcur(cbp, cbrpos_p)
  19.      cbase_t *cbp;
  20.      cbrpos_t *cbrpos_p;
  21.  
  22. DESCRIPTION
  23.      The cbgetrcur function gets the position of the record cursor of
  24.      cbase cbp into the location pointed to by cbrpos_p.
  25.  
  26.      cbgetrcur will fail if one or more of the following is true:
  27.  
  28.      [EINVAL]       cbp is not a valid cbase pointer.
  29.      [EINVAL]       cbrpos_p is the NULL pointer.
  30.      [CBELOCK]      cbp is not locked.
  31.      [CBENOPEN]     cbp is not open.
  32.  
  33. SEE ALSO
  34.      cbgetkcur, cbrcursor, cbsetrcur.
  35.  
  36. DIAGNOSTICS
  37.      Upon successful completion, a value of 0 is returned.  Otherwise, a
  38.      value of -1 is returned, and errno set to indicate the error.
  39.  
  40. ------------------------------------------------------------------------------*/
  41. int cbgetrcur(cbp, cbrpos_p)
  42. cbase_t *  cbp;
  43. cbrpos_t * cbrpos_p;
  44. {
  45.     int    rs    = 0;
  46.     lspos_t    lspos    = 0;
  47.  
  48.     errno = 0;
  49.  
  50.     /* validate arguments */
  51.     if ((!cb_valid(cbp)) || (cbrpos_p == NULL)) {
  52.         errno = EINVAL;
  53.         return -1;
  54.     }
  55.  
  56.     /* check if not open */
  57.     if (!(cbp->flags & CBOPEN)) {
  58.         errno = CBENOPEN;
  59.         return -1;
  60.     }
  61.  
  62.     /* check if not locked */
  63.     if (!(cbp->flags & CBLOCKS)) {
  64.         errno = CBELOCK;
  65.         return -1;
  66.     }
  67.  
  68.     /* get record cursor position */
  69.     rs = lsgetcur(cbp->lsp, &lspos);
  70.     if (rs == -1) {
  71.         CBEPRINT;
  72.         return -1;
  73.     }
  74.  
  75.     /* load return argument */
  76.     *cbrpos_p = lspos;
  77.  
  78.     errno = 0;
  79.     return 0;
  80. }
  81.