home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / modem / cvt100.zip / CVT100.C < prev    next >
Text File  |  1988-08-06  |  3KB  |  99 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <dos.h>
  4.  
  5. /****************************************************************************/
  6. /* Function prototypes                                                      */
  7.  
  8. int  main( void );
  9. void CVT100Init( void );
  10. void terminal( void );
  11. void badexit( char * );
  12.  
  13. /****************************************************************************/
  14. /* Global Data                                                              */
  15.  
  16. char modeline[] =
  17. "F5-Communications  F6-Video  F7-Keyboard  F8-VT emulation  F9-File     F10-Exit";
  18.  
  19. /****************************************************************************/
  20. /* External Variables                                                       */
  21.  
  22. extern unsigned int _stacklen = 4000;
  23. extern unsigned int _heaplen = 5120;
  24.  
  25. /****************************************************************************/
  26. /* Local Static Data                                                        */
  27.  
  28.  
  29. /****************************************************************************/
  30. /****************************************************************************/
  31.  
  32. /* M A I N -- Main function for emulator */
  33.  
  34. main()
  35. {
  36.  
  37.    CVT100Init();                  /* Initialization */
  38.    ttopen();                      /* Open selected com port */
  39.    terminal();                    /* Emulate the terminal for awhile */
  40.    ttclose();                     /* Close the communications port */
  41.    CloseLogFile();                /* Close log file if open */
  42.    gotoxy(1,25);                  /* When leaving set cursor to screen bottom*/
  43.    return(0);                     /* Thats all */
  44. }
  45.  
  46.  
  47. /* C V T 1 0 0 I N I T -- Initialize the VT100 emulator */
  48.  
  49. void CVT100Init() {
  50.  
  51.    FileInit();                    /* Initialize File System *first* */
  52.    TTinit();                      /* Initialize communications system */
  53.    VidInit();                     /* Initialize video system */
  54.    KeyInit();                     /* Initialize Keyboard system */
  55.    VTInit();                      /* Initialize VT Emulation */
  56. }
  57.  
  58. /* T E R M I N A L -- Perform terminal emulation */
  59.  
  60. void terminal()
  61. {
  62.    int thru = 0;
  63.    int key;
  64.    int c;
  65.  
  66.    while (!thru) {                /* Continue until exited */
  67.       if (ConChk()) {                /* If a keystroke is present */
  68.          if (DoKey() == -1)          /* Then interpret it */
  69.             thru = 1;                /* Watch for done flag here */
  70.       }
  71.       if (ttchk())                /* If incoming communications chars */
  72.          ConOut( ttinc() );       /* Output the character to emulation system*/
  73.    }
  74. }
  75.  
  76.  
  77.  
  78. /* B A D E X I T -- Exit the program displaying a fatal error message */
  79.  
  80. void badexit( char * message ) {
  81.    char line[132];
  82.    register char * s = line;
  83.  
  84.    ttclose();
  85.    gotoxy(1,25);                  /* start message on last line of display*/
  86.  
  87.    while ( (*s = *message++) != '\0')
  88.       s++;
  89.    *s++ = '\a';                   /* Concantonate a '$' to the message */
  90.    *s = '$';
  91.  
  92.    _DX = (unsigned) line;
  93.    _AH = 9;
  94.    geninterrupt(0x21);            /* Display message using DOS function 9 */
  95.    exit(1);                       /* Exit with errorlevel 1 */
  96. }
  97.  
  98.  
  99.