X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=mx.c;h=fde597c67fec215ea0fbbcd11de5680e8c09efda;hp=5f18ac1d8b831511d5fc542536fe1ed609a367b1;hb=98cf5779d8184a74541be1bc61d15c5f35efd310;hpb=05a3bbbe420e4afc76e0eea24ce32f859405dc4a diff --git a/mx.c b/mx.c index 5f18ac1..fde597c 100644 --- a/mx.c +++ b/mx.c @@ -8,29 +8,13 @@ * please see the file GPL in the top level source directory. */ -#if HAVE_CONFIG_H -# include "config.h" -#endif +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include - +#include #include +#include #include "mutt.h" #include "buffy.h" @@ -41,8 +25,6 @@ #include "thread.h" #include "copy.h" #include "keymap.h" -#include "url.h" -#include "sidebar.h" #include "compress.h" #include @@ -76,7 +58,7 @@ static list2_t* MailboxFormats = NULL; * retry - should retry if unable to lock? */ -static int invoke_dotlock (const char *path, int dummy, int flags, int retry) +static int invoke_dotlock (const char *path, int flags, int retry) { char cmd[LONG_STRING + _POSIX_PATH_MAX]; char f[SHORT_STRING + _POSIX_PATH_MAX]; @@ -100,7 +82,7 @@ static int invoke_dotlock (const char *path, int dummy, int flags, int retry) return mutt_system (cmd); } -static int dotlock_file (const char *path, int fd, int retry) +static int dotlock_file (const char *path, int retry) { int r; int flags = DL_FL_USEPRIV | DL_FL_RETRY; @@ -109,7 +91,7 @@ static int dotlock_file (const char *path, int fd, int retry) retry = 1; retry_lock: - if ((r = invoke_dotlock (path, fd, flags, retry)) == DL_EX_EXIST) { + if ((r = invoke_dotlock (path, flags, retry)) == DL_EX_EXIST) { if (!option (OPTNOCURSES)) { char msg[LONG_STRING]; @@ -129,9 +111,9 @@ retry_lock: return (r == DL_EX_OK ? 0 : -1); } -static int undotlock_file (const char *path, int fd) +static int undotlock_file (const char *path) { - return (invoke_dotlock (path, fd, DL_FL_USEPRIV | DL_FL_UNLOCK, 0) == + return (invoke_dotlock (path, DL_FL_USEPRIV | DL_FL_UNLOCK, 0) == DL_EX_OK ? 0 : -1); } @@ -165,9 +147,9 @@ static int mx_get_idx (const char* path) { /* 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; @@ -190,7 +172,6 @@ int mx_lock_file (const char *path, int fd, int excl, int dot, int timeout) 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); @@ -204,8 +185,8 @@ int mx_lock_file (const char *path, int fd, int excl, int dot, int timeout) /* 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); @@ -238,8 +219,8 @@ int mx_lock_file (const char *path, int fd, int excl, int dot, int timeout) /* 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; @@ -255,7 +236,7 @@ int mx_lock_file (const char *path, int fd, int excl, int dot, int timeout) #ifdef USE_DOTLOCK if (r == 0 && dot) - r = dotlock_file (path, fd, timeout); + r = dotlock_file (path, time_out); #endif /* USE_DOTLOCK */ if (r == -1) { @@ -293,13 +274,13 @@ int mx_unlock_file (const char *path, int fd, int dot) #ifdef USE_DOTLOCK if (dot) - undotlock_file (path, fd); + undotlock_file (path); #endif return 0; } -void mx_unlink_empty (const char *path) +static void mx_unlink_empty (const char *path) { int fd; @@ -316,7 +297,7 @@ void mx_unlink_empty (const char *path) } #ifdef USE_DOTLOCK - invoke_dotlock (path, fd, DL_FL_UNLINK, 1); + invoke_dotlock (path, DL_FL_UNLINK, 1); #else if (fstat (fd, &sb) == 0 && sb.st_size == 0) unlink (path); @@ -1085,7 +1066,6 @@ MESSAGE *mx_open_new_message (CONTEXT * dest, HEADER * hdr, int flags) address_t *p = NULL; if (!MX_IDX(dest->magic-1)) { - debug_print (1, ("function unimplemented for mailbox type %d.\n", dest->magic)); return (NULL); } @@ -1139,9 +1119,7 @@ int mx_check_mailbox (CONTEXT * ctx, int *index_hint, int lock) { 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 */ @@ -1170,7 +1148,6 @@ MESSAGE *mx_open_message (CONTEXT * ctx, int msgno) if (msg->fp == NULL) { mutt_perror (path); - debug_print (1, ("fopen: %s: %s (errno %d).\n", path, strerror (errno), errno)); p_delete(&msg); } } @@ -1200,7 +1177,6 @@ MESSAGE *mx_open_message (CONTEXT * ctx, int msgno) #endif /* USE_NNTP */ default: - debug_print (1, ("function not implemented for mailbox type %d.\n", ctx->magic)); p_delete(&msg); break; } @@ -1211,7 +1187,6 @@ MESSAGE *mx_open_message (CONTEXT * ctx, int msgno) 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)) @@ -1237,7 +1212,6 @@ int mx_close_message (MESSAGE ** msg) (*msg)->fp = NULL; if ((*msg)->path) { - debug_print (1, ("unlinking %s\n", (*msg)->path)); unlink ((*msg)->path); p_delete(&(*msg)->path); } @@ -1362,9 +1336,6 @@ int mx_acl_check (CONTEXT* ctx, int flag) { } 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 ()); @@ -1375,17 +1346,6 @@ void mx_init (void) { 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) { @@ -1408,7 +1368,7 @@ int mx_rebuild_cache (void) { if (magic != M_MAILDIR && magic != M_MH && magic != M_IMAP) continue; sidebar_set_current (b->path); - sidebar_draw (CurrentMenu); + sidebar_draw (); if ((ctx = mx_open_mailbox (b->path, M_READONLY | M_NOSORT | M_COUNT, NULL)) != NULL) @@ -1418,7 +1378,7 @@ int mx_rebuild_cache (void) { if (Context && Context->path) sidebar_set_current (Context->path); - sidebar_draw (CurrentMenu); + sidebar_draw (); return (0); #endif