Deleted Added
sdiff udiff text old ( 89805 ) new ( 90045 )
full compact
1/*
2 * Copyright (c) 1983, 1988, 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

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

27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35/*
36static char sccsid[] = "@(#)syslog.c 8.5 (Berkeley) 4/29/95";
37*/
38static const char rcsid[] =
39 "$FreeBSD: head/lib/libc/gen/syslog.c 89805 2002-01-25 21:49:34Z dwmalone $";
40#endif /* LIBC_SCCS and not lint */
41
42#include "namespace.h"
43#include <sys/types.h>
44#include <sys/socket.h>
45#include <sys/syslog.h>
46#include <sys/uio.h>
47#include <sys/un.h>
48#include <netdb.h>

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

66static int connected; /* have done connect */
67static int opened; /* have done openlog() */
68static int LogStat = 0; /* status bits, set by openlog() */
69static const char *LogTag = NULL; /* string to tag the entry with */
70static int LogFacility = LOG_USER; /* default facility code */
71static int LogMask = 0xff; /* mask of priorities to be logged */
72extern char *__progname; /* Program name, from crt0. */
73
74static void disconnectlog __P((void)); /* disconnect from syslogd */
75static void connectlog __P((void)); /* (re)connect to syslogd */
76
77/*
78 * Format of the magic cookie passed through the stdio hook
79 */
80struct bufcookie {
81 char *base; /* start of buffer */
82 int left;
83};

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

131#endif
132 vsyslog(pri, fmt, ap);
133 va_end(ap);
134}
135
136void
137vsyslog(pri, fmt, ap)
138 int pri;
139 register const char *fmt;
140 va_list ap;
141{
142 register int cnt;
143 register char ch, *p;
144 time_t now;
145 int fd, saved_errno;
146 char *stdp, tbuf[2048], fmt_cpy[1024], timbuf[26];
147 FILE *fp, *fmt_fp;
148 struct bufcookie tbuf_cookie;
149 struct bufcookie fmt_cookie;
150
151#define INTERNALLOG LOG_ERR|LOG_CONS|LOG_PERROR|LOG_PID

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

225 (void)vfprintf(fp, fmt, ap);
226 (void)fclose(fp);
227
228 cnt = sizeof(tbuf) - tbuf_cookie.left;
229
230 /* Output to stderr if requested. */
231 if (LogStat & LOG_PERROR) {
232 struct iovec iov[2];
233 register struct iovec *v = iov;
234
235 v->iov_base = stdp;
236 v->iov_len = cnt - (stdp - tbuf);
237 ++v;
238 v->iov_base = "\n";
239 v->iov_len = 1;
240 (void)_writev(STDERR_FILENO, iov, 2);
241 }

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

259 /*
260 * Output the message to the console; don't worry about blocking,
261 * if console blocks everything will. Make sure the error reported
262 * is the one from the syslogd failure.
263 */
264 if (LogStat & LOG_CONS &&
265 (fd = _open(_PATH_CONSOLE, O_WRONLY, 0)) >= 0) {
266 struct iovec iov[2];
267 register struct iovec *v = iov;
268
269 p = strchr(tbuf, '>') + 1;
270 v->iov_base = p;
271 v->iov_len = cnt - (p - tbuf);
272 ++v;
273 v->iov_base = "\r\n";
274 v->iov_len = 2;
275 (void)_writev(fd, iov, 2);

--- 92 unchanged lines hidden ---