home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR41 / CBASE11.ZIP / CBGETR.C < prev    next >
C/C++ Source or Header  |  1993-01-01  |  2KB  |  92 lines

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