summaryrefslogtreecommitdiffstats
path: root/remailer.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>1999-01-29 11:05:38 +0000
committerThomas Roessler <roessler@does-not-exist.org>1999-01-29 11:05:38 +0000
commit61811193b3bc96b70f1ad68c143387bb290d7ca9 (patch)
tree75dec20238aca52e63d56138be3a32dbfcf33aea /remailer.c
parent2973c48ed199b7f88505f1d72557ab2d2b0057d5 (diff)
Use a user-definable format for the mixmaster menu.
Diffstat (limited to 'remailer.c')
-rw-r--r--remailer.c80
1 files changed, 75 insertions, 5 deletions
diff --git a/remailer.c b/remailer.c
index dd17a4fd..df9a46f5 100644
--- a/remailer.c
+++ b/remailer.c
@@ -109,6 +109,7 @@ static void mix_add_entry (REMAILER ***type2_list, REMAILER *entry,
}
(*type2_list)[(*used)++] = entry;
+ if (entry) entry->num = *used;
}
static REMAILER *mix_new_remailer (void)
@@ -364,15 +365,84 @@ static const char *mix_format_caps (REMAILER *r)
return capbuff;
}
-
+
+/*
+ * Format an entry for the remailer menu.
+ *
+ * %n number
+ * %c capabilities
+ * %s short name
+ * %a address
+ *
+ */
+
+static const char *mix_entry_fmt (char *dest,
+ size_t destlen,
+ char op,
+ const char *src,
+ const char *prefix,
+ const char *ifstring,
+ const char *elsestring,
+ unsigned long data,
+ format_flag flags)
+{
+ char fmt[16];
+ REMAILER *remailer = (REMAILER *) data;
+ int optional = (flags & M_FORMAT_OPTIONAL);
+
+ switch (op)
+ {
+ case 'n':
+ if (!optional)
+ {
+ snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+ snprintf (dest, destlen, fmt, remailer->num);
+ }
+ break;
+ case 'c':
+ if (!optional)
+ {
+ snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+ snprintf (dest, destlen, fmt, mix_format_caps(remailer));
+ }
+ break;
+ case 's':
+ if (!optional)
+ {
+ snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+ snprintf (dest, destlen, fmt, NONULL(remailer->shortname));
+ }
+ else if (!remailer->shortname)
+ optional = 0;
+ break;
+ case 'a':
+ if (!optional)
+ {
+ snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+ snprintf (dest, destlen, fmt, NONULL(remailer->addr));
+ }
+ else if (!remailer->addr)
+ optional = 0;
+ break;
+
+ default:
+ *dest = '\0';
+ }
+
+ if (optional)
+ mutt_FormatString (dest, destlen, ifstring, mutt_attach_fmt, data, 0);
+ else if (flags & M_FORMAT_OPTIONAL)
+ mutt_FormatString (dest, destlen, elsestring, mutt_attach_fmt, data, 0);
+ return (src);
+}
+
+
static void mix_entry (char *b, size_t blen, MUTTMENU *menu, int num)
{
REMAILER **type2_list = (REMAILER **) menu->data;
- snprintf (b, blen, "%4d %s %-16s %s",
- num + 1, mix_format_caps (type2_list[num]),
- NONULL (type2_list[num]->shortname),
- NONULL (type2_list[num]->addr));
+ mutt_FormatString (b, blen, NONULL (MixEntryFormat), mix_entry_fmt,
+ (unsigned long) type2_list[num], M_FORMAT_ARROWCURSOR);
}
static int mix_search (MUTTMENU *m, regex_t *re, int n)