summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2014-06-10 01:09:09 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-06-10 01:09:10 +0000
commitbdcab25ee6aebe2f5653fdc8f73e6bd94dadb763 (patch)
tree59328b62c6560de4e89051f4701e8f97e0e15cef
parent199e8638df12eb6373771ebb59a1f5a83c6de1cc (diff)
parenta382a792a456fe2710dd3a7be623180ed85a8dce (diff)
downloadbionic-bdcab25ee6aebe2f5653fdc8f73e6bd94dadb763.zip
bionic-bdcab25ee6aebe2f5653fdc8f73e6bd94dadb763.tar.gz
bionic-bdcab25ee6aebe2f5653fdc8f73e6bd94dadb763.tar.bz2
Merge "Hide non-standard syslog API."
-rw-r--r--libc/include/syslog.h40
-rw-r--r--libc/unistd/syslog.c32
2 files changed, 37 insertions, 35 deletions
diff --git a/libc/include/syslog.h b/libc/include/syslog.h
index 4677c14..a52e811 100644
--- a/libc/include/syslog.h
+++ b/libc/include/syslog.h
@@ -25,6 +25,7 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+
#ifndef _SYSLOG_H
#define _SYSLOG_H
@@ -34,7 +35,6 @@
__BEGIN_DECLS
-/* Alert levels */
#define LOG_EMERG 0
#define LOG_ALERT 1
#define LOG_CRIT 2
@@ -47,8 +47,6 @@ __BEGIN_DECLS
#define LOG_PRIMASK 7
#define LOG_PRI(x) ((x) & LOG_PRIMASK)
-
-/* Facilities; not actually used */
#define LOG_KERN 0000
#define LOG_USER 0010
#define LOG_MAIL 0020
@@ -73,30 +71,15 @@ __BEGIN_DECLS
#define LOG_FACMASK 01770
#define LOG_FAC(x) (((x) >> 3) & (LOG_FACMASK >> 3))
-#define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */
-#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */
-
-/* openlog() flags; only LOG_PID and LOG_PERROR supported */
-#define LOG_PID 0x01 /* include pid with message */
-#define LOG_CONS 0x02 /* write to console on logger error */
-#define LOG_ODELAY 0x04 /* delay connection until syslog() */
-#define LOG_NDELAY 0x08 /* open connection immediately */
-#define LOG_NOWAIT 0x10 /* wait for child processes (unused on linux) */
-#define LOG_PERROR 0x20 /* additional logging to stderr */
-
-/* BIONIC: the following definitions are from OpenBSD's sys/syslog.h
- */
-struct syslog_data {
- int log_file;
- int connected;
- int opened;
- int log_stat;
- const char *log_tag;
- int log_fac;
- int log_mask;
-};
+#define LOG_MASK(pri) (1 << (pri))
+#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1)
-#define SYSLOG_DATA_INIT {-1, 0, 0, 0, (const char *)0, LOG_USER, 0xff}
+#define LOG_PID 0x01 /* include pid with message */
+#define LOG_CONS 0x02 /* write to console on logger error */
+#define LOG_ODELAY 0x04 /* delay connection until syslog() */
+#define LOG_NDELAY 0x08 /* open connection immediately */
+#define LOG_NOWAIT 0x10 /* wait for child processes (unused on linux) */
+#define LOG_PERROR 0x20 /* additional logging to stderr */
#define _PATH_LOG "/dev/syslog"
@@ -105,11 +88,6 @@ extern void openlog(const char *, int, int);
extern int setlogmask(int);
extern void syslog(int, const char *, ...) __printflike(2, 3);
extern void vsyslog(int, const char *, va_list) __printflike(2, 0);
-extern void closelog_r(struct syslog_data *);
-extern void openlog_r(const char *, int, int, struct syslog_data *);
-extern int setlogmask_r(int, struct syslog_data *);
-extern void syslog_r(int, struct syslog_data *, const char *, ...) __printflike(3, 4);
-extern void vsyslog_r(int, struct syslog_data *, const char *, va_list) __printflike(3, 0);
__END_DECLS
diff --git a/libc/unistd/syslog.c b/libc/unistd/syslog.c
index 7878475..339df68 100644
--- a/libc/unistd/syslog.c
+++ b/libc/unistd/syslog.c
@@ -44,6 +44,18 @@
#include <unistd.h>
#include <stdarg.h>
+struct syslog_data {
+ int log_file;
+ int connected;
+ int opened;
+ int log_stat;
+ const char* log_tag;
+ int log_fac;
+ int log_mask;
+};
+
+#define SYSLOG_DATA_INIT {-1, 0, 0, 0, (const char *)0, LOG_USER, 0xff}
+
static struct syslog_data sdata = SYSLOG_DATA_INIT;
extern const char *__progname; /* Program name, from crt0. */
@@ -51,6 +63,18 @@ extern const char *__progname; /* Program name, from crt0. */
static void disconnectlog_r(struct syslog_data *); /* disconnect from syslogd */
static void connectlog_r(struct syslog_data *); /* (re)connect to syslogd */
+#if defined(__LP64__)
+#define SYSLOG_R_VISIBILITY static
+#else
+#define SYSLOG_R_VISIBILITY extern
+#endif
+
+SYSLOG_R_VISIBILITY void closelog_r(struct syslog_data*);
+SYSLOG_R_VISIBILITY void openlog_r(const char*, int, int, struct syslog_data*);
+SYSLOG_R_VISIBILITY int setlogmask_r(int, struct syslog_data*);
+SYSLOG_R_VISIBILITY void syslog_r(int, struct syslog_data*, const char*, ...) __printflike(3, 4);
+SYSLOG_R_VISIBILITY void vsyslog_r(int, struct syslog_data*, const char*, va_list) __printflike(3, 0);
+
/*
* syslog, vsyslog --
* print message on log file; output is intended for syslogd(8).
@@ -157,7 +181,7 @@ vsyslog_r(int pri, struct syslog_data *data, const char *fmt, va_list ap)
prlen = snprintf(p, tbuf_left, "<%d>", pri);
DEC();
- /*
+ /*
* syslogd will expand time automagically for reentrant case, and
* for normal case, just do like before
*/
@@ -196,10 +220,10 @@ vsyslog_r(int pri, struct syslog_data *data, const char *fmt, va_list ap)
++fmt;
if (data == &sdata) {
prlen = snprintf(t, fmt_left, "%s",
- strerror(saved_errno));
+ strerror(saved_errno));
} else {
prlen = snprintf(t, fmt_left, "Error %d",
- saved_errno);
+ saved_errno);
}
if (prlen < 0)
prlen = 0;
@@ -269,7 +293,7 @@ vsyslog_r(int pri, struct syslog_data *data, const char *fmt, va_list ap)
if (error == -1 && (data->log_stat & LOG_CONS) &&
(fd = open(_PATH_CONSOLE, O_WRONLY|O_NONBLOCK, 0)) >= 0) {
struct iovec iov[2];
-
+
p = strchr(tbuf, '>') + 1;
iov[0].iov_base = p;
iov[0].iov_len = cnt - (p - tbuf);