Add to a config item by string.
More...
|
static int | long_string_plus_equals (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, const char *value, struct Buffer *err) |
| Add to a Long by string - Implements ConfigSetType::string_plus_equals() -. More...
|
|
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() -. More...
|
|
static int | slist_string_plus_equals (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, const char *value, struct Buffer *err) |
| Add to a Slist by string - Implements ConfigSetType::string_plus_equals() -. More...
|
|
static int | slist_string_minus_equals (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, const char *value, struct Buffer *err) |
| Remove from a Slist by string - Implements ConfigSetType::string_plus_equals() -. More...
|
|
static int | string_string_plus_equals (const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, const char *value, struct Buffer *err) |
| Concat String to a string - Implements ConfigSetType::string_plus_equals() -. More...
|
|
Add to a config item by string.
- Parameters
-
cs | Config items |
var | Variable to set |
cdef | Variable definition |
value | Value to set |
err | Buffer for error messages (may be NULL) |
- Return values
-
Contract
- cs is not NULL
- var is not NULL
- cdef is not NULL
◆ long_string_plus_equals()
static int long_string_plus_equals |
( |
const struct ConfigSet * |
cs, |
|
|
void * |
var, |
|
|
const struct ConfigDef * |
cdef, |
|
|
const char * |
value, |
|
|
struct Buffer * |
err |
|
) |
| |
|
static |
Add to a Long by string - Implements ConfigSetType::string_plus_equals() -.
Definition at line 144 of file long.c.
147{
148 long num = 0;
149 if (!mutt_str_atol_full(value, &num))
150 {
153 }
154
155 long result = *((long *) var) + num;
157 {
160 }
161
162 if (result == (*(long *) var))
164
166 {
167 int rc = cdef->
validator(cs, cdef, (intptr_t) result, err);
168
171 }
172
173 *(long *) var = result;
175}
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
#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.
const char * name
User-visible name.
int(* validator)(const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
uint32_t type
Variable type, e.g. DT_STRING.
#define DT_NOT_NEGATIVE
Negative numbers are not allowed.
◆ number_string_plus_equals()
static int number_string_plus_equals |
( |
const struct ConfigSet * |
cs, |
|
|
void * |
var, |
|
|
const struct ConfigDef * |
cdef, |
|
|
const char * |
value, |
|
|
struct Buffer * |
err |
|
) |
| |
|
static |
Add to a Number by string - Implements ConfigSetType::string_plus_equals() -.
Definition at line 158 of file number.c.
161{
162 int num = 0;
163 if (!mutt_str_atoi_full(value, &num))
164 {
167 }
168
169 int result = *((short *) var) + num;
170 if ((result < SHRT_MIN) || (result > SHRT_MAX))
171 {
174 }
175
177 {
180 }
181
183 {
184 int rc = cdef->
validator(cs, cdef, (intptr_t) result, err);
185
188 }
189
190 *(short *) var = result;
192}
◆ slist_string_plus_equals()
static int slist_string_plus_equals |
( |
const struct ConfigSet * |
cs, |
|
|
void * |
var, |
|
|
const struct ConfigDef * |
cdef, |
|
|
const char * |
value, |
|
|
struct Buffer * |
err |
|
) |
| |
|
static |
Add to a Slist by string - Implements ConfigSetType::string_plus_equals() -.
Definition at line 186 of file slist.c.
189{
190 if (!cs || !cdef)
192
194
195
196 if (value && (value[0] == '\0'))
198
202
204 if (!copy)
206
208
210 {
211 rc = cdef->
validator(cs, cdef, (intptr_t) copy, err);
213 {
216 }
217 }
218
220 *(
struct Slist **) var = copy;
221
222 return rc;
223}
struct Slist * slist_add_string(struct Slist *list, const char *str)
Add a string to a list.
bool slist_is_member(const struct Slist *list, const char *str)
Is a string a member of a list?
struct Slist * slist_dup(const struct Slist *list)
Create a copy of an Slist object.
struct Slist * slist_new(uint32_t flags)
Create a new string list.
void slist_free(struct Slist **list)
Free an Slist object.
#define CSR_ERR_CODE
Problem with the code.
◆ slist_string_minus_equals()
static int slist_string_minus_equals |
( |
const struct ConfigSet * |
cs, |
|
|
void * |
var, |
|
|
const struct ConfigDef * |
cdef, |
|
|
const char * |
value, |
|
|
struct Buffer * |
err |
|
) |
| |
|
static |
Remove from a Slist by string - Implements ConfigSetType::string_plus_equals() -.
Definition at line 228 of file slist.c.
231{
232 if (!cs || !cdef)
234
236
237
238 if (value && (value[0] == '\0'))
240
244
247
249 {
250 rc = cdef->
validator(cs, cdef, (intptr_t) copy, err);
252 {
255 }
256 }
257
259 *(
struct Slist **) var = copy;
260
261 return rc;
262}
struct Slist * slist_remove_string(struct Slist *list, const char *str)
Remove a string from a list.
◆ string_string_plus_equals()
static int string_string_plus_equals |
( |
const struct ConfigSet * |
cs, |
|
|
void * |
var, |
|
|
const struct ConfigDef * |
cdef, |
|
|
const char * |
value, |
|
|
struct Buffer * |
err |
|
) |
| |
|
static |
Concat String to a string - Implements ConfigSetType::string_plus_equals() -.
Definition at line 182 of file string.c.
185{
186
187 if (!value || (value && (value[0] == '\0')))
189
191
192 char *str = NULL;
193 const char **var_str = (const char **) var;
194
195 if (*var_str)
197 else
199
201 {
202 rc = cdef->
validator(cs, cdef, (intptr_t) str, err);
203
205 {
208 }
209 }
210
212 *var_str = str;
213
214 return rc;
215}
static void string_destroy(const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef)
Destroy a String - Implements ConfigSetType::destroy() -.
char * mutt_str_dup(const char *str)
Copy a string, safely.
int mutt_str_asprintf(char **strp, const char *fmt,...)