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 9129 - (show annotations) (download) (as text)
Sat Jan 16 05:21:37 2021 UTC (3 years, 2 months ago) by zmatsuo
File MIME type: text/x-csrc
File size: 146079 byte(s)
VS2005 による Windows 95 のサポート方法を変更

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