summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5733145)
raw | patch | inline | side by side (parent: 5733145)
author | Sebastian Harl <sh@tokkee.org> | |
Wed, 24 Dec 2014 11:58:02 +0000 (12:58 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Wed, 24 Dec 2014 11:58:02 +0000 (12:58 +0100) |
diff --git a/src/client/sock.c b/src/client/sock.c
index 6f231bd96a3e6823a405a7468a3cce6901465af4..bed6fc0ff0b6d20aff605f4f0a1c4b466435b3e8 100644 (file)
--- a/src/client/sock.c
+++ b/src/client/sock.c
/* retrieve status and data len */
assert(len >= 2 * sizeof(uint32_t));
- rstatus = sdb_proto_unmarshal_int(str, len);
- rlen = sdb_proto_unmarshal_int(str + sizeof(rstatus),
+ rstatus = sdb_proto_unmarshal_int32(str, len);
+ rlen = sdb_proto_unmarshal_int32(str + sizeof(rstatus),
len - sizeof(rstatus));
if (! rlen)
diff --git a/src/frontend/query.c b/src/frontend/query.c
index 1c5b1f293b76b83bff5f39dfde1b5baf0edcb5bd..933ca04cae5a887156400b27fb78c086d0fc6c33 100644 (file)
--- a/src/frontend/query.c
+++ b/src/frontend/query.c
return -1;
}
- type = sdb_proto_unmarshal_int(SDB_STRBUF_STR(conn->buf));
+ type = sdb_proto_unmarshal_int32(SDB_STRBUF_STR(conn->buf));
strncpy(name, sdb_strbuf_string(conn->buf) + sizeof(uint32_t),
conn->cmd_len - sizeof(uint32_t));
name[sizeof(name) - 1] = '\0';
return -1;
if (conn->cmd_len == sizeof(uint32_t))
- type = sdb_proto_unmarshal_int(SDB_STRBUF_STR(conn->buf));
+ type = sdb_proto_unmarshal_int32(SDB_STRBUF_STR(conn->buf));
else if (conn->cmd_len) {
sdb_log(SDB_LOG_ERR, "frontend: Invalid command length %d for "
"LIST command", conn->cmd_len);
conn->cmd_len);
return -1;
}
- type = sdb_proto_unmarshal_int(SDB_STRBUF_STR(conn->buf));
+ type = sdb_proto_unmarshal_int32(SDB_STRBUF_STR(conn->buf));
matcher = sdb_strbuf_string(conn->buf) + sizeof(uint32_t);
matcher_len = conn->cmd_len - sizeof(uint32_t);
index 4968977d7de4f9ecac7fbf5090fc46e46aa42984..ab01cf5d1ed9cf53bf66fbbe8c29bf8003921631 100644 (file)
uint32_t *code, uint32_t *msg_len);
/*
- * sdb_proto_unmarshal_int:
- * Read and decode an integer from the specified string.
+ * sdb_proto_unmarshal_int32:
+ * Read and decode a 32-bit integer from the specified string.
*/
uint32_t
-sdb_proto_unmarshal_int(const char *buf, size_t buf_len);
+sdb_proto_unmarshal_int32(const char *buf, size_t buf_len);
#ifdef __cplusplus
} /* extern "C" */
index 78deb717520be48a95d37808b8b3830e32ec73db..2706dd220e12fbe8e5bacb0af539b313d08a8a8a 100644 (file)
static void
log_printer(sdb_strbuf_t *buf)
{
- uint32_t prio = sdb_proto_unmarshal_int(SDB_STRBUF_STR(buf));
+ uint32_t prio = sdb_proto_unmarshal_int32(SDB_STRBUF_STR(buf));
if (prio == UINT32_MAX) {
sdb_log(SDB_LOG_WARNING, "Received a LOG message with invalid "
diff --git a/src/utils/proto.c b/src/utils/proto.c
index 51c2ed8c45361f4625c4e7dc6d956594d7a96a7e..beaa07e98397f18876f27952ab38ed83ff673638 100644 (file)
--- a/src/utils/proto.c
+++ b/src/utils/proto.c
* been available. */
static ssize_t
-marshal_int(char *buf, size_t buf_len, int64_t v)
+marshal_int64(char *buf, size_t buf_len, int64_t v)
{
if (buf_len >= sizeof(v)) {
#if __BYTE_ORDER != __BIG_ENDIAN
memcpy(buf, &v, sizeof(v));
}
return sizeof(v);
-} /* marshal_int */
+} /* marshal_int64 */
static ssize_t
marshal_double(char *buf, size_t buf_len, double v)
static ssize_t
marshal_datetime(char *buf, size_t buf_len, sdb_time_t v)
{
- return marshal_int(buf, buf_len, (int64_t)v);
+ return marshal_int64(buf, buf_len, (int64_t)v);
} /* marshal_datetime */
static ssize_t
return len;
if (datum->type == SDB_TYPE_INTEGER)
- n = marshal_int(buf, buf_len, datum->data.integer);
+ n = marshal_int64(buf, buf_len, datum->data.integer);
else if (datum->type == SDB_TYPE_DECIMAL)
n = marshal_double(buf, buf_len, datum->data.decimal);
else if (datum->type == SDB_TYPE_STRING)
for (i = 0; i < datum->data.array.length; ++i) {
if (type == SDB_TYPE_INTEGER) {
int64_t *v = datum->data.array.values;
- n = marshal_int(buf, buf_len, v[i]);
+ n = marshal_int64(buf, buf_len, v[i]);
}
else if (type == SDB_TYPE_DECIMAL) {
double *v = datum->data.array.values;
if (buf_len < 2 * sizeof(uint32_t))
return -1;
- tmp = sdb_proto_unmarshal_int(buf, buf_len);
+ tmp = sdb_proto_unmarshal_int32(buf, buf_len);
if (code)
*code = tmp;
- tmp = sdb_proto_unmarshal_int(buf + sizeof(uint32_t),
+ tmp = sdb_proto_unmarshal_int32(buf + sizeof(uint32_t),
buf_len - sizeof(uint32_t));
if (msg_len)
*msg_len = tmp;
} /* sdb_proto_unmarshal_header */
uint32_t
-sdb_proto_unmarshal_int(const char *buf, size_t buf_len)
+sdb_proto_unmarshal_int32(const char *buf, size_t buf_len)
{
uint32_t n;
memcpy(&n, buf, sizeof(n));
return ntohl(n);
-} /* sdb_proto_unmarshal_int */
+} /* sdb_proto_unmarshal_int32 */
/* vim: set tw=78 sw=4 ts=4 noexpandtab : */