NeoMutt  2025-09-05-55-g97fc89
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
expando.c
Go to the documentation of this file.
1
22
28
29#include <stdbool.h>
30#include <string.h>
31#include "mutt/lib.h"
32#include "address/lib.h"
33#include "email/lib.h"
34#include "expando.h"
35#include "expando/lib.h"
36
40static void greeting_real_name(const struct ExpandoNode *node, void *data,
41 MuttFormatFlags flags, struct Buffer *buf)
42{
43 const struct Email *e = data;
44 const struct Address *to = TAILQ_FIRST(&e->env->to);
45
46 const char *s = mutt_get_name(to);
47 buf_strcpy(buf, s);
48}
49
53static void greeting_login_name(const struct ExpandoNode *node, void *data,
54 MuttFormatFlags flags, struct Buffer *buf)
55{
56 const struct Email *e = data;
57 const struct Address *to = TAILQ_FIRST(&e->env->to);
58
59 char tmp[128] = { 0 };
60 char *p = NULL;
61
62 if (to)
63 {
64 mutt_str_copy(tmp, mutt_addr_for_display(to), sizeof(tmp));
65 if ((p = strpbrk(tmp, "%@")))
66 {
67 *p = '\0';
68 }
69 }
70
71 buf_strcpy(buf, tmp);
72}
73
77static void greeting_first_name(const struct ExpandoNode *node, void *data,
78 MuttFormatFlags flags, struct Buffer *buf)
79{
80 const struct Email *e = data;
81 const struct Address *to = TAILQ_FIRST(&e->env->to);
82 const struct Address *cc = TAILQ_FIRST(&e->env->cc);
83
84 char tmp[128] = { 0 };
85 char *p = NULL;
86
87 if (to)
88 {
89 const char *s = mutt_get_name(to);
90 mutt_str_copy(tmp, s, sizeof(tmp));
91 }
92 else if (cc)
93 {
94 const char *s = mutt_get_name(cc);
95 mutt_str_copy(tmp, s, sizeof(tmp));
96 }
97
98 if ((p = strpbrk(tmp, " %@")))
99 *p = '\0';
100
101 buf_strcpy(buf, tmp);
102}
103
110 // clang-format off
114 { -1, -1, NULL, NULL },
115 // clang-format on
116};
const char * mutt_addr_for_display(const struct Address *a)
Convert an Address for display purposes.
Definition address.c:1012
Email Address Handling.
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition buffer.c:395
@ ED_ENVELOPE
Envelope ED_ENV_ ExpandoDataEnvelope.
Definition domain.h:42
Structs that make up an email.
const char * mutt_get_name(const struct Address *a)
Pick the best name to display from an address.
Definition sort.c:139
@ ED_ENV_REAL_NAME
Envelope.to (first)
Definition envelope.h:111
@ ED_ENV_USER_NAME
Envelope.to (first)
Definition envelope.h:122
@ ED_ENV_FIRST_NAME
Envelope.from, Envelope.to, Envelope.cc.
Definition envelope.h:101
Parse Expando string.
static void greeting_login_name(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Greeting: Login name - Implements get_string_t -.
Definition expando.c:53
static void greeting_real_name(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Greeting: Real name - Implements get_string_t -.
Definition expando.c:40
static void greeting_first_name(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Greeting: First name - Implements get_string_t -.
Definition expando.c:77
Convenience wrapper for the library headers.
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
#define TAILQ_FIRST(head)
Definition queue.h:780
uint8_t MuttFormatFlags
Flags for expando_render(), e.g. MUTT_FORMAT_FORCESUBJ.
Definition render.h:32
const struct ExpandoRenderCallback GreetingRenderCallbacks[]
Callbacks for Greeting Expandos.
Definition expando.c:109
Greeting Expando definitions.
An email address.
Definition address.h:35
String manipulation buffer.
Definition buffer.h:36
The envelope/body of an email.
Definition email.h:39
struct Envelope * env
Envelope information.
Definition email.h:68
struct AddressList to
Email's 'To' list.
Definition envelope.h:60
struct AddressList cc
Email's 'Cc' list.
Definition envelope.h:61
Basic Expando Node.
Definition node.h:67