summaryrefslogtreecommitdiff
path: root/log.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>1999-11-21 13:23:52 +1100
committerDamien Miller <djm@mindrot.org>1999-11-21 13:23:52 +1100
commit6162d1215bbff30cf0c4c19368dc85ae570d44ca (patch)
treef82956b4429cad04a2296a1ede65e147bafb92f4 /log.c
parentf58db38f8d396ee5ea42975d9409a644e01cede8 (diff)
downloadopenssh-git-6162d1215bbff30cf0c4c19368dc85ae570d44ca.tar.gz
- OpenBSD CVS Changes
- [channels.c] make this compile, bad markus - [log.c readconf.c servconf.c ssh.h] bugfix: loglevels are per host in clientconfig, factor out common log-level parsing code. - [servconf.c] remove unused index (-Wall) - [ssh-agent.c] only one 'extern char *__progname' - [sshd.8] document SIGHUP, -Q to synopsis - [sshconnect.c serverloop.c sshd.c packet.c packet.h] [channels.c clientloop.c] SSH_CMSG_MAX_PACKET_SIZE, some clients use this, some need this, niels@ [hope this time my ISP stays alive during commit]
Diffstat (limited to 'log.c')
-rw-r--r--log.c62
1 files changed, 61 insertions, 1 deletions
diff --git a/log.c b/log.c
index 3e840ecb..1ce534ea 100644
--- a/log.c
+++ b/log.c
@@ -5,7 +5,7 @@ Shared versions of debug(), log(), etc.
*/
#include "includes.h"
-RCSID("$OpenBSD: log.c,v 1.1 1999/11/10 23:36:44 markus Exp $");
+RCSID("$OpenBSD: log.c,v 1.2 1999/11/19 16:04:17 markus Exp $");
#include "ssh.h"
#include "xmalloc.h"
@@ -133,3 +133,63 @@ fatal_cleanup(void)
exit(255);
}
+
+/* textual representation of log-facilities/levels */
+
+
+static struct
+{
+ const char *name;
+ SyslogFacility val;
+} log_facilities[] =
+{
+ { "DAEMON", SYSLOG_FACILITY_DAEMON },
+ { "USER", SYSLOG_FACILITY_USER },
+ { "AUTH", SYSLOG_FACILITY_AUTH },
+ { "LOCAL0", SYSLOG_FACILITY_LOCAL0 },
+ { "LOCAL1", SYSLOG_FACILITY_LOCAL1 },
+ { "LOCAL2", SYSLOG_FACILITY_LOCAL2 },
+ { "LOCAL3", SYSLOG_FACILITY_LOCAL3 },
+ { "LOCAL4", SYSLOG_FACILITY_LOCAL4 },
+ { "LOCAL5", SYSLOG_FACILITY_LOCAL5 },
+ { "LOCAL6", SYSLOG_FACILITY_LOCAL6 },
+ { "LOCAL7", SYSLOG_FACILITY_LOCAL7 },
+ { NULL, 0 }
+};
+
+static struct
+{
+ const char *name;
+ LogLevel val;
+} log_levels[] =
+{
+ { "QUIET", SYSLOG_LEVEL_QUIET },
+ { "FATAL", SYSLOG_LEVEL_FATAL },
+ { "ERROR", SYSLOG_LEVEL_ERROR },
+ { "INFO", SYSLOG_LEVEL_INFO },
+ { "CHAT", SYSLOG_LEVEL_CHAT },
+ { "DEBUG", SYSLOG_LEVEL_DEBUG },
+ { NULL, 0 }
+};
+
+SyslogFacility
+log_facility_number(char *name)
+{
+ int i;
+ if (name != NULL)
+ for (i = 0; log_facilities[i].name; i++)
+ if (strcasecmp(log_facilities[i].name, name) == 0)
+ return log_facilities[i].val;
+ return (SyslogFacility)-1;
+}
+
+LogLevel
+log_level_number(char *name)
+{
+ int i;
+ if (name != NULL)
+ for (i = 0; log_levels[i].name; i++)
+ if (strcasecmp(log_levels[i].name, name) == 0)
+ return log_levels[i].val;
+ return (LogLevel)-1;
+}