1 /* lock_file.h -- lock and unlock files.
2  *
3  * This code is Copyright (c) 2017, by the authors of nmh.  See the
4  * COPYRIGHT file in the root directory of the nmh distribution for
5  * complete copyright information.
6  */
7 
8 /*
9  * Lock open/close routines.
10  *
11  * The lk[f]opendata() functions are designed to open "data" files (anything
12  * not a mail spool file) using the locking mechanism configured for data
13  * files.  The lk[f]openspool() functions are for opening the mail spool
14  * file, which will use the locking algorithm configured for the mail
15  * spool.
16  *
17  * Files opened for reading are locked with a read lock (if possible by
18  * the underlying lock mechanism), files opened for writing are locked
19  * using an exclusive lock.  The int * argument is used to indicate failure
20  * to acquire a lock.
21  */
22 int lkopendata(const char *file, int access, mode_t mode, int *failed_to_lock);
23 int lkopenspool(const char *file, int access, mode_t mode, int *failed_to_lock);
24 FILE *lkfopendata(const char *file, const char *mode, int *failed_to_lock);
25 FILE *lkfopenspool(const char *file, const char *mode);
26 int lkclosedata(int fd, const char *name);
27 int lkfclosedata(FILE *f, const char *name);
28 int lkclosespool(int fd, const char *name);
29 int lkfclosespool(FILE *f, const char *name);
30