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

  1. /* asicheck.c
  2. *
  3. * The Greenleaf Comm Library
  4. *
  5. * Copyright (C) 1985-1990 Greenleaf Software Inc.  All Rights Reserved.
  6. *
  7. *  int asicheck( port,condition,control )
  8. *  int port;            - Port 0..MAX_PORT-1
  9. *  int condition;       - Condition to modify
  10. *  int control;         - ON/OFF
  11. *
  12. * DESCRIPTION
  13. *
  14. * Setup to ignore or change behavior on certain conditions.
  15. * Returns one of the following values:
  16. *
  17. * Condition  Default    What is controlled
  18. *
  19. *  ALERT_FLAG_STOPS_RX_AND_TX:
  20. *
  21. *                OFF    Alert flag does not halt sending/receiving if OFF
  22. *
  23. *                ON     Alert flag prevents sending or receiving if ON
  24. *
  25. *  CTS_LOW_STOPS_TX_INTERRUPTS:
  26. *
  27. *                OFF    Clear to Send does not halt sending if OFF
  28. *
  29. *                ON     CTS will prevent sending characters when it is
  30. *                       low and this has been turned on.
  31. *
  32. *  DSR_LOW_DISCARDS_RX_DATA:
  33. *
  34. *                OFF    Data Set Ready is ignored if OFF
  35. *
  36. *                ON     DSR will prevent receiving characters when it is
  37. *                       low and this has been turned ON
  38. *
  39. *  CD_LOW_DISCARDS_RX_DATA:
  40. *
  41. *                OFF    Carrier Detect is ignored if OFF
  42. *
  43. *                ON     CD will prevent receiving characters when it is
  44. *                       low and this has been turned ON
  45. *
  46. *  MODEM_STATUS_CHANGES_SET_ALERT:
  47. *
  48. *                 OFF   Modem status changes do not affect the alert flag
  49. *                       if OFF.
  50. *
  51. *                 ON    Any modem status change will set the alert flag
  52. *                       if this is set ON.
  53. *
  54. *  LINE_STATUS_ERRORS_SET_ALERT:
  55. *
  56. *                 OFF   Any receiver errors have no effect on the alert
  57. *                       flag if this is set off.
  58. *
  59. *                 ON    Any receive error condition will set the alert
  60. *                       flag if this is set ON.
  61. *
  62. *   The following values can be returned from this function.
  63. *
  64. *       Value           Meaning
  65. *     -------          --------
  66. *       ASSUCCESS       Successful (no error)
  67. *       ASINVPORT       Requested port is out of range
  68. *       ASNOTSETUP      Requested port not setup with asifirst()
  69. *       ASINVPAR        Invalid parameter
  70. *
  71. * SIDE EFFECTS
  72. * If successful bits in the chmode_bits will be modified.
  73. *
  74. * MODIFICATIONS
  75. *  11-09-85     ""
  76. *               Modified for release 2.0
  77. *
  78. *   20-FEB-1987  08:56:50.80
  79. *       Renamed function asiignor() to asicheck().
  80. *   26-MAY-1988  09:20:24.28
  81. *    break; statement missing in case IGCD:  version 2.20, SAR# 110
  82. */
  83. #include <stdio.h>
  84. #include "gf.h"
  85. #include "asiports.h"
  86.  
  87.  
  88. int GF_CONV asicheck( port,condition,control )
  89. int port,condition,control;
  90. {
  91.  
  92.         struct PORT_TABLE *p;
  93.  
  94.         if((p=_aschkcnl(port))==NULL)
  95.                 return(_aserror);
  96.         if(control != ON && control != OFF)
  97.                 return(ASINVPAR);
  98.  
  99.         switch(condition) {
  100.  
  101.                 case ALERT_FLAG_STOPS_RX_AND_TX :
  102.                                 if(control==OFF) {
  103.                                         p->chmode_bits.alert_flag_stops_rx_and_tx=0;
  104.                                         if(p->chst_bits.txwalert) {
  105.                                                 p->chst_bits.txwalert=0;
  106.                                                 _asiprime(p);
  107.                                         }
  108.                                 } else
  109.                                         p->chmode_bits.alert_flag_stops_rx_and_tx=1;
  110.                                 break;
  111.  
  112.                 case CTS_LOW_STOPS_TX_INTERRUPTS :
  113.                                 if(control==OFF) {
  114.                                         p->chmode_bits.cts_low_holds_tx_interrupts=0;
  115.                                         if(p->chst_bits.txwcts) {
  116.                                                 p->chst_bits.txwcts=0;
  117.                                                 _asiprime(p);
  118.                                         }
  119.                                 } else
  120.                                         p->chmode_bits.cts_low_holds_tx_interrupts=1;
  121.                                 break;
  122.  
  123.                 case DSR_LOW_DISCARDS_RX_DATA :
  124.                                 if(control==OFF)
  125.                                         p->chmode_bits.dsr_low_discards_rx_data=0;
  126.                                 else
  127.                                         p->chmode_bits.dsr_low_discards_rx_data=1;
  128.                                 break;
  129.  
  130.                 case CD_LOW_DISCARDS_RX_DATA :
  131.                                 if(control==OFF)
  132.                                         p->chmode_bits.cd_low_discards_rx_data=0;
  133.                                 else
  134.                                         p->chmode_bits.cd_low_discards_rx_data=1;
  135.                                 break;
  136.  
  137.                 case MODEM_STATUS_CHANGES_SET_ALERT :
  138.                                 if(control==OFF) {
  139.                                         p->chmode_bits.modem_status_changes_set_alert = 0;
  140.                                         if(p->chst_bits.alert &&
  141.                                            p->chst_bits.modchg &&
  142.                                            p->chmode_bits.alert_flag_stops_rx_and_tx)
  143.                                                 _asiprime(p);
  144.                                 } else
  145.                                         p->chmode_bits.modem_status_changes_set_alert = 1;
  146.                                 break;
  147.  
  148.                 case LINE_STATUS_ERRORS_SET_ALERT :
  149.                                 if(control==OFF) {
  150.                                         p->chmode_bits.line_errors_set_alert = 0;
  151.                                         if(p->chst_bits.alert &&
  152.                                            p->chst_bits.linerr &&
  153.                                            p->chmode_bits.alert_flag_stops_rx_and_tx)
  154.                                                 _asiprime(p);
  155.                                 } else
  156.                                         p->chmode_bits.line_errors_set_alert = 1;
  157.                                 break;
  158.  
  159.                 default:        return(ASINVPAR);
  160.         }
  161.         return(ASSUCCESS);
  162. }
  163.  
  164. /* For compatibility, asiignore() just calls asicheck()
  165.  */
  166. int GF_CONV asiignore(port,condition,control)
  167. int port,condition,control;
  168. {
  169.         return(asicheck(port,condition,control));
  170. }
  171.  
  172.