From 9dfa22c3925792204b22962851dd44175e1b5735 Mon Sep 17 00:00:00 2001 From: Jan Zeleny Date: Tue, 3 May 2011 05:21:17 -0400 Subject: Make sysdb_ctx_list public structure Also create a routine to initialize it --- src/db/sysdb.c | 41 +++++++++++++++++++++++++++++++++++++++++ src/db/sysdb.h | 13 ++++++++++++- src/db/sysdb_private.h | 7 ------- 3 files changed, 53 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/db/sysdb.c b/src/db/sysdb.c index 0e977900..5396b7fc 100644 --- a/src/db/sysdb.c +++ b/src/db/sysdb.c @@ -2013,6 +2013,47 @@ int sysdb_domain_init(TALLOC_CTX *mem_ctx, db_path, false, _ctx); } +int sysdb_list_init(TALLOC_CTX *mem_ctx, + const char *path, + struct sysdb_ctx *ctx, + struct sysdb_ctx_list **_list) +{ + struct sysdb_ctx_list *list; + int ret; + + list = talloc_zero(mem_ctx, struct sysdb_ctx_list); + if (!list) { + DEBUG(1, ("talloc_zero failed\n")); + return ENOMEM; + } + + list->db_path = talloc_strdup(list, path); + if (!list->db_path) { + DEBUG(1, ("talloc_strdup failed\n")); + ret = ENOMEM; + goto fail; + } + + if (ctx) { + list->num_dbs = 1; + list->dbs = talloc_array(list, struct sysdb_ctx *, list->num_dbs); + if (!list->dbs) { + DEBUG(1, ("talloc_array failed\n")); + ret = ENOMEM; + goto fail; + } + + list->dbs[0] = talloc_steal(list, ctx); + } + + *_list = list; + return EOK; + +fail: + talloc_free(list); + return ret; +} + int sysdb_get_ctx_from_list(struct sysdb_ctx_list *ctx_list, struct sss_domain_info *domain, struct sysdb_ctx **ctx) diff --git a/src/db/sysdb.h b/src/db/sysdb.h index e6f9b4a7..a7d3e7ea 100644 --- a/src/db/sysdb.h +++ b/src/db/sysdb.h @@ -169,9 +169,15 @@ #define SYSDB_MOD_REP LDB_FLAG_MOD_REPLACE struct confdb_ctx; -struct sysdb_ctx_list; struct sysdb_ctx; +struct sysdb_ctx_list { + struct sysdb_ctx **dbs; + size_t num_dbs; + + char *db_path; +}; + struct sysdb_attrs { int num; struct ldb_message_element *a; @@ -282,6 +288,11 @@ int sysdb_domain_init(TALLOC_CTX *mem_ctx, const char *db_path, struct sysdb_ctx **_ctx); +int sysdb_list_init(TALLOC_CTX *mem_ctx, + const char *path, + struct sysdb_ctx *ctx, + struct sysdb_ctx_list **_list); + int sysdb_get_ctx_from_list(struct sysdb_ctx_list *ctx_list, struct sss_domain_info *domain, struct sysdb_ctx **_ctx); diff --git a/src/db/sysdb_private.h b/src/db/sysdb_private.h index 66e7bc72..0cbb3a45 100644 --- a/src/db/sysdb_private.h +++ b/src/db/sysdb_private.h @@ -74,11 +74,4 @@ struct sysdb_ctx { char *ldb_file; }; -struct sysdb_ctx_list { - struct sysdb_ctx **dbs; - size_t num_dbs; - - char *db_path; -}; - #endif /* __INT_SYS_DB_H__ */ -- cgit