46#define TOGGLE_BIT ((SHRT_MAX + 1) << 1)
52 return (*(intptr_t *) var &
TOGGLE_BIT) ? 0 : *(
short *) var;
60 *(intptr_t *) var = 0;
69 *(intptr_t *) var = *(uintptr_t *) var ^
TOGGLE_BIT;
76 const char *value,
struct Buffer *err)
79 if (value && *value && !mutt_str_atoi_full(value, &num))
85 if ((num < SHRT_MIN) || (num > SHRT_MAX))
104 int rc = cdef->
validator(cs, cdef, (intptr_t) num, err);
144 const struct ConfigDef *cdef, intptr_t value,
147 if ((value < SHRT_MIN) || (value > SHRT_MAX))
149 buf_printf(err,
_(
"Invalid number: %ld"), (
long) value);
164 int rc = cdef->
validator(cs, cdef, value, err);
191 const char *value,
struct Buffer *err)
194 if (!mutt_str_atoi_full(value, &num))
201 if ((result < SHRT_MIN) || (result > SHRT_MAX))
203 buf_printf(err,
_(
"Number is too big: %s"), value);
215 int rc = cdef->
validator(cs, cdef, (intptr_t) result, err);
233 const char *value,
struct Buffer *err)
243 if ((result < SHRT_MIN) || (result > SHRT_MAX))
245 buf_printf(err,
_(
"Number is too big: %s"), value);
257 int rc = cdef->
validator(cs, cdef, (intptr_t) result, err);
303 if (!sub || !he || !he->
data)
const char * mutt_str_atoi(const char *str, int *dst)
Convert ASCII string to an integer.
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
struct HashElem * cs_get_base(struct HashElem *he)
Find the root Config Item.
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.
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 int number_native_set(const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
Set a Number config item by int - Implements ConfigSetType::native_set() -.
static int number_reset(const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *err)
Reset a Number to its initial value - Implements ConfigSetType::reset() -.
static int number_string_get(const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *result)
Get a Number as a string - Implements ConfigSetType::string_get() -.
static int number_string_minus_equals(const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, const char *value, struct Buffer *err)
Subtract from a Number by string - Implements ConfigSetType::string_minus_equals() -.
static int number_string_plus_equals(const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, const char *value, struct Buffer *err)
Add to a Number by string - Implements ConfigSetType::string_plus_equals() -.
static int number_string_set(const struct ConfigSet *cs, void *var, struct ConfigDef *cdef, const char *value, struct Buffer *err)
Set a Number by string - Implements ConfigSetType::string_set() -.
Convenience wrapper for the library headers.
static void native_set(void *var, intptr_t val)
Set an int into a Number config item.
const struct ConfigSetType CstNumber
Config type representing a number.
static void native_toggle(void *var)
Toggle a Number config item.
static intptr_t native_get(void *var)
Get an int from a Number config item.
int number_he_toggle(struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Toggle the value of a number (value <-> 0)
Type representing a number.
String manipulation buffer.
const char * name
User-visible name.
intptr_t var
Storage for the variable.
int(* validator)(const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
intptr_t initial
Initial value.
uint32_t type
Variable type, e.g. DT_STRING.
Container for lots of config items.
A set of inherited config items.
The item stored in a Hash Table.
int type
Type of data stored in Hash Table, e.g. DT_STRING.
void * data
User-supplied data.
void cs_subset_notify_observers(const struct ConfigSubset *sub, struct HashElem *he, enum NotifyConfig ev)
Notify all observers of an event.
@ NT_CONFIG_SET
Config item has been set.
Constants for all the config types.
#define D_INTEGER_NOT_NEGATIVE
Negative numbers are not allowed.