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

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "cbsetrcu.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.      cbsetrcur - set cbase record cursor
  14.  
  15. SYNOPSIS
  16.      #include <cbase.h>
  17.  
  18.      int cbsetrcur(cbp, cbrpos_p)
  19.      cbase_t *cbp;
  20.      cbrpos_t *cbrpos_p;
  21.  
  22. DESCRIPTION
  23.      The cbsetrcur function sets the position of the record cursor of
  24.      cbase cbp to the value pointed to by cbpos_p.  If cbrpos_p is the
  25.      NULL pointer, the record cursor is set to null.
  26.  
  27.      cbsetrcur will fail if one or more of the following is true:
  28.  
  29.      [EINVAL]       cbp is not a valid cbase pointer.
  30.      [CBELOCK]      cbp is not locked.
  31.      [CBENOPEN]     cbp is not open.
  32.  
  33. SEE ALSO
  34.      cbgetrcur, cbrcursor, cbsetkcur.
  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 cbsetrcur(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)) {
  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.     /* set record cursor position */
  69.     if (cbrpos_p == NULL) {
  70.         rs = lssetcur(cbp->lsp, NULL);
  71.     } else {
  72.         lspos = *cbrpos_p;
  73.         rs = lssetcur(cbp->lsp, &lspos);
  74.     }
  75.     if (rs == -1) {
  76.         CBEPRINT;
  77.         return -1;
  78.     }
  79.  
  80.     errno = 0;
  81.     return 0;
  82. }
  83.