-/*
+/*
Copyright (c) 1995-1998 by Cisco systems, Inc.
Permission to use, copy, modify, and distribute this software for
FITNESS FOR A PARTICULAR PURPOSE.
*/
+
#include "tac_plus.h"
-#include <stdio.h>
-#ifdef AIX
+#include <stdio.h>
#include <sys/types.h>
-#else
#include <time.h>
+#include <sys/stat.h>
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
#endif
-
-#ifdef __STDC__
-#include <stdarg.h> /* ANSI C, variable length args */
-#else
-#include <varargs.h> /* has 'vararg' definitions */
+#include <string.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
#endif
+#ifdef HAVE_SYSLOG_H
+#include <syslog.h>
+#endif
+#ifdef HAVE_SYS_SYSLOG_H
+#include <sys/syslog.h>
+#endif
+
+#include "report.h"
+#include "utils.h"
+#include "main.h"
+
+
+/* Configurable:
+ */
+
+#define LOGFILE_DEFAULT "/var/log/tac_plus.log"
+
FILE *ostream = NULL;
* All other priorities are always logged to syslog.
*/
+void report TAC_ARGS((int priority, const char *fmt, ...)) G_GNUC_PRINTF(2, 3);
+
#ifdef __STDC__
+
+#include <stdarg.h> /* ANSI C, variable length args */
void
-report(int priority, char *fmt,...)
-#else
+report(int priority, const char *fmt,...)
+
+#else /* __STDC__ */
+
+#include <varargs.h> /* has 'vararg' definitions */
/* VARARGS2 */
void
report(priority, fmt, va_alist)
int priority;
-char *fmt;
+const char *fmt;
va_dcl /* no terminating semi-colon */
-#endif
+
+#endif /* __STDC__ */
{
char msg[255]; /* temporary string */
- char *fp, *bufp, *charp;
- int len, m, i, n;
+ const char *fp;
+ char *bufp, *charp = NULL /* GCC paranoia */;
+ int len, m = 0 /* GCC paranoia */, i, n;
char digits[16];
va_list ap;
m = strlen(digits);
charp = digits;
break;
+ default:
+ syslog(LOG_ERR, "Unknown format character '%c', ignoring it", *fp);
+ continue;
}
-
+
if ((len + m + 1) >= n) {
break;
}
if (console) {
extern int errno;
-
+
if (!ostream)
ostream = fopen("/dev/console", "w");
fprintf(ostream, "Error ");
fprintf(ostream, "%s\n", msg);
}
- else
+ else
syslog(LOG_ERR, "Cannot open /dev/console errno=%d", errno);
}
ct[24] = '\0';
tac_lockfd(logfile, logfd);
- sprintf(buf, "%s [%d]: ", ct, getpid());
+ sprintf(buf, "%s [%d]: ", ct, (int) getpid());
write(logfd, buf, strlen(buf));
if (priority == LOG_ERR)
write(logfd, "Error ", 6);
syslog(priority, "%s", msg);
}
+void report_hex TAC_ARGS((int priority, u_char *p, int len));
+
/* format a hex dump for syslog */
void
report_hex(priority, p, len)
char digit[10];
int buflen;
int i;
-
+
if (len <= 0)
return;
}
+void report_string TAC_ARGS((int priority, u_char *p, int len));
+
/* format a non-null terminated string for syslog */
void
report_string(priority, p, len)
report(priority, "%s", buf);
}
+void tac_regerror TAC_ARGS((const char *s));
+
void
-regerror(s)
-char *s;
+tac_regerror(s)
+const char *s;
{
report(LOG_ERR, "in regular expression %s", s);
}
-