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 3522 - (show annotations) (download) (as text)
Fri Jun 19 09:16:37 2009 UTC (14 years, 9 months ago) by doda
File MIME type: text/x-csrc
File size: 100371 byte(s)
古いコードが残っていたので削除。

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