From cda4a5f8db686b01e540057ca5cb16411829f39f Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Sat, 26 May 2007 17:45:34 +0200 Subject: [PATCH] always use LISTGROUP if available. Signed-off-by: Pierre Habouzit --- nntp/nntp.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/nntp/nntp.c b/nntp/nntp.c index cd2073e..5e76fdd 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -22,8 +22,6 @@ #include "buffy.h" #include "crypt.h" -#define WANT_LISTGROUP_COMMAND 0 - static unsigned int _checked = 0; void nntp_sync_sidebar (NNTP_DATA* data) { @@ -191,13 +189,11 @@ static int nntp_attempt_features (NNTP_SERVER * serv) if (m_strncmp("500", buf, 3)) serv->hasXPAT = 1; -#if WANT_LISTGROUP_COMMAND mutt_socket_write (conn, "LISTGROUP\r\n"); if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) return (nntp_connect_error (serv)); if (m_strncmp("500", buf, 3)) serv->hasLISTGROUP = 1; -#endif mutt_socket_write (conn, "XGTITLE +\r\n"); if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) @@ -603,27 +599,26 @@ typedef struct { char *msg; } FETCH_CONTEXT; -#define fc ((FETCH_CONTEXT *) c) - -#if WANT_LISTGROUP_COMMAND -static int _nntp_fetch_numbers (unsigned int num, void *c) +static int nntp_fetch_numbers (char *line, void *c) { + unsigned int num; + FETCH_CONTEXT *fc = c; + + if (!line) + return 0; + + num = atoi(line); if (num < fc->base || num > fc->last) return 0; + fc->messages[num - fc->base] = 1; return 0; } -static int nntp_fetch_numbers (char *line, void *c) -{ - if (!line) - return 0; - return (_nntp_fetch_numbers ((unsigned int) atoi (line), c)); -} -#endif static int add_xover_line (char *line, void *c) { unsigned int num, total; + FETCH_CONTEXT *fc = c; CONTEXT *ctx = fc->ctx; NNTP_DATA *data = (NNTP_DATA *) ctx->data; @@ -680,7 +675,7 @@ static int nntp_fetch_headers (CONTEXT * ctx, unsigned int first, fc.base = first; fc.last = last; fc.messages = p_new(unsigned short, last - first + 1); -#if WANT_LISTGROUP_COMMAND + if (nntp_data->nserv->hasLISTGROUP) { snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group); if (mutt_nntp_fetch (nntp_data, buf, NULL, NULL, nntp_fetch_numbers, &fc, 0) != @@ -690,14 +685,10 @@ static int nntp_fetch_headers (CONTEXT * ctx, unsigned int first, p_delete(&fc.messages); return -1; } - } - else { -#endif + } else { for (num = 0; num < last - first + 1; num++) fc.messages[num] = 1; -#if WANT_LISTGROUP_COMMAND } -#endif /* CACHE: must be loaded xover cache here */ num = nntp_data->lastCached - first + 1; -- 2.20.1