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 2680 - (show annotations) (download) (as text)
Wed Mar 4 03:19:23 2009 UTC (15 years, 1 month ago) by doda
Original Path: teraterm/trunk/ttpset/ttset.c
File MIME type: text/x-csrc
File size: 92326 byte(s)
Reverse Videoモード時に設定の保存を行うと、文字色/背景色が入れ替わった状態で保存されるのを修正。
# これですべて対処が終わったかな?
# 個別に対処するより、DECSCNMの実装方法を変更した方が簡単だったかも

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