home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 11 / 11.iso / n / n002 / 4.ddi / DEMOS.ZIP / DEMO.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-16  |  929 b   |  39 lines

  1. #include <stdio.h>
  2. #include   "eclproto.h"
  3. #include   "xc.h"
  4. #define    ESC 0x001B
  5.  
  6. int port = COM1;
  7.  
  8. void main(void)
  9. {
  10.     unsigned int ch;
  11.      int stat;
  12.  
  13.     stat = xc_entr(8);
  14.     if (stat == 0) {
  15.           stat = xc_tport(port);
  16.           if (!stat)  {
  17.             xc_link(port, 0);
  18.             xc_init(port, BAUD2400, NOPAR, DATA8, STOP1);
  19.             for (;;) {
  20.                 if (xck_keyt()) {          /* A key is struck */
  21.                     if ((ch = xck_getc() & 0xFF) == ESC)
  22.                        break;              /* Exit */
  23.                     xc_putc(port, ch);
  24.                 }
  25.                 if (xc_test(port))         /* Incoming char */
  26.                     xcv_wtty(xc_getc(port));
  27.             }        
  28.               xc_unlk(port);
  29.          }
  30.         else  {
  31.            printf("\nxc_tport() fail with status = %d",stat);
  32.            }
  33.     }
  34.     else  {
  35.        printf("\nxc_entr() fail with status = %d",stat);
  36.      }
  37.     xc_exit();
  38. }
  39.