FreeBSD/contrib/ntp/ntpsnmpd/ntpSnmpSubagentObject.c
/*****************************************************************************
 *
 *  read_ntp_value
 *
 *  This function retrieves the value for a given variable, currently
 *  this only supports sysvars. It starts a full mode 6 send/receive/parse
 *  iteration and needs to be optimized, e.g. by using a caching mechanism
 *  
 ****************************************************************************
 * Parameters:
 *	variable	char*	The name of the required variable
 *	rbuffer		char*	The buffer where the value goes
 *	maxlength	int	Max. number of bytes for resultbuf
 *
 * Returns:
 *	u_int		number of chars that have been copied to 
 *			rbuffer 
 ****************************************************************************/
read_ntp_value
This function retrieves the value for a given variable, currently
this only supports sysvars. It starts a full mode 6 send/receive/parse
iteration and needs to be optimized, e.g. by using a caching mechanism

variable        char*   The name of the required variable
rbuffer         char*   The buffer where the value goes
maxlength       int     Max. number of bytes for resultbuf

u_int           number of chars that have been copied to
rbuffer
read_ntp_value This function retrieves the value for a given variable currently this only supports sysvars . It starts a full mode 6 send / receive / parse iteration and needs to be optimized e . g . by using a caching mechanism variable char * The name of the required variable rbuffer char * The buffer where the value goes maxlength int Max . number of bytes for resultbuf u_int number of chars that have been copied to rbuffer
size_t
read_ntp_value(
	const char *	variable,
	char *		value,
	size_t		valuesize
	)
{
	size_t	sv_len;
	char	sv_data[NTPQ_BUFLEN];
	memset(sv_data, 0, sizeof(sv_data));
	sv_len = ntpq_read_sysvars(sv_data, sizeof(sv_data));
	if (0 == sv_len)
		return 0;
	else
		return ntpq_getvar(sv_data, sv_len, variable, value,
				   valuesize);
}
size_t read_ntp_value ( const char * variable , char * value , size_t valuesize ) { size_t sv_len ; char sv_data [ NTPQ_BUFLEN ] ; memset ( sv_data , 0 , sizeof ( sv_data ) ) ; sv_len = ntpq_read_sysvars ( sv_data , sizeof ( sv_data ) ) ; if ( 0 == sv_len ) return 0 ; else return ntpq_getvar ( sv_data , sv_len , variable , value , valuesize ) ; }
read_ntp_value
  This function retrieves the value for a given variable, currently
  this only supports sysvars.
read_ntp_value This function retrieves the value for a given variable currently this only supports sysvars .