Index: folder_mbox.c =================================================================== RCS file: /cvs/mailutils/mailbox/folder_mbox.c,v retrieving revision 1.8 diff -u -r1.8 folder_mbox.c --- folder_mbox.c 2001/04/20 04:32:53 1.8 +++ folder_mbox.c 2001/05/10 04:25:02 @@ -32,6 +32,17 @@ #include #include +static int _mbox_path_is_scheme(record_t r, const char* p) +{ + if(strchr(p, ':')) + { + return 0; + } + /* If it doesn't have a ':', then it's not a url, so it's a path! */ + + return 1; +} + /* We export url parsing and the initialisation of the mailbox, via the register entry/record. */ @@ -75,7 +86,7 @@ NULL, /* Mailer init. */ _folder_mbox_init, /* Folder init. */ NULL, /* No need for an owner. */ - NULL, /* is_scheme method. */ + _mbox_path_is_scheme, /* is_scheme method. */ NULL, /* get_url method. */ NULL, /* get_mailbox method. */ NULL, /* get_mailer method. */ Index: url_path.c =================================================================== RCS file: /cvs/mailutils/mailbox/url_path.c,v retrieving revision 1.2 diff -u -r1.2 url_path.c --- url_path.c 2000/12/13 05:06:45 1.2 +++ url_path.c 2001/05/10 04:25:02 @@ -34,6 +34,34 @@ (void)url; } +static char* home_dir(const char* name) +{ + char* home = strdup(getenv("HOME") ? getenv("HOME") : "/home"); + + if(!home) + return NULL; + + /* strip trailing '/' */ + if(home[strlen(home) - 1] == '/') + home[strlen(home) - 1] = 0; + + if(name[1] != '/') + { + /* it's not our home, pull home back to the parent dir. */ + char* p = strrchr(home, '/'); + if(p == home) + { + /* home was "/dir", so use /home */ + free(home); + return strdup("/home/"); + } + p[1] = 0; + return home; + } + /* else it is our home */ + return home; +} + int _url_path_init (url_t url) { @@ -56,7 +84,50 @@ } /* PATH */ - url->path = strdup (name); + /* Do + and = expansion to ~/Mail, if necessary. */ + if(name[0] == '+' || name[0] == '=') + { + char* home = home_dir("~/Mail"); + + if(home) + { + const char* n = name + 1; + + url->path = + malloc(strlen(home) + + strlen("/Mail/") + + strlen(n) + 1); + + if(url->path) + sprintf(url->path, "%s/Mail/%s", home, n); + + free(home); + } + } + + /* Do ~ expansion to home directories, if necessary. */ + else if(name[0] == '~') + { + char* home = home_dir(name); + + if(home) + { + const char* n = name + 1; + + url->path = malloc(strlen(home) + strlen(n) + 1); + + if(url->path) + sprintf(url->path, "%s%s", home, n); + + free(home); + } + } + + if(url->path == NULL) { + /* just use the name and hope for the best */ + url->path = strdup (name); + } + if (url->path == NULL) { url_path_destroy (url);