New support function: change_local_filter_dir().
authorWayne Davison <wayned@samba.org>
Thu, 28 Dec 2006 07:54:19 +0000 (07:54 +0000)
committerWayne Davison <wayned@samba.org>
Thu, 28 Dec 2006 07:54:19 +0000 (07:54 +0000)
exclude.c

index cfaed26..6bf20a5 100644 (file)
--- a/exclude.c
+++ b/exclude.c
@@ -493,6 +493,30 @@ void pop_local_filters(void *mem)
        free(pop);
 }
 
        free(pop);
 }
 
+void change_local_filter_dir(const char *dname, int dlen, int dir_depth)
+{
+       static int min_depth = MAXPATHLEN, cur_depth = -1;
+       static void *filt_array[MAXPATHLEN/2+1];
+
+       if (!dname) {
+               while (cur_depth >= min_depth)
+                       pop_local_filters(filt_array[cur_depth--]);
+               min_depth = MAXPATHLEN;
+               cur_depth = -1;
+               return;
+       }
+
+       assert(dir_depth < MAXPATHLEN/2+1);
+
+       while (cur_depth >= dir_depth && cur_depth >= min_depth)
+               pop_local_filters(filt_array[cur_depth--]);
+       cur_depth = dir_depth;
+       if (cur_depth < min_depth)
+               min_depth = cur_depth;
+
+       filt_array[cur_depth] = push_local_filters(dname, dlen);
+}
+
 static int rule_matches(char *name, struct filter_struct *ex, int name_is_dir)
 {
        int slash_handling, str_cnt = 0, anchored_match = 0;
 static int rule_matches(char *name, struct filter_struct *ex, int name_is_dir)
 {
        int slash_handling, str_cnt = 0, anchored_match = 0;