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 10102 - (show annotations) (download) (as text)
Sat Jul 30 14:56:55 2022 UTC (20 months, 1 week ago) by zmatsuo
File MIME type: text/x-csrc
File size: 138770 byte(s)
ttset.c で確保メモリを開放するようにした

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