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#if 0 |
41#ifndef lint |
42static char sccsid[] = "@(#)logger.c 8.1 (Berkeley) 6/6/93"; |
43#endif /* not lint */ |
44#endif 45 |
46#include <sys/cdefs.h> |
47__FBSDID("$FreeBSD: head/usr.bin/logger/logger.c 146756 2005-05-29 16:04:46Z charnier $"); |
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) { |
194 warnx("syslog/udp: unknown service"); /* not fatal */ |
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; |
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 --- |