Code

proto: Added support for unmarshaling hosts/services/metrics/attributes.
[sysdb.git] / src / include / utils / proto.h
index 0b3374f38cf1337e603abf3595aff78eb0a7da48..df24278742227e1b845e23f20145ef194f141c14 100644 (file)
@@ -67,7 +67,7 @@ typedef struct {
        const char *hostname; /* optional */
        const char *parent;
        const char *key;
-       const sdb_data_t *value;
+       sdb_data_t value;
 } sdb_proto_attribute_t;
 
 /*
@@ -164,6 +164,29 @@ sdb_proto_unmarshal_int32(const char *buf, size_t buf_len, uint32_t *v);
 ssize_t
 sdb_proto_unmarshal_data(const char *buf, size_t len, sdb_data_t *datum);
 
+/*
+ * sdb_proto_unmarshal_host, sdb_proto_unmarshal_service,
+ * sdb_proto_unmarshal_metric, sdb_proto_unmarshal_attribute:
+ * Read and decode a host, service, metric, or attribute object from the
+ * specified string.
+ *
+ * Returns:
+ *  - the number of bytes read on success
+ *  - a negative value else
+ */
+ssize_t
+sdb_proto_unmarshal_host(const char *buf, size_t len,
+               sdb_proto_host_t *host);
+ssize_t
+sdb_proto_unmarshal_service(const char *buf, size_t len,
+               sdb_proto_service_t *svc);
+ssize_t
+sdb_proto_unmarshal_metric(const char *buf, size_t len,
+               sdb_proto_metric_t *metric);
+ssize_t
+sdb_proto_unmarshal_attribute(const char *buf, size_t len,
+               sdb_proto_attribute_t *attr);
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif