mirror of
https://github.com/clearlinux/tallow.git
synced 2026-04-28 10:23:35 +00:00
tallow: a quick demo / lard replacement.
This commit is contained in:
3
autogen.sh
Executable file
3
autogen.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
autoreconf -vif
|
||||
17
configure.ac
Normal file
17
configure.ac
Normal file
@@ -0,0 +1,17 @@
|
||||
# -*- Autoconf -*-
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ([2.64])
|
||||
AC_INIT([tallow], [0], [auke-jan.h.kok@intel.com])
|
||||
AM_INIT_AUTOMAKE([])
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
|
||||
# Systemd is required, obviously
|
||||
PKG_CHECK_MODULES([SYSTEMD], [systemd])
|
||||
PKG_CHECK_MODULES([SD_JOURNAL], [libsystemd-journal])
|
||||
|
||||
SYSTEMDSYSTEMUNITDIR="`$PKG_CONFIG --variable=systemdsystemunitdir systemd`"
|
||||
AC_SUBST(SYSTEMDSYSTEMUNITDIR)
|
||||
|
||||
AC_OUTPUT([
|
||||
])
|
||||
38
tallow.c
Normal file
38
tallow.c
Normal file
@@ -0,0 +1,38 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <systemd/sd-journal.h>
|
||||
|
||||
#define FILTER_STRING "SYSLOG_IDENTIFIER=sshd"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int r;
|
||||
sd_journal *j;
|
||||
|
||||
r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY);
|
||||
if (r < 0) {
|
||||
fprintf(stderr, "Failed to open journal: %s\n", strerror(-r));
|
||||
return 1;
|
||||
}
|
||||
|
||||
sd_journal_add_match(j, FILTER_STRING, 0);
|
||||
sd_journal_seek_tail(j);
|
||||
|
||||
while (sd_journal_wait(j, (uint64_t) -1)) {
|
||||
const void *d;
|
||||
size_t l;
|
||||
|
||||
while (sd_journal_next(j) != 0) {
|
||||
if (sd_journal_get_data(j, "MESSAGE", &d, &l) < 0) {
|
||||
fprintf(stderr, "Failed to read message field: %s\n", strerror(-r));
|
||||
continue;
|
||||
}
|
||||
|
||||
/* read and parse messages */
|
||||
fprintf(stderr, "%.*s\n", (int) l, d);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user