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