home *** CD-ROM | disk | FTP | other *** search
- /* asirchk.c
- *
- * The Greenleaf Comm Library
- *
- * Copyright (C) 1985-1990 Greenleaf Software Inc. All Rights Reserved.
- *
- * int asirchk( port,chk,code,operation )
- * int port; - Port 0..MAX_PORT-1
- * int chk; - One of three codes to check (0..2)
- * unsigned code; - Code to check/ignore 00..255
- * int operation; - Operation (0..4) see below
- *
- * DESCRIPTION
- *
- * Operation Description
- *
- * CHKDISABLE Disable checking for this character code. Use
- * this option to discontinue a filter or check
- * operation.
- *
- * CHKDISCARD Discard the character code, do not set flag.
- *
- * CHKFLAGDISCARD Set flag, do NOT place character in receive buffer. A
- * flag is set each time code is received* the character is
- * not inserted in the buffer.
- *
- * CHKFLAG Set flag, DO place character in receive buffer. A flag
- * is set each time code is received* the character IS placed
- * in the buffer.
- *
- * CHKRESET Reset the flag for this character code. This option does not
- * set any character code in the structure if it is not already
- * there; the flag for the chk argument is just reset.
- *
- *
- * RETURNS
- *
- * Value Meaning
- * ------ --------
- * ASSUCCESS Successful (no error)
- * ASINVPORT Requested port is out of range
- * ASNOTSETUP Requested port not setup with asifirst()
- * ASINVPAR Invalid parameter
- *
- * SIDE EFFECTS
- * none
- *
- * MODIFICATIONS
- * 11-09-85 ""
- * Modified for release 2.0
- *
- * 03-12-86 break; missing from switch(chk) cases.
- *
- */
- #include <stdio.h>
- #include "gf.h"
- #include "asiports.h"
-
- int GF_CONV asirchk(port,chk,code,operation )
- int port,chk,operation;
- unsigned code;
- {
- struct PORT_TABLE *p;
-
- if((p=_aschkcnl(port))==NULL)
- return(_aserror);
- if(operation<0 || operation>4)
- return(ASINVPAR);
- if(chk<0 || chk>2)
- return(ASINVPAR);
- code&=0xff;
- if(operation!=CHKDISABLE && operation!=CHKRESET)
- switch(chk) {
- case 0: if( ( p->chkchr[1] & 0xff ) == code ||
- ( p->chkchr[2] & 0xff ) == code )
- return(ASINVPAR);
- break;
- case 1: if( ( p->chkchr[0] & 0xff ) == code ||
- ( p->chkchr [2] & 0xff) == code )
- return(ASINVPAR);
- break;
- case 2: if( ( p->chkchr[0] & 0xff ) == code ||
- ( p->chkchr[1] & 0xff ) == code )
- return(ASINVPAR);
- break;
- }
- switch(operation) {
-
- case CHKDISABLE:
- p->chkchr[chk]&=0x7fff;
- break;
-
- case CHKDISCARD:
- p->chkchr[chk]=0x8000|code;
- break;
-
- case CHKFLAGDISCARD:
- p->chkchr[chk]=0x8100|code;
- break;
-
- case CHKFLAG:
- p->chkchr[chk]=0x8200|code;
- break;
-
- case CHKRESET:
- p->chkchr[chk]&=0xbfff;
- break;
-
- default: return(ASINVPAR);
- }
- if(p->chkchr[0]&0x8000||p->chkchr[1]&0x8000||p->chkchr[2]&0x8000)
- p->chmode_bits.is_rchking=1;
- else
- p->chmode_bits.is_rchking=0;
- return(ASSUCCESS);
- }
-