]> granicus.if.org Git - neomutt/commitdiff
probe nntp
authorRichard Russon <rich@flatcap.org>
Sat, 25 Aug 2018 16:44:05 +0000 (17:44 +0100)
committerRichard Russon <rich@flatcap.org>
Sun, 26 Aug 2018 21:11:03 +0000 (22:11 +0100)
browser.c
compose.c
mailbox.c
main.c
mx.c
mx.h
nntp/nntp.c

index 9d02397ee6409e2aea56854d3bde1ad659b173b2..c0bf670eb37d61355b9b21b8a9653eea796228f9 100644 (file)
--- 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;
index 42b4cc4aaf1e121ec6da8b26884dbcb3d5515165..5563e7e832e710f63f4b44e804a202b5cea80623 100644 (file)
--- 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)
index 569ad2623c57b3e9d8bbc4803e96ea5dd9c1acf6..2d35ca0939a879eb03284033c228888ae3ea0a18 100644 (file)
--- 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 f898e69b8a1612c90eb06ef672b7aa4b00a48c0e..d2accd4afe9ac0b5c961938d1101615154425206 100644 (file)
--- 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 5657ee5a5b0cdefd56995a2901fc8f148fa8e596..745c1859c8233b743e7dac3edffaca03f40522b1 100644 (file)
--- 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 1c9265aa13c6d46403e8192063a8a5d759cf8152..d81d0999056b42465e2329f73496841bb797c048 100644 (file)
--- 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
index c3c9283c3c36a646aae1c8eb0a5d87eab9e170eb..389a3dede95c9fe03af8ea52eed18e30d0fd7661 100644 (file)
@@ -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;
 }