projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
wibble
[apps/madmutt.git]
/
mx.c
diff --git
a/mx.c
b/mx.c
index
2c8d31b
..
6f6f779
100644
(file)
--- a/
mx.c
+++ b/
mx.c
@@
-12,13
+12,19
@@
# include "config.h"
#endif
# include "config.h"
#endif
+#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-mime/mime.h>
+
#include "mutt.h"
#include "buffy.h"
#include "mutt.h"
#include "buffy.h"
-#include "ascii.h"
#include "mx.h"
#include "mbox.h"
#include "mh.h"
#include "mx.h"
#include "mbox.h"
#include "mh.h"
-#include "rfc2047.h"
#include "sort.h"
#include "thread.h"
#include "copy.h"
#include "sort.h"
#include "thread.h"
#include "copy.h"
@@
-51,9
+57,6
@@
#include "mutt_crypt.h"
#include "mutt_crypt.h"
-#include "lib/mem.h"
-#include "lib/intl.h"
-#include "lib/str.h"
#include "lib/list.h"
#include "lib/debug.h"
#include "lib/list.h"
#include "lib/debug.h"
@@
-72,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 MX_COMMAND(idx,cmd) ((mx_t*) MailboxFormats->data[idx])->cmd
#define MX_IDX(idx) (idx >= 0 && idx < MailboxFormats->length)
-#define mutt_is_spool(s) (
str_cmp
(Spoolfile, s) == 0)
+#define mutt_is_spool(s) (
m_strcmp
(Spoolfile, s) == 0)
#ifdef USE_DOTLOCK
/* parameters:
#ifdef USE_DOTLOCK
/* parameters:
@@
-192,7
+195,7
@@
int mx_lock_file (const char *path, int fd, int excl, int dot, int timeout)
struct flock lck;
struct flock lck;
-
memset (&lck, 0, sizeof (struct flock)
);
+
p_clear(&lck, 1
);
lck.l_type = excl ? F_WRLCK : F_RDLCK;
lck.l_whence = SEEK_SET;
lck.l_type = excl ? F_WRLCK : F_RDLCK;
lck.l_whence = SEEK_SET;
@@
-291,9
+294,9
@@
int mx_lock_file (const char *path, int fd, int excl, int dot, int timeout)
int mx_unlock_file (const char *path, int fd, int dot)
{
#ifdef USE_FCNTL
int mx_unlock_file (const char *path, int fd, int dot)
{
#ifdef USE_FCNTL
- struct flock unlockit
= { F_UNLCK, 0, 0, 0 }
;
+ struct flock unlockit;
-
memset (&unlockit, 0, sizeof (struct flock)
);
+
p_clear(&unlockit, 1
);
unlockit.l_type = F_UNLCK;
unlockit.l_whence = SEEK_SET;
fcntl (fd, F_SETLK, &unlockit);
unlockit.l_type = F_UNLCK;
unlockit.l_whence = SEEK_SET;
fcntl (fd, F_SETLK, &unlockit);
@@
-342,7
+345,7
@@
void mx_unlink_empty (const char *path)
int mx_get_magic (const char *path) {
int i = 0;
int mx_get_magic (const char *path) {
int i = 0;
- if (
str_len
(path) == 0)
+ if (
m_strlen
(path) == 0)
return (-1);
if ((i = mx_get_idx (path)) >= 0)
return (MX_COMMAND(i,type));
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)
int rc;
if (!ctx)
- ctx =
mem_malloc (sizeof (CONTEXT)
);
-
memset (ctx, 0, sizeof (CONTEXT)
);
- ctx->path =
str_dup
(path);
+ ctx =
p_new(CONTEXT, 1
);
+
p_clear(ctx, 1
);
+ ctx->path =
m_strdup
(path);
ctx->msgnotreadyet = -1;
ctx->collapsed = 0;
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)
if (mx_open_mailbox_append (ctx, flags) != 0) {
mx_fastclose_mailbox (ctx);
if (!pctx)
-
mem_free
(&ctx);
+
p_delete
(&ctx);
return NULL;
}
return 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)
if (ctx->magic <= 0) {
mx_fastclose_mailbox (ctx);
if (!pctx)
-
mem_free
(&ctx);
+
p_delete
(&ctx);
return (NULL);
}
return (NULL);
}
@@
-589,7
+592,7
@@
CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT * pctx)
else {
mx_fastclose_mailbox (ctx);
if (!pctx)
else {
mx_fastclose_mailbox (ctx);
if (!pctx)
-
mem_free
(&ctx);
+
p_delete
(&ctx);
}
unset_option (OPTFORCEREFRESH);
}
unset_option (OPTFORCEREFRESH);
@@
-613,18
+616,18
@@
void mx_fastclose_mailbox (CONTEXT * ctx)
mutt_clear_threads (ctx);
for (i = 0; i < ctx->msgcount; i++)
mutt_free_header (&ctx->hdrs[i]);
mutt_clear_threads (ctx);
for (i = 0; i < ctx->msgcount; i++)
mutt_free_header (&ctx->hdrs[i]);
-
mem_free
(&ctx->hdrs);
-
mem_free
(&ctx->v2r);
+
p_delete
(&ctx->hdrs);
+
p_delete
(&ctx->v2r);
#ifdef USE_COMPRESSED
if (ctx->compressinfo)
mutt_fast_close_compressed (ctx);
#endif
#ifdef USE_COMPRESSED
if (ctx->compressinfo)
mutt_fast_close_compressed (ctx);
#endif
-
mem_free
(&ctx->path);
-
mem_free
(&ctx->pattern);
+
p_delete
(&ctx->path);
+
p_delete
(&ctx->pattern);
if (ctx->limit_pattern)
mutt_pattern_free (&ctx->limit_pattern);
safe_fclose (&ctx->fp);
if (ctx->limit_pattern)
mutt_pattern_free (&ctx->limit_pattern);
safe_fclose (&ctx->fp);
-
memset (ctx, 0, sizeof (CONTEXT)
);
+
p_clear(ctx, 1
);
}
/* save changes to disk */
}
/* save changes to disk */
@@
-694,7
+697,7
@@
static int trash_append (CONTEXT * ctx)
}
/* save changes and close mailbox */
}
/* save changes and close mailbox */
-
int
mx_close_mailbox (CONTEXT * ctx, int *index_hint)
+
static int _
mx_close_mailbox (CONTEXT * ctx, int *index_hint)
{
int i, move_messages = 0, purge = 1, read_msgs = 0;
int check;
{
int i, move_messages = 0, purge = 1, read_msgs = 0;
int check;
@@
-743,10
+746,10
@@
int mx_close_mailbox (CONTEXT * ctx, int *index_hint)
if ((p = mutt_find_hook (M_MBOXHOOK, ctx->path))) {
isSpool = 1;
if ((p = mutt_find_hook (M_MBOXHOOK, ctx->path))) {
isSpool = 1;
-
strfcpy (mbox, p, sizeof (mbox)
);
+
m_strcpy(mbox, sizeof(mbox), p
);
}
else {
}
else {
-
strfcpy (mbox, NONULL (Inbox), sizeof (m
box));
+
m_strcpy(mbox, sizeof(mbox), NONULL(In
box));
isSpool = mutt_is_spool (ctx->path) && !mutt_is_spool (mbox);
}
mutt_expand_path (mbox, sizeof (mbox));
isSpool = mutt_is_spool (ctx->path) && !mutt_is_spool (mbox);
}
mutt_expand_path (mbox, sizeof (mbox));
@@
-899,6
+902,14
@@
int mx_close_mailbox (CONTEXT * ctx, int *index_hint)
return 0;
}
return 0;
}
+int mx_close_mailbox (CONTEXT * ctx, int *index_hint) {
+ int ret = 0;
+ if (!ctx)
+ return (0);
+ ret = _mx_close_mailbox (ctx, index_hint);
+ sidebar_set_buffystats (ctx);
+ return (ret);
+}
/* update a Context structure's internal tables. */
/* update a Context structure's internal tables. */
@@
-986,7
+997,7
@@
void mx_update_tables (CONTEXT * ctx, int committing)
* 0 success
* -1 error
*/
* 0 success
* -1 error
*/
-
int
mx_sync_mailbox (CONTEXT * ctx, int *index_hint)
+
static int _
mx_sync_mailbox (CONTEXT * ctx, int *index_hint)
{
int rc, i;
int purge = 1;
{
int rc, i;
int purge = 1;
@@
-999,8
+1010,7
@@
int mx_sync_mailbox (CONTEXT * ctx, int *index_hint)
km_find_func (MENU_MAIN, OP_TOGGLE_WRITE)))
snprintf (tmp, sizeof (tmp), _(" Press '%s' to toggle write"), buf);
else
km_find_func (MENU_MAIN, OP_TOGGLE_WRITE)))
snprintf (tmp, sizeof (tmp), _(" Press '%s' to toggle write"), buf);
else
- strfcpy (tmp, _("Use 'toggle-write' to re-enable write!"),
- sizeof (tmp));
+ m_strcpy(tmp, sizeof(tmp), _("Use 'toggle-write' to re-enable write!"));
mutt_error (_("Mailbox is marked unwritable. %s"), tmp);
return -1;
mutt_error (_("Mailbox is marked unwritable. %s"), tmp);
return -1;
@@
-1077,9
+1087,6
@@
int mx_sync_mailbox (CONTEXT * ctx, int *index_hint)
return 0;
}
return 0;
}
- /* update sidebar counts */
- sidebar_set_buffystats (ctx);
-
/* if we haven't deleted any messages, we don't need to resort */
/* ... except for certain folder formats which need "unsorted"
* sort order in order to synchronize folders.
/* if we haven't deleted any messages, we don't need to resort */
/* ... except for certain folder formats which need "unsorted"
* sort order in order to synchronize folders.
@@
-1102,6
+1109,12
@@
int mx_sync_mailbox (CONTEXT * ctx, int *index_hint)
return (rc);
}
return (rc);
}
+int mx_sync_mailbox (CONTEXT* ctx, int* index_hint) {
+ int ret = _mx_sync_mailbox (ctx, index_hint);
+ sidebar_set_buffystats (ctx);
+ return (ret);
+}
+
/* args:
* dest destintation mailbox
* hdr message being copied (required for maildir support, because
/* args:
* dest destintation mailbox
* hdr message being copied (required for maildir support, because
@@
-1110,14
+1123,14
@@
int mx_sync_mailbox (CONTEXT * ctx, int *index_hint)
MESSAGE *mx_open_new_message (CONTEXT * dest, HEADER * hdr, int flags)
{
MESSAGE *msg;
MESSAGE *mx_open_new_message (CONTEXT * dest, HEADER * hdr, int flags)
{
MESSAGE *msg;
-
ADDRESS
*p = NULL;
+
address_t
*p = NULL;
if (!MX_IDX(dest->magic-1)) {
debug_print (1, ("function unimplemented for mailbox type %d.\n", dest->magic));
return (NULL);
}
if (!MX_IDX(dest->magic-1)) {
debug_print (1, ("function unimplemented for mailbox type %d.\n", dest->magic));
return (NULL);
}
- msg =
mem_calloc (1, sizeof (MESSAGE)
);
+ msg =
p_new(MESSAGE, 1
);
msg->magic = dest->magic;
msg->write = 1;
msg->magic = dest->magic;
msg->write = 1;
@@
-1150,7
+1163,7
@@
MESSAGE *mx_open_new_message (CONTEXT * dest, HEADER * hdr, int flags)
}
}
else
}
}
else
-
mem_free
(&msg);
+
p_delete
(&msg);
return msg;
}
return msg;
}
@@
-1179,7
+1192,7
@@
MESSAGE *mx_open_message (CONTEXT * ctx, int msgno)
{
MESSAGE *msg;
{
MESSAGE *msg;
- msg =
mem_calloc (1, sizeof (MESSAGE)
);
+ msg =
p_new(MESSAGE, 1
);
switch (msg->magic = ctx->magic) {
case M_MBOX:
case M_MMDF:
switch (msg->magic = ctx->magic) {
case M_MBOX:
case M_MMDF:
@@
-1201,7
+1214,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));
if (msg->fp == NULL) {
mutt_perror (path);
debug_print (1, ("fopen: %s: %s (errno %d).\n", path, strerror (errno), errno));
-
mem_free
(&msg);
+
p_delete
(&msg);
}
}
break;
}
}
break;
@@
-1210,7
+1223,7
@@
MESSAGE *mx_open_message (CONTEXT * ctx, int msgno)
case M_IMAP:
{
if (imap_fetch_message (msg, ctx, msgno) != 0)
case M_IMAP:
{
if (imap_fetch_message (msg, ctx, msgno) != 0)
-
mem_free
(&msg);
+
p_delete
(&msg);
break;
}
#endif /* USE_IMAP */
break;
}
#endif /* USE_IMAP */
@@
-1219,7
+1232,7
@@
MESSAGE *mx_open_message (CONTEXT * ctx, int msgno)
case M_POP:
{
if (pop_fetch_message (msg, ctx, msgno) != 0)
case M_POP:
{
if (pop_fetch_message (msg, ctx, msgno) != 0)
-
mem_free
(&msg);
+
p_delete
(&msg);
break;
}
#endif /* USE_POP */
break;
}
#endif /* USE_POP */
@@
-1228,14
+1241,14
@@
MESSAGE *mx_open_message (CONTEXT * ctx, int msgno)
case M_NNTP:
{
if (nntp_fetch_message (msg, ctx, msgno) != 0)
case M_NNTP:
{
if (nntp_fetch_message (msg, ctx, msgno) != 0)
-
mem_free
(&msg);
+
p_delete
(&msg);
break;
}
#endif /* USE_NNTP */
default:
debug_print (1, ("function not implemented for mailbox type %d.\n", ctx->magic));
break;
}
#endif /* USE_NNTP */
default:
debug_print (1, ("function not implemented for mailbox type %d.\n", ctx->magic));
-
mem_free
(&msg);
+
p_delete
(&msg);
break;
}
return (msg);
break;
}
return (msg);
@@
-1277,10
+1290,10
@@
int mx_close_message (MESSAGE ** msg)
if ((*msg)->path) {
debug_print (1, ("unlinking %s\n", (*msg)->path));
unlink ((*msg)->path);
if ((*msg)->path) {
debug_print (1, ("unlinking %s\n", (*msg)->path));
unlink ((*msg)->path);
-
mem_free
(&(*msg)->path);
+
p_delete
(&(*msg)->path);
}
}
-
mem_free
(msg);
+
p_delete
(msg);
return (r);
}
return (r);
}
@@
-1297,12
+1310,12
@@
void mx_alloc_memory (CONTEXT * ctx)
}
if (ctx->hdrs) {
}
if (ctx->hdrs) {
-
mem_realloc (&ctx->hdrs, sizeof (HEADER *) * (ctx->hdrmax += 25)
);
-
mem_realloc (&ctx->v2r, sizeof (int) *
ctx->hdrmax);
+
p_realloc(&ctx->hdrs, ctx->hdrmax += 25
);
+
p_realloc(&ctx->v2r,
ctx->hdrmax);
}
else {
}
else {
- ctx->hdrs =
mem_calloc ((ctx->hdrmax += 25), sizeof (HEADER *
));
- ctx->v2r =
mem_calloc (ctx->hdrmax, sizeof (int)
);
+ ctx->hdrs =
p_new(HEADER *, (ctx->hdrmax += 25
));
+ ctx->v2r =
p_new(int, ctx->hdrmax
);
}
for (i = ctx->msgcount; i < ctx->hdrmax; i++) {
ctx->hdrs[i] = NULL;
}
for (i = ctx->msgcount; i < ctx->hdrmax; i++) {
ctx->hdrs[i] = NULL;
@@
-1342,7
+1355,7
@@
void mx_update_context (CONTEXT * ctx, int new_messages)
h2 = hash_find (ctx->id_hash, h->env->supersedes);
h2 = hash_find (ctx->id_hash, h->env->supersedes);
- /*
mem_free
(&h->env->supersedes); should I ? */
+ /*
p_delete
(&h->env->supersedes); should I ? */
if (h2) {
h2->superseded = 1;
if (!ctx->counting && option (OPTSCORE))
if (h2) {
h2->superseded = 1;
if (!ctx->counting && option (OPTSCORE))
@@
-1457,6
+1470,8
@@
int mx_rebuild_cache (void) {
#endif
)
continue;
#endif
)
continue;
+ sidebar_set_current (b->path);
+ sidebar_draw (CurrentMenu);
if ((ctx = mx_open_mailbox (b->path,
M_READONLY | M_NOSORT | M_COUNT,
NULL)) != NULL)
if ((ctx = mx_open_mailbox (b->path,
M_READONLY | M_NOSORT | M_COUNT,
NULL)) != NULL)
@@
-1464,6
+1479,10
@@
int mx_rebuild_cache (void) {
}
mutt_clear_error ();
}
mutt_clear_error ();
+ if (Context && Context->path)
+ sidebar_set_current (Context->path);
+ sidebar_draw (CurrentMenu);
+
return (0);
#endif
}
return (0);
#endif
}