static void alias_entry(char *s, size_t slen, struct Menu *m, int num)
{
- mutt_FormatString(s, slen, 0, MuttIndexWindow->cols, NONULL(AliasFmt), alias_format_str,
+ mutt_expando_format(s, slen, 0, MuttIndexWindow->cols, NONULL(AliasFmt), alias_format_str,
(unsigned long) ((struct Alias **) m->data)[num],
MUTT_FORMAT_ARROWCURSOR);
}
}
if (optional)
- mutt_FormatString(dest, destlen, col, cols, ifstring, folder_format_str, data, 0);
+ mutt_expando_format(dest, destlen, col, cols, ifstring, folder_format_str, data, 0);
else if (flags & MUTT_FORMAT_OPTIONAL)
- mutt_FormatString(dest, destlen, col, cols, elsestring, folder_format_str, data, 0);
+ mutt_expando_format(dest, destlen, col, cols, elsestring, folder_format_str, data, 0);
return src;
}
if (flags & MUTT_FORMAT_OPTIONAL)
{
if (folder->ff->nd->unread != 0)
- mutt_FormatString(dest, destlen, col, cols, ifstring,
+ mutt_expando_format(dest, destlen, col, cols, ifstring,
newsgroup_format_str, data, flags);
else
- mutt_FormatString(dest, destlen, col, cols, elsestring,
+ mutt_expando_format(dest, destlen, col, cols, elsestring,
newsgroup_format_str, data, flags);
}
else if (Context && Context->data == folder->ff->nd)
#ifdef USE_NNTP
if (option(OPTNEWS))
- mutt_FormatString(s, slen, 0, MuttIndexWindow->cols, NONULL(GroupFormat), newsgroup_format_str,
+ mutt_expando_format(s, slen, 0, MuttIndexWindow->cols, NONULL(GroupFormat), newsgroup_format_str,
(unsigned long) &folder, MUTT_FORMAT_ARROWCURSOR);
else
#endif
- mutt_FormatString(s, slen, 0, MuttIndexWindow->cols, NONULL(FolderFormat),
+ mutt_expando_format(s, slen, 0, MuttIndexWindow->cols, NONULL(FolderFormat),
folder_format_str, (unsigned long) &folder, MUTT_FORMAT_ARROWCURSOR);
}
folder.ff = &((struct FolderFile *) menu->data)[num];
folder.num = num;
- mutt_FormatString(s, slen, 0, MuttIndexWindow->cols, NONULL(VirtFolderFormat),
+ mutt_expando_format(s, slen, 0, MuttIndexWindow->cols, NONULL(VirtFolderFormat),
folder_format_str, (unsigned long) &folder, MUTT_FORMAT_ARROWCURSOR);
}
#endif
if (mutt_strwidth(prompt) > MuttMessageWindow->cols - extra_space)
{
- mutt_format_string(prompt, sizeof(prompt), 0, MuttMessageWindow->cols - extra_space,
+ mutt_simple_format(prompt, sizeof(prompt), 0, MuttMessageWindow->cols - extra_space,
FMT_LEFT, 0, scratch, sizeof(scratch), 0);
safe_strcat(prompt, sizeof(prompt), "...?");
}
static void snd_entry(char *b, size_t blen, struct Menu *menu, int num)
{
- mutt_FormatString(b, blen, 0, MuttIndexWindow->cols, NONULL(AttachFormat), mutt_attach_fmt,
+ mutt_expando_format(b, blen, 0, MuttIndexWindow->cols, NONULL(AttachFormat), mutt_attach_fmt,
(unsigned long) (((struct AttachPtr **) menu->data)[num]),
MUTT_FORMAT_STAT_FILE | MUTT_FORMAT_ARROWCURSOR);
}
static void compose_status_line(char *buf, size_t buflen, size_t col, int cols,
struct Menu *menu, const char *p)
{
- mutt_FormatString(buf, buflen, col, cols, p, compose_format_str, (unsigned long) menu, 0);
+ mutt_expando_format(buf, buflen, col, cols, p, compose_format_str, (unsigned long) menu, 0);
}
/**
* @param flags Format flags, UNUSED
* @return src (unchanged)
*
- * cb_format_str is a callback function for mutt_FormatString. It understands
+ * cb_format_str is a callback function for mutt_expando_format. It understands
* two operators. '%f' : 'from' filename, '%t' : 'to' filename.
*/
static const char *cb_format_str(char *dest, size_t destlen, size_t col, int cols,
* @param buflen Size of the buffer
*
* This function takes a hook command and expands the filename placeholders
- * within it. The function calls mutt_FormatString() to do the replacement
+ * within it. The function calls mutt_expando_format() to do the replacement
* which calls our callback function cb_format_str(). e.g.
*
* Template command:
if (!ctx || !cmd || !buf)
return;
- mutt_FormatString(buf, buflen, 0, buflen, cmd, cb_format_str, (unsigned long) ctx, 0);
+ mutt_expando_format(buf, buflen, 0, buflen, cmd, cb_format_str, (unsigned long) ctx, 0);
}
/**
vsnprintf(scratch, sizeof(scratch), fmt, ap);
mutt_debug(1, "%s\n", scratch);
- mutt_format_string(Errorbuf, sizeof(Errorbuf), 0, MuttMessageWindow->cols,
+ mutt_simple_format(Errorbuf, sizeof(Errorbuf), 0, MuttMessageWindow->cols,
FMT_LEFT, 0, scratch, sizeof(scratch), 0);
if (!option(OPTKEEPQUIET))
l = mutt_strwidth(buf);
va_end(ap);
- mutt_format_string(buf2, sizeof(buf2), 0, COLS - 2, FMT_LEFT, 0, buf, sizeof(buf), 0);
+ mutt_simple_format(buf2, sizeof(buf2), 0, COLS - 2, FMT_LEFT, 0, buf, sizeof(buf), 0);
move(LINES - 1, 0);
* min_width, max_width, s), except that the widths refer to the number of
* character cells when printed.
*/
-void mutt_format_string(char *dest, size_t destlen, int min_width, int max_width,
+void mutt_simple_format(char *dest, size_t destlen, int min_width, int max_width,
int justify, char m_pad_char, const char *s, size_t n, int arboreal)
{
char *p = NULL;
max_width = INT_MAX;
}
- mutt_format_string(dest, destlen, min_width, max_width, justify, ' ', s,
+ mutt_simple_format(dest, destlen, min_width, max_width, justify, ' ', s,
mutt_strlen(s), arboreal);
}
#include <stddef.h>
/**
- * enum FormatFlag - Control the behaviour of mutt_FormatString()
+ * enum FormatFlag - Control the behaviour of mutt_expando_format()
*/
enum FormatFlag
{
const char *ifstring, const char *elsestring,
unsigned long data, enum FormatFlag flags);
-void mutt_FormatString(char *dest, /* output buffer */
+void mutt_expando_format(char *dest, /* output buffer */
size_t destlen, /* output buffer len */
size_t col, /* starting column (nonzero when called recursively) */
int cols, /* maximum columns */
}
if (optional)
- mutt_FormatString(dest, destlen, col, cols, ifstring, hdr_format_str,
+ mutt_expando_format(dest, destlen, col, cols, ifstring, hdr_format_str,
(unsigned long) hfi, flags);
else if (flags & MUTT_FORMAT_OPTIONAL)
- mutt_FormatString(dest, destlen, col, cols, elsestring, hdr_format_str,
+ mutt_expando_format(dest, destlen, col, cols, elsestring, hdr_format_str,
(unsigned long) hfi, flags);
return src;
hfi.ctx = ctx;
hfi.pager_progress = 0;
- mutt_FormatString(dest, destlen, 0, MuttIndexWindow->cols, s, hdr_format_str,
+ mutt_expando_format(dest, destlen, 0, MuttIndexWindow->cols, s, hdr_format_str,
(unsigned long) &hfi, flags);
}
void mutt_make_string_info(char *dst, size_t dstlen, int cols, const char *s,
struct HdrFormatInfo *hfi, enum FormatFlag flags)
{
- mutt_FormatString(dst, dstlen, 0, cols, s, hdr_format_str, (unsigned long) hfi, flags);
+ mutt_expando_format(dst, dstlen, 0, cols, s, hdr_format_str, (unsigned long) hfi, flags);
}
* definition, it obviously won't produce a correct result. */
#define mutt_array_size(x) (sizeof(x) / sizeof((x)[0]))
-/* For mutt_format_string() justifications */
+/* For mutt_simple_format() justifications */
/* Making left 0 and center -1 is of course completely nonsensical, but
- * it retains compatibility for any patches that call mutt_format_string.
+ * it retains compatibility for any patches that call mutt_simple_format.
* Once patches are updated to use FMT_*, these can be made sane. */
#define FMT_LEFT 0
#define FMT_RIGHT 1
int shift = option(OPTARROWCURSOR) ? 3 : 0;
int cols = menu->indexwin->cols - shift;
- mutt_format_string(s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen(scratch), 1);
+ mutt_simple_format(s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen(scratch), 1);
s[n - 1] = 0;
FREE(&scratch);
}
/**
- * mutt_FormatString - Expand expandos (%x) in a string
+ * mutt_expando_format - Expand expandos (%x) in a string
* @param dest output buffer
* @param destlen output buffer len
* @param col starting column (nonzero when called recursively)
* @param data callback data
* @param flags callback flags
*/
-void mutt_FormatString(char *dest, size_t destlen, size_t col, int cols, const char *src,
- format_t *callback, unsigned long data, enum FormatFlag flags)
+void mutt_expando_format(char *dest, size_t destlen, size_t col, int cols,
+ const char *src, format_t *callback,
+ unsigned long data, enum FormatFlag flags)
{
char prefix[SHORT_STRING], buf[LONG_STRING], *cp = NULL, *wptr = dest, ch;
char ifstring[SHORT_STRING], elsestring[SHORT_STRING];
mutt_extract_token(word, srcbuf, 0);
mutt_debug(3, "fmtpipe %2d: %s\n", i++, word->data);
mutt_buffer_addch(command, '\'');
- mutt_FormatString(buf, sizeof(buf), 0, cols, word->data, callback, data,
+ mutt_expando_format(buf, sizeof(buf), 0, cols, word->data, callback, data,
flags | MUTT_FORMAT_NOFILTER);
for (p = buf; p && *p; p++)
{
/* If the result ends with '%', this indicates that the filter
* generated %-tokens that mutt can expand. Eliminate the '%'
- * marker and recycle the string through mutt_FormatString().
+ * marker and recycle the string through mutt_expando_format().
* To literally end with "%", use "%%". */
if ((n > 0) && dest[n - 1] == '%')
{
* it back for the recursive call since the expansion of
* format pipes does not try to append a nul itself.
*/
- mutt_FormatString(dest, destlen + 1, col, cols, recycler,
+ mutt_expando_format(dest, destlen + 1, col, cols, recycler,
callback, data, flags);
FREE(&recycler);
}
int pad;
/* get contents after padding */
- mutt_FormatString(buf, sizeof(buf), 0, cols, src + pl, callback, data, flags);
+ mutt_expando_format(buf, sizeof(buf), 0, cols, src + pl, callback, data, flags);
len = mutt_strlen(buf);
wid = mutt_strwidth(buf);
}
if (optional)
- mutt_FormatString(dest, destlen, col, cols, ifstring, mutt_attach_fmt, data, 0);
+ mutt_expando_format(dest, destlen, col, cols, ifstring, mutt_attach_fmt, data, 0);
else if (flags & MUTT_FORMAT_OPTIONAL)
- mutt_FormatString(dest, destlen, col, cols, elsestring, mutt_attach_fmt, data, 0);
+ mutt_expando_format(dest, destlen, col, cols, elsestring, mutt_attach_fmt, data, 0);
return src;
}
entry.key = key_table[num];
entry.num = num + 1;
- mutt_FormatString(s, l, 0, MuttIndexWindow->cols, NONULL(PgpEntryFormat),
+ mutt_expando_format(s, l, 0, MuttIndexWindow->cols, NONULL(PgpEntryFormat),
crypt_entry_fmt, (unsigned long) &entry, MUTT_FORMAT_ARROWCURSOR);
}
}
if (optional)
- mutt_FormatString(dest, destlen, col, cols, ifstring, _mutt_fmt_pgp_command, data, 0);
+ mutt_expando_format(dest, destlen, col, cols, ifstring, _mutt_fmt_pgp_command, data, 0);
else if (flags & MUTT_FORMAT_OPTIONAL)
- mutt_FormatString(dest, destlen, col, cols, elsestring, _mutt_fmt_pgp_command, data, 0);
+ mutt_expando_format(dest, destlen, col, cols, elsestring, _mutt_fmt_pgp_command, data, 0);
return src;
}
static void mutt_pgp_command(char *d, size_t dlen,
struct PgpCommandContext *cctx, const char *fmt)
{
- mutt_FormatString(d, dlen, 0, MuttIndexWindow->cols, NONULL(fmt),
+ mutt_expando_format(d, dlen, 0, MuttIndexWindow->cols, NONULL(fmt),
_mutt_fmt_pgp_command, (unsigned long) cctx, 0);
mutt_debug(2, "mutt_pgp_command: %s\n", d);
}
}
if (optional)
- mutt_FormatString(dest, destlen, col, cols, ifstring, mutt_attach_fmt, data, 0);
+ mutt_expando_format(dest, destlen, col, cols, ifstring, mutt_attach_fmt, data, 0);
else if (flags & MUTT_FORMAT_OPTIONAL)
- mutt_FormatString(dest, destlen, col, cols, elsestring, mutt_attach_fmt, data, 0);
+ mutt_expando_format(dest, destlen, col, cols, elsestring, mutt_attach_fmt, data, 0);
return src;
}
entry.uid = KeyTable[num];
entry.num = num + 1;
- mutt_FormatString(s, l, 0, MuttIndexWindow->cols, NONULL(PgpEntryFormat),
+ mutt_expando_format(s, l, 0, MuttIndexWindow->cols, NONULL(PgpEntryFormat),
pgp_entry_fmt, (unsigned long) &entry, MUTT_FORMAT_ARROWCURSOR);
}
}
if (optional)
- mutt_FormatString(dest, destlen, col, cols, ifstring, _mutt_fmt_smime_command, data, 0);
+ mutt_expando_format(dest, destlen, col, cols, ifstring, _mutt_fmt_smime_command, data, 0);
else if (flags & MUTT_FORMAT_OPTIONAL)
- mutt_FormatString(dest, destlen, col, cols, elsestring,
+ mutt_expando_format(dest, destlen, col, cols, elsestring,
_mutt_fmt_smime_command, data, 0);
return src;
static void smime_command(char *d, size_t dlen,
struct SmimeCommandContext *cctx, const char *fmt)
{
- mutt_FormatString(d, dlen, 0, MuttIndexWindow->cols, NONULL(fmt),
+ mutt_expando_format(d, dlen, 0, MuttIndexWindow->cols, NONULL(fmt),
_mutt_fmt_smime_command, (unsigned long) cctx, 0);
mutt_debug(2, "smime_command: %s\n", d);
}
/* load .newsrc */
if (rc >= 0)
{
- mutt_FormatString(file, sizeof(file), 0, MuttIndexWindow->cols,
+ mutt_expando_format(file, sizeof(file), 0, MuttIndexWindow->cols,
NONULL(NewsRc), nntp_format_str, (unsigned long) nserv, 0);
mutt_expand_path(file, sizeof(file));
nserv->newsrc_file = safe_strdup(file);
void mutt_expand_fmt(char *dest, size_t destlen, const char *fmt, const char *src);
void mutt_fix_reply_recipients(struct Envelope *env);
void mutt_folder_hook(char *path);
-void mutt_format_string(char *dest, size_t destlen, int min_width, int max_width, int justify,
+void mutt_simple_format(char *dest, size_t destlen, int min_width, int max_width, int justify,
char m_pad_char, const char *s, size_t n, int arboreal);
void mutt_format_s(char *dest, size_t destlen, const char *prefix, const char *s);
void mutt_format_s_tree(char *dest, size_t destlen, const char *prefix, const char *s);
}
if (optional)
- mutt_FormatString(dest, destlen, col, cols, ifstring, query_format_str, data, 0);
+ mutt_expando_format(dest, destlen, col, cols, ifstring, query_format_str, data, 0);
else if (flags & MUTT_FORMAT_OPTIONAL)
- mutt_FormatString(dest, destlen, col, cols, elsestring, query_format_str, data, 0);
+ mutt_expando_format(dest, destlen, col, cols, elsestring, query_format_str, data, 0);
return src;
}
struct Entry *entry = &((struct Entry *) m->data)[num];
entry->data->num = num;
- mutt_FormatString(s, slen, 0, MuttIndexWindow->cols, NONULL(QueryFormat),
+ mutt_expando_format(s, slen, 0, MuttIndexWindow->cols, NONULL(QueryFormat),
query_format_str, (unsigned long) entry, MUTT_FORMAT_ARROWCURSOR);
}
}
if (optional)
- mutt_FormatString(dest, destlen, col, cols, ifstring, mutt_attach_fmt, data, 0);
+ mutt_expando_format(dest, destlen, col, cols, ifstring, mutt_attach_fmt, data, 0);
else if (flags & MUTT_FORMAT_OPTIONAL)
- mutt_FormatString(dest, destlen, col, cols, elsestring, mutt_attach_fmt, data, 0);
+ mutt_expando_format(dest, destlen, col, cols, elsestring, mutt_attach_fmt, data, 0);
return src;
}
static void attach_entry(char *b, size_t blen, struct Menu *menu, int num)
{
- mutt_FormatString(b, blen, 0, MuttIndexWindow->cols, NONULL(AttachFormat), mutt_attach_fmt,
+ mutt_expando_format(b, blen, 0, MuttIndexWindow->cols, NONULL(AttachFormat), mutt_attach_fmt,
(unsigned long) (((struct AttachPtr **) menu->data)[num]),
MUTT_FORMAT_ARROWCURSOR);
}
if (mutt_strwidth(prompt) > MuttMessageWindow->cols - extra_space)
{
- mutt_format_string(prompt, sizeof(prompt) - 4, 0, MuttMessageWindow->cols - extra_space,
+ mutt_simple_format(prompt, sizeof(prompt) - 4, 0, MuttMessageWindow->cols - extra_space,
FMT_LEFT, 0, prompt, sizeof(prompt), 0);
safe_strcat(prompt, sizeof(prompt), "...?");
}
}
if (optional)
- mutt_FormatString(dest, destlen, col, cols, ifstring, mutt_attach_fmt, data, 0);
+ mutt_expando_format(dest, destlen, col, cols, ifstring, mutt_attach_fmt, data, 0);
else if (flags & MUTT_FORMAT_OPTIONAL)
- mutt_FormatString(dest, destlen, col, cols, elsestring, mutt_attach_fmt, data, 0);
+ mutt_expando_format(dest, destlen, col, cols, elsestring, mutt_attach_fmt, data, 0);
return src;
}
static void mix_entry(char *b, size_t blen, struct Menu *menu, int num)
{
struct Remailer **type2_list = (struct Remailer **) menu->data;
- mutt_FormatString(b, blen, 0, MuttIndexWindow->cols, NONULL(MixEntryFormat), mix_entry_fmt,
+ mutt_expando_format(b, blen, 0, MuttIndexWindow->cols, NONULL(MixEntryFormat), mix_entry_fmt,
(unsigned long) type2_list[num], MUTT_FORMAT_ARROWCURSOR);
}
{
char cmd[LONG_STRING];
- mutt_FormatString(cmd, sizeof(cmd), 0, MuttIndexWindow->cols, NONULL(Inews),
+ mutt_expando_format(cmd, sizeof(cmd), 0, MuttIndexWindow->cols, NONULL(Inews),
nntp_format_str, 0, 0);
if (!*cmd)
{
* @param flags Format flags, e.g. MUTT_FORMAT_OPTIONAL
* @return src (unchanged)
*
- * cb_format_str is a callback function for mutt_FormatString. It understands
+ * cb_format_str is a callback function for mutt_expando_format. It understands
* six operators. '%B' : Mailbox name, '%F' : Number of flagged messages,
* '%N' : Number of new messages, '%S' : Size (total number of messages),
* '%!' : Icon denoting number of flagged messages.
}
if (optional)
- mutt_FormatString(dest, destlen, col, SidebarWidth, ifstring, cb_format_str,
+ mutt_expando_format(dest, destlen, col, SidebarWidth, ifstring, cb_format_str,
(unsigned long) sbe, flags);
else if (flags & MUTT_FORMAT_OPTIONAL)
- mutt_FormatString(dest, destlen, col, SidebarWidth, elsestring,
+ mutt_expando_format(dest, destlen, col, SidebarWidth, elsestring,
cb_format_str, (unsigned long) sbe, flags);
/* We return the format string, unchanged */
* @param sbe Mailbox object
*
* Take all the relevant mailbox data and the desired screen width and then get
- * mutt_FormatString to do the actual work. mutt_FormatString will callback to
+ * mutt_expando_format to do the actual work. mutt_expando_format will callback to
* us using cb_format_str() for the sidebar specific formatting characters.
*/
static void make_sidebar_entry(char *buf, unsigned int buflen, int width,
strfcpy(sbe->box, box, sizeof(sbe->box));
- mutt_FormatString(buf, buflen, 0, width, NONULL(SidebarFormat), cb_format_str,
+ mutt_expando_format(buf, buflen, 0, width, NONULL(SidebarFormat), cb_format_str,
(unsigned long) sbe, 0);
/* Force string to be exactly the right width */
static void _menu_status_line(char *buf, size_t buflen, size_t col, int cols,
struct Menu *menu, const char *p)
{
- mutt_FormatString(buf, buflen, col, cols, p, status_format_str, (unsigned long) menu, 0);
+ mutt_expando_format(buf, buflen, col, cols, p, status_format_str, (unsigned long) menu, 0);
}
void menu_status_line(char *buf, size_t buflen, struct Menu *menu, const char *p)
{
- mutt_FormatString(buf, buflen, 0,
+ mutt_expando_format(buf, buflen, 0,
menu ? menu->statuswin->cols : MuttStatusWindow->cols, p,
status_format_str, (unsigned long) menu, 0);
}