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

  1. /*
  2.  *  EXAMP42.C
  3.  *
  4.  *  The Greenleaf Comm Library
  5.  *
  6.  *  Copyright (C) 1989 Greenleaf Software Inc.  All Rights Reserved.
  7.  *
  8.  *  This program is a plain vanilla terminal emulator.  While it is
  9.  *  running, you can stop reading then input buffer by pressing F1.
  10.  *  Characters will then be loaded until you hit another key, at
  11.  *  which point the input buffer is cleared, and emulation restarts.
  12.  *
  13.  */
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include "asiports.h"
  17. #include "xfer.h"
  18. #include "ibmkeys.h"
  19. #include "gf.h"
  20.  
  21. void hold_then_flush( void );
  22. void main( void );
  23.  
  24. void main()
  25. {
  26.     int c;
  27.     int status;
  28.  
  29.     status = asiopen( COM1, ASINOUT | BINARY | NORMALRX, 100, 100,
  30.                       1200L, P_NONE, 1, 8, ON, ON);
  31.     if ( status < ASSUCCESS ) {
  32.         printf( "Failed to open the port.  Status = %d\n", status );
  33.         exit( 1 );
  34.     }
  35.     for ( ; ; ) {
  36.         if ( gfkbhit() ) {
  37.             c = getkey();
  38.             if ( c == ESC )
  39.                 exit( 0 );
  40.             else if ( c == F1 )
  41.                 hold_then_flush();
  42.             else
  43.                 asiputc( COM1, c );
  44.         }
  45.         c = asigetc( COM1 );
  46.         if ( c >= ASSUCCESS )
  47.             putc( c, stdout );
  48.    }
  49. }
  50.  
  51. void hold_then_flush()
  52. {
  53.     printf("\n");
  54.     while ( !gfkbhit() ) {
  55.         printf( "Incoming character count=%d\r", getrxcnt( COM1 ) );
  56.         timer( 2 );
  57.     }
  58.     getkey();
  59.     printf("\n");
  60.     asiclear( COM1, ASIN );
  61. }
  62.