Debian Codegraph @

src/shared/journal-importer.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #pragma once
4
5 #include "sd-id128.h"
6
7 #include "shared-forward.h"
8 #include "iovec-wrapper.h"
9 #include "time-util.h"
10
11 #define LINE_CHUNK 8*1024u
12
13 typedef struct JournalImporter {
14 int fd;
15 bool passive_fd;
16 char *name;
17
18 char *buf;
19 size_t offset; /* offset to the beginning of live data in the buffer */
20 size_t scanned; /* number of bytes since the beginning of data without a newline */
21 size_t filled; /* total number of bytes in the buffer */
22
23 size_t field_len; /* used for binary fields: the field name length */
24 size_t data_size; /* and the size of the binary data chunk being processed */
25
26 struct iovec_wrapper iovw;
27
28 int state;
29 dual_timestamp ts;
30 sd_id128_t boot_id;
31 } JournalImporter;
32
33 #define JOURNAL_IMPORTER_INIT(_fd) { .fd = (_fd), .iovw = {} }
34 #define JOURNAL_IMPORTER_MAKE(_fd) (JournalImporter) JOURNAL_IMPORTER_INIT(_fd)
35
36 void journal_importer_cleanup(JournalImporter *imp);
37 int journal_importer_process_data(JournalImporter *imp);
38 int journal_importer_push_data(JournalImporter *imp, const char *data, size_t size);
39 void journal_importer_drop_iovw(JournalImporter *imp);
40 bool journal_importer_eof(const JournalImporter *imp);
41
42 static inline size_t journal_importer_bytes_remaining(const JournalImporter *imp) {
43 return imp->filled;
44 }