chiark / gitweb /
update NEWS
[elogind.git] / src / journal-remote / journal-remote-write.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 /***
4   This file is part of systemd.
5
6   Copyright 2014 Zbigniew JÄ™drzejewski-Szmek
7
8   systemd is free software; you can redistribute it and/or modify it
9   under the terms of the GNU Lesser General Public License as published by
10   the Free Software Foundation; either version 2.1 of the License, or
11   (at your option) any later version.
12
13   systemd is distributed in the hope that it will be useful, but
14   WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16   Lesser General Public License for more details.
17
18   You should have received a copy of the GNU Lesser General Public License
19   along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #pragma once
23
24 #include <stdlib.h>
25
26 #include "journal-file.h"
27
28 typedef struct RemoteServer RemoteServer;
29
30 struct iovec_wrapper {
31         struct iovec *iovec;
32         size_t size_bytes;
33         size_t count;
34 };
35
36 int iovw_put(struct iovec_wrapper *iovw, void* data, size_t len);
37 void iovw_free_contents(struct iovec_wrapper *iovw);
38 size_t iovw_size(struct iovec_wrapper *iovw);
39 void iovw_rebase(struct iovec_wrapper *iovw, char *old, char *new);
40
41 typedef struct Writer {
42         JournalFile *journal;
43         JournalMetrics metrics;
44
45         MMapCache *mmap;
46         RemoteServer *server;
47         char *hashmap_key;
48
49         uint64_t seqnum;
50
51         int n_ref;
52 } Writer;
53
54 Writer* writer_new(RemoteServer* server);
55 Writer* writer_free(Writer *w);
56
57 Writer* writer_ref(Writer *w);
58 Writer* writer_unref(Writer *w);
59
60 DEFINE_TRIVIAL_CLEANUP_FUNC(Writer*, writer_unref);
61 #define _cleanup_writer_unref_ _cleanup_(writer_unrefp)
62
63 int writer_write(Writer *s,
64                  struct iovec_wrapper *iovw,
65                  dual_timestamp *ts,
66                  bool compress,
67                  bool seal);
68
69 typedef enum JournalWriteSplitMode {
70         JOURNAL_WRITE_SPLIT_NONE,
71         JOURNAL_WRITE_SPLIT_HOST,
72         _JOURNAL_WRITE_SPLIT_MAX,
73         _JOURNAL_WRITE_SPLIT_INVALID = -1
74 } JournalWriteSplitMode;