journal-remote-parse.h revision 8201af08fa09c2bd0f005fbe262f27e2c5bd2d86
6673N/A/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6673N/A
6673N/A/***
6673N/A This file is part of systemd.
6673N/A
6673N/A Copyright 2014 Zbigniew Jędrzejewski-Szmek
6673N/A
6673N/A systemd is free software; you can redistribute it and/or modify it
6673N/A under the terms of the GNU Lesser General Public License as published by
6673N/A the Free Software Foundation; either version 2.1 of the License, or
6673N/A (at your option) any later version.
6673N/A
6673N/A systemd is distributed in the hope that it will be useful, but
6673N/A WITHOUT ANY WARRANTY; without even the implied warranty of
6673N/A MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6673N/A Lesser General Public License for more details.
6673N/A
6673N/A You should have received a copy of the GNU Lesser General Public License
6673N/A along with systemd; If not, see <http://www.gnu.org/licenses/>.
6673N/A***/
6673N/A
6673N/A#pragma once
6673N/A
6673N/A#include "sd-event.h"
6673N/A#include "journal-remote-write.h"
6673N/A
6673N/Atypedef enum {
6673N/A STATE_LINE = 0, /* waiting to read, or reading line */
6673N/A STATE_DATA_START, /* reading binary data header */
6673N/A STATE_DATA, /* reading binary data */
6673N/A STATE_DATA_FINISH, /* expecting newline */
6673N/A STATE_EOF, /* done */
6673N/A} source_state;
6673N/A
6673N/Atypedef struct RemoteSource {
6673N/A char *name;
6673N/A int fd;
6673N/A
6673N/A char *buf;
6673N/A size_t size;
6673N/A size_t scanned;
6673N/A size_t filled;
6673N/A size_t data_size;
6673N/A
6673N/A struct iovec_wrapper iovw;
6673N/A
6673N/A source_state state;
6673N/A dual_timestamp ts;
6673N/A
6673N/A sd_event_source *event;
6673N/A} RemoteSource;
6673N/A
6673N/Astatic inline int source_non_empty(RemoteSource *source) {
6673N/A assert(source);
6673N/A
6673N/A return source->filled > 0;
6673N/A}
6673N/A
6673N/Avoid source_free(RemoteSource *source);
6673N/Aint process_data(RemoteSource *source);
6673N/Aint push_data(RemoteSource *source, const char *data, size_t size);
6673N/Aint process_source(RemoteSource *source, Writer *writer, bool compress, bool seal);
6673N/A