Open-Source-Software-Entwicklung und Downloads

Browse Subversion Repository

Diff of /trunk/teraterm/ttpset/ttset.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3226 by maya, Tue Mar 24 09:37:20 2009 UTC revision 3227 by maya, Tue Mar 24 15:10:33 2009 UTC
# Line 1  Line 1 
1  /* Tera Term  /* Tera Term
2   Copyright(C) 1994-1998 T. Teranishi   Copyright(C) 1994-1998 T. Teranishi
3   All rights reserved. */   All rights reserved. */
4  /* IPv6 modification is Copyright(C) 2000 Jun-ya kato <kato@win6.jp> */  /* IPv6 modification is Copyright(C) 2000 Jun-ya kato <kato@win6.jp> */
5    
6  /* TTSET.DLL, setup file routines*/  /* TTSET.DLL, setup file routines*/
7  #ifndef NO_INET6  #ifndef NO_INET6
8  #include <winsock2.h>  #include <winsock2.h>
9  #include <ws2tcpip.h>  #include <ws2tcpip.h>
10  #endif                                                  /* NO_INET6 */  #endif                                                  /* NO_INET6 */
11  #include "teraterm.h"  #include "teraterm.h"
12  #include "tttypes.h"  #include "tttypes.h"
13  #include <stdio.h>  #include <stdio.h>
14  #include <string.h>  #include <string.h>
15  #include <direct.h>  #include <direct.h>
16  #include "ttlib.h"  #include "ttlib.h"
17  #include "tt_res.h"  #include "tt_res.h"
18    
19  #include "compat_w95.h"  #include "compat_w95.h"
20    
21  #define Section "Tera Term"  #define Section "Tera Term"
22    
23  static PCHAR far TermList[] =  static PCHAR far TermList[] =
24          { "VT100", "VT100J", "VT101", "VT102", "VT102J", "VT220J", "VT282",          { "VT100", "VT100J", "VT101", "VT102", "VT102J", "VT220J", "VT282",
25          "VT320", "VT382", NULL };          "VT320", "VT382", NULL };
26  // expansion (2005.11.30 yutaka)  // expansion (2005.11.30 yutaka)
27  static PCHAR BaudList[] =  static PCHAR BaudList[] =
28          { "110", "300", "600", "1200", "2400", "4800", "9600",          { "110", "300", "600", "1200", "2400", "4800", "9600",
29          "14400", "19200", "38400", "57600", "115200",          "14400", "19200", "38400", "57600", "115200",
30          "230400", "460800", "921600", NULL          "230400", "460800", "921600", NULL
31  };  };
32    
33  static PCHAR far RussList[] =  static PCHAR far RussList[] =
34          { "Windows", "KOI8-R", "CP-866", "ISO-8859-5", NULL };          { "Windows", "KOI8-R", "CP-866", "ISO-8859-5", NULL };
35  static PCHAR far RussList2[] = { "Windows", "KOI8-R", NULL };  static PCHAR far RussList2[] = { "Windows", "KOI8-R", NULL };
36    
37  WORD str2id(PCHAR far * List, PCHAR str, WORD DefId)  WORD str2id(PCHAR far * List, PCHAR str, WORD DefId)
38  {  {
39          WORD i;          WORD i;
40          i = 0;          i = 0;
41          while ((List[i] != NULL) && (_stricmp(List[i], str) != 0))          while ((List[i] != NULL) && (_stricmp(List[i], str) != 0))
42                  i++;                  i++;
43          if (List[i] == NULL)          if (List[i] == NULL)
44                  i = DefId;                  i = DefId;
45          else          else
46                  i++;                  i++;
47    
48          return i;          return i;
49  }  }
50    
51  void id2str(PCHAR far * List, WORD Id, WORD DefId, PCHAR str, int destlen)  void id2str(PCHAR far * List, WORD Id, WORD DefId, PCHAR str, int destlen)
52  {  {
53          int i;          int i;
54    
55          if (Id == 0)          if (Id == 0)
56                  i = DefId - 1;                  i = DefId - 1;
57          else {          else {
58                  i = 0;                  i = 0;
59                  while ((List[i] != NULL) && (i < Id - 1))                  while ((List[i] != NULL) && (i < Id - 1))
60                          i++;                          i++;
61                  if (List[i] == NULL)                  if (List[i] == NULL)
62                          i = DefId - 1;                          i = DefId - 1;
63          }          }
64          strncpy_s(str, destlen, List[i], _TRUNCATE);          strncpy_s(str, destlen, List[i], _TRUNCATE);
65  }  }
66    
67  int IconName2IconId(const char *name) {  int IconName2IconId(const char *name) {
68          int id;          int id;
69    
70          if (_stricmp(name, "tterm") == 0) {          if (_stricmp(name, "tterm") == 0) {
71                  id = IDI_TTERM;                  id = IDI_TTERM;
72          }          }
73          else if (_stricmp(name, "vt") == 0) {          else if (_stricmp(name, "vt") == 0) {
74                  id = IDI_VT;                  id = IDI_VT;
75          }          }
76          else if (_stricmp(name, "tek") == 0) {          else if (_stricmp(name, "tek") == 0) {
77                  id = IDI_TEK;                  id = IDI_TEK;
78          }          }
79          else if (_stricmp(name, "tterm_classic") == 0) {          else if (_stricmp(name, "tterm_classic") == 0) {
80                  id = IDI_TTERM_CLASSIC;                  id = IDI_TTERM_CLASSIC;
81          }          }
82          else if (_stricmp(name, "vt_classic") == 0) {          else if (_stricmp(name, "vt_classic") == 0) {
83                  id = IDI_VT_CLASSIC;                  id = IDI_VT_CLASSIC;
84          }          }
85          else if (_stricmp(name, "cygterm") == 0) {          else if (_stricmp(name, "cygterm") == 0) {
86                  id = IDI_CYGTERM;                  id = IDI_CYGTERM;
87          }          }
88          else {          else {
89                  id = IdIconDefault;                  id = IdIconDefault;
90          }          }
91          return id;          return id;
92  }  }
93    
94  void IconId2IconName(char *name, int len, int id) {  void IconId2IconName(char *name, int len, int id) {
95          char *icon;          char *icon;
96          switch (id) {          switch (id) {
97                  case IDI_TTERM:                  case IDI_TTERM:
98                          icon = "tterm";                          icon = "tterm";
99                          break;                          break;
100                  case IDI_VT:                  case IDI_VT:
101                          icon = "vt";                          icon = "vt";
102                          break;                          break;
103                  case IDI_TEK:                  case IDI_TEK:
104                          icon = "tek";                          icon = "tek";
105                          break;                          break;
106                  case IDI_TTERM_CLASSIC:                  case IDI_TTERM_CLASSIC:
107                          icon = "tterm_classic";                          icon = "tterm_classic";
108                          break;                          break;
109                  case IDI_VT_CLASSIC:                  case IDI_VT_CLASSIC:
110                          icon = "vt_classic";                          icon = "vt_classic";
111                          break;                          break;
112                  case IDI_CYGTERM:                  case IDI_CYGTERM:
113                          icon = "cygterm";                          icon = "cygterm";
114                          break;                          break;
115                  default:                  default:
116                          icon = "Default";                          icon = "Default";
117          }          }
118          strncpy_s(name, len, icon, _TRUNCATE);          strncpy_s(name, len, icon, _TRUNCATE);
119  }  }
120    
121  WORD GetOnOff(PCHAR Sect, PCHAR Key, PCHAR FName, BOOL Default)  WORD GetOnOff(PCHAR Sect, PCHAR Key, PCHAR FName, BOOL Default)
122  {  {
123          char Temp[4];          char Temp[4];
124          GetPrivateProfileString(Sect, Key, "", Temp, sizeof(Temp), FName);          GetPrivateProfileString(Sect, Key, "", Temp, sizeof(Temp), FName);
125          if (Default) {          if (Default) {
126                  if (_stricmp(Temp, "off") == 0)                  if (_stricmp(Temp, "off") == 0)
127                          return 0;                          return 0;
128                  else                  else
129                          return 1;                          return 1;
130          }          }
131          else {          else {
132                  if (_stricmp(Temp, "on") == 0)                  if (_stricmp(Temp, "on") == 0)
133                          return 1;                          return 1;
134                  else                  else
135                          return 0;                          return 0;
136          }          }
137  }  }
138    
139  void WriteOnOff(PCHAR Sect, PCHAR Key, PCHAR FName, WORD Flag)  void WriteOnOff(PCHAR Sect, PCHAR Key, PCHAR FName, WORD Flag)
140  {  {
141          char Temp[4];          char Temp[4];
142    
143          if (Flag != 0)          if (Flag != 0)
144                  strncpy_s(Temp, sizeof(Temp), "on", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "on", _TRUNCATE);
145          else          else
146                  strncpy_s(Temp, sizeof(Temp), "off", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "off", _TRUNCATE);
147          WritePrivateProfileString(Sect, Key, Temp, FName);          WritePrivateProfileString(Sect, Key, Temp, FName);
148  }  }
149    
150  void WriteInt(PCHAR Sect, PCHAR Key, PCHAR FName, int i)  void WriteInt(PCHAR Sect, PCHAR Key, PCHAR FName, int i)
151  {  {
152          char Temp[15];          char Temp[15];
153          _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", i);          _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", i);
154          WritePrivateProfileString(Sect, Key, Temp, FName);          WritePrivateProfileString(Sect, Key, Temp, FName);
155  }  }
156    
157  void WriteUint(PCHAR Sect, PCHAR Key, PCHAR FName, UINT i)  void WriteUint(PCHAR Sect, PCHAR Key, PCHAR FName, UINT i)
158  {  {
159          char Temp[15];          char Temp[15];
160          _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%u", i);          _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%u", i);
161          WritePrivateProfileString(Sect, Key, Temp, FName);          WritePrivateProfileString(Sect, Key, Temp, FName);
162  }  }
163    
164  void WriteInt2(PCHAR Sect, PCHAR Key, PCHAR FName, int i1, int i2)  void WriteInt2(PCHAR Sect, PCHAR Key, PCHAR FName, int i1, int i2)
165  {  {
166          char Temp[32];          char Temp[32];
167          _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d", i1, i2);          _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d", i1, i2);
168          WritePrivateProfileString(Sect, Key, Temp, FName);          WritePrivateProfileString(Sect, Key, Temp, FName);
169  }  }
170    
171  void WriteInt4(PCHAR Sect, PCHAR Key, PCHAR FName,  void WriteInt4(PCHAR Sect, PCHAR Key, PCHAR FName,
172                             int i1, int i2, int i3, int i4)                             int i1, int i2, int i3, int i4)
173  {  {
174          char Temp[64];          char Temp[64];
175          _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d,%d,%d",          _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d,%d,%d",
176                      i1, i2, i3, i4);                      i1, i2, i3, i4);
177          WritePrivateProfileString(Sect, Key, Temp, FName);          WritePrivateProfileString(Sect, Key, Temp, FName);
178  }  }
179    
180  void WriteInt6(PCHAR Sect, PCHAR Key, PCHAR FName,  void WriteInt6(PCHAR Sect, PCHAR Key, PCHAR FName,
181                             int i1, int i2, int i3, int i4, int i5, int i6)                             int i1, int i2, int i3, int i4, int i5, int i6)
182  {  {
183          char Temp[96];          char Temp[96];
184          _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d,%d,%d,%d,%d",          _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d,%d,%d,%d,%d",
185                      i1, i2,i3, i4, i5, i6);                      i1, i2,i3, i4, i5, i6);
186          WritePrivateProfileString(Sect, Key, Temp, FName);          WritePrivateProfileString(Sect, Key, Temp, FName);
187  }  }
188    
189  void WriteFont(PCHAR Sect, PCHAR Key, PCHAR FName,  void WriteFont(PCHAR Sect, PCHAR Key, PCHAR FName,
190                             PCHAR Name, int x, int y, int charset)                             PCHAR Name, int x, int y, int charset)
191  {  {
192          char Temp[80];          char Temp[80];
193          if (Name[0] != 0)          if (Name[0] != 0)
194                  _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%s,%d,%d,%d",                  _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%s,%d,%d,%d",
195                              Name, x, y, charset);                              Name, x, y, charset);
196          else          else
197                  Temp[0] = 0;                  Temp[0] = 0;
198          WritePrivateProfileString(Sect, Key, Temp, FName);          WritePrivateProfileString(Sect, Key, Temp, FName);
199  }  }
200    
201  void FAR PASCAL ReadIniFile(PCHAR FName, PTTSet ts)  void FAR PASCAL ReadIniFile(PCHAR FName, PTTSet ts)
202  {  {
203          int i;          int i;
204          HDC TmpDC;          HDC TmpDC;
205          char Temp[MAXPATHLEN];          char Temp[MAXPATHLEN];
206    
207          ts->Minimize = 0;          ts->Minimize = 0;
208          ts->HideWindow = 0;          ts->HideWindow = 0;
209          ts->LogFlag = 0;                        // Log flags          ts->LogFlag = 0;                        // Log flags
210          ts->FTFlag = 0;                         // File transfer flags          ts->FTFlag = 0;                         // File transfer flags
211          ts->MenuFlag = 0;                       // Menu flags          ts->MenuFlag = 0;                       // Menu flags
212          ts->TermFlag = 0;                       // Terminal flag          ts->TermFlag = 0;                       // Terminal flag
213          ts->ColorFlag = 0;                      // ANSI/Attribute color flags          ts->ColorFlag = 0;                      // ANSI/Attribute color flags
214          ts->PortFlag = 0;                       // Port flags          ts->PortFlag = 0;                       // Port flags
215          ts->TelPort = 23;          ts->TelPort = 23;
216    
217          /* Version number */          /* Version number */
218  /*  GetPrivateProfileString(Section,"Version","",  /*  GetPrivateProfileString(Section,"Version","",
219                            Temp,sizeof(Temp),FName); */                            Temp,sizeof(Temp),FName); */
220    
221          /* Language */          /* Language */
222          GetPrivateProfileString(Section, "Language", "",          GetPrivateProfileString(Section, "Language", "",
223                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
224          if (_stricmp(Temp, "Japanese") == 0)          if (_stricmp(Temp, "Japanese") == 0)
225                  ts->Language = IdJapanese;                  ts->Language = IdJapanese;
226          else if (_stricmp(Temp, "Russian") == 0)          else if (_stricmp(Temp, "Russian") == 0)
227                  ts->Language = IdRussian;                  ts->Language = IdRussian;
228          else if (_stricmp(Temp, "English") == 0)          else if (_stricmp(Temp, "English") == 0)
229                  ts->Language = IdEnglish;                  ts->Language = IdEnglish;
230          else if (_stricmp(Temp,"Korean") == 0) // HKS          else if (_stricmp(Temp,"Korean") == 0) // HKS
231                  ts->Language = IdKorean;                  ts->Language = IdKorean;
232          else {          else {
233                  switch (PRIMARYLANGID(GetSystemDefaultLangID())) {                  switch (PRIMARYLANGID(GetSystemDefaultLangID())) {
234                  case LANG_JAPANESE:                  case LANG_JAPANESE:
235                          ts->Language = IdJapanese;                          ts->Language = IdJapanese;
236                          break;                          break;
237                  case LANG_RUSSIAN:                  case LANG_RUSSIAN:
238                          ts->Language = IdRussian;                          ts->Language = IdRussian;
239                          break;                          break;
240          case LANG_KOREAN:       // HKS          case LANG_KOREAN:       // HKS
241                          ts->Language = IdKorean;                          ts->Language = IdKorean;
242                          break;                          break;
243                  default:                  default:
244                          ts->Language = IdEnglish;                          ts->Language = IdEnglish;
245                  }                  }
246          }          }
247    
248          /* Port type */          /* Port type */
249          GetPrivateProfileString(Section, "Port", "",          GetPrivateProfileString(Section, "Port", "",
250                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
251          if (_stricmp(Temp, "tcpip") == 0)          if (_stricmp(Temp, "tcpip") == 0)
252                  ts->PortType = IdTCPIP;                  ts->PortType = IdTCPIP;
253          else if (_stricmp(Temp, "serial") == 0)          else if (_stricmp(Temp, "serial") == 0)
254                  ts->PortType = IdSerial;                  ts->PortType = IdSerial;
255          else {          else {
256                  ts->PortType = IdTCPIP;                  ts->PortType = IdTCPIP;
257          }          }
258    
259          /* VT win position */          /* VT win position */
260          GetPrivateProfileString(Section, "VTPos", "-2147483648,-2147483648", Temp, sizeof(Temp), FName);        /* default: random position */          GetPrivateProfileString(Section, "VTPos", "-2147483648,-2147483648", Temp, sizeof(Temp), FName);        /* default: random position */
261          GetNthNum(Temp, 1, (int far *) (&ts->VTPos.x));          GetNthNum(Temp, 1, (int far *) (&ts->VTPos.x));
262          GetNthNum(Temp, 2, (int far *) (&ts->VTPos.y));          GetNthNum(Temp, 2, (int far *) (&ts->VTPos.y));
263    
264          /* TEK win position */          /* TEK win position */
265          GetPrivateProfileString(Section, "TEKPos", "-2147483648,-2147483648", Temp, sizeof(Temp), FName);       /* default: random position */          GetPrivateProfileString(Section, "TEKPos", "-2147483648,-2147483648", Temp, sizeof(Temp), FName);       /* default: random position */
266          GetNthNum(Temp, 1, (int far *) &(ts->TEKPos.x));          GetNthNum(Temp, 1, (int far *) &(ts->TEKPos.x));
267          GetNthNum(Temp, 2, (int far *) &(ts->TEKPos.y));          GetNthNum(Temp, 2, (int far *) &(ts->TEKPos.y));
268    
269          /* Save VT Window position */          /* Save VT Window position */
270          ts->SaveVTWinPos = GetOnOff(Section, "SaveVTWinPos", FName, FALSE);          ts->SaveVTWinPos = GetOnOff(Section, "SaveVTWinPos", FName, FALSE);
271    
272          /* VT terminal size  */          /* VT terminal size  */
273          GetPrivateProfileString(Section, "TerminalSize", "80,24",          GetPrivateProfileString(Section, "TerminalSize", "80,24",
274                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
275          GetNthNum(Temp, 1, &ts->TerminalWidth);          GetNthNum(Temp, 1, &ts->TerminalWidth);
276          GetNthNum(Temp, 2, &ts->TerminalHeight);          GetNthNum(Temp, 2, &ts->TerminalHeight);
277          if (ts->TerminalWidth < 0)          if (ts->TerminalWidth < 0)
278                  ts->TerminalWidth = 1;                  ts->TerminalWidth = 1;
279          if (ts->TerminalHeight < 0)          if (ts->TerminalHeight < 0)
280                  ts->TerminalHeight = 1;                  ts->TerminalHeight = 1;
281    
282          /* Terminal size = Window size */          /* Terminal size = Window size */
283          ts->TermIsWin = GetOnOff(Section, "TermIsWin", FName, FALSE);          ts->TermIsWin = GetOnOff(Section, "TermIsWin", FName, FALSE);
284    
285          /* Auto window resize flag */          /* Auto window resize flag */
286          ts->AutoWinResize = GetOnOff(Section, "AutoWinResize", FName, FALSE);          ts->AutoWinResize = GetOnOff(Section, "AutoWinResize", FName, FALSE);
287    
288          /* CR Receive */          /* CR Receive */
289          GetPrivateProfileString(Section, "CRReceive", "",          GetPrivateProfileString(Section, "CRReceive", "",
290                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
291          if (_stricmp(Temp, "CRLF") == 0) {          if (_stricmp(Temp, "CRLF") == 0) {
292                  ts->CRReceive = IdCRLF;                  ts->CRReceive = IdCRLF;
293          }          }
294          else if (_stricmp(Temp, "LF") == 0) {          else if (_stricmp(Temp, "LF") == 0) {
295                  ts->CRReceive = IdLF;                  ts->CRReceive = IdLF;
296          }          }
297          else {          else {
298                  ts->CRReceive = IdCR;                  ts->CRReceive = IdCR;
299          }          }
300          /* CR Send */          /* CR Send */
301          GetPrivateProfileString(Section, "CRSend", "",          GetPrivateProfileString(Section, "CRSend", "",
302                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
303          if (_stricmp(Temp, "CRLF") == 0)          if (_stricmp(Temp, "CRLF") == 0)
304                  ts->CRSend = IdCRLF;                  ts->CRSend = IdCRLF;
305          else          else
306                  ts->CRSend = IdCR;                  ts->CRSend = IdCR;
307          ts->CRSend_ini = ts->CRSend;          ts->CRSend_ini = ts->CRSend;
308    
309          /* Local echo */          /* Local echo */
310          ts->LocalEcho = GetOnOff(Section, "LocalEcho", FName, FALSE);          ts->LocalEcho = GetOnOff(Section, "LocalEcho", FName, FALSE);
311          ts->LocalEcho_ini = ts->LocalEcho;          ts->LocalEcho_ini = ts->LocalEcho;
312    
313          /* Answerback */          /* Answerback */
314          GetPrivateProfileString(Section, "Answerback", "", Temp,          GetPrivateProfileString(Section, "Answerback", "", Temp,
315                                  sizeof(Temp), FName);                                  sizeof(Temp), FName);
316          ts->AnswerbackLen =          ts->AnswerbackLen =
317                  Hex2Str(Temp, ts->Answerback, sizeof(ts->Answerback));                  Hex2Str(Temp, ts->Answerback, sizeof(ts->Answerback));
318    
319          /* Kanji Code (receive) */          /* Kanji Code (receive) */
320          GetPrivateProfileString(Section, "KanjiReceive", "",          GetPrivateProfileString(Section, "KanjiReceive", "",
321                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
322          if (_stricmp(Temp, "EUC") == 0)          if (_stricmp(Temp, "EUC") == 0)
323                  ts->KanjiCode = IdEUC;                  ts->KanjiCode = IdEUC;
324          else if (_stricmp(Temp, "JIS") == 0)          else if (_stricmp(Temp, "JIS") == 0)
325                  ts->KanjiCode = IdJIS;                  ts->KanjiCode = IdJIS;
326          else if (_stricmp(Temp, "UTF-8") == 0)          else if (_stricmp(Temp, "UTF-8") == 0)
327                  ts->KanjiCode = IdUTF8;                  ts->KanjiCode = IdUTF8;
328          else if (_stricmp(Temp, "UTF-8m") == 0)          else if (_stricmp(Temp, "UTF-8m") == 0)
329                  ts->KanjiCode = IdUTF8m;                  ts->KanjiCode = IdUTF8m;
330          else          else
331                  ts->KanjiCode = IdSJIS;                  ts->KanjiCode = IdSJIS;
332    
333          /* Katakana (receive) */          /* Katakana (receive) */
334          GetPrivateProfileString(Section, "KatakanaReceive", "",          GetPrivateProfileString(Section, "KatakanaReceive", "",
335                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
336          if (_stricmp(Temp, "7") == 0)          if (_stricmp(Temp, "7") == 0)
337                  ts->JIS7Katakana = 1;                  ts->JIS7Katakana = 1;
338          else          else
339                  ts->JIS7Katakana = 0;                  ts->JIS7Katakana = 0;
340    
341          /* Kanji Code (transmit) */          /* Kanji Code (transmit) */
342          GetPrivateProfileString(Section, "KanjiSend", "",          GetPrivateProfileString(Section, "KanjiSend", "",
343                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
344          if (_stricmp(Temp, "EUC") == 0)          if (_stricmp(Temp, "EUC") == 0)
345                  ts->KanjiCodeSend = IdEUC;                  ts->KanjiCodeSend = IdEUC;
346          else if (_stricmp(Temp, "JIS") == 0)          else if (_stricmp(Temp, "JIS") == 0)
347                  ts->KanjiCodeSend = IdJIS;                  ts->KanjiCodeSend = IdJIS;
348          else if (_stricmp(Temp, "UTF-8") == 0)          else if (_stricmp(Temp, "UTF-8") == 0)
349                  ts->KanjiCodeSend = IdUTF8;                  ts->KanjiCodeSend = IdUTF8;
350          else          else
351                  ts->KanjiCodeSend = IdSJIS;                  ts->KanjiCodeSend = IdSJIS;
352    
353          /* Katakana (receive) */          /* Katakana (receive) */
354          GetPrivateProfileString(Section, "KatakanaSend", "",          GetPrivateProfileString(Section, "KatakanaSend", "",
355                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
356          if (_stricmp(Temp, "7") == 0)          if (_stricmp(Temp, "7") == 0)
357                  ts->JIS7KatakanaSend = 1;                  ts->JIS7KatakanaSend = 1;
358          else          else
359                  ts->JIS7KatakanaSend = 0;                  ts->JIS7KatakanaSend = 0;
360    
361          /* KanjiIn */          /* KanjiIn */
362          GetPrivateProfileString(Section, "KanjiIn", "",          GetPrivateProfileString(Section, "KanjiIn", "",
363                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
364          if (_stricmp(Temp, "@") == 0)          if (_stricmp(Temp, "@") == 0)
365                  ts->KanjiIn = IdKanjiInA;                  ts->KanjiIn = IdKanjiInA;
366          else          else
367                  ts->KanjiIn = IdKanjiInB;                  ts->KanjiIn = IdKanjiInB;
368    
369          /* KanjiOut */          /* KanjiOut */
370          GetPrivateProfileString(Section, "KanjiOut", "",          GetPrivateProfileString(Section, "KanjiOut", "",
371                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
372          if (_stricmp(Temp, "B") == 0)          if (_stricmp(Temp, "B") == 0)
373                  ts->KanjiOut = IdKanjiOutB;                  ts->KanjiOut = IdKanjiOutB;
374          else if (_stricmp(Temp, "H") == 0)          else if (_stricmp(Temp, "H") == 0)
375                  ts->KanjiOut = IdKanjiOutH;                  ts->KanjiOut = IdKanjiOutH;
376          else          else
377                  ts->KanjiOut = IdKanjiOutJ;                  ts->KanjiOut = IdKanjiOutJ;
378    
379          /* Auto Win Switch VT<->TEK */          /* Auto Win Switch VT<->TEK */
380          ts->AutoWinSwitch = GetOnOff(Section, "AutoWinSwitch", FName, FALSE);          ts->AutoWinSwitch = GetOnOff(Section, "AutoWinSwitch", FName, FALSE);
381    
382          /* Terminal ID */          /* Terminal ID */
383          GetPrivateProfileString(Section, "TerminalID", "",          GetPrivateProfileString(Section, "TerminalID", "",
384                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
385          ts->TerminalID = str2id(TermList, Temp, IdVT100);          ts->TerminalID = str2id(TermList, Temp, IdVT100);
386    
387          /* Russian character set (host) */          /* Russian character set (host) */
388          GetPrivateProfileString(Section, "RussHost", "",          GetPrivateProfileString(Section, "RussHost", "",
389                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
390          ts->RussHost = str2id(RussList, Temp, IdKOI8);          ts->RussHost = str2id(RussList, Temp, IdKOI8);
391    
392          /* Russian character set (client) */          /* Russian character set (client) */
393          GetPrivateProfileString(Section, "RussClient", "",          GetPrivateProfileString(Section, "RussClient", "",
394                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
395          ts->RussClient = str2id(RussList, Temp, IdWindows);          ts->RussClient = str2id(RussList, Temp, IdWindows);
396    
397          /* Title String */          /* Title String */
398          GetPrivateProfileString(Section, "Title", "Tera Term",          GetPrivateProfileString(Section, "Title", "Tera Term",
399                                  ts->Title, sizeof(ts->Title), FName);                                  ts->Title, sizeof(ts->Title), FName);
400    
401          /* Cursor shape */          /* Cursor shape */
402          GetPrivateProfileString(Section, "CursorShape", "",          GetPrivateProfileString(Section, "CursorShape", "",
403                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
404          if (_stricmp(Temp, "vertical") == 0)          if (_stricmp(Temp, "vertical") == 0)
405                  ts->CursorShape = IdVCur;                  ts->CursorShape = IdVCur;
406          else if (_stricmp(Temp, "horizontal") == 0)          else if (_stricmp(Temp, "horizontal") == 0)
407                  ts->CursorShape = IdHCur;                  ts->CursorShape = IdHCur;
408          else          else
409                  ts->CursorShape = IdBlkCur;                  ts->CursorShape = IdBlkCur;
410    
411          /* Hide title */          /* Hide title */
412          ts->HideTitle = GetOnOff(Section, "HideTitle", FName, FALSE);          ts->HideTitle = GetOnOff(Section, "HideTitle", FName, FALSE);
413    
414          /* Popup menu */          /* Popup menu */
415          ts->PopupMenu = GetOnOff(Section, "PopupMenu", FName, FALSE);          ts->PopupMenu = GetOnOff(Section, "PopupMenu", FName, FALSE);
416    
417          /* PC-Style bold color mapping */          /* PC-Style bold color mapping */
418          if (GetOnOff(Section, "PcBoldColor", FName, FALSE))          if (GetOnOff(Section, "PcBoldColor", FName, FALSE))
419                  ts->ColorFlag |= CF_PCBOLD16;                  ts->ColorFlag |= CF_PCBOLD16;
420    
421          /* aixterm style 16 colors mode */          /* aixterm style 16 colors mode */
422          if (GetOnOff(Section, "Aixterm16Color", FName, FALSE))          if (GetOnOff(Section, "Aixterm16Color", FName, FALSE))
423                  ts->ColorFlag |= CF_AIXTERM16;                  ts->ColorFlag |= CF_AIXTERM16;
424    
425          /* xterm style 256 colors mode */          /* xterm style 256 colors mode */
426          if (GetOnOff(Section, "Xterm256Color", FName, TRUE))          if (GetOnOff(Section, "Xterm256Color", FName, TRUE))
427                  ts->ColorFlag |= CF_XTERM256;                  ts->ColorFlag |= CF_XTERM256;
428    
429          /* Enable scroll buffer */          /* Enable scroll buffer */
430          ts->EnableScrollBuff =          ts->EnableScrollBuff =
431                  GetOnOff(Section, "EnableScrollBuff", FName, TRUE);                  GetOnOff(Section, "EnableScrollBuff", FName, TRUE);
432    
433          /* Scroll buffer size */          /* Scroll buffer size */
434          ts->ScrollBuffSize =          ts->ScrollBuffSize =
435                  GetPrivateProfileInt(Section, "ScrollBuffSize", 100, FName);                  GetPrivateProfileInt(Section, "ScrollBuffSize", 100, FName);
436    
437          /* VT Color */          /* VT Color */
438          GetPrivateProfileString(Section, "VTColor", "0,0,0,255,255,255",          GetPrivateProfileString(Section, "VTColor", "0,0,0,255,255,255",
439                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
440          for (i = 0; i <= 5; i++)          for (i = 0; i <= 5; i++)
441                  GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));                  GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
442          for (i = 0; i <= 1; i++)          for (i = 0; i <= 1; i++)
443                  ts->VTColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],                  ts->VTColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
444                                       (BYTE) ts->TmpColor[0][i * 3 + 1],                                       (BYTE) ts->TmpColor[0][i * 3 + 1],
445                                       (BYTE) ts->TmpColor[0][i * 3 + 2]);                                       (BYTE) ts->TmpColor[0][i * 3 + 2]);
446    
447          /* VT Bold Color */          /* VT Bold Color */
448          GetPrivateProfileString(Section, "VTBoldColor", "0,0,255,255,255,255",          GetPrivateProfileString(Section, "VTBoldColor", "0,0,255,255,255,255",
449                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
450          for (i = 0; i <= 5; i++)          for (i = 0; i <= 5; i++)
451                  GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));                  GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
452          for (i = 0; i <= 1; i++)          for (i = 0; i <= 1; i++)
453                  ts->VTBoldColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],                  ts->VTBoldColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
454                                           (BYTE) ts->TmpColor[0][i * 3 + 1],                                           (BYTE) ts->TmpColor[0][i * 3 + 1],
455                                           (BYTE) ts->TmpColor[0][i * 3 + 2]);                                           (BYTE) ts->TmpColor[0][i * 3 + 2]);
456          if (GetOnOff(Section, "EnableBoldAttrColor", FName, TRUE))          if (GetOnOff(Section, "EnableBoldAttrColor", FName, TRUE))
457                  ts->ColorFlag |= CF_BOLDCOLOR;                  ts->ColorFlag |= CF_BOLDCOLOR;
458    
459          /* VT Blink Color */          /* VT Blink Color */
460          GetPrivateProfileString(Section, "VTBlinkColor", "255,0,0,255,255,255",          GetPrivateProfileString(Section, "VTBlinkColor", "255,0,0,255,255,255",
461                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
462          for (i = 0; i <= 5; i++)          for (i = 0; i <= 5; i++)
463                  GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));                  GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
464          for (i = 0; i <= 1; i++)          for (i = 0; i <= 1; i++)
465                  ts->VTBlinkColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],                  ts->VTBlinkColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
466                                            (BYTE) ts->TmpColor[0][i * 3 + 1],                                            (BYTE) ts->TmpColor[0][i * 3 + 1],
467                                            (BYTE) ts->TmpColor[0][i * 3 + 2]);                                            (BYTE) ts->TmpColor[0][i * 3 + 2]);
468          if (GetOnOff(Section, "EnableBlinkAttrColor", FName, TRUE))          if (GetOnOff(Section, "EnableBlinkAttrColor", FName, TRUE))
469                  ts->ColorFlag |= CF_BLINKCOLOR;                  ts->ColorFlag |= CF_BLINKCOLOR;
470    
471          /* VT Reverse Color */          /* VT Reverse Color */
472          GetPrivateProfileString(Section, "VTReverseColor", "255,255,255,0,0,0",          GetPrivateProfileString(Section, "VTReverseColor", "255,255,255,0,0,0",
473                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
474          for (i = 0; i <= 5; i++)          for (i = 0; i <= 5; i++)
475                  GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));                  GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
476          for (i = 0; i <= 1; i++)          for (i = 0; i <= 1; i++)
477                  ts->VTReverseColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],                  ts->VTReverseColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
478                                            (BYTE) ts->TmpColor[0][i * 3 + 1],                                            (BYTE) ts->TmpColor[0][i * 3 + 1],
479                                            (BYTE) ts->TmpColor[0][i * 3 + 2]);                                            (BYTE) ts->TmpColor[0][i * 3 + 2]);
480          if (GetOnOff(Section, "EnableReverseAttrColor", FName, FALSE))          if (GetOnOff(Section, "EnableReverseAttrColor", FName, FALSE))
481                  ts->ColorFlag |= CF_REVERSECOLOR;                  ts->ColorFlag |= CF_REVERSECOLOR;
482    
483          ts->EnableClickableUrl =          ts->EnableClickableUrl =
484                  GetOnOff(Section, "EnableClickableUrl", FName, FALSE);                  GetOnOff(Section, "EnableClickableUrl", FName, FALSE);
485    
486          /* URL Color */          /* URL Color */
487          GetPrivateProfileString(Section, "URLColor", "0,255,0,255,255,255",          GetPrivateProfileString(Section, "URLColor", "0,255,0,255,255,255",
488                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
489          for (i = 0; i <= 5; i++)          for (i = 0; i <= 5; i++)
490                  GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));                  GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
491          for (i = 0; i <= 1; i++)          for (i = 0; i <= 1; i++)
492                  ts->URLColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],                  ts->URLColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
493                                        (BYTE) ts->TmpColor[0][i * 3 + 1],                                        (BYTE) ts->TmpColor[0][i * 3 + 1],
494                                        (BYTE) ts->TmpColor[0][i * 3 + 2]);                                        (BYTE) ts->TmpColor[0][i * 3 + 2]);
495          if (GetOnOff(Section, "EnableURLColor", FName, TRUE))          if (GetOnOff(Section, "EnableURLColor", FName, TRUE))
496                  ts->ColorFlag |= CF_URLCOLOR;                  ts->ColorFlag |= CF_URLCOLOR;
497    
498          /* TEK Color */          /* TEK Color */
499          GetPrivateProfileString(Section, "TEKColor", "0,0,0,255,255,255",          GetPrivateProfileString(Section, "TEKColor", "0,0,0,255,255,255",
500                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
501          for (i = 0; i <= 5; i++)          for (i = 0; i <= 5; i++)
502                  GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));                  GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
503          for (i = 0; i <= 1; i++)          for (i = 0; i <= 1; i++)
504                  ts->TEKColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],                  ts->TEKColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
505                                        (BYTE) ts->TmpColor[0][i * 3 + 1],                                        (BYTE) ts->TmpColor[0][i * 3 + 1],
506                                        (BYTE) ts->TmpColor[0][i * 3 + 2]);                                        (BYTE) ts->TmpColor[0][i * 3 + 2]);
507    
508  #ifndef NO_ANSI_COLOR_EXTENSION  #ifndef NO_ANSI_COLOR_EXTENSION
509          /* ANSI color definition (in the case FullColor=on)  -- special option          /* ANSI color definition (in the case FullColor=on)  -- special option
510             o UseTextColor should be off, or the background and foreground color of             o UseTextColor should be off, or the background and foreground color of
511             VTColor are assigned to color-number 0 and 7 respectively, even if             VTColor are assigned to color-number 0 and 7 respectively, even if
512             they are specified in ANSIColor.             they are specified in ANSIColor.
513             o ANSIColor is a set of 4 values that are color-number(0--15),             o ANSIColor is a set of 4 values that are color-number(0--15),
514             red-value(0--255), green-value(0--255) and blue-value(0--255). */             red-value(0--255), green-value(0--255) and blue-value(0--255). */
515          GetPrivateProfileString(Section, "ANSIColor",          GetPrivateProfileString(Section, "ANSIColor",
516                                  " 0,  0,  0,  0,"                                  " 0,  0,  0,  0,"
517                                  " 1,255,  0,  0,"                                  " 1,255,  0,  0,"
518                                  " 2,  0,255,  0,"                                  " 2,  0,255,  0,"
519                                  " 3,255,255,  0,"                                  " 3,255,255,  0,"
520                                  " 4,  0,  0,255,"                                  " 4,  0,  0,255,"
521                                  " 5,255,  0,255,"                                  " 5,255,  0,255,"
522                                  " 6,  0,255,255,"                                  " 6,  0,255,255,"
523                                  " 7,255,255,255,"                                  " 7,255,255,255,"
524                                  " 8,128,128,128,"                                  " 8,128,128,128,"
525                                  " 9,128,  0,  0,"                                  " 9,128,  0,  0,"
526                                  "10,  0,128,  0,"                                  "10,  0,128,  0,"
527                                  "11,128,128,  0,"                                  "11,128,128,  0,"
528                                  "12,  0,  0,128,"                                  "12,  0,  0,128,"
529                                  "13,128,  0,128,"                                  "13,128,  0,128,"
530                                  "14,  0,128,128,"                                  "14,  0,128,128,"
531                                  "15,192,192,192", Temp, sizeof(Temp), FName);                                  "15,192,192,192", Temp, sizeof(Temp), FName);
532          {          {
533                  char *t;                  char *t;
534                  int n = 1;                  int n = 1;
535                  for (t = Temp; *t; t++)                  for (t = Temp; *t; t++)
536                          if (*t == ',')                          if (*t == ',')
537                                  n++;                                  n++;
538                  n /= 4;                  n /= 4;
539                  for (i = 0; i <= n; i++) {                  for (i = 0; i <= n; i++) {
540                          int colorid, r, g, b;                          int colorid, r, g, b;
541                          GetNthNum(Temp, i * 4 + 1, (int far *) &colorid);                          GetNthNum(Temp, i * 4 + 1, (int far *) &colorid);
542                          GetNthNum(Temp, i * 4 + 2, (int far *) &r);                          GetNthNum(Temp, i * 4 + 2, (int far *) &r);
543                          GetNthNum(Temp, i * 4 + 3, (int far *) &g);                          GetNthNum(Temp, i * 4 + 3, (int far *) &g);
544                          GetNthNum(Temp, i * 4 + 4, (int far *) &b);                          GetNthNum(Temp, i * 4 + 4, (int far *) &b);
545                          ts->ANSIColor[colorid & 15] =                          ts->ANSIColor[colorid & 15] =
546                                  RGB((BYTE) r, (BYTE) g, (BYTE) b);                                  RGB((BYTE) r, (BYTE) g, (BYTE) b);
547                  }                  }
548          }          }
549  #endif                                          /* NO_ANSI_COLOR_EXTENSION */  #endif                                          /* NO_ANSI_COLOR_EXTENSION */
550    
551          TmpDC = GetDC(0);                       /* Get screen device context */          TmpDC = GetDC(0);                       /* Get screen device context */
552          for (i = 0; i <= 1; i++)          for (i = 0; i <= 1; i++)
553                  ts->VTColor[i] = GetNearestColor(TmpDC, ts->VTColor[i]);                  ts->VTColor[i] = GetNearestColor(TmpDC, ts->VTColor[i]);
554          for (i = 0; i <= 1; i++)          for (i = 0; i <= 1; i++)
555                  ts->VTBoldColor[i] = GetNearestColor(TmpDC, ts->VTBoldColor[i]);                  ts->VTBoldColor[i] = GetNearestColor(TmpDC, ts->VTBoldColor[i]);
556          for (i = 0; i <= 1; i++)          for (i = 0; i <= 1; i++)
557                  ts->VTBlinkColor[i] = GetNearestColor(TmpDC, ts->VTBlinkColor[i]);                  ts->VTBlinkColor[i] = GetNearestColor(TmpDC, ts->VTBlinkColor[i]);
558          for (i = 0; i <= 1; i++)          for (i = 0; i <= 1; i++)
559                  ts->TEKColor[i] = GetNearestColor(TmpDC, ts->TEKColor[i]);                  ts->TEKColor[i] = GetNearestColor(TmpDC, ts->TEKColor[i]);
560          /* begin - ishizaki */          /* begin - ishizaki */
561          for (i = 0; i <= 1; i++)          for (i = 0; i <= 1; i++)
562                  ts->URLColor[i] = GetNearestColor(TmpDC, ts->URLColor[i]);                  ts->URLColor[i] = GetNearestColor(TmpDC, ts->URLColor[i]);
563          /* end - ishizaki */          /* end - ishizaki */
564  #ifndef NO_ANSI_COLOR_EXTENSION  #ifndef NO_ANSI_COLOR_EXTENSION
565          for (i = 0; i < 16; i++)          for (i = 0; i < 16; i++)
566                  ts->ANSIColor[i] = GetNearestColor(TmpDC, ts->ANSIColor[i]);                  ts->ANSIColor[i] = GetNearestColor(TmpDC, ts->ANSIColor[i]);
567  #endif                                          /* NO_ANSI_COLOR_EXTENSION */  #endif                                          /* NO_ANSI_COLOR_EXTENSION */
568          ReleaseDC(0, TmpDC);          ReleaseDC(0, TmpDC);
569          if (GetOnOff(Section, "EnableANSIColor", FName, TRUE))          if (GetOnOff(Section, "EnableANSIColor", FName, TRUE))
570                  ts->ColorFlag |= CF_ANSICOLOR;                  ts->ColorFlag |= CF_ANSICOLOR;
571    
572          /* TEK color emulation */          /* TEK color emulation */
573          ts->TEKColorEmu = GetOnOff(Section, "TEKColorEmulation", FName, FALSE);          ts->TEKColorEmu = GetOnOff(Section, "TEKColorEmulation", FName, FALSE);
574    
575          /* VT Font */          /* VT Font */
576          GetPrivateProfileString(Section, "VTFont", "Terminal,0,-13,1",          GetPrivateProfileString(Section, "VTFont", "Terminal,0,-13,1",
577                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
578          GetNthString(Temp, 1, sizeof(ts->VTFont), ts->VTFont);          GetNthString(Temp, 1, sizeof(ts->VTFont), ts->VTFont);
579          GetNthNum(Temp, 2, (int far *) &(ts->VTFontSize.x));          GetNthNum(Temp, 2, (int far *) &(ts->VTFontSize.x));
580          GetNthNum(Temp, 3, (int far *) &(ts->VTFontSize.y));          GetNthNum(Temp, 3, (int far *) &(ts->VTFontSize.y));
581          GetNthNum(Temp, 4, &(ts->VTFontCharSet));          GetNthNum(Temp, 4, &(ts->VTFontCharSet));
582    
583          /* Bold font flag */          /* Bold font flag */
584          ts->EnableBold = GetOnOff(Section, "EnableBold", FName, TRUE);          ts->EnableBold = GetOnOff(Section, "EnableBold", FName, TRUE);
585    
586          /* Russian character set (font) */          /* Russian character set (font) */
587          GetPrivateProfileString(Section, "RussFont", "",          GetPrivateProfileString(Section, "RussFont", "",
588                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
589          ts->RussFont = str2id(RussList, Temp, IdWindows);          ts->RussFont = str2id(RussList, Temp, IdWindows);
590    
591          /* TEK Font */          /* TEK Font */
592          GetPrivateProfileString(Section, "TEKFont", "Courier,0,-13,0",          GetPrivateProfileString(Section, "TEKFont", "Courier,0,-13,0",
593                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
594          GetNthString(Temp, 1, sizeof(ts->TEKFont), ts->TEKFont);          GetNthString(Temp, 1, sizeof(ts->TEKFont), ts->TEKFont);
595          GetNthNum(Temp, 2, (int far *) &(ts->TEKFontSize.x));          GetNthNum(Temp, 2, (int far *) &(ts->TEKFontSize.x));
596          GetNthNum(Temp, 3, (int far *) &(ts->TEKFontSize.y));          GetNthNum(Temp, 3, (int far *) &(ts->TEKFontSize.y));
597          GetNthNum(Temp, 4, &(ts->TEKFontCharSet));          GetNthNum(Temp, 4, &(ts->TEKFontCharSet));
598    
599          /* BS key */          /* BS key */
600          GetPrivateProfileString(Section, "BSKey", "",          GetPrivateProfileString(Section, "BSKey", "",
601                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
602          if (_stricmp(Temp, "DEL") == 0)          if (_stricmp(Temp, "DEL") == 0)
603                  ts->BSKey = IdDEL;                  ts->BSKey = IdDEL;
604          else          else
605                  ts->BSKey = IdBS;                  ts->BSKey = IdBS;
606          /* Delete key */          /* Delete key */
607          ts->DelKey = GetOnOff(Section, "DeleteKey", FName, FALSE);          ts->DelKey = GetOnOff(Section, "DeleteKey", FName, FALSE);
608    
609          /* Meta Key */          /* Meta Key */
610          ts->MetaKey = GetOnOff(Section, "MetaKey", FName, FALSE);          ts->MetaKey = GetOnOff(Section, "MetaKey", FName, FALSE);
611    
612          /* Application Keypad */          /* Application Keypad */
613          ts->DisableAppKeypad =          ts->DisableAppKeypad =
614                  GetOnOff(Section, "DisableAppKeypad", FName, FALSE);                  GetOnOff(Section, "DisableAppKeypad", FName, FALSE);
615    
616          /* Application Cursor */          /* Application Cursor */
617          ts->DisableAppCursor =          ts->DisableAppCursor =
618                  GetOnOff(Section, "DisableAppCursor", FName, FALSE);                  GetOnOff(Section, "DisableAppCursor", FName, FALSE);
619    
620          /* Russian keyboard type */          /* Russian keyboard type */
621          GetPrivateProfileString(Section, "RussKeyb", "",          GetPrivateProfileString(Section, "RussKeyb", "",
622                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
623          ts->RussKeyb = str2id(RussList2, Temp, IdWindows);          ts->RussKeyb = str2id(RussList2, Temp, IdWindows);
624    
625          /* Serial port ID */          /* Serial port ID */
626          ts->ComPort = GetPrivateProfileInt(Section, "ComPort", 1, FName);          ts->ComPort = GetPrivateProfileInt(Section, "ComPort", 1, FName);
627    
628          /* Baud rate */          /* Baud rate */
629          GetPrivateProfileString(Section, "BaudRate", "9600",          GetPrivateProfileString(Section, "BaudRate", "9600",
630                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
631          ts->Baud = str2id(BaudList, Temp, IdBaud9600);          ts->Baud = str2id(BaudList, Temp, IdBaud9600);
632    
633          /* Parity */          /* Parity */
634          GetPrivateProfileString(Section, "Parity", "",          GetPrivateProfileString(Section, "Parity", "",
635                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
636          if (_stricmp(Temp, "even") == 0)          if (_stricmp(Temp, "even") == 0)
637                  ts->Parity = IdParityEven;                  ts->Parity = IdParityEven;
638          else if (_stricmp(Temp, "odd") == 0)          else if (_stricmp(Temp, "odd") == 0)
639                  ts->Parity = IdParityOdd;                  ts->Parity = IdParityOdd;
640          else          else
641                  ts->Parity = IdParityNone;                  ts->Parity = IdParityNone;
642    
643          /* Data bit */          /* Data bit */
644          GetPrivateProfileString(Section, "DataBit", "",          GetPrivateProfileString(Section, "DataBit", "",
645                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
646          if (_stricmp(Temp, "7") == 0)          if (_stricmp(Temp, "7") == 0)
647                  ts->DataBit = IdDataBit7;                  ts->DataBit = IdDataBit7;
648          else          else
649                  ts->DataBit = IdDataBit8;                  ts->DataBit = IdDataBit8;
650    
651          /* Stop bit */          /* Stop bit */
652          GetPrivateProfileString(Section, "StopBit", "",          GetPrivateProfileString(Section, "StopBit", "",
653                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
654          if (_stricmp(Temp, "2") == 0)          if (_stricmp(Temp, "2") == 0)
655                  ts->StopBit = IdStopBit2;                  ts->StopBit = IdStopBit2;
656          else          else
657                  ts->StopBit = IdStopBit1;                  ts->StopBit = IdStopBit1;
658    
659          /* Flow control */          /* Flow control */
660          GetPrivateProfileString(Section, "FlowCtrl", "",          GetPrivateProfileString(Section, "FlowCtrl", "",
661                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
662          if (_stricmp(Temp, "x") == 0)          if (_stricmp(Temp, "x") == 0)
663                  ts->Flow = IdFlowX;                  ts->Flow = IdFlowX;
664          else if (_stricmp(Temp, "hard") == 0)          else if (_stricmp(Temp, "hard") == 0)
665                  ts->Flow = IdFlowHard;                  ts->Flow = IdFlowHard;
666          else          else
667                  ts->Flow = IdFlowNone;                  ts->Flow = IdFlowNone;
668    
669          /* Delay per character */          /* Delay per character */
670          ts->DelayPerChar =          ts->DelayPerChar =
671                  GetPrivateProfileInt(Section, "DelayPerChar", 0, FName);                  GetPrivateProfileInt(Section, "DelayPerChar", 0, FName);
672    
673          /* Delay per line */          /* Delay per line */
674          ts->DelayPerLine =          ts->DelayPerLine =
675                  GetPrivateProfileInt(Section, "DelayPerLine", 0, FName);                  GetPrivateProfileInt(Section, "DelayPerLine", 0, FName);
676    
677          /* Telnet flag */          /* Telnet flag */
678          ts->Telnet = GetOnOff(Section, "Telnet", FName, TRUE);          ts->Telnet = GetOnOff(Section, "Telnet", FName, TRUE);
679    
680          /* Telnet terminal type */          /* Telnet terminal type */
681          GetPrivateProfileString(Section, "TermType", "xterm", ts->TermType,          GetPrivateProfileString(Section, "TermType", "xterm", ts->TermType,
682                                  sizeof(ts->TermType), FName);                                  sizeof(ts->TermType), FName);
683    
684          /* TCP port num */          /* TCP port num */
685          ts->TCPPort =          ts->TCPPort =
686                  GetPrivateProfileInt(Section, "TCPPort", ts->TelPort, FName);                  GetPrivateProfileInt(Section, "TCPPort", ts->TelPort, FName);
687    
688          /* Auto window close flag */          /* Auto window close flag */
689          ts->AutoWinClose = GetOnOff(Section, "AutoWinClose", FName, TRUE);          ts->AutoWinClose = GetOnOff(Section, "AutoWinClose", FName, TRUE);
690    
691          /* History list */          /* History list */
692          ts->HistoryList = GetOnOff(Section, "HistoryList", FName, FALSE);          ts->HistoryList = GetOnOff(Section, "HistoryList", FName, FALSE);
693    
694          /* File transfer binary flag */          /* File transfer binary flag */
695          ts->TransBin = GetOnOff(Section, "TransBin", FName, FALSE);          ts->TransBin = GetOnOff(Section, "TransBin", FName, FALSE);
696    
697          /* Log append */          /* Log append */
698          ts->Append = GetOnOff(Section, "LogAppend", FName, FALSE);          ts->Append = GetOnOff(Section, "LogAppend", FName, FALSE);
699    
700          /* Log plain text (2005.5.7 yutaka) */          /* Log plain text (2005.5.7 yutaka) */
701          ts->LogTypePlainText =          ts->LogTypePlainText =
702                  GetOnOff(Section, "LogTypePlainText", FName, FALSE);                  GetOnOff(Section, "LogTypePlainText", FName, FALSE);
703    
704          /* Log with timestamp (2006.7.23 maya) */          /* Log with timestamp (2006.7.23 maya) */
705          ts->LogTimestamp = GetOnOff(Section, "LogTimestamp", FName, FALSE);          ts->LogTimestamp = GetOnOff(Section, "LogTimestamp", FName, FALSE);
706    
707          /* Log without transfer dialog */          /* Log without transfer dialog */
708          ts->LogHideDialog = GetOnOff(Section, "LogHideDialog", FName, FALSE);          ts->LogHideDialog = GetOnOff(Section, "LogHideDialog", FName, FALSE);
709    
710          /* Default Log file name (2006.8.28 maya) */          /* Default Log file name (2006.8.28 maya) */
711          GetPrivateProfileString(Section, "LogDefaultName", "teraterm.log",          GetPrivateProfileString(Section, "LogDefaultName", "teraterm.log",
712                                  ts->LogDefaultName, sizeof(ts->LogDefaultName),                                  ts->LogDefaultName, sizeof(ts->LogDefaultName),
713                                  FName);                                  FName);
714    
715          /* Default Log file path (2007.5.30 maya) */          /* Default Log file path (2007.5.30 maya) */
716          GetPrivateProfileString(Section, "LogDefaultPath", "",          GetPrivateProfileString(Section, "LogDefaultPath", "",
717                                  ts->LogDefaultPath, sizeof(ts->LogDefaultPath),                                  ts->LogDefaultPath, sizeof(ts->LogDefaultPath),
718                                  FName);                                  FName);
719    
720          /* Auto start logging (2007.5.31 maya) */          /* Auto start logging (2007.5.31 maya) */
721          ts->LogAutoStart = GetOnOff(Section, "LogAutoStart", FName, FALSE);          ts->LogAutoStart = GetOnOff(Section, "LogAutoStart", FName, FALSE);
722    
723          /* XMODEM option */          /* XMODEM option */
724          GetPrivateProfileString(Section, "XmodemOpt", "",          GetPrivateProfileString(Section, "XmodemOpt", "",
725                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
726          if (_stricmp(Temp, "crc") == 0)          if (_stricmp(Temp, "crc") == 0)
727                  ts->XmodemOpt = XoptCRC;                  ts->XmodemOpt = XoptCRC;
728          else if (_stricmp(Temp, "1k") == 0)          else if (_stricmp(Temp, "1k") == 0)
729                  ts->XmodemOpt = Xopt1K;                  ts->XmodemOpt = Xopt1K;
730          else          else
731                  ts->XmodemOpt = XoptCheck;                  ts->XmodemOpt = XoptCheck;
732    
733          /* XMODEM binary file */          /* XMODEM binary file */
734          ts->XmodemBin = GetOnOff(Section, "XmodemBin", FName, TRUE);          ts->XmodemBin = GetOnOff(Section, "XmodemBin", FName, TRUE);
735    
736          /* XMODEM 受信コマンド (2007.12.21 yutaka) */          /* XMODEM 受信コマンド (2007.12.21 yutaka) */
737          GetPrivateProfileString(Section, "XModemRcvCommand", "",          GetPrivateProfileString(Section, "XModemRcvCommand", "",
738                                  ts->XModemRcvCommand,                                  ts->XModemRcvCommand,
739                                  sizeof(ts->XModemRcvCommand), FName);                                  sizeof(ts->XModemRcvCommand), FName);
740    
741          /* Default directory for file transfer */          /* Default directory for file transfer */
742          GetPrivateProfileString(Section, "FileDir", "",          GetPrivateProfileString(Section, "FileDir", "",
743                                  ts->FileDir, sizeof(ts->FileDir), FName);                                  ts->FileDir, sizeof(ts->FileDir), FName);
744          if (strlen(ts->FileDir) == 0)          if (strlen(ts->FileDir) == 0)
745                  strncpy_s(ts->FileDir, sizeof(ts->FileDir), ts->HomeDir, _TRUNCATE);                  strncpy_s(ts->FileDir, sizeof(ts->FileDir), ts->HomeDir, _TRUNCATE);
746          else {          else {
747                  _getcwd(Temp, sizeof(Temp));                  _getcwd(Temp, sizeof(Temp));
748                  if (_chdir(ts->FileDir) != 0)                  if (_chdir(ts->FileDir) != 0)
749                          strncpy_s(ts->FileDir, sizeof(ts->FileDir), ts->HomeDir, _TRUNCATE);                          strncpy_s(ts->FileDir, sizeof(ts->FileDir), ts->HomeDir, _TRUNCATE);
750                  _chdir(Temp);                  _chdir(Temp);
751          }          }
752    
753          /* filter on file send (2007.6.5 maya) */          /* filter on file send (2007.6.5 maya) */
754          GetPrivateProfileString(Section, "FileSendFilter", "",          GetPrivateProfileString(Section, "FileSendFilter", "",
755                                  ts->FileSendFilter, sizeof(ts->FileSendFilter),                                  ts->FileSendFilter, sizeof(ts->FileSendFilter),
756                                  FName);                                  FName);
757    
758  /*--------------------------------------------------*/  /*--------------------------------------------------*/
759          /* 8 bit control code flag  -- special option */          /* 8 bit control code flag  -- special option */
760          if (GetOnOff(Section, "Accept8BitCtrl", FName, TRUE))          if (GetOnOff(Section, "Accept8BitCtrl", FName, TRUE))
761                  ts->TermFlag |= TF_ACCEPT8BITCTRL;                  ts->TermFlag |= TF_ACCEPT8BITCTRL;
762    
763          /* Wrong sequence flag  -- special option */          /* Wrong sequence flag  -- special option */
764          if (GetOnOff(Section, "AllowWrongSequence", FName, FALSE))          if (GetOnOff(Section, "AllowWrongSequence", FName, FALSE))
765                  ts->TermFlag |= TF_ALLOWWRONGSEQUENCE;                  ts->TermFlag |= TF_ALLOWWRONGSEQUENCE;
766    
767          if (((ts->TermFlag & TF_ALLOWWRONGSEQUENCE) == 0) &&          if (((ts->TermFlag & TF_ALLOWWRONGSEQUENCE) == 0) &&
768              (ts->KanjiOut == IdKanjiOutH))              (ts->KanjiOut == IdKanjiOutH))
769                  ts->KanjiOut = IdKanjiOutJ;                  ts->KanjiOut = IdKanjiOutJ;
770    
771          // Auto file renaming --- special option          // Auto file renaming --- special option
772          if (GetOnOff(Section, "AutoFileRename", FName, FALSE))          if (GetOnOff(Section, "AutoFileRename", FName, FALSE))
773                  ts->FTFlag |= FT_RENAME;                  ts->FTFlag |= FT_RENAME;
774    
775          // Auto invoking (character set->G0->GL) --- special option          // Auto invoking (character set->G0->GL) --- special option
776          if (GetOnOff(Section, "AutoInvoke", FName, FALSE))          if (GetOnOff(Section, "AutoInvoke", FName, FALSE))
777                  ts->TermFlag |= TF_AUTOINVOKE;                  ts->TermFlag |= TF_AUTOINVOKE;
778    
779          // Auto text copy --- special option          // Auto text copy --- special option
780          ts->AutoTextCopy = GetOnOff(Section, "AutoTextCopy", FName, TRUE);          ts->AutoTextCopy = GetOnOff(Section, "AutoTextCopy", FName, TRUE);
781    
782          /* Back wrap -- special option */          /* Back wrap -- special option */
783          if (GetOnOff(Section, "BackWrap", FName, FALSE))          if (GetOnOff(Section, "BackWrap", FName, FALSE))
784                  ts->TermFlag |= TF_BACKWRAP;                  ts->TermFlag |= TF_BACKWRAP;
785    
786          /* Beep type -- special option */          /* Beep type -- special option */
787          GetPrivateProfileString(Section, "Beep", "", Temp, sizeof(Temp), FName);          GetPrivateProfileString(Section, "Beep", "", Temp, sizeof(Temp), FName);
788          if (_stricmp(Temp, "off") == 0)          if (_stricmp(Temp, "off") == 0)
789                  ts->Beep = IdBeepOff;                  ts->Beep = IdBeepOff;
790          else if (_stricmp(Temp, "visual") == 0)          else if (_stricmp(Temp, "visual") == 0)
791                  ts->Beep = IdBeepVisual;                  ts->Beep = IdBeepVisual;
792          else          else
793                  ts->Beep = IdBeepOn;                  ts->Beep = IdBeepOn;
794    
795          /* Beep on connection & disconnection -- special option */          /* Beep on connection & disconnection -- special option */
796          if (GetOnOff(Section, "BeepOnConnect", FName, FALSE))          if (GetOnOff(Section, "BeepOnConnect", FName, FALSE))
797                  ts->PortFlag |= PF_BEEPONCONNECT;                  ts->PortFlag |= PF_BEEPONCONNECT;
798    
799          /* Auto B-Plus activation -- special option */          /* Auto B-Plus activation -- special option */
800          if (GetOnOff(Section, "BPAuto", FName, FALSE))          if (GetOnOff(Section, "BPAuto", FName, FALSE))
801                  ts->FTFlag |= FT_BPAUTO;                  ts->FTFlag |= FT_BPAUTO;
802          if ((ts->FTFlag & FT_BPAUTO) != 0) {    /* Answerback */          if ((ts->FTFlag & FT_BPAUTO) != 0) {    /* Answerback */
803                  strncpy_s(ts->Answerback, sizeof(ts->Answerback), "\020++\0200",                  strncpy_s(ts->Answerback, sizeof(ts->Answerback), "\020++\0200",
804                            _TRUNCATE);                            _TRUNCATE);
805                  ts->AnswerbackLen = 5;                  ts->AnswerbackLen = 5;
806          }          }
807    
808          /* B-Plus ESCCTL flag  -- special option */          /* B-Plus ESCCTL flag  -- special option */
809          if (GetOnOff(Section, "BPEscCtl", FName, FALSE))          if (GetOnOff(Section, "BPEscCtl", FName, FALSE))
810                  ts->FTFlag |= FT_BPESCCTL;                  ts->FTFlag |= FT_BPESCCTL;
811    
812          /* B-Plus log  -- special option */          /* B-Plus log  -- special option */
813          if (GetOnOff(Section, "BPLog", FName, FALSE))          if (GetOnOff(Section, "BPLog", FName, FALSE))
814                  ts->LogFlag |= LOG_BP;                  ts->LogFlag |= LOG_BP;
815    
816          /* Clear serial port buffer when port opening -- special option */          /* Clear serial port buffer when port opening -- special option */
817          ts->ClearComBuffOnOpen =          ts->ClearComBuffOnOpen =
818                  GetOnOff(Section, "ClearComBuffOnOpen", FName, TRUE);                  GetOnOff(Section, "ClearComBuffOnOpen", FName, TRUE);
819    
820          /* Confirm disconnection -- special option */          /* Confirm disconnection -- special option */
821          if (GetOnOff(Section, "ConfirmDisconnect", FName, TRUE))          if (GetOnOff(Section, "ConfirmDisconnect", FName, TRUE))
822                  ts->PortFlag |= PF_CONFIRMDISCONN;                  ts->PortFlag |= PF_CONFIRMDISCONN;
823    
824          /* Ctrl code in Kanji -- special option */          /* Ctrl code in Kanji -- special option */
825          if (GetOnOff(Section, "CtrlInKanji", FName, TRUE))          if (GetOnOff(Section, "CtrlInKanji", FName, TRUE))
826                  ts->TermFlag |= TF_CTRLINKANJI;                  ts->TermFlag |= TF_CTRLINKANJI;
827    
828          /* Debug flag  -- special option */          /* Debug flag  -- special option */
829          ts->Debug = GetOnOff(Section, "Debug", FName, FALSE);          ts->Debug = GetOnOff(Section, "Debug", FName, FALSE);
830    
831          /* Delimiter list -- special option */          /* Delimiter list -- special option */
832          GetPrivateProfileString(Section, "DelimList",          GetPrivateProfileString(Section, "DelimList",
833                                  "$20!\"#$24%&\'()*+,-./:;<=>?@[\\]^`{|}~",                                  "$20!\"#$24%&\'()*+,-./:;<=>?@[\\]^`{|}~",
834                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
835          Hex2Str(Temp, ts->DelimList, sizeof(ts->DelimList));          Hex2Str(Temp, ts->DelimList, sizeof(ts->DelimList));
836    
837          /* regard DBCS characters as delimiters -- special option */          /* regard DBCS characters as delimiters -- special option */
838          ts->DelimDBCS = GetOnOff(Section, "DelimDBCS", FName, TRUE);          ts->DelimDBCS = GetOnOff(Section, "DelimDBCS", FName, TRUE);
839    
840          // Enable popup menu -- special option          // Enable popup menu -- special option
841          if (!GetOnOff(Section, "EnablePopupMenu", FName, TRUE))          if (!GetOnOff(Section, "EnablePopupMenu", FName, TRUE))
842                  ts->MenuFlag |= MF_NOPOPUP;                  ts->MenuFlag |= MF_NOPOPUP;
843    
844          // Enable "Show menu" -- special option          // Enable "Show menu" -- special option
845          if (!GetOnOff(Section, "EnableShowMenu", FName, TRUE))          if (!GetOnOff(Section, "EnableShowMenu", FName, TRUE))
846                  ts->MenuFlag |= MF_NOSHOWMENU;                  ts->MenuFlag |= MF_NOSHOWMENU;
847    
848          // Enable the status line -- special option          // Enable the status line -- special option
849          if (GetOnOff(Section, "EnableStatusLine", FName, TRUE))          if (GetOnOff(Section, "EnableStatusLine", FName, TRUE))
850                  ts->TermFlag |= TF_ENABLESLINE;                  ts->TermFlag |= TF_ENABLESLINE;
851    
852          // fixed JIS --- special          // fixed JIS --- special
853          if (GetOnOff(Section, "FixedJIS", FName, FALSE))          if (GetOnOff(Section, "FixedJIS", FName, FALSE))
854                  ts->TermFlag |= TF_FIXEDJIS;                  ts->TermFlag |= TF_FIXEDJIS;
855    
856          /* IME Flag  -- special option */          /* IME Flag  -- special option */
857          ts->UseIME = GetOnOff(Section, "IME", FName, TRUE);          ts->UseIME = GetOnOff(Section, "IME", FName, TRUE);
858    
859          /* IME-inline Flag  -- special option */          /* IME-inline Flag  -- special option */
860          ts->IMEInline = GetOnOff(Section, "IMEInline", FName, TRUE);          ts->IMEInline = GetOnOff(Section, "IMEInline", FName, TRUE);
861    
862          /* Kermit log  -- special option */          /* Kermit log  -- special option */
863          if (GetOnOff(Section, "KmtLog", FName, FALSE))          if (GetOnOff(Section, "KmtLog", FName, FALSE))
864                  ts->LogFlag |= LOG_KMT;                  ts->LogFlag |= LOG_KMT;
865    
866          // Enable language selection -- special option          // Enable language selection -- special option
867          if (!GetOnOff(Section, "LanguageSelection", FName, TRUE))          if (!GetOnOff(Section, "LanguageSelection", FName, TRUE))
868                  ts->MenuFlag |= MF_NOLANGUAGE;                  ts->MenuFlag |= MF_NOLANGUAGE;
869    
870          /* Maximum scroll buffer size  -- special option */          /* Maximum scroll buffer size  -- special option */
871          ts->ScrollBuffMax =          ts->ScrollBuffMax =
872                  GetPrivateProfileInt(Section, "MaxBuffSize", 10000, FName);                  GetPrivateProfileInt(Section, "MaxBuffSize", 10000, FName);
873          if (ts->ScrollBuffMax < 24)          if (ts->ScrollBuffMax < 24)
874                  ts->ScrollBuffMax = 10000;                  ts->ScrollBuffMax = 10000;
875    
876          /* Max com port number -- special option */          /* Max com port number -- special option */
877          ts->MaxComPort = GetPrivateProfileInt(Section, "MaxComPort", 4, FName);          ts->MaxComPort = GetPrivateProfileInt(Section, "MaxComPort", 4, FName);
878          if (ts->MaxComPort < 4)          if (ts->MaxComPort < 4)
879                  ts->MaxComPort = 4;                  ts->MaxComPort = 4;
880          // COM16から99へ拡張 (2005.11.30 yutaka)          // COM16から99へ拡張 (2005.11.30 yutaka)
881          // 99から200へ拡張 (2007.7.23 maya)          // 99から200へ拡張 (2007.7.23 maya)
882          if (ts->MaxComPort > MAXCOMPORT)          if (ts->MaxComPort > MAXCOMPORT)
883                  ts->MaxComPort = MAXCOMPORT;                  ts->MaxComPort = MAXCOMPORT;
884          if ((ts->ComPort < 1) || (ts->ComPort > ts->MaxComPort))          if ((ts->ComPort < 1) || (ts->ComPort > ts->MaxComPort))
885                  ts->ComPort = 1;                  ts->ComPort = 1;
886    
887          /* Non-blinking cursor -- special option */          /* Non-blinking cursor -- special option */
888          ts->NonblinkingCursor =          ts->NonblinkingCursor =
889                  GetOnOff(Section, "NonblinkingCursor", FName, FALSE);                  GetOnOff(Section, "NonblinkingCursor", FName, FALSE);
890    
891          // フォーカス無効時のポリゴンカーソル (2008.1.24 yutaka)          // フォーカス無効時のポリゴンカーソル (2008.1.24 yutaka)
892          ts->KillFocusCursor =          ts->KillFocusCursor =
893                  GetOnOff(Section, "KillFocusCursor", FName, TRUE);                  GetOnOff(Section, "KillFocusCursor", FName, TRUE);
894    
895          /* Delay for pass-thru printing activation */          /* Delay for pass-thru printing activation */
896          /*   -- special option */          /*   -- special option */
897          ts->PassThruDelay =          ts->PassThruDelay =
898                  GetPrivateProfileInt(Section, "PassThruDelay", 3, FName);                  GetPrivateProfileInt(Section, "PassThruDelay", 3, FName);
899    
900          /* Printer port for pass-thru printing */          /* Printer port for pass-thru printing */
901          /*   -- special option */          /*   -- special option */
902          GetPrivateProfileString(Section, "PassThruPort", "",          GetPrivateProfileString(Section, "PassThruPort", "",
903                                  ts->PrnDev, sizeof(ts->PrnDev), FName);                                  ts->PrnDev, sizeof(ts->PrnDev), FName);
904    
905          /* Printer Font --- special option */          /* Printer Font --- special option */
906          GetPrivateProfileString(Section, "PrnFont", "",          GetPrivateProfileString(Section, "PrnFont", "",
907                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
908          if (strlen(Temp) == 0) {          if (strlen(Temp) == 0) {
909                  ts->PrnFont[0] = 0;                  ts->PrnFont[0] = 0;
910                  ts->PrnFontSize.x = 0;                  ts->PrnFontSize.x = 0;
911                  ts->PrnFontSize.y = 0;                  ts->PrnFontSize.y = 0;
912                  ts->PrnFontCharSet = 0;                  ts->PrnFontCharSet = 0;
913          }          }
914          else {          else {
915                  GetNthString(Temp, 1, sizeof(ts->PrnFont), ts->PrnFont);                  GetNthString(Temp, 1, sizeof(ts->PrnFont), ts->PrnFont);
916                  GetNthNum(Temp, 2, (int far *) &(ts->PrnFontSize.x));                  GetNthNum(Temp, 2, (int far *) &(ts->PrnFontSize.x));
917                  GetNthNum(Temp, 3, (int far *) &(ts->PrnFontSize.y));                  GetNthNum(Temp, 3, (int far *) &(ts->PrnFontSize.y));
918                  GetNthNum(Temp, 4, &(ts->PrnFontCharSet));                  GetNthNum(Temp, 4, &(ts->PrnFontCharSet));
919          }          }
920    
921          // Page margins (left, right, top, bottom) for printing          // Page margins (left, right, top, bottom) for printing
922          //    -- special option          //    -- special option
923          GetPrivateProfileString(Section, "PrnMargin", "50,50,50,50",          GetPrivateProfileString(Section, "PrnMargin", "50,50,50,50",
924                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
925          for (i = 0; i <= 3; i++)          for (i = 0; i <= 3; i++)
926                  GetNthNum(Temp, 1 + i, &ts->PrnMargin[i]);                  GetNthNum(Temp, 1 + i, &ts->PrnMargin[i]);
927    
928          /* Quick-VAN log  -- special option */          /* Quick-VAN log  -- special option */
929          if (GetOnOff(Section, "QVLog", FName, FALSE))          if (GetOnOff(Section, "QVLog", FName, FALSE))
930                  ts->LogFlag |= LOG_QV;                  ts->LogFlag |= LOG_QV;
931    
932          /* Quick-VAN window size -- special */          /* Quick-VAN window size -- special */
933          ts->QVWinSize = GetPrivateProfileInt(Section, "QVWinSize", 8, FName);          ts->QVWinSize = GetPrivateProfileInt(Section, "QVWinSize", 8, FName);
934    
935          /* Russian character set (print) -- special option */          /* Russian character set (print) -- special option */
936          GetPrivateProfileString(Section, "RussPrint", "",          GetPrivateProfileString(Section, "RussPrint", "",
937                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
938          ts->RussPrint = str2id(RussList, Temp, IdWindows);          ts->RussPrint = str2id(RussList, Temp, IdWindows);
939    
940          /* Scroll threshold -- special option */          /* Scroll threshold -- special option */
941          ts->ScrollThreshold =          ts->ScrollThreshold =
942                  GetPrivateProfileInt(Section, "ScrollThreshold", 12, FName);                  GetPrivateProfileInt(Section, "ScrollThreshold", 12, FName);
943    
944          ts->MouseWheelScrollLine =          ts->MouseWheelScrollLine =
945                  GetPrivateProfileInt(Section, "MouseWheelScrollLine", 3, FName);                  GetPrivateProfileInt(Section, "MouseWheelScrollLine", 3, FName);
946    
947          // Select on activate -- special option          // Select on activate -- special option
948          ts->SelOnActive = GetOnOff(Section, "SelectOnActivate", FName, TRUE);          ts->SelOnActive = GetOnOff(Section, "SelectOnActivate", FName, TRUE);
949    
950          /* Send 8bit control sequence -- special option */          /* Send 8bit control sequence -- special option */
951          ts->Send8BitCtrl = GetOnOff(Section, "Send8BitCtrl", FName, FALSE);          ts->Send8BitCtrl = GetOnOff(Section, "Send8BitCtrl", FName, FALSE);
952    
953          /* Startup macro -- special option */          /* Startup macro -- special option */
954          GetPrivateProfileString(Section, "StartupMacro", "",          GetPrivateProfileString(Section, "StartupMacro", "",
955                                  ts->MacroFN, sizeof(ts->MacroFN), FName);                                  ts->MacroFN, sizeof(ts->MacroFN), FName);
956    
957          /* TEK GIN Mouse keycode -- special option */          /* TEK GIN Mouse keycode -- special option */
958          ts->GINMouseCode =          ts->GINMouseCode =
959                  GetPrivateProfileInt(Section, "TEKGINMouseCode", 32, FName);                  GetPrivateProfileInt(Section, "TEKGINMouseCode", 32, FName);
960    
961          /* Telnet Auto Detect -- special option */          /* Telnet Auto Detect -- special option */
962          ts->TelAutoDetect = GetOnOff(Section, "TelAutoDetect", FName, TRUE);          ts->TelAutoDetect = GetOnOff(Section, "TelAutoDetect", FName, TRUE);
963    
964          /* Telnet binary flag -- special option */          /* Telnet binary flag -- special option */
965          ts->TelBin = GetOnOff(Section, "TelBin", FName, FALSE);          ts->TelBin = GetOnOff(Section, "TelBin", FName, FALSE);
966    
967          /* Telnet Echo flag -- special option */          /* Telnet Echo flag -- special option */
968          ts->TelEcho = GetOnOff(Section, "TelEcho", FName, FALSE);          ts->TelEcho = GetOnOff(Section, "TelEcho", FName, FALSE);
969    
970          /* Telnet log  -- special option */          /* Telnet log  -- special option */
971          if (GetOnOff(Section, "TelLog", FName, FALSE))          if (GetOnOff(Section, "TelLog", FName, FALSE))
972                  ts->LogFlag |= LOG_TEL;                  ts->LogFlag |= LOG_TEL;
973    
974          /* TCP port num for telnet -- special option */          /* TCP port num for telnet -- special option */
975          ts->TelPort = GetPrivateProfileInt(Section, "TelPort", 23, FName);          ts->TelPort = GetPrivateProfileInt(Section, "TelPort", 23, FName);
976    
977          /* Telnet keep-alive packet(NOP command) interval -- special option */          /* Telnet keep-alive packet(NOP command) interval -- special option */
978          ts->TelKeepAliveInterval =          ts->TelKeepAliveInterval =
979                  GetPrivateProfileInt(Section, "TelKeepAliveInterval", 300, FName);                  GetPrivateProfileInt(Section, "TelKeepAliveInterval", 300, FName);
980    
981          /* Max number of broadcast commad history */          /* Max number of broadcast commad history */
982          ts->MaxBroadcatHistory =          ts->MaxBroadcatHistory =
983                  GetPrivateProfileInt(Section, "MaxBroadcatHistory", 99, FName);                  GetPrivateProfileInt(Section, "MaxBroadcatHistory", 99, FName);
984    
985          /* Local echo for non-telnet */          /* Local echo for non-telnet */
986          ts->TCPLocalEcho = GetOnOff(Section, "TCPLocalEcho", FName, FALSE);          ts->TCPLocalEcho = GetOnOff(Section, "TCPLocalEcho", FName, FALSE);
987    
988          /* "new-line (transmit)" option for non-telnet -- special option */          /* "new-line (transmit)" option for non-telnet -- special option */
989          GetPrivateProfileString(Section, "TCPCRSend", "",          GetPrivateProfileString(Section, "TCPCRSend", "",
990                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
991          if (_stricmp(Temp, "CR") == 0)          if (_stricmp(Temp, "CR") == 0)
992                  ts->TCPCRSend = IdCR;                  ts->TCPCRSend = IdCR;
993          else if (_stricmp(Temp, "CRLF") == 0)          else if (_stricmp(Temp, "CRLF") == 0)
994                  ts->TCPCRSend = IdCRLF;                  ts->TCPCRSend = IdCRLF;
995          else          else
996                  ts->TCPCRSend = 0;              // disabled                  ts->TCPCRSend = 0;              // disabled
997    
998          /* Use text (background) color for "white (black)" --- special option */          /* Use text (background) color for "white (black)" --- special option */
999          if (GetOnOff(Section, "UseTextColor", FName, FALSE))          if (GetOnOff(Section, "UseTextColor", FName, FALSE))
1000                  ts->ColorFlag |= CF_USETEXTCOLOR;                  ts->ColorFlag |= CF_USETEXTCOLOR;
1001    
1002          /* Title format -- special option */          /* Title format -- special option */
1003          ts->TitleFormat =          ts->TitleFormat =
1004                  GetPrivateProfileInt(Section, "TitleFormat", 5, FName);                  GetPrivateProfileInt(Section, "TitleFormat", 5, FName);
1005    
1006          /* VT Compatible Tab -- special option */          /* VT Compatible Tab -- special option */
1007          ts->VTCompatTab = GetOnOff(Section, "VTCompatTab", FName, FALSE);          ts->VTCompatTab = GetOnOff(Section, "VTCompatTab", FName, FALSE);
1008    
1009          /* VT Font space --- special option */          /* VT Font space --- special option */
1010          GetPrivateProfileString(Section, "VTFontSpace", "0,0,0,0",          GetPrivateProfileString(Section, "VTFontSpace", "0,0,0,0",
1011                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
1012          GetNthNum(Temp, 1, &ts->FontDX);          GetNthNum(Temp, 1, &ts->FontDX);
1013          GetNthNum(Temp, 2, &ts->FontDW);          GetNthNum(Temp, 2, &ts->FontDW);
1014          GetNthNum(Temp, 3, &ts->FontDY);          GetNthNum(Temp, 3, &ts->FontDY);
1015          GetNthNum(Temp, 4, &ts->FontDH);          GetNthNum(Temp, 4, &ts->FontDH);
1016          if (ts->FontDX < 0)          if (ts->FontDX < 0)
1017                  ts->FontDX = 0;                  ts->FontDX = 0;
1018          if (ts->FontDW < 0)          if (ts->FontDW < 0)
1019                  ts->FontDW = 0;                  ts->FontDW = 0;
1020          ts->FontDW = ts->FontDW + ts->FontDX;          ts->FontDW = ts->FontDW + ts->FontDX;
1021          if (ts->FontDY < 0)          if (ts->FontDY < 0)
1022                  ts->FontDY = 0;                  ts->FontDY = 0;
1023          if (ts->FontDH < 0)          if (ts->FontDH < 0)
1024                  ts->FontDH = 0;                  ts->FontDH = 0;
1025          ts->FontDH = ts->FontDH + ts->FontDY;          ts->FontDH = ts->FontDH + ts->FontDY;
1026    
1027          // VT-print scaling factors (pixels per inch) --- special option          // VT-print scaling factors (pixels per inch) --- special option
1028          GetPrivateProfileString(Section, "VTPPI", "0,0",          GetPrivateProfileString(Section, "VTPPI", "0,0",
1029                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
1030          GetNthNum(Temp, 1, (int far *) &ts->VTPPI.x);          GetNthNum(Temp, 1, (int far *) &ts->VTPPI.x);
1031          GetNthNum(Temp, 2, (int far *) &ts->VTPPI.y);          GetNthNum(Temp, 2, (int far *) &ts->VTPPI.y);
1032    
1033          // TEK-print scaling factors (pixels per inch) --- special option          // TEK-print scaling factors (pixels per inch) --- special option
1034          GetPrivateProfileString(Section, "TEKPPI", "0,0",          GetPrivateProfileString(Section, "TEKPPI", "0,0",
1035                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
1036          GetNthNum(Temp, 1, (int far *) &ts->TEKPPI.x);          GetNthNum(Temp, 1, (int far *) &ts->TEKPPI.x);
1037          GetNthNum(Temp, 2, (int far *) &ts->TEKPPI.y);          GetNthNum(Temp, 2, (int far *) &ts->TEKPPI.y);
1038    
1039          // Show "Window" menu -- special option          // Show "Window" menu -- special option
1040          if (GetOnOff(Section, "WindowMenu", FName, TRUE))          if (GetOnOff(Section, "WindowMenu", FName, TRUE))
1041                  ts->MenuFlag |= MF_SHOWWINMENU;                  ts->MenuFlag |= MF_SHOWWINMENU;
1042    
1043          /* XMODEM log  -- special option */          /* XMODEM log  -- special option */
1044          if (GetOnOff(Section, "XmodemLog", FName, FALSE))          if (GetOnOff(Section, "XmodemLog", FName, FALSE))
1045                  ts->LogFlag |= LOG_X;                  ts->LogFlag |= LOG_X;
1046    
1047          /* YMODEM log  -- special option */          /* YMODEM log  -- special option */
1048          if (GetOnOff(Section, "YmodemLog", FName, FALSE))          if (GetOnOff(Section, "YmodemLog", FName, FALSE))
1049                  ts->LogFlag |= LOG_Y;                  ts->LogFlag |= LOG_Y;
1050    
1051          /* Auto ZMODEM activation -- special option */          /* Auto ZMODEM activation -- special option */
1052          if (GetOnOff(Section, "ZmodemAuto", FName, FALSE))          if (GetOnOff(Section, "ZmodemAuto", FName, FALSE))
1053                  ts->FTFlag |= FT_ZAUTO;                  ts->FTFlag |= FT_ZAUTO;
1054    
1055          /* ZMODEM data subpacket length for sending -- special */          /* ZMODEM data subpacket length for sending -- special */
1056          ts->ZmodemDataLen =          ts->ZmodemDataLen =
1057                  GetPrivateProfileInt(Section, "ZmodemDataLen", 1024, FName);                  GetPrivateProfileInt(Section, "ZmodemDataLen", 1024, FName);
1058          /* ZMODEM window size for sending -- special */          /* ZMODEM window size for sending -- special */
1059          ts->ZmodemWinSize =          ts->ZmodemWinSize =
1060                  GetPrivateProfileInt(Section, "ZmodemWinSize", 32767, FName);                  GetPrivateProfileInt(Section, "ZmodemWinSize", 32767, FName);
1061    
1062          /* ZMODEM ESCCTL flag  -- special option */          /* ZMODEM ESCCTL flag  -- special option */
1063          if (GetOnOff(Section, "ZmodemEscCtl", FName, FALSE))          if (GetOnOff(Section, "ZmodemEscCtl", FName, FALSE))
1064                  ts->FTFlag |= FT_ZESCCTL;                  ts->FTFlag |= FT_ZESCCTL;
1065    
1066          /* ZMODEM log  -- special option */          /* ZMODEM log  -- special option */
1067          if (GetOnOff(Section, "ZmodemLog", FName, FALSE))          if (GetOnOff(Section, "ZmodemLog", FName, FALSE))
1068                  ts->LogFlag |= LOG_Z;                  ts->LogFlag |= LOG_Z;
1069    
1070          /* ZMODEM 受信コマンド (2007.12.21 yutaka) */          /* ZMODEM 受信コマンド (2007.12.21 yutaka) */
1071          GetPrivateProfileString(Section, "ZModemRcvCommand", "rz",          GetPrivateProfileString(Section, "ZModemRcvCommand", "rz",
1072                                  ts->ZModemRcvCommand, sizeof(ts->ZModemRcvCommand), FName);                                  ts->ZModemRcvCommand, sizeof(ts->ZModemRcvCommand), FName);
1073    
1074  #ifndef NO_COPYLINE_FIX  #ifndef NO_COPYLINE_FIX
1075    
1076          /* Enable continued-line copy  -- special option */          /* Enable continued-line copy  -- special option */
1077          ts->EnableContinuedLineCopy =          ts->EnableContinuedLineCopy =
1078                  GetOnOff(Section, "EnableContinuedLineCopy", FName, FALSE);                  GetOnOff(Section, "EnableContinuedLineCopy", FName, FALSE);
1079  #endif                                                  /* NO_COPYLINE_FIX */  #endif                                                  /* NO_COPYLINE_FIX */
1080    
1081          ts->DisablePasteMouseRButton =          ts->DisablePasteMouseRButton =
1082                  GetOnOff(Section, "DisablePasteMouseRButton", FName, FALSE);                  GetOnOff(Section, "DisablePasteMouseRButton", FName, FALSE);
1083    
1084          // added DisablePasteMouseMButton (2008.3.2 maya)          // added DisablePasteMouseMButton (2008.3.2 maya)
1085          ts->DisablePasteMouseMButton =          ts->DisablePasteMouseMButton =
1086                  GetOnOff(Section, "DisablePasteMouseMButton", FName, TRUE);                  GetOnOff(Section, "DisablePasteMouseMButton", FName, TRUE);
1087    
1088          // added ConfirmPasteMouseRButton (2007.3.17 maya)          // added ConfirmPasteMouseRButton (2007.3.17 maya)
1089          ts->ConfirmPasteMouseRButton =          ts->ConfirmPasteMouseRButton =
1090                  GetOnOff(Section, "ConfirmPasteMouseRButton", FName, FALSE);                  GetOnOff(Section, "ConfirmPasteMouseRButton", FName, FALSE);
1091    
1092          // added ConfirmChangePaste (2008.2.3 yutaka)          // added ConfirmChangePaste (2008.2.3 yutaka)
1093          ts->ConfirmChangePaste =          ts->ConfirmChangePaste =
1094                  GetOnOff(Section, "ConfirmChangePaste", FName, TRUE);                  GetOnOff(Section, "ConfirmChangePaste", FName, TRUE);
1095    
1096          // added ScrollWindowClearScreen (2008.5.3 yutaka)          // added ScrollWindowClearScreen (2008.5.3 yutaka)
1097          ts->ScrollWindowClearScreen =          ts->ScrollWindowClearScreen =
1098                  GetOnOff(Section, "ScrollWindowClearScreen", FName, TRUE);                  GetOnOff(Section, "ScrollWindowClearScreen", FName, TRUE);
1099    
1100          // added SelectOnlyByLButton (2007.11.20 maya)          // added SelectOnlyByLButton (2007.11.20 maya)
1101          ts->SelectOnlyByLButton =          ts->SelectOnlyByLButton =
1102                  GetOnOff(Section, "SelectOnlyByLButton", FName, TRUE);                  GetOnOff(Section, "SelectOnlyByLButton", FName, TRUE);
1103    
1104          // added DisableAcceleratorSendBreak (2007.3.17 maya)          // added DisableAcceleratorSendBreak (2007.3.17 maya)
1105          ts->DisableAcceleratorSendBreak =          ts->DisableAcceleratorSendBreak =
1106                  GetOnOff(Section, "DisableAcceleratorSendBreak", FName, FALSE);                  GetOnOff(Section, "DisableAcceleratorSendBreak", FName, FALSE);
1107    
1108          // WinSock connecting timeout value (2007.1.11 yutaka)          // WinSock connecting timeout value (2007.1.11 yutaka)
1109          ts->ConnectingTimeout =          ts->ConnectingTimeout =
1110                  GetPrivateProfileInt(Section, "ConnectingTimeout", 0, FName);                  GetPrivateProfileInt(Section, "ConnectingTimeout", 0, FName);
1111    
1112          // mouse cursor          // mouse cursor
1113          GetPrivateProfileString(Section, "MouseCursor", "IBEAM",          GetPrivateProfileString(Section, "MouseCursor", "IBEAM",
1114                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
1115          strncpy_s(ts->MouseCursorName, sizeof(ts->MouseCursorName), Temp,          strncpy_s(ts->MouseCursorName, sizeof(ts->MouseCursorName), Temp,
1116                    _TRUNCATE);                    _TRUNCATE);
1117    
1118          // Translucent window          // Translucent window
1119          ts->AlphaBlend =          ts->AlphaBlend =
1120                  GetPrivateProfileInt(Section, "AlphaBlend ", 255, FName);                  GetPrivateProfileInt(Section, "AlphaBlend ", 255, FName);
1121          ts->AlphaBlend = max(0, ts->AlphaBlend);          ts->AlphaBlend = max(0, ts->AlphaBlend);
1122          ts->AlphaBlend = min(255, ts->AlphaBlend);          ts->AlphaBlend = min(255, ts->AlphaBlend);
1123    
1124          // Cygwin install path          // Cygwin install path
1125          GetPrivateProfileString(Section, "CygwinDirectory ", "c:\\cygwin",          GetPrivateProfileString(Section, "CygwinDirectory ", "c:\\cygwin",
1126                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
1127          strncpy_s(ts->CygwinDirectory, sizeof(ts->CygwinDirectory), Temp,          strncpy_s(ts->CygwinDirectory, sizeof(ts->CygwinDirectory), Temp,
1128                    _TRUNCATE);                    _TRUNCATE);
1129    
1130          // Viewlog Editor path          // Viewlog Editor path
1131          GetPrivateProfileString(Section, "ViewlogEditor ", "notepad.exe",          GetPrivateProfileString(Section, "ViewlogEditor ", "notepad.exe",
1132                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
1133          strncpy_s(ts->ViewlogEditor, sizeof(ts->ViewlogEditor), Temp,          strncpy_s(ts->ViewlogEditor, sizeof(ts->ViewlogEditor), Temp,
1134                    _TRUNCATE);                    _TRUNCATE);
1135    
1136          // Locale for UTF-8          // Locale for UTF-8
1137          GetPrivateProfileString(Section, "Locale ", DEFAULT_LOCALE,          GetPrivateProfileString(Section, "Locale ", DEFAULT_LOCALE,
1138                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
1139          strncpy_s(ts->Locale, sizeof(ts->Locale), Temp, _TRUNCATE);          strncpy_s(ts->Locale, sizeof(ts->Locale), Temp, _TRUNCATE);
1140    
1141          // CodePage          // CodePage
1142          ts->CodePage =          ts->CodePage =
1143                  GetPrivateProfileInt(Section, "CodePage ", DEFAULT_CODEPAGE,                  GetPrivateProfileInt(Section, "CodePage ", DEFAULT_CODEPAGE,
1144                                       FName);                                       FName);
1145    
1146          // UI language message file          // UI language message file
1147          GetPrivateProfileString(Section, "UILanguageFile", "lang\\Default.lng",          GetPrivateProfileString(Section, "UILanguageFile", "lang\\Default.lng",
1148                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
1149          {          {
1150                  char CurDir[MAX_PATH];                  char CurDir[MAX_PATH];
1151    
1152                  // フルパス化する前に読み込み時の設定を取っておく                  // フルパス化する前に読み込み時の設定を取っておく
1153                  strncpy_s(ts->UILanguageFile_ini, sizeof(ts->UILanguageFile_ini), Temp, _TRUNCATE);                  strncpy_s(ts->UILanguageFile_ini, sizeof(ts->UILanguageFile_ini), Temp, _TRUNCATE);
1154    
1155                  GetCurrentDirectory(sizeof(CurDir), CurDir);                  GetCurrentDirectory(sizeof(CurDir), CurDir);
1156                  SetCurrentDirectory(ts->HomeDir);                  SetCurrentDirectory(ts->HomeDir);
1157                  _fullpath(ts->UILanguageFile, Temp, sizeof(ts->UILanguageFile));                  _fullpath(ts->UILanguageFile, Temp, sizeof(ts->UILanguageFile));
1158                  SetCurrentDirectory(CurDir);                  SetCurrentDirectory(CurDir);
1159          }          }
1160    
1161          // Broadcast Command History (2007.3.3 maya)          // Broadcast Command History (2007.3.3 maya)
1162          ts->BroadcastCommandHistory =          ts->BroadcastCommandHistory =
1163                  GetOnOff(Section, "BroadcastCommandHistory", FName, FALSE);                  GetOnOff(Section, "BroadcastCommandHistory", FName, FALSE);
1164    
1165          // 337: 2007/03/20 Accept Broadcast          // 337: 2007/03/20 Accept Broadcast
1166          ts->AcceptBroadcast =          ts->AcceptBroadcast =
1167                  GetOnOff(Section, "AcceptBroadcast", FName, TRUE);                  GetOnOff(Section, "AcceptBroadcast", FName, TRUE);
1168    
1169          // Confirm send a file when drag and drop (2007.12.28 maya)          // Confirm send a file when drag and drop (2007.12.28 maya)
1170          ts->ConfirmFileDragAndDrop =          ts->ConfirmFileDragAndDrop =
1171                  GetOnOff(Section, "ConfirmFileDragAndDrop", FName, TRUE);                  GetOnOff(Section, "ConfirmFileDragAndDrop", FName, TRUE);
1172    
1173          // Translate mouse wheel to cursor key when application cursor mode          // Translate mouse wheel to cursor key when application cursor mode
1174          ts->TranslateWheelToCursor =          ts->TranslateWheelToCursor =
1175                  GetOnOff(Section, "TranslateWheelToCursor", FName, TRUE);                  GetOnOff(Section, "TranslateWheelToCursor", FName, TRUE);
1176    
1177          // Display "New Connection" dialog on startup (2008.1.18 maya)          // Display "New Connection" dialog on startup (2008.1.18 maya)
1178          ts->HostDialogOnStartup =          ts->HostDialogOnStartup =
1179                  GetOnOff(Section, "HostDialogOnStartup", FName, TRUE);                  GetOnOff(Section, "HostDialogOnStartup", FName, TRUE);
1180    
1181          // Mouse event tracking          // Mouse event tracking
1182          ts->MouseEventTracking =          ts->MouseEventTracking =
1183                  GetOnOff(Section, "MouseEventTracking", FName, TRUE);                  GetOnOff(Section, "MouseEventTracking", FName, TRUE);
1184    
1185          // Maximized bug tweak          // Maximized bug tweak
1186          ts->MaximizedBugTweak =          ts->MaximizedBugTweak =
1187                  GetOnOff(Section, "MaximizedBugTweak", FName, TRUE);                  GetOnOff(Section, "MaximizedBugTweak", FName, TRUE);
1188    
1189          // Convert Unicode symbol characters to DEC Special characters          // Convert Unicode symbol characters to DEC Special characters
1190          ts->UnicodeDecSpMapping =          ts->UnicodeDecSpMapping =
1191                  GetPrivateProfileInt(Section, "UnicodeToDecSpMapping", 3, FName);                  GetPrivateProfileInt(Section, "UnicodeToDecSpMapping", 3, FName);
1192    
1193          // VT Window Icon          // VT Window Icon
1194          GetPrivateProfileString(Section, "VTIcon", "Default",          GetPrivateProfileString(Section, "VTIcon", "Default",
1195                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
1196          ts->VTIcon = IconName2IconId(Temp);          ts->VTIcon = IconName2IconId(Temp);
1197    
1198          // Tek Window Icon          // Tek Window Icon
1199          GetPrivateProfileString(Section, "TEKIcon", "Default",          GetPrivateProfileString(Section, "TEKIcon", "Default",
1200                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
1201          ts->TEKIcon = IconName2IconId(Temp);          ts->TEKIcon = IconName2IconId(Temp);
1202    
1203          // Unknown Unicode Character          // Unknown Unicode Character
1204          ts->UnknownUnicodeCharaAsWide =          ts->UnknownUnicodeCharaAsWide =
1205                  GetOnOff(Section, "UnknownUnicodeCharacterAsWide", FName, FALSE);                  GetOnOff(Section, "UnknownUnicodeCharacterAsWide", FName, FALSE);
1206    
1207  #ifdef USE_NORMAL_BGCOLOR  #ifdef USE_NORMAL_BGCOLOR
1208          // UseNormalBGColor          // UseNormalBGColor
1209          ts->UseNormalBGColor =          ts->UseNormalBGColor =
1210                  GetOnOff(Section, "UseNormalBGColor", FName, FALSE);                  GetOnOff(Section, "UseNormalBGColor", FName, FALSE);
1211          // 2006/03/11 by 337          // 2006/03/11 by 337
1212          if (ts->UseNormalBGColor) {          if (ts->UseNormalBGColor) {
1213                  ts->VTBoldColor[1] =                  ts->VTBoldColor[1] =
1214                          ts->VTBlinkColor[1] = ts->URLColor[1] = ts->VTColor[1];                          ts->VTBlinkColor[1] = ts->URLColor[1] = ts->VTColor[1];
1215          }          }
1216  #endif  #endif
1217    
1218          // AutoScrollOnlyInBottomLine          // AutoScrollOnlyInBottomLine
1219          ts->AutoScrollOnlyInBottomLine =          ts->AutoScrollOnlyInBottomLine =
1220                  GetOnOff(Section, "AutoScrollOnlyInBottomLine", FName, FALSE);                  GetOnOff(Section, "AutoScrollOnlyInBottomLine", FName, FALSE);
1221    
1222          // Accept remote-controlled window title changing          // Accept remote-controlled window title changing
1223          GetPrivateProfileString(Section, "AcceptTitleChangeRequest", "overwrite",          GetPrivateProfileString(Section, "AcceptTitleChangeRequest", "overwrite",
1224                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
1225          if (_stricmp(Temp, "overwrite") == 0 || _stricmp(Temp, "on") == 0)          if (_stricmp(Temp, "overwrite") == 0 || _stricmp(Temp, "on") == 0)
1226                  ts->AcceptTitleChangeRequest = IdTitleChangeRequestOverwrite;                  ts->AcceptTitleChangeRequest = IdTitleChangeRequestOverwrite;
1227          else if (_stricmp(Temp, "ahead") == 0)          else if (_stricmp(Temp, "ahead") == 0)
1228                  ts->AcceptTitleChangeRequest = IdTitleChangeRequestAhead;                  ts->AcceptTitleChangeRequest = IdTitleChangeRequestAhead;
1229          else if (_stricmp(Temp, "last") == 0)          else if (_stricmp(Temp, "last") == 0)
1230                  ts->AcceptTitleChangeRequest = IdTitleChangeRequestLast;                  ts->AcceptTitleChangeRequest = IdTitleChangeRequestLast;
1231          else          else
1232                  ts->AcceptTitleChangeRequest = IdTitleChangeRequestOff;                  ts->AcceptTitleChangeRequest = IdTitleChangeRequestOff;
1233    
1234          // Size of paste confirm dialog          // Size of paste confirm dialog
1235          GetPrivateProfileString(Section, "PasteDialogSize", "330,220",          GetPrivateProfileString(Section, "PasteDialogSize", "330,220",
1236                                  Temp, sizeof(Temp), FName);                                  Temp, sizeof(Temp), FName);
1237          GetNthNum(Temp, 1, &ts->PasteDialogSize.cx);          GetNthNum(Temp, 1, &ts->PasteDialogSize.cx);
1238          GetNthNum(Temp, 2, &ts->PasteDialogSize.cy);          GetNthNum(Temp, 2, &ts->PasteDialogSize.cy);
1239          if (ts->PasteDialogSize.cx < 0)          if (ts->PasteDialogSize.cx < 0)
1240                  ts->PasteDialogSize.cx = 330;                  ts->PasteDialogSize.cx = 330;
1241          if (ts->PasteDialogSize.cy < 0)          if (ts->PasteDialogSize.cy < 0)
1242                  ts->PasteDialogSize.cy = 220;                  ts->PasteDialogSize.cy = 220;
1243    
1244          // Disable mouse event tracking when Control-Key is pressed.          // Disable mouse event tracking when Control-Key is pressed.
1245          ts->DisableMouseTrackingByCtrl =          ts->DisableMouseTrackingByCtrl =
1246                  GetOnOff(Section, "DisableMouseTrackingByCtrl", FName, TRUE);                  GetOnOff(Section, "DisableMouseTrackingByCtrl", FName, TRUE);
1247    
1248          // Disable TranslateWheelToCursor setting when Control-Key is pressed.          // Disable TranslateWheelToCursor setting when Control-Key is pressed.
1249          ts->DisableWheelToCursorByCtrl =          ts->DisableWheelToCursorByCtrl =
1250                  GetOnOff(Section, "DisableWheelToCursorByCtrl", FName, TRUE);                  GetOnOff(Section, "DisableWheelToCursorByCtrl", FName, TRUE);
1251    
1252          // Strict Key Mapping.          // Strict Key Mapping.
1253          ts->StrictKeyMapping =          ts->StrictKeyMapping =
1254                  GetOnOff(Section, "StrictKeyMapping", FName, FALSE);                  GetOnOff(Section, "StrictKeyMapping", FName, FALSE);
1255    
1256          // added Wait4allMacroCommand (2009.3.23 yutaka)          // added Wait4allMacroCommand (2009.3.23 yutaka)
1257          ts->Wait4allMacroCommand =          ts->Wait4allMacroCommand =
1258                  GetOnOff(Section, "Wait4allMacroCommand", FName, FALSE);                  GetOnOff(Section, "Wait4allMacroCommand", FName, FALSE);
1259  }  }
1260    
1261  void FAR PASCAL WriteIniFile(PCHAR FName, PTTSet ts)  void FAR PASCAL WriteIniFile(PCHAR FName, PTTSet ts)
1262  {  {
1263          int i;          int i;
1264          char Temp[MAXPATHLEN];          char Temp[MAXPATHLEN];
1265          char buf[20];          char buf[20];
1266    
1267          /* version */          /* version */
1268          WritePrivateProfileString(Section, "Version", "2.3", FName);          WritePrivateProfileString(Section, "Version", "2.3", FName);
1269    
1270          /* Language */          /* Language */
1271          if (ts->Language == IdJapanese)          if (ts->Language == IdJapanese)
1272                  strncpy_s(Temp, sizeof(Temp), "Japanese", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "Japanese", _TRUNCATE);
1273          else if (ts->Language == IdRussian)          else if (ts->Language == IdRussian)
1274                  strncpy_s(Temp, sizeof(Temp), "Russian", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "Russian", _TRUNCATE);
1275          else if (ts->Language == IdKorean) //HKS          else if (ts->Language == IdKorean) //HKS
1276                  strncpy_s(Temp, sizeof(Temp), "Korean", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "Korean", _TRUNCATE);
1277          else          else
1278                  strncpy_s(Temp, sizeof(Temp), "English", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "English", _TRUNCATE);
1279          WritePrivateProfileString(Section, "Language", Temp, FName);          WritePrivateProfileString(Section, "Language", Temp, FName);
1280    
1281          /* Port type */          /* Port type */
1282          if (ts->PortType == IdSerial)          if (ts->PortType == IdSerial)
1283                  strncpy_s(Temp, sizeof(Temp), "serial", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "serial", _TRUNCATE);
1284          else                                            /* IdFile -> IdTCPIP */          else                                            /* IdFile -> IdTCPIP */
1285                  strncpy_s(Temp, sizeof(Temp), "tcpip", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "tcpip", _TRUNCATE);
1286    
1287          WritePrivateProfileString(Section, "Port", Temp, FName);          WritePrivateProfileString(Section, "Port", Temp, FName);
1288    
1289          /* Save win position */          /* Save win position */
1290          if (ts->SaveVTWinPos) {          if (ts->SaveVTWinPos) {
1291                  /* VT win position */                  /* VT win position */
1292                  WriteInt2(Section, "VTPos", FName, ts->VTPos.x, ts->VTPos.y);                  WriteInt2(Section, "VTPos", FName, ts->VTPos.x, ts->VTPos.y);
1293          }          }
1294    
1295          /* VT terminal size  */          /* VT terminal size  */
1296          WriteInt2(Section, "TerminalSize", FName,          WriteInt2(Section, "TerminalSize", FName,
1297                            ts->TerminalWidth, ts->TerminalHeight);                            ts->TerminalWidth, ts->TerminalHeight);
1298    
1299          /* Terminal size = Window size */          /* Terminal size = Window size */
1300          WriteOnOff(Section, "TermIsWin", FName, ts->TermIsWin);          WriteOnOff(Section, "TermIsWin", FName, ts->TermIsWin);
1301    
1302          /* Auto window resize flag */          /* Auto window resize flag */
1303          WriteOnOff(Section, "AutoWinResize", FName, ts->AutoWinResize);          WriteOnOff(Section, "AutoWinResize", FName, ts->AutoWinResize);
1304    
1305          /* CR Receive */          /* CR Receive */
1306          if (ts->CRReceive == IdCRLF) {          if (ts->CRReceive == IdCRLF) {
1307                  strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
1308          }          }
1309          else if (ts->CRReceive == IdLF) {          else if (ts->CRReceive == IdLF) {
1310                  strncpy_s(Temp, sizeof(Temp), "LF", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "LF", _TRUNCATE);
1311          }          }
1312          else {          else {
1313                  strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
1314          }          }
1315          WritePrivateProfileString(Section, "CRReceive", Temp, FName);          WritePrivateProfileString(Section, "CRReceive", Temp, FName);
1316    
1317          /* CR Send */          /* CR Send */
1318          if (ts->CRSend == IdCRLF)          if (ts->CRSend == IdCRLF)
1319                  strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
1320          else          else
1321                  strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
1322          WritePrivateProfileString(Section, "CRSend", Temp, FName);          WritePrivateProfileString(Section, "CRSend", Temp, FName);
1323    
1324          /* Local echo */          /* Local echo */
1325          WriteOnOff(Section, "LocalEcho", FName, ts->LocalEcho);          WriteOnOff(Section, "LocalEcho", FName, ts->LocalEcho);
1326    
1327          /* Answerback */          /* Answerback */
1328          if ((ts->FTFlag & FT_BPAUTO) == 0) {          if ((ts->FTFlag & FT_BPAUTO) == 0) {
1329                  Str2Hex(ts->Answerback, Temp, ts->AnswerbackLen,                  Str2Hex(ts->Answerback, Temp, ts->AnswerbackLen,
1330                          sizeof(Temp) - 1, TRUE);                          sizeof(Temp) - 1, TRUE);
1331                  WritePrivateProfileString(Section, "Answerback", Temp, FName);                  WritePrivateProfileString(Section, "Answerback", Temp, FName);
1332          }          }
1333    
1334          /* Kanji Code (receive)  */          /* Kanji Code (receive)  */
1335          switch (ts->KanjiCode) {          switch (ts->KanjiCode) {
1336          case IdEUC:          case IdEUC:
1337                  strncpy_s(Temp, sizeof(Temp), "EUC", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "EUC", _TRUNCATE);
1338                  break;                  break;
1339          case IdJIS:          case IdJIS:
1340                  strncpy_s(Temp, sizeof(Temp), "JIS", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "JIS", _TRUNCATE);
1341                  break;                  break;
1342          case IdUTF8:          case IdUTF8:
1343                  strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
1344                  break;                  break;
1345          case IdUTF8m:          case IdUTF8m:
1346                  strncpy_s(Temp, sizeof(Temp), "UTF-8m", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "UTF-8m", _TRUNCATE);
1347                  break;                  break;
1348          default:          default:
1349                  strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
1350          }          }
1351          WritePrivateProfileString(Section, "KanjiReceive", Temp, FName);          WritePrivateProfileString(Section, "KanjiReceive", Temp, FName);
1352    
1353          /* Katakana (receive)  */          /* Katakana (receive)  */
1354          if (ts->JIS7Katakana == 1)          if (ts->JIS7Katakana == 1)
1355                  strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
1356          else          else
1357                  strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
1358    
1359          WritePrivateProfileString(Section, "KatakanaReceive", Temp, FName);          WritePrivateProfileString(Section, "KatakanaReceive", Temp, FName);
1360    
1361          /* Kanji Code (transmit)  */          /* Kanji Code (transmit)  */
1362          switch (ts->KanjiCodeSend) {          switch (ts->KanjiCodeSend) {
1363          case IdEUC:          case IdEUC:
1364                  strncpy_s(Temp, sizeof(Temp), "EUC", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "EUC", _TRUNCATE);
1365                  break;                  break;
1366          case IdJIS:          case IdJIS:
1367                  strncpy_s(Temp, sizeof(Temp), "JIS", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "JIS", _TRUNCATE);
1368                  break;                  break;
1369          case IdUTF8:          case IdUTF8:
1370                  strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
1371                  break;                  break;
1372          default:          default:
1373                  strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
1374          }          }
1375          WritePrivateProfileString(Section, "KanjiSend", Temp, FName);          WritePrivateProfileString(Section, "KanjiSend", Temp, FName);
1376    
1377          /* Katakana (transmit)  */          /* Katakana (transmit)  */
1378          if (ts->JIS7KatakanaSend == 1)          if (ts->JIS7KatakanaSend == 1)
1379                  strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
1380          else          else
1381                  strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
1382    
1383          WritePrivateProfileString(Section, "KatakanaSend", Temp, FName);          WritePrivateProfileString(Section, "KatakanaSend", Temp, FName);
1384    
1385          /* KanjiIn */          /* KanjiIn */
1386          if (ts->KanjiIn == IdKanjiInA)          if (ts->KanjiIn == IdKanjiInA)
1387                  strncpy_s(Temp, sizeof(Temp), "@", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "@", _TRUNCATE);
1388          else          else
1389                  strncpy_s(Temp, sizeof(Temp), "B", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "B", _TRUNCATE);
1390    
1391          WritePrivateProfileString(Section, "KanjiIn", Temp, FName);          WritePrivateProfileString(Section, "KanjiIn", Temp, FName);
1392    
1393          /* KanjiOut */          /* KanjiOut */
1394          switch (ts->KanjiOut) {          switch (ts->KanjiOut) {
1395          case IdKanjiOutB:          case IdKanjiOutB:
1396                  strncpy_s(Temp, sizeof(Temp), "B", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "B", _TRUNCATE);
1397                  break;                  break;
1398          case IdKanjiOutH:          case IdKanjiOutH:
1399                  strncpy_s(Temp, sizeof(Temp), "H", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "H", _TRUNCATE);
1400                  break;                  break;
1401          default:          default:
1402                  strncpy_s(Temp, sizeof(Temp), "J", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "J", _TRUNCATE);
1403          }          }
1404          WritePrivateProfileString(Section, "KanjiOut", Temp, FName);          WritePrivateProfileString(Section, "KanjiOut", Temp, FName);
1405    
1406          // new configuration          // new configuration
1407          WriteInt(Section, "ConnectingTimeout", FName, ts->ConnectingTimeout);          WriteInt(Section, "ConnectingTimeout", FName, ts->ConnectingTimeout);
1408    
1409          WriteOnOff(Section, "DisablePasteMouseRButton", FName,          WriteOnOff(Section, "DisablePasteMouseRButton", FName,
1410                     ts->DisablePasteMouseRButton);                     ts->DisablePasteMouseRButton);
1411    
1412          // added DisablePasteMouseMButton (2008.3.2 maya)          // added DisablePasteMouseMButton (2008.3.2 maya)
1413          WriteOnOff(Section, "DisablePasteMouseMButton", FName,          WriteOnOff(Section, "DisablePasteMouseMButton", FName,
1414                     ts->DisablePasteMouseMButton);                     ts->DisablePasteMouseMButton);
1415    
1416          // added ConfirmPasteMouseRButton (2007.3.17 maya)          // added ConfirmPasteMouseRButton (2007.3.17 maya)
1417          WriteOnOff(Section, "ConfirmPasteMouseRButton", FName,          WriteOnOff(Section, "ConfirmPasteMouseRButton", FName,
1418                     ts->ConfirmPasteMouseRButton);                     ts->ConfirmPasteMouseRButton);
1419    
1420          // added ConfirmChangePaste          // added ConfirmChangePaste
1421          WriteOnOff(Section, "ConfirmChangePaste", FName,          WriteOnOff(Section, "ConfirmChangePaste", FName,
1422                     ts->ConfirmChangePaste);                     ts->ConfirmChangePaste);
1423    
1424          // added ScrollWindowClearScreen          // added ScrollWindowClearScreen
1425          WriteOnOff(Section, "ScrollWindowClearScreen", FName,          WriteOnOff(Section, "ScrollWindowClearScreen", FName,
1426                  ts->ScrollWindowClearScreen);                  ts->ScrollWindowClearScreen);
1427    
1428          // added SelectOnlyByLButton (2007.11.20 maya)          // added SelectOnlyByLButton (2007.11.20 maya)
1429          WriteOnOff(Section, "SelectOnlyByLButton", FName,          WriteOnOff(Section, "SelectOnlyByLButton", FName,
1430                     ts->SelectOnlyByLButton);                     ts->SelectOnlyByLButton);
1431          // added DisableAcceleratorSendBreak (2007.3.17 maya)          // added DisableAcceleratorSendBreak (2007.3.17 maya)
1432          WriteOnOff(Section, "DisableAcceleratorSendBreak", FName,          WriteOnOff(Section, "DisableAcceleratorSendBreak", FName,
1433                     ts->DisableAcceleratorSendBreak);                     ts->DisableAcceleratorSendBreak);
1434          WriteOnOff(Section, "EnableContinuedLineCopy", FName,          WriteOnOff(Section, "EnableContinuedLineCopy", FName,
1435                     ts->EnableContinuedLineCopy);                     ts->EnableContinuedLineCopy);
1436          WritePrivateProfileString(Section, "MouseCursor", ts->MouseCursorName,          WritePrivateProfileString(Section, "MouseCursor", ts->MouseCursorName,
1437                                    FName);                                    FName);
1438          _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->AlphaBlend);          _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->AlphaBlend);
1439          WritePrivateProfileString(Section, "AlphaBlend", Temp, FName);          WritePrivateProfileString(Section, "AlphaBlend", Temp, FName);
1440          WritePrivateProfileString(Section, "CygwinDirectory",          WritePrivateProfileString(Section, "CygwinDirectory",
1441                                    ts->CygwinDirectory, FName);                                    ts->CygwinDirectory, FName);
1442          WritePrivateProfileString(Section, "ViewlogEditor", ts->ViewlogEditor,          WritePrivateProfileString(Section, "ViewlogEditor", ts->ViewlogEditor,
1443                                    FName);                                    FName);
1444          WritePrivateProfileString(Section, "Locale", ts->Locale, FName);          WritePrivateProfileString(Section, "Locale", ts->Locale, FName);
1445          _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->CodePage);          _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->CodePage);
1446          WritePrivateProfileString(Section, "CodePage", Temp, FName);          WritePrivateProfileString(Section, "CodePage", Temp, FName);
1447    
1448          // ANSI color(2004.9.5 yutaka)          // ANSI color(2004.9.5 yutaka)
1449          Temp[0] = '\0';          Temp[0] = '\0';
1450          for (i = 0; i < 15; i++) {          for (i = 0; i < 15; i++) {
1451                  _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d,%d,%d,%d, ",                  _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d,%d,%d,%d, ",
1452                              i,                              i,
1453                              GetRValue(ts->ANSIColor[i]),                              GetRValue(ts->ANSIColor[i]),
1454                              GetGValue(ts->ANSIColor[i]),                              GetGValue(ts->ANSIColor[i]),
1455                              GetBValue(ts->ANSIColor[i])                              GetBValue(ts->ANSIColor[i])
1456                  );                  );
1457                  strncat_s(Temp, sizeof(Temp), buf, _TRUNCATE);                  strncat_s(Temp, sizeof(Temp), buf, _TRUNCATE);
1458          }          }
1459          i = 15;          i = 15;
1460          _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d,%d,%d,%d",          _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d,%d,%d,%d",
1461                      i,                      i,
1462                      GetRValue(ts->ANSIColor[i]),                      GetRValue(ts->ANSIColor[i]),
1463                      GetGValue(ts->ANSIColor[i]),                      GetGValue(ts->ANSIColor[i]),
1464                      GetBValue(ts->ANSIColor[i])                      GetBValue(ts->ANSIColor[i])
1465          );          );
1466          strncat_s(Temp, sizeof(Temp), buf, _TRUNCATE);          strncat_s(Temp, sizeof(Temp), buf, _TRUNCATE);
1467          WritePrivateProfileString(Section, "ANSIColor", Temp, FName);          WritePrivateProfileString(Section, "ANSIColor", Temp, FName);
1468    
1469          /* AutoWinChange VT<->TEK */          /* AutoWinChange VT<->TEK */
1470          WriteOnOff(Section, "AutoWinSwitch", FName, ts->AutoWinSwitch);          WriteOnOff(Section, "AutoWinSwitch", FName, ts->AutoWinSwitch);
1471    
1472          /* Terminal ID */          /* Terminal ID */
1473          id2str(TermList, ts->TerminalID, IdVT100, Temp, sizeof(Temp));          id2str(TermList, ts->TerminalID, IdVT100, Temp, sizeof(Temp));
1474          WritePrivateProfileString(Section, "TerminalID", Temp, FName);          WritePrivateProfileString(Section, "TerminalID", Temp, FName);
1475    
1476          /* Russian character set (host)  */          /* Russian character set (host)  */
1477          id2str(RussList, ts->RussHost, IdKOI8, Temp, sizeof(Temp));          id2str(RussList, ts->RussHost, IdKOI8, Temp, sizeof(Temp));
1478          WritePrivateProfileString(Section, "RussHost", Temp, FName);          WritePrivateProfileString(Section, "RussHost", Temp, FName);
1479    
1480          /* Russian character set (client)  */          /* Russian character set (client)  */
1481          id2str(RussList, ts->RussClient, IdWindows, Temp, sizeof(Temp));          id2str(RussList, ts->RussClient, IdWindows, Temp, sizeof(Temp));
1482          WritePrivateProfileString(Section, "RussClient", Temp, FName);          WritePrivateProfileString(Section, "RussClient", Temp, FName);
1483    
1484          /* Title text */          /* Title text */
1485          WritePrivateProfileString(Section, "Title", ts->Title, FName);          WritePrivateProfileString(Section, "Title", ts->Title, FName);
1486    
1487          /* Cursor shape */          /* Cursor shape */
1488          switch (ts->CursorShape) {          switch (ts->CursorShape) {
1489          case IdVCur:          case IdVCur:
1490                  strncpy_s(Temp, sizeof(Temp), "vertical", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "vertical", _TRUNCATE);
1491                  break;                  break;
1492          case IdHCur:          case IdHCur:
1493                  strncpy_s(Temp, sizeof(Temp), "horizontal", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "horizontal", _TRUNCATE);
1494                  break;                  break;
1495          default:          default:
1496                  strncpy_s(Temp, sizeof(Temp), "block", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "block", _TRUNCATE);
1497          }          }
1498          WritePrivateProfileString(Section, "CursorShape", Temp, FName);          WritePrivateProfileString(Section, "CursorShape", Temp, FName);
1499    
1500          /* Hide title */          /* Hide title */
1501          WriteOnOff(Section, "HideTitle", FName, ts->HideTitle);          WriteOnOff(Section, "HideTitle", FName, ts->HideTitle);
1502    
1503          /* Popup menu */          /* Popup menu */
1504          WriteOnOff(Section, "PopupMenu", FName, ts->PopupMenu);          WriteOnOff(Section, "PopupMenu", FName, ts->PopupMenu);
1505    
1506          /* PC-Style bold color mapping */          /* PC-Style bold color mapping */
1507          WriteOnOff(Section, "PcBoldColor", FName,          WriteOnOff(Section, "PcBoldColor", FName,
1508                     (WORD) (ts->ColorFlag & CF_PCBOLD16));                     (WORD) (ts->ColorFlag & CF_PCBOLD16));
1509    
1510          /* aixterm 16 colors mode */          /* aixterm 16 colors mode */
1511          WriteOnOff(Section, "Aixterm16Color", FName,          WriteOnOff(Section, "Aixterm16Color", FName,
1512                     (WORD) (ts->ColorFlag & CF_AIXTERM16));                     (WORD) (ts->ColorFlag & CF_AIXTERM16));
1513    
1514          /* xterm 256 colors mode */          /* xterm 256 colors mode */
1515          WriteOnOff(Section, "Xterm256Color", FName,          WriteOnOff(Section, "Xterm256Color", FName,
1516                     (WORD) (ts->ColorFlag & CF_XTERM256));                     (WORD) (ts->ColorFlag & CF_XTERM256));
1517    
1518          /* Enable scroll buffer */          /* Enable scroll buffer */
1519          WriteOnOff(Section, "EnableScrollBuff", FName, ts->EnableScrollBuff);          WriteOnOff(Section, "EnableScrollBuff", FName, ts->EnableScrollBuff);
1520    
1521          /* Scroll buffer size */          /* Scroll buffer size */
1522          WriteInt(Section, "ScrollBuffSize", FName, ts->ScrollBuffSize);          WriteInt(Section, "ScrollBuffSize", FName, ts->ScrollBuffSize);
1523    
1524          /* VT Color */          /* VT Color */
1525          for (i = 0; i <= 1; i++) {          for (i = 0; i <= 1; i++) {
1526                  if (ts->ColorFlag & CF_REVERSEVIDEO) {                  if (ts->ColorFlag & CF_REVERSEVIDEO) {
1527                          if (ts->ColorFlag & CF_REVERSECOLOR) {                          if (ts->ColorFlag & CF_REVERSECOLOR) {
1528                                  ts->TmpColor[0][i * 3] = GetRValue(ts->VTReverseColor[i]);                                  ts->TmpColor[0][i * 3] = GetRValue(ts->VTReverseColor[i]);
1529                                  ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTReverseColor[i]);                                  ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTReverseColor[i]);
1530                                  ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTReverseColor[i]);                                  ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTReverseColor[i]);
1531                          }                          }
1532                          else {                          else {
1533                                  ts->TmpColor[0][i * 3] = GetRValue(ts->VTColor[!i]);                                  ts->TmpColor[0][i * 3] = GetRValue(ts->VTColor[!i]);
1534                                  ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTColor[!i]);                                  ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTColor[!i]);
1535                                  ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTColor[!i]);                                  ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTColor[!i]);
1536                          }                          }
1537                  }                  }
1538                  else {                  else {
1539                          ts->TmpColor[0][i * 3] = GetRValue(ts->VTColor[i]);                          ts->TmpColor[0][i * 3] = GetRValue(ts->VTColor[i]);
1540                          ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTColor[i]);                          ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTColor[i]);
1541                          ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTColor[i]);                          ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTColor[i]);
1542                  }                  }
1543          }          }
1544          WriteInt6(Section, "VTColor", FName,          WriteInt6(Section, "VTColor", FName,
1545                    ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],                    ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
1546                    ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);                    ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
1547    
1548          /* VT Bold Color */          /* VT Bold Color */
1549          for (i = 0; i <= 1; i++) {          for (i = 0; i <= 1; i++) {
1550                  if (ts->ColorFlag & CF_REVERSEVIDEO) {                  if (ts->ColorFlag & CF_REVERSEVIDEO) {
1551                          ts->TmpColor[0][i * 3] = GetRValue(ts->VTBoldColor[!i]);                          ts->TmpColor[0][i * 3] = GetRValue(ts->VTBoldColor[!i]);
1552                          ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBoldColor[!i]);                          ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBoldColor[!i]);
1553                          ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBoldColor[!i]);                          ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBoldColor[!i]);
1554                  }                  }
1555                  else {                  else {
1556                          ts->TmpColor[0][i * 3] = GetRValue(ts->VTBoldColor[i]);                          ts->TmpColor[0][i * 3] = GetRValue(ts->VTBoldColor[i]);
1557                          ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBoldColor[i]);                          ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBoldColor[i]);
1558                          ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBoldColor[i]);                          ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBoldColor[i]);
1559                  }                  }
1560          }          }
1561          WriteInt6(Section, "VTBoldColor", FName,          WriteInt6(Section, "VTBoldColor", FName,
1562                    ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],                    ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
1563                    ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);                    ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
1564    
1565          /* VT Blink Color */          /* VT Blink Color */
1566          for (i = 0; i <= 1; i++) {          for (i = 0; i <= 1; i++) {
1567                  if (ts->ColorFlag & CF_REVERSEVIDEO) {                  if (ts->ColorFlag & CF_REVERSEVIDEO) {
1568                          ts->TmpColor[0][i * 3] = GetRValue(ts->VTBlinkColor[!i]);                          ts->TmpColor[0][i * 3] = GetRValue(ts->VTBlinkColor[!i]);
1569                          ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBlinkColor[!i]);                          ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBlinkColor[!i]);
1570                          ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBlinkColor[!i]);                          ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBlinkColor[!i]);
1571                  }                  }
1572                  else {                  else {
1573                          ts->TmpColor[0][i * 3] = GetRValue(ts->VTBlinkColor[i]);                          ts->TmpColor[0][i * 3] = GetRValue(ts->VTBlinkColor[i]);
1574                          ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBlinkColor[i]);                          ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBlinkColor[i]);
1575                          ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBlinkColor[i]);                          ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBlinkColor[i]);
1576                  }                  }
1577          }          }
1578          WriteInt6(Section, "VTBlinkColor", FName,          WriteInt6(Section, "VTBlinkColor", FName,
1579                    ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],                    ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
1580                    ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);                    ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
1581    
1582          /* VT Reverse Color */          /* VT Reverse Color */
1583          for (i = 0; i <= 1; i++) {          for (i = 0; i <= 1; i++) {
1584                  if (ts->ColorFlag & CF_REVERSEVIDEO && ts->ColorFlag & CF_REVERSECOLOR) {                  if (ts->ColorFlag & CF_REVERSEVIDEO && ts->ColorFlag & CF_REVERSECOLOR) {
1585                          ts->TmpColor[0][i * 3] = GetRValue(ts->VTColor[i]);                          ts->TmpColor[0][i * 3] = GetRValue(ts->VTColor[i]);
1586                          ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTColor[i]);                          ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTColor[i]);
1587                          ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTColor[i]);                          ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTColor[i]);
1588                  }                  }
1589                  else {                  else {
1590                          ts->TmpColor[0][i * 3] = GetRValue(ts->VTReverseColor[i]);                          ts->TmpColor[0][i * 3] = GetRValue(ts->VTReverseColor[i]);
1591                          ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTReverseColor[i]);                          ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTReverseColor[i]);
1592                          ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTReverseColor[i]);                          ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTReverseColor[i]);
1593                  }                  }
1594          }          }
1595          WriteInt6(Section, "VTReverseColor", FName,          WriteInt6(Section, "VTReverseColor", FName,
1596                    ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],                    ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
1597                    ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);                    ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
1598    
1599          WriteOnOff(Section, "EnableClickableUrl", FName,          WriteOnOff(Section, "EnableClickableUrl", FName,
1600                     ts->EnableClickableUrl);                     ts->EnableClickableUrl);
1601    
1602          /* URL color */          /* URL color */
1603          for (i = 0; i <= 1; i++) {          for (i = 0; i <= 1; i++) {
1604                  if (ts->ColorFlag & CF_REVERSEVIDEO) {                  if (ts->ColorFlag & CF_REVERSEVIDEO) {
1605                          ts->TmpColor[0][i * 3] = GetRValue(ts->URLColor[!i]);                          ts->TmpColor[0][i * 3] = GetRValue(ts->URLColor[!i]);
1606                          ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->URLColor[!i]);                          ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->URLColor[!i]);
1607                          ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->URLColor[!i]);                          ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->URLColor[!i]);
1608                  }                  }
1609                  else {                  else {
1610                          ts->TmpColor[0][i * 3] = GetRValue(ts->URLColor[i]);                          ts->TmpColor[0][i * 3] = GetRValue(ts->URLColor[i]);
1611                          ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->URLColor[i]);                          ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->URLColor[i]);
1612                          ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->URLColor[i]);                          ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->URLColor[i]);
1613                  }                  }
1614          }          }
1615          WriteInt6(Section, "URLColor", FName,          WriteInt6(Section, "URLColor", FName,
1616                    ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],                    ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
1617                    ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);                    ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
1618    
1619          WriteOnOff(Section, "EnableBoldAttrColor", FName,          WriteOnOff(Section, "EnableBoldAttrColor", FName,
1620                     (WORD) (ts->ColorFlag & CF_BOLDCOLOR));                     (WORD) (ts->ColorFlag & CF_BOLDCOLOR));
1621    
1622          WriteOnOff(Section, "EnableBlinkAttrColor", FName,          WriteOnOff(Section, "EnableBlinkAttrColor", FName,
1623                     (WORD) (ts->ColorFlag & CF_BLINKCOLOR));                     (WORD) (ts->ColorFlag & CF_BLINKCOLOR));
1624    
1625          WriteOnOff(Section, "EnableReverseAttrColor", FName,          WriteOnOff(Section, "EnableReverseAttrColor", FName,
1626                     (WORD) (ts->ColorFlag & CF_REVERSECOLOR));                     (WORD) (ts->ColorFlag & CF_REVERSECOLOR));
1627    
1628          WriteOnOff(Section, "EnableURLColor", FName,          WriteOnOff(Section, "EnableURLColor", FName,
1629                     (WORD) (ts->ColorFlag & CF_URLCOLOR));                     (WORD) (ts->ColorFlag & CF_URLCOLOR));
1630    
1631          WriteOnOff(Section, "EnableANSIColor", FName,          WriteOnOff(Section, "EnableANSIColor", FName,
1632                     (WORD) (ts->ColorFlag & CF_ANSICOLOR));                     (WORD) (ts->ColorFlag & CF_ANSICOLOR));
1633    
1634          /* TEK Color */          /* TEK Color */
1635          for (i = 0; i <= 1; i++) {          for (i = 0; i <= 1; i++) {
1636                  ts->TmpColor[0][i * 3] = GetRValue(ts->TEKColor[i]);                  ts->TmpColor[0][i * 3] = GetRValue(ts->TEKColor[i]);
1637                  ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->TEKColor[i]);                  ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->TEKColor[i]);
1638                  ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->TEKColor[i]);                  ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->TEKColor[i]);
1639          }          }
1640          WriteInt6(Section, "TEKColor", FName,          WriteInt6(Section, "TEKColor", FName,
1641                    ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],                    ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
1642                    ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);                    ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
1643    
1644          /* TEK color emulation */          /* TEK color emulation */
1645          WriteOnOff(Section, "TEKColorEmulation", FName, ts->TEKColorEmu);          WriteOnOff(Section, "TEKColorEmulation", FName, ts->TEKColorEmu);
1646    
1647          /* VT Font */          /* VT Font */
1648          WriteFont(Section, "VTFont", FName,          WriteFont(Section, "VTFont", FName,
1649                    ts->VTFont, ts->VTFontSize.x, ts->VTFontSize.y,                    ts->VTFont, ts->VTFontSize.x, ts->VTFontSize.y,
1650                    ts->VTFontCharSet);                    ts->VTFontCharSet);
1651    
1652          /* Enable bold font flag */          /* Enable bold font flag */
1653          WriteOnOff(Section, "EnableBold", FName, ts->EnableBold);          WriteOnOff(Section, "EnableBold", FName, ts->EnableBold);
1654    
1655          /* Russian character set (font) */          /* Russian character set (font) */
1656          id2str(RussList, ts->RussFont, IdWindows, Temp, sizeof(Temp));          id2str(RussList, ts->RussFont, IdWindows, Temp, sizeof(Temp));
1657          WritePrivateProfileString(Section, "RussFont", Temp, FName);          WritePrivateProfileString(Section, "RussFont", Temp, FName);
1658    
1659          /* TEK Font */          /* TEK Font */
1660          WriteFont(Section, "TEKFont", FName,          WriteFont(Section, "TEKFont", FName,
1661                    ts->TEKFont, ts->TEKFontSize.x, ts->TEKFontSize.y,                    ts->TEKFont, ts->TEKFontSize.x, ts->TEKFontSize.y,
1662                    ts->TEKFontCharSet);                    ts->TEKFontCharSet);
1663    
1664          /* BS key */          /* BS key */
1665          if (ts->BSKey == IdDEL)          if (ts->BSKey == IdDEL)
1666                  strncpy_s(Temp, sizeof(Temp), "DEL", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "DEL", _TRUNCATE);
1667          else          else
1668                  strncpy_s(Temp, sizeof(Temp), "BS", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "BS", _TRUNCATE);
1669          WritePrivateProfileString(Section, "BSKey", Temp, FName);          WritePrivateProfileString(Section, "BSKey", Temp, FName);
1670    
1671          /* Delete key */          /* Delete key */
1672          WriteOnOff(Section, "DeleteKey", FName, ts->DelKey);          WriteOnOff(Section, "DeleteKey", FName, ts->DelKey);
1673    
1674          /* Meta key */          /* Meta key */
1675          WriteOnOff(Section, "MetaKey", FName, ts->MetaKey);          WriteOnOff(Section, "MetaKey", FName, ts->MetaKey);
1676    
1677          /* Application Keypad */          /* Application Keypad */
1678          WriteOnOff(Section, "DisableAppKeypad", FName, ts->DisableAppKeypad);          WriteOnOff(Section, "DisableAppKeypad", FName, ts->DisableAppKeypad);
1679    
1680          /* Application Cursor */          /* Application Cursor */
1681          WriteOnOff(Section, "DisableAppCursor", FName, ts->DisableAppCursor);          WriteOnOff(Section, "DisableAppCursor", FName, ts->DisableAppCursor);
1682    
1683          /* Russian keyboard type */          /* Russian keyboard type */
1684          id2str(RussList2, ts->RussKeyb, IdWindows, Temp, sizeof(Temp));          id2str(RussList2, ts->RussKeyb, IdWindows, Temp, sizeof(Temp));
1685          WritePrivateProfileString(Section, "RussKeyb", Temp, FName);          WritePrivateProfileString(Section, "RussKeyb", Temp, FName);
1686    
1687          /* Serial port ID */          /* Serial port ID */
1688          _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->ComPort);          _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->ComPort);
1689          WritePrivateProfileString(Section, "ComPort", Temp, FName);          WritePrivateProfileString(Section, "ComPort", Temp, FName);
1690    
1691          /* Baud rate */          /* Baud rate */
1692          id2str(BaudList, ts->Baud, IdBaud9600, Temp, sizeof(Temp));          id2str(BaudList, ts->Baud, IdBaud9600, Temp, sizeof(Temp));
1693          WritePrivateProfileString(Section, "BaudRate", Temp, FName);          WritePrivateProfileString(Section, "BaudRate", Temp, FName);
1694    
1695          /* Parity */          /* Parity */
1696          switch (ts->Parity) {          switch (ts->Parity) {
1697          case IdParityEven:          case IdParityEven:
1698                  strncpy_s(Temp, sizeof(Temp), "even", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "even", _TRUNCATE);
1699                  break;                  break;
1700          case IdParityOdd:          case IdParityOdd:
1701                  strncpy_s(Temp, sizeof(Temp), "odd", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "odd", _TRUNCATE);
1702                  break;                  break;
1703          default:          default:
1704                  strncpy_s(Temp, sizeof(Temp), "none", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "none", _TRUNCATE);
1705          }          }
1706          WritePrivateProfileString(Section, "Parity", Temp, FName);          WritePrivateProfileString(Section, "Parity", Temp, FName);
1707    
1708          /* Data bit */          /* Data bit */
1709          if (ts->DataBit == IdDataBit7)          if (ts->DataBit == IdDataBit7)
1710                  strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
1711          else          else
1712                  strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
1713    
1714          WritePrivateProfileString(Section, "DataBit", Temp, FName);          WritePrivateProfileString(Section, "DataBit", Temp, FName);
1715    
1716          /* Stop bit */          /* Stop bit */
1717          if (ts->StopBit == IdStopBit2)          if (ts->StopBit == IdStopBit2)
1718                  strncpy_s(Temp, sizeof(Temp), "2", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "2", _TRUNCATE);
1719          else          else
1720                  strncpy_s(Temp, sizeof(Temp), "1", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "1", _TRUNCATE);
1721    
1722          WritePrivateProfileString(Section, "StopBit", Temp, FName);          WritePrivateProfileString(Section, "StopBit", Temp, FName);
1723    
1724          /* Flow control */          /* Flow control */
1725          switch (ts->Flow) {          switch (ts->Flow) {
1726          case IdFlowX:          case IdFlowX:
1727                  strncpy_s(Temp, sizeof(Temp), "x", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "x", _TRUNCATE);
1728                  break;                  break;
1729          case IdFlowHard:          case IdFlowHard:
1730                  strncpy_s(Temp, sizeof(Temp), "hard", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "hard", _TRUNCATE);
1731                  break;                  break;
1732          default:          default:
1733                  strncpy_s(Temp, sizeof(Temp), "none", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "none", _TRUNCATE);
1734          }          }
1735          WritePrivateProfileString(Section, "FlowCtrl", Temp, FName);          WritePrivateProfileString(Section, "FlowCtrl", Temp, FName);
1736    
1737          /* Delay per character */          /* Delay per character */
1738          WriteInt(Section, "DelayPerChar", FName, ts->DelayPerChar);          WriteInt(Section, "DelayPerChar", FName, ts->DelayPerChar);
1739    
1740          /* Delay per line */          /* Delay per line */
1741          WriteInt(Section, "DelayPerLine", FName, ts->DelayPerLine);          WriteInt(Section, "DelayPerLine", FName, ts->DelayPerLine);
1742    
1743          /* Telnet flag */          /* Telnet flag */
1744          WriteOnOff(Section, "Telnet", FName, ts->Telnet);          WriteOnOff(Section, "Telnet", FName, ts->Telnet);
1745    
1746          /* Telnet terminal type */          /* Telnet terminal type */
1747          WritePrivateProfileString(Section, "TermType", ts->TermType, FName);          WritePrivateProfileString(Section, "TermType", ts->TermType, FName);
1748    
1749          /* TCP port num for non-telnet */          /* TCP port num for non-telnet */
1750          WriteUint(Section, "TCPPort", FName, ts->TCPPort);          WriteUint(Section, "TCPPort", FName, ts->TCPPort);
1751    
1752          /* Auto close flag */          /* Auto close flag */
1753          WriteOnOff(Section, "AutoWinClose", FName, ts->AutoWinClose);          WriteOnOff(Section, "AutoWinClose", FName, ts->AutoWinClose);
1754    
1755          /* History list */          /* History list */
1756          WriteOnOff(Section, "Historylist", FName, ts->HistoryList);          WriteOnOff(Section, "Historylist", FName, ts->HistoryList);
1757    
1758          /* File transfer binary flag */          /* File transfer binary flag */
1759          WriteOnOff(Section, "TransBin", FName, ts->TransBin);          WriteOnOff(Section, "TransBin", FName, ts->TransBin);
1760    
1761          /* Log append */          /* Log append */
1762          WriteOnOff(Section, "LogAppend", FName, ts->Append);          WriteOnOff(Section, "LogAppend", FName, ts->Append);
1763    
1764          /* File transfer binary flag */          /* File transfer binary flag */
1765          WriteOnOff(Section, "LogTypePlainText", FName, ts->LogTypePlainText);          WriteOnOff(Section, "LogTypePlainText", FName, ts->LogTypePlainText);
1766    
1767          /* Log with timestamp (2006.7.23 maya) */          /* Log with timestamp (2006.7.23 maya) */
1768          WriteOnOff(Section, "LogTimestamp", FName, ts->LogTimestamp);          WriteOnOff(Section, "LogTimestamp", FName, ts->LogTimestamp);
1769    
1770          /* Log without transfer dialog */          /* Log without transfer dialog */
1771          WriteOnOff(Section, "LogHideDialog", FName, ts->LogHideDialog);          WriteOnOff(Section, "LogHideDialog", FName, ts->LogHideDialog);
1772    
1773          /* Default Log file name (2006.8.28 maya) */          /* Default Log file name (2006.8.28 maya) */
1774          WritePrivateProfileString(Section, "LogDefaultName",          WritePrivateProfileString(Section, "LogDefaultName",
1775                                    ts->LogDefaultName, FName);                                    ts->LogDefaultName, FName);
1776    
1777          /* Default Log file path (2007.5.30 maya) */          /* Default Log file path (2007.5.30 maya) */
1778          WritePrivateProfileString(Section, "LogDefaultPath",          WritePrivateProfileString(Section, "LogDefaultPath",
1779                                    ts->LogDefaultPath, FName);                                    ts->LogDefaultPath, FName);
1780    
1781          /* Auto start logging (2007.5.31 maya) */          /* Auto start logging (2007.5.31 maya) */
1782          WriteOnOff(Section, "LogAutoStart", FName, ts->LogAutoStart);          WriteOnOff(Section, "LogAutoStart", FName, ts->LogAutoStart);
1783    
1784          /* XMODEM option */          /* XMODEM option */
1785          switch (ts->XmodemOpt) {          switch (ts->XmodemOpt) {
1786          case XoptCRC:          case XoptCRC:
1787                  strncpy_s(Temp, sizeof(Temp), "crc", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "crc", _TRUNCATE);
1788                  break;                  break;
1789          case Xopt1K:          case Xopt1K:
1790                  strncpy_s(Temp, sizeof(Temp), "1k", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "1k", _TRUNCATE);
1791                  break;                  break;
1792          default:          default:
1793                  strncpy_s(Temp, sizeof(Temp), "checksum", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "checksum", _TRUNCATE);
1794          }          }
1795          WritePrivateProfileString(Section, "XmodemOpt", Temp, FName);          WritePrivateProfileString(Section, "XmodemOpt", Temp, FName);
1796    
1797          /* XMODEM binary flag */          /* XMODEM binary flag */
1798          WriteOnOff(Section, "XmodemBin", FName, ts->XmodemBin);          WriteOnOff(Section, "XmodemBin", FName, ts->XmodemBin);
1799    
1800          /* XMODEM 受信コマンド (2007.12.21 yutaka) */          /* XMODEM 受信コマンド (2007.12.21 yutaka) */
1801          WritePrivateProfileString(Section, "XmodemRcvCommand",          WritePrivateProfileString(Section, "XmodemRcvCommand",
1802                                    ts->XModemRcvCommand, FName);                                    ts->XModemRcvCommand, FName);
1803    
1804          /* Default directory for file transfer */          /* Default directory for file transfer */
1805          WritePrivateProfileString(Section, "FileDir", ts->FileDir, FName);          WritePrivateProfileString(Section, "FileDir", ts->FileDir, FName);
1806    
1807          /* filter on file send (2007.6.5 maya) */          /* filter on file send (2007.6.5 maya) */
1808          WritePrivateProfileString(Section, "FileSendFilter",          WritePrivateProfileString(Section, "FileSendFilter",
1809                                    ts->FileSendFilter, FName);                                    ts->FileSendFilter, FName);
1810    
1811  /*------------------------------------------------------------------*/  /*------------------------------------------------------------------*/
1812          /* 8 bit control code flag  -- special option */          /* 8 bit control code flag  -- special option */
1813          WriteOnOff(Section, "Accept8BitCtrl", FName,          WriteOnOff(Section, "Accept8BitCtrl", FName,
1814                     (WORD) (ts->TermFlag & TF_ACCEPT8BITCTRL));                     (WORD) (ts->TermFlag & TF_ACCEPT8BITCTRL));
1815    
1816          /* Wrong sequence flag  -- special option */          /* Wrong sequence flag  -- special option */
1817          WriteOnOff(Section, "AllowWrongSequence", FName,          WriteOnOff(Section, "AllowWrongSequence", FName,
1818                     (WORD) (ts->TermFlag & TF_ALLOWWRONGSEQUENCE));                     (WORD) (ts->TermFlag & TF_ALLOWWRONGSEQUENCE));
1819    
1820          /* Auto file renaming --- special option */          /* Auto file renaming --- special option */
1821          WriteOnOff(Section, "AutoFileRename", FName,          WriteOnOff(Section, "AutoFileRename", FName,
1822                     (WORD) (ts->FTFlag & FT_RENAME));                     (WORD) (ts->FTFlag & FT_RENAME));
1823    
1824          /* Auto text copy --- special option */          /* Auto text copy --- special option */
1825          WriteOnOff(Section, "AutoTextCopy", FName, ts->AutoTextCopy);          WriteOnOff(Section, "AutoTextCopy", FName, ts->AutoTextCopy);
1826    
1827          /* Back wrap -- special option */          /* Back wrap -- special option */
1828          WriteOnOff(Section, "BackWrap", FName,          WriteOnOff(Section, "BackWrap", FName,
1829                     (WORD) (ts->TermFlag & TF_BACKWRAP));                     (WORD) (ts->TermFlag & TF_BACKWRAP));
1830    
1831          /* Beep type -- special option */          /* Beep type -- special option */
1832          WriteOnOff(Section, "Beep", FName, ts->Beep);          WriteOnOff(Section, "Beep", FName, ts->Beep);
1833          switch (ts->Beep) {          switch (ts->Beep) {
1834          case IdBeepOff:          case IdBeepOff:
1835                  WritePrivateProfileString(Section, "Beep", "Off", FName);                  WritePrivateProfileString(Section, "Beep", "Off", FName);
1836                  break;                  break;
1837          case IdBeepOn:          case IdBeepOn:
1838                  WritePrivateProfileString(Section, "Beep", "On", FName);                  WritePrivateProfileString(Section, "Beep", "On", FName);
1839                  break;                  break;
1840          case IdBeepVisual:          case IdBeepVisual:
1841                  WritePrivateProfileString(Section, "Beep", "Visual", FName);                  WritePrivateProfileString(Section, "Beep", "Visual", FName);
1842                  break;                  break;
1843          }          }
1844    
1845          /* Beep on connection & disconnection -- special option */          /* Beep on connection & disconnection -- special option */
1846          WriteOnOff(Section, "BeepOnConnect", FName,          WriteOnOff(Section, "BeepOnConnect", FName,
1847                     (WORD) (ts->PortFlag & PF_BEEPONCONNECT));                     (WORD) (ts->PortFlag & PF_BEEPONCONNECT));
1848    
1849          /* Auto B-Plus activation -- special option */          /* Auto B-Plus activation -- special option */
1850          WriteOnOff(Section, "BPAuto", FName, (WORD) (ts->FTFlag & FT_BPAUTO));          WriteOnOff(Section, "BPAuto", FName, (WORD) (ts->FTFlag & FT_BPAUTO));
1851    
1852          /* B-Plus ESCCTL flag  -- special option */          /* B-Plus ESCCTL flag  -- special option */
1853          WriteOnOff(Section, "BPEscCtl", FName,          WriteOnOff(Section, "BPEscCtl", FName,
1854                     (WORD) (ts->FTFlag & FT_BPESCCTL));                     (WORD) (ts->FTFlag & FT_BPESCCTL));
1855    
1856          /* B-Plus log  -- special option */          /* B-Plus log  -- special option */
1857          WriteOnOff(Section, "BPLog", FName, (WORD) (ts->LogFlag & LOG_BP));          WriteOnOff(Section, "BPLog", FName, (WORD) (ts->LogFlag & LOG_BP));
1858    
1859          /* Clear serial port buffer when port opening -- special option */          /* Clear serial port buffer when port opening -- special option */
1860          WriteOnOff(Section, "ClearComBuffOnOpen", FName, ts->ClearComBuffOnOpen);          WriteOnOff(Section, "ClearComBuffOnOpen", FName, ts->ClearComBuffOnOpen);
1861    
1862          /* Confirm disconnection -- special option */          /* Confirm disconnection -- special option */
1863          WriteOnOff(Section, "ConfirmDisconnect", FName,          WriteOnOff(Section, "ConfirmDisconnect", FName,
1864                     (WORD) (ts->PortFlag & PF_CONFIRMDISCONN));                     (WORD) (ts->PortFlag & PF_CONFIRMDISCONN));
1865    
1866          /* Ctrl code in Kanji -- special option */          /* Ctrl code in Kanji -- special option */
1867          WriteOnOff(Section, "CtrlInKanji", FName,          WriteOnOff(Section, "CtrlInKanji", FName,
1868                     (WORD) (ts->TermFlag & TF_CTRLINKANJI));                     (WORD) (ts->TermFlag & TF_CTRLINKANJI));
1869    
1870          /* Debug flag  -- special option */          /* Debug flag  -- special option */
1871          WriteOnOff(Section, "Debug", FName, ts->Debug);          WriteOnOff(Section, "Debug", FName, ts->Debug);
1872    
1873          /* Delimiter list -- special option */          /* Delimiter list -- special option */
1874          Str2Hex(ts->DelimList, Temp, strlen(ts->DelimList),          Str2Hex(ts->DelimList, Temp, strlen(ts->DelimList),
1875                  sizeof(Temp) - 1, TRUE);                  sizeof(Temp) - 1, TRUE);
1876          WritePrivateProfileString(Section, "DelimList", Temp, FName);          WritePrivateProfileString(Section, "DelimList", Temp, FName);
1877    
1878          /* regard DBCS characters as delimiters -- special option */          /* regard DBCS characters as delimiters -- special option */
1879          WriteOnOff(Section, "DelimDBCS", FName, ts->DelimDBCS);          WriteOnOff(Section, "DelimDBCS", FName, ts->DelimDBCS);
1880    
1881          // Enable popup menu -- special option          // Enable popup menu -- special option
1882          if ((ts->MenuFlag & MF_NOPOPUP) == 0)          if ((ts->MenuFlag & MF_NOPOPUP) == 0)
1883                  WriteOnOff(Section, "EnablePopupMenu", FName, 1);                  WriteOnOff(Section, "EnablePopupMenu", FName, 1);
1884          else          else
1885                  WriteOnOff(Section, "EnablePopupMenu", FName, 0);                  WriteOnOff(Section, "EnablePopupMenu", FName, 0);
1886    
1887          // Enable "Show menu" -- special option          // Enable "Show menu" -- special option
1888          if ((ts->MenuFlag & MF_NOSHOWMENU) == 0)          if ((ts->MenuFlag & MF_NOSHOWMENU) == 0)
1889                  WriteOnOff(Section, "EnableShowMenu", FName, 1);                  WriteOnOff(Section, "EnableShowMenu", FName, 1);
1890          else          else
1891                  WriteOnOff(Section, "EnableShowMenu", FName, 0);                  WriteOnOff(Section, "EnableShowMenu", FName, 0);
1892    
1893          /* Enable the status line -- special option */          /* Enable the status line -- special option */
1894          WriteOnOff(Section, "EnableStatusLine", FName,          WriteOnOff(Section, "EnableStatusLine", FName,
1895                     (WORD) (ts->TermFlag & TF_ENABLESLINE));                     (WORD) (ts->TermFlag & TF_ENABLESLINE));
1896    
1897          /* IME Flag  -- special option */          /* IME Flag  -- special option */
1898          WriteOnOff(Section, "IME", FName, ts->UseIME);          WriteOnOff(Section, "IME", FName, ts->UseIME);
1899    
1900          /* IME-inline Flag  -- special option */          /* IME-inline Flag  -- special option */
1901          WriteOnOff(Section, "IMEInline", FName, ts->IMEInline);          WriteOnOff(Section, "IMEInline", FName, ts->IMEInline);
1902    
1903          /* Kermit log  -- special option */          /* Kermit log  -- special option */
1904          WriteOnOff(Section, "KmtLog", FName, (WORD) (ts->LogFlag & LOG_KMT));          WriteOnOff(Section, "KmtLog", FName, (WORD) (ts->LogFlag & LOG_KMT));
1905    
1906          // Enable language selection -- special option          // Enable language selection -- special option
1907          if ((ts->MenuFlag & MF_NOLANGUAGE) == 0)          if ((ts->MenuFlag & MF_NOLANGUAGE) == 0)
1908                  WriteOnOff(Section, "LanguageSelection", FName, 1);                  WriteOnOff(Section, "LanguageSelection", FName, 1);
1909          else          else
1910                  WriteOnOff(Section, "LanguageSelection", FName, 0);                  WriteOnOff(Section, "LanguageSelection", FName, 0);
1911    
1912          /* Maximum scroll buffer size  -- special option */          /* Maximum scroll buffer size  -- special option */
1913          WriteInt(Section, "MaxBuffSize", FName, ts->ScrollBuffMax);          WriteInt(Section, "MaxBuffSize", FName, ts->ScrollBuffMax);
1914    
1915          /* Max com port number -- special option */          /* Max com port number -- special option */
1916          WriteInt(Section, "MaxComPort", FName, ts->MaxComPort);          WriteInt(Section, "MaxComPort", FName, ts->MaxComPort);
1917    
1918          /* Non-blinking cursor -- special option */          /* Non-blinking cursor -- special option */
1919          WriteOnOff(Section, "NonblinkingCursor", FName, ts->NonblinkingCursor);          WriteOnOff(Section, "NonblinkingCursor", FName, ts->NonblinkingCursor);
1920    
1921          WriteOnOff(Section, "KillFocusCursor", FName, ts->KillFocusCursor);          WriteOnOff(Section, "KillFocusCursor", FName, ts->KillFocusCursor);
1922    
1923          /* Delay for pass-thru printing activation */          /* Delay for pass-thru printing activation */
1924          /*   -- special option */          /*   -- special option */
1925          WriteUint(Section, "PassThruDelay", FName, ts->PassThruDelay);          WriteUint(Section, "PassThruDelay", FName, ts->PassThruDelay);
1926    
1927          /* Printer port for pass-thru printing */          /* Printer port for pass-thru printing */
1928          /*   -- special option */          /*   -- special option */
1929          WritePrivateProfileString(Section, "PassThruPort", ts->PrnDev, FName);          WritePrivateProfileString(Section, "PassThruPort", ts->PrnDev, FName);
1930    
1931          /* Printer Font --- special option */          /* Printer Font --- special option */
1932          WriteFont(Section, "PrnFont", FName,          WriteFont(Section, "PrnFont", FName,
1933                    ts->PrnFont, ts->PrnFontSize.x, ts->PrnFontSize.y,                    ts->PrnFont, ts->PrnFontSize.x, ts->PrnFontSize.y,
1934                    ts->PrnFontCharSet);                    ts->PrnFontCharSet);
1935    
1936          // Page margins (left, right, top, bottom) for printing          // Page margins (left, right, top, bottom) for printing
1937          //    -- special option          //    -- special option
1938          WriteInt4(Section, "PrnMargin", FName,          WriteInt4(Section, "PrnMargin", FName,
1939                    ts->PrnMargin[0], ts->PrnMargin[1],                    ts->PrnMargin[0], ts->PrnMargin[1],
1940                    ts->PrnMargin[2], ts->PrnMargin[3]);                    ts->PrnMargin[2], ts->PrnMargin[3]);
1941    
1942          /* Quick-VAN log  -- special option */          /* Quick-VAN log  -- special option */
1943          WriteOnOff(Section, "QVLog", FName, (WORD) (ts->LogFlag & LOG_QV));          WriteOnOff(Section, "QVLog", FName, (WORD) (ts->LogFlag & LOG_QV));
1944    
1945          /* Quick-VAN window size -- special */          /* Quick-VAN window size -- special */
1946          WriteInt(Section, "QVWinSize", FName, ts->QVWinSize);          WriteInt(Section, "QVWinSize", FName, ts->QVWinSize);
1947    
1948          /* Russian character set (print) -- special option */          /* Russian character set (print) -- special option */
1949          id2str(RussList, ts->RussPrint, IdWindows, Temp, sizeof(Temp));          id2str(RussList, ts->RussPrint, IdWindows, Temp, sizeof(Temp));
1950          WritePrivateProfileString(Section, "RussPrint", Temp, FName);          WritePrivateProfileString(Section, "RussPrint", Temp, FName);
1951    
1952          /* Scroll threshold -- special option */          /* Scroll threshold -- special option */
1953          WriteInt(Section, "ScrollThreshold", FName, ts->ScrollThreshold);          WriteInt(Section, "ScrollThreshold", FName, ts->ScrollThreshold);
1954    
1955          WriteInt(Section, "MouseWheelScrollLine", FName, ts->MouseWheelScrollLine);          WriteInt(Section, "MouseWheelScrollLine", FName, ts->MouseWheelScrollLine);
1956    
1957          // Select on activate -- special option          // Select on activate -- special option
1958          WriteOnOff(Section, "SelectOnActivate", FName, ts->SelOnActive);          WriteOnOff(Section, "SelectOnActivate", FName, ts->SelOnActive);
1959    
1960          /* Send 8bit control sequence -- special option */          /* Send 8bit control sequence -- special option */
1961          WriteOnOff(Section, "Send8BitCtrl", FName, ts->Send8BitCtrl);          WriteOnOff(Section, "Send8BitCtrl", FName, ts->Send8BitCtrl);
1962    
1963          /* Startup macro -- special option */          /* Startup macro -- special option */
1964          WritePrivateProfileString(Section, "StartupMacro", ts->MacroFN, FName);          WritePrivateProfileString(Section, "StartupMacro", ts->MacroFN, FName);
1965    
1966          /* TEK GIN Mouse keycode -- special option */          /* TEK GIN Mouse keycode -- special option */
1967          WriteInt(Section, "TEKGINMouseCode", FName, ts->GINMouseCode);          WriteInt(Section, "TEKGINMouseCode", FName, ts->GINMouseCode);
1968    
1969          /* Telnet Auto Detect -- special option */          /* Telnet Auto Detect -- special option */
1970          WriteOnOff(Section, "TelAutoDetect", FName, ts->TelAutoDetect);          WriteOnOff(Section, "TelAutoDetect", FName, ts->TelAutoDetect);
1971    
1972          /* Telnet binary flag -- special option */          /* Telnet binary flag -- special option */
1973          WriteOnOff(Section, "TelBin", FName, ts->TelBin);          WriteOnOff(Section, "TelBin", FName, ts->TelBin);
1974    
1975          /* Telnet Echo flag -- special option */          /* Telnet Echo flag -- special option */
1976          WriteOnOff(Section, "TelEcho", FName, ts->TelEcho);          WriteOnOff(Section, "TelEcho", FName, ts->TelEcho);
1977    
1978          /* Telnet log  -- special option */          /* Telnet log  -- special option */
1979          WriteOnOff(Section, "TelLog", FName, (WORD) (ts->LogFlag & LOG_TEL));          WriteOnOff(Section, "TelLog", FName, (WORD) (ts->LogFlag & LOG_TEL));
1980    
1981          /* TCP port num for telnet -- special option */          /* TCP port num for telnet -- special option */
1982          WriteUint(Section, "TelPort", FName, ts->TelPort);          WriteUint(Section, "TelPort", FName, ts->TelPort);
1983    
1984          /* Telnet keep-alive packet(NOP command) interval -- special option */          /* Telnet keep-alive packet(NOP command) interval -- special option */
1985          WriteUint(Section, "TelKeepAliveInterval", FName,          WriteUint(Section, "TelKeepAliveInterval", FName,
1986                    ts->TelKeepAliveInterval);                    ts->TelKeepAliveInterval);
1987    
1988          /* Max number of broadcast commad history */          /* Max number of broadcast commad history */
1989          WriteUint(Section, "MaxBroadcatHistory", FName,          WriteUint(Section, "MaxBroadcatHistory", FName,
1990                    ts->MaxBroadcatHistory);                    ts->MaxBroadcatHistory);
1991    
1992          /* Local echo for non-telnet */          /* Local echo for non-telnet */
1993          WriteOnOff(Section, "TCPLocalEcho", FName, ts->TCPLocalEcho);          WriteOnOff(Section, "TCPLocalEcho", FName, ts->TCPLocalEcho);
1994    
1995          /* "new-line (transmit)" option for non-telnet -- special option */          /* "new-line (transmit)" option for non-telnet -- special option */
1996          if (ts->TCPCRSend == IdCRLF)          if (ts->TCPCRSend == IdCRLF)
1997                  strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
1998          else if (ts->TCPCRSend == IdCR)          else if (ts->TCPCRSend == IdCR)
1999                  strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
2000          else          else
2001                  Temp[0] = 0;                  Temp[0] = 0;
2002          WritePrivateProfileString(Section, "TCPCRSend", Temp, FName);          WritePrivateProfileString(Section, "TCPCRSend", Temp, FName);
2003    
2004          /* Use text (background) color for "white (black)"          /* Use text (background) color for "white (black)"
2005             --- special option */             --- special option */
2006          WriteOnOff(Section, "UseTextColor", FName,          WriteOnOff(Section, "UseTextColor", FName,
2007                     (WORD) (ts->ColorFlag & CF_USETEXTCOLOR));                     (WORD) (ts->ColorFlag & CF_USETEXTCOLOR));
2008    
2009          /* Title format -- special option */          /* Title format -- special option */
2010          WriteUint(Section, "TitleFormat", FName, ts->TitleFormat);          WriteUint(Section, "TitleFormat", FName, ts->TitleFormat);
2011    
2012          /* VT Compatible Tab -- special option */          /* VT Compatible Tab -- special option */
2013          WriteOnOff(Section, "VTCompatTab", FName, ts->VTCompatTab);          WriteOnOff(Section, "VTCompatTab", FName, ts->VTCompatTab);
2014    
2015          /* VT Font space --- special option */          /* VT Font space --- special option */
2016          WriteInt4(Section, "VTFontSpace", FName,          WriteInt4(Section, "VTFontSpace", FName,
2017                    ts->FontDX, ts->FontDW - ts->FontDX,                    ts->FontDX, ts->FontDW - ts->FontDX,
2018                    ts->FontDY, ts->FontDH - ts->FontDY);                    ts->FontDY, ts->FontDH - ts->FontDY);
2019    
2020          // VT-print scaling factors (pixels per inch) --- special option          // VT-print scaling factors (pixels per inch) --- special option
2021          WriteInt2(Section, "VTPPI", FName, ts->VTPPI.x, ts->VTPPI.y);          WriteInt2(Section, "VTPPI", FName, ts->VTPPI.x, ts->VTPPI.y);
2022    
2023          // TEK-print scaling factors (pixels per inch) --- special option          // TEK-print scaling factors (pixels per inch) --- special option
2024          WriteInt2(Section, "TEKPPI", FName, ts->TEKPPI.x, ts->TEKPPI.y);          WriteInt2(Section, "TEKPPI", FName, ts->TEKPPI.x, ts->TEKPPI.y);
2025    
2026          // Show "Window" menu -- special option          // Show "Window" menu -- special option
2027          WriteOnOff(Section, "WindowMenu", FName,          WriteOnOff(Section, "WindowMenu", FName,
2028                     (WORD) (ts->MenuFlag & MF_SHOWWINMENU));                     (WORD) (ts->MenuFlag & MF_SHOWWINMENU));
2029    
2030          /* XMODEM log  -- special option */          /* XMODEM log  -- special option */
2031          WriteOnOff(Section, "XmodemLog", FName, (WORD) (ts->LogFlag & LOG_X));          WriteOnOff(Section, "XmodemLog", FName, (WORD) (ts->LogFlag & LOG_X));
2032    
2033          /* YMODEM log  -- special option */          /* YMODEM log  -- special option */
2034          WriteOnOff(Section, "YmodemLog", FName, (WORD) (ts->LogFlag & LOG_Y));          WriteOnOff(Section, "YmodemLog", FName, (WORD) (ts->LogFlag & LOG_Y));
2035    
2036          /* Auto ZMODEM activation -- special option */          /* Auto ZMODEM activation -- special option */
2037          WriteOnOff(Section, "ZmodemAuto", FName,          WriteOnOff(Section, "ZmodemAuto", FName,
2038                     (WORD) (ts->FTFlag & FT_ZAUTO));                     (WORD) (ts->FTFlag & FT_ZAUTO));
2039    
2040          /* ZMODEM data subpacket length for sending -- special */          /* ZMODEM data subpacket length for sending -- special */
2041          WriteInt(Section, "ZmodemDataLen", FName, ts->ZmodemDataLen);          WriteInt(Section, "ZmodemDataLen", FName, ts->ZmodemDataLen);
2042          /* ZMODEM window size for sending -- special */          /* ZMODEM window size for sending -- special */
2043          WriteInt(Section, "ZmodemWinSize", FName, ts->ZmodemWinSize);          WriteInt(Section, "ZmodemWinSize", FName, ts->ZmodemWinSize);
2044    
2045          /* ZMODEM ESCCTL flag  -- special option */          /* ZMODEM ESCCTL flag  -- special option */
2046          WriteOnOff(Section, "ZmodemEscCtl", FName,          WriteOnOff(Section, "ZmodemEscCtl", FName,
2047                     (WORD) (ts->FTFlag & FT_ZESCCTL));                     (WORD) (ts->FTFlag & FT_ZESCCTL));
2048    
2049          /* ZMODEM log  -- special option */          /* ZMODEM log  -- special option */
2050          WriteOnOff(Section, "ZmodemLog", FName, (WORD) (ts->LogFlag & LOG_Z));          WriteOnOff(Section, "ZmodemLog", FName, (WORD) (ts->LogFlag & LOG_Z));
2051    
2052          /* ZMODEM 受信コマンド (2007.12.21 yutaka) */          /* ZMODEM 受信コマンド (2007.12.21 yutaka) */
2053          WritePrivateProfileString(Section, "ZmodemRcvCommand", ts->ZModemRcvCommand, FName);          WritePrivateProfileString(Section, "ZmodemRcvCommand", ts->ZModemRcvCommand, FName);
2054    
2055          /* update file */          /* update file */
2056          WritePrivateProfileString(NULL, NULL, NULL, FName);          WritePrivateProfileString(NULL, NULL, NULL, FName);
2057    
2058          // Eterm lookfeel alphablend (2005.4.24 yutaka)          // Eterm lookfeel alphablend (2005.4.24 yutaka)
2059  #define ETERM_SECTION "BG"  #define ETERM_SECTION "BG"
2060          WriteOnOff(ETERM_SECTION, "BGEnable", FName,          WriteOnOff(ETERM_SECTION, "BGEnable", FName,
2061                     ts->EtermLookfeel.BGEnable);                     ts->EtermLookfeel.BGEnable);
2062          WriteOnOff(ETERM_SECTION, "BGUseAlphaBlendAPI", FName,          WriteOnOff(ETERM_SECTION, "BGUseAlphaBlendAPI", FName,
2063                     ts->EtermLookfeel.BGUseAlphaBlendAPI);                     ts->EtermLookfeel.BGUseAlphaBlendAPI);
2064          WritePrivateProfileString(ETERM_SECTION, "BGSPIPath",          WritePrivateProfileString(ETERM_SECTION, "BGSPIPath",
2065                                    ts->EtermLookfeel.BGSPIPath, FName);                                    ts->EtermLookfeel.BGSPIPath, FName);
2066          WriteOnOff(ETERM_SECTION, "BGFastSizeMove", FName,          WriteOnOff(ETERM_SECTION, "BGFastSizeMove", FName,
2067                     ts->EtermLookfeel.BGFastSizeMove);                     ts->EtermLookfeel.BGFastSizeMove);
2068          WriteOnOff(ETERM_SECTION, "BGFlickerlessMove", FName,          WriteOnOff(ETERM_SECTION, "BGFlickerlessMove", FName,
2069                     ts->EtermLookfeel.BGNoCopyBits);                     ts->EtermLookfeel.BGNoCopyBits);
2070          WriteOnOff(ETERM_SECTION, "BGNoFrame", FName,          WriteOnOff(ETERM_SECTION, "BGNoFrame", FName,
2071                     ts->EtermLookfeel.BGNoFrame);                     ts->EtermLookfeel.BGNoFrame);
2072          WritePrivateProfileString(ETERM_SECTION, "BGThemeFile",          WritePrivateProfileString(ETERM_SECTION, "BGThemeFile",
2073                                    ts->EtermLookfeel.BGThemeFile, FName);                                    ts->EtermLookfeel.BGThemeFile, FName);
2074    
2075  #ifdef USE_NORMAL_BGCOLOR  #ifdef USE_NORMAL_BGCOLOR
2076          // UseNormalBGColor          // UseNormalBGColor
2077          WriteOnOff(Section, "UseNormalBGColor", FName, ts->UseNormalBGColor);          WriteOnOff(Section, "UseNormalBGColor", FName, ts->UseNormalBGColor);
2078  #endif  #endif
2079    
2080          // UI language message file          // UI language message file
2081          WritePrivateProfileString(Section, "UILanguageFile",          WritePrivateProfileString(Section, "UILanguageFile",
2082                                    ts->UILanguageFile_ini, FName);                                    ts->UILanguageFile_ini, FName);
2083    
2084          // Broadcast Command History (2007.3.3 maya)          // Broadcast Command History (2007.3.3 maya)
2085          WriteOnOff(Section, "BroadcastCommandHistory", FName,          WriteOnOff(Section, "BroadcastCommandHistory", FName,
2086                     ts->BroadcastCommandHistory);                     ts->BroadcastCommandHistory);
2087    
2088          // 337: 2007/03/20 Accept Broadcast          // 337: 2007/03/20 Accept Broadcast
2089          WriteOnOff(Section, "AcceptBroadcast", FName, ts->AcceptBroadcast);          WriteOnOff(Section, "AcceptBroadcast", FName, ts->AcceptBroadcast);
2090    
2091          // Confirm send a file when drag and drop (2007.12.28 maya)          // Confirm send a file when drag and drop (2007.12.28 maya)
2092          WriteOnOff(Section, "ConfirmFileDragAndDrop", FName,          WriteOnOff(Section, "ConfirmFileDragAndDrop", FName,
2093                     ts->ConfirmFileDragAndDrop);                     ts->ConfirmFileDragAndDrop);
2094    
2095          // Translate mouse wheel to cursor key when application cursor mode          // Translate mouse wheel to cursor key when application cursor mode
2096          WriteOnOff(Section, "TranslateWheelToCursor", FName,          WriteOnOff(Section, "TranslateWheelToCursor", FName,
2097                     ts->TranslateWheelToCursor);                     ts->TranslateWheelToCursor);
2098    
2099          // Display "New Connection" dialog on startup (2008.1.18 maya)          // Display "New Connection" dialog on startup (2008.1.18 maya)
2100          WriteOnOff(Section, "HostDialogOnStartup", FName,          WriteOnOff(Section, "HostDialogOnStartup", FName,
2101                     ts->HostDialogOnStartup);                     ts->HostDialogOnStartup);
2102    
2103          // Mouse event tracking          // Mouse event tracking
2104          WriteOnOff(Section, "MouseEventTracking", FName,          WriteOnOff(Section, "MouseEventTracking", FName,
2105                     ts->MouseEventTracking);                     ts->MouseEventTracking);
2106    
2107          // Maximized bug tweak          // Maximized bug tweak
2108          WriteOnOff(Section, "MaximizedBugTweak", FName, ts->MaximizedBugTweak);          WriteOnOff(Section, "MaximizedBugTweak", FName, ts->MaximizedBugTweak);
2109    
2110          // Convert Unicode symbol characters to DEC Special characters          // Convert Unicode symbol characters to DEC Special characters
2111          WriteUint(Section, "UnicodeToDecSpMapping", FName, ts->UnicodeDecSpMapping);          WriteUint(Section, "UnicodeToDecSpMapping", FName, ts->UnicodeDecSpMapping);
2112    
2113          // VT Window Icon          // VT Window Icon
2114          IconId2IconName(Temp, sizeof(Temp), ts->VTIcon);          IconId2IconName(Temp, sizeof(Temp), ts->VTIcon);
2115          WritePrivateProfileString(Section, "VTIcon", Temp, FName);          WritePrivateProfileString(Section, "VTIcon", Temp, FName);
2116    
2117          // Tek Window Icon          // Tek Window Icon
2118          IconId2IconName(Temp, sizeof(Temp), ts->TEKIcon);          IconId2IconName(Temp, sizeof(Temp), ts->TEKIcon);
2119          WritePrivateProfileString(Section, "TEKIcon", Temp, FName);          WritePrivateProfileString(Section, "TEKIcon", Temp, FName);
2120    
2121          // AutoScrollOnlyInBottomLine          // AutoScrollOnlyInBottomLine
2122          WriteOnOff(Section, "AutoScrollOnlyInBottomLine", FName,          WriteOnOff(Section, "AutoScrollOnlyInBottomLine", FName,
2123                  ts->AutoScrollOnlyInBottomLine);                  ts->AutoScrollOnlyInBottomLine);
2124    
2125          // Unknown Unicode Character          // Unknown Unicode Character
2126          WriteOnOff(Section, "UnknownUnicodeCharacterAsWide", FName,          WriteOnOff(Section, "UnknownUnicodeCharacterAsWide", FName,
2127                     ts->UnknownUnicodeCharaAsWide);                     ts->UnknownUnicodeCharaAsWide);
2128    
2129          // Accept remote-controlled window title changing          // Accept remote-controlled window title changing
2130          if (ts->AcceptTitleChangeRequest == IdTitleChangeRequestOff)          if (ts->AcceptTitleChangeRequest == IdTitleChangeRequestOff)
2131                  strncpy_s(Temp, sizeof(Temp), "off", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "off", _TRUNCATE);
2132          else if (ts->AcceptTitleChangeRequest == IdTitleChangeRequestOverwrite)          else if (ts->AcceptTitleChangeRequest == IdTitleChangeRequestOverwrite)
2133                  strncpy_s(Temp, sizeof(Temp), "overwrite", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "overwrite", _TRUNCATE);
2134          else if (ts->AcceptTitleChangeRequest == IdTitleChangeRequestAhead)          else if (ts->AcceptTitleChangeRequest == IdTitleChangeRequestAhead)
2135                  strncpy_s(Temp, sizeof(Temp), "ahead", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "ahead", _TRUNCATE);
2136          else if (ts->AcceptTitleChangeRequest == IdTitleChangeRequestLast)          else if (ts->AcceptTitleChangeRequest == IdTitleChangeRequestLast)
2137                  strncpy_s(Temp, sizeof(Temp), "last", _TRUNCATE);                  strncpy_s(Temp, sizeof(Temp), "last", _TRUNCATE);
2138          else          else
2139                  Temp[0] = 0;                  Temp[0] = 0;
2140          WritePrivateProfileString(Section, "AcceptTitleChangeRequest", Temp, FName);          WritePrivateProfileString(Section, "AcceptTitleChangeRequest", Temp, FName);
2141    
2142          // Size of paste confirm dialog          // Size of paste confirm dialog
2143          WriteInt2(Section, "PasteDialogSize", FName,          WriteInt2(Section, "PasteDialogSize", FName,
2144                    ts->PasteDialogSize.cx, ts->PasteDialogSize.cy);                    ts->PasteDialogSize.cx, ts->PasteDialogSize.cy);
2145    
2146          // Disable mouse event tracking when Control-Key is pressed.          // Disable mouse event tracking when Control-Key is pressed.
2147          WriteOnOff(Section, "DisableMouseTrackingByCtrl", FName,          WriteOnOff(Section, "DisableMouseTrackingByCtrl", FName,
2148                     ts->DisableMouseTrackingByCtrl);                     ts->DisableMouseTrackingByCtrl);
2149    
2150          // Disable TranslateWHeelToCursor when Control-Key is pressed.          // Disable TranslateWHeelToCursor when Control-Key is pressed.
2151          WriteOnOff(Section, "DisableWheelToCursorByCtrl", FName,          WriteOnOff(Section, "DisableWheelToCursorByCtrl", FName,
2152                     ts->DisableWheelToCursorByCtrl);                     ts->DisableWheelToCursorByCtrl);
2153    
2154          // Strict Key Mapping.          // Strict Key Mapping.
2155          WriteOnOff(Section, "StrictKeyMapping", FName,          WriteOnOff(Section, "StrictKeyMapping", FName,
2156                     ts->StrictKeyMapping);                     ts->StrictKeyMapping);
2157    
2158          // Wait4allMacroCommand          // Wait4allMacroCommand
2159          WriteOnOff(Section, "Wait4allMacroCommand", FName,          WriteOnOff(Section, "Wait4allMacroCommand", FName,
2160                     ts->Wait4allMacroCommand);                     ts->Wait4allMacroCommand);
2161  }  }
2162    
2163  #define VTEditor "VT editor keypad"  #define VTEditor "VT editor keypad"
2164  #define VTNumeric "VT numeric keypad"  #define VTNumeric "VT numeric keypad"
2165  #define VTFunction "VT function keys"  #define VTFunction "VT function keys"
2166  #define XFunction "X function keys"  #define XFunction "X function keys"
2167  #define ShortCut "Shortcut keys"  #define ShortCut "Shortcut keys"
2168    
2169  void GetInt(PKeyMap KeyMap, int KeyId, PCHAR Sect, PCHAR Key, PCHAR FName)  void GetInt(PKeyMap KeyMap, int KeyId, PCHAR Sect, PCHAR Key, PCHAR FName)
2170  {  {
2171          char Temp[11];          char Temp[11];
2172          WORD Num;          WORD Num;
2173    
2174          GetPrivateProfileString(Sect, Key, "", Temp, sizeof(Temp), FName);          GetPrivateProfileString(Sect, Key, "", Temp, sizeof(Temp), FName);
2175          if (Temp[0] == 0)          if (Temp[0] == 0)
2176                  Num = 0xFFFF;                  Num = 0xFFFF;
2177          else if (_stricmp(Temp, "off") == 0)          else if (_stricmp(Temp, "off") == 0)
2178                  Num = 0xFFFF;                  Num = 0xFFFF;
2179          else if (sscanf(Temp, "%d", &Num) != 1)          else if (sscanf(Temp, "%d", &Num) != 1)
2180                  Num = 0xFFFF;                  Num = 0xFFFF;
2181    
2182          KeyMap->Map[KeyId - 1] = Num;          KeyMap->Map[KeyId - 1] = Num;
2183  }  }
2184    
2185  void FAR PASCAL ReadKeyboardCnf  void FAR PASCAL ReadKeyboardCnf
2186          (PCHAR FName, PKeyMap KeyMap, BOOL ShowWarning) {          (PCHAR FName, PKeyMap KeyMap, BOOL ShowWarning) {
2187          int i, j, Ptr;          int i, j, Ptr;
2188          char EntName[7];          char EntName[7];
2189          char TempStr[221];          char TempStr[221];
2190          char KStr[201];          char KStr[201];
2191    
2192          // clear key map          // clear key map
2193          for (i = 0; i <= IdKeyMax - 1; i++)          for (i = 0; i <= IdKeyMax - 1; i++)
2194                  KeyMap->Map[i] = 0xFFFF;                  KeyMap->Map[i] = 0xFFFF;
2195          for (i = 0; i <= NumOfUserKey - 1; i++) {          for (i = 0; i <= NumOfUserKey - 1; i++) {
2196                  KeyMap->UserKeyPtr[i] = 0;                  KeyMap->UserKeyPtr[i] = 0;
2197                  KeyMap->UserKeyLen[i] = 0;                  KeyMap->UserKeyLen[i] = 0;
2198          }          }
2199    
2200          // VT editor keypad          // VT editor keypad
2201          GetInt(KeyMap, IdUp, VTEditor, "Up", FName);          GetInt(KeyMap, IdUp, VTEditor, "Up", FName);
2202    
2203          GetInt(KeyMap, IdDown, VTEditor, "Down", FName);          GetInt(KeyMap, IdDown, VTEditor, "Down", FName);
2204    
2205          GetInt(KeyMap, IdRight, VTEditor, "Right", FName);          GetInt(KeyMap, IdRight, VTEditor, "Right", FName);
2206    
2207          GetInt(KeyMap, IdLeft, VTEditor, "Left", FName);          GetInt(KeyMap, IdLeft, VTEditor, "Left", FName);
2208    
2209          GetInt(KeyMap, IdFind, VTEditor, "Find", FName);          GetInt(KeyMap, IdFind, VTEditor, "Find", FName);
2210    
2211          GetInt(KeyMap, IdInsert, VTEditor, "Insert", FName);          GetInt(KeyMap, IdInsert, VTEditor, "Insert", FName);
2212    
2213          GetInt(KeyMap, IdRemove, VTEditor, "Remove", FName);          GetInt(KeyMap, IdRemove, VTEditor, "Remove", FName);
2214    
2215          GetInt(KeyMap, IdSelect, VTEditor, "Select", FName);          GetInt(KeyMap, IdSelect, VTEditor, "Select", FName);
2216    
2217          GetInt(KeyMap, IdPrev, VTEditor, "Prev", FName);          GetInt(KeyMap, IdPrev, VTEditor, "Prev", FName);
2218    
2219          GetInt(KeyMap, IdNext, VTEditor, "Next", FName);          GetInt(KeyMap, IdNext, VTEditor, "Next", FName);
2220    
2221          // VT numeric keypad          // VT numeric keypad
2222          GetInt(KeyMap, Id0, VTNumeric, "Num0", FName);          GetInt(KeyMap, Id0, VTNumeric, "Num0", FName);
2223    
2224          GetInt(KeyMap, Id1, VTNumeric, "Num1", FName);          GetInt(KeyMap, Id1, VTNumeric, "Num1", FName);
2225    
2226          GetInt(KeyMap, Id2, VTNumeric, "Num2", FName);          GetInt(KeyMap, Id2, VTNumeric, "Num2", FName);
2227    
2228          GetInt(KeyMap, Id3, VTNumeric, "Num3", FName);          GetInt(KeyMap, Id3, VTNumeric, "Num3", FName);
2229    
2230          GetInt(KeyMap, Id4, VTNumeric, "Num4", FName);          GetInt(KeyMap, Id4, VTNumeric, "Num4", FName);
2231    
2232          GetInt(KeyMap, Id5, VTNumeric, "Num5", FName);          GetInt(KeyMap, Id5, VTNumeric, "Num5", FName);
2233    
2234          GetInt(KeyMap, Id6, VTNumeric, "Num6", FName);          GetInt(KeyMap, Id6, VTNumeric, "Num6", FName);
2235    
2236          GetInt(KeyMap, Id7, VTNumeric, "Num7", FName);          GetInt(KeyMap, Id7, VTNumeric, "Num7", FName);
2237    
2238          GetInt(KeyMap, Id8, VTNumeric, "Num8", FName);          GetInt(KeyMap, Id8, VTNumeric, "Num8", FName);
2239    
2240          GetInt(KeyMap, Id9, VTNumeric, "Num9", FName);          GetInt(KeyMap, Id9, VTNumeric, "Num9", FName);
2241    
2242          GetInt(KeyMap, IdMinus, VTNumeric, "NumMinus", FName);          GetInt(KeyMap, IdMinus, VTNumeric, "NumMinus", FName);
2243    
2244          GetInt(KeyMap, IdComma, VTNumeric, "NumComma", FName);          GetInt(KeyMap, IdComma, VTNumeric, "NumComma", FName);
2245    
2246          GetInt(KeyMap, IdPeriod, VTNumeric, "NumPeriod", FName);          GetInt(KeyMap, IdPeriod, VTNumeric, "NumPeriod", FName);
2247    
2248          GetInt(KeyMap, IdEnter, VTNumeric, "NumEnter", FName);          GetInt(KeyMap, IdEnter, VTNumeric, "NumEnter", FName);
2249    
2250          GetInt(KeyMap, IdSlash, VTNumeric, "NumSlash", FName);          GetInt(KeyMap, IdSlash, VTNumeric, "NumSlash", FName);
2251    
2252          GetInt(KeyMap, IdAsterisk, VTNumeric, "NumAsterisk", FName);          GetInt(KeyMap, IdAsterisk, VTNumeric, "NumAsterisk", FName);
2253    
2254          GetInt(KeyMap, IdPlus, VTNumeric, "NumPlus", FName);          GetInt(KeyMap, IdPlus, VTNumeric, "NumPlus", FName);
2255    
2256          GetInt(KeyMap, IdPF1, VTNumeric, "PF1", FName);          GetInt(KeyMap, IdPF1, VTNumeric, "PF1", FName);
2257    
2258          GetInt(KeyMap, IdPF2, VTNumeric, "PF2", FName);          GetInt(KeyMap, IdPF2, VTNumeric, "PF2", FName);
2259    
2260          GetInt(KeyMap, IdPF3, VTNumeric, "PF3", FName);          GetInt(KeyMap, IdPF3, VTNumeric, "PF3", FName);
2261    
2262          GetInt(KeyMap, IdPF4, VTNumeric, "PF4", FName);          GetInt(KeyMap, IdPF4, VTNumeric, "PF4", FName);
2263    
2264          // VT function keys          // VT function keys
2265          GetInt(KeyMap, IdHold, VTFunction, "Hold", FName);          GetInt(KeyMap, IdHold, VTFunction, "Hold", FName);
2266    
2267          GetInt(KeyMap, IdPrint, VTFunction, "Print", FName);          GetInt(KeyMap, IdPrint, VTFunction, "Print", FName);
2268    
2269          GetInt(KeyMap, IdBreak, VTFunction, "Break", FName);          GetInt(KeyMap, IdBreak, VTFunction, "Break", FName);
2270    
2271          GetInt(KeyMap, IdF6, VTFunction, "F6", FName);          GetInt(KeyMap, IdF6, VTFunction, "F6", FName);
2272    
2273          GetInt(KeyMap, IdF7, VTFunction, "F7", FName);          GetInt(KeyMap, IdF7, VTFunction, "F7", FName);
2274    
2275          GetInt(KeyMap, IdF8, VTFunction, "F8", FName);          GetInt(KeyMap, IdF8, VTFunction, "F8", FName);
2276    
2277          GetInt(KeyMap, IdF9, VTFunction, "F9", FName);          GetInt(KeyMap, IdF9, VTFunction, "F9", FName);
2278    
2279          GetInt(KeyMap, IdF10, VTFunction, "F10", FName);          GetInt(KeyMap, IdF10, VTFunction, "F10", FName);
2280    
2281          GetInt(KeyMap, IdF11, VTFunction, "F11", FName);          GetInt(KeyMap, IdF11, VTFunction, "F11", FName);
2282    
2283          GetInt(KeyMap, IdF12, VTFunction, "F12", FName);          GetInt(KeyMap, IdF12, VTFunction, "F12", FName);
2284    
2285          GetInt(KeyMap, IdF13, VTFunction, "F13", FName);          GetInt(KeyMap, IdF13, VTFunction, "F13", FName);
2286    
2287          GetInt(KeyMap, IdF14, VTFunction, "F14", FName);          GetInt(KeyMap, IdF14, VTFunction, "F14", FName);
2288    
2289          GetInt(KeyMap, IdHelp, VTFunction, "Help", FName);          GetInt(KeyMap, IdHelp, VTFunction, "Help", FName);
2290    
2291          GetInt(KeyMap, IdDo, VTFunction, "Do", FName);          GetInt(KeyMap, IdDo, VTFunction, "Do", FName);
2292    
2293          GetInt(KeyMap, IdF17, VTFunction, "F17", FName);          GetInt(KeyMap, IdF17, VTFunction, "F17", FName);
2294    
2295          GetInt(KeyMap, IdF18, VTFunction, "F18", FName);          GetInt(KeyMap, IdF18, VTFunction, "F18", FName);
2296    
2297          GetInt(KeyMap, IdF19, VTFunction, "F19", FName);          GetInt(KeyMap, IdF19, VTFunction, "F19", FName);
2298    
2299          GetInt(KeyMap, IdF20, VTFunction, "F20", FName);          GetInt(KeyMap, IdF20, VTFunction, "F20", FName);
2300    
2301          // UDK          // UDK
2302          GetInt(KeyMap, IdUDK6, VTFunction, "UDK6", FName);          GetInt(KeyMap, IdUDK6, VTFunction, "UDK6", FName);
2303    
2304          GetInt(KeyMap, IdUDK7, VTFunction, "UDK7", FName);          GetInt(KeyMap, IdUDK7, VTFunction, "UDK7", FName);
2305    
2306          GetInt(KeyMap, IdUDK8, VTFunction, "UDK8", FName);          GetInt(KeyMap, IdUDK8, VTFunction, "UDK8", FName);
2307    
2308          GetInt(KeyMap, IdUDK9, VTFunction, "UDK9", FName);          GetInt(KeyMap, IdUDK9, VTFunction, "UDK9", FName);
2309    
2310          GetInt(KeyMap, IdUDK10, VTFunction, "UDK10", FName);          GetInt(KeyMap, IdUDK10, VTFunction, "UDK10", FName);
2311    
2312          GetInt(KeyMap, IdUDK11, VTFunction, "UDK11", FName);          GetInt(KeyMap, IdUDK11, VTFunction, "UDK11", FName);
2313    
2314          GetInt(KeyMap, IdUDK12, VTFunction, "UDK12", FName);          GetInt(KeyMap, IdUDK12, VTFunction, "UDK12", FName);
2315    
2316          GetInt(KeyMap, IdUDK13, VTFunction, "UDK13", FName);          GetInt(KeyMap, IdUDK13, VTFunction, "UDK13", FName);
2317    
2318          GetInt(KeyMap, IdUDK14, VTFunction, "UDK14", FName);          GetInt(KeyMap, IdUDK14, VTFunction, "UDK14", FName);
2319    
2320          GetInt(KeyMap, IdUDK15, VTFunction, "UDK15", FName);          GetInt(KeyMap, IdUDK15, VTFunction, "UDK15", FName);
2321    
2322          GetInt(KeyMap, IdUDK16, VTFunction, "UDK16", FName);          GetInt(KeyMap, IdUDK16, VTFunction, "UDK16", FName);
2323    
2324          GetInt(KeyMap, IdUDK17, VTFunction, "UDK17", FName);          GetInt(KeyMap, IdUDK17, VTFunction, "UDK17", FName);
2325    
2326          GetInt(KeyMap, IdUDK18, VTFunction, "UDK18", FName);          GetInt(KeyMap, IdUDK18, VTFunction, "UDK18", FName);
2327    
2328          GetInt(KeyMap, IdUDK19, VTFunction, "UDK19", FName);          GetInt(KeyMap, IdUDK19, VTFunction, "UDK19", FName);
2329    
2330          GetInt(KeyMap, IdUDK20, VTFunction, "UDK20", FName);          GetInt(KeyMap, IdUDK20, VTFunction, "UDK20", FName);
2331    
2332          // XTERM function keys          // XTERM function keys
2333          GetInt(KeyMap, IdXF1, XFunction, "XF1", FName);          GetInt(KeyMap, IdXF1, XFunction, "XF1", FName);
2334    
2335          GetInt(KeyMap, IdXF2, XFunction, "XF2", FName);          GetInt(KeyMap, IdXF2, XFunction, "XF2", FName);
2336    
2337          GetInt(KeyMap, IdXF3, XFunction, "XF3", FName);          GetInt(KeyMap, IdXF3, XFunction, "XF3", FName);
2338    
2339          GetInt(KeyMap, IdXF4, XFunction, "XF4", FName);          GetInt(KeyMap, IdXF4, XFunction, "XF4", FName);
2340    
2341          GetInt(KeyMap, IdXF5, XFunction, "XF5", FName);          GetInt(KeyMap, IdXF5, XFunction, "XF5", FName);
2342    
2343          // accelerator keys          // accelerator keys
2344          GetInt(KeyMap, IdCmdEditCopy, ShortCut, "EditCopy", FName);          GetInt(KeyMap, IdCmdEditCopy, ShortCut, "EditCopy", FName);
2345    
2346          GetInt(KeyMap, IdCmdEditPaste, ShortCut, "EditPaste", FName);          GetInt(KeyMap, IdCmdEditPaste, ShortCut, "EditPaste", FName);
2347    
2348          GetInt(KeyMap, IdCmdEditPasteCR, ShortCut, "EditPasteCR", FName);          GetInt(KeyMap, IdCmdEditPasteCR, ShortCut, "EditPasteCR", FName);
2349    
2350          GetInt(KeyMap, IdCmdEditCLS, ShortCut, "EditCLS", FName);          GetInt(KeyMap, IdCmdEditCLS, ShortCut, "EditCLS", FName);
2351    
2352          GetInt(KeyMap, IdCmdEditCLB, ShortCut, "EditCLB", FName);          GetInt(KeyMap, IdCmdEditCLB, ShortCut, "EditCLB", FName);
2353    
2354          GetInt(KeyMap, IdCmdCtrlOpenTEK, ShortCut, "ControlOpenTEK", FName);          GetInt(KeyMap, IdCmdCtrlOpenTEK, ShortCut, "ControlOpenTEK", FName);
2355    
2356          GetInt(KeyMap, IdCmdCtrlCloseTEK, ShortCut, "ControlCloseTEK", FName);          GetInt(KeyMap, IdCmdCtrlCloseTEK, ShortCut, "ControlCloseTEK", FName);
2357    
2358          GetInt(KeyMap, IdCmdLineUp, ShortCut, "LineUp", FName);          GetInt(KeyMap, IdCmdLineUp, ShortCut, "LineUp", FName);
2359    
2360          GetInt(KeyMap, IdCmdLineDown, ShortCut, "LineDown", FName);          GetInt(KeyMap, IdCmdLineDown, ShortCut, "LineDown", FName);
2361    
2362          GetInt(KeyMap, IdCmdPageUp, ShortCut, "PageUp", FName);          GetInt(KeyMap, IdCmdPageUp, ShortCut, "PageUp", FName);
2363    
2364          GetInt(KeyMap, IdCmdPageDown, ShortCut, "PageDown", FName);          GetInt(KeyMap, IdCmdPageDown, ShortCut, "PageDown", FName);
2365    
2366          GetInt(KeyMap, IdCmdBuffTop, ShortCut, "BuffTop", FName);          GetInt(KeyMap, IdCmdBuffTop, ShortCut, "BuffTop", FName);
2367    
2368          GetInt(KeyMap, IdCmdBuffBottom, ShortCut, "BuffBottom", FName);          GetInt(KeyMap, IdCmdBuffBottom, ShortCut, "BuffBottom", FName);
2369    
2370          GetInt(KeyMap, IdCmdNextWin, ShortCut, "NextWin", FName);          GetInt(KeyMap, IdCmdNextWin, ShortCut, "NextWin", FName);
2371    
2372          GetInt(KeyMap, IdCmdPrevWin, ShortCut, "PrevWin", FName);          GetInt(KeyMap, IdCmdPrevWin, ShortCut, "PrevWin", FName);
2373    
2374          GetInt(KeyMap, IdCmdLocalEcho, ShortCut, "LocalEcho", FName);          GetInt(KeyMap, IdCmdLocalEcho, ShortCut, "LocalEcho", FName);
2375    
2376          GetInt(KeyMap, IdScrollLock, ShortCut, "ScrollLock", FName);          GetInt(KeyMap, IdScrollLock, ShortCut, "ScrollLock", FName);
2377    
2378          /* user keys */          /* user keys */
2379    
2380          Ptr = 0;          Ptr = 0;
2381    
2382          i = IdUser1;          i = IdUser1;
2383          do {          do {
2384                  _snprintf_s(EntName, sizeof(EntName), _TRUNCATE, "User%d", i - IdUser1 + 1);                  _snprintf_s(EntName, sizeof(EntName), _TRUNCATE, "User%d", i - IdUser1 + 1);
2385                  GetPrivateProfileString("User keys", EntName, "",                  GetPrivateProfileString("User keys", EntName, "",
2386                                                                  TempStr, sizeof(TempStr), FName);                                                                  TempStr, sizeof(TempStr), FName);
2387                  if (strlen(TempStr) > 0) {                  if (strlen(TempStr) > 0) {
2388                          /* scan code */                          /* scan code */
2389                          GetNthString(TempStr, 1, sizeof(KStr), KStr);                          GetNthString(TempStr, 1, sizeof(KStr), KStr);
2390                          if (_stricmp(KStr, "off") == 0)                          if (_stricmp(KStr, "off") == 0)
2391                                  KeyMap->Map[i - 1] = 0xFFFF;                                  KeyMap->Map[i - 1] = 0xFFFF;
2392                          else {                          else {
2393                                  GetNthNum(TempStr, 1, &j);                                  GetNthNum(TempStr, 1, &j);
2394                                  KeyMap->Map[i - 1] = (WORD) j;                                  KeyMap->Map[i - 1] = (WORD) j;
2395                          }                          }
2396                          /* conversion flag */                          /* conversion flag */
2397                          GetNthNum(TempStr, 2, &j);                          GetNthNum(TempStr, 2, &j);
2398                          KeyMap->UserKeyType[i - IdUser1] = (BYTE) j;                          KeyMap->UserKeyType[i - IdUser1] = (BYTE) j;
2399                          /* key string */                          /* key string */
2400  /*      GetNthString(TempStr,3,sizeof(KStr),KStr); */  /*      GetNthString(TempStr,3,sizeof(KStr),KStr); */
2401                          KeyMap->UserKeyPtr[i - IdUser1] = Ptr;                          KeyMap->UserKeyPtr[i - IdUser1] = Ptr;
2402  /*      KeyMap->UserKeyLen[i-IdUser1] =  /*      KeyMap->UserKeyLen[i-IdUser1] =
2403          Hex2Str(KStr,&(KeyMap->UserKeyStr[Ptr]),KeyStrMax-Ptr+1);          Hex2Str(KStr,&(KeyMap->UserKeyStr[Ptr]),KeyStrMax-Ptr+1);
2404  */  */
2405                          GetNthString(TempStr, 3, KeyStrMax - Ptr + 1,                          GetNthString(TempStr, 3, KeyStrMax - Ptr + 1,
2406                                       &(KeyMap->UserKeyStr[Ptr]));                                       &(KeyMap->UserKeyStr[Ptr]));
2407                          KeyMap->UserKeyLen[i - IdUser1] =                          KeyMap->UserKeyLen[i - IdUser1] =
2408                                  strlen(&(KeyMap->UserKeyStr[Ptr]));                                  strlen(&(KeyMap->UserKeyStr[Ptr]));
2409                          Ptr = Ptr + KeyMap->UserKeyLen[i - IdUser1];                          Ptr = Ptr + KeyMap->UserKeyLen[i - IdUser1];
2410                  }                  }
2411    
2412                  i++;                  i++;
2413          }          }
2414          while ((i <= IdKeyMax) && (strlen(TempStr) > 0) && (Ptr <= KeyStrMax));          while ((i <= IdKeyMax) && (strlen(TempStr) > 0) && (Ptr <= KeyStrMax));
2415    
2416          for (j = 1; j <= IdKeyMax - 1; j++)          for (j = 1; j <= IdKeyMax - 1; j++)