home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume13 / modemcap / hangup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-01-31  |  1.0 KB  |  70 lines

  1. #include "modemcap.h"
  2. #ifdef    UNIX_S5
  3. #include <termio.h>
  4. #endif
  5. #ifdef    UNIX_V7
  6. #include <sgtty.h>
  7. #endif
  8.  
  9. extern    int    merrno;
  10.  
  11. hangup (fd)
  12. int    fd;
  13. {
  14. #ifdef    UNIX_S5
  15.     struct    termio    termio;
  16.     struct    termio    hupcl;
  17. #endif
  18. #ifdef    UNIX_V7
  19.     struct    sgttyb    termio;
  20.     struct    sgttyb    hupcl;
  21. #endif
  22.     if (HU == (char *) 0 && HC == 0) {
  23.         undial (fd);
  24.         return (0);
  25.     }
  26.     if (AT != (char *) 0) {
  27.         write (fd, AT, strlen (AT));
  28.         if (AD)
  29.             sleep (AD);
  30.     }
  31.     if (HU) {
  32.         if (CS)
  33.             write (fd, CS, strlen (CS));
  34.         write (fd, HU, strlen (HU));
  35.         if (CE)
  36.             write (fd, CE, strlen (CE));
  37.  
  38.         if (IS) {
  39.             write (fd, IS, strlen (IS));
  40.             if (ID)
  41.                 sleep (ID);
  42.         }
  43.         undial (fd);
  44.         return (1);
  45.     }
  46. #ifdef    UNIX_S5
  47.     ioctl (fd, TCGETA, &termio);
  48.     ioctl (fd, TCGETA, &hupcl);
  49.     
  50.     hupcl.c_cflag &= ~CBAUD;
  51.     hupcl.c_cflag |= HUPCL;
  52.  
  53.     ioctl (fd, TCSETA, &hupcl);
  54.     sleep (2);
  55.     ioctl (fd, TCSETA, &termio);
  56. #endif
  57. #ifdef    UNIX_V7
  58.     gtty (fd, &termio);
  59.     gtty (fd, &hupcl);
  60.  
  61.     hupcl.sg_ispeed = B0;
  62.     hupcl.sg_ospeed = B0;
  63.     stty (fd, &hupcl);
  64.     sleep (2);
  65.     stty (fd, &termio);
  66. #endif
  67.     undial (fd);
  68.     return (1);
  69. }
  70.