4 * hextolfp - convert an ascii hex string to an l_fp number
10 #include "ntp_string.h"
11 #include "ntp_stdlib.h"
19 register const char *cp
;
20 register const char *cpstart
;
21 register u_long dec_i
;
22 register u_long dec_f
;
24 static const char *digits
= "0123456789abcdefABCDEF";
30 * We understand numbers of the form:
32 * [spaces]8_hex_digits[.]8_hex_digits[spaces|\n|\0]
34 while (isspace((int)*cp
))
38 while (*cp
!= '\0' && (cp
- cpstart
) < 8 &&
39 (ind
= strchr(digits
, *cp
)) != NULL
) {
40 dec_i
= dec_i
<< 4; /* multiply by 16 */
41 dec_i
+= ((ind
- digits
) > 15) ? (ind
- digits
) - 6
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) ? (ind
- digits
) - 6
60 if ((cp
- cpstart
) < 8 || ind
== NULL
)
63 if (*cp
!= '\0' && !isspace((int)*cp
))