53 mbstate_t mbstate = { 0 };
69 while (slen && (k = mbrtowc(NULL, s, slen, &mbstate)))
71 if ((k == (
size_t) (-1)) || (k == (
size_t) (-2)))
75 (k == (
size_t) (-1)) ? -1 : -2, s, t->
orig_str);
76 if (k == (
size_t) (-1))
77 memset(&mbstate, 0,
sizeof(mbstate));
78 k = (k == (size_t) (-1)) ? 1 : slen;
107 const char *value,
struct Buffer *err)
110 if (value && (value[0] ==
'\0'))
127 rc = cdef->
validator(cs, cdef, (intptr_t) table, err);
138 *(
struct MbTable **) var = table;
161 const char *str = NULL;
198 const struct ConfigDef *cdef, intptr_t value,
205 rc = cdef->
validator(cs, cdef, value, err);
219 *(
struct MbTable **) var = table;
231 return (intptr_t) table;
241 const char *initial = (
const char *) cdef->
initial;
244 const char *curval = curtable ? curtable->
orig_str : NULL;
258 rc = cdef->
validator(cs, cdef, (intptr_t) table, err);
272 *(
struct MbTable **) var = table;
282 if (!table || !*table)
285 FREE(&(*table)->orig_str);
286 FREE(&(*table)->chars);
287 FREE(&(*table)->segmented_str);
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
#define CSR_INV_VALIDATOR
Value was rejected by the validator.
#define CSR_SUC_NO_CHANGE
The value hasn't changed.
#define CSR_SUC_EMPTY
Value is empty/unset.
#define CSR_SUCCESS
Action completed successfully.
static void mbtable_destroy(const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef)
Destroy an MbTable object - Implements ConfigSetType::destroy() -.
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 int mbtable_native_set(const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
Set an MbTable config item by MbTable object - Implements ConfigSetType::native_set() -.
static int mbtable_reset(const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *err)
Reset an MbTable to its initial value - Implements ConfigSetType::reset() -.
static int mbtable_string_get(const struct ConfigSet *cs, void *var, const struct ConfigDef *cdef, struct Buffer *result)
Get a MbTable as a string - Implements ConfigSetType::string_get() -.
static int mbtable_string_set(const struct ConfigSet *cs, void *var, struct ConfigDef *cdef, const char *value, struct Buffer *err)
Set an MbTable by string - Implements ConfigSetType::string_set() -.
#define mutt_debug(LEVEL,...)
@ LL_DEBUG1
Log at debug level 1.
void mbtable_free(struct MbTable **table)
Free an MbTable object.
static struct MbTable * mbtable_dup(struct MbTable *table)
Create a copy of an MbTable object.
struct MbTable * mbtable_parse(const char *s)
Parse a multibyte string into a table.
const struct ConfigSetType CstMbtable
Config type representing a multi-byte table.
Type representing a multibyte character table.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Convenience wrapper for the library headers.
char * mutt_str_dup(const char *str)
Copy a string, safely.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
String manipulation buffer.
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.
Multibyte character table.
char * orig_str
Original string used to generate this object.
int len
Number of characters.
char ** chars
The array of multibyte character strings.
char * segmented_str
Each chars entry points inside this string.
Constants for all the config types.
#define DT_INITIAL_SET
Config item must have its initial value freed.
#define DT_MBTABLE
multibyte char table