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 9048 - (show annotations) (download) (as text)
Wed Dec 16 12:24:13 2020 UTC (3 years, 3 months ago) by nmaya
File MIME type: text/x-csrc
File size: 146138 byte(s)
ソースファイルの著作権表記の "最後の発行の年" を削除

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