NeoMutt  2025-12-11-58-g09398d
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
Expando Parse API

Custom function to parse a format string into a Node. More...

Functions

struct ExpandoNodeparse_folder_date (const char *str, struct ExpandoFormat *fmt, int did, int uid, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
 Parse a Date Expando - Implements ExpandoDefinition::parse() -.
 
struct ExpandoNodenode_padding_parse (const char *str, struct ExpandoFormat *fmt, int did, int uid, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
 Parse a Padding Expando - Implements ExpandoDefinition::parse() -.
 
struct ExpandoNodeparse_index_date_recv_local (const char *str, struct ExpandoFormat *fmt, int did, int uid, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
 Parse a Date Expando - Implements ExpandoDefinition::parse() -.
 
struct ExpandoNodeparse_index_date_local (const char *str, struct ExpandoFormat *fmt, int did, int uid, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
 Parse a Date Expando - Implements ExpandoDefinition::parse() -.
 
struct ExpandoNodeparse_index_date (const char *str, struct ExpandoFormat *fmt, int did, int uid, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
 Parse a Date Expando - Implements ExpandoDefinition::parse() -.
 
struct ExpandoNodeparse_index_hook (const char *str, struct ExpandoFormat *fmt, int did, int uid, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
 Parse an index-hook - Implements ExpandoDefinition::parse() -.
 
struct ExpandoNodeparse_tags_transformed (const char *str, struct ExpandoFormat *fmt, int did, int uid, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
 Parse a Tags-Transformed Expando - Implements ExpandoDefinition::parse() -.
 
struct ExpandoNodeparse_subject (const char *str, struct ExpandoFormat *fmt, int did, int uid, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
 Parse a Subject Expando - Implements ExpandoDefinition::parse() -.
 
struct ExpandoNodeparse_pgp_date (const char *str, struct ExpandoFormat *fmt, int did, int uid, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
 Parse a Date Expando - Implements ExpandoDefinition::parse() -.
 

Detailed Description

Custom function to parse a format string into a Node.

Parameters
[in]strString to parse
[in]fmtFormatting information
[in]didDomain ID of the data
[in]uidUnique ID of the data
[in]flagsFlags, e.g. EP_CONDITIONAL
[out]parsed_untilFirst character after the parsed string
[out]errBuffer for error message
Return values
ptrParsed Node

Function Documentation

◆ parse_folder_date()

struct ExpandoNode * parse_folder_date ( const char * str,
struct ExpandoFormat * fmt,
int did,
int uid,
ExpandoParserFlags flags,
const char ** parsed_until,
struct ExpandoParseError * err )

Parse a Date Expando - Implements ExpandoDefinition::parse() -.

Parse a custom Expando of the form, "%[string]". The "string" will be passed to strftime().

Definition at line 64 of file config.c.

68{
69 if (flags & EP_CONDITIONAL)
70 {
71 return node_conddate_parse(str, did, uid, parsed_until, err);
72 }
73
74 return node_expando_parse_enclosure(str, did, uid, ']', fmt, parsed_until, err);
75}
#define EP_CONDITIONAL
Expando is being used as a condition.
Definition definition.h:35
struct ExpandoNode * node_conddate_parse(const char *str, int did, int uid, const char **parsed_until, struct ExpandoParseError *err)
Parse a CondDate format string.
struct ExpandoNode * node_expando_parse_enclosure(const char *str, int did, int uid, char terminator, struct ExpandoFormat *fmt, const char **parsed_until, struct ExpandoParseError *err)
Parse an enclosed Expando.
+ Here is the call graph for this function:

◆ node_padding_parse()

struct ExpandoNode * node_padding_parse ( const char * str,
struct ExpandoFormat * fmt,
int did,
int uid,
ExpandoParserFlags flags,
const char ** parsed_until,
struct ExpandoParseError * err )

Parse a Padding Expando - Implements ExpandoDefinition::parse() -.

Parse a Padding Expando of the form, "%|X", "%>X" or "%*X", where the character 'X' will be used to fill the space.

Definition at line 234 of file node_padding.c.

238{
239 if (fmt)
240 {
241 // L10N: Padding expandos, %* %> %|, don't use formatting, e.g. %-30x
242 snprintf(err->message, sizeof(err->message), _("Padding cannot be formatted"));
243 err->position = str;
244 return NULL;
245 }
246
247 if (flags & EP_CONDITIONAL)
248 {
249 snprintf(err->message, sizeof(err->message),
250 // L10N: Conditional Expandos can only depend on other Expandos
251 // e.g. "%<X?apple>" displays "apple" if "%X" is true.
252 _("Padding cannot be used as a condition"));
253 err->position = str;
254 return NULL;
255 }
256
257 enum ExpandoPadType pt = 0;
258 switch (uid)
259 {
261 pt = EPT_FILL_EOL;
262 break;
263
265 pt = EPT_HARD_FILL;
266 break;
267
269 pt = EPT_SOFT_FILL;
270 break;
271
272 default:
273 return NULL;
274 }
275
276 // Skip over the name
277 str = *parsed_until + 1;
278
279 size_t consumed = mutt_mb_charlen(str, NULL);
280 if (consumed == 0)
281 {
282 str = " "; // Default to a space
283 consumed = 1;
284 }
285
286 *parsed_until = str + consumed;
287
288 return node_padding_new(pt, str, str + consumed);
289}
int mutt_mb_charlen(const char *s, int *width)
Count the bytes in a (multibyte) character.
Definition mbyte.c:55
#define _(a)
Definition message.h:28
struct ExpandoNode * node_padding_new(enum ExpandoPadType pad_type, const char *start, const char *end)
Creata new Padding ExpandoNode.
ExpandoPadType
Padding type.
@ EPT_FILL_EOL
Fill to the end-of-line.
@ EPT_SOFT_FILL
Soft-fill: right-hand-side will be truncated.
@ EPT_HARD_FILL
Hard-fill: left-hand-side will be truncated.
char message[1024]
Error message.
Definition parse.h:38
const char * position
Position of error in original string.
Definition parse.h:39
@ ED_GLO_PADDING_EOL
Padding to end-of-line.
Definition uid.h:38
@ ED_GLO_PADDING_HARD
Hard Padding.
Definition uid.h:39
@ ED_GLO_PADDING_SOFT
Soft Padding.
Definition uid.h:40
+ Here is the call graph for this function:

◆ parse_index_date_recv_local()

struct ExpandoNode * parse_index_date_recv_local ( const char * str,
struct ExpandoFormat * fmt,
int did,
int uid,
ExpandoParserFlags flags,
const char ** parsed_until,
struct ExpandoParseError * err )

Parse a Date Expando - Implements ExpandoDefinition::parse() -.

Parse a custom Expando of the form, "%(string)". The "string" will be passed to strftime().

Definition at line 162 of file mutt_config.c.

167{
168 if (flags & EP_CONDITIONAL)
169 {
170 return node_conddate_parse(str, did, uid, parsed_until, err);
171 }
172
173 return node_expando_parse_enclosure(str, did, uid, ')', fmt, parsed_until, err);
174}
+ Here is the call graph for this function:

◆ parse_index_date_local()

struct ExpandoNode * parse_index_date_local ( const char * str,
struct ExpandoFormat * fmt,
int did,
int uid,
ExpandoParserFlags flags,
const char ** parsed_until,
struct ExpandoParseError * err )

Parse a Date Expando - Implements ExpandoDefinition::parse() -.

Parse a custom expando of the form, "%[string]". The "string" will be passed to strftime().

Definition at line 182 of file mutt_config.c.

186{
187 if (flags & EP_CONDITIONAL)
188 {
189 return node_conddate_parse(str, did, uid, parsed_until, err);
190 }
191
192 return node_expando_parse_enclosure(str, did, uid, ']', fmt, parsed_until, err);
193}
+ Here is the call graph for this function:

◆ parse_index_date()

struct ExpandoNode * parse_index_date ( const char * str,
struct ExpandoFormat * fmt,
int did,
int uid,
ExpandoParserFlags flags,
const char ** parsed_until,
struct ExpandoParseError * err )

Parse a Date Expando - Implements ExpandoDefinition::parse() -.

Parse a custom Expando of the form, "%{string}". The "string" will be passed to strftime().

Definition at line 201 of file mutt_config.c.

205{
206 if (flags & EP_CONDITIONAL)
207 {
208 return node_conddate_parse(str, did, uid, parsed_until, err);
209 }
210
211 struct ExpandoNode *node = node_expando_parse_enclosure(str, did, uid, '}',
212 fmt, parsed_until, err);
213 if (!node)
214 return NULL;
215
216 const char *pc = strchr(NONULL(node->text), '%');
217 if (!pc)
218 {
219 snprintf(err->message, sizeof(err->message), _("Unknown expando: %%{%s}"), node->text);
220 err->position = str;
221 node_free(&node);
222 }
223
224 return node;
225}
void node_free(struct ExpandoNode **ptr)
Free an ExpandoNode and its private data.
Definition node.c:48
#define NONULL(x)
Definition string2.h:43
Basic Expando Node.
Definition node.h:67
int uid
Unique ID, e.g. ED_EMA_SIZE.
Definition node.h:70
int did
Domain ID, e.g. ED_EMAIL.
Definition node.h:69
const char * text
Node-specific text.
Definition node.h:73
+ Here is the call graph for this function:

◆ parse_index_hook()

struct ExpandoNode * parse_index_hook ( const char * str,
struct ExpandoFormat * fmt,
int did,
int uid,
ExpandoParserFlags flags,
const char ** parsed_until,
struct ExpandoParseError * err )

Parse an index-hook - Implements ExpandoDefinition::parse() -.

Parse a custom Expando of the form, "%@name@". The "name" will be looked up as an index-hook, then the result parsed as an Expando.

Definition at line 234 of file mutt_config.c.

238{
239 if (flags & EP_CONDITIONAL)
240 {
241 snprintf(err->message, sizeof(err->message),
242 _("index-hook cannot be used as a condition"));
243 err->position = str;
244 return NULL;
245 }
246
247 return node_expando_parse_enclosure(str, did, uid, '@', fmt, parsed_until, err);
248}
+ Here is the call graph for this function:

◆ parse_tags_transformed()

struct ExpandoNode * parse_tags_transformed ( const char * str,
struct ExpandoFormat * fmt,
int did,
int uid,
ExpandoParserFlags flags,
const char ** parsed_until,
struct ExpandoParseError * err )

Parse a Tags-Transformed Expando - Implements ExpandoDefinition::parse() -.

Parse a custom expando of the form, "%G?" where '?' is an alphanumeric character.

Definition at line 255 of file mutt_config.c.

259{
260 // Tag expando %G must use a suffix from [A-Za-z0-9], e.g. %Ga, %GL
261 if (!mutt_isalnum(str[1]))
262 return NULL;
263
264 struct ExpandoNode *node = node_expando_new(fmt, did, uid);
265
266 node->text = mutt_strn_dup(str, 2);
267
268 if (flags & EP_CONDITIONAL)
269 {
270 node->type = ENT_CONDBOOL;
272 }
273
274 (*parsed_until) = str + 2;
275
276 return node;
277}
bool mutt_isalnum(int arg)
Wrapper for isalnum(3)
Definition ctype.c:39
int node_condbool_render(const struct ExpandoNode *node, const struct ExpandoRenderCallback *erc, struct Buffer *buf, int max_cols, void *data, MuttFormatFlags flags)
Callback for every bool node - Implements ExpandoNode::render() -.
char * mutt_strn_dup(const char *begin, size_t len)
Duplicate a sub-string.
Definition string.c:382
@ ENT_CONDBOOL
True/False boolean condition.
Definition node.h:42
struct ExpandoNode * node_expando_new(struct ExpandoFormat *fmt, int did, int uid)
Create a new Expando ExpandoNode.
int(* render)(const struct ExpandoNode *node, const struct ExpandoRenderCallback *erc, struct Buffer *buf, int max_cols, void *data, MuttFormatFlags flags)
Definition node.h:92
enum ExpandoNodeType type
Type of Node, e.g. ENT_EXPANDO.
Definition node.h:68
+ Here is the call graph for this function:

◆ parse_subject()

struct ExpandoNode * parse_subject ( const char * str,
struct ExpandoFormat * fmt,
int did,
int uid,
ExpandoParserFlags flags,
const char ** parsed_until,
struct ExpandoParseError * err )

Parse a Subject Expando - Implements ExpandoDefinition::parse() -.

Parse a Subject Expando, "%s", into two separate Nodes. One for the tree, one for the subject.

Definition at line 285 of file mutt_config.c.

288{
289 struct ExpandoNode *node_subj = node_expando_new(NULL, did, uid);
291 struct ExpandoNode *node_cont = node_container_new();
292
293 // Apply the formatting info to the container
294 node_cont->format = fmt;
295
296 node_add_child(node_cont, node_tree);
297 node_add_child(node_cont, node_subj);
298
299 if (*parsed_until[0] != '}')
300 (*parsed_until)++;
301
302 return node_cont;
303}
@ ED_ENVELOPE
Envelope ED_ENV_ ExpandoDataEnvelope.
Definition domain.h:42
@ ED_ENV_THREAD_TREE
Email.tree.
Definition envelope.h:117
void node_add_child(struct ExpandoNode *node, struct ExpandoNode *child)
Add a child to an ExpandoNode.
Definition node.c:76
struct ExpandoNode * node_container_new(void)
Create a new Container ExpandoNode.
struct ExpandoFormat * format
Formatting info.
Definition node.h:72
+ Here is the call graph for this function:

◆ parse_pgp_date()

struct ExpandoNode * parse_pgp_date ( const char * str,
struct ExpandoFormat * fmt,
int did,
int uid,
ExpandoParserFlags flags,
const char ** parsed_until,
struct ExpandoParseError * err )

Parse a Date Expando - Implements ExpandoDefinition::parse() -.

Parse a custom Expando of the form, "%[string]". The "string" will be passed to strftime().

Definition at line 63 of file config.c.

66{
67 if (flags & EP_CONDITIONAL)
68 {
69 return node_conddate_parse(str, did, uid, parsed_until, err);
70 }
71
72 return node_expando_parse_enclosure(str, did, uid, ']', fmt, parsed_until, err);
73}
+ Here is the call graph for this function: