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 2682 - (show annotations) (download) (as text)
Wed Mar 4 04:08:27 2009 UTC (15 years, 1 month ago) by doda
Original Path: teraterm/trunk/ttpset/ttset.c
File MIME type: text/x-csrc
File size: 92353 byte(s)
三項演算子が見づらかったので、if文で書き換えた。
ついでに、他のフラグ処理も同様にif文で書き換えた。

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