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 3729 - (show annotations) (download) (as text)
Fri Jan 8 09:34:39 2010 UTC (14 years, 3 months ago) by doda
File MIME type: text/x-csrc
File size: 101278 byte(s)
設定の保存で、ClearOnResize を書き込むようにした。

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