diff options
author | Dan Winship <danw@src.gnome.org> | 2000-03-29 04:51:58 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2000-03-29 04:51:58 +0800 |
commit | 207652677441264ca1e51d06898b37ea4164c8e2 (patch) | |
tree | ded681c259297bf4b25a83fb9cd1bccc57fe4baf /camel/providers | |
parent | c3b6d117ee155a571d8c4da01b81b6855e26e6f6 (diff) | |
download | gsoc2013-evolution-207652677441264ca1e51d06898b37ea4164c8e2.tar gsoc2013-evolution-207652677441264ca1e51d06898b37ea4164c8e2.tar.gz gsoc2013-evolution-207652677441264ca1e51d06898b37ea4164c8e2.tar.bz2 gsoc2013-evolution-207652677441264ca1e51d06898b37ea4164c8e2.tar.lz gsoc2013-evolution-207652677441264ca1e51d06898b37ea4164c8e2.tar.xz gsoc2013-evolution-207652677441264ca1e51d06898b37ea4164c8e2.tar.zst gsoc2013-evolution-207652677441264ca1e51d06898b37ea4164c8e2.zip |
convenience functions to canonicalize the host and port values of a
* camel-service.c (camel_service_gethost,
camel_service_getport): convenience functions to canonicalize
the host and port values of a service's URL.
* providers/pop3/camel-pop3-store.c: use them
svn path=/trunk/; revision=2216
Diffstat (limited to 'camel/providers')
-rw-r--r-- | camel/providers/pop3/camel-pop3-store.c | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c index 8b9ff03fac..543a6ce532 100644 --- a/camel/providers/pop3/camel-pop3-store.c +++ b/camel/providers/pop3/camel-pop3-store.c @@ -29,7 +29,6 @@ #include <sys/socket.h> #include <netinet/in.h> #include <errno.h> -#include <netdb.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -44,6 +43,9 @@ #include "md5-utils.h" #include "url-util.h" +/* Specified in RFC 1939 */ +#define POP3_PORT 110 + static CamelServiceClass *service_class = NULL; static void finalize (GtkObject *object); @@ -203,28 +205,19 @@ pop3_connect (CamelService *service, CamelException *ex) { struct hostent *h; struct sockaddr_in sin; - int fd, status, apoplen; + int port, fd, status, apoplen; char *buf, *apoptime, *pass; CamelPop3Store *store = CAMEL_POP3_STORE (service); if (!service_class->connect (service, ex)) return FALSE; - h = gethostbyname (service->url->host); - if (!h) { - extern int h_errno; - if (h_errno == HOST_NOT_FOUND || h_errno == NO_DATA) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID, - "No such host %s.", - service->url->host); - } else { - camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, - "Temporarily unable to look up " - "hostname %s.", - service->url->host); - } + h = camel_service_gethost (service, ex); + if (!h) + return FALSE; + port = camel_service_getport (service, "pop3", POP3_PORT, "tcp", ex); + if (port == -1) return FALSE; - } pass = g_strdup (service->url->passwd); if (!pass) { @@ -240,11 +233,7 @@ pop3_connect (CamelService *service, CamelException *ex) } sin.sin_family = h->h_addrtype; - /* XXX this is all bad */ - if (service->url->port && *service->url->port) - sin.sin_port = htons (atoi (service->url->port)); - else - sin.sin_port = htons (110); + sin.sin_port = port; memcpy (&sin.sin_addr, h->h_addr, sizeof (sin.sin_addr)); fd = socket (h->h_addrtype, SOCK_STREAM, 0); |