home *** CD-ROM | disk | FTP | other *** search
- /* _iswhat.c
- *
- * The Greenleaf Comm Library
- *
- * Copyright (C) 1985-1990 Greenleaf Software Inc. All Rights Reserved.
- *
- * int _iswhat(port,option)
- * int port; - Port 0..MAX_PORT-1
- * int option; - What to check
- *
- * DESCRIPTION
- * Check whether or not some condition exists. This function supports
- * Flags and basic status Groups of the is*() macros defined in
- * asiports.h.
- *
- * SIDE EFFECTS
- * none.
- *
- * RETURNS
- *
- * Returns 1 or 0 depending whether or not the condition the condition
- * is true or false. Also can return the following error returns.
- *
- * Value Meaning
- * ------- --------
- * ASINVPORT Requested port is out of range
- * ASNOTSETUP Requested port not setup with asifirst()
- * ASINVPAR Invalid parameter
- *
- * MODIFICATIONS
- * 10-29-85 David Nienhiser
- * 03-12-86 David Nienhiser isigalert(),isigcts(),isigdsr(),isigcd(),
- * isigmstat(),isigrcverr() modified to return
- * FALSE when the corresponding bit is "1" and
- * TRUE when the bit is set to "0". This is
- * necessary to be consistent with asichecke().
- * David Nienhiser 20-FEB-1987 08:57:45.50
- * Changed reference to asiignor() to asicheck()
- */
- #include <stdio.h>
- #include "gf.h"
- #include "asiports.h"
-
- int GF_CONV _iswhat(port,option)
- int port,option;
- {
- struct PORT_TABLE *p;
-
- if((p=_aschkcnl(port))==NULL)
- return(_aserror);
- switch(option) {
-
- case 1: /* Check Alert flag isalert() */
- return((p->chst_bits.alert)?TRUE:FALSE);
-
- case 2: /* Is RX-Buffer empty */
- return((p->chst_bits.rxempty)?TRUE:FALSE);
-
- case 3: /* Is RX-Buffer full? */
- return((p->chst_bits.rxfull)?TRUE:FALSE);
-
- case 4: /* Is RX-Buffer overflow? */
- return((p->chst_bits.rxovflow)?TRUE:FALSE);
-
- case 5: /* Is TX-Buffer empty? */
- return((p->chst_bits.txempty)?TRUE:FALSE);
-
- case 6: /* Is TX-Buffer full? */
- return((p->chst_bits.txfull)?TRUE:FALSE);
-
- case 7: /* Is there a line error? */
- return((p->chst_bits.linerr)?TRUE:FALSE);
-
- case 8: /* Is there a modem error */
- return((p->chst_bits.modchg)?TRUE:FALSE);
-
- case 9: /* Are TX-Interrupts running */
- if(!p->chmode_bits.is_txint||p->chst_bits.txwxon||
- p->chst_bits.txwcts||p->chst_bits.txwalert)
- return(FALSE);
- else
- return(TRUE);
-
- case 10: /* Are RX-Interrupts running */
- return((p->chmode_bits.is_rxint)?TRUE:FALSE);
-
- case 11: /* Is alert being ignored AlertFlagStopsRXAndTX() */
- if ( p->chmode_bits.alert_flag_stops_rx_and_tx )
- return( TRUE );
- else
- return( FALSE );
-
- case 12: /* Is CTS being ignored CTSLowHoldsTXInterrupts() */
- if ( p->chmode_bits.cts_low_holds_tx_interrupts )
- return( TRUE );
- else
- return( FALSE );
-
- case 13: /* Is DSR being ignored DSRLowDiscardsRXData() */
- if ( p->chmode_bits.dsr_low_discards_rx_data )
- return( TRUE );
- else
- return( FALSE );
-
- case 14: /* Is CD being ignored CDLowDiscardsRXData() */
- if ( p->chmode_bits.cd_low_discards_rx_data )
- return( TRUE );
- else
- return( FALSE );
-
- case 15: /* Are modem status errors being
- ignored ModemStatusChangesSetAlert() */
- if ( p->chmode_bits.modem_status_changes_set_alert )
- return( TRUE );
- else
- return( FALSE );
-
- case 16: /* Are receiver errors being ignored? */
- if ( p->chmode_bits.line_errors_set_alert )
- return( TRUE );
- else
- return( FALSE );
-
- case 17: /* Has CTS gone low this block ? */
- return((p->modem_stat&0x1000)?TRUE:FALSE);
-
- case 18: /* Has DSR gone low this block */
- return((p->modem_stat&0x2000)?TRUE:FALSE);
-
- case 19: /* Has CD gone low this block */
- return((p->modem_stat&0x8000)?TRUE:FALSE);
-
- case 20: /* Has Ring indicator been asserted */
- return((p->modem_stat&0x0004)?TRUE:FALSE);
-
- case 21: /* is receiver count > 0 */
- return((p->rx_accum)?TRUE:FALSE);
-
- case 22: /* isxoffblocked(p) */
- return((p->chmode_bits.is_xoffmode&&
- p->chst_bits.txwxon)?TRUE:FALSE);
-
- case 23: /* isctsblocked(p) */
- return((p->chmode_bits.cts_low_holds_tx_interrupts&&
- p->chst_bits.txwcts)?TRUE:FALSE);
-
- default: return(ASINVPAR);
- }
- }
-
-