[Git][NTPsec/ntpsec][21B03-mode6] 6 commits: Fix parsing of commandline parameter 'P'

James Browning gitlab at mg.gitlab.com
Tue Feb 9 15:44:39 UTC 2021



James Browning pushed to branch 21B03-mode6 at NTPsec / ntpsec


Commits:
5f198af7 by Sami Farin at 2021-02-08T13:51:13+01:00
Fix parsing of commandline parameter 'P'

- - - - -
74e3959c by James Browning at 2021-02-09T15:44:27+00:00
ntp_control: Rewrite 3 varlist blocks cutting lines ...

They became 3 near single line callers and 2 new functions.
- - - - -
cc892894 by James Browning at 2021-02-09T15:44:27+00:00
mode6: Change many CS_* macro inserts to switch key.


- - - - -
8e0a23da by James Browning at 2021-02-09T15:44:27+00:00
ntp_control: Add macros to shorten the code/reveal (anti-)patterns.

- - - - -
cc948630 by James Browning at 2021-02-09T15:44:27+00:00
ntp_control: Actually use macros to shorten code/reveal (anti-)patterns.

- - - - -
33fb2ddf by James Browning at 2021-02-09T15:44:27+00:00
ntp_control: strip most ctl_put_* functions to abstracted wrappers.

Wrapping ctl_put_unqstr, saves some lines.
- - - - -


2 changed files:

- ntpd/ntp_control.c
- ntpd/ntpd.c


Changes:

=====================================
ntpd/ntp_control.c
=====================================
@@ -29,6 +29,10 @@
 #include "nts.h"
 #include "timespecops.h"
 
+// Refactored C?_VARLIST innards
+ssize_t CI_VARLIST(char*, char*, const struct ctl_var*, bool*);
+bool CF_VARLIST(const struct ctl_var*, const struct ctl_var*, const struct ctl_var*);
+
 /* undefine to suppress random tags and get fixed emission order */
 #define USE_RANDOMIZE_RESPONSES
 
@@ -1144,14 +1148,9 @@ ctl_putdblf(
 	double		d
 	)
 {
-        char buffer[200];
         char buf[50];
-
-        strlcpy(buffer, tag, sizeof(buffer));
-        snprintf(buf, sizeof(buf), use_f ? "=%.*f" : "=%.*g", precision, d);
-        strlcat(buffer, buf, sizeof(buffer));
-
-        ctl_putdata(buffer, strlen(buffer), false);
+        snprintf(buf, sizeof(buf), use_f ? "%.*f" : "%.*g", precision, d);
+	ctl_putunqstr(tag, buf, strlen(buf));
 }
 
 /*
@@ -1163,15 +1162,9 @@ ctl_putuint(
 	uint64_t uval
 	)
 {
-        char buffer[200];
         char buf[50];
-
-        strlcpy(buffer, tag, sizeof(buffer));
-
-        snprintf(buf, sizeof(buf), "=%" PRIu64, uval);
-        strlcat(buffer, buf, sizeof(buffer));
-
-        ctl_putdata(buffer, strlen(buffer), false);
+        snprintf(buf, sizeof(buf), "%" PRIu64, uval);
+	ctl_putunqstr(tag, buf, strlen(buf));
 }
 
 /*
@@ -1183,22 +1176,16 @@ ctl_puttime(
 	time_t uval
 	)
 {
-	char buffer[200];
 	struct tm tmbuf, *tm = NULL;
         char buf[50];
-
-        strlcpy(buffer, tag, sizeof(buffer));
-
 	tm = gmtime_r(&uval, &tmbuf);
 	if (NULL == tm) {
 		return;
 	}
-	snprintf(buf, sizeof(buf), "=%04d-%02d-%02dT%02d:%02dZ",
+	snprintf(buf, sizeof(buf), "%04d-%02d-%02dT%02d:%02dZ",
                  tm->tm_year + 1900,
 		 tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min);
-        strlcat(buffer, buf, sizeof(buffer));
-
-	ctl_putdata(buffer, strlen(buf), false);
+	ctl_putunqstr(tag, buf, strlen(buf));
 }
 
 
@@ -1212,15 +1199,9 @@ ctl_puthex(
 	uint64_t uval
 	)
 {
-	char buffer[200];
         char buf[50];
-
-        strlcpy(buffer, tag, sizeof(buffer));
-
-	snprintf(buf, sizeof(buf), "=0x%" PRIx64, uval);
-        strlcat(buffer, buf, sizeof(buffer));
-
-	ctl_putdata(buffer, strlen(buffer), false);
+	snprintf(buf, sizeof(buf), "0x%" PRIx64, uval);
+	ctl_putunqstr(tag, buf, strlen(buf));
 }
 
 
@@ -1233,15 +1214,9 @@ ctl_putint(
 	long ival
 	)
 {
-	char buffer[200];
         char buf[50];
-
-        strlcpy(buffer, tag, sizeof(buffer));
-
-	snprintf(buf, sizeof(buf), "=%ld", ival);
-        strlcat(buffer, buf, sizeof(buffer));
-
-	ctl_putdata(buffer, strlen(buffer), false);
+	snprintf(buf, sizeof(buf), "%ld", ival);
+	ctl_putunqstr(tag, buf, strlen(buf));
 }
 
 
@@ -1254,15 +1229,10 @@ ctl_putts(
 	l_fp *ts
 	)
 {
-	char buffer[200];
 	char buf[50];
-
-        strlcpy(buffer, tag, sizeof(buffer));
-
-	snprintf(buf, sizeof(buf), "=0x%08x.%08x",
+	snprintf(buf, sizeof(buf), "0x%08x.%08x",
 		 (unsigned int)lfpuint(*ts), (unsigned int)lfpfrac(*ts));
-        strlcat(buffer, buf, sizeof(buffer));
-	ctl_putdata(buffer, strlen(buffer), false);
+	ctl_putunqstr(tag, buf, strlen(buf));
 }
 
 
@@ -1277,20 +1247,13 @@ ctl_putadr(
 	)
 {
         const char *cq;
-	char buffer[200];
-
-        strlcpy(buffer, tag, sizeof(buffer));
-        strlcat(buffer, "=", sizeof(buffer));
-
 	if (NULL == addr) {
 		struct in_addr in4;
 		in4.s_addr = addr32;
 		cq = inet_ntoa(in4);
 	} else
 		cq = socktoa(addr);
-
-        strlcat(buffer, cq, sizeof(buffer));
-	ctl_putdata(buffer, strlen(buffer), false);
+	ctl_putunqstr(tag, cq, strlen(cq));
 }
 
 
@@ -1303,13 +1266,10 @@ ctl_putrefid(
 	refid_t		refid
 	)
 {
-        char	output[16];
         char    buf[sizeof(refid) + 1];
         char *  cp;
         unsigned int i;
 
-        strlcpy(output, tag, sizeof(output));
-        strlcat(output, "=", sizeof(output));
         /* refid is really a 4 byte, un-terminated, string */
         cp = (char *)&refid;
         /* make sure all printable */
