summaryrefslogtreecommitdiff
path: root/source3/libnet
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2007-12-29 12:52:09 +0100
committerMichael Adam <obnox@samba.org>2007-12-29 12:52:09 +0100
commit2a642a6e2b42c2b111870f95fe6dd38e875766f1 (patch)
treef5c2dd575dab3775daf56dadaa1ecb3a2b1eeb28 /source3/libnet
parentf8c39cbb7b3e4df3c07735575bc5f31717b22f66 (diff)
downloadsamba-2a642a6e2b42c2b111870f95fe6dd38e875766f1.tar.gz
samba-2a642a6e2b42c2b111870f95fe6dd38e875766f1.tar.bz2
samba-2a642a6e2b42c2b111870f95fe6dd38e875766f1.zip
Move functionality of net_conf_listshares() to libnet_conf.c
into new function libnet_smbconf_getshares(). Michael (This used to be commit 306c7e4d9cecac4c2c0ea1172bd585c3c17d4541)
Diffstat (limited to 'source3/libnet')
-rw-r--r--source3/libnet/libnet_conf.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/source3/libnet/libnet_conf.c b/source3/libnet/libnet_conf.c
index ca25a5cc50..a67a361f6e 100644
--- a/source3/libnet/libnet_conf.c
+++ b/source3/libnet/libnet_conf.c
@@ -384,6 +384,59 @@ done:
return werr;
}
+WERROR libnet_smbconf_getshares(TALLOC_CTX *mem_ctx, uint32_t *num_shares,
+ char ***share_names)
+{
+ uint32_t count;
+ TALLOC_CTX *tmp_ctx;
+ WERROR werr = WERR_OK;
+ struct registry_key *key = NULL;
+ char *subkey_name = NULL;
+ char **tmp_share_names = NULL;
+
+ if ((num_shares == NULL) || (share_names == NULL)) {
+ werr = WERR_INVALID_PARAM;
+ goto done;
+ }
+
+ tmp_ctx = talloc_new(mem_ctx);
+ if (tmp_ctx == NULL) {
+ werr = WERR_NOMEM;
+ goto done;
+ }
+
+ werr = libnet_smbconf_reg_open_basepath(tmp_ctx,
+ SEC_RIGHTS_ENUM_SUBKEYS,
+ &key);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
+
+ for (count = 0;
+ W_ERROR_IS_OK(werr = reg_enumkey(tmp_ctx, key, count,
+ &subkey_name, NULL));
+ count++)
+ {
+ tmp_share_names = TALLOC_REALLOC_ARRAY(tmp_ctx, tmp_share_names,
+ char *, count + 1);
+ tmp_share_names[count] = talloc_strdup(tmp_ctx, subkey_name);
+ }
+ if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
+ goto done;
+ }
+
+ werr = WERR_OK;
+
+ *num_shares = count - 1;
+ if (count > 0) {
+ *share_names = talloc_move(mem_ctx, &tmp_share_names);
+ }
+
+done:
+ TALLOC_FREE(tmp_ctx);
+ return werr;
+}
+
/**
* get a definition of a share (service) from configuration.
*/