Deleted Added
full compact
common.c (63334) common.c (68551)
1/*-
2 * Copyright (c) 1998 Dag-Erling Co�dan Sm�rgrav
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
1/*-
2 * Copyright (c) 1998 Dag-Erling Co�dan Sm�rgrav
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $FreeBSD: head/lib/libfetch/common.c 63334 2000-07-17 20:49:39Z des $
28 * $FreeBSD: head/lib/libfetch/common.c 68551 2000-11-10 08:43:40Z des $
29 */
30
31#include <sys/param.h>
32#include <sys/socket.h>
33#include <sys/time.h>
34#include <sys/uio.h>
35#include <netinet/in.h>
36

--- 126 unchanged lines hidden (view full) ---

163 va_end(ap);
164 fputc('\n', stderr);
165}
166
167
168/*** Network-related utility functions ***************************************/
169
170/*
29 */
30
31#include <sys/param.h>
32#include <sys/socket.h>
33#include <sys/time.h>
34#include <sys/uio.h>
35#include <netinet/in.h>
36

--- 126 unchanged lines hidden (view full) ---

163 va_end(ap);
164 fputc('\n', stderr);
165}
166
167
168/*** Network-related utility functions ***************************************/
169
170/*
171 * Return the default port for a scheme
172 */
173int
174_fetch_default_port(char *scheme)
175{
176 struct servent *se;
177
178 if ((se = getservbyname(scheme, "tcp")) != NULL)
179 return ntohs(se->s_port);
180 if (strcasecmp(scheme, SCHEME_FTP) == 0)
181 return FTP_DEFAULT_PORT;
182 if (strcasecmp(scheme, SCHEME_HTTP) == 0)
183 return HTTP_DEFAULT_PORT;
184 return 0;
185}
186
187/*
188 * Return the default proxy port for a scheme
189 */
190int
191_fetch_default_proxy_port(char *scheme)
192{
193 struct servent *se;
194
195 if ((se = getservbyname(scheme, "tcp")) != NULL)
196 return ntohs(se->s_port);
197 if (strcasecmp(scheme, SCHEME_FTP) == 0)
198 return FTP_DEFAULT_PROXY_PORT;
199 if (strcasecmp(scheme, SCHEME_HTTP) == 0)
200 return HTTP_DEFAULT_PROXY_PORT;
201 return 0;
202}
203
204/*
171 * Establish a TCP connection to the specified port on the specified host.
172 */
173int
174_fetch_connect(char *host, int port, int af, int verbose)
175{
176 char pbuf[10];
177 struct addrinfo hints, *res, *res0;
178 int sd, err;

--- 183 unchanged lines hidden ---
205 * Establish a TCP connection to the specified port on the specified host.
206 */
207int
208_fetch_connect(char *host, int port, int af, int verbose)
209{
210 char pbuf[10];
211 struct addrinfo hints, *res, *res0;
212 int sd, err;

--- 183 unchanged lines hidden ---