X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=pop.c;h=a066f6e5dd05562de916dd3f760a506e089e4613;hp=30dcf2de01b2abac59b323d5fb094cfcd20d1681;hb=b94ae1245c98907bffbbbefaf6feb53f1ac80234;hpb=a31de505502560546791fc0158b03c41b7a721ec diff --git a/pop.c b/pop.c index 30dcf2d..a066f6e 100644 --- a/pop.c +++ b/pop.c @@ -13,7 +13,7 @@ #include #include -#include +#include #include "crypt.h" #include "mutt.h" @@ -416,6 +416,7 @@ static pop_query_status pop_authenticate (pop_data_t * pop_data) attempts++; break; } + mutt_socket_close(pop_data->conn); } } } else { @@ -431,6 +432,7 @@ static pop_query_status pop_authenticate (pop_data_t * pop_data) attempts++; break; } + mutt_socket_close(pop_data->conn); } } @@ -454,55 +456,48 @@ static pop_query_status pop_fetch_data(pop_data_t *pop_data, const char *query, progress_t *bar, int (*funct)(char *, void *), void *data) { - char buf[LONG_STRING]; - char *inbuf; - char *p; - pop_query_status ret; - int chunk = 0; - long pos = 0; - ssize_t lenbuf = 0; + pop_query_status ret; + char buf[LONG_STRING]; + buffer_t inbuf; + ssize_t pos = 0; - m_strcpy(buf, sizeof(buf), query); - ret = _pop_query(pop_data, buf, sizeof(buf)); - if (ret != PQ_OK) - return ret; + buffer_init(&inbuf); - inbuf = p_new(char, sizeof(buf)); + m_strcpy(buf, sizeof(buf), query); + ret = _pop_query(pop_data, buf, sizeof(buf)); + if (ret != PQ_OK) + return ret; - for (;;) { - chunk = - mutt_socket_readln(buf, sizeof (buf), pop_data->conn); - if (chunk < 0) { - pop_data->status = POP_DISCONNECTED; - ret = PQ_NOT_CONNECTED; - break; - } + for (;;) { + int dot = 0; - p = buf; - if (!lenbuf && buf[0] == '.') { - if (buf[1] != '.') - break; - p++; - } + if (mutt_socket_readln2(&inbuf, pop_data->conn) < 0) { + pop_data->status = POP_DISCONNECTED; + ret = PQ_NOT_CONNECTED; + break; + } - m_strcpy(inbuf + lenbuf,sizeof(buf), p); - pos += chunk; + if (bar) { + mutt_progress_bar(bar, pos += inbuf.len); + } - if (chunk >= ssizeof(buf)) { - lenbuf += strlen (p); - } else { - if (bar) - mutt_progress_bar (bar, pos); - if (ret == 0 && funct (inbuf, data) < 0) - ret = PFD_FUNCT_ERROR; - lenbuf = 0; - } + if (inbuf.data[0] == '.') { + if (inbuf.data[1] != '.') + break; + dot = 1; + } - p_realloc(&inbuf, lenbuf + sizeof(buf)); - } + if (funct(inbuf.data + dot, data) < 0) { + buffer_wipe(&inbuf); + ret = PFD_FUNCT_ERROR; + break; + } - p_delete(&inbuf); - return ret; + buffer_reset(&inbuf); + } + + buffer_wipe(&inbuf); + return ret; } static int fetch_capa (char *line, void *data) @@ -597,7 +592,7 @@ static pop_query_status pop_capabilities(pop_data_t * pop_data, int mode) /* Check capabilities */ if (mode == 2) { - char *msg = NULL; + const char *msg = NULL; if (!pop_data->expire) msg = _("Unable to leave messages on server."); @@ -632,7 +627,7 @@ static int pop_parse_path (const char *path, ACCOUNT * act) if (url.scheme == U_POP || url.scheme == U_POPS) { if (url.scheme == U_POPS) { - act->flags |= M_ACCT_SSL; + act->has_ssl = 1; act->port = POP_SSL_PORT; } @@ -1400,7 +1395,7 @@ int pop_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno) bar.msg = _("Fetching message..."); mutt_progress_bar (&bar, 0); - msg->fp = m_tempfile(path, sizeof(path), NONULL(MCore.tmpdir), NULL); + msg->fp = m_tempfile(path, sizeof(path), NONULL(mod_core.tmpdir), NULL); if (!msg->fp) { mutt_error(_("Could not create temporary file")); mutt_sleep(2);