summaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2013-12-10 10:14:02 +0100
committerJakub Hrozek <jhrozek@redhat.com>2013-12-19 17:34:01 +0100
commitfb4435785f92712840efb107700452598371ce77 (patch)
tree8a362552ea80ab4758d6205073dbab40caa0eded /src/db
parent022456e93c9b175ce3774afe524e3926f41ba80f (diff)
downloadsssd-fb4435785f92712840efb107700452598371ce77.tar.gz
sssd-fb4435785f92712840efb107700452598371ce77.tar.xz
sssd-fb4435785f92712840efb107700452598371ce77.zip
Add sysdb_attrs_get_int32_t
Diffstat (limited to 'src/db')
-rw-r--r--src/db/sysdb.c26
-rw-r--r--src/db/sysdb.h2
2 files changed, 28 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)
{
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index ec7b72c97..7b5bf8710 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -294,6 +294,8 @@ errno_t sysdb_attrs_get_bool(struct sysdb_attrs *attrs, const char *name,
bool *value);
int sysdb_attrs_get_uint16_t(struct sysdb_attrs *attrs, const char *name,
uint16_t *value);
+int sysdb_attrs_get_int32_t(struct sysdb_attrs *attrs, const char *name,
+ int32_t *value);
int sysdb_attrs_get_uint32_t(struct sysdb_attrs *attrs, const char *name,
uint32_t *value);