summaryrefslogtreecommitdiff
path: root/src/journal-remote/journal-upload.h
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-03-29 00:37:25 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-15 22:23:48 -0400
commiteacbb4d33e2bb5c54311544851140efe3dd0f774 (patch)
treedefb38ea173f0ee691862d1af9000a7e74303d7f /src/journal-remote/journal-upload.h
parent7449bc1f34c206e3ff8e274cd74e2db950d492a1 (diff)
journal-upload: use journal as the source
Diffstat (limited to 'src/journal-remote/journal-upload.h')
-rw-r--r--src/journal-remote/journal-upload.h42
1 files changed, 41 insertions, 1 deletions
diff --git a/src/journal-remote/journal-upload.h b/src/journal-remote/journal-upload.h
index 68d85be6bc..f94d9ac69e 100644
--- a/src/journal-remote/journal-upload.h
+++ b/src/journal-remote/journal-upload.h
@@ -2,24 +2,64 @@
#include <inttypes.h>
+#include "sd-journal.h"
#include "sd-event.h"
+typedef enum {
+ ENTRY_CURSOR = 0, /* Nothing actually written yet. */
+ ENTRY_REALTIME,
+ ENTRY_MONOTONIC,
+ ENTRY_BOOT_ID,
+ ENTRY_NEW_FIELD, /* In between fields. */
+ ENTRY_TEXT_FIELD, /* In the middle of a text field. */
+ ENTRY_BINARY_FIELD_START, /* Writing the name of a binary field. */
+ ENTRY_BINARY_FIELD_SIZE, /* Writing the size of a binary field. */
+ ENTRY_BINARY_FIELD, /* In the middle of a binary field. */
+ ENTRY_OUTRO, /* Writing '\n' */
+ ENTRY_DONE, /* Need to move to a new field. */
+} entry_state;
+
typedef struct Uploader {
sd_event *events;
const char *url;
CURL *easy;
bool uploading;
+ char error[CURL_ERROR_SIZE];
struct curl_slist *header;
+ char *answer;
+
+ sd_event_source *input_event;
+ uint64_t timeout;
+ /* fd stuff */
int input;
- sd_event_source *input_event;
+ /* journal stuff */
+ sd_journal* journal;
+
+ entry_state entry_state;
+ const void *field_data;
+ size_t field_pos, field_length;
+
+ /* general metrics */
+ size_t entries_sent;
+ char *last_cursor;
} Uploader;
+#define JOURNAL_UPLOAD_POLL_TIMEOUT (10 * USEC_PER_SEC)
+
int start_upload(Uploader *u,
size_t (*input_callback)(void *ptr,
size_t size,
size_t nmemb,
void *userdata),
void *data);
+
+int open_journal_for_upload(Uploader *u,
+ sd_journal *j,
+ const char *cursor,
+ bool after_cursor,
+ bool follow);
+void close_journal_input(Uploader *u);
+int check_journal_input(Uploader *u);