NeoMutt  2024-04-25-97-g7d2481
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
native_get()

Get a string from a config item. More...

+ Collaboration diagram for native_get():

Functions

static intptr_t address_native_get (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *err)
 Get an Address object from an Address config item - Implements ConfigSetType::native_get() -.
 
static intptr_t bool_native_get (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *err)
 Get a bool from a Bool config item - Implements ConfigSetType::native_get() -.
 
static intptr_t enum_native_get (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *err)
 Get an int object from an Enumeration config item - Implements ConfigSetType::native_get() -.
 
static intptr_t long_native_get (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *err)
 Get a long from a Long config item - Implements ConfigSetType::native_get() -.
 
static intptr_t mbtable_native_get (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *err)
 Get an MbTable object from a MbTable config item - Implements ConfigSetType::native_get() -.
 
static intptr_t myvar_native_get (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *err)
 Get a string from a MyVar config item - Implements ConfigSetType::native_get() -.
 
static intptr_t number_native_get (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *err)
 Get an int from a Number config item - Implements ConfigSetType::native_get() -.
 
static intptr_t path_native_get (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *err)
 Get a string from a Path config item - Implements ConfigSetType::native_get() -.
 
static intptr_t quad_native_get (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *err)
 Get an int object from a Quad-option config item - Implements ConfigSetType::native_get() -.
 
static intptr_t regex_native_get (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *err)
 Get a Regex object from a Regex config item - Implements ConfigSetType::native_get() -.
 
static intptr_t slist_native_get (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *err)
 Get a Slist from a Slist config item - Implements ConfigSetType::native_get() -.
 
static intptr_t sort_native_get (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *err)
 Get an int from a Sort config item - Implements ConfigSetType::native_get() -.
 
static intptr_t string_native_get (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *err)
 Get a string from a String config item - Implements ConfigSetType::native_get() -.
 
