(mu_normalize_maildir) New function.
Makes sure the mailbox specification either is a pathname ending with '/', or matches regexp 'mbox:.*user='.
Showing
1 changed file
with
21 additions
and
0 deletions
... | @@ -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 | ... | ... |
-
Please register or sign in to post a comment