]> git.ipfire.org Git - thirdparty/systemd.git/blame_incremental - src/journal-remote/journal-upload.h
ukify: fix parsing uname version with '+'
[thirdparty/systemd.git] / src / journal-remote / journal-upload.h
... / ...
CommitLineData
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3#pragma once
4
5#include <curl/curl.h>
6
7#include "forward.h"
8#include "journal-compression-util.h"
9
10typedef enum {
11 ENTRY_CURSOR = 0, /* Nothing actually written yet. */
12 ENTRY_REALTIME,
13 ENTRY_MONOTONIC,
14 ENTRY_BOOT_ID,
15 ENTRY_NEW_FIELD, /* In between fields. */
16 ENTRY_TEXT_FIELD, /* In the middle of a text field. */
17 ENTRY_BINARY_FIELD_START, /* Writing the name of a binary field. */
18 ENTRY_BINARY_FIELD_SIZE, /* Writing the size of a binary field. */
19 ENTRY_BINARY_FIELD, /* In the middle of a binary field. */
20 ENTRY_OUTRO, /* Writing '\n' */
21 ENTRY_DONE, /* Need to move to a new field. */
22} entry_state;
23
24typedef struct Uploader {
25 sd_event *event;
26
27 char *url;
28 CURL *easy;
29 bool uploading;
30 char error[CURL_ERROR_SIZE];
31 struct curl_slist *header;
32 char *answer;
33
34 sd_event_source *input_event;
35 uint64_t timeout;
36
37 /* fd stuff */
38 int input;
39
40 /* journal stuff */
41 sd_journal *journal;
42
43 entry_state entry_state;
44 const void *field_data;
45 size_t field_pos, field_length;
46
47 /* general metrics */
48 const char *state_file;
49
50 size_t entries_sent;
51 char *last_cursor, *current_cursor;
52 usec_t watchdog_timestamp;
53 usec_t watchdog_usec;
54 const CompressionConfig *compression;
55} Uploader;
56
57#define JOURNAL_UPLOAD_POLL_TIMEOUT (10 * USEC_PER_SEC)
58
59int start_upload(Uploader *u,
60 size_t (*input_callback)(void *ptr,
61 size_t size,
62 size_t nmemb,
63 void *userdata),
64 void *data);
65
66int open_journal_for_upload(Uploader *u,
67 sd_journal *j,
68 const char *cursor,
69 bool after_cursor,
70 bool follow);
71void close_journal_input(Uploader *u);
72int check_journal_input(Uploader *u);