{
struct Body *choice = NULL;
struct Body *b = NULL;
- struct List *t = NULL;
int type = 0;
bool mustfree = false;
int rc = 0;
a = b;
/* First, search list of preferred types */
- t = AlternativeOrderList;
- while (t && !choice)
+ struct STailQNode *np;
+ STAILQ_FOREACH(np, &AlternativeOrderList, entries)
{
char *c = NULL;
int btlen; /* length of basetype */
bool wild; /* do we have a wildcard to match all subtypes? */
- c = strchr(t->data, '/');
+ c = strchr(np->data, '/');
if (c)
{
wild = (c[1] == '*' && c[2] == 0);
- btlen = c - t->data;
+ btlen = c - np->data;
}
else
{
wild = true;
- btlen = mutt_strlen(t->data);
+ btlen = mutt_strlen(np->data);
}
if (a->parts)
while (b)
{
const char *bt = TYPE(b);
- if ((mutt_strncasecmp(bt, t->data, btlen) == 0) && (bt[btlen] == 0))
+ if ((mutt_strncasecmp(bt, np->data, btlen) == 0) && (bt[btlen] == 0))
{
/* the basetype matches */
- if (wild || (mutt_strcasecmp(t->data + btlen + 1, b->subtype) == 0))
+ if (wild || (mutt_strcasecmp(np->data + btlen + 1, b->subtype) == 0))
{
choice = b;
}
}
b = b->next;
}
- t = t->next;
+
+ if (choice)
+ break;
}
/* Next, look for an autoviewable type */
}
static int parse_attach_list(struct Buffer *buf, struct Buffer *s,
- struct List **ldata, struct Buffer *err)
+ struct STailQHead *head, struct Buffer *err)
{
struct AttachMatch *a = NULL;
- struct List *listp = NULL, *lastp = NULL;
char *p = NULL;
char *tmpminor = NULL;
int len;
int ret;
- /* Find the last item in the list that data points to. */
- lastp = NULL;
- mutt_debug(5, "parse_attach_list: ldata = %p, *ldata = %p\n", (void *) ldata,
- (void *) *ldata);
- for (listp = *ldata; listp; listp = listp->next)
- {
- a = (struct AttachMatch *) listp->data;
- mutt_debug(5, "parse_attach_list: skipping %s/%s\n", a->major, a->minor);
- lastp = listp;
- }
-
do
{
mutt_extract_token(buf, s, 0);
mutt_debug(5, "parse_attach_list: added %s/%s [%d]\n", a->major, a->minor, a->major_int);
- listp = safe_malloc(sizeof(struct List));
- listp->data = (char *) a;
- listp->next = NULL;
- if (lastp)
- {
- lastp->next = listp;
- }
- else
- {
- *ldata = listp;
- }
- lastp = listp;
+ mutt_stailq_insert_tail(head, (char *)a);
} while (MoreArgs(s));
_attachments_clean();
}
static int parse_unattach_list(struct Buffer *buf, struct Buffer *s,
- struct List **ldata, struct Buffer *err)
+ struct STailQHead *head, struct Buffer *err)
{
struct AttachMatch *a = NULL;
- struct List *lp = NULL, *lastp = NULL, *newlp = NULL;
char *tmp = NULL;
int major;
char *minor = NULL;
}
major = mutt_check_mime_type(tmp);
- /* We must do our own walk here because remove_from_list() will only
- * remove the List->data, not anything pointed to by the List->data. */
- lastp = NULL;
- for (lp = *ldata; lp;)
+ struct STailQNode *np, *tmp2;
+ STAILQ_FOREACH_SAFE(np, head, entries, tmp2)
{
- a = (struct AttachMatch *) lp->data;
+ a = (struct AttachMatch *) np->data;
mutt_debug(5, "parse_unattach_list: check %s/%s [%d] : %s/%s [%d]\n",
a->major, a->minor, a->major_int, tmp, minor, major);
if (a->major_int == major && (mutt_strcasecmp(minor, a->minor) == 0))
a->minor, a->major_int);
regfree(&a->minor_rx);
FREE(&a->major);
-
- /* Relink backward */
- if (lastp)
- lastp->next = lp->next;
- else
- *ldata = lp->next;
-
- newlp = lp->next;
- FREE(&lp->data); /* same as a */
- FREE(&lp);
- lp = newlp;
- continue;
+ STAILQ_REMOVE(head, np, STailQNode, entries);
+ FREE(&np->data);
+ FREE(&np);
}
-
- lastp = lp;
- lp = lp->next;
}
} while (MoreArgs(s));
return 0;
}
-static int print_attach_list(struct List *lp, char op, char *name)
+static int print_attach_list(struct STailQHead *h, char op, char *name)
{
- while (lp)
+ struct STailQNode *np;
+ STAILQ_FOREACH(np, h, entries)
{
printf("attachments %c%s %s/%s\n", op, name,
- ((struct AttachMatch *) lp->data)->major,
- ((struct AttachMatch *) lp->data)->minor);
- lp = lp->next;
+ ((struct AttachMatch *) np->data)->major,
+ ((struct AttachMatch *) np->data)->minor);
}
return 0;
unsigned long data, struct Buffer *err)
{
char op, *category = NULL;
- struct List **listp = NULL;
+ struct STailQHead *headp = NULL;
mutt_extract_token(buf, s, 0);
if (!buf->data || *buf->data == '\0')
mutt_endwin(NULL);
fflush(stdout);
printf(_("\nCurrent attachments settings:\n\n"));
- print_attach_list(AttachAllow, '+', "A");
- print_attach_list(AttachExclude, '-', "A");
- print_attach_list(InlineAllow, '+', "I");
- print_attach_list(InlineExclude, '-', "I");
+ print_attach_list(&AttachAllow, '+', "A");
+ print_attach_list(&AttachExclude, '-', "A");
+ print_attach_list(&InlineAllow, '+', "I");
+ print_attach_list(&InlineExclude, '-', "I");
mutt_any_key_to_continue(NULL);
return 0;
}
if (mutt_strncasecmp(category, "attachment", strlen(category)) == 0)
{
if (op == '+')
- listp = &AttachAllow;
+ headp = &AttachAllow;
else
- listp = &AttachExclude;
+ headp = &AttachExclude;
}
else if (mutt_strncasecmp(category, "inline", strlen(category)) == 0)
{
if (op == '+')
- listp = &InlineAllow;
+ headp = &InlineAllow;
else
- listp = &InlineExclude;
+ headp = &InlineExclude;
}
else
{
return -1;
}
- return parse_attach_list(buf, s, listp, err);
+ return parse_attach_list(buf, s, headp, err);
}
static int parse_unattachments(struct Buffer *buf, struct Buffer *s,
unsigned long data, struct Buffer *err)
{
char op, *p = NULL;
- struct List **listp = NULL;
+ struct STailQHead *head = NULL;
mutt_extract_token(buf, s, 0);
if (!buf->data || *buf->data == '\0')
if (mutt_strncasecmp(p, "attachment", strlen(p)) == 0)
{
if (op == '+')
- listp = &AttachAllow;
+ head = &AttachAllow;
else
- listp = &AttachExclude;
+ head = &AttachExclude;
}
else if (mutt_strncasecmp(p, "inline", strlen(p)) == 0)
{
if (op == '+')
- listp = &InlineAllow;
+ head = &InlineAllow;
else
- listp = &InlineExclude;
+ head = &InlineExclude;
}
else
{
return -1;
}
- return parse_unattach_list(buf, s, listp, err);
+ return parse_unattach_list(buf, s, head, err);
}
static int parse_unlists(struct Buffer *buf, struct Buffer *s,
{ "attachments", parse_attachments, 0 },
{ "unattachments",parse_unattachments,0 },
{ "auto_view", parse_stailq, UL &AutoViewList },
- { "alternative_order", parse_list, UL &AlternativeOrderList },
+ { "alternative_order",parse_stailq, UL &AlternativeOrderList },
{ "bind", mutt_parse_bind, 0 },
{ "charset-hook", mutt_parse_hook, MUTT_CHARSETHOOK },
#ifdef HAVE_COLOR
{ "timeout-hook", mutt_parse_hook, MUTT_TIMEOUTHOOK | MUTT_GLOBALHOOK },
{ "toggle", parse_set, MUTT_SET_INV },
{ "unalias", parse_unalias, 0 },
- { "unalternative_order",parse_unlist, UL &AlternativeOrderList },
+ { "unalternative_order",parse_unstailq, UL &AlternativeOrderList },
{ "unauto_view", parse_unstailq, UL &AutoViewList },
{ "unhdr_order", parse_unlist, UL &HeaderOrderList },
{ "unhook", mutt_parse_unhook, 0 },
/**
* count_body_parts_check - Compares mime types to the ok and except lists
*/
-static bool count_body_parts_check(struct List **checklist, struct Body *b, bool dflt)
+static bool count_body_parts_check(struct STailQHead *checklist, struct Body *b, bool dflt)
{
- struct List *type = NULL;
struct AttachMatch *a = NULL;
/* If list is null, use default behavior. */
- if (!*checklist)
+ if (!checklist || STAILQ_EMPTY(checklist))
{
return false;
}
- for (type = *checklist; type; type = type->next)
+ struct STailQNode *np;
+ STAILQ_FOREACH(np, checklist, entries)
{
- a = (struct AttachMatch *) type->data;
+ a = (struct AttachMatch *) np->data;
mutt_debug(5, "cbpc: %s %d/%s ?? %s/%s [%d]... ",
dflt ? "[OK] " : "[EXCL] ", b->type,
b->subtype ? b->subtype : "*", a->major, a->minor, a->major_int);
else
mutt_parse_mime_message(ctx, hdr);
- if (AttachAllow || AttachExclude || InlineAllow || InlineExclude)
+ if (!STAILQ_EMPTY(&AttachAllow) || !STAILQ_EMPTY(&AttachExclude) ||
+ !STAILQ_EMPTY(&InlineAllow) || !STAILQ_EMPTY(&InlineExclude))
+ {
hdr->attach_total = count_body_parts(hdr->content, MUTT_PARTS_TOPLEVEL);
+ }
else
hdr->attach_total = 0;