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