xlat.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include "putty.h"
  4. static unsigned char win2koi[] =
  5. {
  6. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  7. 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
  8. 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
  9. 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
  10. 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
  11. 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
  12. 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,
  13. 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
  14. 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
  15. 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
  16. 160,161,162,163,164,189,166,167,179,169,180,171,172,173,174,183,
  17. 176,177,182,166,173,181,182,183,163,185,164,187,188,189,190,167,
  18. 225,226,247,231,228,229,246,250,233,234,235,236,237,238,239,240,
  19. 242,243,244,245,230,232,227,254,251,253,255,249,248,252,224,241,
  20. 193,194,215,199,196,197,214,218,201,202,203,204,205,206,207,208,
  21. 210,211,212,213,198,200,195,222,219,221,223,217,216,220,192,209
  22. };
  23. static unsigned char koi2win[] =
  24. {
  25. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  26. 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
  27. 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
  28. 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
  29. 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
  30. 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
  31. 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,
  32. 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
  33. 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
  34. 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
  35. 160,161,162,184,186,165,179,191,168,169,170,171,172,180,174,175,
  36. 176,177,178,168,170,181,178,175,184,185,186,187,188,165,190,191,
  37. 254,224,225,246,228,229,244,227,245,232,233,234,235,236,237,238,
  38. 239,255,240,241,242,243,230,226,252,251,231,248,253,249,247,250,
  39. 222,192,193,214,196,197,212,195,213,200,201,202,203,204,205,206,
  40. 207,223,208,209,210,211,198,194,220,219,199,216,221,217,215,218
  41. };
  42. static unsigned char xlatWIN1250toISO88592[] =
  43. {
  44. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  45. 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
  46. 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
  47. 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
  48. 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
  49. 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
  50. 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,
  51. 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
  52. 128,129, 39,131, 34, 46,124,124,136, 47,169, 60,166,171,174,172,
  53. 144, 96, 39, 34, 34, 42, 45, 45,152, 84,185, 62,182,187,190,188,
  54. 160,183,162,163,164,161,124,167,168, 99,170, 34, 39,173, 82,175,
  55. 176, 63,178,179,180,117,182,255,184,177,186, 34,165,189,181,191,
  56. 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
  57. 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
  58. 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
  59. 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
  60. };
  61. static unsigned char xlatISO88592toWIN1250[] =
  62. {
  63. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  64. 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
  65. 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
  66. 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
  67. 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
  68. 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
  69. 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,
  70. 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
  71. 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
  72. 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
  73. 160,165,162,163,164,188,140,167,168,138,170,141,143,173,142,175,
  74. 176,185,178,179,180,190,156,161,184,154,186,157,159,189,158,191,
  75. 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
  76. 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
  77. 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
  78. 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
  79. };
  80. unsigned char xlat_kbd2tty(unsigned char c)
  81. {
  82. if(cfg.xlat_enablekoiwin)
  83. return win2koi[c];
  84. else if (cfg.xlat_88592w1250)
  85. return xlatWIN1250toISO88592[c];
  86. return c;
  87. }
  88. unsigned char xlat_tty2scr(unsigned char c)
  89. {
  90. if(cfg.xlat_enablekoiwin)
  91. return koi2win[c];
  92. else if (cfg.xlat_88592w1250)
  93. return xlatISO88592toWIN1250[c];
  94. return c;
  95. }
  96. static unsigned char latkbd2_win[]=
  97. {
  98. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  99. 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
  100. 32, 33,221, 35, 36, 37, 38,253, 40, 41, 42,178,225,186,254, 46,
  101. 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,198,230,193,179,222, 44,
  102. 64,212,200,209,194,211,192,207,208,216,206,203,196,220,210,217,
  103. 199,201,202,219,197,195,204,214,215,205,223,245,191,250, 94,170,
  104. 96,244,232,241,226,243,224,239,240,248,238,235,228,252,242,249,
  105. 231,233,234,251,229,227,236,246,247,237,255,213,175,218,126,127,
  106. 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
  107. 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
  108. 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
  109. 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
  110. 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
  111. 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
  112. 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
  113. 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
  114. };
  115. unsigned char xlat_latkbd2win(unsigned char c)
  116. {
  117. if(cfg.xlat_capslockcyr)
  118. return latkbd2_win[c];
  119. return c;
  120. }