X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=complete.c;h=b9d10883173451818ab3f6239c794102f2f2a412;hp=679a839bcc6a6a714c5ef9bc8a49c3d9adf6cbc5;hb=48a027c4e8a676bc53de48f88b09d34347c23f28;hpb=c98480f8568e6c1bc927c6c5f2b5e80b4aa6548c diff --git a/complete.c b/complete.c index 679a839..b9d1088 100644 --- a/complete.c +++ b/complete.c @@ -11,25 +11,23 @@ # include "config.h" #endif -#include "mutt.h" -#ifdef USE_IMAP -#include "mx.h" -#include "imap.h" -#endif -#ifdef USE_NNTP -#include "nntp.h" -#endif - -#include -#include -#include "lib/debug.h" - #include #include #include #include #include +#include +#include +#include + +#include "mutt.h" +#include "mx.h" +#include +#ifdef USE_NNTP +#include "nntp.h" +#endif + /* given a partial pathname, this routine fills in as much of the rest of the * path as is unique. * @@ -45,9 +43,7 @@ int mutt_complete (char *s, size_t slen) char dirpart[_POSIX_PATH_MAX], exp_dirpart[_POSIX_PATH_MAX]; char filepart[_POSIX_PATH_MAX]; -#ifdef USE_IMAP char imap_path[LONG_STRING]; -#endif debug_print (2, ("completing %s\n", s)); @@ -55,7 +51,7 @@ int mutt_complete (char *s, size_t slen) if (option (OPTNEWS)) { LIST *l = CurrentNewsSrv->list; - strfcpy (filepart, s, sizeof (filepart)); + m_strcpy(filepart, sizeof(filepart), s); /* * special case to handle when there is no filepart yet. @@ -66,7 +62,7 @@ int mutt_complete (char *s, size_t slen) NNTP_DATA *data = (NNTP_DATA *) l->data; if (data && data->subscribed) { - strfcpy (filepart, data->group, sizeof (filepart)); + m_strcpy(filepart, sizeof(filepart), data->group); init++; l = l->next; break; @@ -89,7 +85,7 @@ int mutt_complete (char *s, size_t slen) filepart[i] = 0; } else { - strfcpy (filepart, data->group, sizeof (filepart)); + m_strcpy(filepart, sizeof(filepart), data->group); init = 1; } } @@ -101,47 +97,45 @@ int mutt_complete (char *s, size_t slen) } #endif -#ifdef USE_IMAP /* we can use '/' as a delimiter, imap_complete rewrites it */ if (*s == '=' || *s == '+' || *s == '!') { const char *q = NONULL(*s == '!' ? Spoolfile : Maildir); mutt_concat_path(imap_path, sizeof(imap_path), q, s + 1); } else - strfcpy (imap_path, s, sizeof (imap_path)); + m_strcpy(imap_path, sizeof(imap_path), s); if (mx_get_magic (imap_path) == M_IMAP) return imap_complete (s, slen, imap_path); -#endif if (*s == '=' || *s == '+' || *s == '!') { dirpart[0] = *s; dirpart[1] = 0; if (*s == '!') - strfcpy (exp_dirpart, NONULL (Spoolfile), sizeof (exp_dirpart)); + m_strcpy(exp_dirpart, sizeof(exp_dirpart), NONULL(Spoolfile)); else - strfcpy (exp_dirpart, NONULL (Maildir), sizeof (exp_dirpart)); + m_strcpy(exp_dirpart, sizeof(exp_dirpart), NONULL(Maildir)); if ((p = strrchr (s, '/'))) { char buf[_POSIX_PATH_MAX]; *p++ = 0; mutt_concat_path(buf, sizeof(buf), exp_dirpart, s + 1); - strfcpy (exp_dirpart, buf, sizeof (exp_dirpart)); + m_strcpy(exp_dirpart, sizeof(exp_dirpart), buf); snprintf (buf, sizeof (buf), "%s%s/", dirpart, s + 1); - strfcpy (dirpart, buf, sizeof (dirpart)); - strfcpy (filepart, p, sizeof (filepart)); + m_strcpy(dirpart, sizeof(dirpart), buf); + m_strcpy(filepart, sizeof(filepart), p); } else - strfcpy (filepart, s + 1, sizeof (filepart)); + m_strcpy(filepart, sizeof(filepart), s + 1); dirp = opendir (exp_dirpart); } else { if ((p = strrchr (s, '/'))) { if (p == s) { /* absolute path */ p = s + 1; - strfcpy (dirpart, "/", sizeof (dirpart)); + m_strcpy(dirpart, sizeof(dirpart), "/"); exp_dirpart[0] = 0; - strfcpy (filepart, p, sizeof (filepart)); + m_strcpy(filepart, sizeof(filepart), p); dirp = opendir (dirpart); } else { @@ -150,8 +144,8 @@ int mutt_complete (char *s, size_t slen) memcpy(dirpart, s, len); dirpart[len] = 0; p++; - strfcpy (filepart, p, sizeof (filepart)); - strfcpy (exp_dirpart, dirpart, sizeof (exp_dirpart)); + m_strcpy(filepart, sizeof(filepart), p); + m_strcpy(exp_dirpart, sizeof(exp_dirpart), dirpart); mutt_expand_path (exp_dirpart, sizeof (exp_dirpart)); dirp = opendir (exp_dirpart); } @@ -159,7 +153,7 @@ int mutt_complete (char *s, size_t slen) else { /* no directory name, so assume current directory. */ dirpart[0] = 0; - strfcpy (filepart, s, sizeof (filepart)); + m_strcpy(filepart, sizeof(filepart), s); dirp = opendir ("."); } } @@ -177,7 +171,7 @@ int mutt_complete (char *s, size_t slen) while ((de = readdir (dirp)) != NULL) { if (m_strcmp(".", de->d_name) != 0 && m_strcmp("..", de->d_name) != 0) { - strfcpy (filepart, de->d_name, sizeof (filepart)); + m_strcpy(filepart, sizeof(filepart), de->d_name); init++; break; } @@ -199,19 +193,19 @@ int mutt_complete (char *s, size_t slen) char buf[_POSIX_PATH_MAX]; struct stat st; - strfcpy (filepart, de->d_name, sizeof (filepart)); + m_strcpy(filepart, sizeof(filepart), de->d_name); /* check to see if it is a directory */ if (dirpart[0]) { - strfcpy (buf, exp_dirpart, sizeof (buf)); - strfcpy (buf + m_strlen(buf), "/", sizeof (buf) - m_strlen(buf)); + m_strcpy(buf, sizeof(buf), exp_dirpart); + m_strcpy(buf + m_strlen(buf), sizeof(buf) - m_strlen(buf), "/"); } else buf[0] = 0; - strfcpy (buf + m_strlen(buf), filepart, sizeof (buf) - m_strlen(buf)); + m_strcpy(buf + m_strlen(buf), sizeof(buf) - m_strlen(buf), filepart); if (stat (buf, &st) != -1 && (st.st_mode & S_IFDIR)) - strfcpy (filepart + m_strlen(filepart), "/", - sizeof (filepart) - m_strlen(filepart)); + m_strcpy(filepart + m_strlen(filepart), + sizeof(filepart) - m_strlen(filepart), "/"); init = 1; } } @@ -219,14 +213,14 @@ int mutt_complete (char *s, size_t slen) closedir (dirp); if (dirpart[0]) { - strfcpy (s, dirpart, slen); + m_strcpy(s, slen, dirpart); if (m_strcmp("/", dirpart) != 0 && dirpart[0] != '=' && dirpart[0] != '+') - strfcpy (s + m_strlen(s), "/", slen - m_strlen(s)); - strfcpy (s + m_strlen(s), filepart, slen - m_strlen(s)); + m_strcpy(s + m_strlen(s), slen - m_strlen(s), "/"); + m_strcpy(s + m_strlen(s), slen - m_strlen(s), filepart); } else - strfcpy (s, filepart, slen); + m_strcpy(s, slen, filepart); return (init ? 0 : -1); }