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

  1. /* asirchk.c
  2. *
  3. * The Greenleaf Comm Library
  4. *
  5. * Copyright (C) 1985-1990 Greenleaf Software Inc.  All Rights Reserved.
  6. *
  7. *  int asirchk( port,chk,code,operation )
  8. *  int port;            - Port 0..MAX_PORT-1
  9. *  int chk;             - One of three codes to check (0..2)
  10. *  unsigned code;       - Code to check/ignore 00..255
  11. *  int operation;       - Operation (0..4) see below
  12. *
  13. * DESCRIPTION
  14. *
  15. *  Operation    Description
  16. *
  17. *  CHKDISABLE   Disable checking for this character code.  Use
  18. *               this option to discontinue a filter or check
  19. *               operation.
  20. *
  21. *  CHKDISCARD   Discard the character code, do not set flag.
  22. *
  23. * CHKFLAGDISCARD Set flag, do NOT place character in receive buffer.  A
  24. *               flag is set each time code is received* the character is
  25. *               not inserted in the buffer.
  26. *
  27. * CHKFLAG       Set flag, DO place character in receive buffer.  A flag
  28. *               is set each time code is received* the character IS placed
  29. *               in the buffer.
  30. *
  31. * CHKRESET      Reset the flag for this character code.  This option does not
  32. *               set any character code in the structure if it is not already
  33. *               there; the flag for the chk argument is just reset.
  34. *
  35. *
  36. * RETURNS
  37. *
  38. *       Value           Meaning
  39. *       ------          --------
  40. *       ASSUCCESS       Successful (no error)
  41. *       ASINVPORT       Requested port is out of range
  42. *       ASNOTSETUP      Requested port not setup with asifirst()
  43. *       ASINVPAR        Invalid parameter
  44. *
  45. * SIDE EFFECTS
  46. *  none
  47. *
  48. * MODIFICATIONS
  49. *  11-09-85     ""
  50. *               Modified for release 2.0
  51. *
  52. *  03-12-86     break; missing from switch(chk) cases.
  53. *
  54. */
  55. #include <stdio.h>
  56. #include "gf.h"
  57. #include "asiports.h"
  58.  
  59. int GF_CONV asirchk(port,chk,code,operation )
  60. int port,chk,operation;
  61. unsigned code;
  62. {
  63.         struct PORT_TABLE *p;
  64.  
  65.         if((p=_aschkcnl(port))==NULL)
  66.                 return(_aserror);
  67.         if(operation<0 || operation>4)
  68.                 return(ASINVPAR);
  69.         if(chk<0 || chk>2)
  70.                 return(ASINVPAR);
  71.         code&=0xff;
  72.         if(operation!=CHKDISABLE && operation!=CHKRESET)
  73.                 switch(chk) {
  74.                         case 0: if( ( p->chkchr[1] & 0xff ) == code ||
  75.                                     ( p->chkchr[2] & 0xff ) == code )
  76.                                         return(ASINVPAR);
  77.                                 break;
  78.                         case 1: if( ( p->chkchr[0] & 0xff ) == code ||
  79.                                     ( p->chkchr [2] & 0xff) == code )
  80.                                         return(ASINVPAR);
  81.                                 break;
  82.                         case 2: if( ( p->chkchr[0] & 0xff ) == code ||
  83.                                     ( p->chkchr[1] & 0xff ) == code )
  84.                                         return(ASINVPAR);
  85.                                 break;
  86.                         }
  87.         switch(operation) {
  88.  
  89.                 case CHKDISABLE:
  90.                         p->chkchr[chk]&=0x7fff;
  91.                         break;
  92.  
  93.                 case CHKDISCARD:
  94.                         p->chkchr[chk]=0x8000|code;
  95.                         break;
  96.  
  97.                 case CHKFLAGDISCARD:
  98.                         p->chkchr[chk]=0x8100|code;
  99.                         break;
  100.  
  101.                 case CHKFLAG:
  102.                         p->chkchr[chk]=0x8200|code;
  103.                         break;
  104.  
  105.                 case CHKRESET:
  106.                         p->chkchr[chk]&=0xbfff;
  107.                         break;
  108.  
  109.                 default:        return(ASINVPAR);
  110.         }
  111.         if(p->chkchr[0]&0x8000||p->chkchr[1]&0x8000||p->chkchr[2]&0x8000)
  112.                 p->chmode_bits.is_rchking=1;
  113.         else
  114.                 p->chmode_bits.is_rchking=0;
  115.         return(ASSUCCESS);
  116. }
  117.