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 3485 - (show annotations) (download) (as text)
Mon Jun 15 02:39:48 2009 UTC (14 years, 9 months ago) by doda
File MIME type: text/x-csrc
File size: 99694 byte(s)
ウィンドウ制御/報告シーケンスおよびカーソル形状制御シーケンスを受け入れるか設定できるようにした。

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