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 8205 - (show annotations) (download) (as text)
Fri Sep 20 14:16:59 2019 UTC (4 years, 6 months ago) by yutakapon
File MIME type: text/x-csrc
File size: 144053 byte(s)
・シリアルポート設定ダイアログからNew connectionする際、全設定をコマンドラインに渡すようにした。
・コマンドラインオプション /CDATABIT=, /CPARITY=, /CSTOPBIT=, /CFLOWCTRL=, /CDELAYPERCHAR=, /CDELAYPERLINE=を追加した。

branches/serial_port_improvedからリビジョン8172, 8204をマージ:
・シリアルポート設定ダイアログからNew connectionする際、全設定をコマンドラインに渡すようにした。
・コマンドラインオプション /CDATABIT=, /CPARITY=, /CSTOPBIT=, /CFLOWCTRL=, /CDELAYPERCHAR=, /CDELAYPERLINE=を追加した。

........
コマンドラインオプション /CDATABIT=, /CPARITY=, /CSTOPBIT=, /CFLOWCTRL= の指定方法を
teraterm.ini と合わせるようにした。

........

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