Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

196 lines
6.2 KiB

  1. /* File: D:\WACKER\emu\vt100ini.c (Created: 27-Dec-1993)
  2. *
  3. * Copyright 1994, 1998 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 1 $
  7. * $Date: 10/05/98 12:29p $
  8. */
  9. #include <windows.h>
  10. #pragma hdrstop
  11. #include <tdll\stdtyp.h>
  12. #include <tdll\session.h>
  13. #include <tdll\assert.h>
  14. #include <tdll\mc.h>
  15. #include <tdll\backscrl.h>
  16. #include "emu.h"
  17. #include "emu.hh"
  18. #include "emuid.h"
  19. #include "emudec.hh"
  20. #include "keytbls.h"
  21. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  22. * vt100_init
  23. *
  24. * DESCRIPTION:
  25. * Initializes the VT100 emulator.
  26. *
  27. * ARGUMENTS:
  28. *
  29. * RETURNS:
  30. * nothing
  31. */
  32. void vt100_init(const HHEMU hhEmu)
  33. {
  34. PSTDECPRIVATE pstPRI;
  35. int iRow;
  36. static struct trans_entry const vt100_tbl[] =
  37. {
  38. {NEW_STATE, 0, 0, 0}, // State 0
  39. #if !defined(FAR_EAST)
  40. {0, ETEXT('\x20'), ETEXT('\x7E'), emuDecGraphic}, // Space - ~
  41. #else
  42. {0, ETEXT('\x20'), 0xFFFF, emuDecGraphic}, // Space - ~
  43. #endif
  44. {1, ETEXT('\x1B'), ETEXT('\x1B'), nothing}, // Esc
  45. {0, ETEXT('\x05'), ETEXT('\x05'), vt100_answerback}, // Ctrl-E
  46. {0, ETEXT('\x07'), ETEXT('\x07'), emu_bell}, // Ctrl-G
  47. {0, ETEXT('\x08'), ETEXT('\x08'), vt_backspace}, // BackSpace
  48. {0, ETEXT('\x09'), ETEXT('\x09'), emuDecTab}, // Tab
  49. {0, ETEXT('\x0A'), ETEXT('\x0C'), emuLineFeed}, // NL - FF
  50. {0, ETEXT('\x0D'), ETEXT('\x0D'), carriagereturn}, // CR
  51. {0, ETEXT('\x0E'), ETEXT('\x0F'), vt_charshift}, // Ctrl-N
  52. {7, ETEXT('\x18'), ETEXT('\x18'), EmuStdChkZmdm}, // Ctrl-X
  53. {NEW_STATE, 0, 0, 0}, // State 1 // Esc
  54. {2, ETEXT('\x5B'), ETEXT('\x5B'), ANSI_Pn_Clr}, // [
  55. {3, ETEXT('\x23'), ETEXT('\x23'), nothing}, // #
  56. {4, ETEXT('\x28'), ETEXT('\x29'), vt_scs1}, // ( - )
  57. {0, ETEXT('\x37'), ETEXT('\x38'), vt100_savecursor}, // 7 - 8
  58. {1, ETEXT('\x3B'), ETEXT('\x3B'), ANSI_Pn_End}, // ;
  59. {0, ETEXT('\x3D'), ETEXT('\x3E'), vt_alt_kpmode}, // = - >
  60. {0, ETEXT('\x44'), ETEXT('\x44'), emuDecIND}, // D
  61. {0, ETEXT('\x45'), ETEXT('\x45'), ANSI_NEL}, // E
  62. {0, ETEXT('\x48'), ETEXT('\x48'), ANSI_HTS}, // H
  63. {0, ETEXT('\x4D'), ETEXT('\x4D'), emuDecRI}, // M
  64. {0, ETEXT('\x5A'), ETEXT('\x5A'), ANSI_DA}, // Z
  65. {0, ETEXT('\x63'), ETEXT('\x63'), vt100_hostreset}, // c
  66. {NEW_STATE, 0, 0, 0}, // State 2 // Esc[
  67. {2, ETEXT('\x3B'), ETEXT('\x3B'), ANSI_Pn_End}, // ;
  68. {2, ETEXT('\x30'), ETEXT('\x3F'), ANSI_Pn}, // 0 - ?
  69. {5, ETEXT('\x22'), ETEXT('\x22'), nothing}, // "
  70. {0, ETEXT('\x41'), ETEXT('\x41'), emuDecCUU}, // A
  71. {0, ETEXT('\x42'), ETEXT('\x42'), emuDecCUD}, // B
  72. {0, ETEXT('\x43'), ETEXT('\x43'), emuDecCUF}, // C
  73. {0, ETEXT('\x44'), ETEXT('\x44'), emuDecCUB}, // D
  74. {0, ETEXT('\x48'), ETEXT('\x48'), emuDecCUP}, // H
  75. {0, ETEXT('\x4A'), ETEXT('\x4A'), emuDecED}, // J
  76. {0, ETEXT('\x4B'), ETEXT('\x4B'), ANSI_EL}, // K
  77. {0, ETEXT('\x4C'), ETEXT('\x4C'), vt_IL}, // L
  78. {0, ETEXT('\x4D'), ETEXT('\x4D'), vt_DL}, // M
  79. {0, ETEXT('\x50'), ETEXT('\x50'), vt_DCH}, // P
  80. {0, ETEXT('\x63'), ETEXT('\x63'), ANSI_DA}, // c
  81. {0, ETEXT('\x66'), ETEXT('\x66'), emuDecCUP}, // f
  82. {0, ETEXT('\x67'), ETEXT('\x67'), ANSI_TBC}, // g
  83. {0, ETEXT('\x68'), ETEXT('\x68'), ANSI_SM}, // h
  84. {0, ETEXT('\x69'), ETEXT('\x69'), vt100PrintCommands},// i
  85. {0, ETEXT('\x6C'), ETEXT('\x6C'), ANSI_RM}, // l
  86. {0, ETEXT('\x6D'), ETEXT('\x6D'), ANSI_SGR}, // m
  87. {0, ETEXT('\x6E'), ETEXT('\x6E'), ANSI_DSR}, // n
  88. {0, ETEXT('\x71'), ETEXT('\x71'), nothing}, // q
  89. {0, ETEXT('\x72'), ETEXT('\x72'), vt_scrollrgn}, // r
  90. {0, ETEXT('\x78'), ETEXT('\x78'), vt100_report}, // x
  91. {NEW_STATE, 0, 0, 0}, // State 3 // Esc#
  92. {0, ETEXT('\x33'), ETEXT('\x36'), emuSetDoubleAttr}, // 3 - 6
  93. {0, ETEXT('\x38'), ETEXT('\x38'), vt_screen_adjust}, // 8
  94. {NEW_STATE, 0, 0, 0}, // State 4 // Esc ( - )
  95. {0, ETEXT('\x01'), ETEXT('\xFF'), vt_scs2}, // All
  96. {NEW_STATE, 0, 0, 0}, // State 5 // Esc["
  97. {0, ETEXT('\x70'), ETEXT('\x70'), nothing}, // p
  98. {NEW_STATE, 0, 0, 0}, // State 6 // Printer control
  99. {6, ETEXT('\x00'), ETEXT('\xFF'), vt100_prnc}, // All
  100. {NEW_STATE, 0, 0, 0}, // State 7 // Ctrl-X
  101. {7, ETEXT('\x00'), ETEXT('\xFF'), EmuStdChkZmdm}, // All
  102. };
  103. emuInstallStateTable(hhEmu, vt100_tbl, DIM(vt100_tbl));
  104. // Allocate space for and initialize data that is used only by the
  105. // VT100 emulator.
  106. //
  107. hhEmu->pvPrivate = malloc(sizeof(DECPRIVATE));
  108. if (hhEmu->pvPrivate == 0)
  109. {
  110. assert(FALSE);
  111. return;
  112. }
  113. pstPRI = (PSTDECPRIVATE)hhEmu->pvPrivate;
  114. memset(pstPRI, 0, sizeof(DECPRIVATE));
  115. // Allocate an array to hold line attribute values.
  116. //
  117. pstPRI->aiLineAttr = malloc(MAX_EMUROWS * sizeof(int) );
  118. if (pstPRI->aiLineAttr == 0)
  119. {
  120. assert(FALSE);
  121. return;
  122. }
  123. for (iRow = 0; iRow < MAX_EMUROWS; iRow++)
  124. pstPRI->aiLineAttr[iRow] = NO_LINE_ATTR;
  125. pstPRI->sv_row = 0;
  126. pstPRI->sv_col = 0;
  127. pstPRI->gn = 0;
  128. pstPRI->sv_AWM = RESET;
  129. pstPRI->sv_DECOM = RESET;
  130. pstPRI->sv_protectmode = FALSE;
  131. pstPRI->fAttrsSaved = FALSE;
  132. pstPRI->pntr = pstPRI->storage;
  133. // Initialize hhEmu values for VT100.
  134. //
  135. hhEmu->emu_kbdin = vt100_kbdin;
  136. hhEmu->emuResetTerminal = vt100_reset;
  137. hhEmu->emu_setcurpos = emuDecSetCurPos;
  138. hhEmu->emu_deinstall = emuVT100Unload;
  139. hhEmu->emu_clearscreen = emuDecClearScreen;
  140. #if !defined(FAR_EAST)
  141. hhEmu->emu_highchar = 0x7E;
  142. #else
  143. hhEmu->emu_highchar = 0xFFFF;
  144. #endif
  145. hhEmu->emu_maxcol = VT_MAXCOL_80MODE;
  146. hhEmu->mode_vt220 = FALSE;
  147. std_dsptbl(hhEmu, TRUE);
  148. vt_charset_init(hhEmu);
  149. emuKeyTableLoad(hhEmu, VT100KeyTable,
  150. sizeof(VT100KeyTable)/sizeof(KEYTBLSTORAGE),
  151. &hhEmu->stEmuKeyTbl);
  152. emuKeyTableLoad(hhEmu, VT100_Keypad_KeyTable,
  153. sizeof(VT100_Keypad_KeyTable)/sizeof(KEYTBLSTORAGE),
  154. &hhEmu->stEmuKeyTbl2);
  155. emuKeyTableLoad(hhEmu, VT100_Cursor_KeyTable,
  156. sizeof(VT100_Cursor_KeyTable)/sizeof(KEYTBLSTORAGE),
  157. &hhEmu->stEmuKeyTbl3);
  158. emuKeyTableLoad(hhEmu, VT_PF_KeyTable,
  159. sizeof(VT_PF_KeyTable)/sizeof(KEYTBLSTORAGE),
  160. &hhEmu->stEmuKeyTbl4);
  161. backscrlSetShowFlag(sessQueryBackscrlHdl(hhEmu->hSession), TRUE);
  162. return;
  163. }
  164. /* end of vt100ini.c */