NeoMutt  2021-02-05
Teaching an old dog new tricks
DOXYGEN
config.c File Reference

Config used by libhcache. More...

#include "config.h"
#include <stddef.h>
#include <stdbool.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "lib.h"
#include "compress/lib.h"
#include "store/lib.h"
#include "init.h"
+ Include dependency graph for config.c:

Go to the source code of this file.

Functions

int hcache_validator (const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
 Validate the "header_cache_backend" config variable - Implements ConfigDef::validator() More...
 
int compress_method_validator (const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
 Validate the "header_cache_compress_method" config variable - Implements ConfigDef::validator() More...
 
int compress_level_validator (const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
 Validate the "header_cache_compress_level" config variable - Implements ConfigDef::validator() More...
 
bool config_init_hcache (struct ConfigSet *cs)
 Register hcache config variables - Implements module_init_config_t. More...
 

Variables

char * C_HeaderCache
 Config: (hcache) Directory/file for the header cache database. More...
 
char * C_HeaderCacheBackend
 Config: (hcache) Header cache backend to use. More...
 
short C_HeaderCacheCompressLevel
 Config: (hcache) Level of compression for method. More...
 
char * C_HeaderCacheCompressMethod
 Config: (hcache) Enable generic hcache database compression. More...
 
bool C_HeaderCacheCompress = false
 
long C_HeaderCachePagesize = 0
 
struct ConfigDef HcacheVars []
 

Detailed Description

Config used by libhcache.

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

Function Documentation

◆ hcache_validator()

int hcache_validator ( const struct ConfigSet cs,
const struct ConfigDef cdef,
intptr_t  value,
struct Buffer err 
)

Validate the "header_cache_backend" config variable - Implements ConfigDef::validator()

Definition at line 56 of file config.c.

58 {
59  if (value == 0)
60  return CSR_SUCCESS;
61 
62  const char *str = (const char *) value;
63 
64  if (store_is_valid_backend(str))
65  return CSR_SUCCESS;
66 
67  mutt_buffer_printf(err, _("Invalid value for option %s: %s"), cdef->name, str);
68  return CSR_ERR_INVALID;
69 }
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:35
#define CSR_ERR_INVALID
Value hasn&#39;t been set.
Definition: set.h:38
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
const char * name
User-visible name.
Definition: set.h:63
bool store_is_valid_backend(const char *str)
Is the string a valid Store backend.
Definition: store.c:129
+ Here is the call graph for this function:

◆ compress_method_validator()

int compress_method_validator ( const struct ConfigSet cs,
const struct ConfigDef cdef,
intptr_t  value,
struct Buffer err 
)

Validate the "header_cache_compress_method" config variable - Implements ConfigDef::validator()

Definition at line 75 of file config.c.

77 {
78  if (value == 0)
79  return CSR_SUCCESS;
80 
81  const char *str = (const char *) value;
82 
83  if (compress_get_ops(str))
84  return CSR_SUCCESS;
85 
86  mutt_buffer_printf(err, _("Invalid value for option %s: %s"), cdef->name, str);
87  return CSR_ERR_INVALID;
88 }
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:35
#define CSR_ERR_INVALID
Value hasn&#39;t been set.
Definition: set.h:38
const struct ComprOps * compress_get_ops(const char *compr)
Get the API functions for a compress backend.
Definition: compress.c:81
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
const char * name
User-visible name.
Definition: set.h:63
+ Here is the call graph for this function:

◆ compress_level_validator()

int compress_level_validator ( const struct ConfigSet cs,
const struct ConfigDef cdef,
intptr_t  value,
struct Buffer err 
)

Validate the "header_cache_compress_level" config variable - Implements ConfigDef::validator()

Definition at line 93 of file config.c.

95 {
97  {
98  mutt_buffer_printf(err, _("Set option %s before setting %s"),
99  "header_cache_compress_method", cdef->name);
100  return CSR_ERR_INVALID;
101  }
102 
104  if (!cops)
105  {
106  mutt_buffer_printf(err, _("Invalid value for option %s: %s"),
107  "header_cache_compress_method", C_HeaderCacheCompressMethod);
108  return CSR_ERR_INVALID;
109  }
110 
111  if ((value < cops->min_level) || (value > cops->max_level))
112  {
113  // L10N: This applies to the "$header_cache_compress_level" config variable.
114  // It shows the minimum and maximum values, e.g. 'between 1 and 22'
115  mutt_buffer_printf(err, _("Option %s must be between %d and %d inclusive"),
116  cdef->name, cops->min_level, cops->max_level);
117  return CSR_ERR_INVALID;
118  }
119 
120  return CSR_SUCCESS;
121 }
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:35
char * C_HeaderCacheCompressMethod
Config: (hcache) Enable generic hcache database compression.
Definition: config.c:44
#define CSR_ERR_INVALID
Value hasn&#39;t been set.
Definition: set.h:38
const struct ComprOps * compress_get_ops(const char *compr)
Get the API functions for a compress backend.
Definition: compress.c:81
short max_level
Maximum compression level.
Definition: lib.h:59
#define _(a)
Definition: message.h:28
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
const char * name
User-visible name.
Definition: set.h:63
Header Cache Compression API.
Definition: lib.h:55
short min_level
Minimum compression level.
Definition: lib.h:58
+ Here is the call graph for this function:

◆ config_init_hcache()

bool config_init_hcache ( struct ConfigSet cs)

Register hcache config variables - Implements module_init_config_t.

Definition at line 153 of file config.c.

154 {
155  return cs_register_variables(cs, HcacheVars, 0);
156 }
bool cs_register_variables(const struct ConfigSet *cs, struct ConfigDef vars[], uint32_t flags)
Register a set of config items.
Definition: set.c:286
struct ConfigDef HcacheVars[]
Definition: config.c:124
+ Here is the call graph for this function:

Variable Documentation

◆ C_HeaderCache

char* C_HeaderCache

Config: (hcache) Directory/file for the header cache database.

Definition at line 40 of file config.c.

◆ C_HeaderCacheBackend

char* C_HeaderCacheBackend

Config: (hcache) Header cache backend to use.

Definition at line 41 of file config.c.

◆ C_HeaderCacheCompressLevel

short C_HeaderCacheCompressLevel

Config: (hcache) Level of compression for method.

Definition at line 43 of file config.c.

◆ C_HeaderCacheCompressMethod

char* C_HeaderCacheCompressMethod

Config: (hcache) Enable generic hcache database compression.

Definition at line 44 of file config.c.

◆ C_HeaderCacheCompress

bool C_HeaderCacheCompress = false

Definition at line 48 of file config.c.

◆ C_HeaderCachePagesize

long C_HeaderCachePagesize = 0

Definition at line 50 of file config.c.

◆ HcacheVars

struct ConfigDef HcacheVars[]
Initial value:
= {
{ "header_cache", DT_PATH, &C_HeaderCache, 0, 0, NULL,
"(hcache) Directory/file for the header cache database"
},
{ "header_cache_backend", DT_STRING, &C_HeaderCacheBackend, 0, 0, hcache_validator,
"(hcache) Header cache backend to use"
},
"(hcache) Level of compression for method"
},
{ "header_cache_compress_method", DT_STRING, &C_HeaderCacheCompressMethod, 0, 0, compress_method_validator,
"(hcache) Enable generic hcache database compression"
},
{ "header_cache_compress", DT_DEPRECATED|DT_BOOL, &C_HeaderCacheCompress, false, 0, NULL, NULL },
{ "header_cache_pagesize", DT_DEPRECATED|DT_LONG, &C_HeaderCachePagesize, 0, 0, NULL, NULL },
{ NULL, 0, NULL, 0, 0, NULL, NULL },
}
char * C_HeaderCacheCompressMethod
Config: (hcache) Enable generic hcache database compression.
Definition: config.c:44
#define DT_LONG
a number (long)
Definition: types.h:33
int compress_level_validator(const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
Validate the "header_cache_compress_level" config variable - Implements ConfigDef::validator() ...
Definition: config.c:93
char * C_HeaderCache
Config: (hcache) Directory/file for the header cache database.
Definition: config.c:40
int compress_method_validator(const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
Validate the "header_cache_compress_method" config variable - Implements ConfigDef::validator() ...
Definition: config.c:75
long C_HeaderCachePagesize
Definition: config.c:50
bool C_HeaderCacheCompress
Definition: config.c:48
#define DT_NOT_NEGATIVE
Negative numbers are not allowed.
Definition: types.h:47
short C_HeaderCacheCompressLevel
Config: (hcache) Level of compression for method.
Definition: config.c:43
#define DT_STRING
a string
Definition: types.h:41
#define DT_PATH
a path to a file/directory
Definition: types.h:36
#define DT_DEPRECATED
Config item shouldn&#39;t be used any more.
Definition: types.h:79
int hcache_validator(const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
Validate the "header_cache_backend" config variable - Implements ConfigDef::validator() ...
Definition: config.c:56
char * C_HeaderCacheBackend
Config: (hcache) Header cache backend to use.
Definition: config.c:41
#define DT_NUMBER
a number
Definition: types.h:35
#define DT_BOOL
boolean option
Definition: types.h:30

Definition at line 124 of file config.c.