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 9206 - (show annotations) (download) (as text)
Mon Apr 12 14:16:18 2021 UTC (2 years, 11 months ago) by nmaya
File MIME type: text/x-csrc
File size: 146080 byte(s)
シリアルポート接続の1.5ストップビットのサポートを削除

ticket #40299
1.5ストップビットは常に不正な設定となるため

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