003 File Manager
Current Path:
/usr/src/contrib/ntp/libntp
usr
/
src
/
contrib
/
ntp
/
libntp
/
📁
..
📄
Makefile.am
(3.27 KB)
📄
Makefile.in
(105.83 KB)
📄
README
(272 B)
📄
a_md5encrypt.c
(6.76 KB)
📄
adjtime.c
(10.29 KB)
📄
adjtimex.c
(334 B)
📄
atoint.c
(801 B)
📄
atolfp.c
(1.88 KB)
📄
atouint.c
(885 B)
📄
audio.c
(13.09 KB)
📄
authkeys.c
(19.92 KB)
📄
authreadkeys.c
(9.06 KB)
📄
authusekey.c
(748 B)
📄
bsd_strerror.c
(1.35 KB)
📄
buftvtots.c
(643 B)
📄
caljulian.c
(891 B)
📄
caltontp.c
(2.25 KB)
📄
calyearstart.c
(2.1 KB)
📄
clocktime.c
(4.49 KB)
📄
clocktypes.c
(3.69 KB)
📄
decodenetnum.c
(3.93 KB)
📄
dofptoa.c
(2.19 KB)
📄
dolfptoa.c
(3.14 KB)
📄
emalloc.c
(3.4 KB)
📄
findconfig.c
(1.46 KB)
📄
getopt.c
(2.21 KB)
📄
hextoint.c
(673 B)
📄
hextolfp.c
(1.35 KB)
📄
humandate.c
(1.1 KB)
📄
icom.c
(4.22 KB)
📄
iosignal.c
(12.27 KB)
📄
is_ip_address.c
(2.02 KB)
📄
lib_strbuf.c
(633 B)
📄
libssl_compat.c
(6.13 KB)
📄
machines.c
(13.05 KB)
📄
mktime.c
(8.29 KB)
📄
modetoa.c
(507 B)
📄
mstolfp.c
(2.01 KB)
📄
msyslog.c
(12.67 KB)
📄
netof.c
(1.17 KB)
📄
ntp_calendar.c
(58.49 KB)
📄
ntp_calgps.c
(15.73 KB)
📄
ntp_crypto_rnd.c
(2.11 KB)
📄
ntp_intres.c
(28.64 KB)
📄
ntp_libopts.c
(1.27 KB)
📄
ntp_lineedit.c
(3.88 KB)
📄
ntp_random.c
(17.63 KB)
📄
ntp_rfc2553.c
(14.85 KB)
📄
ntp_worker.c
(7.21 KB)
📄
numtoa.c
(963 B)
📄
numtohost.c
(908 B)
📄
octtoint.c
(578 B)
📄
prettydate.c
(5.53 KB)
📄
recvbuff.c
(7.3 KB)
📄
refidsmear.c
(1.05 KB)
📄
refnumtoa.c
(673 B)
📄
snprintf.c
(52.56 KB)
📄
socket.c
(4.88 KB)
📄
socktoa.c
(2.88 KB)
📄
socktohost.c
(2.54 KB)
📄
ssl_init.c
(5.09 KB)
📄
statestr.c
(11.4 KB)
📄
strdup.c
(854 B)
📄
strl_obsd.c
(3.65 KB)
📄
syssignal.c
(2.69 KB)
📄
systime.c
(17.51 KB)
📄
systime_s.c
(33 B)
📄
timespecops.c
(4.27 KB)
📄
timetoa.c
(2.75 KB)
📄
timevalops.c
(12.97 KB)
📄
timexsup.c
(1.17 KB)
📄
uglydate.c
(958 B)
📄
vint64ops.c
(5.1 KB)
📄
work_fork.c
(12.73 KB)
📄
work_thread.c
(22.88 KB)
📄
xsbprintf.c
(2.06 KB)
📄
ymd2yd.c
(582 B)
Editing: dolfptoa.c
/* * dolfptoa - do the grunge work of converting an l_fp number to decimal */ #include <config.h> #include <stdio.h> #include "ntp_fp.h" #include "lib_strbuf.h" #include "ntp_string.h" #include "ntp_stdlib.h" char * dolfptoa( u_int32 fpi, u_int32 fpv, char sign, short ndec, int msec ) { u_char *cp, *cpend, *cpdec; int dec; u_char cbuf[24]; char *buf, *bp; /* * Get a string buffer before starting */ LIB_GETBUF(buf); /* * Zero the character buffer */ ZERO(cbuf); /* * Work on the integral part. This should work reasonable on * all machines with 32 bit arithmetic. Please note that 32 bits * can *always* be represented with at most 10 decimal digits, * including a possible rounding from the fractional part. */ cp = cpend = cpdec = &cbuf[10]; for (dec = (int)(cp - cbuf); dec > 0 && fpi != 0; dec--) { /* can add another digit */ u_int32 digit; digit = fpi; fpi /= 10U; digit -= (fpi << 3) + (fpi << 1); /* i*10 */ *--cp = (u_char)digit; } /* * Done that, now deal with the problem of the fraction. First * determine the number of decimal places. */ dec = ndec; if (dec < 0) dec = 0; if (msec) { dec += 3; cpdec += 3; } if ((size_t)dec > sizeof(cbuf) - (cpend - cbuf)) dec = (int)(sizeof(cbuf) - (cpend - cbuf)); /* * If there's a fraction to deal with, do so. */ for (/*NOP*/; dec > 0 && fpv != 0; dec--) { u_int32 digit, tmph, tmpl; /* * The scheme here is to multiply the fraction * (0.1234...) by ten. This moves a junk of BCD into * the units part. record that and iterate. * multiply by shift/add in two dwords. */ digit = 0; M_LSHIFT(digit, fpv); tmph = digit; tmpl = fpv; M_LSHIFT(digit, fpv); M_LSHIFT(digit, fpv); M_ADD(digit, fpv, tmph, tmpl); *cpend++ = (u_char)digit; } /* decide whether to round or simply extend by zeros */ if (dec > 0) { /* only '0' digits left -- just reposition end */ cpend += dec; } else { /* some bits remain in 'fpv'; do round */ u_char *tp = cpend; int carry = ((fpv & 0x80000000) != 0); for (dec = (int)(tp - cbuf); carry && dec > 0; dec--) { *--tp += 1; if (*tp == 10) *tp = 0; else carry = FALSE; } if (tp < cp) /* rounding from 999 to 1000 or similiar? */ cp = tp; } /* * We've now got the fraction in cbuf[], with cp pointing at * the first character, cpend pointing past the last, and * cpdec pointing at the first character past the decimal. * Remove leading zeros, then format the number into the * buffer. */ while (cp < cpdec && *cp == 0) cp++; if (cp >= cpdec) cp = cpdec - 1; bp = buf; if (sign) *bp++ = sign; while (cp < cpend) { if (cp == cpdec) *bp++ = '.'; *bp++ = (char)(*cp++) + '0'; } *bp = '\0'; /* * Done! */ return buf; } char * mfptoa( u_int32 fpi, u_int32 fpf, short ndec ) { int isneg; isneg = M_ISNEG(fpi); if (isneg) { M_NEG(fpi, fpf); } return dolfptoa(fpi, fpf, (isneg?'-':'+'), ndec, FALSE); } char * mfptoms( u_int32 fpi, u_int32 fpf, short ndec ) { int isneg; isneg = M_ISNEG(fpi); if (isneg) { M_NEG(fpi, fpf); } return dolfptoa(fpi, fpf, (isneg?'-':'+'), ndec, TRUE); }
Upload File
Create Folder