static int expando_native_set (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
 Set an Expando object from an Expando config item - Implements ConfigSetType::native_get() -.
 
static intptr_t expando_native_get (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *err)
 Get an Expando object from an Expando config item - Implements ConfigSetType::native_get() -.
 

Detailed Description

Get a string from a config item.

Parameters
csConfig items
varVariable to get
cdefVariable definition
errBuffer for error messages (may be NULL)
Return values
intptr_tConfig item string
INT_MINError
Precondition
cs is not NULL
var is not NULL
cdef is not NULL

Function Documentation

◆ address_native_get()

static intptr_t address_native_get ( const struct ConfigSet cs,
void *  var,
const struct ConfigDef cdef,
struct Buffer err 
)
static

Get an Address object from an Address config item - Implements ConfigSetType::native_get() -.

Definition at line 207 of file config_type.c.

209{
210 struct Address *addr = *(struct Address **) var;
211
212 return (intptr_t) addr;
213}
An email address.
Definition: address.h:36

◆ bool_native_get()

static intptr_t bool_native_get ( const struct ConfigSet cs,
void *  var,
const struct ConfigDef cdef,
struct Buffer err 
)
static

Get a bool from a Bool config item - Implements ConfigSetType::native_get() -.

Definition at line 159 of file bool.c.

161{
162 return *(bool *) var;
163}

◆ enum_native_get()

static intptr_t enum_native_get ( const struct ConfigSet cs,
void *  var,
const struct ConfigDef cdef,
struct Buffer err 
)
static

Get an int object from an Enumeration config item - Implements ConfigSetType::native_get() -.

Definition at line 160 of file enum.c.

162{
163 if (!cs || !var || !cdef)
164 return INT_MIN; /* LCOV_EXCL_LINE */
165
166 return *(unsigned char *) var;
167}

◆ long_native_get()

static intptr_t long_native_get ( const struct ConfigSet cs,
void *  var,
const struct ConfigDef cdef,
struct Buffer err 
)
static

Get a long from a Long config item - Implements ConfigSetType::native_get() -.

Definition at line 143 of file long.c.

145{
146 return *(long *) var;
147}

◆ mbtable_native_get()

static intptr_t mbtable_native_get ( const struct ConfigSet cs,
void *  var,
const struct ConfigDef cdef,
struct Buffer err 
)
static

Get an MbTable object from a MbTable config item - Implements ConfigSetType::native_get() -.

Definition at line 251 of file mbtable.c.

253{
254 struct MbTable *table = *(struct MbTable **) var;
255
256 return (intptr_t) table;
257}
Multibyte character table.
Definition: mbtable.h:36

◆ myvar_native_get()

static intptr_t myvar_native_get ( const struct ConfigSet cs,
void *  var,
const struct ConfigDef cdef,
struct Buffer err 
)
static

Get a string from a MyVar config item - Implements ConfigSetType::native_get() -.

Definition at line 142 of file myvar.c.

144{
145 const char *str = *(const char **) var;
146
147 return (intptr_t) str;
148}

◆ number_native_get()

static intptr_t number_native_get ( const struct ConfigSet cs,
void *  var,
const struct ConfigDef cdef,
struct Buffer err 
)
static

Get an int from a Number config item - Implements ConfigSetType::native_get() -.

Definition at line 158 of file number.c.

160{
161 return *(short *) var;
162}

◆ path_native_get()

static intptr_t path_native_get ( const struct ConfigSet cs,
void *  var,
const struct ConfigDef cdef,
struct Buffer err 
)
static

Get a string from a Path config item - Implements ConfigSetType::native_get() -.

Definition at line 209 of file path.c.

211{
212 const char *str = *(const char **) var;
213
214 return (intptr_t) str;
215}

◆ quad_native_get()

static intptr_t quad_native_get ( const struct ConfigSet cs,
void *  var,
const struct ConfigDef cdef,
struct Buffer err 
)
static

Get an int object from a Quad-option config item - Implements ConfigSetType::native_get() -.

Definition at line 164 of file quad.c.

166{
167 return *(char *) var;
168}

◆ regex_native_get()

static intptr_t regex_native_get ( const struct ConfigSet cs,
void *  var,
const struct ConfigDef cdef,
struct Buffer err 
)
static

Get a Regex object from a Regex config item - Implements ConfigSetType::native_get() -.

Definition at line 275 of file regex.c.

277{
278 struct Regex *r = *(struct Regex **) var;
279
280 return (intptr_t) r;
281}
Cached regular expression.
Definition: regex3.h:85

◆ slist_native_get()

static intptr_t slist_native_get ( const struct ConfigSet cs,
void *  var,
const struct ConfigDef cdef,
struct Buffer err 
)
static

Get a Slist from a Slist config item - Implements ConfigSetType::native_get() -.

Definition at line 191 of file slist.c.

193{
194 if (!cs || !var || !cdef)
195 return INT_MIN; /* LCOV_EXCL_LINE */
196
197 struct Slist *list = *(struct Slist **) var;
198
199 return (intptr_t) list;
200}
String list.
Definition: slist.h:37

◆ sort_native_get()

static intptr_t sort_native_get ( const struct ConfigSet cs,
void *  var,
const struct ConfigDef cdef,
struct Buffer err 
)
static

Get an int from a Sort config item - Implements ConfigSetType::native_get() -.

Definition at line 190 of file sort.c.

192{
193 return *(short *) var;
194}

◆ string_native_get()

static intptr_t string_native_get ( const struct ConfigSet cs,
void *  var,
const struct ConfigDef cdef,
struct Buffer err 
)
static

Get a string from a String config item - Implements ConfigSetType::native_get() -.

Definition at line 179 of file string.c.

181{
182 const char *str = *(const char **) var;
183
184 return (intptr_t) str;
185}

◆ expando_native_set()

static int expando_native_set ( const struct ConfigSet cs,
void *  var,
const struct ConfigDef cdef,
intptr_t  value,
struct Buffer err 
)
static

Set an Expando object from an Expando config item - Implements ConfigSetType::native_get() -.

Definition at line 160 of file config_type.c.

163{
164 int rc;
165
166 struct Expando *exp_value = (struct Expando *) value;
167 if (!exp_value && (cdef->type & D_NOT_EMPTY))
168 {
169 buf_printf(err, _("Option %s may not be empty"), cdef->name);
171 }
172
173 struct Expando *exp_old = *(struct Expando **) var;
174 if (expando_equal(exp_value, exp_old))
176
177 if (startup_only(cdef, err))
179
180 if (cdef->validator)
181 {
182 rc = cdef->validator(cs, cdef, value, err);
183
184 if (CSR_RESULT(rc) != CSR_SUCCESS)
185 return rc | CSR_INV_VALIDATOR;
186 }
187
188 expando_free(var);
189
190 struct Expando *exp_copy = NULL;
191
192 if (exp_value)
193 {
194 const struct ExpandoDefinition *defs = (const struct ExpandoDefinition *)
195 cdef->data;
196 exp_copy = expando_parse(exp_value->string, defs, err);
197 }
198
199 rc = CSR_SUCCESS;
200 if (!exp_copy)
201 rc |= CSR_SUC_EMPTY;
202
203 *(struct Expando **) var = exp_copy;
204 return rc;
205}
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:161
static bool startup_only(const struct ConfigDef *cdef, struct Buffer *err)
Validator function for D_ON_STARTUP.
Definition: set.h:296
#define CSR_ERR_INVALID
Value hasn't been set.
Definition: set.h:38
#define CSR_INV_VALIDATOR
Value was rejected by the validator.
Definition: set.h:48
#define CSR_SUC_NO_CHANGE
The value hasn't changed.
Definition: set.h:44
#define CSR_RESULT(x)
Definition: set.h:52
#define CSR_SUC_EMPTY
Value is empty/unset.
Definition: set.h:42
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:35
struct Expando * expando_parse(const char *str, const struct ExpandoDefinition *defs, struct Buffer *err)
Parse an Expando string.
Definition: expando.c:74
void expando_free(struct Expando **ptr)
Free an Expando object.
Definition: expando.c:54
bool expando_equal(const struct Expando *a, const struct Expando *b)
Compare two expandos.
Definition: expando.c:128
#define _(a)
Definition: message.h:28
const char * name
User-visible name.
Definition: set.h:65
int(* validator)(const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
Definition: set.h:82
intptr_t data
Extra variable data.
Definition: set.h:68
uint32_t type
Variable type, e.g. DT_STRING.
Definition: set.h:66
Definition of a format string.
Definition: definition.h:52
Parsed Expando trees.
Definition: expando.h:41
const char * string
Pointer to the parsed string.
Definition: expando.h:42
#define D_NOT_EMPTY
Empty strings are not allowed.
Definition: types.h:80
+ Here is the call graph for this function:

◆ expando_native_get()

static intptr_t expando_native_get ( const struct ConfigSet cs,
void *  var,
const struct ConfigDef cdef,
struct Buffer err 
)
static

Get an Expando object from an Expando config item - Implements ConfigSetType::native_get() -.

Definition at line 210 of file config_type.c.

212{
213 if (!cs || !var || !cdef)
214 return INT_MIN; /* LCOV_EXCL_LINE */
215
216 struct Expando *exp = *(struct Expando **) var;
217
218 return (intptr_t) exp;
219}