46 const char *value,
struct Buffer *err)
48 if (!cs || !cdef || !value)
58 buf_printf(err,
_(
"Invalid enum value: %s"), value);
64 if (num == (*(
unsigned char *) var))
72 int rc = cdef->
validator(cs, cdef, (intptr_t) num, err);
78 *(
unsigned char *) var = num;
100 value = *(
unsigned char *) var;
105 if (!ed || !ed->lookup)
125 if (!cs || !var || !cdef)
135 buf_printf(err,
_(
"Invalid enum value: %ld"), (
long) value);
139 if (value == (*(
unsigned char *) var))
147 int rc = cdef->
validator(cs, cdef, value, err);
153 *(
unsigned char *) var = value;
163 if (!cs || !var || !cdef)
166 return *(
unsigned char *) var;
175 if (!cs || !var || !cdef)
178 if (cdef->
initial == (*(
unsigned char *) var))
192 *(
unsigned char *) var = cdef->
initial;
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
static bool startup_only(const struct ConfigDef *cdef, struct Buffer *err)
Validator function for D_ON_STARTUP.
#define CSR_ERR_INVALID
Value hasn't been set.
#define CSR_INV_TYPE
Value is not valid for the type.
#define CSR_INV_VALIDATOR
Value was rejected by the validator.
#define CSR_SUC_NO_CHANGE
The value hasn't changed.
#define CSR_ERR_CODE
Problem with the code.
#define CSR_SUCCESS
Action completed successfully.
const struct ConfigSetType CstEnum
Config type representing an enumeration.
Type representing an enumeration.
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 int enum_native_set(const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
Set an Enumeration config item by int - Implements ConfigSetType::native_set() -.
static int enum_reset(const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *err)
Reset an Enumeration to its initial value - Implements ConfigSetType::reset() -.
static int enum_string_get(const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *result)
Get an Enumeration as a string - Implements ConfigSetType::string_get() -.
static int enum_string_set(const struct ConfigSet *cs, void *var, struct ConfigDef *cdef, const char *value, struct Buffer *err)
Set an Enumeration by string - Implements ConfigSetType::string_set() -.
#define mutt_debug(LEVEL,...)
@ LL_DEBUG1
Log at debug level 1.
int mutt_map_get_value(const char *name, const struct Mapping *map)
Lookup the constant for a string.
const char * mutt_map_get_name(int val, const struct Mapping *map)
Lookup a string for a constant.
Convenience wrapper for the library headers.
String manipulation buffer.
int(* validator)(const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
intptr_t data
Extra variable data.
intptr_t initial
Initial value.
Container for lots of config items.
const char * name
Config variable.
struct Mapping * lookup
Lookup table.
Constants for all the config types.