FreeBSD/contrib/ntp/ntpq/ntpq-subs.c
/*
 * writevar - send a write variables request with the specified variables
 */
send a write variables request with the specified variables
send a write variables request with the specified variables
static void
writevar(
	struct parse *pcmd,
	FILE *fp
	)
{
	const char *datap;
	int res;
	associd_t associd;
	int type;
	size_t dsize;
	u_short rstatus;
	struct varlist tmplist[MAXLIST];
	if (pcmd->argval[0].uval == 0)
		associd = 0;
	else if ((associd = checkassocid(pcmd->argval[0].uval)) == 0)
		return;
	ZERO(tmplist);
	doaddvlist(tmplist, pcmd->argval[1].string);
	res = doquerylist(tmplist, CTL_OP_WRITEVAR, associd, 1, &rstatus,
			  &dsize, &datap);
	doclearvlist(tmplist);
	if (res != 0)
		return;
	if (numhosts > 1)
		fprintf(fp, "server=%s ", currenthost);
	if (dsize == 0)
		fprintf(fp, "done! (no data returned)\n");
	else {
		fprintf(fp,"associd=%u ", associd);
		type = (0 == associd)
			   ? TYPE_SYS
			   : TYPE_PEER;
		printvars(dsize, datap, (int)rstatus, type, 0, fp);
	}
	return;
}
static void writevar ( struct parse * pcmd , FILE * fp ) { const char * datap ; int res ; associd_t associd ; int type ; size_t dsize ; u_short rstatus ; struct varlist tmplist [ MAXLIST ] ; if ( pcmd -> argval [ 0 ] . uval == 0 ) associd = 0 ; else if ( ( associd = checkassocid ( pcmd -> argval [ 0 ] . uval ) ) == 0 ) return ; ZERO ( tmplist ) ; doaddvlist ( tmplist , pcmd -> argval [ 1 ] . string ) ; res = doquerylist ( tmplist , CTL_OP_WRITEVAR , associd , 1 , & rstatus , & dsize , & datap ) ; doclearvlist ( tmplist ) ; if ( res != 0 ) return ; if ( numhosts > 1 ) fprintf ( fp , " " , currenthost ) ; if ( dsize == 0 ) fprintf ( fp , " \n " ) ; else { fprintf ( fp , " " , associd ) ; type = ( 0 == associd ) ? TYPE_SYS : TYPE_PEER ; printvars ( dsize , datap , ( int ) rstatus , type , 0 , fp ) ; } return ; }
writevar - send a write variables request with the specified variables
writevar - send a write variables request with the specified variables
/* HMS: uval? */