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 / EXAMP44.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-11  |  1.3 KB  |  53 lines

  1. /*
  2.  *  EXAMP44.C
  3.  *
  4.  *  The Greenleaf Comm Library
  5.  *
  6.  *  Copyright (C) 1989 Greenleaf Software Inc.  All Rights Reserved.
  7.  *
  8.  *  This example program demonstrates opening a port using asiinit(),
  9.  *  asifirst(), and asistart().  These three routines normally are called
  10.  *  automatically by asiopen(), along with asdtr() and asrts().
  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 = asifirst( COM1, ASINOUT | BINARY | NORMALRX, 100, 100 );
  27.     if ( status < ASSUCCESS ) {
  28.         printf( "Failed to asifirst the port.  Status = %d\n", status );
  29.         exit( 1 );
  30.     }
  31.     status = asiinit( COM1, 1200L, P_NONE, 1, 8);
  32.     if ( status < ASSUCCESS ) {
  33.         printf( "Failed on asiinit.  Status = %d\n", status );
  34.         exit( 1 );
  35.     }
  36.     status = asistart( COM1, ASINOUT );
  37.     if ( status < ASSUCCESS ) {
  38.         printf( "Failed on asistart.  Status = %d\n", status );
  39.         exit( 1 );
  40.     }
  41.     for ( ; ; ) {
  42.         if ( gfkbhit() ) {
  43.             c = getkey();
  44.             if ( c == ESC )
  45.                 exit( 0 );
  46.             asiputc( COM1, c );
  47.         }
  48.         c = asigetc( COM1 );
  49.         if ( c >= ASSUCCESS )
  50.             putc( c, stdout );
  51.    }
  52. }
  53.