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

  1. /*
  2.  *  EXAMP11.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 some of the Hayes
  9.  *  Modem Functions.  This routine sets up the modem and calls
  10.  *  the Greenleaf BBS.  Once it gets through, it hangs up by exiting
  11.  *  the program.  DTR should drop upon exit, which will hang up the
  12.  *  modem.  Your modem may not hang up if it has not been configured
  13.  *  to do so.
  14.  *
  15.  */
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #include "asiports.h"
  20. #include "ibmkeys.h"
  21. #include "gf.h"
  22.  
  23. void main( void );
  24.  
  25. void main()
  26. {
  27.     int status;
  28.     int ticks;
  29.     int c;
  30.  
  31.     status = asiopen( COM1, ASINOUT | BINARY | NORMALRX, 100, 100,
  32.                       1200L, P_NONE, 1, 8, ON, ON);
  33.     if ( status < ASSUCCESS ) {
  34.         printf( "Failed to open the port.  Status = %d\n", status );
  35.         exit( 1 );
  36.     }
  37.     HMFixedDelay( TICKS_PER_SECOND );
  38.     HMReset(COM1);
  39.     HMSetDialingMethod( COM1, PULSE );
  40.     HMDial( COM1, "250-3778");
  41.     ticks = TICKS_PER_SECOND*25;
  42.     while ( ticks > 0 ) {
  43.         if ( iscd( COM1, IMMEDIATE ) ) {
  44.             printf("Detected incoming carrier.\n");
  45.             exit( 0 );
  46.         } else {
  47.             while ( ( c = asigetc( COM1 ) ) > ASSUCCESS )
  48.                 putc( c, stdout );
  49.             if ( gfkbhit() ) {
  50.                 getkey();
  51.                 printf( "User aborted\n");
  52.                 exit( 1 );
  53.             }
  54.             timer( 1 );
  55.             if (--ticks <= 0 ) {
  56.                 printf("Timed out, no carrier.\n");
  57.                 exit( 2 );
  58.             }
  59.         }
  60.     }
  61. }
  62.