From: Pierre Habouzit Date: Sat, 26 May 2007 16:13:09 +0000 (+0200) Subject: nntp fixes: no more warnings. X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=4e846802eb1912873b56a27644215e6eeb91dc76;p=apps%2Fmadmutt.git nntp fixes: no more warnings. Signed-off-by: Pierre Habouzit --- diff --git a/nntp/ChangeLog.nntp b/nntp/ChangeLog.nntp deleted file mode 100644 index 271e8fb..0000000 --- a/nntp/ChangeLog.nntp +++ /dev/null @@ -1,301 +0,0 @@ -* Tue Feb 3 2004 Vsevolod Volkov -- update to 1.5.6 - -* Thu Dec 18 2003 Vsevolod Volkov -- fixed compose menu - -* Thu Nov 6 2003 Vsevolod Volkov -- update to 1.5.5.1 - -* Wed Nov 5 2003 Vsevolod Volkov -- update to 1.5.5 -- added space after newsgroup name in .newsrc file - -* Sun May 18 2003 Vsevolod Volkov -- nntp patch: fixed SIGSEGV when posting article - -* Sat Mar 22 2003 Vsevolod Volkov -- update to 1.5.4 - -* Sat Dec 21 2002 Vsevolod Volkov -- update to 1.5.3 -- replace safe_free calls by the FREE macro - -* Fri Dec 6 2002 Vsevolod Volkov -- update to 1.5.2 -- nntp authentication can be passed after any command - -* Sat May 4 2002 Vsevolod Volkov -- update to 1.5.1 - -* Thu May 2 2002 Vsevolod Volkov -- update to 1.3.99 - -* Wed Mar 13 2002 Vsevolod Volkov -- update to 1.3.28 -- fixed SIGSEGV in , , , - functions -- fixed message about nntp reconnect -- fixed function using browser -- added support of Followup-To: poster -- added %n (new articles) in group_index_format -- posting articles without inews by default - -* Wed Jan 23 2002 Vsevolod Volkov -- update to 1.3.27 - -* Fri Jan 18 2002 Vsevolod Volkov -- update to 1.3.26 - -* Thu Jan 3 2002 Vsevolod Volkov -- update to 1.3.25 -- accelerated speed of access to news->newsgroups hash (by ) -- added default content disposition - -* Mon Dec 3 2001 Vsevolod Volkov -- update to 1.3.24 - -* Fri Nov 9 2001 Vsevolod Volkov -- update to 1.3.23.2 -- fixed segfault if mutt_conn_find() returns null - -* Wed Oct 31 2001 Vsevolod Volkov -- update to 1.3.23.1 -- added support of LISTGROUP command -- added support for servers with broken overview -- disabled function on news server -- fixed error storing bad authentication information - -* Wed Oct 10 2001 Vsevolod Volkov -- update to 1.3.23 -- fixed typo in buffy.c -- added substitution of %s parameter in $inews variable - -* Fri Aug 31 2001 Vsevolod Volkov -- update to 1.3.22.1 -- update to 1.3.22 - -* Thu Aug 23 2001 Vsevolod Volkov -- update to 1.3.21 - -* Wed Jul 25 2001 Vsevolod Volkov -- update to 1.3.20 -- removed 'server-hook', use 'account-hook' instead -- fixed error opening NNTP server without newsgroup using -f option - -* Fri Jun 8 2001 Vsevolod Volkov -- update to 1.3.19 - -* Sat May 5 2001 Vsevolod Volkov -- update to 1.3.18 -- fixed typo in nntp_attempt_features() -- changed algorithm of XGTITLE command testing -- disabled writing of NNTP password in debug file -- fixed reading and writing of long newsrc lines -- changed checking of last line while reading lines from server -- fixed possible buffer overrun in nntp_parse_newsrc_line() -- removed checking of XHDR command -- compare NNTP return codes without trailing space - -* Thu Mar 29 2001 Vsevolod Volkov -- update to 1.3.17 -- support for 'LIST NEWSGROUPS' command to read descriptions - -* Fri Mar 2 2001 Vsevolod Volkov -- update to 1.3.16 - -* Wed Feb 14 2001 Vsevolod Volkov -- update to 1.3.15 - -* Sun Jan 28 2001 Vsevolod Volkov -- update to 1.3.14 -- show number of tagged messages patch from Felix von Leitner - -* Sun Dec 31 2000 Vsevolod Volkov -- update to 1.3.13 - -* Sat Dec 30 2000 Vsevolod Volkov -- Fixed problem if last article in group is deleted - -* Fri Dec 22 2000 Vsevolod Volkov -- Fixed checking of XGTITLE command on some servers - -* Mon Dec 18 2000 Vsevolod Volkov -- Added \r in AUTHINFO commands - -* Mon Nov 27 2000 Vsevolod Volkov -- update to 1.3.12 - -* Wed Nov 1 2000 Vsevolod Volkov -- update to 1.3.11 -- fixed error opening newsgroup from mutt started with -g or -G - -* Thu Oct 12 2000 Vsevolod Volkov -- update to 1.3.10 -- hotkey 'G' (get-message) replaced with '^G' - -* Thu Sep 21 2000 Vsevolod Volkov -- update to 1.3.9 -- changed delay displaying error messages from 1 to 2 seconds -- fixed error compiling with nntp and without imap - -* Wed Sep 6 2000 Vsevolod Volkov -- fixed catchup in index -- fixed nntp_open_mailbox() - -* Sat Sep 2 2000 Vsevolod Volkov -- functions and disabled -- format of news mailbox names changed to url form -- option nntp_attempts removed -- option reconnect_news renamed to nntp_reconnect -- default value of nntp_poll changed from 30 to 60 -- error handling improved - -* Wed Aug 30 2000 Vsevolod Volkov -- update to 1.3.8 -- new option show_only_unread -- add newsgroup completion - -* Fri Aug 4 2000 Vsevolod Volkov -- update to 1.3.7 - -* Sat Jul 29 2000 Vsevolod Volkov -- update to 1.3.6 - -* Sun Jul 9 2000 Vsevolod Volkov -- update to 1.3.5 -- authentication code update -- fix for changing to newsgroup from mailbox with read messages -- socket code optimization - -* Wed Jun 21 2000 Vsevolod Volkov -- update to 1.3.4 - -* Wed Jun 14 2000 Vsevolod Volkov -- don't substitute current newsgroup with deleted new messages - -* Mon Jun 12 2000 Vsevolod Volkov -- update to 1.3.3 -- fix for substitution of newsgroup after reconnection -- fix for loading newsgroups with very long names -- fix for loading more than 32768 newsgroups - -* Wed May 24 2000 Vsevolod Volkov -- update to 1.3.2 - -* Sat May 20 2000 Vsevolod Volkov -- update to 1.3.1 - -* Fri May 12 2000 Vsevolod Volkov -- update to 1.3 - -* Thu May 11 2000 Vsevolod Volkov -- update to 1.2 - -* Thu May 4 2000 Vsevolod Volkov -- update to 1.1.14 - -* Sun Apr 23 2000 Vsevolod Volkov -- update to 1.1.12 - -* Fri Apr 7 2000 Vsevolod Volkov -- add substitution of newsgroup with new messages by default - -* Wed Apr 5 2000 Vsevolod Volkov -- add attach message from newsgroup -- add one-line help in newsreader mode -- disable 'change-dir' command in newsgroups browser -- add -G option - -* Tue Apr 4 2000 Vsevolod Volkov -- get default newsserver name from file /etc/nntpserver -- use case insensitive server names -- add print-style sequence %s to $newsrc -- add -g option - -* Sat Apr 1 2000 Vsevolod Volkov -- remove 'X-FTN-Origin' header processing - -* Thu Mar 30 2000 Vsevolod Volkov -- update to 1.1.11 -- update to 1.1.10 - -* Thu Mar 23 2000 Vsevolod Volkov -- fix mutt_select_newsserver() -- remove 'toggle-mode' function -- add 'change-newsgroup' function - -* Wed Mar 22 2000 Vsevolod Volkov -- fix server-hook - -* Tue Mar 21 2000 Vsevolod Volkov -- fix error 'bounce' function after 'post' -- add 'forward to newsgroup' function - -* Mon Mar 20 2000 Vsevolod Volkov -- 'forward' function works in newsreader mode -- add 'post' and 'followup' functions to pager and attachment menu -- fix active descriptions and allowed flag reload - -* Tue Mar 14 2000 Vsevolod Volkov -- update to 1.1.9 -- remove deleted newsgroups from list - -* Mon Mar 13 2000 Vsevolod Volkov -- update .newsrc in browser - -* Sun Mar 12 2000 Vsevolod Volkov -- reload .newsrc if externally modified -- fix active cache update - -* Sun Mar 5 2000 Vsevolod Volkov -- update to 1.1.8 - -* Sat Mar 4 2000 Vsevolod Volkov -- patch *.update_list_file is not required -- count lines when loading descriptions -- remove cache of unsubscribed newsgroups - -* Thu Mar 2 2000 Vsevolod Volkov -- load list of newsgroups from cache faster - -* Wed Mar 1 2000 Vsevolod Volkov -- update to 1.1.7 - -* Tue Feb 29 2000 Vsevolod Volkov -- fix unread messages in browser -- fix newsrc_gen_entries() - -* Mon Feb 28 2000 Vsevolod Volkov -- fix mutt_newsgroup_stat() -- fix nntp_delete_cache() -- fix nntp_get_status() -- fix check_children() -- fix nntp_fetch_headers() - -* Fri Feb 25 2000 Vsevolod Volkov -- update to 1.1.5 - -* Thu Feb 24 2000 Vsevolod Volkov -- fix updating new messages in cache - -* Mon Feb 21 2000 Vsevolod Volkov -- change default cache filenames -- fix updating new messages in cache - -* Fri Feb 18 2000 Vsevolod Volkov -- fix segmentation fault in news groups browser - -* Tue Feb 15 2000 Vsevolod Volkov -- update to 1.1.4 - -* Thu Feb 10 2000 Vsevolod Volkov -- update to 1.1.3 - -* Sun Jan 30 2000 Vsevolod Volkov -- add X-Comment-To editing -- add my_hdr support for Newsgroups:, Followup-To: and X-Comment-To: headers -- add variables $ask_followup_to and $ask_x_comment_to - -* Fri Jan 28 2000 Vsevolod Volkov -- update to 1.1.2 diff --git a/nntp/newsrc.c b/nntp/newsrc.c index 4f2f249..0eac040 100644 --- a/nntp/newsrc.c +++ b/nntp/newsrc.c @@ -441,8 +441,7 @@ void nntp_get_status (CONTEXT * ctx, HEADER * h, char *group, int article) void mutt_newsgroup_stat (NNTP_DATA * data) { - int i; - unsigned int first, last; + int i, first, last; data->unread = 0; if (data->lastMessage == 0 || data->firstMessage > data->lastMessage) @@ -530,7 +529,7 @@ void newsrc_gen_entries (CONTEXT * ctx) { NNTP_DATA *data = (NNTP_DATA *) ctx->data; int series, x; - unsigned int last = 0, first = 1; + int last = 0, first = 1; int save_sort = SORT_ORDER; if (Sort != SORT_ORDER) { @@ -1066,7 +1065,7 @@ void nntp_buffy (char* dst, ssize_t dstlen) { if (data && data->subscribed && data->unread) { if (Context && Context->magic == M_NNTP && !m_strcmp(data->group, ((NNTP_DATA *) Context->data)->group)) { - unsigned int i, unread = 0; + int i, unread = 0; for (i = 0; i < Context->msgcount; i++) if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted) diff --git a/nntp/nntp.c b/nntp/nntp.c index 5e76fdd..2fc34d6 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -32,12 +32,6 @@ void nntp_sync_sidebar (NNTP_DATA* data) { if (!Incoming.len) return; - /* unfortunately, NNTP_DATA::group only is the plain - * group name, so for every single update, we need to - * compose the full string which must be defined via - * mailboxes command ;-((( FIXME - */ - buf[0] = '\0'; snprintf(buf, sizeof (buf), "nntp%s://%s%s%s%s/%s", data->nserv->conn->account.has_ssl ? "s" : "", NONULL(data->nserv->conn->account.user), @@ -177,6 +171,9 @@ static int nntp_attempt_features (NNTP_SERVER * serv) char buf[LONG_STRING]; CONNECTION *conn = serv->conn; + if (serv->feat_known) + return 0; + mutt_socket_write (conn, "XOVER\r\n"); if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) return nntp_connect_error (serv); @@ -208,6 +205,7 @@ static int nntp_attempt_features (NNTP_SERVER * serv) } while (!(buf[0] == '.' && buf[1] == '\0')); } + serv->feat_known = 1; return 0; } @@ -592,16 +590,16 @@ static int nntp_parse_xover (CONTEXT * ctx, char *buf, HEADER * hdr) typedef struct { CONTEXT *ctx; - unsigned int base; - unsigned int first; - unsigned int last; - unsigned short *messages; - char *msg; + int base; + int first; + int last; + char *messages; + const char *msg; } FETCH_CONTEXT; static int nntp_fetch_numbers (char *line, void *c) { - unsigned int num; + int num; FETCH_CONTEXT *fc = c; if (!line) @@ -617,7 +615,7 @@ static int nntp_fetch_numbers (char *line, void *c) static int add_xover_line (char *line, void *c) { - unsigned int num, total; + int num, total; FETCH_CONTEXT *fc = c; CONTEXT *ctx = fc->ctx; NNTP_DATA *data = (NNTP_DATA *) ctx->data; @@ -650,17 +648,13 @@ static int add_xover_line (char *line, void *c) #undef fc -static int nntp_fetch_headers (CONTEXT * ctx, unsigned int first, - unsigned int last) +static int nntp_fetch_headers(CONTEXT * ctx, int first, int last) { char buf[HUGE_STRING]; const char *msg = _("Fetching message headers..."); const char *msg2 = _("Fetching headers from cache..."); NNTP_DATA *nntp_data = ((NNTP_DATA *) ctx->data); - int ret; - int num; - int oldmsgcount; - unsigned int current; + int ret, num, oldmsgcount, current; FILE *f; FETCH_CONTEXT fc; @@ -674,12 +668,13 @@ static int nntp_fetch_headers (CONTEXT * ctx, unsigned int first, fc.ctx = ctx; fc.base = first; fc.last = last; - fc.messages = p_new(unsigned short, last - first + 1); + fc.messages = p_new(char, last - first + 1); 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) != - 0) { + if (mutt_nntp_fetch(nntp_data, buf, NULL, NULL, + nntp_fetch_numbers, &fc, 0)) + { mutt_error (_("LISTGROUP command failed: %s"), buf); sleep (2); p_delete(&fc.messages); @@ -690,74 +685,74 @@ static int nntp_fetch_headers (CONTEXT * ctx, unsigned int first, fc.messages[num] = 1; } - /* CACHE: must be loaded xover cache here */ - num = nntp_data->lastCached - first + 1; - if (option (OPTNEWSCACHE) && nntp_data->cache && num > 0) { - nntp_cache_expand (buf, nntp_data->cache); - mutt_message (msg2); - - if ((f = safe_fopen (buf, "r"))) { - int r = 0, c = 0; - - /* counting number of lines */ - while (fgets (buf, sizeof (buf), f) != NULL) - r++; - rewind (f); - while (r > num && fgets (buf, sizeof (buf), f) != NULL) - r--; - oldmsgcount = ctx->msgcount; - fc.first = first; - fc.last = first + num - 1; - fc.msg = NULL; - while (fgets (buf, sizeof (buf), f) != NULL) { - if (ReadInc && ((++c) % ReadInc == 0)) - mutt_message ("%s %d/%d", msg2, c, r); - add_xover_line (buf, &fc); - } - m_fclose(&f); - nntp_data->lastLoaded = fc.last; - first = fc.last + 1; - if (ctx->msgcount > oldmsgcount) - mx_update_context (ctx, ctx->msgcount - oldmsgcount); - } - else - nntp_delete_cache (nntp_data); - } - num = last - first + 1; - if (num <= 0) { - p_delete(&fc.messages); - return 0; +/* CACHE: must be loaded xover cache here */ +num = nntp_data->lastCached - first + 1; +if (option (OPTNEWSCACHE) && nntp_data->cache && num > 0) { +nntp_cache_expand (buf, nntp_data->cache); +mutt_message (msg2); + +if ((f = safe_fopen (buf, "r"))) { + int r = 0, c = 0; + + /* counting number of lines */ + while (fgets (buf, sizeof (buf), f) != NULL) + r++; + rewind (f); + while (r > num && fgets (buf, sizeof (buf), f) != NULL) + r--; + oldmsgcount = ctx->msgcount; + fc.first = first; + fc.last = first + num - 1; + fc.msg = NULL; + while (fgets (buf, sizeof (buf), f) != NULL) { + if (ReadInc && ((++c) % ReadInc == 0)) + mutt_message ("%s %d/%d", msg2, c, r); + add_xover_line (buf, &fc); } + m_fclose(&f); + nntp_data->lastLoaded = fc.last; + first = fc.last + 1; + if (ctx->msgcount > oldmsgcount) + mx_update_context (ctx, ctx->msgcount - oldmsgcount); +} +else + nntp_delete_cache (nntp_data); +} +num = last - first + 1; +if (num <= 0) { +p_delete(&fc.messages); +return 0; +} - /* - * Without XOVER, we have to fetch each article header and parse - * it. With XOVER, we ask for all of them - */ - mutt_message (msg); - if (nntp_data->nserv->hasXOVER) { - oldmsgcount = ctx->msgcount; - fc.first = first; - fc.last = last; - fc.msg = msg; - snprintf (buf, sizeof (buf), "XOVER %d-%d\r\n", first, last); - ret = mutt_nntp_fetch (nntp_data, buf, NULL, NULL, add_xover_line, &fc, 0); - if (ctx->msgcount > oldmsgcount) - mx_update_context (ctx, ctx->msgcount - oldmsgcount); - if (ret != 0) { - mutt_error (_("XOVER command failed: %s"), buf); - p_delete(&fc.messages); - return -1; - } - /* fetched OK */ - } - else - for (current = first; current <= last; current++) { - HEADER *h; +/* +* Without XOVER, we have to fetch each article header and parse +* it. With XOVER, we ask for all of them +*/ +mutt_message (msg); +if (nntp_data->nserv->hasXOVER) { +oldmsgcount = ctx->msgcount; +fc.first = first; +fc.last = last; +fc.msg = msg; +snprintf (buf, sizeof (buf), "XOVER %d-%d\r\n", first, last); +ret = mutt_nntp_fetch (nntp_data, buf, NULL, NULL, add_xover_line, &fc, 0); +if (ctx->msgcount > oldmsgcount) + mx_update_context (ctx, ctx->msgcount - oldmsgcount); +if (ret != 0) { + mutt_error (_("XOVER command failed: %s"), buf); + p_delete(&fc.messages); + return -1; +} +/* fetched OK */ +} +else +for (current = first; current <= last; current++) { + HEADER *h; - ret = current - first + 1; - mutt_message ("%s %d/%d", msg, ret, num); + ret = current - first + 1; + mutt_message ("%s %d/%d", msg, ret, num); - if (!fc.messages[current - fc.base]) + if (!fc.messages[current - fc.base]) continue; if (ctx->msgcount >= ctx->hdrmax) @@ -796,8 +791,7 @@ static int nntp_open_mailbox (CONTEXT * ctx) NNTP_SERVER *serv; char buf[HUGE_STRING]; char server[LONG_STRING]; - int count = 0; - unsigned int first; + int count = 0, first; ACCOUNT act; p_clear(&act, 1); @@ -1416,15 +1410,15 @@ int nntp_check_msgid (CONTEXT * ctx, const char *msgid) typedef struct { CONTEXT *ctx; - unsigned int num; - unsigned int max; - unsigned int *child; + int num; + int max; + int *child; } CHILD_CONTEXT; static int check_children (char *s, void *c) { -#define cc ((CHILD_CONTEXT *) c) - unsigned int i, n; + CHILD_CONTEXT *cc = c; + int i, n; if (!s || (n = atoi (s)) == 0) return 0; @@ -1436,7 +1430,6 @@ static int check_children (char *s, void *c) cc->child[cc->num++] = n; return 0; -#undef cc } int nntp_check_children (CONTEXT * ctx, const char *msgid) @@ -1463,7 +1456,7 @@ int nntp_check_children (CONTEXT * ctx, const char *msgid) cc.ctx = ctx; cc.num = 0; cc.max = 25; - cc.child = p_new(unsigned int, 25); + cc.child = p_new(int, 25); if (mutt_nntp_fetch (nntp_data, buf, NULL, NULL, check_children, &cc, 0)) { p_delete(&cc.child); return -1; diff --git a/nntp/nntp.h b/nntp/nntp.h index de7627f..0fe2605 100644 --- a/nntp/nntp.h +++ b/nntp/nntp.h @@ -35,11 +35,12 @@ typedef struct { } NEWSRC_ENTRY; typedef struct { - unsigned int hasXPAT:1; - unsigned int hasXGTITLE:1; - unsigned int hasXOVER:1; - unsigned int hasLISTGROUP:1; - unsigned int status:3; + unsigned feat_known : 1; + unsigned hasXPAT : 1; + unsigned hasXGTITLE : 1; + unsigned hasXOVER : 1; + unsigned hasLISTGROUP : 1; + unsigned status : 3; char *newsrc; char *cache; int stat; @@ -54,24 +55,24 @@ typedef struct { } NNTP_SERVER; typedef struct { - unsigned int index; + int index; char *path; } NNTP_CACHE; typedef struct { NEWSRC_ENTRY *entries; - unsigned int num; /* number of used entries */ - unsigned int max; /* number of allocated entries */ - unsigned int unread; - unsigned int firstMessage; - unsigned int lastMessage; - unsigned int lastLoaded; - unsigned int lastCached; - unsigned int subscribed:1; - unsigned int rc:1; - unsigned int new:1; - unsigned int allowed:1; - unsigned int deleted:1; + int num; /* number of used entries */ + int max; /* number of allocated entries */ + int unread; + int firstMessage; + int lastMessage; + int lastLoaded; + int lastCached; + unsigned subscribed:1; + unsigned rc:1; + unsigned new:1; + unsigned allowed:1; + unsigned deleted:1; char *group; char *desc; char *cache;