summaryrefslogtreecommitdiff
path: root/src/splogger.c
diff options
context:
space:
mode:
authorJannis Hoffmann <jannis@fehcom.de>2024-07-03 15:52:39 +0200
committerJannis Hoffmann <jannis@fehcom.de>2024-07-03 15:52:39 +0200
commita6a7d6ce079cabdaf2fa502b2e2cf15e5428ac6f (patch)
treeb88cc7a8457658d67e0321718556ac807f6bccf3 /src/splogger.c
parent00be7622c428f279872f84569f098ce16150f8a8 (diff)
format files
Diffstat (limited to 'src/splogger.c')
-rw-r--r--src/splogger.c48
1 files changed, 26 insertions, 22 deletions
diff --git a/src/splogger.c b/src/splogger.c
index 4e64590..2dcfe2a 100644
--- a/src/splogger.c
+++ b/src/splogger.c
@@ -1,29 +1,30 @@
-#include <sys/types.h>
#include <sys/time.h>
+#include <sys/types.h>
#include <syslog.h>
#include <unistd.h>
-#include "error.h"
+
#include "buffer.h"
+#include "error.h"
#include "exit.h"
-#include "str.h"
-#include "scan.h"
#include "fmt.h"
+#include "scan.h"
+#include "str.h"
-char buf[800]; /* syslog truncates long lines (or crashes); GPACIC */
+char buf[800]; /* syslog truncates long lines (or crashes); GPACIC */
int bufpos = 0; /* 0 <= bufpos < sizeof(buf) */
int flagcont = 0;
-int priority; /* defined if flagcont */
+int priority; /* defined if flagcont */
char stamp[FMT_ULONG + FMT_ULONG + 3]; /* defined if flagcont */
void stamp_make()
{
struct timeval tv;
char *s;
- gettimeofday(&tv,(struct timezone *) 0);
+ gettimeofday(&tv, (struct timezone *)0);
s = stamp;
- s += fmt_ulong(s,(unsigned long) tv.tv_sec);
+ s += fmt_ulong(s, (unsigned long)tv.tv_sec);
*s++ = '.';
- s += fmt_uint0(s,(unsigned int) tv.tv_usec,6);
+ s += fmt_uint0(s, (unsigned int)tv.tv_usec, 6);
*s = 0;
}
@@ -32,37 +33,40 @@ void flush()
if (bufpos) {
buf[bufpos] = 0;
if (flagcont)
- syslog(priority,"%s+%s",stamp,buf); /* logger folds invisibly; GPACIC */
+ syslog(priority, "%s+%s", stamp, buf); /* logger folds invisibly; GPACIC */
else {
stamp_make();
priority = LOG_INFO;
- if (str_start(buf,"warning:")) priority = LOG_WARNING;
- if (str_start(buf,"alert:")) priority = LOG_ALERT;
- syslog(priority,"%s %s",stamp,buf);
+ if (str_start(buf, "warning:")) priority = LOG_WARNING;
+ if (str_start(buf, "alert:")) priority = LOG_ALERT;
+ syslog(priority, "%s %s", stamp, buf);
flagcont = 1;
}
}
bufpos = 0;
}
-int main(int argc,char **argv)
+int main(int argc, char **argv)
{
char ch;
if (argv[1])
if (argv[2]) {
unsigned long facility;
- scan_ulong(argv[2],&facility);
- openlog(argv[1],0,facility << 3);
- }
- else
- openlog(argv[1],0,LOG_MAIL);
+ scan_ulong(argv[2], &facility);
+ openlog(argv[1], 0, facility << 3);
+ } else
+ openlog(argv[1], 0, LOG_MAIL);
else
- openlog("splogger",0,LOG_MAIL);
+ openlog("splogger", 0, LOG_MAIL);
for (;;) {
- if (buffer_get(buffer_0,&ch,1) < 1) _exit(0);
- if (ch == '\n') { flush(); flagcont = 0; continue; }
+ if (buffer_get(buffer_0, &ch, 1) < 1) _exit(0);
+ if (ch == '\n') {
+ flush();
+ flagcont = 0;
+ continue;
+ }
if (bufpos == sizeof(buf) - 1) flush();
if ((ch < 32) || (ch > 126)) ch = '?'; /* logger truncates at 0; GPACIC */
buf[bufpos++] = ch;