X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=nntp%2Fnewsrc.c;h=bb477f53067adf3805bff1e4d5ca558f8f009deb;hb=9ed7a487e3a922f2cbb222961c2c9710c3a65f91;hp=e9709f74f15a4748a9a5e237fbc9c25ee494f4b3;hpb=ac813896ca32d850febc2d95065ac4fa040f11f9;p=apps%2Fmadmutt.git diff --git a/nntp/newsrc.c b/nntp/newsrc.c index e9709f7..bb477f5 100644 --- a/nntp/newsrc.c +++ b/nntp/newsrc.c @@ -9,32 +9,17 @@ * please see the file GPL in the top level source directory. */ -#ifdef HAVE_CONFIG_H -#include -#endif +#include -#include -#include -#include -#include #include -#include - -#include -#include -#include -#include -#include #include - #include +#include #include "mutt.h" #include "sort.h" -#include "mx.h" #include "nntp.h" -#include "rfc1524.h" void nntp_add_to_list (NNTP_SERVER * s, NNTP_DATA * d) { @@ -126,7 +111,6 @@ static int nntp_parse_newsrc_line (NNTP_SERVER * news, char *line) data->lastMessage = data->entries[x - 1].last; data->num = x; mutt_newsgroup_stat (data); - debug_print (2, ("Newsgroup %s\n", data->group)); return 0; } @@ -145,7 +129,7 @@ static int slurp_newsrc (NNTP_SERVER * news) return -1; /* hmm, should we use dotlock? */ if (mx_lock_file (news->newsrc, fileno (fp), 0, 0, 1)) { - fclose (fp); + m_fclose(&fp); return -1; } @@ -155,7 +139,7 @@ static int slurp_newsrc (NNTP_SERVER * news) p_delete(&buf); mx_unlock_file (news->newsrc, fileno (fp), 0); - fclose (fp); + m_fclose(&fp); return 0; } @@ -251,7 +235,7 @@ static int nntp_parse_cacheindex (NNTP_SERVER * news) mutt_newsgroup_stat (data); } } - fclose (idx); + m_fclose(&idx); return 0; } @@ -437,10 +421,6 @@ void nntp_get_status (CONTEXT * ctx, HEADER * h, char *group, int article) data = (NNTP_DATA *) hash_find (data->nserv->newsgroups, group); if (!data) { -#ifdef DEBUG - if (group) - debug_print (3, ("newsgroup %s not found\n", group)); -#endif return; } @@ -639,14 +619,13 @@ static int mutt_update_list_file (char *filename, char *section, /* if file not exist, create it */ if ((ifp = safe_fopen (filename, "a"))) - fclose (ifp); - debug_print (1, ("Opening %s\n", filename)); + m_fclose(&ifp); if (!(ifp = safe_fopen (filename, "r"))) { mutt_error (_("Unable to open %s for reading"), filename); return -1; } if (mx_lock_file (filename, fileno (ifp), 0, 0, 1)) { - fclose (ifp); + m_fclose(&ifp); mutt_error (_("Unable to lock %s"), filename); return -1; } @@ -658,9 +637,8 @@ static int mutt_update_list_file (char *filename, char *section, m_strcpy(buf, sizeof(buf), filename); m_strcpy(tmpfile, sizeof(tmpfile), basename(filename)); mutt_adv_mktemp ((const char*) dirname (buf), tmpfile, sizeof (tmpfile)); - debug_print (1, ("Opening %s\n", tmpfile)); if (!(ofp = fopen (tmpfile, "w"))) { - fclose (ifp); + m_fclose(&ifp); mutt_error (_("Unable to open %s for writing"), tmpfile); return -1; } @@ -722,8 +700,8 @@ static int mutt_update_list_file (char *filename, char *section, r = fputc ('\n', ofp); } mx_unlock_file (filename, fileno (ifp), 0); - fclose (ofp); - fclose (ifp); + m_fclose(&ofp); + m_fclose(&ifp); if (r == EOF) { unlink (tmpfile); mutt_error (_("Can't write %s"), tmpfile); @@ -732,7 +710,6 @@ static int mutt_update_list_file (char *filename, char *section, link[0] = '\0'; if ((l = readlink (filename, link, sizeof (link)-1)) > 0) link[l] = '\0'; - debug_print (1, ("Renaming %s to %s\n",tmpfile, l > 0 ? link : filename)); if (rename (tmpfile, l > 0 ? link : filename) < 0) { unlink (tmpfile); mutt_error (_("Can't rename %s to %s"), tmpfile, l > 0 ? link : filename); @@ -759,7 +736,6 @@ int mutt_newsrc_update (NNTP_SERVER * news) if (!data || !data->rc) continue; nntp_create_newsrc_line (data, &buf, &line, &llen); - debug_print (2, ("Added to newsrc: %s\n", line)); line += m_strlen(line); } /* newrc being fully rewritten */ @@ -831,7 +807,6 @@ void nntp_clear_cacheindex (NNTP_SERVER * news) if (!data || data->subscribed || !data->cache) continue; nntp_delete_cache (data); - debug_print (2, ("Removed from .index: %s\n", data->group)); } return; } @@ -873,13 +848,13 @@ int nntp_save_cache_index (NNTP_SERVER * news) snprintf (buf, sizeof (buf), "%s %d %d %c\n", d->group, d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n'); if (fputs (buf, f) == EOF) { - fclose (f); + m_fclose(&f); unlink (file); return -1; } } } - fclose (f); + m_fclose(&f); if (nntp_update_cacheindex (news, NULL)) { unlink (file); @@ -946,7 +921,7 @@ int nntp_save_cache_group (CONTEXT * ctx) snprintf (buf, sizeof (buf), "\t%zd\t%d\tXref: %s\n", h->content->length, h->lines, NONULL (h->env->xref)); if (fputs (buf, f) == EOF) { - fclose (f); + m_fclose(&f); unlink (file); return -1; } @@ -958,7 +933,7 @@ int nntp_save_cache_group (CONTEXT * ctx) Sort = save; mutt_sort_headers (ctx, 0); } - fclose (f); + m_fclose(&f); if (nntp_update_cacheindex (((NNTP_DATA *) ctx->data)->nserv, (NNTP_DATA *) ctx->data)) {