NeoMutt  2024-11-14-34-g5aaf0d
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 62 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}
#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 164 of file mutt_config.c.

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

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

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

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

248{
249 // Tag expando %G must use an suffix from [A-Za-z0-9], e.g. %Ga, %GL
250 if (!isalnum(str[1]))
251 return NULL;
252
253 // Let the basic expando parser do the work
254 flags |= EP_NO_CUSTOM_PARSE;
255 struct ExpandoNode *node = parse_short_name(str, IndexFormatDef, flags, fmt,
256 parsed_until, err);
257
258 // but adjust the node to take one more character
259 node->text = mutt_strn_dup((*parsed_until) - 1, 2);
260 (*parsed_until)++;
261
262 if (flags & EP_CONDITIONAL)
263 {
264 node->type = ENT_CONDBOOL;
266 }
267
268 return node;
269}
#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 ExpandoRenderData *rdata, 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:313
@ 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 ExpandoRenderData *rdata, struct Buffer *buf, int max_cols, void *data, MuttFormatFlags flags)
Definition: node.h:91
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 277 of file mutt_config.c.

280{
281 // Let the basic expando parser do the work
282 flags |= EP_NO_CUSTOM_PARSE;
283 struct ExpandoNode *node_subj = parse_short_name(str, IndexFormatDef, flags,
284 NULL, parsed_until, err);
285
287 struct ExpandoNode *node_cont = node_container_new();
288
289 // Apply the formatting info to the container
290 node_cont->format = fmt;
291
292 node_add_child(node_cont, node_tree);
293 node_add_child(node_cont, node_subj);
294
295 return node_cont;
296}
@ 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 62 of file config.c.

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