2 This file is part of systemd.
4 Copyright 2010 Lennart Poettering
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 #include "hexdecoct.h"
25 #include "string-table.h"
26 #include "syslog-util.h"
28 #if 0 /// UNNEEDED by elogind
29 int syslog_parse_priority(const char **p, int *priority, bool with_facility) {
30 int a = 0, b = 0, c = 0;
44 c = undecchar((*p)[1]);
46 } else if ((*p)[3] == '>') {
47 b = undecchar((*p)[1]);
48 c = undecchar((*p)[2]);
50 } else if ((*p)[4] == '>') {
51 a = undecchar((*p)[1]);
52 b = undecchar((*p)[2]);
53 c = undecchar((*p)[3]);
58 if (a < 0 || b < 0 || c < 0 ||
59 (!with_facility && (a || b || c > 7)))
63 *priority = a*100 + b*10 + c;
65 *priority = (*priority & LOG_FACMASK) | c;
72 static const char *const log_facility_unshifted_table[LOG_NFACILITIES] = {
73 [LOG_FAC(LOG_KERN)] = "kern",
74 [LOG_FAC(LOG_USER)] = "user",
75 [LOG_FAC(LOG_MAIL)] = "mail",
76 [LOG_FAC(LOG_DAEMON)] = "daemon",
77 [LOG_FAC(LOG_AUTH)] = "auth",
78 [LOG_FAC(LOG_SYSLOG)] = "syslog",
79 [LOG_FAC(LOG_LPR)] = "lpr",
80 [LOG_FAC(LOG_NEWS)] = "news",
81 [LOG_FAC(LOG_UUCP)] = "uucp",
82 [LOG_FAC(LOG_CRON)] = "cron",
83 [LOG_FAC(LOG_AUTHPRIV)] = "authpriv",
84 [LOG_FAC(LOG_FTP)] = "ftp",
85 [LOG_FAC(LOG_LOCAL0)] = "local0",
86 [LOG_FAC(LOG_LOCAL1)] = "local1",
87 [LOG_FAC(LOG_LOCAL2)] = "local2",
88 [LOG_FAC(LOG_LOCAL3)] = "local3",
89 [LOG_FAC(LOG_LOCAL4)] = "local4",
90 [LOG_FAC(LOG_LOCAL5)] = "local5",
91 [LOG_FAC(LOG_LOCAL6)] = "local6",
92 [LOG_FAC(LOG_LOCAL7)] = "local7"
95 DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(log_facility_unshifted, int, LOG_FAC(~0));
97 #if 0 /// UNNEEDED by elogind
98 bool log_facility_unshifted_is_valid(int facility) {
99 return facility >= 0 && facility <= LOG_FAC(~0);
103 static const char *const log_level_table[] = {
104 [LOG_EMERG] = "emerg",
105 [LOG_ALERT] = "alert",
108 [LOG_WARNING] = "warning",
109 [LOG_NOTICE] = "notice",
111 [LOG_DEBUG] = "debug"
114 DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(log_level, int, LOG_DEBUG);
116 #if 0 /// UNNEEDED by elogind
117 bool log_level_is_valid(int level) {
118 return level >= 0 && level <= LOG_DEBUG;