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

  1. /*
  2.  *  EXAMP10.C
  3.  *
  4.  *  The Greenleaf Comm Library
  5.  *
  6.  *  Copyright (C) 1989 Greenleaf Software Inc.  All Rights Reserved.
  7.  *
  8.  *  This example program demonstrates some of the Hayes Modem Functions.
  9.  *  It dials the Greenleaf BBS, and hangs up as soon as it gets through.
  10.  *  The program hangs up by exiting, which should drop DTR.  Your modem may
  11.  *  not hang up if it has not been configured to do so.
  12.  *
  13.  */
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <string.h>
  17. #include "asiports.h"
  18. #include "ibmkeys.h"
  19. #include "gf.h"
  20.  
  21. void my_putc( char c );
  22. void main( void );
  23.  
  24. void main()
  25. {
  26.     int status;
  27.     char input_line[81];
  28.     int ticks;
  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.     HMWaitForOK( TICKS_PER_SECOND, NULL );
  37.     HMSetUpEchoRoutine( my_putc );
  38.     HMSetUpAbortKey( ESC );
  39.     HMReset(COM1);
  40.     HMSetDialingMethod( COM1, TOUCH_TONE );
  41.     HMDial( COM1, "250-3778");
  42.     ticks = TICKS_PER_SECOND*15;
  43.     while ( ticks > 0 ) {
  44.         ticks = HMInputLine( COM1, ticks, input_line, 81 );
  45.         if (strcmp( input_line, "CONNECT" ) == 0 ) {
  46.             printf( "Connection successfully made!\n" );
  47.             exit( 0 );
  48.         }
  49.     }
  50.     printf( "Failed to connect!\n");
  51.     exit( 1 );
  52. }
  53.  
  54. void my_putc( char c )
  55. {
  56.     putc( c, stdout );
  57. }
  58.