FreeBSD/contrib/ntp/ntpq/ntpq.c
/*
 * decodets - decode a timestamp into an l_fp format number, with
 *	      consideration of fuzzball formats.
 */
decode a timestamp into an l_fp format number, with
consideration of fuzzball formats.
decode a timestamp into an l_fp format number with consideration of fuzzball formats .
int
decodets(
	char *str,
	l_fp *lfp
	)
{
	char *cp;
	char buf[30];
	size_t b;
	if (*str == '0' && (*(str+1) == 'x' || *(str+1) == 'X'))
		return hextolfp(str+2, lfp);
	if (*str == '"') {
		cp = str + 1;
		b = 0;
		while ('"' != *cp && '\0' != *cp &&
		       b < COUNTOF(buf) - 1)
			buf[b++] = *cp++;
		buf[b] = '\0';
		return rtdatetolfp(buf, lfp);
	}
	if ((*str >= 'A' && *str <= 'F') || (*str >= 'a' && *str <= 'f'))
		return hextolfp(str, lfp);
	if (atolfp(str, lfp))
		return 1;
	return rtdatetolfp(str, lfp);
}
int decodets ( char * str , l_fp * lfp ) { char * cp ; char buf [ 30 ] ; size_t b ; if ( * str == ' ' && ( * ( str + 1 ) == ' ' || * ( str + 1 ) == ' ' ) ) return hextolfp ( str + 2 , lfp ) ; if ( * str == ' ' ) { cp = str + 1 ; b = 0 ; while ( ' ' != * cp && ' \0 ' != * cp && b < COUNTOF ( buf ) - 1 ) buf [ b ++ ] = * cp ++ ; buf [ b ] = ' \0 ' ; return rtdatetolfp ( buf , lfp ) ; } if ( ( * str >= ' ' && * str <= ' ' ) || ( * str >= ' ' && * str <= ' ' ) ) return hextolfp ( str , lfp ) ; if ( atolfp ( str , lfp ) ) return 1 ; return rtdatetolfp ( str , lfp ) ; }
decodets - decode a timestamp into an l_fp format number, with
            consideration of fuzzball formats.
decodets - decode a timestamp into an l_fp format number with consideration of fuzzball formats .
/*
	 * If it starts with a 0x, decode as hex.
	 */ /*
	 * If it starts with a '"', try it as an RT-11 date.
	 */ /*
	 * Might still be hex.  Check out the first character.  Talk
	 * about heuristics!
	 */ /*
	 * Try it as a decimal.  If this fails, try as an unquoted
	 * RT-11 date.  This code should go away eventually.
	 */