NeoMutt  2018-07-16 +952-a2da0a
Teaching an old dog new tricks
DOXYGEN
hdrline.c File Reference

String processing routines to generate the mail index. More...

#include "config.h"
#include <locale.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "mutt/mutt.h"
#include "config/lib.h"
#include "email/lib.h"
#include "mutt.h"
#include "hdrline.h"
#include "alias.h"
#include "context.h"
#include "curs_lib.h"
#include "format_flags.h"
#include "globals.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "mutt_parse.h"
#include "mutt_thread.h"
#include "mutt_window.h"
#include "muttlib.h"
#include "ncrypt/ncrypt.h"
#include "sort.h"
+ Include dependency graph for hdrline.c:

Go to the source code of this file.

Enumerations

enum  FlagChars {
  FLAG_CHAR_TAGGED, FLAG_CHAR_IMPORTANT, FLAG_CHAR_DELETED, FLAG_CHAR_DELETED_ATTACH,
  FLAG_CHAR_REPLIED, FLAG_CHAR_OLD, FLAG_CHAR_NEW, FLAG_CHAR_OLD_THREAD,
  FLAG_CHAR_NEW_THREAD, FLAG_CHAR_SEMPTY, FLAG_CHAR_ZEMPTY
}
 Index into the FlagChars variable ($flag_chars) More...
 
enum  CryptChars {
  FLAG_CHAR_CRYPT_GOOD_SIGN, FLAG_CHAR_CRYPT_ENCRYPTED, FLAG_CHAR_CRYPT_SIGNED, FLAG_CHAR_CRYPT_CONTAINS_KEY,
  FLAG_CHAR_CRYPT_NO_CRYPTO
}
 Index into the CryptChars variable ($crypt_chars) More...
 
enum  FieldType {
  DISP_TO, DISP_CC, DISP_BCC, DISP_FROM,
  DISP_PLAIN, DISP_MAX
}
 Header types. More...
 

Functions

bool mutt_is_mail_list (struct Address *addr)
 Is this the email address of a mailing list? More...
 
bool mutt_is_subscribed_list (struct Address *addr)
 Is this the email address of a user-subscribed mailing list? More...
 
static bool check_for_mailing_list (struct Address *addr, const char *pfx, char *buf, int buflen)
 Search list of addresses for a mailing list. More...
 
static bool check_for_mailing_list_addr (struct Address *addr, char *buf, int buflen)
 Check an address list for a mailing list. More...
 
static bool first_mailing_list (char *buf, size_t buflen, struct Address *a)
 Get the first mailing list in the list of addresses. More...
 
static size_t add_index_color (char *buf, size_t buflen, enum FormatFlag flags, char color)
 Insert a color marker into a string. More...
 
static const char * get_nth_wchar (struct MbTable *table, int index)
 Extract one char from a multi-byte table. More...
 
static const char * make_from_prefix (enum FieldType disp)
 Create a prefix for an author field. More...
 
static void make_from (struct Envelope *env, char *buf, size_t buflen, bool do_lists, enum FormatFlag flags)
 Generate a From: field (with optional prefix) More...
 
static void make_from_addr (struct Envelope *hdr, char *buf, size_t buflen, bool do_lists)
 Create a 'from' address for a reply email. More...
 
static bool user_in_addr (struct Address *a)
 Do any of the addresses refer to the user? More...
 
static int user_is_recipient (struct Email *e)
 Is the user a recipient of the message. More...
 
static char * apply_subject_mods (struct Envelope *env)
 Apply regex modifications to the subject. More...
 
static bool thread_is_new (struct Context *ctx, struct Email *e)
 Does the email thread contain any new emails? More...
 
static bool thread_is_old (struct Context *ctx, struct Email *e)
 Does the email thread contain any unread emails? More...
 
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, unsigned long data, enum FormatFlag flags)
 Format a string for the index list - Implements format_t. More...
 
void mutt_make_string_flags (char *buf, size_t buflen, const char *s, struct Context *ctx, struct Email *e, enum FormatFlag flags)
 Create formatted strings using mailbox expandos. More...
 
void mutt_make_string_info (char *buf, size_t buflen, int cols, const char *s, struct HdrFormatInfo *hfi, enum FormatFlag flags)
 Create pager status bar string. More...
 

Variables

struct MbTableCryptChars
 Config: User-configurable crypto flags: signed, encrypted etc. More...
 
struct MbTableFlagChars
 Config: User-configurable index flags: tagged, new, etc. More...
 
struct MbTableFromChars
 Config: User-configurable index flags: to address, cc address, etc. More...
 
struct MbTableToChars
 Config: Indicator characters for the 'To' field in the index. More...
 

Detailed Description

String processing routines to generate the mail index.

Authors
  • Michael R. Elkins
  • Richard Russon
  • Ian Zimmerman

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file hdrline.c.

Enumeration Type Documentation

enum FlagChars

Index into the FlagChars variable ($flag_chars)

Enumerator
FLAG_CHAR_TAGGED 

Character denoting a tagged email.

FLAG_CHAR_IMPORTANT 

Character denoting a important (flagged) email.

FLAG_CHAR_DELETED 

Character denoting a deleted email.

FLAG_CHAR_DELETED_ATTACH 

Character denoting a deleted attachment.

FLAG_CHAR_REPLIED 

Character denoting an email that has been replied to.

FLAG_CHAR_OLD 

Character denoting an email that has been read.

FLAG_CHAR_NEW 

Character denoting an unread email.

FLAG_CHAR_OLD_THREAD 

Character denoting a thread of emails that has been read.

FLAG_CHAR_NEW_THREAD 

Character denoting a thread containing at least one new email.

FLAG_CHAR_SEMPTY 

Character denoting a read email, $index_format S expando.

FLAG_CHAR_ZEMPTY 

Character denoting a read email, $index_format Z expando.

Definition at line 66 of file hdrline.c.

67 {
79 };
Character denoting a tagged email.
Definition: hdrline.c:68
Character denoting a important (flagged) email.
Definition: hdrline.c:69
Character denoting a thread containing at least one new email.
Definition: hdrline.c:76
Character denoting a read email, $index_format S expando.
Definition: hdrline.c:77
Character denoting a deleted attachment.
Definition: hdrline.c:71
Character denoting an email that has been read.
Definition: hdrline.c:73
Character denoting a thread of emails that has been read.
Definition: hdrline.c:75
Character denoting an email that has been replied to.
Definition: hdrline.c:72
Character denoting a read email, $index_format Z expando.
Definition: hdrline.c:78
Character denoting a deleted email.
Definition: hdrline.c:70
Character denoting an unread email.
Definition: hdrline.c:74
enum CryptChars

Index into the CryptChars variable ($crypt_chars)

Enumerator
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_CRYPT_SIGNED 

Character denoting a message is signed.

FLAG_CHAR_CRYPT_CONTAINS_KEY 

Character denoting a message contains a PGP key.

FLAG_CHAR_CRYPT_NO_CRYPTO 

Character denoting a message has no cryptography information.

Definition at line 84 of file hdrline.c.

85 {
91 };
Character denoting a message contains a PGP key.
Definition: hdrline.c:89
Character denoting a message signed with a verified key.
Definition: hdrline.c:86
Character denoting a message is PGP-encrypted.
Definition: hdrline.c:87
Character denoting a message has no cryptography information.
Definition: hdrline.c:90
Character denoting a message is signed.
Definition: hdrline.c:88
enum FieldType

Header types.

Strings for printing headers

Enumerator
DISP_TO 

To: string.

DISP_CC 

Cc: string.

DISP_BCC 

Bcc: string.

DISP_FROM 

From: string.

DISP_PLAIN 

Empty string.

DISP_MAX 

Definition at line 231 of file hdrline.c.

232 {
233  DISP_TO,
234  DISP_CC,
235  DISP_BCC,
236  DISP_FROM,
237  DISP_PLAIN,
238  DISP_MAX,
239 };
Bcc: string.
Definition: hdrline.c:235
Cc: string.
Definition: hdrline.c:234
Empty string.
Definition: hdrline.c:237
From: string.
Definition: hdrline.c:236
To: string.
Definition: hdrline.c:233

Function Documentation

bool mutt_is_mail_list ( struct Address addr)

Is this the email address of a mailing list?

Parameters
addrAddress to test
Return values
trueIf it's a mailing list

Definition at line 98 of file hdrline.c.

99 {
100  if (!mutt_regexlist_match(&UnMailLists, addr->mailbox))
101  return mutt_regexlist_match(&MailLists, addr->mailbox);
102  return false;
103 }
char * mailbox
mailbox and host address
Definition: address.h:35
bool mutt_regexlist_match(struct RegexList *rl, const char *str)
Does a string match any Regex in the list?
Definition: regex.c:187

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool mutt_is_subscribed_list ( struct Address addr)

Is this the email address of a user-subscribed mailing list?

Parameters
addrAddress to test
Return values
trueIf it's a subscribed mailing list

Definition at line 110 of file hdrline.c.

