Updated the exclude-list code to handle the new linked-list
authorWayne Davison <wayned@samba.org>
Wed, 14 Apr 2004 23:33:34 +0000 (23:33 +0000)
committerWayne Davison <wayned@samba.org>
Wed, 14 Apr 2004 23:33:34 +0000 (23:33 +0000)
structure format.

flist.c
options.c
t_stub.c
util.c

diff --git a/flist.c b/flist.c
index 4d67c3c..aa43235 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -64,9 +64,9 @@ extern int sanitize_paths;
 extern int read_batch;
 extern int write_batch;
 
-extern struct exclude_struct **exclude_list;
-extern struct exclude_struct **server_exclude_list;
-extern struct exclude_struct **local_exclude_list;
+extern struct exclude_list_struct exclude_list;
+extern struct exclude_list_struct server_exclude_list;
+extern struct exclude_list_struct local_exclude_list;
 
 int io_error;
 
@@ -226,18 +226,18 @@ static int check_exclude_file(char *fname, int is_dir, int exclude_level)
                                return 0;
                }
        }
-       if (server_exclude_list
-        && check_exclude(server_exclude_list, fname, is_dir,
-           "server pattern"))
+       if (server_exclude_list.head
+        && check_exclude(&server_exclude_list, fname, is_dir,
+                         "server pattern"))
                return 1;
        if (exclude_level != ALL_EXCLUDES)
                return 0;
-       if (exclude_list && check_exclude(exclude_list, fname, is_dir,
-           "pattern"))
+       if (exclude_list.head
+           && check_exclude(&exclude_list, fname, is_dir, "pattern"))
                return 1;
-       if (local_exclude_list
-        && check_exclude(local_exclude_list, fname, is_dir,
-           "local-cvsignore"))
+       if (local_exclude_list.head
+           && check_exclude(&local_exclude_list, fname, is_dir,
+                            "local-cvsignore"))
                return 1;
        return 0;
 }
@@ -956,10 +956,11 @@ void send_file_name(int f, struct file_list *flist, char *fname,
 
        if (recursive && S_ISDIR(file->mode)
            && !(file->flags & FLAG_MOUNT_POINT)) {
-               struct exclude_struct **last_exclude_list = local_exclude_list;
+               struct exclude_list_struct last_list = local_exclude_list;
+               memset(&local_exclude_list, 0, sizeof local_exclude_list);
                send_directory(f, flist, f_name_to(file, fbuf));
-               local_exclude_list = last_exclude_list;
-               return;
+               free_exclude_list(&local_exclude_list);
+               local_exclude_list = last_list;
        }
 }
 
@@ -994,8 +995,6 @@ static void send_directory(int f, struct file_list *flist, char *dir)
                offset++;
        }
 
-       local_exclude_list = NULL;
-
        if (cvs_exclude) {
                if (strlcpy(p, ".cvsignore", MAXPATHLEN - offset)
                    < MAXPATHLEN - offset) {
@@ -1029,9 +1028,6 @@ static void send_directory(int f, struct file_list *flist, char *dir)
                        dir, errno, strerror(errno));
        }
 
-       if (local_exclude_list)
-               free_exclude_list(&local_exclude_list); /* Zeros pointer too */
-
        closedir(d);
 }
 
index 3531531..e848cd7 100644 (file)
--- a/options.c
+++ b/options.c
@@ -23,7 +23,7 @@
 
 extern int sanitize_paths;
 extern char curr_dir[MAXPATHLEN];
-extern struct exclude_struct **exclude_list;
+extern struct exclude_list_struct exclude_list;
 
 int make_backups = 0;
 
index 7a93036..8cc3bf0 100644 (file)
--- a/t_stub.c
+++ b/t_stub.c
@@ -28,7 +28,7 @@
 
 int modify_window = 0;
 int module_id = -1;
-struct exclude_struct **server_exclude_list;
+struct exclude_list_struct server_exclude_list;
 
  void rprintf(UNUSED(enum logcode code), const char *format, ...)
 {
@@ -45,7 +45,7 @@ struct exclude_struct **server_exclude_list;
        exit(code);
 }
 
- int check_exclude(UNUSED(struct exclude_struct **list), UNUSED(char *name),
+ int check_exclude(UNUSED(struct exclude_list_struct *listp), UNUSED(char *name),
                   UNUSED(int name_is_dir), UNUSED(const char *type))
 {
        /* This function doesn't really get called in this test context, so
diff --git a/util.c b/util.c
index fd63009..5c55ce4 100644 (file)
--- a/util.c
+++ b/util.c
@@ -28,6 +28,7 @@
 #include "rsync.h"
 
 extern int verbose;
+extern struct exclude_list_struct server_exclude_list;
 
 int sanitize_paths = 0;
 
@@ -471,12 +472,11 @@ int lock_range(int fd, int offset, int len)
 static int exclude_server_path(char *arg)
 {
        char *s;
-       extern struct exclude_struct **server_exclude_list;
 
-       if (server_exclude_list) {
+       if (server_exclude_list.head) {
                for (s = arg; (s = strchr(s, '/')) != NULL; ) {
                        *s = '\0';
-                       if (check_exclude(server_exclude_list, arg, 1,
+                       if (check_exclude(&server_exclude_list, arg, 1,
                            "server pattern")) {
                                /* We must leave arg truncated! */
                                return 1;