home *** CD-ROM | disk | FTP | other *** search
- /*
- * EXAMP22.C
- *
- * The Greenleaf Comm Library
- *
- * Copyright (C) 1989 Greenleaf Software Inc. All Rights Reserved.
- *
- * This example program demonstrates the use of asirchk(). It is just
- * a simple little terminal emulator program that checks for an incoming
- * 'A' or 'T' character. The A character gets thrown away, the T character
- * gets passed through.
- *
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include "asiports.h"
- #include "ibmkeys.h"
- #include "gf.h"
-
- void main( void );
-
- void main()
- {
- int c;
- int status;
-
- status = asiopen( COM1, ASINOUT | BINARY | NORMALRX, 100, 100,
- 1200L, P_NONE, 1, 8, ON, ON);
- if ( status < ASSUCCESS ) {
- printf( "Failed to open the port. Status = %d\n", status );
- exit( 1 );
- }
- asirchk( COM1, 1, 'A', CHKFLAGDISCARD );
- asirchk( COM1, 2, 'T', CHKFLAG );
- for ( ; ; ) {
- if ( isrchk( COM1, 1 ) ) {
- printf( "\nFlag 1 set.\n" );
- asirchk( COM1, 1, 'A', CHKRESET );
- }
- if ( isrchk( COM1, 2 ) ) {
- printf( "\nFlag 2 set.\n" );
- asirchk( COM1, 2, 'T', CHKRESET );
- }
- if ( gfkbhit() ) {
- c = getkey();
- if ( c == ESC )
- exit( 0 );
- asiputc( COM1, c );
- }
- c = asigetc( COM1 );
- if ( c >= ASSUCCESS )
- putc( c, stdout );
- }
- }