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 09a4b6485..b026a298e 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -364,6 +364,32 @@ int sysdb_attrs_get_string(struct sysdb_attrs *attrs, const char *name,
return EOK;
}
+int sysdb_attrs_get_int32_t(struct sysdb_attrs *attrs, const char *name,
+ int32_t *value)
+{
+ struct ldb_message_element *el;
+ int ret;
+ char *endptr;
+ int32_t val;
+
+ ret = sysdb_attrs_get_el_ext(attrs, name, false, &el);
+ if (ret) {
+ return ret;
+ }
+
+ if (el->num_values != 1) {
+ return ERANGE;
+ }
+
+ errno = 0;
+ val = strtoint32((const char *) el->values[0].data, &endptr, 10);
+ if (errno != 0) return errno;
+ if (*endptr) return EINVAL;
+
+ *value = val;
+ return EOK;
+}
+
int sysdb_attrs_get_uint32_t(struct sysdb_attrs *attrs, const char *name,
uint32_t *value)
{