mdup.h: Remove spurious duplicate summary line from comment.
[mLib] / lock.h
1 /* -*-c-*-
2 *
3 * $Id: lock.h,v 1.3 2004/04/08 01:36:13 mdw Exp $
4 *
5 * Simplified POSIX locking interface
6 *
7 * (c) 1999 Straylight/Edgeware
8 */
9
10 /*----- Licensing notice --------------------------------------------------*
11 *
12 * This file is part of the mLib utilities library.
13 *
14 * mLib is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
18 *
19 * mLib is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
23 *
24 * You should have received a copy of the GNU Library General Public
25 * License along with mLib; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
27 * MA 02111-1307, USA.
28 */
29
30 #ifndef MLIB_LOCK_H
31 #define MLIB_LOCK_H
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 /*----- Magic constants ---------------------------------------------------*/
38
39 enum {
40 LOCK_UNLOCK, /* Release a lock I obtained */
41 LOCK_EXCL, /* Obtain an exclusive lock */
42 LOCK_NONEXCL /* Obtain a nonexclusive lock */
43 };
44
45 /*----- Functions provided ------------------------------------------------*/
46
47 /* --- @lock_file@ --- *
48 *
49 * Arguments: @int fd@ = file descriptor to lock
50 * @unsigned how@ = type of lock required
51 *
52 * Returns: 0 if OK, -1 if it failed.
53 *
54 * Use: Acquires a lock on the given file. The value @how@
55 * specifies the type of lock to acquire: @LOCK_EXCL@ gets
56 * an exclusive (write) lock; @LOCK_NONEXCL@ gets a non-
57 * exclusive (read) lock and @LOCK_UNLOCK@ releases any locks.
58 * Acquiring a lock gets timed out after a while with an
59 * error.
60 */
61
62 extern int lock_file(int /*fd*/, unsigned /*how*/);
63
64 /*----- That's all, folks -------------------------------------------------*/
65
66 #ifdef __cplusplus
67 }
68 #endif
69
70 #endif