]> diplodocus.org Git - nmh/commitdiff
h/prototypes.h: Give sbr/lock_file.c's prototypes their own header.
authorRalph Corderoy <ralph@inputplus.co.uk>
Mon, 15 May 2017 22:54:05 +0000 (23:54 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Mon, 15 May 2017 22:54:05 +0000 (23:54 +0100)
17 files changed:
Makefile.am
h/prototypes.h
sbr/context_read.c
sbr/context_save.c
sbr/folder_free.c
sbr/lock_file.c
sbr/lock_file.h [new file with mode: 0644]
sbr/oauth.c
sbr/seq_read.c
sbr/seq_save.c
uip/annosbr.c
uip/dropsbr.c
uip/inc.c
uip/mhcachesbr.c
uip/mhlogin.c
uip/new.c
uip/slocal.c

index c1a39063a2e60bee0ad2105806501fd263b015ee..c3c1956654bf0a3cb4a24f0395df824559780768 100644 (file)
@@ -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 \
index c582ae7485fe7509d5906045e815b73069b301be..76332fed967856cdfb4029237c691db468ec5123 100644 (file)
@@ -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 *);
index 668fdc3b51565fc57dbc131f67db0dcc55176888..936bf2dd55030f105b332567d811bbbc5a43c056 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <h/mh.h>                              /* mh internals */
+#include "lock_file.h"
 #include <pwd.h>                               /* structure for getpwuid() results */
 
 void
index 39bbf40ebaac585584ee2596907dc2defcbb08a6..9f53397bfb2b2fa795e5be0018565d3461805213 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <h/mh.h>
 #include <h/signals.h>
+#include "lock_file.h"
 
 void
 context_save (void)
index be2771f7e7de46f56700e8ffaf0e783e1b6ab8bd..cf85af183a6b2b04875d55b4da8b570816c68997 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <h/mh.h>
 #include <h/utils.h>
+#include "lock_file.h"
 
 
 void
index c7002b2e361a954f015250097f10d8f52ffd8954..c3dbbd9cf057011b7edce3313c0a3dbbefa9c6ff 100644 (file)
@@ -17,6 +17,7 @@
 #include <h/signals.h>
 #include <h/utils.h>
 #include <h/mts.h>
+#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 (file)
index 0000000..5bb625a
--- /dev/null
@@ -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);
index ccc2ad3c857b5ab7d3979dc3516a99143137613b..76ff8794c65859410e9bb8a57ac10b450933f0c2 100755 (executable)
@@ -24,6 +24,7 @@
 
 #include <h/oauth.h>
 #include <h/utils.h>
+#include "lock_file.h"
 
 #define JSON_TYPE "application/json"
 
index c7f1beac1c69eb79b843d964819481542630cd87..500ea0b90f9b576d2e0d624c8b832987596957f5 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <h/mh.h>
 #include <h/utils.h>
+#include "lock_file.h"
 
 /*
  * static prototypes
index 787db946f70280a833641a4321d7df751ccddf7b..ac7b53e96f7b5b96b9577f1d4efdb6b2e6d30223 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <h/mh.h>
 #include <h/signals.h>
+#include "lock_file.h"
 #include "m_mktemp.h"
 
 
index 778e2ab2c9be8f55a7dd18a17d7385a70eb8d0bd..08201244b2d78865f4f6b0f931b23b79959f4a1d 100644 (file)
@@ -8,6 +8,7 @@
 #include <h/mh.h>
 #include <h/tws.h>
 #include <h/utils.h>
+#include "../sbr/lock_file.h"
 #include "../sbr/m_mktemp.h"
 #include <fcntl.h>
 #include <utime.h>
index e3fcb0d45afc5dd5e855533ba59d2aa1fcf5aaa5..c492b18a1b6d27c9c602590c483a47dd726667cc 100644 (file)
@@ -12,6 +12,7 @@
 #include <h/dropsbr.h>
 #include <h/mts.h>
 #include <h/tws.h>
+#include "../sbr/lock_file.h"
 #include "../sbr/m_mktemp.h"
 
 #ifdef NTOHLSWAP
index fded9267bb5b69a7ef9081b26552cb11daf28d6d..38ab236c4dd1dac6341b7859efa6bc1e6287071a 100644 (file)
--- a/uip/inc.c
+++ b/uip/inc.c
@@ -40,6 +40,7 @@
 #include <h/signals.h>
 #include <h/tws.h>
 #include <h/mts.h>
+#include "../sbr/lock_file.h"
 #include "../sbr/m_mktemp.h"
 
 #ifndef TLS_SUPPORT
index 55a41d5d423276d76fd6d12412ac40eb8482c130..f343bf394878d486687efac22e262450b945181f 100644 (file)
@@ -14,6 +14,7 @@
 #include <h/mhparse.h>
 #include <h/mhcachesbr.h>
 #include <h/utils.h>
+#include "../sbr/lock_file.h"
 #include "../sbr/m_mktemp.h"
 
 #ifdef HAVE_SYS_TIME_H
index 32183863c1f403a080e0f4c3ca59686a5a56b419..1cc1c23ca7d581623dca9d4a958e2c24da04c1f9 100644 (file)
@@ -12,6 +12,7 @@
 #include <h/mh.h>
 #include <h/utils.h>
 #include <h/oauth.h>
+#include "../sbr/lock_file.h"
 
 #define MHLOGIN_SWITCHES \
     X("user username", 0, USERSW) \
index 8e3c3505a651a195b8510008079ebf0a066caf18..70ee8cc7f556a6b0245f7d2b76317663b4eab9c5 100644 (file)
--- a/uip/new.c
+++ b/uip/new.c
@@ -14,6 +14,7 @@
 #include <h/mh.h>
 #include <h/crawl_folders.h>
 #include <h/utils.h>
+#include "../sbr/lock_file.h"
 
 #define NEW_SWITCHES \
     X("mode", 1, MODESW) \
index 60b222d7940aa7057d3386ac45188fa70c90043c..cfbba804b759d77887042fb6cee75ae98d50cd0e 100644 (file)
@@ -27,6 +27,7 @@
 #include <h/tws.h>
 #include <h/mts.h>
 #include <h/utils.h>
+#include "../sbr/lock_file.h"
 #include "../sbr/m_mktemp.h"
 
 #include <pwd.h>