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