From: Richard Russon Date: Sat, 25 Aug 2018 16:44:05 +0000 (+0100) Subject: probe nntp X-Git-Tag: 2019-10-25~682^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=846e429fd899d942304b77878f0cddffe32b7fa4;p=neomutt probe nntp --- diff --git a/browser.c b/browser.c index 9d02397ee..c0bf670eb 100644 --- a/browser.c +++ b/browser.c @@ -994,7 +994,7 @@ static int examine_mailboxes(struct Menu *menu, struct BrowserState *state) } #endif #ifdef USE_NNTP - if (mx_is_nntp(np->b->path)) + if (nntp_path_probe(np->b->path, NULL) == MUTT_NNTP) { add_folder(menu, state, np->b->path, NULL, NULL, np->b, NULL); continue; diff --git a/compose.c b/compose.c index 42b4cc4aa..5563e7e83 100644 --- a/compose.c +++ b/compose.c @@ -1434,7 +1434,7 @@ int mutt_compose_menu(struct Header *msg, char *fcc, size_t fcclen, if (!mx_is_pop(fname)) #endif #ifdef USE_NNTP - if (!mx_is_nntp(fname) && !OptNews) + if (!OptNews && (nntp_path_probe(fname, NULL) != MUTT_NNTP)) #endif /* check to make sure the file exists and is readable */ if (access(fname, R_OK) == -1) diff --git a/mailbox.c b/mailbox.c index 569ad2623..2d35ca093 100644 --- a/mailbox.c +++ b/mailbox.c @@ -52,6 +52,9 @@ #ifdef USE_NOTMUCH #include "notmuch/mutt_notmuch.h" #endif +#ifdef USE_NNTP +#include "nntp/nntp.h" +#endif /* These Config Variables are only used in mailbox.c */ short MailCheck; ///< Config: Number of seconds before NeoMutt checks for new mail @@ -399,7 +402,7 @@ static void mailbox_check(struct Mailbox *tmp, struct stat *contex_sb, bool chec else #endif #ifdef USE_NNTP - if ((tmp->magic == MUTT_NNTP) || mx_is_nntp(tmp->path)) + if ((tmp->magic == MUTT_NNTP) || (nntp_path_probe(tmp->path, NULL) == MUTT_NNTP)) tmp->magic = MUTT_NNTP; #endif #ifdef USE_NOTMUCH diff --git a/main.c b/main.c index f898e69b8..d2accd4af 100644 --- a/main.c +++ b/main.c @@ -797,7 +797,7 @@ int main(int argc, char *argv[], char *envp[]) skip |= mx_is_imap(fpath); #endif #ifdef USE_NNTP - skip |= mx_is_nntp(fpath); + skip |= (nntp_path_probe(fpath, NULL) == MUTT_NNTP); #endif if (!skip && (stat(fpath, &sb) == -1) && (errno == ENOENT)) { diff --git a/mx.c b/mx.c index 5657ee5a5..745c1859c 100644 --- a/mx.c +++ b/mx.c @@ -192,27 +192,6 @@ bool mx_is_pop(const char *p) } #endif -#ifdef USE_NNTP -/** - * mx_is_nntp - Is this an NNTP mailbox - * @param p Mailbox string to test - * @retval true It is an NNTP mailbox - */ -bool mx_is_nntp(const char *p) -{ - enum UrlScheme scheme; - - if (!p) - return false; - - scheme = url_check_scheme(p); - if (scheme == U_NNTP || scheme == U_NNTPS) - return true; - - return false; -} -#endif - /** * mx_access - Wrapper for access, checks permissions on a given mailbox * @param path Path of mailbox diff --git a/mx.h b/mx.h index 1c9265aa1..d81d09990 100644 --- a/mx.h +++ b/mx.h @@ -255,9 +255,6 @@ void mx_update_tables(struct Context *ctx, bool committing); #ifdef USE_IMAP bool mx_is_imap(const char *p); #endif -#ifdef USE_NNTP -bool mx_is_nntp(const char *p); -#endif #ifdef USE_POP bool mx_is_pop(const char *p); #endif diff --git a/nntp/nntp.c b/nntp/nntp.c index c3c9283c3..389a3dede 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -2633,9 +2633,11 @@ int nntp_path_probe(const char *path, const struct stat *st) if (!path) return MUTT_UNKNOWN; - enum UrlScheme scheme = url_check_scheme(path); - if ((scheme == U_NNTP) || (scheme == U_NNTPS)) - return MUTT_NNTP; + if (mutt_str_strncasecmp(path, "news://", 7) == 0) + return MUTT_NOTMUCH; + + if (mutt_str_strncasecmp(path, "snews://", 8) == 0) + return MUTT_NOTMUCH; return MUTT_UNKNOWN; }