From: Pierre Habouzit Date: Sun, 27 May 2007 21:09:02 +0000 (+0200) Subject: Getting rid of useless settings. X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=6a7c1f87b97c733b63c177d41a5aca3427e9521a;p=apps%2Fmadmutt.git Getting rid of useless settings. Signed-off-by: Pierre Habouzit --- diff --git a/globals.h b/globals.h index 2b26cc1..bdb44d5 100644 --- a/globals.h +++ b/globals.h @@ -76,11 +76,9 @@ WHERE char *Muttrc INITVAL (NULL); #ifdef USE_NNTP WHERE char *NewsCacheDir; WHERE char *GroupFormat; -WHERE char *Inews; WHERE char *NewsServer; WHERE char *NntpUser; WHERE char *NntpPass; -WHERE char *NewsRc; #endif WHERE char *PagerFmt; WHERE char *PipeSep; diff --git a/init.h b/init.h index c20fd52..63fffbe 100644 --- a/init.h +++ b/init.h @@ -2169,22 +2169,6 @@ struct option_t MuttVars[] = { ** presents a security risk since the superuser of your machine may read it ** regardless of the file's permissions. */ - {"nntp_newsrc", DT_PATH, R_NONE, UL &NewsRc, "~/.cache/madmutt/newsrc"}, - /* - ** .pp - ** Availability: NNTP - ** - ** .pp - ** This file contains information about subscribed newsgroup and - ** articles read so far. - ** .pp - ** To ease the use of multiple news servers, the following \fTprintf(3)\fP-style - ** sequence is understood: - ** .pp - ** .ts - ** %s newsserver name - ** .te - */ {"nntp_context", DT_NUM, R_NONE, UL &NntpContext, "1000" }, /* ** .pp @@ -2247,22 +2231,6 @@ struct option_t MuttVars[] = { ** Controls whether or not Madmutt will try to reconnect to a newsserver when the ** was connection lost. */ - {"nntp_inews", DT_PATH, R_NONE, UL &Inews, ""}, - /* - ** .pp - ** Availability: NNTP - ** - ** .pp - ** If \fIset\fP, specifies the program and arguments used to deliver news posted - ** by Madmutt. Otherwise, Madmutt posts article using current connection. - ** The following \fTprintf(3)\fP-style sequence is understood: - ** .pp - ** .ts - ** %s newsserver name - ** .te - ** .pp - ** Example: \fTset inews="/usr/local/bin/inews -hS"\fP - */ {"nntp_group_index_format", DT_STR, R_BOTH, UL &GroupFormat, "%4C %M%N %5s %-45.45f %d"}, /* ** .pp diff --git a/nntp.c b/nntp.c index 78935ce..4d81012 100644 --- a/nntp.c +++ b/nntp.c @@ -123,7 +123,7 @@ static int slurp_newsrc (nntp_server_t * news) return -1; } - while (getline(&buf, &n, fp)) { + while (getline(&buf, &n, fp) >= 0) { nntp_parse_newsrc_line(news, buf); } p_delete(&buf); @@ -133,15 +133,15 @@ static int slurp_newsrc (nntp_server_t * news) return 0; } -static void nntp_cache_expand (char *dst, const char *src) -{ - snprintf (dst, _POSIX_PATH_MAX, "%s/%s", NewsCacheDir, src); - mutt_expand_path (dst, _POSIX_PATH_MAX); -} +#define nntp_cache_expand(dst, dlen, fmt, ...) \ + do { \ + snprintf((dst), (dlen), "%s/" fmt, NewsCacheDir, ##__VA_ARGS__); \ + mutt_expand_path((dst), (dlen)); \ + } while (0) /* Loads $news_cache_dir/.index into memory, loads newsserver data * and newsgroup cache names */ -static int nntp_parse_cacheindex (nntp_server_t * news) +static int nntp_parse_cacheindex(nntp_server_t *news) { struct stat st; char buf[HUGE_STRING], *cp; @@ -161,8 +161,7 @@ static int nntp_parse_cacheindex (nntp_server_t * news) mutt_expand_path (dir, sizeof (dir)); if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0) { - snprintf (buf, sizeof (buf), _("Directory %s not exist. Create it?"), - dir); + snprintf(buf, sizeof(buf), _("Directory %s not exist. Create it?"), dir); if (mutt_yesorno (buf, M_YES) != M_YES || mkdir (dir, (S_IRWXU + S_IRWXG + S_IRWXO))) { mutt_error _("Cache directory not created!"); @@ -175,7 +174,7 @@ static int nntp_parse_cacheindex (nntp_server_t * news) set_option (OPTNEWSCACHE); p_delete(&news->cache); - snprintf (buf, sizeof (buf), "%s/.index", dir); + snprintf(buf, sizeof (buf), "%s/%s.index", dir, news->conn->account.host); if (!(idx = safe_fopen (buf, "a+"))) return 0; rewind (idx); @@ -227,26 +226,6 @@ static int nntp_parse_cacheindex (nntp_server_t * news) return 0; } -const char *nntp_format_str(char *dest, ssize_t destlen, char op, - const char *src, const char *fmt, - const char *ifstr __attribute__((unused)), - const char *elstr __attribute__((unused)), - anytype data __attribute__((unused)), - format_flag flags __attribute__((unused))) -{ - char fn[STRING], tmp[STRING]; - - switch (op) { - case 's': - m_strcpy(fn, sizeof (fn), NewsServer); - m_strtolower(fn); - snprintf (tmp, sizeof (tmp), "%%%ss", fmt); - snprintf (dest, destlen, tmp, fn); - break; - } - return (src); -} - /* nntp_parse_url: given an NNPT URL, return host, port, * username, password and newsgroup will recognise. */ static int nntp_parse_url(const char *server, ACCOUNT * act, char *group, @@ -348,7 +327,7 @@ static int nntp_get_cache_all (nntp_server_t * serv) char buf[HUGE_STRING]; FILE *f; - nntp_cache_expand (buf, serv->cache); + nntp_cache_expand(buf, ssizeof(buf), "%s", serv->cache); if ((f = safe_fopen (buf, "r"))) { int i = 0; @@ -414,9 +393,7 @@ nntp_server_t *mutt_select_newsserver (char *server) if (!conn) return NULL; - m_strformat(file, sizeof(file), 0, NewsRc, nntp_format_str, NULL, 0); - mutt_expand_path(file, sizeof(file)); - + nntp_cache_expand(file, sizeof(file), "%s.newsrc", conn->account.host); serv = (nntp_server_t *) conn->data; if (serv) { struct stat sb; @@ -738,11 +715,11 @@ static FILE *mutt_mkname (char *s) int fd; FILE *fp; - nntp_cache_expand (buf, s); + nntp_cache_expand(buf, ssizeof(buf), "%s", s); if ((fp = safe_fopen (buf, "w"))) return fp; - nntp_cache_expand (buf, "cache-XXXXXX"); + nntp_cache_expand(buf, ssizeof(buf), "cache-XXXXXX"); pc = buf + m_strlen(buf) - 12; /* positioning to "cache-XXXXXX" */ if ((fd = mkstemp (buf)) == -1) return NULL; @@ -770,8 +747,8 @@ static int nntp_update_cacheindex (nntp_server_t * serv, nntp_data_t * data) snprintf (buf, sizeof (buf), "ALL %s 0 %d", file, (int) serv->newgroups_time); } - nntp_cache_expand (file, ".index"); - return mutt_update_list_file (file, serv->conn->account.host, key, buf); + nntp_cache_expand(file, ssizeof(file), "%s.index", serv->conn->account.host); + return mutt_update_list_file(file, serv->conn->account.host, key, buf); } static void nntp_delete_cache (nntp_data_t * data) @@ -781,13 +758,14 @@ static void nntp_delete_cache (nntp_data_t * data) if (!option (OPTNEWSCACHE) || !data || !data->cache || !data->nserv) return; - nntp_cache_expand (buf, data->cache); + nntp_cache_expand(buf, ssizeof(buf), "%s", data->cache); unlink (buf); p_delete(&data->cache); data->lastCached = 0; - nntp_cache_expand (buf, ".index"); - mutt_update_list_file (buf, data->nserv->conn->account.host, data->group, - NULL); + nntp_cache_expand(buf, ssizeof(buf), "%s.index", + data->nserv->conn->account.host); + mutt_update_list_file(buf, data->nserv->conn->account.host, data->group, + NULL); } /* Remove cache files of unsubscribed newsgroups */ @@ -819,15 +797,14 @@ static int nntp_save_cache_index (nntp_server_t * news) return 0; if (news->cache) { - nntp_cache_expand (file, news->cache); - unlink (file); - f = safe_fopen (file, "w"); - } - else { - m_strcpy(buf, sizeof(buf), news->conn->account.host); - f = mutt_mkname (buf); + nntp_cache_expand(file, ssizeof(file), "%s", news->cache); + unlink(file); + f = safe_fopen(file, "w"); + } else { + m_strcpy(buf, ssizeof(buf), news->conn->account.host); + f = mutt_mkname(buf); news->cache = m_strdup(buf); - nntp_cache_expand (file, buf); + nntp_cache_expand(file, ssizeof(file), "%s", buf); } if (!f) return -1; @@ -873,17 +850,18 @@ static int nntp_save_cache_group (CONTEXT * ctx) return -1; if (((nntp_data_t *) ctx->data)->cache) { - nntp_cache_expand (file, ((nntp_data_t *) ctx->data)->cache); + nntp_cache_expand(file, ssizeof(file), "%s", + ((nntp_data_t *)ctx->data)->cache); unlink (file); f = safe_fopen (file, "w"); } else { - snprintf (buf, sizeof (buf), "%s-%s", - ((nntp_data_t *) ctx->data)->nserv->conn->account.host, - ((nntp_data_t *) ctx->data)->group); + snprintf(buf, ssizeof(buf), "%s-%s", + ((nntp_data_t *)ctx->data)->nserv->conn->account.host, + ((nntp_data_t *)ctx->data)->group); f = mutt_mkname (buf); - ((nntp_data_t *) ctx->data)->cache = m_strdup(buf); - nntp_cache_expand (file, buf); + ((nntp_data_t *)ctx->data)->cache = m_strdup(buf); + nntp_cache_expand(file, ssizeof(file), "%s", buf); } if (!f) return -1; @@ -1719,7 +1697,7 @@ static int nntp_fetch_headers(CONTEXT * ctx, int first, int last) /* 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); + nntp_cache_expand(buf, ssizeof(buf), "%s", nntp_data->cache); mutt_message (msg2); if ((f = safe_fopen (buf, "r"))) { diff --git a/nntp.h b/nntp.h index 037d8a1..6d10aec 100644 --- a/nntp.h +++ b/nntp.h @@ -102,8 +102,6 @@ int nntp_get_active (nntp_server_t *); void nntp_buffy (char* dst, ssize_t dstlen); void nntp_expand_path (char *, ssize_t, ACCOUNT *); void nntp_logout_all(void); -const char *nntp_format_str(char *, ssize_t, char, const char *, const char *, - const char *, const char *, anytype, format_flag); void nntp_sync_sidebar (nntp_data_t*); WHERE nntp_server_t *CurrentNewsSrv INITVAL (NULL); diff --git a/sendlib.c b/sendlib.c index d55da0a..5ac02ab 100644 --- a/sendlib.c +++ b/sendlib.c @@ -1818,12 +1818,9 @@ int mutt_invoke_mta(address_t *from, address_t *to, address_t *cc, #ifdef USE_NNTP if (option (OPTNEWSSEND)) { - m_strformat(cmd, sizeof(cmd), 0, Inews, nntp_format_str, 0, 0); - if (m_strisempty(cmd)) { - i = nntp_post (msg); - unlink (msg); - return i; - } + i = nntp_post(msg); + unlink(msg); + return i; } else #endif {