NeoMutt  2024-11-14-34-g5aaf0d
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
hdrline.c File Reference

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

#include "config.h"
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "alias/lib.h"
#include "hdrline.h"
#include "attach/lib.h"
#include "color/lib.h"
#include "expando/lib.h"
#include "ncrypt/lib.h"
#include "hook.h"
#include "maillist.h"
#include "mutt_thread.h"
#include "muttlib.h"
#include "mx.h"
#include "sort.h"
#include "subjectrx.h"
#include "notmuch/lib.h"
+ Include dependency graph for hdrline.c:

Go to the source code of this file.

Data Structures

struct  HdrFormatInfo
 Data passed to index_format_str() More...
 

Enumerations

enum  FieldType {
  DISP_TO , DISP_CC , DISP_BCC , DISP_FROM ,
  DISP_PLAIN , DISP_MAX
}
 Header types. More...
 
enum  IndexDateChoice { SENT_SENDER , SENT_LOCAL , RECV_LOCAL }
 Which email date to display in the Index. More...
 

Functions

static const char * make_from_prefix (enum FieldType disp)
 Create a prefix for an author field.
 
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 void make_from_addr (struct Envelope *env, char *buf, size_t buflen, bool do_lists)
 Create a 'from' address for a reply email.
 
static bool user_in_addr (struct AddressList *al)
 Do any of the addresses refer to the user?
 
static enum ToChars user_is_recipient (struct Email *e)
 Is the user a recipient of the message.
 
static bool thread_is_new (struct Email *e)
 Does the email thread contain any new emails?
 
static bool thread_is_old (struct Email *e)
 Does the email thread contain any unread emails?
 
long index_date_recv_local_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Local received date and time - Implements ExpandoRenderData::get_number() -.
 
static void index_email_date (const struct ExpandoNode *node, const struct Email *e, enum IndexDateChoice which, MuttFormatFlags flags, struct Buffer *buf, const char *format)
 Index: Sent/Received Local/Sender date and time.
 
