home *** CD-ROM | disk | FTP | other *** search
-
- /* u4unlock.c (c)Copyright Sequiter Software Inc., 1987-1990. All rights reserved.
-
- Returns
- 0 Normal
- -1 Error
- */
-
- #include "p4misc.h"
- #include "d4base.h"
- #include "u4error.h"
-
- #include <errno.h>
-
- #ifdef NO_LOCK
- u4unlock( int file_handle, long o_set, long num_bytes )
- {
- return 0 ;
- }
- #endif
-
- #ifdef LOCK_TRAP
- extern int u4lock_remove( int, long, long ) ;
- #endif
-
- #ifdef DO_ERRNO
- extern int errno ;
- #endif
-
- #ifdef DO_LOCK
-
- #include <io.h>
-
- u4unlock( int file_handle, long o_set, long num_bytes )
- {
- int rc ;
-
- #ifdef LOCK_TRAP
- d4lock_remove( file_handle, o_set, num_bytes ) ;
- #endif
-
- errno = 0 ;
- rc = unlock( file_handle, o_set, num_bytes ) ;
- #ifdef IS_386
- rc &= 0xFFFF ;
- #endif
-
- if (rc < 0 && errno != EINVAL )
- {
- u4error( E_UNLOCK, (char *) 0 ) ;
- return( -1) ;
- }
-
- return 0 ;
- }
- #endif
-
-
- #ifdef DO_LOCKING
-
- #ifndef UNIX
- #include <io.h>
- #endif
-
- #ifdef UNIX
- #include <sys/locking.h>
- #else
- #include <sys\locking.h>
- #endif
-
-
- u4unlock( int file_handle, long o_set, long num_bytes )
- {
- int rc ;
-
- #ifdef LOCK_TRAP
- d4lock_remove( file_handle, o_set, num_bytes ) ;
- #endif
-
- errno = 0 ;
-
- lseek( file_handle, o_set, 0 ) ;
- rc = locking( file_handle, LK_UNLCK, num_bytes) ;
- #ifdef IS_386
- rc &= 0xFFFF ;
- #endif
-
- if (rc < 0 && errno != EINVAL )
- {
- u4error( E_UNLOCK, (char *) 0 ) ;
- return( -1) ;
- }
-
- return 0 ;
- }
- #endif
-