X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=logger.c;h=7194320c4760f091d4fca4c43c689d26a45c7872;hb=97c4f35cd541baa2f985ff702a5b9f0b8b524a53;hp=8cdc7d20b244b3bd69f466c04827f06907019f55;hpb=f94ea366d38fed424200b748cb042ca44f8c8d50;p=elogind.git
diff --git a/logger.c b/logger.c
index 8cdc7d20b..7194320c4 100644
--- a/logger.c
+++ b/logger.c
@@ -1,5 +1,24 @@
/*-*- Mode: C; c-basic-offset: 8 -*-*/
+/***
+ This file is part of systemd.
+
+ Copyright 2010 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with systemd; If not, see .
+***/
+
#include
#include
#include
@@ -43,11 +62,6 @@ typedef enum StreamState {
STREAM_RUNNING
} StreamState;
-typedef enum LogTarget {
- LOG_TARGET_SYSLOG,
- LOG_TARGET_KMSG
-} LogTarget;
-
struct Stream {
Server *server;
@@ -67,16 +81,9 @@ struct Stream {
LIST_FIELDS(Stream, stream);
};
-#define IOVEC_SET_STRING(iovec, s) \
- do { \
- (iovec).iov_base = s; \
- (iovec).iov_len = strlen(s); \
- } while(false);
-
static int stream_log(Stream *s, char *p, usec_t timestamp) {
char header_priority[16], header_time[64], header_pid[16];
- struct msghdr msghdr;
struct iovec iovec[5];
assert(s);
@@ -120,6 +127,8 @@ static int stream_log(Stream *s, char *p, usec_t timestamp) {
IOVEC_SET_STRING(iovec[0], header_priority);
if (s->target == LOG_TARGET_SYSLOG) {
+ struct msghdr msghdr;
+
IOVEC_SET_STRING(iovec[1], header_time);
IOVEC_SET_STRING(iovec[2], s->process);
IOVEC_SET_STRING(iovec[3], header_pid);
@@ -136,7 +145,7 @@ static int stream_log(Stream *s, char *p, usec_t timestamp) {
IOVEC_SET_STRING(iovec[1], s->process);
IOVEC_SET_STRING(iovec[2], header_pid);
IOVEC_SET_STRING(iovec[3], p);
- IOVEC_SET_STRING(iovec[4], "\n");
+ IOVEC_SET_STRING(iovec[4], (char*) "\n");
if (writev(s->server->kmsg_fd, iovec, ELEMENTSOF(iovec)) < 0)
return -errno;
@@ -529,9 +538,9 @@ int main(int argc, char *argv[]) {
for (;;) {
struct epoll_event event;
- int n;
+ int k;
- if ((n = epoll_wait(server.epoll_fd,
+ if ((k = epoll_wait(server.epoll_fd,
&event, 1,
server.n_streams <= 0 ? TIMEOUT : -1)) < 0) {
@@ -542,10 +551,10 @@ int main(int argc, char *argv[]) {
goto fail;
}
- if (n <= 0)
+ if (k <= 0)
break;
- if ((r = process_event(&server, &event)) < 0)
+ if ((k = process_event(&server, &event)) < 0)
goto fail;
}
r = 0;