r15328: Move some functions around, remove dependencies.
[samba.git] / source / client / client.c
index ceb949ffd9689ef44040730cdbe5ec1a93c7a798..a17ce8e686810ca7df364d81f2722724ccfe599d 100644 (file)
@@ -27,6 +27,7 @@
 #include "lib/cmdline/popt_common.h"
 #include "librpc/gen_ndr/ndr_srvsvc_c.h"
 #include "librpc/gen_ndr/ndr_lsa.h"
+#include "librpc/gen_ndr/ndr_security.h"
 #include "libcli/raw/libcliraw.h"
 #include "libcli/util/clilsa.h"
 #include "system/dir.h"
@@ -39,7 +40,6 @@
 #include "libcli/security/security.h"
 #include "lib/replace/readline.h"
 #include "librpc/gen_ndr/ndr_nbt.h"
-#include "librpc/gen_ndr/ndr_security.h"
 
 static int io_bufsize = 64512;
 
@@ -286,9 +286,9 @@ BOOL mask_match(struct smbcli_state *c, const char *string, const char *pattern,
        char *p2, *s2;
        BOOL ret;
 
-       if (strcmp(string,"..") == 0)
+       if (ISDOTDOT(string))
                string = ".";
-       if (strcmp(pattern,".") == 0)
+       if (ISDOT(pattern))
                return False;
        
        if (is_case_sensitive)
@@ -408,11 +408,13 @@ static void init_do_list_queue(void)
 
 static void adjust_do_list_queue(void)
 {
+       if (do_list_queue == NULL) return;
+
        /*
         * If the starting point of the queue is more than half way through,
         * move everything toward the beginning.
         */
-       if (do_list_queue && (do_list_queue_start == do_list_queue_end))
+       if (do_list_queue_start == do_list_queue_end)
        {
                DEBUG(4,("do_list_queue is empty\n"));
                do_list_queue_start = do_list_queue_end = 0;
@@ -495,8 +497,8 @@ static void do_list_helper(struct clilist_file_info *f, const char *mask, void *
                        do_list_fn(ctx, f);
                }
                if (do_list_recurse && 
-                   !strequal(f->name,".") && 
-                   !strequal(f->name,"..")) {
+                   !ISDOT(f->name) &&
+                   !ISDOTDOT(f->name)) {
                        char *mask2;
                        char *p;
 
@@ -836,7 +838,7 @@ static void do_mget(struct smbclient_context *ctx, struct clilist_file_info *fin
        char *mget_mask;
        char *saved_curdir;
 
-       if (strequal(finfo->name,".") || strequal(finfo->name,".."))
+       if (ISDOT(finfo->name) || ISDOTDOT(finfo->name))
                return;
 
        if (finfo->attrib & FILE_ATTRIBUTE_DIRECTORY)
@@ -1325,8 +1327,9 @@ static int file_find(struct smbclient_context *ctx, struct file_list **list, con
        if (!dir) return -1;
        
         while ((dname = readdirname(dir))) {
-               if (!strcmp("..", dname)) continue;
-               if (!strcmp(".", dname)) continue;
+               if (ISDOT(dname) || ISDOTDOT(dname)) {
+                       continue;
+               }
                
                if (asprintf(&path, "%s/%s", directory, dname) <= 0) {
                        continue;
@@ -2183,7 +2186,7 @@ static int cmd_chmod(struct smbclient_context *ctx, const char **args)
 
        if (NT_STATUS_IS_ERR(smbcli_unix_chmod(ctx->cli->tree, src, mode))) {
                d_printf("%s chmod file %s 0%o\n",
-                       smbcli_errstr(ctx->cli->tree), src, (uint_t)mode);
+                       smbcli_errstr(ctx->cli->tree), src, (mode_t)mode);
                return 1;
        } 
 
@@ -2723,7 +2726,7 @@ static void completion_remote_filter(struct clilist_file_info *f, const char *ma
 {
        completion_remote_t *info = (completion_remote_t *)state;
 
-       if ((info->count < MAX_COMPLETIONS - 1) && (strncmp(info->text, f->name, info->len) == 0) && (strcmp(f->name, ".") != 0) && (strcmp(f->name, "..") != 0)) {
+       if ((info->count < MAX_COMPLETIONS - 1) && (strncmp(info->text, f->name, info->len) == 0) && (!ISDOT(f->name)) && (!ISDOTDOT(f->name))) {
                if ((info->dirmask[0] == 0) && !(f->attrib & FILE_ATTRIBUTE_DIRECTORY))
                        info->matches[info->count] = strdup(f->name);
                else {