From: Sebastian Harl Date: Wed, 11 Mar 2015 19:00:27 +0000 (+0100) Subject: data: Let sdb_data_array_get support DATETIME, BINARY, REGEX values. X-Git-Tag: sysdb-0.8.0~126 X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=commitdiff_plain;h=263fd7beba3f8bac683910a1911c184641b67fc3 data: Let sdb_data_array_get support DATETIME, BINARY, REGEX values. --- 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; }