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) ...@@ -508,3 +508,24 @@ mu_normalize_path (char *path, const char *delim)
508 return path; 508 return path;
509 } 509 }
510 510
511 char *
512 mu_normalize_maildir (const char *dir)
513 {
514 int len = strlen (dir);
515 if (dir[len-1] == '/')
516 return strdup (dir);
517 else if (strncasecmp (dir, "mbox:", 5) == 0 && dir[len-1] == '=')
518 {
519 if (len > 5 && strcmp (dir + len - 5, "user=") == 0)
520 return strdup (dir);
521 else
522 return NULL;
523 }
524 else
525 {
526 char *p = malloc (strlen (dir) + 2);
527 strcat (strcpy (p, dir), "/");
528 return p;
529 }
530 }
531
......