dovecot: Parse namespaces from config file.
dovecot at dovecot.org
dovecot at dovecot.org
Tue Oct 16 20:01:55 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/e752f60f7e60
changeset: 6553:e752f60f7e60
user: Timo Sirainen <tss at iki.fi>
date: Tue Oct 16 20:01:52 2007 +0300
description:
Parse namespaces from config file.
diffstat:
1 file changed, 54 insertions(+), 3 deletions(-)
src/deliver/deliver.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++---
diffs (107 lines):
diff -r d8343f5863d3 -r e752f60f7e60 src/deliver/deliver.c
--- a/src/deliver/deliver.c Tue Oct 16 19:36:23 2007 +0300
+++ b/src/deliver/deliver.c Tue Oct 16 20:01:52 2007 +0300
@@ -1,4 +1,8 @@
/* Copyright (c) 2005-2007 Dovecot authors, see the included COPYING file */
+
+/* This is getting pretty horrible. Especially the config file parsing.
+ Dovecot v2.0 should have a config file handling process which should help
+ with this.. */
#include "lib.h"
#include "lib-signals.h"
@@ -216,6 +220,11 @@ static bool setting_is_bool(const char *
if (strcmp(def->name, name) == 0)
return def->type == SET_BOOL;
}
+ if (strncmp(name, "NAMESPACE_", 10) == 0) {
+ return strstr(name, "_list") != NULL ||
+ strstr(name, "_inbox") != NULL ||
+ strstr(name, "_hidden") != NULL;
+ }
return FALSE;
}
@@ -226,6 +235,8 @@ static void config_file_init(const char
char *line, *p, quote;
int fd, sections = 0;
bool lda_section = FALSE, pop3_section = FALSE, plugin_section = FALSE;
+ bool ns_section = FALSE, ns_location = FALSE;
+ unsigned int ns_idx = 0;
size_t len;
plugin_pool = pool_alloconly_create("Plugin strings", 512);
@@ -280,6 +291,14 @@ static void config_file_init(const char
lda_section = TRUE;
} else if (strcmp(line, "protocol pop3 {") == 0)
pop3_section = TRUE;
+ else if (strncmp(line, "namespace ", 10) == 0) {
+ ns_section = TRUE;
+ ns_idx++;
+ line += 10;
+ env_put(t_strdup_printf(
+ "NAMESPACE_%u_TYPE=%s", ns_idx,
+ t_strcut(line, ' ')));
+ }
sections++;
}
if (*line == '}') {
@@ -287,6 +306,13 @@ static void config_file_init(const char
lda_section = FALSE;
plugin_section = FALSE;
pop3_section = FALSE;
+ ns_section = FALSE;
+ if (ns_location)
+ ns_location = FALSE;
+ else {
+ env_put(t_strdup_printf(
+ "NAMESPACE_%u=", ns_idx));
+ }
}
continue;
}
@@ -295,9 +321,22 @@ static void config_file_init(const char
key = t_strdup_until(line, p);
if (sections > 0 && !lda_section) {
- if (!pop3_section ||
- strcmp(key, "pop3_uidl_format") != 0)
- continue;
+ if (pop3_section) {
+ if (strcmp(key, "pop3_uidl_format") != 0)
+ continue;
+ } else if (ns_section) {
+ if (strcmp(key, "separator") == 0) {
+ key = t_strdup_printf(
+ "NAMESPACE_%u_SEP", ns_idx);
+ } else if (strcmp(key, "location") == 0) {
+ ns_location = TRUE;
+ key = t_strdup_printf("NAMESPACE_%u",
+ ns_idx);
+ } else {
+ key = t_strdup_printf("NAMESPACE_%u_%s",
+ ns_idx, key);
+ }
+ }
}
do {
@@ -736,6 +775,18 @@ int main(int argc, char *argv[])
expand_envs(user);
putenv_extra_fields(&extra_fields);
+ /* Fix namespaces with empty locations */
+ for (i = 1;; i++) {
+ value = getenv(t_strdup_printf("NAMESPACE_%u", i));
+ if (value == NULL)
+ break;
+
+ if (*value == '\0') {
+ env_put(t_strdup_printf("NAMESPACE_%u=%s", i,
+ getenv("MAIL")));
+ }
+ }
+
/* If possible chdir to home directory, so that core file
could be written in case we crash. */
home = getenv("HOME");
More information about the dovecot-cvs
mailing list