summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-06-20 22:40:10 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-06-20 23:03:58 -0400
commitfd59d9f29838c3888168554c774003e7ad6d33b0 (patch)
tree9c079a2c4fe074a98daf9267f21121f39359609c /src/journal
parent1021b21bc6f8dd522b46116e8598b17f9f93f1b7 (diff)
Add hasprefix macro to check prefixes of fixed length
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/journal-send.c2
-rw-r--r--src/journal/journald-native.c10
2 files changed, 6 insertions, 6 deletions
diff --git a/src/journal/journal-send.c b/src/journal/journal-send.c
index da1f89268..fef66fc29 100644
--- a/src/journal/journal-send.c
+++ b/src/journal/journal-send.c
@@ -245,7 +245,7 @@ _public_ int sd_journal_sendv(const struct iovec *iov, int n) {
have_syslog_identifier = have_syslog_identifier ||
(c == (char *) iov[i].iov_base + 17 &&
- memcmp(iov[i].iov_base, "SYSLOG_IDENTIFIER", 17) == 0);
+ hasprefix(iov[i].iov_base, "SYSLOG_IDENTIFIER"));
nl = memchr(iov[i].iov_base, '\n', iov[i].iov_len);
if (nl) {
diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c
index f878dfc91..ec9afa187 100644
--- a/src/journal/journald-native.c
+++ b/src/journal/journald-native.c
@@ -158,23 +158,23 @@ void server_process_native_message(
* of this entry for the rate limiting
* logic */
if (l == 10 &&
- memcmp(p, "PRIORITY=", 9) == 0 &&
+ hasprefix(p, "PRIORITY=") &&
p[9] >= '0' && p[9] <= '9')
priority = (priority & LOG_FACMASK) | (p[9] - '0');
else if (l == 17 &&
- memcmp(p, "SYSLOG_FACILITY=", 16) == 0 &&
+ hasprefix(p, "SYSLOG_FACILITY=") &&
p[16] >= '0' && p[16] <= '9')
priority = (priority & LOG_PRIMASK) | ((p[16] - '0') << 3);
else if (l == 18 &&
- memcmp(p, "SYSLOG_FACILITY=", 16) == 0 &&
+ hasprefix(p, "SYSLOG_FACILITY=") &&
p[16] >= '0' && p[16] <= '9' &&
p[17] >= '0' && p[17] <= '9')
priority = (priority & LOG_PRIMASK) | (((p[16] - '0')*10 + (p[17] - '0')) << 3);
else if (l >= 19 &&
- memcmp(p, "SYSLOG_IDENTIFIER=", 18) == 0) {
+ hasprefix(p, "SYSLOG_IDENTIFIER=")) {
char *t;
t = strndup(p + 18, l - 18);
@@ -183,7 +183,7 @@ void server_process_native_message(
identifier = t;
}
} else if (l >= 8 &&
- memcmp(p, "MESSAGE=", 8) == 0) {
+ hasprefix(p, "MESSAGE=")) {
char *t;
t = strndup(p + 8, l - 8);