]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/basic/journal-importer.h
util: introduce memcmp_safe()
[thirdparty/systemd.git] / src / basic / journal-importer.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
b18453ed
ZJS
2
3#pragma once
4
5#include <stddef.h>
6#include <stdbool.h>
7#include <sys/uio.h>
8
c0b6ada7
ZJS
9#include "sd-id128.h"
10
b18453ed
ZJS
11#include "time-util.h"
12
13/* Make sure not to make this smaller than the maximum coredump size.
14 * See COREDUMP_MAX in coredump.c */
15#define ENTRY_SIZE_MAX (1024*1024*770u)
16#define DATA_SIZE_MAX (1024*1024*768u)
17#define LINE_CHUNK 8*1024u
18
19struct iovec_wrapper {
20 struct iovec *iovec;
21 size_t size_bytes;
22 size_t count;
23};
24
25size_t iovw_size(struct iovec_wrapper *iovw);
26
27typedef struct JournalImporter {
28 int fd;
29 bool passive_fd;
30 char *name;
31
32 char *buf;
33 size_t size; /* total size of the buffer */
34 size_t offset; /* offset to the beginning of live data in the buffer */
35 size_t scanned; /* number of bytes since the beginning of data without a newline */
36 size_t filled; /* total number of bytes in the buffer */
37
38 size_t field_len; /* used for binary fields: the field name length */
39 size_t data_size; /* and the size of the binary data chunk being processed */
40
41 struct iovec_wrapper iovw;
42
43 int state;
44 dual_timestamp ts;
c0b6ada7 45 sd_id128_t boot_id;
b18453ed
ZJS
46} JournalImporter;
47
48void journal_importer_cleanup(JournalImporter *);
49int journal_importer_process_data(JournalImporter *);
50int journal_importer_push_data(JournalImporter *, const char *data, size_t size);
51void journal_importer_drop_iovw(JournalImporter *);
52bool journal_importer_eof(const JournalImporter *);
53
54static inline size_t journal_importer_bytes_remaining(const JournalImporter *imp) {
55 return imp->filled;
56}