1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2014 Zbigniew Jędrzejewski-Szmek
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
25 #include "journal-remote-write.h"
28 STATE_LINE = 0, /* waiting to read, or reading line */
29 STATE_DATA_START, /* reading binary data header */
30 STATE_DATA, /* reading binary data */
31 STATE_DATA_FINISH, /* expecting newline */
35 typedef struct RemoteSource {
41 size_t size; /* total size of the buffer */
42 size_t offset; /* offset to the beginning of live data in the buffer */
43 size_t scanned; /* number of bytes since the beginning of data without a newline */
44 size_t filled; /* total number of bytes in the buffer */
45 size_t data_size; /* size of the binary data chunk being processed */
47 struct iovec_wrapper iovw;
54 sd_event_source *event;
57 RemoteSource* source_new(int fd, bool passive_fd, char *name, Writer *writer);
59 static inline size_t source_non_empty(RemoteSource *source) {
62 return source->filled;
65 void source_free(RemoteSource *source);
66 int process_data(RemoteSource *source);
67 int push_data(RemoteSource *source, const char *data, size_t size);
68 int process_source(RemoteSource *source, bool compress, bool seal);