111 {
112  if (!mutt_regexlist_match(&UnMailLists, addr->mailbox) &&
113  !mutt_regexlist_match(&UnSubscribedLists, addr->mailbox))
114  {
115  return mutt_regexlist_match(&SubscribedLists, addr->mailbox);
116  }
117  return false;
118 }
char * mailbox
mailbox and host address
Definition: address.h:35
bool mutt_regexlist_match(struct RegexList *rl, const char *str)
Does a string match any Regex in the list?
Definition: regex.c:187

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool check_for_mailing_list ( struct Address addr,
const char *  pfx,
char *  buf,
int  buflen 
)
static

Search list of addresses for a mailing list.

Parameters
addrList of addreses to search
pfxPrefix string
bufBuffer to store results
buflenBuffer length
Return values
1Mailing list found
0No list found

Search for a mailing list in the list of addresses pointed to by addr. If one is found, print pfx and the name of the list into buf.

Definition at line 132 of file hdrline.c.

133 {
134  for (; addr; addr = addr->next)
135  {
136  if (mutt_is_subscribed_list(addr))
137  {
138  if (pfx && buf && buflen)
139  snprintf(buf, buflen, "%s%s", pfx, mutt_get_name(addr));
140  return true;
141  }
142  }
143  return false;
144 }
bool mutt_is_subscribed_list(struct Address *addr)
Is this the email address of a user-subscribed mailing list?
Definition: hdrline.c:110
const char * mutt_get_name(struct Address *a)
Pick the best name to display from an address.
Definition: sort.c:153
struct Address * next
Definition: address.h:39

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool check_for_mailing_list_addr ( struct Address addr,
char *  buf,
int  buflen 
)
static

Check an address list for a mailing list.

Parameters
addrAddress list
bufBuffer for the result
buflenLength of buffer
Return values
trueMailing list found

If one is found, print the address of the list into buf.

Definition at line 155 of file hdrline.c.

156 {
157  for (; addr; addr = addr->next)
158  {
159  if (mutt_is_subscribed_list(addr))
160  {
161  if (buf && buflen)
162  snprintf(buf, buflen, "%s", addr->mailbox);
163  return true;
164  }
165  }
166  return false;
167 }
char * mailbox
mailbox and host address
Definition: address.h:35
bool mutt_is_subscribed_list(struct Address *addr)
Is this the email address of a user-subscribed mailing list?
Definition: hdrline.c:110
struct Address * next
Definition: address.h:39

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool first_mailing_list ( char *  buf,
size_t  buflen,
struct Address a 
)
static

Get the first mailing list in the list of addresses.

Parameters
bufBuffer for the result
buflenLength of buffer
aAddress list
Return values
trueIf a mailing list was found

Definition at line 176 of file hdrline.c.

177 {
178  for (; a; a = a->next)
179  {
181  {
182  mutt_save_path(buf, buflen, a);
183  return true;
184  }
185  }
186  return false;
187 }
bool mutt_is_subscribed_list(struct Address *addr)
Is this the email address of a user-subscribed mailing list?
Definition: hdrline.c:110
void mutt_save_path(char *buf, size_t buflen, struct Address *addr)
Turn an email address into a filename (for saving)
Definition: muttlib.c:772
struct Address * next
Definition: address.h:39

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static size_t add_index_color ( char *  buf,
size_t  buflen,
enum FormatFlag  flags,
char  color 
)
static

Insert a color marker into a string.

Parameters
bufBuffer to store marker
buflenBuffer length
flagsFlags, e.g. MUTT_FORMAT_INDEX
colorColor, e.g. MT_COLOR_MESSAGE
Return values
numCharacters written

The colors are stored as "magic" strings embedded in the text.

Definition at line 199 of file hdrline.c.

200 {
201  /* only add color markers if we are operating on main index entries. */
202  if (!(flags & MUTT_FORMAT_INDEX))
203  return 0;
204 
205  /* this item is going to be passed to an external filter */
206  if (flags & MUTT_FORMAT_NOFILTER)
207  return 0;
208 
209  if (color == MT_COLOR_INDEX)
210  { /* buf might be uninitialized other cases */
211  const size_t len = mutt_str_strlen(buf);
212  buf += len;
213  buflen -= len;
214  }
215 
216  if (buflen <= 2)
217  return 0;
218 
219  buf[0] = MUTT_SPECIAL_INDEX;
220  buf[1] = color;
221  buf[2] = '\0';
222 
223  return 2;
224 }
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:663
do not allow filtering on this pass
Definition: format_flags.h:40
this is a main index entry
Definition: format_flags.h:39
Index: default colour (takes a pattern)
Definition: mutt_curses.h:155
#define MUTT_SPECIAL_INDEX
Definition: mutt.h:98

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static const char* get_nth_wchar ( struct MbTable table,
int  index 
)
static

Extract one char from a multi-byte table.

Parameters
tableMulti-byte table
indexSelect this character
Return values
ptrString pointer to the character

Extract one multi-byte character from a string table. If the index is invalid, then a space character will be returned. If the character selected is '
' (Ctrl-M), then "" will be returned.

Definition at line 251 of file hdrline.c.

252 {
253  if (!table || !table->chars || (index < 0) || (index >= table->len))
254  return " ";
255 
256  if (table->chars[index][0] == '\r')
257  return "";
258 
259  return table->chars[index];
260 }
char ** chars
The array of multibyte character strings.
Definition: mbtable.h:39
int index
the absolute (unsorted) message number
Definition: email.h:87
int len
Number of characters.
Definition: mbtable.h:38

+ Here is the caller graph for this function:

static const char* make_from_prefix ( enum FieldType  disp)
static

Create a prefix for an author field.

Parameters
dispType of field
Return values
ptrPrefix string (do not free it)

If $from_chars is set, pick an appropriate character from it. If not, use the default prefix: "To", "Cc", etc

Definition at line 270 of file hdrline.c.

271 {
272  /* need 2 bytes at the end, one for the space, another for NUL */
273  static char padded[8];
274  static const char *long_prefixes[DISP_MAX] = {
275  [DISP_TO] = "To ", [DISP_CC] = "Cc ", [DISP_BCC] = "Bcc ",
276  [DISP_FROM] = "", [DISP_PLAIN] = "",
277  };
278 
279  if (!FromChars || !FromChars->chars || (FromChars->len == 0))
280  return long_prefixes[disp];
281 
282  const char *pchar = get_nth_wchar(FromChars, disp);
283  if (mutt_str_strlen(pchar) == 0)
284  return "";
285 
286  snprintf(padded, sizeof(padded), "%s ", pchar);
287  return padded;
288 }
Bcc: string.
Definition: hdrline.c:235
char ** chars
The array of multibyte character strings.
Definition: mbtable.h:39
Cc: string.
Definition: hdrline.c:234
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:663
Empty string.
Definition: hdrline.c:237
From: string.
Definition: hdrline.c:236
static const char * get_nth_wchar(struct MbTable *table, int index)
Extract one char from a multi-byte table.
Definition: hdrline.c:251
To: string.
Definition: hdrline.c:233
struct MbTable * FromChars
Config: User-configurable index flags: to address, cc address, etc.
Definition: hdrline.c:60
int len
Number of characters.
Definition: mbtable.h:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void make_from ( struct Envelope env,
char *  buf,
size_t  buflen,
bool  do_lists,
enum FormatFlag  flags 
)
static

Generate a From: field (with optional prefix)

Parameters
envEnvelope of the email
bufBuffer to store the result
buflenSize of the buffer
do_listsShould we check for mailing lists?
flagsFormat flags, e.g. MUTT_FORMAT_PLAIN

Generate the F or L field in $index_format. This is the author, or recipient of the email.

The field can optionally be prefixed by a character from $from_chars. If $from_chars is not set, the prefix will be, "To", "Cc", etc

Definition at line 304 of file hdrline.c.

