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 / EXAMP46.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-09  |  1.1 KB  |  48 lines

  1. /*
  2.  *  EXAMP46.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 proper use of the breakchk()
  9.  *  routine.  Break checking can be turned on once all interrupts
  10.  *  have been turned off.
  11.  *
  12.  */
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include "asiports.h"
  16. #include "ibmkeys.h"
  17. #include "gf.h"
  18.  
  19. void main( void );
  20.  
  21. void main()
  22. {
  23.     int c;
  24.     int status;
  25.  
  26.     status = asiopen( COM1, ASINOUT | BINARY | NORMALRX, 100, 100,
  27.                       1200L, P_NONE, 1, 8, ON, ON);
  28.     if ( status < ASSUCCESS ) {
  29.         printf( "Failed to open the port.  Status = %d\n", status );
  30.         exit( 1 );
  31.     }
  32.     for ( ; ; ) {
  33.         if ( gfkbhit() ) {
  34.             c = getkey();
  35.             if ( c == ESC )
  36.                 break;
  37.             asiputc( COM1, c );
  38.         }
  39.         c = asigetc( COM1 );
  40.         if ( c >= ASSUCCESS )
  41.             putc( c, stdout );
  42.    }
  43.    breakchk( ON );
  44.    printf( "Hit the break key now to exit...");
  45.    for ( ; ; )
  46.        getkey();
  47. }
  48.