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 8106 - (show annotations) (download) (as text)
Tue Sep 10 14:42:39 2019 UTC (4 years, 7 months ago) by yutakapon
File MIME type: text/x-csrc
File size: 141539 byte(s)
Eterm look-feel: 
- 「壁紙と画像を混合する」を設定できるようにした。
  -- teraterm.ini に BGIgnoreThemeFile エントリを追加した。デフォルトはoff。
- 壁紙と混合する画像ファイルをランダムに選択する際、無関係なファイルを選択することがある問題を修正した。

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 if (_stricmp(Temp, "rtscts") == 0) // hard��rtscts����������
1074 ts->Flow = IdFlowHard;
1075 else if (_stricmp(Temp, "dsrdtr") == 0)
1076 ts->Flow = IdFlowHardDsrDtr;
1077 else
1078 ts->Flow = IdFlowNone;
1079
1080 /* Delay per character */
1081 ts->DelayPerChar =
1082 GetPrivateProfileInt(Section, "DelayPerChar", 0, FName);
1083
1084 /* Delay per line */
1085 ts->DelayPerLine =
1086 GetPrivateProfileInt(Section, "DelayPerLine", 0, FName);
1087
1088 /* Telnet flag */
1089 ts->Telnet = GetOnOff(Section, "Telnet", FName, TRUE);
1090
1091 /* Telnet terminal type */
1092 GetPrivateProfileString(Section, "TermType", "xterm", ts->TermType,
1093 sizeof(ts->TermType), FName);
1094
1095 /* TCP port num */
1096 ts->TCPPort =
1097 GetPrivateProfileInt(Section, "TCPPort", ts->TelPort, FName);
1098
1099 /* Auto window close flag */
1100 ts->AutoWinClose = GetOnOff(Section, "AutoWinClose", FName, TRUE);
1101
1102 /* History list */
1103 ts->HistoryList = GetOnOff(Section, "HistoryList", FName, FALSE);
1104
1105 /* File transfer binary flag */
1106 ts->TransBin = GetOnOff(Section, "TransBin", FName, FALSE);
1107
1108 /* Log binary flag */
1109 ts->LogBinary = GetOnOff(Section, "LogBinary", FName, FALSE);
1110
1111 /* Log append */
1112 ts->Append = GetOnOff(Section, "LogAppend", FName, FALSE);
1113
1114 /* Log plain text (2005.5.7 yutaka) */
1115 ts->LogTypePlainText =
1116 GetOnOff(Section, "LogTypePlainText", FName, FALSE);
1117
1118 /* Log with timestamp (2006.7.23 maya) */
1119 ts->LogTimestamp = GetOnOff(Section, "LogTimestamp", FName, FALSE);
1120
1121 /* Log without transfer dialog */
1122 ts->LogHideDialog = GetOnOff(Section, "LogHideDialog", FName, FALSE);
1123
1124 ts->LogAllBuffIncludedInFirst = GetOnOff(Section, "LogIncludeScreenBuffer", FName, FALSE);
1125
1126 /* Timestamp format of Log each line */
1127 GetPrivateProfileString(Section, "LogTimestampFormat", "%Y-%m-%d %H:%M:%S.%N",
1128 ts->LogTimestampFormat, sizeof(ts->LogTimestampFormat),
1129 FName);
1130
1131 /* Timestamp type */
1132 GetPrivateProfileString(Section, "LogTimestampType", "", Temp, sizeof(Temp), FName);
1133 if (_stricmp(Temp, "UTC") == 0)
1134 ts->LogTimestampType = TIMESTAMP_UTC;
1135 else if (_stricmp(Temp, "LoggingElapsed") == 0)
1136 ts->LogTimestampType = TIMESTAMP_ELAPSED_LOGSTART;
1137 else if (_stricmp(Temp, "ConnectionElapsed") == 0)
1138 ts->LogTimestampType = TIMESTAMP_ELAPSED_CONNECTED;
1139 else if (_stricmp(Temp, "") == 0 && GetOnOff(Section, "LogTimestampUTC", FName, FALSE))
1140 // LogTimestampType ���������������� LogTimestampUTC ���l���Q������
1141 ts->LogTimestampType = TIMESTAMP_UTC;
1142 else
1143 ts->LogTimestampType = TIMESTAMP_LOCAL;
1144
1145 /* File Transfer dialog visibility */
1146 ts->FTHideDialog = GetOnOff(Section, "FTHideDialog", FName, FALSE);
1147
1148 /* Default Log file name (2006.8.28 maya) */
1149 GetPrivateProfileString(Section, "LogDefaultName", "teraterm.log",
1150 ts->LogDefaultName, sizeof(ts->LogDefaultName),
1151 FName);
1152
1153 /* Default Log file path (2007.5.30 maya) */
1154 GetPrivateProfileString(Section, "LogDefaultPath", "",
1155 ts->LogDefaultPath, sizeof(ts->LogDefaultPath),
1156 FName);
1157
1158 /* Auto start logging (2007.5.31 maya) */
1159 ts->LogAutoStart = GetOnOff(Section, "LogAutoStart", FName, FALSE);
1160
1161 /* Log Rotate (2013.3.24 yutaka) */
1162 ts->LogRotate = GetPrivateProfileInt(Section, "LogRotate", 0, FName);
1163 ts->LogRotateSize = GetPrivateProfileInt(Section, "LogRotateSize", 0, FName);
1164 ts->LogRotateSizeType = GetPrivateProfileInt(Section, "LogRotateSizeType", 0, FName);
1165 ts->LogRotateStep = GetPrivateProfileInt(Section, "LogRotateStep", 0, FName);
1166
1167 /* Deferred Log Write Mode (2013.4.20 yutaka) */
1168 ts->DeferredLogWriteMode = GetOnOff(Section, "DeferredLogWriteMode", FName, TRUE);
1169
1170
1171 /* XMODEM option */
1172 GetPrivateProfileString(Section, "XmodemOpt", "",
1173 Temp, sizeof(Temp), FName);
1174 if (_stricmp(Temp, "crc") == 0)
1175 ts->XmodemOpt = XoptCRC;
1176 else if (_stricmp(Temp, "1k") == 0)
1177 ts->XmodemOpt = Xopt1kCRC;
1178 else if (_stricmp(Temp, "1ksum") == 0)
1179 ts->XmodemOpt = Xopt1kCksum;
1180 else
1181 ts->XmodemOpt = XoptCheck;
1182
1183 /* XMODEM binary file */
1184 ts->XmodemBin = GetOnOff(Section, "XmodemBin", FName, TRUE);
1185
1186 /* XMODEM ���M�R�}���h (2007.12.21 yutaka) */
1187 GetPrivateProfileString(Section, "XModemRcvCommand", "",
1188 ts->XModemRcvCommand,
1189 sizeof(ts->XModemRcvCommand), FName);
1190
1191 /* Default directory for file transfer */
1192 GetPrivateProfileString(Section, "FileDir", "",
1193 ts->FileDir, sizeof(ts->FileDir), FName);
1194 if (strlen(ts->FileDir) == 0)
1195 GetDownloadFolder(ts->FileDir, sizeof(ts->FileDir));
1196 else {
1197 char FileDirExpanded[MAX_PATH];
1198 ExpandEnvironmentStrings(ts->FileDir, FileDirExpanded, sizeof(FileDirExpanded));
1199 _getcwd(Temp, sizeof(Temp));
1200 if (_chdir(FileDirExpanded) != 0)
1201 GetDownloadFolder(ts->FileDir, sizeof(ts->FileDir));
1202 _chdir(Temp);
1203 }
1204
1205 /* filter on file send (2007.6.5 maya) */
1206 GetPrivateProfileString(Section, "FileSendFilter", "",
1207 ts->FileSendFilter, sizeof(ts->FileSendFilter),
1208 FName);
1209
1210 /* SCP���M���p�X (2012.4.6 yutaka) */
1211 GetPrivateProfileString(Section, "ScpSendDir", "",
1212 ts->ScpSendDir, sizeof(ts->ScpSendDir), FName);
1213
1214
1215 /*--------------------------------------------------*/
1216 /* 8 bit control code flag -- special option */
1217 if (GetOnOff(Section, "Accept8BitCtrl", FName, TRUE))
1218 ts->TermFlag |= TF_ACCEPT8BITCTRL;
1219
1220 /* Wrong sequence flag -- special option */
1221 if (GetOnOff(Section, "AllowWrongSequence", FName, FALSE))
1222 ts->TermFlag |= TF_ALLOWWRONGSEQUENCE;
1223
1224 if (((ts->TermFlag & TF_ALLOWWRONGSEQUENCE) == 0) &&
1225 (ts->KanjiOut == IdKanjiOutH))
1226 ts->KanjiOut = IdKanjiOutJ;
1227
1228 // Detect disconnect/reconnect of serial port --- special option
1229 ts->AutoComPortReconnect = GetOnOff(Section, "AutoComPortReconnect", FName, TRUE);
1230
1231 // Auto file renaming --- special option
1232 if (GetOnOff(Section, "AutoFileRename", FName, FALSE))
1233 ts->FTFlag |= FT_RENAME;
1234
1235 // Auto invoking (character set->G0->GL) --- special option
1236 if (GetOnOff(Section, "AutoInvoke", FName, FALSE))
1237 ts->TermFlag |= TF_AUTOINVOKE;
1238
1239 // Auto text copy --- special option
1240 ts->AutoTextCopy = GetOnOff(Section, "AutoTextCopy", FName, TRUE);
1241
1242 /* Back wrap -- special option */
1243 if (GetOnOff(Section, "BackWrap", FName, FALSE))
1244 ts->TermFlag |= TF_BACKWRAP;
1245
1246 /* Beep type -- special option */
1247 GetPrivateProfileString(Section, "Beep", "", Temp, sizeof(Temp), FName);
1248 if (_stricmp(Temp, "off") == 0)
1249 ts->Beep = IdBeepOff;
1250 else if (_stricmp(Temp, "visual") == 0)
1251 ts->Beep = IdBeepVisual;
1252 else
1253 ts->Beep = IdBeepOn;
1254
1255 /* Beep on connection & disconnection -- special option */
1256 if (GetOnOff(Section, "BeepOnConnect", FName, FALSE))
1257 ts->PortFlag |= PF_BEEPONCONNECT;
1258
1259 /* Auto B-Plus activation -- special option */
1260 if (GetOnOff(Section, "BPAuto", FName, FALSE))
1261 ts->FTFlag |= FT_BPAUTO;
1262 if ((ts->FTFlag & FT_BPAUTO) != 0) { /* Answerback */
1263 strncpy_s(ts->Answerback, sizeof(ts->Answerback), "\020++\0200",
1264 _TRUNCATE);
1265 ts->AnswerbackLen = 5;
1266 }
1267
1268 /* B-Plus ESCCTL flag -- special option */
1269 if (GetOnOff(Section, "BPEscCtl", FName, FALSE))
1270 ts->FTFlag |= FT_BPESCCTL;
1271
1272 /* B-Plus log -- special option */
1273 if (GetOnOff(Section, "BPLog", FName, FALSE))
1274 ts->LogFlag |= LOG_BP;
1275
1276 /* Clear serial port buffer when port opening -- special option */
1277 ts->ClearComBuffOnOpen =
1278 GetOnOff(Section, "ClearComBuffOnOpen", FName, TRUE);
1279
1280 /* When serial port is specified with with /C= option and the port does not exist, Tera Term will wait for port connection. */
1281 ts->WaitCom = GetOnOff(Section, "WaitCom", FName, FALSE);
1282
1283 /* Confirm disconnection -- special option */
1284 if (GetOnOff(Section, "ConfirmDisconnect", FName, TRUE))
1285 ts->PortFlag |= PF_CONFIRMDISCONN;
1286
1287 /* Ctrl code in Kanji -- special option */
1288 if (GetOnOff(Section, "CtrlInKanji", FName, TRUE))
1289 ts->TermFlag |= TF_CTRLINKANJI;
1290
1291 /* Debug flag -- special option */
1292 ts->Debug = GetOnOff(Section, "Debug", FName, FALSE);
1293
1294 /* Delimiter list -- special option */
1295 GetPrivateProfileString(Section, "DelimList",
1296 "$20!\"#$24%&\'()*+,-./:;<=>?@[\\]^`{|}~",
1297 Temp, sizeof(Temp), FName);
1298 Hex2Str(Temp, ts->DelimList, sizeof(ts->DelimList));
1299
1300 /* regard DBCS characters as delimiters -- special option */
1301 ts->DelimDBCS = GetOnOff(Section, "DelimDBCS", FName, TRUE);
1302
1303 // Enable popup menu -- special option
1304 if (!GetOnOff(Section, "EnablePopupMenu", FName, TRUE))
1305 ts->MenuFlag |= MF_NOPOPUP;
1306
1307 // Enable "Show menu" -- special option
1308 if (!GetOnOff(Section, "EnableShowMenu", FName, TRUE))
1309 ts->MenuFlag |= MF_NOSHOWMENU;
1310
1311 // Enable the status line -- special option
1312 if (GetOnOff(Section, "EnableStatusLine", FName, TRUE))
1313 ts->TermFlag |= TF_ENABLESLINE;
1314
1315 // Enable multiple bytes send -- special option
1316 ts->FileSendHighSpeedMode = GetOnOff(Section, "FileSendHighSpeedMode", FName, TRUE);
1317
1318 // fixed JIS --- special
1319 if (GetOnOff(Section, "FixedJIS", FName, FALSE))
1320 ts->TermFlag |= TF_FIXEDJIS;
1321
1322 /* IME Flag -- special option */
1323 ts->UseIME = GetOnOff(Section, "IME", FName, TRUE);
1324
1325 /* IME-inline Flag -- special option */
1326 ts->IMEInline = GetOnOff(Section, "IMEInline", FName, TRUE);
1327
1328 /* Kermit log -- special option */
1329 if (GetOnOff(Section, "KmtLog", FName, FALSE))
1330 ts->LogFlag |= LOG_KMT;
1331 if (GetOnOff(Section, "KmtLongPacket", FName, FALSE))
1332 ts->KermitOpt |= KmtOptLongPacket;
1333 if (GetOnOff(Section, "KmtFileAttr", FName, FALSE))
1334 ts->KermitOpt |= KmtOptFileAttr;
1335
1336 // Enable language selection -- special option
1337 if (!GetOnOff(Section, "LanguageSelection", FName, TRUE))
1338 ts->MenuFlag |= MF_NOLANGUAGE;
1339
1340 /* Maximum scroll buffer size -- special option */
1341 ts->ScrollBuffMax =
1342 GetPrivateProfileInt(Section, "MaxBuffSize", 10000, FName);
1343 if (ts->ScrollBuffMax < 24)
1344 ts->ScrollBuffMax = 10000;
1345
1346 /* Max com port number -- special option */
1347 ts->MaxComPort = GetPrivateProfileInt(Section, "MaxComPort", 256, FName);
1348 if (ts->MaxComPort < 4)
1349 ts->MaxComPort = 4;
1350 if (ts->MaxComPort > MAXCOMPORT)
1351 ts->MaxComPort = MAXCOMPORT;
1352 if ((ts->ComPort < 1) || (ts->ComPort > ts->MaxComPort))
1353 ts->ComPort = 1;
1354
1355 /* Non-blinking cursor -- special option */
1356 ts->NonblinkingCursor =
1357 GetOnOff(Section, "NonblinkingCursor", FName, FALSE);
1358
1359 // �t�H�[�J�X���������|���S���J�[�\�� (2008.1.24 yutaka)
1360 ts->KillFocusCursor =
1361 GetOnOff(Section, "KillFocusCursor", FName, TRUE);
1362
1363 /* Delay for pass-thru printing activation */
1364 /* -- special option */
1365 ts->PassThruDelay =
1366 GetPrivateProfileInt(Section, "PassThruDelay", 3, FName);
1367
1368 /* Printer port for pass-thru printing */
1369 /* -- special option */
1370 GetPrivateProfileString(Section, "PassThruPort", "",
1371 ts->PrnDev, sizeof(ts->PrnDev), FName);
1372
1373 /* �v�����^�p�����R�[�h�������t������ */
1374 if (GetOnOff(Section, "PrinterCtrlSequence", FName, TRUE))
1375 ts->TermFlag |= TF_PRINTERCTRL;
1376
1377 /* Printer Font --- special option */
1378 ReadFont(Section, "PrnFont", NULL, FName,
1379 ts->PrnFont, _countof(ts->PrnFont),
1380 &ts->PrnFontSize, &(ts->PrnFontCharSet));
1381
1382 // Page margins (left, right, top, bottom) for printing
1383 // -- special option
1384 GetPrivateProfileString(Section, "PrnMargin", "50,50,50,50",
1385 Temp, sizeof(Temp), FName);
1386 for (i = 0; i <= 3; i++)
1387 GetNthNum(Temp, 1 + i, &ts->PrnMargin[i]);
1388
1389 /* Disable (convert to NL) Form Feed when printing */
1390 /* --- special option */
1391 ts->PrnConvFF =
1392 GetOnOff(Section, "PrnConvFF", FName, FALSE);
1393
1394 /* Quick-VAN log -- special option */
1395 if (GetOnOff(Section, "QVLog", FName, FALSE))
1396 ts->LogFlag |= LOG_QV;
1397
1398 /* Quick-VAN window size -- special */
1399 ts->QVWinSize = GetPrivateProfileInt(Section, "QVWinSize", 8, FName);
1400
1401 /* Russian character set (print) -- special option */
1402 GetPrivateProfileString(Section, "RussPrint", "",
1403 Temp, sizeof(Temp), FName);
1404 ts->RussPrint = str2id(RussList, Temp, IdWindows);
1405
1406 /* Scroll threshold -- special option */
1407 ts->ScrollThreshold =
1408 GetPrivateProfileInt(Section, "ScrollThreshold", 12, FName);
1409
1410 ts->MouseWheelScrollLine =
1411 GetPrivateProfileInt(Section, "MouseWheelScrollLine", 3, FName);
1412
1413 // Select on activate -- special option
1414 ts->SelOnActive = GetOnOff(Section, "SelectOnActivate", FName, TRUE);
1415
1416 /* Send 8bit control sequence -- special option */
1417 ts->Send8BitCtrl = GetOnOff(Section, "Send8BitCtrl", FName, FALSE);
1418
1419 /* SendBreak time (in msec) -- special option */
1420 ts->SendBreakTime =
1421 GetPrivateProfileInt(Section, "SendBreakTime", 1000, FName);
1422
1423 /* Startup macro -- special option */
1424 GetPrivateProfileString(Section, "StartupMacro", "",
1425 ts->MacroFN, sizeof(ts->MacroFN), FName);
1426
1427 /* TEK GIN Mouse keycode -- special option */
1428 ts->GINMouseCode =
1429 GetPrivateProfileInt(Section, "TEKGINMouseCode", 32, FName);
1430
1431 /* Telnet Auto Detect -- special option */
1432 ts->TelAutoDetect = GetOnOff(Section, "TelAutoDetect", FName, TRUE);
1433
1434 /* Telnet binary flag -- special option */
1435 ts->TelBin = GetOnOff(Section, "TelBin", FName, FALSE);
1436
1437 /* Telnet Echo flag -- special option */
1438 ts->TelEcho = GetOnOff(Section, "TelEcho", FName, FALSE);
1439
1440 /* Telnet log -- special option */
1441 if (GetOnOff(Section, "TelLog", FName, FALSE))
1442 ts->LogFlag |= LOG_TEL;
1443
1444 /* TCP port num for telnet -- special option */
1445 ts->TelPort = GetPrivateProfileInt(Section, "TelPort", 23, FName);
1446
1447 /* Telnet keep-alive packet(NOP command) interval -- special option */
1448 ts->TelKeepAliveInterval =
1449 GetPrivateProfileInt(Section, "TelKeepAliveInterval", 300, FName);
1450
1451 /* Max number of broadcast commad history */
1452 ts->MaxBroadcatHistory =
1453 GetPrivateProfileInt(Section, "MaxBroadcatHistory", 99, FName);
1454
1455 /* Local echo for non-telnet */
1456 ts->TCPLocalEcho = GetOnOff(Section, "TCPLocalEcho", FName, FALSE);
1457
1458 /* "new-line (transmit)" option for non-telnet -- special option */
1459 GetPrivateProfileString(Section, "TCPCRSend", "",
1460 Temp, sizeof(Temp), FName);
1461 if (_stricmp(Temp, "CR") == 0)
1462 ts->TCPCRSend = IdCR;
1463 else if (_stricmp(Temp, "CRLF") == 0)
1464 ts->TCPCRSend = IdCRLF;
1465 else
1466 ts->TCPCRSend = 0; // disabled
1467
1468 /* Use text (background) color for "white (black)" --- special option */
1469 if (GetOnOff(Section, "UseTextColor", FName, FALSE))
1470 ts->ColorFlag |= CF_USETEXTCOLOR;
1471
1472 /* Title format -- special option */
1473 ts->TitleFormat =
1474 GetPrivateProfileInt(Section, "TitleFormat", 13, FName);
1475
1476 /* VT Compatible Tab -- special option */
1477 ts->VTCompatTab = GetOnOff(Section, "VTCompatTab", FName, FALSE);
1478
1479 /* VT Font space --- special option */
1480 GetPrivateProfileString(Section, "VTFontSpace", "0,0,0,0",
1481 Temp, sizeof(Temp), FName);
1482 GetNthNum(Temp, 1, &ts->FontDX);
1483 GetNthNum(Temp, 2, &ts->FontDW);
1484 GetNthNum(Temp, 3, &ts->FontDY);
1485 GetNthNum(Temp, 4, &ts->FontDH);
1486 if (ts->FontDX < 0)
1487 ts->FontDX = 0;
1488 if (ts->FontDW < 0)
1489 ts->FontDW = 0;
1490 ts->FontDW = ts->FontDW + ts->FontDX;
1491 if (ts->FontDY < 0)
1492 ts->FontDY = 0;
1493 if (ts->FontDH < 0)
1494 ts->FontDH = 0;
1495 ts->FontDH = ts->FontDH + ts->FontDY;
1496
1497 // VT-print scaling factors (pixels per inch) --- special option
1498 GetPrivateProfileString(Section, "VTPPI", "0,0",
1499 Temp, sizeof(Temp), FName);
1500 GetNthNum(Temp, 1, (int far *) &ts->VTPPI.x);
1501 GetNthNum(Temp, 2, (int far *) &ts->VTPPI.y);
1502
1503 // TEK-print scaling factors (pixels per inch) --- special option
1504 GetPrivateProfileString(Section, "TEKPPI", "0,0",
1505 Temp, sizeof(Temp), FName);
1506 GetNthNum(Temp, 1, (int far *) &ts->TEKPPI.x);
1507 GetNthNum(Temp, 2, (int far *) &ts->TEKPPI.y);
1508
1509 // Show "Window" menu -- special option
1510 if (GetOnOff(Section, "WindowMenu", FName, TRUE))
1511 ts->MenuFlag |= MF_SHOWWINMENU;
1512
1513 /* XMODEM log -- special option */
1514 if (GetOnOff(Section, "XmodemLog", FName, FALSE))
1515 ts->LogFlag |= LOG_X;
1516
1517 /* YMODEM log -- special option */
1518 if (GetOnOff(Section, "YmodemLog", FName, FALSE))
1519 ts->LogFlag |= LOG_Y;
1520
1521 /* YMODEM ���M�R�}���h (2010.3.23 yutaka) */
1522 GetPrivateProfileString(Section, "YModemRcvCommand", "rb",
1523 ts->YModemRcvCommand, sizeof(ts->YModemRcvCommand), FName);
1524
1525 /* Auto ZMODEM activation -- special option */
1526 if (GetOnOff(Section, "ZmodemAuto", FName, FALSE))
1527 ts->FTFlag |= FT_ZAUTO;
1528
1529 /* ZMODEM data subpacket length for sending -- special */
1530 ts->ZmodemDataLen =
1531 GetPrivateProfileInt(Section, "ZmodemDataLen", 1024, FName);
1532 /* ZMODEM window size for sending -- special */
1533 ts->ZmodemWinSize =
1534 GetPrivateProfileInt(Section, "ZmodemWinSize", 32767, FName);
1535
1536 /* ZMODEM ESCCTL flag -- special option */
1537 if (GetOnOff(Section, "ZmodemEscCtl", FName, FALSE))
1538 ts->FTFlag |= FT_ZESCCTL;
1539
1540 /* ZMODEM log -- special option */
1541 if (GetOnOff(Section, "ZmodemLog", FName, FALSE))
1542 ts->LogFlag |= LOG_Z;
1543
1544 /* ZMODEM ���M�R�}���h (2007.12.21 yutaka) */
1545 GetPrivateProfileString(Section, "ZModemRcvCommand", "rz",
1546 ts->ZModemRcvCommand, sizeof(ts->ZModemRcvCommand), FName);
1547
1548 /* Enable continued-line copy -- special option */
1549 ts->EnableContinuedLineCopy =
1550 GetOnOff(Section, "EnableContinuedLineCopy", FName, FALSE);
1551
1552 if (GetOnOff(Section, "DisablePasteMouseRButton", FName, FALSE))
1553 ts->PasteFlag |= CPF_DISABLE_RBUTTON;
1554
1555 if (GetOnOff(Section, "DisablePasteMouseMButton", FName, TRUE))
1556 ts->PasteFlag |= CPF_DISABLE_MBUTTON;
1557
1558 if (GetOnOff(Section, "ConfirmPasteMouseRButton", FName, FALSE))
1559 ts->PasteFlag |= CPF_CONFIRM_RBUTTON;
1560
1561 if (GetOnOff(Section, "ConfirmChangePaste", FName, TRUE))
1562 ts->PasteFlag |= CPF_CONFIRM_CHANGEPASTE;
1563
1564 if (GetOnOff(Section, "ConfirmChangePasteCR", FName, TRUE))
1565 ts->PasteFlag |= CPF_CONFIRM_CHANGEPASTE_CR;
1566
1567 GetPrivateProfileString(Section, "ConfirmChangePasteStringFile", "",
1568 Temp, sizeof(Temp), FName);
1569
1570 strncpy_s(ts->ConfirmChangePasteStringFile, sizeof(ts->ConfirmChangePasteStringFile), Temp,
1571 _TRUNCATE);
1572
1573 // added ScrollWindowClearScreen (2008.5.3 yutaka)
1574 ts->ScrollWindowClearScreen =
1575 GetOnOff(Section, "ScrollWindowClearScreen", FName, TRUE);
1576
1577 // added SelectOnlyByLButton (2007.11.20 maya)
1578 ts->SelectOnlyByLButton =
1579 GetOnOff(Section, "SelectOnlyByLButton", FName, TRUE);
1580
1581 // added DisableAcceleratorSendBreak (2007.3.17 maya)
1582 ts->DisableAcceleratorSendBreak =
1583 GetOnOff(Section, "DisableAcceleratorSendBreak", FName, FALSE);
1584
1585 // WinSock connecting timeout value (2007.1.11 yutaka)
1586 ts->ConnectingTimeout =
1587 GetPrivateProfileInt(Section, "ConnectingTimeout", 0, FName);
1588
1589 // mouse cursor
1590 GetPrivateProfileString(Section, "MouseCursor", "IBEAM",
1591 Temp, sizeof(Temp), FName);
1592 strncpy_s(ts->MouseCursorName, sizeof(ts->MouseCursorName), Temp,
1593 _TRUNCATE);
1594
1595 // Translucent window
1596 ts->AlphaBlendInactive =
1597 GetPrivateProfileInt(Section, "AlphaBlend", 255, FName);
1598 ts->AlphaBlendInactive = max(0, ts->AlphaBlendInactive);
1599 ts->AlphaBlendInactive = min(255, ts->AlphaBlendInactive);
1600 ts->AlphaBlendActive =
1601 GetPrivateProfileInt(Section, "AlphaBlendActive", ts->AlphaBlendInactive, FName);
1602 ts->AlphaBlendActive = max(0, ts->AlphaBlendActive);
1603 ts->AlphaBlendActive = min(255, ts->AlphaBlendActive);
1604
1605 // Cygwin install path
1606 GetPrivateProfileString(Section, "CygwinDirectory ", "c:\\cygwin",
1607 Temp, sizeof(Temp), FName);
1608 strncpy_s(ts->CygwinDirectory, sizeof(ts->CygwinDirectory), Temp,
1609 _TRUNCATE);
1610
1611 // Viewlog Editor path
1612 if (GetWindowsDirectory(Temp, sizeof(Temp)) + 13 < sizeof(Temp)) { // "\\notepad.exe"(12) + NUL(1)
1613 strncat_s(Temp, sizeof(Temp), "\\notepad.exe", _TRUNCATE);
1614 }
1615 else {
1616 Temp[0] = '\0';
1617 }
1618 GetPrivateProfileString(Section, "ViewlogEditor ", Temp,
1619 ts->ViewlogEditor, sizeof(ts->ViewlogEditor), FName);
1620
1621 // Locale for UTF-8
1622 GetPrivateProfileString(Section, "Locale ", DEFAULT_LOCALE,
1623 Temp, sizeof(Temp), FName);
1624 strncpy_s(ts->Locale, sizeof(ts->Locale), Temp, _TRUNCATE);
1625
1626 // UI language message file (�����p�X)
1627 GetPrivateProfileString(Section, "UILanguageFile", "lang\\Default.lng",
1628 ts->UILanguageFile_ini, sizeof(ts->UILanguageFile_ini), FName);
1629
1630 // UI language message file (full path)
1631 GetUILanguageFileFull(ts->HomeDir, ts->UILanguageFile_ini,
1632 ts->UILanguageFile, sizeof(ts->UILanguageFile));
1633
1634 // Broadcast Command History (2007.3.3 maya)
1635 ts->BroadcastCommandHistory =
1636 GetOnOff(Section, "BroadcastCommandHistory", FName, FALSE);
1637
1638 // 337: 2007/03/20 Accept Broadcast
1639 ts->AcceptBroadcast =
1640 GetOnOff(Section, "AcceptBroadcast", FName, TRUE);
1641
1642 // Confirm send a file when drag and drop (2007.12.28 maya)
1643 ts->ConfirmFileDragAndDrop =
1644 GetOnOff(Section, "ConfirmFileDragAndDrop", FName, TRUE);
1645
1646 // Translate mouse wheel to cursor key when application cursor mode
1647 ts->TranslateWheelToCursor =
1648 GetOnOff(Section, "TranslateWheelToCursor", FName, TRUE);
1649
1650 // Display "New Connection" dialog on startup (2008.1.18 maya)
1651 ts->HostDialogOnStartup =
1652 GetOnOff(Section, "HostDialogOnStartup", FName, TRUE);
1653
1654 // Mouse event tracking
1655 ts->MouseEventTracking =
1656 GetOnOff(Section, "MouseEventTracking", FName, TRUE);
1657
1658 // Maximized bug tweak
1659 GetPrivateProfileString(Section, "MaximizedBugTweak", "2", Temp,
1660 sizeof(Temp), FName);
1661 if (_stricmp(Temp, "on") == 0) {
1662 ts->MaximizedBugTweak = 2;
1663 }
1664 else {
1665 ts->MaximizedBugTweak = atoi(Temp);
1666 }
1667
1668 // Convert Unicode symbol characters to DEC Special characters
1669 ts->UnicodeDecSpMapping =
1670 GetPrivateProfileInt(Section, "UnicodeToDecSpMapping", 3, FName);
1671
1672 // VT Window Icon
1673 GetPrivateProfileString(Section, "VTIcon", "Default",
1674 Temp, sizeof(Temp), FName);
1675 ts->VTIcon = IconName2IconId(Temp);
1676
1677 // Tek Window Icon
1678 GetPrivateProfileString(Section, "TEKIcon", "Default",
1679 Temp, sizeof(Temp), FName);
1680 ts->TEKIcon = IconName2IconId(Temp);
1681
1682 // Unknown Unicode Character
1683 ts->UnknownUnicodeCharaAsWide =
1684 GetOnOff(Section, "UnknownUnicodeCharacterAsWide", FName, FALSE);
1685
1686 #ifdef USE_NORMAL_BGCOLOR
1687 // UseNormalBGColor
1688 ts->UseNormalBGColor =
1689 GetOnOff(Section, "UseNormalBGColor", FName, FALSE);
1690 // 2006/03/11 by 337
1691 if (ts->UseNormalBGColor) {
1692 ts->VTBoldColor[1] =
1693 ts->VTBlinkColor[1] = ts->URLColor[1] = ts->VTColor[1];
1694 }
1695 #endif
1696
1697 // AutoScrollOnlyInBottomLine
1698 ts->AutoScrollOnlyInBottomLine =
1699 GetOnOff(Section, "AutoScrollOnlyInBottomLine", FName, FALSE);
1700
1701 // Accept remote-controlled window title changing
1702 GetPrivateProfileString(Section, "AcceptTitleChangeRequest", "overwrite",
1703 Temp, sizeof(Temp), FName);
1704 if (_stricmp(Temp, "overwrite") == 0 || _stricmp(Temp, "on") == 0)
1705 ts->AcceptTitleChangeRequest = IdTitleChangeRequestOverwrite;
1706 else if (_stricmp(Temp, "ahead") == 0)
1707 ts->AcceptTitleChangeRequest = IdTitleChangeRequestAhead;
1708 else if (_stricmp(Temp, "last") == 0)
1709 ts->AcceptTitleChangeRequest = IdTitleChangeRequestLast;
1710 else
1711 ts->AcceptTitleChangeRequest = IdTitleChangeRequestOff;
1712
1713 // Size of paste confirm dialog
1714 GetPrivateProfileString(Section, "PasteDialogSize", "330,220",
1715 Temp, sizeof(Temp), FName);
1716 GetNthNum(Temp, 1, &ts->PasteDialogSize.cx);
1717 GetNthNum(Temp, 2, &ts->PasteDialogSize.cy);
1718 if (ts->PasteDialogSize.cx < 0)
1719 ts->PasteDialogSize.cx = 330;
1720 if (ts->PasteDialogSize.cy < 0)
1721 ts->PasteDialogSize.cy = 220;
1722
1723 // Disable mouse event tracking when Control-Key is pressed.
1724 ts->DisableMouseTrackingByCtrl =
1725 GetOnOff(Section, "DisableMouseTrackingByCtrl", FName, TRUE);
1726
1727 // Disable TranslateWheelToCursor setting when Control-Key is pressed.
1728 ts->DisableWheelToCursorByCtrl =
1729 GetOnOff(Section, "DisableWheelToCursorByCtrl", FName, TRUE);
1730
1731 // Strict Key Mapping.
1732 ts->StrictKeyMapping =
1733 GetOnOff(Section, "StrictKeyMapping", FName, FALSE);
1734
1735 // added Wait4allMacroCommand (2009.3.23 yutaka)
1736 ts->Wait4allMacroCommand =
1737 GetOnOff(Section, "Wait4allMacroCommand", FName, FALSE);
1738
1739 // added DisableMenuSendBreak (2009.4.6 maya)
1740 ts->DisableMenuSendBreak =
1741 GetOnOff(Section, "DisableMenuSendBreak", FName, FALSE);
1742
1743 // added ClearScreenOnCloseConnection (2009.4.6 maya)
1744 ts->ClearScreenOnCloseConnection =
1745 GetOnOff(Section, "ClearScreenOnCloseConnection", FName, FALSE);
1746
1747 // added DisableAcceleratorDuplicateSession (2009.4.6 maya)
1748 ts->DisableAcceleratorDuplicateSession =
1749 GetOnOff(Section, "DisableAcceleratorDuplicateSession", FName, FALSE);
1750
1751 ts->AcceleratorNewConnection =
1752 GetOnOff(Section, "AcceleratorNewConnection", FName, TRUE);
1753
1754 ts->AcceleratorCygwinConnection =
1755 GetOnOff(Section, "AcceleratorCygwinConnection", FName, TRUE);
1756
1757 // added DisableMenuDuplicateSession (2010.8.3 maya)
1758 ts->DisableMenuDuplicateSession =
1759 GetOnOff(Section, "DisableMenuDuplicateSession", FName, FALSE);
1760
1761 // added DisableMenuNewConnection (2010.8.4 maya)
1762 ts->DisableMenuNewConnection =
1763 GetOnOff(Section, "DisableMenuNewConnection", FName, FALSE);
1764
1765 // added PasteDelayPerLine (2009.4.12 maya)
1766 ts->PasteDelayPerLine =
1767 GetPrivateProfileInt(Section, "PasteDelayPerLine", 10, FName);
1768 {
1769 int tmp = min(max(0, ts->PasteDelayPerLine), 5000);
1770 ts->PasteDelayPerLine = tmp;
1771 }
1772
1773 // Font scaling -- test
1774 ts->FontScaling = GetOnOff(Section, "FontScaling", FName, FALSE);
1775
1776 // Meta sets MSB
1777 GetPrivateProfileString(Section, "Meta8Bit", "off", Temp, sizeof(Temp), FName);
1778 if (_stricmp(Temp, "raw") == 0 || _stricmp(Temp, "on") == 0)
1779 ts->Meta8Bit = IdMeta8BitRaw;
1780 else if (_stricmp(Temp, "text") == 0)
1781 ts->Meta8Bit = IdMeta8BitText;
1782 else
1783 ts->Meta8Bit = IdMeta8BitOff;
1784
1785 // Window control sequence
1786 if (GetOnOff(Section, "WindowCtrlSequence", FName, TRUE))
1787 ts->WindowFlag |= WF_WINDOWCHANGE;
1788
1789 // Cursor control sequence
1790 if (GetOnOff(Section, "CursorCtrlSequence", FName, FALSE))
1791 ts->WindowFlag |= WF_CURSORCHANGE;
1792
1793 // Window report sequence
1794 if (GetOnOff(Section, "WindowReportSequence", FName, TRUE))
1795 ts->WindowFlag |= WF_WINDOWREPORT;
1796
1797 // Title report sequence
1798 GetPrivateProfileString(Section, "TitleReportSequence", "Empty", Temp, sizeof(Temp), FName);
1799 if (_stricmp(Temp, "accept") == 0)
1800 ts->WindowFlag |= IdTitleReportAccept;
1801 else if (_stricmp(Temp, "ignore") == 0 || _stricmp(Temp, "off") == 0)
1802 ts->WindowFlag &= ~WF_TITLEREPORT;
1803 else // empty
1804 ts->WindowFlag |= IdTitleReportEmpty;
1805
1806 // Line at a time mode
1807 ts->EnableLineMode = GetOnOff(Section, "EnableLineMode", FName, TRUE);
1808
1809 // Clear window on resize
1810 if (GetOnOff(Section, "ClearOnResize", FName, TRUE))
1811 ts->TermFlag |= TF_CLEARONRESIZE;
1812
1813 // Alternate Screen Buffer
1814 if (GetOnOff(Section, "AlternateScreenBuffer", FName, TRUE))
1815 ts->TermFlag |= TF_ALTSCR;
1816
1817 // IME status related cursor style
1818 if (GetOnOff(Section, "IMERelatedCursor", FName, FALSE))
1819 ts->WindowFlag |= WF_IMECURSORCHANGE;
1820
1821 // Terminal Unique ID
1822 GetPrivateProfileString(Section, "TerminalUID", "FFFFFFFF", Temp, sizeof(Temp), FName);
1823 if (strlen(Temp) == 8) {
1824 for (i=0; i<8 && isxdigit((unsigned char)Temp[i]); i++) {
1825 if (islower(Temp[i])) {
1826 ts->TerminalUID[i] = toupper(Temp[i]);
1827 }
1828 else {
1829 ts->TerminalUID[i] = Temp[i];
1830 }
1831 }
1832 if (i == 8) {
1833 ts->TerminalUID[i] = 0;
1834 }
1835 else {
1836 strncpy_s(ts->TerminalUID, sizeof(ts->TerminalUID), "FFFFFFFF", _TRUNCATE);
1837 }
1838 }
1839 else {
1840 strncpy_s(ts->TerminalUID, sizeof(ts->TerminalUID), "FFFFFFFF", _TRUNCATE);
1841 }
1842
1843 // Lock Terminal UID
1844 if (GetOnOff(Section, "LockTUID", FName, TRUE))
1845 ts->TermFlag |= TF_LOCKTUID;
1846
1847 // Jump List
1848 ts->JumpList = GetOnOff(Section, "JumpList", FName, TRUE);
1849
1850 // TabStopModifySequence
1851 GetPrivateProfileString(Section, "TabStopModifySequence", "on", Temp, sizeof(Temp), FName);
1852 if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "all") == 0)
1853 ts->TabStopFlag = TABF_ALL;
1854 else if (_stricmp(Temp, "off") == 0 || _stricmp(Temp, "none") == 0)
1855 ts->TabStopFlag = TABF_NONE;
1856 else {
1857 ts->TabStopFlag = TABF_NONE;
1858 for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
1859 if (_stricmp(Temp2, "HTS") == 0)
1860 ts->TabStopFlag |= TABF_HTS;
1861 else if (_stricmp(Temp2, "HTS7") == 0)
1862 ts->TabStopFlag |= TABF_HTS7;
1863 else if (_stricmp(Temp2, "HTS8") == 0)
1864 ts->TabStopFlag |= TABF_HTS8;
1865 else if (_stricmp(Temp2, "TBC") == 0)
1866 ts->TabStopFlag |= TABF_TBC;
1867 else if (_stricmp(Temp2, "TBC0") == 0)
1868 ts->TabStopFlag |= TABF_TBC0;
1869 else if (_stricmp(Temp2, "TBC3") == 0)
1870 ts->TabStopFlag |= TABF_TBC3;
1871 }
1872 }
1873
1874 // Clipboard Access from Remote
1875 GetPrivateProfileString(Section, "ClipboardAccessFromRemote", "off", Temp, sizeof(Temp), FName);
1876 if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "readwrite") == 0)
1877 ts->CtrlFlag |= CSF_CBRW;
1878 else if (_stricmp(Temp, "read") == 0)
1879 ts->CtrlFlag |= CSF_CBREAD;
1880 else if (_stricmp(Temp, "write") == 0)
1881 ts->CtrlFlag |= CSF_CBWRITE;
1882
1883 // Notify Clipboard Access from Remote
1884 ts->NotifyClipboardAccess = GetOnOff(Section, "NotifyClipboardAccess", FName, TRUE);
1885
1886 // Use invalid DECRPSS (for testing)
1887 if (GetOnOff(Section, "UseInvalidDECRQSSResponse", FName, FALSE))
1888 ts->TermFlag |= TF_INVALIDDECRPSS;
1889
1890 // ClickableUrlBrowser
1891 GetPrivateProfileString(Section, "ClickableUrlBrowser", "",
1892 ts->ClickableUrlBrowser, sizeof(ts->ClickableUrlBrowser), FName);
1893 GetPrivateProfileString(Section, "ClickableUrlBrowserArg", "",
1894 ts->ClickableUrlBrowserArg, sizeof(ts->ClickableUrlBrowserArg), FName);
1895
1896 // Exclusive Lock when open the log file
1897 ts->LogLockExclusive = GetOnOff(Section, "LogLockExclusive", FName, TRUE);
1898
1899 // Font quality
1900 GetPrivateProfileString(Section, "FontQuality", "default",
1901 Temp, sizeof(Temp), FName);
1902 if (_stricmp(Temp, "nonantialiased") == 0)
1903 ts->FontQuality = NONANTIALIASED_QUALITY;
1904 else if (_stricmp(Temp, "antialiased") == 0)
1905 ts->FontQuality = ANTIALIASED_QUALITY;
1906 else if (_stricmp(Temp, "cleartype") == 0)
1907 ts->FontQuality = CLEARTYPE_QUALITY;
1908 else
1909 ts->FontQuality = DEFAULT_QUALITY;
1910
1911 // Beep Over Used
1912 ts->BeepOverUsedCount =
1913 GetPrivateProfileInt(Section, "BeepOverUsedCount", 5, FName);
1914 ts->BeepOverUsedTime =
1915 GetPrivateProfileInt(Section, "BeepOverUsedTime", 2, FName);
1916 ts->BeepSuppressTime =
1917 GetPrivateProfileInt(Section, "BeepSuppressTime", 5, FName);
1918
1919 // Max OSC string buffer size
1920 ts->MaxOSCBufferSize =
1921 GetPrivateProfileInt(Section, "MaxOSCBufferSize", 4096, FName);
1922
1923 ts->JoinSplitURL = GetOnOff(Section, "JoinSplitURL", FName, FALSE);
1924
1925 GetPrivateProfileString(Section, "JoinSplitURLIgnoreEOLChar", "\\", Temp, sizeof(Temp), FName);
1926 ts->JoinSplitURLIgnoreEOLChar = Temp[0];
1927
1928 // Debug modes.
1929 GetPrivateProfileString(Section, "DebugModes", "all", Temp, sizeof(Temp), FName);
1930 if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "all") == 0)
1931 ts->DebugModes = DBGF_ALL;
1932 else if (_stricmp(Temp, "off") == 0 || _stricmp(Temp, "none") == 0) {
1933 ts->DebugModes = DBGF_NONE;
1934 ts->Debug = FALSE;
1935 }
1936 else {
1937 ts->DebugModes = DBGF_NONE;
1938 for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
1939 if (_stricmp(Temp2, "normal") == 0)
1940 ts->DebugModes |= DBGF_NORM;
1941 else if (_stricmp(Temp2, "hex") == 0)
1942 ts->DebugModes |= DBGF_HEXD;
1943 else if (_stricmp(Temp2, "noout") == 0)
1944 ts->DebugModes |= DBGF_NOUT;
1945 }
1946 if (ts->DebugModes == DBGF_NONE)
1947 ts->Debug = FALSE;
1948 }
1949
1950 // Xmodem Timeout
1951 GetPrivateProfileString(Section, "XmodemTimeouts", "10,3,10,20,60", Temp, sizeof(Temp), FName);
1952 ts->XmodemTimeOutInit = GetNthNum2(Temp, 1, 10);
1953 if (ts->XmodemTimeOutInit < 1)
1954 ts->XmodemTimeOutInit = 1;
1955 ts->XmodemTimeOutInitCRC = GetNthNum2(Temp, 2, 3);
1956 if (ts->XmodemTimeOutInitCRC < 1)
1957 ts->XmodemTimeOutInitCRC = 1;
1958 ts->XmodemTimeOutShort = GetNthNum2(Temp, 3, 10);
1959 if (ts->XmodemTimeOutShort < 1)
1960 ts->XmodemTimeOutShort = 1;
1961 ts->XmodemTimeOutLong = GetNthNum2(Temp, 4, 20);
1962 if (ts->XmodemTimeOutLong < 1)
1963 ts->XmodemTimeOutLong = 1;
1964 ts->XmodemTimeOutVLong = GetNthNum2(Temp, 5, 60);
1965 if (ts->XmodemTimeOutVLong < 1)
1966 ts->XmodemTimeOutVLong = 1;
1967
1968 // Ymodem Timeout
1969 GetPrivateProfileString(Section, "YmodemTimeouts", "10,3,10,20,60", Temp, sizeof(Temp), FName);
1970 ts->YmodemTimeOutInit = GetNthNum2(Temp, 1, 10);
1971 if (ts->YmodemTimeOutInit < 1)
1972 ts->YmodemTimeOutInit = 1;
1973 ts->YmodemTimeOutInitCRC = GetNthNum2(Temp, 2, 3);
1974 if (ts->YmodemTimeOutInitCRC < 1)
1975 ts->YmodemTimeOutInitCRC = 1;
1976 ts->YmodemTimeOutShort = GetNthNum2(Temp, 3, 10);
1977 if (ts->YmodemTimeOutShort < 1)
1978 ts->YmodemTimeOutShort = 1;
1979 ts->YmodemTimeOutLong = GetNthNum2(Temp, 4, 20);
1980 if (ts->YmodemTimeOutLong < 1)
1981 ts->YmodemTimeOutLong = 1;
1982 ts->YmodemTimeOutVLong = GetNthNum2(Temp, 5, 60);
1983 if (ts->YmodemTimeOutVLong < 1)
1984 ts->YmodemTimeOutVLong = 1;
1985
1986 // Zmodem Timeout
1987 GetPrivateProfileString(Section, "ZmodemTimeouts", "10,0,10,3", Temp, sizeof(Temp), FName);
1988 ts->ZmodemTimeOutNormal = GetNthNum2(Temp, 1, 10);
1989 if (ts->ZmodemTimeOutNormal < 1)
1990 ts->ZmodemTimeOutNormal = 1;
1991 ts->ZmodemTimeOutTCPIP = GetNthNum2(Temp, 2, 0);
1992 if (ts->ZmodemTimeOutTCPIP < 0)
1993 ts->ZmodemTimeOutTCPIP = 0;
1994 ts->ZmodemTimeOutInit = GetNthNum2(Temp, 3, 10);
1995 if (ts->ZmodemTimeOutInit < 1)
1996 ts->ZmodemTimeOutInit = 1;
1997 ts->ZmodemTimeOutFin = GetNthNum2(Temp, 4, 3);
1998 if (ts->ZmodemTimeOutFin < 1)
1999 ts->ZmodemTimeOutFin = 1;
2000
2001 // Trim trailing new line character when pasting
2002 if (GetOnOff(Section, "TrimTrailingNLonPaste", FName, FALSE))
2003 ts->PasteFlag |= CPF_TRIM_TRAILING_NL;
2004
2005 // Normalize line break when pasting
2006 if (GetOnOff(Section, "NormalizeLineBreakOnPaste", FName, FALSE))
2007 ts->PasteFlag |= CPF_NORMALIZE_LINEBREAK;
2008
2009 // List Inactive Font
2010 ts->ListHiddenFonts = GetOnOff(Section, "ListHiddenFonts", FName, FALSE);
2011
2012 // ISO2022ShiftFunction
2013 GetPrivateProfileString(Section, "ISO2022ShiftFunction", "on", Temp, sizeof(Temp), FName);
2014 ts->ISO2022Flag = ISO2022_SHIFT_NONE;
2015 for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
2016 BOOL add=TRUE;
2017 char *p = Temp2, *p2;
2018 int mask = 0;
2019
2020 while (*p == ' ' || *p == '\t') {
2021 p++;
2022 }
2023 p2 = p + strlen(p);
2024 while (p2 > p) {
2025 p2--;
2026 if (*p2 != ' ' && *p2 != '\t') {
2027 break;
2028 }
2029 }
2030 *++p2 = 0;
2031
2032 if (*p == '-') {
2033 p++;
2034 add=FALSE;
2035 }
2036 else if (*p == '+') {
2037 p++;
2038 }
2039
2040 if (_stricmp(p, "on") == 0 || _stricmp(p, "all") == 0)
2041 ts->ISO2022Flag = ISO2022_SHIFT_ALL;
2042 else if (_stricmp(p, "off") == 0 || _stricmp(p, "none") == 0)
2043 ts->ISO2022Flag = ISO2022_SHIFT_NONE;
2044 else if (_stricmp(p, "SI") == 0 || _stricmp(p, "LS0") == 0)
2045 mask = ISO2022_SI;
2046 else if (_stricmp(p, "SO") == 0 || _stricmp(p, "LS1") == 0)
2047 mask = ISO2022_SO;
2048 else if (_stricmp(p, "LS2") == 0)
2049 mask = ISO2022_LS2;
2050 else if (_stricmp(p, "LS3") == 0)
2051 mask = ISO2022_LS3;
2052 else if (_stricmp(p, "LS1R") == 0)
2053 mask = ISO2022_LS1R;
2054 else if (_stricmp(p, "LS2R") == 0)
2055 mask = ISO2022_LS2R;
2056 else if (_stricmp(p, "LS3R") == 0)
2057 mask = ISO2022_LS3R;
2058 else if (_stricmp(p, "SS2") == 0)
2059 mask = ISO2022_SS2;
2060 else if (_stricmp(p, "SS3") == 0)
2061 mask = ISO2022_SS3;
2062
2063 if (mask) {
2064 if (add) {
2065 ts->ISO2022Flag |= mask;
2066 }
2067 else {
2068 ts->ISO2022Flag &= ~mask;
2069 }
2070 }
2071 }
2072
2073 // Terminal Speed (Used by telnet and ssh)
2074 GetPrivateProfileString(Section, "TerminalSpeed", "38400", Temp, sizeof(Temp), FName);
2075 GetNthNum(Temp, 1, &i);
2076 if (i > 0)
2077 ts->TerminalInputSpeed = i;
2078 else
2079 ts->TerminalInputSpeed = 38400;
2080 GetNthNum(Temp, 2, &i);
2081 if (i > 0)
2082 ts->TerminalOutputSpeed = i;
2083 else
2084 ts->TerminalOutputSpeed = ts->TerminalInputSpeed;
2085
2086 // Fallback to CP932 (Experimental)
2087 ts->FallbackToCP932 = GetOnOff(Section, "FallbackToCP932", FName, FALSE);
2088
2089 // CygTerm Configuration File
2090 ReadCygtermConfFile(ts);
2091
2092 // dialog font
2093 ReadFont3("Tera Term", "DlgFont", NULL, FName,
2094 ts->DialogFontName, sizeof(ts->DialogFontName),
2095 &ts->DialogFontPoint, &ts->DialogFontCharSet);
2096 }
2097
2098 void PASCAL WriteIniFile(PCHAR FName, PTTSet ts)
2099 {
2100 int i;
2101 char Temp[MAX_PATH];
2102 char buf[20];
2103 int ret;
2104 char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG], msg[MAX_UIMSG];
2105
2106 /* version */
2107 ret = WritePrivateProfileString(Section, "Version", TT_VERSION_STR("."), FName);
2108 if (ret == 0) {
2109 // ini�t�@�C�����������������s�������A�G���[���b�Z�[�W���\�������B(2012.10.18 yutaka)
2110 ret = GetLastError();
2111 get_lang_msg("MSG_INI_WRITE_ERROR", uimsg, sizeof(uimsg), "Cannot write ini file", ts->UILanguageFile);
2112 _snprintf_s(msg, sizeof(msg), _TRUNCATE, "%s (%d)", uimsg, ret);
2113
2114 get_lang_msg("MSG_INI_ERROR", uimsg2, sizeof(uimsg2), "Tera Term: Error", ts->UILanguageFile);
2115
2116 MessageBox(NULL, msg, uimsg2, MB_ICONEXCLAMATION);
2117 }
2118
2119 /* Language */
2120 switch (ts->Language) {
2121 case IdJapanese:
2122 strncpy_s(Temp, sizeof(Temp), "Japanese", _TRUNCATE);
2123 break;
2124 case IdKorean:
2125 strncpy_s(Temp, sizeof(Temp), "Korean", _TRUNCATE);
2126 break;
2127 case IdRussian:
2128 strncpy_s(Temp, sizeof(Temp), "Russian", _TRUNCATE);
2129 break;
2130 case IdUtf8:
2131 strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
2132 break;
2133 default:
2134 strncpy_s(Temp, sizeof(Temp), "English", _TRUNCATE);
2135 }
2136
2137 WritePrivateProfileString(Section, "Language", Temp, FName);
2138
2139 /* Port type */
2140 WritePrivateProfileString(Section, "Port", (ts->PortType==IdSerial)?"serial":"tcpip", FName);
2141
2142 /* Save win position */
2143 if (ts->SaveVTWinPos) {
2144 /* VT win position */
2145 WriteInt2(Section, "VTPos", FName, ts->VTPos.x, ts->VTPos.y);
2146 }
2147
2148 /* VT terminal size */
2149 WriteInt2(Section, "TerminalSize", FName,
2150 ts->TerminalWidth, ts->TerminalHeight);
2151
2152 /* Terminal size = Window size */
2153 WriteOnOff(Section, "TermIsWin", FName, ts->TermIsWin);
2154
2155 /* Auto window resize flag */
2156 WriteOnOff(Section, "AutoWinResize", FName, ts->AutoWinResize);
2157
2158 /* CR Receive */
2159 if (ts->CRReceive == IdCRLF) {
2160 strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
2161 }
2162 else if (ts->CRReceive == IdLF) {
2163 strncpy_s(Temp, sizeof(Temp), "LF", _TRUNCATE);
2164 }
2165 else if (ts->CRReceive == IdAUTO) {
2166 strncpy_s(Temp, sizeof(Temp), "AUTO", _TRUNCATE);
2167 }
2168 else {
2169 strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
2170 }
2171 WritePrivateProfileString(Section, "CRReceive", Temp, FName);
2172
2173 /* CR Send */
2174 if (ts->CRSend == IdCRLF) {
2175 strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
2176 }
2177 else if (ts->CRSend == IdLF) {
2178 strncpy_s(Temp, sizeof(Temp), "LF", _TRUNCATE);
2179 }
2180 else {
2181 strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
2182 }
2183 WritePrivateProfileString(Section, "CRSend", Temp, FName);
2184
2185 /* Local echo */
2186 WriteOnOff(Section, "LocalEcho", FName, ts->LocalEcho);
2187
2188 /* Answerback */
2189 if ((ts->FTFlag & FT_BPAUTO) == 0) {
2190 Str2Hex(ts->Answerback, Temp, ts->AnswerbackLen,
2191 sizeof(Temp) - 1, TRUE);
2192 WritePrivateProfileString(Section, "Answerback", Temp, FName);
2193 }
2194
2195 /* Kanji Code (receive) */
2196 switch (ts->KanjiCode) {
2197 case IdEUC:
2198 strncpy_s(Temp, sizeof(Temp), "EUC", _TRUNCATE);
2199 break;
2200 case IdJIS:
2201 strncpy_s(Temp, sizeof(Temp), "JIS", _TRUNCATE);
2202 break;
2203 case IdUTF8:
2204 strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
2205 break;
2206 case IdUTF8m:
2207 strncpy_s(Temp, sizeof(Temp), "UTF-8m", _TRUNCATE);
2208 break;
2209 default:
2210 switch (ts->Language) {
2211 case IdJapanese:
2212 strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2213 break;
2214 case IdKorean:
2215 strncpy_s(Temp, sizeof(Temp), "KS5601", _TRUNCATE);
2216 break;
2217 default:
2218 strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2219 }
2220 }
2221 WritePrivateProfileString(Section, "KanjiReceive", Temp, FName);
2222
2223 /* Katakana (receive) */
2224 if (ts->JIS7Katakana == 1)
2225 strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
2226 else
2227 strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
2228
2229 WritePrivateProfileString(Section, "KatakanaReceive", Temp, FName);
2230
2231 /* Kanji Code (transmit) */
2232 switch (ts->KanjiCodeSend) {
2233 case IdEUC:
2234 strncpy_s(Temp, sizeof(Temp), "EUC", _TRUNCATE);
2235 break;
2236 case IdJIS:
2237 strncpy_s(Temp, sizeof(Temp), "JIS", _TRUNCATE);
2238 break;
2239 case IdUTF8:
2240 strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
2241 break;
2242 default:
2243 switch (ts->Language) {
2244 case IdJapanese:
2245 strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2246 break;
2247 case IdKorean:
2248 strncpy_s(Temp, sizeof(Temp), "KS5601", _TRUNCATE);
2249 break;
2250 default:
2251 strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2252 }
2253 }
2254 WritePrivateProfileString(Section, "KanjiSend", Temp, FName);
2255
2256 /* Katakana (transmit) */
2257 if (ts->JIS7KatakanaSend == 1)
2258 strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
2259 else
2260 strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
2261
2262 WritePrivateProfileString(Section, "KatakanaSend", Temp, FName);
2263
2264 /* KanjiIn */
2265 if (ts->KanjiIn == IdKanjiInA)
2266 strncpy_s(Temp, sizeof(Temp), "@", _TRUNCATE);
2267 else
2268 strncpy_s(Temp, sizeof(Temp), "B", _TRUNCATE);
2269
2270 WritePrivateProfileString(Section, "KanjiIn", Temp, FName);
2271
2272 /* KanjiOut */
2273 switch (ts->KanjiOut) {
2274 case IdKanjiOutB:
2275 strncpy_s(Temp, sizeof(Temp), "B", _TRUNCATE);
2276 break;
2277 case IdKanjiOutH:
2278 strncpy_s(Temp, sizeof(Temp), "H", _TRUNCATE);
2279 break;
2280 default:
2281 strncpy_s(Temp, sizeof(Temp), "J", _TRUNCATE);
2282 }
2283 WritePrivateProfileString(Section, "KanjiOut", Temp, FName);
2284
2285 // new configuration
2286 WriteInt(Section, "ConnectingTimeout", FName, ts->ConnectingTimeout);
2287
2288 WriteOnOff(Section, "DisablePasteMouseRButton", FName,
2289 (WORD) (ts->PasteFlag & CPF_DISABLE_RBUTTON));
2290
2291 WriteOnOff(Section, "DisablePasteMouseMButton", FName,
2292 (WORD) (ts->PasteFlag & CPF_DISABLE_MBUTTON));
2293
2294 WriteOnOff(Section, "ConfirmPasteMouseRButton", FName,
2295 (WORD) (ts->PasteFlag & CPF_CONFIRM_RBUTTON));
2296
2297 // added ConfirmChangePaste
2298 WriteOnOff(Section, "ConfirmChangePaste", FName,
2299 (WORD) (ts->PasteFlag & CPF_CONFIRM_CHANGEPASTE));
2300
2301 WriteOnOff(Section, "ConfirmChangePasteCR", FName,
2302 (WORD) (ts->PasteFlag & CPF_CONFIRM_CHANGEPASTE_CR));
2303
2304 WritePrivateProfileString(Section, "ConfirmChangePasteStringFile",
2305 ts->ConfirmChangePasteStringFile, FName);
2306
2307 // added ScrollWindowClearScreen
2308 WriteOnOff(Section, "ScrollWindowClearScreen", FName,
2309 ts->ScrollWindowClearScreen);
2310
2311 // added SelectOnlyByLButton (2007.11.20 maya)
2312 WriteOnOff(Section, "SelectOnlyByLButton", FName,
2313 ts->SelectOnlyByLButton);
2314 // added DisableAcceleratorSendBreak (2007.3.17 maya)
2315 WriteOnOff(Section, "DisableAcceleratorSendBreak", FName,
2316 ts->DisableAcceleratorSendBreak);
2317 WriteOnOff(Section, "EnableContinuedLineCopy", FName,
2318 ts->EnableContinuedLineCopy);
2319 WritePrivateProfileString(Section, "MouseCursor", ts->MouseCursorName,
2320 FName);
2321 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->AlphaBlendInactive);
2322 WritePrivateProfileString(Section, "AlphaBlend", Temp, FName);
2323 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->AlphaBlendActive);
2324 WritePrivateProfileString(Section, "AlphaBlendActive", Temp, FName);
2325 WritePrivateProfileString(Section, "CygwinDirectory",
2326 ts->CygwinDirectory, FName);
2327 WritePrivateProfileString(Section, "ViewlogEditor", ts->ViewlogEditor,
2328 FName);
2329 WritePrivateProfileString(Section, "Locale", ts->Locale, FName);
2330
2331 // ANSI color(2004.9.5 yutaka)
2332 Temp[0] = '\0';
2333 for (i = 0; i < 15; i++) {
2334 _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d,%d,%d,%d, ",
2335 i,
2336 GetRValue(ts->ANSIColor[i]),
2337 GetGValue(ts->ANSIColor[i]),
2338 GetBValue(ts->ANSIColor[i])
2339 );
2340 strncat_s(Temp, sizeof(Temp), buf, _TRUNCATE);
2341 }
2342 i = 15;
2343 _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d,%d,%d,%d",
2344 i,
2345 GetRValue(ts->ANSIColor[i]),
2346 GetGValue(ts->ANSIColor[i]),
2347 GetBValue(ts->ANSIColor[i])
2348 );
2349 strncat_s(Temp, sizeof(Temp), buf, _TRUNCATE);
2350 WritePrivateProfileString(Section, "ANSIColor", Temp, FName);
2351
2352 /* AutoWinChange VT<->TEK */
2353 WriteOnOff(Section, "AutoWinSwitch", FName, ts->AutoWinSwitch);
2354
2355 /* Terminal ID */
2356 id2str(TermList, ts->TerminalID, IdVT100, Temp, sizeof(Temp));
2357 WritePrivateProfileString(Section, "TerminalID", Temp, FName);
2358
2359 /* Russian character set (host) */
2360 id2str(RussList, ts->RussHost, IdKOI8, Temp, sizeof(Temp));
2361 WritePrivateProfileString(Section, "RussHost", Temp, FName);
2362
2363 /* Russian character set (client) */
2364 id2str(RussList, ts->RussClient, IdWindows, Temp, sizeof(Temp));
2365 WritePrivateProfileString(Section, "RussClient", Temp, FName);
2366
2367 /* Title text */
2368 WritePrivateProfileString(Section, "Title", ts->Title, FName);
2369
2370 /* Cursor shape */
2371 switch (ts->CursorShape) {
2372 case IdVCur:
2373 strncpy_s(Temp, sizeof(Temp), "vertical", _TRUNCATE);
2374 break;
2375 case IdHCur:
2376 strncpy_s(Temp, sizeof(Temp), "horizontal", _TRUNCATE);
2377 break;
2378 default:
2379 strncpy_s(Temp, sizeof(Temp), "block", _TRUNCATE);
2380 }
2381 WritePrivateProfileString(Section, "CursorShape", Temp, FName);
2382
2383 /* Hide title */
2384 WriteOnOff(Section, "HideTitle", FName, ts->HideTitle);
2385
2386 /* Popup menu */
2387 WriteOnOff(Section, "PopupMenu", FName, ts->PopupMenu);
2388
2389 /* PC-Style bold color mapping */
2390 WriteOnOff(Section, "PcBoldColor", FName,
2391 (WORD) (ts->ColorFlag & CF_PCBOLD16));
2392
2393 /* aixterm 16 colors mode */
2394 WriteOnOff(Section, "Aixterm16Color", FName,
2395 (WORD) (ts->ColorFlag & CF_AIXTERM16));
2396
2397 /* xterm 256 colors mode */
2398 WriteOnOff(Section, "Xterm256Color", FName,
2399 (WORD) (ts->ColorFlag & CF_XTERM256));
2400
2401 /* Enable scroll buffer */
2402 WriteOnOff(Section, "EnableScrollBuff", FName, ts->EnableScrollBuff);
2403
2404 /* Scroll buffer size */
2405 WriteInt(Section, "ScrollBuffSize", FName, ts->ScrollBuffSize);
2406
2407 /* VT Color */
2408 for (i = 0; i <= 1; i++) {
2409 if (ts->ColorFlag & CF_REVERSEVIDEO) {
2410 if (ts->ColorFlag & CF_REVERSECOLOR) {
2411 ts->TmpColor[0][i * 3] = GetRValue(ts->VTReverseColor[i]);
2412 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTReverseColor[i]);
2413 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTReverseColor[i]);
2414 }
2415 else {
2416 ts->TmpColor[0][i * 3] = GetRValue(ts->VTColor[!i]);
2417 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTColor[!i]);
2418 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTColor[!i]);
2419 }
2420 }
2421 else {
2422 ts->TmpColor[0][i * 3] = GetRValue(ts->VTColor[i]);
2423 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTColor[i]);
2424 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTColor[i]);
2425 }
2426 }
2427 WriteInt6(Section, "VTColor", FName,
2428 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
2429 ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
2430
2431 /* VT Bold Color */
2432 for (i = 0; i <= 1; i++) {
2433 if (ts->ColorFlag & CF_REVERSEVIDEO) {
2434 ts->TmpColor[0][i * 3] = GetRValue(ts->VTBoldColor[!i]);
2435 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBoldColor[!i]);
2436 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBoldColor[!i]);
2437 }
2438 else {
2439 ts->TmpColor[0][i * 3] = GetRValue(ts->VTBoldColor[i]);
2440 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBoldColor[i]);
2441 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBoldColor[i]);
2442 }
2443 }
2444 WriteInt6(Section, "VTBoldColor", FName,
2445 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
2446 ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
2447
2448 /* VT Blink Color */
2449 for (i = 0; i <= 1; i++) {
2450 if (ts->ColorFlag & CF_REVERSEVIDEO) {
2451 ts->TmpColor[0][i * 3] = GetRValue(ts->VTBlinkColor[!i]);
2452 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBlinkColor[!i]);
2453 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBlinkColor[!i]);
2454 }
2455 else {
2456 ts->TmpColor[0][i * 3] = GetRValue(ts->VTBlinkColor[i]);
2457 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBlinkColor[i]);
2458 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBlinkColor[i]);
2459 }
2460 }
2461 WriteInt6(Section, "VTBlinkColor", FName,
2462 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
2463 ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
2464
2465 /* VT Reverse Color */
2466 for (i = 0; i <= 1; i++) {
2467 if (ts->ColorFlag & CF_REVERSEVIDEO && ts->ColorFlag & CF_REVERSECOLOR) {
2468 ts->TmpColor[0][i * 3] = GetRValue(ts->VTColor[i]);
2469 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTColor[i]);
2470 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTColor[i]);
2471 }
2472 else {
2473 ts->TmpColor[0][i * 3] = GetRValue(ts->VTReverseColor[i]);
2474 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTReverseColor[i]);
2475 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTReverseColor[i]);
2476 }
2477 }
2478 WriteInt6(Section, "VTReverseColor", FName,
2479 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
2480 ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
2481
2482 WriteOnOff(Section, "EnableClickableUrl", FName,
2483 ts->EnableClickableUrl);
2484
2485 /* URL color */
2486 for (i = 0; i <= 1; i++) {
2487 if (ts->ColorFlag & CF_REVERSEVIDEO) {
2488 ts->TmpColor[0][i * 3] = GetRValue(ts->URLColor[!i]);
2489 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->URLColor[!i]);
2490 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->URLColor[!i]);
2491 }
2492 else {
2493 ts->TmpColor[0][i * 3] = GetRValue(ts->URLColor[i]);
2494 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->URLColor[i]);
2495 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->URLColor[i]);
2496 }
2497 }
2498 WriteInt6(Section, "URLColor", FName,
2499 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
2500 ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
2501
2502 WriteOnOff(Section, "EnableBoldAttrColor", FName,
2503 (WORD) (ts->ColorFlag & CF_BOLDCOLOR));
2504
2505 WriteOnOff(Section, "EnableBlinkAttrColor", FName,
2506 (WORD) (ts->ColorFlag & CF_BLINKCOLOR));
2507
2508 WriteOnOff(Section, "EnableReverseAttrColor", FName,
2509 (WORD) (ts->ColorFlag & CF_REVERSECOLOR));
2510
2511 WriteOnOff(Section, "EnableURLColor", FName,
2512 (WORD) (ts->ColorFlag & CF_URLCOLOR));
2513
2514 WriteOnOff(Section, "URLUnderline", FName,
2515 (WORD) (ts->FontFlag & FF_URLUNDERLINE));
2516
2517 WriteOnOff(Section, "EnableANSIColor", FName,
2518 (WORD) (ts->ColorFlag & CF_ANSICOLOR));
2519
2520 /* TEK Color */
2521 for (i = 0; i <= 1; i++) {
2522 ts->TmpColor[0][i * 3] = GetRValue(ts->TEKColor[i]);
2523 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->TEKColor[i]);
2524 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->TEKColor[i]);
2525 }
2526 WriteInt6(Section, "TEKColor", FName,
2527 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
2528 ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
2529
2530 /* TEK color emulation */
2531 WriteOnOff(Section, "TEKColorEmulation", FName, ts->TEKColorEmu);
2532
2533 /* VT Font */
2534 WriteFont(Section, "VTFont", FName,
2535 ts->VTFont, ts->VTFontSize.x, ts->VTFontSize.y,
2536 ts->VTFontCharSet);
2537
2538 /* Enable bold font flag */
2539 WriteOnOff(Section, "EnableBold", FName,
2540 (WORD) (ts->FontFlag & FF_BOLD));
2541
2542 /* Russian character set (font) */
2543 id2str(RussList, ts->RussFont, IdWindows, Temp, sizeof(Temp));
2544 WritePrivateProfileString(Section, "RussFont", Temp, FName);
2545
2546 /* TEK Font */
2547 WriteFont(Section, "TEKFont", FName,
2548 ts->TEKFont, ts->TEKFontSize.x, ts->TEKFontSize.y,
2549 ts->TEKFontCharSet);
2550
2551 /* BS key */
2552 if (ts->BSKey == IdDEL)
2553 strncpy_s(Temp, sizeof(Temp), "DEL", _TRUNCATE);
2554 else
2555 strncpy_s(Temp, sizeof(Temp), "BS", _TRUNCATE);
2556 WritePrivateProfileString(Section, "BSKey", Temp, FName);
2557
2558 /* Delete key */
2559 WriteOnOff(Section, "DeleteKey", FName, ts->DelKey);
2560
2561 /* Meta key */
2562 switch (ts->MetaKey) {
2563 case 1:
2564 strncpy_s(Temp, sizeof(Temp), "on", _TRUNCATE);
2565 break;
2566 case 2:
2567 strncpy_s(Temp, sizeof(Temp), "left", _TRUNCATE);
2568 break;
2569 case 3:
2570 strncpy_s(Temp, sizeof(Temp), "right", _TRUNCATE);
2571 break;
2572 default:
2573 strncpy_s(Temp, sizeof(Temp), "off", _TRUNCATE);
2574 }
2575 WritePrivateProfileString(Section, "Metakey", Temp, FName);
2576
2577 /* Application Keypad */
2578 WriteOnOff(Section, "DisableAppKeypad", FName, ts->DisableAppKeypad);
2579
2580 /* Application Cursor */
2581 WriteOnOff(Section, "DisableAppCursor", FName, ts->DisableAppCursor);
2582
2583 /* Russian keyboard type */
2584 id2str(RussList2, ts->RussKeyb, IdWindows, Temp, sizeof(Temp));
2585 WritePrivateProfileString(Section, "RussKeyb", Temp, FName);
2586
2587 /* Serial port ID */
2588 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->ComPort);
2589 WritePrivateProfileString(Section, "ComPort", Temp, FName);
2590
2591 /* Baud rate */
2592 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->Baud);
2593 WritePrivateProfileString(Section, "BaudRate", Temp, FName);
2594
2595 /* Parity */
2596 switch (ts->Parity) {
2597 case IdParityEven:
2598 strncpy_s(Temp, sizeof(Temp), "even", _TRUNCATE);
2599 break;
2600 case IdParityOdd:
2601 strncpy_s(Temp, sizeof(Temp), "odd", _TRUNCATE);
2602 break;
2603 case IdParityMark:
2604 strncpy_s(Temp, sizeof(Temp), "mark", _TRUNCATE);
2605 break;
2606 case IdParitySpace:
2607 strncpy_s(Temp, sizeof(Temp), "space", _TRUNCATE);
2608 break;
2609 default:
2610 strncpy_s(Temp, sizeof(Temp), "none", _TRUNCATE);
2611 }
2612 WritePrivateProfileString(Section, "Parity", Temp, FName);
2613
2614 /* Data bit */
2615 if (ts->DataBit == IdDataBit7)
2616 strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
2617 else
2618 strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
2619
2620 WritePrivateProfileString(Section, "DataBit", Temp, FName);
2621
2622 /* Stop bit */
2623 switch (ts->StopBit) {
2624 case IdStopBit2:
2625 strncpy_s(Temp, sizeof(Temp), "2", _TRUNCATE);
2626 break;
2627 case IdStopBit15:
2628 strncpy_s(Temp, sizeof(Temp), "1.5", _TRUNCATE);
2629 break;
2630 default:
2631 strncpy_s(Temp, sizeof(Temp), "1", _TRUNCATE);
2632 break;
2633 }
2634
2635 WritePrivateProfileString(Section, "StopBit", Temp, FName);
2636
2637 /* Flow control */
2638 switch (ts->Flow) {
2639 case IdFlowX:
2640 strncpy_s(Temp, sizeof(Temp), "x", _TRUNCATE);
2641 break;
2642 case IdFlowHard:
2643 strncpy_s(Temp, sizeof(Temp), "hard", _TRUNCATE);
2644 break;
2645 case IdFlowHardDsrDtr:
2646 strncpy_s(Temp, sizeof(Temp), "dsrdtr", _TRUNCATE);
2647 break;
2648 default:
2649 strncpy_s(Temp, sizeof(Temp), "none", _TRUNCATE);
2650 }
2651 WritePrivateProfileString(Section, "FlowCtrl", Temp, FName);
2652
2653 /* Delay per character */
2654 WriteInt(Section, "DelayPerChar", FName, ts->DelayPerChar);
2655
2656 /* Delay per line */
2657 WriteInt(Section, "DelayPerLine", FName, ts->DelayPerLine);
2658
2659 /* Telnet flag */
2660 WriteOnOff(Section, "Telnet", FName, ts->Telnet);
2661
2662 /* Telnet terminal type */
2663 WritePrivateProfileString(Section, "TermType", ts->TermType, FName);
2664
2665 /* TCP port num for non-telnet */
2666 WriteUint(Section, "TCPPort", FName, ts->TCPPort);
2667
2668 /* Auto close flag */
2669 WriteOnOff(Section, "AutoWinClose", FName, ts->AutoWinClose);
2670
2671 /* History list */
2672 WriteOnOff(Section, "Historylist", FName, ts->HistoryList);
2673
2674 /* File transfer binary flag */
2675 WriteOnOff(Section, "TransBin", FName, ts->TransBin);
2676
2677 /* Log binary flag */
2678 WriteOnOff(Section, "LogBinary", FName, ts->LogBinary);
2679
2680 /* Log append */
2681 WriteOnOff(Section, "LogAppend", FName, ts->Append);
2682
2683 /* Log plain text flag */
2684 WriteOnOff(Section, "LogTypePlainText", FName, ts->LogTypePlainText);
2685
2686 /* Log with timestamp (2006.7.23 maya) */
2687 WriteOnOff(Section, "LogTimestamp", FName, ts->LogTimestamp);
2688
2689 /* Log without transfer dialog */
2690 WriteOnOff(Section, "LogHideDialog", FName, ts->LogHideDialog);
2691
2692 WriteOnOff(Section, "LogIncludeScreenBuffer", FName, ts->LogAllBuffIncludedInFirst);
2693
2694 /* Timestamp format of Log each line */
2695 WritePrivateProfileString(Section, "LogTimestampFormat",
2696 ts->LogTimestampFormat, FName);
2697
2698 /* Timestamp type */
2699 switch (ts->LogTimestampType) {
2700 case TIMESTAMP_LOCAL:
2701 WritePrivateProfileString(Section, "LogTimestampType", "Local", FName);
2702 break;
2703 case TIMESTAMP_UTC:
2704 WritePrivateProfileString(Section, "LogTimestampType", "UTC", FName);
2705 break;
2706 case TIMESTAMP_ELAPSED_LOGSTART:
2707 WritePrivateProfileString(Section, "LogTimestampType", "LoggingElapsed", FName);
2708 break;
2709 case TIMESTAMP_ELAPSED_CONNECTED:
2710 WritePrivateProfileString(Section, "LogTimestampType", "ConnectionElapsed", FName);
2711 break;
2712 }
2713
2714 /* Default Log file name (2006.8.28 maya) */
2715 WritePrivateProfileString(Section, "LogDefaultName",
2716 ts->LogDefaultName, FName);
2717
2718 /* Default Log file path (2007.5.30 maya) */
2719 WritePrivateProfileString(Section, "LogDefaultPath",
2720 ts->LogDefaultPath, FName);
2721
2722 /* Auto start logging (2007.5.31 maya) */
2723 WriteOnOff(Section, "LogAutoStart", FName, ts->LogAutoStart);
2724
2725 /* Log Rotate (2013.3.24 yutaka) */
2726 WriteInt(Section, "LogRotate", FName, ts->LogRotate);
2727 WriteInt(Section, "LogRotateSize", FName, ts->LogRotateSize);
2728 WriteInt(Section, "LogRotateSizeType", FName, ts->LogRotateSizeType);
2729 WriteInt(Section, "LogRotateStep", FName, ts->LogRotateStep);
2730
2731 /* Deferred Log Write Mode (2013.4.20 yutaka) */
2732 WriteOnOff(Section, "DeferredLogWriteMode", FName, ts->DeferredLogWriteMode);
2733
2734 /* XMODEM option */
2735 switch (ts->XmodemOpt) {
2736 case XoptCRC:
2737 strncpy_s(Temp, sizeof(Temp), "crc", _TRUNCATE);
2738 break;
2739 case Xopt1kCRC:
2740 strncpy_s(Temp, sizeof(Temp), "1k", _TRUNCATE);
2741 break;
2742 case Xopt1kCksum:
2743 strncpy_s(Temp, sizeof(