- Changed add_filter() to parse_rule() and add_filter_file()
[rsync.git] / options.c
index 3876ce0f2939a12903329fb54d656d63e74f0d76..a00370fcf3f9dca32c010249fa8882187764d92a 100644 (file)
--- a/options.c
+++ b/options.c
@@ -21,6 +21,7 @@
 #include "rsync.h"
 #include "popt.h"
 
+extern int module_id;
 extern int sanitize_paths;
 extern int select_timeout;
 extern struct filter_list_struct filter_list;
@@ -52,7 +53,6 @@ int omit_dir_times = 0;
 int update_only = 0;
 int cvs_exclude = 0;
 int dry_run = 0;
-int local_server = 0;
 int ignore_times = 0;
 int delete_mode = 0;
 int delete_during = 0;
@@ -70,9 +70,8 @@ int implied_dirs = 1;
 int numeric_ids = 0;
 int force_delete = 0;
 int io_timeout = 0;
-int module_id = -1;
 int am_server = 0;
-int am_sender = 0;
+int am_sender = -1;
 int am_generator = 0;
 char *files_from = NULL;
 int filesfrom_fd = -1;
@@ -657,17 +656,17 @@ int parse_arguments(int *argc, const char ***argv, int frommain)
                        break;
 
                case OPT_FILTER:
-                       add_filter(&filter_list, poptGetOptArg(pc), 0);
+                       parse_rule(&filter_list, poptGetOptArg(pc), 0, 0);
                        break;
 
                case OPT_EXCLUDE:
-                       add_filter(&filter_list, poptGetOptArg(pc),
-                                  XFLG_DEF_EXCLUDE);
+                       parse_rule(&filter_list, poptGetOptArg(pc),
+                                  0, XFLG_OLD_PREFIXES);
                        break;
 
                case OPT_INCLUDE:
-                       add_filter(&filter_list, poptGetOptArg(pc),
-                                  XFLG_DEF_INCLUDE);
+                       parse_rule(&filter_list, poptGetOptArg(pc),
+                                  MATCHFLG_INCLUDE, XFLG_OLD_PREFIXES);
                        break;
 
                case OPT_EXCLUDE_FROM:
@@ -681,9 +680,9 @@ int parse_arguments(int *argc, const char ***argv, int frommain)
                                if (check_filter(&server_filter_list, cp, 0) < 0)
                                        goto options_rejected;
                        }
-                       add_filter_file(&filter_list, arg, XFLG_FATAL_ERRORS
-                               | (opt == OPT_INCLUDE_FROM ? XFLG_DEF_INCLUDE
-                                                          : XFLG_DEF_EXCLUDE));
+                       parse_filter_file(&filter_list, arg,
+                               opt == OPT_INCLUDE_FROM ? MATCHFLG_INCLUDE : 0,
+                               XFLG_FATAL_ERRORS | XFLG_OLD_PREFIXES);
                        break;
 
                case 'h':
@@ -710,12 +709,10 @@ int parse_arguments(int *argc, const char ***argv, int frommain)
                case 'F':
                        switch (++F_option_cnt) {
                        case 1:
-                               add_filter(&filter_list,
-                                           ": /.rsync-filter", 0);
+                               parse_rule(&filter_list,": /.rsync-filter",0,0);
                                break;
                        case 2:
-                               add_filter(&filter_list,
-                                           "- .rsync-filter", 0);
+                               parse_rule(&filter_list,"- .rsync-filter",0,0);
                                break;
                        }
                        break;
@@ -825,6 +822,9 @@ int parse_arguments(int *argc, const char ***argv, int frommain)
                }
        }
 
+       if (am_sender < 0)
+               am_sender = 0;
+
 #if !SUPPORT_LINKS
        if (preserve_links && !am_sender) {
                snprintf(err_buf, sizeof err_buf,
@@ -914,7 +914,10 @@ int parse_arguments(int *argc, const char ***argv, int frommain)
                        "You may not combine multiple --delete-WHEN options.\n");
                return 0;
        }
-       if (delete_before || delete_during || delete_after)
+       if (!recurse) {
+               delete_before = delete_during = delete_after = 0;
+               delete_mode = delete_excluded = 0;
+       } else if (delete_before || delete_during || delete_after)
                delete_mode = 1;
        else if (delete_mode || delete_excluded)
                delete_mode = delete_before = 1;
@@ -1034,8 +1037,8 @@ int parse_arguments(int *argc, const char ***argv, int frommain)
                        if (!*partial_dir || strcmp(partial_dir, ".") == 0)
                                partial_dir = NULL;
                        else if (*partial_dir != '/') {
-                               add_filter(&filter_list, partial_dir,
-                                           XFLG_DIRECTORY | XFLG_DEF_EXCLUDE);
+                               parse_rule(&filter_list, partial_dir,
+                                   MATCHFLG_NO_PREFIXES|MATCHFLG_DIRECTORY, 0);
                        }
                        keep_partial = 1;
                }
@@ -1126,7 +1129,7 @@ void server_options(char **args,int *argc)
        if (copy_links)
                argstr[x++] = 'L';
        if (xfer_dirs > 1)
-               argstr[x++] = 'k';
+               argstr[x++] = 'd';
        if (keep_dirlinks && am_sender)
                argstr[x++] = 'K';