summaryrefslogtreecommitdiffstats
path: root/src/db
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:06:19 -0400
commitee613f42cc2dd75fde6402581f22a2acb0a26597 (patch)
tree20f2680f49daf9d21c68fb4500c49450628f1015 /src/db
parentf9caae7be34cbe22d44bf9d1086d7fabcf28fa15 (diff)
downloadsssd-ee613f42cc2dd75fde6402581f22a2acb0a26597.tar.gz
sssd-ee613f42cc2dd75fde6402581f22a2acb0a26597.tar.xz
sssd-ee613f42cc2dd75fde6402581f22a2acb0a26597.zip
Add sysdb_attrs_get_string_array()
Diffstat (limited to 'src/db')
-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 21e69c04a..41e1756c9 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -140,6 +140,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 fcdb90e69..50427d613 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -176,6 +176,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);