152 else if (*start ==
'=')
166 unsigned short number = 0;
170 if (!end_ptr || (end_ptr > end) || (number == USHRT_MAX))
173 snprintf(err->
message,
sizeof(err->
message),
_(
"Invalid number: %s"), start);
186 if (!isdigit(*start))
195 unsigned short number = 0;
199 if (!end_ptr || (end_ptr > end) || (number == USHRT_MAX))
202 snprintf(err->
message,
sizeof(err->
message),
_(
"Invalid number: %s"), start);
237 char expando[128] = { 0 };
238 const int expando_len = expando_end - format_end;
239 mutt_strn_copy(expando, format_end, expando_len,
sizeof(expando));
255 return def->
parse(str, def->
did, def->
uid, flags, parsed_until, err);
259 *parsed_until = expando_end;
269 snprintf(err->
message,
sizeof(err->
message),
_(
"Unknown expando: %%%.*s"),
270 expando_len, format_end);
286 char terminator,
const char **parsed_until,
293 const char *expando_end =
skip_until_ch(format_end, terminator);
295 if (*expando_end != terminator)
301 _(
"Expando is missing terminator: '%c'"), terminator);
313 *parsed_until = expando_end + 1;
347 rd_match->
get_string(node, data, flags, buf_expando);
352 ASSERT(rd_match &&
"Unknown UID");
354 const long num = rd_match->
get_number(node, data, flags);
362 if (priv->
color > -1)
385 if (priv->
color > -1)
const char * mutt_str_atous(const char *str, unsigned short *dst)
Convert ASCII string to an unsigned short.
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
size_t buf_len(const struct Buffer *buf)
Calculate the length of a Buffer.
size_t buf_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Color and attribute parsing.
ColorId
List of all colored objects.
@ MT_COLOR_INDEX
Index: default colour.
Define an Expando format string.
#define EP_NO_CUSTOM_PARSE
Don't use the custom parser.
uint8_t ExpandoParserFlags
Flags for expando_parse(), e.g. EP_CONDITIONAL.
const char * skip_until_ch(const char *start, char terminator)
Search a string for a terminator character.
const char * skip_classic_expando(const char *str, const struct ExpandoDefinition *defs)
Skip over the text of an Expando.
const char * skip_until_classic_expando(const char *start)
Search through string until we reach an Expando character.
const struct ExpandoRenderData * find_get_number(const struct ExpandoRenderData *rdata, int did, int uid)
Find a get_number() callback function.
const struct ExpandoRenderData * find_get_string(const struct ExpandoRenderData *rdata, int did, int uid)
Find a get_string() callback function.
void buf_lower_special(struct Buffer *buf)
Convert to lowercase, excluding special characters.
int node_expando_render(const struct ExpandoNode *node, const struct ExpandoRenderData *rdata, struct Buffer *buf, int max_cols, void *data, MuttFormatFlags flags)
Render an Expando Node - Implements ExpandoNode::render() -.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Convenience wrapper for the library headers.
char * mutt_strn_dup(const char *begin, size_t len)
Duplicate a sub-string.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
char * mutt_strn_copy(char *dest, const char *src, size_t len, size_t dsize)
Copy a sub-string into a buffer.
Create/manipulate threading in emails.
@ MUTT_SPECIAL_INDEX
Colour indicator.
struct ExpandoNode * node_new(void)
Create a new empty ExpandoNode.
@ ENT_EXPANDO
Expando, e.g. 'n'.
struct ExpandoNode * node_expando_parse(const char *str, const struct ExpandoDefinition *defs, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
Parse an Expando format string.
void node_expando_private_free(void **ptr)
Free Expando private data - Implements ExpandoNode::ndata_free()
void node_expando_set_color(const struct ExpandoNode *node, int cid)
Set the colour for an Expando.
void node_expando_set_has_tree(const struct ExpandoNode *node, bool has_tree)
Set the has_tree flag for an Expando.
struct ExpandoFormat * parse_format(const char *start, const char *end, struct ExpandoParseError *err)
Parse a format string.
void add_color(struct Buffer *buf, enum ColorId cid)
Add a colour code to a buffer.
struct NodeExpandoPrivate * node_expando_private_new(void)
Create new Expando private data.
struct ExpandoNode * node_expando_new(struct ExpandoFormat *fmt, int did, int uid)
Create a new Expando ExpandoNode.
struct ExpandoNode * node_expando_parse_enclosure(const char *str, int did, int uid, char terminator, const char **parsed_until, struct ExpandoParseError *err)
Parse an enclosed Expando.
Expando Node for an Expando.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Render Expandos using Data.
uint8_t MuttFormatFlags
Flags for expando_render(), e.g. MUTT_FORMAT_FORCESUBJ.
String manipulation buffer.
Definition of a format string.
short uid
Unique ID in domain.
struct ExpandoNode *(* parse)(const char *str, int did, int uid, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
const char * short_name
Short Expando name, e.g. "n".
int uid
Unique ID, e.g. ED_EMA_SIZE.
int(* render)(const struct ExpandoNode *node, const struct ExpandoRenderData *rdata, struct Buffer *buf, int max_cols, void *data, MuttFormatFlags flags)
void * ndata
Private node data.
struct ExpandoFormat * format
Formatting info.
int did
Domain ID, e.g. ED_EMAIL.
const char * text
Node-specific text.
enum ExpandoNodeType type
Type of Node, e.g. ENT_EXPANDO.
void(* ndata_free)(void **ptr)
Function to free the private node data.
Buffer for parsing errors.
const char * position
Position of error in original string.
char message[256]
Error message.
long(* get_number)(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
void(* get_string)(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Private data for an Expando -.
bool has_tree
Contains tree characters, used in $index_format's s.