From 985bff769942e74d8a4614115b7153a96bf6d0b6 Mon Sep 17 00:00:00 2001 From: des Date: Fri, 10 Nov 2000 08:43:40 +0000 Subject: Use the documented (and historical) defaults. Centralize the decision logic in order to avoid this bug in the future. Submitted by: se --- lib/libfetch/common.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'lib/libfetch/common.c') diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c index c03b1f5..4d05a6b6 100644 --- a/lib/libfetch/common.c +++ b/lib/libfetch/common.c @@ -168,6 +168,40 @@ _fetch_info(char *fmt, ...) /*** Network-related utility functions ***************************************/ /* + * Return the default port for a scheme + */ +int +_fetch_default_port(char *scheme) +{ + struct servent *se; + + if ((se = getservbyname(scheme, "tcp")) != NULL) + return ntohs(se->s_port); + if (strcasecmp(scheme, SCHEME_FTP) == 0) + return FTP_DEFAULT_PORT; + if (strcasecmp(scheme, SCHEME_HTTP) == 0) + return HTTP_DEFAULT_PORT; + return 0; +} + +/* + * Return the default proxy port for a scheme + */ +int +_fetch_default_proxy_port(char *scheme) +{ + struct servent *se; + + if ((se = getservbyname(scheme, "tcp")) != NULL) + return ntohs(se->s_port); + if (strcasecmp(scheme, SCHEME_FTP) == 0) + return FTP_DEFAULT_PROXY_PORT; + if (strcasecmp(scheme, SCHEME_HTTP) == 0) + return HTTP_DEFAULT_PROXY_PORT; + return 0; +} + +/* * Establish a TCP connection to the specified port on the specified host. */ int -- cgit v1.1