2 * hextolfp - convert an ascii hex string to an l_fp number
9 #include "ntp_string.h"
10 #include "ntp_stdlib.h"
18 register const char *cp;
19 register const char *cpstart;
20 register u_long dec_i;
21 register u_long dec_f;
23 static const char *digits = "0123456789abcdefABCDEF";
29 * We understand numbers of the form:
31 * [spaces]8_hex_digits[.]8_hex_digits[spaces|\n|\0]
33 while (isspace((unsigned char)*cp))
37 while (*cp != '\0' && (cp - cpstart) < 8 &&
38 (ind = strchr(digits, *cp)) != NULL) {
39 dec_i = dec_i << 4; /* multiply by 16 */
40 dec_i += ((ind - digits) > 15) ? (ind - digits) - 6
45 if ((cp - cpstart) < 8 || ind == NULL)
51 while (*cp != '\0' && (cp - cpstart) < 8 &&
52 (ind = strchr(digits, *cp)) != NULL) {
53 dec_f = dec_f << 4; /* multiply by 16 */
54 dec_f += ((ind - digits) > 15) ? (ind - digits) - 6
59 if ((cp - cpstart) < 8 || ind == NULL)
62 if (*cp != '\0' && !isspace((unsigned char)*cp))