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 2496 - (show annotations) (download) (as text)
Fri May 2 15:21:14 2008 UTC (15 years, 11 months ago) by doda
Original Path: teraterm/trunk/ttpset/ttset.c
File MIME type: text/x-csrc
File size: 82542 byte(s)
・インデントを調整
・Unicode Box DrawingsからDEC特殊文字への変換を制御する設定を追加。
# 漏れた…

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

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26