]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libsmbconf: refactor autocreation of [global] into a helper function.
authorMichael Adam <obnox@samba.org>
Thu, 20 Mar 2008 09:43:17 +0000 (10:43 +0100)
committerMichael Adam <obnox@samba.org>
Fri, 21 Mar 2008 01:25:55 +0000 (02:25 +0100)
Michael

source/lib/smbconf/smbconf.c

index a5059c9eb5239889207f3c8fb59ab49dbab83d09..dd044eef818008e29d7866079765b29ef1b283fb 100644 (file)
@@ -432,6 +432,14 @@ static void smbconf_reg_get_csn(struct smbconf_ctx *ctx,
        csn->csn = (uint64_t)regdb_get_seqnum();
 }
 
+static WERROR smbconf_global_check(struct smbconf_ctx *ctx)
+{
+       if (!smbconf_share_exists(ctx, GLOBAL_NAME)) {
+               return smbconf_create_share(ctx, GLOBAL_NAME);
+       }
+       return WERR_OK;
+}
+
 /**********************************************************************
  *
  * The actual net conf api functions, that are exported.
@@ -844,15 +852,11 @@ WERROR smbconf_set_global_parameter(struct smbconf_ctx *ctx,
 {
        WERROR werr;
 
-       if (!smbconf_share_exists(ctx, GLOBAL_NAME)) {
-               werr = smbconf_create_share(ctx, GLOBAL_NAME);
-               if (!W_ERROR_IS_OK(werr)) {
-                       goto done;
-               }
+       werr = smbconf_global_check(ctx);
+       if (W_ERROR_IS_OK(werr)) {
+               werr = smbconf_set_parameter(ctx, GLOBAL_NAME, param, val);
        }
-       werr = smbconf_set_parameter(ctx, GLOBAL_NAME, param, val);
 
-done:
        return werr;
 }
 
@@ -919,15 +923,12 @@ WERROR smbconf_get_global_parameter(struct smbconf_ctx *ctx,
 {
        WERROR werr;
 
-       if (!smbconf_share_exists(ctx, GLOBAL_NAME)) {
-               werr = smbconf_create_share(ctx, GLOBAL_NAME);
-               if (!W_ERROR_IS_OK(werr)) {
-                       goto done;
-               }
+       werr = smbconf_global_check(ctx);
+       if (W_ERROR_IS_OK(werr)) {
+               werr = smbconf_get_parameter(ctx, mem_ctx, GLOBAL_NAME, param,
+                                            valstr);
        }
-       werr = smbconf_get_parameter(ctx, mem_ctx, GLOBAL_NAME, param, valstr);
 
-done:
        return werr;
 }
 
@@ -973,14 +974,10 @@ WERROR smbconf_delete_global_parameter(struct smbconf_ctx *ctx,
 {
        WERROR werr;
 
-       if (!smbconf_share_exists(ctx, GLOBAL_NAME)) {
-               werr = smbconf_create_share(ctx, GLOBAL_NAME);
-               if (!W_ERROR_IS_OK(werr)) {
-                       goto done;
-               }
+       werr = smbconf_global_check(ctx);
+       if (W_ERROR_IS_OK(werr)) {
+               werr = smbconf_delete_parameter(ctx, GLOBAL_NAME, param);
        }
-       werr = smbconf_delete_parameter(ctx, GLOBAL_NAME, param);
 
-done:
        return werr;
 }