-/* try to figure out what type of mailbox ``path'' is
- *
- * return values:
- * M_* mailbox type
- * 0 not a mailbox
- * -1 error
- */
-
-#ifdef USE_IMAP
-
-int mx_is_imap (const char *p)
-{
- url_scheme_t scheme;
-
- if (!p)
- return 0;
-
- if (*p == '{')
- return 1;
-
- scheme = url_check_scheme (p);
- if (scheme == U_IMAP || scheme == U_IMAPS)
- return 1;
-
- return 0;
-}
-
-#endif
-
-#ifdef USE_POP
-int mx_is_pop (const char *p)
-{
- url_scheme_t scheme;
-
- if (!p)
- return 0;
-
- scheme = url_check_scheme (p);
- if (scheme == U_POP || scheme == U_POPS)
- return 1;
-
- return 0;
-}
-#endif
-
-#ifdef USE_NNTP
-int mx_is_nntp (const char *p)
-{
- url_scheme_t scheme;
-
- if (!p)
- return 0;
-
- scheme = url_check_scheme (p);
- if (scheme == U_NNTP || scheme == U_NNTPS)
- return 1;
-
- return 0;
-}
-#endif
-
-int mx_get_magic (const char *path)
-{
- struct stat st;
- int magic = 0;
- char tmp[_POSIX_PATH_MAX];
- FILE *f;
-
-#ifdef USE_IMAP
- if (mx_is_imap (path))
- return M_IMAP;
-#endif /* USE_IMAP */
-
-#ifdef USE_POP
- if (mx_is_pop (path))
- return M_POP;
-#endif /* USE_POP */
-
-#ifdef USE_NNTP
- if (mx_is_nntp (path))
- return M_NNTP;
-#endif /* USE_NNTP */
-
- if (stat (path, &st) == -1) {
- dprint (1,
- (debugfile, "mx_get_magic(): unable to stat %s: %s (errno %d).\n",
- path, strerror (errno), errno));
- return (-1);
- }
-
- if (S_ISDIR (st.st_mode)) {
- /* check for maildir-style mailbox */
-
- snprintf (tmp, sizeof (tmp), "%s/cur", path);
- if (stat (tmp, &st) == 0 && S_ISDIR (st.st_mode))
- return (M_MAILDIR);
-
- /* check for mh-style mailbox */
-
- snprintf (tmp, sizeof (tmp), "%s/.mh_sequences", path);
- if (access (tmp, F_OK) == 0)
- return (M_MH);
-
- snprintf (tmp, sizeof (tmp), "%s/.xmhcache", path);
- if (access (tmp, F_OK) == 0)
- return (M_MH);
-
- snprintf (tmp, sizeof (tmp), "%s/.mew_cache", path);
- if (access (tmp, F_OK) == 0)
- return (M_MH);
-
- snprintf (tmp, sizeof (tmp), "%s/.mew-cache", path);
- if (access (tmp, F_OK) == 0)
- return (M_MH);
-
- snprintf (tmp, sizeof (tmp), "%s/.sylpheed_cache", path);
- if (access (tmp, F_OK) == 0)
- return (M_MH);
-
- /*
- * ok, this isn't an mh folder, but mh mode can be used to read
- * Usenet news from the spool. ;-)
- */
-
- snprintf (tmp, sizeof (tmp), "%s/.overview", path);
- if (access (tmp, F_OK) == 0)
- return (M_MH);
-
- }
- else if (st.st_size == 0) {
- /* hard to tell what zero-length files are, so assume the default magic */
- if (DefaultMagic == M_MBOX || DefaultMagic == M_MMDF)
- return (DefaultMagic);
- else
- return (M_MBOX);
- }
- else if ((f = fopen (path, "r")) != NULL) {
-#ifndef BUFFY_SIZE
- struct utimbuf times;
-#endif