sd-journal.h revision 85a131e8d8aa9fe3c2115e281569bed64a4200f1
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering#ifndef foojournalhfoo
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering#define foojournalhfoo
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering/***
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering This file is part of systemd.
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering Copyright 2011 Lennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering systemd is free software; you can redistribute it and/or modify it
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering under the terms of the GNU General Public License as published by
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering the Free Software Foundation; either version 2 of the License, or
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering (at your option) any later version.
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering systemd is distributed in the hope that it will be useful, but
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering General Public License for more details.
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering You should have received a copy of the GNU General Public License
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering***/
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering#include <inttypes.h>
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering#include <sys/types.h>
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering#include <stdarg.h>
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering#include <sys/uio.h>
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering#include "sd-id128.h"
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering/* TODO:
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering *
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering * - check LE/BE conversion for 8bit, 16bit, 32bit values
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering * - implement audit gateway
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering * - extend hash tables table as we go
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering * - accelerate looking for "all hostnames" and suchlike.
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering * - cryptographic hash
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering * - never access beyond fle size check
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering * - OR of matches is borked...
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering */
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering/* Write to daemon */
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint sd_journal_print(int piority, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint sd_journal_printv(int priority, const char *format, va_list ap);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint sd_journal_send(const char *format, ...) __attribute__((sentinel));
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint sd_journal_sendv(const struct iovec *iov, int n);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint sd_journal_stream_fd(const char *tag, int priority, int priority_prefix);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering/* Browse journal stream */
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringtypedef struct sd_journal sd_journal;
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint sd_journal_open(sd_journal **ret);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringvoid sd_journal_close(sd_journal *j);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint sd_journal_previous(sd_journal *j);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint sd_journal_next(sd_journal *j);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint sd_journal_previous_skip(sd_journal *j, uint64_t skip);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint sd_journal_next_skip(sd_journal *j, uint64_t skip);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint sd_journal_get_realtime_usec(sd_journal *j, uint64_t *ret);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint sd_journal_get_monotonic_usec(sd_journal *j, uint64_t *ret, sd_id128_t *ret_boot_id);
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poetteringint sd_journal_get_data(sd_journal *j, const char *field, const void **data, size_t *l);
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poetteringint sd_journal_enumerate_data(sd_journal *j, const void **data, size_t *l);
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poetteringvoid sd_journal_restart_data(sd_journal *j);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint sd_journal_add_match(sd_journal *j, const void *data, size_t size);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringvoid sd_journal_flush_matches(sd_journal *j);
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poetteringint sd_journal_seek_head(sd_journal *j);
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poetteringint sd_journal_seek_tail(sd_journal *j);
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poetteringint sd_journal_seek_monotonic_usec(sd_journal *j, sd_id128_t boot_id, uint64_t usec);
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poetteringint sd_journal_seek_realtime_usec(sd_journal *j, uint64_t usec);
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poetteringint sd_journal_seek_cursor(sd_journal *j, const char *cursor);
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poetteringint sd_journal_get_cursor(sd_journal *j, char **cursor);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint sd_journal_query_unique(sd_journal *j, const char *field); /* missing */
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint sd_journal_enumerate_unique(sd_journal *j, const void **data, size_t *l); /* missing */
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringvoid sd_journal_restart_unique(sd_journal *j); /* missing */
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringenum {
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering SD_JOURNAL_NOP,
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering SD_JOURNAL_APPEND,
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering SD_JOURNAL_INVALIDATE_ADD,
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering SD_JOURNAL_INVALIDATE_REMOVE
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering};
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint sd_journal_get_fd(sd_journal *j);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint sd_journal_process(sd_journal *j);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering#define SD_JOURNAL_FOREACH(j) \
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering if (sd_journal_seek_head(j) >= 0) \
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering while (sd_journal_next(j) > 0)
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering#define SD_JOURNAL_FOREACH_BACKWARDS(j) \
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering if (sd_journal_seek_tail(j) >= 0) \
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering while (sd_journal_previous(j) > 0)
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering#define SD_JOURNAL_FOREACH_DATA(j, data, l) \
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering for (sd_journal_restart_data(j); sd_journal_enumerate_data((j), &(data), &(l)) > 0; )
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering#define SD_JOURNAL_FOREACH_UNIQUE(j, data, l) \
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering for (sd_journal_restart_unique(j); sd_journal_enumerate_data((j), &(data), &(l)) > 0; )
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering#endif
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering