NeoMutt  2023-11-03-85-g512e01
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

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 82 of file config_cache.c.

83{
84 if (CacheActive)
85 return; // LCOV_EXCL_LINE
86
88
89 CachedAssumedCharset = cs_subset_slist(NeoMutt->sub, "assumed_charset");
91 CachedMaildirFieldDelimiter = cs_subset_string(NeoMutt->sub, "maildir_field_delimiter");
92
93 CacheActive = true;
94}
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:292
const struct Slist * cs_subset_slist(const struct ConfigSubset *sub, const char *name)
Get a string-list config item by name.
Definition: helpers.c:243
static const char * CachedMaildirFieldDelimiter
Cached value of $maildir_field_delimiter.
Definition: config_cache.c:44
static const struct Slist * CachedAssumedCharset
Cached value of $assumed_charset.
Definition: config_cache.c:40
static const char * CachedCharset
Cached value of $charset.
Definition: config_cache.c:42
static bool CacheActive
Is the cache enabled?
Definition: config_cache.c:38
static int cc_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: config_cache.c:49
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:41
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:45
+ 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 100 of file config_cache.c.

101{
102 if (!CacheActive)
103 {
104 cache_setup();
105 CachedAssumedCharset = cs_subset_slist(NeoMutt->sub, "assumed_charset");
106 }
107
109}
static void cache_setup(void)
Setup a cache of some config variables.
Definition: config_cache.c:82
+ 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 115 of file config_cache.c.

116{
117 if (!CacheActive)
118 {
119 cache_setup();
121 }
122
123 return CachedCharset;
124}
+ 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 130 of file config_cache.c.

131{
132 if (!CacheActive)
133 {
134 cache_setup();
135 CachedMaildirFieldDelimiter = cs_subset_string(NeoMutt->sub, "maildir_field_delimiter");
136 }
137
139}
+ 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 144 of file config_cache.c.

145{
146 if (NeoMutt)
148
149 // Don't free them, the config system owns the data
151 CachedCharset = NULL;
153
154 CacheActive = false;
155}
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 38 of file config_cache.c.

◆ CachedAssumedCharset

const struct Slist* CachedAssumedCharset = NULL
static

Cached value of $assumed_charset.

Definition at line 40 of file config_cache.c.

◆ CachedCharset

const char* CachedCharset = NULL
static

Cached value of $charset.

Definition at line 42 of file config_cache.c.

◆ CachedMaildirFieldDelimiter

const char* CachedMaildirFieldDelimiter = NULL
static

Cached value of $maildir_field_delimiter.

Definition at line 44 of file config_cache.c.