Mercurial > dovecot > original-hg > dovecot-1.2
changeset 813:493bc8da9e80 HEAD
default_mail_env behaviour changed. We use %u instead of $U now. Added also
several other variables which can be used. Ideas based on David Champion's
mailpath library.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 20 Dec 2002 06:47:39 +0200 |
parents | 9e6317fa800c |
children | a6d24244c23f |
files | dovecot-example.conf src/master/imap-process.c |
diffstat | 2 files changed, 53 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/dovecot-example.conf Fri Dec 20 06:43:11 2002 +0200 +++ b/dovecot-example.conf Fri Dec 20 06:47:39 2002 +0200 @@ -141,8 +141,20 @@ # Default MAIL environment to use when it's not set. By leaving this empty # dovecot tries to do some automatic detection as described in -# doc/mail-storages.txt. $U will be replaced with username. Some examples: -# maildir:/var/mail/$U/Maildir, mbox:~/mail/ +# doc/mail-storages.txt. There's a few special variables you can use: +# +# %u - username +# %n - user part in user@domain, same as %u if there's no domain +# %d - domain part in user@domain, empty if user there's no domain +# %h - home directory +# +# You can also limit a width of string by giving the number of max. characters +# after the '%' character. For example %1u gives the first character of +# username. Some examples: +# +# maildir:/var/mail/%1u/%u/Maildir +# mbox:~/mail/ +# #default_mail_env = # Space-separated list of fields to cache for all mails. Currently these
--- a/src/master/imap-process.c Fri Dec 20 06:43:11 2002 +0200 +++ b/src/master/imap-process.c Fri Dec 20 06:47:39 2002 +0200 @@ -68,7 +68,8 @@ const char *home) { TempString *str; - const char *p; + const char *p, *var; + unsigned int width; str = t_string_new(256); @@ -89,13 +90,45 @@ env++; } - /* expand $U if found */ + /* expand %vars */ for (; *env != '\0'; env++) { - if (*env == '$' && env[1] == 'U') { - t_string_append(str, user); - env++; - } else { + if (*env != '%') t_string_append_c(str, *env); + else { + width = 0; + while (env[1] >= '0' && env[1] <= '9') { + width = width*10 + (env[1] - '0'); + env++; + } + + switch (env[1]) { + case '%': + var = "%"; + break; + case 'u': + var = user; + break; + case 'h': + var = home; + break; + case 'n': + var = t_strcut(user, '@'); + break; + case 'd': + var = strchr(user, '@'); + if (var != NULL) var++; + break; + default: + var = NULL; + break; + } + + if (var != NULL) { + if (width == 0) + t_string_append(str, var); + else + t_string_append_n(str, var, width); + } } }