X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=complete.c;h=b0c96cfa68e383ca1cf7e50603fd18b49f999043;hp=fcb9269ff8a233a949fb30b93104e4dbca785fa4;hb=53ceb3f257ec0af78a9129a8a565e8ca2bb03903;hpb=df70e07e24add1869bcc9b7af2277d9d0c09a281 diff --git a/complete.c b/complete.c index fcb9269..b0c96cf 100644 --- a/complete.c +++ b/complete.c @@ -1,19 +1,10 @@ /* + * Copyright notice from original mutt: * Copyright (C) 1996-2000 Michael R. Elkins - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * + * This file is part of mutt-ng, see http://www.muttng.org/. + * It's licensed under the GNU General Public License, + * please see the file GPL in the top level source directory. */ #if HAVE_CONFIG_H @@ -22,13 +13,15 @@ #include "mutt.h" #ifdef USE_IMAP -#include "mailbox.h" +#include "mx.h" #include "imap.h" #endif #ifdef USE_NNTP #include "nntp.h" #endif +#include "lib/str.h" + #include #include #include @@ -66,7 +59,7 @@ int mutt_complete (char *s, size_t slen) * special case to handle when there is no filepart yet. * find the first subscribed newsgroup */ - if ((len = mutt_strlen (filepart)) == 0) { + if ((len = safe_strlen (filepart)) == 0) { for (; l; l = l->next) { NNTP_DATA *data = (NNTP_DATA *) l->data; @@ -83,7 +76,7 @@ int mutt_complete (char *s, size_t slen) NNTP_DATA *data = (NNTP_DATA *) l->data; if (data && data->subscribed && - mutt_strncmp (data->group, filepart, len) == 0) { + safe_strncmp (data->group, filepart, len) == 0) { if (init) { for (i = 0; filepart[i] && data->group[i]; i++) { if (filepart[i] != data->group[i]) { @@ -119,7 +112,7 @@ int mutt_complete (char *s, size_t slen) else strfcpy (imap_path, s, sizeof (imap_path)); - if (mx_is_imap (imap_path)) + if (mx_get_magic (imap_path) == M_IMAP) return imap_complete (s, slen, imap_path); #endif @@ -184,10 +177,10 @@ int mutt_complete (char *s, size_t slen) * special case to handle when there is no filepart yet. find the first * file/directory which is not ``.'' or ``..'' */ - if ((len = mutt_strlen (filepart)) == 0) { + if ((len = safe_strlen (filepart)) == 0) { while ((de = readdir (dirp)) != NULL) { - if (mutt_strcmp (".", de->d_name) != 0 - && mutt_strcmp ("..", de->d_name) != 0) { + if (safe_strcmp (".", de->d_name) != 0 + && safe_strcmp ("..", de->d_name) != 0) { strfcpy (filepart, de->d_name, sizeof (filepart)); init++; break; @@ -196,7 +189,7 @@ int mutt_complete (char *s, size_t slen) } while ((de = readdir (dirp)) != NULL) { - if (mutt_strncmp (de->d_name, filepart, len) == 0) { + if (safe_strncmp (de->d_name, filepart, len) == 0) { if (init) { for (i = 0; filepart[i] && de->d_name[i]; i++) { if (filepart[i] != de->d_name[i]) { @@ -215,14 +208,14 @@ int mutt_complete (char *s, size_t slen) /* check to see if it is a directory */ if (dirpart[0]) { strfcpy (buf, exp_dirpart, sizeof (buf)); - strfcpy (buf + strlen (buf), "/", sizeof (buf) - strlen (buf)); + strfcpy (buf + safe_strlen (buf), "/", sizeof (buf) - safe_strlen (buf)); } else buf[0] = 0; - strfcpy (buf + strlen (buf), filepart, sizeof (buf) - strlen (buf)); + strfcpy (buf + safe_strlen (buf), filepart, sizeof (buf) - safe_strlen (buf)); if (stat (buf, &st) != -1 && (st.st_mode & S_IFDIR)) - strfcpy (filepart + strlen (filepart), "/", - sizeof (filepart) - strlen (filepart)); + strfcpy (filepart + safe_strlen (filepart), "/", + sizeof (filepart) - safe_strlen (filepart)); init = 1; } } @@ -231,10 +224,10 @@ int mutt_complete (char *s, size_t slen) if (dirpart[0]) { strfcpy (s, dirpart, slen); - if (mutt_strcmp ("/", dirpart) != 0 && dirpart[0] != '=' + if (safe_strcmp ("/", dirpart) != 0 && dirpart[0] != '=' && dirpart[0] != '+') - strfcpy (s + strlen (s), "/", slen - strlen (s)); - strfcpy (s + strlen (s), filepart, slen - strlen (s)); + strfcpy (s + safe_strlen (s), "/", slen - safe_strlen (s)); + strfcpy (s + safe_strlen (s), filepart, slen - safe_strlen (s)); } else strfcpy (s, filepart, slen);