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