NeoMutt  2024-11-14-34-g5aaf0d
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
config.c
Go to the documentation of this file.
1
30#include "config.h"
31#include <ctype.h>
32#include <stdbool.h>
33#include <stddef.h>
34#include <stdint.h>
35#include <string.h>
36#include "mutt/lib.h"
37#include "config/lib.h"
38
44static int maildir_field_delimiter_validator(const struct ConfigSet *cs,
45 const struct ConfigDef *cdef,
46 intptr_t value, struct Buffer *err)
47{
48 const char *delim = (const char *) value;
49
50 if (strlen(delim) != 1)
51 {
52 // L10N: maildir_field_delimiter is a config variable and shouldn't be translated
53 buf_printf(err, _("maildir_field_delimiter must be exactly one character long"));
54 return CSR_ERR_INVALID;
55 }
56
57 if (isalnum(*delim) || strchr("-.\\/", *delim))
58 {
59 // L10N: maildir_field_delimiter is a config variable and shouldn't be translated
60 buf_printf(err, _("maildir_field_delimiter cannot be alphanumeric or '-.\\/'"));
61 return CSR_ERR_INVALID;
62 }
63
64 return CSR_SUCCESS;
65}
66
70static struct ConfigDef MaildirVars[] = {
71 // clang-format off
72 { "check_new", DT_BOOL, true, 0, NULL,
73 "(maildir,mh) Check for new mail while the mailbox is open"
74 },
75 { "maildir_check_cur", DT_BOOL, false, 0, NULL,
76 "Check both 'new' and 'cur' directories for new mail"
77 },
78 { "maildir_field_delimiter", DT_STRING|D_NOT_EMPTY|D_ON_STARTUP, IP ":", 0, maildir_field_delimiter_validator,
79 "Field delimiter to be used for maildir email files (default is colon, recommended alternative is semi-colon)"
80 },
81 { "maildir_trash", DT_BOOL, false, 0, NULL,
82 "Use the maildir 'trashed' flag, rather than deleting"
83 },
84 { NULL },
85 // clang-format on
86};
87
88#if defined(USE_HCACHE)
92static struct ConfigDef MaildirVarsHcache[] = {
93 // clang-format off
94 { "maildir_header_cache_verify", DT_BOOL, true, 0, NULL,
95 "Check for maildir changes when opening mailbox"
96 },
97 { NULL },
98 // clang-format on
99};
100#endif
101
106{
107 bool rc = cs_register_variables(cs, MaildirVars);
108
109#if defined(USE_HCACHE)
111#endif
112
113 return rc;
114}
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:161
Convenience wrapper for the config headers.
bool cs_register_variables(const struct ConfigSet *cs, struct ConfigDef vars[])
Register a set of config items.
Definition: set.c:281
#define CSR_ERR_INVALID
Value hasn't been set.
Definition: set.h:38
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:35
#define IP
Definition: set.h:54
static int maildir_field_delimiter_validator(const struct ConfigSet *cs, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
Validate the "maildir_field_delimiter" config variable - Implements ConfigDef::validator() -.
Definition: config.c:44
bool config_init_maildir(struct ConfigSet *cs)
Register maildir config variables - Implements module_init_config_t -.
Definition: config.c:105
static struct ConfigDef MaildirVars[]
Config definitions for the Maildir library.
Definition: config.c:70
static struct ConfigDef MaildirVarsHcache[]
Config definitions for the Maildir header cache.
Definition: config.c:92
Convenience wrapper for the library headers.
#define _(a)
Definition: message.h:28
String manipulation buffer.
Definition: buffer.h:36
Definition: set.h:64
Container for lots of config items.
Definition: set.h:252
@ DT_BOOL
boolean option
Definition: types.h:32
@ DT_STRING
a string
Definition: types.h:45
#define D_NOT_EMPTY
Empty strings are not allowed.
Definition: types.h:80
#define D_ON_STARTUP
May only be set at startup.
Definition: types.h:79