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

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "lsgetcur.c    1.1 - 89/07/03" */
  5.  
  6. #include <blkio.h>
  7. #include <errno.h>
  8. /* #include <string.h> */
  9. #include "lseq_.h"
  10.  
  11. /*man---------------------------------------------------------------------------
  12. NAME
  13.      lsgetcur - get lseq cursor
  14.  
  15. SYNOPSIS
  16.      #include <lseq.h>
  17.  
  18.      int lsgetcur(lsp, lspos_p)
  19.      lseq_t *lsp;
  20.      lspos_t *lspos_p;
  21.  
  22. DESCRIPTION
  23.      The lsgetcur function gets the current cursor position of lseq lsp and
  24.      copies it to the location pointed to by lspos_p.  A lseq position saved
  25.      with lsgetcur can be used to reposition to a record using lssetcur.  It
  26.      is important to remember that an lseq position saved with lsgetcur is
  27.      not valid after that lseq has been unlocked.
  28.  
  29.      lsgetcur will fail if one or more of the following is true:
  30.  
  31.      [EINVAL]       lsp is not a valid lseq pointer.
  32.      [EINVAL]       lspos_p is the NULL pointer.
  33.      [LSELOCK]      lsp is not locked.
  34.      [LSENOPEN]     lsp is not open.
  35.  
  36. SEE ALSO
  37.      lssetcur.
  38.  
  39. DIAGNOSTICS
  40.      Upon successful completion, a value of 0 is returned.  Otherwise, a
  41.      value of -1 is returned, and errno set to indicate the error.
  42.  
  43. ------------------------------------------------------------------------------*/
  44. int lsgetcur(lsp, lspos_p)
  45. lseq_t *  lsp;
  46. lspos_t * lspos_p;
  47. {
  48.     errno = 0;
  49.  
  50.     /* validate arguments */
  51.     if ((!ls_valid(lsp)) || (lspos_p == NULL)) {
  52.         errno = EINVAL;
  53.         return -1;
  54.     }
  55.  
  56.     /* check if not open */
  57.     if (!(lsp->flags & LSOPEN)) {
  58.         errno = EINVAL;
  59.         return -1;
  60.     }
  61.  
  62.     /* check if not read locked */
  63.     if (!(lsp->flags & LSLOCKS)) {
  64.         errno = LSELOCK;
  65.         return -1;
  66.     }
  67.  
  68.     /* get current position */
  69.     memcpy((void *)lspos_p, (void *)&lsp->clspos, sizeof(lsp->clspos));
  70.  
  71.     errno = 0;
  72.     return 0;
  73. }
  74.