void index_date_recv_local (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Received local date and time - Implements ExpandoRenderData::get_string() -.
 
long index_date_local_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Local date and time - Implements ExpandoRenderData::get_number() -.
 
void index_date_local (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Sent local date and time - Implements ExpandoRenderData::get_string() -.
 
long index_date_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Sender's date and time - Implements ExpandoRenderData::get_number() -.
 
void index_date (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Sent date and time - Implements ExpandoRenderData::get_string() -.
 
void index_format_hook (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: index-format-hook - Implements ExpandoRenderData::get_string() -.
 
void index_a (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Author Address - Implements ExpandoRenderData::get_string() -.
 
void index_A (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Reply-to address - Implements ExpandoRenderData::get_string() -.
 
void index_b (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Filename - Implements ExpandoRenderData::get_string() -.
 
void index_B (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Email list - Implements ExpandoRenderData::get_string() -.
 
long index_c_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Number of bytes - Implements ExpandoRenderData::get_number() -.
 
void index_c (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Number of bytes - Implements ExpandoRenderData::get_string() -.
 
void index_cr (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Number of raw bytes - Implements ExpandoRenderData::get_string() -.
 
long index_C_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Index number - Implements ExpandoRenderData::get_number() -.
 
long index_d_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Senders Date and time - Implements ExpandoRenderData::get_number() -.
 
void index_d (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Sent date and time - Implements ExpandoRenderData::get_string() -.
 
void index_D (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Sent local date and time - Implements ExpandoRenderData::get_string() -.
 
long index_D_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Local Date and time - Implements ExpandoRenderData::get_number() -.
 
long index_e_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Thread index number - Implements ExpandoRenderData::get_number() -.
 
long index_E_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Number of messages thread - Implements ExpandoRenderData::get_number() -.
 
void index_f (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Sender - Implements ExpandoRenderData::get_string() -.
 
void index_F (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Author name - Implements ExpandoRenderData::get_string() -.
 
void index_Fp (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Plain author name - Implements ExpandoRenderData::get_string() -.
 
void index_g (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Message tags - Implements ExpandoRenderData::get_string() -.
 
void index_G (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Individual tag - Implements ExpandoRenderData::get_string() -.
 
void index_H (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Spam attributes - Implements ExpandoRenderData::get_string() -.
 
void index_i (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Message-id - Implements ExpandoRenderData::get_string() -.
 
void index_I (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Initials of author - Implements ExpandoRenderData::get_string() -.
 
void index_J (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Tags - Implements ExpandoRenderData::get_string() -.
 
void index_K (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Mailing list - Implements ExpandoRenderData::get_string() -.
 
long index_l_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Number of lines - Implements ExpandoRenderData::get_number() -.
 
void index_L (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: List address - Implements ExpandoRenderData::get_string() -.
 
long index_m_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Total number of message - Implements ExpandoRenderData::get_number() -.
 
void index_M (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Number of hidden messages - Implements ExpandoRenderData::get_string() -.
 
long index_M_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Number of hidden messages - Implements ExpandoRenderData::get_number() -.
 
void index_n (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Author's real name - Implements ExpandoRenderData::get_string() -.
 
long index_N_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Message score - Implements ExpandoRenderData::get_number() -.
 
void index_O (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: List Name or Save folder - Implements ExpandoRenderData::get_string() -.
 
void index_P (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Progress indicator - Implements ExpandoRenderData::get_string() -.
 
void index_q (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Newsgroup name - Implements ExpandoRenderData::get_string() -.
 
void index_r (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: To recipients - Implements ExpandoRenderData::get_string() -.
 
void index_R (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Cc recipients - Implements ExpandoRenderData::get_string() -.
 
void index_s (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Subject - Implements ExpandoRenderData::get_string() -.
 
void index_S (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Status flag - Implements ExpandoRenderData::get_string() -.
 
void index_t (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: To field - Implements ExpandoRenderData::get_string() -.
 
void index_T (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: $to_chars flag - Implements ExpandoRenderData::get_string() -.
 
void index_tree (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Thread tree - Implements ExpandoRenderData::get_string() -.
 
void index_u (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: User name - Implements ExpandoRenderData::get_string() -.
 
void index_v (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: First name - Implements ExpandoRenderData::get_string() -.
 
void index_W (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Organization - Implements ExpandoRenderData::get_string() -.
 
void index_x (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: X-Comment-To - Implements ExpandoRenderData::get_string() -.
 
long index_X_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Index: Number of MIME attachments - Implements ExpandoRenderData::get_number() -.
 
void index_y (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: X-Label - Implements ExpandoRenderData::get_string() -.
 
void index_Y (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: X-Label (if different) - Implements ExpandoRenderData::get_string() -.
 
void index_zc (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Message crypto flags - Implements ExpandoRenderData::get_string() -.
 
void index_zs (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Message status flags - Implements ExpandoRenderData::get_string() -.
 
void index_zt (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Message tag flags - Implements ExpandoRenderData::get_string() -.
 
void index_Z (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Index: Status flags - Implements ExpandoRenderData::get_string() -.
 
int mutt_make_string (struct Buffer *buf, size_t max_cols, const struct Expando *exp, struct Mailbox *m, int inpgr, struct Email *e, MuttFormatFlags flags, const char *progress)
 Create formatted strings using mailbox expandos.
 

Variables

const struct ExpandoRenderData IndexRenderData []
 Callbacks for Index Expandos.
 

Detailed Description

String processing routines to generate the mail index.

Authors
  • Michael R. Elkins
  • Ian Zimmerman
  • Richard Russon
  • Stefan Assmann
  • Victor Fernandes
  • Pietro Cerutti
  • Ashish Panigrahi
  • Tóth János
  • наб
  • Dennis Schön

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

◆ FieldType

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 83 of file hdrline.c.

84{
85 DISP_TO,
86 DISP_CC,
87 DISP_BCC,
88 DISP_FROM,
91};
@ DISP_PLAIN
Empty string.
Definition: hdrline.c:89
@ DISP_TO
To: string.
Definition: hdrline.c:85
@ DISP_CC
Cc: string.
Definition: hdrline.c:86
@ DISP_BCC
Bcc: string.
Definition: hdrline.c:87
@ DISP_MAX
Definition: hdrline.c:90
@ DISP_FROM
From: string.
Definition: hdrline.c:88

◆ IndexDateChoice

Which email date to display in the Index.

Enumerator
SENT_SENDER 

Date sent in the sender's timezone.

SENT_LOCAL 

Date sent in the local timezone.

RECV_LOCAL 

Date received in the local timezone.

Definition at line 320 of file hdrline.c.

321{
323 SENT_LOCAL,
325};
@ SENT_LOCAL
Date sent in the local timezone.
Definition: hdrline.c:323
@ RECV_LOCAL
Date received in the local timezone.
Definition: hdrline.c:324
@ SENT_SENDER
Date sent in the sender's timezone.
Definition: hdrline.c:322

Function Documentation

◆ make_from_prefix()

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 101 of file hdrline.c.

102{
103 /* need 2 bytes at the end, one for the space, another for NUL */
104 static char padded[8];
105 static const char *long_prefixes[DISP_MAX] = {
106 [DISP_TO] = "To ", [DISP_CC] = "Cc ", [DISP_BCC] = "Bcc ",
107 [DISP_FROM] = "", [DISP_PLAIN] = "",
108 };
109
110 const struct MbTable *c_from_chars = cs_subset_mbtable(NeoMutt->sub, "from_chars");
111
112 if (!c_from_chars || !c_from_chars->chars || (c_from_chars->len == 0))
113 return long_prefixes[disp];
114
115 const char *pchar = mbtable_get_nth_wchar(c_from_chars, disp);
116 if (mutt_str_len(pchar) == 0)
117 return "";
118
119 snprintf(padded, sizeof(padded), "%s ", pchar);
120 return padded;
121}
struct MbTable * cs_subset_mbtable(const struct ConfigSubset *sub, const char *name)
Get a Multibyte table config item by name.
Definition: helpers.c:119
const char * mbtable_get_nth_wchar(const struct MbTable *table, int index)
Extract one char from a multi-byte table.
Definition: mbtable.c:331
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition: string.c:496
Multibyte character table.
Definition: mbtable.h:36
int len
Number of characters.
Definition: mbtable.h:38
char ** chars
The array of multibyte character strings.
Definition: mbtable.h:39
Container for Accounts, Notifications.
Definition: neomutt.h:42
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_from()

static void make_from ( struct Envelope env,
char *  buf,
size_t  buflen,
bool  do_lists,
MuttFormatFlags  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, see MuttFormatFlags

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 137 of file hdrline.c.

139{
140 if (!env || !buf)
141 return;
142
143 bool me;
144 enum FieldType disp;
145 struct AddressList *name = NULL;
146
148
149 if (do_lists || me)
150 {
151 if (check_for_mailing_list(&env->to, make_from_prefix(DISP_TO), buf, buflen))
152 return;
153 if (check_for_mailing_list(&env->cc, make_from_prefix(DISP_CC), buf, buflen))
154 return;
155 }
156
157 if (me && !TAILQ_EMPTY(&env->to))
158 {
159 disp = (flags & MUTT_FORMAT_PLAIN) ? DISP_PLAIN : DISP_TO;
160 name = &env->to;
161 }
162 else if (me && !TAILQ_EMPTY(&env->cc))
163 {
164 disp = DISP_CC;
165 name = &env->cc;
166 }
167 else if (me && !TAILQ_EMPTY(&env->bcc))
168 {
169 disp = DISP_BCC;
170 name = &env->bcc;
171 }
172 else if (!TAILQ_EMPTY(&env->from))
173 {
174 disp = DISP_FROM;
175 name = &env->from;
176 }
177 else
178 {
179 *buf = '\0';
180 return;
181 }
182
183 snprintf(buf, buflen, "%s%s", make_from_prefix(disp), mutt_get_name(TAILQ_FIRST(name)));
184}
bool mutt_addr_is_user(const struct Address *addr)
Does the address belong to the user.
Definition: alias.c:600
static const char * make_from_prefix(enum FieldType disp)
Create a prefix for an author field.
Definition: hdrline.c:101
FieldType
Header types.
Definition: hdrline.c:84
bool check_for_mailing_list(struct AddressList *al, const char *pfx, char *buf, int buflen)
Search list of addresses for a mailing list.
Definition: maillist.c:79
#define TAILQ_FIRST(head)
Definition: queue.h:723
#define TAILQ_EMPTY(head)
Definition: queue.h:721
#define MUTT_FORMAT_PLAIN
Do not prepend DISP_TO, DISP_CC ...
Definition: render.h:39
const char * mutt_get_name(const struct Address *a)
Pick the best name to display from an address.
Definition: sort.c:134
struct AddressList to
Email's 'To' list.
Definition: envelope.h:60
struct AddressList cc
Email's 'Cc' list.
Definition: envelope.h:61
struct AddressList bcc
Email's 'Bcc' list.
Definition: envelope.h:62
struct AddressList from
Email's 'From' list.
Definition: envelope.h:59
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_from_addr()

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

Create a 'from' address for a reply email.

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

Definition at line 193 of file hdrline.c.

194{
195 if (!env || !buf)
196 return;
197
198 bool me = mutt_addr_is_user(TAILQ_FIRST(&env->from));
199
200 if (do_lists || me)
201 {
202 if (check_for_mailing_list_addr(&env->to, buf, buflen))
203 return;
204 if (check_for_mailing_list_addr(&env->cc, buf, buflen))
205 return;
206 }
207
208 if (me && !TAILQ_EMPTY(&env->to))
209 snprintf(buf, buflen, "%s", buf_string(TAILQ_FIRST(&env->to)->mailbox));
210 else if (me && !TAILQ_EMPTY(&env->cc))
211 snprintf(buf, buflen, "%s", buf_string(TAILQ_FIRST(&env->cc)->mailbox));
212 else if (!TAILQ_EMPTY(&env->from))
213 mutt_str_copy(buf, buf_string(TAILQ_FIRST(&env->from)->mailbox), buflen);
214 else
215 *buf = '\0';
216}
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:96
bool check_for_mailing_list_addr(struct AddressList *al, char *buf, int buflen)
Check an address list for a mailing list.
Definition: maillist.c:103
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:581
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ user_in_addr()

static bool user_in_addr ( struct AddressList *  al)
static

Do any of the addresses refer to the user?

Parameters
alAddressList
Return values
trueAny of the addresses match one of the user's addresses

Definition at line 223 of file hdrline.c.

224{
225 struct Address *a = NULL;
226 TAILQ_FOREACH(a, al, entries)
227 if (mutt_addr_is_user(a))
228 return true;
229 return false;
230}
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:725
An email address.
Definition: address.h:36
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ user_is_recipient()

static enum ToChars user_is_recipient ( struct Email e)
static

Is the user a recipient of the message.

Parameters
eEmail to test
Return values
enumCharacter index into the $to_chars config variable

Definition at line 237 of file hdrline.c.

238{
239 if (!e || !e->env)
241
242 struct Envelope *env = e->env;
243
244 if (!e->recip_valid)
245 {
246 e->recip_valid = true;
247
249 {
251 }
252 else if (user_in_addr(&env->to))
253 {
254 if (TAILQ_NEXT(TAILQ_FIRST(&env->to), entries) || !TAILQ_EMPTY(&env->cc))
255 e->recipient = FLAG_CHAR_TO_TO; /* non-unique recipient */
256 else
257 e->recipient = FLAG_CHAR_TO_UNIQUE; /* unique recipient */
258 }
259 else if (user_in_addr(&env->cc))
260 {
262 }
263 else if (check_for_mailing_list(&env->to, NULL, NULL, 0))
264 {
266 }
267 else if (check_for_mailing_list(&env->cc, NULL, NULL, 0))
268 {
270 }
271 else if (user_in_addr(&env->reply_to))
272 {
274 }
275 else
276 {
278 }
279 }
280
281 return e->recipient;
282}
static bool user_in_addr(struct AddressList *al)
Do any of the addresses refer to the user?
Definition: hdrline.c:223
@ FLAG_CHAR_TO_ORIGINATOR
Character denoting that the user is originator.
Definition: hdrline.h:74
@ FLAG_CHAR_TO_UNIQUE
Character denoting that the user is unique recipient.
Definition: hdrline.h:71
@ FLAG_CHAR_TO_NOT_IN_THE_LIST
Character denoting that the user is not in list.
Definition: hdrline.h:70
@ FLAG_CHAR_TO_TO
Character denoting that the user is in the TO list.
Definition: hdrline.h:72
@ FLAG_CHAR_TO_CC
Character denoting that the user is in the CC list.
Definition: hdrline.h:73
@ FLAG_CHAR_TO_REPLY_TO
Character denoting that the user is in the Reply-To list.
Definition: hdrline.h:76
@ FLAG_CHAR_TO_SUBSCRIBED_LIST
Character denoting that the message is sent to a subscribed mailing list.
Definition: hdrline.h:75
#define TAILQ_NEXT(elm, field)
Definition: queue.h:832
bool recip_valid
Is_recipient is valid.
Definition: email.h:104
struct Envelope * env
Envelope information.
Definition: email.h:68
short recipient
User_is_recipient()'s return value, cached.
Definition: email.h:116
The header of an Email.
Definition: envelope.h:57
struct AddressList reply_to
Email's 'reply-to'.
Definition: envelope.h:64
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ thread_is_new()

static bool thread_is_new ( struct Email e)
static

Does the email thread contain any new emails?

Parameters
eEmail
Return values
trueThread contains new mail

Definition at line 289 of file hdrline.c.

290{
291 return e->collapsed && (e->num_hidden > 1) && (mutt_thread_contains_unread(e) == 1);
292}
#define mutt_thread_contains_unread(e)
Definition: mutt_thread.h:109
bool collapsed
Is this message part of a collapsed thread?
Definition: email.h:120
size_t num_hidden
Number of hidden messages in this view (only valid when collapsed is set)
Definition: email.h:123
+ Here is the caller graph for this function:

◆ thread_is_old()

static bool thread_is_old ( struct Email e)
static

Does the email thread contain any unread emails?

Parameters
eEmail
Return values
trueThread contains unread mail

Definition at line 299 of file hdrline.c.

300{
301 return e->collapsed && (e->num_hidden > 1) && (mutt_thread_contains_unread(e) == 2);
302}
+ Here is the caller graph for this function:

◆ index_email_date()

static void index_email_date ( const struct ExpandoNode node,
const struct Email e,
enum IndexDateChoice  which,
MuttFormatFlags  flags,
struct Buffer buf,
const char *  format 
)
static

Index: Sent/Received Local/Sender date and time.

Parameters
nodeExpandoNode containing the callback
eEmail
whichWhich date to use
flagsFlags, see MuttFormatFlags
bufBuffer for the result
formatFormat string

Definition at line 336 of file hdrline.c.

339{
340 struct tm tm = { 0 };
341 switch (which)
342 {
343 case SENT_SENDER:
344 {
345 int offset = (e->zhours * 3600 + e->zminutes * 60) * (e->zoccident ? -1 : 1);
346 const time_t now = e->date_sent + offset;
347 tm = mutt_date_gmtime(now);
348 tm.tm_gmtoff = offset;
349 break;
350 }
351 case SENT_LOCAL:
352 {
354 break;
355 }
356 case RECV_LOCAL:
357 {
359 break;
360 }
361 }
362
363 char *fmt = mutt_str_dup(format);
364
365 const bool use_c_locale = (*fmt == '!');
366
367 if (which != RECV_LOCAL)
368 {
369 // The sender's time zone might only be available as a numerical offset, so "%Z" behaves like "%z".
370 for (char *bigz = fmt; (bigz = strstr(bigz, "%Z")); bigz += 2)
371 {
372 bigz[1] = 'z';
373 }
374 }
375
376 char out[128] = { 0 };
377 if (use_c_locale)
378 {
379 strftime_l(out, sizeof(out), fmt + 1, &tm, NeoMutt->time_c_locale);
380 }
381 else
382 {
383 strftime(out, sizeof(out), fmt, &tm);
384 }
385
386 FREE(&fmt);
387
388 if (flags & MUTT_FORMAT_INDEX)
390 buf_strcpy(buf, out);
391}
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:395
@ MT_COLOR_INDEX_DATE
Index: date field.
Definition: color.h:86
#define FREE(x)
Definition: memory.h:55
struct tm mutt_date_localtime(time_t t)
Converts calendar time to a broken-down time structure expressed in user timezone.
Definition: date.c:906
struct tm mutt_date_gmtime(time_t t)
Converts calendar time to a broken-down time structure expressed in UTC timezone.
Definition: date.c:927
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:253
void node_expando_set_color(const struct ExpandoNode *node, int cid)
Set the colour for an Expando.
Definition: node_expando.c:100
#define MUTT_FORMAT_INDEX
This is a main index entry.
Definition: render.h:38
unsigned int zminutes
Minutes away from UTC.
Definition: email.h:57
bool zoccident
True, if west of UTC, False if east.
Definition: email.h:58
unsigned int zhours
Hours away from UTC.
Definition: email.h:56
time_t date_sent
Time when the message was sent (UTC)
Definition: email.h:60
time_t received
Time when the message was placed in the mailbox.
Definition: email.h:61
locale_t time_c_locale
Current locale but LC_TIME=C.
Definition: neomutt.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_make_string()

int mutt_make_string ( struct Buffer buf,
size_t  max_cols,
const struct Expando exp,
struct Mailbox m,
int  inpgr,
struct Email e,
MuttFormatFlags  flags,
const char *  progress 
)

Create formatted strings using mailbox expandos.

Parameters
bufBuffer for the result
max_colsNumber of screen columns (-1 means unlimited)
expExpando containing expando tree
mMailbox
inpgrMessage shown in the pager
eEmail
flagsFlags, see MuttFormatFlags
progressPager progress string
Return values
numNumber of screen columns used

Definition at line 1719 of file hdrline.c.

1722{
1723 if (!exp)
1724 return 0;
1725
1726 struct HdrFormatInfo hfi = { 0 };
1727
1728 hfi.email = e;
1729 hfi.mailbox = m;
1730 hfi.msg_in_pager = inpgr;
1731 hfi.pager_progress = progress;
1732
1733 return expando_filter(exp, IndexRenderData, &hfi, flags, max_cols, buf);
1734}
int expando_filter(const struct Expando *exp, const struct ExpandoRenderData *rdata, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
Render an Expando and run the result through a filter.
Definition: filter.c:138
const struct ExpandoRenderData IndexRenderData[]
Callbacks for Index Expandos.
Definition: hdrline.c:65
Data passed to index_format_str()
Definition: hdrline.c:71
struct Email * email
Current Email.
Definition: hdrline.c:74
int msg_in_pager
Index of Email displayed in the Pager.
Definition: hdrline.c:73
struct Mailbox * mailbox
Current Mailbox.
Definition: hdrline.c:72
const char * pager_progress
String representing Pager position through Email.
Definition: hdrline.c:75
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ IndexRenderData

const struct ExpandoRenderData IndexRenderData

Callbacks for Index Expandos.

See also
IndexFormatDef, ExpandoDataEmail, ExpandoDataEnvelope, ExpandoDataGlobal, ExpandoDataMailbox

Definition at line 65 of file hdrline.c.