summaryrefslogtreecommitdiff
path: root/libproto/pop/mbox.c
diff options
context:
space:
mode:
Diffstat (limited to 'libproto/pop/mbox.c')
-rw-r--r--libproto/pop/mbox.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/libproto/pop/mbox.c b/libproto/pop/mbox.c
index 67d97a9aa..79854aebc 100644
--- a/libproto/pop/mbox.c
+++ b/libproto/pop/mbox.c
@@ -24,12 +24,13 @@
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
+#include <netdb.h>
#include <mailutils/pop3.h>
#include <mailutils/attribute.h>
#include <mailutils/auth.h>
#include <mailutils/body.h>
#include <mailutils/debug.h>
@@ -47,12 +48,13 @@
#include <mailutils/md5.h>
#include <mailutils/io.h>
#include <mailutils/util.h>
#include <mailutils/cstr.h>
#include <mailutils/cctype.h>
#include <mailutils/opool.h>
+#include <mailutils/sockaddr.h>
#include <mailutils/sys/folder.h>
#include <mailutils/sys/mailbox.h>
#include <mailutils/sys/registrar.h>
#include <mailutils/sys/url.h>
@@ -106,29 +108,32 @@ static int pop_create_pop3_message (struct _pop3_mailbox *mpd, size_t msgno,
static int
pop_open (mu_mailbox_t mbox, int flags)
{
struct _pop3_mailbox *mpd = mbox->data;
int status;
- const char *host;
- unsigned port = mpd->pops ? MU_POPS_PORT : MU_POP_PORT;
mu_stream_t stream;
-
+ struct mu_sockaddr *sa;
+ struct mu_sockaddr_hints hints;
+
/* Sanity checks. */
if (mpd == NULL)
return EINVAL;
- /* Fetch the pop server name and the port in the mu_url_t. */
- status = mu_url_sget_host (mbox->url, &host);
- if (status != 0)
- return status;
- mu_url_get_port (mbox->url, &port);
-
mbox->flags = flags;
-
- status = mu_tcp_stream_create (&stream, host, port, mbox->flags);
+
+ memset (&hints, 0, sizeof (hints));
+ hints.flags = MU_AH_DETECT_FAMILY;
+ hints.port = mpd->pops ? MU_POPS_PORT : MU_POP_PORT;
+ hints.protocol = IPPROTO_TCP;
+ hints.socktype = SOCK_STREAM;
+ status = mu_sockaddr_from_url (&sa, mbox->url, &hints);
+ if (status)
+ return status;
+
+ status = mu_tcp_stream_create_from_sa (&stream, sa, NULL, mbox->flags);
if (status)
return status;
#ifdef WITH_TLS
if (mpd->pops)
{
mu_stream_t newstr;

Return to:

Send suggestions and report system problems to the System administrator.