summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2010-05-28 14:28:06 +0200
committerStephen Gallagher <sgallagh@redhat.com>2010-06-02 11:11:51 -0400
commit5fad9a3d700ba24783e66c6941f68f84459b4d61 (patch)
tree7e9956fd36fe01e1439ed22b2aa82f768b100e26 /src
parent53cdc09262026587b70e0fd9173a96544a0bcc12 (diff)
downloadsssd-5fad9a3d700ba24783e66c6941f68f84459b4d61.tar.gz
sssd-5fad9a3d700ba24783e66c6941f68f84459b4d61.tar.xz
sssd-5fad9a3d700ba24783e66c6941f68f84459b4d61.zip
Add sysdb_attrs_get_string_array()
Diffstat (limited to 'src')
-rw-r--r--src/db/sysdb.c33
-rw-r--r--src/db/sysdb.h2
2 files changed, 35 insertions, 0 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index bfad77d8a..f784e735c 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -130,6 +130,39 @@ int sysdb_attrs_get_string(struct sysdb_attrs *attrs, const char *name,
return EOK;
}
+int sysdb_attrs_get_string_array(struct sysdb_attrs *attrs, const char *name,
+ TALLOC_CTX *mem_ctx, const char ***string)
+{
+ struct ldb_message_element *el;
+ int ret;
+ unsigned int u;
+ const char **a;
+
+ ret = sysdb_attrs_get_el_int(attrs, name, false, &el);
+ if (ret) {
+ return ret;
+ }
+
+ a = talloc_array(mem_ctx, const char *, el->num_values + 1);
+ if (a == NULL) {
+ return ENOMEM;
+ }
+
+ memset(a, 0, sizeof(const char *) * (el->num_values + 1));
+
+ for(u = 0; u < el->num_values; u++) {
+ a[u] = talloc_strndup(a, (const char *)el->values[u].data,
+ el->values[u].length);
+ if (a[u] == NULL) {
+ talloc_free(a);
+ return ENOMEM;
+ }
+ }
+
+ *string = a;
+ return EOK;
+}
+
int sysdb_attrs_add_val(struct sysdb_attrs *attrs,
const char *name, const struct ldb_val *val)
{
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index a5413a25c..54119457e 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -175,6 +175,8 @@ int sysdb_attrs_steal_string(struct sysdb_attrs *attrs,
const char *name, char *str);
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_replace_name(struct sysdb_attrs *attrs, const char *oldname,
const char *newname);