NeoMutt  2023-05-17-16-g61469c
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 , NT_CONFIG_DELETED }
 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...
 
int cs_subset_he_delete (const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
 Delete config item from a config. 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 cs_subset_str_delete (const struct ConfigSubset *sub, const char *name, struct Buffer *err)
 Delete config item from a config 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.

NT_CONFIG_DELETED 

Config item has been deleted.

Definition at line 60 of file subset.h.

61{
62 NT_CONFIG_SET = 1,
65};
@ NT_CONFIG_DELETED
Config item has been deleted.
Definition: subset.h: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 149 of file subset.c.

151{
152 struct ConfigSubset *sub = mutt_mem_calloc(1, sizeof(*sub));
153
154 if (sub_parent)
155 {
156 sub->parent = sub_parent;
157 sub->cs = sub_parent->cs;
158 }
159
160 if (name)
161 {
162 char scope[256] = { 0 };
163
164 if (sub_parent && sub_parent->name)
165 snprintf(scope, sizeof(scope), "%s:%s", sub_parent->name, name);
166 else
167 mutt_str_copy(scope, name, sizeof(scope));
168
169 sub->name = mutt_str_dup(scope);
170 }
171
172 sub->notify = notify_new();
173 notify_set_parent(sub->notify, not_parent);
174
175 return sub;
176}
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:251
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:653
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 105 of file subset.c.

106{
107 if (!ptr || !*ptr)
108 return;
109
110 struct ConfigSubset *sub = *ptr;
111
112 struct EventConfig ev_c = { sub, NULL, NULL };
113 mutt_debug(LL_NOTIFY, "NT_CONFIG_DELETED: ALL\n");
115
116 if (sub->cs && sub->name)
117 {
118 char scope[256] = { 0 };
119 snprintf(scope, sizeof(scope), "%s:", sub->name);
120
121 // We don't know if any config items have been set,
122 // so search for anything with a matching scope.
123 struct HashElem **he_list = get_elem_list(sub->cs);
124 for (size_t i = 0; he_list[i]; i++)
125 {
126 const char *item = he_list[i]->key.strkey;
127 if (mutt_str_startswith(item, scope) != 0)
128 {
129 cs_uninherit_variable(sub->cs, item);
130 }
131 }
132 FREE(&he_list);
133 }
134
135 notify_free(&sub->notify);
136 FREE(&sub->name);
137 FREE(ptr);
138}
void cs_uninherit_variable(const struct ConfigSet *cs, const char *name)
Remove an inherited config item.
Definition: set.c:375
#define mutt_debug(LEVEL,...)
Definition: logging2.h:84
@ LL_NOTIFY
Log of notifications.
Definition: logging2.h:45
#define FREE(x)
Definition: memory.h:43
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
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:228
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:43
A config-change event.
Definition: subset.h:71
const struct ConfigSubset * sub
Config Subset.
Definition: subset.h:72
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:76
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 205 of file subset.c.

206{
207 if (!sub)
208 return NULL;
209
210 struct HashElem *he = cs_subset_lookup(sub, name);
211 if (he)
212 return he;
213
214 if (sub->parent)
215 {
216 // Create parent before creating name
217 he = cs_subset_create_inheritance(sub->parent, name);
218 }
219
220 if (!he)
221 return NULL;
222
223 char scope[256] = { 0 };
224 snprintf(scope, sizeof(scope), "%s:%s", sub->name, name);
225 return cs_inherit_variable(sub->cs, he, scope);
226}
struct HashElem * cs_inherit_variable(const struct ConfigSet *cs, struct HashElem *he_parent, const char *name)
Create in inherited config item.
Definition: set.c:346
struct HashElem * cs_subset_create_inheritance(const struct ConfigSubset *sub, const char *name)
Create a Subset config item (inherited)
Definition: subset.c:205
struct HashElem * cs_subset_lookup(const struct ConfigSubset *sub, const char *name)
Find an inherited config item.
Definition: subset.c:184
+ 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 184 of file subset.c.

185{
186 if (!sub || !name)
187 return NULL;
188
189 char scope[256] = { 0 };
190 if (sub->name)
191 snprintf(scope, sizeof(scope), "%s:%s", sub->name, name);
192 else
193 mutt_str_copy(scope, name, sizeof(scope));
194
195 return cs_get_elem(sub->cs, scope);
196}
struct HashElem * cs_get_elem(const struct ConfigSet *cs, const char *name)
Get the HashElem representing a config item.
Definition: set.c:172
+ 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 234 of file subset.c.

236{
237 if (!sub || !he)
238 return;
239
240 struct HashElem *he_base = cs_get_base(he);
241 struct EventConfig ev_c = { sub, he_base->key.strkey, he };
242 mutt_debug(LL_NOTIFY, "%s: %s\n",
244 notify_send(sub->notify, NT_CONFIG, ev, &ev_c);
245}
struct HashElem * cs_get_base(struct HashElem *he)
Find the root Config Item.
Definition: set.c:157
const char * mutt_map_get_name(int val, const struct Mapping *map)
Lookup a string for a constant.
Definition: mapping.c:42
#define NONULL(x)
Definition: string2.h:37
struct HashElem * he
Config item that changed.
Definition: subset.h:74
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 255 of file subset.c.

257{
258 if (!sub)
259 return INT_MIN;
260
261 return cs_he_native_get(sub->cs, he, err);
262}
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:834
+ 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 288 of file subset.c.

290{
291 if (!sub)
292 return CSR_ERR_CODE;
293
294 int rc = cs_he_native_set(sub->cs, he, value, err);
295
296 if ((CSR_RESULT(rc) == CSR_SUCCESS) && !(rc & CSR_SUC_NO_CHANGE))
298
299 return rc;
300}
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:729
#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:234
+ 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 325 of file subset.c.

326{
327 if (!sub)
328 return CSR_ERR_CODE;
329
330 int rc = cs_he_reset(sub->cs, he, err);
331
332 if ((CSR_RESULT(rc) == CSR_SUCCESS) && !(rc & CSR_SUC_NO_CHANGE))
334
335 return rc;
336}
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:390
+ 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 359 of file subset.c.

361{
362 if (!sub)
363 return CSR_ERR_CODE;
364
365 return cs_he_string_get(sub->cs, he, result);
366}
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:662
+ 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 467 of file subset.c.

469{
470 if (!sub)
471 return CSR_ERR_CODE;
472
473 int rc = cs_he_string_minus_equals(sub->cs, he, value, err);
474
475 if ((CSR_RESULT(rc) == CSR_SUCCESS) && !(rc & CSR_SUC_NO_CHANGE))
477
478 return rc;
479}
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:985
+ 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 429 of file subset.c.

431{
432 if (!sub)
433 return CSR_ERR_CODE;
434
435 int rc = cs_he_string_plus_equals(sub->cs, he, value, err);
436
437 if ((CSR_RESULT(rc) == CSR_SUCCESS) && !(rc & CSR_SUC_NO_CHANGE))
439
440 return rc;
441}
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:902
+ 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 391 of file subset.c.

393{
394 if (!sub)
395 return CSR_ERR_CODE;
396
397 int rc = cs_he_string_set(sub->cs, he, value, err);
398
399 if ((CSR_RESULT(rc) == CSR_SUCCESS) && !(rc & CSR_SUC_NO_CHANGE))
401
402 return rc;
403}
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:587
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cs_subset_he_delete()

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

Delete config item from a config.

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

Definition at line 504 of file subset.c.

505{
506 if (!sub)
507 return CSR_ERR_CODE;
508
509 const char *name = mutt_str_dup(he->key.strkey);
510 int rc = cs_he_delete(sub->cs, he, err);
511
512 if (CSR_RESULT(rc) == CSR_SUCCESS)
513 {
514 struct EventConfig ev_c = { sub, name, NULL };
515 mutt_debug(LL_NOTIFY, "NT_CONFIG_DELETED: %s\n", name);
517 }
518
519 FREE(&name);
520 return rc;
521}
int cs_he_delete(const struct ConfigSet *cs, struct HashElem *he, struct Buffer *err)
Delete config item from a config set.
Definition: set.c:1067
const char * name
Name of config item that changed.
Definition: subset.h:73
+ 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 272 of file subset.c.

274{
275 struct HashElem *he = cs_subset_create_inheritance(sub, name);
276
277 return cs_subset_he_native_get(sub, he, err);
278}
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:255
+ 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 310 of file subset.c.

312{
313 struct HashElem *he = cs_subset_create_inheritance(sub, name);
314
315 return cs_subset_he_native_set(sub, he, value, err);
316}
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:288
+ 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 345 of file subset.c.

346{
347 struct HashElem *he = cs_subset_create_inheritance(sub, name);
348
349 return cs_subset_he_reset(sub, he, err);
350}
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:325
+ 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 375 of file subset.c.

377{
378 struct HashElem *he = cs_subset_create_inheritance(sub, name);
379
380 return cs_subset_he_string_get(sub, he, result);
381}
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:359
+ 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 489 of file subset.c.

491{
492 struct HashElem *he = cs_subset_create_inheritance(sub, name);
493
494 return cs_subset_he_string_minus_equals(sub, he, value, err);
495}
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:467
+ 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 451 of file subset.c.

453{
454 struct HashElem *he = cs_subset_create_inheritance(sub, name);
455
456 return cs_subset_he_string_plus_equals(sub, he, value, err);
457}
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:429
+ 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 413 of file subset.c.

415{
416 struct HashElem *he = cs_subset_create_inheritance(sub, name);
417
418 return cs_subset_he_string_set(sub, he, value, err);
419}
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:391
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cs_subset_str_delete()

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

Delete config item from a config by string.

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

Definition at line 530 of file subset.c.

531{
532 struct HashElem *he = cs_subset_create_inheritance(sub, name);
533
534 return cs_subset_he_delete(sub, he, err);
535}
int cs_subset_he_delete(const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Delete config item from a config.
Definition: subset.c:504
+ Here is the call 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 60 of file subset.c.

61{
62 if (!a || !b)
63 return 0;
64
65 const struct HashElem *hea = *(struct HashElem const *const *) a;
66 const struct HashElem *heb = *(struct HashElem const *const *) b;
67
68 return mutt_istr_cmp(hea->key.strkey, heb->key.strkey);
69}
int mutt_istr_cmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:484
+ 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 76 of file subset.c.

77{
78 if (!cs)
79 return NULL;
80
81 struct HashElem **he_list = mutt_mem_calloc(1024, sizeof(struct HashElem *));
82 size_t index = 0;
83
84 struct HashWalkState walk = { 0 };
85 struct HashElem *he = NULL;
86
87 while ((he = mutt_hash_walk(cs->hash, &walk)))
88 {
89 he_list[index++] = he;
90 if (index == 1022)
91 break; /* LCOV_EXCL_LINE */
92 }
93
94 qsort(he_list, index, sizeof(struct HashElem *), elem_list_sort);
95
96 return he_list;
97}
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
Hash Table: "$name" -> ConfigDef.
Definition: set.h:253
Cursor to iterate through a Hash Table.
Definition: hash.h:133
int elem_list_sort(const void *a, const void *b)
Sort two HashElem pointers to config.
Definition: subset.c:60
+ Here is the call graph for this function:
+ Here is the caller graph for this function: