summaryrefslogtreecommitdiffstats
path: root/src/db/sysdb.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/db/sysdb.c')
-rw-r--r--src/db/sysdb.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index 399beee3c..6bd787f7e 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -388,6 +388,32 @@ int sysdb_attrs_get_uint32_t(struct sysdb_attrs *attrs, const char *name,
return EOK;
}
+int sysdb_attrs_get_uint16_t(struct sysdb_attrs *attrs, const char *name,
+ uint16_t *value)
+{
+ struct ldb_message_element *el;
+ int ret;
+ char *endptr;
+ uint16_t val;
+
+ ret = sysdb_attrs_get_el_int(attrs, name, false, &el);
+ if (ret) {
+ return ret;
+ }
+
+ if (el->num_values != 1) {
+ return ERANGE;
+ }
+
+ errno = 0;
+ val = strtouint16((const char *) el->values[0].data, &endptr, 10);
+ if (errno != 0) return errno;
+ if (*endptr) return EINVAL;
+
+ *value = val;
+ return EOK;
+}
+
errno_t sysdb_attrs_get_bool(struct sysdb_attrs *attrs, const char *name,
bool *value)
{