X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=mx.c;h=27947b4b1847e87979ad56bff3b1e35e00d0b5d7;hp=2cdbe7eef44889e922e3013ba384a5aae3bd07fa;hb=169f101dc43f0581d8c52bcf8131d9eecb7cdeb0;hpb=42cc85de46ed8971a6c793835023cf26766fb096 diff --git a/mx.c b/mx.c index 2cdbe7e..27947b4 100644 --- a/mx.c +++ b/mx.c @@ -13,11 +13,13 @@ #endif #include "mutt.h" +#include "ascii.h" #include "mx.h" #include "mbox.h" #include "mh.h" #include "rfc2047.h" #include "sort.h" +#include "thread.h" #include "copy.h" #include "keymap.h" #include "url.h" @@ -73,7 +75,7 @@ static list2_t* MailboxFormats = NULL; #define MX_COMMAND(idx,cmd) ((mx_t*) MailboxFormats->data[idx])->cmd #define MX_IDX(idx) (idx >= 0 && idx < MailboxFormats->length) -#define mutt_is_spool(s) (mutt_strcmp (Spoolfile, s) == 0) +#define mutt_is_spool(s) (str_cmp (Spoolfile, s) == 0) #ifdef USE_DOTLOCK /* parameters: @@ -199,6 +201,7 @@ int mx_lock_file (const char *path, int fd, int excl, int dot, int timeout) count = 0; attempt = 0; + prev_sb.st_size = 0; while (fcntl (fd, F_SETLK, &lck) == -1) { struct stat sb; @@ -342,7 +345,7 @@ void mx_unlink_empty (const char *path) int mx_get_magic (const char *path) { int i = 0; - if (mutt_strlen (path) == 0) + if (str_len (path) == 0) return (-1); if ((i = mx_get_idx (path)) >= 0) return (MX_COMMAND(i,type)); @@ -518,9 +521,9 @@ CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT * pctx) int rc; if (!ctx) - ctx = safe_malloc (sizeof (CONTEXT)); + ctx = mem_malloc (sizeof (CONTEXT)); memset (ctx, 0, sizeof (CONTEXT)); - ctx->path = safe_strdup (path); + ctx->path = str_dup (path); ctx->msgnotreadyet = -1; ctx->collapsed = 0; @@ -536,7 +539,7 @@ CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT * pctx) if (mx_open_mailbox_append (ctx, flags) != 0) { mx_fastclose_mailbox (ctx); if (!pctx) - FREE (&ctx); + mem_free (&ctx); return NULL; } return ctx; @@ -559,7 +562,7 @@ CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT * pctx) if (ctx->magic <= 0) { mx_fastclose_mailbox (ctx); if (!pctx) - FREE (&ctx); + mem_free (&ctx); return (NULL); } @@ -589,7 +592,7 @@ CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT * pctx) else { mx_fastclose_mailbox (ctx); if (!pctx) - FREE (&ctx); + mem_free (&ctx); } unset_option (OPTFORCEREFRESH); @@ -613,14 +616,14 @@ void mx_fastclose_mailbox (CONTEXT * ctx) mutt_clear_threads (ctx); for (i = 0; i < ctx->msgcount; i++) mutt_free_header (&ctx->hdrs[i]); - FREE (&ctx->hdrs); - FREE (&ctx->v2r); + mem_free (&ctx->hdrs); + mem_free (&ctx->v2r); #ifdef USE_COMPRESSED if (ctx->compressinfo) mutt_fast_close_compressed (ctx); #endif - FREE (&ctx->path); - FREE (&ctx->pattern); + mem_free (&ctx->path); + mem_free (&ctx->pattern); if (ctx->limit_pattern) mutt_pattern_free (&ctx->limit_pattern); safe_fclose (&ctx->fp); @@ -1117,7 +1120,7 @@ MESSAGE *mx_open_new_message (CONTEXT * dest, HEADER * hdr, int flags) return (NULL); } - msg = safe_calloc (1, sizeof (MESSAGE)); + msg = mem_calloc (1, sizeof (MESSAGE)); msg->magic = dest->magic; msg->write = 1; @@ -1150,7 +1153,7 @@ MESSAGE *mx_open_new_message (CONTEXT * dest, HEADER * hdr, int flags) } } else - FREE (&msg); + mem_free (&msg); return msg; } @@ -1179,7 +1182,7 @@ MESSAGE *mx_open_message (CONTEXT * ctx, int msgno) { MESSAGE *msg; - msg = safe_calloc (1, sizeof (MESSAGE)); + msg = mem_calloc (1, sizeof (MESSAGE)); switch (msg->magic = ctx->magic) { case M_MBOX: case M_MMDF: @@ -1201,7 +1204,7 @@ 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)); - FREE (&msg); + mem_free (&msg); } } break; @@ -1210,7 +1213,7 @@ MESSAGE *mx_open_message (CONTEXT * ctx, int msgno) case M_IMAP: { if (imap_fetch_message (msg, ctx, msgno) != 0) - FREE (&msg); + mem_free (&msg); break; } #endif /* USE_IMAP */ @@ -1219,7 +1222,7 @@ MESSAGE *mx_open_message (CONTEXT * ctx, int msgno) case M_POP: { if (pop_fetch_message (msg, ctx, msgno) != 0) - FREE (&msg); + mem_free (&msg); break; } #endif /* USE_POP */ @@ -1228,14 +1231,14 @@ MESSAGE *mx_open_message (CONTEXT * ctx, int msgno) case M_NNTP: { if (nntp_fetch_message (msg, ctx, msgno) != 0) - FREE (&msg); + mem_free (&msg); break; } #endif /* USE_NNTP */ default: debug_print (1, ("function not implemented for mailbox type %d.\n", ctx->magic)); - FREE (&msg); + mem_free (&msg); break; } return (msg); @@ -1277,10 +1280,10 @@ int mx_close_message (MESSAGE ** msg) if ((*msg)->path) { debug_print (1, ("unlinking %s\n", (*msg)->path)); unlink ((*msg)->path); - FREE (&(*msg)->path); + mem_free (&(*msg)->path); } - FREE (msg); + mem_free (msg); return (r); } @@ -1297,12 +1300,12 @@ void mx_alloc_memory (CONTEXT * ctx) } if (ctx->hdrs) { - safe_realloc (&ctx->hdrs, sizeof (HEADER *) * (ctx->hdrmax += 25)); - safe_realloc (&ctx->v2r, sizeof (int) * ctx->hdrmax); + mem_realloc (&ctx->hdrs, sizeof (HEADER *) * (ctx->hdrmax += 25)); + mem_realloc (&ctx->v2r, sizeof (int) * ctx->hdrmax); } else { - ctx->hdrs = safe_calloc ((ctx->hdrmax += 25), sizeof (HEADER *)); - ctx->v2r = safe_calloc (ctx->hdrmax, sizeof (int)); + ctx->hdrs = mem_calloc ((ctx->hdrmax += 25), sizeof (HEADER *)); + ctx->v2r = mem_calloc (ctx->hdrmax, sizeof (int)); } for (i = ctx->msgcount; i < ctx->hdrmax; i++) { ctx->hdrs[i] = NULL; @@ -1342,7 +1345,7 @@ void mx_update_context (CONTEXT * ctx, int new_messages) h2 = hash_find (ctx->id_hash, h->env->supersedes); - /* FREE (&h->env->supersedes); should I ? */ + /* mem_free (&h->env->supersedes); should I ? */ if (h2) { h2->superseded = 1; if (!ctx->counting && option (OPTSCORE))