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

  1. /*
  2.  *  EXAMP26.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 asrts() and asdtr().
  9.  *  This is a terminal emulator.  Hitting F1 will drop RTS and DTR
  10.  *  for two seconds, which should cause most modems to disconnect.
  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.                 exit( 0 );
  37.             else if ( c == F1 ) {
  38.                 asrts( COM1, OFF );
  39.                 asdtr( COM1, OFF );
  40.                 timer( TICKS_PER_SECOND * 2 );
  41.                 asrts( COM1, ON );
  42.                 asdtr( COM1, ON );
  43.             } else
  44.                 asiputc( COM1, c );
  45.         }
  46.         c = asigetc( COM1 );
  47.         if ( c >= ASSUCCESS )
  48.             putc( c, stdout );
  49.    }
  50. }
  51.