home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / GRLF-C-4.ZIP / GSAMP / GSAMP.ZIP / EXAMP22.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-09  |  1.4 KB  |  55 lines

  1. /*
  2.  *  EXAMP22.C
  3.  *
  4.  *  The Greenleaf Comm Library
  5.  *
  6.  *  Copyright (C) 1989 Greenleaf Software Inc.  All Rights Reserved.
  7.  *
  8.  *  This example program demonstrates the use of asirchk().  It is just
  9.  *  a simple little terminal emulator program that checks for an incoming
  10.  *  'A' or 'T' character.  The A character gets thrown away, the T character
  11.  *  gets passed through.
  12.  *
  13.  */
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include "asiports.h"
  17. #include "ibmkeys.h"
  18. #include "gf.h"
  19.  
  20. void main( void );
  21.  
  22. void main()
  23. {
  24.     int c;
  25.     int status;
  26.  
  27.     status = asiopen( COM1, ASINOUT | BINARY | NORMALRX, 100, 100,
  28.                       1200L, P_NONE, 1, 8, ON, ON);
  29.     if ( status < ASSUCCESS ) {
  30.         printf( "Failed to open the port.  Status = %d\n", status );
  31.         exit( 1 );
  32.     }
  33.     asirchk( COM1, 1, 'A', CHKFLAGDISCARD );
  34.     asirchk( COM1, 2, 'T', CHKFLAG );
  35.     for ( ; ; ) {
  36.         if ( isrchk( COM1, 1 ) ) {
  37.             printf( "\nFlag 1 set.\n" );
  38.             asirchk( COM1, 1, 'A', CHKRESET );
  39.         }
  40.         if ( isrchk( COM1, 2 ) ) {
  41.             printf( "\nFlag 2 set.\n" );
  42.             asirchk( COM1, 2, 'T', CHKRESET );
  43.         }
  44.         if ( gfkbhit() ) {
  45.             c = getkey();
  46.             if ( c == ESC )
  47.                 exit( 0 );
  48.             asiputc( COM1, c );
  49.         }
  50.         c = asigetc( COM1 );
  51.         if ( c >= ASSUCCESS )
  52.             putc( c, stdout );
  53.    }
  54. }
  55.