* BUG 446
[samba.git] / source3 / client / client.c
index 949933b890b5a0a079a303d091d6d499274b969e..6c43a974f2bb6be0f9b4c16512f89a34ba2ec0b0 100644 (file)
@@ -1006,7 +1006,7 @@ static int cmd_mkdir(void)
                *ddir2 = 0;
                
                pstrcpy(ddir,mask);
-               trim_string(ddir,".",NULL);
+               trim_char(ddir,'.','\0');
                p = strtok(ddir,"/\\");
                while (p) {
                        pstrcat(ddir2,p);
@@ -2403,10 +2403,9 @@ static char **completion_fn(const char *text, int start, int end)
                return matches;
 
 cleanup:
-               while (i >= 0) {
+               for (i = 0; i < count; i++)
                        free(matches[i]);
-                       i--;
-               }
+
                free(matches);
                return NULL;
        }
@@ -2779,6 +2778,7 @@ static void remember_query_host(const char *arg,
        poptContext pc;
        char *p;
        int rc = 0;
+       fstring new_workgroup;
        struct poptOption long_options[] = {
                POPT_AUTOHELP
 
@@ -2809,9 +2809,15 @@ static void remember_query_host(const char *arg,
 
        *query_host = 0;
        *base_directory = 0;
+       
+       /* initialize the workgroup name so we can determine whether or 
+          not it was set by a command line option */
+          
+       set_global_myworkgroup( "" );
 
         /* set default debug level to 0 regardless of what smb.conf sets */
-       DEBUGLEVEL_CLASS[DBGC_ALL] = 0;
+       setup_logging( "smbclient", True );
+       DEBUGLEVEL_CLASS[DBGC_ALL] = 1;
        dbf = x_stderr;
        x_setbuf( x_stderr, NULL );
 
@@ -2891,13 +2897,24 @@ static void remember_query_host(const char *arg,
         * set by cmdline arg or remain default (0)
         */
        AllowDebugChange = False;
-
+       
+       /* save the workgroup...
+       
+          FIXME!! do we need to do tyhis for other options as well 
+          (or maybe a generic way to keep lp_load() from overwriting 
+          everything)?  */
+       
+       fstrcpy( new_workgroup, lp_workgroup() );               
+       
        if (!lp_load(dyn_CONFIGFILE,True,False,False)) {
                fprintf(stderr, "%s: Can't load %s - run testparm to debug it\n",
                        argv[0], dyn_CONFIGFILE);
        }
        
        load_interfaces();
+       
+       if ( strlen(new_workgroup) != 0 )
+               set_global_myworkgroup( new_workgroup );
 
        if(poptPeekArg(pc)) {
                pstrcpy(service,poptGetArg(pc));