NeoMutt  2022-04-29-249-gaae397
Teaching an old dog new tricks
DOXYGEN
subset.h File Reference

Subset of Config Items. More...

#include <stdint.h>
+ Include dependency graph for subset.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ConfigSubset
 A set of inherited config items. More...
 
struct  EventConfig
 A config-change event. More...
 

Enumerations

enum  ConfigScope { SET_SCOPE_NEOMUTT , SET_SCOPE_ACCOUNT , SET_SCOPE_MAILBOX }
 Who does this Config belong to? More...
 
enum  NotifyConfig { NT_CONFIG_SET = 1 , NT_CONFIG_RESET }
 Config notification types. More...
 

Functions

struct ConfigSubsetcs_subset_new (const char *name, struct ConfigSubset *sub_parent, struct Notify *not_parent)
 Create a new Config Subset. More...
 
void cs_subset_free (struct ConfigSubset **ptr)
 Free a Config Subset. More...
 
struct HashElemcs_subset_create_inheritance (const struct ConfigSubset *sub, const char *name)
 Create a Subset config item (inherited) More...
 
struct HashElemcs_subset_lookup (const struct ConfigSubset *sub, const char *name)
 Find an inherited config item. More...
 
void cs_subset_notify_observers (const struct ConfigSubset *sub, struct HashElem *he, enum NotifyConfig ev)
 Notify all observers of an event. More...
 
