diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-12-28 15:27:43 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-12-28 15:27:43 +0000 |
commit | 36868ac9ddc6b4e521913858b04ace62d8edfa5a (patch) | |
tree | 1eddc5d77090130ea7d23eb6d679b403496a6ac0 | |
parent | 7b123e22274933f402814d3c4e4c146a13ccffb6 (diff) | |
download | mailutils-36868ac9ddc6b4e521913858b04ace62d8edfa5a.tar.gz mailutils-36868ac9ddc6b4e521913858b04ace62d8edfa5a.tar.bz2 |
Additional mailbox URL parameters `type', `user' and `param' can
appear in any local URLs.
* TODO, NEWS: Update.
* examples/url-parse.c: Print field/value pairs.
* include/mailutils/argcv.h (MU_ARGCV_RETURN_DELIMS): New macro.
(mu_argcv_get_np): New function.
(mu_argcv_remove): New function.
* include/mailutils/mutil.h (mu_scheme_autodetect_p): Change
prototype.
* include/mailutils/registrar.h (mu_registrar_lookup_url): New
function.
(struct _mu_record._is_scheme): Change signature.
* include/mailutils/url.h (mu_url_sget_fvpairs)
(mu_url_aget_fvpairs): New functions.
(mu_url_expand_path): New function.
* libproto/imap/folder.c (folder_imap_list): Fix signature.
* libproto/nntp/folder.c (nntp_folder_list): Fix signature.
* libproto/include/amd.h (amd_url_init): Remove.
* libproto/include/registrar0.h: Fix scheme defines.
* libproto/include/url0.h (struct _mu_url.fvpairs,fvcount): New
members.
* libproto/maildir/folder.c (_maildir_is_scheme): Change
signature.
(_maildir_url_init): Remove
(_maildir_record): Remove url_init.
* libproto/mbox/folder.c (_path_record): Remove url_init.
(_mbox_record): Use mu_url_expand_path as url_init.
(_path_is_scheme): Change signature.
* libproto/mh/folder.c (_mh_is_scheme): Change signature.
(_mh_url_init): Remove.
(_mh_record): Use mu_url_expand_path as url_init.
* libproto/mbox/Makefile.am (libmu_mbox_la_SOURCES): Remove url.c
* libproto/mbox/url.c: Remove.
* mail/mail.h, mail/util.c (util_url_to_string): New function.
* mail/quit.c, mail/summary.c: Use util_url_to_string where
appropriate.
* mailbox/amd.c (amd_url_destroy, amd_url_init): Remove.
* mailbox/argcv.c (mu_argcv_get_np): New function.
(argcv_scan): Change signature. All callers updated.
(argcv_get_n): Rewrite using argcv_get_np.
(mu_argcv_remove): New function.
* mailbox/file_stream.c (struct _prog_stream.argc): Fix data type.
* mailbox/folder.c (mu_folder_create_from_record): URL initializer
is optional.
* mailbox/gdebug.c (mu_global_debug_from_string): Fix datatype of
argc.
* mailbox/mailbox.c (mailbox_folder_create): Rewrite.
(_create_mailbox): Split off _create_mailbox0 function.
Make URL initializer optional.
* mailbox/mutil.c (mu_scheme_autodetect_p): Rewrite.
* mailbox/registrar.c (mu_registrar_lookup_url): New function.
(mu_registrar_lookup): Rewrite using mu_registrar_lookup_url.
(mu_record_is_scheme,mu_record_set_is_scheme): Change signature.
* mailbox/url.c (mu_url_destroy): Destroy fvpairs.
(url_parse0): Use scheme "file" for URLs beginning with a /.
Parse parameters.
(mu_url_sget_fvpairs, mu_url_aget_fvpairs): New functions.
(mu_url_expand_path): New function.
* mailbox/testsuite/Urls: Update.
* pop3d/bulletin.c (set_bulletin_db,set_bulletin_source): Allocate
string storage.
(read_bulletin_db): Return 0 if no record was found.
(get_last_delivered_num): Return error code.
(deliver_pending_bulletins): Rewrite.
* pop3d/capa.c (pop3d_capa): Bugfix.
36 files changed, 850 insertions, 616 deletions
@@ -1,3 +1,77 @@ +2007-12-28 Sergey Poznyakoff <gray@gnu.org.ua> + + Additional mailbox URL parameters `type', `user' and `param' can + appear in any local URLs. + + * TODO, NEWS: Update. + + * examples/url-parse.c: Print field/value pairs. + * include/mailutils/argcv.h (MU_ARGCV_RETURN_DELIMS): New macro. + (mu_argcv_get_np): New function. + (mu_argcv_remove): New function. + * include/mailutils/mutil.h (mu_scheme_autodetect_p): Change + prototype. + * include/mailutils/registrar.h (mu_registrar_lookup_url): New + function. + (struct _mu_record._is_scheme): Change signature. + * include/mailutils/url.h (mu_url_sget_fvpairs) + (mu_url_aget_fvpairs): New functions. + (mu_url_expand_path): New function. + + * libproto/imap/folder.c (folder_imap_list): Fix signature. + * libproto/nntp/folder.c (nntp_folder_list): Fix signature. + * libproto/include/amd.h (amd_url_init): Remove. + * libproto/include/registrar0.h: Fix scheme defines. + * libproto/include/url0.h (struct _mu_url.fvpairs,fvcount): New + members. + * libproto/maildir/folder.c (_maildir_is_scheme): Change + signature. + (_maildir_url_init): Remove + (_maildir_record): Remove url_init. + * libproto/mbox/folder.c (_path_record): Remove url_init. + (_mbox_record): Use mu_url_expand_path as url_init. + (_path_is_scheme): Change signature. + * libproto/mh/folder.c (_mh_is_scheme): Change signature. + (_mh_url_init): Remove. + (_mh_record): Use mu_url_expand_path as url_init. + * libproto/mbox/Makefile.am (libmu_mbox_la_SOURCES): Remove url.c + * libproto/mbox/url.c: Remove. + + * mail/mail.h, mail/util.c (util_url_to_string): New function. + * mail/quit.c, mail/summary.c: Use util_url_to_string where + appropriate. + * mailbox/amd.c (amd_url_destroy, amd_url_init): Remove. + * mailbox/argcv.c (mu_argcv_get_np): New function. + (argcv_scan): Change signature. All callers updated. + (argcv_get_n): Rewrite using argcv_get_np. + (mu_argcv_remove): New function. + + * mailbox/file_stream.c (struct _prog_stream.argc): Fix data type. + * mailbox/folder.c (mu_folder_create_from_record): URL initializer + is optional. + * mailbox/gdebug.c (mu_global_debug_from_string): Fix datatype of + argc. + * mailbox/mailbox.c (mailbox_folder_create): Rewrite. + (_create_mailbox): Split off _create_mailbox0 function. + Make URL initializer optional. + * mailbox/mutil.c (mu_scheme_autodetect_p): Rewrite. + * mailbox/registrar.c (mu_registrar_lookup_url): New function. + (mu_registrar_lookup): Rewrite using mu_registrar_lookup_url. + (mu_record_is_scheme,mu_record_set_is_scheme): Change signature. + * mailbox/url.c (mu_url_destroy): Destroy fvpairs. + (url_parse0): Use scheme "file" for URLs beginning with a /. + Parse parameters. + (mu_url_sget_fvpairs, mu_url_aget_fvpairs): New functions. + (mu_url_expand_path): New function. + * mailbox/testsuite/Urls: Update. + + * pop3d/bulletin.c (set_bulletin_db,set_bulletin_source): Allocate + string storage. + (read_bulletin_db): Return 0 if no record was found. + (get_last_delivered_num): Return error code. + (deliver_pending_bulletins): Rewrite. + * pop3d/capa.c (pop3d_capa): Bugfix. + 2007-12-21 Sergey Poznyakoff <gray@gnu.org.ua> * examples/lsf.c: Use mu_folder_enumerate + callback function, for @@ -1,4 +1,4 @@ -GNU mailutils NEWS -- history of user-visible changes. 2007-12-19 +GNU mailutils NEWS -- history of user-visible changes. 2007-12-28 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. See the end of file for copying conditions. @@ -26,6 +26,11 @@ The programs using configuration file facility also understand the output the detailed description of configuration file statements that affect the given program. +** URL parameters. + +Additional mailbox URL parameters `type', `user' and `param' can +appear in any local URLs. + ** New utility `maidag' Maidag is a MAIl Delivery AGent. It is a general-purpose MDA able to @@ -185,6 +190,9 @@ extern int mu_url_aget_path (const mu_url_t, char **); extern int mu_url_sget_query (const mu_url_t, const char **); extern int mu_url_aget_query (const mu_url_t, char **); +int mu_url_sget_fvpairs (const mu_url_t, size_t *, char ***); +int mu_url_aget_fvpairs (const mu_url_t, size_t *, char ***); + ** ACL A set of functions implements general-purpose access control lists. @@ -227,6 +235,29 @@ that can be done over them is mu_mailbox_append_message. E.g., appending to the URL `remote+smtp://127.0.0.1:24' is equivalent to sending a message using mailer `smtp://127.0.0.1:24'. +** New argcv functions. + +- int mu_argcv_get_np (const char *command, int len, + const char *delim, const char *cmnt, + int flags, + int *pargc, char ***pargv, char **endp); + +This function is an alternative entry point to +mu_argcv_get/mu_argcv_get_n functions. The resulting argv will contain +non-whitespace delimiters only if flags contains the bit +MU_ARGCV_RETURN_DELIMS. + +- void mu_argcv_remove (int *pargc, char ***pargv, + int (*sel) (const char *, void *), void *); + +Removes from pargc/pargv all elements for which the sel function +returns true. + +** New registry functions. + +- int mu_registrar_lookup_url (mu_url_t url, int flags, + mu_record_t *precord, int *pflags); + ** Fixed parsing of URLs similar to file:///a/b. It is parsed as an absolute file name `/a/b'. @@ -1,7 +1,9 @@ -GNU mailutils TODO list. 2007-12-07 +GNU mailutils TODO list. 2007-12-28 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. +* Fix folder_imap_list in libproto/imap/folder.c + * Documentation * Review the code and use mu_vartab_* and mu_kwd_* functions where diff --git a/examples/url-parse.c b/examples/url-parse.c index 2d10adecc..cc3e037a1 100644 --- a/examples/url-parse.c +++ b/examples/url-parse.c @@ -39,6 +39,22 @@ } \ printf ("\t" #field " <%s>\n", buf) +static void +print_fvpairs (mu_url_t url) +{ + size_t fvc, i; + char **fvp; + int rc = mu_url_sget_fvpairs (url, &fvc, &fvp); + if (rc) + { + mu_error ("cannot get F/V pairs: %s", mu_strerror (rc)); + exit (1); + } + if (fvc == 0) + return; + for (i = 0; i < fvc; i++) + printf ("\tparam[%d] <%s>\n", i, fvp[i]); +} int main () @@ -84,6 +100,7 @@ main () printf ("\tport %ld\n", port); GET_AND_PRINT (path, u, buf, rc); + print_fvpairs (u); GET_AND_PRINT (query, u, buf, rc); mu_url_destroy (&u); diff --git a/include/mailutils/argcv.h b/include/mailutils/argcv.h index a880f05c3..bbae929f9 100644 --- a/include/mailutils/argcv.h +++ b/include/mailutils/argcv.h @@ -28,12 +28,18 @@ extern "C" { #endif +#define MU_ARGCV_RETURN_DELIMS 0x01 + extern int mu_argcv_get (const char *command, const char *delim, const char* cmnt, int *argc, char ***argv); extern int mu_argcv_get_n (const char *command, int len, const char *delim, const char *cmnt, int *argc, char ***argv); +extern int mu_argcv_get_np (const char *command, int len, + const char *delim, const char *cmnt, + int flags, + int *pargc, char ***pargv, char **endp); extern int mu_argcv_string (int argc, char **argv, char **string); extern int mu_argcv_free (int argc, char **argv); @@ -42,6 +48,8 @@ extern int mu_argcv_quote_char (int c); extern size_t mu_argcv_quoted_length (const char *str, int *quote); extern void mu_argcv_unquote_copy (char *dst, const char *src, size_t n); extern void mu_argcv_quote_copy (char *dst, const char *src); +extern void mu_argcv_remove (int *pargc, char ***pargv, + int (*sel) (const char *, void *), void *); #ifdef __cplusplus } diff --git a/include/mailutils/mutil.h b/include/mailutils/mutil.h index 6802de8cf..16765aee0 100644 --- a/include/mailutils/mutil.h +++ b/include/mailutils/mutil.h @@ -128,7 +128,7 @@ extern int mu_unre_subject (const char *subject, const char **new_subject); extern char *mu_charset_lookup (char *lang, char *terr); extern int mu_true_answer_p (const char *p); -extern int mu_scheme_autodetect_p (const char *scheme, const char **path); +extern int mu_scheme_autodetect_p (mu_url_t); struct timeval; diff --git a/include/mailutils/registrar.h b/include/mailutils/registrar.h index 03836b85e..ecc904d32 100644 --- a/include/mailutils/registrar.h +++ b/include/mailutils/registrar.h @@ -38,7 +38,7 @@ struct _mu_record void *data; /* back pointer. */ /* Stub functions to override. The default is to return the fields. */ - int (*_is_scheme) (mu_record_t, const char *, int); + int (*_is_scheme) (mu_record_t, mu_url_t, int); int (*_get_url) (mu_record_t, int (*(*_mu_url)) (mu_url_t)); int (*_get_mailbox) (mu_record_t, int (*(*_mu_mailbox)) (mu_mailbox_t)); int (*_get_mailer) (mu_record_t, int (*(*_mu_mailer)) (mu_mailer_t)); @@ -51,14 +51,16 @@ extern int mu_registrar_get_list (mu_list_t *) __attribute__ ((deprecated)); extern int mu_registrar_lookup (const char *name, int flags, mu_record_t *precord, int *pflags); +extern int mu_registrar_lookup_url (mu_url_t url, int flags, + mu_record_t *precord, int *pflags); extern int mu_registrar_record (mu_record_t); extern int mu_unregistrar_record (mu_record_t); /* Scheme. */ -extern int mu_record_is_scheme (mu_record_t, const char *, int flags); +extern int mu_record_is_scheme (mu_record_t, mu_url_t, int flags); extern int mu_record_set_scheme (mu_record_t, const char *); extern int mu_record_set_is_scheme (mu_record_t, - int (*_is_scheme) (mu_record_t, const char *, int)); + int (*_is_scheme) (mu_record_t, mu_url_t, int)); /* Url. */ extern int mu_record_get_url (mu_record_t, int (*(*)) (mu_url_t)); diff --git a/include/mailutils/url.h b/include/mailutils/url.h index 69985f175..52a42264a 100644 --- a/include/mailutils/url.h +++ b/include/mailutils/url.h @@ -59,9 +59,13 @@ extern int mu_url_get_query (const mu_url_t, char *, size_t, size_t *); extern int mu_url_get_port (const mu_url_t, long *); +int mu_url_sget_fvpairs (const mu_url_t url, size_t *fvc, char ***fvp); +int mu_url_aget_fvpairs (const mu_url_t url, size_t *pfvc, char ***pfvp); + +extern int mu_url_expand_path (mu_url_t url); extern const char *mu_url_to_string (const mu_url_t); -extern int mu_url_is_scheme (mu_url_t, const char* scheme); +extern int mu_url_is_scheme (mu_url_t, const char *scheme); extern int mu_url_is_same_scheme (mu_url_t, mu_url_t); extern int mu_url_is_same_user (mu_url_t, mu_url_t); @@ -69,11 +73,11 @@ extern int mu_url_is_same_path (mu_url_t, mu_url_t); extern int mu_url_is_same_host (mu_url_t, mu_url_t); extern int mu_url_is_same_port (mu_url_t, mu_url_t); -extern char* mu_url_decode (const char *s); +extern char *mu_url_decode (const char *s); extern int mu_url_is_ticket (mu_url_t ticket, mu_url_t url); extern int mu_url_init (mu_url_t url, int port, const char *scheme); - + #ifdef __cplusplus } #endif diff --git a/lib/.cvsignore b/lib/.cvsignore index 494fca35f..b01887cc1 100644 --- a/lib/.cvsignore +++ b/lib/.cvsignore @@ -143,6 +143,8 @@ streq.h strerror.c string.h string.in.h +strings.h +strings.in.h stripslash.c strncasecmp.c strndup.c diff --git a/libproto/imap/folder.c b/libproto/imap/folder.c index 815b4ecfe..d718a4d3d 100644 --- a/libproto/imap/folder.c +++ b/libproto/imap/folder.c @@ -112,7 +112,7 @@ static int folder_imap_close (mu_folder_t); static void folder_imap_destroy (mu_folder_t); static int folder_imap_delete (mu_folder_t, const char *); static int folder_imap_list (mu_folder_t, const char *, void *, - size_t, + int, size_t, mu_list_t, mu_folder_enumerate_fp efp, void *edp); static int folder_imap_lsub (mu_folder_t, const char *, const char *, @@ -975,9 +975,10 @@ glob_to_imap (const char *pat, int recursive) return ret; } +/* FIXME: Flags unused */ static int folder_imap_list (mu_folder_t folder, const char *ref, void *name, - size_t max_level, + int flags, size_t max_level, mu_list_t flist, mu_folder_enumerate_fp efp, void *edp) { diff --git a/libproto/include/amd.h b/libproto/include/amd.h index 505b48df6..3c9c5ab94 100644 --- a/libproto/include/amd.h +++ b/libproto/include/amd.h @@ -99,7 +99,6 @@ int _amd_message_insert (struct _amd_data *mhd, struct _amd_message *msg); int amd_message_stream_open (struct _amd_message *mhm); void amd_message_stream_close (struct _amd_message *mhm); void amd_cleanup (void *arg); -int amd_url_init (mu_url_t url, const char *scheme); struct _amd_message *_amd_get_message (struct _amd_data *amd, size_t msgno); int amd_msg_lookup (struct _amd_data *amd, struct _amd_message *msg, size_t *pret); diff --git a/libproto/include/registrar0.h b/libproto/include/registrar0.h index 571c8a5fb..13d114cf8 100644 --- a/libproto/include/registrar0.h +++ b/libproto/include/registrar0.h @@ -36,62 +36,60 @@ extern "C" { Perhaps they can be changed? */ #define MU_POP_PORT 110 -#define MU_POP_SCHEME "pop://" +#define MU_POP_SCHEME "pop" #define MU_POP_SCHEME_LEN (sizeof (MU_POP_SCHEME) - 1) extern int _url_pop_init (mu_url_t); extern int _mailbox_pop_init (mu_mailbox_t); extern int _folder_pop_init (mu_folder_t); #define MU_POPS_PORT 995 -#define MU_POPS_SCHEME "pops://" +#define MU_POPS_SCHEME "pops" #define MU_POPS_SCHEME_LEN (sizeof (MU_POPS_SCHEME) - 1) extern int _url_pops_init (mu_url_t); extern int _mailbox_pops_init (mu_mailbox_t); #define MU_IMAP_PORT 143 -#define MU_IMAP_SCHEME "imap://" +#define MU_IMAP_SCHEME "imap" #define MU_IMAP_SCHEME_LEN (sizeof (MU_IMAP_SCHEME) - 1) extern int _url_imap_init (mu_url_t); extern int _mailbox_imap_init (mu_mailbox_t); extern int _folder_imap_init (mu_folder_t); #define MU_IMAPS_PORT 993 -#define MU_IMAPS_SCHEME "imaps://" +#define MU_IMAPS_SCHEME "imaps" #define MU_IMAPS_SCHEME_LEN (sizeof (MU_IMAPS_SCHEME) - 1) extern int _url_imaps_init (mu_url_t); extern int _mailbox_imaps_init (mu_mailbox_t); -#define MU_MBOX_SCHEME "mbox:" +#define MU_MBOX_SCHEME "mbox" #define MU_MBOX_SCHEME_LEN (sizeof (MU_MBOX_SCHEME) - 1) -extern int _url_mbox_init (mu_url_t); extern int _mailbox_mbox_init (mu_mailbox_t); extern int _folder_mbox_init (mu_folder_t); -#define MU_FILE_SCHEME "file:" +#define MU_FILE_SCHEME "file" #define MU_FILE_SCHEME_LEN (sizeof (MU_FILE_SCHEME) - 1) #define MU_PATH_SCHEME "/" #define MU_PATH_SCHEME_LEN (sizeof (MU_PATH_SCHEME) - 1) -extern int _url_path_init (mu_url_t); extern int _mailbox_path_init (mu_mailbox_t); extern int _folder_path_init (mu_folder_t); -#define MU_SMTP_SCHEME "smtp://" +#define MU_SMTP_SCHEME "smtp" #define MU_SMTP_SCHEME_LEN (sizeof (MU_SMTP_SCHEME) - 1) #define MU_SMTP_PORT 25 extern int _url_smtp_init (mu_url_t); extern int _mailer_smtp_init (mu_mailer_t); -#define MU_SENDMAIL_SCHEME "sendmail:" +#define MU_SENDMAIL_SCHEME "sendmail" #define MU_SENDMAIL_SCHEME_LEN (sizeof (MU_SENDMAIL_SCHEME) - 1) extern int _url_sendmail_init (mu_url_t); extern int _mailer_sendmail_init (mu_mailer_t); -#define MU_MH_SCHEME "mh:" +#define MU_MH_SCHEME "mh" #define MU_MH_SCHEME_LEN (sizeof (MU_MH_SCHEME) - 1) extern int _mailbox_mh_init (mu_mailbox_t mailbox); -#define MU_MAILDIR_SCHEME "maildir:" +#define MU_MAILDIR_SCHEME "maildir" #define MU_MAILDIR_SCHEME_LEN (sizeof (MU_MAILDIR_SCHEME) - 1) extern int _mailbox_maildir_init (mu_mailbox_t mailbox); diff --git a/libproto/include/url0.h b/libproto/include/url0.h index f4cc8af81..a2485e4e0 100644 --- a/libproto/include/url0.h +++ b/libproto/include/url0.h @@ -40,9 +40,10 @@ struct _mu_url char *host; long port; char *path; + char **fvpairs; + int fvcount; char *query; - void *data; void (*_destroy) (mu_url_t url); diff --git a/libproto/maildir/folder.c b/libproto/maildir/folder.c index 3fe14d76e..cc91b32d8 100644 --- a/libproto/maildir/folder.c +++ b/libproto/maildir/folder.c @@ -33,6 +33,7 @@ #include <maildir.h> #include <mailutils/mutil.h> +#include <mailutils/url.h> #include <amd.h> static int @@ -56,22 +57,21 @@ dir_exists (const char *name, const char *suf) } static int -_maildir_is_scheme (mu_record_t record, const char *url, int flags) +_maildir_is_scheme (mu_record_t record, mu_url_t url, int flags) { - const char *path; - - if (!url || !record->scheme) - return 0; - - if (strncmp (record->scheme, url, strlen (record->scheme)) == 0) + if (mu_url_is_scheme (url, record->scheme)) return MU_FOLDER_ATTRIBUTE_ALL & flags; - if (mu_scheme_autodetect_p (url, &path)) + if (mu_scheme_autodetect_p (url)) { /* Attemp auto-detection */ + const char *path; struct stat st; int rc = 0; + if (mu_url_sget_path (url, &path)) + return 0; + if (stat (path, &st) < 0) return 0; @@ -89,21 +89,11 @@ _maildir_is_scheme (mu_record_t record, const char *url, int flags) return 0; } -/* - MAILDIR url - maildir:path -*/ -int -_maildir_url_init (mu_url_t url) -{ - return amd_url_init (url, MU_MAILDIR_SCHEME); -} - static struct _mu_record _maildir_record = { MU_MAILDIR_PRIO, MU_MAILDIR_SCHEME, - _maildir_url_init, /* Url init. */ + mu_url_expand_path, /* Url init. */ _mailbox_maildir_init, /* Mailbox init. */ NULL, /* Mailer init. */ _maildir_folder_init, /* Folder init. */ diff --git a/libproto/mbox/Makefile.am b/libproto/mbox/Makefile.am index 48a7fd2ef..8bc7290d2 100644 --- a/libproto/mbox/Makefile.am +++ b/libproto/mbox/Makefile.am @@ -26,6 +26,5 @@ libmu_mbox_la_SOURCES = \ folder.c\ mbox.c\ mboxscan.c\ - mbox0.h\ - url.c + mbox0.h diff --git a/libproto/mbox/folder.c b/libproto/mbox/folder.c index 7e8354949..cf23178f3 100644 --- a/libproto/mbox/folder.c +++ b/libproto/mbox/folder.c @@ -50,7 +50,7 @@ static struct _mu_record _mbox_record = { MU_MBOX_PRIO, MU_MBOX_SCHEME, - _url_mbox_init, /* Mailbox init. */ + mu_url_expand_path, /* URL init. */ _mailbox_mbox_init, /* Mailbox init. */ NULL, /* Mailer init. */ _folder_mbox_init, /* Folder init. */ @@ -64,19 +64,18 @@ static struct _mu_record _mbox_record = mu_record_t mu_mbox_record = &_mbox_record; static int -_path_is_scheme (mu_record_t record, const char *url, int flags) +_path_is_scheme (mu_record_t record, mu_url_t url, int flags) { int rc = 0; - const char *path; if (url && record->scheme) { - if (mu_scheme_autodetect_p (url, &path)) - /* implies: - if (strncmp (record->scheme, url, strlen(record->scheme)) == 0) */ + if (mu_scheme_autodetect_p (url)) { struct stat st; - + const char *path; + + mu_url_sget_path (url, &path); if (stat (path, &st) < 0) { if (errno == ENOENT) @@ -92,6 +91,10 @@ _path_is_scheme (mu_record_t record, const char *url, int flags) } else if (flags & MU_FOLDER_ATTRIBUTE_FILE) { +#if 0 + /* This effectively sieves out all non-mailbox files, + but it makes mu_folder_enumerate crawl, which is + intolerable for imap4d LIST command. */ int fd = open (path, O_RDONLY); if (fd != -1) { @@ -101,6 +104,9 @@ _path_is_scheme (mu_record_t record, const char *url, int flags) rc |= MU_FOLDER_ATTRIBUTE_FILE; close (fd); } +#else + rc |= MU_FOLDER_ATTRIBUTE_FILE; +#endif } } @@ -116,7 +122,7 @@ static struct _mu_record _path_record = { MU_PATH_PRIO, MU_PATH_SCHEME, - _url_path_init, /* Mailbox init. */ + NULL, /* URL init. */ _mailbox_mbox_init, /* Mailbox init. */ NULL, /* Mailer init. */ _folder_mbox_init, /* Folder init. */ diff --git a/libproto/mbox/url.c b/libproto/mbox/url.c deleted file mode 100644 index 6841e13a2..000000000 --- a/libproto/mbox/url.c +++ /dev/null @@ -1,301 +0,0 @@ -/* GNU Mailutils -- a suite of utilities for electronic mail - Copyright (C) 1999, 2000, 2003, 2007 Free Software Foundation, Inc. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301 USA */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#include <errno.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#ifdef HAVE_STRINGS_H -# include <strings.h> -#endif - -#include <registrar0.h> -#include <url0.h> -#include <mailutils/errno.h> -#include <mailutils/mutil.h> - -static void url_mbox_destroy (mu_url_t purl); - -static void -url_mbox_destroy (mu_url_t url MU_ARG_UNUSED) -{ -} - -/* Default mailbox path generator */ -static char * -_url_path_default (const char *spooldir, const char *user, int unused) -{ - char *mbox = malloc (sizeof(spooldir) + strlen(user) + 2); - if (!mbox) - errno = ENOMEM; - else - sprintf (mbox, "%s/%s", spooldir, user); - return mbox; -} - -/* Hashed indexing */ -static char * -_url_path_hashed (const char *spooldir, const char *user, int param) -{ - int i; - int ulen = strlen (user); - char *mbox; - unsigned hash; - - if (param > ulen) - param = ulen; - for (i = 0, hash = 0; i < param; i++) - hash += user[i]; - - mbox = malloc (ulen + strlen (spooldir) + 5); - sprintf (mbox, "%s/%02X/%s", spooldir, hash % 256, user); - return mbox; -} - -static int transtab[] = { - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', - 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', - 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', - 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', - 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', - 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', - 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', - 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', - 'm', 'a', 'b', 'c', 'd', 'e', 'f', 'g', - 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', - 'x', 'y', 'z', 'b', 'c', 'd', 'e', 'f', - 'g', 'a', 'b', 'c', 'd', 'e', 'f', 'g', - 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', - 'x', 'y', 'z', 'b', 'c', 'd', 'e', 'f', - 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', - 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', - 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', - 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', - 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', - 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', - 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', - 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', - 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', - 'y', 'z', 'b', 'c', 'd', 'e', 'f', 'g', - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', - 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', - 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', |