home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / PROGRAMM / SERIAL.ZIP / DUH3.CPP < prev    next >
C/C++ Source or Header  |  1992-01-29  |  1KB  |  47 lines

  1. /********************************************************************
  2. * duh3.cpp - An extremely dumb terminal program (C++ Interrupt Version)
  3. *            Copyright (c) 1992 By Mark Goodwin
  4. ********************************************************************/
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <dos.h>
  8. #include <conio.h>
  9. #include "sercpp.h"
  10.  
  11. #define PORT 2                        /* serial port */
  12. #define BAUDRATE 2400                /* baud rate */
  13.  
  14. SERIALPORT port(PORT, 1024);
  15.  
  16. void main(void)
  17. {
  18.     int c;
  19.  
  20.     printf("Duh No. 3 - An Extremely Dumb Terminal Program\n");
  21.     printf("Copyright (c) 1992 By Mark Goodwin\n\n");
  22.  
  23.     /* open the serial port */
  24.     port.set_port(BAUDRATE);
  25.  
  26.     /* main program loop */
  27.     while (TRUE) {
  28.         /* process keyboard presses */
  29.         if (kbhit()) {
  30.             c = getch();
  31.             switch (c) {
  32.                 case 0:                        /* exit on Alt-X */
  33.                     if (getch() == 45)
  34.                         exit(0);
  35.                     break;
  36.                 default:
  37.                     port.put(c);            /* send to the serial port */
  38.             }
  39.         }
  40.         /* process remote characters */
  41.         if (port.in_ready()) {
  42.             c = port.get();                /* get the character */
  43.             putch(c);                        /* display it */
  44.         }
  45.     }
  46. }
  47.