From 263fd7beba3f8bac683910a1911c184641b67fc3 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Wed, 11 Mar 2015 20:00:27 +0100 Subject: [PATCH] data: Let sdb_data_array_get support DATETIME, BINARY, REGEX values. --- src/core/data.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/core/data.c b/src/core/data.c index 2b1cff2..4435305 100644 --- a/src/core/data.c +++ b/src/core/data.c @@ -781,9 +781,28 @@ sdb_data_array_get(const sdb_data_t *array, size_t i, sdb_data_t *value) char **v = array->data.array.values; tmp.data.string = v[i]; } + else if (type == SDB_TYPE_DATETIME) { + sdb_time_t *v = array->data.array.values; + tmp.data.datetime = v[i]; + } + else if (type == SDB_TYPE_BINARY) { + struct { + size_t length; + unsigned char *datum; + } *v = array->data.array.values; + assert(sizeof(tmp.data.binary) == sizeof(v[i])); + memcpy(&tmp.data.binary, &v[i], sizeof(v[i])); + } + else if (type == SDB_TYPE_REGEX) { + struct { + char *raw; + regex_t regex; + } *v = array->data.array.values; + assert(sizeof(tmp.data.re) == sizeof(v[i])); + memcpy(&tmp.data.re, &v[i], sizeof(v[i])); + } else { - /* TODO */ - errno = ENOTSUP; + errno = EINVAL; return -1; } -- 2.30.2