X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=pop%2Fpop.c;h=bba466f36e8aa5509accf98b55cf824dbb1c866e;hp=804fec25714f5a4dc5b63a2afb012fb4cc5b4ae2;hb=91d0c04349c9345f0ee29a61cc18dfc144b60edc;hpb=4711a1a970ba7dda6eaf71f16fdfd74f90d02bb8 diff --git a/pop/pop.c b/pop/pop.c index 804fec2..bba466f 100644 --- a/pop/pop.c +++ b/pop/pop.c @@ -11,15 +11,17 @@ # include "config.h" #endif +#include +#include +#include +#include + #include "mutt.h" #include "mx.h" #include "pop.h" #include "mutt_crypt.h" #include "mutt_curses.h" -#include "lib/mem.h" -#include "lib/str.h" -#include "lib/intl.h" #include "lib/debug.h" #include @@ -130,7 +132,7 @@ static int fetch_uidl (char *line, void *data) sscanf (line, "%d %s", &index, line); for (i = 0; i < ctx->msgcount; i++) - if (!str_cmp (line, ctx->hdrs[i]->data)) + if (!m_strcmp(line, ctx->hdrs[i]->data)) break; if (i == ctx->msgcount) { @@ -141,7 +143,7 @@ static int fetch_uidl (char *line, void *data) ctx->msgcount++; ctx->hdrs[i] = mutt_new_header (); - ctx->hdrs[i]->data = str_dup (line); + ctx->hdrs[i]->data = m_strdup(line); } else if (ctx->hdrs[i]->index != index - 1) pop_data->clear_cache = 1; @@ -246,10 +248,10 @@ int pop_open_mailbox (CONTEXT * ctx) if (!conn) return -1; - mem_free (&ctx->path); - ctx->path = str_dup (buf); + p_delete(&ctx->path); + ctx->path = m_strdup(buf); - pop_data = mem_calloc (1, sizeof (POP_DATA)); + pop_data = p_new(POP_DATA, 1); pop_data->conn = conn; ctx->data = pop_data; @@ -258,7 +260,7 @@ int pop_open_mailbox (CONTEXT * ctx) conn->data = pop_data; - FOREVER { + for (;;) { if (pop_reconnect (ctx) != PQ_OK) return -1; @@ -291,7 +293,7 @@ static void pop_clear_cache (POP_DATA * pop_data) for (i = 0; i < POP_CACHE_LEN; i++) { if (pop_data->cache[i].path) { unlink (pop_data->cache[i].path); - mem_free (&pop_data->cache[i].path); + p_delete(&pop_data->cache[i].path); } } } @@ -349,11 +351,11 @@ int pop_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno) else { /* clear the previous entry */ unlink (cache->path); - mem_free (&cache->path); + p_delete(&cache->path); } } - FOREVER { + for (;;) { if (pop_reconnect (ctx) != PQ_OK) return -1; @@ -404,7 +406,7 @@ int pop_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno) * portion of the headers, those required for the main display. */ cache->index = h->index; - cache->path = str_dup (path); + cache->path = m_strdup(path); rewind (msg->fp); uidl = h->data; mutt_free_envelope (&h->env); @@ -417,7 +419,7 @@ int pop_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno) fgets (buf, sizeof (buf), msg->fp); } - h->content->length = ftell (msg->fp) - h->content->offset; + h->content->length = ftello (msg->fp) - h->content->offset; /* This needs to be done in case this is a multipart message */ if (!WithCrypto) @@ -439,7 +441,7 @@ pop_query_status pop_sync_mailbox (CONTEXT * ctx, int unused, int *index_hint) pop_data->check_time = 0; - FOREVER { + for (;;) { if (pop_reconnect (ctx) != PQ_OK) return PQ_NOT_CONNECTED; @@ -453,7 +455,7 @@ pop_query_status pop_sync_mailbox (CONTEXT * ctx, int unused, int *index_hint) } if (ret == PQ_OK) { - strfcpy (buf, "QUIT\r\n", sizeof (buf)); + m_strcpy(buf, sizeof(buf), "QUIT\r\n"); ret = pop_query (pop_data, buf, sizeof (buf)); } @@ -524,7 +526,7 @@ void pop_fetch_mail (void) return; } - url = p = mem_calloc (strlen (PopHost) + 7, sizeof (char)); + url = p = p_new(char, strlen (PopHost) + 7); if (url_check_scheme (PopHost) == U_UNKNOWN) { strcpy (url, "pop://"); /* __STRCPY_CHECKED__ */ p = strchr (url, '\0'); @@ -532,7 +534,7 @@ void pop_fetch_mail (void) strcpy (p, PopHost); /* __STRCPY_CHECKED__ */ ret = pop_parse_path (url, &acct); - mem_free (&url); + p_delete(&url); if (ret) { mutt_error (_("%s is an invalid POP path"), PopHost); return; @@ -542,12 +544,12 @@ void pop_fetch_mail (void) if (!conn) return; - pop_data = mem_calloc (1, sizeof (POP_DATA)); + pop_data = p_new(POP_DATA, 1); pop_data->conn = conn; if (pop_open_connection (pop_data) < 0) { mutt_socket_free (pop_data->conn); - mem_free (&pop_data); + p_delete(&pop_data); return; } @@ -556,7 +558,7 @@ void pop_fetch_mail (void) mutt_message _("Checking for new messages..."); /* find out how many messages are in the mailbox. */ - strfcpy (buffer, "STAT\r\n", sizeof (buffer)); + m_strcpy(buffer, sizeof(buffer), "STAT\r\n"); ret = pop_query (pop_data, buffer, sizeof (buffer)); if (ret == PQ_NOT_CONNECTED) goto fail; @@ -569,7 +571,7 @@ void pop_fetch_mail (void) /* only get unread messages */ if (msgs > 0 && option (OPTPOPLAST)) { - strfcpy (buffer, "LAST\r\n", sizeof (buffer)); + m_strcpy(buffer, sizeof(buffer), "LAST\r\n"); ret = pop_query (pop_data, buffer, sizeof (buffer)); if (ret == PQ_NOT_CONNECTED) goto fail; @@ -638,22 +640,22 @@ void pop_fetch_mail (void) if (rset) { /* make sure no messages get deleted */ - strfcpy (buffer, "RSET\r\n", sizeof (buffer)); + m_strcpy(buffer, sizeof(buffer), "RSET\r\n"); if (pop_query (pop_data, buffer, sizeof (buffer)) == PQ_NOT_CONNECTED) goto fail; } finish: /* exit gracefully */ - strfcpy (buffer, "QUIT\r\n", sizeof (buffer)); + m_strcpy(buffer, sizeof(buffer), "QUIT\r\n"); if (pop_query (pop_data, buffer, sizeof (buffer)) == PQ_NOT_CONNECTED) goto fail; mutt_socket_close (conn); - mem_free (&pop_data); + p_delete(&pop_data); return; fail: mutt_error _("Server closed connection!"); mutt_socket_close (conn); - mem_free (&pop_data); + p_delete(&pop_data); }