160 else if (*
start ==
'=')
174 unsigned short number = 0;
178 if (!end_ptr || (end_ptr >
end) || (number == USHRT_MAX))
194 if (!isdigit(*
start))
198 snprintf(error->
message,
sizeof(error->
message),
_(
"Number is expected"));
203 unsigned short number = 0;
207 if (!end_ptr || (end_ptr >
end) || (number == USHRT_MAX))
246 char expando[128] = { 0 };
247 const int expando_len = expando_end - format_end;
248 mutt_strn_copy(expando, format_end, expando_len,
sizeof(expando));
264 return definition->
parse(str, parsed_until, definition->
did,
265 definition->
uid, flags, error);
269 *parsed_until = expando_end;
280 snprintf(error->
message,
sizeof(error->
message),
_(
"Unknown expando: %%%.*s"),
281 expando_len, format_end);
297 int did,
int uid,
char terminator,
304 const char *expando_end =
skip_until_ch(format_end, terminator);
306 if (*expando_end != terminator)
312 _(
"Expando is missing terminator: '%c'"), terminator);
324 *parsed_until = expando_end + 1;
355 rd_match->
get_string(node, data, flags, max_cols, buf_expando);
360 ASSERT(rd_match &&
"Unknown UID");
362 const long num = rd_match->
get_number(node, data, flags);
370 if (priv->
color > -1)
393 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.
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'.
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 *error)
Parse a format string.
struct ExpandoNode * node_expando_parse(const char *str, const char **parsed_until, const struct ExpandoDefinition *defs, ExpandoParserFlags flags, struct ExpandoParseError *error)
Parse an Expando format string.
struct ExpandoNode * node_expando_new(const char *start, const char *end, struct ExpandoFormat *fmt, int did, int uid)
Create a new Expando ExpandoNode.
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_parse_enclosure(const char *str, const char **parsed_until, int did, int uid, char terminator, struct ExpandoParseError *error)
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, const char **parsed_until, int did, int uid, ExpandoParserFlags flags, struct ExpandoParseError *error)
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.
const char * end
End of string data.
int did
Domain ID, e.g. ED_EMAIL.
enum ExpandoNodeType type
Type of Node, e.g. ENT_EXPANDO.
const char * start
Start of string data.
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.
void(* get_string)(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
long(* get_number)(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Private data for an Expando.
bool has_tree
Contains tree characters, used in $index_format's s.