Commit 583dce7c 583dce7c015747fb690545eb29121592e2496476 by Sergey Poznyakoff

(mu_normalize_maildir) New function.

Makes sure the mailbox specification either is a
pathname ending with '/', or matches regexp 'mbox:.*user='.
1 parent a12d1c64
......@@ -508,3 +508,24 @@ mu_normalize_path (char *path, const char *delim)
return path;
}
char *
mu_normalize_maildir (const char *dir)
{
int len = strlen (dir);
if (dir[len-1] == '/')
return strdup (dir);
else if (strncasecmp (dir, "mbox:", 5) == 0 && dir[len-1] == '=')
{
if (len > 5 && strcmp (dir + len - 5, "user=") == 0)
return strdup (dir);
else
return NULL;
}
else
{
char *p = malloc (strlen (dir) + 2);
strcat (strcpy (p, dir), "/");
return p;
}
}
......