]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/journal/journal-remote-parse.h
Remove unnecessary casts in printfs
[thirdparty/systemd.git] / src / journal / 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 {
36 char* name;
37 int fd;
38
39 char *buf;
40 size_t size;
41 size_t filled;
42 size_t data_size;
43
44 struct iovec_wrapper iovw;
45
46 source_state state;
47 dual_timestamp ts;
48
49 sd_event_source *event;
50} RemoteSource;
51
52static inline int source_non_empty(RemoteSource *source) {
53 assert(source);
54
55 return source->filled > 0;
56}
57
58void source_free(RemoteSource *source);
59int process_data(RemoteSource *source);
cc64d017 60int push_data(RemoteSource *source, const char *data, size_t size);
fdfccdbc 61int process_source(RemoteSource *source, Writer *writer, bool compress, bool seal);