diff options
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/gen/syslog.c | 26 | ||||
-rw-r--r-- | lib/libc/gen/syslog_r.c | 22 | ||||
-rw-r--r-- | lib/libc/hidden/syslog.h | 42 |
3 files changed, 55 insertions, 35 deletions
diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c index e713b64edcf..ccbf5c03151 100644 --- a/lib/libc/gen/syslog.c +++ b/lib/libc/gen/syslog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syslog.c,v 1.31 2011/05/30 18:48:33 martynas Exp $ */ +/* $OpenBSD: syslog.c,v 1.32 2015/09/12 14:30:31 guenther Exp $ */ /* * Copyright (c) 1983, 1988, 1993 * The Regents of the University of California. All rights reserved. @@ -29,26 +29,12 @@ */ #include <sys/types.h> -#include <sys/socket.h> -#include <sys/syslog.h> -#include <sys/uio.h> -#include <sys/un.h> -#include <netdb.h> - -#include <errno.h> -#include <fcntl.h> -#include <paths.h> -#include <stdio.h> -#include <string.h> -#include <time.h> -#include <unistd.h> #include <stdarg.h> +#include <syslog.h> +#include <time.h> static struct syslog_data sdata = SYSLOG_DATA_INIT; -void __vsyslog_r(int pri, struct syslog_data *, size_t (*)(char *, size_t), - const char *, va_list); - static size_t gettime(char *buf, size_t maxsize) { @@ -63,7 +49,6 @@ gettime(char *buf, size_t maxsize) * syslog, vsyslog -- * print message on log file; output is intended for syslogd(8). */ -/* PRINTFLIKE2 */ void syslog(int pri, const char *fmt, ...) { @@ -73,12 +58,14 @@ syslog(int pri, const char *fmt, ...) vsyslog(pri, fmt, ap); va_end(ap); } +DEF_WEAK(syslog); void vsyslog(int pri, const char *fmt, va_list ap) { __vsyslog_r(pri, &sdata, &gettime, fmt, ap); } +DEF_WEAK(vsyslog); void openlog(const char *ident, int logstat, int logfac) @@ -96,7 +83,7 @@ closelog(void) int setlogmask(int pmask) { - return setlogmask_r(pmask, &sdata); + return (setlogmask_r(pmask, &sdata)); } /* setlogmask -- set the log mask level */ @@ -110,3 +97,4 @@ setlogmask_r(int pmask, struct syslog_data *data) data->log_mask = pmask; return (omask); } +DEF_WEAK(setlogmask_r); diff --git a/lib/libc/gen/syslog_r.c b/lib/libc/gen/syslog_r.c index fa2a2c839f6..8da599aef64 100644 --- a/lib/libc/gen/syslog_r.c +++ b/lib/libc/gen/syslog_r.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syslog_r.c,v 1.8 2015/09/09 10:50:59 bluhm Exp $ */ +/* $OpenBSD: syslog_r.c,v 1.9 2015/09/12 14:30:31 guenther Exp $ */ /* * Copyright (c) 1983, 1988, 1993 * The Regents of the University of California. All rights reserved. @@ -29,7 +29,6 @@ */ #include <sys/types.h> -#include <sys/syslog.h> #include <sys/uio.h> #include <netdb.h> @@ -38,6 +37,7 @@ #include <paths.h> #include <stdio.h> #include <string.h> +#include <syslog.h> #include <time.h> #include <unistd.h> #include <limits.h> @@ -45,14 +45,8 @@ extern char *__progname; /* Program name, from crt0. */ -int sendsyslog(const char *, size_t); - -void __vsyslog_r(int pri, struct syslog_data *, size_t (*)(char *, size_t), - const char *, va_list); /* Reentrant version of syslog, i.e. syslog_r() */ - -/* PRINTFLIKE3 */ void syslog_r(int pri, struct syslog_data *data, const char *fmt, ...) { @@ -62,19 +56,14 @@ syslog_r(int pri, struct syslog_data *data, const char *fmt, ...) vsyslog_r(pri, data, fmt, ap); va_end(ap); } +DEF_WEAK(syslog_r); void vsyslog_r(int pri, struct syslog_data *data, const char *fmt, va_list ap) { - const char *ident; - __vsyslog_r(pri, data, NULL, fmt, ap); - - /* close the socket without losing log_tag */ - ident = data->log_tag; - closelog_r(data); - data->log_tag = ident; } +DEF_WEAK(vsyslog_r); /* * This is used by both syslog_r and syslog. The latter supplies @@ -247,10 +236,11 @@ openlog_r(const char *ident, int logstat, int logfac, struct syslog_data *data) if (logfac != 0 && (logfac &~ LOG_FACMASK) == 0) data->log_fac = logfac; } +DEF_WEAK(openlog_r); void closelog_r(struct syslog_data *data) { data->log_tag = NULL; } - +DEF_WEAK(closelog_r); diff --git a/lib/libc/hidden/syslog.h b/lib/libc/hidden/syslog.h new file mode 100644 index 00000000000..867a05ca7ea --- /dev/null +++ b/lib/libc/hidden/syslog.h @@ -0,0 +1,42 @@ +/* $OpenBSD: syslog.h,v 1.1 2015/09/12 14:30:31 guenther Exp $ */ +/* + * Copyright (c) 2015 Philip Guenther <guenther@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBC_SYSLOG_H_ +#define _LIBC_SYSLOG_H_ + +#include_next <syslog.h> + +int sendsyslog(const char *, __size_t); +PROTO_NORMAL(sendsyslog); + +__BEGIN_HIDDEN_DECLS +void __vsyslog_r(int, struct syslog_data *, __size_t (*)(char *, __size_t), + const char *, __va_list); +__END_HIDDEN_DECLS + +PROTO_DEPRECATED(closelog); +PROTO_NORMAL(closelog_r); +PROTO_DEPRECATED(openlog); +PROTO_NORMAL(openlog_r); +PROTO_DEPRECATED(setlogmask); +PROTO_NORMAL(setlogmask_r); +PROTO_NORMAL(syslog); +PROTO_NORMAL(syslog_r); +PROTO_NORMAL(vsyslog); +PROTO_NORMAL(vsyslog_r); + +#endif /* !_LIBC_SYSLOG_H_ */ |