83c5b2754d8433e74a86b40eac667e23caf5890c
3 * Simplified POSIX locking interface
5 * (c) 1999 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of the mLib utilities library.
12 * mLib is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
17 * mLib is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with mLib; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
35 /*----- Magic constants ---------------------------------------------------*/
38 LOCK_UNLOCK
, /* Release a lock I obtained */
39 LOCK_EXCL
, /* Obtain an exclusive lock */
40 LOCK_NONEXCL
/* Obtain a nonexclusive lock */
43 /*----- Functions provided ------------------------------------------------*/
45 /* --- @lock_file@ --- *
47 * Arguments: @int fd@ = file descriptor to lock
48 * @unsigned how@ = type of lock required
50 * Returns: 0 if OK, -1 if it failed.
52 * Use: Acquires a lock on the given file. The value @how@
53 * specifies the type of lock to acquire: @LOCK_EXCL@ gets
54 * an exclusive (write) lock; @LOCK_NONEXCL@ gets a non-
55 * exclusive (read) lock and @LOCK_UNLOCK@ releases any locks.
56 * Acquiring a lock gets timed out after a while with an
60 extern int lock_file(int /*fd*/, unsigned /*how*/);
62 /*----- That's all, folks -------------------------------------------------*/