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

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "cbgetr.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.      cbgetr - get cbase record
  14.  
  15. SYNOPSIS
  16.      #include <cbase.h>
  17.  
  18.      int cbgetr(cbp, buf)
  19.      cbase_t *cbp;
  20.      void *buf;
  21.  
  22. DESCRIPTION
  23.      The cbgetr function reads the current record of cbase cbp into buf.
  24.      buf must point to a storage area at least as large as the record size
  25.      for cbp.
  26.  
  27.      cbgetr will fail if one or more of the following is true:
  28.  
  29.      [EINVAL]       cbp is not a valid cbase pointer.
  30.      [EINVAL]       buf is the NULL pointer.
  31.      [CBELOCK]      cbp is not read locked.
  32.      [CBENOPEN]     cbp is not open.
  33.      [CBENREC]      The record cursor for cbp is null.
  34.  
  35. SEE ALSO
  36.      cbrcursor, cbrecsize, cbgetrf, cbputr.
  37.  
  38. DIAGNOSTICS
  39.      Upon successful completion, a value of 0 is returned.  Otherwise, a
  40.      value of -1 is returned, and errno set to indicate the error.
  41.  
  42. ------------------------------------------------------------------------------*/
  43. int cbgetr(cbp, buf)
  44. cbase_t * cbp;
  45. void *    buf;
  46. {
  47.     int rs = 0;
  48.  
  49.     errno = 0;
  50.  
  51.     /* validate arguments */
  52.     if ((!cb_valid(cbp)) || (buf == NULL)) {
  53.         errno = EINVAL;
  54.         return -1;
  55.     }
  56.  
  57.     /* check if not open */
  58.     if (!(cbp->flags & CBOPEN)) {
  59.         errno = CBENOPEN;
  60.         return -1;
  61.     }
  62.  
  63.     /* check if not read locked */
  64.     if (!(cbp->flags & CBRDLCK)) {
  65.         errno = CBELOCK;
  66.         return -1;
  67.     }
  68.  
  69.     /* check if cursor is null */
  70.     if (lscursor(cbp->lsp) == NULL) {
  71.         errno = CBENREC;
  72.         return -1;
  73.     }
  74.  
  75.     /* read field */
  76.     rs = lsgetr(cbp->lsp, buf);
  77.     if (rs == -1) {
  78.         CBEPRINT;
  79.         return -1;
  80.     }
  81.  
  82.     errno = 0;
  83.     return 0;
  84. }
  85.