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

  1. /*
  2.  *  EXAMP04.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 wide track input.
  9.  *  It prints out any character that has a parity error inside
  10.  *  brackets.
  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.     char wide_status;
  26.  
  27.     status = asiopen( COM1, ASINOUT | BINARY | WIDETRACKRX, 100, 100,
  28.                       1200L, P_EVEN, 1, 8, ON, ON);
  29.     if ( status < ASSUCCESS ) {
  30.         printf( "Failed to open the port.  Status = %d\n", status );
  31.         exit( 1 );
  32.     }
  33.     for ( ; ; ) {
  34.         if ( gfkbhit() ) {
  35.             c = getkey();
  36.             if ( c == ESC )
  37.                 exit( 0 );
  38.             asiputc( COM1, c );
  39.         }
  40.         c = asiwgetc( COM1, &wide_status );
  41.         if ( c >= ASSUCCESS ) {
  42.             if ( wide_status & PARITY_ERR )
  43.                 printf( "[%c]", c );
  44.             else
  45.                 putc( c, stdout );
  46.         }
  47.    }
  48. }
  49.