Deleted Added
full compact
syslog.c (89805) syslog.c (90045)
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)
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";
35static 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 */
36#endif /* LIBC_SCCS and not lint */
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/lib/libc/gen/syslog.c 90045 2002-02-01 01:32:19Z obrien $");
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
39
40#include "namespace.h"
41#include <sys/types.h>
42#include <sys/socket.h>
43#include <sys/syslog.h>
44#include <sys/uio.h>
45#include <sys/un.h>
46#include <netdb.h>

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

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

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

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

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

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

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

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

--- 92 unchanged lines hidden ---