NeoMutt  2024-12-12-19-ge4b57e
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.
Definition: node_expando.c:349
+ 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 if (*str == '|')
259 {
260 pt = EPT_FILL_EOL;
261 }
262 else if (*str == '>')
263 {
264 pt = EPT_HARD_FILL;
265 }
266 else if (*str == '*')
267 {
268 pt = EPT_SOFT_FILL;
269 }
270 else
271 {
272 return NULL;
273 }
274 str++;
275
276 size_t consumed = mutt_mb_charlen(str, NULL);
277 if (consumed == 0)
278 {
279 str = " "; // Default to a space
280 consumed = 1;
281 }
282
283 *parsed_until = str + consumed;
284 return node_padding_new(pt, str, str + consumed);
285}
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.
Definition: node_padding.c:201
ExpandoPadType
Padding type.
Definition: node_padding.h:44
@ EPT_FILL_EOL
Fill to the end-of-line.
Definition: node_padding.h:45
@ EPT_SOFT_FILL
Soft-fill: right-hand-side will be truncated.
Definition: node_padding.h:47
@ EPT_HARD_FILL
Hard-fill: left-hand-side will be truncated.
Definition: node_padding.h:46
char message[1024]
Error message.
Definition: parse.h:38
const char * position
Position of error in original string.
Definition: parse.h:39
+ 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 165 of file mutt_config.c.

170{
171 if (flags & EP_CONDITIONAL)
172 {
173 return node_conddate_parse(str, did, uid, parsed_until, err);
174 }
175
176 return node_expando_parse_enclosure(str, did, uid, ')', fmt, parsed_until, err);
177}
+ 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 185 of file mutt_config.c.

189{
190 if (flags & EP_CONDITIONAL)
191 {
192 return node_conddate_parse(str, did, uid, parsed_until, err);
193 }
194
195 return node_expando_parse_enclosure(str, did, uid, ']', fmt, parsed_until, err);
196}
+ 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 204 of file mutt_config.c.

208{
209 if (flags & EP_CONDITIONAL)
210 {
211 return node_conddate_parse(str, did, uid, parsed_until, err);
212 }
213
214 return node_expando_parse_enclosure(str, did, uid, '}', fmt, parsed_until, err);
215}
+ 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 224 of file mutt_config.c.

228{
229 if (flags & EP_CONDITIONAL)
230 {
231 snprintf(err->message, sizeof(err->message),
232 _("index-hook cannot be used as a condition"));
233 err->position = str;
234 return NULL;
235 }
236
237 return node_expando_parse_enclosure(str, did, uid, '@', fmt, parsed_until, err);
238}
+ 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 alpha-numeric character.

Definition at line 245 of file mutt_config.c.

249{
250 // Tag expando %G must use an suffix from [A-Za-z0-9], e.g. %Ga, %GL
251 if (!isalnum(str[1]))
252 return NULL;
253
254 // Let the basic expando parser do the work
255 flags |= EP_NO_CUSTOM_PARSE;
256 struct ExpandoNode *node = parse_short_name(str, IndexFormatDef, flags, fmt,
257 parsed_until, err);
258
259 // but adjust the node to take one more character
260 node->text = mutt_strn_dup((*parsed_until) - 1, 2);
261 (*parsed_until)++;
262
263 if (flags & EP_CONDITIONAL)
264 {
265 node->type = ENT_CONDBOOL;
267 }
268
269 return node;
270}
#define EP_NO_CUSTOM_PARSE
Don't use the custom parser.
Definition: definition.h:36
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() -.
Definition: node_condbool.c:41
char * mutt_strn_dup(const char *begin, size_t len)
Duplicate a sub-string.
Definition: string.c:380
const struct ExpandoDefinition IndexFormatDef[]
Expando definitions.
Definition: mutt_config.c:314
@ ENT_CONDBOOL
True/False boolean condition.
Definition: node.h:42
struct ExpandoNode * parse_short_name(const char *str, const struct ExpandoDefinition *defs, ExpandoParserFlags flags, struct ExpandoFormat *fmt, const char **parsed_until, struct ExpandoParseError *err)
Create an expando by its short name.
Definition: node_expando.c:245
Basic Expando Node.
Definition: node.h:67
int(* render)(const struct ExpandoNode *node, const struct ExpandoRenderCallback *erc, struct Buffer *buf, int max_cols, void *data, MuttFormatFlags flags)
Definition: node.h:92
const char * text
Node-specific text.
Definition: node.h:73
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 278 of file mutt_config.c.

281{
282 // Let the basic expando parser do the work
283 flags |= EP_NO_CUSTOM_PARSE;
284 struct ExpandoNode *node_subj = parse_short_name(str, IndexFormatDef, flags,
285 NULL, parsed_until, err);
286
288 struct ExpandoNode *node_cont = node_container_new();
289
290 // Apply the formatting info to the container
291 node_cont->format = fmt;
292
293 node_add_child(node_cont, node_tree);
294 node_add_child(node_cont, node_subj);
295
296 return node_cont;
297}
@ 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 ExpandoNode * node_expando_new(struct ExpandoFormat *fmt, int did, int uid)
Create a new Expando ExpandoNode.
Definition: node_expando.c:78
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: