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.

2770 lines
82 KiB

  1. /* File: D:\WACKER\emu\emuhdl.c (Created: 10-Dec-1993)
  2. *
  3. * Copyright 1994-2001 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 22 $
  7. * $Date: 7/08/02 6:33p $
  8. */
  9. #include <windows.h>
  10. #pragma hdrstop
  11. // #define DEBUGSTR
  12. #include <time.h>
  13. #include <tapi.h>
  14. #include <tdll\stdtyp.h>
  15. #include <tdll\mc.h>
  16. #include <tdll\assert.h>
  17. #include <tdll\sf.h>
  18. #include <tdll\sess_ids.h>
  19. #include <tdll\session.h>
  20. #include <tdll\capture.h>
  21. #include <tdll\cloop.h>
  22. #include <tdll\term.h>
  23. #include <tdll\print.h>
  24. #include <tdll\update.h>
  25. #include <tdll\load_res.h>
  26. #include <tdll\globals.h>
  27. #include <tdll\statusbr.h>
  28. #include <tdll\cnct.h>
  29. #include <tdll\cnct.hh>
  30. #include <tdll\htchar.h>
  31. #include <tdll\com.h>
  32. #include <tdll\errorbox.h> // TimedMessageBox()
  33. #include <cncttapi\cncttapi.hh> // cncttapiSetLineConfig()
  34. #include <term\res.h>
  35. #include "emu.h"
  36. #include "emu.hh"
  37. #include "emuid.h"
  38. #include "viewdata.hh"
  39. #include "minitel.hh"
  40. #include "emudec.hh"
  41. #include "keytbls.h"
  42. // Function prototypes...
  43. //
  44. STATIC_FUNC int emuLoadSettings(const HHEMU hhEmu,
  45. const unsigned int uiId,
  46. unsigned long ulDataSize,
  47. void *pvData);
  48. STATIC_FUNC void emuCheckSettings(struct stEmuBaseSFSettings *pstBaseSettings);
  49. // Keytable declarations
  50. //
  51. const KEYTBLSTORAGE AnsiKeyTable[MAX_ANSI_KEYS] =
  52. {
  53. {VK_UP | VIRTUAL_KEY, {"\x1B[A\xff"}},
  54. {VK_DOWN | VIRTUAL_KEY, {"\x1B[B\xff"}},
  55. {VK_RIGHT | VIRTUAL_KEY, {"\x1B[C\xff"}},
  56. {VK_LEFT | VIRTUAL_KEY, {"\x1B[D\xff"}},
  57. // Added 27 Aug 98 rde
  58. {VK_HOME | VIRTUAL_KEY, {"\x1B[H\xff"}},
  59. {VK_END | VIRTUAL_KEY, {"\x1B[K\xff"}},
  60. //VK_UP | VIRTUAL_KEY | CTRL_KEY, "\x1BOx\xff",
  61. //VK_DOWN | VIRTUAL_KEY | CTRL_KEY, "\x1BOr\xff",
  62. //VK_RIGHT | VIRTUAL_KEY | CTRL_KEY, "\x1BOv\xff",
  63. //VK_LEFT | VIRTUAL_KEY | CTRL_KEY, "\x1BOt\xff",
  64. //VK_HOME | VIRTUAL_KEY, "\x1B[H\xff",
  65. //VK_END | VIRTUAL_KEY, "\x1B[K\xff",
  66. //VK_HOME | VIRTUAL_KEY | CTRL_KEY, "\x1BOw\xff",
  67. //VK_END | VIRTUAL_KEY | CTRL_KEY, "\x1BOq\xff",
  68. //VK_PRIOR | VIRTUAL_KEY, "\x1B[M\xff",
  69. //VK_NEXT | VIRTUAL_KEY, "\x1B[H\x1B[2J\xff",
  70. //VK_PRIOR | VIRTUAL_KEY | CTRL_KEY, "\x1BOy\xff",
  71. //VK_NEXT | VIRTUAL_KEY | CTRL_KEY, "\x1BOs\xff",
  72. //VK_RETURN | VIRTUAL_KEY, "\x0D\xff",
  73. //VK_RETURN | VIRTUAL_KEY | CTRL_KEY, "\x1BOM\xff",
  74. //VK_INSERT | VIRTUAL_KEY | CTRL_KEY, "\x1BOp\xff",
  75. /* -------------- Function keys ------------- */
  76. {VK_F1 | VIRTUAL_KEY, {"\x1BOP\xff"}},
  77. {VK_F2 | VIRTUAL_KEY, {"\x1BOQ\xff"}},
  78. {VK_F3 | VIRTUAL_KEY, {"\x1BOR\xff"}},
  79. {VK_F4 | VIRTUAL_KEY, {"\x1BOS\xff"}},
  80. /* -------------- Gray keys, (extended edit pad) ------------- */
  81. {VK_UP | VIRTUAL_KEY | EXTENDED_KEY, {"\x1B[A\xff"}},
  82. {VK_DOWN | VIRTUAL_KEY | EXTENDED_KEY, {"\x1B[B\xff"}},
  83. {VK_RIGHT | VIRTUAL_KEY | EXTENDED_KEY, {"\x1B[C\xff"}},
  84. {VK_LEFT | VIRTUAL_KEY | EXTENDED_KEY, {"\x1B[D\xff"}},
  85. // Added 27 Aug 98 rde
  86. {VK_HOME | VIRTUAL_KEY | EXTENDED_KEY, {"\x1B[H\xff"}},
  87. {VK_END | VIRTUAL_KEY | EXTENDED_KEY, {"\x1B[K\xff"}},
  88. //VK_HOME | VIRTUAL_KEY | EXTENDED_KEY, "\x1B[H\xff",
  89. //VK_END | VIRTUAL_KEY | EXTENDED_KEY, "\x1B[K\xff",
  90. //VK_PRIOR | VIRTUAL_KEY | EXTENDED_KEY, "\x1B[M\xff",
  91. //VK_NEXT | VIRTUAL_KEY | EXTENDED_KEY, "\x1B[H\x1B[2J\xff",
  92. {VK_TAB | VIRTUAL_KEY | SHIFT_KEY,{"\x1B\x5B\x5A\xff"}}, /* KT_SHIFT + KN_TAB */
  93. };
  94. /* Also for ANSI emulator */
  95. const KEYTBLSTORAGE IBMPCKeyTable[MAX_IBMPC_KEYS] =
  96. {
  97. {VK_BACK, {"\x08\xff"}}, /* KN_BS */
  98. {VK_DELETE | VIRTUAL_KEY, {"\x00\x53\xff"}}, /* KN_DEL */
  99. {VK_DOWN | VIRTUAL_KEY, {"\x00\x50\xff"}}, /* KN_DOWN */
  100. {VK_END | VIRTUAL_KEY, {"\x00\x4F\xff"}}, /* KN_END */
  101. {VK_RETURN, {"\x0D\xff"}}, /* KN_ENTER */
  102. {VK_ESCAPE, {"\x1B\xff"}}, /* KN_ESC */
  103. {VK_F1 | VIRTUAL_KEY, {"\x00\x3B\xff"}}, /* KN_F1 */
  104. {VK_F2 | VIRTUAL_KEY, {"\x00\x3C\xff"}}, /* KN_F2 */
  105. {VK_F3 | VIRTUAL_KEY, {"\x00\x3D\xff"}}, /* KN_F3 */
  106. {VK_F4 | VIRTUAL_KEY, {"\x00\x3E\xff"}}, /* KN_F4 */
  107. {VK_F5 | VIRTUAL_KEY, {"\x00\x3F\xff"}}, /* KN_F5 */
  108. {VK_F6 | VIRTUAL_KEY, {"\x00\x40\xff"}}, /* KN_F6 */
  109. {VK_F7 | VIRTUAL_KEY, {"\x00\x41\xff"}}, /* KN_F7 */
  110. {VK_F8 | VIRTUAL_KEY, {"\x00\x42\xff"}}, /* KN_F8 */
  111. {VK_F9 | VIRTUAL_KEY, {"\x00\x43\xff"}}, /* KN_F9 */
  112. {VK_F10 | VIRTUAL_KEY, {"\x00\x44\xff"}}, /* KN_F10 */
  113. {VK_F11 | VIRTUAL_KEY, {"\x00\x85\xff"}}, /* KN_F11 */
  114. {VK_F12 | VIRTUAL_KEY, {"\x00\x86\xff"}}, /* KN_F12 */
  115. {VK_HOME | VIRTUAL_KEY, {"\x00\x47\xff"}}, /* KN_HOME */
  116. {VK_INSERT | VIRTUAL_KEY, {"\x00\x52\xff"}}, /* KN_INS */
  117. {VK_LEFT | VIRTUAL_KEY, {"\x00\x4B\xff"}}, /* KN_LEFT */
  118. {VK_NEXT | VIRTUAL_KEY, {"\x00\x51\xff"}}, /* KN_PGDN */
  119. {VK_PRIOR | VIRTUAL_KEY, {"\x00\x49\xff"}}, /* KN_PGUP */
  120. {VK_RIGHT | VIRTUAL_KEY, {"\x00\x4D\xff"}}, /* KN_RIGHT */
  121. {VK_TAB, {"\x09\xff"}}, /* KN_TAB */
  122. {VK_UP | VIRTUAL_KEY, {"\x00\x48\xff"}}, /* KN_UP */
  123. {VK_BACK | VIRTUAL_KEY | CTRL_KEY, {"\x7F\xff"}}, /* KT_CTRL + KN_BS */
  124. {VK_DELETE | VIRTUAL_KEY | CTRL_KEY, {"\x00\x93\xff"}}, /* KT_CTRL + KN_DEL */
  125. {VK_DOWN | VIRTUAL_KEY | CTRL_KEY, {"\x00\x91\xff"}}, /* KT_CTRL + KN_DOWN */
  126. {VK_END | VIRTUAL_KEY | CTRL_KEY, {"\x00\x75\xff"}}, /* KT_CTRL + KN_END */
  127. {VK_RETURN | VIRTUAL_KEY | CTRL_KEY, {"\x0A\xff"}}, /* KT_CTRL + KN_ENTER */
  128. {VK_F1 | VIRTUAL_KEY | CTRL_KEY, {"\x00\x5E\xff"}}, /* KT_CTRL + KN_F1 */
  129. {VK_F10 | VIRTUAL_KEY | CTRL_KEY, {"\x00\x67\xff"}}, /* KT_CTRL + KN_F10 */
  130. {VK_F11 | VIRTUAL_KEY | CTRL_KEY, {"\x00\x89\xff"}}, /* KT_CTRL + KN_F11 */
  131. {VK_F12 | VIRTUAL_KEY | CTRL_KEY, {"\x00\x8A\xff"}}, /* KT_CTRL + KN_F12 */
  132. {VK_F2 | VIRTUAL_KEY | CTRL_KEY, {"\x00\x5F\xff"}}, /* KT_CTRL + KN_F2 */
  133. {VK_F3 | VIRTUAL_KEY | CTRL_KEY, {"\x00\x60\xff"}}, /* KT_CTRL + KN_F3 */
  134. {VK_F4 | VIRTUAL_KEY | CTRL_KEY, {"\x00\x61\xff"}}, /* KT_CTRL + KN_F4 */
  135. {VK_F5 | VIRTUAL_KEY | CTRL_KEY, {"\x00\x62\xff"}}, /* KT_CTRL + KN_F5 */
  136. {VK_F6 | VIRTUAL_KEY | CTRL_KEY, {"\x00\x63\xff"}}, /* KT_CTRL + KN_F6 */
  137. {VK_F7 | VIRTUAL_KEY | CTRL_KEY, {"\x00\x64\xff"}}, /* KT_CTRL + KN_F7 */
  138. {VK_F8 | VIRTUAL_KEY | CTRL_KEY, {"\x00\x65\xff"}}, /* KT_CTRL + KN_F8 */
  139. {VK_F9 | VIRTUAL_KEY | CTRL_KEY, {"\x00\x66\xff"}}, /* KT_CTRL + KN_F9 */
  140. {VK_HOME | VIRTUAL_KEY | CTRL_KEY, {"\x00\x77\xff"}}, /* KT_CTRL + KN_HOME */
  141. {VK_INSERT | VIRTUAL_KEY | CTRL_KEY, {"\x00\x92\xff"}}, /* KT_CTRL + KN_INS */
  142. {VK_LEFT | VIRTUAL_KEY | CTRL_KEY, {"\x00\x73\xff"}}, /* KT_CTRL + KN_LEFT */
  143. {VK_F1 | VIRTUAL_KEY | CTRL_KEY, {"\x00\x8F\xff"}}, /* KT_CTRL + KN_MID */
  144. {VK_PRIOR | VIRTUAL_KEY | CTRL_KEY, {"\x00\x76\xff"}}, /* KT_CTRL + KN_PGDN */
  145. {VK_NEXT | VIRTUAL_KEY | CTRL_KEY, {"\x00\x84\xff"}}, /* KT_CTRL + KN_PGUP */
  146. {VK_PRINT | VIRTUAL_KEY | CTRL_KEY, {"\x00\x72\xff"}}, /* KT_CTRL + KN_PRTSC */
  147. {VK_RIGHT | VIRTUAL_KEY | CTRL_KEY, {"\x00\x74\xff"}}, /* KT_CTRL + KN_RIGHT */
  148. {VK_TAB | VIRTUAL_KEY | CTRL_KEY, {"\x00\x94\xff"}}, /* KT_CTRL + KN_TAB */
  149. {VK_UP | VIRTUAL_KEY | CTRL_KEY, {"\x00\x8D\xff"}}, /* KT_CTRL + KN_UP */
  150. {VK_F1 | VIRTUAL_KEY | SHIFT_KEY,{"\x00\x54\xff"}}, /* KT_SHIFT + KN_F1 */
  151. {VK_F10 | VIRTUAL_KEY | SHIFT_KEY,{"\x00\x5D\xff"}}, /* KT_SHIFT + KN_F10 */
  152. {VK_F11 | VIRTUAL_KEY | SHIFT_KEY,{"\x00\x87\xff"}}, /* KT_SHIFT + KN_F11 */
  153. {VK_F12 | VIRTUAL_KEY | SHIFT_KEY,{"\x00\x88\xff"}}, /* KT_SHIFT + KN_F12 */
  154. {VK_F2 | VIRTUAL_KEY | SHIFT_KEY,{"\x00\x55\xff"}}, /* KT_SHIFT + KN_F2 */
  155. {VK_F3 | VIRTUAL_KEY | SHIFT_KEY,{"\x00\x56\xff"}}, /* KT_SHIFT + KN_F3 */
  156. {VK_F4 | VIRTUAL_KEY | SHIFT_KEY,{"\x00\x57\xff"}}, /* KT_SHIFT + KN_F4 */
  157. {VK_F5 | VIRTUAL_KEY | SHIFT_KEY,{"\x00\x58\xff"}}, /* KT_SHIFT + KN_F5 */
  158. {VK_F6 | VIRTUAL_KEY | SHIFT_KEY,{"\x00\x59\xff"}}, /* KT_SHIFT + KN_F6 */
  159. {VK_F7 | VIRTUAL_KEY | SHIFT_KEY,{"\x00\x5A\xff"}}, /* KT_SHIFT + KN_F7 */
  160. {VK_F8 | VIRTUAL_KEY | SHIFT_KEY,{"\x00\x5B\xff"}}, /* KT_SHIFT + KN_F8 */
  161. {VK_F9 | VIRTUAL_KEY | SHIFT_KEY,{"\x00\x5C\xff"}}, /* KT_SHIFT + KN_F9 */
  162. {VK_TAB | VIRTUAL_KEY | SHIFT_KEY,{"\x00\x0F\xff"}}, /* KT_SHIFT + KN_TAB */
  163. {0x5C | ALT_KEY | VIRTUAL_KEY, {"\x00\x28\xff"}}, /* KT_ALT + '\'' */
  164. {0x2C | ALT_KEY | VIRTUAL_KEY, {"\x00\x33\xff"}}, /* KT_ALT + ',' */
  165. {0x2D | ALT_KEY | VIRTUAL_KEY, {"\x00\x82\xff"}}, /* KT_ALT + '-' */
  166. {0x2E | ALT_KEY | VIRTUAL_KEY, {"\x00\x34\xff"}}, /* KT_ALT + '.' */
  167. {0x2F | ALT_KEY | VIRTUAL_KEY, {"\x00\x35\xff"}}, /* KT_ALT + '/' */
  168. {0x30 | ALT_KEY | VIRTUAL_KEY, {"\x00\x81\xff"}}, /* KT_ALT + '0' */
  169. {0x31 | ALT_KEY | VIRTUAL_KEY, {"\x00\x78\xff"}}, /* KT_ALT + '1' */
  170. {0x32 | ALT_KEY | VIRTUAL_KEY, {"\x00\x79\xff"}}, /* KT_ALT + '2' */
  171. {0x33 | ALT_KEY | VIRTUAL_KEY, {"\x00\x7A\xff"}}, /* KT_ALT + '3' */
  172. {0x34 | ALT_KEY | VIRTUAL_KEY, {"\x00\x7B\xff"}}, /* KT_ALT + '4' */
  173. {0x35 | ALT_KEY | VIRTUAL_KEY, {"\x00\x7C\xff"}}, /* KT_ALT + '5' */
  174. {0x36 | ALT_KEY | VIRTUAL_KEY, {"\x00\x7D\xff"}}, /* KT_ALT + '6' */
  175. {0x37 | ALT_KEY | VIRTUAL_KEY, {"\x00\x7E\xff"}}, /* KT_ALT + '7' */
  176. {0x38 | ALT_KEY | VIRTUAL_KEY, {"\x00\x7F\xff"}}, /* KT_ALT + '8' */
  177. {0x39 | ALT_KEY | VIRTUAL_KEY, {"\x00\x80\xff"}}, /* KT_ALT + '9' */
  178. {0x3B | ALT_KEY | VIRTUAL_KEY, {"\x00\x27\xff"}}, /* KT_ALT + ';' */
  179. {0x3D | ALT_KEY | VIRTUAL_KEY, {"\x00\x83\xff"}}, /* KT_ALT + '=' */
  180. {0x41 | ALT_KEY | VIRTUAL_KEY, {"\x00\x1E\xff"}}, /* KT_ALT + 'A' */
  181. {0x42 | ALT_KEY | VIRTUAL_KEY, {"\x00\x30\xff"}}, /* KT_ALT + 'B' */
  182. {0x43 | ALT_KEY | VIRTUAL_KEY, {"\x00\x2E\xff"}}, /* KT_ALT + 'C' */
  183. {0x44 | ALT_KEY | VIRTUAL_KEY, {"\x00\x20\xff"}}, /* KT_ALT + 'D' */
  184. {0x45 | ALT_KEY | VIRTUAL_KEY, {"\x00\x12\xff"}}, /* KT_ALT + 'E' */
  185. {0x46 | ALT_KEY | VIRTUAL_KEY, {"\x00\x21\xff"}}, /* KT_ALT + 'F' */
  186. {0x47 | ALT_KEY | VIRTUAL_KEY, {"\x00\x22\xff"}}, /* KT_ALT + 'G' */
  187. {0x48 | ALT_KEY | VIRTUAL_KEY, {"\x00\x23\xff"}}, /* KT_ALT + 'H' */
  188. {0x49 | ALT_KEY | VIRTUAL_KEY, {"\x00\x17\xff"}}, /* KT_ALT + 'I' */
  189. {0x4A | ALT_KEY | VIRTUAL_KEY, {"\x00\x24\xff"}}, /* KT_ALT + 'J' */
  190. {0x4B | ALT_KEY | VIRTUAL_KEY, {"\x00\x25\xff"}}, /* KT_ALT + 'K' */
  191. {0x4C | ALT_KEY | VIRTUAL_KEY, {"\x00\x26\xff"}}, /* KT_ALT + 'L' */
  192. {0x4D | ALT_KEY | VIRTUAL_KEY, {"\x00\x32\xff"}}, /* KT_ALT + 'M' */
  193. {0x4E | ALT_KEY | VIRTUAL_KEY, {"\x00\x31\xff"}}, /* KT_ALT + 'N' */
  194. {0x4F | ALT_KEY | VIRTUAL_KEY, {"\x00\x18\xff"}}, /* KT_ALT + 'O' */
  195. {0x50 | ALT_KEY | VIRTUAL_KEY, {"\x00\x19\xff"}}, /* KT_ALT + 'P' */
  196. {0x51 | ALT_KEY | VIRTUAL_KEY, {"\x00\x10\xff"}}, /* KT_ALT + 'Q' */
  197. {0x52 | ALT_KEY | VIRTUAL_KEY, {"\x00\x13\xff"}}, /* KT_ALT + 'R' */
  198. {0x53 | ALT_KEY | VIRTUAL_KEY, {"\x00\x1F\xff"}}, /* KT_ALT + 'S' */
  199. {0x54 | ALT_KEY | VIRTUAL_KEY, {"\x00\x14\xff"}}, /* KT_ALT + 'T' */
  200. {0x55 | ALT_KEY | VIRTUAL_KEY, {"\x00\x16\xff"}}, /* KT_ALT + 'U' */
  201. {0x56 | ALT_KEY | VIRTUAL_KEY, {"\x00\x2F\xff"}}, /* KT_ALT + 'V' */
  202. {0x57 | ALT_KEY | VIRTUAL_KEY, {"\x00\x11\xff"}}, /* KT_ALT + 'W' */
  203. {0x58 | ALT_KEY | VIRTUAL_KEY, {"\x00\x2D\xff"}}, /* KT_ALT + 'X' */
  204. {0x59 | ALT_KEY | VIRTUAL_KEY, {"\x00\x15\xff"}}, /* KT_ALT + 'Y' */
  205. {0x5A | ALT_KEY | VIRTUAL_KEY, {"\x00\x2C\xff"}}, /* KT_ALT + 'Z' */
  206. {0x5B | ALT_KEY | VIRTUAL_KEY, {"\x00\x1A\xff"}}, /* KT_ALT + '[' */
  207. {0x5D | ALT_KEY | VIRTUAL_KEY, {"\x00\x1B\xff"}}, /* KT_ALT + ']' */
  208. {0x60 | ALT_KEY | VIRTUAL_KEY, {"\x00\x29\xff"}}, /* KT_ALT + '`' */
  209. {VK_BACK | VIRTUAL_KEY | ALT_KEY, {"\x00\x0E\xff"}}, /* KT_ALT + KN_BS */
  210. {VK_RETURN | VIRTUAL_KEY | ALT_KEY, {"\x00\x1C\xff"}}, /* KT_ALT + KN_ENTER */
  211. {VK_ESCAPE | VIRTUAL_KEY | ALT_KEY, {"\x00\x01\xff"}}, /* KT_ALT + KN_ESC */
  212. {VK_F1 | VIRTUAL_KEY | ALT_KEY, {"\x00\x68\xff"}}, /* KT_ALT + KN_F1 */
  213. {VK_F10 | VIRTUAL_KEY | ALT_KEY, {"\x00\x71\xff"}}, /* KT_ALT + KN_F10 */
  214. {VK_F11 | VIRTUAL_KEY | ALT_KEY, {"\x00\x8B\xff"}}, /* KT_ALT + KN_F11 */
  215. {VK_F12 | VIRTUAL_KEY | ALT_KEY, {"\x00\x8C\xff"}}, /* KT_ALT + KN_F12 */
  216. {VK_F2 | VIRTUAL_KEY | ALT_KEY, {"\x00\x69\xff"}}, /* KT_ALT + KN_F2 */
  217. {VK_F3 | VIRTUAL_KEY | ALT_KEY, {"\x00\x6A\xff"}}, /* KT_ALT + KN_F3 */
  218. {VK_F4 | VIRTUAL_KEY | ALT_KEY, {"\x00\x6B\xff"}}, /* KT_ALT + KN_F4 */
  219. {VK_F5 | VIRTUAL_KEY | ALT_KEY, {"\x00\x6C\xff"}}, /* KT_ALT + KN_F5 */
  220. {VK_F6 | VIRTUAL_KEY | ALT_KEY, {"\x00\x6D\xff"}}, /* KT_ALT + KN_F6 */
  221. {VK_F7 | VIRTUAL_KEY | ALT_KEY, {"\x00\x6E\xff"}}, /* KT_ALT + KN_F7 */
  222. {VK_F8 | VIRTUAL_KEY | ALT_KEY, {"\x00\x6F\xff"}}, /* KT_ALT + KN_F8 */
  223. {VK_F9 | VIRTUAL_KEY | ALT_KEY, {"\x00\x70\xff"}}, /* KT_ALT + KN_F9 */
  224. {VK_TAB | VIRTUAL_KEY | ALT_KEY, {"\x00\xA5\xff"}}, /* KT_ALT + KN_TAB */
  225. {VK_RETURN | EXTENDED_KEY, {"\x00\xE0\x0D\xff"}}, /* KT_KP + KN_ENTER */
  226. {0x2F | EXTENDED_KEY, {"\x00\xE0\x2F\xff"}}, /* KT_KP + '/' */
  227. {VK_MULTIPLY | VIRTUAL_KEY, {"\x2A\xff"}}, /* KT_KP + '*' */
  228. {VK_ADD | VIRTUAL_KEY, {"\x2B\xff"}}, /* KT_KP + '+' */
  229. {VK_SUBTRACT | VIRTUAL_KEY, {"\x2D\xff"}}, /* KT_KP + '-' */
  230. {VK_DECIMAL | VIRTUAL_KEY, {"\x2E\xff"}}, /* KT_KP + '.' */
  231. {VK_NUMPAD0 | VIRTUAL_KEY, {"\x30\xff"}}, /* KT_KP + '0' */
  232. {VK_NUMPAD1 | VIRTUAL_KEY, {"\x31\xff"}}, /* KT_KP + '1' */
  233. {VK_NUMPAD2 | VIRTUAL_KEY, {"\x32\xff"}}, /* KT_KP + '2' */
  234. {VK_NUMPAD3 | VIRTUAL_KEY, {"\x33\xff"}}, /* KT_KP + '3' */
  235. {VK_NUMPAD4 | VIRTUAL_KEY, {"\x34\xff"}}, /* KT_KP + '4' */
  236. {VK_NUMPAD5 | VIRTUAL_KEY, {"\x35\xff"}}, /* KT_KP + '5' */
  237. {VK_NUMPAD6 | VIRTUAL_KEY, {"\x36\xff"}}, /* KT_KP + '6' */
  238. {VK_NUMPAD7 | VIRTUAL_KEY, {"\x37\xff"}}, /* KT_KP + '7' */
  239. {VK_NUMPAD8 | VIRTUAL_KEY, {"\x38\xff"}}, /* KT_KP + '8' */
  240. {VK_NUMPAD9 | VIRTUAL_KEY, {"\x39\xff"}}, /* KT_KP + '9' */
  241. {VK_MULTIPLY | VIRTUAL_KEY | CTRL_KEY, {"\x00\x96\xff"}}, /* KT_CTRL + KT_KP + '*' */
  242. {VK_ADD | VIRTUAL_KEY | CTRL_KEY, {"\x00\x90\xff"}}, /* KT_CTRL + KT_KP + '+' */
  243. {VK_SUBTRACT | VIRTUAL_KEY | CTRL_KEY, {"\x00\x8E\xff"}}, /* KT_CTRL + KT_KP + '-' */
  244. {VK_DIVIDE | VIRTUAL_KEY | EXTENDED_KEY | CTRL_KEY, {"\x00\x95\xff"}}, /* KT_CTRL + KT_KP + '/' */
  245. {0x0a | EXTENDED_KEY | CTRL_KEY, {"\x0A\xff"}}, /* KT_CTRL+KT_KP+KN_ENTER */
  246. {VK_MULTIPLY | VIRTUAL_KEY | ALT_KEY, {"\x00\x37\xff"}}, /* KT_ALT + KT_KP + '*' */
  247. {VK_ADD | VIRTUAL_KEY | ALT_KEY, {"\x00\x4E\xff"}}, /* KT_ALT + KT_KP + '+' */
  248. {VK_SUBTRACT | VIRTUAL_KEY | ALT_KEY, {"\x00\x4A\xff"}}, /* KT_ALT + KT_KP + '-' */
  249. {VK_DIVIDE | VIRTUAL_KEY | ALT_KEY, {"\x00\xA4\xff"}}, /* KT_ALT + KT_KP + '/' */
  250. {0x0d | VIRTUAL_KEY | EXTENDED_KEY | ALT_KEY, {"\x00\xA6\xff"}}, /* KT_ALT + KT_KP +KN_ENTER */
  251. {VK_DELETE | VIRTUAL_KEY | EXTENDED_KEY, {"\x00\xE0\x53\xff"}}, /* KT_EP +KN_DEL */
  252. {VK_DOWN | VIRTUAL_KEY | EXTENDED_KEY, {"\x00\xE0\x50\xff"}}, /* KT_EP +KN_DOWN */
  253. {VK_END | VIRTUAL_KEY | EXTENDED_KEY, {"\x00\xE0\x4F\xff"}}, /* KT_EP +KN_END */
  254. {VK_HOME | VIRTUAL_KEY | EXTENDED_KEY, {"\x00\xE0\x47\xff"}}, /* KT_EP +KN_HOME */
  255. {VK_INSERT | VIRTUAL_KEY | EXTENDED_KEY, {"\x00\xE0\x52\xff"}}, /* KT_EP +KN_INS */
  256. {VK_LEFT | VIRTUAL_KEY | EXTENDED_KEY, {"\x00\xE0\x4B\xff"}}, /* KT_EP +KN_LEFT */
  257. {VK_NEXT | VIRTUAL_KEY | EXTENDED_KEY, {"\x00\xE0\x51\xff"}}, /* KT_EP +KN_PGDN */
  258. {VK_PRIOR | VIRTUAL_KEY | EXTENDED_KEY, {"\x00\xE0\x49\xff"}}, /* KT_EP +KN_PGUP */
  259. {VK_RIGHT | VIRTUAL_KEY | EXTENDED_KEY, {"\x00\xE0\x4D\xff"}}, /* KT_EP +KN_RIGHT */
  260. {VK_UP | VIRTUAL_KEY | EXTENDED_KEY, {"\x00\xE0\x48\xff"}}, /* KT_EP +KN_UP */
  261. {VK_DELETE | VIRTUAL_KEY | EXTENDED_KEY | CTRL_KEY, {"\x00\xE0\x93\xff"}}, /* KT_CTRL + KT_EP +KN_DEL */
  262. {VK_DOWN | VIRTUAL_KEY | EXTENDED_KEY | CTRL_KEY, {"\x00\xE0\x91\xff"}}, /* KT_CTRL + KT_EP +KN_DOWN */
  263. {VK_END | VIRTUAL_KEY | EXTENDED_KEY | CTRL_KEY, {"\x00\xE0\x75\xff"}}, /* KT_CTRL + KT_EP +KN_END */
  264. {VK_HOME | VIRTUAL_KEY | EXTENDED_KEY | CTRL_KEY, {"\x00\xE0\x77\xff"}}, /* KT_CTRL + KT_EP +KN_HOME */
  265. {VK_INSERT | VIRTUAL_KEY | EXTENDED_KEY | CTRL_KEY, {"\x00\xE0\x92\xff"}}, /* KT_CTRL + KT_EP +KN_INS */
  266. {VK_LEFT | VIRTUAL_KEY | EXTENDED_KEY | CTRL_KEY, {"\x00\xE0\x73\xff"}}, /* KT_CTRL + KT_EP +KN_LEFT */
  267. {VK_NEXT | VIRTUAL_KEY | EXTENDED_KEY | CTRL_KEY, {"\x00\xE0\x76\xff"}}, /* KT_CTRL + KT_EP +KN_PGDN */
  268. {VK_PRIOR | VIRTUAL_KEY | EXTENDED_KEY | CTRL_KEY, {"\x00\xE0\x84\xff"}}, /* KT_CTRL + KT_EP +KN_PGUP */
  269. {VK_RIGHT | VIRTUAL_KEY | EXTENDED_KEY | CTRL_KEY, {"\x00\xE0\x74\xff"}}, /* KT_CTRL + KT_EP +KN_RIGHT */
  270. {VK_UP | VIRTUAL_KEY | EXTENDED_KEY | CTRL_KEY, {"\x00\xE0\x8D\xff"}}, /* KT_CTRL + KT_EP +KN_UP */
  271. {VK_DELETE | VIRTUAL_KEY | EXTENDED_KEY | ALT_KEY, {"\x00\xA3\xff"}}, /* KT_ALT + KT_EP +KN_DEL */
  272. {VK_DOWN | VIRTUAL_KEY | EXTENDED_KEY | ALT_KEY, {"\x00\xA0\xff"}}, /* KT_ALT + KT_EP +KN_DOWN */
  273. {VK_END | VIRTUAL_KEY | EXTENDED_KEY | ALT_KEY, {"\x00\x9F\xff"}}, /* KT_ALT + KT_EP +KN_END */
  274. {VK_HOME | VIRTUAL_KEY | EXTENDED_KEY | ALT_KEY, {"\x00\x97\xff"}}, /* KT_ALT + KT_EP +KN_HOME */
  275. {VK_INSERT | VIRTUAL_KEY | EXTENDED_KEY | ALT_KEY, {"\x00\xA2\xff"}}, /* KT_ALT + KT_EP +KN_INS */
  276. {VK_LEFT | VIRTUAL_KEY | EXTENDED_KEY | ALT_KEY, {"\x00\x9B\xff"}}, /* KT_ALT + KT_EP +KN_LEFT */
  277. {VK_NEXT | VIRTUAL_KEY | EXTENDED_KEY | ALT_KEY, {"\x00\xA1\xff"}}, /* KT_ALT + KT_EP +KN_PGDN */
  278. {VK_PRIOR | VIRTUAL_KEY | EXTENDED_KEY | ALT_KEY, {"\x00\x99\xff"}}, /* KT_ALT + KT_EP +KN_PGUP */
  279. {VK_RIGHT | VIRTUAL_KEY | EXTENDED_KEY | ALT_KEY, {"\x00\x9D\xff"}}, /* KT_ALT + KT_EP +KN_RIGHT */
  280. {VK_UP | VIRTUAL_KEY | EXTENDED_KEY | ALT_KEY, {"\x00\x98\xff"}}, /* KT_ALT + KT_EP +KN_UP */
  281. {0x32 | VIRTUAL_KEY | CTRL_KEY, {"\x00\x03\xff"}}, /* KT_CTRL + '@' (NUL) */
  282. };
  283. /* for VT52 emulator */
  284. const KEYTBLSTORAGE VT52KeyTable[MAX_VT52_KEYS] =
  285. {
  286. {VK_UP | EXTENDED_KEY | VIRTUAL_KEY,{"\x1B\x41\xff"}}, /* KN_UP */
  287. {VK_DOWN | EXTENDED_KEY | VIRTUAL_KEY,{"\x1B\x42\xff"}}, /* KN_DOWN */
  288. {VK_RIGHT| EXTENDED_KEY | VIRTUAL_KEY,{"\x1B\x43\xff"}}, /* KN_RIGHT */
  289. {VK_LEFT | EXTENDED_KEY | VIRTUAL_KEY,{"\x1B\x44\xff"}}, /* KN_LEFT */
  290. {VK_UP | VIRTUAL_KEY, {"\x1B\x41\xff"}}, /* KN_UP */
  291. {VK_DOWN | VIRTUAL_KEY, {"\x1B\x42\xff"}}, /* KN_DOWN */
  292. {VK_RIGHT| VIRTUAL_KEY, {"\x1B\x43\xff"}}, /* KN_RIGHT */
  293. {VK_LEFT | VIRTUAL_KEY, {"\x1B\x44\xff"}}, /* KN_LEFT */
  294. {VK_F1 | VIRTUAL_KEY, {"\x1BP\xff"}}, /* KN_F1 */
  295. {VK_F2 | VIRTUAL_KEY, {"\x1BQ\xff"}}, /* KN_F2 */
  296. {VK_F3 | VIRTUAL_KEY, {"\x1BR\xff"}}, /* KN_F3 */
  297. {VK_F4 | VIRTUAL_KEY, {"\x1BS\xff"}}, /* KN_F4 */
  298. {VK_F1 | EXTENDED_KEY | VIRTUAL_KEY, {"\x1BP\xff"}}, /* KN_F1 */
  299. {VK_F2 | EXTENDED_KEY | VIRTUAL_KEY, {"\x1BQ\xff"}}, /* KN_F2 */
  300. {VK_F3 | EXTENDED_KEY | VIRTUAL_KEY, {"\x1BR\xff"}}, /* KN_F3 */
  301. {VK_F4 | EXTENDED_KEY | VIRTUAL_KEY, {"\x1BS\xff"}}, /* KN_F4 */
  302. {VK_DELETE | VIRTUAL_KEY, {"\x7F\xff"}}, /* KN_DEL */
  303. {VK_DELETE | VIRTUAL_KEY | EXTENDED_KEY,{"\x7F\xff"}}, /* KN_DEL */
  304. {VK_ADD | VIRTUAL_KEY, {",\xff"}},
  305. };
  306. const KEYTBLSTORAGE VT52_Keypad_KeyTable[MAX_VT52_KEYPAD_KEYS] =
  307. {
  308. {VK_NUMPAD0 | VIRTUAL_KEY, {"\x1B?p\xff"}}, /* KT_KP + '0' (alternate mode) */
  309. {VK_NUMPAD1 | VIRTUAL_KEY, {"\x1B?q\xff"}}, /* KT_KP + '1' (alternate mode) */
  310. {VK_NUMPAD2 | VIRTUAL_KEY, {"\x1B?r\xff"}}, /* KT_KP + '2' (alternate mode) */
  311. {VK_NUMPAD3 | VIRTUAL_KEY, {"\x1B?s\xff"}}, /* KT_KP + '3' (alternate mode) */
  312. {VK_NUMPAD4 | VIRTUAL_KEY, {"\x1B?t\xff"}}, /* KT_KP + '4' (alternate mode) */
  313. {VK_NUMPAD5 | VIRTUAL_KEY, {"\x1B?u\xff"}}, /* KT_KP + '5' (alternate mode) */
  314. {VK_NUMPAD6 | VIRTUAL_KEY, {"\x1B?v\xff"}}, /* KT_KP + '6' (alternate mode) */
  315. {VK_NUMPAD7 | VIRTUAL_KEY, {"\x1B?w\xff"}}, /* KT_KP + '7' (alternate mode) */
  316. {VK_NUMPAD8 | VIRTUAL_KEY, {"\x1B?x\xff"}}, /* KT_KP + '8' (alternate mode) */
  317. {VK_NUMPAD9 | VIRTUAL_KEY, {"\x1B?y\xff"}}, /* KT_KP + '9' (alternate mode) */
  318. {VK_DECIMAL | VIRTUAL_KEY, {"\x1B?n\xff"}}, /* KT_KP + '.' (alternate mode) */
  319. {VK_ADD | VIRTUAL_KEY, {"\x1B?l\xff"}}, /* KT_KP + '+' (alternate mode) */
  320. {VK_RETURN | EXTENDED_KEY, {"\x1B?M\xff"}}, /* KT_KP + enter (alternate mode) */
  321. {VK_SUBTRACT | VIRTUAL_KEY, {"\x1B?m\xff"}}, /* KT_KP + '-' (alternate mode) */
  322. };
  323. const KEYTBLSTORAGE VT_PF_KeyTable[MAX_VT_PF_KEYS] =
  324. {
  325. {VK_NUMLOCK | VIRTUAL_KEY | EXTENDED_KEY, {"\x1BP\xff"}}, /* KT_KP + NUMLOCK */
  326. {0x2F | EXTENDED_KEY, {"\x1BQ\xff"}}, /* KT_KP + '/' */
  327. {VK_MULTIPLY | VIRTUAL_KEY, {"\x1BR\xff"}}, /* KT_KP + '*' */
  328. {VK_SUBTRACT | VIRTUAL_KEY, {"\x1BS\xff"}}, /* KT_KP + '-' */
  329. };
  330. /* for VT100 emulator */
  331. const KEYTBLSTORAGE VT100KeyTable[MAX_VT100_KEYS] =
  332. {
  333. {VK_UP | VIRTUAL_KEY, {"\x1B[A\xff"}}, /* KN_UP */
  334. {VK_DOWN | VIRTUAL_KEY, {"\x1B[B\xff"}}, /* KN_DOWN */
  335. {VK_RIGHT| VIRTUAL_KEY, {"\x1B[C\xff"}}, /* KN_RIGHT */
  336. {VK_LEFT | VIRTUAL_KEY, {"\x1B[D\xff"}}, /* KN_LEFT */
  337. {VK_UP | EXTENDED_KEY | VIRTUAL_KEY, {"\x1B[A\xff"}}, /* KN_UP */
  338. {VK_DOWN | EXTENDED_KEY | VIRTUAL_KEY,{"\x1B[B\xff"}}, /* KN_DOWN */
  339. {VK_RIGHT| EXTENDED_KEY | VIRTUAL_KEY,{"\x1B[C\xff"}}, /* KN_RIGHT */
  340. {VK_LEFT | EXTENDED_KEY | VIRTUAL_KEY,{"\x1B[D\xff"}}, /* KN_LEFT */
  341. {VK_F1 | VIRTUAL_KEY, {"\x1BOP\xff"}}, /* KN_F1 */
  342. {VK_F2 | VIRTUAL_KEY, {"\x1BOQ\xff"}}, /* KN_F2 */
  343. {VK_F3 | VIRTUAL_KEY, {"\x1BOR\xff"}}, /* KN_F3 */
  344. {VK_F4 | VIRTUAL_KEY, {"\x1BOS\xff"}}, /* KN_F4 */
  345. {VK_F1 | EXTENDED_KEY | VIRTUAL_KEY, {"\x1BOP\xff"}}, /* KN_F1 */
  346. {VK_F2 | EXTENDED_KEY | VIRTUAL_KEY, {"\x1BOQ\xff"}}, /* KN_F2 */
  347. {VK_F3 | EXTENDED_KEY | VIRTUAL_KEY, {"\x1BOR\xff"}}, /* KN_F3 */
  348. {VK_F4 | EXTENDED_KEY | VIRTUAL_KEY, {"\x1BOS\xff"}}, /* KN_F4 */
  349. {VK_DELETE | VIRTUAL_KEY, {"\x7F\xff"}}, /* KN_DEL */
  350. {VK_DELETE | VIRTUAL_KEY | EXTENDED_KEY,{"\x7F\xff"}}, /* KN_DEL */
  351. {VK_ADD | VIRTUAL_KEY, {",\xff"}},
  352. {VK_SPACE | VIRTUAL_KEY | CTRL_KEY, {"\x00\xff"}}, /* CTRL + SPACE */
  353. {0x32 | VIRTUAL_KEY | SHIFT_KEY | CTRL_KEY, {"\x00\xff"}}, /* CTRL + @ */
  354. {0x32 | VIRTUAL_KEY | CTRL_KEY, {"\x00\xff"}}, /* CTRL + 2 */
  355. {0x36 | VIRTUAL_KEY | CTRL_KEY, {"\x1e\xff"}}, /* CTRL + 6 */
  356. {0xbd | VIRTUAL_KEY | CTRL_KEY, {"\x1f\xff"}}, /* CTRL + - */
  357. };
  358. const KEYTBLSTORAGE VT100_Cursor_KeyTable[MAX_VT100_CURSOR_KEYS] =
  359. {
  360. {VK_UP | EXTENDED_KEY | VIRTUAL_KEY, {"\x1BOA\xff"}}, /* KN_UP */
  361. {VK_DOWN | EXTENDED_KEY | VIRTUAL_KEY,{"\x1BOB\xff"}}, /* KN_DOWN */
  362. {VK_RIGHT| EXTENDED_KEY | VIRTUAL_KEY,{"\x1BOC\xff"}}, /* KN_RIGHT */
  363. {VK_LEFT | EXTENDED_KEY | VIRTUAL_KEY,{"\x1BOD\xff"}}, /* KN_LEFT */
  364. {VK_UP | VIRTUAL_KEY, {"\x1BOA\xff"}}, /* KN_UP */
  365. {VK_DOWN | VIRTUAL_KEY, {"\x1BOB\xff"}}, /* KN_DOWN */
  366. {VK_RIGHT| VIRTUAL_KEY, {"\x1BOC\xff"}}, /* KN_RIGHT */
  367. {VK_LEFT | VIRTUAL_KEY, {"\x1BOD\xff"}}, /* KN_LEFT */
  368. };
  369. const KEYTBLSTORAGE VT100_Keypad_KeyTable[MAX_VT100_KEYPAD_KEYS] =
  370. {
  371. {VK_NUMPAD0 | VIRTUAL_KEY, {"\x1BOp\xff"}}, /* KT_KP + '0' (alternate mode) */
  372. {VK_NUMPAD1 | VIRTUAL_KEY, {"\x1BOq\xff"}}, /* KT_KP + '1' (alternate mode) */
  373. {VK_NUMPAD2 | VIRTUAL_KEY, {"\x1BOr\xff"}}, /* KT_KP + '2' (alternate mode) */
  374. {VK_NUMPAD3 | VIRTUAL_KEY, {"\x1BOs\xff"}}, /* KT_KP + '3' (alternate mode) */
  375. {VK_NUMPAD4 | VIRTUAL_KEY, {"\x1BOt\xff"}}, /* KT_KP + '4' (alternate mode) */
  376. {VK_NUMPAD5 | VIRTUAL_KEY, {"\x1BOu\xff"}}, /* KT_KP + '5' (alternate mode) */
  377. {VK_NUMPAD6 | VIRTUAL_KEY, {"\x1BOv\xff"}}, /* KT_KP + '6' (alternate mode) */
  378. {VK_NUMPAD7 | VIRTUAL_KEY, {"\x1BOw\xff"}}, /* KT_KP + '7' (alternate mode) */
  379. {VK_NUMPAD8 | VIRTUAL_KEY, {"\x1BOx\xff"}}, /* KT_KP + '8' (alternate mode) */
  380. {VK_NUMPAD9 | VIRTUAL_KEY, {"\x1BOy\xff"}}, /* KT_KP + '9' (alternate mode) */
  381. {VK_DECIMAL | VIRTUAL_KEY, {"\x1BOn\xff"}}, /* KT_KP + '.' (alternate mode) */
  382. {VK_ADD | VIRTUAL_KEY, {"\x1BOl\xff"}}, /* KT_KP + '*' (alternate mode) */
  383. {VK_RETURN | EXTENDED_KEY, {"\x1BOM\xff"}}, /* KT_KP + '+' (alternate mode) */
  384. {VK_SUBTRACT | VIRTUAL_KEY, {"\x1BOm\xff"}}, /* KT_KP + '-' (alternate mode) */
  385. };
  386. #if defined(INCL_MINITEL)
  387. const KEYTBLSTORAGE Minitel_KeyTable[MAX_MINITEL_KEYS] =
  388. {
  389. {0x4D | VIRTUAL_KEY | CTRL_KEY, {"\x0D\xff"}}, /* ctrl-m */
  390. {VK_RETURN | VIRTUAL_KEY, {"\x13\x41\xff"}}, /* Envoi CNTRL-MA*/
  391. {VK_RETURN | EXTENDED_KEY, {"\x13\x41\xff"}}, /* Send CNTRL-MA*/
  392. {VK_TAB | VIRTUAL_KEY, {"\x13\x41\xff"}}, /* Send CNTRL-MA*/
  393. {VK_F8 | VIRTUAL_KEY, {"\x13\x41\xff"}}, /* Send CNTRL-MA*/
  394. {VK_HOME | VIRTUAL_KEY, {"\x13\x46"}}, /* Sommaire CNTRL-MF*/
  395. {VK_HOME | VIRTUAL_KEY | EXTENDED_KEY, {"\x13\x46\xff"}}, /* Index CNTRL-MF*/
  396. {VK_F1 | VIRTUAL_KEY, {"\x13\x46\xff"}}, /* Index CNTRL-MF*/
  397. {VK_DELETE | VIRTUAL_KEY, {"\x13\x45\xff"}}, /* Annulation CNTRL-ME*/
  398. {VK_DELETE | VIRTUAL_KEY | EXTENDED_KEY, {"\x13\x45\xff"}}, /* Cancel CNTRL-ME*/
  399. {VK_F2 | VIRTUAL_KEY, {"\x13\x45\xff"}}, /* Cancel CNTRL-ME*/
  400. {VK_PRIOR | VIRTUAL_KEY, {"\x13\x42\xff"}}, /* Retour CNTRL-MB*/
  401. {VK_PRIOR | VIRTUAL_KEY | EXTENDED_KEY, {"\x13\x42\xff"}}, /* Previous CNTRL-MB*/
  402. {VK_F3 | VIRTUAL_KEY, {"\x13\x42\xff"}}, /* Previous CNTRL-MB*/
  403. {VK_INSERT | VIRTUAL_KEY, {"\x13\x43\xff"}}, /* Repeat CNTRL-MC*/
  404. {VK_INSERT | VIRTUAL_KEY | EXTENDED_KEY, {"\x13\x43\xff"}}, /* Repeat CNTRL-MC*/
  405. {VK_F4 | VIRTUAL_KEY, {"\x13\x43\xff"}}, /* Repeat CNTRL-MC*/
  406. {VK_BACK | VIRTUAL_KEY, {"\x13\x47\xff"}}, /* Correct CNTRL-MG*/
  407. {VK_F6 | VIRTUAL_KEY, {"\x13\x47\xff"}}, /* Correct CNTRL-MG*/
  408. {VK_INSERT | VIRTUAL_KEY, {"\x13\x44\xff"}}, /* Guide CNTRL-MD*/
  409. {VK_INSERT | VIRTUAL_KEY | EXTENDED_KEY, {"\x13\x44\xff"}}, /* Guide CNTRL-MD*/
  410. {VK_F5 | VIRTUAL_KEY, {"\x13\x44\xff"}}, /* Guide CNTRL-MD*/
  411. {VK_NEXT | VIRTUAL_KEY, {"\x13\x48\xff"}}, /* Suite CNTRL-MH*/
  412. {VK_NEXT | VIRTUAL_KEY | EXTENDED_KEY, {"\x13\x48\xff"}}, /* Next CNTRL-MH*/
  413. {VK_F7 | VIRTUAL_KEY, {"\x13\x48\xff"}}, /* Next CNTRL-MH*/
  414. {VK_F9 | VIRTUAL_KEY, {"\x13\x49\xff"}}, /* Connect (page 123) */
  415. // Page 124
  416. {VK_UP | VIRTUAL_KEY, {"\x1B[A\xff"}},
  417. {VK_UP | VIRTUAL_KEY | EXTENDED_KEY, {"\x1B[A\xff"}},
  418. {VK_UP | VIRTUAL_KEY | SHIFT_KEY, {"\x1B[M\xff"}},
  419. {VK_UP | VIRTUAL_KEY | EXTENDED_KEY | SHIFT_KEY, {"\x1B[M\xff"}},
  420. {VK_DOWN | VIRTUAL_KEY, {"\x1B[B\xff"}},
  421. {VK_DOWN | VIRTUAL_KEY | EXTENDED_KEY, {"\x1B[B\xff"}},
  422. {VK_DOWN | VIRTUAL_KEY | SHIFT_KEY, {"\x1B[L\xff"}},
  423. {VK_DOWN | VIRTUAL_KEY | SHIFT_KEY | EXTENDED_KEY, {"\x1B[L\xff"}},
  424. {VK_RIGHT | VIRTUAL_KEY, {"\x1B[C\xff"}},
  425. {VK_RIGHT | VIRTUAL_KEY | EXTENDED_KEY, {"\x1B[C\xff"}},
  426. /* See minitel kbdin routine on this one - mrw */
  427. {VK_RIGHT | VIRTUAL_KEY | SHIFT_KEY, {"\x1B[4\xff"}},
  428. {VK_RIGHT | VIRTUAL_KEY | SHIFT_KEY | EXTENDED_KEY, {"\x1B[4\xff"}},
  429. {VK_LEFT | VIRTUAL_KEY, {"\x1B[D\xff"}},
  430. {VK_LEFT | VIRTUAL_KEY | EXTENDED_KEY, {"\x1B[D\xff"}},
  431. {VK_LEFT | VIRTUAL_KEY | SHIFT_KEY, {"\x1B[P\xff"}},
  432. {VK_LEFT | VIRTUAL_KEY | SHIFT_KEY | EXTENDED_KEY, {"\x1B[P\xff"}},
  433. {VK_LEFT | VIRTUAL_KEY | CTRL_KEY, {"\x7F\xff"}},
  434. {VK_LEFT | VIRTUAL_KEY | CTRL_KEY | EXTENDED_KEY, {"\x7F\xff"}},
  435. /* numpad enter */
  436. {VK_RETURN | VIRTUAL_KEY | EXTENDED_KEY, {"\x13\x41\xff"}},
  437. {VK_RETURN | VIRTUAL_KEY | EXTENDED_KEY | SHIFT_KEY, {"\x1B[H\xff"}},
  438. {VK_RETURN | VIRTUAL_KEY | EXTENDED_KEY | CTRL_KEY, {"\x1B[2J\xff"}},
  439. // page 118
  440. {0xA3, {"\x19\x23\xff"}}, // British pound symbol.
  441. {0xA7, {"\x19\x27\xff"}}, // Paragraph symbol.
  442. {0xA8, {"\x19\x48\xff"}}, // umluot
  443. {0xB0, {"\x19\x30\xff"}}, // degree symbol
  444. {0xB1, {"\x19\x31\xff"}}, // plus over minus symbol
  445. {0xB4, {"\x19\x42\xff"}}, // accute accent
  446. {0xBC, {"\x19\x3C\xff"}}, // 1/4
  447. {0xBD, {"\x19\x3D\xff"}}, // 1/2
  448. {0xBE, {"\x19\x3E\xff"}}, // 3/4
  449. {0xB8, {"\x19\x4B\xff"}}, // beard
  450. {0xC0, {"\x19\x2D\xff"}}, // up arrow symbol
  451. {0xC3, {"\x19\x2C\xff"}}, // left arrow symbol
  452. {0xC4, {"\x19\x2E\xff"}}, // right arrow symbol
  453. {0xC5, {"\x19\x2F\xff"}}, // down arrow symbol
  454. {0xDF, {"\x19\x7B\xff"}}, // Beta
  455. {0xE0, {"\x19\x41\x61\xff"}}, // a grave accent
  456. {0xE2, {"\x19\x43\x61\xff"}}, // a circumflex
  457. {0xE4, {"\x19\x48\x61\xff"}}, // a umluot
  458. {0xE7, {"\x19\x4B\x63\xff"}}, // c with a beard
  459. {0xE8, {"\x19\x41\x65\xff"}}, // e grave accent
  460. {0xE9, {"\x19\x42\x65\xff"}}, // e accute accent
  461. {0xEA, {"\x19\x43\x65\xff"}}, // e circumflex
  462. {0xEB, {"\x19\x48\x65\xff"}}, // e umluot
  463. {0xEE, {"\x19\x43\x69\xff"}}, // i circumflex
  464. {0xEF, {"\x19\x48\x69\xff"}}, // i umluot
  465. {0xF4, {"\x19\x43\x6f\xff"}}, // o circumflex
  466. {0xF5, {"\x19\x48\x6f\xff"}}, // o umluot
  467. {0xF7, {"\x19\x38\xff"}}, // divide-by symbol
  468. {0xF9, {"\x19\x41\x75\xff"}}, // u grave accent
  469. {0xFB, {"\x19\x43\x75\xff"}}, // u circumflex
  470. {0xFC, {"\x19\x48\x75\xff"}}, // u circumflex
  471. {0x5E, {"\x19\x43\xff"}}, // circumflex accent (^)
  472. {0x60, {"\x19\x41\xff"}}, // grave accent(`)
  473. {0x8C, {"\x19\x6A\xff"}}, // big OE
  474. {0x9C, {"\x19\x7A\xff"}}, // little oe
  475. };
  476. #endif
  477. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  478. * FUNCTION:
  479. * emuCreateHdl
  480. *
  481. * DESCRIPTION:
  482. * Creates an emulator handle. The creation of an Emulator handle
  483. * includes setting default user settings and loading the ANSI
  484. * emulator.
  485. *
  486. * ARGUMENTS:
  487. * hSession - session handle.
  488. *
  489. * RETURNS:
  490. * HEMU or zero on error.
  491. *
  492. */
  493. HEMU emuCreateHdl(const HSESSION hSession)
  494. {
  495. HHEMU hhEmu;
  496. hhEmu = malloc(sizeof(*hhEmu));
  497. if (hhEmu == 0)
  498. {
  499. assert(FALSE);
  500. return 0;
  501. }
  502. memset(hhEmu, 0, sizeof(*hhEmu));
  503. InitializeCriticalSection(&hhEmu->csEmu);
  504. hhEmu->hSession = hSession;
  505. // Create and load the Emulator Name & Id table.
  506. //
  507. if (!emuCreateNameTable(hhEmu))
  508. {
  509. assert(FALSE);
  510. emuDestroyHdl((HEMU)hhEmu);
  511. hhEmu = NULL;
  512. return 0;
  513. }
  514. // Create the text and attribute buffers.
  515. //
  516. if (!emuCreateTextAttrBufs((HEMU)hhEmu, MAX_EMUROWS, MAX_EMUCOLS))
  517. {
  518. assert(FALSE);
  519. emuDestroyHdl((HEMU)hhEmu);
  520. hhEmu = NULL;
  521. return 0;
  522. }
  523. // Create the Print handle used for Printer Echo.
  524. //
  525. hhEmu->hPrintEcho = printCreateHdl(hSession);
  526. if(hhEmu->hPrintEcho == 0)
  527. {
  528. assert(FALSE);
  529. emuDestroyHdl((HEMU)hhEmu);
  530. hhEmu = NULL;
  531. return 0;
  532. }
  533. // Create the Print handle used for Host directed printing.
  534. //
  535. hhEmu->hPrintHost = printCreateHdl(hSession);
  536. if (hhEmu->hPrintHost == 0)
  537. {
  538. assert(FALSE);
  539. emuDestroyHdl((HEMU)hhEmu);
  540. hhEmu = NULL;
  541. return 0;
  542. }
  543. // Initialize the user settings for the emulation handle.
  544. //
  545. if (emuInitializeHdl((HEMU)hhEmu) != 0)
  546. {
  547. assert(FALSE);
  548. emuDestroyHdl((HEMU)hhEmu);
  549. hhEmu = NULL;
  550. return 0;
  551. }
  552. return (HEMU)hhEmu;
  553. }
  554. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  555. * FUNCTION:
  556. * emuDestroyHdl
  557. *
  558. * DESCRIPTION:
  559. * Death and destruction of the once noble emulator handle.
  560. *
  561. * ARGUMENTS:
  562. * hEmu - external emulator handle.
  563. *
  564. * RETURNS:
  565. * 0=OK, else error
  566. *
  567. */
  568. int emuDestroyHdl(const HEMU hEmu)
  569. {
  570. const HHEMU hhEmu = (HHEMU)hEmu;
  571. if (hhEmu == 0)
  572. {
  573. assert(0);
  574. return -1;
  575. }
  576. if (hhEmu->pstNameTable)
  577. {
  578. free(hhEmu->pstNameTable);
  579. hhEmu->pstNameTable = NULL;
  580. }
  581. if (hhEmu->emu_deinstall)
  582. {
  583. (*hhEmu->emu_deinstall)(hhEmu);
  584. }
  585. printDestroyHdl(hhEmu->hPrintEcho);
  586. hhEmu->hPrintEcho = NULL;
  587. printDestroyHdl(hhEmu->hPrintHost);
  588. hhEmu->hPrintHost = NULL;
  589. emuDestroyTextAttrBufs(hEmu);
  590. DeleteCriticalSection(&hhEmu->csEmu);
  591. if(hhEmu)
  592. free(hhEmu);
  593. return 0;
  594. }
  595. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  596. * FUNCTION:
  597. * emuInitializeHdl
  598. *
  599. * DESCRIPTION:
  600. * This function initializes the stUserSettings structure of the internal
  601. * emulator handle with the values stored in the session file.
  602. *
  603. * ARGUMENTS:
  604. * HEMU - The External Emulator Handle.
  605. *
  606. * RETURNS:
  607. * 0 if successful, otherwise -1
  608. *
  609. */
  610. int emuInitializeHdl(const HEMU hEmu)
  611. {
  612. int nRet, nReturn;
  613. struct stEmuBaseSFSettings stBaseSFSettings;
  614. const HHEMU hhEmu = (HHEMU)hEmu;
  615. nReturn = -1;
  616. if (hhEmu == 0)
  617. {
  618. assert(FALSE);
  619. return nReturn;
  620. }
  621. emuLock(hEmu);
  622. hhEmu->emu_maxcol = EMU_DEFAULT_MAXCOL;
  623. hhEmu->emu_maxrow = EMU_DEFAULT_MAXROW;
  624. hhEmu->bottom_margin = EMU_DEFAULT_MAXROW;
  625. hhEmu->mode_vt220 = FALSE;
  626. hhEmu->mode_vt320 = FALSE;
  627. // Added for the VT220/320 rde 16 Feb 1998
  628. hhEmu->fUse8BitCodes = FALSE;
  629. hhEmu->fAllowUserKeys = FALSE;
  630. #if defined(INCL_PRINT_PASSTHROUGH)
  631. // Added for VT100/220/320 mpt: 5-19-00
  632. // hhEmu->fPrintRaw = FALSE;
  633. #endif // INCL_PRINT_PASSTHROUGH
  634. hhEmu->attrState[0].txtclr =
  635. hhEmu->attrState[1].txtclr = VC_WHITE;
  636. hhEmu->attrState[0].bkclr =
  637. hhEmu->attrState[1].bkclr = VC_BLACK;
  638. hhEmu->iCurAttrState = CS_STATE;
  639. std_setcolors(hhEmu, GetNearestColorIndex(GetSysColor(COLOR_WINDOWTEXT)),
  640. GetNearestColorIndex(GetSysColor(COLOR_WINDOW)));
  641. // Initialize the user setting default values.
  642. //
  643. memset(&stBaseSFSettings, 0, sizeof(stBaseSFSettings));
  644. stBaseSFSettings.nTermKeys = EMU_KEYS_TERM;
  645. stBaseSFSettings.nCursorType = EMU_CURSOR_LINE;
  646. stBaseSFSettings.fCursorBlink = TRUE;
  647. stBaseSFSettings.nCharacterSet = EMU_CHARSET_ASCII;
  648. stBaseSFSettings.fMapPFkeys = FALSE;
  649. stBaseSFSettings.fAltKeypadMode = FALSE;
  650. stBaseSFSettings.fKeypadAppMode = FALSE;
  651. stBaseSFSettings.fCursorKeypadMode = FALSE;
  652. stBaseSFSettings.fReverseDelBk = FALSE;
  653. stBaseSFSettings.f132Columns = FALSE;
  654. stBaseSFSettings.fWrapLines = TRUE;
  655. stBaseSFSettings.fDestructiveBk = TRUE;
  656. stBaseSFSettings.fLbSymbolOnEnter = FALSE;
  657. stBaseSFSettings.fUse8BitCodes = FALSE;
  658. stBaseSFSettings.fAllowUserKeys = FALSE;
  659. stBaseSFSettings.nEmuId = EMU_AUTO;
  660. #if defined(INCL_ULTC_VERSION)
  661. stBaseSFSettings.nEmuId = EMU_VT220;
  662. stBaseSFSettings.nCharacterSet = EMU_CHARSET_MULTINATIONAL;
  663. #endif
  664. stBaseSFSettings.nAutoAttempts = 0;
  665. #ifdef INCL_USER_DEFINED_BACKSPACE_AND_TELNET_TERMINAL_ID
  666. // Initialize new user settings. - cab:11/14/96
  667. //
  668. stBaseSFSettings.nBackspaceKeys = EMU_BKSPKEYS_CTRLH;
  669. // Zero the telnet id string. I am doing this because if there
  670. // isn't one in the session file, I want to load the default.
  671. //
  672. stBaseSFSettings.acTelnetId[0] = TEXT('\0');
  673. emuQueryDefaultTelnetId(stBaseSFSettings.nEmuId,
  674. stBaseSFSettings.acTelnetId, EMU_MAX_TELNETID);
  675. #endif
  676. // Load the settings if they exist.
  677. if ((nRet = emuLoadSettings(hhEmu,
  678. SFID_EMU_SETTINGS,
  679. sizeof(stBaseSFSettings),
  680. &stBaseSFSettings)) == -1)
  681. {
  682. nReturn = -1;
  683. goto InitExit;
  684. }
  685. if (nRet > 0)
  686. {
  687. // The data was present.
  688. // Check to see if there is a telnet id. If not, use the default.
  689. //
  690. emuCheckSettings(&stBaseSFSettings);
  691. #ifdef INCL_USER_DEFINED_BACKSPACE_AND_TELNET_TERMINAL_ID
  692. if ( stBaseSFSettings.acTelnetId[0] == TEXT('\0') )
  693. {
  694. emuQueryDefaultTelnetId(stBaseSFSettings.nEmuId,
  695. stBaseSFSettings.acTelnetId, EMU_MAX_TELNETID);
  696. }
  697. #endif
  698. }
  699. // Initialize the emu's user settings structure from the data stored
  700. // in the session file.
  701. hhEmu->stUserSettings.nEmuId = stBaseSFSettings.nEmuId;
  702. hhEmu->stUserSettings.nTermKeys = stBaseSFSettings.nTermKeys;
  703. hhEmu->stUserSettings.nCursorType = stBaseSFSettings.nCursorType;
  704. hhEmu->stUserSettings.nCharacterSet = stBaseSFSettings.nCharacterSet;
  705. hhEmu->stUserSettings.nAutoAttempts = stBaseSFSettings.nAutoAttempts;
  706. hhEmu->stUserSettings.fCursorBlink = stBaseSFSettings.fCursorBlink;
  707. hhEmu->stUserSettings.fMapPFkeys = stBaseSFSettings.fMapPFkeys;
  708. hhEmu->stUserSettings.fAltKeypadMode = stBaseSFSettings.fAltKeypadMode;
  709. hhEmu->stUserSettings.fKeypadAppMode = stBaseSFSettings.fKeypadAppMode;
  710. hhEmu->stUserSettings.fCursorKeypadMode = stBaseSFSettings.fCursorKeypadMode;
  711. hhEmu->stUserSettings.fReverseDelBk = stBaseSFSettings.fReverseDelBk;
  712. hhEmu->stUserSettings.f132Columns = stBaseSFSettings.f132Columns;
  713. #if defined(INCL_PRINT_PASSTHROUGH)
  714. //hhEmu->stUserSettings.fPrintRaw = stBaseSFSettings.fPrintRaw;
  715. #endif // INCL_PRINT_PASSTHROUGH
  716. hhEmu->stUserSettings.fDestructiveBk = stBaseSFSettings.fDestructiveBk;
  717. hhEmu->stUserSettings.fWrapLines = stBaseSFSettings.fWrapLines;
  718. hhEmu->stUserSettings.fLbSymbolOnEnter = stBaseSFSettings.fLbSymbolOnEnter;
  719. hhEmu->stUserSettings.fUse8BitCodes = stBaseSFSettings.fUse8BitCodes;
  720. hhEmu->stUserSettings.fAllowUserKeys = stBaseSFSettings.fAllowUserKeys;
  721. hhEmu->stUserSettings.nBackspaceKeys = stBaseSFSettings.nBackspaceKeys;
  722. StrCharCopyN(hhEmu->stUserSettings.acTelnetId, stBaseSFSettings.acTelnetId, EMU_MAX_TELNETID);
  723. #ifdef INCL_TERMINAL_SIZE_AND_COLORS
  724. // Set up the default colors in case the user settings don't exist.
  725. #if TRUE
  726. hhEmu->stUserSettings.nTextColor =
  727. GetNearestColorIndex(GetSysColor(COLOR_WINDOWTEXT));
  728. hhEmu->stUserSettings.nBackgroundColor =
  729. GetNearestColorIndex(GetSysColor(COLOR_WINDOW));
  730. #else
  731. // We've decided not to do this. rde 14 Jul 98
  732. // Use white (non-bold) on black. rde 8 Jul 98
  733. hhEmu->stUserSettings.nBackgroundColor = VC_BLACK;
  734. hhEmu->stUserSettings.nTextColor = VC_WHITE;
  735. #endif
  736. // Load the settings if they exist.
  737. if ((nRet = emuLoadSettings(hhEmu,
  738. SFID_EMU_TEXTCOLOR_SETTING,
  739. sizeof(hhEmu->stUserSettings.nTextColor),
  740. &hhEmu->stUserSettings.nTextColor)) == -1)
  741. {
  742. nReturn = -1;
  743. goto InitExit;
  744. }
  745. if (nRet > 0)
  746. {
  747. // The data was present, so use it.
  748. std_setcolors(hhEmu,
  749. hhEmu->stUserSettings.nTextColor,
  750. hhEmu->stUserSettings.nBackgroundColor);
  751. }
  752. if ((nRet = emuLoadSettings(hhEmu,
  753. SFID_EMU_BKGRNDCOLOR_SETTING,
  754. sizeof(hhEmu->stUserSettings.nBackgroundColor),
  755. &hhEmu->stUserSettings.nBackgroundColor)) == -1)
  756. {
  757. nReturn = -1;
  758. goto InitExit;
  759. }
  760. if (nRet > 0)
  761. {
  762. // The data was present, so use it.
  763. std_setcolors(hhEmu,
  764. hhEmu->stUserSettings.nTextColor,
  765. hhEmu->stUserSettings.nBackgroundColor);
  766. }
  767. // Set up the default screen size in case the user settings don't exist.
  768. hhEmu->stUserSettings.nUserDefRows = EMU_DEFAULT_ROWS;
  769. hhEmu->stUserSettings.nUserDefCols =
  770. hhEmu->stUserSettings.f132Columns ? MAX_EMUCOLS : EMU_DEFAULT_COLS;
  771. #if defined(INCL_PRINT_PASSTHROUGH)
  772. // default host-controlled print mode with regard to windows drivers
  773. hhEmu->stUserSettings.fPrintRaw = FALSE;
  774. #endif // INCL_PRINT_PASSTHROUGH
  775. // Load the settings if they exist.
  776. if ((nRet = emuLoadSettings(hhEmu,
  777. SFID_EMU_SCRNROWS_SETTING,
  778. sizeof(hhEmu->stUserSettings.nUserDefRows),
  779. &hhEmu->stUserSettings.nUserDefRows)) == -1)
  780. {
  781. nReturn = -1;
  782. goto InitExit;
  783. }
  784. if ((nRet = emuLoadSettings(hhEmu,
  785. SFID_EMU_SCRNCOLS_SETTING,
  786. sizeof(hhEmu->stUserSettings.nUserDefCols),
  787. &hhEmu->stUserSettings.nUserDefCols)) == -1)
  788. {
  789. nReturn = -1;
  790. goto InitExit;
  791. }
  792. #if defined(INCL_PRINT_PASSTHROUGH)
  793. if ((nRet = emuLoadSettings(hhEmu,
  794. SFID_EMU_PRINT_RAW,
  795. sizeof(hhEmu->stUserSettings.fPrintRaw),
  796. &hhEmu->stUserSettings.fPrintRaw)) == -1)
  797. {
  798. nReturn = -1;
  799. goto InitExit;
  800. }
  801. #endif // INCL_PRINT_PASSTHROUGH
  802. if (nRet > 0)
  803. {
  804. // The data was present, so use it.
  805. hhEmu->stUserSettings.f132Columns =
  806. (hhEmu->stUserSettings.nUserDefCols == 132) ? TRUE : FALSE;
  807. #if FALSE // TODO:rde Is this needed?
  808. hhEmu->emu_setscrsize = std_setscrsize;
  809. #endif
  810. }
  811. #endif
  812. // Load the emulator.
  813. //
  814. nReturn = emuLoad((HEMU)hhEmu, hhEmu->stUserSettings.nEmuId);
  815. //JMH 01-09-97 emuSetSettings() was being called before emuLoad(), but
  816. // emuLoad() initialized some values that got set by emuSetSettings().
  817. // (e.g. 132-column mode).
  818. //
  819. // Tell the emulator about the user's settings.
  820. //
  821. emuSetSettings((HEMU)hhEmu, &hhEmu->stUserSettings);
  822. // Clear the emulator image.
  823. //
  824. //*for (nRow = 0 ; nRow < MAX_EMUROWS ; ++nRow)
  825. //* clear_imgrow(hhEmu, nRow);
  826. //* This breaks the MINITEL bad - mrw
  827. //*(hhEmu->emu_setcurpos)(hhEmu, 0, 0);
  828. InitExit:
  829. emuUnlock(hEmu);
  830. NotifyClient(hhEmu->hSession, EVENT_EMU_SETTINGS, 0);
  831. NotifyClient(hhEmu->hSession, EVENT_TERM_UPDATE, 0);
  832. if (nReturn < 0)
  833. nRet = 0;
  834. return nReturn;
  835. }
  836. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  837. * FUNCTION:
  838. * emuSaveHdl
  839. *
  840. * DESCRIPTION:
  841. * This function stores the emulator user settings in the session file.
  842. *
  843. *
  844. * ARGUMENTS:
  845. * HEMU - The External Emulator Handle.
  846. *
  847. * RETURNS:
  848. * 0=OK, else error
  849. *
  850. */
  851. int emuSaveHdl(const HEMU hEmu)
  852. {
  853. struct stEmuBaseSFSettings stBaseSFSettings;
  854. const HHEMU hhEmu = (HHEMU)hEmu;
  855. if (hhEmu == 0)
  856. {
  857. assert(FALSE);
  858. return -1;
  859. }
  860. // Initialize the base structure that gets saved in the session file.
  861. stBaseSFSettings.nEmuId = hhEmu->stUserSettings.nEmuId;
  862. stBaseSFSettings.nTermKeys = hhEmu->stUserSettings.nTermKeys;
  863. stBaseSFSettings.nCursorType = hhEmu->stUserSettings.nCursorType;
  864. stBaseSFSettings.nCharacterSet = hhEmu->stUserSettings.nCharacterSet;
  865. stBaseSFSettings.nAutoAttempts = hhEmu->stUserSettings.nAutoAttempts;
  866. stBaseSFSettings.fCursorBlink = hhEmu->stUserSettings.fCursorBlink;
  867. stBaseSFSettings.fMapPFkeys = hhEmu->stUserSettings.fMapPFkeys;
  868. stBaseSFSettings.fAltKeypadMode = hhEmu->stUserSettings.fAltKeypadMode;
  869. stBaseSFSettings.fKeypadAppMode = hhEmu->stUserSettings.fKeypadAppMode;
  870. stBaseSFSettings.fCursorKeypadMode = hhEmu->stUserSettings.fCursorKeypadMode;
  871. stBaseSFSettings.fReverseDelBk = hhEmu->stUserSettings.fReverseDelBk;
  872. stBaseSFSettings.f132Columns = hhEmu->stUserSettings.f132Columns;
  873. stBaseSFSettings.fDestructiveBk = hhEmu->stUserSettings.fDestructiveBk;
  874. stBaseSFSettings.fWrapLines = hhEmu->stUserSettings.fWrapLines;
  875. stBaseSFSettings.fLbSymbolOnEnter = hhEmu->stUserSettings.fLbSymbolOnEnter;
  876. stBaseSFSettings.fUse8BitCodes = hhEmu->stUserSettings.fUse8BitCodes;
  877. stBaseSFSettings.fAllowUserKeys = hhEmu->stUserSettings.fAllowUserKeys;
  878. stBaseSFSettings.nBackspaceKeys = hhEmu->stUserSettings.nBackspaceKeys;
  879. StrCharCopyN(stBaseSFSettings.acTelnetId, hhEmu->stUserSettings.acTelnetId, EMU_MAX_TELNETID);
  880. emuLock(hEmu);
  881. sfPutSessionItem(sessQuerySysFileHdl(hhEmu->hSession),
  882. SFID_EMU_SETTINGS,
  883. sizeof(stBaseSFSettings),
  884. &stBaseSFSettings);
  885. #ifdef INCL_TERMINAL_SIZE_AND_COLORS
  886. sfPutSessionItem(sessQuerySysFileHdl(hhEmu->hSession),
  887. SFID_EMU_TEXTCOLOR_SETTING,
  888. sizeof(hhEmu->stUserSettings.nTextColor),
  889. &hhEmu->stUserSettings.nTextColor);
  890. sfPutSessionItem(sessQuerySysFileHdl(hhEmu->hSession),
  891. SFID_EMU_BKGRNDCOLOR_SETTING,
  892. sizeof(hhEmu->stUserSettings.nBackgroundColor),
  893. &hhEmu->stUserSettings.nBackgroundColor);
  894. sfPutSessionItem(sessQuerySysFileHdl(hhEmu->hSession),
  895. SFID_EMU_SCRNROWS_SETTING,
  896. sizeof(hhEmu->stUserSettings.nUserDefRows),
  897. &hhEmu->stUserSettings.nUserDefRows);
  898. sfPutSessionItem(sessQuerySysFileHdl(hhEmu->hSession),
  899. SFID_EMU_SCRNCOLS_SETTING,
  900. sizeof(hhEmu->stUserSettings.nUserDefCols),
  901. &hhEmu->stUserSettings.nUserDefCols);
  902. #endif
  903. #if defined(INCL_PRINT_PASSTHROUGH)
  904. sfPutSessionItem(sessQuerySysFileHdl(hhEmu->hSession),
  905. SFID_EMU_PRINT_RAW,
  906. sizeof(hhEmu->stUserSettings.fPrintRaw),
  907. &hhEmu->stUserSettings.fPrintRaw);
  908. #endif // INCL_PRINT_PASSTHROUGH
  909. emuUnlock(hEmu);
  910. return 0;
  911. }
  912. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  913. * FUNCTION:
  914. * emuLock
  915. *
  916. * DESCRIPTION:
  917. * Grabs the emulator's critical section semaphore. Access functions
  918. * to the emulator should also call this so we can call emulator
  919. * functions from anywhere.
  920. *
  921. * ARGUMENTS:
  922. * hEmu - external emulator handle.
  923. *
  924. * RETURNS:
  925. * void
  926. *
  927. */
  928. void emuLock(const HEMU hEmu)
  929. {
  930. const HHEMU hhEmu = (HHEMU)hEmu;
  931. EnterCriticalSection(&hhEmu->csEmu);
  932. }
  933. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  934. * FUNCTION:
  935. * emuUnlock
  936. *
  937. * DESCRIPTION:
  938. * Releases the emulator's critical section semaphore.
  939. *
  940. * ARGUMENTS:
  941. * hEmu - external emulator handle.
  942. *
  943. * RETURNS:
  944. * void
  945. *
  946. */
  947. void emuUnlock(const HEMU hEmu)
  948. {
  949. const HHEMU hhEmu = (HHEMU)hEmu;
  950. LeaveCriticalSection(&hhEmu->csEmu);
  951. }
  952. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  953. * FUNCTION:
  954. * emuGetTxtBuf
  955. *
  956. * DESCRIPTION:
  957. * Obviously we don't need the handle here but when we do go reentrant,
  958. * we only change the guts of this function. Also, I don't call
  959. * emuLock(), emuUnlock() since only termGetUpdate() calls these functions
  960. * and at that point the emulator is already locked down.
  961. *
  962. * ARGUMENTS:
  963. * hEmu - external emulator handle
  964. *
  965. * RETURNS:
  966. * pointer to text buf array
  967. *
  968. */
  969. ECHAR **emuGetTxtBuf(const HEMU hEmu)
  970. {
  971. const HHEMU hhEmu = (HHEMU)hEmu;
  972. if (hEmu == 0)
  973. {
  974. assert(0);
  975. return 0;
  976. }
  977. return hhEmu->emu_apText;
  978. }
  979. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  980. * FUNCTION:
  981. * emuGetAttrBuf
  982. *
  983. * DESCRIPTION:
  984. * Obviously we don't need the handle here but when we do go reentrant,
  985. * we only change the guts of this function. Also, I don't call
  986. * emuLock(), emuUnlock() since only termGetUpdate() calls these functions
  987. * and at that point the emulator is already locked down.
  988. *
  989. * ARGUMENTS:
  990. * hEmu - external emulator handle
  991. *
  992. * RETURNS:
  993. * pointer to attribute buf array
  994. *
  995. */
  996. PSTATTR *emuGetAttrBuf(const HEMU hEmu)
  997. {
  998. const HHEMU hhEmu = (HHEMU)hEmu;
  999. if (hEmu == 0)
  1000. {
  1001. assert(0);
  1002. return 0;
  1003. }
  1004. return hhEmu->emu_apAttr;
  1005. }
  1006. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1007. * FUNCTION:
  1008. * emuKbdIn
  1009. *
  1010. * DESCRIPTION:
  1011. *
  1012. *
  1013. * ARGUMENTS:
  1014. *
  1015. *
  1016. * RETURNS:
  1017. * 0=termkey, -1=not termkey, -2=error
  1018. *
  1019. */
  1020. int emuKbdIn(const HEMU hEmu, KEY_T key, const int fTest)
  1021. {
  1022. const HHEMU hhEmu = (HHEMU)hEmu;
  1023. int iRet;
  1024. if (hEmu == 0)
  1025. {
  1026. assert(0);
  1027. return -2;
  1028. }
  1029. emuLock(hEmu);
  1030. iRet = (*hhEmu->emu_kbdin)(hhEmu, (int)key, fTest);
  1031. emuUnlock(hEmu);
  1032. return iRet;
  1033. }
  1034. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1035. * FUNCTION:
  1036. * emuIsEmuKey
  1037. *
  1038. * DESCRIPTION:
  1039. * Checks to see if the the given key maps to any defined terminal keys.
  1040. *
  1041. * ARGUMENTS:
  1042. * HEMU hEmu - External emulator handle.
  1043. * int key - Key to test.
  1044. *
  1045. * RETURNS:
  1046. * TRUE=termkey, FALSE=not termkey
  1047. *
  1048. */
  1049. int emuIsEmuKey(const HEMU hEmu, KEY_T key)
  1050. {
  1051. const HHEMU hhEmu = (HHEMU)hEmu;
  1052. int iRet;
  1053. if (hEmu == 0)
  1054. {
  1055. assert(0);
  1056. return FALSE;
  1057. }
  1058. if (cnctQueryStatus(sessQueryCnctHdl(hhEmu->hSession)) !=
  1059. CNCT_STATUS_TRUE || IsSessionSuspended(hhEmu->hSession) ||
  1060. hhEmu->stUserSettings.nTermKeys == EMU_KEYS_ACCEL)
  1061. {
  1062. return FALSE;
  1063. }
  1064. emuLock(hEmu);
  1065. iRet = (*hhEmu->emu_kbdin)(hhEmu, (int)key, TRUE);
  1066. emuUnlock(hEmu);
  1067. return (iRet == -1) ? FALSE : TRUE;
  1068. }
  1069. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1070. * emuComDone
  1071. *
  1072. * DESCRIPTION:
  1073. *
  1074. * ARGUMENTS:
  1075. *
  1076. * RETURNS:
  1077. * 0=OK, else error
  1078. *
  1079. */
  1080. int emuComDone(const HEMU hEmu)
  1081. {
  1082. const HHEMU hhEmu = (HHEMU)hEmu;
  1083. if (hEmu == 0)
  1084. {
  1085. assert(0);
  1086. return -1;
  1087. }
  1088. NotifyClient(hhEmu->hSession, EVENT_TERM_UPDATE, 0L);
  1089. return 0;
  1090. }
  1091. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1092. * FUNCTION:
  1093. * emuQueryCurPos
  1094. *
  1095. * DESCRIPTION: Returns the row and column position of the current
  1096. * cursor position.
  1097. *
  1098. * ARGUMENTS: hEmu - The External emulator handle.
  1099. * *row - A pointer to an integer.
  1100. * *col - A pointer to an integer.
  1101. *
  1102. * RETURNS:
  1103. * 0=OK, else error
  1104. *
  1105. */
  1106. int emuQueryCurPos(const HEMU hEmu, int *row, int *col)
  1107. {
  1108. const HHEMU hhEmu = (HHEMU)hEmu;
  1109. if (hEmu == 0)
  1110. {
  1111. assert(0);
  1112. return -1;
  1113. }
  1114. emuLock(hEmu);
  1115. *row = hhEmu->emu_currow;
  1116. *col = hhEmu->emu_curcol;
  1117. emuUnlock(hEmu);
  1118. return 0;
  1119. }
  1120. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1121. * FUNCTION:
  1122. * emuQueryCursorType
  1123. *
  1124. * DESCRIPTION:
  1125. * Returns the current cursor type.
  1126. *
  1127. * ARGUMENTS:
  1128. * hEmu - public emulator handle.
  1129. *
  1130. * RETURNS:
  1131. * The cursor type.
  1132. *
  1133. */
  1134. int emuQueryCursorType(const HEMU hEmu)
  1135. {
  1136. int iCurType;
  1137. const HHEMU hhEmu = (HHEMU)hEmu;
  1138. if (hEmu == 0)
  1139. {
  1140. assert(0);
  1141. return -1;
  1142. }
  1143. emuLock(hEmu);
  1144. iCurType = hhEmu->iCurType;
  1145. emuUnlock(hEmu);
  1146. return iCurType;
  1147. }
  1148. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1149. * FUNCTION:
  1150. * emuTrackingNotify
  1151. *
  1152. * DESCRIPTION:
  1153. * Cloop calls this function when it detects a pause in the data flow.
  1154. * This allows the client side to track to the cursor position if that
  1155. * option is enabled.
  1156. *
  1157. * ARGUMENTS:
  1158. * HEMU hEmu - External emulator handle.
  1159. *
  1160. * RETURNS:
  1161. * 0
  1162. *
  1163. */
  1164. int emuTrackingNotify(const HEMU hEmu)
  1165. {
  1166. const HHEMU hhEmu = (HHEMU)hEmu;
  1167. if (hhEmu == 0)
  1168. {
  1169. assert(FALSE);
  1170. return 0;
  1171. }
  1172. NotifyClient(hhEmu->hSession, EVENT_TERM_TRACK, 0);
  1173. return 0;
  1174. }
  1175. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1176. * FUNCTION:
  1177. * emuQueryClearAttr
  1178. *
  1179. * DESCRIPTION:
  1180. *
  1181. * ARGUMENTS:
  1182. *
  1183. * RETURNS:
  1184. * 0=OK, else error
  1185. *
  1186. */
  1187. int emuQueryClearAttr(const HEMU hEmu, PSTATTR pstClearAttr)
  1188. {
  1189. const HHEMU hhEmu = (HHEMU)hEmu;
  1190. if (hhEmu == 0)
  1191. {
  1192. assert(0);
  1193. return -1;
  1194. }
  1195. emuLock(hEmu);
  1196. *pstClearAttr = hhEmu->emu_clearattr_sav;
  1197. emuUnlock(hEmu);
  1198. return 0;
  1199. }
  1200. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1201. * FUNCTION:
  1202. * emuQueryRowsCols
  1203. *
  1204. * DESCRIPTION:
  1205. * Returns the current number of rows and columns set in the emulator.
  1206. *
  1207. * ARGUMENTS:
  1208. * hEmu - public emulator handle
  1209. * piRows - pointer to row variable
  1210. * piCols - pointer to col variable
  1211. *
  1212. * RETURNS:
  1213. * 0=OK, else error
  1214. *
  1215. */
  1216. int emuQueryRowsCols(const HEMU hEmu, int *piRows, int *piCols)
  1217. {
  1218. const HHEMU hhEmu = (HHEMU)hEmu;
  1219. if (hEmu == 0)
  1220. {
  1221. assert(0);
  1222. return -1;
  1223. }
  1224. emuLock(hEmu);
  1225. *piRows = hhEmu->emu_maxrow + 1;
  1226. *piCols = hhEmu->emu_maxcol + 1;
  1227. emuUnlock(hEmu);
  1228. return 0;
  1229. }
  1230. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1231. * FUNCTION:
  1232. * emuQueryPrintEchoHdl
  1233. *
  1234. * DESCRIPTION: This routine returns the Print handle used for
  1235. * Printer Echo for the given emulator handle.
  1236. *
  1237. * ARGUMENTS: hEmu - The external emulator handle.
  1238. *
  1239. * RETURNS: HPRINT - The External print handle for Printer Echo.
  1240. *
  1241. */
  1242. HPRINT emuQueryPrintEchoHdl(const HEMU hEmu)
  1243. {
  1244. const HHEMU hhEmu = (HHEMU)hEmu;
  1245. HPRINT hPrint;
  1246. if (hhEmu == 0)
  1247. {
  1248. assert(FALSE);
  1249. return 0;
  1250. }
  1251. emuLock(hEmu);
  1252. hPrint = hhEmu->hPrintEcho;
  1253. emuUnlock(hEmu);
  1254. return hPrint;
  1255. }
  1256. #if 0
  1257. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1258. * FUNCTION:
  1259. * emuQueryEmuName
  1260. *
  1261. * DESCRIPTION:
  1262. * Returns the name of the emulator.
  1263. *
  1264. * ARGUMENTS:
  1265. * hEmu - The External Emulator Handle.
  1266. * *acBuffer - The address of a buffer to receive the information.
  1267. * nSize - The size of the buffer.
  1268. *
  1269. * RETURNS:
  1270. * 0=OK else error
  1271. *
  1272. */
  1273. int emuQueryName(const HEMU hEmu, TCHAR *achBuffer, int nSize)
  1274. {
  1275. const HHEMU hhEmu = (HHEMU)hEmu;
  1276. BYTE *pv;
  1277. BYTE *temp;
  1278. DWORD nLen;
  1279. int indx;
  1280. int nEmuCount;
  1281. int nEmuId;
  1282. if (hhEmu == 0)
  1283. {
  1284. *achBuffer = 0;
  1285. assert(FALSE);
  1286. return -1 ;
  1287. }
  1288. emuLock(hEmu);
  1289. nEmuId = hhEmu->stUserSettings.nEmuId;
  1290. emuUnlock(hEmu);
  1291. if (resLoadDataBlock(glblQueryDllHinst(),
  1292. IDT_EMU_NAMES,
  1293. (LPVOID *)&pv, &nLen))
  1294. {
  1295. assert(FALSE);
  1296. return -2;
  1297. }
  1298. nEmuCount = *(RCDATA_TYPE *)pv;
  1299. pv += sizeof(RCDATA_TYPE);
  1300. for (indx = 0 ; indx < nEmuCount ; indx++)
  1301. {
  1302. nLen = (DWORD)StrCharGetByteCount((LPTSTR)pv) + (DWORD)sizeof(BYTE);
  1303. if (nLen == 0)
  1304. {
  1305. assert(FALSE);
  1306. return -3;
  1307. }
  1308. temp = pv + nLen;
  1309. if (*(RCDATA_TYPE *)temp == nEmuId)
  1310. {
  1311. if (StrCharGetByteCount(pv) < nSize)
  1312. {
  1313. StrCharCopyN(achBuffer, pv, nSize);
  1314. break;
  1315. }
  1316. else
  1317. {
  1318. *achBuffer = 0;
  1319. return -4;
  1320. }
  1321. }
  1322. pv += (nLen + (DWORD)sizeof(RCDATA_TYPE));
  1323. }
  1324. return 0;
  1325. }
  1326. #endif
  1327. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1328. * FUNCTION:
  1329. * emuQueryEmuName
  1330. *
  1331. * DESCRIPTION:
  1332. * Returns the name of the emulator.
  1333. *
  1334. * ARGUMENTS:
  1335. * hEmu - The External Emulator Handle.
  1336. * *acBuffer - The address of a buffer to receive the information.
  1337. * nSize - The size of the buffer.
  1338. *
  1339. * RETURNS:
  1340. * 0=OK else error
  1341. *
  1342. */
  1343. int emuQueryName(const HEMU hEmu, TCHAR *achBuffer, int nSize)
  1344. {
  1345. const HHEMU hhEmu = (HHEMU)hEmu;
  1346. TCHAR achText[256];
  1347. int nEmuId,
  1348. nResourceId,
  1349. nLen;
  1350. emuLock(hEmu);
  1351. nEmuId = hhEmu->stUserSettings.nEmuId;
  1352. emuUnlock(hEmu);
  1353. switch(nEmuId)
  1354. {
  1355. case EMU_AUTO:
  1356. nResourceId = IDS_EMUNAME_AUTO;
  1357. break;
  1358. case EMU_ANSI:
  1359. nResourceId = IDS_EMUNAME_ANSI;
  1360. break;
  1361. case EMU_ANSIW:
  1362. nResourceId = IDS_EMUNAME_ANSIW;
  1363. break;
  1364. case EMU_MINI:
  1365. nResourceId = IDS_EMUNAME_MINI;
  1366. break;
  1367. case EMU_VIEW:
  1368. nResourceId = IDS_EMUNAME_VIEW;
  1369. break;
  1370. case EMU_TTY:
  1371. nResourceId = IDS_EMUNAME_TTY;
  1372. break;
  1373. case EMU_VT100:
  1374. nResourceId = IDS_EMUNAME_VT100;
  1375. break;
  1376. case EMU_VT52:
  1377. nResourceId = IDS_EMUNAME_VT52;
  1378. break;
  1379. case EMU_VT100J:
  1380. nResourceId = IDS_EMUNAME_VT100J;
  1381. break;
  1382. #if defined(INCL_VT220)
  1383. case EMU_VT220:
  1384. nResourceId = IDS_EMUNAME_VT220;
  1385. break;
  1386. #endif
  1387. #if defined(INCL_VT320)
  1388. case EMU_VT320:
  1389. nResourceId = IDS_EMUNAME_VT320;
  1390. break;
  1391. #endif
  1392. #if defined(INCL_VT100PLUS)
  1393. case EMU_VT100PLUS:
  1394. nResourceId = IDS_EMUNAME_VT100PLUS;
  1395. break;
  1396. #endif
  1397. #if defined(INCL_VTUTF8)
  1398. case EMU_VTUTF8:
  1399. nResourceId = IDS_EMUNAME_VTUTF8;
  1400. break;
  1401. #endif
  1402. default:
  1403. assert(FALSE);
  1404. return(-1);
  1405. }
  1406. nLen = LoadString(glblQueryDllHinst(), (unsigned)nResourceId, achText,
  1407. sizeof(achText) / sizeof(TCHAR));
  1408. // Has the caller supplied a large enough buffer.
  1409. //
  1410. if (nSize <= nLen)
  1411. return(-1);
  1412. StrCharCopyN(achBuffer, achText, nSize);
  1413. return(0);
  1414. }
  1415. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1416. * FUNCTION:
  1417. * emuGetIdFromName
  1418. *
  1419. * DESCRIPTION:
  1420. * Returns the Id for the supplied emulator name.
  1421. *
  1422. * ARGUMENTS:
  1423. * hEmu - The External Emulator Handle.
  1424. * *acBuffer - The address of a buffer to receive the information.
  1425. * nSize - The size of the buffer.
  1426. *
  1427. * RETURNS:
  1428. * An emulator ID otherwise (-1) if the function fails.
  1429. *
  1430. */
  1431. int emuGetIdFromName(const HEMU hEmu, TCHAR *achEmuName)
  1432. {
  1433. const HHEMU hhEmu = (HHEMU)hEmu;
  1434. int iRet, idx;
  1435. for(idx = 0; idx < NBR_EMULATORS; idx++)
  1436. {
  1437. iRet = StrCharCmp(achEmuName, hhEmu->pstNameTable[idx].acName);
  1438. if (iRet == 0)
  1439. {
  1440. return(hhEmu->pstNameTable[idx].nEmuId);
  1441. }
  1442. }
  1443. return(-1);
  1444. }
  1445. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1446. * FUNCTION:
  1447. * emuQueryEmulatorId
  1448. *
  1449. * DESCRIPTION:
  1450. * Returns the oridinal value for the current emulator. This can be
  1451. * used through-out the program to write conditional code for emulators.
  1452. *
  1453. * ARGUMENTS:
  1454. * HEMU hEmulator - external emulator handle.
  1455. *
  1456. * RETURNS:
  1457. * ordinal value (>0).
  1458. *
  1459. */
  1460. int emuQueryEmulatorId(const HEMU hEmulator)
  1461. {
  1462. const HHEMU hhEmu = (HHEMU)hEmulator;
  1463. int nEmuId;
  1464. if (hhEmu == 0)
  1465. {
  1466. assert(0);
  1467. return -1;
  1468. }
  1469. emuLock(hEmulator);
  1470. nEmuId = hhEmu->stUserSettings.nEmuId;
  1471. emuUnlock(hEmulator);
  1472. return (nEmuId);
  1473. }
  1474. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1475. * emuLoad
  1476. *
  1477. * DESCRIPTION:
  1478. * Loads all pertinent tables into memory for the specified emulator.
  1479. *
  1480. * ARGUMENTS: hEmu External Emulator Handle.
  1481. * nEmuId ID that identifies a specific emulator.
  1482. * fForceLoad -
  1483. *
  1484. *
  1485. * RETURNS: 0 if successful. -1 if nEmuId is invalid.
  1486. *
  1487. */
  1488. int emuLoad(const HEMU hEmu, const int nEmuId)
  1489. {
  1490. const HHEMU hhEmu = (HHEMU)hEmu;
  1491. int col;
  1492. void (*emuInitFunction)(const HHEMU hhEmu);
  1493. if (hEmu == 0)
  1494. {
  1495. assert(0);
  1496. return -2;
  1497. }
  1498. emuLock(hEmu);
  1499. // If the requested emulator is already loaded, return.
  1500. //
  1501. if (hhEmu->nEmuLoaded == nEmuId)
  1502. {
  1503. emuUnlock(hEmu);
  1504. return 0;
  1505. }
  1506. // Validate nEmuId and set set initialization function.
  1507. switch(nEmuId)
  1508. {
  1509. #if defined(INCL_MINITEL)
  1510. case EMU_MINI:
  1511. if (hhEmu->nEmuLoaded == EMU_AUTO && hhEmu->hSession)
  1512. {
  1513. HCOM hCom = sessQueryComHdl(hhEmu->hSession);
  1514. HCLOOP hCLoop = sessQueryCLoopHdl(hhEmu->hSession);
  1515. HCNCT hCnct = sessQueryCnctHdl(hhEmu->hSession);
  1516. if (hCom && ComValidHandle(hCom))
  1517. {
  1518. int iDataBits = 8;
  1519. int iParity = NOPARITY;
  1520. int iStopBits = ONESTOPBIT;
  1521. ComGetDataBits(hCom, &iDataBits);
  1522. ComGetParity(hCom, &iParity);
  1523. ComGetStopBits(hCom, &iStopBits);
  1524. //
  1525. // Force the incoming ASCII data to 7 bit.
  1526. //
  1527. CLoopSetASCII7(hCLoop, TRUE);
  1528. if (iDataBits != 7 || iParity != EVENPARITY || iStopBits != ONESTOPBIT)
  1529. {
  1530. const HHCNCT hhCnct = (HHCNCT)hCnct;
  1531. ComSetDataBits(hCom, 7);
  1532. ComSetParity(hCom, EVENPARITY);
  1533. ComSetStopBits(hCom, ONESTOPBIT);
  1534. ComSetAutoDetect(hCom, FALSE);
  1535. if (hCnct)
  1536. {
  1537. HHDRIVER hhDriver = (HHDRIVER)hhCnct->hDriver;
  1538. if (hhDriver && cncttapiSetLineConfig(hhDriver->dwLine, hCom) == -16)
  1539. {
  1540. cnctDisconnect(hCnct, CNCT_DIALNOW | CNCT_XFERABORTCONFIRM);
  1541. }
  1542. }
  1543. }
  1544. }
  1545. }
  1546. emuInitFunction = emuMinitelInit;
  1547. break;
  1548. #endif
  1549. case EMU_AUTO:
  1550. emuInitFunction = emuAutoInit;
  1551. break;
  1552. case EMU_ANSIW:
  1553. case EMU_ANSI:
  1554. emuInitFunction = emuAnsiInit;
  1555. break;
  1556. case EMU_TTY:
  1557. emuInitFunction = emuAnsiInit;
  1558. break;
  1559. case EMU_VT100J:
  1560. case EMU_VT100:
  1561. emuInitFunction = vt100_init;
  1562. break;
  1563. case EMU_VT52:
  1564. emuInitFunction = vt52_init;
  1565. break;
  1566. #if defined(INCL_VT220)
  1567. case EMU_VT220:
  1568. emuInitFunction = vt220_init;
  1569. break;
  1570. #endif
  1571. #if defined(INCL_VT320)
  1572. case EMU_VT320:
  1573. emuInitFunction = vt220_init; // The VT320 is the same as the VT220.
  1574. break;
  1575. #endif
  1576. #if defined(INCL_VT100PLUS)
  1577. case EMU_VT100PLUS:
  1578. emuInitFunction = vt100_init; // The VT100+ is the same as the VT100.
  1579. break;
  1580. #endif
  1581. #if defined(INCL_VTUTF8)
  1582. case EMU_VTUTF8:
  1583. emuInitFunction = vtutf8_init;
  1584. break;
  1585. #endif
  1586. #if defined(INCL_VIEWDATA)
  1587. case EMU_VIEW:
  1588. emuInitFunction = EmuViewdataInit;
  1589. break;
  1590. #endif
  1591. default:
  1592. emuUnlock(hEmu);
  1593. return(-1);
  1594. }
  1595. // Remove the current emulator, if one is loaded.
  1596. //
  1597. if (hhEmu->emu_deinstall)
  1598. (*hhEmu->emu_deinstall)(hhEmu);
  1599. // Save the new emulator Id.
  1600. //
  1601. hhEmu->stUserSettings.nEmuId = nEmuId;
  1602. hhEmu->nEmuLoaded = nEmuId;
  1603. // setup function pointers to standard routines.
  1604. hhEmu->EmuSetCursorType = EmuStdSetCursorType;
  1605. hhEmu->emuResetTerminal = stdResetTerminal;
  1606. hhEmu->emu_graphic = emuStdGraphic;
  1607. #if defined(EXTENDED_FEATURES)
  1608. hhEmu->emu_datain = emuStdDataIn;
  1609. #else
  1610. hhEmu->emu_datain = emuDataIn;
  1611. #endif
  1612. hhEmu->emu_kbdin = std_kbdin;
  1613. hhEmu->emu_getscrsize = std_getscrsize;
  1614. #ifdef INCL_TERMINAL_SIZE_AND_COLORS
  1615. hhEmu->emu_setscrsize = std_setscrsize;
  1616. #endif
  1617. hhEmu->emu_getscrollcnt = std_getscrollcnt;
  1618. hhEmu->emu_getcurpos = std_getcurpos;
  1619. hhEmu->emu_setcurpos = std_setcurpos;
  1620. hhEmu->emu_getattr = std_getattr;
  1621. hhEmu->emu_setattr = std_setattr;
  1622. hhEmu->emu_setcolors = std_setcolors;
  1623. hhEmu->emu_getcolors = std_getcolors;
  1624. hhEmu->emu_initcolors = std_initcolors;
  1625. hhEmu->emu_clearscreen = std_clearscreen;
  1626. hhEmu->emu_clearline = std_clearline;
  1627. hhEmu->emu_clearrgn = std_clearrgn;
  1628. hhEmu->emu_scroll = std_scroll;
  1629. hhEmu->emu_deinstall = std_deinstall;
  1630. hhEmu->emu_ntfy = std_emu_ntfy;
  1631. hhEmu->emuHomeHostCursor= std_HomeHostCursor;
  1632. hhEmu->emu_maxrow = EMU_DEFAULT_MAXROW;
  1633. hhEmu->emu_maxcol = EMU_DEFAULT_MAXCOL;
  1634. hhEmu->bottom_margin = hhEmu->emu_maxrow; // mrw:2/21/96
  1635. hhEmu->top_margin = 0; // mrw:2/21/96
  1636. hhEmu->emu_charattr = hhEmu->attrState[CS_STATE];
  1637. hhEmu->emu_clearattr =
  1638. hhEmu->emu_clearattr_sav = hhEmu->attrState[CSCLEAR_STATE];
  1639. // Initialize mode variables.
  1640. //
  1641. hhEmu->mode_KAM = RESET; /* Enable Keyboard */
  1642. hhEmu->mode_IRM = RESET; /* Replace chars rather than insert */
  1643. hhEmu->mode_VEM = RESET; /* Inserting lines scrolls down, not up */
  1644. hhEmu->mode_HEM = RESET; /* Inserting chars scrolls right, not left */
  1645. hhEmu->mode_SRM = SET; /* Send-Receive. No local character echo */
  1646. hhEmu->mode_LNM = RESET; /* LF moves vertically only */
  1647. hhEmu->mode_DECOM = RESET; /* Absolute cursor positioning */
  1648. hhEmu->mode_DECPFF = RESET; /* No form feed after screen prINT */
  1649. hhEmu->mode_DECPEX = RESET; /* PrINT only scroll rgn. on screen prINT */
  1650. hhEmu->mode_DECSCNM = RESET; /* Screen mode. RESET=normal vid, SET=reverse vid */
  1651. hhEmu->mode_DECTCEM = SET; /* Cursor enable. RESET=hidden, SET=visible */
  1652. hhEmu->mode_25enab = RESET; /* When true (SET), emulator can use 25th line */
  1653. hhEmu->mode_protect = RESET; /* When true (SET), protected mode is on */
  1654. hhEmu->mode_block = RESET; /* When true (SET), block mode is on */
  1655. hhEmu->mode_local = RESET; /* When true (SET), block mode is on */
  1656. hhEmu->print_echo = FALSE;
  1657. // Initialize state table.
  1658. //
  1659. hhEmu->emu_highchar = 0x7F;
  1660. // Set default tab stops to 8.
  1661. //
  1662. //for (col = 0; col <= EMU_DEFAULT_MAXCOL; ++col)
  1663. // Need to define tab stops for the whole screen so received tabs
  1664. // with cursor at column 72 or more will go to the next tab rather
  1665. // than the right edge of the screen. 22 Apr 99 rde
  1666. for (col = 0; col < MAX_EMUCOLS; ++col)
  1667. {
  1668. if (!(col % 8))
  1669. hhEmu->tab_stop[col] = TRUE;
  1670. }
  1671. // Call initialization function for emulator.
  1672. //
  1673. (*emuInitFunction)(hhEmu);
  1674. // Paints every cell with the new attributes...
  1675. //
  1676. std_initcolors(hhEmu);
  1677. #ifdef INCL_TERMINAL_SIZE_AND_COLORS
  1678. // Update the screen size.
  1679. //
  1680. hhEmu->emu_setscrsize(hhEmu);
  1681. #endif
  1682. // We want the terminal to read the emulator image after loading
  1683. // but we don't want a scroll operation so update each line
  1684. // individually - mrw
  1685. updateLine(sessQueryUpdateHdl(hhEmu->hSession), 0, hhEmu->emu_maxrow);
  1686. NotifyClient(hhEmu->hSession, EVENT_EMU_CLRATTR, 0);
  1687. NotifyClient(hhEmu->hSession, EVENT_EMU_SETTINGS, 0);
  1688. NotifyClient(hhEmu->hSession, EVENT_TERM_UPDATE, 0);
  1689. emuUnlock(hEmu);
  1690. PostMessage(sessQueryHwndStatusbar(hhEmu->hSession),
  1691. SBR_NTFY_REFRESH, (WPARAM)SBR_EMU_PART_NO, 0);
  1692. return 0;
  1693. }
  1694. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1695. * FUNCTION:
  1696. * emuQuerySettings
  1697. *
  1698. * DESCRIPTION:
  1699. * This function returns a copy of the of the User Settings structure
  1700. * found in the internal emulator handle.
  1701. *
  1702. * ARGUMENTS:
  1703. * HEMU - The External emulator handle.
  1704. * PSTEMUSET - A pointer to a structure of type STEMUSET
  1705. *
  1706. * RETURNS:
  1707. * 0=OK, else error
  1708. *
  1709. */
  1710. int emuQuerySettings(const HEMU hEmu, PSTEMUSET pstSettings)
  1711. {
  1712. const HHEMU hhEmu = (HHEMU)hEmu;
  1713. if (hhEmu == 0)
  1714. {
  1715. assert(0);
  1716. return -1;
  1717. }
  1718. emuLock(hEmu);
  1719. MemCopy(pstSettings, &hhEmu->stUserSettings, sizeof(STEMUSET));
  1720. emuUnlock(hEmu);
  1721. return 0;
  1722. }
  1723. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1724. * FUNCTION:
  1725. * emuSetSettings
  1726. *
  1727. * DESCRIPTION:
  1728. * This function stores the Emulator Settings in the internal Emualtor
  1729. * handle. This function DOES NOT save the information in the session
  1730. * file. The values to be set are validated. If any values passed
  1731. * into this routine are invalid, default values will be set.
  1732. *
  1733. * ARGUMENTS:
  1734. *
  1735. * RETURNS:
  1736. * 0 if the values passed in are validated. A number less than 0 will
  1737. * be returned if any one of the values are invalid. Note that in the
  1738. * case of several invalid settings, the return value will point only
  1739. * to the last one that was invalid.
  1740. *
  1741. */
  1742. int emuSetSettings(const HEMU hEmu, const PSTEMUSET pstSettings)
  1743. {
  1744. const HHEMU hhEmu = (HHEMU)hEmu;
  1745. int iReturn;
  1746. if (hhEmu == 0)
  1747. {
  1748. assert(0);
  1749. return -1;
  1750. }
  1751. iReturn = 0;
  1752. switch(pstSettings->nEmuId)
  1753. {
  1754. case EMU_AUTO:
  1755. case EMU_ANSI:
  1756. case EMU_ANSIW:
  1757. case EMU_MINI:
  1758. case EMU_VIEW:
  1759. case EMU_TTY:
  1760. case EMU_VT100:
  1761. case EMU_VT100J:
  1762. case EMU_VT52:
  1763. case EMU_VT220:
  1764. case EMU_VT320:
  1765. case EMU_VT100PLUS:
  1766. case EMU_VTUTF8:
  1767. break;
  1768. default:
  1769. pstSettings->nEmuId = EMU_AUTO;
  1770. iReturn = -1;
  1771. assert(FALSE);
  1772. break;
  1773. }
  1774. switch(pstSettings->nTermKeys)
  1775. {
  1776. case EMU_KEYS_ACCEL:
  1777. case EMU_KEYS_TERM:
  1778. case EMU_KEYS_SCAN:
  1779. break;
  1780. default:
  1781. pstSettings->nTermKeys = EMU_KEYS_TERM;
  1782. iReturn = -2;
  1783. assert(FALSE);
  1784. break;
  1785. }
  1786. switch(pstSettings->nCursorType)
  1787. {
  1788. case EMU_CURSOR_BLOCK:
  1789. case EMU_CURSOR_LINE:
  1790. case EMU_CURSOR_NONE:
  1791. break;
  1792. default:
  1793. pstSettings->nCursorType = EMU_CURSOR_LINE;
  1794. iReturn = -3;
  1795. assert(FALSE);
  1796. break;
  1797. }
  1798. switch(pstSettings->nCharacterSet)
  1799. {
  1800. case EMU_CHARSET_ASCII:
  1801. case EMU_CHARSET_UK:
  1802. case EMU_CHARSET_SPECIAL:
  1803. #if defined(INCL_VT220)
  1804. case EMU_CHARSET_MULTINATIONAL:
  1805. case EMU_CHARSET_FRENCH:
  1806. case EMU_CHARSET_FRENCHCANADIAN:
  1807. case EMU_CHARSET_GERMAN:
  1808. #endif
  1809. break;
  1810. default:
  1811. pstSettings->nCharacterSet = EMU_CHARSET_ASCII;
  1812. iReturn = -4;
  1813. assert(FALSE);
  1814. break;
  1815. }
  1816. // The values to be set have been validated. Set the emulator handle
  1817. // values, and the internal emualtor variables that correspond.
  1818. //
  1819. emuLock(hEmu);
  1820. #ifdef INCL_TERMINAL_SIZE_AND_COLORS
  1821. if (pstSettings->nTextColor != hhEmu->stUserSettings.nTextColor ||
  1822. pstSettings->nBackgroundColor != hhEmu->stUserSettings.nBackgroundColor)
  1823. {
  1824. // The user defined colors have changed--implement them.
  1825. std_setcolors(hhEmu,
  1826. pstSettings->nTextColor,
  1827. pstSettings->nBackgroundColor);
  1828. }
  1829. #endif
  1830. // When called from emuInitializeHdl, the source and dest pointers
  1831. // for the following call are the same, so there's no need to
  1832. // to do the copy.
  1833. //
  1834. if(&hhEmu->stUserSettings != pstSettings)
  1835. MemCopy(&hhEmu->stUserSettings, pstSettings, sizeof(STEMUSET));
  1836. hhEmu->iCurType = hhEmu->stUserSettings.nCursorType;
  1837. hhEmu->mode_AWM = hhEmu->stUserSettings.fWrapLines;
  1838. hhEmu->mode_DECKPAM = hhEmu->stUserSettings.fKeypadAppMode;
  1839. hhEmu->mode_DECCKM = hhEmu->stUserSettings.fCursorKeypadMode;
  1840. hhEmu->fUse8BitCodes = hhEmu->stUserSettings.fUse8BitCodes;
  1841. hhEmu->fAllowUserKeys = hhEmu->stUserSettings.fAllowUserKeys;
  1842. // Call emuSetDecColumns only if the emulator is a VT100, and
  1843. // there has been change in the user setting of 132 column mode.
  1844. //
  1845. emuSetDecColumns(hhEmu,
  1846. hhEmu->stUserSettings.f132Columns ?
  1847. VT_MAXCOL_132MODE :
  1848. VT_MAXCOL_80MODE,
  1849. FALSE);
  1850. #ifdef INCL_TERMINAL_SIZE_AND_COLORS
  1851. // Set the possible new row and column values if
  1852. // the emulator is not about to change.
  1853. //
  1854. hhEmu->emu_setscrsize(hhEmu);
  1855. #endif
  1856. emuUnlock(hEmu);
  1857. NotifyClient(hhEmu->hSession, EVENT_EMU_SETTINGS, 0);
  1858. //JMH 01-09-97 These two events also need to be sent, says JCM.
  1859. //
  1860. NotifyClient(hhEmu->hSession, EVENT_TERM_UPDATE, 0);
  1861. NotifyClient(hhEmu->hSession, EVENT_EMU_CLRATTR, 0);
  1862. return(iReturn);
  1863. }
  1864. #if defined(EXTENDED_FEATURES) //TODO:rde 23 mar 98
  1865. // When we're comfortable enough with changing to using a function
  1866. // pointer here, do it for all builds.
  1867. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1868. * FUNCTION:
  1869. * emuDataIn
  1870. *
  1871. * DESCRIPTION:
  1872. * External entry point for incoming data.
  1873. *
  1874. * ARGUMENTS:
  1875. * hEmu - public emulator handle
  1876. * ccode - character code
  1877. *
  1878. * RETURNS:
  1879. * TRUE if displayable
  1880. *
  1881. */
  1882. int emuDataIn(const HEMU hEmu, const ECHAR ccode)
  1883. {
  1884. int iRetVal = TRUE;
  1885. const HHEMU hhEmu = (HHEMU)hEmu;
  1886. if (hhEmu == 0)
  1887. {
  1888. assert(FALSE);
  1889. }
  1890. else
  1891. {
  1892. emuLock(hEmu);
  1893. CaptureChar(sessQueryCaptureFileHdl(hhEmu->hSession),
  1894. CPF_MODE_RAW,
  1895. ccode); //moved from emuStdDataIn 05AUG98 mpt
  1896. emuUnlock(hEmu);
  1897. iRetVal = (*hhEmu->emu_datain)(hhEmu, ccode);
  1898. }
  1899. return iRetVal;
  1900. }
  1901. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1902. * emuStdDataIn
  1903. *
  1904. * DESCRIPTION:
  1905. * Processes passed in codes through the emulation state tables.
  1906. *
  1907. * ARGUMENTS:
  1908. * hhEmu - The internal emulator handle.
  1909. * ccode - The character to process.
  1910. *
  1911. * RETURNS:
  1912. * TRUE if displayable character
  1913. */
  1914. int emuStdDataIn(const HHEMU hhEmu, const ECHAR ccode)
  1915. {
  1916. //ECHAR echCode;
  1917. int ntrans;
  1918. struct trans_entry *tptr;
  1919. emuLock((HEMU)hhEmu);
  1920. hhEmu->emu_code = ETEXT(ccode);
  1921. // Capture raw data.
  1922. //
  1923. #if 0 //moved to emuDataIn to prevent characters being captures
  1924. //multiple times due to the re-entrant nature of this function. - mpt 5aug98
  1925. CaptureChar(sessQueryCaptureFileHdl(hhEmu->hSession),
  1926. CPF_MODE_RAW,
  1927. ccode);
  1928. #endif
  1929. // Seek next state by finding character range.
  1930. //
  1931. tptr = hhEmu->state_tbl[hhEmu->state].first_trans;
  1932. ntrans = hhEmu->state_tbl[hhEmu->state].number_trans;
  1933. for (; ntrans > 0; ntrans--, ++tptr)
  1934. if (ccode >= tptr->lochar && ccode <= tptr->hichar)
  1935. break;
  1936. if (ntrans <= 0)
  1937. {
  1938. // Added to handle the case of 2 successive ESC chars--just
  1939. // the 1st ESC should be thrown away
  1940. hhEmu->state = 0;
  1941. tptr = hhEmu->state_tbl[hhEmu->state].first_trans;
  1942. ntrans = hhEmu->state_tbl[hhEmu->state].number_trans;
  1943. for (; ntrans > 0; ntrans--, ++tptr)
  1944. {
  1945. if (ccode >= tptr->lochar && ccode <= tptr->hichar)
  1946. break;
  1947. }
  1948. // 6-14-83
  1949. // second condition (below) added to allow emulator to toss invalid
  1950. // escpae sequences (i.e.ESC [ 0v).
  1951. if (ntrans <= 0 || tptr->next_state == 0)
  1952. {
  1953. commanderror(hhEmu);
  1954. goto DataInExit;
  1955. }
  1956. else
  1957. {
  1958. CaptureChar(sessQueryCaptureFileHdl(hhEmu->hSession),
  1959. CF_CAP_CHARS, ccode);
  1960. printEchoChar(hhEmu->hPrintEcho, ccode);
  1961. }
  1962. }
  1963. hhEmu->state = tptr->next_state;
  1964. (*tptr->funct_ptr)(hhEmu);
  1965. // The code has been process through the emulator. Check for
  1966. // capturing and printing, and reset other emulator values.
  1967. //
  1968. if (hhEmu->state == 0)
  1969. {
  1970. if (IN_RANGE(ccode, ETEXT(' '), hhEmu->emu_highchar) ||
  1971. ccode == ETEXT('\r') ||
  1972. ccode == ETEXT('\n'))
  1973. {
  1974. CaptureChar(sessQueryCaptureFileHdl(hhEmu->hSession),
  1975. CF_CAP_CHARS, ccode);
  1976. printEchoChar(hhEmu->hPrintEcho, ccode);
  1977. }
  1978. hhEmu->num_param_cnt = hhEmu->selector_cnt =
  1979. hhEmu->selector[0] = hhEmu->num_param[0] = 0;
  1980. hhEmu->DEC_private = FALSE;
  1981. }
  1982. DataInExit:
  1983. emuUnlock((HEMU)hhEmu);
  1984. return(TRUE);
  1985. }
  1986. //#if FALSE
  1987. #else
  1988. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1989. * emuDataIn
  1990. *
  1991. * DESCRIPTION:
  1992. * Processes passed in codes through the emulation state tables.
  1993. *
  1994. * ARGUMENTS:
  1995. * hhEmu - The internal emulator handle.
  1996. * ccode - The character to process.
  1997. *
  1998. * RETURNS:
  1999. * TRUE if displayable character
  2000. */
  2001. int emuDataIn(const HEMU hEmu, const ECHAR ccode)
  2002. {
  2003. //ECHAR echCode;
  2004. int ntrans;
  2005. struct trans_entry *tptr;
  2006. const HHEMU hhEmu = (HHEMU)hEmu;
  2007. if (hhEmu == 0)
  2008. {
  2009. assert(FALSE);
  2010. goto DataInExit;
  2011. }
  2012. emuLock(hEmu);
  2013. hhEmu->emu_code = ETEXT(ccode);
  2014. // Capture raw data.
  2015. //
  2016. CaptureChar(sessQueryCaptureFileHdl(hhEmu->hSession),
  2017. CPF_MODE_RAW,
  2018. ccode);
  2019. // Seek next state by finding character range.
  2020. //
  2021. tptr = hhEmu->state_tbl[hhEmu->state].first_trans;
  2022. ntrans = hhEmu->state_tbl[hhEmu->state].number_trans;
  2023. for (; ntrans > 0; ntrans--, ++tptr)
  2024. if (ccode >= tptr->lochar && ccode <= tptr->hichar)
  2025. break;
  2026. if (ntrans <= 0)
  2027. {
  2028. // Added to handle the case of 2 successive ESC chars--just
  2029. // the 1st ESC should be thrown away
  2030. hhEmu->state = 0;
  2031. tptr = hhEmu->state_tbl[hhEmu->state].first_trans;
  2032. ntrans = hhEmu->state_tbl[hhEmu->state].number_trans;
  2033. for (; ntrans > 0; ntrans--, ++tptr)
  2034. {
  2035. if (ccode >= tptr->lochar && ccode <= tptr->hichar)
  2036. break;
  2037. }
  2038. // 6-14-83
  2039. // second condition (below) added to allow emulator to toss invalid
  2040. // escpae sequences (i.e.ESC [ 0v).
  2041. if (ntrans <= 0 || tptr->next_state == 0)
  2042. {
  2043. commanderror(hhEmu);
  2044. goto DataInExit;
  2045. }
  2046. else
  2047. {
  2048. CaptureChar(sessQueryCaptureFileHdl(hhEmu->hSession),
  2049. CF_CAP_CHARS, ccode);
  2050. printEchoChar(hhEmu->hPrintEcho, ccode);
  2051. }
  2052. }
  2053. hhEmu->state = tptr->next_state;
  2054. (*tptr->funct_ptr)(hhEmu);
  2055. // The code has been process through the emulator. Check for
  2056. // capturing and printing, and reset other emulator values.
  2057. //
  2058. if (hhEmu->state == 0)
  2059. {
  2060. if (IN_RANGE(ccode, ETEXT(' '), hhEmu->emu_highchar) ||
  2061. ccode == ETEXT('\r') ||
  2062. ccode == ETEXT('\n'))
  2063. {
  2064. CaptureChar(sessQueryCaptureFileHdl(hhEmu->hSession),
  2065. CF_CAP_CHARS, ccode);
  2066. printEchoChar(hhEmu->hPrintEcho, ccode);
  2067. }
  2068. hhEmu->num_param_cnt = hhEmu->selector_cnt =
  2069. hhEmu->selector[0] = hhEmu->num_param[0] = 0;
  2070. hhEmu->DEC_private = FALSE;
  2071. }
  2072. DataInExit:
  2073. emuUnlock(hEmu);
  2074. return(TRUE);
  2075. }
  2076. #endif
  2077. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  2078. * FUNCTION:
  2079. * emuNotify
  2080. *
  2081. * DESCRIPTION:
  2082. * A function that can be called to notify the emulators of an event.
  2083. * As events are identified, they can be added to this function.
  2084. *
  2085. * ARGUMENTS:
  2086. * hEmu - The external emulator handle.
  2087. * nEvent - The event ID.
  2088. *
  2089. * RETURNS:
  2090. * 0=OK, else error
  2091. *
  2092. */
  2093. int emuNotify(const HEMU hEmu, const int nEvent)
  2094. {
  2095. const HHEMU hhEmu = (HHEMU)hEmu;
  2096. if (hhEmu == 0)
  2097. {
  2098. assert(FALSE);
  2099. return -1;
  2100. }
  2101. emuLock(hEmu);
  2102. switch(nEvent)
  2103. {
  2104. case EMU_EVENT_CONNECTED:
  2105. hhEmu->fWasConnected = TRUE;
  2106. break;
  2107. case EMU_EVENT_DISCONNECTED:
  2108. if (hhEmu->stUserSettings.nEmuId == EMU_AUTO)
  2109. {
  2110. if (hhEmu->fWasConnected)
  2111. hhEmu->stUserSettings.nAutoAttempts++;
  2112. if (hhEmu->stUserSettings.nAutoAttempts ==
  2113. EMU_MAX_AUTODETECT_ATTEMPTS)
  2114. #if !defined(FAR_EAST)
  2115. emuAutoDetectLoad(hhEmu, EMU_ANSI);
  2116. #else
  2117. emuAutoDetectLoad(hhEmu, EMU_ANSIW);
  2118. #endif
  2119. }
  2120. hhEmu->fWasConnected = FALSE;
  2121. break;
  2122. default:
  2123. break;
  2124. }
  2125. (*hhEmu->emu_ntfy)(hhEmu, nEvent);
  2126. emuUnlock(hEmu);
  2127. return 0;
  2128. }
  2129. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  2130. * FUNCTION:
  2131. * emuHomeHostCursor
  2132. *
  2133. * DESCRIPTION:
  2134. * Homes the cursor. Needed when we first load a session. Incidently,
  2135. * homing the cursor for a minitel places the cursor at 1,0, not 0,0
  2136. * which is why this function exists.
  2137. *
  2138. * ARGUMENTS:
  2139. * hEmu - public emulator handle.
  2140. *
  2141. * RETURNS:
  2142. * 0=OK,else error
  2143. *
  2144. */
  2145. int emuHomeHostCursor(const HEMU hEmu)
  2146. {
  2147. const HHEMU hhEmu = (HHEMU)hEmu;
  2148. if (hhEmu == 0)
  2149. {
  2150. assert(0);
  2151. return -1;
  2152. }
  2153. return (*hhEmu->emuHomeHostCursor)(hhEmu);
  2154. }
  2155. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  2156. * FUNCTION:
  2157. * emuEraseTerminalScreen
  2158. *
  2159. * DESCRIPTION:
  2160. * Erases emulator image, doesn't put stuff in the backscroll.
  2161. *
  2162. * ARGUMENTS:
  2163. * hEmu - public emulator handle.
  2164. *
  2165. * RETURNS:
  2166. * 0=OK,else error
  2167. *
  2168. */
  2169. int emuEraseTerminalScreen(const HEMU hEmu)
  2170. {
  2171. const HHEMU hhEmu = (HHEMU)hEmu;
  2172. int i;
  2173. if (hhEmu == 0)
  2174. {
  2175. assert(0);
  2176. return -1;
  2177. }
  2178. for (i = 0 ; i <= hhEmu->emu_maxrow ; ++i)
  2179. clear_imgrow(hhEmu, i);
  2180. updateLine(sessQueryUpdateHdl(hhEmu->hSession), 0, hhEmu->emu_maxrow);
  2181. // The notify function is used to in minitel to set the state
  2182. // of the screen based on connection status (F or C in upper corner).
  2183. //
  2184. hhEmu->emu_ntfy(hhEmu, 0);
  2185. return 0;
  2186. }
  2187. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  2188. * FUNCTION:
  2189. * emuQueryDefaultTelnetId
  2190. *
  2191. * DESCRIPTION:
  2192. * Gets the default telnet terminal id string for the given emulator.
  2193. *
  2194. * ARGUMENTS:
  2195. * nEmuId - id of the emulator (e.g. EMU_ANSI).
  2196. * achTelnetId - pointer to the buffer for the string.
  2197. * nSize - size of the buffer (in characters).
  2198. *
  2199. * RETURNS:
  2200. * 0=OK, else error
  2201. *
  2202. * AUTHOR: C. Baumgartner, 11/15/96
  2203. */
  2204. int emuQueryDefaultTelnetId(const int nEmuId, TCHAR *achTelnetId, int nSize)
  2205. {
  2206. int iRet = 0;
  2207. TCHAR * pszDefaultId;
  2208. // Note : Since these strings are a part of the telnet
  2209. // protocol, it is okay if they are hard-coded.
  2210. //
  2211. switch(nEmuId)
  2212. {
  2213. case EMU_AUTO:
  2214. case EMU_ANSI:
  2215. pszDefaultId = TEXT("ANSI");
  2216. break;
  2217. case EMU_TTY:
  2218. pszDefaultId = TEXT("TELETYPE-33");
  2219. break;
  2220. case EMU_VT52:
  2221. pszDefaultId = TEXT("VT52");
  2222. break;
  2223. #if defined(INCL_VT220)
  2224. case EMU_VT220:
  2225. pszDefaultId = TEXT("VT220");
  2226. break;
  2227. #endif
  2228. #if defined(INCL_VT320)
  2229. case EMU_VT320:
  2230. pszDefaultId = TEXT("VT320");
  2231. break;
  2232. #endif
  2233. #if defined(INCL_VT100PLUS)
  2234. case EMU_VT100PLUS:
  2235. pszDefaultId = TEXT("VT100+");
  2236. break;
  2237. #endif
  2238. #if defined(INCL_VTUTF8)
  2239. case EMU_VTUTF8:
  2240. pszDefaultId = TEXT("VT-UTF8");
  2241. break;
  2242. #endif
  2243. case EMU_VT100:
  2244. default:
  2245. pszDefaultId = TEXT("VT100");
  2246. break;
  2247. }
  2248. if ( StrCharGetStrLength(pszDefaultId) < nSize )
  2249. {
  2250. StrCharCopyN(achTelnetId, pszDefaultId, nSize);
  2251. iRet = 0;
  2252. }
  2253. else
  2254. {
  2255. iRet = -1;
  2256. }
  2257. return iRet;
  2258. }
  2259. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  2260. * FUNCTION:
  2261. * emuLoadDefaultTelnetId
  2262. *
  2263. * DESCRIPTION:
  2264. * Loads the given emulator handle with the default telnet terminal id
  2265. * string for the current emulator type.
  2266. *
  2267. * ARGUMENTS:
  2268. * hEmu - A public emulator handle
  2269. *
  2270. * RETURNS:
  2271. * 0=OK, else error
  2272. *
  2273. * AUTHOR: C. Baumgartner, 11/18/96
  2274. */
  2275. int emuLoadDefaultTelnetId(const HEMU hEmu)
  2276. {
  2277. HHEMU hhEmu = (HHEMU)hEmu;
  2278. return emuQueryDefaultTelnetId(hhEmu->stUserSettings.nEmuId,
  2279. hhEmu->stUserSettings.acTelnetId, EMU_MAX_TELNETID);
  2280. }
  2281. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  2282. * FUNCTION:
  2283. * emuLoadSettings
  2284. *
  2285. * DESCRIPTION:
  2286. * Loads the given emulator user settings.
  2287. *
  2288. * ARGUMENTS:
  2289. * hhEmu - an internal emulator handle
  2290. * uiId - the SFID of the data to load
  2291. * ulDataSize - the size of the data to load (in bytes)
  2292. * pvData - address at which to put the data
  2293. *
  2294. * RETURNS:
  2295. * The size (in bytes) of the data loaded, -1 if an error occured
  2296. *
  2297. * AUTHOR: Bob Everett - 6 Jun 1998
  2298. */
  2299. STATIC_FUNC int emuLoadSettings(const HHEMU hhEmu,
  2300. const unsigned int uiId,
  2301. unsigned long ulDataSize,
  2302. void *pvData)
  2303. {
  2304. int iResult = 0;
  2305. int iRetVal = 0;
  2306. unsigned long ulSize = 0;
  2307. // Do the screen color settings exist?
  2308. sfGetSessionItem(sessQuerySysFileHdl(hhEmu->hSession), uiId, &ulSize, 0);
  2309. if (ulSize > 0)
  2310. {
  2311. // The settings exist. Go get them.
  2312. iResult = sfGetSessionItem(sessQuerySysFileHdl(hhEmu->hSession),
  2313. uiId, &ulDataSize, pvData);
  2314. if (iResult != 0)
  2315. iRetVal = -1;
  2316. else
  2317. iRetVal = (int)ulSize;
  2318. }
  2319. return iRetVal;
  2320. }
  2321. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  2322. * FUNCTION:
  2323. * emuCheckSettings
  2324. *
  2325. * DESCRIPTION:
  2326. * This ugly piece of code checks for a mismatch in settings between versions.
  2327. * The settings affected are fUse8BitCodes, fAllowUserKeys, nBackspaceKeys,
  2328. * and acTelnetId. The mismatch occurs when moving an HTPE3 session file to
  2329. * any newer version. This includes HT98 and HTPE4.
  2330. *
  2331. * ARGUMENTS:
  2332. * hhEmu - an internal emulator handle
  2333. *
  2334. * RETURNS:
  2335. * Nada, zip, not a thing.
  2336. *
  2337. * AUTHOR: Bob Everett - 8 Jun 1998
  2338. */
  2339. STATIC_FUNC void emuCheckSettings(struct stEmuBaseSFSettings *pstBaseSFSettings)
  2340. {
  2341. TCHAR *psz = 0;
  2342. TCHAR sz[EMU_MAX_TELNETID];
  2343. if ((pstBaseSFSettings->nBackspaceKeys != EMU_BKSPKEYS_CTRLH) &&
  2344. (pstBaseSFSettings->nBackspaceKeys != EMU_BKSPKEYS_DEL) &&
  2345. (pstBaseSFSettings->nBackspaceKeys != EMU_BKSPKEYS_CTRLHSPACE))
  2346. {
  2347. // This is the best test for this scenario. Move the data.
  2348. psz = (TCHAR *)&pstBaseSFSettings->fAllowUserKeys;
  2349. if (StrCharGetStrLength(psz) < EMU_MAX_TELNETID)
  2350. {
  2351. StrCharCopyN(sz, psz, sizeof(sz) / sizeof(TCHAR));
  2352. StrCharCopyN(pstBaseSFSettings->acTelnetId, sz, EMU_MAX_TELNETID );
  2353. }
  2354. pstBaseSFSettings->nBackspaceKeys =
  2355. pstBaseSFSettings->fUse8BitCodes;
  2356. // Use the defaults.
  2357. pstBaseSFSettings->fUse8BitCodes = FALSE;
  2358. pstBaseSFSettings->fAllowUserKeys = FALSE;
  2359. }
  2360. // Check the data.
  2361. if ((pstBaseSFSettings->fUse8BitCodes != TRUE) &&
  2362. (pstBaseSFSettings->fUse8BitCodes != FALSE))
  2363. pstBaseSFSettings->fUse8BitCodes = FALSE;
  2364. if ((pstBaseSFSettings->fAllowUserKeys != TRUE) &&
  2365. (pstBaseSFSettings->fAllowUserKeys != FALSE))
  2366. pstBaseSFSettings->fAllowUserKeys = FALSE;
  2367. if ((pstBaseSFSettings->nBackspaceKeys != EMU_BKSPKEYS_CTRLH) &&
  2368. (pstBaseSFSettings->nBackspaceKeys != EMU_BKSPKEYS_DEL) &&
  2369. (pstBaseSFSettings->nBackspaceKeys != EMU_BKSPKEYS_CTRLHSPACE))
  2370. {
  2371. pstBaseSFSettings->nBackspaceKeys = EMU_BKSPKEYS_CTRLH;
  2372. // Assume that if nBackspaceKeys is messed up, so is acTelnetId.
  2373. pstBaseSFSettings->acTelnetId[0] = TEXT('\0');
  2374. }
  2375. }