Commit 6d490ce1 6d490ce129c98caddf5db5601094497a375f47e7 by Sergey Poznyakoff

* NEWS: Update.

* configure.ac (MU_LIB_REMOTE): New substitution variable.
(AC_CONFIG_FILES): Add libproto/remote/Makefile.
* imap4d/copy.c, imap4d/create.c, imap4d/delete.c, imap4d/fetch.c,
imap4d/imap4d.c, imap4d/list.c, imap4d/lsub.c, imap4d/rename.c,
imap4d/subscribe.c, imap4d/unsubscribe.c, imap4d/util.c: Spelling
fixes.
* include/mailutils/cfg.h (mu_cfg_error_count): New variable.
* include/mailutils/gocs.h (struct mu_gocs_mailbox):  New member
mailbox_pattern
* include/mailutils/libargp.h (mu_rcfile_lint): New variable.
* include/mailutils/mailbox.h (mu_set_mailbox_pattern): New
function.
(mu_mail_directory): Removed.
(mu_mailbox_url): New function.
* include/mailutils/mutil.h (mu_normalize_mailbox_url): Remove.
* include/mailutils/registrar.h (mu_0_6_registrar_lookup): Remove.

* libargp/common.c: New options --rcfile-lint and
--mailbox-pattern.
* libargp/muinit.c: Handle --rcfile-lint.
* libcfg/common.c: New statement mailbox-pattern
* libmu_scm/mu_mailbox.c (mu-mail-directory): Deprecated.
(mu-user-mailbox-url): New function.

* libproto/remote: New directory.
* libproto/remote/folder.c: New file.
* libproto/remote/mbox.c: New file.
* libproto/remote/.cvsignore: New file.

