X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=imap%2Fimap.c;h=44d3eeed9b82c18976259b6885286a2ee466841c;hp=8c7cc5e562f6801266ab589d9fa19e473ccaab0e;hb=c98480f8568e6c1bc927c6c5f2b5e80b4aa6548c;hpb=8e037c67a88cb4680c4391134c578e3b55a80f8a diff --git a/imap/imap.c b/imap/imap.c index 8c7cc5e..44d3eee 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -16,10 +16,11 @@ #endif #include +#include +#include +#include #include "mutt.h" -#include "ascii.h" -#include "buffer.h" #include "mx.h" #include "globals.h" #include "sort.h" @@ -31,9 +32,7 @@ #endif #include "buffy.h" -#include "lib/mem.h" -#include "lib/intl.h" -#include "lib/str.h" +#include #include "lib/debug.h" #include @@ -560,11 +559,11 @@ int imap_open_mailbox (CONTEXT * ctx) /* Clean up path and replace the one in the ctx */ imap_fix_path (idata, mx.mbox, buf, sizeof (buf)); p_delete(&(idata->mailbox)); - idata->mailbox = str_dup (buf); + idata->mailbox = m_strdup(buf); imap_qualify_path (buf, sizeof (buf), &mx, idata->mailbox); p_delete(&(ctx->path)); - ctx->path = str_dup (buf); + ctx->path = m_strdup(buf); idata->ctx = ctx; @@ -692,8 +691,8 @@ int imap_open_mailbox (CONTEXT * ctx) } ctx->hdrmax = count; - ctx->hdrs = mem_calloc (count, sizeof (HEADER *)); - ctx->v2r = mem_calloc (count, sizeof (int)); + ctx->hdrs = p_new(HEADER *, count); + ctx->v2r = p_new(int, count); ctx->msgcount = 0; if (count && (imap_read_headers (idata, 0, count - 1) < 0)) { mutt_error _("Error opening mailbox"); @@ -786,12 +785,13 @@ int imap_close_connection (CONTEXT *ctx) /* imap_set_flag: append str to flags if we currently have permission * according to aclbit */ -static void imap_set_flag (IMAP_DATA * idata, int aclbit, int flag, - const char *str, char *flags, size_t flsize) +static void imap_set_flag(IMAP_DATA *idata, int aclbit, int flag, + const char *str, char *flags, size_t flsize) { - if (mutt_bit_isset (idata->rights, aclbit)) - if (flag) - str_cat (flags, flsize, str); + if (mutt_bit_isset(idata->rights, aclbit)) { + if (flag) + m_strcat(flags, flsize, str); + } } /* imap_make_msg_set: make an IMAP4rev1 UID message set out of a set of @@ -816,8 +816,7 @@ int imap_make_msg_set (IMAP_DATA * idata, BUFFER * buf, int flag, int changed) int started = 0; /* make copy of header pointers to sort in natural order */ - hdrs = mem_calloc (idata->ctx->msgcount, sizeof (HEADER *)); - memcpy (hdrs, idata->ctx->hdrs, idata->ctx->msgcount * sizeof (HEADER *)); + hdrs = p_dup(idata->ctx->hdrs, idata->ctx->msgcount); if (Sort != SORT_ORDER) { oldsort = Sort; @@ -977,7 +976,7 @@ int imap_sync_mailbox (CONTEXT * ctx, int expunge, int *index_hint) if ((rc = imap_check_mailbox (ctx, index_hint, 0)) != 0) return rc; - memset (&cmd, 0, sizeof (cmd)); + p_clear(&cmd, 1); /* if we are expunging anyway, we can do deleted messages very quickly... */ if (expunge && mutt_bit_isset (idata->rights, ACL_DELETE)) { @@ -1183,9 +1182,9 @@ int imap_mailbox_check (char *path, int new) * command on a mailbox that you have selected */ - if (str_cmp (mbox_unquoted, idata->mailbox) == 0 + if (m_strcmp(mbox_unquoted, idata->mailbox) == 0 || (ascii_strcasecmp (mbox_unquoted, "INBOX") == 0 - && str_casecmp (mbox_unquoted, idata->mailbox) == 0)) { + && m_strcasecmp(mbox_unquoted, idata->mailbox) == 0)) { strfcpy (buf, "NOOP", sizeof (buf)); } else if (mutt_bit_isset (idata->capabilities, IMAP4REV1) || @@ -1210,8 +1209,8 @@ int imap_mailbox_check (char *path, int new) /* The mailbox name may or may not be quoted here. We could try to * munge the server response and compare with quoted (or vise versa) * but it is probably more efficient to just strncmp against both. */ - if (str_ncmp (mbox_unquoted, s, str_len (mbox_unquoted)) == 0 - || str_ncmp (mbox, s, str_len (mbox)) == 0) { + if (m_strncmp(mbox_unquoted, s, m_strlen(mbox_unquoted)) == 0 + || m_strncmp(mbox, s, m_strlen(mbox)) == 0) { s = imap_next_word (s); s = imap_next_word (s); if (isdigit ((unsigned char) *s)) { @@ -1347,7 +1346,7 @@ int imap_search (CONTEXT* ctx, const pattern_t* pat) { if (!do_search (pat, 1)) return 0; - memset (&buf, 0, sizeof (buf)); + p_clear(&buf, 1); mutt_buffer_addstr (&buf, "UID SEARCH "); if (imap_compile_search (pat, &buf) < 0) { p_delete(&buf.data); @@ -1459,7 +1458,7 @@ int imap_subscribe (char *path, int subscribe) imap_fix_path (idata, mx.mbox, buf, sizeof (buf)); if (option (OPTIMAPCHECKSUBSCRIBED)) { - memset (&token, 0, sizeof (token)); + p_clear(&token, 1); err.data = errstr; err.dsize = sizeof (errstr); snprintf (mbox, sizeof (mbox), "%smailboxes \"%s\"", @@ -1510,12 +1509,12 @@ static int imap_complete_hosts (char *dest, size_t len) { int matchlen; int i = 0; - matchlen = str_len (dest); + matchlen = m_strlen(dest); if (list_empty (Incoming)) return (-1); for (i = 0; i < Incoming->length; i++) { mailbox = (BUFFY*) Incoming->data[i]; - if (!str_ncmp (dest, mailbox->path, matchlen)) { + if (!m_strncmp(dest, mailbox->path, matchlen)) { if (rc) { strfcpy (dest, mailbox->path, len); rc = 0; @@ -1536,7 +1535,7 @@ static int imap_complete_hosts (char *dest, size_t len) { url.user = NULL; url.path = NULL; url_ciss_tostring (&url, urlstr, sizeof (urlstr), 0); - if (!str_ncmp (dest, urlstr, matchlen)) { + if (!m_strncmp(dest, urlstr, matchlen)) { if (rc) { strfcpy (dest, urlstr, len); rc = 0; @@ -1604,14 +1603,14 @@ int imap_complete (char *dest, size_t dlen, char *path) { /* if the folder isn't selectable, append delimiter to force browse * to enter it on second tab. */ if (noselect) { - clen = str_len (list_word); + clen = m_strlen(list_word); list_word[clen++] = delim; list_word[clen] = '\0'; } /* copy in first word */ if (!completions) { strfcpy (completion, list_word, sizeof (completion)); - matchlen = str_len (completion); + matchlen = m_strlen(completion); completions++; continue; }