Deleted Added
full compact
logger.c (102944) logger.c (146756)
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. 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

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

32 */
33
34#ifndef lint
35static const char copyright[] =
36"@(#) Copyright (c) 1983, 1993\n\
37 The Regents of the University of California. All rights reserved.\n";
38#endif /* not lint */
39
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. 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

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

32 */
33
34#ifndef lint
35static const char copyright[] =
36"@(#) Copyright (c) 1983, 1993\n\
37 The Regents of the University of California. All rights reserved.\n";
38#endif /* not lint */
39
40#ifndef lint
41#if 0
40#if 0
41#ifndef lint
42static char sccsid[] = "@(#)logger.c 8.1 (Berkeley) 6/6/93";
42static char sccsid[] = "@(#)logger.c 8.1 (Berkeley) 6/6/93";
43#endif
44#endif /* not lint */
43#endif /* not lint */
44#endif
45
45#include <sys/cdefs.h>
46#include <sys/cdefs.h>
46__FBSDID("$FreeBSD: head/usr.bin/logger/logger.c 102944 2002-09-04 23:29:10Z dwmalone $");
47__FBSDID("$FreeBSD: head/usr.bin/logger/logger.c 146756 2005-05-29 16:04:46Z charnier $");
47
48#include <sys/types.h>
49#include <sys/socket.h>
50#include <netinet/in.h>
51
52#include <ctype.h>
53#include <err.h>
54#include <netdb.h>

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

185
186 if (nsock <= 0) { /* set up socket stuff */
187 /* resolve hostname */
188 memset(&hints, 0, sizeof(hints));
189 hints.ai_family = family;
190 hints.ai_socktype = SOCK_DGRAM;
191 error = getaddrinfo(host, "syslog", &hints, &res);
192 if (error == EAI_SERVICE) {
48
49#include <sys/types.h>
50#include <sys/socket.h>
51#include <netinet/in.h>
52
53#include <ctype.h>
54#include <err.h>
55#include <netdb.h>

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

186
187 if (nsock <= 0) { /* set up socket stuff */
188 /* resolve hostname */
189 memset(&hints, 0, sizeof(hints));
190 hints.ai_family = family;
191 hints.ai_socktype = SOCK_DGRAM;
192 error = getaddrinfo(host, "syslog", &hints, &res);
193 if (error == EAI_SERVICE) {
193 warnx ("syslog/udp: unknown service"); /* not fatal */
194 warnx("syslog/udp: unknown service"); /* not fatal */
194 error = getaddrinfo(host, "514", &hints, &res);
195 }
196 if (error)
197 errx(1, "%s: %s", gai_strerror(error), host);
198 /* count max number of sockets we may open */
199 for (maxs = 0, r = res; r; r = r->ai_next, maxs++);
200 socks = malloc(maxs * sizeof(struct socks));
201 if (!socks)

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

212 freeaddrinfo(res);
213 if (nsock <= 0)
214 errx(1, "socket");
215 }
216
217 if ((len = asprintf(&line, "<%d>%s", pri, buf)) == -1)
218 errx(1, "asprintf");
219
195 error = getaddrinfo(host, "514", &hints, &res);
196 }
197 if (error)
198 errx(1, "%s: %s", gai_strerror(error), host);
199 /* count max number of sockets we may open */
200 for (maxs = 0, r = res; r; r = r->ai_next, maxs++);
201 socks = malloc(maxs * sizeof(struct socks));
202 if (!socks)

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

213 freeaddrinfo(res);
214 if (nsock <= 0)
215 errx(1, "socket");
216 }
217
218 if ((len = asprintf(&line, "<%d>%s", pri, buf)) == -1)
219 errx(1, "asprintf");
220
221 lsent = -1;
220 for (i = 0; i < nsock; ++i) {
221 lsent = sendto(socks[i].sock, line, len, 0,
222 (struct sockaddr *)&socks[i].addr,
223 socks[i].addrlen);
224 if (lsent == len && !send_to_all)
225 break;
226 }
227 if (lsent != len) {

--- 59 unchanged lines hidden ---
222 for (i = 0; i < nsock; ++i) {
223 lsent = sendto(socks[i].sock, line, len, 0,
224 (struct sockaddr *)&socks[i].addr,
225 socks[i].addrlen);
226 if (lsent == len && !send_to_all)
227 break;
228 }
229 if (lsent != len) {

--- 59 unchanged lines hidden ---