>From d58bde82706ca22329727c2b9b4cb08ced7107bb Mon Sep 17 00:00:00 2001
From: Simo Sorce <simo@redhat.com>
Date: Thu, 19 Jul 2012 17:40:40 -0400
Subject: [PATCH 01/16] Change subdomain_info

Rename the structure to use a standard name prefix so it is properly
name-spaced, in preparation for changing the structure itself.
---
 src/db/sysdb.h                               |   10 +++----
 src/db/sysdb_subdomains.c                    |   24 ++++++++--------
 src/providers/dp_backend.h                   |    2 +-
 src/providers/ipa/ipa_subdomains.c           |   12 ++++----
 src/responder/common/responder_get_domains.c |    2 +-
 src/tests/sysdb-tests.c                      |   38 +++++++++++++++-----------
 6 files changed, 47 insertions(+), 41 deletions(-)

diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index 3c6166cf42104aa3615f74413212f3cff6a0fd78..20641a753ef7d140f075e077f9afc0498c15f8de 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -240,7 +240,7 @@ struct sysdb_attrs {
 /* sysdb_attrs helper functions */
 struct sysdb_attrs *sysdb_new_attrs(TALLOC_CTX *mem_ctx);
 
-struct subdomain_info {
+struct sysdb_subdom {
     char *name;
     char *flat_name;
     char *id;
@@ -364,12 +364,12 @@ int sysdb_transaction_cancel(struct sysdb_ctx *sysdb);
 errno_t sysdb_get_subdomains(TALLOC_CTX *mem_ctx,
                              struct sysdb_ctx *sysdb,
                              size_t *subdomain_count,
-                             struct subdomain_info ***subdomain_list);
+                             struct sysdb_subdom ***subdomain_list);
 
 errno_t sysdb_domain_create(struct sysdb_ctx *sysdb, const char *domain_name);
 
 errno_t sysdb_update_subdomains(struct sysdb_ctx *sysdb,
-                                struct subdomain_info **subdomains);
+                                struct sysdb_subdom **subdomains);
 
 errno_t sysdb_get_subdomain_context(TALLOC_CTX *mem_ctx,
                                     struct sysdb_ctx *sysdb,
@@ -378,10 +378,10 @@ errno_t sysdb_get_subdomain_context(TALLOC_CTX *mem_ctx,
 
 errno_t sysdb_master_domain_get_info(TALLOC_CTX *mem_ctx,
                                      struct sysdb_ctx *sysdb,
-                                     struct subdomain_info **info);
+                                     struct sysdb_subdom **info);
 
 errno_t sysdb_master_domain_add_info(struct sysdb_ctx *sysdb,
-                                     struct subdomain_info *domain_info);
+                                     struct sysdb_subdom *domain_info);
 
 
 errno_t sysdb_search_domuser_by_name(TALLOC_CTX *mem_ctx,
diff --git a/src/db/sysdb_subdomains.c b/src/db/sysdb_subdomains.c
index 523a23a5b8e0c2d9db2d08233861b7d9b3923897..b5a92fdda4997fa2aa07119aac52b9244b61d47f 100644
--- a/src/db/sysdb_subdomains.c
+++ b/src/db/sysdb_subdomains.c
@@ -25,7 +25,7 @@
 
 errno_t sysdb_get_subdomains(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb,
                              size_t *subdomain_count,
-                             struct subdomain_info ***subdomain_list)
+                             struct sysdb_subdom ***subdomain_list)
 {
     int i;
     errno_t ret;
@@ -35,7 +35,7 @@ errno_t sysdb_get_subdomains(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb,
                            SYSDB_SUBDOMAIN_FLAT,
                            SYSDB_SUBDOMAIN_ID,
                            NULL};
-    struct subdomain_info **list;
+    struct sysdb_subdom **list;
     struct ldb_dn *basedn;
     const char *tmp_str;
 
@@ -58,14 +58,14 @@ errno_t sysdb_get_subdomains(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb,
         goto done;
     }
 
-    list = talloc_zero_array(tmp_ctx, struct subdomain_info *, res->count);
+    list = talloc_zero_array(tmp_ctx, struct sysdb_subdom *, res->count);
     if (list == NULL) {
         ret = ENOMEM;
         goto done;
     }
 
     for (i = 0; i < res->count; i++) {
-        list[i] = talloc_zero(list, struct subdomain_info);
+        list[i] = talloc_zero(list, struct sysdb_subdom);
         if (list[i] == NULL) {
             ret = ENOMEM;
             goto done;
@@ -114,13 +114,13 @@ done:
 
 errno_t sysdb_master_domain_get_info(TALLOC_CTX *mem_ctx,
                                      struct sysdb_ctx *sysdb,
-                                     struct subdomain_info **_info)
+                                     struct sysdb_subdom **_info)
 {
     errno_t ret;
     TALLOC_CTX *tmp_ctx;
     const char *tmp_str;
     struct ldb_dn *basedn;
-    struct subdomain_info *info;
+    struct sysdb_subdom *info;
     struct ldb_result *res;
     const char *attrs[] = {"cn",
                            SYSDB_SUBDOMAIN_FLAT,
@@ -132,7 +132,7 @@ errno_t sysdb_master_domain_get_info(TALLOC_CTX *mem_ctx,
         return ENOMEM;
     }
 
-    info = talloc_zero(tmp_ctx, struct subdomain_info);
+    info = talloc_zero(tmp_ctx, struct sysdb_subdom);
     if (info == NULL) {
         ret = ENOMEM;
         goto done;
@@ -185,13 +185,13 @@ done:
 }
 
 errno_t sysdb_master_domain_add_info(struct sysdb_ctx *sysdb,
-                                     struct subdomain_info *domain_info)
+                                     struct sysdb_subdom *domain_info)
 {
     TALLOC_CTX *tmp_ctx;
     struct ldb_message *msg;
     int ret;
     bool do_update = false;
-    struct subdomain_info *current_info;
+    struct sysdb_subdom *current_info;
 
     tmp_ctx = talloc_new(NULL);
     if (tmp_ctx == NULL) {
@@ -279,7 +279,7 @@ done:
     return ret;
 }
 static errno_t sysdb_add_subdomain_attributes(struct sysdb_ctx *sysdb,
-                                             struct subdomain_info *domain_info)
+                                             struct sysdb_subdom *domain_info)
 {
     TALLOC_CTX *tmp_ctx;
     struct ldb_message *msg;
@@ -366,7 +366,7 @@ done:
 }
 
 errno_t sysdb_update_subdomains(struct sysdb_ctx *sysdb,
-                                struct subdomain_info **subdomains)
+                                struct sysdb_subdom **subdomains)
 {
     int ret;
     int sret;
@@ -374,7 +374,7 @@ errno_t sysdb_update_subdomains(struct sysdb_ctx *sysdb,
     size_t d;
     TALLOC_CTX *tmp_ctx = NULL;
     size_t cur_subdomains_count;
-    struct subdomain_info **cur_subdomains;
+    struct sysdb_subdom **cur_subdomains;
     struct ldb_dn *dn;
     bool in_transaction = false;
     bool *keep_subdomain;
diff --git a/src/providers/dp_backend.h b/src/providers/dp_backend.h
index 6e5c6e1a6923f97912c128759871502e4f68e1bf..c9129ff79ac445a57f21cb6a56f190f76e882ab2 100644
--- a/src/providers/dp_backend.h
+++ b/src/providers/dp_backend.h
@@ -168,7 +168,7 @@ struct be_autofs_req {
 struct be_get_subdomains_req {
     bool force;
     char *domain_hint;
-    struct subdomain_info **domain_list;
+    struct sysdb_subdom **domain_list;
 };
 
 struct be_host_req {
diff --git a/src/providers/ipa/ipa_subdomains.c b/src/providers/ipa/ipa_subdomains.c
index 6d27b138d9a20978d6e8de57718df087d5b816f1..c4ed51ac5a04f9cecffbb800178585c760e40f2d 100644
--- a/src/providers/ipa/ipa_subdomains.c
+++ b/src/providers/ipa/ipa_subdomains.c
@@ -156,12 +156,12 @@ static errno_t ipa_subdomains_parse_results(
                                         size_t count,
                                         struct sysdb_attrs **reply)
 {
-    struct subdomain_info **new_domain_list = NULL;
+    struct sysdb_subdom **new_domain_list = NULL;
     const char *value;
     size_t c;
     int ret;
 
-    new_domain_list = talloc_array(sd_data, struct subdomain_info *, count + 1);
+    new_domain_list = talloc_array(sd_data, struct sysdb_subdom *, count + 1);
     if (new_domain_list == NULL) {
         DEBUG(SSSDBG_OP_FAILURE, ("talloc_array failed.\n"));
         return ENOMEM;
@@ -169,7 +169,7 @@ static errno_t ipa_subdomains_parse_results(
 
     for (c = 0; c < count; c++) {
         new_domain_list[c] = talloc_zero(new_domain_list,
-                                         struct subdomain_info);
+                                         struct sysdb_subdom);
         if (new_domain_list[c] == NULL) {
             DEBUG(SSSDBG_OP_FAILURE, ("talloc_zero failed.\n"));
             ret = ENOMEM;
@@ -471,7 +471,7 @@ static void ipa_subdomains_handler_ranges_done(struct tevent_req *req)
     struct ipa_subdomains_req_ctx *ctx = tevent_req_callback_data(req,
                                                        struct ipa_subdomains_req_ctx);
     struct be_req *be_req = ctx->be_req;
-    struct subdomain_info *domain_info;
+    struct sysdb_subdom *domain_info;
     struct range_info **range_list = NULL;
     struct sysdb_ctx *sysdb;
 
@@ -532,7 +532,7 @@ static void ipa_subdomains_handler_master_done(struct tevent_req *req)
     struct ipa_subdomains_req_ctx *ctx = tevent_req_callback_data(req,
                                                        struct ipa_subdomains_req_ctx);
     struct be_req *be_req = ctx->be_req;
-    struct subdomain_info *domain_info;
+    struct sysdb_subdom *domain_info;
     const char *tmp_str;
 
     ret = sdap_get_generic_recv(req, ctx, &reply_count, &reply);
@@ -543,7 +543,7 @@ static void ipa_subdomains_handler_master_done(struct tevent_req *req)
     }
 
     if (reply_count) {
-        domain_info = talloc_zero(ctx, struct subdomain_info);
+        domain_info = talloc_zero(ctx, struct sysdb_subdom);
         if (domain_info == NULL) {
             ret = ENOMEM;
             goto done;
diff --git a/src/responder/common/responder_get_domains.c b/src/responder/common/responder_get_domains.c
index 6b92bbe2c72a92171949387512266cffc56b4a72..2660d5e8006dea20383b66055ea976e82d0836e6 100644
--- a/src/responder/common/responder_get_domains.c
+++ b/src/responder/common/responder_get_domains.c
@@ -229,7 +229,7 @@ static errno_t get_domains_done(struct tevent_req *req)
     struct sss_domain_info *domain;
     struct sss_domain_info **new_sd_list = NULL;
     size_t subdomain_count;
-    struct subdomain_info **subdomains;
+    struct sysdb_subdom **subdomains;
 
     state = tevent_req_data(req, struct sss_dp_domains_info);
     domain = state->dom;
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
index 24e619f927c170bdd98645c2fafa194e542fd21d..b4ac0493404a12ddcc2ff1e955b493350fdd0ebc 100644
--- a/src/tests/sysdb-tests.c
+++ b/src/tests/sysdb-tests.c
@@ -3388,13 +3388,13 @@ START_TEST(test_sysdb_original_dn_case_insensitive)
 }
 END_TEST
 
-const struct subdomain_info dom1 =  {discard_const("dom1.sub"),
+const struct sysdb_subdom dom1 =  {discard_const("dom1.sub"),
                                      discard_const("dom1"),
                                      discard_const("S-1")};
-const struct subdomain_info dom2 =  {discard_const("dom2.sub"),
+const struct sysdb_subdom dom2 =  {discard_const("dom2.sub"),
                                      discard_const("dom2"),
                                      discard_const("S-2")};
-const struct subdomain_info dom_t = {discard_const("test.sub"),
+const struct sysdb_subdom dom_t = {discard_const("test.sub"),
                                      discard_const("test"),
                                      discard_const("S-3")};
 
@@ -3402,11 +3402,11 @@ START_TEST(test_sysdb_subdomain_create)
 {
     struct sysdb_test_ctx *test_ctx;
     errno_t ret;
-    struct subdomain_info **cur_subdomains = NULL;
+    struct sysdb_subdom **cur_subdomains = NULL;
     size_t cur_subdomains_count;
-    const struct subdomain_info *new_subdom1[] = { &dom1, NULL};
-    const struct subdomain_info *new_subdom2[] = { &dom2, NULL};
-    const struct subdomain_info *empty[] = { NULL};
+    const struct sysdb_subdom *new_subdom1[] = { &dom1, NULL};
+    const struct sysdb_subdom *new_subdom2[] = { &dom2, NULL};
+    const struct sysdb_subdom *empty[] = { NULL};
 
     ret = setup_sysdb_tests(&test_ctx);
     fail_if(ret != EOK, "Could not set up the test");
@@ -3418,7 +3418,8 @@ START_TEST(test_sysdb_subdomain_create)
     fail_unless(cur_subdomains != NULL, "No sub-domains returned.");
     fail_unless(cur_subdomains[0] == NULL, "No empyt sub-domain list returned.");
 
-    ret = sysdb_update_subdomains(test_ctx->sysdb, discard_const_p(struct subdomain_info *, new_subdom1));
+    ret = sysdb_update_subdomains(test_ctx->sysdb,
+                        discard_const_p(struct sysdb_subdom *, new_subdom1));
     fail_unless(ret == EOK, "sysdb_update_subdomains failed with [%d][%s]",
                             ret, strerror(ret));
 
@@ -3432,7 +3433,8 @@ START_TEST(test_sysdb_subdomain_create)
                 "Unexpected sub-domain found, expected [%s], got [%s]",
                 new_subdom1[0]->name, cur_subdomains[0]->name);
 
-    ret = sysdb_update_subdomains(test_ctx->sysdb, discard_const_p(struct subdomain_info *, new_subdom2));
+    ret = sysdb_update_subdomains(test_ctx->sysdb,
+                        discard_const_p(struct sysdb_subdom *, new_subdom2));
     fail_unless(ret == EOK, "sysdb_update_subdomains failed with [%d][%s]",
                             ret, strerror(ret));
 
@@ -3446,7 +3448,8 @@ START_TEST(test_sysdb_subdomain_create)
                 "Unexpected sub-domain found, expected [%s], got [%s]",
                 new_subdom2[0]->name, cur_subdomains[0]->name);
 
-    ret = sysdb_update_subdomains(test_ctx->sysdb, discard_const_p(struct subdomain_info *, empty));
+    ret = sysdb_update_subdomains(test_ctx->sysdb,
+                                discard_const_p(struct sysdb_subdom *, empty));
     fail_unless(ret == EOK, "sysdb_update_subdomains failed with [%d][%s]",
                             ret, strerror(ret));
 
@@ -3463,7 +3466,7 @@ START_TEST(test_sysdb_subdomain_store_user)
 {
     struct sysdb_test_ctx *test_ctx;
     errno_t ret;
-    const struct subdomain_info *test_subdom[] = { &dom_t, NULL};
+    const struct sysdb_subdom *test_subdom[] = { &dom_t, NULL};
     struct sss_domain_info *subdomain = NULL;
     struct ldb_result *results = NULL;
     struct ldb_dn *base_dn = NULL;
@@ -3472,7 +3475,8 @@ START_TEST(test_sysdb_subdomain_store_user)
     ret = setup_sysdb_tests(&test_ctx);
     fail_if(ret != EOK, "Could not set up the test");
 
-    ret = sysdb_update_subdomains(test_ctx->sysdb, discard_const_p(struct subdomain_info *, test_subdom));
+    ret = sysdb_update_subdomains(test_ctx->sysdb,
+                        discard_const_p(struct sysdb_subdom *, test_subdom));
     fail_unless(ret == EOK, "sysdb_update_subdomains failed with [%d][%s]",
                             ret, strerror(ret));
 
@@ -3518,7 +3522,7 @@ START_TEST(test_sysdb_subdomain_user_ops)
 {
     struct sysdb_test_ctx *test_ctx;
     errno_t ret;
-    const struct subdomain_info *test_subdom[] = { &dom_t, NULL};
+    const struct sysdb_subdom *test_subdom[] = { &dom_t, NULL};
     struct sss_domain_info *subdomain = NULL;
     struct ldb_message *msg = NULL;
     struct ldb_dn *check_dn = NULL;
@@ -3526,7 +3530,8 @@ START_TEST(test_sysdb_subdomain_user_ops)
     ret = setup_sysdb_tests(&test_ctx);
     fail_if(ret != EOK, "Could not set up the test");
 
-    ret = sysdb_update_subdomains(test_ctx->sysdb, discard_const_p(struct subdomain_info *, test_subdom));
+    ret = sysdb_update_subdomains(test_ctx->sysdb,
+                        discard_const_p(struct sysdb_subdom *, test_subdom));
     fail_unless(ret == EOK, "sysdb_update_subdomains failed with [%d][%s]",
                             ret, strerror(ret));
 
@@ -3567,7 +3572,7 @@ START_TEST(test_sysdb_subdomain_group_ops)
 {
     struct sysdb_test_ctx *test_ctx;
     errno_t ret;
-    const struct subdomain_info *test_subdom[] = { &dom_t, NULL};
+    const struct sysdb_subdom *test_subdom[] = { &dom_t, NULL};
     struct sss_domain_info *subdomain = NULL;
     struct ldb_message *msg = NULL;
     struct ldb_dn *check_dn = NULL;
@@ -3575,7 +3580,8 @@ START_TEST(test_sysdb_subdomain_group_ops)
     ret = setup_sysdb_tests(&test_ctx);
     fail_if(ret != EOK, "Could not set up the test");
 
-    ret = sysdb_update_subdomains(test_ctx->sysdb, discard_const_p(struct subdomain_info *, test_subdom));
+    ret = sysdb_update_subdomains(test_ctx->sysdb,
+                        discard_const_p(struct sysdb_subdom *, test_subdom));
     fail_unless(ret == EOK, "sysdb_update_subdomains failed with [%d][%s]",
                             ret, strerror(ret));
 
-- 
1.7.10.4

