home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / CODE4-1.ZIP / SOURCE.ZIP / U4UNLOCK.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-10-14  |  864 b   |  52 lines

  1.  
  2. /* u4unlock.c    (c)Copyright Sequiter Software Inc., 1987, 1988, 1989.  All rights reserved.
  3.  
  4.    Returns
  5.       0   Normal
  6.      -1   Error
  7. */
  8.  
  9. #include "d4base.h"
  10. #include "u4error.h"
  11.  
  12. #ifndef UNIX
  13.    #include <io.h>
  14. #endif
  15. #ifndef TURBO
  16.    #ifdef UNIX
  17.       #include <sys/locking.h>
  18.    #else
  19.       #include <sys\locking.h>
  20.    #endif
  21. #endif
  22. #include <stdlib.h>
  23.  
  24. #include <errno.h>
  25.  
  26.  
  27. u4unlock( file_handle, o_set, num_bytes )
  28. int  file_handle ;
  29. long o_set, num_bytes ;
  30. {
  31.    int    rc ;
  32.  
  33.    errno =  0 ;
  34.  
  35.    #ifdef TURBO
  36.       rc =  unlock( file_handle, o_set, num_bytes ) ;
  37.    #else
  38.       lseek( file_handle, o_set, 0 ) ;
  39.       rc =  locking( file_handle, LK_UNLCK, num_bytes) ;
  40.    #endif
  41.  
  42.    if (rc < 0  && errno != EINVAL )
  43.    {
  44.       u4error( E_UNLOCK, (char *) 0 ) ;
  45.       return( -1) ;
  46.    }
  47.  
  48.    return 0 ;
  49. }
  50.  
  51.  
  52.