#include <lib-lib/mem.h>
#include <lib-lib/str.h>
#include <lib-lib/macros.h>
+#include <lib-lib/file.h>
+#include <lib-lib/mapping.h>
#include "mutt.h"
#include "enter.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "buffy.h"
-#include "mapping.h"
#include "sort.h"
#include "browser.h"
#include "attach.h"
struct folder_file *pa = (struct folder_file *) a;
struct folder_file *pb = (struct folder_file *) b;
- int r = str_coll (pa->name, pb->name);
+ int r = strcoll(NONULL(pa->name), NONULL(pb->name));
return ((BrowserSort & SORT_REVERSE) ? -r : r);
}
struct stat st;
char fullpath[_POSIX_PATH_MAX];
- mutt_concat_path (fullpath, folder, path, sizeof (fullpath));
+ mutt_concat_path(fullpath, sizeof(fullpath), folder, path);
if (stat (fullpath, &st) == 0)
return (S_ISDIR (st.st_mode));
break;
case 'f':
- strncpy (fn, folder->ff->name, sizeof (fn) - 1);
+ m_strcpy(fn, sizeof(fn), folder->ff->name);
snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
snprintf (dest, destlen, tmp, fn);
break;
init_state (state, menu);
while ((de = readdir (dp)) != NULL) {
- if (str_cmp (de->d_name, ".") == 0)
+ if (m_strcmp(de->d_name, ".") == 0)
continue; /* we don't need . */
if (prefix && *prefix
- && str_ncmp (prefix, de->d_name, m_strlen(prefix)) != 0)
+ && m_strncmp(prefix, de->d_name, m_strlen(prefix)) != 0)
continue;
if (!((regexec (Mask.rx, de->d_name, 0, NULL, 0) == 0) ^ Mask.not))
continue;
- mutt_concat_path (buffer, d, de->d_name, sizeof (buffer));
+ mutt_concat_path(buffer, sizeof(buffer), d, de->d_name);
if (lstat (buffer, &s) == -1)
continue;
(!S_ISLNK (s.st_mode)))
continue;
- strfcpy (buffer, NONULL (tmp->path), sizeof (buffer));
+ m_strcpy(buffer, sizeof(buffer), NONULL(tmp->path));
mutt_pretty_mailbox (buffer);
add_folder (menu, state, buffer, &s, NULL, tmp->new);
else
#endif
if (buffy)
- snprintf (title, titlelen, _("Mailboxes [%d]"), buffy_check (0));
+ snprintf(title, titlelen, _("Mailboxes [%d]"), buffy_check(0));
else {
- strfcpy (path, LastDir, sizeof (path));
+ m_strcpy(path, sizeof(path), LastDir);
mutt_pretty_mailbox (path);
#ifdef USE_IMAP
if (state->imap_browse && option (OPTIMAPLSUB))
buffy = buffy && folder;
- memset (&state, 0, sizeof (struct browser_state));
+ p_clear(&state, 1);
if (!folder)
- strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup));
+ m_strcpy(LastDirBackup, sizeof(LastDirBackup), LastDir);
#ifdef USE_NNTP
if (option (OPTNEWS)) {
if (*f)
- strfcpy (prefix, f, sizeof (prefix));
+ m_strcpy(prefix, sizeof(prefix), f);
else {
LIST *list;
init_state (&state, NULL);
state.imap_browse = 1;
if (!imap_browse (f, &state))
- strfcpy (LastDir, state.folder, sizeof (LastDir));
+ m_strcpy(LastDir, sizeof(LastDir), state.folder);
}
else {
#endif
for (i = m_strlen(f) - 1; i > 0 && f[i] != '/'; i--);
if (i > 0) {
if (f[0] == '/') {
- if (i > sizeof (LastDir) - 1)
- i = sizeof (LastDir) - 1;
- strncpy (LastDir, f, i);
- LastDir[i] = 0;
+ i = MIN(sizeof(LastDir) - 1, i);
+ m_strcpy(LastDir, sizeof(LastDir), f);
}
else {
- getcwd (LastDir, sizeof (LastDir));
- str_cat (LastDir, sizeof (LastDir), "/");
- str_ncat (LastDir, sizeof (LastDir), f, i);
+ getcwd(LastDir, sizeof(LastDir));
+ m_strcat(LastDir, sizeof(LastDir), "/");
+ m_strncat(LastDir, sizeof(LastDir), f, i);
}
}
else {
}
if (i <= 0 && f[0] != '/')
- strfcpy (prefix, f, sizeof (prefix));
+ m_strcpy(prefix, sizeof(prefix), f);
else
- strfcpy (prefix, f + i + 1, sizeof (prefix));
+ m_strcpy(prefix, sizeof(prefix), f + i + 1);
killPrefix = 1;
#ifdef USE_IMAP
}
if (!folder)
getcwd (LastDir, sizeof (LastDir));
else if (!LastDir[0])
- strfcpy (LastDir, NONULL (Maildir), sizeof (LastDir));
+ m_strcpy(LastDir, sizeof(LastDir), NONULL(Maildir));
#ifdef USE_IMAP
if (!buffy && imap_is_magic (LastDir, NULL) == M_IMAP) {
init_menu (&state, menu, title, sizeof (title), buffy);
- FOREVER {
+ for (;;) {
switch (i = mutt_menuLoop (menu)) {
case OP_GENERIC_SELECT_ENTRY:
) {
/* make sure this isn't a MH or maildir mailbox */
if (buffy) {
- strfcpy (buf, state.entry[menu->current].name, sizeof (buf));
+ m_strcpy(buf, sizeof(buf), state.entry[menu->current].name);
mutt_expand_path (buf, sizeof (buf));
}
#ifdef USE_IMAP
else if (state.imap_browse) {
- strfcpy (buf, state.entry[menu->current].name, sizeof (buf));
+ m_strcpy(buf, sizeof(buf), state.entry[menu->current].name);
}
#endif
else
- mutt_concat_path (buf, LastDir, state.entry[menu->current].name,
- sizeof (buf));
+ mutt_concat_path(buf, sizeof(buf), LastDir,
+ state.entry[menu->current].name);
if ((mx_get_magic (buf) <= 0)
#ifdef USE_IMAP
char OldLastDir[_POSIX_PATH_MAX];
/* save the old directory */
- strfcpy (OldLastDir, LastDir, sizeof (OldLastDir));
+ m_strcpy(OldLastDir, sizeof(OldLastDir), LastDir);
- if (str_cmp (state.entry[menu->current].name, "..") == 0) {
- if (str_cmp ("..", LastDir + m_strlen(LastDir) - 2) == 0)
+ if (m_strcmp(state.entry[menu->current].name, "..") == 0) {
+ if (m_strcmp("..", LastDir + m_strlen(LastDir) - 2) == 0)
strcat (LastDir, "/.."); /* __STRCAT_CHECKED__ */
else {
char *p = strrchr (LastDir + 1, '/');
}
}
else if (buffy) {
- strfcpy (LastDir, state.entry[menu->current].name,
- sizeof (LastDir));
+ m_strcpy(LastDir, sizeof(LastDir),
+ state.entry[menu->current].name);
mutt_expand_path (LastDir, sizeof (LastDir));
}
#ifdef USE_IMAP
int n;
ciss_url_t url;
- strfcpy (LastDir, state.entry[menu->current].name,
- sizeof (LastDir));
+ m_strcpy(LastDir, sizeof(LastDir),
+ state.entry[menu->current].name);
/* tack on delimiter here */
n = m_strlen(LastDir) + 1;
else {
char tmp[_POSIX_PATH_MAX];
- mutt_concat_path (tmp, LastDir, state.entry[menu->current].name,
- sizeof (tmp));
- strfcpy (LastDir, tmp, sizeof (LastDir));
+ mutt_concat_path(tmp, sizeof(tmp), LastDir,
+ state.entry[menu->current].name);
+ m_strcpy(LastDir, sizeof(LastDir), tmp);
}
destroy_state (&state);
#endif
if (examine_directory (menu, &state, LastDir, prefix) == -1) {
/* try to restore the old values */
- strfcpy (LastDir, OldLastDir, sizeof (LastDir));
+ m_strcpy(LastDir, sizeof(LastDir), OldLastDir);
if (examine_directory (menu, &state, LastDir, prefix) == -1) {
- strfcpy (LastDir, NONULL (Homedir), sizeof (LastDir));
+ m_strcpy(LastDir, sizeof(LastDir), NONULL(Homedir));
goto bail;
}
}
if (buffy)
#endif
{
- strfcpy (f, state.entry[menu->current].name, flen);
+ m_strcpy(f, flen, state.entry[menu->current].name);
mutt_expand_path (f, flen);
}
#ifdef USE_IMAP
else if (state.imap_browse)
- strfcpy (f, state.entry[menu->current].name, flen);
+ m_strcpy(f, flen, state.entry[menu->current].name);
#endif
else
- mutt_concat_path (f, LastDir, state.entry[menu->current].name, flen);
+ mutt_concat_path(f, flen, LastDir, state.entry[menu->current].name);
/* Fall through to OP_EXIT */
char full[_POSIX_PATH_MAX];
if (ff.tagged) {
- mutt_concat_path (full, LastDir, ff.name, sizeof (full));
+ mutt_concat_path(full, sizeof(full), LastDir, ff.name);
mutt_expand_path (full, sizeof (full));
tfiles[j++] = m_strdup(full);
}
break;
#endif
- strfcpy (buf, LastDir, sizeof (buf));
+ m_strcpy(buf, sizeof(buf), LastDir);
#ifdef USE_IMAP
if (!state.imap_browse)
#endif
mutt_expand_path (buf, sizeof (buf));
#ifdef USE_IMAP
if (imap_is_magic (buf, NULL) == M_IMAP) {
- strfcpy (LastDir, buf, sizeof (LastDir));
+ m_strcpy(LastDir, sizeof(LastDir), buf);
destroy_state (&state);
init_state (&state, NULL);
state.imap_browse = 1;
if (S_ISDIR (st.st_mode)) {
destroy_state (&state);
if (examine_directory (menu, &state, buf, prefix) == 0)
- strfcpy (LastDir, buf, sizeof (LastDir));
+ m_strcpy(LastDir, sizeof(LastDir), buf);
else {
mutt_error _("Error scanning directory.");
case OP_ENTER_MASK:
- strfcpy (buf, NONULL (Mask.pattern), sizeof (buf));
+ m_strcpy(buf, sizeof(buf), NONULL(Mask.pattern));
if (mutt_get_field (_("File Mask: "), buf, sizeof (buf), 0) == 0) {
regex_t *rx = p_new(regex_t, 1);
char *s = buf;
buffy = 0;
/* assume that the user wants to see everything */
if (!buf[0])
- strfcpy (buf, ".", sizeof (buf));
- SKIPWS (s);
+ m_strcpy(buf, sizeof(buf), ".");
+ s = vskipspaces(s);
if (*s == '!') {
- s++;
- SKIPWS (s);
+ s = vskipspaces(s + 1);
not = 1;
}
mutt_error ("%s", buf);
}
else {
- str_replace (&Mask.pattern, buf);
+ m_strreplace(&Mask.pattern, buf);
regfree (Mask.rx);
p_delete(&Mask.rx);
Mask.rx = rx;
snprintf (buf, sizeof (buf), "%s/", LastDir);
if (mutt_get_field (_("New file name: "), buf, sizeof (buf), M_FILE) ==
0) {
- strfcpy (f, buf, flen);
+ m_strcpy(f, flen, buf);
destroy_state (&state);
mutt_menuDestroy (&menu);
goto bail;
#ifdef USE_IMAP
if (state.entry[menu->current].selectable) {
- strfcpy (f, state.entry[menu->current].name, flen);
+ m_strcpy(f, flen, state.entry[menu->current].name);
destroy_state (&state);
mutt_menuDestroy (&menu);
goto bail;
BODY *b;
char buf[_POSIX_PATH_MAX];
- mutt_concat_path (buf, LastDir, state.entry[menu->current].name,
- sizeof (buf));
+ mutt_concat_path(buf, sizeof(buf), LastDir,
+ state.entry[menu->current].name);
b = mutt_make_file_attach (buf);
if (b != NULL) {
mutt_view_attachment (NULL, b, M_REGULAR, NULL, NULL, 0);
bail:
if (!folder)
- strfcpy (LastDir, LastDirBackup, sizeof (LastDir));
+ m_strcpy(LastDir, sizeof(LastDir), LastDirBackup);
}