Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4198 - (show annotations) (download) (as text)
Tue Nov 30 11:49:00 2010 UTC (13 years, 4 months ago) by doda
File MIME type: text/x-csrc
File size: 103638 byte(s)
ViewlogEditor のデフォルト値をフルパスにした。

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