1 /* SPDX-License-Identifier: LGPL-2.1+ */
8 #include "string-table.h"
9 #include "syslog-util.h"
11 #if 0 /// UNNEEDED by elogind
12 int syslog_parse_priority(const char **p, int *priority, bool with_facility) {
13 int a = 0, b = 0, c = 0;
27 c = undecchar((*p)[1]);
29 } else if ((*p)[3] == '>') {
30 b = undecchar((*p)[1]);
31 c = undecchar((*p)[2]);
33 } else if ((*p)[4] == '>') {
34 a = undecchar((*p)[1]);
35 b = undecchar((*p)[2]);
36 c = undecchar((*p)[3]);
41 if (a < 0 || b < 0 || c < 0 ||
42 (!with_facility && (a || b || c > 7)))
46 *priority = a*100 + b*10 + c;
48 *priority = (*priority & LOG_FACMASK) | c;
55 static const char *const log_facility_unshifted_table[LOG_NFACILITIES] = {
56 [LOG_FAC(LOG_KERN)] = "kern",
57 [LOG_FAC(LOG_USER)] = "user",
58 [LOG_FAC(LOG_MAIL)] = "mail",
59 [LOG_FAC(LOG_DAEMON)] = "daemon",
60 [LOG_FAC(LOG_AUTH)] = "auth",
61 [LOG_FAC(LOG_SYSLOG)] = "syslog",
62 [LOG_FAC(LOG_LPR)] = "lpr",
63 [LOG_FAC(LOG_NEWS)] = "news",
64 [LOG_FAC(LOG_UUCP)] = "uucp",
65 [LOG_FAC(LOG_CRON)] = "cron",
66 [LOG_FAC(LOG_AUTHPRIV)] = "authpriv",
67 [LOG_FAC(LOG_FTP)] = "ftp",
68 [LOG_FAC(LOG_LOCAL0)] = "local0",
69 [LOG_FAC(LOG_LOCAL1)] = "local1",
70 [LOG_FAC(LOG_LOCAL2)] = "local2",
71 [LOG_FAC(LOG_LOCAL3)] = "local3",
72 [LOG_FAC(LOG_LOCAL4)] = "local4",
73 [LOG_FAC(LOG_LOCAL5)] = "local5",
74 [LOG_FAC(LOG_LOCAL6)] = "local6",
75 [LOG_FAC(LOG_LOCAL7)] = "local7"
78 DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(log_facility_unshifted, int, LOG_FAC(~0));
80 #if 0 /// UNNEEDED by elogind
81 bool log_facility_unshifted_is_valid(int facility) {
82 return facility >= 0 && facility <= LOG_FAC(~0);
86 static const char *const log_level_table[] = {
87 [LOG_EMERG] = "emerg",
88 [LOG_ALERT] = "alert",
91 [LOG_WARNING] = "warning",
92 [LOG_NOTICE] = "notice",
97 DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(log_level, int, LOG_DEBUG);
99 #if 0 /// UNNEEDED by elogind
100 bool log_level_is_valid(int level) {
101 return level >= 0 && level <= LOG_DEBUG;