NeoMutt  2024-10-02-37-gfa9146
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
config_cache.c File Reference

Cache of config variables. More...

#include "config.h"
#include <stdbool.h>
#include <string.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "config_cache.h"
#include "neomutt.h"
+ Include dependency graph for config_cache.c:

Go to the source code of this file.

Functions

static int cc_config_observer (struct NotifyCallback *nc)
 Notification that a Config Variable has changed - Implements observer_t -.
 
static void cache_setup (void)
 Setup a cache of some config variables.
 
const struct Slistcc_assumed_charset (void)
 Get the cached value of $assumed_charset.
 
const char * cc_charset (void)
 Get the cached value of $charset.
 
const char * cc_maildir_field_delimiter (void)
 Get the cached value of $maildir_field_delimiter.
 
void config_cache_cleanup (void)
 Cleanup the cache of charset config variables.
 

Variables

static bool CacheActive = false
 Is the cache enabled?
 
static const struct SlistCachedAssumedCharset = NULL
 Cached value of $assumed_charset.
 
static const char * CachedCharset = NULL
 Cached value of $charset.
 
static const char * CachedMaildirFieldDelimiter = NULL
 Cached value of $maildir_field_delimiter.
 

Detailed Description

Cache of config variables.

Authors
  • Richard Russon
  • Pietro Cerutti

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

Function Documentation

◆ cache_setup()

static void cache_setup ( void  )
static

Setup a cache of some config variables.

Definition at line 83 of file config_cache.c.

84{
85 if (CacheActive)
86 return; // LCOV_EXCL_LINE
87
89
90 CachedAssumedCharset = cs_subset_slist(NeoMutt->sub, "assumed_charset");
92 CachedMaildirFieldDelimiter = cs_subset_string(NeoMutt->sub, "maildir_field_delimiter");
93
94 CacheActive = true;
95}
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:291
const struct Slist * cs_subset_slist(const struct ConfigSubset *sub, const char *name)
Get a string-list config item by name.
Definition: helpers.c:242
static const char * CachedMaildirFieldDelimiter
Cached value of $maildir_field_delimiter.
Definition: config_cache.c:45
static const struct Slist * CachedAssumedCharset
Cached value of $assumed_charset.
Definition: config_cache.c:41
static const char * CachedCharset
Cached value of $charset.
Definition: config_cache.c:43
static bool CacheActive
Is the cache enabled?
Definition: config_cache.c:39
static int cc_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: config_cache.c:50
bool notify_observer_add(struct Notify *notify, enum NotifyType type, observer_t callback, void *global_data)
Add an observer to an object.
Definition: notify.c:191
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:43
struct Notify * notify
Notifications: NotifyConfig, EventConfig.
Definition: subset.h:52
Container for Accounts, Notifications.
Definition: neomutt.h:42
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cc_assumed_charset()

const struct Slist * cc_assumed_charset ( void  )

Get the cached value of $assumed_charset.

Return values
ptrValue of $assumed_charset

Definition at line 101 of file config_cache.c.

102{
103 if (!CacheActive)
104 {
105 cache_setup();
106 CachedAssumedCharset = cs_subset_slist(NeoMutt->sub, "assumed_charset");
107 }
108
110}
static void cache_setup(void)
Setup a cache of some config variables.
Definition: config_cache.c:83
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cc_charset()

const char * cc_charset ( void  )

Get the cached value of $charset.

Return values
ptrValue of $charset

Definition at line 116 of file config_cache.c.

117{
118 if (!CacheActive)
119 {
120 cache_setup();
122 }
123
124 return CachedCharset;
125}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cc_maildir_field_delimiter()

const char * cc_maildir_field_delimiter ( void  )

Get the cached value of $maildir_field_delimiter.

Return values
ptrValue of $maildir_field_delimiter

Definition at line 131 of file config_cache.c.

132{
133 if (!CacheActive)
134 {
135 cache_setup();
136 CachedMaildirFieldDelimiter = cs_subset_string(NeoMutt->sub, "maildir_field_delimiter");
137 }
138
140}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ config_cache_cleanup()

void config_cache_cleanup ( void  )

Cleanup the cache of charset config variables.

Definition at line 145 of file config_cache.c.

146{
147 if (NeoMutt)
149
150 // Don't free them, the config system owns the data
152 CachedCharset = NULL;
154
155 CacheActive = false;
156}
bool notify_observer_remove(struct Notify *notify, const observer_t callback, const void *global_data)
Remove an observer from an object.
Definition: notify.c:230
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ CacheActive

bool CacheActive = false
static

Is the cache enabled?

Definition at line 39 of file config_cache.c.

◆ CachedAssumedCharset

const struct Slist* CachedAssumedCharset = NULL
static

Cached value of $assumed_charset.

Definition at line 41 of file config_cache.c.

◆ CachedCharset

const char* CachedCharset = NULL
static

Cached value of $charset.

Definition at line 43 of file config_cache.c.

◆ CachedMaildirFieldDelimiter

const char* CachedMaildirFieldDelimiter = NULL
static

Cached value of $maildir_field_delimiter.

Definition at line 45 of file config_cache.c.