summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2012-01-28 11:35:42 -0500
committerStephen Gallagher <sgallagh@redhat.com>2012-01-31 09:37:40 -0500
commit48b6eab1b369107af0d568e016a87637b7affc55 (patch)
treee159a3936c773fa5bbecbeaeb4a546ee772fd2ca /src
parente299638926171e0e92a36122aeff6611cd52418d (diff)
downloadsssd-48b6eab1b369107af0d568e016a87637b7affc55.tar.gz
sssd-48b6eab1b369107af0d568e016a87637b7affc55.tar.bz2
sssd-48b6eab1b369107af0d568e016a87637b7affc55.zip
SYSDB: Add sysdb_attrs_get_uint16_t
Diffstat (limited to 'src')
-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 399beee3..6bd787f7 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)
{
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index 5863afc9..31b988eb 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -219,6 +219,8 @@ int sysdb_attrs_get_string_array(struct sysdb_attrs *attrs, const char *name,
TALLOC_CTX *mem_ctx, const char ***string);
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_uint32_t(struct sysdb_attrs *attrs, const char *name,
uint32_t *value);