home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2039 < prev    next >
Internet Message Format  |  1990-12-28  |  4KB

  1. From: turner@ksr.com (James M. Turner)
  2. Newsgroups: alt.sources,comp.protocols.time.ntp
  3. Subject: utcclock - Patch 01
  4. Message-ID: <887@ksr.com>
  5. Date: 8 Nov 90 14:48:01 GMT
  6.  
  7.  
  8. Here's the first patch for utcclock.c, which should allow the terminal
  9. handling for the modem to work with standard bsd systems.  Thanks to
  10. Jim Rees for the changes.
  11.  
  12. *** /tmp/,RCSt1a11912    Thu Nov  8 09:37:44 1990
  13. --- utcclock.c    Thu Nov  8 09:37:05 1990
  14. ***************
  15. *** 49,54 ****
  16. --- 49,57 ----
  17.      617-895-9480
  18.   
  19.      $Log:    utcclock.c,v $
  20. +  * Revision 1.5  90/11/08  09:24:42  turner
  21. +  * Patches from citi.umich.edu!rees (Jim Rees) to BSD-ify the terminal I/O.
  22. +  * 
  23.    * Revision 1.4  90/11/05  16:27:56  turner
  24.    * Added GPL notice
  25.    * 
  26. ***************
  27. *** 64,72 ****
  28.   #include <fcntl.h>
  29.   #include <stdio.h>
  30.   #include <signal.h>
  31. ! #include <termio.h>
  32.   
  33. ! char version[] = "$Id: utcclock.c,v 1.4 90/11/05 16:27:56 turner Exp $";
  34.   
  35.   /* PLEASE CHECK AND SET THE VALUES BELOW THIS LINE !!! */
  36.   
  37. --- 67,75 ----
  38.   #include <fcntl.h>
  39.   #include <stdio.h>
  40.   #include <signal.h>
  41. ! #include <sys/ioctl.h>
  42.   
  43. ! char version[] = "$Id: utcclock.c,v 1.5 90/11/08 09:24:42 turner Exp $";
  44.   
  45.   /* PLEASE CHECK AND SET THE VALUES BELOW THIS LINE !!! */
  46.   
  47. ***************
  48. *** 151,157 ****
  49.     extern int optind;
  50.     int fd1, flags;
  51.     struct sigvec ovec;
  52. !   struct termio tty;
  53.     char c, *OptLine, *OptNumber, option, device[50];
  54.     struct tm tm;
  55.     struct timeval del, del1;
  56. --- 154,160 ----
  57.     extern int optind;
  58.     int fd1, flags;
  59.     struct sigvec ovec;
  60. !   struct sgttyb tty;
  61.     char c, *OptLine, *OptNumber, option, device[50];
  62.     struct tm tm;
  63.     struct timeval del, del1;
  64. ***************
  65. *** 159,165 ****
  66.     struct timeb tp;
  67.     time_t i;
  68.     long utc_time;
  69. !   int hh, mm, ss, dd, yy, dummy, milli[3], m, n = 0, r, k=0, des,
  70.         yydd, year, month, OptSetme = 0, OptSpeed = BAUDRATE;
  71.     char buffer[80];
  72.     
  73. --- 162,168 ----
  74.     struct timeb tp;
  75.     time_t i;
  76.     long utc_time;
  77. !   int hh, mm, ss, dd, yy, dummy, milli[3], m, n, r, k=0,
  78.         yydd, year, month, OptSetme = 0, OptSpeed = BAUDRATE;
  79.     char buffer[80];
  80.     
  81. ***************
  82. *** 212,220 ****
  83.       OptSpeed = B9600;
  84.       break;
  85.         case 19200:
  86.       OptSpeed = B19200;
  87.       break;
  88. !       otherwise:
  89.       fprintf(stderr, "utcclock: Illegal baud rate\n");
  90.       exit(2);
  91.         }
  92. --- 215,227 ----
  93.       OptSpeed = B9600;
  94.       break;
  95.         case 19200:
  96. + #ifdef B19200
  97.       OptSpeed = B19200;
  98. + #else
  99. +     OptSpeed = EXTA;
  100. + #endif
  101.       break;
  102. !       default:
  103.       fprintf(stderr, "utcclock: Illegal baud rate\n");
  104.       exit(2);
  105.         }
  106. ***************
  107. *** 250,260 ****
  108.       exit(2);
  109.     }
  110.     timeout_reason = "setting line parameters";
  111. !   if (ioctl(des, TCGETA, &tty) == 0) {
  112. !     tty.c_cflag &= ~CBAUD;
  113. !     tty.c_cflag |= (CLOCAL | OptSpeed);
  114.     }
  115. !   ioctl(des, TCSETA, &tty);
  116.     fcntl(modem,F_SETFL,0);    /* Turn off NDELAY. */
  117.     /* Mom says we have to reopen for effect */
  118.     fd1 = open(device, O_RDWR|O_EXCL);
  119. --- 257,271 ----
  120.       exit(2);
  121.     }
  122.     timeout_reason = "setting line parameters";
  123. !   if (ioctl(modem, TIOCGETP, &tty) == -1) {
  124. !     perror("ioctl");
  125. !     exit(2);
  126.     }
  127. !   tty.sg_ispeed = tty.sg_ospeed = OptSpeed;
  128. !   if (ioctl(modem, TIOCSETP, &tty) == -1) {
  129. !     perror("ioctl");
  130. !     exit(2);
  131. !   }
  132.     fcntl(modem,F_SETFL,0);    /* Turn off NDELAY. */
  133.     /* Mom says we have to reopen for effect */
  134.     fd1 = open(device, O_RDWR|O_EXCL);
  135. ***************
  136. *** 263,269 ****
  137.   
  138.     /* dial utc */
  139.     timeout_reason = "dialing";
  140. !   ioctl(modem, TCFLSH, 0);    /* Flush any old characters */
  141.     sprintf(buffer, DIALSTRING, OptNumber); /* Change for non-hayes */
  142.     write(modem, buffer, strlen(buffer));
  143.   
  144. --- 274,280 ----
  145.   
  146.     /* dial utc */
  147.     timeout_reason = "dialing";
  148. !   ioctl(modem, TIOCFLUSH, 0);    /* Flush any old characters */
  149.     sprintf(buffer, DIALSTRING, OptNumber); /* Change for non-hayes */
  150.     write(modem, buffer, strlen(buffer));
  151.   
  152. -- 
  153. Name:    James M. Turner            * Great Moments in Aviation #21: While on a
  154. Company: Kendall Square Research    * NDB approach into Hanscom, pilot Ted Hertz
  155. Email:   turner@ksr.com, ksr!turner * accidently tunes WEEI on his NAV instead
  156. Phone:   (617) 895-9400             * of the LOM, and lands on top of the Pru.
  157.