+/* The server makes sure that if either side only supports a pre-release
+ * version of a protocol, that both sides must speak a compatible version
+ * of that protocol for it to be advertised as available. */
+static void check_sub_protocol(void)
+{
+ char *dot;
+ int their_protocol, their_sub;
+ int our_sub = protocol_version < PROTOCOL_VERSION ? 0 : SUBPROTOCOL_VERSION;
+
+ if (!shell_cmd || !(dot = strchr(shell_cmd, '.'))
+ || !(their_protocol = atoi(shell_cmd))
+ || !(their_sub = atoi(dot+1))) {
+ if (our_sub)
+ protocol_version--;
+ return;
+ }
+
+ if (their_protocol < protocol_version) {
+ if (their_sub)
+ protocol_version = their_protocol - 1;
+ return;
+ }
+
+ if (their_protocol > protocol_version)
+ their_sub = 0; /* 0 == final version */
+ if (their_sub != our_sub)
+ protocol_version--;
+}
+