Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C Library Reference - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <io.h>
    int unlock( int handle,
                unsigned long offset,
                unsigned long nbytes );

Description:
    The unlock function unlocks nbytes amount of previously locked data in
    the file designated by handle starting at byte offset in the file.  This
    allows other processes to lock this region of the file.

    Multiple regions of a file can be locked, but no overlapping regions are
    allowed.  You cannot unlock multiple regions in the same call, even if
    the regions are contiguous.  All locked regions of a file should be
    unlocked before closing a file or exiting the program.

    With DOS, locking is supported by version 3.0 or later.  Note that
    SHARE.COM or SHARE.EXE must be installed.

Returns:
    The unlock function returns zero if successful, and -1 when an error
    occurs.  When an error has occurred,  errno contains a value indicating
    the type of error that has been detected.

Example:
    #include <stdio.h>
    #include <fcntl.h>
    #include <io.h>

    void main()
      {
        int handle;
        char buffer[20];

        handle = open( "file", O_RDWR | O_TEXT );
        if( handle != -1 ) {
          if( lock( handle, 0L, 20L ) ) {
            printf( "Lock failed\n" );
          } else {
            read( handle, buffer, 20 );
            /* update the buffer here */
            lseek( handle, 0L, SEEK_SET );
            write( handle, buffer, 20 );
            unlock( handle, 0L, 20L );
          }
          close( handle );
        }
      }

Classification:
    WATCOM

Systems:
    All, Netware

See Also:
    lock, locking, open, sopen

See Also: lock

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson