chiark / gitweb /
Revert "socket: add support for TCP fast Open"
[elogind.git] / src / journal-remote / journal-upload.h
1 #pragma once
2
3 #include <inttypes.h>
4
5 #include "sd-journal.h"
6 #include "sd-event.h"
7
8 typedef 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
22 typedef struct Uploader {
23         sd_event *events;
24         sd_event_source *sigint_event, *sigterm_event;
25
26         char *url;
27         CURL *easy;
28         bool uploading;
29         char error[CURL_ERROR_SIZE];
30         struct curl_slist *header;
31         char *answer;
32
33         sd_event_source *input_event;
34         uint64_t timeout;
35
36         /* fd stuff */
37         int input;
38
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 */
47         const char *state_file;
48
49         size_t entries_sent;
50         char *last_cursor, *current_cursor;
51 } Uploader;
52
53 #define JOURNAL_UPLOAD_POLL_TIMEOUT (10 * USEC_PER_SEC)
54
55 int 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);
61
62 int open_journal_for_upload(Uploader *u,
63                             sd_journal *j,
64                             const char *cursor,
65                             bool after_cursor,
66                             bool follow);
67 void close_journal_input(Uploader *u);
68 int check_journal_input(Uploader *u);