* Copyright (C) 1996-2001 Andrew Tridgell <tridge@samba.org>
* Copyright (C) 1996 Paul Mackerras
* Copyright (C) 2002 Martin Pool
- * Copyright (C) 2003-2008 Wayne Davison
+ * Copyright (C) 2003-2009 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
extern unsigned int curr_dir_len;
extern unsigned int module_dirlen;
-struct filter_list_struct filter_list = { 0, 0, 0, "" };
-struct filter_list_struct cvs_filter_list = { 0, 0, 0, " [global CVS]" };
-struct filter_list_struct daemon_filter_list = { 0, 0, 0, " [daemon]" };
+struct filter_list_struct filter_list = { .debug_type = "" };
+struct filter_list_struct cvs_filter_list = { .debug_type = " [global CVS]" };
+struct filter_list_struct daemon_filter_list = { .debug_type = " [daemon]" };
/* Need room enough for ":MODS " prefix plus some room to grow. */
#define MAX_RULE_PREFIX (16)
static void teardown_mergelist(struct filter_struct *ex)
{
- if (DEBUG_GTE(FILTER, 2))
+ if (DEBUG_GTE(FILTER, 2)) {
rprintf(FINFO, "[%s] deactivating mergelist #%d%s\n",
who_am_i(), mergelist_cnt - 1,
ex->u.mergelist->debug_type);
+ }
/* We should deactivate mergelists in LIFO order. */
assert(mergelist_cnt > 0);
if (!mergelist_parents)
out_of_memory("add_rule");
}
- if (DEBUG_GTE(FILTER, 2))
+ if (DEBUG_GTE(FILTER, 2)) {
rprintf(FINFO, "[%s] activating mergelist #%d%s\n",
who_am_i(), mergelist_cnt, lp->debug_type);
+ }
mergelist_parents[mergelist_cnt++] = ret;
} else
ret->u.slash_cnt = slash_cnt;
if (!(x = parse_merge_name(pat, NULL, 0)) || *x != '/')
return 0;
- if (DEBUG_GTE(FILTER, 2))
+ if (DEBUG_GTE(FILTER, 2)) {
rprintf(FINFO, "[%s] performing parent_dirscan for mergelist #%d%s\n",
who_am_i(), mergelist_num, lp->debug_type);
+ }
y = strrchr(x, '/');
*y = '\0';
ex->pattern = strdup(y+1);
/* Save current head for freeing when the mergelist becomes inactive. */
lp->parent_dirscan_head = lp->head;
parent_dirscan = False;
- if (DEBUG_GTE(FILTER, 2))
+ if (DEBUG_GTE(FILTER, 2)) {
rprintf(FINFO, "[%s] completed parent_dirscan for mergelist #%d%s\n",
who_am_i(), mergelist_num, lp->debug_type);
+ }
free(pat);
return 1;
}
struct local_filter_state {
int mergelist_cnt;
- struct filter_list_struct mergelists[0];
+ struct filter_list_struct mergelists[1];
};
/* Each time rsync changes to a new directory it call this function to
int i;
set_filter_dir(dir, dirlen);
- if (DEBUG_GTE(FILTER, 2))
+ if (DEBUG_GTE(FILTER, 2)) {
rprintf(FINFO, "[%s] pushing local filters for %s\n",
who_am_i(), dirbuf);
+ }
- if (!mergelist_cnt)
+ if (!mergelist_cnt) {
/* No old state to save and no new merge files to push. */
return NULL;
+ }
- push = (struct local_filter_state *) malloc(sizeof (struct local_filter_state)
- + mergelist_cnt * sizeof (struct filter_list_struct));
+ push = (struct local_filter_state *)new_array(char,
+ sizeof (struct local_filter_state)
+ + (mergelist_cnt-1) * sizeof (struct filter_list_struct));
if (!push)
out_of_memory("push_local_filters");
* below. (Counterpart to setup_merge_file call in
* push_local_filters. Must be done here, not in
* free_filter, for LIFO order.) */
- if (DEBUG_GTE(FILTER, 2))
+ if (DEBUG_GTE(FILTER, 2)) {
rprintf(FINFO, "[%s] freeing parent_dirscan filters of mergelist #%d%s\n",
who_am_i(), i, ex->u.mergelist->debug_type);
+ }
free_filters(lp->parent_dirscan_head);
lp->parent_dirscan_head = NULL;
}
* should be those with a state to be restored. */
assert(mergelist_cnt == old_mergelist_cnt);
- if (!pop)
+ if (!pop) {
/* No state to restore. */
return;
+ }
for (i = 0; i < mergelist_cnt; i++) {
memcpy(mergelist_parents[i]->u.mergelist, &pop->mergelists[i],
static void report_filter_result(enum logcode code, char const *name,
- struct filter_struct const *ent,
- int name_is_dir, const char *type)
+ struct filter_struct const *ent,
+ int name_is_dir, const char *type)
{
/* If a trailing slash is present to match only directories,
* then it is stripped out by add_rule(). So as a special