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 7674 - (show annotations) (download) (as text)
Mon May 13 15:14:30 2019 UTC (4 years, 10 months ago) by zmatsuo
File MIME type: text/x-csrc
File size: 139956 byte(s)
GetHomeDir(),GetUILanguageFileFull()#ttlib.cを追加、同様な処理は関数を使用するようにした
1 /*
2 * Copyright (C) 1994-1998 T. Teranishi
3 * (C) 2004-2019 TeraTerm Project
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29 /* IPv6 modification is Copyright(C) 2000 Jun-ya kato <kato@win6.jp> */
30
31 /* TTSET.DLL, setup file routines*/
32 #include <winsock2.h>
33 #include <ws2tcpip.h>
34 #include "teraterm.h"
35 #include "tttypes.h"
36 #include <stdio.h>
37 #include <string.h>
38 #include <direct.h>
39 #include <ctype.h>
40 #include <errno.h>
41 #include "ttlib.h"
42 #include "tt_res.h"
43 #include "servicenames.h"
44
45 #include "compat_w95.h"
46
47 #ifndef CLEARTYPE_QUALITY
48 #define CLEARTYPE_QUALITY 5
49 #endif
50
51 #define Section "Tera Term"
52
53 #define MaxStrLen (LONG)512
54
55 static PCHAR far TermList[] =
56 { "VT100", "VT100J", "VT101", "VT102", "VT102J", "VT220J", "VT282",
57 "VT320", "VT382", "VT420", "VT520", "VT525", NULL };
58
59 static PCHAR far RussList[] =
60 { "Windows", "KOI8-R", "CP-866", "ISO-8859-5", NULL };
61 static PCHAR far RussList2[] = { "Windows", "KOI8-R", NULL };
62
63 WORD str2id(PCHAR far * List, PCHAR str, WORD DefId)
64 {
65 WORD i;
66 i = 0;
67 while ((List[i] != NULL) && (_stricmp(List[i], str) != 0))
68 i++;
69 if (List[i] == NULL)
70 i = DefId;
71 else
72 i++;
73
74 return i;
75 }
76
77 void id2str(PCHAR far * List, WORD Id, WORD DefId, PCHAR str, int destlen)
78 {
79 int i;
80
81 if (Id == 0)
82 i = DefId - 1;
83 else {
84 i = 0;
85 while ((List[i] != NULL) && (i < Id - 1))
86 i++;
87 if (List[i] == NULL)
88 i = DefId - 1;
89 }
90 strncpy_s(str, destlen, List[i], _TRUNCATE);
91 }
92
93 int IconName2IconId(const char *name) {
94 int id;
95
96 if (_stricmp(name, "tterm") == 0) {
97 id = IDI_TTERM;
98 }
99 else if (_stricmp(name, "vt") == 0) {
100 id = IDI_VT;
101 }
102 else if (_stricmp(name, "tek") == 0) {
103 id = IDI_TEK;
104 }
105 else if (_stricmp(name, "tterm_classic") == 0) {
106 id = IDI_TTERM_CLASSIC;
107 }
108 else if (_stricmp(name, "vt_classic") == 0) {
109 id = IDI_VT_CLASSIC;
110 }
111 else if (_stricmp(name, "tterm_3d") == 0) {
112 id = IDI_TTERM_3D;
113 }
114 else if (_stricmp(name, "vt_3d") == 0) {
115 id = IDI_VT_3D;
116 }
117 else if (_stricmp(name, "cygterm") == 0) {
118 id = IDI_CYGTERM;
119 }
120 else {
121 id = IdIconDefault;
122 }
123 return id;
124 }
125
126 void IconId2IconName(char *name, int len, int id) {
127 char *icon;
128 switch (id) {
129 case IDI_TTERM:
130 icon = "tterm";
131 break;
132 case IDI_VT:
133 icon = "vt";
134 break;
135 case IDI_TEK:
136 icon = "tek";
137 break;
138 case IDI_TTERM_CLASSIC:
139 icon = "tterm_classic";
140 break;
141 case IDI_VT_CLASSIC:
142 icon = "vt_classic";
143 break;
144 case IDI_TTERM_3D:
145 icon = "tterm_3d";
146 break;
147 case IDI_VT_3D:
148 icon = "vt_3d";
149 break;
150 case IDI_CYGTERM:
151 icon = "cygterm";
152 break;
153 default:
154 icon = "Default";
155 }
156 strncpy_s(name, len, icon, _TRUNCATE);
157 }
158
159 WORD GetOnOff(PCHAR Sect, PCHAR Key, PCHAR FName, BOOL Default)
160 {
161 char Temp[4];
162 GetPrivateProfileString(Sect, Key, "", Temp, sizeof(Temp), FName);
163 if (Default) {
164 if (_stricmp(Temp, "off") == 0)
165 return 0;
166 else
167 return 1;
168 }
169 else {
170 if (_stricmp(Temp, "on") == 0)
171 return 1;
172 else
173 return 0;
174 }
175 }
176
177 void WriteOnOff(PCHAR Sect, PCHAR Key, PCHAR FName, WORD Flag)
178 {
179 char Temp[4];
180
181 if (Flag != 0)
182 strncpy_s(Temp, sizeof(Temp), "on", _TRUNCATE);
183 else
184 strncpy_s(Temp, sizeof(Temp), "off", _TRUNCATE);
185 WritePrivateProfileString(Sect, Key, Temp, FName);
186 }
187
188 void WriteInt(PCHAR Sect, PCHAR Key, PCHAR FName, int i)
189 {
190 char Temp[15];
191 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", i);
192 WritePrivateProfileString(Sect, Key, Temp, FName);
193 }
194
195 void WriteUint(PCHAR Sect, PCHAR Key, PCHAR FName, UINT i)
196 {
197 char Temp[15];
198 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%u", i);
199 WritePrivateProfileString(Sect, Key, Temp, FName);
200 }
201
202 void WriteInt2(PCHAR Sect, PCHAR Key, PCHAR FName, int i1, int i2)
203 {
204 char Temp[32];
205 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d", i1, i2);
206 WritePrivateProfileString(Sect, Key, Temp, FName);
207 }
208
209 void WriteInt4(PCHAR Sect, PCHAR Key, PCHAR FName,
210 int i1, int i2, int i3, int i4)
211 {
212 char Temp[64];
213 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d,%d,%d",
214 i1, i2, i3, i4);
215 WritePrivateProfileString(Sect, Key, Temp, FName);
216 }
217
218 void WriteInt6(PCHAR Sect, PCHAR Key, PCHAR FName,
219 int i1, int i2, int i3, int i4, int i5, int i6)
220 {
221 char Temp[96];
222 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d,%d,%d,%d,%d",
223 i1, i2,i3, i4, i5, i6);
224 WritePrivateProfileString(Sect, Key, Temp, FName);
225 }
226
227 void WriteFont(PCHAR Sect, PCHAR Key, PCHAR FName,
228 PCHAR Name, int x, int y, int charset)
229 {
230 char Temp[80];
231 if (Name[0] != 0)
232 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%s,%d,%d,%d",
233 Name, x, y, charset);
234 else
235 Temp[0] = 0;
236 WritePrivateProfileString(Sect, Key, Temp, FName);
237 }
238
239
240
241 #define CYGTERM_FILE "cygterm.cfg" // CygTerm configuration file
242 #define CYGTERM_FILE_MAXLINE 100
243
244 static void ReadCygtermConfFile(PTTSet ts)
245 {
246 char *cfgfile = CYGTERM_FILE; // CygTerm configuration file
247 char cfg[MAX_PATH];
248 FILE *fp;
249 char buf[256], *head, *body;
250 cygterm_t settings;
251
252 // try to read CygTerm config file
253 memset(&settings, 0, sizeof(settings));
254 _snprintf_s(settings.term, sizeof(settings.term), _TRUNCATE, "ttermpro.exe %%s %%d /E /KR=SJIS /KT=SJIS /VTICON=CygTerm /nossh");
255 _snprintf_s(settings.term_type, sizeof(settings.term_type), _TRUNCATE, "vt100");
256 _snprintf_s(settings.port_start, sizeof(settings.port_start), _TRUNCATE, "20000");
257 _snprintf_s(settings.port_range, sizeof(settings.port_range), _TRUNCATE, "40");
258 _snprintf_s(settings.shell, sizeof(settings.shell), _TRUNCATE, "auto");
259 _snprintf_s(settings.env1, sizeof(settings.env1), _TRUNCATE, "MAKE_MODE=unix");
260 _snprintf_s(settings.env2, sizeof(settings.env2), _TRUNCATE, "");
261 settings.login_shell = FALSE;
262 settings.home_chdir = FALSE;
263 settings.agent_proxy = FALSE;
264
265 strncpy_s(cfg, sizeof(cfg), ts->HomeDir, _TRUNCATE);
266 AppendSlash(cfg, sizeof(cfg));
267 strncat_s(cfg, sizeof(cfg), cfgfile, _TRUNCATE);
268
269 fp = fopen(cfg, "r");
270 if (fp != NULL) {
271 while (fgets(buf, sizeof(buf), fp) != NULL) {
272 int len = strlen(buf);
273
274 if (buf[len - 1] == '\n')
275 buf[len - 1] = '\0';
276
277 split_buffer(buf, '=', &head, &body);
278 if (head == NULL || body == NULL)
279 continue;
280
281 if (_stricmp(head, "TERM") == 0) {
282 _snprintf_s(settings.term, sizeof(settings.term), _TRUNCATE, "%s", body);
283
284 }
285 else if (_stricmp(head, "TERM_TYPE") == 0) {
286 _snprintf_s(settings.term_type, sizeof(settings.term_type), _TRUNCATE, "%s", body);
287
288 }
289 else if (_stricmp(head, "PORT_START") == 0) {
290 _snprintf_s(settings.port_start, sizeof(settings.port_start), _TRUNCATE, "%s", body);
291
292 }
293 else if (_stricmp(head, "PORT_RANGE") == 0) {
294 _snprintf_s(settings.port_range, sizeof(settings.port_range), _TRUNCATE, "%s", body);
295
296 }
297 else if (_stricmp(head, "SHELL") == 0) {
298 _snprintf_s(settings.shell, sizeof(settings.shell), _TRUNCATE, "%s", body);
299
300 }
301 else if (_stricmp(head, "ENV_1") == 0) {
302 _snprintf_s(settings.env1, sizeof(settings.env1), _TRUNCATE, "%s", body);
303
304 }
305 else if (_stricmp(head, "ENV_2") == 0) {
306 _snprintf_s(settings.env2, sizeof(settings.env2), _TRUNCATE, "%s", body);
307
308 }
309 else if (_stricmp(head, "LOGIN_SHELL") == 0) {
310 if (strchr("YyTt", *body)) {
311 settings.login_shell = TRUE;
312 }
313
314 }
315 else if (_stricmp(head, "HOME_CHDIR") == 0) {
316 if (strchr("YyTt", *body)) {
317 settings.home_chdir = TRUE;
318 }
319
320 }
321 else if (_stricmp(head, "SSH_AGENT_PROXY") == 0) {
322 if (strchr("YyTt", *body)) {
323 settings.agent_proxy = TRUE;
324 }
325
326 }
327 else {
328 // TODO: error check
329
330 }
331 }
332 fclose(fp);
333 }
334
335 memcpy(&ts->CygtermSettings, &settings, sizeof(cygterm_t));
336 }
337
338 static void WriteCygtermConfFile(PTTSet ts)
339 {
340 char *cfgfile = CYGTERM_FILE; // CygTerm configuration file
341 char *tmpfile = "cygterm.tmp";
342 char cfg[MAX_PATH];
343 char tmp[MAX_PATH];
344 FILE *fp;
345 FILE *tmp_fp;
346 char buf[256], *head, *body;
347 char uimsg[MAX_UIMSG];
348 cygterm_t settings;
349 char *line[CYGTERM_FILE_MAXLINE];
350 int i, linenum, len;
351
352 // Cygwin���������X�������������������A�t�@�C�����������������B
353 if (ts->CygtermSettings.update_flag == FALSE)
354 return;
355 // �t���O���������ASave setup�����x�����x�������������������������B
356 ts->CygtermSettings.update_flag = FALSE;
357
358 memcpy(&settings, &ts->CygtermSettings, sizeof(cygterm_t));
359
360 strncpy_s(cfg, sizeof(cfg), ts->HomeDir, _TRUNCATE);
361 AppendSlash(cfg, sizeof(cfg));
362 strncat_s(cfg, sizeof(cfg), cfgfile, _TRUNCATE);
363
364 strncpy_s(tmp, sizeof(tmp), ts->HomeDir, _TRUNCATE);
365 AppendSlash(tmp, sizeof(tmp));
366 strncat_s(tmp, sizeof(tmp), tmpfile, _TRUNCATE);
367
368 // cygterm.cfg �������������A�������������������������������B
369 memset(line, 0, sizeof(line));
370 linenum = 0;
371 fp = fopen(cfg, "r");
372 if (fp) {
373 i = 0;
374 while (fgets(buf, sizeof(buf), fp) != NULL) {
375 len = strlen(buf);
376 if (buf[len - 1] == '\n')
377 buf[len - 1] = '\0';
378 if (i < CYGTERM_FILE_MAXLINE)
379 line[i++] = _strdup(buf);
380 else
381 break;
382 }
383 linenum = i;
384 fclose(fp);
385 }
386
387 tmp_fp = fopen(cfg, "w");
388 if (tmp_fp == NULL) {
389 get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts->UILanguageFile);
390 get_lang_msg("MSG_CYGTERM_CONF_WRITEFILE_ERROR", ts->UIMsg, sizeof(ts->UIMsg),
391 "Can't write CygTerm configuration file (%d).", ts->UILanguageFile);
392 _snprintf_s(buf, sizeof(buf), _TRUNCATE, ts->UIMsg, GetLastError());
393 MessageBox(NULL, buf, uimsg, MB_ICONEXCLAMATION);
394 }
395 else {
396 if (linenum > 0) {
397 for (i = 0; i < linenum; i++) {
398 split_buffer(line[i], '=', &head, &body);
399 if (head == NULL || body == NULL) {
400 fprintf(tmp_fp, "%s\n", line[i]);
401 }
402 else if (_stricmp(head, "TERM") == 0) {
403 fprintf(tmp_fp, "TERM = %s\n", settings.term);
404 settings.term[0] = '\0';
405 }
406 else if (_stricmp(head, "TERM_TYPE") == 0) {
407 fprintf(tmp_fp, "TERM_TYPE = %s\n", settings.term_type);
408 settings.term_type[0] = '\0';
409 }
410 else if (_stricmp(head, "PORT_START") == 0) {
411 fprintf(tmp_fp, "PORT_START = %s\n", settings.port_start);
412 settings.port_start[0] = '\0';
413 }
414 else if (_stricmp(head, "PORT_RANGE") == 0) {
415 fprintf(tmp_fp, "PORT_RANGE = %s\n", settings.port_range);
416 settings.port_range[0] = '\0';
417 }
418 else if (_stricmp(head, "SHELL") == 0) {
419 fprintf(tmp_fp, "SHELL = %s\n", settings.shell);
420 settings.shell[0] = '\0';
421 }
422 else if (_stricmp(head, "ENV_1") == 0) {
423 fprintf(tmp_fp, "ENV_1 = %s\n", settings.env1);
424 settings.env1[0] = '\0';
425 }
426 else if (_stricmp(head, "ENV_2") == 0) {
427 fprintf(tmp_fp, "ENV_2 = %s\n", settings.env2);
428 settings.env2[0] = '\0';
429 }
430 else if (_stricmp(head, "LOGIN_SHELL") == 0) {
431 fprintf(tmp_fp, "LOGIN_SHELL = %s\n", (settings.login_shell == TRUE) ? "yes" : "no");
432 settings.login_shell = FALSE;
433 }
434 else if (_stricmp(head, "HOME_CHDIR") == 0) {
435 fprintf(tmp_fp, "HOME_CHDIR = %s\n", (settings.home_chdir == TRUE) ? "yes" : "no");
436 settings.home_chdir = FALSE;
437 }
438 else if (_stricmp(head, "SSH_AGENT_PROXY") == 0) {
439 fprintf(tmp_fp, "SSH_AGENT_PROXY = %s\n", (settings.agent_proxy == TRUE) ? "yes" : "no");
440 settings.agent_proxy = FALSE;
441 }
442 else {
443 fprintf(tmp_fp, "%s = %s\n", head, body);
444 }
445 }
446 }
447 else {
448 fputs("# CygTerm setting\n", tmp_fp);
449 fputs("\n", tmp_fp);
450 }
451 if (settings.term[0] != '\0') {
452 fprintf(tmp_fp, "TERM = %s\n", settings.term);
453 }
454 if (settings.term_type[0] != '\0') {
455 fprintf(tmp_fp, "TERM_TYPE = %s\n", settings.term_type);
456 }
457 if (settings.port_start[0] != '\0') {
458 fprintf(tmp_fp, "PORT_START = %s\n", settings.port_start);
459 }
460 if (settings.port_range[0] != '\0') {
461 fprintf(tmp_fp, "PORT_RANGE = %s\n", settings.port_range);
462 }
463 if (settings.shell[0] != '\0') {
464 fprintf(tmp_fp, "SHELL = %s\n", settings.shell);
465 }
466 if (settings.env1[0] != '\0') {
467 fprintf(tmp_fp, "ENV_1 = %s\n", settings.env1);
468 }
469 if (settings.env2[0] != '\0') {
470 fprintf(tmp_fp, "ENV_2 = %s\n", settings.env2);
471 }
472 if (settings.login_shell) {
473 fprintf(tmp_fp, "LOGIN_SHELL = yes\n");
474 }
475 if (settings.home_chdir) {
476 fprintf(tmp_fp, "HOME_CHDIR = yes\n");
477 }
478 if (settings.agent_proxy) {
479 fprintf(tmp_fp, "SSH_AGENT_PROXY = yes\n");
480 }
481 fclose(tmp_fp);
482
483 // �_�C���N�g���t�@�C���������������������������A���L�������s�v�B
484 #if 0
485 if (remove(cfg) != 0 && errno != ENOENT) {
486 get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts->UILanguageFile);
487 get_lang_msg("MSG_CYGTERM_CONF_REMOVEFILE_ERROR", ts->UIMsg, sizeof(ts->UIMsg),
488 "Can't remove old CygTerm configuration file (%d).", ts->UILanguageFile);
489 _snprintf_s(buf, sizeof(buf), _TRUNCATE, ts->UIMsg, GetLastError());
490 MessageBox(NULL, buf, uimsg, MB_ICONEXCLAMATION);
491 }
492 else if (rename(tmp, cfg) != 0) {
493 get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts->UILanguageFile);
494 get_lang_msg("MSG_CYGTERM_CONF_RENAMEFILE_ERROR", ts->UIMsg, sizeof(ts->UIMsg),
495 "Can't rename CygTerm configuration file (%d).", ts->UILanguageFile);
496 _snprintf_s(buf, sizeof(buf), _TRUNCATE, ts->UIMsg, GetLastError());
497 MessageBox(NULL, buf, uimsg, MB_ICONEXCLAMATION);
498 }
499 else {
500 // cygterm.cfg �t�@�C�����������������������A���b�Z�[�W�_�C�A���O���\�������B
501 // �������ASave setup�����s�����K�v�������������������N�����B
502 // (2012.5.1 yutaka)
503 // Save setup ���s�����ACygTerm�������������������������������������A
504 // �_�C�A���O�\�����s�v�����������A���������B
505 // (2015.11.12 yutaka)
506 get_lang_msg("MSG_TT_NOTICE", uimsg, sizeof(uimsg), "MSG_TT_NOTICE", ts->UILanguageFile);
507 get_lang_msg("MSG_CYGTERM_CONF_SAVED_NOTICE", ts->UIMsg, sizeof(ts->UIMsg),
508 "%s has been saved. Do not do save setup.", ts->UILanguageFile);
509 _snprintf_s(buf, sizeof(buf), _TRUNCATE, ts->UIMsg, CYGTERM_FILE);
510 MessageBox(NULL, buf, uimsg, MB_OK | MB_ICONINFORMATION);
511 }
512 #endif
513 }
514
515 // �Y�������������t���[���������B
516 for (i = 0; i < linenum; i++) {
517 free(line[i]);
518 }
519
520 }
521
522 void PASCAL ReadIniFile(PCHAR FName, PTTSet ts)
523 {
524 int i;
525 HDC TmpDC;
526 char Temp[MAX_PATH], Temp2[MAX_PATH];
527
528 ts->Minimize = 0;
529 ts->HideWindow = 0;
530 ts->LogFlag = 0; // Log flags
531 ts->FTFlag = 0; // File transfer flags
532 ts->MenuFlag = 0; // Menu flags
533 ts->TermFlag = 0; // Terminal flag
534 ts->ColorFlag = 0; // ANSI/Attribute color flags
535 ts->FontFlag = 0; // Font flag
536 ts->PortFlag = 0; // Port flags
537 ts->WindowFlag = 0; // Window flags
538 ts->CtrlFlag = 0; // Control sequence flags
539 ts->PasteFlag = 0; // Clipboard Paste flags
540 ts->TelPort = 23;
541
542 ts->DisableTCPEchoCR = FALSE;
543
544 /* Version number */
545 /* GetPrivateProfileString(Section,"Version","",
546 Temp,sizeof(Temp),FName); */
547
548 /* Language */
549 GetPrivateProfileString(Section, "Language", "",
550 Temp, sizeof(Temp), FName);
551 if (_stricmp(Temp, "Japanese") == 0)
552 ts->Language = IdJapanese;
553 else if (_stricmp(Temp, "Russian") == 0)
554 ts->Language = IdRussian;
555 else if (_stricmp(Temp, "English") == 0)
556 ts->Language = IdEnglish;
557 else if (_stricmp(Temp,"Korean") == 0) // HKS
558 ts->Language = IdKorean;
559 else if (_stricmp(Temp,"UTF-8") == 0)
560 ts->Language = IdUtf8;
561 else {
562 switch (PRIMARYLANGID(GetSystemDefaultLangID())) {
563 case LANG_JAPANESE:
564 ts->Language = IdJapanese;
565 break;
566 case LANG_RUSSIAN:
567 ts->Language = IdRussian;
568 break;
569 case LANG_KOREAN: // HKS
570 ts->Language = IdKorean;
571 break;
572 default:
573 ts->Language = IdEnglish;
574 }
575 }
576
577 /* Port type */
578 GetPrivateProfileString(Section, "Port", "",
579 Temp, sizeof(Temp), FName);
580 if (_stricmp(Temp, "serial") == 0)
581 ts->PortType = IdSerial;
582 else {
583 ts->PortType = IdTCPIP;
584 }
585
586 /* VT win position */
587 GetPrivateProfileString(Section, "VTPos", "-2147483648,-2147483648", Temp, sizeof(Temp), FName); /* default: random position */
588 GetNthNum(Temp, 1, (int far *) (&ts->VTPos.x));
589 GetNthNum(Temp, 2, (int far *) (&ts->VTPos.y));
590
591 /* TEK win position */
592 GetPrivateProfileString(Section, "TEKPos", "-2147483648,-2147483648", Temp, sizeof(Temp), FName); /* default: random position */
593 GetNthNum(Temp, 1, (int far *) &(ts->TEKPos.x));
594 GetNthNum(Temp, 2, (int far *) &(ts->TEKPos.y));
595
596 /* Save VT Window position */
597 ts->SaveVTWinPos = GetOnOff(Section, "SaveVTWinPos", FName, FALSE);
598
599 /* VT terminal size */
600 GetPrivateProfileString(Section, "TerminalSize", "80,24",
601 Temp, sizeof(Temp), FName);
602 GetNthNum(Temp, 1, &ts->TerminalWidth);
603 GetNthNum(Temp, 2, &ts->TerminalHeight);
604 if (ts->TerminalWidth <= 0)
605 ts->TerminalWidth = 80;
606 else if (ts->TerminalWidth > TermWidthMax)
607 ts->TerminalWidth = TermWidthMax;
608 if (ts->TerminalHeight <= 0)
609 ts->TerminalHeight = 24;
610 else if (ts->TerminalHeight > TermHeightMax)
611 ts->TerminalHeight = TermHeightMax;
612
613 /* Terminal size = Window size */
614 ts->TermIsWin = GetOnOff(Section, "TermIsWin", FName, FALSE);
615
616 /* Auto window resize flag */
617 ts->AutoWinResize = GetOnOff(Section, "AutoWinResize", FName, FALSE);
618
619 /* CR Receive */
620 GetPrivateProfileString(Section, "CRReceive", "",
621 Temp, sizeof(Temp), FName);
622 if (_stricmp(Temp, "CRLF") == 0) {
623 ts->CRReceive = IdCRLF;
624 }
625 else if (_stricmp(Temp, "LF") == 0) {
626 ts->CRReceive = IdLF;
627 }
628 else if (_stricmp(Temp, "AUTO") == 0) {
629 ts->CRReceive = IdAUTO;
630 }
631 else {
632 ts->CRReceive = IdCR;
633 }
634 /* CR Send */
635 GetPrivateProfileString(Section, "CRSend", "",
636 Temp, sizeof(Temp), FName);
637 if (_stricmp(Temp, "CRLF") == 0) {
638 ts->CRSend = IdCRLF;
639 }
640 else if (_stricmp(Temp, "LF") == 0) {
641 ts->CRSend = IdLF;
642 }
643 else {
644 ts->CRSend = IdCR;
645 }
646 ts->CRSend_ini = ts->CRSend;
647
648 /* Local echo */
649 ts->LocalEcho = GetOnOff(Section, "LocalEcho", FName, FALSE);
650 ts->LocalEcho_ini = ts->LocalEcho;
651
652 /* Answerback */
653 GetPrivateProfileString(Section, "Answerback", "", Temp,
654 sizeof(Temp), FName);
655 ts->AnswerbackLen =
656 Hex2Str(Temp, ts->Answerback, sizeof(ts->Answerback));
657
658 /* Kanji Code (receive) */
659 GetPrivateProfileString(Section, "KanjiReceive", "",
660 Temp, sizeof(Temp), FName);
661 if (_stricmp(Temp, "EUC") == 0)
662 ts->KanjiCode = IdEUC;
663 else if (_stricmp(Temp, "JIS") == 0)
664 ts->KanjiCode = IdJIS;
665 else if (_stricmp(Temp, "UTF-8") == 0)
666 ts->KanjiCode = IdUTF8;
667 else if (_stricmp(Temp, "UTF-8m") == 0)
668 ts->KanjiCode = IdUTF8m;
669 else if (_stricmp(Temp, "KS5601") == 0)
670 ts->KanjiCode = IdSJIS;
671 else
672 ts->KanjiCode = IdSJIS;
673 // KanjiCode/KanjiCodeSend �������� Language �����������l���u��������
674 {
675 WORD KanjiCode = ts->KanjiCode;
676 ts->KanjiCode = KanjiCodeTranslate(ts->Language,KanjiCode);
677 }
678
679 /* Katakana (receive) */
680 GetPrivateProfileString(Section, "KatakanaReceive", "",
681 Temp, sizeof(Temp), FName);
682 if (_stricmp(Temp, "7") == 0)
683 ts->JIS7Katakana = 1;
684 else
685 ts->JIS7Katakana = 0;
686
687 /* Kanji Code (transmit) */
688 GetPrivateProfileString(Section, "KanjiSend", "",
689 Temp, sizeof(Temp), FName);
690 if (_stricmp(Temp, "EUC") == 0)
691 ts->KanjiCodeSend = IdEUC;
692 else if (_stricmp(Temp, "JIS") == 0)
693 ts->KanjiCodeSend = IdJIS;
694 else if (_stricmp(Temp, "UTF-8") == 0)
695 ts->KanjiCodeSend = IdUTF8;
696 else if (_stricmp(Temp, "KS5601") == 0)
697 ts->KanjiCode = IdSJIS;
698 else
699 ts->KanjiCodeSend = IdSJIS;
700 // KanjiCode/KanjiCodeSend �������� Language �����������l���u��������
701 {
702 WORD KanjiCodeSend = ts->KanjiCodeSend;
703 ts->KanjiCodeSend = KanjiCodeTranslate(ts->Language,KanjiCodeSend);
704 }
705
706 /* Katakana (receive) */
707 GetPrivateProfileString(Section, "KatakanaSend", "",
708 Temp, sizeof(Temp), FName);
709 if (_stricmp(Temp, "7") == 0)
710 ts->JIS7KatakanaSend = 1;
711 else
712 ts->JIS7KatakanaSend = 0;
713
714 /* KanjiIn */
715 GetPrivateProfileString(Section, "KanjiIn", "",
716 Temp, sizeof(Temp), FName);
717 if (_stricmp(Temp, "@") == 0)
718 ts->KanjiIn = IdKanjiInA;
719 else
720 ts->KanjiIn = IdKanjiInB;
721
722 /* KanjiOut */
723 GetPrivateProfileString(Section, "KanjiOut", "",
724 Temp, sizeof(Temp), FName);
725 if (_stricmp(Temp, "B") == 0)
726 ts->KanjiOut = IdKanjiOutB;
727 else if (_stricmp(Temp, "H") == 0)
728 ts->KanjiOut = IdKanjiOutH;
729 else
730 ts->KanjiOut = IdKanjiOutJ;
731
732 /* Auto Win Switch VT<->TEK */
733 ts->AutoWinSwitch = GetOnOff(Section, "AutoWinSwitch", FName, FALSE);
734
735 /* Terminal ID */
736 GetPrivateProfileString(Section, "TerminalID", "",
737 Temp, sizeof(Temp), FName);
738 ts->TerminalID = str2id(TermList, Temp, IdVT100);
739
740 /* Russian character set (host) */
741 GetPrivateProfileString(Section, "RussHost", "",
742 Temp, sizeof(Temp), FName);
743 ts->RussHost = str2id(RussList, Temp, IdKOI8);
744
745 /* Russian character set (client) */
746 GetPrivateProfileString(Section, "RussClient", "",
747 Temp, sizeof(Temp), FName);
748 ts->RussClient = str2id(RussList, Temp, IdWindows);
749
750 /* Title String */
751 GetPrivateProfileString(Section, "Title", "Tera Term",
752 ts->Title, sizeof(ts->Title), FName);
753
754 /* Cursor shape */
755 GetPrivateProfileString(Section, "CursorShape", "",
756 Temp, sizeof(Temp), FName);
757 if (_stricmp(Temp, "vertical") == 0)
758 ts->CursorShape = IdVCur;
759 else if (_stricmp(Temp, "horizontal") == 0)
760 ts->CursorShape = IdHCur;
761 else
762 ts->CursorShape = IdBlkCur;
763
764 /* Hide title */
765 ts->HideTitle = GetOnOff(Section, "HideTitle", FName, FALSE);
766
767 /* Popup menu */
768 ts->PopupMenu = GetOnOff(Section, "PopupMenu", FName, FALSE);
769
770 /* PC-Style bold color mapping */
771 if (GetOnOff(Section, "PcBoldColor", FName, FALSE))
772 ts->ColorFlag |= CF_PCBOLD16;
773
774 /* aixterm style 16 colors mode */
775 if (GetOnOff(Section, "Aixterm16Color", FName, FALSE))
776 ts->ColorFlag |= CF_AIXTERM16;
777
778 /* xterm style 256 colors mode */
779 if (GetOnOff(Section, "Xterm256Color", FName, TRUE))
780 ts->ColorFlag |= CF_XTERM256;
781
782 /* Enable scroll buffer */
783 ts->EnableScrollBuff =
784 GetOnOff(Section, "EnableScrollBuff", FName, TRUE);
785
786 /* Scroll buffer size */
787 ts->ScrollBuffSize =
788 GetPrivateProfileInt(Section, "ScrollBuffSize", 100, FName);
789
790 /* VT Color */
791 GetPrivateProfileString(Section, "VTColor", "0,0,0,255,255,255",
792 Temp, sizeof(Temp), FName);
793 for (i = 0; i <= 5; i++)
794 GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
795 for (i = 0; i <= 1; i++)
796 ts->VTColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
797 (BYTE) ts->TmpColor[0][i * 3 + 1],
798 (BYTE) ts->TmpColor[0][i * 3 + 2]);
799
800 /* VT Bold Color */
801 GetPrivateProfileString(Section, "VTBoldColor", "0,0,255,255,255,255",
802 Temp, sizeof(Temp), FName);
803 for (i = 0; i <= 5; i++)
804 GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
805 for (i = 0; i <= 1; i++)
806 ts->VTBoldColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
807 (BYTE) ts->TmpColor[0][i * 3 + 1],
808 (BYTE) ts->TmpColor[0][i * 3 + 2]);
809 if (GetOnOff(Section, "EnableBoldAttrColor", FName, TRUE))
810 ts->ColorFlag |= CF_BOLDCOLOR;
811
812 /* VT Blink Color */
813 GetPrivateProfileString(Section, "VTBlinkColor", "255,0,0,255,255,255",
814 Temp, sizeof(Temp), FName);
815 for (i = 0; i <= 5; i++)
816 GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
817 for (i = 0; i <= 1; i++)
818 ts->VTBlinkColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
819 (BYTE) ts->TmpColor[0][i * 3 + 1],
820 (BYTE) ts->TmpColor[0][i * 3 + 2]);
821 if (GetOnOff(Section, "EnableBlinkAttrColor", FName, TRUE))
822 ts->ColorFlag |= CF_BLINKCOLOR;
823
824 /* VT Reverse Color */
825 GetPrivateProfileString(Section, "VTReverseColor", "255,255,255,0,0,0",
826 Temp, sizeof(Temp), FName);
827 for (i = 0; i <= 5; i++)
828 GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
829 for (i = 0; i <= 1; i++)
830 ts->VTReverseColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
831 (BYTE) ts->TmpColor[0][i * 3 + 1],
832 (BYTE) ts->TmpColor[0][i * 3 + 2]);
833 if (GetOnOff(Section, "EnableReverseAttrColor", FName, FALSE))
834 ts->ColorFlag |= CF_REVERSECOLOR;
835
836 ts->EnableClickableUrl =
837 GetOnOff(Section, "EnableClickableUrl", FName, FALSE);
838
839 /* URL Color */
840 GetPrivateProfileString(Section, "URLColor", "0,255,0,255,255,255",
841 Temp, sizeof(Temp), FName);
842 for (i = 0; i <= 5; i++)
843 GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
844 for (i = 0; i <= 1; i++)
845 ts->URLColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
846 (BYTE) ts->TmpColor[0][i * 3 + 1],
847 (BYTE) ts->TmpColor[0][i * 3 + 2]);
848 if (GetOnOff(Section, "EnableURLColor", FName, TRUE))
849 ts->ColorFlag |= CF_URLCOLOR;
850
851 if (GetOnOff(Section, "URLUnderline", FName, TRUE))
852 ts->FontFlag |= FF_URLUNDERLINE;
853
854 /* TEK Color */
855 GetPrivateProfileString(Section, "TEKColor", "0,0,0,255,255,255",
856 Temp, sizeof(Temp), FName);
857 for (i = 0; i <= 5; i++)
858 GetNthNum(Temp, i + 1, (int far *) &(ts->TmpColor[0][i]));
859 for (i = 0; i <= 1; i++)
860 ts->TEKColor[i] = RGB((BYTE) ts->TmpColor[0][i * 3],
861 (BYTE) ts->TmpColor[0][i * 3 + 1],
862 (BYTE) ts->TmpColor[0][i * 3 + 2]);
863
864 /* ANSI color definition (in the case FullColor=on) -- special option
865 o UseTextColor should be off, or the background and foreground color of
866 VTColor are assigned to color-number 0 and 7 respectively, even if
867 they are specified in ANSIColor.
868 o ANSIColor is a set of 4 values that are color-number(0--15),
869 red-value(0--255), green-value(0--255) and blue-value(0--255). */
870 GetPrivateProfileString(Section, "ANSIColor",
871 " 0, 0, 0, 0,"
872 " 1,255, 0, 0,"
873 " 2, 0,255, 0,"
874 " 3,255,255, 0,"
875 " 4, 0, 0,255,"
876 " 5,255, 0,255,"
877 " 6, 0,255,255,"
878 " 7,255,255,255,"
879 " 8,128,128,128,"
880 " 9,128, 0, 0,"
881 "10, 0,128, 0,"
882 "11,128,128, 0,"
883 "12, 0, 0,128,"
884 "13,128, 0,128,"
885 "14, 0,128,128,"
886 "15,192,192,192", Temp, sizeof(Temp), FName);
887 {
888 char *t;
889 int n = 1;
890 for (t = Temp; *t; t++)
891 if (*t == ',')
892 n++;
893 n /= 4;
894 for (i = 0; i < n; i++) {
895 int colorid, r, g, b;
896 GetNthNum(Temp, i * 4 + 1, (int far *) &colorid);
897 GetNthNum(Temp, i * 4 + 2, (int far *) &r);
898 GetNthNum(Temp, i * 4 + 3, (int far *) &g);
899 GetNthNum(Temp, i * 4 + 4, (int far *) &b);
900 ts->ANSIColor[colorid & 15] =
901 RGB((BYTE) r, (BYTE) g, (BYTE) b);
902 }
903 }
904
905 TmpDC = GetDC(0); /* Get screen device context */
906 for (i = 0; i <= 1; i++)
907 ts->VTColor[i] = GetNearestColor(TmpDC, ts->VTColor[i]);
908 for (i = 0; i <= 1; i++)
909 ts->VTBoldColor[i] = GetNearestColor(TmpDC, ts->VTBoldColor[i]);
910 for (i = 0; i <= 1; i++)
911 ts->VTBlinkColor[i] = GetNearestColor(TmpDC, ts->VTBlinkColor[i]);
912 for (i = 0; i <= 1; i++)
913 ts->TEKColor[i] = GetNearestColor(TmpDC, ts->TEKColor[i]);
914 /* begin - ishizaki */
915 for (i = 0; i <= 1; i++)
916 ts->URLColor[i] = GetNearestColor(TmpDC, ts->URLColor[i]);
917 /* end - ishizaki */
918 for (i = 0; i < 16; i++)
919 ts->ANSIColor[i] = GetNearestColor(TmpDC, ts->ANSIColor[i]);
920 ReleaseDC(0, TmpDC);
921 if (GetOnOff(Section, "EnableANSIColor", FName, TRUE))
922 ts->ColorFlag |= CF_ANSICOLOR;
923
924 /* TEK color emulation */
925 ts->TEKColorEmu = GetOnOff(Section, "TEKColorEmulation", FName, FALSE);
926
927 /* VT Font */
928 GetPrivateProfileString(Section, "VTFont", "Terminal,0,-13,1",
929 Temp, sizeof(Temp), FName);
930 GetNthString(Temp, 1, sizeof(ts->VTFont), ts->VTFont);
931 GetNthNum(Temp, 2, (int far *) &(ts->VTFontSize.x));
932 GetNthNum(Temp, 3, (int far *) &(ts->VTFontSize.y));
933 GetNthNum(Temp, 4, &(ts->VTFontCharSet));
934
935 /* Bold font flag */
936 if (GetOnOff(Section, "EnableBold", FName, TRUE))
937 ts->FontFlag |= FF_BOLD;
938
939 /* Russian character set (font) */
940 GetPrivateProfileString(Section, "RussFont", "",
941 Temp, sizeof(Temp), FName);
942 ts->RussFont = str2id(RussList, Temp, IdWindows);
943
944 /* TEK Font */
945 GetPrivateProfileString(Section, "TEKFont", "Courier,0,-13,0",
946 Temp, sizeof(Temp), FName);
947 GetNthString(Temp, 1, sizeof(ts->TEKFont), ts->TEKFont);
948 GetNthNum(Temp, 2, (int far *) &(ts->TEKFontSize.x));
949 GetNthNum(Temp, 3, (int far *) &(ts->TEKFontSize.y));
950 GetNthNum(Temp, 4, &(ts->TEKFontCharSet));
951
952 /* BS key */
953 GetPrivateProfileString(Section, "BSKey", "",
954 Temp, sizeof(Temp), FName);
955 if (_stricmp(Temp, "DEL") == 0)
956 ts->BSKey = IdDEL;
957 else
958 ts->BSKey = IdBS;
959 /* Delete key */
960 ts->DelKey = GetOnOff(Section, "DeleteKey", FName, FALSE);
961
962 /* Meta Key */
963 GetPrivateProfileString(Section, "MetaKey", "off", Temp, sizeof(Temp), FName);
964 if (_stricmp(Temp, "on") == 0)
965 ts->MetaKey = IdMetaOn;
966 else if (_stricmp(Temp, "left") == 0)
967 ts->MetaKey = IdMetaLeft;
968 else if (_stricmp(Temp, "right") == 0)
969 ts->MetaKey = IdMetaRight;
970 else
971 ts->MetaKey = IdMetaOff;
972
973 // Windows95 �n�����E�� Alt ��������������
974 if (!IsWindowsNTKernel() && ts->MetaKey != IdMetaOff) {
975 ts->MetaKey = IdMetaOn;
976 }
977
978 /* Application Keypad */
979 ts->DisableAppKeypad =
980 GetOnOff(Section, "DisableAppKeypad", FName, FALSE);
981
982 /* Application Cursor */
983 ts->DisableAppCursor =
984 GetOnOff(Section, "DisableAppCursor", FName, FALSE);
985
986 /* Russian keyboard type */
987 GetPrivateProfileString(Section, "RussKeyb", "",
988 Temp, sizeof(Temp), FName);
989 ts->RussKeyb = str2id(RussList2, Temp, IdWindows);
990
991 /* Serial port ID */
992 ts->ComPort = GetPrivateProfileInt(Section, "ComPort", 1, FName);
993
994 /* Baud rate */
995 ts->Baud = GetPrivateProfileInt(Section, "BaudRate", 9600, FName);
996
997 /* Parity */
998 GetPrivateProfileString(Section, "Parity", "",
999 Temp, sizeof(Temp), FName);
1000 if (_stricmp(Temp, "even") == 0)
1001 ts->Parity = IdParityEven;
1002 else if (_stricmp(Temp, "odd") == 0)
1003 ts->Parity = IdParityOdd;
1004 else if (_stricmp(Temp, "mark") == 0)
1005 ts->Parity = IdParityMark;
1006 else if (_stricmp(Temp, "space") == 0)
1007 ts->Parity = IdParitySpace;
1008 else
1009 ts->Parity = IdParityNone;
1010
1011 /* Data bit */
1012 GetPrivateProfileString(Section, "DataBit", "",
1013 Temp, sizeof(Temp), FName);
1014 if (_stricmp(Temp, "7") == 0)
1015 ts->DataBit = IdDataBit7;
1016 else
1017 ts->DataBit = IdDataBit8;
1018
1019 /* Stop bit */
1020 GetPrivateProfileString(Section, "StopBit", "",
1021 Temp, sizeof(Temp), FName);
1022 if (_stricmp(Temp, "2") == 0)
1023 ts->StopBit = IdStopBit2;
1024 else if (_stricmp(Temp, "1.5") == 0)
1025 ts->StopBit = IdStopBit15;
1026 else
1027 ts->StopBit = IdStopBit1;
1028
1029 /* Flow control */
1030 GetPrivateProfileString(Section, "FlowCtrl", "",
1031 Temp, sizeof(Temp), FName);
1032 if (_stricmp(Temp, "x") == 0)
1033 ts->Flow = IdFlowX;
1034 else if (_stricmp(Temp, "hard") == 0)
1035 ts->Flow = IdFlowHard;
1036 else
1037 ts->Flow = IdFlowNone;
1038
1039 /* Delay per character */
1040 ts->DelayPerChar =
1041 GetPrivateProfileInt(Section, "DelayPerChar", 0, FName);
1042
1043 /* Delay per line */
1044 ts->DelayPerLine =
1045 GetPrivateProfileInt(Section, "DelayPerLine", 0, FName);
1046
1047 /* Telnet flag */
1048 ts->Telnet = GetOnOff(Section, "Telnet", FName, TRUE);
1049
1050 /* Telnet terminal type */
1051 GetPrivateProfileString(Section, "TermType", "xterm", ts->TermType,
1052 sizeof(ts->TermType), FName);
1053
1054 /* TCP port num */
1055 ts->TCPPort =
1056 GetPrivateProfileInt(Section, "TCPPort", ts->TelPort, FName);
1057
1058 /* Auto window close flag */
1059 ts->AutoWinClose = GetOnOff(Section, "AutoWinClose", FName, TRUE);
1060
1061 /* History list */
1062 ts->HistoryList = GetOnOff(Section, "HistoryList", FName, FALSE);
1063
1064 /* File transfer binary flag */
1065 ts->TransBin = GetOnOff(Section, "TransBin", FName, FALSE);
1066
1067 /* Log binary flag */
1068 ts->LogBinary = GetOnOff(Section, "LogBinary", FName, FALSE);
1069
1070 /* Log append */
1071 ts->Append = GetOnOff(Section, "LogAppend", FName, FALSE);
1072
1073 /* Log plain text (2005.5.7 yutaka) */
1074 ts->LogTypePlainText =
1075 GetOnOff(Section, "LogTypePlainText", FName, FALSE);
1076
1077 /* Log with timestamp (2006.7.23 maya) */
1078 ts->LogTimestamp = GetOnOff(Section, "LogTimestamp", FName, FALSE);
1079
1080 /* Log without transfer dialog */
1081 ts->LogHideDialog = GetOnOff(Section, "LogHideDialog", FName, FALSE);
1082
1083 ts->LogAllBuffIncludedInFirst = GetOnOff(Section, "LogIncludeScreenBuffer", FName, FALSE);
1084
1085 /* Timestamp format of Log each line */
1086 GetPrivateProfileString(Section, "LogTimestampFormat", "%Y-%m-%d %H:%M:%S.%N",
1087 ts->LogTimestampFormat, sizeof(ts->LogTimestampFormat),
1088 FName);
1089
1090 /* Timestamp type */
1091 GetPrivateProfileString(Section, "LogTimestampType", "", Temp, sizeof(Temp), FName);
1092 if (_stricmp(Temp, "UTC") == 0)
1093 ts->LogTimestampType = TIMESTAMP_UTC;
1094 else if (_stricmp(Temp, "LoggingElapsed") == 0)
1095 ts->LogTimestampType = TIMESTAMP_ELAPSED_LOGSTART;
1096 else if (_stricmp(Temp, "ConnectionElapsed") == 0)
1097 ts->LogTimestampType = TIMESTAMP_ELAPSED_CONNECTED;
1098 else if (_stricmp(Temp, "") == 0 && GetOnOff(Section, "LogTimestampUTC", FName, FALSE))
1099 // LogTimestampType ���������������� LogTimestampUTC ���l���Q������
1100 ts->LogTimestampType = TIMESTAMP_UTC;
1101 else
1102 ts->LogTimestampType = TIMESTAMP_LOCAL;
1103
1104 /* File Transfer dialog visibility */
1105 ts->FTHideDialog = GetOnOff(Section, "FTHideDialog", FName, FALSE);
1106
1107 /* Default Log file name (2006.8.28 maya) */
1108 GetPrivateProfileString(Section, "LogDefaultName", "teraterm.log",
1109 ts->LogDefaultName, sizeof(ts->LogDefaultName),
1110 FName);
1111
1112 /* Default Log file path (2007.5.30 maya) */
1113 GetPrivateProfileString(Section, "LogDefaultPath", "",
1114 ts->LogDefaultPath, sizeof(ts->LogDefaultPath),
1115 FName);
1116
1117 /* Auto start logging (2007.5.31 maya) */
1118 ts->LogAutoStart = GetOnOff(Section, "LogAutoStart", FName, FALSE);
1119
1120 /* Log Rotate (2013.3.24 yutaka) */
1121 ts->LogRotate = GetPrivateProfileInt(Section, "LogRotate", 0, FName);
1122 ts->LogRotateSize = GetPrivateProfileInt(Section, "LogRotateSize", 0, FName);
1123 ts->LogRotateSizeType = GetPrivateProfileInt(Section, "LogRotateSizeType", 0, FName);
1124 ts->LogRotateStep = GetPrivateProfileInt(Section, "LogRotateStep", 0, FName);
1125
1126 /* Deferred Log Write Mode (2013.4.20 yutaka) */
1127 ts->DeferredLogWriteMode = GetOnOff(Section, "DeferredLogWriteMode", FName, TRUE);
1128
1129
1130 /* XMODEM option */
1131 GetPrivateProfileString(Section, "XmodemOpt", "",
1132 Temp, sizeof(Temp), FName);
1133 if (_stricmp(Temp, "crc") == 0)
1134 ts->XmodemOpt = XoptCRC;
1135 else if (_stricmp(Temp, "1k") == 0)
1136 ts->XmodemOpt = Xopt1kCRC;
1137 else if (_stricmp(Temp, "1ksum") == 0)
1138 ts->XmodemOpt = Xopt1kCksum;
1139 else
1140 ts->XmodemOpt = XoptCheck;
1141
1142 /* XMODEM binary file */
1143 ts->XmodemBin = GetOnOff(Section, "XmodemBin", FName, TRUE);
1144
1145 /* XMODEM ���M�R�}���h (2007.12.21 yutaka) */
1146 GetPrivateProfileString(Section, "XModemRcvCommand", "",
1147 ts->XModemRcvCommand,
1148 sizeof(ts->XModemRcvCommand), FName);
1149
1150 /* Default directory for file transfer */
1151 GetPrivateProfileString(Section, "FileDir", "",
1152 ts->FileDir, sizeof(ts->FileDir), FName);
1153 if (strlen(ts->FileDir) == 0)
1154 GetDownloadFolder(ts->FileDir, sizeof(ts->FileDir));
1155 else {
1156 _getcwd(Temp, sizeof(Temp));
1157 if (_chdir(ts->FileDir) != 0)
1158 GetDownloadFolder(ts->FileDir, sizeof(ts->FileDir));
1159 _chdir(Temp);
1160 }
1161
1162 /* filter on file send (2007.6.5 maya) */
1163 GetPrivateProfileString(Section, "FileSendFilter", "",
1164 ts->FileSendFilter, sizeof(ts->FileSendFilter),
1165 FName);
1166
1167 /* SCP���M���p�X (2012.4.6 yutaka) */
1168 GetPrivateProfileString(Section, "ScpSendDir", "",
1169 ts->ScpSendDir, sizeof(ts->ScpSendDir), FName);
1170
1171
1172 /*--------------------------------------------------*/
1173 /* 8 bit control code flag -- special option */
1174 if (GetOnOff(Section, "Accept8BitCtrl", FName, TRUE))
1175 ts->TermFlag |= TF_ACCEPT8BITCTRL;
1176
1177 /* Wrong sequence flag -- special option */
1178 if (GetOnOff(Section, "AllowWrongSequence", FName, FALSE))
1179 ts->TermFlag |= TF_ALLOWWRONGSEQUENCE;
1180
1181 if (((ts->TermFlag & TF_ALLOWWRONGSEQUENCE) == 0) &&
1182 (ts->KanjiOut == IdKanjiOutH))
1183 ts->KanjiOut = IdKanjiOutJ;
1184
1185 // Detect disconnect/reconnect of serial port --- special option
1186 ts->AutoComPortReconnect = GetOnOff(Section, "AutoComPortReconnect", FName, TRUE);
1187
1188 // Auto file renaming --- special option
1189 if (GetOnOff(Section, "AutoFileRename", FName, FALSE))
1190 ts->FTFlag |= FT_RENAME;
1191
1192 // Auto invoking (character set->G0->GL) --- special option
1193 if (GetOnOff(Section, "AutoInvoke", FName, FALSE))
1194 ts->TermFlag |= TF_AUTOINVOKE;
1195
1196 // Auto text copy --- special option
1197 ts->AutoTextCopy = GetOnOff(Section, "AutoTextCopy", FName, TRUE);
1198
1199 /* Back wrap -- special option */
1200 if (GetOnOff(Section, "BackWrap", FName, FALSE))
1201 ts->TermFlag |= TF_BACKWRAP;
1202
1203 /* Beep type -- special option */
1204 GetPrivateProfileString(Section, "Beep", "", Temp, sizeof(Temp), FName);
1205 if (_stricmp(Temp, "off") == 0)
1206 ts->Beep = IdBeepOff;
1207 else if (_stricmp(Temp, "visual") == 0)
1208 ts->Beep = IdBeepVisual;
1209 else
1210 ts->Beep = IdBeepOn;
1211
1212 /* Beep on connection & disconnection -- special option */
1213 if (GetOnOff(Section, "BeepOnConnect", FName, FALSE))
1214 ts->PortFlag |= PF_BEEPONCONNECT;
1215
1216 /* Auto B-Plus activation -- special option */
1217 if (GetOnOff(Section, "BPAuto", FName, FALSE))
1218 ts->FTFlag |= FT_BPAUTO;
1219 if ((ts->FTFlag & FT_BPAUTO) != 0) { /* Answerback */
1220 strncpy_s(ts->Answerback, sizeof(ts->Answerback), "\020++\0200",
1221 _TRUNCATE);
1222 ts->AnswerbackLen = 5;
1223 }
1224
1225 /* B-Plus ESCCTL flag -- special option */
1226 if (GetOnOff(Section, "BPEscCtl", FName, FALSE))
1227 ts->FTFlag |= FT_BPESCCTL;
1228
1229 /* B-Plus log -- special option */
1230 if (GetOnOff(Section, "BPLog", FName, FALSE))
1231 ts->LogFlag |= LOG_BP;
1232
1233 /* Clear serial port buffer when port opening -- special option */
1234 ts->ClearComBuffOnOpen =
1235 GetOnOff(Section, "ClearComBuffOnOpen", FName, TRUE);
1236
1237 /* When serial port is specified with with /C= option and the port does not exist, Tera Term will wait for port connection. */
1238 ts->WaitCom = GetOnOff(Section, "WaitCom", FName, FALSE);
1239
1240 /* Confirm disconnection -- special option */
1241 if (GetOnOff(Section, "ConfirmDisconnect", FName, TRUE))
1242 ts->PortFlag |= PF_CONFIRMDISCONN;
1243
1244 /* Ctrl code in Kanji -- special option */
1245 if (GetOnOff(Section, "CtrlInKanji", FName, TRUE))
1246 ts->TermFlag |= TF_CTRLINKANJI;
1247
1248 /* Debug flag -- special option */
1249 ts->Debug = GetOnOff(Section, "Debug", FName, FALSE);
1250
1251 /* Delimiter list -- special option */
1252 GetPrivateProfileString(Section, "DelimList",
1253 "$20!\"#$24%&\'()*+,-./:;<=>?@[\\]^`{|}~",
1254 Temp, sizeof(Temp), FName);
1255 Hex2Str(Temp, ts->DelimList, sizeof(ts->DelimList));
1256
1257 /* regard DBCS characters as delimiters -- special option */
1258 ts->DelimDBCS = GetOnOff(Section, "DelimDBCS", FName, TRUE);
1259
1260 // Enable popup menu -- special option
1261 if (!GetOnOff(Section, "EnablePopupMenu", FName, TRUE))
1262 ts->MenuFlag |= MF_NOPOPUP;
1263
1264 // Enable "Show menu" -- special option
1265 if (!GetOnOff(Section, "EnableShowMenu", FName, TRUE))
1266 ts->MenuFlag |= MF_NOSHOWMENU;
1267
1268 // Enable the status line -- special option
1269 if (GetOnOff(Section, "EnableStatusLine", FName, TRUE))
1270 ts->TermFlag |= TF_ENABLESLINE;
1271
1272 // Enable multiple bytes send -- special option
1273 ts->FileSendHighSpeedMode = GetOnOff(Section, "FileSendHighSpeedMode", FName, TRUE);
1274
1275 // fixed JIS --- special
1276 if (GetOnOff(Section, "FixedJIS", FName, FALSE))
1277 ts->TermFlag |= TF_FIXEDJIS;
1278
1279 /* IME Flag -- special option */
1280 ts->UseIME = GetOnOff(Section, "IME", FName, TRUE);
1281
1282 /* IME-inline Flag -- special option */
1283 ts->IMEInline = GetOnOff(Section, "IMEInline", FName, TRUE);
1284
1285 /* Kermit log -- special option */
1286 if (GetOnOff(Section, "KmtLog", FName, FALSE))
1287 ts->LogFlag |= LOG_KMT;
1288 if (GetOnOff(Section, "KmtLongPacket", FName, FALSE))
1289 ts->KermitOpt |= KmtOptLongPacket;
1290 if (GetOnOff(Section, "KmtFileAttr", FName, FALSE))
1291 ts->KermitOpt |= KmtOptFileAttr;
1292
1293 // Enable language selection -- special option
1294 if (!GetOnOff(Section, "LanguageSelection", FName, TRUE))
1295 ts->MenuFlag |= MF_NOLANGUAGE;
1296
1297 /* Maximum scroll buffer size -- special option */
1298 ts->ScrollBuffMax =
1299 GetPrivateProfileInt(Section, "MaxBuffSize", 10000, FName);
1300 if (ts->ScrollBuffMax < 24)
1301 ts->ScrollBuffMax = 10000;
1302
1303 /* Max com port number -- special option */
1304 ts->MaxComPort = GetPrivateProfileInt(Section, "MaxComPort", 256, FName);
1305 if (ts->MaxComPort < 4)
1306 ts->MaxComPort = 4;
1307 if (ts->MaxComPort > MAXCOMPORT)
1308 ts->MaxComPort = MAXCOMPORT;
1309 if ((ts->ComPort < 1) || (ts->ComPort > ts->MaxComPort))
1310 ts->ComPort = 1;
1311
1312 /* Non-blinking cursor -- special option */
1313 ts->NonblinkingCursor =
1314 GetOnOff(Section, "NonblinkingCursor", FName, FALSE);
1315
1316 // �t�H�[�J�X���������|���S���J�[�\�� (2008.1.24 yutaka)
1317 ts->KillFocusCursor =
1318 GetOnOff(Section, "KillFocusCursor", FName, TRUE);
1319
1320 /* Delay for pass-thru printing activation */
1321 /* -- special option */
1322 ts->PassThruDelay =
1323 GetPrivateProfileInt(Section, "PassThruDelay", 3, FName);
1324
1325 /* Printer port for pass-thru printing */
1326 /* -- special option */
1327 GetPrivateProfileString(Section, "PassThruPort", "",
1328 ts->PrnDev, sizeof(ts->PrnDev), FName);
1329
1330 /* �v�����^�p�����R�[�h�������t������ */
1331 if (GetOnOff(Section, "PrinterCtrlSequence", FName, TRUE))
1332 ts->TermFlag |= TF_PRINTERCTRL;
1333
1334 /* Printer Font --- special option */
1335 GetPrivateProfileString(Section, "PrnFont", "",
1336 Temp, sizeof(Temp), FName);
1337 if (strlen(Temp) == 0) {
1338 ts->PrnFont[0] = 0;
1339 ts->PrnFontSize.x = 0;
1340 ts->PrnFontSize.y = 0;
1341 ts->PrnFontCharSet = 0;
1342 }
1343 else {
1344 GetNthString(Temp, 1, sizeof(ts->PrnFont), ts->PrnFont);
1345 GetNthNum(Temp, 2, (int far *) &(ts->PrnFontSize.x));
1346 GetNthNum(Temp, 3, (int far *) &(ts->PrnFontSize.y));
1347 GetNthNum(Temp, 4, &(ts->PrnFontCharSet));
1348 }
1349
1350 // Page margins (left, right, top, bottom) for printing
1351 // -- special option
1352 GetPrivateProfileString(Section, "PrnMargin", "50,50,50,50",
1353 Temp, sizeof(Temp), FName);
1354 for (i = 0; i <= 3; i++)
1355 GetNthNum(Temp, 1 + i, &ts->PrnMargin[i]);
1356
1357 /* Disable (convert to NL) Form Feed when printing */
1358 /* --- special option */
1359 ts->PrnConvFF =
1360 GetOnOff(Section, "PrnConvFF", FName, FALSE);
1361
1362 /* Quick-VAN log -- special option */
1363 if (GetOnOff(Section, "QVLog", FName, FALSE))
1364 ts->LogFlag |= LOG_QV;
1365
1366 /* Quick-VAN window size -- special */
1367 ts->QVWinSize = GetPrivateProfileInt(Section, "QVWinSize", 8, FName);
1368
1369 /* Russian character set (print) -- special option */
1370 GetPrivateProfileString(Section, "RussPrint", "",
1371 Temp, sizeof(Temp), FName);
1372 ts->RussPrint = str2id(RussList, Temp, IdWindows);
1373
1374 /* Scroll threshold -- special option */
1375 ts->ScrollThreshold =
1376 GetPrivateProfileInt(Section, "ScrollThreshold", 12, FName);
1377
1378 ts->MouseWheelScrollLine =
1379 GetPrivateProfileInt(Section, "MouseWheelScrollLine", 3, FName);
1380
1381 // Select on activate -- special option
1382 ts->SelOnActive = GetOnOff(Section, "SelectOnActivate", FName, TRUE);
1383
1384 /* Send 8bit control sequence -- special option */
1385 ts->Send8BitCtrl = GetOnOff(Section, "Send8BitCtrl", FName, FALSE);
1386
1387 /* SendBreak time (in msec) -- special option */
1388 ts->SendBreakTime =
1389 GetPrivateProfileInt(Section, "SendBreakTime", 1000, FName);
1390
1391 /* Startup macro -- special option */
1392 GetPrivateProfileString(Section, "StartupMacro", "",
1393 ts->MacroFN, sizeof(ts->MacroFN), FName);
1394
1395 /* TEK GIN Mouse keycode -- special option */
1396 ts->GINMouseCode =
1397 GetPrivateProfileInt(Section, "TEKGINMouseCode", 32, FName);
1398
1399 /* Telnet Auto Detect -- special option */
1400 ts->TelAutoDetect = GetOnOff(Section, "TelAutoDetect", FName, TRUE);
1401
1402 /* Telnet binary flag -- special option */
1403 ts->TelBin = GetOnOff(Section, "TelBin", FName, FALSE);
1404
1405 /* Telnet Echo flag -- special option */
1406 ts->TelEcho = GetOnOff(Section, "TelEcho", FName, FALSE);
1407
1408 /* Telnet log -- special option */
1409 if (GetOnOff(Section, "TelLog", FName, FALSE))
1410 ts->LogFlag |= LOG_TEL;
1411
1412 /* TCP port num for telnet -- special option */
1413 ts->TelPort = GetPrivateProfileInt(Section, "TelPort", 23, FName);
1414
1415 /* Telnet keep-alive packet(NOP command) interval -- special option */
1416 ts->TelKeepAliveInterval =
1417 GetPrivateProfileInt(Section, "TelKeepAliveInterval", 300, FName);
1418
1419 /* Max number of broadcast commad history */
1420 ts->MaxBroadcatHistory =
1421 GetPrivateProfileInt(Section, "MaxBroadcatHistory", 99, FName);
1422
1423 /* Local echo for non-telnet */
1424 ts->TCPLocalEcho = GetOnOff(Section, "TCPLocalEcho", FName, FALSE);
1425
1426 /* "new-line (transmit)" option for non-telnet -- special option */
1427 GetPrivateProfileString(Section, "TCPCRSend", "",
1428 Temp, sizeof(Temp), FName);
1429 if (_stricmp(Temp, "CR") == 0)
1430 ts->TCPCRSend = IdCR;
1431 else if (_stricmp(Temp, "CRLF") == 0)
1432 ts->TCPCRSend = IdCRLF;
1433 else
1434 ts->TCPCRSend = 0; // disabled
1435
1436 /* Use text (background) color for "white (black)" --- special option */
1437 if (GetOnOff(Section, "UseTextColor", FName, FALSE))
1438 ts->ColorFlag |= CF_USETEXTCOLOR;
1439
1440 /* Title format -- special option */
1441 ts->TitleFormat =
1442 GetPrivateProfileInt(Section, "TitleFormat", 13, FName);
1443
1444 /* VT Compatible Tab -- special option */
1445 ts->VTCompatTab = GetOnOff(Section, "VTCompatTab", FName, FALSE);
1446
1447 /* VT Font space --- special option */
1448 GetPrivateProfileString(Section, "VTFontSpace", "0,0,0,0",
1449 Temp, sizeof(Temp), FName);
1450 GetNthNum(Temp, 1, &ts->FontDX);
1451 GetNthNum(Temp, 2, &ts->FontDW);
1452 GetNthNum(Temp, 3, &ts->FontDY);
1453 GetNthNum(Temp, 4, &ts->FontDH);
1454 if (ts->FontDX < 0)
1455 ts->FontDX = 0;
1456 if (ts->FontDW < 0)
1457 ts->FontDW = 0;
1458 ts->FontDW = ts->FontDW + ts->FontDX;
1459 if (ts->FontDY < 0)
1460 ts->FontDY = 0;
1461 if (ts->FontDH < 0)
1462 ts->FontDH = 0;
1463 ts->FontDH = ts->FontDH + ts->FontDY;
1464
1465 // VT-print scaling factors (pixels per inch) --- special option
1466 GetPrivateProfileString(Section, "VTPPI", "0,0",
1467 Temp, sizeof(Temp), FName);
1468 GetNthNum(Temp, 1, (int far *) &ts->VTPPI.x);
1469 GetNthNum(Temp, 2, (int far *) &ts->VTPPI.y);
1470
1471 // TEK-print scaling factors (pixels per inch) --- special option
1472 GetPrivateProfileString(Section, "TEKPPI", "0,0",
1473 Temp, sizeof(Temp), FName);
1474 GetNthNum(Temp, 1, (int far *) &ts->TEKPPI.x);
1475 GetNthNum(Temp, 2, (int far *) &ts->TEKPPI.y);
1476
1477 // Show "Window" menu -- special option
1478 if (GetOnOff(Section, "WindowMenu", FName, TRUE))
1479 ts->MenuFlag |= MF_SHOWWINMENU;
1480
1481 /* XMODEM log -- special option */
1482 if (GetOnOff(Section, "XmodemLog", FName, FALSE))
1483 ts->LogFlag |= LOG_X;
1484
1485 /* YMODEM log -- special option */
1486 if (GetOnOff(Section, "YmodemLog", FName, FALSE))
1487 ts->LogFlag |= LOG_Y;
1488
1489 /* YMODEM ���M�R�}���h (2010.3.23 yutaka) */
1490 GetPrivateProfileString(Section, "YModemRcvCommand", "rb",
1491 ts->YModemRcvCommand, sizeof(ts->YModemRcvCommand), FName);
1492
1493 /* Auto ZMODEM activation -- special option */
1494 if (GetOnOff(Section, "ZmodemAuto", FName, FALSE))
1495 ts->FTFlag |= FT_ZAUTO;
1496
1497 /* ZMODEM data subpacket length for sending -- special */
1498 ts->ZmodemDataLen =
1499 GetPrivateProfileInt(Section, "ZmodemDataLen", 1024, FName);
1500 /* ZMODEM window size for sending -- special */
1501 ts->ZmodemWinSize =
1502 GetPrivateProfileInt(Section, "ZmodemWinSize", 32767, FName);
1503
1504 /* ZMODEM ESCCTL flag -- special option */
1505 if (GetOnOff(Section, "ZmodemEscCtl", FName, FALSE))
1506 ts->FTFlag |= FT_ZESCCTL;
1507
1508 /* ZMODEM log -- special option */
1509 if (GetOnOff(Section, "ZmodemLog", FName, FALSE))
1510 ts->LogFlag |= LOG_Z;
1511
1512 /* ZMODEM ���M�R�}���h (2007.12.21 yutaka) */
1513 GetPrivateProfileString(Section, "ZModemRcvCommand", "rz",
1514 ts->ZModemRcvCommand, sizeof(ts->ZModemRcvCommand), FName);
1515
1516 /* Enable continued-line copy -- special option */
1517 ts->EnableContinuedLineCopy =
1518 GetOnOff(Section, "EnableContinuedLineCopy", FName, FALSE);
1519
1520 if (GetOnOff(Section, "DisablePasteMouseRButton", FName, FALSE))
1521 ts->PasteFlag |= CPF_DISABLE_RBUTTON;
1522
1523 if (GetOnOff(Section, "DisablePasteMouseMButton", FName, TRUE))
1524 ts->PasteFlag |= CPF_DISABLE_MBUTTON;
1525
1526 if (GetOnOff(Section, "ConfirmPasteMouseRButton", FName, FALSE))
1527 ts->PasteFlag |= CPF_CONFIRM_RBUTTON;
1528
1529 if (GetOnOff(Section, "ConfirmChangePaste", FName, TRUE))
1530 ts->PasteFlag |= CPF_CONFIRM_CHANGEPASTE;
1531
1532 if (GetOnOff(Section, "ConfirmChangePasteCR", FName, TRUE))
1533 ts->PasteFlag |= CPF_CONFIRM_CHANGEPASTE_CR;
1534
1535 GetPrivateProfileString(Section, "ConfirmChangePasteStringFile", "",
1536 Temp, sizeof(Temp), FName);
1537
1538 strncpy_s(ts->ConfirmChangePasteStringFile, sizeof(ts->ConfirmChangePasteStringFile), Temp,
1539 _TRUNCATE);
1540
1541 // added ScrollWindowClearScreen (2008.5.3 yutaka)
1542 ts->ScrollWindowClearScreen =
1543 GetOnOff(Section, "ScrollWindowClearScreen", FName, TRUE);
1544
1545 // added SelectOnlyByLButton (2007.11.20 maya)
1546 ts->SelectOnlyByLButton =
1547 GetOnOff(Section, "SelectOnlyByLButton", FName, TRUE);
1548
1549 // added DisableAcceleratorSendBreak (2007.3.17 maya)
1550 ts->DisableAcceleratorSendBreak =
1551 GetOnOff(Section, "DisableAcceleratorSendBreak", FName, FALSE);
1552
1553 // WinSock connecting timeout value (2007.1.11 yutaka)
1554 ts->ConnectingTimeout =
1555 GetPrivateProfileInt(Section, "ConnectingTimeout", 0, FName);
1556
1557 // mouse cursor
1558 GetPrivateProfileString(Section, "MouseCursor", "IBEAM",
1559 Temp, sizeof(Temp), FName);
1560 strncpy_s(ts->MouseCursorName, sizeof(ts->MouseCursorName), Temp,
1561 _TRUNCATE);
1562
1563 // Translucent window
1564 ts->AlphaBlendInactive =
1565 GetPrivateProfileInt(Section, "AlphaBlend", 255, FName);
1566 ts->AlphaBlendInactive = max(0, ts->AlphaBlendInactive);
1567 ts->AlphaBlendInactive = min(255, ts->AlphaBlendInactive);
1568 ts->AlphaBlendActive =
1569 GetPrivateProfileInt(Section, "AlphaBlendActive", ts->AlphaBlendInactive, FName);
1570 ts->AlphaBlendActive = max(0, ts->AlphaBlendActive);
1571 ts->AlphaBlendActive = min(255, ts->AlphaBlendActive);
1572
1573 // Cygwin install path
1574 GetPrivateProfileString(Section, "CygwinDirectory ", "c:\\cygwin",
1575 Temp, sizeof(Temp), FName);
1576 strncpy_s(ts->CygwinDirectory, sizeof(ts->CygwinDirectory), Temp,
1577 _TRUNCATE);
1578
1579 // Viewlog Editor path
1580 if (GetWindowsDirectory(Temp, sizeof(Temp)) + 13 < sizeof(Temp)) { // "\\notepad.exe"(12) + NUL(1)
1581 strncat_s(Temp, sizeof(Temp), "\\notepad.exe", _TRUNCATE);
1582 }
1583 else {
1584 Temp[0] = '\0';
1585 }
1586 GetPrivateProfileString(Section, "ViewlogEditor ", Temp,
1587 ts->ViewlogEditor, sizeof(ts->ViewlogEditor), FName);
1588
1589 // Locale for UTF-8
1590 GetPrivateProfileString(Section, "Locale ", DEFAULT_LOCALE,
1591 Temp, sizeof(Temp), FName);
1592 strncpy_s(ts->Locale, sizeof(ts->Locale), Temp, _TRUNCATE);
1593
1594 // UI language message file (�����p�X)
1595 GetPrivateProfileString(Section, "UILanguageFile", "lang\\Default.lng",
1596 ts->UILanguageFile_ini, sizeof(ts->UILanguageFile_ini), FName);
1597
1598 // UI language message file (full path)
1599 GetUILanguageFileFull(ts->HomeDir, ts->UILanguageFile_ini,
1600 ts->UILanguageFile, sizeof(ts->UILanguageFile));
1601
1602 // Broadcast Command History (2007.3.3 maya)
1603 ts->BroadcastCommandHistory =
1604 GetOnOff(Section, "BroadcastCommandHistory", FName, FALSE);
1605
1606 // 337: 2007/03/20 Accept Broadcast
1607 ts->AcceptBroadcast =
1608 GetOnOff(Section, "AcceptBroadcast", FName, TRUE);
1609
1610 // Confirm send a file when drag and drop (2007.12.28 maya)
1611 ts->ConfirmFileDragAndDrop =
1612 GetOnOff(Section, "ConfirmFileDragAndDrop", FName, TRUE);
1613
1614 // Translate mouse wheel to cursor key when application cursor mode
1615 ts->TranslateWheelToCursor =
1616 GetOnOff(Section, "TranslateWheelToCursor", FName, TRUE);
1617
1618 // Display "New Connection" dialog on startup (2008.1.18 maya)
1619 ts->HostDialogOnStartup =
1620 GetOnOff(Section, "HostDialogOnStartup", FName, TRUE);
1621
1622 // Mouse event tracking
1623 ts->MouseEventTracking =
1624 GetOnOff(Section, "MouseEventTracking", FName, TRUE);
1625
1626 // Maximized bug tweak
1627 GetPrivateProfileString(Section, "MaximizedBugTweak", "2", Temp,
1628 sizeof(Temp), FName);
1629 if (_stricmp(Temp, "on") == 0) {
1630 ts->MaximizedBugTweak = 2;
1631 }
1632 else {
1633 ts->MaximizedBugTweak = atoi(Temp);
1634 }
1635
1636 // Convert Unicode symbol characters to DEC Special characters
1637 ts->UnicodeDecSpMapping =
1638 GetPrivateProfileInt(Section, "UnicodeToDecSpMapping", 3, FName);
1639
1640 // VT Window Icon
1641 GetPrivateProfileString(Section, "VTIcon", "Default",
1642 Temp, sizeof(Temp), FName);
1643 ts->VTIcon = IconName2IconId(Temp);
1644
1645 // Tek Window Icon
1646 GetPrivateProfileString(Section, "TEKIcon", "Default",
1647 Temp, sizeof(Temp), FName);
1648 ts->TEKIcon = IconName2IconId(Temp);
1649
1650 // Unknown Unicode Character
1651 ts->UnknownUnicodeCharaAsWide =
1652 GetOnOff(Section, "UnknownUnicodeCharacterAsWide", FName, FALSE);
1653
1654 #ifdef USE_NORMAL_BGCOLOR
1655 // UseNormalBGColor
1656 ts->UseNormalBGColor =
1657 GetOnOff(Section, "UseNormalBGColor", FName, FALSE);
1658 // 2006/03/11 by 337
1659 if (ts->UseNormalBGColor) {
1660 ts->VTBoldColor[1] =
1661 ts->VTBlinkColor[1] = ts->URLColor[1] = ts->VTColor[1];
1662 }
1663 #endif
1664
1665 // AutoScrollOnlyInBottomLine
1666 ts->AutoScrollOnlyInBottomLine =
1667 GetOnOff(Section, "AutoScrollOnlyInBottomLine", FName, FALSE);
1668
1669 // Accept remote-controlled window title changing
1670 GetPrivateProfileString(Section, "AcceptTitleChangeRequest", "overwrite",
1671 Temp, sizeof(Temp), FName);
1672 if (_stricmp(Temp, "overwrite") == 0 || _stricmp(Temp, "on") == 0)
1673 ts->AcceptTitleChangeRequest = IdTitleChangeRequestOverwrite;
1674 else if (_stricmp(Temp, "ahead") == 0)
1675 ts->AcceptTitleChangeRequest = IdTitleChangeRequestAhead;
1676 else if (_stricmp(Temp, "last") == 0)
1677 ts->AcceptTitleChangeRequest = IdTitleChangeRequestLast;
1678 else
1679 ts->AcceptTitleChangeRequest = IdTitleChangeRequestOff;
1680
1681 // Size of paste confirm dialog
1682 GetPrivateProfileString(Section, "PasteDialogSize", "330,220",
1683 Temp, sizeof(Temp), FName);
1684 GetNthNum(Temp, 1, &ts->PasteDialogSize.cx);
1685 GetNthNum(Temp, 2, &ts->PasteDialogSize.cy);
1686 if (ts->PasteDialogSize.cx < 0)
1687 ts->PasteDialogSize.cx = 330;
1688 if (ts->PasteDialogSize.cy < 0)
1689 ts->PasteDialogSize.cy = 220;
1690
1691 // Disable mouse event tracking when Control-Key is pressed.
1692 ts->DisableMouseTrackingByCtrl =
1693 GetOnOff(Section, "DisableMouseTrackingByCtrl", FName, TRUE);
1694
1695 // Disable TranslateWheelToCursor setting when Control-Key is pressed.
1696 ts->DisableWheelToCursorByCtrl =
1697 GetOnOff(Section, "DisableWheelToCursorByCtrl", FName, TRUE);
1698
1699 // Strict Key Mapping.
1700 ts->StrictKeyMapping =
1701 GetOnOff(Section, "StrictKeyMapping", FName, FALSE);
1702
1703 // added Wait4allMacroCommand (2009.3.23 yutaka)
1704 ts->Wait4allMacroCommand =
1705 GetOnOff(Section, "Wait4allMacroCommand", FName, FALSE);
1706
1707 // added DisableMenuSendBreak (2009.4.6 maya)
1708 ts->DisableMenuSendBreak =
1709 GetOnOff(Section, "DisableMenuSendBreak", FName, FALSE);
1710
1711 // added ClearScreenOnCloseConnection (2009.4.6 maya)
1712 ts->ClearScreenOnCloseConnection =
1713 GetOnOff(Section, "ClearScreenOnCloseConnection", FName, FALSE);
1714
1715 // added DisableAcceleratorDuplicateSession (2009.4.6 maya)
1716 ts->DisableAcceleratorDuplicateSession =
1717 GetOnOff(Section, "DisableAcceleratorDuplicateSession", FName, FALSE);
1718
1719 ts->AcceleratorNewConnection =
1720 GetOnOff(Section, "AcceleratorNewConnection", FName, TRUE);
1721
1722 ts->AcceleratorCygwinConnection =
1723 GetOnOff(Section, "AcceleratorCygwinConnection", FName, TRUE);
1724
1725 // added DisableMenuDuplicateSession (2010.8.3 maya)
1726 ts->DisableMenuDuplicateSession =
1727 GetOnOff(Section, "DisableMenuDuplicateSession", FName, FALSE);
1728
1729 // added DisableMenuNewConnection (2010.8.4 maya)
1730 ts->DisableMenuNewConnection =
1731 GetOnOff(Section, "DisableMenuNewConnection", FName, FALSE);
1732
1733 // added PasteDelayPerLine (2009.4.12 maya)
1734 ts->PasteDelayPerLine =
1735 GetPrivateProfileInt(Section, "PasteDelayPerLine", 10, FName);
1736 {
1737 int tmp = min(max(0, ts->PasteDelayPerLine), 5000);
1738 ts->PasteDelayPerLine = tmp;
1739 }
1740
1741 // Font scaling -- test
1742 ts->FontScaling = GetOnOff(Section, "FontScaling", FName, FALSE);
1743
1744 // Meta sets MSB
1745 GetPrivateProfileString(Section, "Meta8Bit", "off", Temp, sizeof(Temp), FName);
1746 if (_stricmp(Temp, "raw") == 0 || _stricmp(Temp, "on") == 0)
1747 ts->Meta8Bit = IdMeta8BitRaw;
1748 else if (_stricmp(Temp, "text") == 0)
1749 ts->Meta8Bit = IdMeta8BitText;
1750 else
1751 ts->Meta8Bit = IdMeta8BitOff;
1752
1753 // Window control sequence
1754 if (GetOnOff(Section, "WindowCtrlSequence", FName, TRUE))
1755 ts->WindowFlag |= WF_WINDOWCHANGE;
1756
1757 // Cursor control sequence
1758 if (GetOnOff(Section, "CursorCtrlSequence", FName, FALSE))
1759 ts->WindowFlag |= WF_CURSORCHANGE;
1760
1761 // Window report sequence
1762 if (GetOnOff(Section, "WindowReportSequence", FName, TRUE))
1763 ts->WindowFlag |= WF_WINDOWREPORT;
1764
1765 // Title report sequence
1766 GetPrivateProfileString(Section, "TitleReportSequence", "Empty", Temp, sizeof(Temp), FName);
1767 if (_stricmp(Temp, "accept") == 0)
1768 ts->WindowFlag |= IdTitleReportAccept;
1769 else if (_stricmp(Temp, "ignore") == 0 || _stricmp(Temp, "off") == 0)
1770 ts->WindowFlag &= ~WF_TITLEREPORT;
1771 else // empty
1772 ts->WindowFlag |= IdTitleReportEmpty;
1773
1774 // Line at a time mode
1775 ts->EnableLineMode = GetOnOff(Section, "EnableLineMode", FName, TRUE);
1776
1777 // Clear window on resize
1778 if (GetOnOff(Section, "ClearOnResize", FName, TRUE))
1779 ts->TermFlag |= TF_CLEARONRESIZE;
1780
1781 // Alternate Screen Buffer
1782 if (GetOnOff(Section, "AlternateScreenBuffer", FName, TRUE))
1783 ts->TermFlag |= TF_ALTSCR;
1784
1785 // IME status related cursor style
1786 if (GetOnOff(Section, "IMERelatedCursor", FName, FALSE))
1787 ts->WindowFlag |= WF_IMECURSORCHANGE;
1788
1789 // Terminal Unique ID
1790 GetPrivateProfileString(Section, "TerminalUID", "FFFFFFFF", Temp, sizeof(Temp), FName);
1791 if (strlen(Temp) == 8) {
1792 for (i=0; i<8 && isxdigit((unsigned char)Temp[i]); i++) {
1793 if (islower(Temp[i])) {
1794 ts->TerminalUID[i] = toupper(Temp[i]);
1795 }
1796 else {
1797 ts->TerminalUID[i] = Temp[i];
1798 }
1799 }
1800 if (i == 8) {
1801 ts->TerminalUID[i] = 0;
1802 }
1803 else {
1804 strncpy_s(ts->TerminalUID, sizeof(ts->TerminalUID), "FFFFFFFF", _TRUNCATE);
1805 }
1806 }
1807 else {
1808 strncpy_s(ts->TerminalUID, sizeof(ts->TerminalUID), "FFFFFFFF", _TRUNCATE);
1809 }
1810
1811 // Lock Terminal UID
1812 if (GetOnOff(Section, "LockTUID", FName, TRUE))
1813 ts->TermFlag |= TF_LOCKTUID;
1814
1815 // Jump List
1816 ts->JumpList = GetOnOff(Section, "JumpList", FName, TRUE);
1817
1818 // TabStopModifySequence
1819 GetPrivateProfileString(Section, "TabStopModifySequence", "on", Temp, sizeof(Temp), FName);
1820 if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "all") == 0)
1821 ts->TabStopFlag = TABF_ALL;
1822 else if (_stricmp(Temp, "off") == 0 || _stricmp(Temp, "none") == 0)
1823 ts->TabStopFlag = TABF_NONE;
1824 else {
1825 ts->TabStopFlag = TABF_NONE;
1826 for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
1827 if (_stricmp(Temp2, "HTS") == 0)
1828 ts->TabStopFlag |= TABF_HTS;
1829 else if (_stricmp(Temp2, "HTS7") == 0)
1830 ts->TabStopFlag |= TABF_HTS7;
1831 else if (_stricmp(Temp2, "HTS8") == 0)
1832 ts->TabStopFlag |= TABF_HTS8;
1833 else if (_stricmp(Temp2, "TBC") == 0)
1834 ts->TabStopFlag |= TABF_TBC;
1835 else if (_stricmp(Temp2, "TBC0") == 0)
1836 ts->TabStopFlag |= TABF_TBC0;
1837 else if (_stricmp(Temp2, "TBC3") == 0)
1838 ts->TabStopFlag |= TABF_TBC3;
1839 }
1840 }
1841
1842 // Clipboard Access from Remote
1843 GetPrivateProfileString(Section, "ClipboardAccessFromRemote", "off", Temp, sizeof(Temp), FName);
1844 if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "readwrite") == 0)
1845 ts->CtrlFlag |= CSF_CBRW;
1846 else if (_stricmp(Temp, "read") == 0)
1847 ts->CtrlFlag |= CSF_CBREAD;
1848 else if (_stricmp(Temp, "write") == 0)
1849 ts->CtrlFlag |= CSF_CBWRITE;
1850
1851 // Notify Clipboard Access from Remote
1852 ts->NotifyClipboardAccess = GetOnOff(Section, "NotifyClipboardAccess", FName, TRUE);
1853
1854 // Use invalid DECRPSS (for testing)
1855 if (GetOnOff(Section, "UseInvalidDECRQSSResponse", FName, FALSE))
1856 ts->TermFlag |= TF_INVALIDDECRPSS;
1857
1858 // ClickableUrlBrowser
1859 GetPrivateProfileString(Section, "ClickableUrlBrowser", "",
1860 ts->ClickableUrlBrowser, sizeof(ts->ClickableUrlBrowser), FName);
1861 GetPrivateProfileString(Section, "ClickableUrlBrowserArg", "",
1862 ts->ClickableUrlBrowserArg, sizeof(ts->ClickableUrlBrowserArg), FName);
1863
1864 // Exclusive Lock when open the log file
1865 ts->LogLockExclusive = GetOnOff(Section, "LogLockExclusive", FName, TRUE);
1866
1867 // Font quality
1868 GetPrivateProfileString(Section, "FontQuality", "default",
1869 Temp, sizeof(Temp), FName);
1870 if (_stricmp(Temp, "nonantialiased") == 0)
1871 ts->FontQuality = NONANTIALIASED_QUALITY;
1872 else if (_stricmp(Temp, "antialiased") == 0)
1873 ts->FontQuality = ANTIALIASED_QUALITY;
1874 else if (_stricmp(Temp, "cleartype") == 0)
1875 ts->FontQuality = CLEARTYPE_QUALITY;
1876 else
1877 ts->FontQuality = DEFAULT_QUALITY;
1878
1879 // Beep Over Used
1880 ts->BeepOverUsedCount =
1881 GetPrivateProfileInt(Section, "BeepOverUsedCount", 5, FName);
1882 ts->BeepOverUsedTime =
1883 GetPrivateProfileInt(Section, "BeepOverUsedTime", 2, FName);
1884 ts->BeepSuppressTime =
1885 GetPrivateProfileInt(Section, "BeepSuppressTime", 5, FName);
1886
1887 // Max OSC string buffer size
1888 ts->MaxOSCBufferSize =
1889 GetPrivateProfileInt(Section, "MaxOSCBufferSize", 4096, FName);
1890
1891 ts->JoinSplitURL = GetOnOff(Section, "JoinSplitURL", FName, FALSE);
1892
1893 GetPrivateProfileString(Section, "JoinSplitURLIgnoreEOLChar", "\\", Temp, sizeof(Temp), FName);
1894 ts->JoinSplitURLIgnoreEOLChar = Temp[0];
1895
1896 // Debug modes.
1897 GetPrivateProfileString(Section, "DebugModes", "all", Temp, sizeof(Temp), FName);
1898 if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "all") == 0)
1899 ts->DebugModes = DBGF_ALL;
1900 else if (_stricmp(Temp, "off") == 0 || _stricmp(Temp, "none") == 0) {
1901 ts->DebugModes = DBGF_NONE;
1902 ts->Debug = FALSE;
1903 }
1904 else {
1905 ts->DebugModes = DBGF_NONE;
1906 for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
1907 if (_stricmp(Temp2, "normal") == 0)
1908 ts->DebugModes |= DBGF_NORM;
1909 else if (_stricmp(Temp2, "hex") == 0)
1910 ts->DebugModes |= DBGF_HEXD;
1911 else if (_stricmp(Temp2, "noout") == 0)
1912 ts->DebugModes |= DBGF_NOUT;
1913 }
1914 if (ts->DebugModes == DBGF_NONE)
1915 ts->Debug = FALSE;
1916 }
1917
1918 // Xmodem Timeout
1919 GetPrivateProfileString(Section, "XmodemTimeouts", "10,3,10,20,60", Temp, sizeof(Temp), FName);
1920 ts->XmodemTimeOutInit = GetNthNum2(Temp, 1, 10);
1921 if (ts->XmodemTimeOutInit < 1)
1922 ts->XmodemTimeOutInit = 1;
1923 ts->XmodemTimeOutInitCRC = GetNthNum2(Temp, 2, 3);
1924 if (ts->XmodemTimeOutInitCRC < 1)
1925 ts->XmodemTimeOutInitCRC = 1;
1926 ts->XmodemTimeOutShort = GetNthNum2(Temp, 3, 10);
1927 if (ts->XmodemTimeOutShort < 1)
1928 ts->XmodemTimeOutShort = 1;
1929 ts->XmodemTimeOutLong = GetNthNum2(Temp, 4, 20);
1930 if (ts->XmodemTimeOutLong < 1)
1931 ts->XmodemTimeOutLong = 1;
1932 ts->XmodemTimeOutVLong = GetNthNum2(Temp, 5, 60);
1933 if (ts->XmodemTimeOutVLong < 1)
1934 ts->XmodemTimeOutVLong = 1;
1935
1936 // Ymodem Timeout
1937 GetPrivateProfileString(Section, "YmodemTimeouts", "10,3,10,20,60", Temp, sizeof(Temp), FName);
1938 ts->YmodemTimeOutInit = GetNthNum2(Temp, 1, 10);
1939 if (ts->YmodemTimeOutInit < 1)
1940 ts->YmodemTimeOutInit = 1;
1941 ts->YmodemTimeOutInitCRC = GetNthNum2(Temp, 2, 3);
1942 if (ts->YmodemTimeOutInitCRC < 1)
1943 ts->YmodemTimeOutInitCRC = 1;
1944 ts->YmodemTimeOutShort = GetNthNum2(Temp, 3, 10);
1945 if (ts->YmodemTimeOutShort < 1)
1946 ts->YmodemTimeOutShort = 1;
1947 ts->YmodemTimeOutLong = GetNthNum2(Temp, 4, 20);
1948 if (ts->YmodemTimeOutLong < 1)
1949 ts->YmodemTimeOutLong = 1;
1950 ts->YmodemTimeOutVLong = GetNthNum2(Temp, 5, 60);
1951 if (ts->YmodemTimeOutVLong < 1)
1952 ts->YmodemTimeOutVLong = 1;
1953
1954 // Zmodem Timeout
1955 GetPrivateProfileString(Section, "ZmodemTimeouts", "10,0,10,3", Temp, sizeof(Temp), FName);
1956 ts->ZmodemTimeOutNormal = GetNthNum2(Temp, 1, 10);
1957 if (ts->ZmodemTimeOutNormal < 1)
1958 ts->ZmodemTimeOutNormal = 1;
1959 ts->ZmodemTimeOutTCPIP = GetNthNum2(Temp, 2, 0);
1960 if (ts->ZmodemTimeOutTCPIP < 0)
1961 ts->ZmodemTimeOutTCPIP = 0;
1962 ts->ZmodemTimeOutInit = GetNthNum2(Temp, 3, 10);
1963 if (ts->ZmodemTimeOutInit < 1)
1964 ts->ZmodemTimeOutInit = 1;
1965 ts->ZmodemTimeOutFin = GetNthNum2(Temp, 4, 3);
1966 if (ts->ZmodemTimeOutFin < 1)
1967 ts->ZmodemTimeOutFin = 1;
1968
1969 // Trim trailing new line character when pasting
1970 if (GetOnOff(Section, "TrimTrailingNLonPaste", FName, FALSE))
1971 ts->PasteFlag |= CPF_TRIM_TRAILING_NL;
1972
1973 // Normalize line break when pasting
1974 if (GetOnOff(Section, "NormalizeLineBreakOnPaste", FName, FALSE))
1975 ts->PasteFlag |= CPF_NORMALIZE_LINEBREAK;
1976
1977 // List Inactive Font
1978 ts->ListHiddenFonts = GetOnOff(Section, "ListHiddenFonts", FName, FALSE);
1979
1980 // ISO2022ShiftFunction
1981 GetPrivateProfileString(Section, "ISO2022ShiftFunction", "on", Temp, sizeof(Temp), FName);
1982 ts->ISO2022Flag = ISO2022_SHIFT_NONE;
1983 for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
1984 BOOL add=TRUE;
1985 char *p = Temp2, *p2;
1986 int mask = 0;
1987
1988 while (*p == ' ' || *p == '\t') {
1989 p++;
1990 }
1991 p2 = p + strlen(p);
1992 while (p2 > p) {
1993 p2--;
1994 if (*p2 != ' ' && *p2 != '\t') {
1995 break;
1996 }
1997 }
1998 *++p2 = 0;
1999
2000 if (*p == '-') {
2001 p++;
2002 add=FALSE;
2003 }
2004 else if (*p == '+') {
2005 p++;
2006 }
2007
2008 if (_stricmp(p, "on") == 0 || _stricmp(p, "all") == 0)
2009 ts->ISO2022Flag = ISO2022_SHIFT_ALL;
2010 else if (_stricmp(p, "off") == 0 || _stricmp(p, "none") == 0)
2011 ts->ISO2022Flag = ISO2022_SHIFT_NONE;
2012 else if (_stricmp(p, "SI") == 0 || _stricmp(p, "LS0") == 0)
2013 mask = ISO2022_SI;
2014 else if (_stricmp(p, "SO") == 0 || _stricmp(p, "LS1") == 0)
2015 mask = ISO2022_SO;
2016 else if (_stricmp(p, "LS2") == 0)
2017 mask = ISO2022_LS2;
2018 else if (_stricmp(p, "LS3") == 0)
2019 mask = ISO2022_LS3;
2020 else if (_stricmp(p, "LS1R") == 0)
2021 mask = ISO2022_LS1R;
2022 else if (_stricmp(p, "LS2R") == 0)
2023 mask = ISO2022_LS2R;
2024 else if (_stricmp(p, "LS3R") == 0)
2025 mask = ISO2022_LS3R;
2026 else if (_stricmp(p, "SS2") == 0)
2027 mask = ISO2022_SS2;
2028 else if (_stricmp(p, "SS3") == 0)
2029 mask = ISO2022_SS3;
2030
2031 if (mask) {
2032 if (add) {
2033 ts->ISO2022Flag |= mask;
2034 }
2035 else {
2036 ts->ISO2022Flag &= ~mask;
2037 }
2038 }
2039 }
2040
2041 // Terminal Speed (Used by telnet and ssh)
2042 GetPrivateProfileString(Section, "TerminalSpeed", "38400", Temp, sizeof(Temp), FName);
2043 GetNthNum(Temp, 1, &i);
2044 if (i > 0)
2045 ts->TerminalInputSpeed = i;
2046 else
2047 ts->TerminalInputSpeed = 38400;
2048 GetNthNum(Temp, 2, &i);
2049 if (i > 0)
2050 ts->TerminalOutputSpeed = i;
2051 else
2052 ts->TerminalOutputSpeed = ts->TerminalInputSpeed;
2053
2054 // Fallback to CP932 (Experimental)
2055 ts->FallbackToCP932 = GetOnOff(Section, "FallbackToCP932", FName, FALSE);
2056
2057 // CygTerm Configuration File
2058 ReadCygtermConfFile(ts);
2059 }
2060
2061 void PASCAL WriteIniFile(PCHAR FName, PTTSet ts)
2062 {
2063 int i;
2064 char Temp[MAX_PATH];
2065 char buf[20];
2066 int ret;
2067 char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG], msg[MAX_UIMSG];
2068
2069 /* version */
2070 ret = WritePrivateProfileString(Section, "Version", TT_VERSION_STR("."), FName);
2071 if (ret == 0) {
2072 // ini�t�@�C�����������������s�������A�G���[���b�Z�[�W���\�������B(2012.10.18 yutaka)
2073 ret = GetLastError();
2074 get_lang_msg("MSG_INI_WRITE_ERROR", uimsg, sizeof(uimsg), "Cannot write ini file", ts->UILanguageFile);
2075 _snprintf_s(msg, sizeof(msg), _TRUNCATE, "%s (%d)", uimsg, ret);
2076
2077 get_lang_msg("MSG_INI_ERROR", uimsg2, sizeof(uimsg2), "Tera Term: Error", ts->UILanguageFile);
2078
2079 MessageBox(NULL, msg, uimsg2, MB_ICONEXCLAMATION);
2080 }
2081
2082 /* Language */
2083 switch (ts->Language) {
2084 case IdJapanese:
2085 strncpy_s(Temp, sizeof(Temp), "Japanese", _TRUNCATE);
2086 break;
2087 case IdKorean:
2088 strncpy_s(Temp, sizeof(Temp), "Korean", _TRUNCATE);
2089 break;
2090 case IdRussian:
2091 strncpy_s(Temp, sizeof(Temp), "Russian", _TRUNCATE);
2092 break;
2093 case IdUtf8:
2094 strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
2095 break;
2096 default:
2097 strncpy_s(Temp, sizeof(Temp), "English", _TRUNCATE);
2098 }
2099
2100 WritePrivateProfileString(Section, "Language", Temp, FName);
2101
2102 /* Port type */
2103 WritePrivateProfileString(Section, "Port", (ts->PortType==IdSerial)?"serial":"tcpip", FName);
2104
2105 /* Save win position */
2106 if (ts->SaveVTWinPos) {
2107 /* VT win position */
2108 WriteInt2(Section, "VTPos", FName, ts->VTPos.x, ts->VTPos.y);
2109 }
2110
2111 /* VT terminal size */
2112 WriteInt2(Section, "TerminalSize", FName,
2113 ts->TerminalWidth, ts->TerminalHeight);
2114
2115 /* Terminal size = Window size */
2116 WriteOnOff(Section, "TermIsWin", FName, ts->TermIsWin);
2117
2118 /* Auto window resize flag */
2119 WriteOnOff(Section, "AutoWinResize", FName, ts->AutoWinResize);
2120
2121 /* CR Receive */
2122 if (ts->CRReceive == IdCRLF) {
2123 strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
2124 }
2125 else if (ts->CRReceive == IdLF) {
2126 strncpy_s(Temp, sizeof(Temp), "LF", _TRUNCATE);
2127 }
2128 else if (ts->CRReceive == IdAUTO) {
2129 strncpy_s(Temp, sizeof(Temp), "AUTO", _TRUNCATE);
2130 }
2131 else {
2132 strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
2133 }
2134 WritePrivateProfileString(Section, "CRReceive", Temp, FName);
2135
2136 /* CR Send */
2137 if (ts->CRSend == IdCRLF) {
2138 strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
2139 }
2140 else if (ts->CRSend == IdLF) {
2141 strncpy_s(Temp, sizeof(Temp), "LF", _TRUNCATE);
2142 }
2143 else {
2144 strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
2145 }
2146 WritePrivateProfileString(Section, "CRSend", Temp, FName);
2147
2148 /* Local echo */
2149 WriteOnOff(Section, "LocalEcho", FName, ts->LocalEcho);
2150
2151 /* Answerback */
2152 if ((ts->FTFlag & FT_BPAUTO) == 0) {
2153 Str2Hex(ts->Answerback, Temp, ts->AnswerbackLen,
2154 sizeof(Temp) - 1, TRUE);
2155 WritePrivateProfileString(Section, "Answerback", Temp, FName);
2156 }
2157
2158 /* Kanji Code (receive) */
2159 switch (ts->KanjiCode) {
2160 case IdEUC:
2161 strncpy_s(Temp, sizeof(Temp), "EUC", _TRUNCATE);
2162 break;
2163 case IdJIS:
2164 strncpy_s(Temp, sizeof(Temp), "JIS", _TRUNCATE);
2165 break;
2166 case IdUTF8:
2167 strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
2168 break;
2169 case IdUTF8m:
2170 strncpy_s(Temp, sizeof(Temp), "UTF-8m", _TRUNCATE);
2171 break;
2172 default:
2173 switch (ts->Language) {
2174 case IdJapanese:
2175 strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2176 break;
2177 case IdKorean:
2178 strncpy_s(Temp, sizeof(Temp), "KS5601", _TRUNCATE);
2179 break;
2180 default:
2181 strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2182 }
2183 }
2184 WritePrivateProfileString(Section, "KanjiReceive", Temp, FName);
2185
2186 /* Katakana (receive) */
2187 if (ts->JIS7Katakana == 1)
2188 strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
2189 else
2190 strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
2191
2192 WritePrivateProfileString(Section, "KatakanaReceive", Temp, FName);
2193
2194 /* Kanji Code (transmit) */
2195 switch (ts->KanjiCodeSend) {
2196 case IdEUC:
2197 strncpy_s(Temp, sizeof(Temp), "EUC", _TRUNCATE);
2198 break;
2199 case IdJIS:
2200 strncpy_s(Temp, sizeof(Temp), "JIS", _TRUNCATE);
2201 break;
2202 case IdUTF8:
2203 strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
2204 break;
2205 default:
2206 switch (ts->Language) {
2207 case IdJapanese:
2208 strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2209 break;
2210 case IdKorean:
2211 strncpy_s(Temp, sizeof(Temp), "KS5601", _TRUNCATE);
2212 break;
2213 default:
2214 strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2215 }
2216 }
2217 WritePrivateProfileString(Section, "KanjiSend", Temp, FName);
2218
2219 /* Katakana (transmit) */
2220 if (ts->JIS7KatakanaSend == 1)
2221 strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
2222 else
2223 strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
2224
2225 WritePrivateProfileString(Section, "KatakanaSend", Temp, FName);
2226
2227 /* KanjiIn */
2228 if (ts->KanjiIn == IdKanjiInA)
2229 strncpy_s(Temp, sizeof(Temp), "@", _TRUNCATE);
2230 else
2231 strncpy_s(Temp, sizeof(Temp), "B", _TRUNCATE);
2232
2233 WritePrivateProfileString(Section, "KanjiIn", Temp, FName);
2234
2235 /* KanjiOut */
2236 switch (ts->KanjiOut) {
2237 case IdKanjiOutB:
2238 strncpy_s(Temp, sizeof(Temp), "B", _TRUNCATE);
2239 break;
2240 case IdKanjiOutH:
2241 strncpy_s(Temp, sizeof(Temp), "H", _TRUNCATE);
2242 break;
2243 default:
2244 strncpy_s(Temp, sizeof(Temp), "J", _TRUNCATE);
2245 }
2246 WritePrivateProfileString(Section, "KanjiOut", Temp, FName);
2247
2248 // new configuration
2249 WriteInt(Section, "ConnectingTimeout", FName, ts->ConnectingTimeout);
2250
2251 WriteOnOff(Section, "DisablePasteMouseRButton", FName,
2252 (WORD) (ts->PasteFlag & CPF_DISABLE_RBUTTON));
2253
2254 WriteOnOff(Section, "DisablePasteMouseMButton", FName,
2255 (WORD) (ts->PasteFlag & CPF_DISABLE_MBUTTON));
2256
2257 WriteOnOff(Section, "ConfirmPasteMouseRButton", FName,
2258 (WORD) (ts->PasteFlag & CPF_CONFIRM_RBUTTON));
2259
2260 // added ConfirmChangePaste
2261 WriteOnOff(Section, "ConfirmChangePaste", FName,
2262 (WORD) (ts->PasteFlag & CPF_CONFIRM_CHANGEPASTE));
2263
2264 WriteOnOff(Section, "ConfirmChangePasteCR", FName,
2265 (WORD) (ts->PasteFlag & CPF_CONFIRM_CHANGEPASTE_CR));
2266
2267 WritePrivateProfileString(Section, "ConfirmChangePasteStringFile",
2268 ts->ConfirmChangePasteStringFile, FName);
2269
2270 // added ScrollWindowClearScreen
2271 WriteOnOff(Section, "ScrollWindowClearScreen", FName,
2272 ts->ScrollWindowClearScreen);
2273
2274 // added SelectOnlyByLButton (2007.11.20 maya)
2275 WriteOnOff(Section, "SelectOnlyByLButton", FName,
2276 ts->SelectOnlyByLButton);
2277 // added DisableAcceleratorSendBreak (2007.3.17 maya)
2278 WriteOnOff(Section, "DisableAcceleratorSendBreak", FName,
2279 ts->DisableAcceleratorSendBreak);
2280 WriteOnOff(Section, "EnableContinuedLineCopy", FName,
2281 ts->EnableContinuedLineCopy);
2282 WritePrivateProfileString(Section, "MouseCursor", ts->MouseCursorName,
2283 FName);
2284 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->AlphaBlendInactive);
2285 WritePrivateProfileString(Section, "AlphaBlend", Temp, FName);
2286 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->AlphaBlendActive);
2287 WritePrivateProfileString(Section, "AlphaBlendActive", Temp, FName);
2288 WritePrivateProfileString(Section, "CygwinDirectory",
2289 ts->CygwinDirectory, FName);
2290 WritePrivateProfileString(Section, "ViewlogEditor", ts->ViewlogEditor,
2291 FName);
2292 WritePrivateProfileString(Section, "Locale", ts->Locale, FName);
2293
2294 // ANSI color(2004.9.5 yutaka)
2295 Temp[0] = '\0';
2296 for (i = 0; i < 15; i++) {
2297 _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d,%d,%d,%d, ",
2298 i,
2299 GetRValue(ts->ANSIColor[i]),
2300 GetGValue(ts->ANSIColor[i]),
2301 GetBValue(ts->ANSIColor[i])
2302 );
2303 strncat_s(Temp, sizeof(Temp), buf, _TRUNCATE);
2304 }
2305 i = 15;
2306 _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d,%d,%d,%d",
2307 i,
2308 GetRValue(ts->ANSIColor[i]),
2309 GetGValue(ts->ANSIColor[i]),
2310 GetBValue(ts->ANSIColor[i])
2311 );
2312 strncat_s(Temp, sizeof(Temp), buf, _TRUNCATE);
2313 WritePrivateProfileString(Section, "ANSIColor", Temp, FName);
2314
2315 /* AutoWinChange VT<->TEK */
2316 WriteOnOff(Section, "AutoWinSwitch", FName, ts->AutoWinSwitch);
2317
2318 /* Terminal ID */
2319 id2str(TermList, ts->TerminalID, IdVT100, Temp, sizeof(Temp));
2320 WritePrivateProfileString(Section, "TerminalID", Temp, FName);
2321
2322 /* Russian character set (host) */
2323 id2str(RussList, ts->RussHost, IdKOI8, Temp, sizeof(Temp));
2324 WritePrivateProfileString(Section, "RussHost", Temp, FName);
2325
2326 /* Russian character set (client) */
2327 id2str(RussList, ts->RussClient, IdWindows, Temp, sizeof(Temp));
2328 WritePrivateProfileString(Section, "RussClient", Temp, FName);
2329
2330 /* Title text */
2331 WritePrivateProfileString(Section, "Title", ts->Title, FName);
2332
2333 /* Cursor shape */
2334 switch (ts->CursorShape) {
2335 case IdVCur:
2336 strncpy_s(Temp, sizeof(Temp), "vertical", _TRUNCATE);
2337 break;
2338 case IdHCur:
2339 strncpy_s(Temp, sizeof(Temp), "horizontal", _TRUNCATE);
2340 break;
2341 default:
2342 strncpy_s(Temp, sizeof(Temp), "block", _TRUNCATE);
2343 }
2344 WritePrivateProfileString(Section, "CursorShape", Temp, FName);
2345
2346 /* Hide title */
2347 WriteOnOff(Section, "HideTitle", FName, ts->HideTitle);
2348
2349 /* Popup menu */
2350 WriteOnOff(Section, "PopupMenu", FName, ts->PopupMenu);
2351
2352 /* PC-Style bold color mapping */
2353 WriteOnOff(Section, "PcBoldColor", FName,
2354 (WORD) (ts->ColorFlag & CF_PCBOLD16));
2355
2356 /* aixterm 16 colors mode */
2357 WriteOnOff(Section, "Aixterm16Color", FName,
2358 (WORD) (ts->ColorFlag & CF_AIXTERM16));
2359
2360 /* xterm 256 colors mode */
2361 WriteOnOff(Section, "Xterm256Color", FName,
2362 (WORD) (ts->ColorFlag & CF_XTERM256));
2363
2364 /* Enable scroll buffer */
2365 WriteOnOff(Section, "EnableScrollBuff", FName, ts->EnableScrollBuff);
2366
2367 /* Scroll buffer size */
2368 WriteInt(Section, "ScrollBuffSize", FName, ts->ScrollBuffSize);
2369
2370 /* VT Color */
2371 for (i = 0; i <= 1; i++) {
2372 if (ts->ColorFlag & CF_REVERSEVIDEO) {
2373 if (ts->ColorFlag & CF_REVERSECOLOR) {
2374 ts->TmpColor[0][i * 3] = GetRValue(ts->VTReverseColor[i]);
2375 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTReverseColor[i]);
2376 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTReverseColor[i]);
2377 }
2378 else {
2379 ts->TmpColor[0][i * 3] = GetRValue(ts->VTColor[!i]);
2380 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTColor[!i]);
2381 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTColor[!i]);
2382 }
2383 }
2384 else {
2385 ts->TmpColor[0][i * 3] = GetRValue(ts->VTColor[i]);
2386 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTColor[i]);
2387 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTColor[i]);
2388 }
2389 }
2390 WriteInt6(Section, "VTColor", FName,
2391 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
2392 ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
2393
2394 /* VT Bold Color */
2395 for (i = 0; i <= 1; i++) {
2396 if (ts->ColorFlag & CF_REVERSEVIDEO) {
2397 ts->TmpColor[0][i * 3] = GetRValue(ts->VTBoldColor[!i]);
2398 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBoldColor[!i]);
2399 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBoldColor[!i]);
2400 }
2401 else {
2402 ts->TmpColor[0][i * 3] = GetRValue(ts->VTBoldColor[i]);
2403 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBoldColor[i]);
2404 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBoldColor[i]);
2405 }
2406 }
2407 WriteInt6(Section, "VTBoldColor", FName,
2408 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
2409 ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
2410
2411 /* VT Blink Color */
2412 for (i = 0; i <= 1; i++) {
2413 if (ts->ColorFlag & CF_REVERSEVIDEO) {
2414 ts->TmpColor[0][i * 3] = GetRValue(ts->VTBlinkColor[!i]);
2415 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBlinkColor[!i]);
2416 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBlinkColor[!i]);
2417 }
2418 else {
2419 ts->TmpColor[0][i * 3] = GetRValue(ts->VTBlinkColor[i]);
2420 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBlinkColor[i]);
2421 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBlinkColor[i]);
2422 }
2423 }
2424 WriteInt6(Section, "VTBlinkColor", FName,
2425 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
2426 ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
2427
2428 /* VT Reverse Color */
2429 for (i = 0; i <= 1; i++) {
2430 if (ts->ColorFlag & CF_REVERSEVIDEO && ts->ColorFlag & CF_REVERSECOLOR) {
2431 ts->TmpColor[0][i * 3] = GetRValue(ts->VTColor[i]);
2432 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTColor[i]);
2433 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTColor[i]);
2434 }
2435 else {
2436 ts->TmpColor[0][i * 3] = GetRValue(ts->VTReverseColor[i]);
2437 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTReverseColor[i]);
2438 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTReverseColor[i]);
2439 }
2440 }
2441 WriteInt6(Section, "VTReverseColor", FName,
2442 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
2443 ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
2444
2445 WriteOnOff(Section, "EnableClickableUrl", FName,
2446 ts->EnableClickableUrl);
2447
2448 /* URL color */
2449 for (i = 0; i <= 1; i++) {
2450 if (ts->ColorFlag & CF_REVERSEVIDEO) {
2451 ts->TmpColor[0][i * 3] = GetRValue(ts->URLColor[!i]);
2452 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->URLColor[!i]);
2453 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->URLColor[!i]);
2454 }
2455 else {
2456 ts->TmpColor[0][i * 3] = GetRValue(ts->URLColor[i]);
2457 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->URLColor[i]);
2458 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->URLColor[i]);
2459 }
2460 }
2461 WriteInt6(Section, "URLColor", FName,
2462 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
2463 ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
2464
2465 WriteOnOff(Section, "EnableBoldAttrColor", FName,
2466 (WORD) (ts->ColorFlag & CF_BOLDCOLOR));
2467
2468 WriteOnOff(Section, "EnableBlinkAttrColor", FName,
2469 (WORD) (ts->ColorFlag & CF_BLINKCOLOR));
2470
2471 WriteOnOff(Section, "EnableReverseAttrColor", FName,
2472 (WORD) (ts->ColorFlag & CF_REVERSECOLOR));
2473
2474 WriteOnOff(Section, "EnableURLColor", FName,
2475 (WORD) (ts->ColorFlag & CF_URLCOLOR));
2476
2477 WriteOnOff(Section, "URLUnderline", FName,
2478 (WORD) (ts->FontFlag & FF_URLUNDERLINE));
2479
2480 WriteOnOff(Section, "EnableANSIColor", FName,
2481 (WORD) (ts->ColorFlag & CF_ANSICOLOR));
2482
2483 /* TEK Color */
2484 for (i = 0; i <= 1; i++) {
2485 ts->TmpColor[0][i * 3] = GetRValue(ts->TEKColor[i]);
2486 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->TEKColor[i]);
2487 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->TEKColor[i]);
2488 }
2489 WriteInt6(Section, "TEKColor", FName,
2490 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
2491 ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
2492
2493 /* TEK color emulation */
2494 WriteOnOff(Section, "TEKColorEmulation", FName, ts->TEKColorEmu);
2495
2496 /* VT Font */
2497 WriteFont(Section, "VTFont", FName,
2498 ts->VTFont, ts->VTFontSize.x, ts->VTFontSize.y,
2499 ts->VTFontCharSet);
2500
2501 /* Enable bold font flag */
2502 WriteOnOff(Section, "EnableBold", FName,
2503 (WORD) (ts->FontFlag & FF_BOLD));
2504
2505 /* Russian character set (font) */
2506 id2str(RussList, ts->RussFont, IdWindows, Temp, sizeof(Temp));
2507 WritePrivateProfileString(Section, "RussFont", Temp, FName);
2508
2509 /* TEK Font */
2510 WriteFont(Section, "TEKFont", FName,
2511 ts->TEKFont, ts->TEKFontSize.x, ts->TEKFontSize.y,
2512 ts->TEKFontCharSet);
2513
2514 /* BS key */
2515 if (ts->BSKey == IdDEL)
2516 strncpy_s(Temp, sizeof(Temp), "DEL", _TRUNCATE);
2517 else
2518 strncpy_s(Temp, sizeof(Temp), "BS", _TRUNCATE);
2519 WritePrivateProfileString(Section, "BSKey", Temp, FName);
2520
2521 /* Delete key */
2522 WriteOnOff(Section, "DeleteKey", FName, ts->DelKey);
2523
2524 /* Meta key */
2525 switch (ts->MetaKey) {
2526 case 1:
2527 strncpy_s(Temp, sizeof(Temp), "on", _TRUNCATE);
2528 break;
2529 case 2:
2530 strncpy_s(Temp, sizeof(Temp), "left", _TRUNCATE);
2531 break;
2532 case 3:
2533 strncpy_s(Temp, sizeof(Temp), "right", _TRUNCATE);
2534 break;
2535 default:
2536 strncpy_s(Temp, sizeof(Temp), "off", _TRUNCATE);
2537 }
2538 WritePrivateProfileString(Section, "Metakey", Temp, FName);
2539
2540 /* Application Keypad */
2541 WriteOnOff(Section, "DisableAppKeypad", FName, ts->DisableAppKeypad);
2542
2543 /* Application Cursor */
2544 WriteOnOff(Section, "DisableAppCursor", FName, ts->DisableAppCursor);
2545
2546 /* Russian keyboard type */
2547 id2str(RussList2, ts->RussKeyb, IdWindows, Temp, sizeof(Temp));
2548 WritePrivateProfileString(Section, "RussKeyb", Temp, FName);
2549
2550 /* Serial port ID */
2551 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->ComPort);
2552 WritePrivateProfileString(Section, "ComPort", Temp, FName);
2553
2554 /* Baud rate */
2555 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->Baud);
2556 WritePrivateProfileString(Section, "BaudRate", Temp, FName);
2557
2558 /* Parity */
2559 switch (ts->Parity) {
2560 case IdParityEven:
2561 strncpy_s(Temp, sizeof(Temp), "even", _TRUNCATE);
2562 break;
2563 case IdParityOdd:
2564 strncpy_s(Temp, sizeof(Temp), "odd", _TRUNCATE);
2565 break;
2566 case IdParityMark:
2567 strncpy_s(Temp, sizeof(Temp), "mark", _TRUNCATE);
2568 break;
2569 case IdParitySpace:
2570 strncpy_s(Temp, sizeof(Temp), "space", _TRUNCATE);
2571 break;
2572 default:
2573 strncpy_s(Temp, sizeof(Temp), "none", _TRUNCATE);
2574 }
2575 WritePrivateProfileString(Section, "Parity", Temp, FName);
2576
2577 /* Data bit */
2578 if (ts->DataBit == IdDataBit7)
2579 strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
2580 else
2581 strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
2582
2583 WritePrivateProfileString(Section, "DataBit", Temp, FName);
2584
2585 /* Stop bit */
2586 switch (ts->StopBit) {
2587 case IdStopBit2:
2588 strncpy_s(Temp, sizeof(Temp), "2", _TRUNCATE);
2589 break;
2590 case IdStopBit15:
2591 strncpy_s(Temp, sizeof(Temp), "1.5", _TRUNCATE);
2592 break;
2593 default:
2594 strncpy_s(Temp, sizeof(Temp), "1", _TRUNCATE);
2595 break;
2596 }
2597
2598 WritePrivateProfileString(Section, "StopBit", Temp, FName);
2599
2600 /* Flow control */
2601 switch (ts->Flow) {
2602 case IdFlowX:
2603 strncpy_s(Temp, sizeof(Temp), "x", _TRUNCATE);
2604 break;
2605 case IdFlowHard:
2606 strncpy_s(Temp, sizeof(Temp), "hard", _TRUNCATE);
2607 break;
2608 default:
2609 strncpy_s(Temp, sizeof(Temp), "none", _TRUNCATE);
2610 }
2611 WritePrivateProfileString(Section, "FlowCtrl", Temp, FName);
2612
2613 /* Delay per character */
2614 WriteInt(Section, "DelayPerChar", FName, ts->DelayPerChar);
2615
2616 /* Delay per line */
2617 WriteInt(Section, "DelayPerLine", FName, ts->DelayPerLine);
2618
2619 /* Telnet flag */
2620 WriteOnOff(Section, "Telnet", FName, ts->Telnet);
2621
2622 /* Telnet terminal type */
2623 WritePrivateProfileString(Section, "TermType", ts->TermType, FName);
2624
2625 /* TCP port num for non-telnet */
2626 WriteUint(Section, "TCPPort", FName, ts->TCPPort);
2627
2628 /* Auto close flag */
2629 WriteOnOff(Section, "AutoWinClose", FName, ts->AutoWinClose);
2630
2631 /* History list */
2632 WriteOnOff(Section, "Historylist", FName, ts->HistoryList);
2633
2634 /* File transfer binary flag */
2635 WriteOnOff(Section, "TransBin", FName, ts->TransBin);
2636
2637 /* Log binary flag */
2638 WriteOnOff(Section, "LogBinary", FName, ts->LogBinary);
2639
2640 /* Log append */
2641 WriteOnOff(Section, "LogAppend", FName, ts->Append);
2642
2643 /* Log plain text flag */
2644 WriteOnOff(Section, "LogTypePlainText", FName, ts->LogTypePlainText);
2645
2646 /* Log with timestamp (2006.7.23 maya) */
2647 WriteOnOff(Section, "LogTimestamp", FName, ts->LogTimestamp);
2648
2649 /* Log without transfer dialog */
2650 WriteOnOff(Section, "LogHideDialog", FName, ts->LogHideDialog);
2651
2652 WriteOnOff(Section, "LogIncludeScreenBuffer", FName, ts->LogAllBuffIncludedInFirst);
2653
2654 /* Timestamp format of Log each line */
2655 WritePrivateProfileString(Section, "LogTimestampFormat",
2656 ts->LogTimestampFormat, FName);
2657
2658 /* Timestamp type */
2659 switch (ts->LogTimestampType) {
2660 case TIMESTAMP_LOCAL:
2661 WritePrivateProfileString(Section, "LogTimestampType", "Local", FName);
2662 break;
2663 case TIMESTAMP_UTC:
2664 WritePrivateProfileString(Section, "LogTimestampType", "UTC", FName);
2665 break;
2666 case TIMESTAMP_ELAPSED_LOGSTART:
2667 WritePrivateProfileString(Section, "LogTimestampType", "LoggingElapsed", FName);
2668 break;
2669 case TIMESTAMP_ELAPSED_CONNECTED:
2670 WritePrivateProfileString(Section, "LogTimestampType", "ConnectionElapsed", FName);
2671 break;
2672 }
2673
2674 /* Default Log file name (2006.8.28 maya) */
2675 WritePrivateProfileString(Section, "LogDefaultName",
2676 ts->LogDefaultName, FName);
2677
2678 /* Default Log file path (2007.5.30 maya) */
2679 WritePrivateProfileString(Section, "LogDefaultPath",
2680 ts->LogDefaultPath, FName);
2681
2682 /* Auto start logging (2007.5.31 maya) */
2683 WriteOnOff(Section, "LogAutoStart", FName, ts->LogAutoStart);
2684
2685 /* Log Rotate (2013.3.24 yutaka) */
2686 WriteInt(Section, "LogRotate", FName, ts->LogRotate);
2687 WriteInt(Section, "LogRotateSize", FName, ts->LogRotateSize);
2688 WriteInt(Section, "LogRotateSizeType", FName, ts->LogRotateSizeType);
2689 WriteInt(Section, "LogRotateStep", FName, ts->LogRotateStep);
2690
2691 /* Deferred Log Write Mode (2013.4.20 yutaka) */
2692 WriteOnOff(Section, "DeferredLogWriteMode", FName, ts->DeferredLogWriteMode);
2693
2694 /* XMODEM option */
2695 switch (ts->XmodemOpt) {
2696 case XoptCRC:
2697 strncpy_s(Temp, sizeof(Temp), "crc", _TRUNCATE);
2698 break;
2699 case Xopt1kCRC:
2700 strncpy_s(Temp, sizeof(Temp), "1k", _TRUNCATE);
2701 break;
2702 case Xopt1kCksum:
2703 strncpy_s(Temp, sizeof(Temp), "1ksum", _TRUNCATE);
2704 break;
2705 default:
2706 strncpy_s(Temp, sizeof(Temp), "checksum", _TRUNCATE);
2707 }
2708 WritePrivateProfileString(Section, "XmodemOpt", Temp, FName);
2709
2710 /* XMODEM binary flag */
2711 WriteOnOff(Section, "XmodemBin", FName, ts->XmodemBin);
2712
2713 /* XMODEM ���M�R�}���h (2007.12.21 yutaka) */
2714 WritePrivateProfileString(Section, "XmodemRcvCommand",
2715 ts->XModemRcvCommand, FName);
2716
2717 /* Default directory for file transfer */
2718 WritePrivateProfileString(Section, "FileDir", ts->FileDir, FName);
2719
2720 /* filter on file send (2007.6.5 maya) */
2721 WritePrivateProfileString(Section, "FileSendFilter",
2722 ts->FileSendFilter, FName);
2723
2724 WritePrivateProfileString(Section, "ScpSendDir", ts->ScpSendDir, FName);
2725
2726 /*------------------------------------------------------------------*/
2727 /* 8 bit control code flag -- special option */
2728 WriteOnOff(Section, "Accept8BitCtrl", FName,
2729 (WORD) (ts->TermFlag & TF_ACCEPT8BITCTRL));
2730
2731 /* Wrong sequence flag -- special option */
2732 WriteOnOff(Section, "AllowWrongSequence", FName,
2733 (WORD) (ts->TermFlag & TF_ALLOWWRONGSEQUENCE));
2734
2735 /* Detect disconnect/reconnect of serial port --- special option */
2736 WriteOnOff(Section, "AutoComPortReconnect", FName, ts->AutoComPortReconnect);
2737
2738 /* Auto file renaming --- special option */
2739 WriteOnOff(Section, "AutoFileRename", FName,
2740 (WORD) (ts->FTFlag & FT_RENAME));
2741
2742 /* Auto text copy --- special option */
2743 WriteOnOff(Section, "AutoTextCopy", FName, ts->AutoTextCopy);
2744
2745 /* Back wrap -- special option */