136 static char padded[8];
137 static const char *long_prefixes[
DISP_MAX] = {
144 if (!c_from_chars || !c_from_chars->
chars || (c_from_chars->
len == 0))
145 return long_prefixes[disp];
151 snprintf(padded,
sizeof(padded),
"%s ", pchar);
177 struct AddressList *name = NULL;
394 char op,
const char *src,
const char *prec,
395 const char *if_str,
const char *else_str,
399 char fmt[128], tmp[1024];
400 char *p = NULL, *tags = NULL;
430 if (reply_to && reply_to->
mailbox)
521 snprintf(fmt + colorlen,
sizeof(fmt) - colorlen,
"%%%sd", prec);
523 snprintf(buf, buflen, fmt, e->
msgno + 1);
534 const char *cp = NULL;
538 if (optional && ((op ==
'[') || (op ==
'(')))
544 char *is = (
char *) prec;
552 while (*is && (*is !=
'?'))
554 int t = strtol(is, &is, 10);
562 t *= (60 * 60 * 24 * 365);
564 t += ((tm.tm_mon * 60 * 60 * 24 * 30) + (tm.tm_mday * 60 * 60 * 24) +
565 (tm.tm_hour * 60 * 60) + (tm.tm_min * 60) + tm.tm_sec);
572 t *= (60 * 60 * 24 * 30);
574 t += ((tm.tm_mday * 60 * 60 * 24) + (tm.tm_hour * 60 * 60) +
575 (tm.tm_min * 60) + tm.tm_sec);
582 t *= (60 * 60 * 24 * 7);
584 t += ((tm.tm_wday * 60 * 60 * 24) + (tm.tm_hour * 60 * 60) +
585 (tm.tm_min * 60) + tm.tm_sec);
594 t += ((tm.tm_hour * 60 * 60) + (tm.tm_min * 60) + tm.tm_sec);
603 t += ((tm.tm_min * 60) + tm.tm_sec);
624 if (((now > j) || (now < (-1 * j))) ^ invert)
631 cp = ((op ==
'd') || (op ==
'D')) ? (
NONULL(c_date_format)) : src;
632 bool use_c_locale =
false;
639 size_t len = buflen - 1;
641 ((((op ==
'd') || (op ==
'D')) && *cp) ||
642 ((op ==
'{') && (*cp !=
'}')) || ((op ==
'[') && (*cp !=
']')) ||
643 ((op ==
'(') && (*cp !=
')')) || ((op ==
'<') && (*cp !=
'>'))))
648 if (((*cp ==
'Z') || (*cp ==
'z')) && ((op ==
'd') || (op ==
'{')))
684 struct tm tm = { 0 };
685 if ((op ==
'[') || (op ==
'D'))
711 strftime(tmp,
sizeof(tmp), buf, &tm);
717 if ((len > 0) && (op !=
'd') && (op !=
'D'))
723 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
730 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
752 const bool is_plain = (src[0] ==
'p');
785 char format[3] = { 0 };
837 bool have_tags =
true;
843 char *parent_tags = NULL;
864 optional = have_tags;
868 mutt_format_s(buf + colorlen, buflen - colorlen, prec, tags);
879 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
881 snprintf(buf + colorlen, buflen - colorlen, fmt, e->
lines);
884 else if (e->
lines <= 0)
908 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
909 snprintf(buf, buflen, fmt, m->
msg_count);
924 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
930 snprintf(buf + colorlen, buflen - colorlen, fmt, e->
num_hidden);
933 else if (is_index && threads)
953 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
954 snprintf(buf, buflen, fmt, e->
score);
968 if (!c_save_address && (p = strpbrk(tmp,
"%@")))
995 if (optional && (tmp[0] ==
'\0'))
1007 if (optional && (tmp[0] ==
'\0'))
1028 snprintf(tmp,
sizeof(tmp),
"%s%s", e->
tree, buf);
1047 const char *wch = NULL;
1058 else if (e->
read && (msg_in_pager != e->
msgno))
1065 snprintf(tmp,
sizeof(tmp),
"%s", wch);
1067 mutt_format_s(buf + colorlen, buflen - colorlen, prec, tmp);
1088 snprintf(fmt,
sizeof(fmt),
"%%%ss", prec);
1089 snprintf(buf, buflen, fmt,
1091 c_to_chars->
chars[i] :
1100 p = strpbrk(tmp,
"%@");
1125 p = strpbrk(tmp,
" %@");
1165 optional = (count != 0);
1167 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
1168 snprintf(buf, buflen, fmt, count);
1187 struct Email *e_tmp = NULL;
1222 const char *ch = NULL;
1239 else if (e->
read && (msg_in_pager != e->
msgno))
1254 snprintf(tmp,
sizeof(tmp),
"%s", ch);
1257 else if (src[0] ==
'c')
1259 const char *ch = NULL;
1281 snprintf(tmp,
sizeof(tmp),
"%s", ch);
1284 else if (src[0] ==
't')
1286 const char *ch = NULL;
1294 snprintf(tmp,
sizeof(tmp),
"%s", ch);
1303 mutt_format_s(buf + colorlen, buflen - colorlen, prec, tmp);
1310 const char *first = NULL;
1319 else if (e->
read && (msg_in_pager != e->
msgno))
1335 const char *second = NULL;
1352 const char *third = NULL;
1360 snprintf(tmp,
sizeof(tmp),
"%s%s%s", first, second, third);
1364 mutt_format_s(buf + colorlen, buflen - colorlen, prec, tmp);
1373 const char *end = src;
1374 static unsigned char recurse = 0;
1376 while ((*end !=
'\0') && (*end !=
'@'))
1378 if ((*end ==
'@') && (recurse < 20))
1395 snprintf(buf, buflen,
"%%%s%c", prec, op);
size_t mutt_addrlist_write(const struct AddressList *al, struct Buffer *buf, bool display)
Write an Address to a buffer.
const char * mutt_addr_for_display(const struct Address *a)
Convert an Address for display purposes.
bool mutt_addr_is_user(const struct Address *addr)
Does the address belong to the user.
GUI display the mailboxes in a side panel.
int mutt_count_body_parts(const struct Mailbox *m, struct Email *e, FILE *fp)
Count the MIME Body parts.
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Color and attribute parsing.
ColorId
List of all colored objects.
@ MT_COLOR_INDEX_AUTHOR
Index: author field.
@ MT_COLOR_INDEX_SIZE
Index: size field.
@ MT_COLOR_INDEX_TAGS
Index: tags field (g, J)
@ MT_COLOR_INDEX_SUBJECT
Index: subject field.
@ MT_COLOR_INDEX_DATE
Index: date field.
@ MT_COLOR_INDEX_TAG
Index: tag field (G)
@ MT_COLOR_INDEX_LABEL
Index: label field.
@ MT_COLOR_INDEX
Index: default colour.
@ MT_COLOR_INDEX_NUMBER
Index: index number.
@ MT_COLOR_INDEX_FLAGS
Index: flags field.
@ MT_COLOR_INDEX_COLLAPSED
Index: number of messages in collapsed thread.
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
struct MbTable * cs_subset_mbtable(const struct ConfigSubset *sub, const char *name)
Get a Multibyte table config item by name.
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
void mutt_format_s_x(char *buf, size_t buflen, const char *prec, const char *s, bool arboreal)
Format a string like snprintf()
void mutt_format_s_tree(char *buf, size_t buflen, const char *prec, const char *s)
Format a simple string with tree characters.
void mutt_format_s(char *buf, size_t buflen, const char *prec, const char *s)
Format a simple string.
size_t email_size(const struct Email *e)
Compute the size of an email.
Structs that make up an email.
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 -.
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 -.
Convenience wrapper for the gui headers.
void * mutt_hash_find(const struct HashTable *table, const char *strkey)
Find the HashElem data in a Hash Table element using a key.
static const char * make_from_prefix(enum FieldType disp)
Create a prefix for an author field.
static void make_from_addr(struct Envelope *env, char *buf, size_t buflen, bool do_lists)
Create a 'from' address for a reply email.
void mutt_make_string(char *buf, size_t buflen, int cols, const char *s, struct Mailbox *m, int inpgr, struct Email *e, MuttFormatFlags flags, const char *progress)
Create formatted strings using mailbox expandos.
@ DISP_PLAIN
Empty string.
static bool thread_is_old(struct Email *e)
Does the email thread contain any unread emails?
static enum ToChars user_is_recipient(struct Email *e)
Is the user a recipient of the message.
static size_t add_index_color(char *buf, size_t buflen, MuttFormatFlags flags, enum ColorId color)
Insert a color marker into a string.
static void make_from(struct Envelope *env, char *buf, size_t buflen, bool do_lists, MuttFormatFlags flags)
Generate a From: field (with optional prefix)
static bool thread_is_new(struct Email *e)
Does the email thread contain any new emails?
static bool user_in_addr(struct AddressList *al)
Do any of the addresses refer to the user?
String processing routines to generate the mail index.
ToChars
Index into the $to_chars config variable.
@ FLAG_CHAR_TO_ORIGINATOR
Character denoting that the user is originator.
@ FLAG_CHAR_TO_UNIQUE
Character denoting that the user is unique recipient.
@ FLAG_CHAR_TO_NOT_IN_THE_LIST
Character denoting that the user is not in list.
@ FLAG_CHAR_TO_TO
Character denoting that the user is in the TO list.
@ FLAG_CHAR_TO_CC
Character denoting that the user is in the CC list.
@ FLAG_CHAR_TO_REPLY_TO
Character denoting that the user is in the Reply-To list.
@ FLAG_CHAR_TO_SUBSCRIBED_LIST
Character denoting that the message is sent to a subscribed mailing list.
@ FLAG_CHAR_CRYPT_CONTAINS_KEY
Character denoting a message contains a PGP key.
@ FLAG_CHAR_CRYPT_SIGNED
Character denoting a message is signed.
@ FLAG_CHAR_CRYPT_NO_CRYPTO
Character denoting a message has no cryptography information.
@ FLAG_CHAR_CRYPT_GOOD_SIGN
Character denoting a message signed with a verified key.
@ FLAG_CHAR_CRYPT_ENCRYPTED
Character denoting a message is PGP-encrypted.
@ FLAG_CHAR_OLD
Character denoting an email that has been read.
@ FLAG_CHAR_REPLIED
Character denoting an email that has been replied to.
@ FLAG_CHAR_OLD_THREAD
Character denoting a thread of emails that has been read.
@ FLAG_CHAR_ZEMPTY
Character denoting a read email, $index_format Z expando.
@ FLAG_CHAR_TAGGED
Character denoting a tagged email.
@ FLAG_CHAR_NEW
Character denoting an unread email.
@ FLAG_CHAR_DELETED
Character denoting a deleted email.
@ FLAG_CHAR_NEW_THREAD
Character denoting a thread containing at least one new email.
@ FLAG_CHAR_DELETED_ATTACH
Character denoting a deleted attachment.
@ FLAG_CHAR_SEMPTY
Character denoting a read email, $index_format S expando.
@ FLAG_CHAR_IMPORTANT
Character denoting a important (flagged) email.
const char * mutt_idxfmt_hook(const char *name, struct Mailbox *m, struct Email *e)
Get index-format-hook format string.
Parse and execute user-defined hooks.
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
bool check_for_mailing_list(struct AddressList *al, const char *pfx, char *buf, int buflen)
Search list of addresses for a mailing list.
bool check_for_mailing_list_addr(struct AddressList *al, char *buf, int buflen)
Check an address list for a mailing list.
bool first_mailing_list(char *buf, size_t buflen, struct AddressList *al)
Get the first mailing list in the list of addresses.
const char * mbtable_get_nth_wchar(const struct MbTable *table, int index)
Extract one char from a multi-byte table.
bool mutt_mb_get_initials(const char *name, char *buf, size_t buflen)
Turn a name into initials.
struct tm mutt_date_localtime(time_t t)
Converts calendar time to a broken-down time structure expressed in user timezone.
struct tm mutt_date_gmtime(time_t t)
Converts calendar time to a broken-down time structure expressed in UTC timezone.
time_t mutt_date_now(void)
Return the number of seconds since the Unix epoch.
Convenience wrapper for the library headers.
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
char * mutt_strn_copy(char *dest, const char *src, size_t len, size_t dsize)
Copy a sub-string into a buffer.
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
int mutt_messages_in_thread(struct Mailbox *m, struct Email *e, enum MessageInThread mit)
Count the messages in a thread.
Create/manipulate threading in emails.
#define mutt_using_threads()
@ MIT_NUM_MESSAGES
How many messages are in the thread.
@ MIT_POSITION
Our position in the thread.
#define mutt_thread_contains_unread(e)
@ MUTT_SPECIAL_INDEX
Colour indicator.
void mutt_str_pretty_size(char *buf, size_t buflen, size_t num)
Display an abbreviated size, like 3.4K.
Some miscellaneous functions.
int mx_msg_close(struct Mailbox *m, struct Message **ptr)
Close a message.
struct Message * mx_msg_open(struct Mailbox *m, struct Email *e)
Return a stream pointer for a message.
API for encryption/signing of emails.
#define SEC_GOODSIGN
Email has a valid signature.
#define APPLICATION_PGP
Use PGP to encrypt/sign.
#define SEC_ENCRYPT
Email is encrypted.
#define SEC_SIGN
Email is signed.
Notmuch virtual mailbox type.
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.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
#define TAILQ_FOREACH(var, head, field)
#define TAILQ_FIRST(head)
#define TAILQ_NEXT(elm, field)
#define TAILQ_EMPTY(head)
const char * mutt_get_name(const struct Address *a)
Pick the best name to display from an address.
Assorted sorting methods.
struct Buffer * mailbox
Mailbox and host address.
LOFF_T length
length (in bytes) of attachment
String manipulation buffer.
The envelope/body of an email.
unsigned int zminutes
Minutes away from UTC.
bool recip_valid
Is_recipient is valid.
struct Envelope * env
Envelope information.
bool collapsed
Is this message part of a collapsed thread?
int lines
How many lines in the body of this message?
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib....
struct Body * body
List of MIME parts.
char * tree
Character string to print thread tree.
bool old
Email is seen, but unread.
size_t num_hidden
Number of hidden messages in this view (only valid when collapsed is set)
bool zoccident
True, if west of UTC, False if east.
bool attach_del
Has an attachment marked for deletion.
bool flagged
Marked important?
unsigned int zhours
Hours away from UTC.
time_t date_sent
Time when the message was sent (UTC)
bool replied
Email has been replied to.
struct TagList tags
For drivers that support server tagging.
int msgno
Number displayed to the user.
bool deleted
Email is deleted.
short recipient
User_is_recipient()'s return value, cached.
bool tagged
Email is tagged.
time_t received
Time when the message was placed in the mailbox.
struct MuttThread * thread
Thread of Emails.
struct AddressList to
Email's 'To' list.
struct AddressList reply_to
Email's 'reply-to'.
char * message_id
Message ID.
char * x_comment_to
List of 'X-comment-to' fields.
char * newsgroups
List of newsgroups.
struct AddressList cc
Email's 'Cc' list.
struct Buffer spam
Spam header.
char * subject
Email's subject.
struct AddressList bcc
Email's 'Bcc' list.
char * organization
Organisation header.
char * disp_subj
Display subject (modified copy of subject)
struct AddressList from
Email's 'From' list.
int msg_count
Total number of messages.
enum MailboxType type
Mailbox type.
Multibyte character table.
int len
Number of characters.
char ** chars
The array of multibyte character strings.
A local copy of an email.
FILE * fp
pointer to the message data
struct Message::@0 flags
Flags for the Message.
struct MuttThread * parent
Parent of this Thread.
struct MuttThread * prev
Previous sibling Thread.
struct Email * message
Email this Thread refers to.
Container for Accounts, Notifications.
struct ConfigSubset * sub
Inherited config items.
locale_t time_c_locale
Current locale but LC_TIME=C.
bool subjrx_apply_mods(struct Envelope *env)
Apply regex modifications to the subject.