306 {
307  if (!env || !buf)
308  return;
309 
310  bool me;
311  enum FieldType disp;
312  struct Address *name = NULL;
313 
314  me = mutt_addr_is_user(env->from);
315 
316  if (do_lists || me)
317  {
318  if (check_for_mailing_list(env->to, make_from_prefix(DISP_TO), buf, buflen))
319  return;
320  if (check_for_mailing_list(env->cc, make_from_prefix(DISP_CC), buf, buflen))
321  return;
322  }
323 
324  if (me && env->to)
325  {
326  disp = (flags & MUTT_FORMAT_PLAIN) ? DISP_PLAIN : DISP_TO;
327  name = env->to;
328  }
329  else if (me && env->cc)
330  {
331  disp = DISP_CC;
332  name = env->cc;
333  }
334  else if (me && env->bcc)
335  {
336  disp = DISP_BCC;
337  name = env->bcc;
338  }
339  else if (env->from)
340  {
341  disp = DISP_FROM;
342  name = env->from;
343  }
344  else
345  {
346  *buf = '\0';
347  return;
348  }
349 
350  snprintf(buf, buflen, "%s%s", make_from_prefix(disp), mutt_get_name(name));
351 }
Bcc: string.
Definition: hdrline.c:235
struct Address * to
Definition: envelope.h:36
Cc: string.
Definition: hdrline.c:234
An email address.
Definition: address.h:32
static bool check_for_mailing_list(struct Address *addr, const char *pfx, char *buf, int buflen)
Search list of addresses for a mailing list.
Definition: hdrline.c:132
const char * name
Definition: pgpmicalg.c:42
Empty string.
Definition: hdrline.c:237
struct Address * from
Definition: envelope.h:35
From: string.
Definition: hdrline.c:236
struct Address * bcc
Definition: envelope.h:38
static const char * make_from_prefix(enum FieldType disp)
Create a prefix for an author field.
Definition: hdrline.c:270
const char * mutt_get_name(struct Address *a)
Pick the best name to display from an address.
Definition: sort.c:153
do not prepend DISP_TO, DISP_CC ...
Definition: format_flags.h:41
To: string.
Definition: hdrline.c:233
FieldType
Header types.
Definition: hdrline.c:231
struct Address * cc
Definition: envelope.h:37
bool mutt_addr_is_user(struct Address *addr)
Does the address belong to the user.
Definition: alias.c:676

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void make_from_addr ( struct Envelope hdr,
char *  buf,
size_t  buflen,
bool  do_lists 
)
static

Create a 'from' address for a reply email.

Parameters
hdrEnvelope of current email
bufBuffer for the result
buflenLength of buffer
do_listsIf true, check for mailing lists

Definition at line 360 of file hdrline.c.

361 {
362  if (!hdr || !buf)
363  return;
364 
365  bool me = mutt_addr_is_user(hdr->from);
366 
367  if (do_lists || me)
368  {
369  if (check_for_mailing_list_addr(hdr->to, buf, buflen))
370  return;
371  if (check_for_mailing_list_addr(hdr->cc, buf, buflen))
372  return;
373  }
374 
375  if (me && hdr->to)
376  snprintf(buf, buflen, "%s", hdr->to->mailbox);
377  else if (me && hdr->cc)
378  snprintf(buf, buflen, "%s", hdr->cc->mailbox);
379  else if (hdr->from)
380  mutt_str_strfcpy(buf, hdr->from->mailbox, buflen);
381  else
382  *buf = 0;
383 }
struct Address * to
Definition: envelope.h:36
char * mailbox
mailbox and host address
Definition: address.h:35
struct Address * from
Definition: envelope.h:35
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:742
static bool check_for_mailing_list_addr(struct Address *addr, char *buf, int buflen)
Check an address list for a mailing list.
Definition: hdrline.c:155
struct Address * cc
Definition: envelope.h:37
bool mutt_addr_is_user(struct Address *addr)
Does the address belong to the user.
Definition: alias.c:676

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool user_in_addr ( struct Address a)
static

Do any of the addresses refer to the user?

Parameters
aAddress list
Return values
trueIf any of the addresses match one of the user's addresses

Definition at line 390 of file hdrline.c.

391 {
392  for (; a; a = a->next)
393  if (mutt_addr_is_user(a))
394  return true;
395  return false;
396 }
bool mutt_addr_is_user(struct Address *addr)
Does the address belong to the user.
Definition: alias.c:676
struct Address * next
Definition: address.h:39

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int user_is_recipient ( struct Email e)
static

Is the user a recipient of the message.

Parameters
eEmail to test
Return values
0User is not in list
1User is unique recipient
2User is in the TO list
3User is in the CC list
4User is originator
5Sent to a subscribed mailinglist
6User is in the Reply-To list

Definition at line 409 of file hdrline.c.

410 {
411  if (!e || !e->env)
412  return 0;
413 
414  struct Envelope *env = e->env;
415 
416  if (!e->recip_valid)
417  {
418  e->recip_valid = true;
419 
420  if (mutt_addr_is_user(env->from))
421  e->recipient = 4;
422  else if (user_in_addr(env->to))
423  {
424  if (env->to->next || env->cc)
425  e->recipient = 2; /* non-unique recipient */
426  else
427  e->recipient = 1; /* unique recipient */
428  }
429  else if (user_in_addr(env->cc))
430  e->recipient = 3;
431  else if (check_for_mailing_list(env->to, NULL, NULL, 0))
432  e->recipient = 5;
433  else if (check_for_mailing_list(env->cc, NULL, NULL, 0))
434  e->recipient = 5;
435  else if (user_in_addr(env->reply_to))
436  e->recipient = 6;
437  else
438  e->recipient = 0;
439  }
440 
441  return e->recipient;
442 }
struct Address * to
Definition: envelope.h:36
short recipient
user_is_recipient()&#39;s return value, cached
Definition: email.h:79
static bool check_for_mailing_list(struct Address *addr, const char *pfx, char *buf, int buflen)
Search list of addresses for a mailing list.
Definition: hdrline.c:132
struct Address * reply_to
Definition: envelope.h:40
struct Envelope * env
envelope information
Definition: email.h:91
struct Address * from
Definition: envelope.h:35
bool recip_valid
is_recipient is valid
Definition: email.h:56
struct Address * cc
Definition: envelope.h:37
The header of an email.
Definition: envelope.h:32
bool mutt_addr_is_user(struct Address *addr)
Does the address belong to the user.
Definition: alias.c:676
static bool user_in_addr(struct Address *a)
Do any of the addresses refer to the user?
Definition: hdrline.c:390
struct Address * next
Definition: address.h:39

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static char* apply_subject_mods ( struct Envelope env)
static

Apply regex modifications to the subject.

Parameters
envEnvelope of email
Return values
ptrModified subject
NULLNo modification made

Definition at line 450 of file hdrline.c.

451 {
452  if (!env)
453  return NULL;
454 
455  if (STAILQ_EMPTY(&SubjectRegexList))
456  return env->subject;
457 
458  if (!env->subject || *env->subject == '\0')
459  {
460  env->disp_subj = NULL;
461  return NULL;
462  }
463 
464  env->disp_subj = mutt_replacelist_apply(&SubjectRegexList, NULL, 0, env->subject);
465  return env->disp_subj;
466 }
char * disp_subj
display subject (modified copy of subject)
Definition: envelope.h:46
char * mutt_replacelist_apply(struct ReplaceList *rl, char *buf, size_t buflen, const char *str)
Apply replacements to a buffer.
Definition: regex.c:348
char * subject
Definition: envelope.h:44
#define STAILQ_EMPTY(head)
Definition: queue.h:346

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool thread_is_new ( struct Context ctx,
struct Email e 
)
static

Does the email thread contain any new emails?

Parameters
ctxMailbox
eEmail
Return values
trueIf thread contains new mail

Definition at line 474 of file hdrline.c.

475 {
476  return e->collapsed && (e->num_hidden > 1) &&
477  (mutt_thread_contains_unread(ctx, e) == 1);
478 }
#define mutt_thread_contains_unread(x, y)
Definition: mutt_thread.h:62
size_t num_hidden
number of hidden messages in this view
Definition: email.h:77
bool collapsed
is this message part of a collapsed thread?
Definition: email.h:75

+ Here is the caller graph for this function:

static bool thread_is_old ( struct Context ctx,
struct Email e 
)
static

Does the email thread contain any unread emails?

Parameters
ctxMailbox
eEmail
Return values
trueIf thread contains unread mail

Definition at line 486 of file hdrline.c.

487 {
488  return e->collapsed && (e->num_hidden > 1) &&
489  (mutt_thread_contains_unread(ctx, e) == 2);
490 }
#define mutt_thread_contains_unread(x, y)
Definition: mutt_thread.h:62
size_t num_hidden
number of hidden messages in this view
Definition: email.h:77
bool collapsed
is this message part of a collapsed thread?
Definition: email.h:75

+ Here is the caller graph for this function:

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,
unsigned long  data,
enum FormatFlag  flags 
)
static

Format a string for the index list - Implements format_t.

