]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/journal-remote/journal-remote-parse.h
Merge pull request #5146 from ssahani/ifname-alias
[thirdparty/systemd.git] / src / journal-remote / journal-remote-parse.h
CommitLineData
0ef6f454
LP
1#pragma once
2
fdfccdbc
ZJS
3/***
4 This file is part of systemd.
5
6 Copyright 2014 Zbigniew Jędrzejewski-Szmek
7
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.
12
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.
17
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/>.
20***/
21
fdfccdbc 22#include "sd-event.h"
71d35b6b 23
fdfccdbc
ZJS
24#include "journal-remote-write.h"
25
26typedef enum {
27 STATE_LINE = 0, /* waiting to read, or reading line */
28 STATE_DATA_START, /* reading binary data header */
29 STATE_DATA, /* reading binary data */
30 STATE_DATA_FINISH, /* expecting newline */
31 STATE_EOF, /* done */
32} source_state;
33
34typedef struct RemoteSource {
8201af08 35 char *name;
fdfccdbc 36 int fd;
9ff48d09 37 bool passive_fd;
fdfccdbc
ZJS
38
39 char *buf;
92b10cbc
ZJS
40 size_t size; /* total size of the buffer */
41 size_t offset; /* offset to the beginning of live data in the buffer */
42 size_t scanned; /* number of bytes since the beginning of data without a newline */
43 size_t filled; /* total number of bytes in the buffer */
09d801a8
ZJS
44
45 size_t field_len; /* used for binary fields: the field name length */
46 size_t data_size; /* and the size of the binary data chunk being processed */
fdfccdbc
ZJS
47
48 struct iovec_wrapper iovw;
49
50 source_state state;
51 dual_timestamp ts;
52
9ff48d09
ZJS
53 Writer *writer;
54
fdfccdbc 55 sd_event_source *event;
043945b9 56 sd_event_source *buffer_event;
fdfccdbc
ZJS
57} RemoteSource;
58
9ff48d09
ZJS
59RemoteSource* source_new(int fd, bool passive_fd, char *name, Writer *writer);
60
4a0a6ac0 61static inline size_t source_non_empty(RemoteSource *source) {
fdfccdbc
ZJS
62 assert(source);
63
4a0a6ac0 64 return source->filled;
fdfccdbc
ZJS
65}
66
67void source_free(RemoteSource *source);
cc64d017 68int push_data(RemoteSource *source, const char *data, size_t size);
9ff48d09 69int process_source(RemoteSource *source, bool compress, bool seal);