📄 138
字号:
****************** 7,90 **** #include "ntp_calendar.h" #include "ntp_stdlib.h" - /*- * calmonthtab - month start offsets from the beginning of a cycle.- */- static u_short calmonthtab[12] = {- 0, /* March */- MAR, /* April */- (MAR+APR), /* May */- (MAR+APR+MAY), /* June */- (MAR+APR+MAY+JUN), /* July */- (MAR+APR+MAY+JUN+JUL), /* August */- (MAR+APR+MAY+JUN+JUL+AUG), /* September */- (MAR+APR+MAY+JUN+JUL+AUG+SEP), /* October */- (MAR+APR+MAY+JUN+JUL+AUG+SEP+OCT), /* November */- (MAR+APR+MAY+JUN+JUL+AUG+SEP+OCT+NOV), /* December */- (MAR+APR+MAY+JUN+JUL+AUG+SEP+OCT+NOV+DEC), /* January */- (MAR+APR+MAY+JUN+JUL+AUG+SEP+OCT+NOV+DEC+JAN), /* February */- };- u_long! caltontp(jt)! register const struct calendar *jt; {! register int cyear;! register int resyear;! register u_long nt;! register int yearday;! ! /*! * Find the start of the cycle this is in.! */! cyear = (int)(jt->year - 1900) >> 2;! resyear = (jt->year - 1900) - (cyear << 2);! yearday = 0;! if (resyear == 0) {! if (jt->yearday == 0) {! if (jt->month == 1 || jt->month == 2) {! cyear--;! resyear = 3;! }! } else {! if (jt->yearday <= (u_short)(JAN+FEBLEAP)) {! cyear--;! resyear = 3;! yearday = calmonthtab[10] + jt->yearday;! } else {! yearday = jt->yearday - (JAN+FEBLEAP);! }! }! } else {! if (jt->yearday == 0) {! if (jt->month == 1 || jt->month == 2)! resyear--;! } else {! if (jt->yearday <= (u_short)(JAN+FEB)) {! resyear--;! yearday = calmonthtab[10] + jt->yearday;! } else {! yearday = jt->yearday - (JAN+FEB);! }! }! }! ! if (yearday == 0) {! if (jt->month >= 3) {! yearday = calmonthtab[jt->month - 3] + jt->monthday;! } else {! yearday = calmonthtab[jt->month + 9] + jt->monthday;! }! }! ! nt = TIMESDPERC((u_long)cyear);! while (resyear-- > 0)! nt += DAYSPERYEAR;! nt += (u_long) (yearday - 1);! ! nt = TIMES24(nt) + (u_long)jt->hour;! nt = TIMES60(nt) + (u_long)jt->minute;! nt = TIMES60(nt) + (u_long)jt->second; ! return nt + MAR1900; }--- 7,40 ---- #include "ntp_calendar.h" #include "ntp_stdlib.h" u_long! caltontp(register const struct calendar *jt) {! u_long ace_days; /* absolute Christian Era days */! u_long ntp_days;! int prior_years;! u_long ntp_time;! ! /*! * First convert today's date to absolute days past 12/1/1 BC! */! prior_years = jt->year-1;! ace_days = jt->yearday /* days this year */! +(DAYSPERYEAR*prior_years) /* plus days in previous years */! +(prior_years/4) /* plus prior years's leap days */! -(prior_years/100) /* minus leapless century years */! +(prior_years/400); /* plus leapful Gregorian yrs */! ! /*! * Subtract out 1/1/1900, the beginning of the NTP epoch! */! ntp_days = ace_days - DAY_NTP_STARTS;! ! /*! * Do the obvious:! */! ntp_time = ! ntp_days*SECSPERDAY+SECSPERMIN*(MINSPERHR*jt->hour + jt->minute); ! return ntp_time; }*** xntp3-5.90/xntpd/refclock_chu.c.~1~ Tue Jan 7 22:17:11 1997--- xntp3-5.90/xntpd/refclock_chu.c Sat May 3 15:17:32 1997****************** 483,489 **** * receive timestamp. If this doesn't work, mark the * date as bad and forget it. */! if (!clocktime(day, hour, minute, second, 0, rbufp->recv_time.l_ui, &pp->yearstart, (u_int32 *)&reftime)) { refclock_report(peer, CEVNT_BADDATE); return;--- 483,489 ---- * receive timestamp. If this doesn't work, mark the * date as bad and forget it. */! if (!clocktime(day, hour, minute, second, GMT, rbufp->recv_time.l_ui, &pp->yearstart, (u_int32 *)&reftime)) { refclock_report(peer, CEVNT_BADDATE); return;*** xntp3-5.90/xntpd/ntp_refclock.c.~1~ Sat May 3 16:30:08 1997--- xntp3-5.90/xntpd/ntp_refclock.c Sat May 3 16:30:03 1997****************** 861,868 ****--- 861,870 ---- printf("refclock_open: fd %d modem status %lx\n", fd, ltemp); #endif+ #if 0 if (ltemp & TIOCM_DSR) ttyp->c_cflag &= ~CLOCAL;+ #endif #endif /* TIOCMGET */ if (tcsetattr(fd, TCSANOW, ttyp) < 0) { msyslog(LOG_ERR,*** xntp3-5.90/xntpd/refclock_leitch.c.~1~ Tue Dec 17 16:30:46 1996--- xntp3-5.90/xntpd/refclock_leitch.c Sat May 3 15:17:31 1997****************** 478,484 **** if (!leitch_get_time(rbufp,leitch,1)) { } if (!clocktime(leitch->yearday,leitch->hour,leitch->minute,! leitch->second, 0, rbufp->recv_time.l_ui, &leitch->yearstart, &leitch->reftime1.l_ui)) { leitch->state = STATE_IDLE; break;--- 478,484 ---- if (!leitch_get_time(rbufp,leitch,1)) { } if (!clocktime(leitch->yearday,leitch->hour,leitch->minute,! leitch->second, GMT, rbufp->recv_time.l_ui, &leitch->yearstart, &leitch->reftime1.l_ui)) { leitch->state = STATE_IDLE; break;****************** 495,501 **** if (!leitch_get_time(rbufp,leitch,2)) { } if (!clocktime(leitch->yearday,leitch->hour,leitch->minute,! leitch->second, 0, rbufp->recv_time.l_ui, &leitch->yearstart, &leitch->reftime2.l_ui)) { leitch->state = STATE_IDLE; break;--- 495,501 ---- if (!leitch_get_time(rbufp,leitch,2)) { } if (!clocktime(leitch->yearday,leitch->hour,leitch->minute,! leitch->second, GMT, rbufp->recv_time.l_ui, &leitch->yearstart, &leitch->reftime2.l_ui)) { leitch->state = STATE_IDLE; break;****************** 512,518 **** if (!leitch_get_time(rbufp,leitch,3)) { } if (!clocktime(leitch->yearday,leitch->hour,leitch->minute,! leitch->second, 0, rbufp->recv_time.l_ui, &leitch->yearstart, &leitch->reftime3.l_ui)) { leitch->state = STATE_IDLE; break;--- 512,518 ---- if (!leitch_get_time(rbufp,leitch,3)) { } if (!clocktime(leitch->yearday,leitch->hour,leitch->minute,! leitch->second, GMT, rbufp->recv_time.l_ui, &leitch->yearstart, &leitch->reftime3.l_ui)) { leitch->state = STATE_IDLE; break;*** xntp3-5.90/xntpd/refclock_wwvb.c.~1~ Tue May 7 22:09:26 1996--- xntp3-5.90/xntpd/refclock_wwvb.c Sat May 3 18:03:33 1997****************** 11,21 ****--- 11,23 ---- #include <stdio.h> #include <ctype.h> #include <sys/time.h>+ #include <time.h> #include "ntpd.h" #include "ntp_io.h" #include "ntp_refclock.h" #include "ntp_stdlib.h"+ #include "ntp_calendar.h" /* * This driver supports the Spectracom Model 8170 and Netclock/2 WWVB****************** 101,106 ****--- 103,109 ---- #define NSAMPLES 3 /* stages of median filter */ #define LENWWVB0 22 /* format 0 timecode length */ #define LENWWVB2 24 /* format 2 timecode length */+ #define LENWWVB3 29 /* format 3 timecode length */ #define MONLIN 15 /* number of monitoring lines */ /******************* 160,165 ****--- 163,172 ---- int fd; char device[20]; + #ifdef DEBUG+ if (debug)+ printf("inside wwvb_start\n");+ #endif /* * Open serial port. Use CLK line discipline, if available. */****************** 169,175 **** #else if (!(fd = refclock_open(device, SPEED232, 0))) #endif /* TTYCLK */! return (0); /* * Allocate and initialize unit structure--- 176,188 ---- #else if (!(fd = refclock_open(device, SPEED232, 0))) #endif /* TTYCLK */! {! #ifdef DEBUG! if (debug)! printf ("refclock_open barfed\n");! #endif! return (0);! } /* * Allocate and initialize unit structure****************** 238,243 ****--- 251,260 ---- char qualchar; /* quality indicator */ char leapchar; /* leap indicator */ + #ifdef DEBUG+ if (debug)+ printf ("in wwvb_receive\n");+ #endif /* * Initialize pointers and read the timecode and timestamp */****************** 307,312 ****--- 324,359 ---- &leapchar) == 9) break; + case LENWWVB3:+ /*+ * Timecode format 3: "0003I yyyymmdd hhmmss+0000SL#"+ */+ {+ int month,day;+ int matched;+ + qualchar = ' ';+ matched =+ sscanf(pp->lastcode,"0003%c %4d%2d%2d %2d%2d%2d%*c%c",+ &syncchar,&pp->year,&month,&day,+ &pp->hour,&pp->minute,&pp->second,&leapchar);+ if (matched==8)+ {+ pp->msec = 0;+ pp->day = 31*(month - 1) + day;+ if (month > 2)+ {+ pp->day = pp->day - (4*month + 23)/10;+ if (is_leapyear(pp->year))+ pp->day++;+ }+ break;+ }+ #ifdef DEBUG+ if (debug)+ printf ("wwvb_receive: Surrender, Dorothy!\n");+ #endif+ } default: if (up->linect > 0)-- Robert L. McMillin | Not the voice of Syseca, Inc. | rlm@syseca-us.com Personal: rlm@helen.surfcty.com |爎lm@netcom.com
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -