r13161: Remove optional password as second parameter. Improve return values a bit.
authorJelmer Vernooij <jelmer@samba.org>
Thu, 26 Jan 2006 11:48:45 +0000 (11:48 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:51:30 +0000 (13:51 -0500)
source/client/client.c

index f4e85a4ea6f00d2dfdabfe1c696a51cd3029ac72..077ca351c1fa89711dbed0a55b0456b6cbba127f 100644 (file)
@@ -74,8 +74,6 @@ void dos_clean_name(char *s)
        /* remove any double slashes */
        all_string_sub(s, "\\\\", "\\", 0);
 
        /* remove any double slashes */
        all_string_sub(s, "\\\\", "\\", 0);
 
-       all_string_sub(s, "/", "\\", 0);
-
        while ((p = strstr(s,"\\..\\")) != NULL) {
                *p = '\0';
                if ((r = strrchr(s,'\\')) != NULL)
        while ((p = strstr(s,"\\..\\")) != NULL) {
                *p = '\0';
                if ((r = strrchr(s,'\\')) != NULL)
@@ -991,7 +989,7 @@ static int cmd_quit(struct smbclient_context *ctx, const char **args)
   ****************************************************************************/
 static int cmd_mkdir(struct smbclient_context *ctx, const char **args)
 {
   ****************************************************************************/
 static int cmd_mkdir(struct smbclient_context *ctx, const char **args)
 {
-       char *mask;
+       char *mask, *p;
   
        if (!args[1]) {
                if (!ctx->recurse)
   
        if (!args[1]) {
                if (!ctx->recurse)
@@ -1002,28 +1000,20 @@ static int cmd_mkdir(struct smbclient_context *ctx, const char **args)
        mask = talloc_asprintf(ctx, "%s%s", ctx->remote_cur_dir,args[1]);
 
        if (ctx->recurse) {
        mask = talloc_asprintf(ctx, "%s%s", ctx->remote_cur_dir,args[1]);
 
        if (ctx->recurse) {
-               int i;
-               const char **els;
-               char *parent = NULL;
                dos_clean_name(mask);
 
                trim_string(mask,".",NULL);
                dos_clean_name(mask);
 
                trim_string(mask,".",NULL);
-
-               els = str_list_make(ctx, mask, "/\\");
-
-               for (i = 0; els[i]; i++) {
-                       parent = talloc_asprintf_append(parent, "%s\\", els[i]);
+               for (p = strtok(mask,"/\\"); p; p = strtok(p, "/\\")) {
+                       char *parent = talloc_strndup(ctx, mask, PTR_DIFF(p, mask));
                        
                        if (NT_STATUS_IS_ERR(smbcli_chkpath(ctx->cli->tree, parent))) { 
                                do_mkdir(ctx, parent);
                        }
                        
                        if (NT_STATUS_IS_ERR(smbcli_chkpath(ctx->cli->tree, parent))) { 
                                do_mkdir(ctx, parent);
                        }
-               }        
-
 
 
-               talloc_free(parent);
+                       talloc_free(parent);
+               }        
        } else {
        } else {
-               if (NT_STATUS_IS_ERR(do_mkdir(ctx, mask)))
-                       return 1;
+               do_mkdir(ctx, mask);
        }
        
        return 0;
        }
        
        return 0;
@@ -2094,13 +2084,10 @@ static int cmd_rmdir(struct smbclient_context *ctx, const char **args)
                return 1;
        }
        mask = talloc_asprintf(ctx, "%s%s", ctx->remote_cur_dir, args[1]);
                return 1;
        }
        mask = talloc_asprintf(ctx, "%s%s", ctx->remote_cur_dir, args[1]);
-       
-       dos_clean_name(mask);
 
        if (NT_STATUS_IS_ERR(smbcli_rmdir(ctx->cli->tree, mask))) {
 
        if (NT_STATUS_IS_ERR(smbcli_rmdir(ctx->cli->tree, mask))) {
-               d_printf("%s removing remote directory %s\n",
+               d_printf("%s removing remote directory file %s\n",
                         smbcli_errstr(ctx->cli->tree),mask);
                         smbcli_errstr(ctx->cli->tree),mask);
-               return 1;
        }
        
        return 0;
        }
        
        return 0;
@@ -2705,8 +2692,7 @@ process a -c command string
 static int process_command_string(struct smbclient_context *ctx, const char *cmd)
 {
        const char **lines;
 static int process_command_string(struct smbclient_context *ctx, const char *cmd)
 {
        const char **lines;
-       int i;
-       int rc = 0;
+       int i, rc = 0;
 
        lines = str_list_make(NULL, cmd, ";");
        for (i = 0; lines[i]; i++) {
 
        lines = str_list_make(NULL, cmd, ";");
        for (i = 0; lines[i]; i++) {
@@ -2950,12 +2936,9 @@ static int process_stdin(struct smbclient_context *ctx)
 {
        int rc = 0;
        while (1) {
 {
        int rc = 0;
        while (1) {
-               char *the_prompt;
-               char *cline;
-               
                /* display a prompt */
                /* display a prompt */
-               the_prompt = talloc_asprintf(ctx, "smb: %s> ", ctx->remote_cur_dir);
-               cline = smb_readline(the_prompt, readline_callback, completion_fn);
+               char *the_prompt = talloc_asprintf(ctx, "smb: %s> ", ctx->remote_cur_dir);
+               char *cline = smb_readline(the_prompt, readline_callback, completion_fn);
                talloc_free(the_prompt);
                        
                if (!cline) break;
                talloc_free(the_prompt);
                        
                if (!cline) break;
@@ -2966,7 +2949,7 @@ static int process_stdin(struct smbclient_context *ctx)
                        continue;
                }
 
                        continue;
                }
 
-               rc |= process_line(ctx, cline); 
+               rc |= process_command_string(ctx, cline); 
        }
 
        return rc;
        }
 
        return rc;