ctdb-common: Refactor code to remove a stale socket
[sfrench/samba-autobuild/.git] / ctdb / common / sock_io.h
1 /*
2    Generic Socket I/O
3
4    Copyright (C) Amitay Isaacs  2016
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef __CTDB_SOCK_IO_H__
21 #define __CTDB_SOCK_IO_H__
22
23 typedef void (*sock_queue_callback_fn_t)(uint8_t *buf, size_t buflen,
24                                          void *private_data);
25
26 struct sock_queue;
27
28 bool sock_clean(const char *sockpath);
29 int sock_connect(const char *sockpath);
30
31 struct sock_queue *sock_queue_setup(TALLOC_CTX *mem_ctx,
32                                     struct tevent_context *ev,
33                                     int fd,
34                                     sock_queue_callback_fn_t callback,
35                                     void *private_data);
36
37 int sock_queue_write(struct sock_queue *queue, uint8_t *buf, size_t buflen);
38
39 #endif /* __CTDB_SOCK_IO_H__ */