diff options
author | Jan Zeleny <jzeleny@redhat.com> | 2012-07-16 13:52:49 -0400 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2012-07-18 16:32:22 +0200 |
commit | 266fd9834133e31c51b9e967307a793e5a49258e (patch) | |
tree | 6af64aa646d687ea0b727ccde6ce434346eba9af /src | |
parent | bc76428246c4ce532abd0eadcd539069fc1d94a8 (diff) | |
download | sssd-266fd9834133e31c51b9e967307a793e5a49258e.tar.gz sssd-266fd9834133e31c51b9e967307a793e5a49258e.tar.xz 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')
-rw-r--r-- | src/db/sysdb.c | 24 | ||||
-rw-r--r-- | src/db/sysdb.h | 3 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c index fd76f73c3..7f7310a2c 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 f0ff6f5a8..5baac98b3 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, |