]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/journal-remote/journal-remote-parse.h
Clear up confusion wrt. ENTRY_SIZE_MAX and DATA_SIZE_MAX
[thirdparty/systemd.git] / src / journal-remote / journal-remote-parse.h
CommitLineData
fdfccdbc
ZJS
1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
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
22#pragma once
23
24#include "sd-event.h"
25#include "journal-remote-write.h"
26
27typedef enum {
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 */
32 STATE_EOF, /* done */
33} source_state;
34
35typedef struct RemoteSource {
8201af08 36 char *name;
fdfccdbc 37 int fd;
9ff48d09 38 bool passive_fd;
fdfccdbc
ZJS
39
40 char *buf;
41 size_t size;
851d4e2a 42 size_t scanned;
fdfccdbc
ZJS
43 size_t filled;
44 size_t data_size;
45
46 struct iovec_wrapper iovw;
47
48 source_state state;
49 dual_timestamp ts;
50
9ff48d09
ZJS
51 Writer *writer;
52
fdfccdbc
ZJS
53 sd_event_source *event;
54} RemoteSource;
55
9ff48d09
ZJS
56RemoteSource* source_new(int fd, bool passive_fd, char *name, Writer *writer);
57
4a0a6ac0 58static inline size_t source_non_empty(RemoteSource *source) {
fdfccdbc
ZJS
59 assert(source);
60
4a0a6ac0 61 return source->filled;
fdfccdbc
ZJS
62}
63
64void source_free(RemoteSource *source);
65int process_data(RemoteSource *source);
cc64d017 66int push_data(RemoteSource *source, const char *data, size_t size);
9ff48d09 67int process_source(RemoteSource *source, bool compress, bool seal);