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

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "cbgetrf.c    1.2 - 89/11/08" */
  5.  
  6. #include <blkio.h>
  7. #include <errno.h>
  8. #include <lseq.h>
  9. #include "cbase_.h"
  10.  
  11. /*man---------------------------------------------------------------------------
  12. NAME
  13.      cbgetrf - get cbase record field
  14.  
  15. SYNOPSIS
  16.      #include <cbase.h>
  17.  
  18.      int cbgetrf(cbp, field, buf)
  19.      cbase_t *cbp;
  20.      int field;
  21.      void *buf;
  22.  
  23. DESCRIPTION
  24.      The cbgetrf function reads the specified field from the current
  25.      record of cbase cbp into buf.  buf must point to a storage area
  26.      of size no less than the size of the specified field.
  27.  
  28.      cbgetrf will fail if one or more of the following is true:
  29.  
  30.      [EINVAL]       cbp is not a valid cbase pointer.
  31.      [EINVAL]       field is not a valid field number for
  32.                     cbase cbp.
  33.      [EINVAL]       buf is the NULL pointer.
  34.      [CBELOCK]      cbp is not read locked.
  35.      [CBENOPEN]     cbp is not open.
  36.      [CBENREC]      The record cursor for cbp is null.
  37.  
  38. SEE ALSO
  39.      cbcursor, cbgetr, cbputrf.
  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 cbgetrf(cbp, field, buf)
  47. cbase_t *cbp;
  48. int field;
  49. void *buf;
  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.     /* validate field argument */
  64.     if ((field < 0) || (field >= cbp->fldc)) {
  65.         errno = EINVAL;
  66.         return -1;
  67.     }
  68.  
  69.     /* check if not read locked */
  70.     if (!(cbp->flags & CBRDLCK)) {
  71.         errno = CBELOCK;
  72.         return -1;
  73.     }
  74.  
  75.     /* check if cursor is null */
  76.     if (lscursor(cbp->lsp) == NULL) {
  77.         errno = CBENREC;
  78.         return -1;
  79.     }
  80.  
  81.     /* read field */
  82.     if (lsgetrf(cbp->lsp, cbp->fldv[field].offset, buf, cbp->fldv[field].len) == -1) {
  83.         CBEPRINT;
  84.         return -1;
  85.     }
  86.  
  87.     errno = 0;
  88.     return 0;
  89. }
  90.