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)
41 ? (u_long)(ind - digits - 6)
42 : (u_long)(ind - digits);
46 if ((cp - cpstart) < 8 || ind == NULL)
52 while (*cp != '\0' && (cp - cpstart) < 8 &&
53 (ind = strchr(digits, *cp)) != NULL) {
54 dec_f = dec_f << 4; /* multiply by 16 */
55 dec_f += ((ind - digits) > 15)
56 ? (u_long)(ind - digits - 6)
57 : (u_long)(ind - digits);
61 if ((cp - cpstart) < 8 || ind == NULL)
64 if (*cp != '\0' && !isspace((unsigned char)*cp))