home *** CD-ROM | disk | FTP | other *** search
- From: turner@ksr.com (James M. Turner)
- Newsgroups: alt.sources,comp.protocols.time.ntp
- Subject: utcclock - Patch 01
- Message-ID: <887@ksr.com>
- Date: 8 Nov 90 14:48:01 GMT
-
-
- Here's the first patch for utcclock.c, which should allow the terminal
- handling for the modem to work with standard bsd systems. Thanks to
- Jim Rees for the changes.
-
- *** /tmp/,RCSt1a11912 Thu Nov 8 09:37:44 1990
- --- utcclock.c Thu Nov 8 09:37:05 1990
- ***************
- *** 49,54 ****
- --- 49,57 ----
- 617-895-9480
-
- $Log: utcclock.c,v $
- + * Revision 1.5 90/11/08 09:24:42 turner
- + * Patches from citi.umich.edu!rees (Jim Rees) to BSD-ify the terminal I/O.
- + *
- * Revision 1.4 90/11/05 16:27:56 turner
- * Added GPL notice
- *
- ***************
- *** 64,72 ****
- #include <fcntl.h>
- #include <stdio.h>
- #include <signal.h>
- ! #include <termio.h>
-
- ! char version[] = "$Id: utcclock.c,v 1.4 90/11/05 16:27:56 turner Exp $";
-
- /* PLEASE CHECK AND SET THE VALUES BELOW THIS LINE !!! */
-
- --- 67,75 ----
- #include <fcntl.h>
- #include <stdio.h>
- #include <signal.h>
- ! #include <sys/ioctl.h>
-
- ! char version[] = "$Id: utcclock.c,v 1.5 90/11/08 09:24:42 turner Exp $";
-
- /* PLEASE CHECK AND SET THE VALUES BELOW THIS LINE !!! */
-
- ***************
- *** 151,157 ****
- extern int optind;
- int fd1, flags;
- struct sigvec ovec;
- ! struct termio tty;
- char c, *OptLine, *OptNumber, option, device[50];
- struct tm tm;
- struct timeval del, del1;
- --- 154,160 ----
- extern int optind;
- int fd1, flags;
- struct sigvec ovec;
- ! struct sgttyb tty;
- char c, *OptLine, *OptNumber, option, device[50];
- struct tm tm;
- struct timeval del, del1;
- ***************
- *** 159,165 ****
- struct timeb tp;
- time_t i;
- long utc_time;
- ! int hh, mm, ss, dd, yy, dummy, milli[3], m, n = 0, r, k=0, des,
- yydd, year, month, OptSetme = 0, OptSpeed = BAUDRATE;
- char buffer[80];
-
- --- 162,168 ----
- struct timeb tp;
- time_t i;
- long utc_time;
- ! int hh, mm, ss, dd, yy, dummy, milli[3], m, n, r, k=0,
- yydd, year, month, OptSetme = 0, OptSpeed = BAUDRATE;
- char buffer[80];
-
- ***************
- *** 212,220 ****
- OptSpeed = B9600;
- break;
- case 19200:
- OptSpeed = B19200;
- break;
- ! otherwise:
- fprintf(stderr, "utcclock: Illegal baud rate\n");
- exit(2);
- }
- --- 215,227 ----
- OptSpeed = B9600;
- break;
- case 19200:
- + #ifdef B19200
- OptSpeed = B19200;
- + #else
- + OptSpeed = EXTA;
- + #endif
- break;
- ! default:
- fprintf(stderr, "utcclock: Illegal baud rate\n");
- exit(2);
- }
- ***************
- *** 250,260 ****
- exit(2);
- }
- timeout_reason = "setting line parameters";
- ! if (ioctl(des, TCGETA, &tty) == 0) {
- ! tty.c_cflag &= ~CBAUD;
- ! tty.c_cflag |= (CLOCAL | OptSpeed);
- }
- ! ioctl(des, TCSETA, &tty);
- fcntl(modem,F_SETFL,0); /* Turn off NDELAY. */
- /* Mom says we have to reopen for effect */
- fd1 = open(device, O_RDWR|O_EXCL);
- --- 257,271 ----
- exit(2);
- }
- timeout_reason = "setting line parameters";
- ! if (ioctl(modem, TIOCGETP, &tty) == -1) {
- ! perror("ioctl");
- ! exit(2);
- }
- ! tty.sg_ispeed = tty.sg_ospeed = OptSpeed;
- ! if (ioctl(modem, TIOCSETP, &tty) == -1) {
- ! perror("ioctl");
- ! exit(2);
- ! }
- fcntl(modem,F_SETFL,0); /* Turn off NDELAY. */
- /* Mom says we have to reopen for effect */
- fd1 = open(device, O_RDWR|O_EXCL);
- ***************
- *** 263,269 ****
-
- /* dial utc */
- timeout_reason = "dialing";
- ! ioctl(modem, TCFLSH, 0); /* Flush any old characters */
- sprintf(buffer, DIALSTRING, OptNumber); /* Change for non-hayes */
- write(modem, buffer, strlen(buffer));
-
- --- 274,280 ----
-
- /* dial utc */
- timeout_reason = "dialing";
- ! ioctl(modem, TIOCFLUSH, 0); /* Flush any old characters */
- sprintf(buffer, DIALSTRING, OptNumber); /* Change for non-hayes */
- write(modem, buffer, strlen(buffer));
-
- --
- Name: James M. Turner * Great Moments in Aviation #21: While on a
- Company: Kendall Square Research * NDB approach into Hanscom, pilot Ted Hertz
- Email: turner@ksr.com, ksr!turner * accidently tunes WEEI on his NAV instead
- Phone: (617) 895-9400 * of the LOM, and lands on top of the Pru.
-