NeoMutt  2023-11-03-85-g512e01
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
subset.c File Reference

Subset of config items. More...

#include "config.h"
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include "mutt/lib.h"
#include "subset.h"
#include "set.h"
+ Include dependency graph for subset.c:

Go to the source code of this file.

Functions

int elem_list_sort (const void *a, const void *b, void *sdata)
 Compare two HashElem pointers to config - Implements sort_t -.
 
struct HashElem ** get_elem_list (struct ConfigSet *cs)
 Create a sorted list of all config items.
 
void cs_subset_free (struct ConfigSubset **ptr)
 Free a Config Subset.
 
struct ConfigSubsetcs_subset_new (const char *name, struct ConfigSubset *sub_parent, struct Notify *not_parent)
 Create a new Config Subset.
 
struct HashElemcs_subset_lookup (const struct ConfigSubset *sub, const char *name)
 Find an inherited config item.
 
struct HashElemcs_subset_create_inheritance (const struct ConfigSubset *sub, const char *name)
 Create a Subset config item (inherited)
 
void cs_subset_notify_observers (const struct ConfigSubset *sub, struct HashElem *he, enum NotifyConfig ev)
 Notify all observers of an event.
 
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.
 
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.
 
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.
 
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.
 
int cs_subset_he_reset (const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
 Reset a config item to its initial value.
 
int cs_subset_str_reset (const struct ConfigSubset *sub, const char *name, struct Buffer *err)
 Reset a config item to its initial value.
 
int cs_subset_he_string_get (const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *result)
 Get a config item as a string.
 
int cs_subset_str_string_get (const struct ConfigSubset *sub, const char *name, struct Buffer *result)
 Get a config item as a string.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
int cs_subset_he_delete (const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
 Delete config item from a config.
 
int cs_subset_str_delete (const struct ConfigSubset *sub, const char *name, struct Buffer *err)
 Delete config item from a config by string.
 

Variables

static const struct Mapping ConfigEventNames []
 Names for logging.
 

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.c.

Function Documentation

◆ 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 70 of file subset.c.

71{
72 if (!cs)
73 return NULL;
74
75 struct HashElem **he_list = mutt_mem_calloc(1024, sizeof(struct HashElem *));
76 size_t index = 0;
77
78 struct HashWalkState walk = { 0 };
79 struct HashElem *he = NULL;
80
81 while ((he = mutt_hash_walk(cs->hash, &walk)))
82 {
83 he_list[index++] = he;
84 if (index == 1022)
85 break; /* LCOV_EXCL_LINE */
86 }
87
88 mutt_qsort_r(he_list, index, sizeof(struct HashElem *), elem_list_sort, NULL);
89
90 return he_list;
91}
int elem_list_sort(const void *a, const void *b, void *sdata)
Compare two HashElem pointers to config - Implements sort_t -.
Definition: subset.c:54
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
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
void mutt_qsort_r(void *base, size_t nmemb, size_t size, sort_t compar, void *sdata)
Sort an array, where the comparator has access to opaque data rather than requiring global variables.
Definition: qsort_r.c:66
struct HashTable * hash
Hash Table: "$name" -> ConfigDef.
Definition: set.h:253
The item stored in a Hash Table.
Definition: hash.h:44
Cursor to iterate through a Hash Table.
Definition: hash.h:133
+ 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 99 of file subset.c.

100{
101 if (!ptr || !*ptr)
102 return;
103
104 struct ConfigSubset *sub = *ptr;
105
106 struct EventConfig ev_c = { sub, NULL, NULL };
107 mutt_debug(LL_NOTIFY, "NT_CONFIG_DELETED: ALL\n");
109
110 if (sub->cs && sub->name)
111 {
112 char scope[256] = { 0 };
113 snprintf(scope, sizeof(scope), "%s:", sub->name);
114
115 // We don't know if any config items have been set,
116 // so search for anything with a matching scope.
117 struct HashElem **he_list = get_elem_list(sub->cs);
118 for (size_t i = 0; he_list[i]; i++)
119 {
120 const char *item = he_list[i]->key.strkey;
121 if (mutt_str_startswith(item, scope) != 0)
122 {
123 cs_uninherit_variable(sub->cs, item);
124 }
125 }
126 FREE(&he_list);
127 }
128
129 notify_free(&sub->notify);
130 FREE(&sub->name);
131 FREE(ptr);
132}
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:89
@ LL_NOTIFY
Log of notifications.
Definition: logging2.h:48
#define FREE(x)
Definition: memory.h:45
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition: notify.c:173
void notify_free(struct Notify **ptr)
Free a notification handler.
Definition: notify.c:75
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 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
A config-change event.
Definition: subset.h:71
const struct ConfigSubset * sub
Config Subset.
Definition: subset.h:72
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:70
@ NT_CONFIG_DELETED
Config item has been deleted.
Definition: subset.h:64
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_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 143 of file subset.c.

145{
146 struct ConfigSubset *sub = mutt_mem_calloc(1, sizeof(*sub));
147
148 if (sub_parent)
149 {
150 sub->parent = sub_parent;
151 sub->cs = sub_parent->cs;
152 }
153
154 if (name)
155 {
156 char scope[256] = { 0 };
157
158 if (sub_parent && sub_parent->name)
159 snprintf(scope, sizeof(scope), "%s:%s", sub_parent->name, name);
160 else
161 mutt_str_copy(scope, name, sizeof(scope));
162
163 sub->name = mutt_str_dup(scope);
164 }
165
166 sub->notify = notify_new();
167 notify_set_parent(sub->notify, not_parent);
168
169 return sub;
170}
struct Notify * notify_new(void)
Create a new notifications handler.
Definition: notify.c:62
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition: notify.c:95
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
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_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 178 of file subset.c.

179{
180 if (!sub || !name)
181 return NULL;
182
183 char scope[256] = { 0 };
184 if (sub->name)
185 snprintf(scope, sizeof(scope), "%s:%s", sub->name, name);
186 else
187 mutt_str_copy(scope, name, sizeof(scope));
188
189 return cs_get_elem(sub->cs, scope);
190}
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_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 199 of file subset.c.

200{
201 if (!sub)
202 return NULL;
203
204 struct HashElem *he = cs_subset_lookup(sub, name);
205 if (he)
206 return he;
207
208 if (sub->parent)
209 {
210 // Create parent before creating name
211 he = cs_subset_create_inheritance(sub->parent, name);
212 }
213
214 if (!he)
215 return NULL;
216
217 char scope[256] = { 0 };
218 snprintf(scope, sizeof(scope), "%s:%s", sub->name, name);
219 return cs_inherit_variable(sub->cs, he, scope);
220}
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:199
struct HashElem * cs_subset_lookup(const struct ConfigSubset *sub, const char *name)
Find an inherited config item.
Definition: subset.c:178
+ 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 228 of file subset.c.

230{
231 if (!sub || !he)
232 return;
233
234 struct HashElem *he_base = cs_get_base(he);
235 struct EventConfig ev_c = { sub, he_base->key.strkey, he };
236 mutt_debug(LL_NOTIFY, "%s: %s\n",
238 notify_send(sub->notify, NT_CONFIG, ev, &ev_c);
239}
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:42
+ 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 249 of file subset.c.

251{
252 if (!sub)
253 return INT_MIN;
254
255 return cs_he_native_get(sub->cs, he, err);
256}
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_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 266 of file subset.c.

268{
269 struct HashElem *he = cs_subset_create_inheritance(sub, name);
270
271 return cs_subset_he_native_get(sub, he, err);
272}
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:249
+ Here is the call 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 282 of file subset.c.

284{
285 if (!sub)
286 return CSR_ERR_CODE;
287
288 int rc = cs_he_native_set(sub->cs, he, value, err);
289
290 if ((CSR_RESULT(rc) == CSR_SUCCESS) && !(rc & CSR_SUC_NO_CHANGE))
292
293 return rc;
294}
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:228
@ NT_CONFIG_SET
Config item has been set.
Definition: subset.h:62
+ Here is the call graph for this function:
+ Here is the caller 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 304 of file subset.c.

306{
307 struct HashElem *he = cs_subset_create_inheritance(sub, name);
308
309 return cs_subset_he_native_set(sub, he, value, err);
310}
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:282
+ 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 319 of file subset.c.

320{
321 if (!sub)
322 return CSR_ERR_CODE;
323
324 int rc = cs_he_reset(sub->cs, he, err);
325
326 if ((CSR_RESULT(rc) == CSR_SUCCESS) && !(rc & CSR_SUC_NO_CHANGE))
328
329 return rc;
330}
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
@ NT_CONFIG_RESET
Config item has been reset to initial, or parent, value.
Definition: subset.h:63
+ 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 339 of file subset.c.

340{
341 struct HashElem *he = cs_subset_create_inheritance(sub, name);
342
343 return cs_subset_he_reset(sub, he, err);
344}
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:319
+ Here is the call 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 353 of file subset.c.

355{
356 if (!sub)
357 return CSR_ERR_CODE;
358
359 return cs_he_string_get(sub->cs, he, result);
360}
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_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 369 of file subset.c.

371{
372 struct HashElem *he = cs_subset_create_inheritance(sub, name);
373
374 return cs_subset_he_string_get(sub, he, result);
375}
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:353
+ 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 385 of file subset.c.

387{
388 if (!sub)
389 return CSR_ERR_CODE;
390
391 int rc = cs_he_string_set(sub->cs, he, value, err);
392
393 if ((CSR_RESULT(rc) == CSR_SUCCESS) && !(rc & CSR_SUC_NO_CHANGE))
395
396 return rc;
397}
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_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 407 of file subset.c.

409{
410 struct HashElem *he = cs_subset_create_inheritance(sub, name);
411
412 return cs_subset_he_string_set(sub, he, value, err);
413}
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:385
+ 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 423 of file subset.c.

425{
426 if (!sub)
427 return CSR_ERR_CODE;
428
429 int rc = cs_he_string_plus_equals(sub->cs, he, value, err);
430
431 if ((CSR_RESULT(rc) == CSR_SUCCESS) && !(rc & CSR_SUC_NO_CHANGE))
433
434 return rc;
435}
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_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 445 of file subset.c.

447{
448 struct HashElem *he = cs_subset_create_inheritance(sub, name);
449
450 return cs_subset_he_string_plus_equals(sub, he, value, err);
451}
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:423
+ Here is the call 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 461 of file subset.c.

463{
464 if (!sub)
465 return CSR_ERR_CODE;
466
467 int rc = cs_he_string_minus_equals(sub->cs, he, value, err);
468
469 if ((CSR_RESULT(rc) == CSR_SUCCESS) && !(rc & CSR_SUC_NO_CHANGE))
471
472 return rc;
473}
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_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 483 of file subset.c.

485{
486 struct HashElem *he = cs_subset_create_inheritance(sub, name);
487
488 return cs_subset_he_string_minus_equals(sub, he, value, err);
489}
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:461
+ Here is the call 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 498 of file subset.c.

499{
500 if (!sub)
501 return CSR_ERR_CODE;
502
503 const char *name = mutt_str_dup(he->key.strkey);
504 int rc = cs_he_delete(sub->cs, he, err);
505
506 if (CSR_RESULT(rc) == CSR_SUCCESS)
507 {
508 struct EventConfig ev_c = { sub, name, NULL };
509 mutt_debug(LL_NOTIFY, "NT_CONFIG_DELETED: %s\n", name);
511 }
512
513 FREE(&name);
514 return rc;
515}
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_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 524 of file subset.c.

525{
526 struct HashElem *he = cs_subset_create_inheritance(sub, name);
527
528 return cs_subset_he_delete(sub, he, err);
529}
int cs_subset_he_delete(const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Delete config item from a config.
Definition: subset.c:498
+ Here is the call graph for this function:

Variable Documentation

◆ ConfigEventNames

const struct Mapping ConfigEventNames[]
static
Initial value:
= {
{ "NT_CONFIG_SET", NT_CONFIG_SET },
{ "NT_CONFIG_RESET", NT_CONFIG_RESET },
{ "NT_CONFIG_DELETED", NT_CONFIG_DELETED },
{ NULL, 0 },
}

Names for logging.

Definition at line 42 of file subset.c.