summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-04-03 22:14:34 +0200
committerLennart Poettering <lennart@poettering.net>2011-04-03 22:15:14 +0200
commit7c3b203c5c69fc37c8d143851cd395cbf8920786 (patch)
tree7702142c649171975c0b69a1c354652e48dfee2a /src/util.c
parent5b754353282e3ba3cf9c4ffc50579aff4b7d72db (diff)
kmsg-syslogd: pass facility value into kmsg
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 2a5f3074b6..a1686ed389 100644
--- a/src/util.c
+++ b/src/util.c
@@ -4191,6 +4191,42 @@ bool plymouth_running(void) {
return access("/run/plymouth/pid", F_OK) >= 0;
}
+void parse_syslog_priority(char **p, int *priority) {
+ int a = 0, b = 0, c = 0;
+ int k;
+
+ assert(p);
+ assert(*p);
+ assert(priority);
+
+ if ((*p)[0] != '<')
+ return;
+
+ if (!strchr(*p, '>'))
+ return;
+
+ if ((*p)[2] == '>') {
+ c = undecchar((*p)[1]);
+ k = 3;
+ } else if ((*p)[3] == '>') {
+ b = undecchar((*p)[1]);
+ c = undecchar((*p)[2]);
+ k = 4;
+ } else if ((*p)[4] == '>') {
+ a = undecchar((*p)[1]);
+ b = undecchar((*p)[2]);
+ c = undecchar((*p)[3]);
+ k = 5;
+ } else
+ return;
+
+ if (a < 0 || b < 0 || c < 0)
+ return;
+
+ *priority = a*100+b*10+c;
+ *p += k;
+}
+
static const char *const ioprio_class_table[] = {
[IOPRIO_CLASS_NONE] = "none",
[IOPRIO_CLASS_RT] = "realtime",