summaryrefslogtreecommitdiffstats
path: root/lib/server.h
diff options
context:
space:
mode:
authorJulian Bouzas <julian.bouzas@collabora.com>2021-04-20 04:08:58 -0400
committerGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2021-07-28 13:19:02 +0300
commitf25bb13718f334bc0c96d29ea9f3a57c0a6f3a34 (patch)
treeeaa30eafe2df92e3d5d75571d022c3a775246bff /lib/server.h
parent7bf96bda703dd157385cbb175ec90bd6f38af404 (diff)
lib: add wpipc library
Simple library that uses sockets for inter-process communication. It provides an API to create server and client objects. Users can add custom handlers in the server, and clients can send requests for those custom handlers. Signed-off-by: George Kiagiadakis <george.kiagiadakis@collabora.com>
Diffstat (limited to 'lib/server.h')
-rw-r--r--lib/server.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/lib/server.h b/lib/server.h
new file mode 100644
index 0000000..3cc0ed9
--- /dev/null
+++ b/lib/server.h
@@ -0,0 +1,85 @@
+/* PipeWire AGL Cluster IPC
+ *
+ * Copyright © 2021 Collabora Ltd.
+ * @author Julian Bouzas <julian.bouzas@collabora.com>
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#ifndef __ICIPC_SERVER_H__
+#define __ICIPC_SERVER_H__
+
+#include <spa/pod/pod.h>
+
+#include "defs.h"
+
+#include "receiver.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define icipc_server_to_receiver(self) ((struct icipc_receiver *)(self))
+
+struct icipc_server;
+
+typedef void (*icipc_server_client_handler_func_t) (struct icipc_server *self,
+ int client_fd,
+ enum icipc_receiver_sender_state client_state,
+ void *data);
+
+typedef bool (*icipc_server_request_handler_func_t) (struct icipc_server *self,
+ int client_fd,
+ const char *name,
+ const struct spa_pod *args,
+ void *data);
+
+ICIPC_API
+struct icipc_server *
+icipc_server_new (const char *path, bool start);
+
+ICIPC_API
+void
+icipc_server_free (struct icipc_server *self);
+
+ICIPC_API
+void
+icipc_server_set_client_handler (struct icipc_server *self,
+ icipc_server_client_handler_func_t handler,
+ void *data);
+
+ICIPC_API
+void
+icipc_server_clear_client_handler (struct icipc_server *self);
+
+ICIPC_API
+bool
+icipc_server_set_request_handler (struct icipc_server *self,
+ const char *name,
+ icipc_server_request_handler_func_t handler,
+ void *data);
+
+ICIPC_API
+void
+icipc_server_clear_request_handler (struct icipc_server *self,
+ const char *name);
+
+/* for request handlers only */
+
+ICIPC_API
+bool
+icipc_server_reply_ok (struct icipc_server *self,
+ int client_fd,
+ const struct spa_pod *value);
+
+ICIPC_API
+bool
+icipc_server_reply_error (struct icipc_server *self,
+ int client_fd,
+ const char *msg);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif