Deleted Added
full compact
common.c (85143) common.c (88769)
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

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

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
29#include <sys/cdefs.h>
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

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

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
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/lib/libfetch/common.c 85143 2001-10-19 10:08:05Z des $");
30__FBSDID("$FreeBSD: head/lib/libfetch/common.c 88769 2002-01-01 14:48:09Z des $");
31
32#include <sys/param.h>
33#include <sys/socket.h>
34#include <sys/time.h>
35#include <sys/uio.h>
36#include <netinet/in.h>
37
38#include <errno.h>

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

203 */
204int
205_fetch_connect(const char *host, int port, int af, int verbose)
206{
207 char pbuf[10];
208 struct addrinfo hints, *res, *res0;
209 int sd, err;
210
31
32#include <sys/param.h>
33#include <sys/socket.h>
34#include <sys/time.h>
35#include <sys/uio.h>
36#include <netinet/in.h>
37
38#include <errno.h>

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

203 */
204int
205_fetch_connect(const char *host, int port, int af, int verbose)
206{
207 char pbuf[10];
208 struct addrinfo hints, *res, *res0;
209 int sd, err;
210
211 DEBUG(fprintf(stderr, "\033[1m---> %s:%d\033[m\n", host, port));
211 DEBUG(fprintf(stderr, "---> %s:%d\n", host, port));
212
213 if (verbose)
214 _fetch_info("looking up %s", host);
215
216 /* look up host name and set up socket address structure */
217 snprintf(pbuf, sizeof(pbuf), "%d", port);
218 memset(&hints, 0, sizeof(hints));
219 hints.ai_family = af;

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

319 errno = ENOMEM;
320 return -1;
321 }
322 *buf = tmp;
323 *size = *size * 2 + 1;
324 }
325 } while (c != '\n');
326
212
213 if (verbose)
214 _fetch_info("looking up %s", host);
215
216 /* look up host name and set up socket address structure */
217 snprintf(pbuf, sizeof(pbuf), "%d", port);
218 memset(&hints, 0, sizeof(hints));
219 hints.ai_family = af;

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

319 errno = ENOMEM;
320 return -1;
321 }
322 *buf = tmp;
323 *size = *size * 2 + 1;
324 }
325 } while (c != '\n');
326
327 DEBUG(fprintf(stderr, "\033[1m<<< %.*s\033[m", (int)*len, *buf));
327 DEBUG(fprintf(stderr, "<<< %.*s", (int)*len, *buf));
328 return 0;
329}
330
331
332/*
333 * Write a line of text to a socket w/ timeout
334 * XXX currently does not enforce timeout
335 */

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

343 iov[0].iov_base = (char *)str;
344 iov[0].iov_len = len;
345 iov[1].iov_base = (char *)ENDL;
346 iov[1].iov_len = sizeof ENDL;
347 len += sizeof ENDL;
348 wlen = writev(fd, iov, 2);
349 if (wlen < 0 || (size_t)wlen != len)
350 return -1;
328 return 0;
329}
330
331
332/*
333 * Write a line of text to a socket w/ timeout
334 * XXX currently does not enforce timeout
335 */

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

343 iov[0].iov_base = (char *)str;
344 iov[0].iov_len = len;
345 iov[1].iov_base = (char *)ENDL;
346 iov[1].iov_len = sizeof ENDL;
347 len += sizeof ENDL;
348 wlen = writev(fd, iov, 2);
349 if (wlen < 0 || (size_t)wlen != len)
350 return -1;
351 DEBUG(fprintf(stderr, "\033[1m>>> %s\n\033[m", str));
351 DEBUG(fprintf(stderr, ">>> %s\n", str));
352 return 0;
353}
354
355
356/*** Directory-related utility functions *************************************/
357
358int
359_fetch_add_entry(struct url_ent **p, int *size, int *len,

--- 36 unchanged lines hidden ---
352 return 0;
353}
354
355
356/*** Directory-related utility functions *************************************/
357
358int
359_fetch_add_entry(struct url_ent **p, int *size, int *len,

--- 36 unchanged lines hidden ---