static short BuffyCount = 0; /* how many boxes with new mail */
static short BuffyNotify = 0; /* # of unnotified new boxes */
-/* func to free buffy for list_del() */
-static inline void buffy_free (BUFFY** p) {
- p_delete(&(*p)->path);
- p_delete(p);
+static inline void buffy_delete(BUFFY** p)
+{
+ p_delete(&(*p)->path);
+ p_delete(p);
}
+DO_ARRAY_FUNCS(BUFFY, buffy, buffy_delete);
+
/* Return the index number of path in Incoming list */
int buffy_lookup (const char* path) {
int i = 0;
- if (list_empty(Incoming) || !path || !*path)
+ if (!Incoming.len || !path || !*path)
return (-1);
- for (i = 0; i < Incoming->length; i++) {
- if (!m_strcmp(((BUFFY *)Incoming->data[i])->path, path))
+ for (i = 0; i < Incoming.len; i++) {
+ if (!m_strcmp(Incoming.arr[i]->path, path))
return (i);
}
m_strcpy(buf, sizeof(buf), path->data);
if (data == M_UNMAILBOXES && !strcmp(buf, "*")) {
- list_del (&Incoming, (list_del_t*) buffy_free);
+ buffy_array_wipe(&Incoming);
return 0;
}
i = buffy_lookup (buf);
if (data == M_UNMAILBOXES) {
- if (i >= 0) {
- tmp = (BUFFY*) list_pop_idx (Incoming, i);
- buffy_free (&tmp);
- }
+ tmp = buffy_array_take(&Incoming, i);
+ buffy_delete(&tmp);
continue;
}
tmp = p_new(BUFFY, 1);
tmp->path = m_strdup(buf);
tmp->magic = 0;
- list_push_back (&Incoming, tmp);
- i = Incoming->length-1;
- } else
- tmp = (BUFFY*) Incoming->data[i];
+ buffy_array_append(&Incoming, tmp);
+ i = Incoming.len-1;
+ } else {
+ tmp = Incoming.arr[i];
+ }
tmp->new = 0;
tmp->notified = 1;
mutt_update_num_postponed ();
/* fastest return if there are no mailboxes */
- if (list_empty(Incoming))
+ if (!Incoming.len)
return 0;
now = time (NULL);
if (force == 0 && (now - BuffyTime < BuffyTimeout)
contex_sb.st_ino = 0;
}
- for (i = 0; i < Incoming->length; i++) {
- tmp = (BUFFY*) Incoming->data[i];
+ for (i = 0; i < Incoming.len; i++) {
+ tmp = Incoming.arr[i];
tmp->magic = mx_get_magic (tmp->path);
local = mx_is_local (tmp->magic-1);
if ((tmp->magic <= 0 || local) && (stat (tmp->path, &sb) != 0 || sb.st_size == 0)) {
first = 1;
buffylist[0] = 0;
pos += m_strlen(strncat (buffylist, _("New mail in "), sizeof (buffylist) - 1 - pos)); /* __STRNCAT_CHECKED__ */
- if (Incoming) {
- for (i = 0; i < Incoming->length; i++) {
- tmp = Incoming->data[i];
- /* Is there new mail in this mailbox? */
- if (tmp->new <= 0 || (have_unnotified && tmp->notified))
- continue;
+ for (i = 0; i < Incoming.len; i++) {
+ tmp = Incoming.arr[i];
+ /* Is there new mail in this mailbox? */
+ if (tmp->new <= 0 || (have_unnotified && tmp->notified))
+ continue;
- m_strcpy(path, sizeof(path), tmp->path);
- mutt_pretty_mailbox (path);
+ m_strcpy(path, sizeof(path), tmp->path);
+ mutt_pretty_mailbox (path);
- if (!first && pos + m_strlen(path) >= COLS - 7)
- break;
+ if (!first && pos + m_strlen(path) >= COLS - 7)
+ break;
- if (!first)
- pos += m_strlen(strncat (buffylist + pos, ", ", sizeof (buffylist) - 1 - pos)); /* __STRNCAT_CHECKED__ */
+ if (!first)
+ pos += m_strlen(strncat (buffylist + pos, ", ", sizeof (buffylist) - 1 - pos)); /* __STRNCAT_CHECKED__ */
- tmp->notified = 1;
- BuffyNotify--;
+ tmp->notified = 1;
+ BuffyNotify--;
- pos += m_strlen(strncat (buffylist + pos, path, sizeof (buffylist) - 1 - pos)); /* __STRNCAT_CHECKED__ */
- first = 0;
- }
+ pos += m_strlen(strncat (buffylist + pos, path, sizeof (buffylist) - 1 - pos)); /* __STRNCAT_CHECKED__ */
+ first = 0;
}
- if (!first && i < Incoming->length) {
+
+ if (!first && i < Incoming.len) {
strncat (buffylist + pos, ", ...", sizeof (buffylist) - 1 - pos); /* __STRNCAT_CHECKED__ */
}
if (!first) {
/*
* buffy_lookup returns the index,
- * or -1 if not found (-1..Incoming->length-1);
- * plus one --> (0..Incoming->length).
+ * or -1 if not found (-1..Incoming.len-1);
+ * plus one --> (0..Incoming.len).
* Modulo mapps it into the correct range.
*/
i = 1 + buffy_lookup (s);
- for (l = 0; l < Incoming->length; l++) {
- c = (l+i) % Incoming->length;
+ for (l = 0; l < Incoming.len; l++) {
+ c = (l+i) % Incoming.len;
- if (m_strcmp(((BUFFY*) Incoming->data[c])->path, s) &&
- ((BUFFY*) Incoming->data[c])->new > 0)
+ if (m_strcmp(Incoming.arr[c]->path, s) && Incoming.arr[c]->new > 0)
break;
}
- if (l >= Incoming->length) {
+ if (l >= Incoming.len) {
*s = '\0';
/* something went wrong since we're here when buffy_check
* reported new mail */
buffy_check (1);
} else {
- m_strcpy(s, slen, ((BUFFY*)Incoming->data[c])->path);
+ m_strcpy(s, slen, Incoming.arr[c]->path);
mutt_pretty_mailbox (s);
}
}