| 60 | | url_ciss_tostring (&url, host, sizeof (host), 0); |
| 61 | | |
| 62 | | dprint (3, (debugfile, "bcache: host: '%s'\n", host)); |
| 63 | | |
| 64 | | /* |
| 65 | | * replace all '/' in proto://host part to '_' so the hierarchy |
| 66 | | * doesn't get too deeply nested |
| 67 | | * XXX imaps:__joe@example.com@imap.example.com doesn't look nice |
| 68 | | * |
| 69 | | * ('*(s+1)' since url_ciss_tostring() appends '/' after host part |
| 70 | | * which we want to keep) |
| 71 | | */ |
| 72 | | for (s = host; s && *s && *(s+1) ; s++) |
| 73 | | if (*s == '/') |
| 74 | | *s = '_'; |
| 75 | | |
| 76 | | /* |
| 77 | | * not enough space is the only error I can think of |
| 78 | | * (dstlen-1 for '/'-termination, see below) |
| 79 | | */ |
| 80 | | if (snprintf (dst, dstlen-1, "%s/%s%s", MessageCachedir, |
| 81 | | host, NONULL(mailbox)) <= 0) |
| 82 | | return -1; |
| 83 | | |
| 84 | | /* make sure to '/'-terminate the path as we assume that elsewhere */ |
| 85 | | len = mutt_strlen (dst); |
| 86 | | if (len <= dstlen+2 && dst[len-1] != '/') |
| 87 | | { |
| 88 | | dst[len++] = '/'; |
| 89 | | dst[len] = '\0'; |
| 90 | | } |
| 91 | | |
| 92 | | dprint (3, (debugfile, "bcache: directory: '%s'\n", dst)); |
| | 60 | if (url_ciss_tostring (&url, host, sizeof (host), 0) < 0) |
| | 61 | { |
| | 62 | dprint (1, (debugfile, "bcache_path: URL to string failed\n")); |
| | 63 | return -1; |
| | 64 | } |
| | 65 | |
| | 66 | dprint (3, (debugfile, "bcache_path: URL: '%s'\n", host)); |
| | 67 | |
| | 68 | /* transform URL scheme:// to scheme: */ |
| | 69 | for (s = p = host; *s; s++) |
| | 70 | /* keep trailing slash */ |
| | 71 | if (*s != '/' || *(s + 1) == '\0') |
| | 72 | *p++ = *s; |
| | 73 | *p = '\0'; |
| | 74 | |
| | 75 | len = snprintf (dst, dstlen-1, "%s/%s%s%s", MessageCachedir, |
| | 76 | host, NONULL(mailbox), |
| | 77 | (mailbox && *mailbox && |
| | 78 | mailbox[mutt_strlen(mailbox) - 1] == '/') ? "" : "/"); |
| | 79 | if (len < 0 || len >= dstlen-1) |
| | 80 | return -1; |
| | 81 | |
| | 82 | dprint (3, (debugfile, "bcache_path: directory: '%s'\n", dst)); |