* please see the file GPL in the top level source directory.
*/
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include <lib-lib/lib-lib.h>
-#include <dirent.h>
-#include <fcntl.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
#include <utime.h>
-#include <lib-lib/mem.h>
-#include <lib-lib/ascii.h>
-#include <lib-lib/str.h>
-#include <lib-lib/macros.h>
-#include <lib-lib/file.h>
-#include <lib-lib/debug.h>
-
+#include <lib-sys/unix.h>
#include <lib-mime/mime.h>
+#include <lib-ui/sidebar.h>
#include "mutt.h"
#include "buffy.h"
#include "thread.h"
#include "copy.h"
#include "keymap.h"
-#include "url.h"
-#include "sidebar.h"
#include "compress.h"
#include <imap/imap.h>
/* Args:
* excl if excl != 0, request an exclusive lock
* dot if dot != 0, try to dotlock the file
- * timeout should retry locking?
+ * time_out should retry locking?
*/
-int mx_lock_file (const char *path, int fd, int excl, int dot, int timeout)
+int mx_lock_file (const char *path, int fd, int excl, int dot, int time_out)
{
#if defined (USE_FCNTL) || defined (USE_FLOCK)
int count;
while (fcntl (fd, F_SETLK, &lck) == -1) {
struct stat sb;
- debug_print (1, ("fcntl errno %d.\n", errno));
if (errno != EAGAIN && errno != EACCES) {
mutt_perror ("fcntl");
return (-1);
/* only unlock file if it is unchanged */
if (prev_sb.st_size == sb.st_size
- && ++count >= (timeout ? MAXLOCKATTEMPT : 0)) {
- if (timeout)
+ && ++count >= (time_out ? MAXLOCKATTEMPT : 0)) {
+ if (time_out)
mutt_error _("Timeout exceeded while attempting fcntl lock!");
return (-1);
/* only unlock file if it is unchanged */
if (prev_sb.st_size == sb.st_size
- && ++count >= (timeout ? MAXLOCKATTEMPT : 0)) {
- if (timeout)
+ && ++count >= (time_out ? MAXLOCKATTEMPT : 0)) {
+ if (time_out)
mutt_error _("Timeout exceeded while attempting flock lock!");
r = -1;
#ifdef USE_DOTLOCK
if (r == 0 && dot)
- r = dotlock_file (path, fd, timeout);
+ r = dotlock_file (path, fd, time_out);
#endif /* USE_DOTLOCK */
if (r == -1) {
address_t *p = NULL;
if (!MX_IDX(dest->magic-1)) {
- debug_print (1, ("function unimplemented for mailbox type %d.\n", dest->magic));
return (NULL);
}
return (MX_COMMAND(ctx->magic-1,mx_check_mailbox)(ctx, index_hint, lock));
}
- debug_print (1, ("null or invalid context.\n"));
return (-1);
-
}
/* return a stream pointer for a message */
if (msg->fp == NULL) {
mutt_perror (path);
- debug_print (1, ("fopen: %s: %s (errno %d).\n", path, strerror (errno), errno));
p_delete(&msg);
}
}
#endif /* USE_NNTP */
default:
- debug_print (1, ("function not implemented for mailbox type %d.\n", ctx->magic));
p_delete(&msg);
break;
}
int mx_commit_message (MESSAGE * msg, CONTEXT * ctx) {
if (!(msg->write && ctx->append)) {
- debug_print (1, ("msg->write = %d, ctx->append = %d\n", msg->write, ctx->append));
return -1;
}
if (!ctx || !MX_IDX(ctx->magic-1) || !MX_COMMAND(ctx->magic-1,mx_commit_message))
(*msg)->fp = NULL;
if ((*msg)->path) {
- debug_print (1, ("unlinking %s\n", (*msg)->path));
unlink ((*msg)->path);
p_delete(&(*msg)->path);
}
}
void mx_init (void) {
-#ifdef DEBUG
- int i = 0;
-#endif
list_push_back (&MailboxFormats, (void*) mbox_reg_mx ());
list_push_back (&MailboxFormats, (void*) mmdf_reg_mx ());
list_push_back (&MailboxFormats, (void*) mh_reg_mx ());
list_push_back (&MailboxFormats, (void*) nntp_reg_mx ());
#endif
list_push_back (&MailboxFormats, (void*) compress_reg_mx ());
-#ifdef DEBUG
- /* check module registration for completeness with debug versions */
-#define EXITWITHERR(m) do { fprintf(stderr, "error: incomplete mx module: %s is missing for type %i\n",m,i);exit(1); } while (0)
- for (i = 0; i < MailboxFormats->length; i++) {
- if (MX_COMMAND(i,type) < 1) EXITWITHERR("type");
- if (!MX_COMMAND(i,mx_is_magic)) EXITWITHERR("mx_is_magic");
- if (!MX_COMMAND(i,mx_open_mailbox)) EXITWITHERR("mx_open_mailbox");
-/* if (!MX_COMMAND(i,mx_sync_mailbox)) EXITWITHERR("mx_sync_mailbox");*/
- }
-#undef EXITWITHERR
-#endif /* DEBUG */
}
int mx_rebuild_cache (void) {