home *** CD-ROM | disk | FTP | other *** search
-
- /*
- d4unlock() (c)Copyright Sequiter Software Inc., 1987, 1988, 1989. All rights reserved.
-
- - unlocks the previos lock for that database
- */
-
- #include "d4base.h"
- #include "u4error.h"
- #ifndef UNIX
- #include <io.h>
- #include <errno.h>
-
- #ifndef TURBO
- #include <sys\locking.h>
- #endif
- #endif
- #include <stdlib.h>
-
- #ifdef UNIX
- extern int errno ;
- #endif
-
- extern BASE *v4base ;
- extern int v4cur_base ;
-
-
- int d4unlock( lock_code )
- long lock_code ;
- {
- int rc ;
- BASE *base_ptr ;
-
- if ( v4cur_base < 0 )
- {
- u4error( E_D_MISSING, (char *) 0 ) ;
- return( -1 ) ;
- }
-
- #ifndef SMALL
- if ( lock_code == -1 )
- if ( i4unlock( -1 ) < 0 ) return( -1 ) ;
- #endif
-
- base_ptr = v4base + v4cur_base ;
- rc = errno = 0 ;
-
- if ( base_ptr->file_lock == 1 && lock_code == -1 )
- {
- /* The Whole File */
- rc = u4unlock( base_ptr->dos_file, LOCK_START, LOCK_START ) ;
- base_ptr->file_lock = 0 ;
- base_ptr->rec_lock = 0 ;
- }
- else
- {
- if ( base_ptr->file_lock == 2 && (lock_code == -1 || lock_code == 0) )
- {
- /* Record Count Bytes */
- rc = u4unlock(base_ptr->dos_file, LOCK_START, 1L) ;
- base_ptr->file_lock = 0 ;
- }
-
- if ( base_ptr->rec_lock > 0 && (lock_code == -1 || lock_code > 0) )
- {
- rc = u4unlock(base_ptr->dos_file, LOCK_START+base_ptr->rec_lock, 1L) ;
- base_ptr->rec_lock = 0 ;
- }
- }
-
- return( rc ) ;
- }
-