- int opt;
- int option_index;
-
- while ((opt = getopt_long(argc, argv,
- short_options, long_options, &option_index))
- != -1) {
- switch (opt)
- {
- case OPT_VERSION:
- printf("rsync version %s protocol version %d\n\n",
- VERSION,PROTOCOL_VERSION);
- printf("Written by Andrew Tridgell and Paul Mackerras\n");
- exit_cleanup(0);
-
- case OPT_SUFFIX:
- backup_suffix = optarg;
- break;
-
- case OPT_RSYNC_PATH:
- rsync_path = optarg;
- break;
-
- case 'I':
- ignore_times = 1;
- break;
-
- case 'x':
- one_file_system=1;
- break;
-
- case OPT_DELETE:
- delete_mode = 1;
- break;
-
- case OPT_FORCE:
- force_delete = 1;
- break;
-
- case OPT_NUMERIC_IDS:
- numeric_ids = 1;
- break;
-
- case OPT_EXCLUDE:
- add_exclude(optarg, 0);
- break;
-
- case OPT_INCLUDE:
- add_exclude(optarg, 1);
- break;
-
- case OPT_EXCLUDE_FROM:
- add_exclude_file(optarg,1, 0);
- break;
-
- case OPT_INCLUDE_FROM:
- add_exclude_file(optarg,1, 1);
- break;
-
- case 'h':
- usage(FINFO);
- exit_cleanup(0);
-
- case 'b':
- make_backups=1;
- break;
-
- case 'n':
- dry_run=1;
- break;
-
- case 'S':
- sparse_files=1;
- break;
-
- case 'C':
- cvs_exclude=1;
- break;
-
- case 'u':
- update_only=1;
- break;
-
- case 'l':
- preserve_links=1;
- break;
-
- case 'L':
- copy_links=1;
- break;
-
- case 'W':
- whole_file=1;
- break;
-
- case 'H':
+ if (err_buf[0]) {
+ rprintf(FLOG,"%s", err_buf);
+ rprintf(FERROR,"%s", err_buf);
+ } else {
+ rprintf(FLOG,"Error parsing options - unsupported option?\n");
+ rprintf(FERROR,"Error parsing options - unsupported option?\n");
+ }
+ exit_cleanup(RERR_UNSUPPORTED);
+}
+
+/* check to see if we should refuse this option */
+static int check_refuse_options(char *ref, int opt)
+{
+ int i, len;
+ char *p;
+ const char *name;
+
+ for (i=0; long_options[i].name; i++) {
+ if (long_options[i].val == opt) break;
+ }
+
+ if (!long_options[i].name) return 0;
+
+ name = long_options[i].name;
+ len = strlen(name);
+
+ while ((p = strstr(ref,name))) {
+ if ((p==ref || p[-1]==' ') &&
+ (p[len] == ' ' || p[len] == 0)) {
+ slprintf(err_buf,sizeof(err_buf),
+ "The '%s' option is not supported by this server\n", name);
+ return 1;
+ }
+ ref += len;
+ }
+ return 0;
+}
+
+
+int parse_arguments(int argc, char *argv[], int frommain)
+{
+ int opt;
+ int option_index;
+ char *ref = lp_refuse_options(module_id);
+
+ while ((opt = getopt_long(argc, argv,
+ short_options, long_options, &option_index))
+ != -1) {
+
+ if (ref) {
+ if (check_refuse_options(ref, opt)) return 0;
+ }
+
+ switch (opt) {
+ case OPT_VERSION:
+ rprintf(FINFO,"rsync version %s protocol version %d\n\n",
+ VERSION,PROTOCOL_VERSION);
+ rprintf(FINFO,"Written by Andrew Tridgell and Paul Mackerras\n");
+ exit_cleanup(0);
+
+ case OPT_SUFFIX:
+ backup_suffix = optarg;
+ break;
+
+ case OPT_RSYNC_PATH:
+ rsync_path = optarg;
+ break;
+
+ case OPT_PASSWORD_FILE:
+ password_file =optarg;
+ break;
+ case 'I':
+ ignore_times = 1;
+ break;
+
+ case 'x':
+ one_file_system=1;
+ break;
+
+ case OPT_DELETE:
+ delete_mode = 1;
+ break;
+
+ case OPT_FORCE:
+ force_delete = 1;
+ break;
+
+ case OPT_NUMERIC_IDS:
+ numeric_ids = 1;
+ break;
+
+ case OPT_EXCLUDE:
+ add_exclude(optarg, 0);
+ break;
+
+ case OPT_INCLUDE:
+ add_exclude(optarg, 1);
+ break;
+
+ case OPT_EXCLUDE_FROM:
+ add_exclude_file(optarg,1, 0);
+ break;
+
+ case OPT_INCLUDE_FROM:
+ add_exclude_file(optarg,1, 1);
+ break;
+
+ case OPT_SAFE_LINKS:
+ safe_symlinks=1;
+ break;
+
+ case 'h':
+ usage(FINFO);
+ exit_cleanup(0);
+
+ case 'b':
+ make_backups=1;
+ break;
+
+ case 'n':
+ dry_run=1;
+ break;
+
+ case 'S':
+ sparse_files=1;
+ break;
+
+ case 'C':
+ cvs_exclude=1;
+ break;
+
+ case 'u':
+ update_only=1;
+ break;
+
+ case 'l':
+ preserve_links=1;
+ break;
+
+ case 'L':
+ copy_links=1;
+ break;
+
+ case 'W':
+ whole_file=1;
+ break;
+
+ case 'H':