Mercurial > dovecot > original-hg > dovecot-1.2
changeset 3971:539a58176e7b HEAD
Moved mailbox flag and lock method parsing to lib-storage.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 02 Feb 2006 22:20:30 +0200 |
parents | 23e76fc59a35 |
children | a506ee4ec31e |
files | src/imap/namespace.c src/lib-storage/mail-storage.c src/lib-storage/mail-storage.h src/pop3/main.c |
diffstat | 4 files changed, 38 insertions(+), 52 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/namespace.c Thu Feb 02 21:37:59 2006 +0200 +++ b/src/imap/namespace.c Thu Feb 02 22:20:30 2006 +0200 @@ -87,33 +87,10 @@ struct namespace *namespaces, *ns, **ns_p; enum mail_storage_flags flags; enum mail_storage_lock_method lock_method; - const char *str, *mail, *data; + const char *mail, *data; unsigned int i; - flags = 0; - if (getenv("FULL_FILESYSTEM_ACCESS") != NULL) - flags |= MAIL_STORAGE_FLAG_FULL_FS_ACCESS; - if (getenv("DEBUG") != NULL) - flags |= MAIL_STORAGE_FLAG_DEBUG; - if (getenv("MMAP_DISABLE") != NULL) - flags |= MAIL_STORAGE_FLAG_MMAP_DISABLE; - if (getenv("MMAP_NO_WRITE") != NULL) - flags |= MAIL_STORAGE_FLAG_MMAP_NO_WRITE; - if (getenv("MAIL_READ_MMAPED") != NULL) - flags |= MAIL_STORAGE_FLAG_MMAP_MAILS; - if (getenv("MAIL_SAVE_CRLF") != NULL) - flags |= MAIL_STORAGE_FLAG_SAVE_CRLF; - - str = getenv("LOCK_METHOD"); - if (str == NULL || strcmp(str, "flock") == 0) - lock_method = MAIL_STORAGE_LOCK_FLOCK; - else if (strcmp(str, "fcntl") == 0) - lock_method = MAIL_STORAGE_LOCK_FCNTL; - else if (strcmp(str, "dotlock") == 0) - lock_method = MAIL_STORAGE_LOCK_DOTLOCK; - else - i_fatal("Unknown lock_method: %s", str); - + mail_storage_parse_env(&flags, &lock_method); namespaces = NULL; ns_p = &namespaces; /* first try NAMESPACE_* environments */
--- a/src/lib-storage/mail-storage.c Thu Feb 02 21:37:59 2006 +0200 +++ b/src/lib-storage/mail-storage.c Thu Feb 02 22:20:30 2006 +0200 @@ -49,6 +49,36 @@ } } +void mail_storage_parse_env(enum mail_storage_flags *flags_r, + enum mail_storage_lock_method *lock_method_r) +{ + const char *str; + + *flags_r = 0; + if (getenv("FULL_FILESYSTEM_ACCESS") != NULL) + *flags_r |= MAIL_STORAGE_FLAG_FULL_FS_ACCESS; + if (getenv("DEBUG") != NULL) + *flags_r |= MAIL_STORAGE_FLAG_DEBUG; + if (getenv("MMAP_DISABLE") != NULL) + *flags_r |= MAIL_STORAGE_FLAG_MMAP_DISABLE; + if (getenv("MMAP_NO_WRITE") != NULL) + *flags_r |= MAIL_STORAGE_FLAG_MMAP_NO_WRITE; + if (getenv("MAIL_READ_MMAPED") != NULL) + *flags_r |= MAIL_STORAGE_FLAG_MMAP_MAILS; + if (getenv("MAIL_SAVE_CRLF") != NULL) + *flags_r |= MAIL_STORAGE_FLAG_SAVE_CRLF; + + str = getenv("LOCK_METHOD"); + if (str == NULL || strcmp(str, "flock") == 0) + *lock_method_r = MAIL_STORAGE_LOCK_FLOCK; + else if (strcmp(str, "fcntl") == 0) + *lock_method_r = MAIL_STORAGE_LOCK_FCNTL; + else if (strcmp(str, "dotlock") == 0) + *lock_method_r = MAIL_STORAGE_LOCK_DOTLOCK; + else + i_fatal("Unknown lock_method: %s", str); +} + static struct mail_storage *mail_storage_find(const char *name) { struct mail_storage *const *classes;
--- a/src/lib-storage/mail-storage.h Thu Feb 02 21:37:59 2006 +0200 +++ b/src/lib-storage/mail-storage.h Thu Feb 02 22:20:30 2006 +0200 @@ -213,6 +213,10 @@ void mail_storage_class_register(struct mail_storage *storage_class); void mail_storage_class_unregister(struct mail_storage *storage_class); +/* Returns flags and lock_method based on environment settings. */ +void mail_storage_parse_env(enum mail_storage_flags *flags_r, + enum mail_storage_lock_method *lock_method_r); + /* Create a new instance of registered mail storage class with given storage-specific data. If data is NULL, it tries to use defaults. May return NULL if anything fails.
--- a/src/pop3/main.c Thu Feb 02 21:37:59 2006 +0200 +++ b/src/pop3/main.c Thu Feb 02 22:20:30 2006 +0200 @@ -152,7 +152,7 @@ enum mail_storage_flags flags; enum mail_storage_lock_method lock_method; struct mail_storage *storage; - const char *str, *mail; + const char *mail; lib_signals_init(); lib_signals_set_handler(SIGINT, TRUE, sig_die, NULL); @@ -200,32 +200,7 @@ i_fatal("pop3_uidl_format setting doesn't contain any " "%% variables."); - flags = 0; - if (getenv("FULL_FILESYSTEM_ACCESS") != NULL) - flags |= MAIL_STORAGE_FLAG_FULL_FS_ACCESS; - if (getenv("DEBUG") != NULL) - flags |= MAIL_STORAGE_FLAG_DEBUG; - if (getenv("MMAP_DISABLE") != NULL) - flags |= MAIL_STORAGE_FLAG_MMAP_DISABLE; - if (getenv("MMAP_NO_WRITE") != NULL) - flags |= MAIL_STORAGE_FLAG_MMAP_NO_WRITE; - if (getenv("MAIL_READ_MMAPED") != NULL) - flags |= MAIL_STORAGE_FLAG_MMAP_MAILS; - if (getenv("MAIL_SAVE_CRLF") != NULL) - flags |= MAIL_STORAGE_FLAG_SAVE_CRLF; - if ((uidl_keymask & UIDL_MD5) != 0) - flags |= MAIL_STORAGE_FLAG_KEEP_HEADER_MD5; - - str = getenv("LOCK_METHOD"); - if (str == NULL || strcmp(str, "flock") == 0) - lock_method = MAIL_STORAGE_LOCK_FLOCK; - else if (strcmp(str, "fcntl") == 0) - lock_method = MAIL_STORAGE_LOCK_FCNTL; - else if (strcmp(str, "dotlock") == 0) - lock_method = MAIL_STORAGE_LOCK_DOTLOCK; - else - i_fatal("Unknown lock_method: %s", str); - + mail_storage_parse_env(&flags, &lock_method); storage = mail_storage_create_with_data(mail, getenv("USER"), flags, lock_method); if (storage == NULL) {