163 if (!table || !table->
chars || (index < 0) || (index >= table->
len))
166 if (table->
chars[index][0] ==
'\r')
169 return table->
chars[index];
183 static char padded[8];
184 static const char *long_prefixes[
DISP_MAX] = {
189 if (!C_FromChars || !C_FromChars->
chars || (C_FromChars->
len == 0))
190 return long_prefixes[disp];
196 snprintf(padded,
sizeof(padded),
"%s ", pchar);
222 struct AddressList *name = NULL;
456 char op,
const char *src,
const char *prec,
457 const char *if_str,
const char *else_str,
461 char fmt[128], tmp[1024];
462 char *p = NULL, *tags = NULL;
487 if (reply_to && reply_to->
mailbox)
583 snprintf(fmt + colorlen,
sizeof(fmt) - colorlen,
"%%%sd", prec);
585 snprintf(buf, buflen, fmt, e->
msgno + 1);
596 const char *cp = NULL;
600 if (optional && ((op ==
'[') || (op ==
'(')))
606 char *is = (
char *) prec;
614 while (*is && (*is !=
'?'))
616 int t = strtol(is, &is, 10);
624 t *= (60 * 60 * 24 * 365);
626 t += ((tm.tm_mon * 60 * 60 * 24 * 30) + (tm.tm_mday * 60 * 60 * 24) +
627 (tm.tm_hour * 60 * 60) + (tm.tm_min * 60) + tm.tm_sec);
634 t *= (60 * 60 * 24 * 30);
636 t += ((tm.tm_mday * 60 * 60 * 24) + (tm.tm_hour * 60 * 60) +
637 (tm.tm_min * 60) + tm.tm_sec);
644 t *= (60 * 60 * 24 * 7);
646 t += ((tm.tm_wday * 60 * 60 * 24) + (tm.tm_hour * 60 * 60) +
647 (tm.tm_min * 60) + tm.tm_sec);
656 t += ((tm.tm_hour * 60 * 60) + (tm.tm_min * 60) + tm.tm_sec);
665 t += ((tm.tm_min * 60) + tm.tm_sec);
686 if (((now > j) || (now < (-1 * j))) ^ invert)
703 size_t len = buflen - 1;
705 ((((op ==
'd') || (op ==
'D')) && *cp) ||
706 ((op ==
'{') && (*cp !=
'}')) || ((op ==
'[') && (*cp !=
']')) ||
707 ((op ==
'(') && (*cp !=
')')) || ((op ==
'<') && (*cp !=
'>'))))
712 if (((*cp ==
'Z') || (*cp ==
'z')) && ((op ==
'd') || (op ==
'{')))
745 if ((op ==
'[') || (op ==
'D'))
765 setlocale(LC_TIME,
"C");
766 strftime(tmp,
sizeof(tmp), buf, &tm);
768 setlocale(LC_TIME,
"");
774 if ((len > 0) && (op !=
'd') && (op !=
'D'))
780 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
787 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
803 const bool is_plain = (src[0] ==
'p');
886 bool have_tags =
true;
892 char *parent_tags = NULL;
911 optional = have_tags;
915 mutt_format_s(buf + colorlen, buflen - colorlen, prec, tags);
926 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
928 snprintf(buf + colorlen, buflen - colorlen, fmt, (
int) e->
lines);
931 else if (e->
lines <= 0)
953 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
954 snprintf(buf, buflen, fmt, m->
msg_count);
967 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
973 snprintf(buf + colorlen, buflen - colorlen, fmt, e->
num_hidden);
976 else if (is_index && threads)
994 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
995 snprintf(buf, buflen, fmt, e->
score);
1032 if (optional && (tmp[0] ==
'\0'))
1040 if (optional && (tmp[0] ==
'\0'))
1061 snprintf(tmp,
sizeof(tmp),
"%s%s", e->
tree, buf);
1078 const char *wch = NULL;
1089 else if (e->
read && (msg_in_pager != e->
msgno))
1096 snprintf(tmp,
sizeof(tmp),
"%s", wch);
1098 mutt_format_s(buf + colorlen, buflen - colorlen, prec, tmp);
1119 snprintf(fmt,
sizeof(fmt),
"%%%ss", prec);
1120 snprintf(buf, buflen, fmt,
1122 C_ToChars->
chars[i] :
1131 p = strpbrk(tmp,
"%@");
1152 p = strpbrk(tmp,
" %@");
1184 optional = (count != 0);
1186 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
1187 snprintf(buf, buflen, fmt, count);
1205 struct Email *e_tmp = NULL;
1238 const char *ch = NULL;
1247 else if (e->
read && (msg_in_pager != e->
msgno))
1262 snprintf(tmp,
sizeof(tmp),
"%s", ch);
1265 else if (src[0] ==
'c')
1267 const char *ch =
"";
1281 snprintf(tmp,
sizeof(tmp),
"%s", ch);
1284 else if (src[0] ==
't')
1286 const char *ch =
"";
1294 snprintf(tmp,
sizeof(tmp),
"%s", ch);
1301 mutt_format_s(buf + colorlen, buflen - colorlen, prec, tmp);
1308 const char *first = NULL;
1313 else if (e->
read && (msg_in_pager != e->
msgno))
1329 const char *second =
"";
1346 const char *third =
"";
1354 snprintf(tmp,
sizeof(tmp),
"%s%s%s", first, second, third);
1358 mutt_format_s(buf + colorlen, buflen - colorlen, prec, tmp);
1364 const char *end = src;
1365 static unsigned char recurse = 0;
1367 while ((*end !=
'\0') && (*end !=
'@'))
1369 if ((*end ==
'@') && (recurse < 20))
1386 snprintf(buf, buflen,
"%%%s%c", prec, op);
1393 (intptr_t) hfi, flags);
1398 (intptr_t) hfi, flags);
void * mutt_hash_find(const struct HashTable *table, const char *strkey)
Find the HashElem data in a Hash Table element using a key.
Convenience wrapper for the gui headers.
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
FlagChars
Index into the $flag_chars variable ($flag_chars)
Character denoting a tagged email.
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Character denoting a important (flagged) email.
int lines
How many lines in the body of this message?
enum MailboxType type
Mailbox type.
Miscellaneous email parsing routines.
int msg_count
Total number of messages.
void mutt_make_string_flags(char *buf, size_t buflen, int cols, const char *s, struct Mailbox *m, int inpgr, struct Email *e, MuttFormatFlags flags)
Create formatted strings using mailbox expandos.
The envelope/body of an email.
#define TAILQ_FIRST(head)
char ** chars
The array of multibyte character strings.
#define TAILQ_FOREACH(var, head, field)
struct Body * body
List of MIME parts.
struct ReplaceList SubjectRegexList
List of regexes to tidy the view of the email's subject.
Structs that make up an email.
String processing routines to generate the mail index.
The "currently-open" mailbox.
struct AddressList reply_to
Email's 'reply-to'.
struct tm mutt_date_localtime(time_t t)
Converts calendar time to a broken-down time structure expressed in user timezone.
static bool user_in_addr(struct AddressList *al)
Do any of the addresses refer to the user?
static bool thread_is_new(struct Email *e)
Does the email thread contain any new emails?
struct AddressList bcc
Email's 'Bcc' list.
struct MuttThread * thread
Thread of Emails.
char * disp_subj
Display subject (modified copy of subject)
Character denoting a thread containing at least one new email.
#define SEC_ENCRYPT
Email is encrypted.
bool attach_del
Has an attachment marked for deletion.
short recipient
User_is_recipient()'s return value, cached.
Character denoting a message contains a PGP key.
#define MUTT_DATE_NOW
Constant representing the 'current time', see: mutt_date_gmtime(), mutt_date_localtime() ...
struct MuttThread * parent
Parent of this Thread.
char * mailbox
Mailbox and host address.
Character denoting a read email, $index_format S expando.
struct tm mutt_date_gmtime(time_t t)
Converts calendar time to a broken-down time structure expressed in UTC timezone. ...
static bool thread_is_old(struct Email *e)
Does the email thread contain any unread emails?
multibyte character table
bool zoccident
True, if west of UTC, False if east.
Index: number of messages in collapsed thread.
struct MbTable * C_FromChars
Config: User-configurable index flags: to address, cc address, etc.
struct MbTable * C_ToChars
Config: Indicator characters for the 'To' field in the index.
Convenience wrapper for the config headers.
static char * apply_subject_mods(struct Envelope *env)
Apply regex modifications to the subject.
static void make_from(struct Envelope *env, char *buf, size_t buflen, bool do_lists, MuttFormatFlags flags)
Generate a From: field (with optional prefix)
Assorted sorting methods.
Some miscellaneous functions.
bool check_for_mailing_list(struct AddressList *al, const char *pfx, char *buf, int buflen)
Search list of addresses for a mailing list.
Index: author field (takes a pattern)
bool tagged
Email is tagged.
const char * mutt_addr_for_display(const struct Address *a)
Convert an Address for display purposes.
char * message_id
Message ID.
struct MuttThread * prev
Previous sibling Thread.
Parse and execute user-defined hooks.
bool old
Email is seen, but unread.
struct AddressList from
Email's 'From' list.
struct Envelope * env
Envelope information.
Index: tag field (g, takes a pattern)
Convenience wrapper for the core headers.
Character denoting a deleted attachment.
struct AddressList cc
Email's 'Cc' list.
#define mutt_thread_contains_unread(e)
Character denoting an email that has been read.
static int user_is_recipient(struct Email *e)
Is the user a recipient of the message.
Character denoting a thread of emails that has been read.
WHERE short C_Sort
Config: Sort method for the index.
struct TagList tags
For drivers that support server tagging.
char * mutt_strn_copy(char *dest, const char *src, size_t len, size_t dsize)
Copy a sub-string into a buffer.
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
time_t date_sent
Time when the message was sent (UTC)
void mutt_make_string_info(char *buf, size_t buflen, int cols, const char *s, struct HdrFormatInfo *hfi, MuttFormatFlags flags)
Create pager status bar string.
char * x_comment_to
List of 'X-comment-to' fields.
const char * mutt_idxfmt_hook(const char *name, struct Mailbox *m, struct Email *e)
Get index-format-hook format string.
Notmuch virtual mailbox type.
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Character denoting an email that has been replied to.
Create/manipulate threading in emails.
WHERE bool C_SaveAddress
Config: Use sender's full address as a default save folder.
LOFF_T length
length (in bytes) of attachment
void mutt_format_s_x(char *buf, size_t buflen, const char *prec, const char *s, bool arboreal)
Format a string like snprintf()
bool check_for_mailing_list_addr(struct AddressList *al, char *buf, int buflen)
Check an address list for a mailing list.
static void make_from_addr(struct Envelope *env, char *buf, size_t buflen, bool do_lists)
Create a 'from' address for a reply email.
size_t num_hidden
Number of hidden messages in this view (only valid when collapsed is set)
void mutt_str_pretty_size(char *buf, size_t buflen, size_t num)
Display an abbreviated size, like 3.4K.
Character denoting a message signed with a verified key.
bool mutt_mb_get_initials(const char *name, char *buf, size_t buflen)
Turn a name into initials.
static const char * make_from_prefix(enum FieldType disp)
Create a prefix for an author field.
static size_t add_index_color(char *buf, size_t buflen, MuttFormatFlags flags, char color)
Insert a color marker into a string.
API for encryption/signing of emails.
bool collapsed
Is this message part of a collapsed thread?
Character denoting a message is PGP-encrypted.
char * mutt_replacelist_apply(struct ReplaceList *rl, char *buf, size_t buflen, const char *str)
Apply replacements to a buffer.
int mutt_messages_in_thread(struct Mailbox *m, struct Email *e, int flag)
Count the messages in a thread.
CryptChars
Index into the $crypt_chars variable ($crypt_chars)
unsigned int zhours
Hours away from UTC.
char * tree
Character string to print thread tree.
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib...
struct Email * message
Email this Thread refers to.
static const char * get_nth_wchar(struct MbTable *table, int index)
Extract one char from a multi-byte table.
'Notmuch' (virtual) Mailbox type
#define SEC_SIGN
Email is signed.
Character denoting a read email, $index_format Z expando.
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
char * subject
Email's subject.
WHERE char * C_DateFormat
Config: strftime format string for the d expando.
Index: subject field (takes a pattern)
void mutt_format_s(char *buf, size_t buflen, const char *prec, const char *s)
Format a simple string.
bool flagged
Marked important?
char * newsgroups
List of newsgroups.
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Character denoting a deleted email.
struct MbTable * C_FlagChars
Config: User-configurable index flags: tagged, new, etc.
bool deleted
Email is deleted.
void mutt_expando_format(char *buf, size_t buflen, size_t col, int cols, const char *src, format_t callback, intptr_t data, MuttFormatFlags flags)
Expand expandos (x) in a string.
bool replied
Email has been replied to.
Character denoting an unread email.
Character denoting a message has no cryptography information.
bool mutt_addr_is_user(const struct Address *addr)
Does the address belong to the user.
char * organization
Organisation header.
Character denoting a message is signed.
#define STAILQ_EMPTY(head)
bool recip_valid
Is_recipient is valid.
struct AddressList to
Email's 'To' list.
char * nm_email_get_folder_rel_db(struct Mailbox *m, struct Email *e)
Get the folder for a Email from the same level as the notmuch database.
#define TAILQ_NEXT(elm, field)
int mutt_count_body_parts(struct Mailbox *m, struct Email *e)
Count the MIME Body parts.
Hundreds of global variables to back the user variables.
bool first_mailing_list(char *buf, size_t buflen, struct AddressList *al)
Get the first mailing list in the list of addresses.
#define TAILQ_EMPTY(head)
Index: default colour (takes a pattern)
struct MbTable * C_CryptChars
Config: User-configurable crypto flags: signed, encrypted etc.
Convenience wrapper for the library headers.
WHERE struct HashTable * TagFormats
Hash Table of tag-formats (tag -> format string)
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
#define SEC_GOODSIGN
Email has a valid signature.
size_t mutt_addrlist_write(const struct AddressList *al, char *buf, size_t buflen, bool display)
Write an Address to a buffer.
unsigned int zminutes
Minutes away from UTC.
size_t email_size(const struct Email *e)
compute the size of an email
#define SORT_MASK
Mask for the sort id.
time_t received
Time when the message was placed in the mailbox.
static const char * index_format_str(char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, intptr_t data, MuttFormatFlags flags)
Format a string for the index list - Implements format_t.
Index: flags field (takes a pattern)
struct Buffer spam
Spam header.
int len
Number of characters.
void mutt_format_s_tree(char *buf, size_t buflen, const char *prec, const char *s)
Format a simple string with tree characters.
int msgno
Number displayed to the user.
const char * mutt_get_name(const struct Address *a)
Pick the best name to display from an address.