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

  1. /*
  2.  *  EXAMP59.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 the HMSetEchoMode()
  9.  *  and the HMSetFullDuplexMode() functions.  I turn off echoing of
  10.  *  characters in command mode, and turn on echoing when connected.
  11.  *  If I connect to a full-duplex remote end, I will now see each
  12.  *  typed character twice.
  13.  *
  14.  */
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <string.h>
  18. #include "asiports.h"
  19. #include "ibmkeys.h"
  20. #include "gf.h"
  21.  
  22. void my_putc( char c );
  23. void main( void );
  24.  
  25. void main()
  26. {
  27.     int status;
  28.     int c;
  29.  
  30.     status = asiopen( COM1, ASINOUT | BINARY | NORMALRX, 100, 100,
  31.                       1200L, P_NONE, 1, 8, ON, ON);
  32.     if ( status < ASSUCCESS ) {
  33.         printf( "Failed to open the port.  Status = %d\n", status );
  34.         exit( 1 );
  35.     }
  36.  
  37.     HMWaitForOK( TICKS_PER_SECOND, NULL );
  38.     HMSetUpEchoRoutine( my_putc );
  39.     HMSetFullDuplexMode( COM1, OFF );
  40.     HMSetEchoMode( COM1, OFF );
  41.     HMDial( COM1, "250-3778" );
  42.     for ( ; ; ) {
  43.         if ( gfkbhit() ) {
  44.             c = getkey();
  45.             if ( c == ESC )
  46.                 exit( 0 );
  47.             else
  48.                 asiputc( COM1, c );
  49.         }
  50.         c = asigetc( COM1 );
  51.         if ( c >= ASSUCCESS )
  52.             putc( c, stdout );
  53.    }
  54. }
  55.  
  56. void my_putc( char c )
  57. {
  58.     putc( c, stdout );
  59. }
  60.  
  61.