/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* PPPoE Server-mode daemon log file support.
*
* Copyright (c) 2000-2001 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <unistd.h>
#include <stdarg.h>
#include <alloca.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <syslog.h>
#include <assert.h>
#include "common.h"
#include "logging.h"
/* Not all functions are used by all applications. Let lint know this. */
/*LINTLIBRARY*/
/*
* Returns -1 on error (with errno set), 0 on blocked write (file
* system full), or N (buffer length) on success.
*/
static int
{
int retv;
while (len > 0) {
if (retv == 0) {
break;
}
if (retv == -1) {
break;
} else {
}
}
if (len <= 0)
return (retv);
}
/* A close that avoids closing stderr */
static int
doclose(void)
{
int retval = 0;
if (curlogfd == -1)
return (0);
curlogfd = -1;
return (retval);
}
/*
* Log levels are 0 for no messages, 1 for errors, 2 for warnings, 3
* for informational messages, and 4 for debugging messages.
*/
static void
{
char *ostr;
int timlen;
int slen;
char *nstr;
int sloglev;
int retv;
static int xlate_loglev[] = {
};
return;
timbuf[0] = '\0';
timlen = 0;
if (curlogfd >= 0) {
/*
* Caution: string broken in two so that SCCS doesn't mangle
* the %-T-% sequence.
*/
}
/* Try formatting once into the small buffer. */
} else {
/*
* Length returned by vsnprintf doesn't include null,
* and may also be missing a terminating \n.
*/
}
/* Don't bother logging empty lines. */
if (slen <= 0)
return;
/* Tack on a \n if needed. */
}
/* Translate our log levels into syslog standard values */
/* Log each line separately */
/* Ignore zero-length lines. */
continue;
/*
* If we're supposed to be logging to a file, then try
* that first. Ditch the file and revert to syslog if
* any errors occur.
*/
if (curlogfd >= 0) {
/*
* If we've successfully logged this line,
* then go do the next one.
*/
if (retv > 0)
continue;
/* Save errno (if any) and close log file */
if (doclose() == -1)
else
err2 = 0;
/*
* Recursion is safe here because we cleared
* out curlogfd above.
*/
if (retv == -1)
mystrerror(err1));
else
if (err2 == 0)
else
mystrerror(err2));
}
}
}
/* Log at debug level */
void
{
}
/* Log informational messages */
void
{
}
/* Log warning messages */
void
{
}
/* Log error messages */
void
{
}
/* Log a strerror message */
void
{
}
void
{
if (curlogfd >= 0)
}
/*
* Set indicated log file and debug level.
*/
void
{
return;
if (curlogfd >= 0) {
return;
}
if (doclose() == -1)
}
if (curlogfd == -1)
}
if (closed) {
if (err1 == 0)
else
mystrerror(err1));
}
if (err2 == 0)
else
}
}
/*
* Close any open log file. This is used for SIGHUP (to support log
* file rotation) and when execing.
*/
void
close_log_files(void)
{
int err = 0;
if (curlogfd >= 0) {
if (doclose() == -1)
if (err == 0)
else
mystrerror(err));
}
}
/*
* Reopen syslog connection; in case it was closed.
*/
void
reopen_log(void)
{
/* I control the log level */
}