DIR *dp = NULL;
struct dirent *de = NULL;
char buffer[PATH_MAX + SHORT_STRING];
- struct Buffy *tmp = NULL;
while (stat(d, &s) == -1)
{
else if (!S_ISREG(s.st_mode))
continue;
- tmp = Incoming;
- while (tmp && (mutt_str_strcmp(buffer, tmp->path) != 0))
- tmp = tmp->next;
- if (tmp && Context && (mutt_str_strcmp(tmp->realpath, Context->realpath) == 0))
+ struct BuffyNode *np = NULL;
+ STAILQ_FOREACH(np, &BuffyList, entries)
{
- tmp->msg_count = Context->msgcount;
- tmp->msg_unread = Context->unread;
+ if (mutt_str_strcmp(buffer, np->b->path) != 0)
+ break;
+ }
+
+ if (np && Context && (mutt_str_strcmp(np->b->realpath, Context->realpath) == 0))
+ {
+ np->b->msg_count = Context->msgcount;
+ np->b->msg_unread = Context->unread;
}
- add_folder(menu, state, de->d_name, NULL, &s, tmp, NULL);
+ add_folder(menu, state, de->d_name, NULL, &s, np->b, NULL);
}
closedir(dp);
}
*/
static int examine_vfolders(struct Menu *menu, struct BrowserState *state)
{
- struct Buffy *tmp = Incoming;
- if (!tmp)
+ if (STAILQ_EMPTY(&BuffyList))
return -1;
mutt_buffy_check(0);
init_state(state, menu);
- do
+ struct BuffyNode *np = NULL;
+ STAILQ_FOREACH(np, &BuffyList, entries)
{
- if (mx_is_notmuch(tmp->path))
+ if (mx_is_notmuch(np->b->path))
{
- nm_nonctx_get_count(tmp->path, &tmp->msg_count, &tmp->msg_unread);
- add_folder(menu, state, tmp->path, tmp->desc, NULL, tmp, NULL);
+ nm_nonctx_get_count(np->b->path, &np->b->msg_count, &np->b->msg_unread);
+ add_folder(menu, state, np->b->path, np->b->desc, NULL, np->b, NULL);
continue;
}
- } while ((tmp = tmp->next));
+ }
+
browser_sort(state);
return 0;
}
else
#endif
{
- struct Buffy *tmp = Incoming;
-
init_state(state, menu);
- if (!Incoming)
+ if (STAILQ_EMPTY(&BuffyList))
return -1;
mutt_buffy_check(0);
- do
+ struct BuffyNode *np = NULL;
+ STAILQ_FOREACH(np, &BuffyList, entries)
{
- if (Context && (mutt_str_strcmp(tmp->realpath, Context->realpath) == 0))
+ if (Context && (mutt_str_strcmp(np->b->realpath, Context->realpath) == 0))
{
- tmp->msg_count = Context->msgcount;
- tmp->msg_unread = Context->unread;
+ np->b->msg_count = Context->msgcount;
+ np->b->msg_unread = Context->unread;
}
char buffer[PATH_MAX];
- mutt_str_strfcpy(buffer, tmp->path, sizeof(buffer));
+ mutt_str_strfcpy(buffer, np->b->path, sizeof(buffer));
if (BrowserAbbreviateMailboxes)
mutt_pretty_mailbox(buffer, sizeof(buffer));
#ifdef USE_IMAP
- if (mx_is_imap(tmp->path))
+ if (mx_is_imap(np->b->path))
{
- add_folder(menu, state, buffer, NULL, NULL, tmp, NULL);
+ add_folder(menu, state, buffer, NULL, NULL, np->b, NULL);
continue;
}
#endif
#ifdef USE_POP
- if (mx_is_pop(tmp->path))
+ if (mx_is_pop(np->b->path))
{
- add_folder(menu, state, buffer, NULL, NULL, tmp, NULL);
+ add_folder(menu, state, buffer, NULL, NULL, np->b, NULL);
continue;
}
#endif
#ifdef USE_NNTP
- if (mx_is_nntp(tmp->path))
+ if (mx_is_nntp(np->b->path))
{
- add_folder(menu, state, tmp->path, NULL, NULL, tmp, NULL);
+ add_folder(menu, state, np->b->path, NULL, NULL, np->b, NULL);
continue;
}
#endif
- if (lstat(tmp->path, &s) == -1)
+ if (lstat(np->b->path, &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(np->b->path))
{
struct stat st2;
char md[PATH_MAX];
- snprintf(md, sizeof(md), "%s/new", tmp->path);
+ snprintf(md, sizeof(md), "%s/new", np->b->path);
if (stat(md, &s) < 0)
s.st_mtime = 0;
- snprintf(md, sizeof(md), "%s/cur", tmp->path);
+ snprintf(md, sizeof(md), "%s/cur", np->b->path);
if (stat(md, &st2) < 0)
st2.st_mtime = 0;
if (st2.st_mtime > s.st_mtime)
s.st_mtime = st2.st_mtime;
}
- add_folder(menu, state, buffer, NULL, &s, tmp, NULL);
- } while ((tmp = tmp->next));
+ add_folder(menu, state, buffer, NULL, &s, np->b, NULL);
+ }
}
browser_sort(state);
return 0;
static short BuffyCount = 0; /**< how many boxes with new mail */
static short BuffyNotify = 0; /**< # of unnotified new boxes */
+struct BuffyList BuffyList = STAILQ_HEAD_INITIALIZER(BuffyList);
+
/**
* fseek_last_message - Find the last message in the file
* @param f File to search
mutt_str_strfcpy(buffy->path, path, sizeof(buffy->path));
char *r = realpath(path, rp);
mutt_str_strfcpy(buffy->realpath, r ? rp : path, sizeof(buffy->realpath));
- buffy->next = NULL;
buffy->magic = 0;
return buffy;
*/
static struct Buffy *buffy_get(const char *path)
{
- struct Buffy *cur = NULL;
- char *epath = NULL;
-
if (!path)
return NULL;
- epath = mutt_str_strdup(path);
+ char *epath = mutt_str_strdup(path);
mutt_expand_path(epath, mutt_str_strlen(epath));
- for (cur = Incoming; cur; cur = cur->next)
+ struct BuffyNode *np = NULL;
+ STAILQ_FOREACH(np, &BuffyList, entries)
{
/* must be done late because e.g. IMAP delimiter may change */
- mutt_expand_path(cur->path, sizeof(cur->path));
- if (mutt_str_strcmp(cur->path, path) == 0)
+ mutt_expand_path(np->b->path, sizeof(np->b->path));
+ if (mutt_str_strcmp(np->b->path, path) == 0)
{
FREE(&epath);
- return cur;
+ return np->b;
}
}
*/
struct Buffy *mutt_find_mailbox(const char *path)
{
+ if (!path)
+ return NULL;
+
struct stat sb;
struct stat tmp_sb;
if (stat(path, &sb) != 0)
return NULL;
- for (struct Buffy *b = Incoming; b; b = b->next)
+ struct BuffyNode *np = NULL;
+ STAILQ_FOREACH(np, &BuffyList, entries)
{
- if (stat(b->path, &tmp_sb) == 0 && sb.st_dev == tmp_sb.st_dev &&
- sb.st_ino == tmp_sb.st_ino)
+ if ((stat(np->b->path, &tmp_sb) == 0) && (sb.st_dev == tmp_sb.st_dev) &&
+ (sb.st_ino == tmp_sb.st_ino))
{
- return b;
+ return np->b;
}
}
+
return NULL;
}
int mutt_parse_mailboxes(struct Buffer *path, struct Buffer *s,
unsigned long data, struct Buffer *err)
{
- struct Buffy **b = NULL;
char buf[PATH_MAX];
struct stat sb;
char f1[PATH_MAX];
/* avoid duplicates */
p = realpath(buf, f1);
- for (b = &Incoming; *b; b = &((*b)->next))
+ struct BuffyNode *np = NULL;
+ STAILQ_FOREACH(np, &BuffyList, entries)
{
- if (mutt_str_strcmp(p ? p : buf, (*b)->realpath) == 0)
+ if (mutt_str_strcmp(p ? p : buf, np->b->realpath) == 0)
{
- mutt_debug(3, "mailbox '%s' already registered as '%s'\n", buf, (*b)->path);
+ mutt_debug(3, "mailbox '%s' already registered as '%s'\n", buf, np->b->path);
break;
}
}
- if (*b)
+ if (np)
{
FREE(&desc);
continue;
}
- *b = buffy_new(buf);
+ struct Buffy *b = buffy_new(buf);
- (*b)->new = false;
- (*b)->notified = true;
- (*b)->newly_created = false;
- (*b)->desc = desc;
+ b->new = false;
+ b->notified = true;
+ b->newly_created = false;
+ b->desc = desc;
#ifdef USE_NOTMUCH
- if (mx_is_notmuch((*b)->path))
+ if (mx_is_notmuch(b->path))
{
- (*b)->magic = MUTT_NOTMUCH;
- (*b)->size = 0;
+ b->magic = MUTT_NOTMUCH;
+ b->size = 0;
}
else
#endif
* reading it), the size is set to 0 so that later when we check we see
* that it increased. without check_mbox_size we probably don't care.
*/
- if (CheckMboxSize && stat((*b)->path, &sb) == 0 && !test_new_folder((*b)->path))
+ if (CheckMboxSize && stat(b->path, &sb) == 0 && !test_new_folder(b->path))
{
/* some systems out there don't have an off_t type */
- (*b)->size = (off_t) sb.st_size;
+ b->size = (off_t) sb.st_size;
}
else
- (*b)->size = 0;
+ b->size = 0;
}
+ struct BuffyNode *bn = mutt_mem_calloc(1, sizeof(*bn));
+ bn->b = b;
+ STAILQ_INSERT_TAIL(&BuffyList, bn, entries);
+
#ifdef USE_SIDEBAR
- mutt_sb_notify_mailbox(*b, 1);
+ mutt_sb_notify_mailbox(b, 1);
#endif
}
return 0;
}
}
- for (struct Buffy **b = &Incoming; *b;)
+ struct BuffyNode *np = NULL;
+ struct BuffyNode *tmp = NULL;
+ STAILQ_FOREACH_SAFE(np, &BuffyList, entries, tmp)
{
/* Decide whether to delete all normal mailboxes or all virtual */
- bool virt = (((*b)->magic == MUTT_NOTMUCH) && (data & MUTT_VIRTUAL));
- bool norm = (((*b)->magic != MUTT_NOTMUCH) && !(data & MUTT_VIRTUAL));
+ bool virt = ((np->b->magic == MUTT_NOTMUCH) && (data & MUTT_VIRTUAL));
+ bool norm = ((np->b->magic != MUTT_NOTMUCH) && !(data & MUTT_VIRTUAL));
bool clear_this = clear_all && (virt || norm);
- if (clear_this || (mutt_str_strcasecmp(buf, (*b)->path) == 0) ||
- (mutt_str_strcasecmp(buf, (*b)->desc) == 0))
+ if (clear_this || (mutt_str_strcasecmp(buf, np->b->path) == 0) ||
+ (mutt_str_strcasecmp(buf, np->b->desc) == 0))
{
- struct Buffy *next = (*b)->next;
#ifdef USE_SIDEBAR
- mutt_sb_notify_mailbox(*b, 0);
+ mutt_sb_notify_mailbox(np->b, 0);
#endif
- buffy_free(b);
- *b = next;
+ STAILQ_REMOVE(&BuffyList, np, BuffyNode, entries);
+ buffy_free(&np->b);
+ FREE(&np);
continue;
}
-
- b = &((*b)->next);
}
}
return 0;
}
/**
- * mutt_buffy_check - Check all Incoming for new mail
+ * mutt_buffy_check - Check all BuffyList for new mail
* @param force Force flags, see below
* @retval num Number of mailboxes with new mail
*
* - MUTT_BUFFY_CHECK_FORCE ignore BuffyTimeout and check for new mail
* - MUTT_BUFFY_CHECK_FORCE_STATS ignore BuffyTimeout and calculate statistics
*
- * Check all Incoming for new mail and total/new/flagged messages
+ * Check all BuffyList for new mail and total/new/flagged messages
*/
int mutt_buffy_check(int force)
{
#endif
/* fastest return if there are no mailboxes */
- if (!Incoming)
+ if (STAILQ_EMPTY(&BuffyList))
return 0;
t = time(NULL);
contex_sb.st_ino = 0;
}
- for (struct Buffy *b = Incoming; b; b = b->next)
- buffy_check(b, &contex_sb, check_stats);
+ struct BuffyNode *np = NULL;
+ STAILQ_FOREACH(np, &BuffyList, entries)
+ {
+ buffy_check(np->b, &contex_sb, check_stats);
+ }
BuffyDoneTime = BuffyTime;
return BuffyCount;
*/
bool mutt_buffy_list(void)
{
- struct Buffy *b = NULL;
char path[PATH_MAX];
char buffylist[2 * STRING];
size_t pos = 0;
buffylist[0] = '\0';
pos += strlen(strncat(buffylist, _("New mail in "), sizeof(buffylist) - 1 - pos));
- for (b = Incoming; b; b = b->next)
+ struct BuffyNode *np = NULL;
+ STAILQ_FOREACH(np, &BuffyList, entries)
{
/* Is there new mail in this mailbox? */
- if (!b->new || (have_unnotified && b->notified))
+ if (!np->b->new || (have_unnotified && np->b->notified))
continue;
- mutt_str_strfcpy(path, b->path, sizeof(path));
+ mutt_str_strfcpy(path, np->b->path, sizeof(path));
mutt_pretty_mailbox(path, sizeof(path));
if (!first && (MuttMessageWindow->cols >= 7) &&
pos += strlen(strncat(buffylist + pos, ", ", sizeof(buffylist) - 1 - pos));
/* Prepend an asterisk to mailboxes not already notified */
- if (!b->notified)
+ if (!np->b->notified)
{
/* pos += strlen (strncat(buffylist + pos, "*", sizeof(buffylist)-1-pos)); */
- b->notified = true;
+ np->b->notified = true;
BuffyNotify--;
}
pos += strlen(strncat(buffylist + pos, path, sizeof(buffylist) - 1 - pos));
first = 0;
}
- if (!first && b)
+
+ if (!first && np)
{
strncat(buffylist + pos, ", ...", sizeof(buffylist) - 1 - pos);
}
int found = 0;
for (int pass = 0; pass < 2; pass++)
{
- for (struct Buffy *b = Incoming; b; b = b->next)
+ struct BuffyNode *np = NULL;
+ STAILQ_FOREACH(np, &BuffyList, entries)
{
- if (b->magic == MUTT_NOTMUCH) /* only match real mailboxes */
+ if (np->b->magic == MUTT_NOTMUCH) /* only match real mailboxes */
continue;
- mutt_expand_path(b->path, sizeof(b->path));
- if ((found || pass) && b->new)
+ mutt_expand_path(np->b->path, sizeof(np->b->path));
+ if ((found || pass) && np->b->new)
{
- mutt_str_strfcpy(s, b->path, slen);
+ mutt_str_strfcpy(s, np->b->path, slen);
mutt_pretty_mailbox(s, slen);
return;
}
- if (mutt_str_strcmp(s, b->path) == 0)
+ if (mutt_str_strcmp(s, np->b->path) == 0)
found = 1;
}
}
bool found = false;
for (int pass = 0; pass < 2; pass++)
{
- for (struct Buffy *b = Incoming; b; b = b->next)
+ struct BuffyNode *np = NULL;
+ STAILQ_FOREACH(np, &BuffyList, entries)
{
- if (b->magic != MUTT_NOTMUCH)
+ if (np->b->magic != MUTT_NOTMUCH)
continue;
- if ((found || pass) && b->new)
+ if ((found || pass) && np->b->new)
{
- mutt_str_strfcpy(buf, b->desc, buflen);
+ mutt_str_strfcpy(buf, np->b->desc, buflen);
return;
}
- if (mutt_str_strcmp(buf, b->path) == 0)
+ if (mutt_str_strcmp(buf, np->b->path) == 0)
found = true;
}
}
#include <stdbool.h>
#include <sys/types.h>
#include <time.h>
+#include "mutt/mutt.h"
#include "where.h"
struct Buffer;
* comparison, and the sidebar */
char *desc;
off_t size;
- struct Buffy *next;
bool new; /**< mailbox has new mail */
/* These next three are only set when MailCheckStats is set */
time_t stats_last_checked; /**< mtime of mailbox the last time stats where checked. */
};
-WHERE struct Buffy *Incoming;
+struct BuffyNode
+{
+ struct Buffy *b;
+ STAILQ_ENTRY(BuffyNode) entries;
+};
+
+STAILQ_HEAD(BuffyList, BuffyNode);
+
+extern struct BuffyList BuffyList;
#ifdef USE_NOTMUCH
void mutt_buffy_vfolder(char *buf, size_t buflen);
char tmp[PATH_MAX];
char relpath[PATH_MAX];
struct ImapMbox mx;
- struct Buffy *b = NULL;
if (imap_parse_path(state->folder, &mx))
return;
(state->entry)[state->entrylen].selectable = !noselect;
(state->entry)[state->entrylen].inferiors = !noinferiors;
- b = Incoming;
- while (b && (mutt_str_strcmp(tmp, b->path) != 0))
- b = b->next;
- if (b)
+ struct BuffyNode *np = NULL;
+ STAILQ_FOREACH(np, &BuffyList, entries)
{
- if (Context && (mutt_str_strcmp(b->realpath, Context->realpath) == 0))
+ if (mutt_str_strcmp(tmp, np->b->path) == 0)
+ break;
+ }
+
+ if (np)
+ {
+ if (Context && (mutt_str_strcmp(np->b->realpath, Context->realpath) == 0))
{
- b->msg_count = Context->msgcount;
- b->msg_unread = Context->unread;
+ np->b->msg_count = Context->msgcount;
+ np->b->msg_unread = Context->unread;
}
(state->entry)[state->entrylen].has_buffy = true;
- (state->entry)[state->entrylen].new = b->new;
- (state->entry)[state->entrylen].msg_count = b->msg_count;
- (state->entry)[state->entrylen].msg_unread = b->msg_unread;
+ (state->entry)[state->entrylen].new = np->b->new;
+ (state->entry)[state->entrylen].msg_count = np->b->msg_count;
+ (state->entry)[state->entrylen].msg_unread = np->b->msg_unread;
}
(state->entrylen)++;
static void cmd_parse_status(struct ImapData *idata, char *s)
{
char *value = NULL;
- struct Buffy *inc = NULL;
struct ImapMbox mx;
struct ImapStatus *status = NULL;
unsigned int olduv, oldun;
mutt_debug(3, "Running default STATUS handler\n");
/* should perhaps move this code back to imap_buffy_check */
- for (inc = Incoming; inc; inc = inc->next)
+ struct BuffyNode *np = NULL;
+ STAILQ_FOREACH(np, &BuffyList, entries)
{
- if (inc->magic != MUTT_IMAP)
+ if (np->b->magic != MUTT_IMAP)
continue;
- if (imap_parse_path(inc->path, &mx) < 0)
+ if (imap_parse_path(np->b->path, &mx) < 0)
{
- mutt_debug(1, "Error parsing mailbox %s, skipping\n", inc->path);
+ mutt_debug(1, "Error parsing mailbox %s, skipping\n", np->b->path);
continue;
}
new = (status->unseen > 0);
#ifdef USE_SIDEBAR
- if ((inc->new != new) || (inc->msg_count != status->messages) ||
- (inc->msg_unread != status->unseen))
+ if ((np->b->new != new) || (np->b->msg_count != status->messages) ||
+ (np->b->msg_unread != status->unseen))
{
mutt_menu_set_current_redraw(REDRAW_SIDEBAR);
}
#endif
- inc->new = new;
+ np->b->new = new;
if (new_msg_count)
- inc->msg_count = status->messages;
- inc->msg_unread = status->unseen;
+ np->b->msg_count = status->messages;
+ np->b->msg_unread = status->unseen;
- if (inc->new)
+ if (np->b->new)
{
/* force back to keep detecting new mail until the mailbox is
opened */
*/
static int complete_hosts(char *buf, size_t buflen)
{
- struct Buffy *mailbox = NULL;
struct Connection *conn = NULL;
int rc = -1;
size_t matchlen;
matchlen = mutt_str_strlen(buf);
- for (mailbox = Incoming; mailbox; mailbox = mailbox->next)
+ struct BuffyNode *np = NULL;
+ STAILQ_FOREACH(np, &BuffyList, entries)
{
- if (mutt_str_strncmp(buf, mailbox->path, matchlen) == 0)
+ if (mutt_str_strncmp(buf, np->b->path, matchlen) != 0)
+ continue;
+
+ if (rc)
{
- if (rc)
- {
- mutt_str_strfcpy(buf, mailbox->path, buflen);
- rc = 0;
- }
- else
- longest_common_prefix(buf, mailbox->path, matchlen, buflen);
+ mutt_str_strfcpy(buf, np->b->path, buflen);
+ rc = 0;
}
+ else
+ longest_common_prefix(buf, np->b->path, matchlen, buflen);
}
TAILQ_FOREACH(conn, mutt_socket_head(), entries)
{
struct ImapData *idata = NULL;
struct ImapData *lastdata = NULL;
- struct Buffy *mailbox = NULL;
char name[LONG_STRING];
char command[LONG_STRING];
char munged[LONG_STRING];
int buffies = 0;
- for (mailbox = Incoming; mailbox; mailbox = mailbox->next)
+ struct BuffyNode *np = NULL;
+ STAILQ_FOREACH(np, &BuffyList, entries)
{
/* Init newly-added mailboxes */
- if (!mailbox->magic)
+ if (!np->b->magic)
{
- if (mx_is_imap(mailbox->path))
- mailbox->magic = MUTT_IMAP;
+ if (mx_is_imap(np->b->path))
+ np->b->magic = MUTT_IMAP;
}
- if (mailbox->magic != MUTT_IMAP)
+ if (np->b->magic != MUTT_IMAP)
continue;
- if (get_mailbox(mailbox->path, &idata, name, sizeof(name)) < 0)
+ if (get_mailbox(np->b->path, &idata, name, sizeof(name)) < 0)
{
- mailbox->new = false;
+ np->b->new = false;
continue;
}
* mailbox's, and shouldn't expand to INBOX in that case. #3216. */
if (idata->mailbox && (imap_mxcmp(name, idata->mailbox) == 0))
{
- mailbox->new = false;
+ np->b->new = false;
continue;
}
}
/* collect results */
- for (mailbox = Incoming; mailbox; mailbox = mailbox->next)
+ STAILQ_FOREACH(np, &BuffyList, entries)
{
- if (mailbox->magic == MUTT_IMAP && mailbox->new)
+ if ((np->b->magic == MUTT_IMAP) && np->b->new)
buffies++;
}
{
char scratch[PATH_MAX];
mutt_str_strfcpy(scratch, buf->data, sizeof(scratch));
-
+
if (mutt_str_strcmp(buf->data, "builtin") != 0)
{
mutt_expand_path(scratch, sizeof(scratch));
if (VirtualSpoolfile)
{
/* Find the first virtual folder and open it */
- for (struct Buffy *b = Incoming; b; b = b->next)
+ struct BuffyNode *bp = NULL;
+ STAILQ_FOREACH(bp, &BuffyList, entries)
{
- if (b->magic == MUTT_NOTMUCH)
+ if (bp->b->magic == MUTT_NOTMUCH)
{
- cs_str_string_set(Config, "spoolfile", b->path, NULL);
+ cs_str_string_set(Config, "spoolfile", bp->b->path, NULL);
mutt_sb_toggle_virtual();
break;
}
}
else
#endif
- if (!Incoming)
+ if (STAILQ_EMPTY(&BuffyList))
{
mutt_error(_("No incoming mailboxes defined."));
goto main_curses; // TEST39: neomutt -n -F /dev/null -y
*/
char *nm_get_description(struct Context *ctx)
{
- for (struct Buffy *b = Incoming; b; b = b->next)
- if (b->desc && (strcmp(b->path, ctx->path) == 0))
- return b->desc;
+ struct BuffyNode *np = NULL;
+ STAILQ_FOREACH(np, &BuffyList, entries)
+ {
+ if (np->b->desc && (strcmp(np->b->path, ctx->path) == 0))
+ return np->b->desc;
+ }
return NULL;
}
/**
- * nm_description_to_path - Find a path from a folder's description
+ * nm_desc&ription_to_path - Find a path from a folder's description
* @param desc Description
* @param buf Buffer for path
* @param buflen Length of buffer
if (!desc || !buf || (buflen == 0))
return -EINVAL;
- for (struct Buffy *b = Incoming; b; b = b->next)
+ struct BuffyNode *np = NULL;
+ STAILQ_FOREACH(np, &BuffyList, entries)
{
- if ((b->magic == MUTT_NOTMUCH) && b->desc && (strcmp(desc, b->desc) == 0))
+ if ((np->b->magic == MUTT_NOTMUCH) && np->b->desc && (strcmp(desc, np->b->desc) == 0))
{
- strncpy(buf, b->path, buflen);
+ strncpy(buf, np->b->path, buflen);
buf[buflen - 1] = '\0';
return 0;
}
*/
static void unsort_entries(void)
{
- struct Buffy *cur = Incoming;
int i = 0;
- while (cur && (i < EntryCount))
+ struct BuffyNode *np = NULL;
+ STAILQ_FOREACH(np, &BuffyList, entries)
{
+ if (i >= EntryCount)
+ break;
+
int j = i;
- while ((j < EntryCount) && (Entries[j]->buffy != cur))
+ while ((j < EntryCount) && (Entries[j]->buffy != np->b))
j++;
if (j < EntryCount)
{
}
i++;
}
- cur = cur->next;
}
}
* Display a list of mailboxes in a panel on the left. What's displayed will
* depend on our index markers: TopBuffy, OpnBuffy, HilBuffy, BotBuffy.
* On the first run they'll be NULL, so we display the top of NeoMutt's list
- * (Incoming).
+ * (BuffyList).
*
* * TopBuffy - first visible mailbox
* * BotBuffy - last visible mailbox
int div_width = draw_divider(num_rows, num_cols);
if (!Entries)
- for (struct Buffy *b = Incoming; b; b = b->next)
- mutt_sb_notify_mailbox(b, 1);
+ {
+ struct BuffyNode *np = NULL;
+ STAILQ_FOREACH(np, &BuffyList, entries)
+ {
+ mutt_sb_notify_mailbox(np->b, 1);
+ }
+ }
if (!prepare_sidebar(num_rows))
{
*/
void mutt_sb_set_buffystats(const struct Context *ctx)
{
- /* Even if the sidebar's hidden,
- * we should take note of the new data. */
- struct Buffy *b = Incoming;
- if (!ctx || !b)
+ if (!ctx)
return;
- for (; b; b = b->next)
+ /* Even if the sidebar's hidden, we should take note of the new data. */
+ struct BuffyNode *np = NULL;
+ STAILQ_FOREACH(np, &BuffyList, entries)
{
- if (mutt_str_strcmp(b->realpath, ctx->realpath) == 0)
+ if (mutt_str_strcmp(np->b->realpath, ctx->realpath) == 0)
{
- b->msg_unread = ctx->unread;
- b->msg_count = ctx->msgcount;
- b->msg_flagged = ctx->flagged;
+ np->b->msg_unread = ctx->unread;
+ np->b->msg_count = ctx->msgcount;
+ np->b->msg_flagged = ctx->flagged;
break;
}
}
EntryCount = 0;
FREE(&Entries);
EntryLen = 0;
- for (struct Buffy *b = Incoming; b; b = b->next)
+ struct BuffyNode *np = NULL;
+ STAILQ_FOREACH(np, &BuffyList, entries)
{
/* and reintroduce the ones that are visible */
- if (((b->magic == MUTT_NOTMUCH) && (sidebar_source == SB_SRC_VIRT)) ||
- ((b->magic != MUTT_NOTMUCH) && (sidebar_source == SB_SRC_INCOMING)))
+ if (((np->b->magic == MUTT_NOTMUCH) && (sidebar_source == SB_SRC_VIRT)) ||
+ ((np->b->magic != MUTT_NOTMUCH) && (sidebar_source == SB_SRC_INCOMING)))
{
- mutt_sb_notify_mailbox(b, true);
+ mutt_sb_notify_mailbox(np->b, true);
}
}