continue;
tmp = Incoming;
- while (tmp && mutt_strcmp (mutt_b2s (buffer), tmp->path))
+ while (tmp && mutt_strcmp (mutt_b2s (buffer), mutt_b2s (tmp->pathbuf)))
tmp = tmp->next;
if (tmp && Context &&
!mutt_strcmp (tmp->realpath, Context->realpath))
tmp->msg_unread = Context->unread;
}
- strfcpy (buffer, NONULL (tmp->path), sizeof (buffer));
+ strfcpy (buffer, mutt_b2s (tmp->pathbuf), sizeof (buffer));
if (option (OPTBROWSERABBRMAILBOXES))
mutt_pretty_mailbox (buffer, sizeof (buffer));
#ifdef USE_IMAP
- if (mx_is_imap (tmp->path))
+ if (mx_is_imap (mutt_b2s (tmp->pathbuf)))
{
add_folder (menu, state, buffer, NULL, tmp);
continue;
}
#endif
#ifdef USE_POP
- if (mx_is_pop (tmp->path))
+ if (mx_is_pop (mutt_b2s (tmp->pathbuf)))
{
add_folder (menu, state, buffer, NULL, tmp);
continue;
}
#endif
- if (lstat (tmp->path, &s) == -1)
+ if (lstat (mutt_b2s (tmp->pathbuf), &s) == -1)
continue;
if ((! S_ISREG (s.st_mode)) && (! S_ISDIR (s.st_mode)) &&
(! S_ISLNK (s.st_mode)))
continue;
- if (mx_is_maildir (tmp->path))
+ if (mx_is_maildir (mutt_b2s (tmp->pathbuf)))
{
struct stat st2;
- mutt_buffer_printf (md, "%s/new", tmp->path);
+ mutt_buffer_printf (md, "%s/new", mutt_b2s (tmp->pathbuf));
if (stat (mutt_b2s (md), &s) < 0)
s.st_mtime = 0;
- mutt_buffer_printf (md, "%s/cur", tmp->path);
+ mutt_buffer_printf (md, "%s/cur", mutt_b2s (tmp->pathbuf));
if (stat (mutt_b2s (md), &st2) < 0)
st2.st_mtime = 0;
if (st2.st_mtime > s.st_mtime)
for (tmp = Incoming; tmp; tmp = tmp->next)
{
- if (stat (tmp->path,&tmp_sb) ==0 &&
+ if (stat (mutt_b2s (tmp->pathbuf), &tmp_sb) ==0 &&
sb.st_dev == tmp_sb.st_dev && sb.st_ino == tmp_sb.st_ino)
break;
}
if (!b)
return;
- if (stat (b->path, &sb) == 0)
+ if (stat (mutt_b2s (b->pathbuf), &sb) == 0)
b->size = (off_t) sb.st_size;
else
b->size = 0;
char *r = NULL;
buffy = (BUFFY *) safe_calloc (1, sizeof (BUFFY));
- strfcpy (buffy->path, path, sizeof (buffy->path));
+ buffy->pathbuf = mutt_buffer_new ();
+ mutt_buffer_strcpy (buffy->pathbuf, path);
r = realpath (path, rp);
buffy->realpath = safe_strdup (r ? rp : path);
buffy->next = NULL;
if (!(mailbox && *mailbox))
return;
+ mutt_buffer_free (&((*mailbox)->pathbuf));
FREE (&((*mailbox)->realpath));
FREE (mailbox); /* __FREE_CHECKED__ */
}
{
if (mutt_strcmp (p ? p : buf, (*tmp)->realpath) == 0)
{
- dprint(3,(debugfile,"mailbox '%s' already registered as '%s'\n", buf, (*tmp)->path));
+ dprint(3,(debugfile,"mailbox '%s' already registered as '%s'\n", buf,
+ mutt_b2s ((*tmp)->pathbuf)));
break;
}
}
mutt_sb_notify_mailbox (*tmp, 1);
#endif
#ifdef USE_INOTIFY
- (*tmp)->magic = mx_get_magic ((*tmp)->path);
+ (*tmp)->magic = mx_get_magic (mutt_b2s ((*tmp)->pathbuf));
mutt_monitor_add (*tmp);
#endif
}
* that it increased . without check_mbox_size we probably don't care.
*/
if (option(OPTCHECKMBOXSIZE) &&
- stat ((*tmp)->path, &sb) == 0 && !test_new_folder ((*tmp)->path))
+ stat (mutt_b2s ((*tmp)->pathbuf), &sb) == 0 &&
+ !test_new_folder (mutt_b2s ((*tmp)->pathbuf)))
{
/* some systems out there don't have an off_t type */
(*tmp)->size = (off_t) sb.st_size;
path = mutt_buffer_pool_get ();
msgpath = mutt_buffer_pool_get ();
- mutt_buffer_printf (path, "%s/%s", mailbox->path, dir_name);
+ mutt_buffer_printf (path, "%s/%s", mutt_b2s (mailbox->pathbuf), dir_name);
/* when $mail_check_recent is set, if the new/ directory hasn't been modified since
* the user last exited the mailbox, then we know there is no recent mail.
if (check_stats &&
(mutt_stat_timespec_compare (sb, MUTT_STAT_MTIME, &mailbox->stats_last_checked) > 0))
{
- if (mx_open_mailbox (mailbox->path,
+ if (mx_open_mailbox (mutt_b2s (mailbox->pathbuf),
MUTT_READONLY | MUTT_QUIET | MUTT_NOSORT | MUTT_PEEK,
&ctx) != NULL)
{
{
tmp->new = 0;
#ifdef USE_POP
- if (mx_is_pop (tmp->path))
+ if (mx_is_pop (mutt_b2s (tmp->pathbuf)))
tmp->magic = MUTT_POP;
else
#endif
- if (stat (tmp->path, &sb) != 0 || (S_ISREG(sb.st_mode) && sb.st_size == 0) ||
- (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0))
+ if (stat (mutt_b2s (tmp->pathbuf), &sb) != 0 ||
+ (S_ISREG(sb.st_mode) && sb.st_size == 0) ||
+ (!tmp->magic &&
+ (tmp->magic = mx_get_magic (mutt_b2s (tmp->pathbuf))) <= 0))
{
/* if the mailbox still doesn't exist, set the newly created flag to
* be ready for when it does. */
* before polling */
if (!Context || !Context->path ||
(( tmp->magic == MUTT_IMAP || tmp->magic == MUTT_POP )
- ? mutt_strcmp (tmp->path, Context->path) :
+ ? mutt_strcmp (mutt_b2s (tmp->pathbuf), Context->path) :
(sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino)))
{
switch (tmp->magic)
if (!tmp->new || (have_unnotified && tmp->notified))
continue;
- strfcpy (path, tmp->path, sizeof (path));
+ strfcpy (path, mutt_b2s (tmp->pathbuf), sizeof (path));
mutt_pretty_mailbox (path, sizeof (path));
if (!first && (MuttMessageWindow->cols >= 7) &&
for (pass = 0; pass < 2; pass++)
for (tmp = Incoming; tmp; tmp = tmp->next)
{
- mutt_expand_path (tmp->path, sizeof (tmp->path));
+ mutt_buffer_expand_path (tmp->pathbuf);
if ((found || pass) && tmp->new)
{
- mutt_buffer_strcpy (s, tmp->path);
+ mutt_buffer_strcpy (s, mutt_b2s (tmp->pathbuf));
mutt_buffer_pretty_mailbox (s);
return;
}
- if (mutt_strcmp (mutt_b2s (s), tmp->path) == 0)
+ if (mutt_strcmp (mutt_b2s (s), mutt_b2s (tmp->pathbuf)) == 0)
found = 1;
}
for (cur = Incoming; cur; cur = cur->next)
{
/* must be done late because e.g. IMAP delimiter may change */
- mutt_expand_path (cur->path, sizeof (cur->path));
- if (!mutt_strcmp(cur->path, path))
+ mutt_buffer_expand_path (cur->pathbuf);
+ if (!mutt_strcmp (mutt_b2s (cur->pathbuf), path))
{
FREE (&epath);
return cur;
typedef struct buffy_t
{
- char path[_POSIX_PATH_MAX];
+ BUFFER *pathbuf;
const char *realpath; /* used for duplicate detection, context comparison,
and the sidebar */
off_t size;
(state->entry)[state->entrylen].inferiors = !noinferiors;
b = Incoming;
- while (b && mutt_strcmp (tmp, b->path))
+ while (b && mutt_strcmp (tmp, mutt_b2s (b->pathbuf)))
b = b->next;
if (b)
{
if (inc->magic != MUTT_IMAP)
continue;
- if (imap_parse_path (inc->path, &mx) < 0)
+ if (imap_parse_path (mutt_b2s (inc->pathbuf), &mx) < 0)
{
- dprint (1, (debugfile, "Error parsing mailbox %s, skipping\n", inc->path));
+ dprint (1, (debugfile, "Error parsing mailbox %s, skipping\n", mutt_b2s (inc->pathbuf)));
continue;
}
/* dprint (2, (debugfile, "Buffy entry: [%s] mbox: [%s]\n", inc->path, NONULL(mx.mbox))); */
/* Init newly-added mailboxes */
if (! mailbox->magic)
{
- if (mx_is_imap (mailbox->path))
+ if (mx_is_imap (mutt_b2s (mailbox->pathbuf)))
mailbox->magic = MUTT_IMAP;
}
if (mailbox->magic != MUTT_IMAP)
continue;
- if (imap_get_mailbox (mailbox->path, &idata, name, sizeof (name)) < 0)
+ if (imap_get_mailbox (mutt_b2s (mailbox->pathbuf), &idata, name, sizeof (name)) < 0)
{
mailbox->new = 0;
continue;
matchlen = mutt_strlen (dest);
for (mailbox = Incoming; mailbox; mailbox = mailbox->next)
{
- if (!mutt_strncmp (dest, mailbox->path, matchlen))
+ if (!mutt_strncmp (dest, mutt_b2s (mailbox->pathbuf), matchlen))
{
if (rc)
{
- strfcpy (dest, mailbox->path, len);
+ strfcpy (dest, mutt_b2s (mailbox->pathbuf), len);
rc = 0;
}
else
- longest_common_prefix (dest, mailbox->path, matchlen, len);
+ longest_common_prefix (dest, mutt_b2s (mailbox->pathbuf), matchlen, len);
}
}
int rc = -1;
path = mutt_buffer_pool_get ();
- mutt_buffer_printf (path, "%s/.mh_sequences", b->path);
+ mutt_buffer_printf (path, "%s/.mh_sequences", mutt_b2s (b->pathbuf));
if (stat (mutt_b2s (path), &sb) == 0)
rc = (mutt_stat_timespec_compare (&sb, MUTT_STAT_MTIME, &b->last_visited) > 0);
mutt_buffer_pool_release (&path);
int rc = -1;
path = mutt_buffer_pool_get ();
- mutt_buffer_printf (path, "%s/%d", b->path, msgno);
+ mutt_buffer_printf (path, "%s/%d", mutt_b2s (b->pathbuf), msgno);
if (stat (mutt_b2s (path), &sb) == 0)
rc = (mutt_stat_timespec_compare (&sb, MUTT_STAT_MTIME, &b->last_visited) <= 0);
mutt_buffer_pool_release (&path);
return rc;
memset (&mhs, 0, sizeof (mhs));
- if (mh_read_sequences (&mhs, mailbox->path) < 0)
+ if (mh_read_sequences (&mhs, mutt_b2s (mailbox->pathbuf)) < 0)
return 0;
if (check_stats)
if (check_stats)
{
- if ((dirp = opendir (mailbox->path)) != NULL)
+ if ((dirp = opendir (mutt_b2s (mailbox->pathbuf))) != NULL)
{
while ((de = readdir (dirp)) != NULL)
{
* mutt_FormatString to do the actual work. mutt_FormatString will callback to
* us using cb_format_str() for the sidebar specific formatting characters.
*/
-static void make_sidebar_entry (char *buf, unsigned int buflen, int width, char *box,
+static void make_sidebar_entry (char *buf, unsigned int buflen, int width, const char *box,
SBENTRY *sbe)
{
if (!buf || !box || !sbe)
result = (b2->msg_flagged - b1->msg_flagged);
break;
case SORT_PATH:
- result = mutt_strcasecmp (b1->path, b2->path);
+ result = mutt_strcasecmp (mutt_b2s (b1->pathbuf), mutt_b2s (b2->pathbuf));
break;
}
/* Spool directory */
continue;
- if (mutt_find_list (SidebarWhitelist, sbe->buffy->path))
+ if (mutt_find_list (SidebarWhitelist, mutt_b2s (sbe->buffy->pathbuf)))
/* Explicitly asked to be visible */
continue;
else if (b->msg_flagged > 0)
SETCOLOR(MT_COLOR_FLAGGED);
else if ((ColorDefs[MT_COLOR_SB_SPOOLFILE] != 0) &&
- (mutt_strcmp (b->path, Spoolfile) == 0))
+ (mutt_strcmp (mutt_b2s (b->pathbuf), Spoolfile) == 0))
SETCOLOR(MT_COLOR_SB_SPOOLFILE);
else
SETCOLOR(MT_COLOR_NORMAL);
/* check whether Maildir is a prefix of the current folder's path */
short maildir_is_prefix = 0;
- if ((mutt_strlen (b->path) > maildirlen) &&
- (mutt_strncmp (Maildir, b->path, maildirlen) == 0) &&
+ if ((mutt_buffer_len (b->pathbuf) > maildirlen) &&
+ (mutt_strncmp (Maildir, mutt_b2s (b->pathbuf), maildirlen) == 0) &&
SidebarDelimChars &&
- strchr (SidebarDelimChars, b->path[maildirlen]))
+ strchr (SidebarDelimChars, mutt_b2s (b->pathbuf)[maildirlen]))
maildir_is_prefix = 1;
/* calculate depth of current folder and generate its display name with indented spaces */
int sidebar_folder_depth = 0;
- char *sidebar_folder_name;
+ const char *sidebar_folder_name;
+ BUFFER *short_folder_name = NULL;
int i;
if (option (OPTSIDEBARSHORTPATH))
{
/* disregard a trailing separator, so strlen() - 2 */
- sidebar_folder_name = b->path;
+ sidebar_folder_name = mutt_b2s (b->pathbuf);
for (i = mutt_strlen (sidebar_folder_name) - 2; i >= 0; i--)
{
if (SidebarDelimChars &&
}
}
else
- sidebar_folder_name = b->path + maildir_is_prefix * (maildirlen + 1);
+ sidebar_folder_name = mutt_b2s (b->pathbuf) + maildir_is_prefix * (maildirlen + 1);
if (maildir_is_prefix && option (OPTSIDEBARFOLDERINDENT))
{
const char *tmp_folder_name;
int lastsep = 0;
- tmp_folder_name = b->path + maildirlen + 1;
+ tmp_folder_name = mutt_b2s (b->pathbuf) + maildirlen + 1;
int tmplen = (int) mutt_strlen (tmp_folder_name) - 1;
for (i = 0; i < tmplen; i++)
{
{
if (option (OPTSIDEBARSHORTPATH))
tmp_folder_name += lastsep; /* basename */
- int sfn_len = mutt_strlen (tmp_folder_name) +
- sidebar_folder_depth*mutt_strlen (SidebarIndentString) + 1;
- sidebar_folder_name = safe_malloc (sfn_len);
- sidebar_folder_name[0]=0;
+ short_folder_name = mutt_buffer_pool_get ();
for (i=0; i < sidebar_folder_depth; i++)
- safe_strcat (sidebar_folder_name, sfn_len, NONULL(SidebarIndentString));
- safe_strcat (sidebar_folder_name, sfn_len, tmp_folder_name);
+ mutt_buffer_addstr (short_folder_name, NONULL(SidebarIndentString));
+ mutt_buffer_addstr (short_folder_name, tmp_folder_name);
+ sidebar_folder_name = mutt_b2s (short_folder_name);
}
}
char str[STRING];
make_sidebar_entry (str, sizeof (str), w, sidebar_folder_name, entry);
printw ("%s", str);
- if (sidebar_folder_depth > 0)
- FREE (&sidebar_folder_name);
+ mutt_buffer_pool_release (&short_folder_name);
row++;
}
if (!EntryCount || HilIndex < 0)
return NULL;
- return Entries[HilIndex]->buffy->path;
+ return mutt_b2s (Entries[HilIndex]->buffy->pathbuf);
}
/**