From c2755ffb0c31b1ddd826f28ffb02dd362cfde0b8 Mon Sep 17 00:00:00 2001 From: ruti <> Date: Tue, 20 May 2025 22:37:20 +0300 Subject: [PATCH] --copy --- main.c | 26 +++++++++++++++++++++++++- params.h | 2 ++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index e3c0599..f083ae2 100644 --- a/main.c +++ b/main.c @@ -153,6 +153,7 @@ const struct option options[] = { #ifdef TIMEOUT_SUPPORT {"timeout", 1, 0, 'T'}, #endif + {"copy", 1, 0, 'B'}, {"proto", 1, 0, 'K'}, {"hosts", 1, 0, 'H'}, {"pf", 1, 0, 'V'}, @@ -659,6 +660,8 @@ int main(int argc, char **argv) char *end = 0; bool all_limited = 1; + int curr_optind = 1; + struct desync_params *dp = add((void *)¶ms.dp, ¶ms.dp_count, sizeof(struct desync_params)); if (!dp) { @@ -668,7 +671,6 @@ int main(int argc, char **argv) while (!invalid && (rez = getopt_long( argc, argv, opt, options, 0)) != -1) { - switch (rez) { case 'N': @@ -762,6 +764,10 @@ int main(int argc, char **argv) break; case 'A': + if (optind < curr_optind) { + optind = curr_optind; + continue; + } if (!(dp->hosts || dp->proto || dp->pf[0] || dp->detect || dp->ipset)) { all_limited = 0; } @@ -796,6 +802,24 @@ int main(int argc, char **argv) if (dp->detect && params.auto_level == AUTO_NOBUFF) { params.auto_level = AUTO_NOSAVE; } + dp->_optind = optind; + break; + + case 'B': + if (optind < curr_optind) { + continue; + } + if (*optarg == 'i') { + dp->pf[0] = htons(1); + continue; + } + val = strtol(optarg, &end, 0); + if (val < 1 || val >= params.dp_count || *end) + invalid = 1; + else { + curr_optind = optind; + optind = params.dp[val - 1]._optind; + } break; case 'u': diff --git a/params.h b/params.h index 6035c38..83420e4 100644 --- a/params.h +++ b/params.h @@ -105,6 +105,8 @@ struct desync_params { char *file_ptr; ssize_t file_size; + + int _optind; }; struct params {