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

  1. /*
  2.  *    Copyright (c) 1989-1992 Citadel Software, Inc.
  3.  *    All Rights Reserved
  4.  */
  5.  
  6. /* #ident    "@(#)cbgetrf.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.      cbgetrf - get cbase record field
  23.  
  24. SYNOPSIS
  25.      #include <cbase.h>
  26.  
  27.      int cbgetrf(cbp, field, buf)
  28.      cbase_t *cbp;
  29.      int field;
  30.      void *buf;
  31.  
  32. DESCRIPTION
  33.      The cbgetrf function reads the specified field from the current
  34.      record of cbase cbp into buf.  buf must point to a storage area
  35.      of size no less than the size of the specified field.
  36.  
  37.      cbgetrf will fail if one or more of the following is true:
  38.  
  39.      [EINVAL]       cbp is not a valid cbase pointer.
  40.      [EINVAL]       field is not a valid field number for
  41.                     cbase cbp.
  42.      [EINVAL]       buf is the NULL pointer.
  43.      [CBELOCK]      cbp is not read locked.
  44.      [CBENOPEN]     cbp is not open.
  45.      [CBENREC]      The record cursor for cbp is null.
  46.  
  47. SEE ALSO
  48.      cbcursor, cbgetr, cbputrf.
  49.  
  50. DIAGNOSTICS
  51.      Upon successful completion, a value of 0 is returned.  Otherwise,
  52.      a value of -1 is returned, and errno set to indicate the error.
  53.  
  54. ------------------------------------------------------------------------------*/
  55. #ifdef AC_PROTO
  56. int cbgetrf(cbase_t *cbp, int field, void *buf)
  57. #else
  58. int cbgetrf(cbp, field, buf)
  59. cbase_t *cbp;
  60. int field;
  61. void *buf;
  62. #endif
  63. {
  64.     /* validate arguments */
  65.     if (!cb_valid(cbp) || buf == NULL) {
  66.         errno = EINVAL;
  67.         return -1;
  68.     }
  69.  
  70.     /* check if not open */
  71.     if (!(cbp->flags & CBOPEN)) {
  72.         errno = CBENOPEN;
  73.         return -1;
  74.     }
  75.  
  76.     /* validate field argument */
  77.     if (field < 0 || field >= cbp->fldc) {
  78.         errno = EINVAL;
  79.         return -1;
  80.     }
  81.  
  82.     /* check if not read locked */
  83.     if (!(cbp->flags & CBRDLCK)) {
  84.         errno = CBELOCK;
  85.         return -1;
  86.     }
  87.  
  88.     /* check if cursor is null */
  89.     if (lscursor(cbp->lsp) == NULL) {
  90.         errno = CBENREC;
  91.         return -1;
  92.     }
  93.  
  94.     /* read field */
  95.     if (lsgetrf(cbp->lsp, cbp->fldv[field].offset, buf, cbp->fldv[field].len) == -1) {
  96.         CBERRLOG;
  97.         return -1;
  98.     }
  99.  
  100.     return 0;
  101. }
  102.