summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2010-10-15 09:40:56 +0200
committerStephen Gallagher <sgallagh@redhat.com>2010-10-15 09:03:07 -0400
commit8c08a5e11f19cfe39695ee80793b72e2034c5aa4 (patch)
tree2945f81abcc345908fa2dc98c49d8fdcef3a838a /src
parent6a195bd7126020d42f89a6a97c56c15f47debb2e (diff)
downloadsssd-8c08a5e11f19cfe39695ee80793b72e2034c5aa4.tar.gz
sssd-8c08a5e11f19cfe39695ee80793b72e2034c5aa4.tar.bz2
sssd-8c08a5e11f19cfe39695ee80793b72e2034c5aa4.zip
Add sysdb_attrs_get_ulong utility function
Diffstat (limited to 'src')
-rw-r--r--src/db/sysdb.c27
-rw-r--r--src/db/sysdb.h2
2 files changed, 29 insertions, 0 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index b6ef8df4..ca053ae8 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -171,6 +171,33 @@ int sysdb_attrs_get_string(struct sysdb_attrs *attrs, const char *name,
return EOK;
}
+int sysdb_attrs_get_ulong(struct sysdb_attrs *attrs, const char *name,
+ unsigned long *value)
+{
+ struct ldb_message_element *el;
+ int ret;
+ char *endptr;
+ unsigned long 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 = strtoul((const char *) el->values[0].data, &endptr, 0);
+ if (errno || *endptr) {
+ return EINVAL;
+ }
+
+ *value = val;
+ return EOK;
+}
+
int sysdb_attrs_get_string_array(struct sysdb_attrs *attrs, const char *name,
TALLOC_CTX *mem_ctx, const char ***string)
{
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index 60c0ae8f..76e1715d 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -196,6 +196,8 @@ int sysdb_attrs_get_string(struct sysdb_attrs *attrs, const char *name,
const char **string);
int sysdb_attrs_get_string_array(struct sysdb_attrs *attrs, const char *name,
TALLOC_CTX *mem_ctx, const char ***string);
+int sysdb_attrs_get_ulong(struct sysdb_attrs *attrs, const char *name,
+ unsigned long *value);
int sysdb_attrs_replace_name(struct sysdb_attrs *attrs, const char *oldname,
const char *newname);