1 | #ifndef NVIM_EVENT_SOCKET_H |
---|---|
2 | #define NVIM_EVENT_SOCKET_H |
3 | |
4 | #include <uv.h> |
5 | |
6 | #include "nvim/event/loop.h" |
7 | #include "nvim/event/rstream.h" |
8 | #include "nvim/event/wstream.h" |
9 | |
10 | #define ADDRESS_MAX_SIZE 256 |
11 | |
12 | typedef struct socket_watcher SocketWatcher; |
13 | typedef void (*socket_cb)(SocketWatcher *watcher, int result, void *data); |
14 | typedef void (*socket_close_cb)(SocketWatcher *watcher, void *data); |
15 | |
16 | struct socket_watcher { |
17 | // Pipe/socket path, or TCP address string |
18 | char addr[ADDRESS_MAX_SIZE]; |
19 | // TCP server or unix socket (named pipe on Windows) |
20 | union { |
21 | struct { |
22 | uv_tcp_t handle; |
23 | struct addrinfo *addrinfo; |
24 | } tcp; |
25 | struct { |
26 | uv_pipe_t handle; |
27 | } pipe; |
28 | } uv; |
29 | uv_stream_t *stream; |
30 | void *data; |
31 | socket_cb cb; |
32 | socket_close_cb close_cb; |
33 | MultiQueue *events; |
34 | }; |
35 | |
36 | #ifdef INCLUDE_GENERATED_DECLARATIONS |
37 | # include "event/socket.h.generated.h" |
38 | #endif |
39 | #endif // NVIM_EVENT_SOCKET_H |
40 |