aboutsummaryrefslogtreecommitdiff
path: root/include/connection.h
diff options
context:
space:
mode:
authorKenny Levinsen <kl@kl.wtf>2020-07-31 00:22:18 +0200
committerKenny Levinsen <kl@kl.wtf>2020-07-31 00:22:18 +0200
commit61716a2c77dfde9addf6b41a6d72d26a8584150e (patch)
tree537cd84661955497bdb304f88896e36896df4e5f /include/connection.h
parentf85434de666f10da0cbcaccdbb7d88917c5fa887 (diff)
Initial implementation of seatd and libseat
Diffstat (limited to 'include/connection.h')
-rw-r--r--include/connection.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/include/connection.h b/include/connection.h
new file mode 100644
index 0000000..6c57901
--- /dev/null
+++ b/include/connection.h
@@ -0,0 +1,36 @@
+#ifndef _SEATD_CONNECTION_H
+#define _SEATD_CONNECTION_H
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#define CONNECTION_BUFFER_SIZE 1024
+
+#define MAX_FDS_OUT 8
+
+struct connection_buffer {
+ uint32_t head, tail;
+ char data[CONNECTION_BUFFER_SIZE];
+};
+
+struct connection {
+ struct connection_buffer in, out;
+ struct connection_buffer fds_in, fds_out;
+ int fd;
+ bool want_flush;
+};
+
+int connection_read(struct connection *connection);
+int connection_flush(struct connection *connection);
+
+int connection_put(struct connection *connection, const void *data, size_t count);
+int connection_put_fd(struct connection *connection, int fd);
+
+size_t connection_pending(struct connection *connection);
+int connection_get(struct connection *connection, void *dst, size_t count);
+int connection_get_fd(struct connection *connection);
+void connection_restore(struct connection *connection, size_t count);
+
+void connection_close_fds(struct connection *connection);
+
+#endif