Expando Description
%a Address of the author
%A Reply-to address (if present; otherwise: address of author)
%b Filename of the original message folder (think mailbox)
%B The list to which the letter was sent, or else the folder name (b).
%C Current message number
%c Number of characters (bytes) in the message
%D Date and time of message using $date_format and local timezone
%d Date and time of message using $date_format and sender's timezone
%e Current message number in thread
%E Number of messages in current thread
%F Author name, or recipient name if the message is from you
%Fp Like F, but plain. No contextual formatting is applied to recipient name
%f Sender (address + real name), either From: or Return-Path:
%g Message tags (e.g. notmuch tags/imap flags)
%Gx Individual message tag (e.g. notmuch tags/imap flags)
%H Spam attribute(s) of this message
%I Initials of author
%i Message-id of the current message
%J Message tags (if present, tree unfolded, and != parent's tags)
%K The list to which the letter was sent (if any; otherwise: empty)
%L Like F, except 'lists' are displayed first
%l Number of lines in the message
%M Number of hidden messages if the thread is collapsed
%m Total number of message in the mailbox
%N Message score
%n Author's real name (or address if missing)
%O Like L, except using address instead of name
%P Progress indicator for the built-in pager (how much of the file has been displayed)
%q Newsgroup name (if compiled with NNTP support)
%R Comma separated list of Cc: recipients
%r Comma separated list of To: recipients
%S Single character status of the message (N/O/D/d/!/r/-)
%s Subject of the message
%T The appropriate character from the $$to_chars string
%t 'To:' field (recipients)
%u User (login) name of the author
%v First name of the author, or the recipient if the message is from you
%W Name of organization of author ('Organization:' field)
%x 'X-Comment-To:' field (if present and compiled with NNTP support)
%X Number of MIME attachments
%Y 'X-Label:' field (if present, tree unfolded, and != parent's x-label)
%y 'X-Label:' field (if present)
%Z Combined message flags
%zc Message crypto flags
%zs Message status flags
%zt Message tag flags
%(fmt) Date/time when the message was received
%[fmt] Message date/time converted to the local time zone
%{fmt} Message date/time converted to sender's time zone

Definition at line 547 of file hdrline.c.

551 {
552  struct HdrFormatInfo *hfi = (struct HdrFormatInfo *) data;
553  char fmt[SHORT_STRING], tmp[LONG_STRING], *p, *tags = NULL;
554  const char *wch = NULL;
555  int i;
556  int optional = (flags & MUTT_FORMAT_OPTIONAL);
557  int threads = ((Sort & SORT_MASK) == SORT_THREADS);
558  int is_index = (flags & MUTT_FORMAT_INDEX);
559  size_t colorlen;
560 
561  struct Email *e = hfi->email;
562  struct Context *ctx = hfi->ctx;
563 
564  if (!e || !e->env)
565  return src;
566  buf[0] = 0;
567  switch (op)
568  {
569  case 'A':
570  case 'I':
571  if (op == 'A')
572  {
573  if (e->env->reply_to && e->env->reply_to->mailbox)
574  {
575  colorlen = add_index_color(buf, buflen, flags, MT_COLOR_INDEX_AUTHOR);
576  mutt_format_s(buf + colorlen, buflen - colorlen, prec,
578  add_index_color(buf + colorlen, buflen - colorlen, flags, MT_COLOR_INDEX);
579  break;
580  }
581  }
582  else
583  {
584  if (mutt_mb_get_initials(mutt_get_name(e->env->from), tmp, sizeof(tmp)))
585  {
586  colorlen = add_index_color(buf, buflen, flags, MT_COLOR_INDEX_AUTHOR);
587  mutt_format_s(buf + colorlen, buflen - colorlen, prec, tmp);
588  add_index_color(buf + colorlen, buflen - colorlen, flags, MT_COLOR_INDEX);
589  break;
590  }
591  }
592  /* fallthrough */
593 
594  case 'a':
595  colorlen = add_index_color(buf, buflen, flags, MT_COLOR_INDEX_AUTHOR);
596  if (e->env->from && e->env->from->mailbox)
597  {
598  mutt_format_s(buf + colorlen, buflen - colorlen, prec,
600  }
601  else
602  mutt_format_s(buf + colorlen, buflen - colorlen, prec, "");
603  add_index_color(buf + colorlen, buflen - colorlen, flags, MT_COLOR_INDEX);
604  break;
605 
606  case 'B':
607  case 'K':
608  if (!first_mailing_list(buf, buflen, e->env->to) &&
609  !first_mailing_list(buf, buflen, e->env->cc))
610  {
611  buf[0] = 0;
612  }
613  if (buf[0])
614  {
615  mutt_str_strfcpy(tmp, buf, sizeof(tmp));
616  mutt_format_s(buf, buflen, prec, tmp);
617  break;
618  }
619  if (op == 'K')
620  {
621  if (optional)
622  optional = 0;
623  /* break if 'K' returns nothing */
624  break;
625  }
626  /* if 'B' returns nothing */
627  /* fallthrough */
628 
629  case 'b':
630  if (ctx)
631  {
632  p = strrchr(ctx->mailbox->path, '/');
633  if (p)
634  mutt_str_strfcpy(buf, p + 1, buflen);
635  else
636  mutt_str_strfcpy(buf, ctx->mailbox->path, buflen);
637  }
638  else
639  mutt_str_strfcpy(buf, "(null)", buflen);
640  mutt_str_strfcpy(tmp, buf, sizeof(tmp));
641  mutt_format_s(buf, buflen, prec, tmp);
642  break;
643 
644  case 'c':
645  colorlen = add_index_color(buf, buflen, flags, MT_COLOR_INDEX_SIZE);
646  mutt_str_pretty_size(tmp, sizeof(tmp), (long) e->content->length);
647  mutt_format_s(buf + colorlen, buflen - colorlen, prec, tmp);
648  add_index_color(buf + colorlen, buflen - colorlen, flags, MT_COLOR_INDEX);
649  break;
650 
651  case 'C':
652  colorlen = add_index_color(fmt, sizeof(fmt), flags, MT_COLOR_INDEX_NUMBER);
653  snprintf(fmt + colorlen, sizeof(fmt) - colorlen, "%%%sd", prec);
654  add_index_color(fmt + colorlen, sizeof(fmt) - colorlen, flags, MT_COLOR_INDEX);
655  snprintf(buf, buflen, fmt, e->msgno + 1);
656  break;
657 
658  case 'd':
659  case 'D':
660  case '{':
661  case '[':
662  case '(':
663  case '<':
664  /* preprocess $date_format to handle %Z */
665  {
666  const char *cp = NULL;
667  struct tm *tm = NULL;
668  time_t T;
669  int j = 0;
670 
671  if (optional && ((op == '[') || (op == '(')))
672  {
673  char *is = NULL;
674  T = time(NULL);
675  tm = localtime(&T);
676  T -= (op == '(') ? e->received : e->date_sent;
677 
678  is = (char *) prec;
679  int invert = 0;
680  if (*is == '>')
681  {
682  invert = 1;
683  is++;
684  }
685 
686  while (*is && (*is != '?'))
687  {
688  int t = strtol(is, &is, 10);
689  /* semi-broken (assuming 30 days in all months) */
690  switch (*(is++))
691  {
692  case 'y':
693  if (t > 1)
694  {
695  t--;
696  t *= (60 * 60 * 24 * 365);
697  }
698  t += ((tm->tm_mon * 60 * 60 * 24 * 30) + (tm->tm_mday * 60 * 60 * 24) +
699  (tm->tm_hour * 60 * 60) + (tm->tm_min * 60) + tm->tm_sec);
700  break;
701 
702  case 'm':
703  if (t > 1)
704  {
705  t--;
706  t *= (60 * 60 * 24 * 30);
707  }
708  t += ((tm->tm_mday * 60 * 60 * 24) + (tm->tm_hour * 60 * 60) +
709  (tm->tm_min * 60) + tm->tm_sec);
710  break;
711 
712  case 'w':
713  if (t > 1)
714  {
715  t--;
716  t *= (60 * 60 * 24 * 7);
717  }
718  t += ((tm->tm_wday * 60 * 60 * 24) + (tm->tm_hour * 60 * 60) +
719  (tm->tm_min * 60) + tm->tm_sec);
720  break;
721 
722  case 'd':
723  if (t > 1)
724  {
725  t--;
726  t *= (60 * 60 * 24);
727  }
728  t += ((tm->tm_hour * 60 * 60) + (tm->tm_min * 60) + tm->tm_sec);
729  break;
730 
731  case 'H':
732  if (t > 1)
733  {
734  t--;
735  t *= (60 * 60);
736  }
737  t += ((tm->tm_min * 60) + tm->tm_sec);
738  break;
739 
740  case 'M':
741  if (t > 1)
742  {
743  t--;
744  t *= (60);
745  }
746  t += (tm->tm_sec);
747  break;
748 
749  default:
750  break;
751  }
752  j += t;
753  }
754 
755  if (j < 0)
756  j *= -1;
757 
758  if (((T > j) || (T < (-1 * j))) ^ invert)
759  optional = 0;
760  break;
761  }
762 
763  p = buf;
764 
765  cp = (op == 'd' || op == 'D') ? (NONULL(DateFormat)) : src;
766  bool do_locales;
767  if (*cp == '!')
768  {
769  do_locales = false;
770  cp++;
771  }
772  else
773  do_locales = true;
774 
775  size_t len = buflen - 1;
776  while (len > 0 && (((op == 'd' || op == 'D') && *cp) ||
777  (op == '{' && *cp != '}') || (op == '[' && *cp != ']') ||
778  (op == '(' && *cp != ')') || (op == '<' && *cp != '>')))
779  {
780  if (*cp == '%')
781  {
782  cp++;
783  if ((*cp == 'Z' || *cp == 'z') && (op == 'd' || op == '{'))
784  {
785  if (len >= 5)
786  {
787  sprintf(p, "%c%02u%02u", e->zoccident ? '-' : '+', e->zhours, e->zminutes);
788  p += 5;
789  len -= 5;
790  }
791  else
792  break; /* not enough space left */
793  }
794  else
795  {
796  if (len >= 2)
797  {
798  *p++ = '%';
799  *p++ = *cp;
800  len -= 2;
801  }
802  else
803  break; /* not enough space */
804  }
805  cp++;
806  }
807  else
808  {
809  *p++ = *cp++;
810  len--;
811  }
812  }
813  *p = 0;
814 
815  if (op == '[' || op == 'D')
816  tm = localtime(&e->date_sent);
817  else if (op == '(')
818  tm = localtime(&e->received);
819  else if (op == '<')
820  {
821  T = time(NULL);
822  tm = localtime(&T);
823  }
824  else
825  {
826  /* restore sender's time zone */
827  T = e->date_sent;
828  if (e->zoccident)
829  T -= (e->zhours * 3600 + e->zminutes * 60);
830  else
831  T += (e->zhours * 3600 + e->zminutes * 60);
832  tm = gmtime(&T);
833  }
834 
835  if (!do_locales)
836  setlocale(LC_TIME, "C");
837  strftime(tmp, sizeof(tmp), buf, tm);
838  if (!do_locales)
839  setlocale(LC_TIME, "");
840 
841  colorlen = add_index_color(buf, buflen, flags, MT_COLOR_INDEX_DATE);
842  mutt_format_s(buf + colorlen, buflen - colorlen, prec, tmp);
843  add_index_color(buf + colorlen, buflen - colorlen, flags, MT_COLOR_INDEX);
844 
845  if (len > 0 && op != 'd' && op != 'D') /* Skip ending op */
846  src = cp + 1;
847  }
848  break;
849 
850  case 'e':
851  snprintf(fmt, sizeof(fmt), "%%%sd", prec);
852  snprintf(buf, buflen, fmt, mutt_messages_in_thread(ctx->mailbox, e, 1));
853  break;
854 
855  case 'E':
856  if (!optional)
857  {
858  snprintf(fmt, sizeof(fmt), "%%%sd", prec);
859  snprintf(buf, buflen, fmt, mutt_messages_in_thread(ctx->mailbox, e, 0));
860  }
861  else if (mutt_messages_in_thread(ctx->mailbox, e, 0) <= 1)
862  optional = 0;
863  break;
864 
865  case 'f':
866  tmp[0] = 0;
867  mutt_addr_write(tmp, sizeof(tmp), e->env->from, true);
868  mutt_format_s(buf, buflen, prec, tmp);
869  break;
870 
871  case 'F':
872  if (!optional)
873  {
874  const bool is_plain = (src[0] == 'p');
875  colorlen = add_index_color(buf, buflen, flags, MT_COLOR_INDEX_AUTHOR);
876  make_from(e->env, tmp, sizeof(tmp), false, (is_plain ? MUTT_FORMAT_PLAIN : 0));
877  mutt_format_s(buf + colorlen, buflen - colorlen, prec, tmp);
878  add_index_color(buf + colorlen, buflen - colorlen, flags, MT_COLOR_INDEX);
879 
880  if (is_plain)
881  src++;
882  }
883  else if (mutt_addr_is_user(e->env->from))
884  {
885  optional = 0;
886  }
887  break;
888 
889  case 'g':
890  tags = driver_tags_get_transformed(&e->tags);
891  if (!optional)
892  {
893  colorlen = add_index_color(buf, buflen, flags, MT_COLOR_INDEX_TAGS);
894  mutt_format_s(buf + colorlen, buflen - colorlen, prec, NONULL(tags));
895  add_index_color(buf + colorlen, buflen - colorlen, flags, MT_COLOR_INDEX);
896  }
897  else if (!tags)
898  optional = 0;
899  FREE(&tags);
900  break;
901 
902  case 'G':
903  {
904  char format[3];
905  char *tag = NULL;
906 
907  if (!optional)
908  {
909  format[0] = op;
910  format[1] = *src;
911  format[2] = 0;
912 
913  tag = mutt_hash_find(TagFormats, format);
914  if (tag)
915  {
916  tags = driver_tags_get_transformed_for(tag, &e->tags);
917  colorlen = add_index_color(buf, buflen, flags, MT_COLOR_INDEX_TAG);
918  mutt_format_s(buf + colorlen, buflen - colorlen, prec, NONULL(tags));
919  add_index_color(buf + colorlen, buflen - colorlen, flags, MT_COLOR_INDEX);
920  FREE(&tags);
921  }
922  src++;
923  }
924  else
925  {
926  format[0] = op;
927  format[1] = *prec;
928  format[2] = 0;
929 
930  tag = mutt_hash_find(TagFormats, format);
931  if (tag)
932  {
933  tags = driver_tags_get_transformed_for(tag, &e->tags);
934  if (!tags)
935  optional = 0;
936  FREE(&tags);
937  }
938  }
939  }
940  break;
941 
942  case 'H':
943  /* (Hormel) spam score */
944  if (optional)
945  optional = e->env->spam ? 1 : 0;
946 
947  if (e->env->spam)
948  mutt_format_s(buf, buflen, prec, NONULL(e->env->spam->data));
949  else
950  mutt_format_s(buf, buflen, prec, "");
951  break;
952 
953  case 'i':
954  mutt_format_s(buf, buflen, prec, e->env->message_id ? e->env->message_id : "<no.id>");
955  break;
956 
957  case 'J':
958  tags = driver_tags_get_transformed(&e->tags);
959  if (tags)
960  {
961  i = 1; /* reduce reuse recycle */
962  if (flags & MUTT_FORMAT_TREE)
963  {
964  char *parent_tags = NULL;
965  if (e->thread->prev && e->thread->prev->message)
966  {
967  parent_tags = driver_tags_get_transformed(&e->thread->prev->message->tags);
968  }
969  if (!parent_tags && e->thread->parent && e->thread->parent->message)
970  {
971  parent_tags =
973  }
974  if (parent_tags && mutt_str_strcasecmp(tags, parent_tags) == 0)
975  i = 0;
976  FREE(&parent_tags);
977  }
978  }
979  else
980  i = 0;
981 
982  if (optional)
983  optional = i;
984 
985  colorlen = add_index_color(buf, buflen, flags, MT_COLOR_INDEX_TAGS);
986  if (i)
987  mutt_format_s(buf + colorlen, buflen - colorlen, prec, tags);
988  else
989  mutt_format_s(buf + colorlen, buflen - colorlen, prec, "");
990  add_index_color(buf + colorlen, buflen - colorlen, flags, MT_COLOR_INDEX);
991  FREE(&tags);
992  break;
993 
994  case 'l':
995  if (!optional)
996  {
997  snprintf(fmt, sizeof(fmt), "%%%sd", prec);
998  colorlen = add_index_color(buf, buflen, flags, MT_COLOR_INDEX_SIZE);
999  snprintf(buf + colorlen, buflen - colorlen, fmt, (int) e->lines);
1000  add_index_color(buf + colorlen, buflen - colorlen, flags, MT_COLOR_INDEX);
1001  }
1002  else if (e->lines <= 0)
1003  optional = 0;
1004  break;
1005 
1006  case 'L':
1007  if (!optional)
1008  {
1009  colorlen = add_index_color(buf, buflen, flags, MT_COLOR_INDEX_AUTHOR);
1010  make_from(e->env, tmp, sizeof(tmp), true, flags);
1011  mutt_format_s(buf + colorlen, buflen - colorlen, prec, tmp);
1012  add_index_color(buf + colorlen, buflen - colorlen, flags, MT_COLOR_INDEX);
1013  }
1014  else if (!check_for_mailing_list(e->env->to, NULL, NULL, 0) &&
1015  !check_for_mailing_list(e->env->cc, NULL, NULL, 0))
1016  {
1017  optional = 0;
1018  }
1019  break;
1020 
1021  case 'm':
1022  if (ctx)
1023  {
1024  snprintf(fmt, sizeof(fmt), "%%%sd", prec);
1025  snprintf(buf, buflen, fmt, ctx->mailbox->msg_count);
1026  }
1027  else
1028  mutt_str_strfcpy(buf, "(null)", buflen);
1029  break;
1030 
1031  case 'n':
1032  colorlen = add_index_color(buf, buflen, flags, MT_COLOR_INDEX_AUTHOR);
1033  mutt_format_s(buf + colorlen, buflen - colorlen, prec,
1034  mutt_get_name(e->env->from));
1035  add_index_color(buf + colorlen, buflen - colorlen, flags, MT_COLOR_INDEX);
1036  break;
1037 
1038  case 'M':
1039  snprintf(fmt, sizeof(fmt), "%%%sd", prec);
1040  if (!optional)
1041  {
1042  colorlen = add_index_color(buf, buflen, flags, MT_COLOR_INDEX_COLLAPSED);
1043  if (threads && is_index && e->collapsed && e->num_hidden > 1)
1044  {
1045  snprintf(buf + colorlen, buflen - colorlen, fmt, e->num_hidden);
1046  add_index_color(buf, buflen - colorlen, flags, MT_COLOR_INDEX);
1047  }
1048  else if (is_index && threads)
1049  {
1050  mutt_format_s(buf + colorlen, buflen - colorlen, prec, " ");
1051  add_index_color(buf, buflen - colorlen, flags, MT_COLOR_INDEX);
1052  }
1053  else
1054  *buf = '\0';
1055  }
1056  else
1057  {
1058  if (!(threads && is_index && e->collapsed && e->num_hidden > 1))
1059  optional = 0;
1060  }
1061  break;
1062 
1063  case 'N':
1064  if (!optional)
1065  {
1066  snprintf(fmt, sizeof(fmt), "%%%sd", prec);
1067  snprintf(buf, buflen, fmt, e->score);
1068  }
1069  else
1070  {
1071  if (e->score == 0)
1072  optional = 0;
1073  }
1074  break;
1075 
1076  case 'O':
1077  if (!optional)
1078  {
1079  make_from_addr(e->env, tmp, sizeof(tmp), true);
1080  if (!SaveAddress && (p = strpbrk(tmp, "%@")))
1081  *p = 0;
1082  mutt_format_s(buf, buflen, prec, tmp);
1083  }
1084  else if (!check_for_mailing_list_addr(e->env->to, NULL, 0) &&
1085  !check_for_mailing_list_addr(e->env->cc, NULL, 0))
1086  {
1087  optional = 0;
1088  }
1089  break;
1090 
1091  case 'P':
1092  mutt_str_strfcpy(buf, hfi->pager_progress, buflen);
1093  break;
1094 
1095 #ifdef USE_NNTP
1096  case 'q':
1097  mutt_format_s(buf, buflen, prec, e->env->newsgroups ? e->env->newsgroups : "");
1098  break;
1099 #endif
1100 
1101  case 'r':
1102  tmp[0] = 0;
1103  mutt_addr_write(tmp, sizeof(tmp), e->env->to, true);
1104  if (optional && tmp[0] == '\0')
1105  optional = 0;
1106  mutt_format_s(buf, buflen, prec, tmp);
1107  break;
1108 
1109  case 'R':
1110  tmp[0] = 0;
1111  mutt_addr_write(tmp, sizeof(tmp), e->env->cc, true);
1112  if (optional && tmp[0] == '\0')
1113  optional = 0;
1114  mutt_format_s(buf, buflen, prec, tmp);
1115  break;
1116 
1117  case 's':
1118  {
1119  char *subj = NULL;
1120  if (e->env->disp_subj)
1121  subj = e->env->disp_subj;
1122  else if (!STAILQ_EMPTY(&SubjectRegexList))
1123  subj = apply_subject_mods(e->env);
1124  else
1125  subj = e->env->subject;
1126  if (flags & MUTT_FORMAT_TREE && !e->collapsed)
1127  {
1128  if (flags & MUTT_FORMAT_FORCESUBJ)
1129  {
1130  colorlen = add_index_color(buf, buflen, flags, MT_COLOR_INDEX_SUBJECT);
1131  mutt_format_s(buf + colorlen, buflen - colorlen, "", NONULL(subj));
1132  add_index_color(buf + colorlen, buflen - colorlen, flags, MT_COLOR_INDEX);
1133  snprintf(tmp, sizeof(tmp), "%s%s", e->tree, buf);
1134  mutt_format_s_tree(buf, buflen, prec, tmp);
1135  }
1136  else
1137  mutt_format_s_tree(buf, buflen, prec, e->tree);
1138  }
1139  else
1140  {
1141  colorlen = add_index_color(buf, buflen, flags, MT_COLOR_INDEX_SUBJECT);
1142  mutt_format_s(buf + colorlen, buflen - colorlen, prec, NONULL(subj));
1143  add_index_color(buf + colorlen, buflen - colorlen, flags, MT_COLOR_INDEX);
1144  }
1145  }
1146  break;
1147 
1148  case 'S':
1149  if (e->deleted)
1151  else if (e->attach_del)
1153  else if (e->tagged)
1155  else if (e->flagged)
1157  else if (e->replied)
1159  else if (e->read && (ctx && ctx->msgnotreadyet != e->msgno))
1161  else if (e->old)
1163  else
1165 
1166  snprintf(tmp, sizeof(tmp), "%s", wch);
1167  colorlen = add_index_color(buf, buflen, flags, MT_COLOR_INDEX_FLAGS);
1168  mutt_format_s(buf + colorlen, buflen - colorlen, prec, tmp);
1169  add_index_color(buf + colorlen, buflen - colorlen, flags, MT_COLOR_INDEX);
1170  break;
1171 
1172  case 't':
1173  tmp[0] = 0;
1174  if (!check_for_mailing_list(e->env->to, "To ", tmp, sizeof(tmp)) &&
1175  !check_for_mailing_list(e->env->cc, "Cc ", tmp, sizeof(tmp)))
1176  {
1177  if (e->env->to)
1178  snprintf(tmp, sizeof(tmp), "To %s", mutt_get_name(e->env->to));
1179  else if (e->env->cc)
1180  snprintf(tmp, sizeof(tmp), "Cc %s", mutt_get_name(e->env->cc));
1181  }
1182  mutt_format_s(buf, buflen, prec, tmp);
1183  break;
1184 
1185  case 'T':
1186  snprintf(fmt, sizeof(fmt), "%%%ss", prec);
1187  snprintf(buf, buflen, fmt,
1188  (ToChars && ((i = user_is_recipient(e))) < ToChars->len) ?
1189  ToChars->chars[i] :
1190  " ");
1191  break;
1192 
1193  case 'u':
1194  if (e->env->from && e->env->from->mailbox)
1195  {
1196  mutt_str_strfcpy(tmp, mutt_addr_for_display(e->env->from), sizeof(tmp));
1197  p = strpbrk(tmp, "%@");
1198  if (p)
1199  *p = 0;
1200  }
1201  else
1202  tmp[0] = 0;
1203  mutt_format_s(buf, buflen, prec, tmp);
1204  break;
1205 
1206  case 'v':
1207  if (mutt_addr_is_user(e->env->from))
1208  {
1209  if (e->env->to)
1210  mutt_format_s(tmp, sizeof(tmp), prec, mutt_get_name(e->env->to));
1211  else if (e->env->cc)
1212  mutt_format_s(tmp, sizeof(tmp), prec, mutt_get_name(e->env->cc));
1213  else
1214  *tmp = 0;
1215  }
1216  else
1217  mutt_format_s(tmp, sizeof(tmp), prec, mutt_get_name(e->env->from));
1218  p = strpbrk(tmp, " %@");
1219  if (p)
1220  *p = 0;
1221  mutt_format_s(buf, buflen, prec, tmp);
1222  break;
1223 
1224  case 'W':
1225  if (!optional)
1226  {
1227  mutt_format_s(buf, buflen, prec, e->env->organization ? e->env->organization : "");
1228  }
1229  else if (!e->env->organization)
1230  optional = 0;
1231  break;
1232 
1233 #ifdef USE_NNTP
1234  case 'x':
1235  if (!optional)
1236  {
1237  mutt_format_s(buf, buflen, prec, e->env->x_comment_to ? e->env->x_comment_to : "");
1238  }
1239  else if (!e->env->x_comment_to)
1240  optional = 0;
1241  break;
1242 #endif
1243 
1244  case 'X':
1245  {
1246  int count = mutt_count_body_parts(ctx->mailbox, e);
1247 
1248  /* The recursion allows messages without depth to return 0. */
1249  if (optional)
1250  optional = count != 0;
1251 
1252  snprintf(fmt, sizeof(fmt), "%%%sd", prec);
1253  snprintf(buf, buflen, fmt, count);
1254  }
1255  break;
1256 
1257  case 'y':
1258  if (optional)
1259  optional = e->env->x_label ? 1 : 0;
1260 
1261  colorlen = add_index_color(buf, buflen, flags, MT_COLOR_INDEX_LABEL);
1262  mutt_format_s(buf + colorlen, buflen - colorlen, prec, NONULL(e->env->x_label));
1263  add_index_color(buf + colorlen, buflen - colorlen, flags, MT_COLOR_INDEX);
1264  break;
1265 
1266  case 'Y':
1267  if (e->env->x_label)
1268  {
1269  i = 1; /* reduce reuse recycle */
1270  struct Email *etmp = NULL;
1271  if (flags & MUTT_FORMAT_TREE && (e->thread->prev && e->thread->prev->message &&
1272  e->thread->prev->message->env->x_label))
1273  {
1274  etmp = e->thread->prev->message;
1275  }
1276  else if (flags & MUTT_FORMAT_TREE &&
1277  (e->thread->parent && e->thread->parent->message &&
1278  e->thread->parent->message->env->x_label))
1279  {
1280  etmp = e->thread->parent->message;
1281  }
1282  if (etmp && (mutt_str_strcasecmp(e->env->x_label, etmp->env->x_label) == 0))
1283  i = 0;
1284  }
1285  else
1286  i = 0;
1287 
1288  if (optional)
1289  optional = i;
1290 
1291  colorlen = add_index_color(buf, buflen, flags, MT_COLOR_INDEX_LABEL);
1292  if (i)
1293  mutt_format_s(buf + colorlen, buflen - colorlen, prec, NONULL(e->env->x_label));
1294  else
1295  mutt_format_s(buf + colorlen, buflen - colorlen, prec, "");
1296  add_index_color(buf + colorlen, buflen - colorlen, flags, MT_COLOR_INDEX);
1297  break;
1298 
1299  case 'z':
1300  if (src[0] == 's') /* status: deleted/new/old/replied */
1301  {
1302  const char *ch = NULL;
1303  if (e->deleted)
1305  else if (e->attach_del)
1307  else if (threads && thread_is_new(ctx, e))
1309  else if (threads && thread_is_old(ctx, e))
1311  else if (e->read && (ctx && (ctx->msgnotreadyet != e->msgno)))
1312  {
1313  if (e->replied)
1315  else
1317  }
1318  else
1319  {
1320  if (e->old)
1322  else
1324  }
1325 
1326  snprintf(tmp, sizeof(tmp), "%s", ch);
1327  src++;
1328  }
1329  else if (src[0] == 'c') /* crypto */
1330  {
1331  const char *ch = NULL;
1332  if ((WithCrypto != 0) && (e->security & GOODSIGN))
1334  else if ((WithCrypto != 0) && (e->security & ENCRYPT))
1336  else if ((WithCrypto != 0) && (e->security & SIGN))
1338  else if (((WithCrypto & APPLICATION_PGP) != 0) && ((e->security & PGP_KEY) == PGP_KEY))
1339  {
1341  }
1342  else
1344 
1345  snprintf(tmp, sizeof(tmp), "%s", ch);
1346  src++;
1347  }
1348  else if (src[0] == 't') /* tagged, flagged, recipient */
1349  {
1350  const char *ch = NULL;
1351  if (e->tagged)
1353  else if (e->flagged)
1355  else
1357 
1358  snprintf(tmp, sizeof(tmp), "%s", ch);
1359  src++;
1360  }
1361  else /* fallthrough */
1362  break;
1363 
1364  colorlen = add_index_color(buf, buflen, flags, MT_COLOR_INDEX_FLAGS);
1365  mutt_format_s(buf + colorlen, buflen - colorlen, prec, tmp);
1366  add_index_color(buf + colorlen, buflen - colorlen, flags, MT_COLOR_INDEX);
1367  break;
1368 
1369  case 'Z':
1370  {
1371  /* New/Old for threads; replied; New/Old for messages */
1372  const char *first = NULL;
1373  if (threads && thread_is_new(ctx, e))
1375  else if (threads && thread_is_old(ctx, e))
1377  else if (e->read && (ctx && (ctx->msgnotreadyet != e->msgno)))
1378  {
1379  if (e->replied)
1381  else
1383  }
1384  else
1385  {
1386  if (e->old)
1388  else
1390  }
1391 
1392  /* Marked for deletion; deleted attachments; crypto */
1393  const char *second = NULL;
1394  if (e->deleted)
1396  else if (e->attach_del)
1398  else if ((WithCrypto != 0) && (e->security & GOODSIGN))
1400  else if ((WithCrypto != 0) && (e->security & ENCRYPT))
1402  else if ((WithCrypto != 0) && (e->security & SIGN))
1404  else if (((WithCrypto & APPLICATION_PGP) != 0) && (e->security & PGP_KEY))
1406  else
1408 
1409  /* Tagged, flagged and recipient flag */
1410  const char *third = NULL;
1411  if (e->tagged)
1413  else if (e->flagged)
1415  else
1417 
1418  snprintf(tmp, sizeof(tmp), "%s%s%s", first, second, third);
1419  }
1420 
1421  colorlen = add_index_color(buf, buflen, flags, MT_COLOR_INDEX_FLAGS);
1422  mutt_format_s(buf + colorlen, buflen - colorlen, prec, tmp);
1423  add_index_color(buf + colorlen, buflen - colorlen, flags, MT_COLOR_INDEX);
1424  break;
1425 
1426  default:
1427  snprintf(buf, buflen, "%%%s%c", prec, op);
1428  break;
1429  }
1430 
1431  if (optional)
1432  {
1433  mutt_expando_format(buf, buflen, col, cols, if_str, index_format_str,
1434  (unsigned long) hfi, flags);
1435  }
1436  else if (flags & MUTT_FORMAT_OPTIONAL)
1437  {
1438  mutt_expando_format(buf, buflen, col, cols, else_str, index_format_str,
1439  (unsigned long) hfi, flags);
1440  }
1441 
1442  return src;
1443 }
static void make_from(struct Envelope *env, char *buf, size_t buflen, bool do_lists, enum FormatFlag flags)
Generate a From: field (with optional prefix)
Definition: hdrline.c:304
Index: subject field (takes a pattern)
Definition: mutt_curses.h:159
FlagChars
Index into the FlagChars variable ($flag_chars)
Definition: hdrline.c:66
struct Context * ctx
Definition: hdrline.h:45
The "current" mailbox.
Definition: context.h:36
Character denoting a tagged email.
Definition: hdrline.c:68
#define SIGN
Definition: ncrypt.h:120
Character denoting a important (flagged) email.
Definition: hdrline.c:69
int lines
how many lines in the body of this message?
Definition: email.h:86
#define NONULL(x)
Definition: string2.h:39
int msg_count
total number of messages
Definition: mailbox.h:86
#define SHORT_STRING
Definition: string2.h:34
The envelope/body of an email.
Definition: email.h:35
char ** chars
The array of multibyte character strings.
Definition: mbtable.h:39
Index: tags field (g, J)
Definition: mutt_curses.h:166
unsigned int security
bit 0-8: flags, bit 9,10: application.
Definition: email.h:37
struct Address * to
Definition: envelope.h:36
WHERE bool SaveAddress
Config: Use sender&#39;s full address as a default save folder.
Definition: globals.h:250
struct MuttThread * thread
Definition: email.h:96
static bool thread_is_new(struct Context *ctx, struct Email *e)
Does the email thread contain any new emails?
Definition: hdrline.c:474
char * disp_subj
display subject (modified copy of subject)
Definition: envelope.h:46
Character denoting a thread containing at least one new email.
Definition: hdrline.c:76
bool attach_del
has an attachment marked for deletion
Definition: email.h:47
char * driver_tags_get_transformed_for(char *name, struct TagHead *head)
Get transformed tag for a tag name from a header.
Definition: tags.c:177
struct Body * content
list of MIME parts
Definition: email.h:92
int msgnotreadyet
which msg "new" in pager, -1 if none
Definition: context.h:44
void * mutt_hash_find(const struct Hash *table, const char *strkey)
Find the HashElem data in a Hash table element using a key.
Definition: hash.c:374
WHERE char * DateFormat
Config: strftime format string for the d expando.
Definition: globals.h:107
WHERE struct Hash * TagFormats
Hash table of tag-formats (tag -> format string)
Definition: globals.h:59
Character denoting a message contains a PGP key.
Definition: hdrline.c:89
struct MuttThread * parent
Definition: thread.h:44
char * mailbox
mailbox and host address
Definition: address.h:35
Character denoting a read email, $index_format S expando.
Definition: hdrline.c:77
struct TagHead tags
for drivers that support server tagging
Definition: email.h:109
char * driver_tags_get_transformed(struct TagHead *head)
Get transformed tags.
Definition: tags.c:138
#define LONG_STRING
Definition: string2.h:36
bool zoccident
Definition: email.h:65
static char * apply_subject_mods(struct Envelope *env)
Apply regex modifications to the subject.
Definition: hdrline.c:450
static bool check_for_mailing_list(struct Address *addr, const char *pfx, char *buf, int buflen)
Search list of addresses for a mailing list.
Definition: hdrline.c:132
struct Address * reply_to
Definition: envelope.h:40
size_t mutt_addr_write(char *buf, size_t buflen, struct Address *addr, bool display)
Write an Address to a buffer.
Definition: address.c:1146
bool tagged
Definition: email.h:42
bool read
Definition: email.h:49
char * message_id
Definition: envelope.h:47
struct MuttThread * prev
Definition: thread.h:47
struct Mailbox * mailbox
Definition: context.h:50
bool old
Definition: email.h:48
Data passed to index_format_str()
Definition: hdrline.h:43
this is a main index entry
Definition: format_flags.h:39
Index: default colour (takes a pattern)
Definition: mutt_curses.h:155
struct Envelope * env
envelope information
Definition: email.h:91
Character denoting a deleted attachment.
Definition: hdrline.c:71
Index: index number.
Definition: mutt_curses.h:164
allow optional field processing
Definition: format_flags.h:36
Character denoting an email that has been read.
Definition: hdrline.c:73
static int user_is_recipient(struct Email *e)
Is the user a recipient of the message.
Definition: hdrline.c:409
Character denoting a thread of emails that has been read.
Definition: hdrline.c:75
static bool first_mailing_list(char *buf, size_t buflen, struct Address *a)
Get the first mailing list in the list of addresses.
Definition: hdrline.c:176
struct Address * from
Definition: envelope.h:35
static size_t add_index_color(char *buf, size_t buflen, enum FormatFlag flags, char color)
Insert a color marker into a string.
Definition: hdrline.c:199
int score
Definition: email.h:90
time_t date_sent
time when the message was sent (UTC)
Definition: email.h:83
static void make_from_addr(struct Envelope *hdr, char *buf, size_t buflen, bool do_lists)
Create a &#39;from&#39; address for a reply email.
Definition: hdrline.c:360
#define ENCRYPT
Definition: ncrypt.h:119
char * x_comment_to
Definition: envelope.h:56
Index: tag field (g, takes a pattern)
Definition: mutt_curses.h:158
Index: flags field (takes a pattern)
Definition: mutt_curses.h:157
Character denoting an email that has been replied to.
Definition: hdrline.c:72
Index: date field.
Definition: mutt_curses.h:162
LOFF_T length
length (in bytes) of attachment
Definition: body.h:46
#define SORT_THREADS
Sort by email threads.
Definition: sort.h:51
size_t num_hidden
number of hidden messages in this view
Definition: email.h:77
#define PGP_KEY
Definition: ncrypt.h:137
static bool thread_is_old(struct Context *ctx, struct Email *e)
Does the email thread contain any unread emails?
Definition: hdrline.c:486
Index: author field (takes a pattern)
Definition: mutt_curses.h:156
Character denoting a message signed with a verified key.
Definition: hdrline.c:86
char * data
pointer to data
Definition: buffer.h:35
bool mutt_mb_get_initials(const char *name, char *buf, size_t buflen)
Turn a name into initials.
Definition: mbyte.c:84
draw the thread tree
Definition: format_flags.h:34
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:742
bool collapsed
is this message part of a collapsed thread?
Definition: email.h:75
Character denoting a message is PGP-encrypted.
Definition: hdrline.c:87
int mutt_messages_in_thread(struct Mailbox *m, struct Email *e, int flag)
Count the messages in a thread.
Definition: mutt_thread.c:1397
CryptChars
Index into the CryptChars variable ($crypt_chars)
Definition: hdrline.c:84
unsigned int zhours
Definition: email.h:63
char * tree
character string to print thread tree
Definition: email.h:95
struct Email * message
Definition: thread.h:48
static const char * get_nth_wchar(struct MbTable *table, int index)
Extract one char from a multi-byte table.
Definition: hdrline.c:251
#define APPLICATION_PGP
Definition: ncrypt.h:129
char path[PATH_MAX]
Definition: mailbox.h:78
Character denoting a read email, $index_format Z expando.
Definition: hdrline.c:78
const char * mutt_get_name(struct Address *a)
Pick the best name to display from an address.
Definition: sort.c:153
struct Buffer * spam
Definition: envelope.h:58
char * subject
Definition: envelope.h:44
void mutt_format_s(char *buf, size_t buflen, const char *prec, const char *s)
Format a simple string.
Definition: curs_lib.c:1061
bool flagged
marked important?
Definition: email.h:41
char * newsgroups
Definition: envelope.h:53
do not prepend DISP_TO, DISP_CC ...
Definition: format_flags.h:41
WHERE short Sort
Config: Sort method for the index.
Definition: sort.h:58
Character denoting a deleted email.
Definition: hdrline.c:70
bool deleted
Definition: email.h:43
Index: size field.
Definition: mutt_curses.h:165
bool replied
Definition: email.h:52
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:625
const char * mutt_addr_for_display(struct Address *a)
Convert an Address for display purposes.
Definition: address.c:986
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, unsigned long data, enum FormatFlag flags)
Format a string for the index list - Implements format_t.
Definition: hdrline.c:547
Character denoting an unread email.
Definition: hdrline.c:74
Character denoting a message has no cryptography information.
Definition: hdrline.c:90
#define FREE(x)
Definition: memory.h:46
const char * pager_progress
Definition: hdrline.h:47
char * organization
Definition: envelope.h:51
Character denoting a message is signed.
Definition: hdrline.c:88
#define STAILQ_EMPTY(head)
Definition: queue.h:346
Index: number of messages in collapsed thread.
Definition: mutt_curses.h:161
Index: label field.
Definition: mutt_curses.h:163
int mutt_count_body_parts(struct Mailbox *m, struct Email *e)
Count the MIME Body parts.
Definition: mutt_parse.c:220
struct MbTable * ToChars
Config: Indicator characters for the &#39;To&#39; field in the index.
Definition: hdrline.c:61
void mutt_str_pretty_size(char *buf, size_t buflen, size_t num)
Display an abbreviated size, like 3.4K.
Definition: string.c:1015
static bool check_for_mailing_list_addr(struct Address *addr, char *buf, int buflen)
Check an address list for a mailing list.
Definition: hdrline.c:155
struct Email * email
Definition: hdrline.h:46
char * x_label
Definition: envelope.h:50
#define WithCrypto
Definition: ncrypt.h:154
#define SORT_MASK
Mask for the sort id.
Definition: sort.h:77
unsigned int zminutes
Definition: email.h:64
void mutt_expando_format(char *buf, size_t buflen, size_t col, int cols, const char *src, format_t *callback, unsigned long data, enum FormatFlag flags)
Expand expandos (x) in a string.
Definition: muttlib.c:816
time_t received
time when the message was placed in the mailbox
Definition: email.h:84
struct Address * cc
Definition: envelope.h:37
bool mutt_addr_is_user(struct Address *addr)
Does the address belong to the user.
Definition: alias.c:676
int len
Number of characters.
Definition: mbtable.h:38
void mutt_format_s_tree(char *buf, size_t buflen, const char *prec, const char *s)
Format a simple string with tree characters.
Definition: curs_lib.c:1073
int msgno
number displayed to the user
Definition: email.h:88
#define GOODSIGN
Definition: ncrypt.h:121
print the subject even if unchanged
Definition: format_flags.h:33

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_make_string_flags ( char *  buf,
size_t  buflen,
const char *  s,
struct Context ctx,
struct Email e,
enum FormatFlag  flags 
)

Create formatted strings using mailbox expandos.

Parameters
bufBuffer for the result
buflenBuffer length
sprintf-line format string
ctxMailbox
eEmail
flagsFormat flags

Definition at line 1454 of file hdrline.c.

1456 {
1457  struct HdrFormatInfo hfi;
1458 
1459  hfi.email = e;
1460  hfi.ctx = ctx;
1461  hfi.pager_progress = 0;
1462 
1463  mutt_expando_format(buf, buflen, 0, MuttIndexWindow->cols, s,
1464  index_format_str, (unsigned long) &hfi, flags);
1465 }
struct Context * ctx
Definition: hdrline.h:45
Data passed to index_format_str()
Definition: hdrline.h:43
struct MuttWindow * MuttIndexWindow
Index Window.
Definition: mutt_window.c:39
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, unsigned long data, enum FormatFlag flags)
Format a string for the index list - Implements format_t.
Definition: hdrline.c:547
struct Email * email
Definition: hdrline.h:46
void mutt_expando_format(char *buf, size_t buflen, size_t col, int cols, const char *src, format_t *callback, unsigned long data, enum FormatFlag flags)
Expand expandos (x) in a string.
Definition: muttlib.c:816

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_make_string_info ( char *  buf,
size_t  buflen,
int  cols,
const char *  s,
struct HdrFormatInfo hfi,
enum FormatFlag  flags 
)

Create pager status bar string.

Parameters
bufBuffer for the result
buflenBuffer length
colsNumber of screen columns
sprintf-line format string
hfiMailbox data to pass to the formatter
flagsFormat flags

Definition at line 1476 of file hdrline.c.

1478 {
1479  mutt_expando_format(buf, buflen, 0, cols, s, index_format_str, (unsigned long) hfi, flags);
1480 }
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, unsigned long data, enum FormatFlag flags)
Format a string for the index list - Implements format_t.
Definition: hdrline.c:547
void mutt_expando_format(char *buf, size_t buflen, size_t col, int cols, const char *src, format_t *callback, unsigned long data, enum FormatFlag flags)
Expand expandos (x) in a string.
Definition: muttlib.c:816

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

Config: User-configurable crypto flags: signed, encrypted etc.

Definition at line 58 of file hdrline.c.

struct MbTable* FlagChars

Config: User-configurable index flags: tagged, new, etc.

Definition at line 59 of file hdrline.c.

struct MbTable* FromChars

Config: User-configurable index flags: to address, cc address, etc.

Definition at line 60 of file hdrline.c.

struct MbTable* ToChars

Config: Indicator characters for the 'To' field in the index.

Definition at line 61 of file hdrline.c.