NeoMutt
2025-12-11-1039-g550ac6
Teaching an old dog new tricks
DOXYGEN
Toggle main menu visibility
Loading...
Searching...
No Matches
node_condbool.c
Go to the documentation of this file.
1
23
29
30
#include "config.h"
31
#include <stdio.h>
32
#include "
mutt/lib.h
"
33
#include "
node_condbool.h
"
34
#include "
helpers.h
"
35
#include "
node.h
"
36
#include "
render.h
"
37
41
int
node_condbool_render
(
const
struct
ExpandoNode
*node,
42
const
struct
ExpandoRenderCallback
*erc,
struct
Buffer
*buf,
43
int
max_cols,
void
*
data
,
MuttFormatFlags
flags)
44
{
45
ASSERT
(node->
type
==
ENT_CONDBOOL
);
46
47
const
struct
ExpandoRenderCallback
*erc_match =
find_get_number
(erc, node->
did
, node->
uid
);
48
if
(erc_match)
49
{
50
const
long
num = erc_match->
get_number
(node, data, flags);
51
return
(num != 0);
// bool-ify
52
}
53
54
erc_match =
find_get_string
(erc, node->
did
, node->
uid
);
55
if
(erc_match)
56
{
57
struct
Buffer
*buf_str =
buf_pool_get
();
58
erc_match->
get_string
(node,
data
, flags, buf_str);
59
const
size_t
len =
buf_len
(buf_str);
60
buf_pool_release
(&buf_str);
61
62
return
(len > 0);
// bool-ify
63
}
64
65
return
0;
66
}
buf_len
size_t buf_len(const struct Buffer *buf)
Calculate the length of a Buffer.
Definition
buffer.c:497
find_get_string
const struct ExpandoRenderCallback * find_get_string(const struct ExpandoRenderCallback *erc, int did, int uid)
Find a get_string() callback function.
Definition
helpers.c:69
find_get_number
const struct ExpandoRenderCallback * find_get_number(const struct ExpandoRenderCallback *erc, int did, int uid)
Find a get_number() callback function.
Definition
helpers.c:45
helpers.h
Shared code.
node_condbool_render
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
lib.h
Convenience wrapper for the library headers.
node.h
Basic Expando Node.
ENT_CONDBOOL
@ ENT_CONDBOOL
True/False boolean condition.
Definition
node.h:42
node_condbool.h
Expando Node for a Conditional Boolean.
buf_pool_get
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition
pool.c:91
buf_pool_release
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition
pool.c:111
render.h
Render Expandos using Data.
MuttFormatFlags
uint8_t MuttFormatFlags
Definition
render.h:45
ASSERT
#define ASSERT(COND)
Definition
signal2.h:59
Buffer
String manipulation buffer.
Definition
buffer.h:36
Buffer::data
char * data
Pointer to data.
Definition
buffer.h:37
ExpandoNode
Basic Expando Node.
Definition
node.h:67
ExpandoNode::uid
int uid
Unique ID, e.g. ED_EMA_SIZE.
Definition
node.h:70
ExpandoNode::did
int did
Domain ID, e.g. ED_EMAIL.
Definition
node.h:69
ExpandoNode::type
enum ExpandoNodeType type
Type of Node, e.g. ENT_EXPANDO.
Definition
node.h:68
ExpandoRenderCallback
Definition
render.h:82
ExpandoRenderCallback::get_string
get_string_t get_string
Callback function to get a string.
Definition
render.h:86
ExpandoRenderCallback::get_number
get_number_t get_number
Callback function to get a number.
Definition
render.h:87