From 2ed790f3541cd5803b285bb46b2cba02103cc88b Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Mon, 23 Apr 2007 19:54:07 +0000 Subject: [PATCH] Improved the SUBPROTOCOL_VERSION code a little, and bumped the value to 2. --- options.c | 19 ++++++++----------- rsync.h | 2 +- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/options.c b/options.c index 4a9b28f2..f860a496 100644 --- a/options.c +++ b/options.c @@ -198,7 +198,7 @@ char *bind_address; static void print_rsync_version(enum logcode f) { - char buf[32]; + char *subprotocol = ""; char const *got_socketpair = "no "; char const *have_inplace = "no "; char const *hardlinks = "no "; @@ -208,18 +208,18 @@ static void print_rsync_version(enum logcode f) char const *ipv6 = "no "; STRUCT_STAT *dumstat; +#if SUBPROTOCOL_VERSION != 0 + asprintf(&subprotocol, ".PR%d", SUBPROTOCOL_VERSION); +#endif #ifdef HAVE_SOCKETPAIR got_socketpair = ""; #endif - #ifdef HAVE_FTRUNCATE have_inplace = ""; #endif - #ifdef SUPPORT_HARD_LINKS hardlinks = ""; #endif - #ifdef SUPPORT_ACLS acls = ""; #endif @@ -229,17 +229,12 @@ static void print_rsync_version(enum logcode f) #ifdef SUPPORT_LINKS links = ""; #endif - #ifdef INET6 ipv6 = ""; #endif - if (SUBPROTOCOL_VERSION) - snprintf(buf, sizeof buf, ".PR%d", SUBPROTOCOL_VERSION); - else - *buf = '\0'; rprintf(f, "%s version %s protocol version %d%s\n", - RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION, buf); + RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION, subprotocol); rprintf(f, "Copyright (C) 1996-2007 by Andrew Tridgell, Wayne Davison, and others.\n"); rprintf(f, "Web site: http://rsync.samba.org/\n"); rprintf(f, "Capabilities:\n"); @@ -1650,12 +1645,14 @@ void server_options(char **args,int *argc) argstr[x] = '\0'; +#if SUBPROTOCOL_VERSION != 0 /* If we're speaking a pre-release version of a protocol, we tell * the server about this by (ab)using the -e option. */ - if (SUBPROTOCOL_VERSION && protocol_version == PROTOCOL_VERSION) { + if (protocol_version == PROTOCOL_VERSION) { x += snprintf(argstr+x, sizeof argstr - x, "e%d.%d", PROTOCOL_VERSION, SUBPROTOCOL_VERSION); } +#endif if (x != 1) args[ac++] = argstr; diff --git a/rsync.h b/rsync.h index 5bb155e8..4717e35b 100644 --- a/rsync.h +++ b/rsync.h @@ -86,7 +86,7 @@ /* This is used when working on a new protocol version in CVS, and should * be a new non-zero value for each CVS change that affects the protocol. * It must ALWAYS be 0 when the protocol goes final! */ -#define SUBPROTOCOL_VERSION 1 +#define SUBPROTOCOL_VERSION 2 /* We refuse to interoperate with versions that are not in this range. * Note that we assume we'll work with later versions: the onus is on -- 2.34.1