@@ -1320,9 +1280,7 @@ ctl_putrefid(
                         buf[i] = '.';
         }
         buf[i] = '\0';
-
-        strlcat(output, buf, sizeof(output));
-        ctl_putdata(output, strlen(output), false);
+	ctl_putunqstr(tag, buf, strlen(buf));
 }
 
 
@@ -1339,10 +1297,6 @@ ctl_putarray(
 	char buffer[200];
 	char buf[50];
 	int i;
-
-        strlcpy(buffer, tag, sizeof(buffer));
-        strlcat(buffer, "=", sizeof(buffer));
-
 	i = start;
 	do {
 		if (i == 0)
@@ -1351,11 +1305,32 @@ ctl_putarray(
 		snprintf(buf, sizeof(buf), " %.2f", arr[i] * MS_PER_S);
                 strlcat(buffer, buf, sizeof(buffer));
 	} while (i != start);
-
-	ctl_putdata(buffer, strlen(buffer), false);
+	ctl_putunqstr(tag, buffer, strlen(buf));
 }
 
 
+#define CASE_DBL(number, variable)	case number: \
+		ctl_putdbl(CV_NAME, variable); \
+		break
+#define CASE_DBL6(number, variable)	case number: \
+		ctl_putdbl6(CV_NAME, variable); \
+		break
+#define CASE_HEX(number, variable)	case number: \
+		ctl_puthex(CV_NAME, variable); \
+		break
+#define CASE_INT(number, variable)	case number: \
+		ctl_putint(CV_NAME, variable); \
+		break
+#define CASE_SFP(number, variable)	case number: \
+		ctl_putsfp(CV_NAME, variable); \
+		break
+#define CASE_TS(number, variable)	case number: \
+		ctl_putts(CV_NAME, variable); \
+		break
+#define CASE_UINT(number, variable)	case number: \
+		ctl_putuint(CV_NAME, variable); \
+		break
+#define CV_NAME sys_var[varid].text
 /*
  * ctl_putsys - output a system variable
  */
@@ -1386,27 +1361,15 @@ ctl_putsys(
 
 	switch (varid) {
 
-	case CS_LEAP:
-		ctl_putuint(sys_var[CS_LEAP].text, sys_vars.sys_leap);
-		break;
+	CASE_UINT(CS_LEAP, sys_vars.sys_leap);
 
-	case CS_STRATUM:
-		ctl_putuint(sys_var[CS_STRATUM].text, sys_vars.sys_stratum);
-		break;
+	CASE_UINT(CS_STRATUM, sys_vars.sys_stratum);
 
-	case CS_PRECISION:
-		ctl_putint(sys_var[CS_PRECISION].text, sys_vars.sys_precision);
-		break;
+	CASE_INT(CS_PRECISION, sys_vars.sys_precision);
 
-	case CS_ROOTDELAY:
-		ctl_putdbl(sys_var[CS_ROOTDELAY].text,
-                           sys_vars.sys_rootdelay * MS_PER_S);
-		break;
+	CASE_DBL(CS_ROOTDELAY, sys_vars.sys_rootdelay * MS_PER_S);
 
-	case CS_ROOTDISPERSION:
-		ctl_putdbl(sys_var[CS_ROOTDISPERSION].text,
-			   sys_vars.sys_rootdisp * MS_PER_S);
-		break;
+	CASE_DBL(CS_ROOTDISPERSION, sys_vars.sys_rootdisp * MS_PER_S);
 
 	case CS_REFID:
 		if (sys_vars.sys_stratum > 1 &&
@@ -1417,19 +1380,15 @@ ctl_putsys(
 			ctl_putrefid(sys_var[varid].text, sys_vars.sys_refid);
 		break;
 
-	case CS_REFTIME:
-		ctl_putts(sys_var[CS_REFTIME].text, &sys_vars.sys_reftime);
-		break;
+	CASE_TS(CS_REFTIME, &sys_vars.sys_reftime);
 
-	case CS_POLL:
-		ctl_putuint(sys_var[CS_POLL].text, clkstate.sys_poll);
-		break;
+	CASE_UINT(CS_POLL, clkstate.sys_poll);
 
 	case CS_PEERID:
 		if (sys_vars.sys_peer == NULL)
-			ctl_putuint(sys_var[CS_PEERID].text, 0);
+			ctl_putuint(sys_var[varid].text, 0);
 		else
-			ctl_putuint(sys_var[CS_PEERID].text,
+			ctl_putuint(sys_var[varid].text,
 				    sys_vars.sys_peer->associd);
 		break;
 
@@ -1439,7 +1398,7 @@ ctl_putsys(
 			ss = sockporttoa(&sys_vars.sys_peer->srcadr);
 		else
 			ss = "0.0.0.0:0";
-		ctl_putunqstr(sys_var[CS_PEERADR].text, ss, strlen(ss));
+		ctl_putunqstr(sys_var[varid].text, ss, strlen(ss));
 		break;
 
 	case CS_PEERMODE: {
@@ -1447,120 +1406,60 @@ ctl_putsys(
 		u = (sys_vars.sys_peer != NULL)
 			? sys_vars.sys_peer->hmode
 			: MODE_UNSPEC;
-		ctl_putuint(sys_var[CS_PEERMODE].text, u);
+		ctl_putuint(sys_var[varid].text, u);
 		break;
 		}
 
-	case CS_OFFSET:
-		ctl_putdbl6(sys_var[CS_OFFSET].text, clkstate.last_offset * MS_PER_S);
-		break;
+	CASE_DBL6(CS_OFFSET, clkstate.last_offset * MS_PER_S);
 
 	case CS_DRIFT:
                 /* a.k.a frequency.  (s/s), reported as us/s a.k.a. ppm */
-		ctl_putdbl6(sys_var[CS_DRIFT].text, loop_data.drift_comp * US_PER_S);
+		ctl_putdbl6(sys_var[varid].text, loop_data.drift_comp * US_PER_S);
 		break;
 
-	case CS_JITTER:
-		ctl_putdbl6(sys_var[CS_JITTER].text, clkstate.sys_jitter * MS_PER_S);
-		break;
+	CASE_DBL6(CS_JITTER, clkstate.sys_jitter * MS_PER_S);
 
 	case CS_ERROR:
 		/* a.k.a clk_jitter (s).  output as ms */
-		ctl_putdbl6(sys_var[CS_ERROR].text, clkstate.clock_jitter * MS_PER_S);
+		ctl_putdbl6(sys_var[varid].text, clkstate.clock_jitter * MS_PER_S);
 		break;
 
 	case CS_CLOCK:
 		get_systime(&tmp);
-		ctl_putts(sys_var[CS_CLOCK].text, &tmp);
+		ctl_putts(sys_var[varid].text, &tmp);
 		break;
 
 	case CS_PROCESSOR:
-		ctl_putstr(sys_var[CS_PROCESSOR].text,
+		ctl_putstr(sys_var[varid].text,
 			   utsnamebuf.machine, strlen(utsnamebuf.machine));
 		break;
 
 	case CS_SYSTEM:
 		snprintf(str, sizeof(str), "%.100s/%.100s", utsnamebuf.sysname,
 			 utsnamebuf.release);
-		ctl_putstr(sys_var[CS_SYSTEM].text, str, strlen(str));
+		ctl_putstr(sys_var[varid].text, str, strlen(str));
 		break;
 
 	case CS_VERSION:
 		ss = ntpd_version();
-		ctl_putstr(sys_var[CS_VERSION].text, ss, strlen(ss));
+		ctl_putstr(sys_var[varid].text, ss, strlen(ss));
 		break;
 
 	case CS_STABIL:
 		/* a.k.a clk_wander (s/s), output as us/s */
-		ctl_putdbl6(sys_var[CS_STABIL].text,
+		ctl_putdbl6(sys_var[varid].text,
                             loop_data.clock_stability * US_PER_S);
 		break;
 
 	case CS_VARLIST:
 	{
-		char buf[CTL_MAX_DATA_LEN];
-		//buffPointer, firstElementPointer, buffEndPointer
-		char *buffp, *buffend;
-		bool firstVarName;
-		const char *ss1;
-		size_t len;
-		const struct ctl_var *k;
-
-		buffp = buf;
-		buffend = buf + sizeof(buf);
-		if (buffp + strlen(sys_var[CS_VARLIST].text) + 4 > buffend)
-			break;	/* really long var name */
-
-		snprintf(buffp, sizeof(buf), "%s=\"",sys_var[CS_VARLIST].text);
-		buffp += strlen(buffp);
-		firstVarName = true;
-		for (k = sys_var; !(k->flags & EOV); k++) {
-			if (k->flags & PADDING)
-				continue;
-			len = strlen(k->text);
-			if (buffp + len + 1 >= buffend)
-				break;
-			if (!firstVarName)
-				*buffp++ = ',';
-			else
-				firstVarName = false;
-			memcpy(buffp, k->text, len);
-			buffp += len;
-		}
-
-		for (k = ext_sys_var; k && !(k->flags & EOV); k++) {
-			if (k->flags & PADDING)
-				continue;
-			if (NULL == k->text)
-				continue;
-			ss1 = strchr(k->text, '=');
-			if (NULL == ss1)
-				len = strlen(k->text);
-			else
-				len = (size_t)(ss1 - k->text);
-			if (buffp + len + 1 >= buffend)
-				break;
-			if (firstVarName) {
-				*buffp++ = ',';
-				firstVarName = false;
-			}
-			memcpy(buffp, k->text, len);
-			buffp += len;
-		}
-		if (buffp + 2 >= buffend) {
-			break;
-		}
-
-		*buffp++ = '"';
-		*buffp = '\0';
-
-		ctl_putdata(buf, (unsigned)( buffp - buf ), false);
+		(void)CF_VARLIST(&sys_var[varid], sys_var, ext_sys_var);
 		break;
 	}
 
 	case CS_TAI:
 		if (sys_tai > 0)
-			ctl_putuint(sys_var[CS_TAI].text, sys_tai);
+			ctl_putuint(sys_var[varid].text, sys_tai);
 		break;
 
 	case CS_LEAPTAB:
@@ -1568,7 +1467,7 @@ ctl_putsys(
 		leap_signature_t lsig;
 		leapsec_getsig(&lsig);
 		if (lsig.ttime > 0)
-			ctl_puttime(sys_var[CS_LEAPTAB].text, lsig.ttime);
+			ctl_puttime(sys_var[varid].text, lsig.ttime);
 		break;
 	}
 
@@ -1577,39 +1476,31 @@ ctl_putsys(
 		leap_signature_t lsig;
 		leapsec_getsig(&lsig);
 		if (lsig.etime > 0)
-			ctl_puttime(sys_var[CS_LEAPEND].text, lsig.etime);
+			ctl_puttime(sys_var[varid].text, lsig.etime);
 		break;
 	}
 
 #ifdef ENABLE_LEAP_SMEAR
 	case CS_LEAPSMEARINTV:
 		if (leap_smear_intv > 0)
-			ctl_putuint(sys_var[CS_LEAPSMEARINTV].text,
+			ctl_putuint(sys_var[varid].text,
                                     leap_smear_intv);
 		break;
 
 	case CS_LEAPSMEAROFFS:
 		if (leap_smear_intv > 0)
-			ctl_putdbl(sys_var[CS_LEAPSMEAROFFS].text,
+			ctl_putdbl(sys_var[varid].text,
 				   leap_smear.doffset * MS_PER_S);
 		break;
 #endif	/* ENABLE_LEAP_SMEAR */
 
-	case CS_RATE:
-		ctl_putuint(sys_var[CS_RATE].text, rstrct.ntp_minpoll);
-		break;
+	CASE_UINT(CS_RATE, rstrct.ntp_minpoll);
 
-	case CS_MRU_ENABLED:
-		ctl_puthex(sys_var[varid].text, mon_data.mon_enabled);
-		break;
+	CASE_HEX(CS_MRU_ENABLED, mon_data.mon_enabled);
 
-	case CS_MRU_DEPTH:  /* mru_entries */
-		ctl_putuint(sys_var[varid].text, mon_data.mru_entries);
-		break;
+	CASE_UINT(CS_MRU_DEPTH, mon_data.mru_entries);
 
-	case CS_MRU_HASHSLOTS:
-		ctl_putuint(sys_var[varid].text, mon_data.mru_hashslots);
-		break;
+	CASE_UINT(CS_MRU_HASHSLOTS, mon_data.mru_hashslots);
 
 	case CS_MRU_MEM: {
 		uint64_t u;
@@ -1619,25 +1510,15 @@ ctl_putsys(
 		break;
 		}
 
-	case CS_MRU_DEEPEST:
-		ctl_putuint(sys_var[varid].text, mon_data.mru_peakentries);
-		break;
+	CASE_UINT(CS_MRU_DEEPEST, mon_data.mru_peakentries);
 
-	case CS_MRU_MINDEPTH:
-		ctl_putuint(sys_var[varid].text, mon_data.mru_mindepth);
-		break;
+	CASE_UINT(CS_MRU_MINDEPTH, mon_data.mru_mindepth);
 
-	case CS_MRU_MAXAGE:
-		ctl_putint(sys_var[varid].text, mon_data.mru_maxage);
-		break;
+	CASE_INT(CS_MRU_MAXAGE, mon_data.mru_maxage);
 
-	case CS_MRU_MINAGE:
-		ctl_putint(sys_var[varid].text, mon_data.mru_minage);
-		break;
+	CASE_INT(CS_MRU_MINAGE, mon_data.mru_minage);
 
-	case CS_MRU_MAXDEPTH:
-		ctl_putuint(sys_var[varid].text, mon_data.mru_maxdepth);
-		break;
+	CASE_UINT(CS_MRU_MAXDEPTH, mon_data.mru_maxdepth);
 
 	case CS_MRU_MAXMEM: {
 		uint64_t u;
@@ -1647,25 +1528,15 @@ ctl_putsys(
 		break;
 		}
 
-	case CS_MRU_EXISTS:
-		ctl_putuint(sys_var[varid].text, mon_data.mru_exists);
-		break;
+	CASE_UINT(CS_MRU_EXISTS, mon_data.mru_exists);
 
-	case CS_MRU_NEW:
-		ctl_putuint(sys_var[varid].text, mon_data.mru_new);
-		break;
+	CASE_UINT(CS_MRU_NEW, mon_data.mru_new);
 
-	case CS_MRU_RECYCLEOLD:
-		ctl_putuint(sys_var[varid].text, mon_data.mru_recycleold);
-		break;
+	CASE_UINT(CS_MRU_RECYCLEOLD, mon_data.mru_recycleold);
 
-	case CS_MRU_RECYCLEFULL:
-		ctl_putuint(sys_var[varid].text, mon_data.mru_recyclefull);
-		break;
+	CASE_UINT(CS_MRU_RECYCLEFULL, mon_data.mru_recyclefull);
 
-	case CS_MRU_NONE:
-		ctl_putuint(sys_var[varid].text, mon_data.mru_none);
-		break;
+	CASE_UINT(CS_MRU_NONE, mon_data.mru_none);
 
 	case CS_MRU_OLDEST_AGE: {
 		l_fp now;
@@ -1674,112 +1545,63 @@ ctl_putsys(
 		break;
 		}
 
-	case CS_SS_UPTIME:
-		ctl_putuint(sys_var[varid].text, current_time);
-		break;
+	CASE_UINT(CS_SS_UPTIME, current_time);
 
-	case CS_SS_RESET:
-		ctl_putuint(sys_var[varid].text, current_time - stat_stattime());
-		break;
+	CASE_UINT(CS_SS_RESET, current_time - stat_stattime());
 
-	case CS_SS_RECEIVED:
-        ctl_putuint(sys_var[varid].text, stat_received());
-		break;
+	CASE_UINT(CS_SS_RECEIVED, stat_received());
 
-	case CS_SS_THISVER:
-		ctl_putuint(sys_var[varid].text, stat_newversion());
-		break;
+	CASE_UINT(CS_SS_THISVER, stat_newversion());
+	
+	CASE_UINT(CS_SS_OLDVER, stat_oldversion());
 
-	case CS_SS_OLDVER:
-		ctl_putuint(sys_var[varid].text, stat_oldversion());
-		break;
-
-	case CS_SS_BADFORMAT:
-		ctl_putuint(sys_var[varid].text, stat_badlength());
-		break;
+	CASE_UINT(CS_SS_BADFORMAT, stat_badlength());
 
-	case CS_SS_BADAUTH:
-		ctl_putuint(sys_var[varid].text, stat_badauth());
-		break;
+	CASE_UINT(CS_SS_BADAUTH, stat_badauth());
 
-	case CS_SS_DECLINED:
-		ctl_putuint(sys_var[varid].text, stat_declined());
-		break;
+	CASE_UINT(CS_SS_DECLINED, stat_declined());
 
-	case CS_SS_RESTRICTED:
-		ctl_putuint(sys_var[varid].text, stat_restricted());
-		break;
+	CASE_UINT(CS_SS_RESTRICTED, stat_restricted());
 
-	case CS_SS_LIMITED:
-		ctl_putuint(sys_var[varid].text, stat_limitrejected());
-		break;
+	CASE_UINT(CS_SS_LIMITED, stat_limitrejected());
 
-	case CS_SS_KODSENT:
-		ctl_putuint(sys_var[varid].text, stat_kodsent());
-		break;
+	CASE_UINT(CS_SS_KODSENT, stat_kodsent());
 
-	case CS_SS_PROCESSED:
-		ctl_putuint(sys_var[varid].text, stat_processed());
-		break;
+	CASE_UINT(CS_SS_PROCESSED, stat_processed());
 
 	case CS_AUTHDELAY:
 		dtemp = lfptod(sys_authdelay);
 		ctl_putdbl(sys_var[varid].text, dtemp * MS_PER_S);
 		break;
 
-	case CS_AUTHKEYS:
-		ctl_putuint(sys_var[varid].text, authnumkeys);
-		break;
+	CASE_UINT(CS_AUTHKEYS, authnumkeys);
 
 	case CS_AUTHFREEK:
 		ctl_putuint(sys_var[varid].text,
                             (unsigned long)authnumfreekeys);
 		break;
 
-	case CS_AUTHKLOOKUPS:
-		ctl_putuint(sys_var[varid].text, authkeylookups);
-		break;
+	CASE_UINT(CS_AUTHKLOOKUPS, authkeylookups);
 
-	case CS_AUTHKNOTFOUND:
-		ctl_putuint(sys_var[varid].text, authkeynotfound);
-		break;
+	CASE_UINT(CS_AUTHKNOTFOUND, authkeynotfound);
 
-	case CS_AUTHENCRYPTS:
-		ctl_putuint(sys_var[varid].text, authencryptions);
-		break;
+	CASE_UINT(CS_AUTHENCRYPTS, authencryptions);
 
-	case CS_AUTHDIGESTENCRYPT:
-		ctl_putuint(sys_var[varid].text, authdigestencrypt);
-		break;
+	CASE_UINT(CS_AUTHDIGESTENCRYPT, authdigestencrypt);
 
-	case CS_AUTHCMACENCRYPT:
-		ctl_putuint(sys_var[varid].text, authcmacencrypt);
-		break;
+	CASE_UINT(CS_AUTHCMACENCRYPT, authcmacencrypt);
 
-	case CS_AUTHDECRYPTS:
-		ctl_putuint(sys_var[varid].text, authdecryptions);
-		break;
+	CASE_UINT(CS_AUTHDECRYPTS, authdecryptions);
 
-	case CS_AUTHDIGESTDECRYPT:
-		ctl_putuint(sys_var[varid].text, authdigestdecrypt);
-		break;
+	CASE_UINT(CS_AUTHDIGESTDECRYPT, authdigestdecrypt);
 
-	case CS_AUTHDIGESTFAIL:
-		ctl_putuint(sys_var[varid].text, authdigestfail);
-		break;
+	CASE_UINT(CS_AUTHDIGESTFAIL, authdigestfail);
 
-	case CS_AUTHCMACDECRYPT:
-		ctl_putuint(sys_var[varid].text, authcmacdecrypt);
-		break;
+	CASE_UINT(CS_AUTHCMACDECRYPT, authcmacdecrypt);
 
-	case CS_AUTHCMACFAIL:
-		ctl_putuint(sys_var[varid].text, authcmacfail);
-		break;
+	CASE_UINT(CS_AUTHCMACFAIL, authcmacfail);
 
-	case CS_AUTHRESET:
-		ctl_putuint(sys_var[varid].text,
-			    current_time - auth_timereset);
-		break;
+	CASE_UINT(CS_AUTHRESET, current_time - auth_timereset);
 
 		/*
 		 * CTL_IF_KERNPPS() puts a zero if kernel hard PPS is not
@@ -1796,9 +1618,7 @@ ctl_putsys(
 			ntp_error_in_seconds(ntx.offset) * MS_PER_S);
 		break;
 
-	case CS_K_FREQ:
-		ctl_putsfp(sys_var[varid].text, ntx.freq);
-		break;
+	CASE_SFP(CS_K_FREQ, ntx.freq);
 
 	case CS_K_MAXERR:
 		ctl_putdblf(sys_var[varid].text, false, 6,
@@ -1815,18 +1635,14 @@ ctl_putsys(
 		ctl_putstr(sys_var[varid].text, ss, strlen(ss));
 		break;
 
-	case CS_K_TIMECONST:
-		ctl_putint(sys_var[varid].text, ntx.constant);
-		break;
+	CASE_INT(CS_K_TIMECONST, ntx.constant);
 
 	case CS_K_PRECISION:
 		ctl_putdblf(sys_var[varid].text, false, 6,
 			    ntp_error_in_seconds(ntx.precision) * MS_PER_S);
 		break;
 
-	case CS_K_FREQTOL:
-	        ctl_putsfp(sys_var[varid].text, ntx.tolerance);
-		break;
+	CASE_SFP(CS_K_FREQTOL, ntx.tolerance);
 
 	case CS_K_PPS_FREQ:
 		CTL_IF_KERNPPS(
@@ -1885,31 +1701,23 @@ ctl_putsys(
 		);
 		break;
 
-	case CS_K_LOCKCLOCK:
-		ctl_putuint(sys_var[varid].text, loop_data.lockclock);
-		break;
+	CASE_UINT(CS_K_LOCKCLOCK, loop_data.lockclock);
 
 	case CS_IOSTATS_RESET:
 		ctl_putuint(sys_var[varid].text,
             current_time - counter_reset_time());
 		break;
 
-	case CS_TOTAL_RBUF:
-		ctl_putuint(sys_var[varid].text, total_recvbuffs());
-		break;
+	CASE_UINT(CS_TOTAL_RBUF, total_recvbuffs());
 
-	case CS_FREE_RBUF:
-		ctl_putuint(sys_var[varid].text, free_recvbuffs());
-		break;
+	CASE_UINT(CS_FREE_RBUF, free_recvbuffs());
 
 	case CS_USED_RBUF:
 		// FIXME: nuke this slot
 		ctl_putuint(sys_var[varid].text, 0);
 		break;
 
-	case CS_RBUF_LOWATER:
-		ctl_putuint(sys_var[varid].text, lowater_additions());
-		break;
+	CASE_UINT(CS_RBUF_LOWATER, lowater_additions());
 
 	case CS_IO_DROPPED:
         ctl_putuint(sys_var[varid].text, dropped_count());
@@ -1939,18 +1747,11 @@ ctl_putsys(
         ctl_putuint(sys_var[varid].text, handler_pkts_count());
 		break;
 
-	case CS_TIMERSTATS_RESET:
-		ctl_putuint(sys_var[varid].text,
-			    current_time - timer_timereset);
-		break;
+	CASE_UINT(CS_TIMERSTATS_RESET, current_time - timer_timereset);
 
-	case CS_TIMER_OVERRUNS:
-		ctl_putuint(sys_var[varid].text, alarm_overflow);
-		break;
+	CASE_UINT(CS_TIMER_OVERRUNS, alarm_overflow);
 
-	case CS_TIMER_XMTS:
-		ctl_putuint(sys_var[varid].text, timer_xmtcalls);
-		break;
+	CASE_UINT(CS_TIMER_XMTS, timer_xmtcalls);
 
 	case CS_FUZZ:
 		/* a.k.a. fuzz (s), output in ms */
@@ -1961,9 +1762,7 @@ ctl_putsys(
 #endif
 		break;
 
-	case CS_WANDER_THRESH:
-		ctl_putdbl(sys_var[varid].text, wander_threshold * US_PER_S);
-		break;
+	CASE_DBL(CS_WANDER_THRESH, wander_threshold * US_PER_S);
 
 	case CS_TICK:
 		/* a.k.a. sys_tick (s), output in ms */
@@ -1974,75 +1773,40 @@ ctl_putsys(
 #endif
 		break;
 
-	case CS_NUMCTLREQ:
-		ctl_putuint(sys_var[varid].text, numctlreq);
-		break;
+	CASE_UINT(CS_NUMCTLREQ, numctlreq);
 
-	case CS_ROOTDISTANCE:
-		ctl_putdbl(sys_var[CS_ROOTDISTANCE].text,
-			   sys_vars.sys_rootdist * MS_PER_S);
-		break;
+	CASE_DBL(CS_ROOTDISTANCE, sys_vars.sys_rootdist * MS_PER_S);
 
 #ifndef DISABLE_NTS
-	case CS_nts_client_send:
-		ctl_putuint(sys_var[varid].text, nts_client_send);
-		break;
+	CASE_UINT(CS_nts_client_send, nts_client_send);
 
-	case CS_nts_client_recv_good:
-		ctl_putuint(sys_var[varid].text, nts_client_recv_good);
-		break;
+	CASE_UINT(CS_nts_client_recv_good, nts_client_recv_good);
 
-	case CS_nts_client_recv_bad:
-		ctl_putuint(sys_var[varid].text, nts_client_recv_bad);
-		break;
+	CASE_UINT(CS_nts_client_recv_bad, nts_client_recv_bad);
 
-	case CS_nts_server_send:
-		ctl_putuint(sys_var[varid].text, nts_server_send);
-		break;
+	CASE_UINT(CS_nts_server_send, nts_server_send);
 
-	case CS_nts_server_recv_good:
-		ctl_putuint(sys_var[varid].text, nts_server_recv_good);
-		break;
+	CASE_UINT(CS_nts_server_recv_good, nts_server_recv_good);
 
-	case CS_nts_server_recv_bad:
-		ctl_putuint(sys_var[varid].text, nts_server_recv_bad);
-		break;
+	CASE_UINT(CS_nts_server_recv_bad, nts_server_recv_bad);
 
-	case CS_nts_cookie_make:
-		ctl_putuint(sys_var[varid].text, nts_cookie_make);
-		break;
+	CASE_UINT(CS_nts_cookie_make, nts_cookie_make);
 
-	case CS_nts_cookie_decode:
-		ctl_putuint(sys_var[varid].text, nts_cookie_decode);
-		break;
+	CASE_UINT(CS_nts_cookie_decode, nts_cookie_decode);
 
-	case CS_nts_cookie_decode_old:
-		ctl_putuint(sys_var[varid].text, nts_cookie_decode_old);
-		break;
+	CASE_UINT(CS_nts_cookie_decode_old, nts_cookie_decode_old);
 
-	case CS_nts_cookie_decode_too_old:
-		ctl_putuint(sys_var[varid].text, nts_cookie_decode_too_old);
-		break;
+	CASE_UINT(CS_nts_cookie_decode_too_old, nts_cookie_decode_too_old);
 
-	case CS_nts_cookie_decode_error:
-		ctl_putuint(sys_var[varid].text, nts_cookie_decode_error);
-		break;
+	CASE_UINT(CS_nts_cookie_decode_error, nts_cookie_decode_error);
 
-	case CS_nts_ke_serves_good:
-		ctl_putuint(sys_var[varid].text, nts_ke_serves_good);
-		break;
+	CASE_UINT(CS_nts_ke_serves_good, nts_ke_serves_good);
 
-	case CS_nts_ke_serves_bad:
-		ctl_putuint(sys_var[varid].text, nts_ke_serves_bad);
-		break;
+	CASE_UINT(CS_nts_ke_serves_bad, nts_ke_serves_bad);
 
-	case CS_nts_ke_probes_good:
-		ctl_putuint(sys_var[varid].text, nts_ke_probes_good);
-		break;
+	CASE_UINT(CS_nts_ke_probes_good, nts_ke_probes_good);
 
-	case CS_nts_ke_probes_bad:
-		ctl_putuint(sys_var[varid].text, nts_ke_probes_bad);
-		break;
+	CASE_UINT(CS_nts_ke_probes_bad, nts_ke_probes_bad);
 #endif
 
         default:
@@ -2050,8 +1814,10 @@ ctl_putsys(
                 break;
 	}
 }
+#undef CV_NAME
 
 
+#define CV_NAME peer_var[id].text
 /*
  * ctl_putpeer - output a peer variable
  */
@@ -2061,13 +1827,6 @@ ctl_putpeer(
 	struct peer *p
 	)
 {
-	char buf[CTL_MAX_DATA_LEN];
-	char *s;
-	char *t;
-	char *be;
-	size_t sz;
-	const struct ctl_var *k;
-
 	switch (id) {
 
 	case CP_CONFIG:
@@ -2075,9 +1834,7 @@ ctl_putpeer(
 			    !(FLAG_PREEMPT & p->cfg.flags));
 		break;
 
-	case CP_AUTHENABLE:
-		ctl_putuint(peer_var[id].text, !(p->cfg.peerkey));
-		break;
+	CASE_UINT(CP_AUTHENABLE, !(p->cfg.peerkey));
 
 	case CP_AUTHENTIC:
 		ctl_putuint(peer_var[id].text,
@@ -2088,9 +1845,7 @@ ctl_putpeer(
 		ctl_putadr(peer_var[id].text, 0, &p->srcadr);
 		break;
 
-	case CP_SRCPORT:
-		ctl_putuint(peer_var[id].text, SRCPORT(&p->srcadr));
-		break;
+	CASE_UINT(CP_SRCPORT, SRCPORT(&p->srcadr));
 
 	case CP_SRCHOST:
 		if (p->hostname != NULL)
@@ -2119,41 +1874,23 @@ ctl_putpeer(
 				: 0);
 		break;
 
-	case CP_RATE:
-		ctl_putuint(peer_var[id].text, p->throttle);
-		break;
+	CASE_UINT(CP_RATE, p->throttle);
 
-	case CP_LEAP:
-		ctl_putuint(peer_var[id].text, p->leap);
-		break;
+	CASE_UINT(CP_LEAP, p->leap);
 
-	case CP_HMODE:
-		ctl_putuint(peer_var[id].text, p->hmode);
-		break;
+	CASE_UINT(CP_HMODE, p->hmode);
 
-	case CP_STRATUM:
-		ctl_putuint(peer_var[id].text, p->stratum);
-		break;
+	CASE_UINT(CP_STRATUM, p->stratum);
 
-	case CP_PPOLL:
-		ctl_putuint(peer_var[id].text, p->ppoll);
-		break;
+	CASE_UINT(CP_PPOLL, p->ppoll);
 
-	case CP_HPOLL:
-		ctl_putuint(peer_var[id].text, p->hpoll);
-		break;
+	CASE_UINT(CP_HPOLL, p->hpoll);
 
-	case CP_PRECISION:
-		ctl_putint(peer_var[id].text, p->precision);
-		break;
+	CASE_INT(CP_PRECISION, p->precision);
 
-	case CP_ROOTDELAY:
-		ctl_putdbl(peer_var[id].text, p->rootdelay * MS_PER_S);
-		break;
+	CASE_DBL(CP_ROOTDELAY, p->rootdelay * MS_PER_S);
 
-	case CP_ROOTDISPERSION:
-		ctl_putdbl(peer_var[id].text, p->rootdisp * MS_PER_S);
-		break;
+	CASE_DBL(CP_ROOTDISPERSION, p->rootdisp * MS_PER_S);
 
 	case CP_REFID:
 #ifdef REFCLOCK
@@ -2169,30 +1906,20 @@ ctl_putpeer(
 			ctl_putrefid(peer_var[id].text, p->refid);
 		break;
 
-	case CP_REFTIME:
-		ctl_putts(peer_var[id].text, &p->reftime);
-		break;
+	CASE_TS(CP_REFTIME, &p->reftime);
 
-	case CP_REC:
-		ctl_putts(peer_var[id].text, &p->dst);
-		break;
+	CASE_TS(CP_REC, &p->dst);
 
-	case CP_XMT:
-		ctl_putts(peer_var[id].text, &p->xmt);
-		break;
+	CASE_TS(CP_XMT, &p->xmt);
 
 	case CP_BIAS:
 		if ( !D_ISZERO_NS(p->cfg.bias) )
 			ctl_putdbl(peer_var[id].text, p->cfg.bias);
 		break;
 
-	case CP_REACH:
-		ctl_puthex(peer_var[id].text, p->reach);
-		break;
+	CASE_HEX(CP_REACH, p->reach);
 
-	case CP_FLASH:
-		ctl_puthex(peer_var[id].text, p->flash);
-		break;
+	CASE_HEX(CP_FLASH, p->flash);
 
 	case CP_MODE:
 #ifdef REFCLOCK
@@ -2203,30 +1930,17 @@ ctl_putpeer(
 #endif
 		break;
 
-	case CP_UNREACH:
-		ctl_putuint(peer_var[id].text, (unsigned long)p->unreach);
-		break;
+	CASE_UINT(CP_UNREACH, (unsigned long)p->unreach);
 
-	case CP_TIMER:
-		ctl_putuint(peer_var[id].text,
-			    p->nextdate - current_time);
-		break;
+	CASE_UINT(CP_TIMER, p->nextdate - current_time);
 
-	case CP_DELAY:
-		ctl_putdbl6(peer_var[id].text, p->delay * MS_PER_S);
-		break;
+	CASE_DBL6(CP_DELAY, p->delay * MS_PER_S);
 
-	case CP_OFFSET:
-		ctl_putdbl6(peer_var[id].text, p->offset * MS_PER_S);
-		break;
+	CASE_DBL6(CP_OFFSET, p->offset * MS_PER_S);
 
-	case CP_JITTER:
-		ctl_putdbl6(peer_var[id].text, p->jitter * MS_PER_S);
-		break;
+	CASE_DBL6(CP_JITTER, p->jitter * MS_PER_S);
 
-	case CP_DISPERSION:
-		ctl_putdbl6(peer_var[id].text, p->disp * MS_PER_S);
-		break;
+	CASE_DBL6(CP_DISPERSION, p->disp * MS_PER_S);
 
 	case CP_KEYID:
 		if (p->cfg.peerkey > NTP_MAXKEY)
@@ -2250,90 +1964,122 @@ ctl_putpeer(
 			     p->filter_nextpt);
 		break;
 
-	case CP_PMODE:
-		ctl_putuint(peer_var[id].text, p->pmode);
-		break;
+	CASE_UINT(CP_PMODE, p->pmode);
 
-	case CP_RECEIVED:
-		ctl_putuint(peer_var[id].text, p->received);
-		break;
+	CASE_UINT(CP_RECEIVED, p->received);
 
-	case CP_SENT:
-		ctl_putuint(peer_var[id].text, p->sent);
-		break;
+	CASE_UINT(CP_SENT, p->sent);
 
 	case CP_VARLIST:
-		s = buf;
-		be = buf + sizeof(buf);
-		if (strlen(peer_var[id].text) + 4 > sizeof(buf))
-			break;	/* really long var name */
-
-		snprintf(s, sizeof(buf), "%s=\"", peer_var[id].text);
-		s += strlen(s);
-		t = s;
-		for (k = peer_var; !(EOV & k->flags); k++) {
-			if (PADDING & k->flags)
-				continue;
-			sz = strlen(k->text);
-			if (s + sz + 1 >= be)
-				break;
-			if (s != t)
-				*s++ = ',';
-			memcpy(s, k->text, sz);
-			s += sz;
-		}
-		if (s + 2 < be) {
-			*s++ = '"';
-			*s = '\0';
-			ctl_putdata(buf, (unsigned int)(s - buf), false);
-		}
+		(void)CF_VARLIST(&peer_var[id], peer_var, NULL);
 		break;
 
-	case CP_TIMEREC:
-		ctl_putuint(peer_var[id].text,
-			    current_time - p->timereceived);
-		break;
+	CASE_UINT(CP_TIMEREC, current_time - p->timereceived);
 
-	case CP_TIMEREACH:
-		ctl_putuint(peer_var[id].text,
-			    current_time - p->timereachable);
-		break;
+	CASE_UINT(CP_TIMEREACH, current_time - p->timereachable);
 
-	case CP_BADAUTH:
-		ctl_putuint(peer_var[id].text, p->badauth);
-		break;
+	CASE_UINT(CP_BADAUTH, p->badauth);
 
-	case CP_BOGUSORG:
-		ctl_putuint(peer_var[id].text, p->bogusorg);
-		break;
+	CASE_UINT(CP_BOGUSORG, p->bogusorg);
 
-	case CP_OLDPKT:
-		ctl_putuint(peer_var[id].text, p->oldpkt);
-		break;
+	CASE_UINT(CP_OLDPKT, p->oldpkt);
 
-	case CP_SELDISP:
-		ctl_putuint(peer_var[id].text, p->seldisptoolarge);
-		break;
+	CASE_UINT(CP_SELDISP, p->seldisptoolarge);
 
-	case CP_SELBROKEN:
-		ctl_putuint(peer_var[id].text, p->selbroken);
-		break;
+	CASE_UINT(CP_SELBROKEN, p->selbroken);
 
-	case CP_CANDIDATE:
-		ctl_putuint(peer_var[id].text, p->status);
-		break;
+	CASE_UINT(CP_CANDIDATE, p->status);
 
-	case CP_NTSCOOKIES:
-		ctl_putint(peer_var[id].text, p->nts_state.count);
-		break;
+	CASE_INT(CP_NTSCOOKIES, p->nts_state.count);
 
 	default:
 		break;
 	}
 }
+#undef CV_NAME
+
+
+ssize_t CI_VARLIST(
+    char *buffer_lap,
+    char *buf_end,
+    const struct ctl_var *table,
+    bool *first
+    ) {
+	char *start = buffer_lap;
+	char *string_split;
+	size_t string_length;
+	const struct ctl_var *row;
+	if (NULL == table) {
+		return 0;
+	}
+	for (row = table; !(EOV & row->flags); row++) {
+		if (PADDING & row->flags)
+			continue;
+		string_split = strchr(row->text, '=');
+		if (string_split == NULL) {
+			string_length = strlen(row->text);
+		} else {
+			string_length = string_split - row->text; 
+		}
+		if (string_length >= buf_end - buffer_lap - (size_t)1) {
+			return -1;
+		}
+		if (!*first) {
+			*buffer_lap++ = ',';
+		} else {
+			*first = false;
+		}
+		memcpy(buffer_lap, row->text, string_length);
+		buffer_lap+= string_length;
+	}
+	*buffer_lap = '\0';
+	return buffer_lap - start;
+}
+
+
+bool CF_VARLIST(
+    const struct ctl_var *entry,
+    const struct ctl_var *table1,
+    const struct ctl_var *table2
+    ) {
+	char buf[1500];  // Arbitrary length greeter than used to be.
+	char *buffer_lap, *buffer_end;
+	bool first = true;
+	ssize_t increment;
+	memset(buf, '.', sizeof(buf));
+	buf[0] = '\0';
+	buffer_lap = buf;
+	buffer_end = buf + sizeof(buf);
+	if (strlen(entry->text) + 4 > sizeof(buf)) {
+		return false;	// really long var name
+	}
+
+	snprintf(buffer_lap, sizeof(buf), "%s=\"", entry->text);
+	buffer_lap += strlen(buffer_lap);
+	increment = CI_VARLIST(buffer_lap, buffer_end,
+			    table1, &first);
+	if (increment <= 0) {
+		return false;
+	}
+	buffer_lap += increment;
+	increment = CI_VARLIST(buffer_lap, buffer_end,
+			       table2, &first);
+	if (increment < 0) {
+		return false;
+	}
+	buffer_lap += increment;
+	if (buffer_lap + 2 >= buffer_end)
+		return false;
+
+	*buffer_lap++ = '"';
+	*buffer_lap = '\0';
+	ctl_putdata(buf, (unsigned)(buffer_lap - buf), false);
+	return true;
+}
 
 
 #ifdef REFCLOCK
+#define CV_NAME clock_var[id].text
 /*
  * ctl_putclock - output clock variables
  */
@@ -2344,12 +2090,6 @@ ctl_putclock(
 	int mustput
 	)
 {
-	char buf[CTL_MAX_DATA_LEN];
-	char *s, *t, *be;
-	const char *ss;
-	size_t sz;
-	const struct ctl_var *k;
-
 	switch (id) {
 
 	case CC_NAME:
@@ -2370,24 +2110,13 @@ ctl_putclock(
 			   (unsigned)pcs->lencode);
 		break;
 
-	case CC_POLL:
-		ctl_putuint(clock_var[id].text, pcs->polls);
-		break;
+	CASE_UINT(CC_POLL, pcs->polls);
 
-	case CC_NOREPLY:
-		ctl_putuint(clock_var[id].text,
-			    pcs->noresponse);
-		break;
+	CASE_UINT(CC_NOREPLY, pcs->noresponse);
 
-	case CC_BADFORMAT:
-		ctl_putuint(clock_var[id].text,
-			    pcs->badformat);
-		break;
+	CASE_UINT(CC_BADFORMAT, pcs->badformat);
 
-	case CC_BADDATA:
-		ctl_putuint(clock_var[id].text,
-			    pcs->baddata);
-		break;
+	CASE_UINT(CC_BADDATA, pcs->baddata);
 
 	case CC_FUDGETIME1:
 		if (mustput || (pcs->haveflags & CLK_HAVETIME1))
@@ -2418,9 +2147,7 @@ ctl_putclock(
 		}
 		break;
 
-	case CC_FLAGS:
-		ctl_putuint(clock_var[id].text, pcs->flags);
-		break;
+	CASE_UINT(CC_FLAGS, pcs->flags);
 
 	case CC_DEVICE:
 		if (pcs->clockdesc == NULL ||
@@ -2436,57 +2163,7 @@ ctl_putclock(
 		break;
 
 	case CC_VARLIST:
-		s = buf;
-		be = buf + sizeof(buf);
-		if (strlen(clock_var[CC_VARLIST].text) + 4 >
-		    sizeof(buf))
-			break;	/* really long var name */
-
-		snprintf(s, sizeof(buf), "%s=\"",
-			 clock_var[CC_VARLIST].text);
-		s += strlen(s);
-		t = s;
-
-		for (k = clock_var; !(EOV & k->flags); k++) {
-			if (PADDING & k->flags)
-				continue;
-
-			sz = strlen(k->text);
-			if (s + sz + 1 >= be)
-				break;
-
-			if (s != t)
-				*s++ = ',';
-			memcpy(s, k->text, sz);
-			s += sz;
-		}
-
-		for (k = pcs->kv_list; k && !(EOV & k->flags); k++) {
-			if (PADDING & k->flags)
-				continue;
-
-			ss = k->text;
-			if (NULL == ss)
-				continue;
-
-			while (*ss && *ss != '=')
-				ss++;
-			sz = (size_t)(ss - k->text);
-			if (s + sz + 1 >= be)
-				break;
-
-			if (s != t)
-				*s++ = ',';
-			memcpy(s, k->text, sz);
-			s += sz;
-			*s = '\0';
-		}
-		if (s + 2 >= be)
-			break;
-
-		*s++ = '"';
-		*s = '\0';
-		ctl_putdata(buf, (unsigned)(s - buf), false);
+		(void)CF_VARLIST(&clock_var[id], clock_var, pcs->kv_list);
 		break;
 
         default:
@@ -2494,7 +2171,15 @@ ctl_putclock(
                 break;
 	}
 }
+#undef CV_NAME
 #endif
+#undef CASE_UINT
+#undef CASE_TS
+#undef CASE_SFP
+#undef CASE_INT
+#undef CASE_HEX
+#undef CASE_DBL6
+#undef CASE_DBL
 
 
 /*


=====================================
ntpd/ntpd.c
=====================================
@@ -105,7 +105,7 @@ static  void    close_all_beyond(int);
 static  void    close_all_except(int);
 
 
-#define ALL_OPTIONS "46abc:dD:f:gGhi:I:k:l:LmnNp:Pqr:Rs:t:u:U:Vw:xzZ"
+#define ALL_OPTIONS "46abc:dD:f:gGhi:I:k:l:LmnNp:P:qr:Rs:t:u:U:Vw:xzZ"
 static const struct option longoptions[] = {
     { "ipv4",		    0, 0, '4' },
     { "ipv6",		    0, 0, '6' },



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/a912d238f296a3adc52d66b178b553d6690552f1...33fb2ddf3b9c556bb60df91618850a89d0459f75

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/a912d238f296a3adc52d66b178b553d6690552f1...33fb2ddf3b9c556bb60df91618850a89d0459f75
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20210209/d156150a/attachment-0001.htm>


More information about the vc mailing list