index 8ab2e1ee7b3a22adb1481fb7cfecb09daaef77c7..e76211965a416d4e06d6fa93bdfbcc3e1d32b2e9 100644 (file)
#ifndef SDB_UTILS_PROTO_H
#define SDB_UTILS_PROTO_H 1
+#include "utils/strbuf.h"
+
#include <stdint.h>
#include <unistd.h>
extern "C" {
#endif
+/*
+ * sdb_proto_marshal:
+ * Encode the message into the wire format by adding an appropriate header.
+ * The encoded message is written to buf which has to be large enough to store
+ * the header (64 bits) and the entire message.
+ *
+ * Returns:
+ * - the number of bytes of the full encoded message on success (even if less
+ * than that fit into and was written to the buffer)
+ * - a negative value on error
+ */
ssize_t
-sdb_proto_send(int fd, size_t msg_len, const char *msg);
-
-ssize_t
-sdb_proto_send_msg(int fd, uint32_t code,
+sdb_proto_marshal(char *buf, size_t buf_len, uint32_t code,
uint32_t msg_len, const char *msg);
+uint32_t
+sdb_proto_get_int(sdb_strbuf_t *buf, size_t offset);
+
#ifdef __cplusplus
} /* extern "C" */
#endif