diff options
author | Peter S. Mazinger <ps.m@gmx.net> | 2005-12-08 14:42:29 +0000 |
---|---|---|
committer | Peter S. Mazinger <ps.m@gmx.net> | 2005-12-08 14:42:29 +0000 |
commit | c6023f4908ee819063fdbbd5d51a5a51548ed573 (patch) | |
tree | abda1f2e4e4627f7054dbc217aa2948b23766f15 /libc/misc/syslog/syslog.c | |
parent | 2dc51f82eb1deca8f1e948d82538f2846f62950d (diff) |
Reorder and remove prototypes
Diffstat (limited to 'libc/misc/syslog/syslog.c')
-rw-r--r-- | libc/misc/syslog/syslog.c | 116 |
1 files changed, 55 insertions, 61 deletions
diff --git a/libc/misc/syslog/syslog.c b/libc/misc/syslog/syslog.c index 4472abcfd..016db0864 100644 --- a/libc/misc/syslog/syslog.c +++ b/libc/misc/syslog/syslog.c @@ -33,6 +33,7 @@ #define ctime __ctime #define sigaction __sigaction_internal +#define connect __connect #define __FORCE_GLIBC #define _GNU_SOURCE @@ -101,13 +102,6 @@ static int LogFacility = LOG_USER; /* default facility code */ static int LogMask = 0xff; /* mask of priorities to be logged */ static struct sockaddr SyslogAddr; /* AF_UNIX address of local logger */ -static void closelog_intern( int ); -void syslog( int, const char *, ...); -void vsyslog( int, const char *, va_list ); -void openlog( const char *, int, int ); -void closelog( void ); -int setlogmask(int pmask); - static void closelog_intern(int to_default) { @@ -134,6 +128,59 @@ sigpipe_handler (int sig) } /* + * OPENLOG -- open system log + */ +void attribute_hidden +__openlog( const char *ident, int logstat, int logfac ) +{ + int logType = SOCK_DGRAM; + + LOCK; + + if (ident != NULL) + LogTag = ident; + LogStat = logstat; + if (logfac != 0 && (logfac &~ LOG_FACMASK) == 0) + LogFacility = logfac; + if (LogFile == -1) { + SyslogAddr.sa_family = AF_UNIX; + (void)__strncpy(SyslogAddr.sa_data, _PATH_LOG, + sizeof(SyslogAddr.sa_data)); +retry: + if (LogStat & LOG_NDELAY) { + if ((LogFile = socket(AF_UNIX, logType, 0)) == -1){ + UNLOCK; + return; + } + /* fcntl(LogFile, F_SETFD, 1); */ + } + } + + if (LogFile != -1 && !connected) { + if (connect(LogFile, &SyslogAddr, sizeof(SyslogAddr) - + sizeof(SyslogAddr.sa_data) + __strlen(SyslogAddr.sa_data)) != -1) + { + connected = 1; + } else if (logType == SOCK_DGRAM) { + logType = SOCK_STREAM; + if (LogFile != -1) { + __close(LogFile); + LogFile = -1; + } + goto retry; + } else { + if (LogFile != -1) { + __close(LogFile); + LogFile = -1; + } + } + } + + UNLOCK; +} +strong_alias(__openlog,openlog) + +/* * syslog, vsyslog -- * print message on log file; output is intended for syslogd(8). */ @@ -162,7 +209,7 @@ __vsyslog( int pri, const char *fmt, va_list ap ) if (!(LogMask & LOG_MASK(LOG_PRI(pri))) || (pri &~ (LOG_PRIMASK|LOG_FACMASK))) goto getout; if (LogFile < 0 || !connected) - openlog(LogTag, LogStat | LOG_NDELAY, 0); + __openlog(LogTag, LogStat | LOG_NDELAY, 0); /* Set default facility if none specified. */ if ((pri & LOG_FACMASK) == 0) @@ -272,59 +319,6 @@ __syslog(int pri, const char *fmt, ...) strong_alias(__syslog,syslog) /* - * OPENLOG -- open system log - */ -void attribute_hidden -__openlog( const char *ident, int logstat, int logfac ) -{ - int logType = SOCK_DGRAM; - - LOCK; - - if (ident != NULL) - LogTag = ident; - LogStat = logstat; - if (logfac != 0 && (logfac &~ LOG_FACMASK) == 0) - LogFacility = logfac; - if (LogFile == -1) { - SyslogAddr.sa_family = AF_UNIX; - (void)__strncpy(SyslogAddr.sa_data, _PATH_LOG, - sizeof(SyslogAddr.sa_data)); -retry: - if (LogStat & LOG_NDELAY) { - if ((LogFile = socket(AF_UNIX, logType, 0)) == -1){ - UNLOCK; - return; - } - /* fcntl(LogFile, F_SETFD, 1); */ - } - } - - if (LogFile != -1 && !connected) { - if (connect(LogFile, &SyslogAddr, sizeof(SyslogAddr) - - sizeof(SyslogAddr.sa_data) + __strlen(SyslogAddr.sa_data)) != -1) - { - connected = 1; - } else if (logType == SOCK_DGRAM) { - logType = SOCK_STREAM; - if (LogFile != -1) { - __close(LogFile); - LogFile = -1; - } - goto retry; - } else { - if (LogFile != -1) { - __close(LogFile); - LogFile = -1; - } - } - } - - UNLOCK; -} -strong_alias(__openlog,openlog) - -/* * CLOSELOG -- close the system log */ void attribute_hidden |