[GLUE] Rsync SAMBA_3_2_0 SVN r25598 in order to create the v3-2-test branch.
[samba.git] / source / utils / smbtree.c
index 5deb29a149b3a03b5b3f66feea464e9376d03695..7d62d65b05695e926242b8b9f36ca7536954cbc1 100644 (file)
@@ -16,8 +16,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
@@ -134,12 +133,10 @@ static BOOL get_rpc_shares(struct cli_state *cli,
        NTSTATUS status;
        struct rpc_pipe_client *pipe_hnd;
        TALLOC_CTX *mem_ctx;
-       uint32 enum_hnd;
-       struct srvsvc_NetShareCtr1 ctr1;
-       union srvsvc_NetShareCtr ctr;
-       uint32 numentries;
+       ENUM_HND enum_hnd;
+       WERROR werr;
+       SRV_SHARE_INFO_CTR ctr;
        int i;
-       uint32 info_level = 1;
 
        mem_ctx = talloc_new(NULL);
        if (mem_ctx == NULL) {
@@ -147,7 +144,8 @@ static BOOL get_rpc_shares(struct cli_state *cli,
                return False;
        }
 
-       enum_hnd = 0;
+       init_enum_hnd(&enum_hnd, 0);
+
        pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SRVSVC, &status);
 
        if (pipe_hnd == NULL) {
@@ -157,24 +155,23 @@ static BOOL get_rpc_shares(struct cli_state *cli,
                return False;
        }
 
-       ZERO_STRUCT(ctr1);
-       level = 1;
-       ctr.ctr1 = &ctr1;
-
-       status = rpccli_srvsvc_NetShareEnum(pipe_hnd, mem_ctx, NULL,
-                                           &info_level, &ctr,
-                                           0xffffffff, &numentries,
-                                           &enum_hnd);
+       werr = rpccli_srvsvc_net_share_enum(pipe_hnd, mem_ctx, 1, &ctr,
+                                           0xffffffff, &enum_hnd);
 
-       if (!NT_STATUS_IS_OK(status)) {
+       if (!W_ERROR_IS_OK(werr)) {
                TALLOC_FREE(mem_ctx);
                cli_rpc_pipe_close(pipe_hnd);
                return False;
        }
 
-       for (i=0; i<numentries; i++) {
-               fn(ctr.ctr1->array[i].name, ctr.ctr1->array[i].type, 
-                  ctr.ctr1->array[i].comment, state);
+       for (i=0; i<ctr.num_entries; i++) {
+               SRV_SHARE_INFO_1 *info = &ctr.share.info1[i];
+               char *name, *comment;
+               name = rpcstr_pull_unistr2_talloc(
+                       mem_ctx, &info->info_1_str.uni_netname);
+               comment = rpcstr_pull_unistr2_talloc(
+                       mem_ctx, &info->info_1_str.uni_remark);
+               fn(name, info->info_1.type, comment, state);
        }
 
        TALLOC_FREE(mem_ctx);
@@ -250,6 +247,7 @@ static BOOL print_tree(struct user_auth_info *user_info)
 ****************************************************************************/
  int main(int argc,char *argv[])
 {
+       TALLOC_CTX *frame = talloc_stackframe();
        struct poptOption long_options[] = {
                POPT_AUTOHELP
                { "broadcast", 'b', POPT_ARG_VAL, &use_bcast, True, "Use broadcast instead of using the master browser" },
@@ -290,8 +288,11 @@ static BOOL print_tree(struct user_auth_info *user_info)
 
        /* Now do our stuff */
 
-        if (!print_tree(&cmdline_auth_info))
+        if (!print_tree(&cmdline_auth_info)) {
+               TALLOC_FREE(frame);
                 return 1;
+       }
 
+       TALLOC_FREE(frame);
        return 0;
 }