X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=mx.c;h=6ee2be7a01f1bf0fe640cc4cbc9558bc66b2ca80;hp=2f127c177d46bf3eb40fe87e06004b365a20d499;hb=ac1ea3143e61def7fc9000bee6d0d59d56c5b997;hpb=2ce8de509852f47a90f834b3e8d047e054810309 diff --git a/mx.c b/mx.c index 2f127c1..6ee2be7 100644 --- a/mx.c +++ b/mx.c @@ -26,26 +26,17 @@ #include "copy.h" #include "keymap.h" #include "compress.h" +#include "dotlock.h" #include -#include - #include -#include #ifdef USE_NNTP -#include "nntp/nntp.h" -#include "nntp/mx_nntp.h" -#endif - -#ifdef USE_DOTLOCK -#include "dotlock.h" +#include #endif #include -#include "lib/list.h" - static mx_t const *mxfmts[] = { &mbox_mx, &mmdf_mx, @@ -62,12 +53,10 @@ static mx_t const *mxfmts[] = { #define MX_IDX(idx) (idx >= 0 && idx < countof(mxfmts)) #define mutt_is_spool(s) (m_strcmp(Spoolfile, s) == 0) -#ifdef USE_DOTLOCK /* parameters: * path - file to lock * retry - should retry if unable to lock? */ - static int invoke_dotlock (const char *path, int flags, int retry) { char cmd[LONG_STRING + _POSIX_PATH_MAX]; @@ -127,8 +116,6 @@ static int undotlock_file (const char *path) DL_EX_OK ? 0 : -1); } -#endif /* USE_DOTLOCK */ - /* looks up index of type for path in mxfmts */ static int mx_get_idx (const char* path) { int i = 0, t = 0; @@ -244,10 +231,8 @@ int mx_lock_file (const char *path, int fd, int excl, int dot, int time_out) } #endif /* USE_FLOCK */ -#ifdef USE_DOTLOCK if (r == 0 && dot) r = dotlock_file (path, time_out); -#endif /* USE_DOTLOCK */ if (r == -1) { /* release any other locks obtained in this routine */ @@ -282,10 +267,8 @@ int mx_unlock_file (const char *path, int fd, int dot) flock (fd, LOCK_UN); #endif -#ifdef USE_DOTLOCK if (dot) undotlock_file (path); -#endif return 0; } @@ -294,10 +277,6 @@ static void mx_unlink_empty (const char *path) { int fd; -#ifndef USE_DOTLOCK - struct stat sb; -#endif - if ((fd = open (path, O_RDWR)) == -1) return; @@ -306,12 +285,7 @@ static void mx_unlink_empty (const char *path) return; } -#ifdef USE_DOTLOCK - invoke_dotlock (path, DL_FL_UNLINK, 1); -#else - if (fstat (fd, &sb) == 0 && sb.st_size == 0) - unlink (path); -#endif + invoke_dotlock(path, DL_FL_UNLINK, 1); mx_unlock_file (path, fd, 0); close (fd); @@ -1354,13 +1328,13 @@ int mx_rebuild_cache (void) { CONTEXT* ctx = NULL; BUFFY* b = NULL; - if (list_empty(Incoming)) { + if (!Incoming.len) { mutt_error (_("No mailboxes defined.")); return (1); } - for (i = 0; i < Incoming->length; i++) { - b = (BUFFY*) Incoming->data[i]; + for (i = 0; i < Incoming.len; i++) { + b = Incoming.arr[i]; magic = mx_get_magic (b->path); if (magic != M_MAILDIR && magic != M_MH && magic != M_IMAP) continue;