summaryrefslogtreecommitdiffstats
path: root/imap
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>2000-09-04 10:49:46 +0000
committerThomas Roessler <roessler@does-not-exist.org>2000-09-04 10:49:46 +0000
commit643690a1274d0598ee973b272c934bb147e6cda4 (patch)
tree441d9f1613dd75bd8dc460fc2b247bd1a4246190 /imap
parent3b9b910c6db2443ea544613578e1a604b38b6071 (diff)
patch-bac.imapurl-4
Diffstat (limited to 'imap')
-rw-r--r--imap/browse.c10
-rw-r--r--imap/imap.c4
-rw-r--r--imap/imap.h2
-rw-r--r--imap/imap_private.h1
-rw-r--r--imap/util.c69
5 files changed, 32 insertions, 54 deletions
diff --git a/imap/browse.c b/imap/browse.c
index cfd77c79..cf7c4bc5 100644
--- a/imap/browse.c
+++ b/imap/browse.c
@@ -133,7 +133,7 @@ int imap_browse (char* path, struct browser_state* state)
/* don't show parents in the home namespace */
if (!home_namespace)
showparents = 1;
- imap_qualify_path (buf, sizeof (buf), &mx, mbox, NULL);
+ imap_qualify_path (buf, sizeof (buf), &mx, mbox);
state->folder = safe_strdup (buf);
n--;
}
@@ -165,7 +165,7 @@ int imap_browse (char* path, struct browser_state* state)
mbox[n++] = ctmp;
ctmp = mbox[n];
mbox[n] = '\0';
- imap_qualify_path (buf, sizeof (buf), &mx, mbox, NULL);
+ imap_qualify_path (buf, sizeof (buf), &mx, mbox);
state->folder = safe_strdup (buf);
}
mbox[n] = ctmp;
@@ -180,7 +180,7 @@ int imap_browse (char* path, struct browser_state* state)
imap_add_folder (idata->delim, relpath, 1, 0, state, 1);
if (!state->folder)
{
- imap_qualify_path (buf, sizeof (buf), &mx, relpath, NULL);
+ imap_qualify_path (buf, sizeof (buf), &mx, relpath);
state->folder = safe_strdup (buf);
}
}
@@ -189,7 +189,7 @@ int imap_browse (char* path, struct browser_state* state)
/* no namespace, no folder: set folder to host only */
if (!state->folder)
{
- imap_qualify_path (buf, sizeof (buf), &mx, NULL, NULL);
+ imap_qualify_path (buf, sizeof (buf), &mx, NULL);
state->folder = safe_strdup (buf);
}
@@ -362,7 +362,7 @@ static void imap_add_folder (char delim, char *folder, int noselect,
return;
}
- imap_qualify_path (tmp, sizeof (tmp), &mx, folder, NULL);
+ imap_qualify_path (tmp, sizeof (tmp), &mx, folder);
(state->entry)[state->entrylen].name = safe_strdup (tmp);
/* mark desc with delim in browser if it can have subfolders */
diff --git a/imap/imap.c b/imap/imap.c
index 21da0e59..32399722 100644
--- a/imap/imap.c
+++ b/imap/imap.c
@@ -484,7 +484,7 @@ int imap_open_mailbox (CONTEXT* ctx)
imap_fix_path (idata, mx.mbox, buf, sizeof (buf));
FREE(&(idata->mailbox));
idata->mailbox = safe_strdup (buf);
- imap_qualify_path (buf, sizeof (buf), &mx, idata->mailbox, NULL);
+ imap_qualify_path (buf, sizeof (buf), &mx, idata->mailbox);
FREE (&(ctx->path));
ctx->path = safe_strdup (buf);
@@ -1330,7 +1330,7 @@ int imap_complete(char* dest, size_t dlen, char* path) {
if (completions)
{
/* reformat output */
- imap_qualify_path (dest, dlen, &mx, completion, NULL);
+ imap_qualify_path (dest, dlen, &mx, completion);
mutt_pretty_mailbox (dest);
FREE (&mx.mbox);
diff --git a/imap/imap.h b/imap/imap.h
index 1e26941e..a89ba032 100644
--- a/imap/imap.h
+++ b/imap/imap.h
@@ -60,8 +60,6 @@ void imap_logout_all (void);
/* util.c */
int imap_parse_path (const char* path, IMAP_MBOX* mx);
-void imap_qualify_path (char* dest, size_t len, const IMAP_MBOX* mx,
- const char* path, const char* name);
int imap_wait_keepalive (pid_t pid);
void imap_keepalive (void);
diff --git a/imap/imap_private.h b/imap/imap_private.h
index 0c980925..5e2bac23 100644
--- a/imap/imap_private.h
+++ b/imap/imap_private.h
@@ -207,6 +207,7 @@ char* imap_fix_path (IMAP_DATA* idata, char* mailbox, char* path,
int imap_get_literal_count (const char* buf, long* bytes);
char* imap_get_qualifier (char* buf);
char* imap_next_word (char* s);
+void imap_qualify_path (char *dest, size_t len, IMAP_MBOX *mx, char* path);
void imap_quote_string (char* dest, size_t slen, const char* src);
void imap_unquote_string (char* s);
void imap_munge_mbox_name (char *dest, size_t dlen, const char *src);
diff --git a/imap/util.c b/imap/util.c
index fdb540b0..8e15d043 100644
--- a/imap/util.c
+++ b/imap/util.c
@@ -133,7 +133,6 @@ char *imap_next_word (char *s)
int imap_parse_path (const char* path, IMAP_MBOX* mx)
{
char tmp[128];
- url_scheme_t scheme;
ciss_url_t url;
char *c;
int n;
@@ -143,36 +142,27 @@ int imap_parse_path (const char* path, IMAP_MBOX* mx)
mx->account.port = IMAP_PORT;
mx->account.type = M_ACCT_TYPE_IMAP;
-#ifdef USE_SSL
- if (option (OPTIMAPFORCESSL))
- mx->account.flags |= M_ACCT_SSL;
-#endif
-
- scheme = url_check_scheme (NONULL (path));
- if (scheme == U_IMAP || scheme == U_IMAPS)
+ c = safe_strdup (path);
+ url_parse_ciss (&url, c);
+ if (url.scheme == U_IMAP || url.scheme == U_IMAPS)
{
- if (url_parse_ciss (&url, path) < 0)
- return -1;
-
- n = mutt_account_fromurl (&mx->account, &url);
- FREE (&url.user);
- FREE (&url.pass);
- FREE (&url.host);
-
- if (n < 0)
+ if (mutt_account_fromurl (&mx->account, &url) < 0)
{
- FREE (&url.path);
+ FREE (&c);
return -1;
}
-
- mx->mbox = url.path;
- if (scheme == U_IMAPS)
+ mx->mbox = safe_strdup (url.path);
+
+ if (url.scheme == U_IMAPS)
mx->account.flags |= M_ACCT_SSL;
+
+ FREE (&c);
}
/* old PINE-compatibility code */
else
{
+ FREE (&c);
if (sscanf (path, "{%128[^}]}", tmp) != 1)
return -1;
@@ -215,38 +205,27 @@ int imap_parse_path (const char* path, IMAP_MBOX* mx)
}
}
+#ifdef USE_SSL
+ if (option (OPTIMAPFORCESSL))
+ mx->account.flags |= M_ACCT_SSL;
+#endif
+
if ((mx->account.flags & M_ACCT_SSL) && !(mx->account.flags & M_ACCT_PORT))
mx->account.port = IMAP_SSL_PORT;
return 0;
}
-
-/* imap_qualify_path: make an absolute IMAP folder target, given host, port
- * and relative path. Use this and maybe it will be easy to convert to
- * IMAP URLs */
-void imap_qualify_path (char *dest, size_t len, const IMAP_MBOX *mx,
- const char* path, const char* name)
+/* imap_qualify_path: make an absolute IMAP folder target, given IMAP_MBOX
+ * and relative path. */
+void imap_qualify_path (char *dest, size_t len, IMAP_MBOX *mx, char* path)
{
- char tmp[128];
-
- strcpy (dest, "{");
- if ((mx->account.flags & M_ACCT_USER) && (!ImapUser || strcmp (mx->account.user, ImapUser)))
- {
- snprintf (tmp, sizeof (tmp), "%s@", mx->account.user);
- strncat (dest, tmp, len);
- }
- strncat (dest, mx->account.host, len);
- if (mx->account.flags & M_ACCT_PORT)
- {
- snprintf (tmp, sizeof (tmp), ":%d", mx->account.port);
- strncat (dest, tmp, len);
- }
- if (mx->account.flags & M_ACCT_SSL)
- strncat (dest, "/ssl", len);
+ ciss_url_t url;
+
+ mutt_account_tourl (&mx->account, &url);
+ url.path = path;
- snprintf (tmp, sizeof (tmp), "}%s%s", NONULL (path), NONULL (name));
- strncat (dest, tmp, len);
+ url_ciss_tostring (&url, dest, len);
}