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 / _ISWHAT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-14  |  5.6 KB  |  151 lines

  1. /* _iswhat.c
  2. *
  3. * The Greenleaf Comm Library
  4. *
  5. * Copyright (C) 1985-1990 Greenleaf Software Inc.  All Rights Reserved.
  6. *
  7. *  int _iswhat(port,option)
  8. *  int port;            - Port 0..MAX_PORT-1
  9. *  int option;          - What to check
  10. *
  11. * DESCRIPTION
  12. *  Check whether or not some condition exists.  This function supports
  13. *  Flags and basic status Groups of the is*() macros defined in
  14. *  asiports.h.
  15. *
  16. * SIDE EFFECTS
  17. *  none.
  18. *
  19. * RETURNS
  20. *
  21. *    Returns 1 or 0 depending whether or not the condition the condition
  22. *    is true or false.  Also can return the following error returns.
  23. *
  24. *       Value           Meaning
  25. *     -------          --------
  26. *       ASINVPORT       Requested port is out of range
  27. *       ASNOTSETUP      Requested port not setup with asifirst()
  28. *       ASINVPAR        Invalid parameter
  29. *
  30. * MODIFICATIONS
  31. *  10-29-85     David Nienhiser
  32. *  03-12-86     David Nienhiser  isigalert(),isigcts(),isigdsr(),isigcd(),
  33. *                                isigmstat(),isigrcverr() modified to return
  34. *                                FALSE when the corresponding bit is "1" and
  35. *                                TRUE when the bit is set to "0".  This is
  36. *                                necessary to be consistent with asichecke().
  37. *  David Nienhiser   20-FEB-1987  08:57:45.50
  38. *       Changed reference to asiignor() to asicheck()
  39. */
  40. #include <stdio.h>
  41. #include "gf.h"
  42. #include "asiports.h"
  43.  
  44. int GF_CONV _iswhat(port,option)
  45. int port,option;
  46. {
  47.         struct PORT_TABLE *p;
  48.  
  49.         if((p=_aschkcnl(port))==NULL)
  50.                 return(_aserror);
  51.         switch(option) {
  52.  
  53.                 case 1: /* Check Alert flag isalert() */
  54.                         return((p->chst_bits.alert)?TRUE:FALSE);
  55.  
  56.                 case 2: /* Is RX-Buffer empty */
  57.                         return((p->chst_bits.rxempty)?TRUE:FALSE);
  58.  
  59.                 case 3: /* Is RX-Buffer full? */
  60.                         return((p->chst_bits.rxfull)?TRUE:FALSE);
  61.  
  62.                 case 4: /* Is RX-Buffer overflow? */
  63.                         return((p->chst_bits.rxovflow)?TRUE:FALSE);
  64.  
  65.                 case 5: /* Is TX-Buffer empty? */
  66.                         return((p->chst_bits.txempty)?TRUE:FALSE);
  67.  
  68.                 case 6: /* Is TX-Buffer full? */
  69.                         return((p->chst_bits.txfull)?TRUE:FALSE);
  70.  
  71.                 case 7: /* Is there a line error? */
  72.                         return((p->chst_bits.linerr)?TRUE:FALSE);
  73.  
  74.                 case 8: /* Is there a modem error */
  75.                         return((p->chst_bits.modchg)?TRUE:FALSE);
  76.  
  77.                 case 9: /* Are TX-Interrupts running */
  78.                         if(!p->chmode_bits.is_txint||p->chst_bits.txwxon||
  79.                            p->chst_bits.txwcts||p->chst_bits.txwalert)
  80.                                 return(FALSE);
  81.                         else
  82.                                 return(TRUE);
  83.  
  84.                 case 10: /* Are RX-Interrupts running */
  85.                         return((p->chmode_bits.is_rxint)?TRUE:FALSE);
  86.  
  87.                 case 11: /* Is alert being ignored AlertFlagStopsRXAndTX() */
  88.                         if ( p->chmode_bits.alert_flag_stops_rx_and_tx )
  89.                             return( TRUE );
  90.                         else
  91.                             return( FALSE );
  92.  
  93.                 case 12: /* Is CTS being ignored CTSLowHoldsTXInterrupts() */
  94.                     if ( p->chmode_bits.cts_low_holds_tx_interrupts )
  95.                         return( TRUE );
  96.                     else
  97.                         return( FALSE );
  98.  
  99.                 case 13: /* Is DSR being ignored DSRLowDiscardsRXData() */
  100.                     if ( p->chmode_bits.dsr_low_discards_rx_data )
  101.                         return( TRUE );
  102.                     else
  103.                         return( FALSE );
  104.  
  105.                 case 14: /* Is CD being ignored CDLowDiscardsRXData() */
  106.                     if ( p->chmode_bits.cd_low_discards_rx_data )
  107.                         return( TRUE );
  108.                     else
  109.                         return( FALSE );
  110.  
  111.                 case 15: /* Are modem status errors being
  112.                             ignored ModemStatusChangesSetAlert() */
  113.                     if ( p->chmode_bits.modem_status_changes_set_alert )
  114.                         return( TRUE );
  115.                     else
  116.                         return( FALSE );
  117.  
  118.                 case 16: /* Are receiver errors being ignored? */
  119.                     if ( p->chmode_bits.line_errors_set_alert )
  120.                         return( TRUE );
  121.                     else
  122.                         return( FALSE );
  123.  
  124.                 case 17:  /* Has CTS gone low this block ? */
  125.                         return((p->modem_stat&0x1000)?TRUE:FALSE);
  126.  
  127.                 case 18:  /* Has DSR gone low this block */
  128.                         return((p->modem_stat&0x2000)?TRUE:FALSE);
  129.  
  130.                 case 19:  /* Has CD gone low this block */
  131.                         return((p->modem_stat&0x8000)?TRUE:FALSE);
  132.  
  133.                 case 20:  /* Has Ring indicator been asserted */
  134.                         return((p->modem_stat&0x0004)?TRUE:FALSE);
  135.  
  136.                 case 21:  /* is receiver count > 0 */
  137.                         return((p->rx_accum)?TRUE:FALSE);
  138.  
  139.                 case 22:  /* isxoffblocked(p) */
  140.                         return((p->chmode_bits.is_xoffmode&&
  141.                                 p->chst_bits.txwxon)?TRUE:FALSE);
  142.  
  143.                 case 23:  /* isctsblocked(p) */
  144.                         return((p->chmode_bits.cts_low_holds_tx_interrupts&&
  145.                                 p->chst_bits.txwcts)?TRUE:FALSE);
  146.  
  147.                 default: return(ASINVPAR);
  148.         }
  149. }
  150.  
  151.