X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Finclude%2Futils%2Fproto.h;h=0b3374f38cf1337e603abf3595aff78eb0a7da48;hb=9c130e1fb599c2e7fb3c6ba2cafbacaf3644effc;hp=eb0d52883700bcbc1ffcb0dc194f6feaee3d8657;hpb=5f48615842bd6c16984ae1113951c68bc987ade6;p=sysdb.git diff --git a/src/include/utils/proto.h b/src/include/utils/proto.h index eb0d528..0b3374f 100644 --- a/src/include/utils/proto.h +++ b/src/include/utils/proto.h @@ -61,6 +61,15 @@ typedef struct { const char *store_id; /* optional */ } sdb_proto_metric_t; +typedef struct { + sdb_time_t last_update; + int parent_type; + const char *hostname; /* optional */ + const char *parent; + const char *key; + const sdb_data_t *value; +} sdb_proto_attribute_t; + /* * sdb_proto_marshal: * Encode the message into the wire format by adding an appropriate header. @@ -90,11 +99,11 @@ sdb_proto_marshal(char *buf, size_t buf_len, uint32_t code, * - a negative value else */ ssize_t -sdb_proto_marshal_data(char *buf, size_t buf_len, sdb_data_t *datum); +sdb_proto_marshal_data(char *buf, size_t buf_len, const sdb_data_t *datum); /* * sdb_proto_marshal_host, sdb_proto_marshal_service, - * sdb_proto_marshal_metric: + * sdb_proto_marshal_metric, sdb_proto_marshal_attribute: * Encode the basic information of a stored object into the wire format and * write it to buf. These functions are similar to the sdb_store_ * functions. See their documentation for details about the arguments. @@ -115,25 +124,45 @@ sdb_proto_marshal_service(char *buf, size_t buf_len, ssize_t sdb_proto_marshal_metric(char *buf, size_t buf_len, const sdb_proto_metric_t *metric); +ssize_t +sdb_proto_marshal_attribute(char *buf, size_t buf_len, + const sdb_proto_attribute_t *attr); /* * sdb_proto_unmarshal_header: * Read and decode a message header from the specified string. * * Returns: - * - 0 on success + * - the number of bytes read on success * - a negative value else */ -int +ssize_t sdb_proto_unmarshal_header(const char *buf, size_t buf_len, uint32_t *code, uint32_t *msg_len); /* * sdb_proto_unmarshal_int32: * Read and decode a 32-bit integer from the specified string. + * + * Returns: + * - the number of bytes read on success + * - a negative value else */ -uint32_t -sdb_proto_unmarshal_int32(const char *buf, size_t buf_len); +ssize_t +sdb_proto_unmarshal_int32(const char *buf, size_t buf_len, uint32_t *v); + +/* + * sdb_proto_unmarshal_data: + * Read and decode a datum from the specified string. The datum's data will be + * allocated dynamically if necessary and will have to be free'd using + * sdb_data_free_datum. + * + * Returns: + * - the number of bytes read on success + * - a negative value else + */ +ssize_t +sdb_proto_unmarshal_data(const char *buf, size_t len, sdb_data_t *datum); #ifdef __cplusplus } /* extern "C" */