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

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "lssync.c    1.1 - 89/07/03" */
  5.  
  6. #include <blkio.h>
  7. #include <errno.h>
  8. #include "lseq_.h"
  9.  
  10. /*man---------------------------------------------------------------------------
  11. NAME
  12.      lssync - lseq synchronize
  13.  
  14. SYNOPSIS
  15.      #include <lseq.h>
  16.  
  17.      int lssync(lsp);
  18.      lseq_t *lsp;
  19.  
  20. DESCRIPTION
  21.      The lssync function causes any buffered data for the named lseq to
  22.      be written to the file.  The lseq remains open and the buffer contents
  23.      remain intact.
  24.  
  25.      lssync will fail if one or more of the following is true:
  26.  
  27.      [EINVAL]       lsp is not a valid lseq pointer.
  28.      [LSENOPEN]     lsp is not open.
  29.  
  30. SEE ALSO
  31.      lsclose, lslock, lssetbuf, lssetvbuf.
  32.  
  33. DIAGNOSTICS
  34.      Upon successful completion, a value of 0 is returned.  Otherwise, a
  35.      value of -1 is returned, and errno set to indicate the error.
  36.  
  37. ------------------------------------------------------------------------------*/
  38. int lssync(lsp)
  39. lseq_t *lsp;
  40. {
  41.     int rs = 0;
  42.  
  43.     errno = 0;
  44.  
  45.     /* validate arguments */
  46.     if (!ls_valid(lsp)) {
  47.         errno = EINVAL;
  48.         return -1;
  49.     }
  50.  
  51.     /* check if not open */
  52.     if (!(lsp->flags & LSOPEN)) {
  53.         errno = LSENOPEN;
  54.         return -1;
  55.     }
  56.  
  57.     /* synchronize file with buffers */
  58.     rs = bsync(lsp->bp);
  59.     if (rs == -1) {
  60.         LSEPRINT;
  61.         return -1;
  62.     }
  63.  
  64.     errno = 0;
  65.     return 0;
  66. }
  67.