summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRobby Zambito <contact@robbyzambito.me>2026-01-24 16:13:35 -0500
committerRobby Zambito <contact@robbyzambito.me>2026-01-24 17:16:06 -0500
commit16fd65e281776bd27d9aefdcfb39fa8b8f7a9fba (patch)
treede77af954753512ccca8d030f8637048696ef4b6 /include
parent8965a4d5d4ce494ae45ea28186379ea7aea9d2e1 (diff)
Add C API
Diffstat (limited to 'include')
-rw-r--r--include/zaprus.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/include/zaprus.h b/include/zaprus.h
new file mode 100644
index 0000000..e81383b
--- /dev/null
+++ b/include/zaprus.h
@@ -0,0 +1,33 @@
+#ifndef ZAPRUS_H
+#define ZAPRUS_H
+
+#include <stdint.h>
+#include <stdlib.h>
+
+typedef void* zaprus_client;
+typedef void* zaprus_connection;
+
+// Returns NULL if there was an error.
+zaprus_client zaprus_init_client(void);
+
+void zaprus_deinit_client(zaprus_client client);
+
+// Returns 0 on success, else returns 1.
+int zaprus_client_send_relay(zaprus_client client, const char* payload, size_t payload_len, const char dest[4]);
+
+// Returns NULL if there was an error.
+// Caller should call zaprus_deinit_connection when done with the connection.
+zaprus_connection zaprus_connect(zaprus_client client, const char* payload, size_t payload_len);
+
+void zaprus_deinit_connection(zaprus_connection connection);
+
+// Capacity is the maximum length of the output buffer.
+// out_len is modified to specify how much of the capacity is used by the response.
+// Blocks until the next message is available, or returns 1 if the underlying socket times out.
+// Returns 0 on success, else returns 1.
+int zaprus_connection_next(zaprus_connection connection, char *out, size_t capacity, size_t *out_len);
+
+// Returns 0 on success, else returns 1.
+int zaprus_connection_send(zaprus_connection connection, const char *payload, size_t payload_len);
+
+#endif // ZAPRUS_H