48 const char *value,
struct Buffer *err)
50 if (!value || (value[0] ==
'\0'))
57 if (!mutt_str_atoi_full(value, &num))
63 if ((num < SHRT_MIN) || (num > SHRT_MAX))
77 if (num == (*(
short *) var))
82 int rc = cdef->
validator(cs, cdef, (intptr_t) num, err);
110 value = *(
short *) var;
122 const struct ConfigDef *cdef, intptr_t value,
125 if ((value < SHRT_MIN) || (value > SHRT_MAX))
127 buf_printf(err,
_(
"Invalid number: %ld"), (
long) value);
137 if (value == (*(
short *) var))
142 int rc = cdef->
validator(cs, cdef, value, err);
151 *(
short *) var = value;
161 return *(
short *) var;
169 const char *value,
struct Buffer *err)
172 if (!mutt_str_atoi_full(value, &num))
178 int result = *((
short *) var) + num;
179 if ((result < SHRT_MIN) || (result > SHRT_MAX))
181 buf_printf(err,
_(
"Number is too big: %s"), value);
193 int rc = cdef->
validator(cs, cdef, (intptr_t) result, err);
202 *(
short *) var = result;
211 const char *value,
struct Buffer *err)
220 int result = *((
short *) var) - num;
221 if ((result < SHRT_MIN) || (result > SHRT_MAX))
223 buf_printf(err,
_(
"Number is too big: %s"), value);
235 int rc = cdef->
validator(cs, cdef, (intptr_t) result, err);
244 *(
short *) var = result;
254 if (cdef->
initial == (*(
short *) var))
268 *(
short *) var = cdef->
initial;
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.
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_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.
const struct ConfigSetType CstNumber
Config type representing a number.
String manipulation buffer.
const char * name
User-visible name.
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.
Constants for all the config types.
#define D_INTEGER_NOT_NEGATIVE
Negative numbers are not allowed.