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 2545 - (show annotations) (download) (as text)
Fri Jun 20 11:58:47 2008 UTC (15 years, 9 months ago) by doda
Original Path: teraterm/trunk/ttpset/ttset.c
File MIME type: text/x-csrc
File size: 85541 byte(s)
・TeraTerm -> Tera Term
・その他細かい修正

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

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