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