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

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