endif
SUBDIRS = intl m4 po $(XXXXXXXXXXXX_doc) contrib \
- lib-mime lib-lib lib-crypt lib-hash lib-sys lib-ui lib \
+ lib-mime lib-lib lib-crypt lib-hash lib-sys lib-ui \
pop imap $(NNTP_SUBDIR)
BUILT_SOURCES = keymap_defs.h version.h charset.gperf
-Limap -limap -Lpop -lpop $(LIBNNTP) \
-Llib-lib -llib -Llib-mime -lmime -Llib-crypt -lcrypt -Llib-hash -lhash \
-Llib-sys -lsys -Llib-ui -lui \
- -Llib -lsane $(MUTTLIBS) $(INTLLIBS) $(LIBICONV)
+ $(MUTTLIBS) $(INTLLIBS) $(LIBICONV)
madmutt_DEPENDENCIES = @MUTT_LIB_OBJECTS@ @LIBOBJS@ \
$(top_builddir)/lib-lib/liblib.a \
$(top_builddir)/lib-crypt/libcrypt.a \
$(top_builddir)/lib-hash/libhash.a \
$(top_builddir)/lib-ui/libui.a \
- $(top_builddir)/lib/libsane.a \
\
$(top_builddir)/pop/libpop.a \
$(top_builddir)/imap/libimap.a \
pgpringng_SOURCES = pgppubring.c lib.c extlib.c
pgpringng_LDADD = @LIBOBJS@ $(INTLLIBS) \
- -Llib-lib -llib -Llib-hash -lhash -Llib-crypt -lcrypt -Llib -lsane
+ -Llib-lib -llib -Llib-hash -lhash -Llib-crypt -lcrypt
pgpringng_DEPENDENCIES = @LIBOBJS@ $(INTLDEPS) \
$(top_builddir)/lib-lib/liblib.a \
$(top_builddir)/lib-hash/libhash.a
i = buffy_lookup (buffer);
#ifdef USE_NNTP
- add_folder (menu, state, de->d_name, &s, NULL, i >= 0 ? ((BUFFY*) Incoming->data[i])->new : 0);
+ add_folder (menu, state, de->d_name, &s, NULL, i >= 0 ? Incoming.arr[i]->new : 0);
#else
- add_folder (menu, state, de->d_name, &s, i >= 0 ? ((BUFFY*) Incoming->data[i])->new : 0);
+ add_folder (menu, state, de->d_name, &s, i >= 0 ? Incoming.arr[i]->new : 0);
#endif
}
closedir (dp);
int i = 0;
BUFFY* tmp;
- if (!Incoming)
+ if (!Incoming.len)
return (-1);
buffy_check (0);
init_state (state, menu);
- 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);
if (tmp->magic == M_IMAP) {
#ifdef USE_NNTP
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);
}
}
#ifndef _BUFFY_H
#define _BUFFY_H
-#include "lib/list.h"
-
/*parameter to mutt_parse_mailboxes*/
#define M_MAILBOXES 1
#define M_UNMAILBOXES 2
short magic; /* mailbox type */
short newly_created; /* mbox or mmdf just popped into existence */
} BUFFY;
+DO_ARRAY_TYPE(BUFFY, buffy);
/* folders with incomming mail (via mailboxes command) */
-WHERE list2_t* Incoming;
+WHERE buffy_array Incoming;
WHERE short BuffyTimeout INITVAL (3);
extern time_t BuffyDoneTime; /* last time we knew for sure how much mail there was */
lib-hash/Makefile
lib-sys/Makefile
lib-ui/Makefile
- lib/Makefile
imap/Makefile
pop/Makefile
nntp/Makefile
int this_is_from;
int ignore = 0;
char buf[STRING]; /* should be long enough to get most fields in one pass */
- char *nl;
+ char *eol;
string_list_t *t;
char **headers;
int hdr_count;
* we can do a more efficient line to line copying
*/
while (ftello (in) < off_end) {
- nl = strchr (buf, '\n');
+ eol = strchr (buf, '\n');
if ((fgets (buf, sizeof (buf), in)) == NULL)
break;
/* Is it the begining of a header? */
- if (nl && buf[0] != ' ' && buf[0] != '\t') {
+ if (eol && buf[0] != ' ' && buf[0] != '\t') {
ignore = 1;
if (!from && m_strncmp("From ", buf, 5) == 0) {
if ((flags & CH_FROM) == 0)
/* Read all the headers into the array */
while (ftello (in) < off_end) {
- nl = strchr (buf, '\n');
+ eol = strchr (buf, '\n');
/* Read a line */
if ((fgets (buf, sizeof (buf), in)) == NULL)
break;
/* Is it the begining of a header? */
- if (nl && buf[0] != ' ' && buf[0] != '\t') {
+ if (eol && buf[0] != ' ' && buf[0] != '\t') {
/* set curline to 1 for To:/Cc:/Bcc: and 0 otherwise */
curline = (flags & CH_WEED) && (m_strncmp("To:", buf, 3) == 0 ||
int i = 0;
matchlen = m_strlen(dest);
- if (list_empty (Incoming))
+ if (!Incoming.len)
return (-1);
- for (i = 0; i < Incoming->length; i++) {
- mailbox = (BUFFY*) Incoming->data[i];
+ for (i = 0; i < Incoming.len; i++) {
+ mailbox = Incoming.arr[i];
if (!m_strncmp(dest, mailbox->path, matchlen)) {
if (rc) {
m_strcpy(dest, len, mailbox->path);
noinst_LIBRARIES = liblib.a
liblib_a_SOURCES = lib-lib.h mem.h \
- str.h buffer.h hash.h list.h file.h mapping.h date.h rx.h url.h \
- str.c buffer.c hash.c list.c file.c mapping.c date.c rx.c url.c
+ str.h buffer.h hash.h array.h list.h file.h mapping.h date.h rx.h url.h \
+ str.c buffer.c hash.c array.c list.c file.c mapping.c date.c rx.c url.c
noinst_HEADERS = lib-lib.h mem.h \
- str.h buffer.h hash.h list.h file.h mapping.h date.h rx.h url.h
+ str.h buffer.h hash.h array.h list.h file.h mapping.h date.h rx.h url.h
-include ../cflags.mk
/* }}} */
#include "mem.h"
-
#include "str.h"
+
+#include "array.h"
#include "buffer.h"
#include "date.h"
#include "file.h"
/* computes first entry to be shown */
static void calc_boundaries (void) {
- if (list_empty(Incoming))
+ if (!Incoming.len)
return;
- if (CurBuffy < 0 || CurBuffy >= Incoming->length)
+ if (CurBuffy < 0 || CurBuffy >= Incoming.len)
CurBuffy = 0;
- if (TopBuffy < 0 || TopBuffy >= Incoming->length)
+ if (TopBuffy < 0 || TopBuffy >= Incoming.len)
TopBuffy = 0;
if (option (OPTSIDEBARNEWMAILONLY)) {
int i = CurBuffy;
TopBuffy = CurBuffy - 1;
while (i >= 0) {
- if (((BUFFY*) Incoming->data[i])->new > 0)
+ if (Incoming.arr[i]->new > 0)
TopBuffy = i;
i--;
}
const char* ifstr, const char* elstr,
unsigned long data, format_flag flags) {
char tmp[SHORT_STRING];
- BUFFY* b = (BUFFY*) Incoming->data[data];
+ BUFFY* b = Incoming.arr[data];
int opt = flags & M_FORMAT_OPTIONAL;
int c = Context && !m_strcmp(Context->path, b->path);
SidebarWidth = COLS;
if (option (OPTSIDEBARNEWMAILONLY) && sbox && Context && Context->path &&
- m_strcmp(Context->path, sbox) && ((BUFFY*) Incoming->data[idx])->new == 0)
+ m_strcmp(Context->path, sbox) && Incoming.arr[idx]->new == 0)
/* if $sidebar_newmail_only is set, don't display the
* box only if it's not the currently opened
* (i.e. always display the currently opened) */
* selected folder for <sidebar-open>
*/
const char* sidebar_get_current (void) {
- if (list_empty(Incoming))
+ if (!Incoming.len)
return (NULL);
- return ((char*) ((BUFFY*) Incoming->data[CurBuffy])->path);
+ return Incoming.arr[CurBuffy]->path;
}
/* internally sets item to buf */
void sidebar_set_buffystats (CONTEXT* curContext) {
int i = 0;
BUFFY* tmp = NULL;
- if (!curContext || list_empty(Incoming) || (i = buffy_lookup (curContext->path)) < 0)
+ if (!curContext || !Incoming.len || (i = buffy_lookup (curContext->path)) < 0)
return;
- tmp = Incoming->data[i];
+ tmp = Incoming.arr[i];
tmp->new = curContext->new;
tmp->msg_unread = curContext->unread;
tmp->msgcount = curContext->msgcount;
sidebar_draw_frames();
- if (list_empty(Incoming))
+ if (!Incoming.len)
return 0;
/* actually print items */
- for (i = TopBuffy, line=first_line; i < Incoming->length && line < last_line; i++) {
- tmp = (BUFFY*) Incoming->data[i];
+ for (i = TopBuffy, line=first_line; i < Incoming.len && line < last_line; i++) {
+ tmp = Incoming.arr[i];
if (i == CurBuffy)
SETCOLOR (MT_COLOR_INDICATOR);
/* returns index of new item with new mail or -1 */
static int exist_next_new () {
int i = 0;
- if (list_empty(Incoming))
+ if (!Incoming.len)
return (-1);
i = CurBuffy + 1;
- while (i < Incoming->length)
- if (((BUFFY*) Incoming->data[i++])->new > 0)
+ while (i < Incoming.len)
+ if (Incoming.arr[i++]->new > 0)
return (i-1);
return (-1);
}
/* returns index of prev item with new mail or -1 */
static int exist_prev_new () {
int i = 0;
- if (list_empty(Incoming))
+ if (!Incoming.len)
return (-1);
i = CurBuffy - 1;
while (i >= 0)
- if (((BUFFY*) Incoming->data[i--])->new > 0)
+ if (Incoming.arr[i--]->new > 0)
return (i+1);
return (-1);
}
void sidebar_scroll (int op) {
int i = 0;
- if (!SidebarWidth || list_empty(Incoming))
+ if (!SidebarWidth || !Incoming.len)
return;
switch (op) {
case OP_SIDEBAR_NEXT:
if (!option (OPTSIDEBARNEWMAILONLY)) {
- if (CurBuffy + 1 == Incoming->length) {
+ if (CurBuffy + 1 == Incoming.len) {
mutt_error (_("You are on the last mailbox."));
return;
}
CurBuffy = 0;
break;
case OP_SIDEBAR_SCROLL_DOWN:
- if (CurBuffy + 1 == Incoming->length) {
+ if (CurBuffy + 1 == Incoming.len) {
mutt_error (_("You are on the last mailbox."));
return;
}
CurBuffy += known_lines;
- if (CurBuffy >= Incoming->length)
- CurBuffy = Incoming->length - 1;
+ if (CurBuffy >= Incoming.len)
+ CurBuffy = Incoming.len - 1;
break;
default:
return;
+++ /dev/null
-## Process this file with automake to produce Makefile.in
-
-AR=@AR@
-
-AUTOMAKE_OPTIONS = foreign
-
-noinst_LIBRARIES = libsane.a
-noinst_HEADERS = list.h
-
-libsane_a_SOURCES = list.c list.h
-
--include ../cflags.mk
+++ /dev/null
-/*
- * written for mutt-ng by:
- * Rocco Rutte <pdmef@cs.tu-berlin.de>
- *
- * 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.
- */
-
-#include <lib-lib/lib-lib.h>
-#include "list.h"
-
-list2_t* list_new (void) {
- return p_new(list2_t, 1);
-}
-
-void list_del (list2_t** l, list_del_t* del) {
- ssize_t i = 0;
- if (!l || !*l)
- return;
- if (del)
- for (i = 0; i < (*l)->length; i++)
- del (&(*l)->data[i]);
- p_delete(&(*l)->data);
- p_delete(l);
-}
-
-void list_push_back (list2_t** l, void* p) {
- if (!*l)
- *l = list_new ();
- p_realloc(&(*l)->data, ++(*l)->length);
- (*l)->data[(*l)->length-1] = p;
-}
-
-void list_push_front (list2_t** l, void* p) {
- if (!*l)
- *l = list_new ();
- p_realloc(&(*l)->data, ++(*l)->length);
- if ((*l)->length > 1)
- memmove (&(*l)->data[1], &(*l)->data[0], ((*l)->length-1)*sizeof(void*));
- (*l)->data[0] = p;
-}
-
-void* list_pop_back (list2_t* l) {
- void* p = NULL;
- if (list_empty(l))
- return (NULL);
- p = l->data[l->length-1];
- p_realloc(&l->data, --(l->length));
- return (p);
-}
-
-void* list_pop_front (list2_t* l) {
- void* p = NULL;
- if (list_empty(l))
- return (NULL);
- p = l->data[0];
- memmove (&l->data[0], &l->data[1], (--(l->length))*sizeof(void*));
- p_realloc(&l->data, l->length);
- return (p);
-}
-
-void* list_pop_idx (list2_t* l, int c) {
- void* p = NULL;
- if (list_empty(l) || c < 0 || c >= l->length)
- return (NULL);
- if (c == l->length-1)
- return (list_pop_back (l));
- p = l->data[c];
- memmove (&l->data[c], &l->data[c+1], (l->length-c)*sizeof(void*));
- p_realloc(&l->data, --(l->length));
- return (p);
-}
-
-list2_t *list_cpy(list2_t *l) {
- list2_t* ret = NULL;
- if (list_empty(l))
- return NULL;
- ret = list_new();
- ret->length = l->length;
- ret->data = p_dup(l->data, l->length);
- return ret;
-}
-
-list2_t* list_dup (list2_t* l, void* (*dup_f) (void*)) {
- list2_t* ret = NULL;
- int i = 0;
- if (list_empty(l) || !*dup_f)
- return (NULL);
- ret = list_new ();
- ret->length = l->length;
- ret->data = p_new(void*, l->length);
- for (i = 0; i < l->length; i++)
- ret->data[i] = dup_f (l->data[i]);
- return (ret);
-}
-
-int list_lookup (list2_t* l, int (*cmp) (const void*, const void*), const void* p) {
- int i = 0;
- if (list_empty(l) || !*cmp)
- return (-1);
- for (i = 0; i < l->length; i++)
- if (cmp (l->data[i], p) == 0)
- return (i);
- return (-1);
-}
-
-list2_t* list_from_str (const char* str, const char* delim) {
- list2_t* ret = NULL;
- char* tmp = NULL, *p = NULL;
-
- if (!str || !*str || !delim || !*delim)
- return (NULL);
-
- tmp = m_strdup(str);
- for (p = strtok (tmp, delim); p; p = strtok (NULL, delim)) {
- list_push_back (&ret, m_strdup(p));
- }
- p_delete(&tmp);
- return (ret);
-}
-
+++ /dev/null
-/*
- * written for mutt-ng by:
- * Rocco Rutte <pdmef@cs.tu-berlin.de>
- *
- * 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.
- */
-
-/*
- * this aims to provide a generic list
- * implementation using arrays only
- * mostly untested
- */
-
-#ifndef _LIB_LIST_H
-#define _LIB_LIST_H
-
-typedef struct list2_t {
- void** data;
- ssize_t length;
-} list2_t;
-
-/*
- * basics
- */
-
-list2_t* list_new (void);
-
-typedef void list_del_t (void**);
-
-/* free() all memory used by list and optionally
- * use del function to free() items as well */
-void list_del (list2_t**, list_del_t* del);
-
-#define list_empty(l) (!l || l->length == 0 || !l->data)
-
-/*
- * insertion, removal
- * the list_push_* functions create a list if empty so far
- * for convenience
- */
-void list_push_back (list2_t**, void*);
-void list_push_front (list2_t**, void*);
-void* list_pop_back (list2_t*);
-void* list_pop_front (list2_t*);
-void* list_pop_idx (list2_t*, int);
-
-/*
- * copying
- */
-
-/* plain copy */
-list2_t* list_cpy (list2_t*);
-/* "hard copy" using callback to copy items */
-list2_t* list_dup (list2_t*, void* (*dup) (void*));
-
-/*
- * misc
- */
-
-/* looks up item in list using callback function and comparison item
- * return:
- * -1 if not found
- * index in data array otherwise
- * the callback must return 0 on equality
- */
-typedef int list_lookup_t (const void*, const void*);
-int list_lookup (list2_t*, list_lookup_t* cmp, const void*);
-
-/*
- * dumb-splits string at boundary characters into list
- */
-list2_t* list_from_str (const char* str, const char* delim);
-
-#endif /* !_LIB_LIST_H */
}
else
#endif
- if (!Incoming) {
+ if (!Incoming.len) {
mutt_endwin _("No incoming mailboxes defined.");
exit (1);
CONTEXT* ctx = NULL;
BUFFY* b = NULL;
- if (list_empty(Incoming)) {
+ if (!Incoming.len) {
mutt_error (_("No mailboxes defined."));
return (1);
}
- for (i = 0; i < Incoming->length; i++) {
- b = (BUFFY*) Incoming->data[i];
+ for (i = 0; i < Incoming.len; i++) {
+ b = Incoming.arr[i];
magic = mx_get_magic (b->path);
if (magic != M_MAILDIR && magic != M_MH && magic != M_IMAP)
continue;
BUFFY* tmp = NULL;
char buf[STRING];
- if (list_empty (Incoming))
+ if (!Incoming.len)
return;
/* unfortunately, NNTP_DATA::group only is the plain
if ((i = buffy_lookup (buf)) < 0)
return;
- tmp = (BUFFY*) Incoming->data[i];
+ tmp = Incoming.arr[i];
/* copied from browser.c */
if (option (OPTMARKOLD) &&
data->lastCached >= data->firstMessage &&