* libproto/Makefile.am (SUBDIRS): Add remote
* libproto/mbox/folder.c, libproto/mbox/url.c: Indentation and
spelling fixes.
* maidag/Makefile.am (maidag_LDADD): Add MU_LIB_REMOTE.
* maidag/maidag.c: Register mu_remote_mbox_record.
* mailbox/cfg_parser.y (mu_cfg_error_count): New variable.
(mu_cfg_format_error,_mu_cfg_vperror): Increment
mu_cfg_error_count.
* mailbox/debug.c (mu_debug_check_level): Do not mask out
inheritance bit.
* mailbox/gocs.c (mu_gocs_mailbox_init): Set mailbox pattern.
* mailbox/mailbox.c (_create_mailbox): Bugfix.
* mailbox/mbx_default.c (mu_set_mailbox_pattern): New finction.
(mu_set_mail_directory): Rewrite.
(user_mailbox_name): Rewrite.
* mailbox/mutil.c (mu_normalize_mailbox_url): Remove.
* mailbox/registrar.c (mu_0_6_registrar_lookup): Remove.
* guimb/scm/sieve-core.scm (sieve-main): Use mu-user-mailbox-url.
1 parent 5a30e7b2
1 2007-12-19 Sergey Poznyakoff <gray@gnu.org.ua>
2
3 * NEWS: Update.
4 * configure.ac (MU_LIB_REMOTE): New substitution variable.
5 (AC_CONFIG_FILES): Add libproto/remote/Makefile.
6 * imap4d/copy.c, imap4d/create.c, imap4d/delete.c, imap4d/fetch.c,
7 imap4d/imap4d.c, imap4d/list.c, imap4d/lsub.c, imap4d/rename.c,
8 imap4d/subscribe.c, imap4d/unsubscribe.c, imap4d/util.c: Spelling
9 fixes.
10 * include/mailutils/cfg.h (mu_cfg_error_count): New variable.
11 * include/mailutils/gocs.h (struct mu_gocs_mailbox): New member
12 mailbox_pattern
13 * include/mailutils/libargp.h (mu_rcfile_lint): New variable.
14 * include/mailutils/mailbox.h (mu_set_mailbox_pattern): New
15 function.
16 (mu_mail_directory): Removed.
17 (mu_mailbox_url): New function.
18 * include/mailutils/mutil.h (mu_normalize_mailbox_url): Remove.
19 * include/mailutils/registrar.h (mu_0_6_registrar_lookup): Remove.
20
21 * libargp/common.c: New options --rcfile-lint and
22 --mailbox-pattern.
23 * libargp/muinit.c: Handle --rcfile-lint.
24 * libcfg/common.c: New statement mailbox-pattern
25 * libmu_scm/mu_mailbox.c (mu-mail-directory): Deprecated.
26 (mu-user-mailbox-url): New function.
27
28 * libproto/remote: New directory.
29 * libproto/remote/folder.c: New file.
30 * libproto/remote/mbox.c: New file.
31 * libproto/remote/.cvsignore: New file.
32
33 * libproto/Makefile.am (SUBDIRS): Add remote
34 * libproto/mbox/folder.c, libproto/mbox/url.c: Indentation and
35 spelling fixes.
36 * maidag/Makefile.am (maidag_LDADD): Add MU_LIB_REMOTE.
37 * maidag/maidag.c: Register mu_remote_mbox_record.
38 * mailbox/cfg_parser.y (mu_cfg_error_count): New variable.
39 (mu_cfg_format_error,_mu_cfg_vperror): Increment
40 mu_cfg_error_count.
41 * mailbox/debug.c (mu_debug_check_level): Do not mask out
42 inheritance bit.
43 * mailbox/gocs.c (mu_gocs_mailbox_init): Set mailbox pattern.
44 * mailbox/mailbox.c (_create_mailbox): Bugfix.
45 * mailbox/mbx_default.c (mu_set_mailbox_pattern): New finction.
46 (mu_set_mail_directory): Rewrite.
47 (user_mailbox_name): Rewrite.
48 * mailbox/mutil.c (mu_normalize_mailbox_url): Remove.
49 * mailbox/registrar.c (mu_0_6_registrar_lookup): Remove.
50 * guimb/scm/sieve-core.scm (sieve-main): Use mu-user-mailbox-url.
51
1 2007-12-15 Sergey Poznyakoff <gray@gnu.org.ua> 52 2007-12-15 Sergey Poznyakoff <gray@gnu.org.ua>
2 53
3 * libcfg/acl.c (getword): Bugfix. 54 * libcfg/acl.c (getword): Bugfix.
......
1 GNU mailutils NEWS -- history of user-visible changes. 2007-12-07 1 GNU mailutils NEWS -- history of user-visible changes. 2007-12-19
2 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. 2 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
3 See the end of file for copying conditions. 3 See the end of file for copying conditions.
4 4
...@@ -30,10 +30,14 @@ affect the given program. ...@@ -30,10 +30,14 @@ affect the given program.
30 30
31 Maidag is a MAIl Delivery AGent. It is a general-purpose MDA able to 31 Maidag is a MAIl Delivery AGent. It is a general-purpose MDA able to
32 run in both traditional and LMTP mode and to deliver mails to various 32 run in both traditional and LMTP mode and to deliver mails to various
33 mailbox formats. It is also able to process incoming messages using 33 mailbox formats. These formats, among others, include remote+smtp and
34 Sieve or Scheme scripts and, based on results of this processing, 34 remote+sendmail (see `New mailbox types.', below), which are
35 to take a decision on whether to actually deliver and where to 35 equivalent to forwarding a message over SMTP. Thus, maidag supercedes
36 deliver them. 36 both `mail.local' and `mail.remote' (both of which are still included
37 for backward compatibility). Maidag is also able to process incoming
38 messages using Sieve or Scheme scripts and, based on results of this
39 processing, to take a decision on whether to actually deliver and
40 where to deliver them.
37 41
38 ** New Sieve action `pipe' 42 ** New Sieve action `pipe'
39 43
...@@ -215,6 +219,14 @@ Any mu_url_get_.* accessors return MU_ERR_ENOENT if the corresponding ...@@ -215,6 +219,14 @@ Any mu_url_get_.* accessors return MU_ERR_ENOENT if the corresponding
215 field is not present in the object. Previous versions in that case 219 field is not present in the object. Previous versions in that case
216 returned 0 and stored empty string in the output buffer. 220 returned 0 and stored empty string in the output buffer.
217 221
222 ** New mailbox types.
223
224 Two new mailbox types, "remote+smtp" and "remote+sendmail", are
225 supported. These are `append-only' mailboxes, i.e. the only operation
226 that can be done over them is mu_mailbox_append_message. E.g.,
227 appending to the URL `remote+smtp://127.0.0.1:24' is equivalent to
228 sending a message using mailer `smtp://127.0.0.1:24'.
229
218 ** Fixed parsing of URLs similar to file:///a/b. 230 ** Fixed parsing of URLs similar to file:///a/b.
219 231
220 It is parsed as an absolute file name `/a/b'. 232 It is parsed as an absolute file name `/a/b'.
...@@ -224,6 +236,10 @@ Previous versions incorrectly understood such an URL as `a/b' ...@@ -224,6 +236,10 @@ Previous versions incorrectly understood such an URL as `a/b'
224 236
225 ** Remove v0.6 compatibility layer. 237 ** Remove v0.6 compatibility layer.
226 238
239 ** Function mu_mail_directory is removed.
240
241 ** New function mu_mailbox_url.
242
227 243
228 Version 1.2: 244 Version 1.2:
229 245
......
...@@ -41,6 +41,7 @@ AC_SUBST(MU_LIB_MBOX,'${top_builddir}/libproto/mbox/libmu_mbox.la') ...@@ -41,6 +41,7 @@ AC_SUBST(MU_LIB_MBOX,'${top_builddir}/libproto/mbox/libmu_mbox.la')
41 AC_SUBST(MU_LIB_MH,'${top_builddir}/libproto/mh/libmu_mh.la') 41 AC_SUBST(MU_LIB_MH,'${top_builddir}/libproto/mh/libmu_mh.la')
42 AC_SUBST(MU_LIB_NNTP,'${top_builddir}/libproto/nntp/libmu_nntp.la') 42 AC_SUBST(MU_LIB_NNTP,'${top_builddir}/libproto/nntp/libmu_nntp.la')
43 AC_SUBST(MU_LIB_POP,'${top_builddir}/libproto/pop/libmu_pop.la') 43 AC_SUBST(MU_LIB_POP,'${top_builddir}/libproto/pop/libmu_pop.la')
44 AC_SUBST(MU_LIB_REMOTE,'${top_builddir}/libproto/remote/libmu_remotembox.la')
44 AC_SUBST(MU_LIB_SIEVE,'${top_builddir}/libsieve/libsieve.la') 45 AC_SUBST(MU_LIB_SIEVE,'${top_builddir}/libsieve/libsieve.la')
45 AC_SUBST(MU_LIB_SCM,'${top_builddir}/libmu_scm/libmu_scm.la') 46 AC_SUBST(MU_LIB_SCM,'${top_builddir}/libmu_scm/libmu_scm.la')
46 AC_SUBST(MU_LIB_CPP,'${top_builddir}/libmu_cpp/libmu_cpp.la') 47 AC_SUBST(MU_LIB_CPP,'${top_builddir}/libmu_cpp/libmu_cpp.la')
...@@ -1194,6 +1195,7 @@ AC_CONFIG_FILES([Makefile ...@@ -1194,6 +1195,7 @@ AC_CONFIG_FILES([Makefile
1194 libproto/nntp/Makefile 1195 libproto/nntp/Makefile
1195 libproto/imap/Makefile 1196 libproto/imap/Makefile
1196 libproto/include/Makefile 1197 libproto/include/Makefile
1198 libproto/remote/Makefile
1197 libsieve/Makefile 1199 libsieve/Makefile
1198 libsieve/extensions/Makefile 1200 libsieve/extensions/Makefile
1199 libargp/Makefile 1201 libargp/Makefile
......
...@@ -492,8 +492,8 @@ ...@@ -492,8 +492,8 @@
492 (name (if (and (not (null? (cdr cl))) 492 (name (if (and (not (null? (cdr cl)))
493 (string? (cadr cl))) 493 (string? (cadr cl)))
494 (cadr cl) 494 (cadr cl)
495 (string-append (mu-mail-directory) "/" 495 (mu-user-mailbox-url
496 (passwd:name (mu-getpwuid (getuid))))))) 496 (passwd:name (mu-getpwuid (getuid)))))))
497 497
498 (set! sieve-mailbox (mu-mailbox-open name "rw")) 498 (set! sieve-mailbox (mu-mailbox-open name "rw"))
499 (sieve-run thunk) 499 (sieve-run thunk)
......
...@@ -109,7 +109,7 @@ imap4d_copy0 (char *arg, int isuid, char *resp, size_t resplen) ...@@ -109,7 +109,7 @@ imap4d_copy0 (char *arg, int isuid, char *resp, size_t resplen)
109 return RESP_OK; 109 return RESP_OK;
110 } 110 }
111 111
112 /* Unless it is certain that the destination mailbox can not be created, 112 /* Unless it is certain that the destination mailbox cannot be created,
113 the server MUST send the response code "[TRYCREATE]" as the prefix 113 the server MUST send the response code "[TRYCREATE]" as the prefix
114 of the text of the tagged NO response. This gives a hint to the 114 of the text of the tagged NO response. This gives a hint to the
115 client that it can attempt a CREATE command and retry the copy if 115 client that it can attempt a CREATE command and retry the copy if
......
...@@ -71,7 +71,7 @@ imap4d_create (struct imap4d_command *command, char *arg) ...@@ -71,7 +71,7 @@ imap4d_create (struct imap4d_command *command, char *arg)
71 name = namespace_getfullpath (name, delim); 71 name = namespace_getfullpath (name, delim);
72 72
73 if (!name) 73 if (!name)
74 return util_finish (command, RESP_NO, "Can not create mailbox"); 74 return util_finish (command, RESP_NO, "Cannot create mailbox");
75 75
76 /* It will fail if the mailbox already exists. */ 76 /* It will fail if the mailbox already exists. */
77 if (access (name, F_OK) != 0) 77 if (access (name, F_OK) != 0)
...@@ -98,7 +98,7 @@ imap4d_create (struct imap4d_command *command, char *arg) ...@@ -98,7 +98,7 @@ imap4d_create (struct imap4d_command *command, char *arg)
98 else 98 else
99 { 99 {
100 rc = RESP_NO; 100 rc = RESP_NO;
101 msg = "Can not create mailbox"; 101 msg = "Cannot create mailbox";
102 break; 102 break;
103 } 103 }
104 } 104 }
...@@ -113,7 +113,7 @@ imap4d_create (struct imap4d_command *command, char *arg) ...@@ -113,7 +113,7 @@ imap4d_create (struct imap4d_command *command, char *arg)
113 else 113 else
114 { 114 {
115 rc = RESP_NO; 115 rc = RESP_NO;
116 msg = "Can not create mailbox"; 116 msg = "Cannot create mailbox";
117 } 117 }
118 } 118 }
119 } 119 }
......
...@@ -44,12 +44,12 @@ imap4d_delete (struct imap4d_command *command, char *arg) ...@@ -44,12 +44,12 @@ imap4d_delete (struct imap4d_command *command, char *arg)
44 /* Allocates memory. */ 44 /* Allocates memory. */
45 name = namespace_getfullpath (name, delim); 45 name = namespace_getfullpath (name, delim);
46 if (!name) 46 if (!name)
47 return util_finish (command, RESP_NO, "Can not remove"); 47 return util_finish (command, RESP_NO, "Cannot remove");
48 48
49 if (remove (name) != 0) 49 if (remove (name) != 0)
50 { 50 {
51 rc = RESP_NO; 51 rc = RESP_NO;
52 msg = "Can not remove"; 52 msg = "Cannot remove";
53 } 53 }
54 free (name); 54 free (name);
55 return util_finish (command, rc, msg); 55 return util_finish (command, rc, msg);
......
...@@ -1031,7 +1031,7 @@ fetch_operation (mu_message_t msg, char **arg, int silent) ...@@ -1031,7 +1031,7 @@ fetch_operation (mu_message_t msg, char **arg, int silent)
1031 { 1031 {
1032 if (!silent) 1032 if (!silent)
1033 { 1033 {
1034 /* NOTE: We violate the RFC here: Header can not take a prefix for 1034 /* NOTE: We violate the RFC here: Header cannot take a prefix for
1035 section messages it only referes to the RFC822 header .. ok 1035 section messages it only referes to the RFC822 header .. ok
1036 see it as an extension. But according to IMAP4 we should 1036 see it as an extension. But according to IMAP4 we should
1037 have send an empty string: util_send (" \"\""); 1037 have send an empty string: util_send (" \"\"");
......
...@@ -59,9 +59,10 @@ size_t children; ...@@ -59,9 +59,10 @@ size_t children;
59 const char *program_version = "imap4d (" PACKAGE_STRING ")"; 59 const char *program_version = "imap4d (" PACKAGE_STRING ")";
60 static char doc[] = N_("GNU imap4d -- the IMAP4D daemon"); 60 static char doc[] = N_("GNU imap4d -- the IMAP4D daemon");
61 61
62 #define ARG_LOGIN_DISABLED 1 62 #define ARG_LOGIN_DISABLED 256
63 #define ARG_TLS_REQUIRED 2 63 #define ARG_TLS_REQUIRED 257
64 #define ARG_CREATE_HOME_DIR 3 64 #define ARG_CREATE_HOME_DIR 258
65 #define ARG_OPTION_PREAUTH 259
65 66
66 static struct argp_option options[] = { 67 static struct argp_option options[] = {
67 {"other-namespace", 'O', N_("PATHLIST"), OPTION_HIDDEN, 68 {"other-namespace", 'O', N_("PATHLIST"), OPTION_HIDDEN,
...@@ -73,6 +74,8 @@ static struct argp_option options[] = { ...@@ -73,6 +74,8 @@ static struct argp_option options[] = {
73 {"create-home-dir", ARG_CREATE_HOME_DIR, N_("MODE"), 74 {"create-home-dir", ARG_CREATE_HOME_DIR, N_("MODE"),
74 OPTION_ARG_OPTIONAL|OPTION_HIDDEN, 75 OPTION_ARG_OPTIONAL|OPTION_HIDDEN,
75 N_("Create home directory, if it does not exist")}, 76 N_("Create home directory, if it does not exist")},
77 {"preauth", ARG_OPTION_PREAUTH, NULL, 0,
78 N_("Start in preauth mode") },
76 #ifdef WITH_TLS 79 #ifdef WITH_TLS
77 {"tls-required", ARG_TLS_REQUIRED, NULL, OPTION_HIDDEN, 80 {"tls-required", ARG_TLS_REQUIRED, NULL, OPTION_HIDDEN,
78 N_("Always require STARTTLS before entering authentication phase")}, 81 N_("Always require STARTTLS before entering authentication phase")},
...@@ -140,6 +143,10 @@ imap4d_parse_opt (int key, char *arg, struct argp_state *state) ...@@ -140,6 +143,10 @@ imap4d_parse_opt (int key, char *arg, struct argp_state *state)
140 break; 143 break;
141 #endif 144 #endif
142 145
146 case ARG_OPTION_PREAUTH:
147 preauth_mode = preauth_stdio;
148 break;
149
143 case ARGP_KEY_INIT: 150 case ARGP_KEY_INIT:
144 mu_argp_node_list_init (&lst); 151 mu_argp_node_list_init (&lst);
145 break; 152 break;
......
...@@ -36,7 +36,7 @@ struct inode_list ...@@ -36,7 +36,7 @@ struct inode_list
36 }; 36 };
37 37
38 /* 38 /*
39 1- IMAP4 insists: the reference argument that is include in the 39 1- IMAP4 insists: the reference argument present in the
40 interpreted form SHOULD prefix the interpreted form. It SHOULD 40 interpreted form SHOULD prefix the interpreted form. It SHOULD
41 also be in the same form as the reference name argument. This 41 also be in the same form as the reference name argument. This
42 rule permits the client to determine if the returned mailbox name 42 rule permits the client to determine if the returned mailbox name
...@@ -52,7 +52,7 @@ struct inode_list ...@@ -52,7 +52,7 @@ struct inode_list
52 52
53 2- The character "*" is a wildcard, and matches zero or more characters 53 2- The character "*" is a wildcard, and matches zero or more characters
54 at this position. The charcater "%" is similar to "*", 54 at this position. The charcater "%" is similar to "*",
55 but it does not match ahierarchy delimiter. */ 55 but it does not match a hierarchy delimiter. */
56 56
57 static int match (const char *, const char *, const char *); 57 static int match (const char *, const char *, const char *);
58 static void list_file (const char *, const char *, const char *, const char *, struct inode_list *); 58 static void list_file (const char *, const char *, const char *, const char *, struct inode_list *);
......
...@@ -74,5 +74,5 @@ imap4d_lsub (struct imap4d_command *command, char *arg) ...@@ -74,5 +74,5 @@ imap4d_lsub (struct imap4d_command *command, char *arg)
74 } 74 }
75 else if (errno == ENOENT) 75 else if (errno == ENOENT)
76 return util_finish (command, RESP_OK, "Completed"); 76 return util_finish (command, RESP_OK, "Completed");
77 return util_finish (command, RESP_NO, "Can not list subscriber"); 77 return util_finish (command, RESP_NO, "Cannot list subscriber");
78 } 78 }
......
...@@ -75,7 +75,7 @@ imap4d_rename (struct imap4d_command *command, char *arg) ...@@ -75,7 +75,7 @@ imap4d_rename (struct imap4d_command *command, char *arg)
75 if (S_ISDIR(newst.st_mode)) 75 if (S_ISDIR(newst.st_mode))
76 { 76 {
77 free (newname); 77 free (newname);
78 return util_finish (command, RESP_NO, "Can not be a directory"); 78 return util_finish (command, RESP_NO, "Cannot be a directory");
79 } 79 }
80 name = calloc (strlen ("mbox:") + strlen (newname) + 1, 1); 80 name = calloc (strlen ("mbox:") + strlen (newname) + 1, 1);
81 sprintf (name, "mbox:%s", newname); 81 sprintf (name, "mbox:%s", newname);
...@@ -84,7 +84,7 @@ imap4d_rename (struct imap4d_command *command, char *arg) ...@@ -84,7 +84,7 @@ imap4d_rename (struct imap4d_command *command, char *arg)
84 { 84 {
85 free (name); 85 free (name);
86 free (newname); 86 free (newname);
87 return util_finish (command, RESP_NO, "Can not create new mailbox"); 87 return util_finish (command, RESP_NO, "Cannot create new mailbox");
88 } 88 }
89 free (name); 89 free (name);
90 free (newname); 90 free (newname);
......
...@@ -45,5 +45,5 @@ imap4d_subscribe (struct imap4d_command *command, char *arg) ...@@ -45,5 +45,5 @@ imap4d_subscribe (struct imap4d_command *command, char *arg)
45 fclose (fp); 45 fclose (fp);
46 return util_finish (command, RESP_OK, "Completed"); 46 return util_finish (command, RESP_OK, "Completed");
47 } 47 }
48 return util_finish (command, RESP_NO, "Can not subscribe"); 48 return util_finish (command, RESP_NO, "Cannot subscribe");
49 } 49 }
......
...@@ -112,7 +112,7 @@ imap4d_unsubscribe (struct imap4d_command *command, char *arg) ...@@ -112,7 +112,7 @@ imap4d_unsubscribe (struct imap4d_command *command, char *arg)
112 112
113 free (file); 113 free (file);
114 if (rc) 114 if (rc)
115 return util_finish (command, RESP_NO, "Can not unsubscribe"); 115 return util_finish (command, RESP_NO, "Cannot unsubscribe");
116 116
117 return util_finish (command, RESP_OK, "Completed"); 117 return util_finish (command, RESP_OK, "Completed");
118 } 118 }
......
...@@ -26,7 +26,7 @@ static int add2set (size_t **, int *, unsigned long); ...@@ -26,7 +26,7 @@ static int add2set (size_t **, int *, unsigned long);
26 static const char *sc2string (int); 26 static const char *sc2string (int);
27 27
28 /* Get the next space/CR/NL separated word, some words are between double 28 /* Get the next space/CR/NL separated word, some words are between double
29 quotes, strtok() can not handle it. */ 29 quotes, strtok() cannot handle it. */
30 char * 30 char *
31 util_getword (char *s, char **save) 31 util_getword (char *s, char **save)
32 { 32 {
......
...@@ -231,6 +231,7 @@ int mu_parse_config (const char *file, const char *progname, ...@@ -231,6 +231,7 @@ int mu_parse_config (const char *file, const char *progname,
231 int mu_cfg_parse_boolean (const char *str, int *res); 231 int mu_cfg_parse_boolean (const char *str, int *res);
232 232
233 extern int mu_cfg_parser_verbose; 233 extern int mu_cfg_parser_verbose;
234 extern size_t mu_cfg_error_count;
234 235
235 void mu_cfg_format_docstring (mu_stream_t stream, const char *docstring, 236 void mu_cfg_format_docstring (mu_stream_t stream, const char *docstring,
236 int level); 237 int level);
......
...@@ -52,6 +52,7 @@ struct mu_gocs_debug ...@@ -52,6 +52,7 @@ struct mu_gocs_debug
52 struct mu_gocs_mailbox 52 struct mu_gocs_mailbox
53 { 53 {
54 char *mail_spool; 54 char *mail_spool;
55 char *mailbox_pattern;
55 char *mailbox_type; 56 char *mailbox_type;
56 }; 57 };
57 58
......
...@@ -43,7 +43,8 @@ struct mu_cmdline_capa ...@@ -43,7 +43,8 @@ struct mu_cmdline_capa
43 }; 43 };
44 44
45 extern int mu_help_config_mode; 45 extern int mu_help_config_mode;
46 46 extern int mu_rcfile_lint;
47
47 extern struct mu_cmdline_capa mu_common_cmdline; 48 extern struct mu_cmdline_capa mu_common_cmdline;
48 extern struct mu_cmdline_capa mu_logging_cmdline; 49 extern struct mu_cmdline_capa mu_logging_cmdline;
49 extern struct mu_cmdline_capa mu_license_cmdline; 50 extern struct mu_cmdline_capa mu_license_cmdline;
......
...@@ -29,8 +29,9 @@ extern "C" { ...@@ -29,8 +29,9 @@ extern "C" {
29 #endif 29 #endif
30 30
31 int mu_set_mail_directory (const char *p); 31 int mu_set_mail_directory (const char *p);
32 int mu_set_mailbox_pattern (const char *pat);
32 void mu_set_folder_directory (const char *p); 33 void mu_set_folder_directory (const char *p);
33 const char *mu_mail_directory (void); 34 const char *mu_mailbox_url (void);
34 const char *mu_folder_directory (void); 35 const char *mu_folder_directory (void);
35 int mu_construct_user_mailbox_url (char **pout, const char *name); 36 int mu_construct_user_mailbox_url (char **pout, const char *name);
36 37
......
...@@ -97,7 +97,6 @@ extern int mu_get_user_email_domain (const char** domain); ...@@ -97,7 +97,6 @@ extern int mu_get_user_email_domain (const char** domain);
97 extern char *mu_get_user_email (const char *name); 97 extern char *mu_get_user_email (const char *name);
98 98
99 extern char *mu_normalize_path (char *path, const char *delim); 99 extern char *mu_normalize_path (char *path, const char *delim);
100 extern int mu_normalize_mailbox_url (char **out, const char *dir);
101 extern int mu_tempfile (const char *tmpdir, char **namep); 100 extern int mu_tempfile (const char *tmpdir, char **namep);
102 extern char *mu_tempname (const char *tmpdir); 101 extern char *mu_tempname (const char *tmpdir);
103 102
......
...@@ -51,8 +51,6 @@ extern int mu_registrar_get_list (mu_list_t *) __attribute__ ((deprecated)); ...@@ -51,8 +51,6 @@ extern int mu_registrar_get_list (mu_list_t *) __attribute__ ((deprecated));
51 51
52 extern int mu_registrar_lookup (const char *name, int flags, 52 extern int mu_registrar_lookup (const char *name, int flags,
53 mu_record_t *precord, int *pflags); 53 mu_record_t *precord, int *pflags);
54 extern int mu_0_6_registrar_lookup (const char *name, mu_record_t *precord,
55 int flags);
56 extern int mu_registrar_record (mu_record_t); 54 extern int mu_registrar_record (mu_record_t);
57 extern int mu_unregistrar_record (mu_record_t); 55 extern int mu_unregistrar_record (mu_record_t);
58 56
...@@ -103,17 +101,20 @@ extern mu_record_t mu_path_record; ...@@ -103,17 +101,20 @@ extern mu_record_t mu_path_record;
103 extern mu_record_t mu_mh_record; 101 extern mu_record_t mu_mh_record;
104 /* Maildir, "maildir:" */ 102 /* Maildir, "maildir:" */
105 extern mu_record_t mu_maildir_record; 103 extern mu_record_t mu_maildir_record;
106 104 /* Remote mailbox */
107 #define MU_IMAP_PRIO 100 105 extern mu_record_t mu_remote_mbox_record;
108 #define MU_POP_PRIO 200 106
109 #define MU_MBOX_PRIO 300 107 #define MU_IMAP_PRIO 100
110 #define MU_MH_PRIO 400 108 #define MU_POP_PRIO 200
111 #define MU_MAILDIR_PRIO 500 109 #define MU_MBOX_PRIO 300
112 #define MU_NNTP_PRIO 600 110 #define MU_MH_PRIO 400
113 #define MU_PATH_PRIO 1000 111 #define MU_MAILDIR_PRIO 500
114 112 #define MU_NNTP_PRIO 600
115 #define MU_SMTP_PRIO 10000 113 #define MU_PATH_PRIO 1000
116 #define MU_SENDMAIL_PRIO 10000 114
115 #define MU_REMOTE_MBOX_PRIO 10000
116 #define MU_SMTP_PRIO 10000
117 #define MU_SENDMAIL_PRIO 10000
117 118
118 /* SMTP mailer, "smtp://" */ 119 /* SMTP mailer, "smtp://" */
119 extern mu_record_t mu_smtp_record; 120 extern mu_record_t mu_smtp_record;
......
...@@ -34,6 +34,7 @@ enum { ...@@ -34,6 +34,7 @@ enum {
34 OPT_NO_USER_RCFILE, 34 OPT_NO_USER_RCFILE,
35 OPT_NO_SITE_RCFILE, 35 OPT_NO_SITE_RCFILE,
36 OPT_RCFILE, 36 OPT_RCFILE,
37 OPT_RCFILE_LINT,
37 OPT_RCFILE_VERBOSE, 38 OPT_RCFILE_VERBOSE,
38 OPT_LOG_FACILITY, 39 OPT_LOG_FACILITY,
39 OPT_LOCK_FLAGS, 40 OPT_LOCK_FLAGS,
...@@ -41,7 +42,8 @@ enum { ...@@ -41,7 +42,8 @@ enum {
41 OPT_LOCK_RETRY_TIMEOUT, 42 OPT_LOCK_RETRY_TIMEOUT,
42 OPT_LOCK_EXPIRE_TIMEOUT, 43 OPT_LOCK_EXPIRE_TIMEOUT,
43 OPT_LOCK_EXTERNAL_PROGRAM, 44 OPT_LOCK_EXTERNAL_PROGRAM,
44 OPT_LICENSE, 45 OPT_LICENSE,
46 OPT_MAILBOX_PATTERN,
45 OPT_MAILBOX_TYPE, 47 OPT_MAILBOX_TYPE,
46 OPT_DEBUG_LEVEL, 48 OPT_DEBUG_LEVEL,
47 OPT_LINE_INFO, 49 OPT_LINE_INFO,
...@@ -63,6 +65,8 @@ static struct argp_option mu_common_argp_options[] = ...@@ -63,6 +65,8 @@ static struct argp_option mu_common_argp_options[] =
63 N_("Load this configuration file"), 0, }, 65 N_("Load this configuration file"), 0, },
64 { "rcfile-verbose", OPT_RCFILE_VERBOSE, NULL, 0, 66 { "rcfile-verbose", OPT_RCFILE_VERBOSE, NULL, 0,
65 N_("Verbosely log parsing of the configuration files"), 0 }, 67 N_("Verbosely log parsing of the configuration files"), 0 },
68 { "rcfile-lint", OPT_RCFILE_LINT, NULL, 0,
69 N_("Check configuration file syntax and exit"), 0 },
66 { NULL, 0, NULL, 0, NULL, 0 } 70 { NULL, 0, NULL, 0, NULL, 0 }
67 }; 71 };
68 72
...@@ -87,6 +91,11 @@ mu_common_argp_parser (int key, char *arg, struct argp_state *state) ...@@ -87,6 +91,11 @@ mu_common_argp_parser (int key, char *arg, struct argp_state *state)
87 mu_load_rcfile = arg; 91 mu_load_rcfile = arg;
88 break; 92 break;
89 93
94 case OPT_RCFILE_LINT:
95 mu_cfg_parser_verbose++;
96 mu_rcfile_lint = 1;
97 break;
98
90 case OPT_RCFILE_VERBOSE: 99 case OPT_RCFILE_VERBOSE:
91 mu_cfg_parser_verbose++; 100 mu_cfg_parser_verbose++;
92 break; 101 break;
...@@ -222,6 +231,8 @@ struct mu_cmdline_capa mu_license_cmdline = { ...@@ -222,6 +231,8 @@ struct mu_cmdline_capa mu_license_cmdline = {
222 static struct argp_option mu_mailbox_argp_option[] = { 231 static struct argp_option mu_mailbox_argp_option[] = {
223 { "mail-spool", 'm', N_("URL"), OPTION_HIDDEN, 232 { "mail-spool", 'm', N_("URL"), OPTION_HIDDEN,
224 N_("Use specified URL as a mailspool directory"), 0 }, 233 N_("Use specified URL as a mailspool directory"), 0 },
234 { "mailbox-pattern", OPT_MAILBOX_PATTERN, N_("pat"), OPTION_HIDDEN,
235 "", 0 },
225 { "mailbox-type", OPT_MAILBOX_TYPE, N_("PROTO"), OPTION_HIDDEN, 236 { "mailbox-type", OPT_MAILBOX_TYPE, N_("PROTO"), OPTION_HIDDEN,
226 N_("Default mailbox type to use"), 0 }, 237 N_("Default mailbox type to use"), 0 },
227 { NULL } 238 { NULL }
...@@ -239,6 +250,10 @@ mu_mailbox_argp_parser (int key, char *arg, struct argp_state *state) ...@@ -239,6 +250,10 @@ mu_mailbox_argp_parser (int key, char *arg, struct argp_state *state)
239 mu_argp_node_list_new (&lst, "mail-spool", arg); 250 mu_argp_node_list_new (&lst, "mail-spool", arg);
240 break; 251 break;
241 252
253 case OPT_MAILBOX_PATTERN:
254 mu_argp_node_list_new (&lst, "mailbox-pattern", arg);
255 break;
256
242 case OPT_MAILBOX_TYPE: 257 case OPT_MAILBOX_TYPE:
243 mu_argp_node_list_new (&lst, "mailbox-type", arg); 258 mu_argp_node_list_new (&lst, "mailbox-type", arg);
244 break; 259 break;
......
...@@ -49,6 +49,7 @@ get_canonical_name () ...@@ -49,6 +49,7 @@ get_canonical_name ()
49 } 49 }
50 50
51 int mu_help_config_mode; 51 int mu_help_config_mode;
52 int mu_rcfile_lint;
52 53
53 int 54 int
54 mu_app_init (struct argp *myargp, const char **capa, 55 mu_app_init (struct argp *myargp, const char **capa,
...@@ -115,7 +116,9 @@ mu_app_init (struct argp *myargp, const char **capa, ...@@ -115,7 +116,9 @@ mu_app_init (struct argp *myargp, const char **capa,
115 cfgflags |= MU_PARSE_CONFIG_DUMP; 116 cfgflags |= MU_PARSE_CONFIG_DUMP;
116 rc = mu_cfg_tree_reduce (mu_argp_tree, mu_program_name, cfg_param, 117 rc = mu_cfg_tree_reduce (mu_argp_tree, mu_program_name, cfg_param,
117 cfgflags, data); 118 cfgflags, data);
118 119 if (mu_rcfile_lint)
120 exit ((rc || mu_cfg_error_count) ? 1 : 0);
121
119 mu_gocs_flush (); 122 mu_gocs_flush ();
120 mu_cfg_destroy_tree (&mu_argp_tree); 123 mu_cfg_destroy_tree (&mu_argp_tree);
121 124
......
...@@ -43,6 +43,10 @@ static struct mu_cfg_param mu_mailbox_param[] = { ...@@ -43,6 +43,10 @@ static struct mu_cfg_param mu_mailbox_param[] = {
43 { "mail-spool", mu_cfg_string, &mailbox_settings.mail_spool, 0, NULL, 43 { "mail-spool", mu_cfg_string, &mailbox_settings.mail_spool, 0, NULL,
44 N_("Use specified URL as a mailspool directory."), 44 N_("Use specified URL as a mailspool directory."),
45 N_("url") }, 45 N_("url") },
46 { "mailbox-pattern", mu_cfg_string, &mailbox_settings.mailbox_pattern,
47 0, NULL,
48 N_("Create mailbox URL using <pattern>."),
49 N_("pattern") },
46 { "mailbox-type", mu_cfg_string, &mailbox_settings.mailbox_type, 0, NULL, 50 { "mailbox-type", mu_cfg_string, &mailbox_settings.mailbox_type, 0, NULL,
47 N_("Default mailbox type."), N_("protocol") }, 51 N_("Default mailbox type."), N_("protocol") },
48 { NULL } 52 { NULL }
......
...@@ -106,16 +106,34 @@ mu_scm_is_mailbox (SCM scm) ...@@ -106,16 +106,34 @@ mu_scm_is_mailbox (SCM scm)
106 106
107 SCM_DEFINE (scm_mu_mail_directory, "mu-mail-directory", 0, 1, 0, 107 SCM_DEFINE (scm_mu_mail_directory, "mu-mail-directory", 0, 1, 0,
108 (SCM URL), 108 (SCM URL),
109 "If URL is given, sets it as a name of the user's mail directory.\n" 109 "Do not use this function. Use mu-user-mailbox-url instead.")
110 "Returns the current value of the mail directory.")
111 #define FUNC_NAME s_scm_mu_mail_directory 110 #define FUNC_NAME s_scm_mu_mail_directory
112 { 111 {
113 if (!SCM_UNBNDP (URL)) 112 mu_scm_error (FUNC_NAME, ENOSYS,
114 { 113 "This function is deprecated. Use mu-user-mailbox-url instead.",
115 SCM_ASSERT (scm_is_string (URL), URL, SCM_ARG1, FUNC_NAME); 114 scm_list_1 (URL));
116 mu_set_mail_directory (scm_i_string_chars (URL)); 115 return SCM_EOL;
117 } 116 }
118 return scm_makfrom0str (mu_mail_directory ()); 117 #undef FUNC_NAME
118
119 SCM_DEFINE (scm_mu_user_mailbox_url, "mu-user-mailbox-url", 1, 0, 0,
120 (SCM USER),
121 "")
122 #define FUNC_NAME s_scm_mu_user_mailbox_url
123 {
124 int rc;
125 char *p;
126 SCM ret;
127
128 SCM_ASSERT (scm_is_string (USER), USER, SCM_ARG1, FUNC_NAME);
129 rc = mu_construct_user_mailbox_url (&p, scm_i_string_chars (USER));
130 if (rc)
131 mu_scm_error (FUNC_NAME, rc,
132 "Cannot construct mailbox URL for ~A",
133 scm_list_1 (USER));
134 ret = scm_makfrom0str (p);
135 free (p);
136 return ret;
119 } 137 }
120 #undef FUNC_NAME 138 #undef FUNC_NAME
121 139
......
...@@ -17,5 +17,5 @@ ...@@ -17,5 +17,5 @@
17 ## Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 17 ## Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA
18 ## 02110-1301 USA 18 ## 02110-1301 USA
19 19
20 SUBDIRS = include mbox pop nntp imap mh maildir mailer 20 SUBDIRS = include mbox pop nntp imap mh maildir mailer remote
21 21
......
...@@ -114,8 +114,7 @@ static int folder_mbox_close (mu_folder_t); ...@@ -114,8 +114,7 @@ static int folder_mbox_close (mu_folder_t);
114 static int folder_mbox_delete (mu_folder_t, const char *); 114 static int folder_mbox_delete (mu_folder_t, const char *);
115 static int folder_mbox_rename (mu_folder_t , const char *, const char *); 115 static int folder_mbox_rename (mu_folder_t , const char *, const char *);
116 static int folder_mbox_list (mu_folder_t, const char *, const char *, 116 static int folder_mbox_list (mu_folder_t, const char *, const char *,
117 size_t, 117 size_t, mu_list_t);
118 mu_list_t);
119 static int folder_mbox_subscribe (mu_folder_t, const char *); 118 static int folder_mbox_subscribe (mu_folder_t, const char *);
120 static int folder_mbox_unsubscribe (mu_folder_t, const char *); 119 static int folder_mbox_unsubscribe (mu_folder_t, const char *);
121 static int folder_mbox_lsub (mu_folder_t, const char *, const char *, 120 static int folder_mbox_lsub (mu_folder_t, const char *, const char *,
...@@ -380,9 +379,9 @@ list_helper (struct search_data *data, ...@@ -380,9 +379,9 @@ list_helper (struct search_data *data,
380 return status; 379 return status;
381 } 380 }
382 381
383 /* The listing is not recursif and we use glob() some expansion for us. 382 /* The listing is not recursive and we use glob() some expansion for us.
384 Unfortunately glob() does not expand the '~'. We also return 383 Unfortunately glob() does not expand the '~'. We also return
385 The full pathname so it can be use to create other folders. */ 384 the full pathname so it can be use to create other folders. */
386 static int 385 static int
387 folder_mbox_list (mu_folder_t folder, const char *dirname, const char *pattern, 386 folder_mbox_list (mu_folder_t folder, const char *dirname, const char *pattern,
388 size_t max_level, 387 size_t max_level,
......
...@@ -178,7 +178,7 @@ _url_mbox_init (mu_url_t url) ...@@ -178,7 +178,7 @@ _url_mbox_init (mu_url_t url)
178 178
179 /* reject the obvious */ 179 /* reject the obvious */
180 if (name == NULL || strncmp (MU_MBOX_SCHEME, name, MU_MBOX_SCHEME_LEN) != 0 180 if (name == NULL || strncmp (MU_MBOX_SCHEME, name, MU_MBOX_SCHEME_LEN) != 0
181 || len < (MU_MBOX_SCHEME_LEN + 1) /* (scheme)+1(path)*/) 181 || len < (MU_MBOX_SCHEME_LEN + 1) /* (scheme)+1+(path)*/)
182 return EINVAL; 182 return EINVAL;
183 183
184 /* do I need to decode url encoding '% hex hex' ? */ 184 /* do I need to decode url encoding '% hex hex' ? */
......
1 *.la
2 *.lo
3 .deps
4 .libs
5 Makefile
6 Makefile.in
7 T
8 _*
9 .gdbinit
1 ## Process this file with GNU Automake to create Makefile.in
2
3 ## Copyright (C) 2007 Free Software Foundation, Inc.
4 ##
5 ## GNU Mailutils is free software; you can redistribute it and/or
6 ## modify it under the terms of the GNU General Public License as
7 ## published by the Free Software Foundation; either version 3, or (at
8 ## your option) any later version.
9 ##
10 ## This program is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program; if not, write to the Free Software
17 ## Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA
18 ## 02110-1301 USA
19
20 INCLUDES = @MU_COMMON_INCLUDES@ -I${top_srcdir}/libproto/include
21
22 lib_LTLIBRARIES = libmu_remotembox.la
23 libmu_remotembox_la_LDFLAGS=-version-info @VI_CURRENT@:@VI_REVISION@:@VI_AGE@
24 libmu_remotembox_la_LIBADD = ${MU_LIB_MAILUTILS} ${MU_LIB_MAILER}
25 libmu_remotembox_la_SOURCES = \
26 folder.c\
27 mbox.c
28
29
1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 2007 Free Software Foundation, Inc.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 3 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General
15 Public License along with this library; if not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301 USA */
18
19 #ifdef HAVE_CONFIG_H
20 #include <config.h>
21 #endif
22
23 #include <stdlib.h>
24 #include <string.h>
25 #include <mailutils/errno.h>
26 #include <mailutils/error.h>
27 #include <mailutils/url.h>
28 #include <mailbox0.h>
29 #include <url0.h>
30 #include <folder0.h>
31 #include <registrar0.h>
32
33 #define MU_REMOTE_MBOX_PREFIX "remote+"
34 #define MU_REMOTE_MBOX_PREFIX_LEN (sizeof (MU_REMOTE_MBOX_PREFIX) - 1)
35
36 extern int remote_mbox_init (mu_mailbox_t mailbox);
37
38 int
39 remote_url_init (mu_url_t url)
40 {
41 const char *name = mu_url_to_string (url);
42 const char *p;
43 size_t len = strlen (name);
44 int rc;
45
46 if (!name)
47 return 0;
48 /* reject the obvious */
49 if (name == NULL
50 || len < MU_REMOTE_MBOX_PREFIX_LEN
51 || strncmp (MU_REMOTE_MBOX_PREFIX, name, MU_REMOTE_MBOX_PREFIX_LEN) != 0)
52 return EINVAL;
53
54 rc = mu_registrar_lookup (name + MU_REMOTE_MBOX_PREFIX_LEN, 0, NULL, NULL);
55 if (rc)
56 return rc;
57
58 p = strchr (name, ':');
59 if (!p)
60 return EINVAL;
61 p++;
62
63 len = p - name;
64 url->scheme = malloc (len + 1);
65 if (!url->scheme)
66 return ENOMEM;
67 memcpy (url->scheme, name, len);
68 url->scheme[len] = 0;
69
70 return 0;
71 }
72
73 static int
74 remote_folder_init (mu_folder_t folder MU_ARG_UNUSED)
75 {
76 return 0;
77 }
78
79 static struct _mu_record _remote_mbox_record =
80 {
81 MU_REMOTE_MBOX_PRIO,
82 MU_REMOTE_MBOX_PREFIX,
83 remote_url_init, /* Mailbox init. */
84 remote_mbox_init, /* Mailbox init. */
85 NULL, /* Mailer init. */
86 remote_folder_init, /* Folder init. */
87 NULL, /* No need for back pointer. */
88 NULL, /* _is_scheme method. */
89 NULL, /* _get_url method. */
90 NULL, /* _get_mailbox method. */
91 NULL, /* _get_mailer method. */
92 NULL /* _get_folder method. */
93 };
94 mu_record_t mu_remote_mbox_record = &_remote_mbox_record;
1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 2007 Free Software Foundation, Inc.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 3 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General
15 Public License along with this library; if not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301 USA */
18
19 #ifdef HAVE_CONFIG_H
20 #include <config.h>
21 #endif
22
23 #include <stdlib.h>
24 #include <string.h>
25 #include <mailutils/address.h>
26 #include <mailutils/debug.h>
27 #include <mailutils/errno.h>
28 #include <mailutils/error.h>
29 #include <mailutils/property.h>
30 #include <mailutils/mailer.h>
31 #include <mailutils/url.h>
32 #include <mailbox0.h>
33
34 struct remote_mbox_data
35 {
36 mu_mailer_t mailer;
37 };
38
39 static void
40 remote_mbox_destroy (mu_mailbox_t mailbox)
41 {
42 if (mailbox->data)
43 {
44 struct remote_mbox_data *dat = mailbox->data;
45 mu_mailer_destroy (&dat->mailer);
46 free (dat);
47 mailbox->data = NULL;
48 }
49 }
50
51 static int
52 remote_mbox_open (mu_mailbox_t mbox, int flags)
53 {
54 struct remote_mbox_data *dat = mbox->data;
55 int status;
56 int mflags = 0;
57 mu_log_level_t lev = 0;
58
59 if (!dat->mailer)
60 return EINVAL;
61
62 mu_debug_get_level (mbox->debug, &lev);
63 if (lev & MU_DEBUG_TRACE7)
64 mflags = MAILER_FLAG_DEBUG_DATA;
65 status = mu_mailer_open (dat->mailer, mflags);
66 if (status)
67 {
68 MU_DEBUG1 (mbox->debug, MU_DEBUG_ERROR,
69 "cannot open mailer: %s\n", mu_strerror (status));
70 return status;
71 }
72 if (lev & MU_DEBUG_INHERIT)
73 {
74 mu_debug_t debug;
75 if (mu_mailer_get_debug (dat->mailer, &debug) == 0)
76 mu_debug_set_level (debug, lev);
77 }
78 mbox->flags = flags;
79 return 0;
80 }
81
82 static int
83 remote_mbox_close (mu_mailbox_t mbox)
84 {
85 struct remote_mbox_data *dat = mbox->data;
86 int status;
87
88 MU_DEBUG (mbox->debug, MU_DEBUG_TRACE1, "remote_mbox_close\n");
89 status = mu_mailer_close (dat->mailer);
90 if (status)
91 MU_DEBUG1 (mbox->debug, MU_DEBUG_ERROR, "closing mailer failed: %s\n",
92 mu_strerror (status));
93 return status;
94 }
95
96 static int
97 mkaddr (mu_mailbox_t mbox, mu_property_t property,
98 const char *key, mu_address_t *addr)
99 {
100 const char *str = NULL;
101 mu_property_sget_value (property, key, &str);
102 if (str && *str)
103 {
104 int status = mu_address_create (addr, str);
105 if (status)
106 {
107 MU_DEBUG3 (mbox->debug, MU_DEBUG_ERROR,
108 "%s: %s mu_address_create failed: %s\n",
109 str, key, mu_strerror (status));
110 return status;
111 }
112 }
113 else
114 *addr = NULL;
115 return 0;
116 }
117
118
119 static int
120 remote_mbox_append_message (mu_mailbox_t mbox, mu_message_t msg)
121 {
122 struct remote_mbox_data *dat = mbox->data;
123 int status;
124 mu_property_t property = NULL;
125 mu_address_t from, to;
126
127 if (!dat->mailer)
128 return EINVAL;
129
130 status = mu_mailbox_get_property (mbox, &property);
131 if (status)
132 MU_DEBUG1 (mbox->debug, MU_DEBUG_ERROR, "failed to get property: %s\n",
133 mu_strerror (status));
134
135 mkaddr (mbox, property, "FROM", &from);
136 mkaddr (mbox, property, "TO", &to);
137
138 status = mu_mailer_send_message (dat->mailer, msg, from, to);
139
140 if (status)
141 MU_DEBUG1 (mbox->debug, MU_DEBUG_ERROR,
142 "Sending message failed: %s\n", mu_strerror (status));
143 return status;
144 }
145
146 static int
147 remote_mbox_scan (mu_mailbox_t mbox, size_t offset, size_t *pcount)
148 {
149 if (pcount)
150 *pcount = 0;
151 return 0;
152 }
153
154 static int
155 remote_get_size (mu_mailbox_t mbox, mu_off_t *psize)
156 {
157 if (psize)
158 *psize = 0;
159 return 0;
160 }
161
162 static int
163 remote_sync (mu_mailbox_t mbox)
164 {
165 return 0;
166 }
167
168 int
169 remote_mbox_init (mu_mailbox_t mailbox)
170 {
171 struct remote_mbox_data *dat;
172 const char *s, *p;
173 int rc;
174 mu_mailer_t mailer;
175
176 if (mailbox == NULL)
177 return EINVAL;
178
179 s = mu_url_to_string (mailbox->url);
180 if (rc)
181 {
182 MU_DEBUG1 (mailbox->debug, MU_DEBUG_ERROR,
183 "remote_mbox_init: cannot get url: %s\n", mu_strerror (rc));
184 return rc;
185 }
186
187 MU_DEBUG1 (mailbox->debug, MU_DEBUG_TRACE1, "remote_mbox_init (%s)\n", s);
188
189 p = strchr (s, '+');
190 if (!p)
191 {
192 MU_DEBUG2 (mailbox->debug, MU_DEBUG_ERROR,
193 "remote_mbox_init(%s): invalid url: %s\n", s,
194 mu_strerror (rc));
195 return MU_ERR_MAILER_BAD_URL;
196 }
197 p++;
198 rc = mu_mailer_create (&mailer, p);
199 if (rc)
200 {
201 MU_DEBUG2 (mailbox->debug, MU_DEBUG_ERROR,
202 "remote_mbox_init(%s): cannot create mailer: %s\n",
203 s, mu_strerror (rc));
204 return rc;
205 }
206
207 dat = mailbox->data = calloc (1, sizeof (*dat));
208 if (dat == NULL)
209 {
210 mu_mailer_destroy (&mailer);
211 return ENOMEM;
212 }
213 dat->mailer = mailer;
214
215 mailbox->_destroy = remote_mbox_destroy;
216 mailbox->_open = remote_mbox_open;
217 mailbox->_close = remote_mbox_close;
218 mailbox->_append_message = remote_mbox_append_message;
219 mailbox->_scan = remote_mbox_scan;
220 mailbox->_get_size = remote_get_size;
221 mailbox->_sync = remote_sync;
222
223 return 0;
224 }
225
...@@ -41,6 +41,7 @@ maidag_LDADD = \ ...@@ -41,6 +41,7 @@ maidag_LDADD = \
41 ${MU_LIB_MAILDIR}\ 41 ${MU_LIB_MAILDIR}\
42 ${MU_LIB_AUTH}\ 42 ${MU_LIB_AUTH}\
43 ${MU_LIB_MAILER}\ 43 ${MU_LIB_MAILER}\
44 ${MU_LIB_REMOTE}\
44 @MU_AUTHLIBS@\ 45 @MU_AUTHLIBS@\
45 ${MU_LIB_MAILUTILS} \ 46 ${MU_LIB_MAILUTILS} \
46 @MU_COMMON_LIBRARIES@\ 47 @MU_COMMON_LIBRARIES@\
......
...@@ -449,13 +449,13 @@ main (int argc, char *argv[]) ...@@ -449,13 +449,13 @@ main (int argc, char *argv[])
449 /* Register needed modules */ 449 /* Register needed modules */
450 MU_AUTH_REGISTER_ALL_MODULES (); 450 MU_AUTH_REGISTER_ALL_MODULES ();
451 451
452 /* Register mailbox formats */ 452 /* Register all supported mailbox and mailer formats */
453 mu_register_all_formats (); 453 mu_register_all_formats ();
454
455 /* Register the supported mailers. */
456 mu_registrar_record (mu_sendmail_record);
457 mu_registrar_record (mu_smtp_record); 454 mu_registrar_record (mu_smtp_record);
458 455
456 /* Register a special mailbox */
457 mu_registrar_record (mu_remote_mbox_record);
458
459 mu_gocs_register ("sieve", mu_sieve_module_init); 459 mu_gocs_register ("sieve", mu_sieve_module_init);
460 460
461 mu_gocs_daemon = daemon_param; 461 mu_gocs_daemon = daemon_param;
......
...@@ -36,6 +36,7 @@ int mu_cfg_parser_verbose; ...@@ -36,6 +36,7 @@ int mu_cfg_parser_verbose;
36 static mu_cfg_node_t *parse_tree; 36 static mu_cfg_node_t *parse_tree;
37 mu_cfg_locus_t mu_cfg_locus; 37 mu_cfg_locus_t mu_cfg_locus;
38 int mu_cfg_tie_in; 38 int mu_cfg_tie_in;
39 size_t mu_cfg_error_count;
39 40
40 static int _mu_cfg_errcnt; 41 static int _mu_cfg_errcnt;
41 static mu_cfg_lexer_t _mu_cfg_lexer; 42 static mu_cfg_lexer_t _mu_cfg_lexer;
...@@ -100,6 +101,7 @@ mu_cfg_format_error (mu_debug_t debug, size_t level, const char *fmt, ...) ...@@ -100,6 +101,7 @@ mu_cfg_format_error (mu_debug_t debug, size_t level, const char *fmt, ...)
100 mu_debug_vprintf (debug, 0, fmt, ap); 101 mu_debug_vprintf (debug, 0, fmt, ap);
101 mu_debug_printf (debug, 0, "\n"); 102 mu_debug_printf (debug, 0, "\n");
102 va_end (ap); 103 va_end (ap);
104 mu_cfg_error_count++;
103 } 105 }
104 106
105 static void 107 static void
...@@ -114,6 +116,7 @@ _mu_cfg_vperror (mu_debug_t debug, const mu_cfg_locus_t *loc, ...@@ -114,6 +116,7 @@ _mu_cfg_vperror (mu_debug_t debug, const mu_cfg_locus_t *loc,
114 mu_debug_vprintf (debug, 0, fmt, ap); 116 mu_debug_vprintf (debug, 0, fmt, ap);
115 mu_debug_printf (debug, 0, "\n"); 117 mu_debug_printf (debug, 0, "\n");
116 mu_debug_set_locus (debug, NULL, 0); 118 mu_debug_set_locus (debug, NULL, 0);
119 mu_cfg_error_count++;
117 } 120 }
118 121
119 static void 122 static void
......
...@@ -252,7 +252,7 @@ mu_debug_check_level (mu_debug_t debug, mu_log_level_t level) ...@@ -252,7 +252,7 @@ mu_debug_check_level (mu_debug_t debug, mu_log_level_t level)
252 { 252 {
253 if (!debug) 253 if (!debug)
254 return 0; 254 return 0;
255 return debug->level & MU_DEBUG_LEVEL_MASK (level); 255 return debug->level & level;
256 } 256 }
257 257
258 int 258 int
......
...@@ -61,7 +61,15 @@ mu_gocs_mailbox_init (void *data) ...@@ -61,7 +61,15 @@ mu_gocs_mailbox_init (void *data)
61 free (p->mail_spool); 61 free (p->mail_spool);
62 p->mail_spool = NULL; 62 p->mail_spool = NULL;
63 } 63 }
64 64 if (p->mailbox_pattern)
65 {
66 rc = mu_set_mailbox_pattern (p->mailbox_pattern);
67 if (rc)
68 mu_error (_("Cannot set mailbox pattern to `%s': %s"),
69 p->mailbox_pattern, mu_strerror (rc));
70 free (p->mailbox_pattern);
71 p->mailbox_pattern = NULL;
72 }
65 if (p->mailbox_type) 73 if (p->mailbox_type)
66 { 74 {
67 if (mu_mailbox_set_default_proto (p->mailbox_type)) 75 if (mu_mailbox_set_default_proto (p->mailbox_type))
......
...@@ -137,19 +137,21 @@ _create_mailbox (mu_mailbox_t *pmbox, const char *name) ...@@ -137,19 +137,21 @@ _create_mailbox (mu_mailbox_t *pmbox, const char *name)
137 if (status != 0) 137 if (status != 0)
138 mu_mailbox_destroy (&mbox); 138 mu_mailbox_destroy (&mbox);
139 else 139 else
140 *pmbox = mbox;
141
142 level = mu_global_debug_level ("mailbox");
143 if (level)
144 { 140 {
145 int status = mu_debug_create (&mbox->debug, mbox); 141 *pmbox = mbox;
146 if (status) 142
147 return 0; /* FIXME: don't want to bail out just because I 143 level = mu_global_debug_level ("mailbox");
148 failed to create a *debug* object. But maybe 144 if (level)
149 I'm wrong... */ 145 {
150 mu_debug_set_level (mbox->debug, level); 146 int status = mu_debug_create (&mbox->debug, mbox);
151 if (level & MU_DEBUG_INHERIT) 147 if (status)
152 mu_folder_set_debug (mbox->folder, mbox->debug); 148 return 0; /* FIXME: don't want to bail out just because I
149 failed to create a *debug* object. But I may
150 be wrong... */
151 mu_debug_set_level (mbox->debug, level);
152 if (level & MU_DEBUG_INHERIT)
153 mu_folder_set_debug (mbox->folder, mbox->debug);
154 }
153 } 155 }
154 156
155 return status; 157 return status;
......
...@@ -37,18 +37,61 @@ ...@@ -37,18 +37,61 @@
37 #include <mailutils/error.h> 37 #include <mailutils/error.h>
38 #include <mailutils/errno.h> 38 #include <mailutils/errno.h>
39 #include <mailutils/mu_auth.h> 39 #include <mailutils/mu_auth.h>
40 #include <mailutils/vartab.h>
41
42 static char *_mu_mailbox_pattern;
40 43
41 static char *_default_mail_dir = MU_PATH_MAILDIR;
42 static char *_mu_mail_dir;
43 static char *_default_folder_dir = "Mail"; 44 static char *_default_folder_dir = "Mail";
44 static char *_mu_folder_dir; 45 static char *_mu_folder_dir;
45 46
47 static int
48 mu_normalize_mailbox_url (char **pout, const char *dir)
49 {
50 int len;
51 int addslash = 0;
52 #define USERSUFFIX "${user}"
53
54 if (!pout)
55 return MU_ERR_OUT_PTR_NULL;
56
57 len = strlen (dir);
58 if (strncasecmp (dir, "mbox:", 5) == 0 && dir[len-1] == '=')
59 {
60 if (len > 5 && strcmp (dir + len - 5, "user=") == 0)
61 *pout = strdup (dir);
62 else
63 return MU_ERR_BAD_FILENAME;
64 }
65 else if (dir[len-1] != '/')
66 addslash = 1;
67
68 *pout = malloc (strlen (dir) + (addslash ? 1 : 0) + sizeof USERSUFFIX);
69 if (!*pout)
70 return ENOMEM;
71
72 strcpy (*pout, dir);
73 if (addslash)
74 strcat (*pout, "/");
75 strcat (*pout, USERSUFFIX);
76 #undef USERSUFFIX
77 return 0;
78 }
79
46 int 80 int
47 mu_set_mail_directory (const char *p) 81 mu_set_mail_directory (const char *p)
48 { 82 {
49 if (_mu_mail_dir != _default_mail_dir) 83 if (_mu_mailbox_pattern)
50 free (_mu_mail_dir); 84 free (_mu_mailbox_pattern);
51 return mu_normalize_mailbox_url (&_mu_mail_dir, p); 85 return mu_normalize_mailbox_url (&_mu_mailbox_pattern, p);
86 }
87
88 int
89 mu_set_mailbox_pattern (const char *pat)
90 {
91 if (_mu_mailbox_pattern)
92 free (_mu_mailbox_pattern);
93 _mu_mailbox_pattern = strdup (pat);
94 return _mu_mailbox_pattern ? 0 : ENOMEM;
52 } 95 }
53 96
54 void 97 void
...@@ -60,11 +103,11 @@ mu_set_folder_directory (const char *p) ...@@ -60,11 +103,11 @@ mu_set_folder_directory (const char *p)
60 } 103 }
61 104
62 const char * 105 const char *
63 mu_mail_directory () 106 mu_mailbox_url ()
64 { 107 {
65 if (!_mu_mail_dir) 108 if (!_mu_mailbox_pattern)
66 _mu_mail_dir = _default_mail_dir; 109 mu_set_mail_directory (MU_PATH_MAILDIR);
67 return _mu_mail_dir; 110 return _mu_mailbox_pattern;
68 } 111 }
69 112
70 const char * 113 const char *
...@@ -78,12 +121,15 @@ mu_folder_directory () ...@@ -78,12 +121,15 @@ mu_folder_directory ()
78 int 121 int
79 mu_construct_user_mailbox_url (char **pout, const char *name) 122 mu_construct_user_mailbox_url (char **pout, const char *name)
80 { 123 {
81 const char *p = mu_mail_directory (); 124 int rc;
82 *pout = malloc (strlen (p) + strlen (name) + 1); 125 const char *pat = mu_mailbox_url ();
83 if (!*pout) 126 mu_vartab_t vtab;
84 return errno; 127
85 strcat (strcpy (*pout, p), name); 128 mu_vartab_create (&vtab);
86 return 0; 129 mu_vartab_define (vtab, "user", name, 1);
130 rc = mu_vartab_expand (vtab, pat, pout);
131 mu_vartab_destroy (&vtab);
132 return rc;
87 } 133 }
88 134
89 /* Is this a security risk? */ 135 /* Is this a security risk? */
...@@ -177,16 +223,6 @@ get_homedir (const char *user) ...@@ -177,16 +223,6 @@ get_homedir (const char *user)
177 static int 223 static int
178 user_mailbox_name (const char *user, char **mailbox_name) 224 user_mailbox_name (const char *user, char **mailbox_name)
179 { 225 {
180 char *p;
181 const char *url = mu_mail_directory ();
182
183 p = strchr (url, ':');
184 if (p && strncmp (url, "mbox", p - url))
185 {
186 *mailbox_name = strdup (url);
187 return 0;
188 }
189
190 #ifdef USE_ENVIRON 226 #ifdef USE_ENVIRON
191 if (!user) 227 if (!user)
192 user = (getenv ("LOGNAME")) ? getenv ("LOGNAME") : getenv ("USER"); 228 user = (getenv ("LOGNAME")) ? getenv ("LOGNAME") : getenv ("USER");
...@@ -204,7 +240,7 @@ user_mailbox_name (const char *user, char **mailbox_name) ...@@ -204,7 +240,7 @@ user_mailbox_name (const char *user, char **mailbox_name)
204 240
205 if (!auth) 241 if (!auth)
206 { 242 {
207 mu_error ("Who am I ?\n"); 243 mu_error ("Who am I?");
208 return EINVAL; 244 return EINVAL;
209 } 245 }
210 *mailbox_name = strdup (auth->mailbox); 246 *mailbox_name = strdup (auth->mailbox);
......
...@@ -552,35 +552,6 @@ mu_normalize_path (char *path, const char *delim) ...@@ -552,35 +552,6 @@ mu_normalize_path (char *path, const char *delim)
552 return path; 552 return path;
553 } 553 }
554 554
555 int
556 mu_normalize_mailbox_url (char **pout, const char *dir)
557 {
558 int len;
559
560 if (!pout)
561 return MU_ERR_OUT_PTR_NULL;
562
563 len = strlen (dir);
564 if (dir[len-1] == '/')
565 *pout = strdup (dir);
566 else if (strncasecmp (dir, "mbox:", 5) == 0 && dir[len-1] == '=')
567 {
568 if (len > 5 && strcmp (dir + len - 5, "user=") == 0)
569 *pout = strdup (dir);
570 else
571 return MU_ERR_BAD_FILENAME;
572 }
573 else
574 {
575 *pout = malloc (strlen (dir) + 2);
576 if (*pout)
577 strcat (strcpy (*pout, dir), "/");
578 }
579
580 /* Final check */
581 return (*pout == NULL) ? errno : 0;
582 }
583
584 /* Create and open a temporary file. Be very careful about it, since we 555 /* Create and open a temporary file. Be very careful about it, since we
585 may be running with extra privilege i.e setgid(). 556 may be running with extra privilege i.e setgid().
586 Returns file descriptor of the open file. 557 Returns file descriptor of the open file.
......
...@@ -118,15 +118,6 @@ mu_registrar_lookup (const char *name, int flags, ...@@ -118,15 +118,6 @@ mu_registrar_lookup (const char *name, int flags,
118 return status; 118 return status;
119 } 119 }
120 120
121 /* For compatibility with earlier versions */
122 int
123 mu_0_6_registrar_lookup (const char *name, mu_record_t *precord, int flags)
124 {
125 int status = mu_registrar_lookup (name, flags, precord, &flags);
126 return (status == 0) ? flags : 0;
127 }
128
129
130 static int 121 static int
131 _compare_prio (const void *item, const void *value) 122 _compare_prio (const void *item, const void *value)
132 { 123 {
......