home *** CD-ROM | disk | FTP | other *** search
/ PC Press 1997 July / Sezamfile97_1.iso / msdos / c / cbase11.a03 / CBASE11.ZIP / LSEQ / LSSYNC.C < prev    next >
C/C++ Source or Header  |  1993-01-01  |  2KB  |  74 lines

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