summaryrefslogtreecommitdiff
path: root/src/db
diff options
context:
space:
mode:
authorJan Zeleny <jzeleny@redhat.com>2012-07-16 13:52:49 -0400
committerJakub Hrozek <jhrozek@redhat.com>2012-07-18 16:32:22 +0200
commit266fd9834133e31c51b9e967307a793e5a49258e (patch)
tree6af64aa646d687ea0b727ccde6ce434346eba9af /src/db
parentbc76428246c4ce532abd0eadcd539069fc1d94a8 (diff)
downloadsssd-266fd9834133e31c51b9e967307a793e5a49258e.tar.gz
sssd-266fd9834133e31c51b9e967307a793e5a49258e.tar.bz2
sssd-266fd9834133e31c51b9e967307a793e5a49258e.zip
Add function sysdb_attrs_copy_values()
This function copies all values from one sysdb_attrs structure to another
Diffstat (limited to 'src/db')
-rw-r--r--src/db/sysdb.c24
-rw-r--r--src/db/sysdb.h3
2 files changed, 27 insertions, 0 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index fd76f73c..7f7310a2 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -604,6 +604,30 @@ int sysdb_attrs_add_time_t(struct sysdb_attrs *attrs,
return ret;
}
+int sysdb_attrs_copy_values(struct sysdb_attrs *src,
+ struct sysdb_attrs *dst,
+ const char *name)
+{
+ int ret = EOK;
+ int i;
+ struct ldb_message_element *src_el;
+
+ ret = sysdb_attrs_get_el(src, name, &src_el);
+ if (ret != EOK) {
+ goto done;
+ }
+
+ for (i = 0; i < src_el->num_values; i++) {
+ ret = sysdb_attrs_add_val(dst, name, &src_el->values[i]);
+ if (ret != EOK) {
+ goto done;
+ }
+ }
+
+done:
+ return ret;
+}
+
int sysdb_attrs_users_from_str_list(struct sysdb_attrs *attrs,
const char *attr_name,
const char *domain,
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index f0ff6f5a..5baac98b 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -268,6 +268,9 @@ int sysdb_attrs_add_uint32(struct sysdb_attrs *attrs,
const char *name, uint32_t value);
int sysdb_attrs_add_time_t(struct sysdb_attrs *attrs,
const char *name, time_t value);
+int sysdb_attrs_copy_values(struct sysdb_attrs *src,
+ struct sysdb_attrs *dst,
+ const char *name);
int sysdb_attrs_get_el(struct sysdb_attrs *attrs, const char *name,
struct ldb_message_element **el);
int sysdb_attrs_steal_string(struct sysdb_attrs *attrs,