smbclient: Introduce struct do_list_helper_state
authorVolker Lendecke <vl@samba.org>
Sun, 11 Oct 2020 05:41:01 +0000 (07:41 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 4 Nov 2020 18:55:40 +0000 (18:55 +0000)
We'll pass more information to do_list_helper() soon

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/client/client.c

index 0c14e65389d8769bc652064daa393ec579283a11..2b9ef12defcfdea4c83f52f003d0b0a9b41e969d 100644 (file)
@@ -723,13 +723,17 @@ static int do_list_queue_empty(void)
  A helper for do_list.
 ****************************************************************************/
 
+struct do_list_helper_state {
+       struct cli_state *cli;
+};
+
 static NTSTATUS do_list_helper(
        const char *mntpoint,
        struct file_info *f,
        const char *mask,
-       void *state)
+       void *private_data)
 {
-       struct cli_state *cli_state = (struct cli_state *)state;
+       struct do_list_helper_state *state = private_data;
        TALLOC_CTX *ctx = talloc_tos();
        char *dir = NULL;
        char *dir_end = NULL;
@@ -748,14 +752,14 @@ static NTSTATUS do_list_helper(
 
        if (!(f->attr & FILE_ATTRIBUTE_DIRECTORY)) {
                if (do_this_one(f)) {
-                       status = do_list_fn(cli_state, f, dir);
+                       status = do_list_fn(state->cli, f, dir);
                }
                TALLOC_FREE(dir);
                return status;
        }
 
        if (do_list_dirs && do_this_one(f)) {
-               status = do_list_fn(cli_state, f, dir);
+               status = do_list_fn(state->cli, f, dir);
                if (!NT_STATUS_IS_OK(status)) {
                        return status;
                }
@@ -837,7 +841,7 @@ NTSTATUS do_list(const char *mask,
 
        while (!do_list_queue_empty()) {
                const char *head = do_list_queue_head();
-               struct cli_state *targetcli = NULL;
+               struct do_list_helper_state state = { .cli = NULL };
                char *targetpath = NULL;
 
                /* check for dfs */
@@ -848,7 +852,7 @@ NTSTATUS do_list(const char *mask,
                        creds,
                        cli,
                        head,
-                       &targetcli,
+                       &state.cli,
                        &targetpath);
                if (!NT_STATUS_IS_OK(status)) {
                        d_printf("do_list: [%s] %s\n", head,
@@ -858,11 +862,11 @@ NTSTATUS do_list(const char *mask,
                }
 
                status = cli_list(
-                       targetcli,
+                       state.cli,
                        targetpath,
                        attribute,
                        do_list_helper,
-                       targetcli);
+                       &state);
                if (!NT_STATUS_IS_OK(status)) {
                        d_printf("%s listing %s\n",
                                 nt_errstr(status), targetpath);