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 3535 - (show annotations) (download) (as text)
Fri Jun 26 11:20:55 2009 UTC (14 years, 9 months ago) by yutakapon
File MIME type: text/x-csrc
File size: 100753 byte(s)
ConfirmChangePaste 時に、あらかじめ指定したテキストファイルで定義された文字列群が、
クリップボードに含まれているかどうかを判断するようにした。
フローは以下のとおり。

  1. ConfirmChangePaste が有効化どうか
  2. クリップボードに改行が含まれているかどうか
  3. クリップボードにファイルに指定された文字列が含まれているかどうか

TERATERM.INI に ConfirmChangePasteStringFile エントリを追加した。

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