Add a function libnet_conf_get_global_parameter() to libnet_conf.c
authorMichael Adam <obnox@samba.org>
Sun, 13 Jan 2008 22:12:27 +0000 (23:12 +0100)
committerMichael Adam <obnox@samba.org>
Sun, 13 Jan 2008 22:16:42 +0000 (23:16 +0100)
It creates the [global] section if it does not yet exist.

Michael
(This used to be commit 627a29b690c30f1096a4746186089cd9a1c92407)

source3/libnet/libnet_conf.c

index 858c4a06b4115266e87e491ebd2ada4ac1af6699..37e05b9fe9b4eccb856e53b42c0cd410d77cbcec 100644 (file)
@@ -867,6 +867,31 @@ done:
        return werr;
 }
 
+/**
+ * Get the value of a global parameter.
+ *
+ * Create [global] if it does not exist.
+ */
+WERROR libnet_conf_get_global_parameter(TALLOC_CTX *mem_ctx,
+                                       struct libnet_conf_ctx *ctx,
+                                       const char *param,
+                                       char **valstr)
+{
+       WERROR werr;
+
+       if (!libnet_conf_share_exists(ctx, GLOBAL_NAME)) {
+               werr = libnet_conf_create_share(ctx, GLOBAL_NAME);
+               if (!W_ERROR_IS_OK(werr)) {
+                       goto done;
+               }
+       }
+       werr = libnet_conf_get_parameter(mem_ctx, ctx, GLOBAL_NAME, param,
+                                        valstr);
+
+done:
+       return werr;
+}
+
 /**
  * delete a parameter from configuration
  */