]> 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 c1a3906..c3c1956 100644 (file)
@@ -358,6 +358,7 @@ noinst_HEADERS = \
     h/utils.h \
     mts/smtp/smtp.h \
     sbr/ctype-checked.h \
     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 \
     sbr/m_mktemp.h \
     thirdparty/jsmn/jsmn.h \
     uip/mhfree.h \
index c582ae7..76332fe 100644 (file)
@@ -221,28 +221,6 @@ char *get_term_stringparm(char *capability, long arg1, long arg2);
  */
 int get_term_numcap(char *capability);
 
  */
 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 *);
 int m_atoi (char *);
 char *m_backup (const char *);
 int m_convert (struct msgs *, char *);
index 668fdc3..936bf2d 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <h/mh.h>                              /* mh internals */
  */
 
 #include <h/mh.h>                              /* mh internals */
+#include "lock_file.h"
 #include <pwd.h>                               /* structure for getpwuid() results */
 
 void
 #include <pwd.h>                               /* structure for getpwuid() results */
 
 void
index 39bbf40..9f53397 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <h/mh.h>
 #include <h/signals.h>
 
 #include <h/mh.h>
 #include <h/signals.h>
+#include "lock_file.h"
 
 void
 context_save (void)
 
 void
 context_save (void)
index be2771f..cf85af1 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <h/mh.h>
 #include <h/utils.h>
 
 #include <h/mh.h>
 #include <h/utils.h>
+#include "lock_file.h"
 
 
 void
 
 
 void
index c7002b2..c3dbbd9 100644 (file)
@@ -17,6 +17,7 @@
 #include <h/signals.h>
 #include <h/utils.h>
 #include <h/mts.h>
 #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
 #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 ccc2ad3..76ff879 100755 (executable)
@@ -24,6 +24,7 @@
 
 #include <h/oauth.h>
 #include <h/utils.h>
 
 #include <h/oauth.h>
 #include <h/utils.h>
+#include "lock_file.h"
 
 #define JSON_TYPE "application/json"
 
 
 #define JSON_TYPE "application/json"
 
index c7f1bea..500ea0b 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <h/mh.h>
 #include <h/utils.h>
 
 #include <h/mh.h>
 #include <h/utils.h>
+#include "lock_file.h"
 
 /*
  * static prototypes
 
 /*
  * static prototypes
index 787db94..ac7b53e 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <h/mh.h>
 #include <h/signals.h>
 
 #include <h/mh.h>
 #include <h/signals.h>
+#include "lock_file.h"
 #include "m_mktemp.h"
 
 
 #include "m_mktemp.h"
 
 
index 778e2ab..0820124 100644 (file)
@@ -8,6 +8,7 @@
 #include <h/mh.h>
 #include <h/tws.h>
 #include <h/utils.h>
 #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>
 #include "../sbr/m_mktemp.h"
 #include <fcntl.h>
 #include <utime.h>
index e3fcb0d..c492b18 100644 (file)
@@ -12,6 +12,7 @@
 #include <h/dropsbr.h>
 #include <h/mts.h>
 #include <h/tws.h>
 #include <h/dropsbr.h>
 #include <h/mts.h>
 #include <h/tws.h>
+#include "../sbr/lock_file.h"
 #include "../sbr/m_mktemp.h"
 
 #ifdef NTOHLSWAP
 #include "../sbr/m_mktemp.h"
 
 #ifdef NTOHLSWAP
index fded926..38ab236 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 <h/signals.h>
 #include <h/tws.h>
 #include <h/mts.h>
+#include "../sbr/lock_file.h"
 #include "../sbr/m_mktemp.h"
 
 #ifndef TLS_SUPPORT
 #include "../sbr/m_mktemp.h"
 
 #ifndef TLS_SUPPORT
index 55a41d5..f343bf3 100644 (file)
@@ -14,6 +14,7 @@
 #include <h/mhparse.h>
 #include <h/mhcachesbr.h>
 #include <h/utils.h>
 #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
 #include "../sbr/m_mktemp.h"
 
 #ifdef HAVE_SYS_TIME_H
index 3218386..1cc1c23 100644 (file)
@@ -12,6 +12,7 @@
 #include <h/mh.h>
 #include <h/utils.h>
 #include <h/oauth.h>
 #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) \
 
 #define MHLOGIN_SWITCHES \
     X("user username", 0, USERSW) \
index 8e3c350..70ee8cc 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 <h/mh.h>
 #include <h/crawl_folders.h>
 #include <h/utils.h>
+#include "../sbr/lock_file.h"
 
 #define NEW_SWITCHES \
     X("mode", 1, MODESW) \
 
 #define NEW_SWITCHES \
     X("mode", 1, MODESW) \
index 60b222d..cfbba80 100644 (file)
@@ -27,6 +27,7 @@
 #include <h/tws.h>
 #include <h/mts.h>
 #include <h/utils.h>
 #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>
 #include "../sbr/m_mktemp.h"
 
 #include <pwd.h>