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