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

  1. /*
  2.  *  EXAMP38.C
  3.  *
  4.  *  The Greenleaf Comm Library
  5.  *
  6.  *  Copyright (C) 1989 Greenleaf Software Inc.  All Rights Reserved.
  7.  *
  8.  *  This example program is used to demonstrate the use of isrxempty(),
  9.  *  isrxfull(), and isrxempty().
  10.  *
  11.  */
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include "asiports.h"
  15. #include "ibmkeys.h"
  16. #include "gf.h"
  17.  
  18. void do_shell( void );
  19. void main( void );
  20.  
  21. void main()
  22. {
  23.     int status;
  24.     int c;
  25.  
  26.     status = asiopen( COM1, ASINOUT | BINARY | NORMALRX, 15, 15,
  27.                       1200L, P_NONE, 1, 8, OFF, 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.                 exit( 0 );
  37.             else if ( c == F1 )
  38.                 do_shell();
  39.             else
  40.                 asiputc( COM1, c );
  41.         }
  42.         c = asigetc( COM1 );
  43.         if ( c >= ASSUCCESS )
  44.             putc( c, stdout );
  45.    }
  46. }
  47.  
  48. void do_shell()
  49. {
  50.     printf( "Interrupts will continue to run while you in DOS!\n");
  51.     printf( "Type EXIT to return to this program.\n");
  52.     system( "command" );
  53.     if ( isrxovflow( COM1 ) )
  54.         printf( "Receive buffer overflowed while you were gone!\n");
  55.     if ( isrxfull( COM1 ) )
  56.         printf( "Receive buffer is now full!\n" );
  57.     if ( isrxempty( COM1 ) )
  58.         printf( "Receive buffer is empty!\n" );
  59. }
  60.