intptr_t cs_subset_he_native_get (const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
 Natively get the value of a HashElem config item. More...
 
int cs_subset_he_native_set (const struct ConfigSubset *sub, struct HashElem *he, intptr_t value, struct Buffer *err)
 Natively set the value of a HashElem config item. More...
 
int cs_subset_he_reset (const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
 Reset a config item to its initial value. More...
 
int cs_subset_he_string_get (const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *result)
 Get a config item as a string. More...
 
int cs_subset_he_string_minus_equals (const struct ConfigSubset *sub, struct HashElem *he, const char *value, struct Buffer *err)
 Remove from a config item by string. More...
 
int cs_subset_he_string_plus_equals (const struct ConfigSubset *sub, struct HashElem *he, const char *value, struct Buffer *err)
 Add to a config item by string. More...
 
int cs_subset_he_string_set (const struct ConfigSubset *sub, struct HashElem *he, const char *value, struct Buffer *err)
 Set a config item by string. More...
 
intptr_t cs_subset_str_native_get (const struct ConfigSubset *sub, const char *name, struct Buffer *err)
 Natively get the value of a string config item. More...
 
int cs_subset_str_native_set (const struct ConfigSubset *sub, const char *name, intptr_t value, struct Buffer *err)
 Natively set the value of a string config item. More...
 
int cs_subset_str_reset (const struct ConfigSubset *sub, const char *name, struct Buffer *err)
 Reset a config item to its initial value. More...
 
int cs_subset_str_string_get (const struct ConfigSubset *sub, const char *name, struct Buffer *result)
 Get a config item as a string. More...
 
int cs_subset_str_string_minus_equals (const struct ConfigSubset *sub, const char *name, const char *value, struct Buffer *err)
 Remove from a config item by string. More...
 
int cs_subset_str_string_plus_equals (const struct ConfigSubset *sub, const char *name, const char *value, struct Buffer *err)
 Add to a config item by string. More...
 
int cs_subset_str_string_set (const struct ConfigSubset *sub, const char *name, const char *value, struct Buffer *err)
 Set a config item by string. More...
 
int elem_list_sort (const void *a, const void *b)
 Sort two HashElem pointers to config. More...
 
struct HashElem ** get_elem_list (struct ConfigSet *cs)
 Create a sorted list of all config items. More...
 

Detailed Description

Subset of Config Items.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file subset.h.

Enumeration Type Documentation

◆ ConfigScope

Who does this Config belong to?

Enumerator
SET_SCOPE_NEOMUTT 

This Config is NeoMutt-specific (global)

SET_SCOPE_ACCOUNT 

This Config is Account-specific.

SET_SCOPE_MAILBOX 

This Config is Mailbox-specific.

Definition at line 36 of file subset.h.

37{
41};
@ SET_SCOPE_MAILBOX
This Config is Mailbox-specific.
Definition: subset.h:40
@ SET_SCOPE_NEOMUTT
This Config is NeoMutt-specific (global)
Definition: subset.h:38
@ SET_SCOPE_ACCOUNT
This Config is Account-specific.
Definition: subset.h:39

◆ NotifyConfig

Config notification types.

Observers of NT_CONFIG will be passed an EventConfig.

Enumerator
NT_CONFIG_SET 

Config item has been set.

NT_CONFIG_RESET 

Config item has been reset to initial, or parent, value.

Definition at line 60 of file subset.h.

61{
62 NT_CONFIG_SET = 1,
64};
@ NT_CONFIG_RESET
Config item has been reset to initial, or parent, value.
Definition: subset.h:63
@ NT_CONFIG_SET
Config item has been set.
Definition: subset.h:62

Function Documentation

◆ cs_subset_new()

struct ConfigSubset * cs_subset_new ( const char *  name,
struct ConfigSubset sub_parent,
struct Notify not_parent 
)

Create a new Config Subset.

Parameters
nameName for this Subset
sub_parentParent Subset
not_parentParent Notification
Return values
ptrNew Subset
Note
The name will be combined with the parents' names

Definition at line 144 of file subset.c.

146{
147 struct ConfigSubset *sub = mutt_mem_calloc(1, sizeof(*sub));
148
149 if (sub_parent)
150 {
151 sub->parent = sub_parent;
152 sub->cs = sub_parent->cs;
153 }
154
155 if (name)
156 {
157 char scope[256] = { 0 };
158
159 if (sub_parent && sub_parent->name)
160 snprintf(scope, sizeof(scope), "%s:%s", sub_parent->name, name);
161 else
162 mutt_str_copy(scope, name, sizeof(scope));
163
164 sub->name = mutt_str_dup(scope);
165 }
166
167 sub->notify = notify_new();
168 notify_set_parent(sub->notify, not_parent);
169
170 return sub;
171}
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
struct Notify * notify_new(void)
Create a new notifications handler.
Definition: notify.c:60
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition: notify.c:93
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:250
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:652
A set of inherited config items.
Definition: subset.h:47
struct Notify * notify
Notifications: NotifyConfig, EventConfig.
Definition: subset.h:52
const char * name
Scope name of Subset.
Definition: subset.h:48
struct ConfigSet * cs
Parent ConfigSet.
Definition: subset.h:51
struct ConfigSubset * parent
Parent Subset.
Definition: subset.h:50
enum ConfigScope scope
Scope of Subset, e.g. SET_SCOPE_ACCOUNT.
Definition: subset.h:49
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cs_subset_free()

void cs_subset_free ( struct ConfigSubset **  ptr)

Free a Config Subset.

Parameters
ptrSubset to free
Note
Config items matching this Subset will be freed

Definition at line 104 of file subset.c.

105{
106 if (!ptr || !*ptr)
107 return;
108
109 struct ConfigSubset *sub = *ptr;
110
111 if (sub->cs && sub->name)
112 {
113 char scope[256] = { 0 };
114 snprintf(scope, sizeof(scope), "%s:", sub->name);
115
116 // We don't know if any config items have been set,
117 // so search for anything with a matching scope.
118 struct HashElem **list = get_elem_list(sub->cs);
119 for (size_t i = 0; list[i]; i++)
120 {
121 const char *item = list[i]->key.strkey;
122 if (mutt_str_startswith(item, scope) != 0)
123 {
124 cs_uninherit_variable(sub->cs, item);
125 }
126 }
127 FREE(&list);
128 }
129
130 notify_free(&sub->notify);
131 FREE(&sub->name);
132 FREE(ptr);
133}
#define FREE(x)
Definition: memory.h:43
void notify_free(struct Notify **ptr)
Free a notification handler.
Definition: notify.c:73
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
Definition: string.c:227
void cs_uninherit_variable(const struct ConfigSet *cs, const char *name)
Remove an inherited config item.
Definition: set.c:331
The item stored in a Hash Table.
Definition: hash.h:44
union HashKey key
Key representing the data.
Definition: hash.h:46
struct HashElem ** get_elem_list(struct ConfigSet *cs)
Create a sorted list of all config items.
Definition: subset.c:75
const char * strkey
String key.
Definition: hash.h:36
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cs_subset_create_inheritance()

struct HashElem * cs_subset_create_inheritance ( const struct ConfigSubset sub,
const char *  name 
)

Create a Subset config item (inherited)

Parameters
subConfig Subset
nameName of config item
Return values
ptrHashElem of the config item
NULLError

Definition at line 200 of file subset.c.

201{
202 if (!sub)
203 return NULL;
204
205 struct HashElem *he = cs_subset_lookup(sub, name);
206 if (he)
207 return he;
208
209 if (sub->parent)
210 {
211 // Create parent before creating name
212 he = cs_subset_create_inheritance(sub->parent, name);
213 }
214
215 if (!he)
216 return NULL;
217
218 char scope[256] = { 0 };
219 snprintf(scope, sizeof(scope), "%s:%s", sub->name, name);
220 return cs_inherit_variable(sub->cs, he, scope);
221}
struct HashElem * cs_inherit_variable(const struct ConfigSet *cs, struct HashElem *parent, const char *name)
Create in inherited config item.
Definition: set.c:306
struct HashElem * cs_subset_create_inheritance(const struct ConfigSubset *sub, const char *name)
Create a Subset config item (inherited)
Definition: subset.c:200
struct HashElem * cs_subset_lookup(const struct ConfigSubset *sub, const char *name)
Find an inherited config item.
Definition: subset.c:179
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cs_subset_lookup()

struct HashElem * cs_subset_lookup ( const struct ConfigSubset sub,
const char *  name 
)

Find an inherited config item.

Parameters
subSubset to search
nameName of Config item to find
Return values
ptrHashElem of the config item

Definition at line 179 of file subset.c.

180{
181 if (!sub || !name)
182 return NULL;
183
184 char scope[256] = { 0 };
185 if (sub->name)
186 snprintf(scope, sizeof(scope), "%s:%s", sub->name, name);
187 else
188 mutt_str_copy(scope, name, sizeof(scope));
189
190 return cs_get_elem(sub->cs, scope);
191}
struct HashElem * cs_get_elem(const struct ConfigSet *cs, const char *name)
Get the HashElem representing a config item.
Definition: set.c:204
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cs_subset_notify_observers()

void cs_subset_notify_observers ( const struct ConfigSubset sub,
struct HashElem he,
enum NotifyConfig  ev 
)

Notify all observers of an event.

Parameters
subConfig Subset
heHashElem representing config item
evType of event

Definition at line 229 of file subset.c.

231{
232 if (!sub || !he)
233 return;
234
235 struct HashElem *he_base = cs_get_base(he);
236 struct EventConfig ev_c = { sub, he_base->key.strkey, he };
237 mutt_debug(LL_NOTIFY, "%s: %s\n",
239 notify_send(sub->notify, NT_CONFIG, ev, &ev_c);
240}
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
@ LL_NOTIFY
Log of notifications.
Definition: logging.h:45
const char * mutt_map_get_name(int val, const struct Mapping *map)
Lookup a string for a constant.
Definition: mapping.c:42
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition: notify.c:171
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:43
struct HashElem * cs_get_base(struct HashElem *he)
Find the root Config Item.
Definition: set.c:189
#define NONULL(x)
Definition: string2.h:37
A config-change event.
Definition: subset.h:70
const struct ConfigSubset * sub
Config Subset.
Definition: subset.h:71
struct HashElem * he
Config item that changed.
Definition: subset.h:73
static const struct Mapping ConfigEventNames[]
Names for logging.
Definition: subset.c:43
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cs_subset_he_native_get()

intptr_t cs_subset_he_native_get ( const struct ConfigSubset sub,
struct HashElem he,
struct Buffer err 
)

Natively get the value of a HashElem config item.

Parameters
subConfig Subset
heHashElem representing config item
errBuffer for error messages
Return values
intptr_tNative pointer/value
INT_MINError

Definition at line 250 of file subset.c.

252{
253 if (!sub)
254 return INT_MIN;
255
256 return cs_he_native_get(sub->cs, he, err);
257}
intptr_t cs_he_native_get(const struct ConfigSet *cs, struct HashElem *he, struct Buffer *err)
Natively get the value of a HashElem config item.
Definition: set.c:790
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cs_subset_he_native_set()

int cs_subset_he_native_set ( const struct ConfigSubset sub,
struct HashElem he,
intptr_t  value,
struct Buffer err 
)

Natively set the value of a HashElem config item.

Parameters
subConfig Subset
heHashElem representing config item
valueNative pointer/value to set
errBuffer for error messages
Return values
numResult, e.g. CSR_SUCCESS

Definition at line 283 of file subset.c.

285{
286 if (!sub)
287 return CSR_ERR_CODE;
288
289 int rc = cs_he_native_set(sub->cs, he, value, err);
290
291 if ((CSR_RESULT(rc) == CSR_SUCCESS) && !(rc & CSR_SUC_NO_CHANGE))
293
294 return rc;
295}
int cs_he_native_set(const struct ConfigSet *cs, struct HashElem *he, intptr_t value, struct Buffer *err)
Natively set the value of a HashElem config item.
Definition: set.c:685
#define CSR_SUC_NO_CHANGE
The value hasn't changed.
Definition: set.h:44
#define CSR_ERR_CODE
Problem with the code.
Definition: set.h:36
#define CSR_RESULT(x)
Definition: set.h:52
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:35
void cs_subset_notify_observers(const struct ConfigSubset *sub, struct HashElem *he, enum NotifyConfig ev)
Notify all observers of an event.
Definition: subset.c:229
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cs_subset_he_reset()

int cs_subset_he_reset ( const struct ConfigSubset sub,
struct HashElem he,
struct Buffer err 
)

Reset a config item to its initial value.

Parameters
subConfig Subset
heHashElem representing config item
errBuffer for error messages
Return values
numResult, e.g. CSR_SUCCESS

Definition at line 320 of file subset.c.

321{
322 if (!sub)
323 return CSR_ERR_CODE;
324
325 int rc = cs_he_reset(sub->cs, he, err);
326
327 if ((CSR_RESULT(rc) == CSR_SUCCESS) && !(rc & CSR_SUC_NO_CHANGE))
329
330 return rc;
331}
int cs_he_reset(const struct ConfigSet *cs, struct HashElem *he, struct Buffer *err)
Reset a config item to its initial value.
Definition: set.c:346
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cs_subset_he_string_get()

int cs_subset_he_string_get ( const struct ConfigSubset sub,
struct HashElem he,
struct Buffer result 
)

Get a config item as a string.

Parameters
subConfig Subset
heHashElem representing config item
resultBuffer for results or error messages
Return values
numResult, e.g. CSR_SUCCESS

Definition at line 354 of file subset.c.

356{
357 if (!sub)
358 return CSR_ERR_CODE;
359
360 return cs_he_string_get(sub->cs, he, result);
361}
int cs_he_string_get(const struct ConfigSet *cs, struct HashElem *he, struct Buffer *result)
Get a config item as a string.
Definition: set.c:618
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cs_subset_he_string_minus_equals()

int cs_subset_he_string_minus_equals ( const struct ConfigSubset sub,
struct HashElem he,
const char *  value,
struct Buffer err 
)

Remove from a config item by string.

Parameters
subConfig Subset
heHashElem representing config item
valueValue to set
errBuffer for error messages
Return values
numResult, e.g. CSR_SUCCESS

Definition at line 462 of file subset.c.

464{
465 if (!sub)
466 return CSR_ERR_CODE;
467
468 int rc = cs_he_string_minus_equals(sub->cs, he, value, err);
469
470 if ((CSR_RESULT(rc) == CSR_SUCCESS) && !(rc & CSR_SUC_NO_CHANGE))
472
473 return rc;
474}
int cs_he_string_minus_equals(const struct ConfigSet *cs, struct HashElem *he, const char *value, struct Buffer *err)
Remove from a config item by string.
Definition: set.c:941
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cs_subset_he_string_plus_equals()

int cs_subset_he_string_plus_equals ( const struct ConfigSubset sub,
struct HashElem he,
const char *  value,
struct Buffer err 
)

Add to a config item by string.

Parameters
subConfig Subset
heHashElem representing config item
valueValue to set
errBuffer for error messages
Return values
numResult, e.g. CSR_SUCCESS

Definition at line 424 of file subset.c.

426{
427 if (!sub)
428 return CSR_ERR_CODE;
429
430 int rc = cs_he_string_plus_equals(sub->cs, he, value, err);
431
432 if ((CSR_RESULT(rc) == CSR_SUCCESS) && !(rc & CSR_SUC_NO_CHANGE))
434
435 return rc;
436}
int cs_he_string_plus_equals(const struct ConfigSet *cs, struct HashElem *he, const char *value, struct Buffer *err)
Add to a config item by string.
Definition: set.c:858
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cs_subset_he_string_set()

int cs_subset_he_string_set ( const struct ConfigSubset sub,
struct HashElem he,
const char *  value,
struct Buffer err 
)

Set a config item by string.

Parameters
subConfig Subset
heHashElem representing config item
valueValue to set
errBuffer for error messages
Return values
numResult, e.g. CSR_SUCCESS

Definition at line 386 of file subset.c.

388{
389 if (!sub)
390 return CSR_ERR_CODE;
391
392 int rc = cs_he_string_set(sub->cs, he, value, err);
393
394 if ((CSR_RESULT(rc) == CSR_SUCCESS) && !(rc & CSR_SUC_NO_CHANGE))
396
397 return rc;
398}
int cs_he_string_set(const struct ConfigSet *cs, struct HashElem *he, const char *value, struct Buffer *err)
Set a config item by string.
Definition: set.c:543
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cs_subset_str_native_get()

intptr_t cs_subset_str_native_get ( const struct ConfigSubset sub,
const char *  name,
struct Buffer err 
)

Natively get the value of a string config item.

Parameters
subConfig Subset
nameName of config item
errBuffer for error messages
Return values
intptr_tNative pointer/value
INT_MINError

Definition at line 267 of file subset.c.

269{
270 struct HashElem *he = cs_subset_create_inheritance(sub, name);
271
272 return cs_subset_he_native_get(sub, he, err);
273}
intptr_t cs_subset_he_native_get(const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Natively get the value of a HashElem config item.
Definition: subset.c:250
+ Here is the call graph for this function:

◆ cs_subset_str_native_set()

int cs_subset_str_native_set ( const struct ConfigSubset sub,
const char *  name,
intptr_t  value,
struct Buffer err 
)

Natively set the value of a string config item.

Parameters
subConfig Subset
nameName of config item
valueNative pointer/value to set
errBuffer for error messages
Return values
numResult, e.g. CSR_SUCCESS

Definition at line 305 of file subset.c.

307{
308 struct HashElem *he = cs_subset_create_inheritance(sub, name);
309
310 return cs_subset_he_native_set(sub, he, value, err);
311}
int cs_subset_he_native_set(const struct ConfigSubset *sub, struct HashElem *he, intptr_t value, struct Buffer *err)
Natively set the value of a HashElem config item.
Definition: subset.c:283
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cs_subset_str_reset()

int cs_subset_str_reset ( const struct ConfigSubset sub,
const char *  name,
struct Buffer err 
)

Reset a config item to its initial value.

Parameters
subConfig Subset
nameName of config item
errBuffer for error messages
Return values
numResult, e.g. CSR_SUCCESS

Definition at line 340 of file subset.c.

341{
342 struct HashElem *he = cs_subset_create_inheritance(sub, name);
343
344 return cs_subset_he_reset(sub, he, err);
345}
int cs_subset_he_reset(const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Reset a config item to its initial value.
Definition: subset.c:320
+ Here is the call graph for this function:

◆ cs_subset_str_string_get()

int cs_subset_str_string_get ( const struct ConfigSubset sub,
const char *  name,
struct Buffer result 
)

Get a config item as a string.

Parameters
subConfig Subset
nameName of config item
resultBuffer for results or error messages
Return values
numResult, e.g. CSR_SUCCESS

Definition at line 370 of file subset.c.

372{
373 struct HashElem *he = cs_subset_create_inheritance(sub, name);
374
375 return cs_subset_he_string_get(sub, he, result);
376}
int cs_subset_he_string_get(const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *result)
Get a config item as a string.
Definition: subset.c:354
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cs_subset_str_string_minus_equals()

int cs_subset_str_string_minus_equals ( const struct ConfigSubset sub,
const char *  name,
const char *  value,
struct Buffer err 
)

Remove from a config item by string.

Parameters
subConfig Subset
nameName of config item
valueValue to set
errBuffer for error messages
Return values
numResult, e.g. CSR_SUCCESS

Definition at line 484 of file subset.c.

486{
487 struct HashElem *he = cs_subset_create_inheritance(sub, name);
488
489 return cs_subset_he_string_minus_equals(sub, he, value, err);
490}
int cs_subset_he_string_minus_equals(const struct ConfigSubset *sub, struct HashElem *he, const char *value, struct Buffer *err)
Remove from a config item by string.
Definition: subset.c:462
+ Here is the call graph for this function:

◆ cs_subset_str_string_plus_equals()

int cs_subset_str_string_plus_equals ( const struct ConfigSubset sub,
const char *  name,
const char *  value,
struct Buffer err 
)

Add to a config item by string.

Parameters
subConfig Subset
nameName of config item
valueValue to set
errBuffer for error messages
Return values
numResult, e.g. CSR_SUCCESS

Definition at line 446 of file subset.c.

448{
449 struct HashElem *he = cs_subset_create_inheritance(sub, name);
450
451 return cs_subset_he_string_plus_equals(sub, he, value, err);
452}
int cs_subset_he_string_plus_equals(const struct ConfigSubset *sub, struct HashElem *he, const char *value, struct Buffer *err)
Add to a config item by string.
Definition: subset.c:424
+ Here is the call graph for this function:

◆ cs_subset_str_string_set()

int cs_subset_str_string_set ( const struct ConfigSubset sub,
const char *  name,
const char *  value,
struct Buffer err 
)

Set a config item by string.

Parameters
subConfig Subset
nameName of config item
valueValue to set
errBuffer for error messages
Return values
numResult, e.g. CSR_SUCCESS

Definition at line 408 of file subset.c.

410{
411 struct HashElem *he = cs_subset_create_inheritance(sub, name);
412
413 return cs_subset_he_string_set(sub, he, value, err);
414}
int cs_subset_he_string_set(const struct ConfigSubset *sub, struct HashElem *he, const char *value, struct Buffer *err)
Set a config item by string.
Definition: subset.c:386
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ elem_list_sort()

int elem_list_sort ( const void *  a,
const void *  b 
)

Sort two HashElem pointers to config.

Parameters
aFirst HashElem
bSecond HashElem
Return values
-1a precedes b
0a and b are identical
1b precedes a

Definition at line 59 of file subset.c.

60{
61 if (!a || !b)
62 return 0;
63
64 const struct HashElem *hea = *(struct HashElem const *const *) a;
65 const struct HashElem *heb = *(struct HashElem const *const *) b;
66
67 return mutt_istr_cmp(hea->key.strkey, heb->key.strkey);
68}
int mutt_istr_cmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:483
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_elem_list()

struct HashElem ** get_elem_list ( struct ConfigSet cs)

Create a sorted list of all config items.

Parameters
csConfigSet to read
Return values
ptrNull-terminated array of HashElem

Definition at line 75 of file subset.c.

76{
77 if (!cs)
78 return NULL;
79
80 struct HashElem **list = mutt_mem_calloc(1024, sizeof(struct HashElem *));
81 size_t index = 0;
82
83 struct HashWalkState walk = { 0 };
84 struct HashElem *he = NULL;
85
86 while ((he = mutt_hash_walk(cs->hash, &walk)))
87 {
88 list[index++] = he;
89 if (index == 1022)
90 break; /* LCOV_EXCL_LINE */
91 }
92
93 qsort(list, index, sizeof(struct HashElem *), elem_list_sort);
94
95 return list;
96}
struct HashElem * mutt_hash_walk(const struct HashTable *table, struct HashWalkState *state)
Iterate through all the HashElem's in a Hash Table.
Definition: hash.c:489
struct HashTable * hash
HashTable storing the config items.
Definition: set.h:261
Cursor to iterate through a Hash Table.
Definition: hash.h:132
int elem_list_sort(const void *a, const void *b)
Sort two HashElem pointers to config.
Definition: subset.c:59
+ Here is the call graph for this function:
+ Here is the caller graph for this function: