From: Ralph Corderoy Date: Mon, 15 May 2017 22:54:05 +0000 (+0100) Subject: h/prototypes.h: Give sbr/lock_file.c's prototypes their own header. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/544d69c657e0d33176b47afc9288ce0a588aff6d?ds=inline;hp=--cc h/prototypes.h: Give sbr/lock_file.c's prototypes their own header. --- 544d69c657e0d33176b47afc9288ce0a588aff6d diff --git a/Makefile.am b/Makefile.am index c1a39063..c3c19566 100644 --- a/Makefile.am +++ b/Makefile.am @@ -358,6 +358,7 @@ noinst_HEADERS = \ h/utils.h \ mts/smtp/smtp.h \ sbr/ctype-checked.h \ + sbr/lock_file.h \ sbr/m_mktemp.h \ thirdparty/jsmn/jsmn.h \ uip/mhfree.h \ diff --git a/h/prototypes.h b/h/prototypes.h index c582ae74..76332fed 100644 --- a/h/prototypes.h +++ b/h/prototypes.h @@ -221,28 +221,6 @@ char *get_term_stringparm(char *capability, long arg1, long arg2); */ int get_term_numcap(char *capability); -/* - * Lock open/close routines. - * - * The lk[f]opendata() functions are designed to open "data" files (anything - * not a mail spool file) using the locking mechanism configured for data - * files. The lk[f]openspool() functions are for opening the mail spool - * file, which will use the locking algorithm configured for the mail - * spool. - * - * Files opened for reading are locked with a read lock (if possible by - * the underlying lock mechanism), files opened for writing are locked - * using an exclusive lock. The int * argument is used to indicate failure - * to acquire a lock. - */ -int lkclosedata(int, const char *); -int lkclosespool(int, const char *); -int lkfclosedata(FILE *, const char *); -int lkfclosespool(FILE *, const char *); -FILE *lkfopendata(const char *, const char *, int *); -int lkopendata(const char *, int, mode_t, int *); -FILE *lkfopenspool(const char *, const char *); -int lkopenspool(const char *, int, mode_t, int *); int m_atoi (char *); char *m_backup (const char *); int m_convert (struct msgs *, char *); diff --git a/sbr/context_read.c b/sbr/context_read.c index 668fdc3b..936bf2dd 100644 --- a/sbr/context_read.c +++ b/sbr/context_read.c @@ -22,6 +22,7 @@ */ #include /* mh internals */ +#include "lock_file.h" #include /* structure for getpwuid() results */ void diff --git a/sbr/context_save.c b/sbr/context_save.c index 39bbf40e..9f53397b 100644 --- a/sbr/context_save.c +++ b/sbr/context_save.c @@ -13,6 +13,7 @@ #include #include +#include "lock_file.h" void context_save (void) diff --git a/sbr/folder_free.c b/sbr/folder_free.c index be2771f7..cf85af18 100644 --- a/sbr/folder_free.c +++ b/sbr/folder_free.c @@ -7,6 +7,7 @@ #include #include +#include "lock_file.h" void diff --git a/sbr/lock_file.c b/sbr/lock_file.c index c7002b2e..c3dbbd9c 100644 --- a/sbr/lock_file.c +++ b/sbr/lock_file.c @@ -17,6 +17,7 @@ #include #include #include +#include "lock_file.h" #include "m_mktemp.h" #ifdef HAVE_SYS_TIME_H diff --git a/sbr/lock_file.h b/sbr/lock_file.h new file mode 100644 index 00000000..5bb625af --- /dev/null +++ b/sbr/lock_file.h @@ -0,0 +1,29 @@ +/* lock_file.h -- lock and unlock files. + * + * This code is Copyright (c) 2017, by the authors of nmh. See the + * COPYRIGHT file in the root directory of the nmh distribution for + * complete copyright information. + */ + +/* + * Lock open/close routines. + * + * The lk[f]opendata() functions are designed to open "data" files (anything + * not a mail spool file) using the locking mechanism configured for data + * files. The lk[f]openspool() functions are for opening the mail spool + * file, which will use the locking algorithm configured for the mail + * spool. + * + * Files opened for reading are locked with a read lock (if possible by + * the underlying lock mechanism), files opened for writing are locked + * using an exclusive lock. The int * argument is used to indicate failure + * to acquire a lock. + */ +int lkopendata(const char *file, int access, mode_t mode, int *failed_to_lock); +int lkopenspool(const char *file, int access, mode_t mode, int *failed_to_lock); +FILE *lkfopendata(const char *file, const char *mode, int *failed_to_lock); +FILE *lkfopenspool(const char *file, const char *mode); +int lkclosedata(int fd, const char *name); +int lkfclosedata(FILE *f, const char *name); +int lkclosespool(int fd, const char *name); +int lkfclosespool(FILE *f, const char *name); diff --git a/sbr/oauth.c b/sbr/oauth.c index ccc2ad3c..76ff8794 100755 --- a/sbr/oauth.c +++ b/sbr/oauth.c @@ -24,6 +24,7 @@ #include #include +#include "lock_file.h" #define JSON_TYPE "application/json" diff --git a/sbr/seq_read.c b/sbr/seq_read.c index c7f1beac..500ea0b9 100644 --- a/sbr/seq_read.c +++ b/sbr/seq_read.c @@ -8,6 +8,7 @@ #include #include +#include "lock_file.h" /* * static prototypes diff --git a/sbr/seq_save.c b/sbr/seq_save.c index 787db946..ac7b53e9 100644 --- a/sbr/seq_save.c +++ b/sbr/seq_save.c @@ -8,6 +8,7 @@ #include #include +#include "lock_file.h" #include "m_mktemp.h" diff --git a/uip/annosbr.c b/uip/annosbr.c index 778e2ab2..08201244 100644 --- a/uip/annosbr.c +++ b/uip/annosbr.c @@ -8,6 +8,7 @@ #include #include #include +#include "../sbr/lock_file.h" #include "../sbr/m_mktemp.h" #include #include diff --git a/uip/dropsbr.c b/uip/dropsbr.c index e3fcb0d4..c492b18a 100644 --- a/uip/dropsbr.c +++ b/uip/dropsbr.c @@ -12,6 +12,7 @@ #include #include #include +#include "../sbr/lock_file.h" #include "../sbr/m_mktemp.h" #ifdef NTOHLSWAP diff --git a/uip/inc.c b/uip/inc.c index fded9267..38ab236c 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -40,6 +40,7 @@ #include #include #include +#include "../sbr/lock_file.h" #include "../sbr/m_mktemp.h" #ifndef TLS_SUPPORT diff --git a/uip/mhcachesbr.c b/uip/mhcachesbr.c index 55a41d5d..f343bf39 100644 --- a/uip/mhcachesbr.c +++ b/uip/mhcachesbr.c @@ -14,6 +14,7 @@ #include #include #include +#include "../sbr/lock_file.h" #include "../sbr/m_mktemp.h" #ifdef HAVE_SYS_TIME_H diff --git a/uip/mhlogin.c b/uip/mhlogin.c index 32183863..1cc1c23c 100644 --- a/uip/mhlogin.c +++ b/uip/mhlogin.c @@ -12,6 +12,7 @@ #include #include #include +#include "../sbr/lock_file.h" #define MHLOGIN_SWITCHES \ X("user username", 0, USERSW) \ diff --git a/uip/new.c b/uip/new.c index 8e3c3505..70ee8cc7 100644 --- a/uip/new.c +++ b/uip/new.c @@ -14,6 +14,7 @@ #include #include #include +#include "../sbr/lock_file.h" #define NEW_SWITCHES \ X("mode", 1, MODESW) \ diff --git a/uip/slocal.c b/uip/slocal.c index 60b222d7..cfbba804 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -27,6 +27,7 @@ #include #include #include +#include "../sbr/lock_file.h" #include "../sbr/m_mktemp.h" #include