X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=mx.c;h=190f527343ff0f19cb66c21fae8e1cf0680f058c;hp=b1efdceeaa962858a174db98c9b6c7635f4ac94f;hb=fdb93a08e305b8755260144807e4d45106a9cb9f;hpb=4761fa78a6dfc9437caa6e6e0aac806e50e01c83 diff --git a/mx.c b/mx.c index b1efdce..190f527 100644 --- a/mx.c +++ b/mx.c @@ -12,11 +12,25 @@ # include "config.h" #endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include #include #include #include #include +#include + +#include #include @@ -29,7 +43,6 @@ #include "thread.h" #include "copy.h" #include "keymap.h" -#include "url.h" #include "sidebar.h" #include "compress.h" @@ -51,18 +64,6 @@ #include #include "lib/list.h" -#include "lib/debug.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include static list2_t* MailboxFormats = NULL; #define MX_COMMAND(idx,cmd) ((mx_t*) MailboxFormats->data[idx])->cmd @@ -165,9 +166,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 +191,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 +204,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 +238,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 +255,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, fd, time_out); #endif /* USE_DOTLOCK */ if (r == -1) { @@ -592,7 +592,7 @@ void mx_fastclose_mailbox (CONTEXT * ctx) hash_destroy (&ctx->id_hash, NULL); mutt_clear_threads (ctx); for (i = 0; i < ctx->msgcount; i++) - mutt_free_header (&ctx->hdrs[i]); + header_delete(&ctx->hdrs[i]); p_delete(&ctx->hdrs); p_delete(&ctx->v2r); @@ -947,7 +947,7 @@ void mx_update_tables (CONTEXT * ctx, int committing) if (ctx->id_hash && ctx->hdrs[i]->env->message_id) hash_delete (ctx->id_hash, ctx->hdrs[i]->env->message_id, ctx->hdrs[i], NULL); - mutt_free_header (&ctx->hdrs[i]); + header_delete(&ctx->hdrs[i]); } } #undef this_body @@ -1085,7 +1085,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 +1138,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 +1167,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 +1196,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 +1206,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 +1231,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 +1355,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 +1365,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) { @@ -1423,3 +1402,27 @@ int mx_rebuild_cache (void) { return (0); #endif } + +void mutt_parse_mime_message (CONTEXT * ctx, HEADER * cur) +{ + MESSAGE *msg; + int flags = 0; + + do { + if (cur->content->type != TYPEMESSAGE + && cur->content->type != TYPEMULTIPART) + break; /* nothing to do */ + + if (cur->content->parts) + break; /* The message was parsed earlier. */ + + if ((msg = mx_open_message (ctx, cur->msgno))) { + mutt_parse_part (msg->fp, cur->content); + + cur->security = crypt_query (cur->content); + + mx_close_message (&msg); + } + } while (0); + mutt_count_body_parts (cur, flags | M_PARTS_RECOUNT); +}