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 2664 - (show annotations) (download) (as text)
Fri Feb 20 04:45:31 2009 UTC (15 years, 1 month ago) by maya
Original Path: teraterm/trunk/ttpset/ttset.c
File MIME type: text/x-csrc
File size: 89935 byte(s)
IsDebuggerPresent 関係のコードを新しいヘッダファイルに集約した。

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