home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / TELECOM / rzsz_3_36_3_src.lzh / rbsb.c < prev    next >
Text File  |  1996-01-28  |  15KB  |  762 lines

  1. /*
  2.  *    V7/BSD HACKERS:  SEE NOTES UNDER mode(2) !!!
  3.  *
  4.  *   This file is #included so the main file can set parameters such as HOWMANY.
  5.  *   See the main files (rz.c/sz.c) for compile instructions.
  6.  */
  7.  
  8. /* Note, this removed since "Copyrz" is also defined in the output code */
  9. #ifndef m6809
  10. char *Copyr = "Copyright 1994 Omen Technology Inc All Rights Reserved";
  11. #endif
  12. /* as the same string. This copy only wastes space in the module. GH */
  13.  
  14. #ifdef OS9
  15. #include <stdio.h>
  16. #include <sgstat.h>
  17. #include <errno.h>
  18. #include "os9.h"
  19. /* from rz.c/sz.c */
  20. extern unsigned Baudrate;
  21. extern unsigned Effbaud;
  22. extern int Zmodem;
  23. extern int errors;
  24. extern struct sgbuf sttyold;
  25. #endif
  26.  
  27. #ifdef V7
  28. #include <sys/types.h>
  29. #include <sys/stat.h>
  30. #define STAT
  31. #include <sgtty.h>
  32. #define OS "V7/BSD"
  33. char *getenv(), *ttyname();
  34. #ifdef LLITOUT
  35. long Locmode;        /* Saved "local mode" for 4.x BSD "new driver" */
  36. long Locbit = LLITOUT;    /* Bit SUPPOSED to disable output translations */
  37. #include <strings.h>
  38. #endif
  39. #endif
  40.  
  41. #ifdef USG
  42. #include <sys/types.h>
  43. #include <sys/stat.h>
  44. #define STAT
  45. #include <termio.h>
  46. #define OS "SYS III/V"
  47. #define MODE2OK
  48. #include <string.h>
  49. #ifndef OLD
  50. #include <stdlib.h>
  51. #endif
  52. #include <unistd.h>
  53. #endif
  54.  
  55. #ifdef POSIX
  56. #define USG
  57. #include <sys/types.h>
  58. #include <sys/stat.h>
  59. #include <sys/ioctl.h>
  60. #define STAT
  61. #include <termios.h>
  62. #define OS "POSIX"
  63. #include <string.h>
  64. #include <stdlib.h>
  65. #include <unistd.h>
  66. #ifndef READCHECK
  67. #ifndef FIONREAD
  68. #define SV
  69. #endif
  70. #endif
  71. #endif
  72.  
  73. #ifdef OLD
  74. char *ttyname();
  75. char *getenv();
  76. #define time_t long
  77. #endif
  78.  
  79.  
  80. #ifdef T6K
  81. #include <sys/ioctl.h>        /* JPRadley: for the Tandy 6000 */
  82. #endif
  83.  
  84. #include <setjmp.h>
  85.  
  86. /* This blows up m6809 compiler
  87. #if HOWMANY  > 255
  88. Howmany must be 255 or less
  89. #endif
  90. */
  91.  
  92.  /*
  93.  *  Some systems (Venix, Coherent, Regulus) may not support tty raw mode
  94.  *  read(2) the same way as Unix. ONEREAD must be defined to force one
  95.  *  character reads for these systems. Added 7-01-84 CAF
  96.  */
  97.  
  98. #ifndef OS9
  99. #define sendline(c) putc(c & 0377, Ttystream)
  100. #define xsendline(c) putc(c, Ttystream)
  101. #endif
  102.  
  103. #ifdef OS9
  104. char Nametty[32]; /* "/t2\n" doesn't need a whole page! was 256. GH */
  105. int lclerr;
  106. #else
  107. char *Nametty;
  108. #endif
  109.  
  110. FILE *Ttystream;
  111. int Tty;
  112. char linbuf[HOWMANY];
  113. char xXbuf[BUFSIZ];
  114. int Lleft=0;        /* number of characters in linbuf */
  115. jmp_buf tohere;        /* For the interrupt on RX timeout */
  116. #ifdef ONEREAD
  117. /* Sorry, Regulus and some others don't work right in raw mode! */
  118. int Readnum = 1;    /* Number of bytes to ask for in read() from modem */
  119. #else
  120. int Readnum = HOWMANY;    /* Number of bytes to ask for in read() from modem */
  121. #endif
  122. int Verbose=0;
  123.  
  124.  
  125. /*
  126.  *  The following uses an external rdchk() routine if available,
  127.  *  otherwise defines the function for BSD or fakes it for SYSV.
  128.  */
  129.  
  130. #ifdef OS9
  131. rdchk(f)
  132. {
  133.     return((_gs_rdy(f) > 0) ? 1 : 0);
  134. }
  135. #else /* !OS9 */
  136. #ifndef READCHECK
  137. #ifdef FIONREAD
  138. #define READCHECK
  139. /*
  140.  *  Return non 0 iff something to read from io descriptor f
  141.  */
  142. rdchk(f)
  143. {
  144.     static long lf;
  145.  
  146.     ioctl(f, FIONREAD, &lf);
  147.     return ((int) lf);
  148. }
  149.  
  150. #else        /* FIONREAD */
  151.  
  152. #ifdef SV
  153. #define READCHECK
  154. #include <fcntl.h>
  155.  
  156. int checked = 0;
  157. /*
  158.  * Nonblocking I/O is a bit different in System V, Release 2
  159.  *  Note: this rdchk vsn throws away a byte, OK for ZMODEM
  160.  *  sender because protocol design anticipates this problem.
  161.  */
  162. #define EATSIT
  163. rdchk(f)
  164. {
  165.     int lf, savestat;
  166.     static char bchecked;
  167.  
  168.     savestat = fcntl(f, F_GETFL) ;
  169. #ifdef O_NDELAY
  170.     fcntl(f, F_SETFL, savestat | O_NDELAY) ;
  171. #else
  172.     fcntl(f, F_SETFL, savestat | O_NONBLOCK) ;
  173. #endif
  174.     lf = read(f, &bchecked, 1) ;
  175.     fcntl(f, F_SETFL, savestat) ;
  176.     checked = bchecked & 0377;    /* force unsigned byte */
  177.     return(lf) ;
  178. }
  179. #endif
  180. #endif
  181. #endif
  182. #endif /* !OS9 */
  183.  
  184.  
  185. #ifdef OS9
  186. #ifdef m6809
  187. int speeds[] = {
  188.     110,
  189.     300,
  190.     600,
  191.     1200,
  192.     2400,
  193.     4800,
  194.     9600,
  195.     19200,
  196.     38400,
  197.     57600,
  198.     76800,
  199.     115200,
  200.     0,0,0,
  201.     31250,
  202.     0
  203. };
  204. #else /* !m6809 */
  205. int speeds[] = {
  206.     50,
  207.     75,
  208.     110,
  209.     134,
  210.     150,
  211.     300,
  212.     600,
  213.     1200,
  214.     1800,
  215.     2400,
  216.     3000,
  217.     3600,
  218.     4800,
  219.     7200,
  220.     9600,
  221.     19200,
  222.     38400,
  223.     0
  224. };
  225. #endif /* !m6809 */
  226. #else /* !OS9 */
  227. struct {
  228.     unsigned baudr;
  229.     int speedcode;
  230. } speeds[] = {
  231.     110,    B110,
  232. #ifdef B150
  233.     150,    B150,
  234. #endif
  235.     300,    B300,
  236.     600,    B600,
  237.     1200,    B1200,
  238.     2400,    B2400,
  239.     4800,    B4800,
  240.     9600,    B9600,
  241. #ifdef B19200
  242.     19200,    B19200,
  243. #endif
  244. #ifdef EXTA
  245.     19200,    EXTA,
  246. #endif
  247. #ifdef B38400
  248.     38400,    B38400,
  249. #endif
  250. #ifdef EXTB
  251.     38400,    EXTB,
  252. #endif
  253.     0,    0
  254. };
  255. static unsigned
  256. getspeed(code)
  257. {
  258.     register n;
  259.  
  260.     for (n=0; speeds[n].baudr; ++n)
  261.         if (speeds[n].speedcode == code)
  262.             return speeds[n].baudr;
  263.     if (code > 49)
  264.         return ((unsigned)code);
  265.     return 1;    /* Assume fifo if ioctl failed */
  266. }
  267. #endif /* !OS9 */
  268.  
  269.  
  270. #ifdef OS9
  271. struct sgbuf oldtty, tty;
  272. #else /* !OS9 */
  273. #ifdef ICANON
  274. #ifdef POSIX
  275. struct termios oldtty, tty;
  276. #else
  277. struct termio oldtty, tty;
  278. #endif
  279. #else
  280. struct sgttyb oldtty, tty;
  281. struct tchars oldtch, tch;
  282. #endif
  283. #endif /* !OS9 */
  284.  
  285. /*
  286.  * mode(n)
  287.  *  3: save old tty stat, set raw mode with flow control
  288.  *  2: set XON/XOFF for sb/sz with ZMODEM or YMODEM-g
  289.  *  1: save old tty stat, set raw mode 
  290.  *  0: restore original tty mode
  291.  */
  292. mode(n)
  293. {
  294.     static did0 = FALSE;
  295.  
  296.     vfile("mode:%d", n);
  297.     switch(n) {
  298. #ifdef OS9
  299.     case 1:
  300.     case 2:
  301.     case 3:
  302.         if(!did0)
  303.             _gs_opt(Tty, &oldtty);
  304. #ifdef m6809
  305.         _strass(&tty, &oldtty, sizeof(struct sgbuf));
  306. #else
  307.         tty = oldtty;
  308. #endif
  309.                 tty.sg_case             =
  310.                 tty.sg_backsp           =
  311.                 tty.sg_delete           =
  312.                 tty.sg_echo             =
  313.                 tty.sg_alf              =
  314.                 tty.sg_nulls            =
  315.                 tty.sg_pause            =
  316.                 tty.sg_page             =
  317.                 tty.sg_bspch            =
  318.                 tty.sg_dlnch            =
  319.                 tty.sg_eorch            =
  320.                 tty.sg_eofch            =
  321.                 tty.sg_rlnch            =
  322.                 tty.sg_dulnch           =
  323.                 tty.sg_psch             =
  324.                 tty.sg_kbach            =
  325.                 tty.sg_bsech            =
  326.                 tty.sg_bellch           =0;
  327.         if (n == 2)
  328.             tty.sg_kbich    = Zmodem ? 0 : 030;
  329.         else
  330.             tty.sg_kbich    =0;
  331.                 tty.sg_parity           &= 0x9f;    /* No parity */
  332. #ifdef m6809
  333.         if(n == 3)
  334.                     tty.sg_parity   |= 0x02;    /*Set hardware flow control */
  335. #else
  336.         if(n == 3)
  337.                     tty.sg_parity   |= 0x80;    /*Set hardware flow control */
  338. #endif
  339.                 tty.sg_baud             &= 0x1f;    /* 8 bits, 1 stop */
  340. #ifdef MODE2OK
  341.         if (n == 2)
  342.         {
  343.             tty.sg_xon = 11;
  344.                     tty.sg_xoff = 13;
  345.         }
  346.         else
  347. #endif
  348.         {
  349.             tty.sg_xon = 0;
  350.             tty.sg_xoff = 0;
  351.         }
  352.  
  353.  
  354.                 _ss_opt(Tty, &tty);
  355.                 _ss_opt(fileno(Ttystream), &tty);
  356.                 did0 = TRUE;
  357. #ifdef m6809
  358.                 Effbaud = Baudrate = speeds[tty.sg_baud & 0x0F];
  359. #else
  360.                 Effbaud = Baudrate = speeds[tty.sg_baud & 0x1F];
  361. #endif
  362.         vfile("Baudrate = %d\n", Baudrate);
  363.                 return( OK );
  364. #endif /* OS9 */
  365.  
  366. #ifdef USG
  367.     case 2:        /* Un-raw mode used by sz, sb when -g detected */
  368. #ifdef POSIX
  369.         if(!did0)
  370.             (void) tcgetattr(Tty, &oldtty);
  371. #else
  372.         if(!did0)
  373.             (void) ioctl(Tty, TCGETA, &oldtty);
  374. #endif
  375.         tty = oldtty;
  376.  
  377.         tty.c_iflag = BRKINT|IXON;
  378.  
  379.         tty.c_oflag = 0;    /* Transparent output */
  380.  
  381.         tty.c_cflag &= ~(PARENB|CSIZE);        /* Disable parity */
  382.         tty.c_cflag |= (CREAD|CS8);    /* Set character size = 8 */
  383.  
  384.  
  385. #ifdef READCHECK
  386.         tty.c_lflag = Zmodem ? 0 : ISIG;
  387.         tty.c_cc[VINTR] = Zmodem ? -1:030;    /* Interrupt char */
  388. #else
  389.         tty.c_lflag = ISIG;
  390.         tty.c_cc[VINTR] = Zmodem ? 03:030;    /* Interrupt char */
  391. #endif
  392.         tty.c_cc[VQUIT] = -1;            /* Quit char */
  393. #ifdef NFGVMIN
  394.         tty.c_cc[VMIN] = 1;
  395. #else
  396.         tty.c_cc[VMIN] = 3;     /* This many chars satisfies reads */
  397. #endif
  398.         tty.c_cc[VTIME] = 1;    /* or in this many tenths of seconds */
  399.  
  400. #ifdef POSIX
  401.         (void) tcsetattr(Tty, TCSADRAIN, &tty);
  402. #else
  403.         (void) ioctl(Tty, TCSETAW, &tty);
  404. #endif
  405.         did0 = TRUE;
  406.         return OK;
  407.     case 1:
  408.     case 3:
  409. #ifdef POSIX
  410.         if(!did0)
  411.             (void) tcgetattr(Tty, &oldtty);
  412. #else
  413.         if(!did0)
  414.             (void) ioctl(Tty, TCGETA, &oldtty);
  415. #endif
  416.         tty = oldtty;
  417.  
  418.         tty.c_iflag = n==3 ? (IXON|IXOFF) : IXOFF;
  419.  
  420.         tty.c_lflag = 0;
  421.  
  422.         tty.c_oflag = 0;
  423.  
  424.         tty.c_cflag &= ~(CSIZE|PARENB);    /* disable parity */
  425.         tty.c_cflag |= CS8;    /* Set character size = 8 */
  426. #ifdef NFGVMIN
  427.         tty.c_cc[VMIN] = 1; /* This many chars satisfies reads */
  428. #else
  429.         tty.c_cc[VMIN] = HOWMANY; /* This many chars satisfies reads */
  430. #endif
  431.         tty.c_cc[VTIME] = 1;    /* or in this many tenths of seconds */
  432. #ifdef POSIX
  433.         (void) tcsetattr(Tty, TCSADRAIN, &tty);
  434. #else
  435.         (void) ioctl(Tty, TCSETAW, &tty);
  436. #endif
  437.         did0 = TRUE;
  438. #ifdef POSIX
  439.         Effbaud = Baudrate = getspeed(cfgetospeed(&tty));
  440. #else
  441.         Effbaud = Baudrate = getspeed(tty.c_cflag & CBAUD);
  442. #endif
  443.         vfile("Baudrate = %u\n", Baudrate);
  444.         return OK;
  445. #endif
  446. #ifdef V7
  447.     /*
  448.      *  NOTE: this should transmit all 8 bits and at the same time
  449.      *   respond to XOFF/XON flow control.  If no FIONREAD or other
  450.      *   rdchk() alternative, also must respond to INTRRUPT char
  451.      *   This doesn't work with V7.  It should work with LLITOUT,
  452.      *   but LLITOUT was broken on the machine I tried it on.
  453.      */
  454.     case 2:        /* Un-raw mode used by sz, sb when -g detected */
  455.         if(!did0) {
  456.             ioctl(Tty, TIOCEXCL, 0);
  457.             ioctl(Tty, TIOCGETP, &oldtty);
  458.             ioctl(Tty, TIOCGETC, &oldtch);
  459. #ifdef LLITOUT
  460.             ioctl(Tty, TIOCLGET, &Locmode);
  461. #endif
  462.         }
  463.         tty = oldtty;
  464.         tch = oldtch;
  465. #ifdef READCHECK
  466.         tch.t_intrc = Zmodem ? -1:030;    /* Interrupt char */
  467. #else
  468.         tch.t_intrc = Zmodem ? 03:030;    /* Interrupt char */
  469. #endif
  470.         tty.sg_flags |= (ODDP|EVENP|CBREAK);
  471.         tty.sg_flags &= ~(ALLDELAY|CRMOD|ECHO|LCASE);
  472.         ioctl(Tty, TIOCSETP, &tty);
  473.         ioctl(Tty, TIOCSETC, &tch);
  474. #ifdef LLITOUT
  475.         ioctl(Tty, TIOCLBIS, &Locbit);
  476. #else
  477.         bibi(99);    /* un-raw doesn't work w/o lit out */
  478. #endif
  479.         did0 = TRUE;
  480.         return OK;
  481.     case 1:
  482.     case 3:
  483.         if(!did0) {
  484.             ioctl(Tty, TIOCEXCL, 0);
  485.             ioctl(Tty, TIOCGETP, &oldtty);
  486.             ioctl(Tty, TIOCGETC, &oldtch);
  487. #ifdef LLITOUT
  488.             ioctl(Tty, TIOCLGET, &Locmode);
  489. #endif
  490.         }
  491.         tty = oldtty;
  492.         tty.sg_flags |= (RAW|TANDEM);
  493.         tty.sg_flags &= ~ECHO;
  494.         ioctl(Tty, TIOCSETP, &tty);
  495.         did0 = TRUE;
  496.         Effbaud = Baudrate = getspeed(tty.sg_ospeed);
  497.         return OK;
  498. #endif
  499.     case 0:
  500.         if(!did0)
  501.             return ERROR;
  502. #ifdef OS9
  503.         fflush(Ttystream);
  504.         purgeline();
  505.         _ss_opt(Tty, &oldtty);
  506.         _ss_opt(fileno(Ttystream), &oldtty);
  507. #endif /* OS9 */
  508. #ifdef USG
  509. #ifdef POSIX
  510.         (void) tcdrain(Tty);    /* Wait for output to drain */
  511.         (void) tcflush(Tty, TCIFLUSH);    /* Flush input queue */
  512.         (void) tcsetattr(Tty, TCSADRAIN, &oldtty);    /* Restore */
  513.         (void) tcflow(Tty, TCOON);    /* Restart output */
  514. #else
  515.         (void) ioctl(Tty, TCSBRK, 1);    /* Wait for output to drain */
  516.         (void) ioctl(Tty, TCFLSH, 1);    /* Flush input queue */
  517.         (void) ioctl(Tty, TCSETAW, &oldtty);    /* Restore modes */
  518.         (void) ioctl(Tty, TCXONC,1);    /* Restart output */
  519. #endif
  520. #endif
  521. #ifdef V7
  522.         ioctl(Tty, TIOCSETP, &oldtty);
  523.         ioctl(Tty, TIOCSETC, &oldtch);
  524.         ioctl(Tty, TIOCNXCL, 0);
  525. #ifdef LLITOUT
  526.         ioctl(Tty, TIOCLSET, &Locmode);
  527. #endif
  528. #endif
  529.  
  530.         return OK;
  531.     default:
  532.         return ERROR;
  533.     }
  534. }
  535.  
  536. sendbrk()
  537. {
  538. #ifdef OS9
  539.     _ss_sbreak(fileno(Ttystream));
  540. #endif /* OS9 */
  541. #ifdef V7
  542. #ifdef TIOCSBRK
  543. #define CANBREAK
  544.     sleep(1);
  545.     ioctl(Tty, TIOCSBRK, 0);
  546.     sleep(1);
  547.     ioctl(Tty, TIOCCBRK, 0);
  548. #endif
  549. #endif
  550. #ifdef USG
  551. #define CANBREAK
  552. #ifdef POSIX
  553.     tcsendbreak(Tty, 200);
  554. #else
  555.     ioctl(Tty, TCSBRK, 0);
  556. #endif
  557. #endif
  558. }
  559.  
  560. /* Initialize tty device for serial file xfer */
  561. inittty()
  562. {
  563. #ifdef OS9
  564.     Nametty[0] = '/';
  565.     lclerr=_gs_devn(0, Nametty+1); /* returns last char with msbit set! */
  566.     if (lclerr==-1) /* error by the function */
  567.         exit(216);
  568.  
  569. /* no path for vfile yet! */ /* vfile("Initializing Tty = %s", Nametty); */
  570.  
  571.     Tty = open(Nametty, 3);
  572.     if (Tty < 0)
  573.     {
  574.         fprintf(stderr, " - Errno #%d\n");
  575.         _ss_opt(fileno(stderr), &sttyold);
  576.         exit(2);
  577.     }
  578. #else /* !OS9 */
  579.     if ((Nametty = ttyname(0)) && *Nametty) {
  580.         Tty = open(Nametty, 2);
  581.     } else {
  582.         Tty = open(Nametty = "/dev/tty", 2);
  583.     }
  584.  
  585.     if (Tty <= 0) {
  586.         perror(Nametty);  exit(2);
  587.     }
  588. #endif /* !OS9 */
  589.     Ttystream = fdopen(Tty, "r+");
  590. #ifdef OS9
  591.     Ttystream->_flag &= ~_SCF;
  592.     Ttystream->_flag |= _RBF;
  593. #endif
  594. }
  595.  
  596. /*
  597. flushmoc()
  598. {
  599.     fflush(Ttystream);
  600. }
  601. */
  602. flushmo()
  603. {
  604.     fflush(Ttystream);
  605. }
  606.  
  607. /*
  608.  * This version of readline is reasoably well suited for
  609.  * reading many characters.
  610.  *
  611.  * timeout is in tenths of seconds
  612.  */
  613. void
  614. alrm(c)
  615. {
  616.     longjmp(tohere, -1);
  617. }
  618. readline(timeout)
  619. int timeout;
  620. {
  621.     register n;
  622.     static char *cdq;    /* pointer for removing chars from linbuf */
  623.  
  624.     if (--Lleft >= 0)
  625.     {
  626.         if (Verbose > 8)
  627.         {
  628.             fprintf(stderr, "%02x ", *cdq&0377);
  629.         }
  630.         return (*cdq++ & 0377);
  631.     }
  632.     n = timeout/10;
  633.     if (n < 2)
  634.         n = 2;
  635.     if (Verbose > 5)
  636.         fprintf(stderr, "Calling read: alarm=%d  Readnum=%d ",
  637.           n, Readnum);
  638.     if (setjmp(tohere)) {
  639. #ifdef TIOCFLUSH
  640. /*        ioctl(Tty, TIOCFLUSH, 0); */
  641. #endif
  642.         Lleft = 0;
  643.         if (Verbose>1)
  644.             fprintf(stderr, "Readline:TIMEOUT\n");
  645.         return TIMEOUT;
  646.     }
  647. #ifdef OS9
  648.     errno = 0;
  649.     Lleft=alarmread(Tty, cdq=linbuf, Readnum, alrm, n);
  650. #else
  651.     signal(SIGALRM, alrm); alarm(n);
  652.     errno = 0;
  653.     Lleft=read(Tty, cdq=linbuf, Readnum);
  654.     alarm(0);
  655. #endif
  656.     if (Verbose > 5) {
  657.         fprintf(stderr, "Read returned %d bytes errno=%d\n",
  658.           Lleft, errno);
  659.     }
  660. #ifdef OS9         /* handle read error condition */
  661.     if (Lleft < 0)
  662.         return ERROR;
  663. #endif
  664.     if (Lleft < 1)
  665.         return TIMEOUT;
  666.  
  667. /* logger prints Lleft copies of first char in buffer, needs fixed GH */
  668. #ifdef DEBUGZ /* this works, but I'm seeing duplicate data from elsewhere */
  669.     if (Verbose > 8) /* soooo, ... */
  670.     { /* the following line was (n=Lleft;--n>=0;) GH */
  671.         for (n = 0; n++ <= Lleft; ) /* part of fix GH */
  672.         { /* the following line was "*cdq&0377" GH */
  673.             fprintf(stderr, "%02x ", *(cdq+n)&0377);/*remainder*/
  674.         }
  675.         fprintf(stderr, "\n");
  676.     }
  677. #endif
  678.     --Lleft;
  679.     return (*cdq++ & 0377);
  680. }
  681.  
  682.  
  683.  
  684. /*
  685.  * Purge the modem input queue of all characters
  686.  */
  687. purgeline()
  688. {
  689. #ifdef OS9
  690.     char ch[256];
  691.     int cnt;
  692. #endif
  693.  
  694.     Lleft = 0;
  695. #ifdef OS9
  696.     while ((cnt = _gs_rdy(Tty)) > 0)
  697.         read(Tty, ch, min(cnt, 255));
  698. #else /* !OS9 */
  699. #ifdef USG
  700. #ifdef POSIX
  701.     tcflush(Tty, 0);
  702. #else
  703.     ioctl(Tty, TCFLSH, 0);
  704. #endif
  705. #else
  706.     lseek(Tty, 0L, 2);
  707. #endif
  708. #endif /* !OS9 */
  709. }
  710.  
  711.  
  712. /* send cancel string to get the other end to shut up */
  713. canit()
  714. {
  715.     static char canistr[] = {
  716.      24,24,24,24,24,24,24,24,24,24,8,8,8,8,8,8,8,8,8,8,0
  717.     };
  718.  
  719.     zmputs(canistr);
  720.     Lleft=0;    /* Do read next time ... */
  721. }
  722.  
  723. /*
  724.  * Send a string to the modem, processing for \336 (sleep 1 sec)
  725.  *   and \335 (break signal)
  726.  */
  727. zmputs(s)
  728. char *s;
  729. {
  730.     register c;
  731.  
  732.     while (*s) {
  733.         switch (c = *s++) {
  734.         case '\336':
  735.             sleep(1); continue;
  736.         case '\335':
  737.             sendbrk(); continue;
  738.         default:
  739.             sendline(c);
  740.         }
  741.     }
  742.     flushmo();
  743. }
  744.  
  745.  
  746. /* VARARGS1 */
  747. vfile(f, a, b, c, d)
  748. char *f;
  749. #ifndef m6809
  750. long a, b, c, d;
  751. #else
  752. int a, b, c, d;
  753. #endif
  754. {
  755.     if (Verbose > 2) {
  756.         fprintf(stderr, f, a, b, c, d);
  757.         fprintf(stderr, "\n");
  758.     }
  759. }
  760.  
  761. /* End of rbsb.c */
  762.