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