]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/journal-remote/journal-remote.h
journal-remote: simplify error handling a bit
[thirdparty/systemd.git] / src / journal-remote / journal-remote.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include "sd-event.h"
5
6 #include "hashmap.h"
7 #include "journal-remote-parse.h"
8 #include "journal-remote-write.h"
9 #include "journal-vacuum.h"
10
11 #if HAVE_MICROHTTPD
12 #include "microhttpd-util.h"
13
14 typedef struct MHDDaemonWrapper MHDDaemonWrapper;
15
16 struct MHDDaemonWrapper {
17 uint64_t fd;
18 struct MHD_Daemon *daemon;
19
20 sd_event_source *io_event;
21 sd_event_source *timer_event;
22 };
23
24 MHDDaemonWrapper *MHDDaemonWrapper_free(MHDDaemonWrapper *d);
25 DEFINE_TRIVIAL_CLEANUP_FUNC(MHDDaemonWrapper*, MHDDaemonWrapper_free);
26 #endif
27
28 struct RemoteServer {
29 RemoteSource **sources;
30 size_t active;
31
32 sd_event *events;
33 sd_event_source *sigterm_event, *sigint_event, *listen_event;
34
35 Hashmap *writers;
36 Writer *_single_writer;
37 uint64_t event_count;
38
39 #if HAVE_MICROHTTPD
40 Hashmap *daemons;
41 #endif
42 const char *output; /* either the output file or directory */
43
44 JournalWriteSplitMode split_mode;
45 JournalFileFlags file_flags;
46 bool check_trust;
47 JournalMetrics metrics;
48 };
49 extern RemoteServer *journal_remote_server_global;
50
51 int journal_remote_server_init(
52 RemoteServer *s,
53 const char *output,
54 JournalWriteSplitMode split_mode,
55 JournalFileFlags file_flags);
56
57 int journal_remote_get_writer(RemoteServer *s, const char *host, Writer **writer);
58
59 int journal_remote_add_source(RemoteServer *s, int fd, char* name, bool own_name);
60 int journal_remote_add_raw_socket(RemoteServer *s, int fd);
61 int journal_remote_handle_raw_source(
62 sd_event_source *event,
63 int fd,
64 uint32_t revents,
65 RemoteServer *s);
66
67 void journal_remote_server_destroy(RemoteServer *s);