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 10 #if HAVE_MICROHTTPD 11 #include "microhttpd-util.h" 12 13 typedef struct MHDDaemonWrapper MHDDaemonWrapper; 14 15 struct MHDDaemonWrapper { 16 uint64_t fd; 17 struct MHD_Daemon *daemon; 18 19 sd_event_source *io_event; 20 sd_event_source *timer_event; 21 }; 22 #endif 23 24 struct RemoteServer { 25 RemoteSource **sources; 26 size_t active; 27 28 sd_event *events; 29 sd_event_source *sigterm_event, *sigint_event, *listen_event; 30 31 Hashmap *writers; 32 Writer *_single_writer; 33 uint64_t event_count; 34 35 #if HAVE_MICROHTTPD 36 Hashmap *daemons; 37 #endif 38 const char *output; /* either the output file or directory */ 39 40 JournalWriteSplitMode split_mode; 41 JournalFileFlags file_flags; 42 bool check_trust; 43 }; 44 extern RemoteServer *journal_remote_server_global; 45 46 int journal_remote_server_init( 47 RemoteServer *s, 48 const char *output, 49 JournalWriteSplitMode split_mode, 50 JournalFileFlags file_flags); 51 52 int journal_remote_get_writer(RemoteServer *s, const char *host, Writer **writer); 53 54 int journal_remote_add_source(RemoteServer *s, int fd, char* name, bool own_name); 55 int journal_remote_add_raw_socket(RemoteServer *s, int fd); 56 int journal_remote_handle_raw_source( 57 sd_event_source *event, 58 int fd, 59 uint32_t revents, 60 RemoteServer *s); 61 62 void journal_remote_server_destroy(RemoteServer *s); 63