|
|
2fc102 |
From 91c41b25f3d2e5a6074d1dd73c3355f9159d2cae Mon Sep 17 00:00:00 2001
|
|
|
2fc102 |
From: Sumit Bose <sbose@redhat.com>
|
|
|
2fc102 |
Date: Tue, 10 Dec 2013 10:14:02 +0100
|
|
|
2fc102 |
Subject: [PATCH 41/41] Add sysdb_attrs_get_int32_t
|
|
|
2fc102 |
|
|
|
2fc102 |
---
|
|
|
2fc102 |
src/db/sysdb.c | 26 ++++++++++++++++++++++++++
|
|
|
2fc102 |
src/db/sysdb.h | 2 ++
|
|
|
2fc102 |
2 files changed, 28 insertions(+)
|
|
|
2fc102 |
|
|
|
2fc102 |
diff --git a/src/db/sysdb.c b/src/db/sysdb.c
|
|
|
2fc102 |
index 2a4be58008fc1164765db26aaba3886071448d30..0e07ed60858298a1ac85d06146ccb98c5899a705 100644
|
|
|
2fc102 |
--- a/src/db/sysdb.c
|
|
|
2fc102 |
+++ b/src/db/sysdb.c
|
|
|
2fc102 |
@@ -366,6 +366,32 @@ int sysdb_attrs_get_string(struct sysdb_attrs *attrs, const char *name,
|
|
|
2fc102 |
return EOK;
|
|
|
2fc102 |
}
|
|
|
2fc102 |
|
|
|
2fc102 |
+int sysdb_attrs_get_int32_t(struct sysdb_attrs *attrs, const char *name,
|
|
|
2fc102 |
+ int32_t *value)
|
|
|
2fc102 |
+{
|
|
|
2fc102 |
+ struct ldb_message_element *el;
|
|
|
2fc102 |
+ int ret;
|
|
|
2fc102 |
+ char *endptr;
|
|
|
2fc102 |
+ int32_t val;
|
|
|
2fc102 |
+
|
|
|
2fc102 |
+ ret = sysdb_attrs_get_el_ext(attrs, name, false, &el);
|
|
|
2fc102 |
+ if (ret) {
|
|
|
2fc102 |
+ return ret;
|
|
|
2fc102 |
+ }
|
|
|
2fc102 |
+
|
|
|
2fc102 |
+ if (el->num_values != 1) {
|
|
|
2fc102 |
+ return ERANGE;
|
|
|
2fc102 |
+ }
|
|
|
2fc102 |
+
|
|
|
2fc102 |
+ errno = 0;
|
|
|
2fc102 |
+ val = strtoint32((const char *) el->values[0].data, &endptr, 10);
|
|
|
2fc102 |
+ if (errno != 0) return errno;
|
|
|
2fc102 |
+ if (*endptr) return EINVAL;
|
|
|
2fc102 |
+
|
|
|
2fc102 |
+ *value = val;
|
|
|
2fc102 |
+ return EOK;
|
|
|
2fc102 |
+}
|
|
|
2fc102 |
+
|
|
|
2fc102 |
int sysdb_attrs_get_uint32_t(struct sysdb_attrs *attrs, const char *name,
|
|
|
2fc102 |
uint32_t *value)
|
|
|
2fc102 |
{
|
|
|
2fc102 |
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
|
|
|
2fc102 |
index 9bcd7be0960fcfa390fb9150594ea84880a14eea..255a135f0cad788e4c952b86fe24ca10f5e63732 100644
|
|
|
2fc102 |
--- a/src/db/sysdb.h
|
|
|
2fc102 |
+++ b/src/db/sysdb.h
|
|
|
2fc102 |
@@ -294,6 +294,8 @@ errno_t sysdb_attrs_get_bool(struct sysdb_attrs *attrs, const char *name,
|
|
|
2fc102 |
bool *value);
|
|
|
2fc102 |
int sysdb_attrs_get_uint16_t(struct sysdb_attrs *attrs, const char *name,
|
|
|
2fc102 |
uint16_t *value);
|
|
|
2fc102 |
+int sysdb_attrs_get_int32_t(struct sysdb_attrs *attrs, const char *name,
|
|
|
2fc102 |
+ int32_t *value);
|
|
|
2fc102 |
int sysdb_attrs_get_uint32_t(struct sysdb_attrs *attrs, const char *name,
|
|
|
2fc102 |
uint32_t *value);
|
|
|
2fc102 |
|
|
|
2fc102 |
--
|
|
|
2fc102 |
1.8.4.2
|
|
|
2fc102 |
|