home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name FLLOCK -- Lock or unlock a section of a file
- * associated with a file handle.
- *
- * Synopsis ercode = fllock (handle, option, offset, length);
- *
- * int ercode DOS function error code.
- * int handle File handle of open file.
- * int option FL_LOCK or FL_UNLOCK.
- * unsigned long offset
- * Offset (in bytes) of beginning of
- * region to lock.
- * unsigned long length
- * Length (in bytes) of beginning of
- * region to lock.
- *
- * Description This function locks or unlocks a section of an open file
- * associated with the specified handle.
- *
- * DOS 3.10 or later is required. Earlier versions of DOS
- * return a value of 1 indicating that the function number
- * is unknown.
- *
- * The designated region of the file may extend beyond the
- * end of the file.
- *
- * Do not close the file or allow the program to terminate
- * without removing all locks.
- *
- * Returns ercode DOS function return code
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1987, 1989
- *
- **/
-
- #include <dos.h>
-
- #include <bfiles.h>
-
- #define LOCK_FUNC 0x5c
-
- int fllock (handle, option, offset, length)
- int handle, option;
- unsigned long offset, length;
- {
- union REGS regs;
-
- if (utdosmajor < 3) /* DOS version 2.x: */
- return 1; /* This function is unknown. */
-
- /* (Note: DOS 3.00 does not support function 0x5c but at least */
- /* it reports a valid error code & extended error information.) */
-
- regs.x.ax = utbyword (LOCK_FUNC, option);
- regs.x.bx = handle;
- regs.x.cx = (int) uthiword (offset);
- regs.x.dx = (int) utloword (offset);
- regs.x.si = (int) uthiword (length);
- regs.x.di = (int) utloword (length);
-
- int86 (FL_DOS_INT, ®s, ®s);
-
- return ((regs.x.cflag)
- ? (regs.h.al)
- : (0));
- }