public static int ParseArguments(string[] args, Options options) { int argsNotUsed = 0; int i = 0; Exclude excl = new Exclude(options); while (i < args.Length) { try { switch (args[i]) { case "--version": MainClass.PrintRsyncVersion(); MainClass.Exit("", null); break; case "--suffix": options.backupSuffix = args[++i]; break; case "--rsync-path": options.rsyncPath = args[++i]; break; case "--password-file": options.passwordFile = args[++i]; break; case "--ignore-times": case "-I": options.ignoreTimes = true; break; case "--size-only": options.sizeOnly = true; break; case "--modify-window": options.usingModifyWindow = true; options.modifyWindow = Convert.ToInt32(args[++i]); break; case "--one-file-system": case "-x": options.oneFileSystem = true; break; case "--delete": options.deleteMode = true; break; case "--existing": options.onlyExisting = true; break; case "--ignore-existing": options.optIgnoreExisting = true; break; case "--delete-after": options.deleteMode = true; options.deleteAfter = true; break; case "--delete-excluded": options.deleteMode = true; options.deleteExcluded = true; break; case "--force": options.forceDelete = true; break; case "--numeric-ids": options.numericIds = true; break; case "--exclude": excl.AddExclude(ref options.excludeList, args[++i], 0); break; case "--include": excl.AddExclude(ref options.excludeList, args[++i], (int)Options.XFLG_DEF_INCLUDE); options.forceDelete = true; break; case "--exclude-from": case "--include-from": string arg = args[i]; excl.AddExcludeFile(ref options.excludeList, args[++i], (arg.CompareTo("--exclude-from") == 0) ? 0 :(int)Options.XFLG_DEF_INCLUDE); break; case "--safe-links": options.safeSymlinks = true; break; case "--help": case "-h": MainClass.Usage(); MainClass.Exit("", null); break; case "--backup": case "-b": options.makeBackups = true; break; case "--dry-run": case "-n": options.dryRun = true; break; case "--sparse": case "-S": options.sparseFiles = true; break; case "--cvs-exclude": case "-C": options.cvsExclude = true; break; case "--update": case "-u": options.updateOnly = true; break; case "--inplace": options.inplace = true; break; case "--keep-dirlinks": case "-K": options.keepDirLinks = true; break; case "--links": case "-l": options.preserveLinks = true; break; case "--copy-links": case "-L": options.copyLinks = true; break; case "--whole-file": case "-W": options.wholeFile = 1; break; case "--no-whole-file": options.wholeFile = 0; break; case "--copy-unsafe-links": options.copyUnsafeLinks = true; break; case "--perms": case "-p": options.preservePerms = true; break; case "--owner": case "-o": options.preserveUID = true; break; case "--group": case "-g": options.preserveGID = true; break; case "--devices": case "-D": options.preserveDevices = true; break; case "--times": case "-t": options.preserveTimes = true; break; case "--checksum": case "-c": options.alwaysChecksum = true; break; case "--verbose": case "-v": options.verbose++; break; case "--quiet": case "-q": options.quiet++; break; case "--archive": case "-a": options.archiveMode = true; break; case "--server": options.amServer = true; break; case "--sender": options.amSender = true; break; case "--recursive": case "-r": options.recurse = true; break; case "--relative": case "-R": options.relativePaths = 1; break; case "--no-relative": options.relativePaths = 0; break; case "--rsh": case "-e": options.shellCmd = args[++i]; break; case "--block-size": case "-B": options.blockSize = Convert.ToInt32(args[++i]); break; case "--max-delete": options.maxDelete = Convert.ToInt32(args[++i]); break; case "--timeout": options.ioTimeout = Convert.ToInt32(args[++i]); break; case "--temp-dir": case "-T": options.tmpDir = args[++i]; break; case "--compare-dest": options.compareDest = args[++i]; break; case "--link-dest": options.compareDest = args[++i]; break; case "--compress": case "-z": options.doCompression = true; break; case "--stats": options.doStats = true; break; case "--progress": options.doProgress = true; break; case "--partial": options.keepPartial = true; break; case "--partial-dir": options.partialDir = args[++i]; break; case "--ignore-errors": options.ignoreErrors = true; break; case "--blocking-io": options.blockingIO = 1; break; case "--no-blocking-io": options.blockingIO = 0; break; case "-P": options.doProgress = true; options.keepPartial = true; break; case "--log-format": options.logFormat = args[++i]; break; case "--bwlimit": options.bwLimit = Convert.ToInt32(args[++i]); break; case "--backup-dir": options.backupDir = args[++i]; break; case "--hard-links": case "-H": options.preserveHardLinks = true; break; case "--read-batch": options.batchName = args[++i]; options.readBatch = true; break; case "--write-batch": options.batchName = args[++i]; options.writeBatch = true; break; case "--files-from": options.filesFrom = args[++i]; break; case "--from0": options.eolNulls = true; break; case "--no-implied-dirs": options.impliedDirs = true; break; case "--protocol": options.protocolVersion = Convert.ToInt32(args[++i]); break; case "--checksum-seed": options.checksumSeed = Convert.ToInt32(args[++i]); break; case "--daemon": options.amDaemon = true; break; case "--address": options.bindAddress = args[++i]; break; case "--port": options.rsyncPort = Convert.ToInt32(args[++i]); break; case "--config": options.configFile = args[++i].Trim(); break; default: { argsNotUsed += ParseMergeArgs(args[i], options); break; } } i++; } catch { return(-1); } } if (options.amSender && !options.amServer) { MainClass.Usage(); MainClass.Exit("", null); } if (options.ioTimeout > 0 && options.ioTimeout < options.selectTimeout) { options.selectTimeout = options.ioTimeout; } return(argsNotUsed); }