diff options
Diffstat (limited to 'libproto/pop/mbox.c')
-rw-r--r-- | libproto/pop/mbox.c | 27 |
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 | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <sys/time.h> | 27 | #include <sys/time.h> |
28 | #include <sys/types.h> | 28 | #include <sys/types.h> |
29 | #include <unistd.h> | 29 | #include <unistd.h> |
30 | #include <netdb.h> | ||
30 | 31 | ||
31 | #include <mailutils/pop3.h> | 32 | #include <mailutils/pop3.h> |
32 | #include <mailutils/attribute.h> | 33 | #include <mailutils/attribute.h> |
@@ -50,6 +51,7 @@ | |||
50 | #include <mailutils/cstr.h> | 51 | #include <mailutils/cstr.h> |
51 | #include <mailutils/cctype.h> | 52 | #include <mailutils/cctype.h> |
52 | #include <mailutils/opool.h> | 53 | #include <mailutils/opool.h> |
54 | #include <mailutils/sockaddr.h> | ||
53 | 55 | ||
54 | #include <mailutils/sys/folder.h> | 56 | #include <mailutils/sys/folder.h> |
55 | #include <mailutils/sys/mailbox.h> | 57 | #include <mailutils/sys/mailbox.h> |
@@ -109,23 +111,26 @@ pop_open (mu_mailbox_t mbox, int flags) | |||
109 | { | 111 | { |
110 | struct _pop3_mailbox *mpd = mbox->data; | 112 | struct _pop3_mailbox *mpd = mbox->data; |
111 | int status; | 113 | int status; |
112 | const char *host; | ||
113 | unsigned port = mpd->pops ? MU_POPS_PORT : MU_POP_PORT; | ||
114 | mu_stream_t stream; | 114 | mu_stream_t stream; |
115 | 115 | struct mu_sockaddr *sa; | |
116 | struct mu_sockaddr_hints hints; | ||
117 | |||
116 | /* Sanity checks. */ | 118 | /* Sanity checks. */ |
117 | if (mpd == NULL) | 119 | if (mpd == NULL) |
118 | return EINVAL; | 120 | return EINVAL; |
119 | 121 | ||
120 | /* Fetch the pop server name and the port in the mu_url_t. */ | ||
121 | status = mu_url_sget_host (mbox->url, &host); | ||
122 | if (status != 0) | ||
123 | return status; | ||
124 | mu_url_get_port (mbox->url, &port); | ||
125 | |||
126 | mbox->flags = flags; | 122 | mbox->flags = flags; |
127 | 123 | ||
128 | status = mu_tcp_stream_create (&stream, host, port, mbox->flags); | 124 | memset (&hints, 0, sizeof (hints)); |
125 | hints.flags = MU_AH_DETECT_FAMILY; | ||
126 | hints.port = mpd->pops ? MU_POPS_PORT : MU_POP_PORT; | ||
127 | hints.protocol = IPPROTO_TCP; | ||
128 | hints.socktype = SOCK_STREAM; | ||
129 | status = mu_sockaddr_from_url (&sa, mbox->url, &hints); | ||
130 | if (status) | ||
131 | return status; | ||
132 | |||
133 | status = mu_tcp_stream_create_from_sa (&stream, sa, NULL, mbox->flags); | ||
129 | if (status) | 134 | if (status) |
130 | return status; | 135 | return status; |
131 | #ifdef WITH_TLS | 136 | #ifdef WITH_TLS |