1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/* Copyright (c) 2011-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "settings-parser.h"
#include "mail-storage-settings.h"
#include "pop3c-settings.h"
#include <stddef.h>
#undef DEF
#define DEF(type, name) \
SETTING_DEFINE_STRUCT_##type(#name, name, struct pop3c_settings)
static const struct setting_define pop3c_setting_defines[] = {
DEF(STR, pop3c_host),
DEF(IN_PORT, pop3c_port),
DEF(STR_VARS, pop3c_user),
DEF(STR_VARS, pop3c_master_user),
DEF(STR, pop3c_password),
DEF(ENUM, pop3c_ssl),
DEF(BOOL, pop3c_ssl_verify),
DEF(STR, pop3c_rawlog_dir),
DEF(BOOL, pop3c_quick_received_date),
DEF(STR, pop3c_features),
SETTING_DEFINE_LIST_END
};
static const struct pop3c_settings pop3c_default_settings = {
.pop3c_host = "",
.pop3c_port = 110,
.pop3c_user = "%u",
.pop3c_master_user = "",
.pop3c_password = "",
.pop3c_ssl = "no:pop3s:starttls",
.pop3c_ssl_verify = TRUE,
.pop3c_rawlog_dir = "",
.pop3c_quick_received_date = FALSE,
.pop3c_features = ""
};
/* <settings checks> */
struct pop3c_feature_list {
const char *name;
enum pop3c_features num;
};
static const struct pop3c_feature_list pop3c_feature_list[] = {
{ "no-pipelining", POP3C_FEATURE_NO_PIPELINING },
{ NULL, 0 }
};
static int
pop3c_settings_parse_features(struct pop3c_settings *set,
const char **error_r)
{
enum pop3c_features features = 0;
const struct pop3c_feature_list *list;
const char *const *str;
str = t_strsplit_spaces(set->pop3c_features, " ,");
for (; *str != NULL; str++) {
list = pop3c_feature_list;
for (; list->name != NULL; list++) {
if (strcasecmp(*str, list->name) == 0) {
features |= list->num;
break;
}
}
if (list->name == NULL) {
*error_r = t_strdup_printf("pop3c_features: "
"Unknown feature: %s", *str);
return -1;
}
}
set->parsed_features = features;
return 0;
}
static bool pop3c_settings_check(void *_set, pool_t pool ATTR_UNUSED,
const char **error_r)
{
struct pop3c_settings *set = _set;
if (pop3c_settings_parse_features(set, error_r) < 0)
return FALSE;
return TRUE;
}
/* </settings checks> */
static const struct setting_parser_info pop3c_setting_parser_info = {
.module_name = "pop3c",
.defines = pop3c_setting_defines,
.defaults = &pop3c_default_settings,
.type_offset = SIZE_MAX,
.struct_size = sizeof(struct pop3c_settings),
.parent_offset = SIZE_MAX,
.parent = &mail_user_setting_parser_info,
.check_func = pop3c_settings_check
};
const struct setting_parser_info *pop3c_get_setting_parser_info(void)
{
return &pop3c_setting_parser_info;
}
|