index f3f1a871d83e48c28e96bee92fd8a40ac4e3188a..311162bb0682c09aa8acc11908e8b8bf2f7df4f1 100644 (file)
extern "C" {
#endif
-enum {
- SDB_PROTO_SELECTIN = 0,
- SDB_PROTO_SELECTOUT,
- SDB_PROTO_SELECTERR,
-};
-
/*
- * sdb_proto_select:
- * Wait for a file-descriptor to become ready for I/O operations of the
- * specified type. This is a simple wrapper around the select() system call.
- * The type argument may be any of the SDB_PROTO_SELECT* constants.
+ * 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 file descriptors ready for I/O
+ * - 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
*/
-int
-sdb_proto_select(int fd, int type);
-
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);
+/*
+ * sdb_proto_unmarshal_header:
+ * Read and decode a message header from the specified string buffer.
+ *
+ * Returns:
+ * - 0 on success
+ * - a negative value else
+ */
+int
+sdb_proto_unmarshal_header(sdb_strbuf_t *buf,
+ uint32_t *code, uint32_t *msg_len);
+
+/*
+ * sdb_proto_unmarshal_int:
+ * Read and decode an integer from the specified string buffer.
+ */
uint32_t
-sdb_proto_get_int(sdb_strbuf_t *buf, size_t offset);
+sdb_proto_unmarshal_int(sdb_strbuf_t *buf, size_t offset);
#ifdef __cplusplus
} /* extern "C" */