mdbox-settings.c revision 7744586e3e0fd60158abfbb03a233d3bd8d6c48b
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen/* Copyright (c) 2006-2009 Dovecot authors, see the included COPYING file */
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#include "lib.h"
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#include "settings-parser.h"
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#include "mail-storage-settings.h"
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#include "mdbox-settings.h"
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#include <stddef.h>
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#undef DEF
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#define DEF(type, name) \
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen { type, #name, offsetof(struct mdbox_settings, name), NULL }
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstatic bool mdbox_settings_verify(void *_set, pool_t pool ATTR_UNUSED,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen const char **error_r);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
7744586e3e0fd60158abfbb03a233d3bd8d6c48bTimo Sirainenstatic const struct setting_define mdbox_setting_defines[] = {
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen DEF(SET_UINT, mdbox_rotate_size),
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen DEF(SET_UINT, mdbox_rotate_min_size),
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen DEF(SET_UINT, mdbox_rotate_days),
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen DEF(SET_UINT, mdbox_max_open_files),
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen DEF(SET_UINT, mdbox_purge_min_percentage),
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen SETTING_DEFINE_LIST_END
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen};
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
7744586e3e0fd60158abfbb03a233d3bd8d6c48bTimo Sirainenstatic const struct mdbox_settings mdbox_default_settings = {
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen MEMBER(mdbox_rotate_size) 2048*1024,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen MEMBER(mdbox_rotate_min_size) 16*1024,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen MEMBER(mdbox_rotate_days) 0,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen MEMBER(mdbox_max_open_files) 64,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen MEMBER(mdbox_purge_min_percentage) 0
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen};
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
7744586e3e0fd60158abfbb03a233d3bd8d6c48bTimo Sirainenstatic const struct setting_parser_info mdbox_setting_parser_info = {
1cfdcb36985904eff281fc6d7ea2d13b3c375980Timo Sirainen MEMBER(module_name) "mdbox",
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen MEMBER(defines) mdbox_setting_defines,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen MEMBER(defaults) &mdbox_default_settings,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen MEMBER(type_offset) (size_t)-1,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen MEMBER(struct_size) sizeof(struct mdbox_settings),
383d0e8c24451468d6bea17e4b55d74de744abe6Timo Sirainen
383d0e8c24451468d6bea17e4b55d74de744abe6Timo Sirainen MEMBER(parent_offset) (size_t)-1,
383d0e8c24451468d6bea17e4b55d74de744abe6Timo Sirainen MEMBER(parent) &mail_user_setting_parser_info,
383d0e8c24451468d6bea17e4b55d74de744abe6Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen MEMBER(check_func) mdbox_settings_verify
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen};
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen/* <settings checks> */
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstatic bool mdbox_settings_verify(void *_set, pool_t pool ATTR_UNUSED,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen const char **error_r)
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen{
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen const struct mdbox_settings *set = _set;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen if (set->mdbox_max_open_files < 2) {
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen *error_r = "mdbox_max_open_files must be at least 2";
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen return FALSE;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen }
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen return TRUE;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen}
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen/* </settings checks> */
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenconst struct setting_parser_info *mdbox_get_setting_parser_info(void)
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen{
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen return &mdbox_setting_parser_info;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen}