4
/* dsync inter-brain communicator */
8
#include "dsync-brain.h"
11
struct dsync_mailbox_state;
12
struct dsync_mailbox_node;
13
struct dsync_mailbox_delete;
14
struct dsync_mailbox_attribute;
16
struct dsync_mail_change;
17
struct dsync_mail_request;
19
enum dsync_ibc_send_ret {
20
DSYNC_IBC_SEND_RET_OK = 1,
21
/* send queue is full, stop sending more */
22
DSYNC_IBC_SEND_RET_FULL = 0
25
enum dsync_ibc_recv_ret {
26
DSYNC_IBC_RECV_RET_FINISHED = -1,
27
/* try again / error (the error handling delayed until io callback) */
28
DSYNC_IBC_RECV_RET_TRYAGAIN = 0,
29
DSYNC_IBC_RECV_RET_OK = 1
32
enum dsync_ibc_eol_type {
33
DSYNC_IBC_EOL_MAILBOX_STATE,
34
DSYNC_IBC_EOL_MAILBOX_TREE,
35
DSYNC_IBC_EOL_MAILBOX_ATTRIBUTE,
36
DSYNC_IBC_EOL_MAILBOX,
37
DSYNC_IBC_EOL_MAIL_CHANGES,
38
DSYNC_IBC_EOL_MAIL_REQUESTS,
42
struct dsync_ibc_settings {
43
/* Server hostname. Used for determining which server does the
46
/* if non-NULL, sync only this namespace */
47
const char *sync_ns_prefix;
48
/* if non-NULL, sync only this mailbox name */
50
/* if non-empty, sync only this mailbox GUID */
51
guid_128_t sync_box_guid;
52
/* Exclude these mailboxes from the sync. They can contain '*'
53
wildcards and be \special-use flags. */
54
const char *const *exclude_mailboxes;
56
enum dsync_brain_sync_type sync_type;
57
enum dsync_brain_flags brain_flags;
58
unsigned int lock_timeout;
61
void dsync_ibc_init_pipe(struct dsync_ibc **ibc1_r,
62
struct dsync_ibc **ibc2_r);
64
dsync_ibc_init_stream(struct istream *input, struct ostream *output,
65
const char *name, const char *temp_path_prefix);
66
void dsync_ibc_deinit(struct dsync_ibc **ibc);
68
/* I/O callback is called whenever new data is available. It's also called on
69
errors, so check first the error status. */
70
void dsync_ibc_set_io_callback(struct dsync_ibc *ibc,
71
io_callback_t *callback, void *context);
73
void dsync_ibc_send_handshake(struct dsync_ibc *ibc,
74
const struct dsync_ibc_settings *set);
75
enum dsync_ibc_recv_ret
76
dsync_ibc_recv_handshake(struct dsync_ibc *ibc,
77
const struct dsync_ibc_settings **set_r);
79
enum dsync_ibc_send_ret ATTR_NOWARN_UNUSED_RESULT
80
dsync_ibc_send_end_of_list(struct dsync_ibc *ibc, enum dsync_ibc_eol_type type);
82
enum dsync_ibc_send_ret ATTR_NOWARN_UNUSED_RESULT
83
dsync_ibc_send_mailbox_state(struct dsync_ibc *ibc,
84
const struct dsync_mailbox_state *state);
85
enum dsync_ibc_recv_ret
86
dsync_ibc_recv_mailbox_state(struct dsync_ibc *ibc,
87
struct dsync_mailbox_state *state_r);
89
enum dsync_ibc_send_ret ATTR_NOWARN_UNUSED_RESULT
90
dsync_ibc_send_mailbox_tree_node(struct dsync_ibc *ibc,
91
const char *const *name,
92
const struct dsync_mailbox_node *node);
93
enum dsync_ibc_recv_ret
94
dsync_ibc_recv_mailbox_tree_node(struct dsync_ibc *ibc,
95
const char *const **name_r,
96
const struct dsync_mailbox_node **node_r);
98
enum dsync_ibc_send_ret ATTR_NOWARN_UNUSED_RESULT
99
dsync_ibc_send_mailbox_deletes(struct dsync_ibc *ibc,
100
const struct dsync_mailbox_delete *deletes,
101
unsigned int count, char hierarchy_sep);
102
enum dsync_ibc_recv_ret
103
dsync_ibc_recv_mailbox_deletes(struct dsync_ibc *ibc,
104
const struct dsync_mailbox_delete **deletes_r,
105
unsigned int *count_r, char *hierarchy_sep_r);
107
enum dsync_ibc_send_ret ATTR_NOWARN_UNUSED_RESULT
108
dsync_ibc_send_mailbox(struct dsync_ibc *ibc,
109
const struct dsync_mailbox *dsync_box);
110
enum dsync_ibc_recv_ret
111
dsync_ibc_recv_mailbox(struct dsync_ibc *ibc,
112
const struct dsync_mailbox **dsync_box_r);
114
enum dsync_ibc_send_ret ATTR_NOWARN_UNUSED_RESULT
115
dsync_ibc_send_mailbox_attribute(struct dsync_ibc *ibc,
116
const struct dsync_mailbox_attribute *attr);
117
enum dsync_ibc_recv_ret
118
dsync_ibc_recv_mailbox_attribute(struct dsync_ibc *ibc,
119
const struct dsync_mailbox_attribute **attr_r);
121
enum dsync_ibc_send_ret ATTR_NOWARN_UNUSED_RESULT
122
dsync_ibc_send_change(struct dsync_ibc *ibc,
123
const struct dsync_mail_change *change);
124
enum dsync_ibc_recv_ret
125
dsync_ibc_recv_change(struct dsync_ibc *ibc,
126
const struct dsync_mail_change **change_r);
128
enum dsync_ibc_send_ret ATTR_NOWARN_UNUSED_RESULT
129
dsync_ibc_send_mail_request(struct dsync_ibc *ibc,
130
const struct dsync_mail_request *request);
131
enum dsync_ibc_recv_ret
132
dsync_ibc_recv_mail_request(struct dsync_ibc *ibc,
133
const struct dsync_mail_request **request_r);
135
enum dsync_ibc_send_ret ATTR_NOWARN_UNUSED_RESULT
136
dsync_ibc_send_mail(struct dsync_ibc *ibc, const struct dsync_mail *mail);
137
enum dsync_ibc_recv_ret
138
dsync_ibc_recv_mail(struct dsync_ibc *ibc, struct dsync_mail **mail_r);
140
/* Close any mail input streams that are kept open. This needs to be called
141
before the mail is attempted to be freed (usually on error conditions). */
142
void dsync_ibc_close_mail_streams(struct dsync_ibc *ibc);
144
bool dsync_ibc_has_failed(struct dsync_ibc *ibc);
145
bool dsync_ibc_has_timed_out(struct dsync_ibc *ibc);
146
bool dsync_ibc_is_send_queue_full(struct dsync_ibc *ibc);
147
bool dsync_ibc_has_pending_data(struct dsync_ibc *ibc);