Output the default checksum & compress lists in the --version output.
authorWayne Davison <wayne@opencoder.net>
Mon, 25 May 2020 19:45:28 +0000 (12:45 -0700)
committerWayne Davison <wayne@opencoder.net>
Mon, 25 May 2020 20:02:12 +0000 (13:02 -0700)
compat.c
options.c

index d35a3f98906d8e7ef25272bfd9647df8cd4f81b6..e89fac268335cbdec252a4239d7debecb998a53d 100644 (file)
--- a/compat.c
+++ b/compat.c
@@ -334,10 +334,52 @@ static void recv_negotiate_str(int f_in, struct name_num_obj *nno, char *tmpbuf,
        exit_cleanup(RERR_UNSUPPORTED);
 }
 
+/* The saw buffer is initialized and used to store ordinal values from 1 to N
+ * for the order of the args in the array.  If dup_markup == '\0', duplicates
+ * are removed otherwise the char is prefixed to the duplicate term and, if it
+ * is an opening paren/bracket/brace, the matching closing char is suffixed. */
+int get_default_nno_list(struct name_num_obj *nno, char *to_buf, int to_buf_len, char dup_markup)
+{
+       struct name_num_item *nni;
+       int len = 0, cnt = 0;
+       char pre_char = '\0', post_char = '\0';
+
+       init_nno_saw(nno, 0);
+
+       for (nni = nno->list, len = 0; nni->name; nni++) {
+               if (nni->main_name) {
+                       if (!dup_markup)
+                               continue;
+                       pre_char = dup_markup;
+                       switch (pre_char) {
+                       case '(': post_char = ')'; break;
+                       case '[': post_char = ']'; break;
+                       case '{': post_char = '}'; break;
+                       default: break;
+                       }
+               }
+               if (len)
+                       to_buf[len++]= ' ';
+               if (pre_char) {
+                       to_buf[len++]= pre_char;
+                       pre_char = '\0';
+               }
+               len += strlcpy(to_buf+len, nni->name, to_buf_len - len);
+               if (len >= to_buf_len - 3)
+                       exit_cleanup(RERR_UNSUPPORTED); /* IMPOSSIBLE... */
+               if (post_char) {
+                       to_buf[len++]= post_char;
+                       post_char = '\0';
+               }
+               nno->saw[nni->num] = ++cnt;
+       }
+
+       return len;
+}
+
 static void send_negotiate_str(int f_out, struct name_num_obj *nno, const char *env_name)
 {
        char tmpbuf[MAX_NSTR_STRLEN];
-       struct name_num_item *nni;
        const char *list_str = getenv(env_name);
        int len, fail_if_empty = list_str && strstr(list_str, "FAIL");
 
@@ -349,9 +391,8 @@ static void send_negotiate_str(int f_out, struct name_num_obj *nno, const char *
                return;
        }
 
-       init_nno_saw(nno, 0);
-
        if (list_str && *list_str && (!am_server || local_server)) {
+               init_nno_saw(nno, 0);
                len = parse_nni_str(nno, list_str, tmpbuf, MAX_NSTR_STRLEN);
                if (fail_if_empty && !len)
                        len = strlcpy(tmpbuf, "FAIL", MAX_NSTR_STRLEN);
@@ -360,17 +401,7 @@ static void send_negotiate_str(int f_out, struct name_num_obj *nno, const char *
                list_str = NULL;
 
        if (!list_str || !*list_str) {
-               int cnt = 0;
-               for (nni = nno->list, len = 0; nni->name; nni++) {
-                       if (nni->main_name)
-                               continue;
-                       if (len)
-                               tmpbuf[len++]= ' ';
-                       len += strlcpy(tmpbuf+len, nni->name, MAX_NSTR_STRLEN - len);
-                       if (len >= (int)MAX_NSTR_STRLEN - 1)
-                               exit_cleanup(RERR_UNSUPPORTED); /* IMPOSSIBLE... */
-                       nno->saw[nni->num] = ++cnt;
-               }
+               len = get_default_nno_list(nno, tmpbuf, sizeof tmpbuf, '\0');
        }
 
        if (DEBUG_GTE(NSTR, am_server ? 3 : 2)) {
index 5f3b8d92d50747bbcc1e8ab75604966575606fc3..5b55dbc98d3459a9e4b39913869f5e06f65c4437 100644 (file)
--- a/options.c
+++ b/options.c
@@ -29,6 +29,8 @@ extern int local_server;
 extern int sanitize_paths;
 extern int daemon_over_rsh;
 extern unsigned int module_dirlen;
+extern struct name_num_obj valid_checksums;
+extern struct name_num_obj valid_compressions;
 extern filter_rule_list filter_list;
 extern filter_rule_list daemon_filter_list;
 
@@ -566,6 +568,7 @@ void negate_output_levels(void)
 
 static void print_rsync_version(enum logcode f)
 {
+       char tmpbuf[256];
        char *subprotocol = "";
        char const *got_socketpair = "no ";
        char const *have_inplace = "no ";
@@ -637,6 +640,14 @@ static void print_rsync_version(enum logcode f)
        rprintf(f, "    %sappend, %sACLs, %sxattrs, %siconv, %ssymtimes, %sprealloc, %sSIMD, %sxxhash\n",
                have_inplace, acls, xattrs, iconv, symtimes, prealloc, simd, xxhash);
 
+       rprintf(f,"\n");
+       
+       get_default_nno_list(&valid_checksums, tmpbuf, sizeof tmpbuf, '(');
+       rprintf(f, "Checksum list: %s\n", tmpbuf);
+
+       get_default_nno_list(&valid_compressions, tmpbuf, sizeof tmpbuf, '(');
+       rprintf(f, "Compress list: %s\n", tmpbuf);
+
 #ifdef MAINTAINER_MODE
        rprintf(f, "Panic Action: \"%s\"\n", get_panic_action());
 #endif