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

  1. /* _isstat.c
  2. *
  3. * The Greenleaf Comm Library
  4. *
  5. * Copyright (C) 1985-1990 Greenleaf Software Inc.  All Rights Reserved.
  6. *
  7. *  int _isstat(port,option,cmd)
  8. *  int port;            - Port 0..15
  9. *  int option;          - What to check
  10. *  int cmd;             - What to do
  11. *
  12. * DESCRIPTION
  13. *  Check whether or not some condition exists.  This function supports
  14. *  Flags and basic line and modem status Groups of the is*() macros defined in
  15. *  asiports.h.
  16. *
  17. * SIDE EFFECTS
  18. *  none.
  19. *
  20. * RETURNS
  21. *
  22. *    Returns 1 or 0 depending whether or not the condition the condition
  23. *    is true or false.  Also can return the following error returns.
  24. *
  25. *       Value           Meaning
  26. *     -------          --------
  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-29-85     David Nienhiser
  33. *  David Nienhiser   11-FEB-1987  13:15:43.68
  34. *       Case 11 in switch statement was checking bit 2 (TERI) instead of
  35. *       bit 3 (DRLSD)
  36. */
  37. #include <stdio.h>
  38. #include "gf.h"
  39. #include "asiports.h"
  40.  
  41. int GF_CONV _isstat(port,option,cmd)
  42. int port,option,cmd;
  43. {
  44.         struct PORT_TABLE *p;
  45.         unsigned temp;
  46.  
  47.         if((p=_aschkcnl(port))==NULL)
  48.                 return(_aserror);
  49.         if ((option!=CUMULATIVE)&&(option!=IMMEDIATE)) return (ASINVPAR);
  50.         switch(cmd) {
  51.  
  52.                 case 1: /* Has a receiver overrun error occurred */
  53.                         temp=(option==CUMULATIVE)?p->line_stat:
  54.                                             (unsigned)_asinb(p->base_8250+5);
  55.                         return((temp&2)?TRUE:FALSE);
  56.  
  57.                 case 2: /* Has a parity error occurred */
  58.                         temp=(option==CUMULATIVE)?p->line_stat:
  59.                                              (unsigned)_asinb(p->base_8250+5);
  60.                         return((temp&0x0004)?TRUE:FALSE);
  61.  
  62.                 case 3: /* Has a framing error occurred */
  63.                         temp=(option==CUMULATIVE)?p->line_stat:
  64.                                              (unsigned)_asinb(p->base_8250+5);
  65.                         return((temp&0x0008)?TRUE:FALSE);
  66.  
  67.                 case 4: /* Has a break signal been received */
  68.                         temp=(option==CUMULATIVE)?p->line_stat:
  69.                                              (unsigned)_asinb(p->base_8250+5);
  70.                         return((temp&0x0010)?TRUE:FALSE);
  71.  
  72.                 case 5: /* Return the state of CTS */
  73.                         temp=(option==CUMULATIVE)?p->modem_stat:
  74.                                              (unsigned)_asinb(p->base_8250+6);
  75.                         return((temp&0x0010)?TRUE:FALSE);
  76.  
  77.                 case 6: /* Return the state of DSR */
  78.                         temp=(option==CUMULATIVE)?p->modem_stat:
  79.                                              (unsigned)_asinb(p->base_8250+6);
  80.                         return((temp&0x0020)?TRUE:FALSE);
  81.  
  82.                 case 7: /* Return the state of Carrier Detect */
  83.                         temp=(option==CUMULATIVE)?p->modem_stat:
  84.                                              (unsigned)_asinb(p->base_8250+6);
  85.                         return((temp&0x0080)?TRUE:FALSE);
  86.  
  87.                 case 8: /* Return the state of Ring Indicator */
  88.                         temp=(option==CUMULATIVE)?p->modem_stat:
  89.                                              (unsigned)_asinb(p->base_8250+6);
  90.                         return((temp&0x0040)?TRUE:FALSE);
  91.  
  92.                 case 9: /* Has there been a change in CTS */
  93.                         temp=(option==CUMULATIVE)?p->modem_stat:
  94.                                              (unsigned)_asinb(p->base_8250+6);
  95.                         return((temp&0x0001)?TRUE:FALSE);
  96.  
  97.                 case 10: /* Has there been a change in DSR */
  98.                         temp=(option==CUMULATIVE)?p->modem_stat:
  99.                                              (unsigned)_asinb(p->base_8250+6);
  100.                         return((temp&0x0002)?TRUE:FALSE);
  101.  
  102.                 case 11: /* Has there been a change in CD */
  103.                         temp=(option==CUMULATIVE)?p->modem_stat:
  104.                                              (unsigned)_asinb(p->base_8250+6);
  105.                         return((temp&0x0008)?TRUE:FALSE);
  106.  
  107.                 case 12: /* Has there been a change in RI */
  108.                         temp=(option==CUMULATIVE)?p->modem_stat:
  109.                                              (unsigned)_asinb(p->base_8250+6);
  110.                         return((temp&0x0004)?TRUE:FALSE);
  111.  
  112.                 default:
  113.                         return(ASINVPAR);
  114.         }
  115. }
  116.  
  117. /* Check character counter with parameter, return true if character counter
  118.    is the same as or greater than the count parameter.
  119.  */
  120. int GF_CONV isxmrxcnt(port,count)
  121. int port;
  122. unsigned count;
  123. {
  124.         extern int _aserror;
  125.         struct PORT_TABLE * GF_CONV _aschkcnl(),*p;
  126.         if((p=_aschkcnl(port))==NULL)
  127.                 return(_aserror);
  128.         return((p->rx_accum>=count)?TRUE:FALSE);
  129.  
  130. }
  131.