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 / EXAMP02.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-09  |  917 b   |  42 lines

  1. /*
  2.  *  EXAMP02.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 interrupt driver I/O.
  9.  *
  10.  */
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include "asiports.h"
  14. #include "ibmkeys.h"
  15. #include "gf.h"
  16.  
  17. void main( void );
  18.  
  19. void main()
  20. {
  21.     int c;
  22.     int status;
  23.  
  24.     status = asiopen( COM1, ASINOUT | BINARY | NORMALRX, 100, 100,
  25.                       1200L, P_NONE, 1, 8, ON, ON);
  26.     if ( status < ASSUCCESS ) {
  27.         printf( "Failed to open the port.  Status = %d\n", status );
  28.         exit( 1 );
  29.     }
  30.     for ( ; ; ) {
  31.         if ( gfkbhit() ) {
  32.             c = getkey();
  33.             if ( c == ESC )
  34.                 exit( 0 );
  35.             asiputc( COM1, c );
  36.         }
  37.         c = asigetc( COM1 );
  38.         if ( c >= ASSUCCESS )
  39.             putc( c, stdout );
  40.    }
  41. }
  42.