home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / GRLF-C-1.ZIP / GCOMM / ASICLEAR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-14  |  2.2 KB  |  75 lines

  1. /* asiclear.c
  2. *
  3. * The Greenleaf Comm Library
  4. *
  5. * Copyright (C) 1985-1990 Greenleaf Software Inc.  All Rights Reserved.
  6. *
  7. *  int asiclear( port, option)
  8. *  int port;            - Port 0..MAX_PORT-1
  9. *  int option;          - ASIN, ASOUT, or ASINOUT
  10. *
  11. * DESCRIPTION
  12. *  clear specified buffer of any characters, ASIN = clear
  13. *  receive buffer, ASOUT = clear transmit buffer,
  14. *  ASINOUT = clear transmit & receive buffers.  Also sets buffer
  15. *  empty bits and clears the alert bit, and clears receiver overflow bit.
  16. *  Clears receiver error flag, clears modem status change flag.
  17. *
  18. * SIDE EFFECTS
  19. *  Any character(s) in buffer(s) will be lost, alert and other flags
  20. *  lost if set.
  21. *
  22. * RETURNS
  23. *
  24. *       Value           Meaning
  25. *     -------          --------
  26. *       ASSUCCESS       (no error)
  27. *       ASINVPORT       Requested port is out of range
  28. *       ASNOTSETUP      Requested port not setup with asifirst()
  29. *       ASINVPAR        Invalid parameter
  30. *
  31. * MODIFICATIONS
  32. *  10-25-85     ""
  33. *               Modified for release 2.0
  34. */
  35. #include <stdio.h>
  36. #include "gf.h"
  37. #include "asiports.h"
  38.  
  39.  
  40. int GF_CONV asiclear(port,option)
  41. int port,option;
  42. {
  43.  
  44.         struct PORT_TABLE *p;
  45.  
  46.         if((p=_aschkcnl(port))==NULL)
  47.                 return(_aserror);
  48.         switch(option) {
  49.         case ASINOUT:
  50.         case ASIN:
  51.                 _ascli();
  52.                 p->rx_head=p->rx_tail=p->rx_count=0;
  53.                 p->chst_bits.rxfull=p->chst_bits.rxovflow=0;
  54.                 p->chst_bits.rxempty=1;
  55.                 p->chst_bits.alert=p->chst_bits.linerr=p->chst_bits.modchg=0;
  56.                 _assti();
  57.                 if(p->chmode_bits.is_rtscontrol&&!p->chst_bits.rtsactive)
  58.                         _asrts(p->base_8250,1,p);
  59.                 if(option==ASIN)
  60.                         break;
  61.         case ASOUT:
  62.                 _ascli();
  63.                 p->tx_head=p->tx_tail=p->tx_count=0;
  64.                 p->chst_bits.txfull=0;
  65.                 p->chst_bits.txempty=1;
  66.                 p->chst_bits.alert=p->chst_bits.modchg=0;
  67.                 _assti();
  68.                 break;
  69.         default:
  70.                 return(ASINVPAR);
  71.         }
  72.         return(ASSUCCESS);
  73. }
  74.  
  75.