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 10036 - (show annotations) (download) (as text)
Mon Jul 4 23:05:12 2022 UTC (21 months, 1 week ago) by nmaya
File MIME type: text/x-csrc
File size: 137517 byte(s)
ウィンドウの角丸抑止(DWMWCP_DONOTROUND)を設定で選べるようにした

WindowCornerDontround を追加
デフォルトは off

ticket #44861
https://osdn.net/projects/ttssh2/ticket/44861#comment:1412:44861:1656675501

merge from 4-stable: r10035
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 void PASCAL ReadIniFile(const wchar_t *FName, PTTSet ts)
768 {
769 int i;
770 HDC TmpDC;
771 char Temp[MAX_PATH], Temp2[MAX_PATH], *p;
772 wchar_t TempW[MAX_PATH];
773 WORD TmpColor[12][6];
774
775 ts->Minimize = 0;
776 ts->HideWindow = 0;
777 ts->LogFlag = 0; // Log flags
778 ts->FTFlag = 0; // File transfer flags
779 ts->MenuFlag = 0; // Menu flags
780 ts->TermFlag = 0; // Terminal flag
781 ts->ColorFlag = 0; // ANSI/Attribute color flags
782 ts->FontFlag = 0; // Font flag
783 ts->PortFlag = 0; // Port flags
784 ts->WindowFlag = 0; // Window flags
785 ts->CtrlFlag = 0; // Control sequence flags
786 ts->PasteFlag = 0; // Clipboard Paste flags
787 ts->TelPort = 23;
788
789 ts->DisableTCPEchoCR = FALSE;
790
791 /*
792 * Version number
793 * �����t�@�C���������o�[�W������ Tera Term �����������������\��
794 * �����t�@�C�����������������l���������A������ Tera Term ���o�[�W�������g������
795 */
796 GetPrivateProfileString(Section, "Version", TT_VERSION_STR("."), Temp, sizeof(Temp), FName);
797 p = strchr(Temp, '.');
798 if (p) {
799 *p++ = 0;
800 ts->ConfigVersion = atoi(Temp) * 10000 + atoi(p);
801 }
802 else {
803 ts->ConfigVersion = 0;
804 }
805
806 // TTX �� �m�F�����������ATera Term ���o�[�W�������i�[��������
807 ts->RunningVersion = TT_VERSION_MAJOR * 10000 + TT_VERSION_MINOR;
808
809 /* Language */
810 GetPrivateProfileString(Section, "Language", "",
811 Temp, sizeof(Temp), FName);
812 if (Temp[0] != 0) {
813 ts->Language = GetLanguageFromStr(Temp);
814 }
815 else {
816 switch (PRIMARYLANGID(GetSystemDefaultLangID())) {
817 case LANG_JAPANESE:
818 ts->Language = IdJapanese;
819 break;
820 case LANG_RUSSIAN:
821 ts->Language = IdRussian;
822 break;
823 case LANG_KOREAN: // HKS
824 ts->Language = IdKorean;
825 break;
826 default:
827 ts->Language = IdEnglish;
828 }
829 }
830
831 /* Port type */
832 GetPrivateProfileString(Section, "Port", "",
833 Temp, sizeof(Temp), FName);
834 if (_stricmp(Temp, "serial") == 0)
835 ts->PortType = IdSerial;
836 else {
837 ts->PortType = IdTCPIP;
838 }
839
840 /* VT win position */
841 GetPrivateProfileString(Section, "VTPos", "-2147483648,-2147483648", Temp, sizeof(Temp), FName); /* default: random position */
842 GetNthNum(Temp, 1, (int *) (&ts->VTPos.x));
843 GetNthNum(Temp, 2, (int *) (&ts->VTPos.y));
844
845 /* TEK win position */
846 GetPrivateProfileString(Section, "TEKPos", "-2147483648,-2147483648", Temp, sizeof(Temp), FName); /* default: random position */
847 GetNthNum(Temp, 1, (int *) &(ts->TEKPos.x));
848 GetNthNum(Temp, 2, (int *) &(ts->TEKPos.y));
849
850 /* Save VT Window position */
851 ts->SaveVTWinPos = GetOnOff(Section, "SaveVTWinPos", FName, FALSE);
852
853 /* VT terminal size */
854 GetPrivateProfileString(Section, "TerminalSize", "80,24",
855 Temp, sizeof(Temp), FName);
856 GetNthNum(Temp, 1, &ts->TerminalWidth);
857 GetNthNum(Temp, 2, &ts->TerminalHeight);
858 if (ts->TerminalWidth <= 0)
859 ts->TerminalWidth = 80;
860 else if (ts->TerminalWidth > TermWidthMax)
861 ts->TerminalWidth = TermWidthMax;
862 if (ts->TerminalHeight <= 0)
863 ts->TerminalHeight = 24;
864 else if (ts->TerminalHeight > TermHeightMax)
865 ts->TerminalHeight = TermHeightMax;
866
867 /* Terminal size = Window size */
868 ts->TermIsWin = GetOnOff(Section, "TermIsWin", FName, FALSE);
869
870 /* Auto window resize flag */
871 ts->AutoWinResize = GetOnOff(Section, "AutoWinResize", FName, FALSE);
872
873 /* CR Receive */
874 GetPrivateProfileString(Section, "CRReceive", "",
875 Temp, sizeof(Temp), FName);
876 if (_stricmp(Temp, "CRLF") == 0) {
877 ts->CRReceive = IdCRLF;
878 }
879 else if (_stricmp(Temp, "LF") == 0) {
880 ts->CRReceive = IdLF;
881 }
882 else if (_stricmp(Temp, "AUTO") == 0) {
883 ts->CRReceive = IdAUTO;
884 }
885 else {
886 ts->CRReceive = IdCR;
887 }
888 /* CR Send */
889 GetPrivateProfileString(Section, "CRSend", "",
890 Temp, sizeof(Temp), FName);
891 if (_stricmp(Temp, "CRLF") == 0) {
892 ts->CRSend = IdCRLF;
893 }
894 else if (_stricmp(Temp, "LF") == 0) {
895 ts->CRSend = IdLF;
896 }
897 else {
898 ts->CRSend = IdCR;
899 }
900 ts->CRSend_ini = ts->CRSend;
901
902 /* Local echo */
903 ts->LocalEcho = GetOnOff(Section, "LocalEcho", FName, FALSE);
904 ts->LocalEcho_ini = ts->LocalEcho;
905
906 /* Answerback */
907 GetPrivateProfileString(Section, "Answerback", "", Temp,
908 sizeof(Temp), FName);
909 ts->AnswerbackLen =
910 Hex2Str(Temp, ts->Answerback, sizeof(ts->Answerback));
911
912 /* Kanji Code (receive) */
913 GetPrivateProfileString(Section, "KanjiReceive", "",
914 Temp, sizeof(Temp), FName);
915 ts->KanjiCode = GetKanjiCodeFromStr(ts->Language, Temp);
916
917 /* Katakana (receive) */
918 GetPrivateProfileString(Section, "KatakanaReceive", "",
919 Temp, sizeof(Temp), FName);
920 if (_stricmp(Temp, "7") == 0)
921 ts->JIS7Katakana = 1;
922 else
923 ts->JIS7Katakana = 0;
924
925 /* Kanji Code (transmit) */
926 GetPrivateProfileString(Section, "KanjiSend", "",
927 Temp, sizeof(Temp), FName);
928 ts->KanjiCodeSend = GetKanjiCodeFromStr(ts->Language, Temp);
929
930 /* Katakana (receive) */
931 GetPrivateProfileString(Section, "KatakanaSend", "",
932 Temp, sizeof(Temp), FName);
933 if (_stricmp(Temp, "7") == 0)
934 ts->JIS7KatakanaSend = 1;
935 else
936 ts->JIS7KatakanaSend = 0;
937
938 /* KanjiIn */
939 GetPrivateProfileString(Section, "KanjiIn", "",
940 Temp, sizeof(Temp), FName);
941 if (_stricmp(Temp, "@") == 0)
942 ts->KanjiIn = IdKanjiInA;
943 else
944 ts->KanjiIn = IdKanjiInB;
945
946 /* KanjiOut */
947 GetPrivateProfileString(Section, "KanjiOut", "",
948 Temp, sizeof(Temp), FName);
949 if (_stricmp(Temp, "B") == 0)
950 ts->KanjiOut = IdKanjiOutB;
951 else if (_stricmp(Temp, "H") == 0)
952 ts->KanjiOut = IdKanjiOutH;
953 else
954 ts->KanjiOut = IdKanjiOutJ;
955
956 /* Auto Win Switch VT<->TEK */
957 ts->AutoWinSwitch = GetOnOff(Section, "AutoWinSwitch", FName, FALSE);
958
959 /* Terminal ID */
960 GetPrivateProfileString(Section, "TerminalID", "",
961 Temp, sizeof(Temp), FName);
962 ts->TerminalID = str2id(TermList, Temp, IdVT100);
963
964 /* Title String */
965 GetPrivateProfileString(Section, "Title", "Tera Term",
966 ts->Title, sizeof(ts->Title), FName);
967
968 /* Cursor shape */
969 GetPrivateProfileString(Section, "CursorShape", "",
970 Temp, sizeof(Temp), FName);
971 if (_stricmp(Temp, "vertical") == 0)
972 ts->CursorShape = IdVCur;
973 else if (_stricmp(Temp, "horizontal") == 0)
974 ts->CursorShape = IdHCur;
975 else
976 ts->CursorShape = IdBlkCur;
977
978 /* Hide title */
979 ts->HideTitle = GetOnOff(Section, "HideTitle", FName, FALSE);
980
981 /* Popup menu */
982 ts->PopupMenu = GetOnOff(Section, "PopupMenu", FName, FALSE);
983
984 /* PC-Style bold color mapping */
985 if (GetOnOff(Section, "PcBoldColor", FName, FALSE))
986 ts->ColorFlag |= CF_PCBOLD16;
987
988 /* aixterm style 16 colors mode */
989 if (GetOnOff(Section, "Aixterm16Color", FName, FALSE))
990 ts->ColorFlag |= CF_AIXTERM16;
991
992 /* xterm style 256 colors mode */
993 if (GetOnOff(Section, "Xterm256Color", FName, TRUE))
994 ts->ColorFlag |= CF_XTERM256;
995
996 /* Enable scroll buffer */
997 ts->EnableScrollBuff =
998 GetOnOff(Section, "EnableScrollBuff", FName, TRUE);
999
1000 /* Scroll buffer size */
1001 ts->ScrollBuffSize =
1002 GetPrivateProfileInt(Section, "ScrollBuffSize", 100, FName);
1003
1004 /* VT Color */
1005 GetPrivateProfileString(Section, "VTColor", "0,0,0,255,255,255",
1006 Temp, sizeof(Temp), FName);
1007 for (i = 0; i <= 5; i++)
1008 GetNthNum(Temp, i + 1, (int *) &(TmpColor[0][i]));
1009 for (i = 0; i <= 1; i++)
1010 ts->VTColor[i] = RGB((BYTE) TmpColor[0][i * 3],
1011 (BYTE) TmpColor[0][i * 3 + 1],
1012 (BYTE) TmpColor[0][i * 3 + 2]);
1013
1014 /* VT Bold Color */
1015 GetPrivateProfileString(Section, "VTBoldColor", "0,0,255,255,255,255",
1016 Temp, sizeof(Temp), FName);
1017 for (i = 0; i <= 5; i++)
1018 GetNthNum(Temp, i + 1, (int *) &(TmpColor[0][i]));
1019 for (i = 0; i <= 1; i++)
1020 ts->VTBoldColor[i] = RGB((BYTE) TmpColor[0][i * 3],
1021 (BYTE) TmpColor[0][i * 3 + 1],
1022 (BYTE) TmpColor[0][i * 3 + 2]);
1023 if (GetOnOff(Section, "EnableBoldAttrColor", FName, TRUE))
1024 ts->ColorFlag |= CF_BOLDCOLOR;
1025
1026 /* VT Blink Color */
1027 GetPrivateProfileString(Section, "VTBlinkColor", "255,0,0,255,255,255",
1028 Temp, sizeof(Temp), FName);
1029 for (i = 0; i <= 5; i++)
1030 GetNthNum(Temp, i + 1, (int *) &(TmpColor[0][i]));
1031 for (i = 0; i <= 1; i++)
1032 ts->VTBlinkColor[i] = RGB((BYTE) TmpColor[0][i * 3],
1033 (BYTE) TmpColor[0][i * 3 + 1],
1034 (BYTE) TmpColor[0][i * 3 + 2]);
1035 if (GetOnOff(Section, "EnableBlinkAttrColor", FName, TRUE))
1036 ts->ColorFlag |= CF_BLINKCOLOR;
1037
1038 /* VT Reverse Color */
1039 GetPrivateProfileString(Section, "VTReverseColor", "255,255,255,0,0,0",
1040 Temp, sizeof(Temp), FName);
1041 for (i = 0; i <= 5; i++)
1042 GetNthNum(Temp, i + 1, (int *) &(TmpColor[0][i]));
1043 for (i = 0; i <= 1; i++)
1044 ts->VTReverseColor[i] = RGB((BYTE) TmpColor[0][i * 3],
1045 (BYTE) TmpColor[0][i * 3 + 1],
1046 (BYTE) TmpColor[0][i * 3 + 2]);
1047 if (GetOnOff(Section, "EnableReverseAttrColor", FName, FALSE))
1048 ts->ColorFlag |= CF_REVERSECOLOR;
1049
1050 ts->EnableClickableUrl =
1051 GetOnOff(Section, "EnableClickableUrl", FName, FALSE);
1052
1053 /* URL Color */
1054 GetPrivateProfileString(Section, "URLColor", "0,255,0,255,255,255",
1055 Temp, sizeof(Temp), FName);
1056 for (i = 0; i <= 5; i++)
1057 GetNthNum(Temp, i + 1, (int *) &(TmpColor[0][i]));
1058 for (i = 0; i <= 1; i++)
1059 ts->URLColor[i] = RGB((BYTE) TmpColor[0][i * 3],
1060 (BYTE) TmpColor[0][i * 3 + 1],
1061 (BYTE) TmpColor[0][i * 3 + 2]);
1062 if (GetOnOff(Section, "EnableURLColor", FName, TRUE))
1063 ts->ColorFlag |= CF_URLCOLOR;
1064
1065 if (GetOnOff(Section, "URLUnderline", FName, TRUE))
1066 ts->FontFlag |= FF_URLUNDERLINE;
1067
1068 /* TEK Color */
1069 GetPrivateProfileString(Section, "TEKColor", "0,0,0,255,255,255",
1070 Temp, sizeof(Temp), FName);
1071 for (i = 0; i <= 5; i++)
1072 GetNthNum(Temp, i + 1, (int *) &(TmpColor[0][i]));
1073 for (i = 0; i <= 1; i++)
1074 ts->TEKColor[i] = RGB((BYTE) TmpColor[0][i * 3],
1075 (BYTE) TmpColor[0][i * 3 + 1],
1076 (BYTE) TmpColor[0][i * 3 + 2]);
1077
1078 /* ANSI color definition (in the case FullColor=on) -- special option
1079 o UseTextColor should be off, or the background and foreground color of
1080 VTColor are assigned to color-number 0 and 7 respectively, even if
1081 they are specified in ANSIColor.
1082 o ANSIColor is a set of 4 values that are color-number(0--15),
1083 red-value(0--255), green-value(0--255) and blue-value(0--255). */
1084 GetPrivateProfileString(Section, "ANSIColor",
1085 " 0, 0, 0, 0,"
1086 " 1,255, 0, 0,"
1087 " 2, 0,255, 0,"
1088 " 3,255,255, 0,"
1089 " 4, 0, 0,255,"
1090 " 5,255, 0,255,"
1091 " 6, 0,255,255,"
1092 " 7,255,255,255,"
1093 " 8,128,128,128,"
1094 " 9,128, 0, 0,"
1095 "10, 0,128, 0,"
1096 "11,128,128, 0,"
1097 "12, 0, 0,128,"
1098 "13,128, 0,128,"
1099 "14, 0,128,128,"
1100 "15,192,192,192", Temp, sizeof(Temp), FName);
1101 {
1102 char *t;
1103 int n = 1;
1104 for (t = Temp; *t; t++)
1105 if (*t == ',')
1106 n++;
1107 n /= 4;
1108 for (i = 0; i < n; i++) {
1109 int colorid, r, g, b;
1110 GetNthNum(Temp, i * 4 + 1, (int *) &colorid);
1111 GetNthNum(Temp, i * 4 + 2, (int *) &r);
1112 GetNthNum(Temp, i * 4 + 3, (int *) &g);
1113 GetNthNum(Temp, i * 4 + 4, (int *) &b);
1114 ts->ANSIColor[colorid & 15] =
1115 RGB((BYTE) r, (BYTE) g, (BYTE) b);
1116 }
1117 }
1118
1119 TmpDC = GetDC(0); /* Get screen device context */
1120 for (i = 0; i <= 1; i++)
1121 ts->VTColor[i] = GetNearestColor(TmpDC, ts->VTColor[i]);
1122 for (i = 0; i <= 1; i++)
1123 ts->VTBoldColor[i] = GetNearestColor(TmpDC, ts->VTBoldColor[i]);
1124 for (i = 0; i <= 1; i++)
1125 ts->VTBlinkColor[i] = GetNearestColor(TmpDC, ts->VTBlinkColor[i]);
1126 for (i = 0; i <= 1; i++)
1127 ts->TEKColor[i] = GetNearestColor(TmpDC, ts->TEKColor[i]);
1128 /* begin - ishizaki */
1129 for (i = 0; i <= 1; i++)
1130 ts->URLColor[i] = GetNearestColor(TmpDC, ts->URLColor[i]);
1131 /* end - ishizaki */
1132 for (i = 0; i < 16; i++)
1133 ts->ANSIColor[i] = GetNearestColor(TmpDC, ts->ANSIColor[i]);
1134 ReleaseDC(0, TmpDC);
1135 if (GetOnOff(Section, "EnableANSIColor", FName, TRUE))
1136 ts->ColorFlag |= CF_ANSICOLOR;
1137
1138 /* TEK color emulation */
1139 ts->TEKColorEmu = GetOnOff(Section, "TEKColorEmulation", FName, FALSE);
1140
1141 /* VT Font */
1142 ReadFont(Section, "VTFont", "Terminal,0,-13,1", FName,
1143 ts->VTFont, _countof(ts->VTFont),
1144 &ts->VTFontSize, &(ts->VTFontCharSet));
1145
1146 /* Bold font flag */
1147 if (GetOnOff(Section, "EnableBold", FName, TRUE))
1148 ts->FontFlag |= FF_BOLD;
1149
1150 /* TEK Font */
1151 ReadFont(Section, "TEKFont", "Courier,0,-13,0", FName,
1152 ts->TEKFont, _countof(ts->TEKFont),
1153 &ts->TEKFontSize, &(ts->TEKFontCharSet));
1154
1155 /* BS key */
1156 GetPrivateProfileString(Section, "BSKey", "",
1157 Temp, sizeof(Temp), FName);
1158 if (_stricmp(Temp, "DEL") == 0)
1159 ts->BSKey = IdDEL;
1160 else
1161 ts->BSKey = IdBS;
1162 /* Delete key */
1163 ts->DelKey = GetOnOff(Section, "DeleteKey", FName, FALSE);
1164
1165 /* Meta Key */
1166 GetPrivateProfileString(Section, "MetaKey", "off", Temp, sizeof(Temp), FName);
1167 if (_stricmp(Temp, "on") == 0)
1168 ts->MetaKey = IdMetaOn;
1169 else if (_stricmp(Temp, "left") == 0)
1170 ts->MetaKey = IdMetaLeft;
1171 else if (_stricmp(Temp, "right") == 0)
1172 ts->MetaKey = IdMetaRight;
1173 else
1174 ts->MetaKey = IdMetaOff;
1175
1176 // Windows95 �n�����E�� Alt ��������������
1177 if (!IsWindowsNTKernel() && ts->MetaKey != IdMetaOff) {
1178 ts->MetaKey = IdMetaOn;
1179 }
1180
1181 /* Application Keypad */
1182 ts->DisableAppKeypad =
1183 GetOnOff(Section, "DisableAppKeypad", FName, FALSE);
1184
1185 /* Application Cursor */
1186 ts->DisableAppCursor =
1187 GetOnOff(Section, "DisableAppCursor", FName, FALSE);
1188
1189 /* Russian keyboard type */
1190 GetPrivateProfileString(Section, "RussKeyb", "",
1191 Temp, sizeof(Temp), FName);
1192 ts->RussKeyb = str2id(RussList2, Temp, IdWindows);
1193
1194 /* Serial port ID */
1195 ts->ComPort = GetPrivateProfileInt(Section, "ComPort", 1, FName);
1196
1197 /* Baud rate */
1198 ts->Baud = GetPrivateProfileInt(Section, "BaudRate", 9600, FName);
1199
1200 /* Parity */
1201 GetPrivateProfileStringW(SectionW, L"Parity", L"",
1202 TempW, _countof(TempW), FName);
1203 if (!SerialPortConfconvertStr2Id(COM_PARITY, TempW, &ts->Parity)) {
1204 ts->Parity = IdParityNone;
1205 }
1206
1207 /* Data bit */
1208 GetPrivateProfileStringW(SectionW, L"DataBit", L"",
1209 TempW, _countof(TempW), FName);
1210 if (!SerialPortConfconvertStr2Id(COM_DATABIT, TempW, &ts->DataBit)) {
1211 ts->DataBit = IdDataBit8;
1212 }
1213
1214 /* Stop bit */
1215 GetPrivateProfileStringW(SectionW, L"StopBit", L"",
1216 TempW, _countof(TempW), FName);
1217 if (!SerialPortConfconvertStr2Id(COM_STOPBIT, TempW, &ts->StopBit)) {
1218 ts->StopBit = IdStopBit1;
1219 }
1220
1221 /* Flow control */
1222 GetPrivateProfileStringW(SectionW, L"FlowCtrl", L"",
1223 TempW, _countof(TempW), FName);
1224 if (!SerialPortConfconvertStr2Id(COM_FLOWCTRL, TempW, &ts->Flow)) {
1225 ts->Flow = IdFlowNone;
1226 }
1227
1228 /* Delay per character */
1229 ts->DelayPerChar =
1230 GetPrivateProfileInt(Section, "DelayPerChar", 0, FName);
1231
1232 /* Delay per line */
1233 ts->DelayPerLine =
1234 GetPrivateProfileInt(Section, "DelayPerLine", 0, FName);
1235
1236 /* Telnet flag */
1237 ts->Telnet = GetOnOff(Section, "Telnet", FName, TRUE);
1238
1239 /* Telnet terminal type */
1240 GetPrivateProfileString(Section, "TermType", "xterm", ts->TermType,
1241 sizeof(ts->TermType), FName);
1242
1243 /* TCP port num */
1244 ts->TCPPort =
1245 GetPrivateProfileInt(Section, "TCPPort", ts->TelPort, FName);
1246
1247 /* Auto window close flag */
1248 ts->AutoWinClose = GetOnOff(Section, "AutoWinClose", FName, TRUE);
1249
1250 /* History list */
1251 ts->HistoryList = GetOnOff(Section, "HistoryList", FName, FALSE);
1252
1253 /* File transfer binary flag */
1254 ts->TransBin = GetOnOff(Section, "TransBin", FName, FALSE);
1255
1256 /* Log binary flag */
1257 ts->LogBinary = GetOnOff(Section, "LogBinary", FName, FALSE);
1258
1259 /* Log append */
1260 ts->Append = GetOnOff(Section, "LogAppend", FName, FALSE);
1261
1262 /* Log plain text (2005.5.7 yutaka) */
1263 ts->LogTypePlainText =
1264 GetOnOff(Section, "LogTypePlainText", FName, FALSE);
1265
1266 /* Log with timestamp (2006.7.23 maya) */
1267 ts->LogTimestamp = GetOnOff(Section, "LogTimestamp", FName, FALSE);
1268
1269 /* Log without transfer dialog */
1270 ts->LogHideDialog = GetOnOff(Section, "LogHideDialog", FName, FALSE);
1271
1272 ts->LogAllBuffIncludedInFirst = GetOnOff(Section, "LogIncludeScreenBuffer", FName, FALSE);
1273
1274 /* Timestamp format of Log each line */
1275 GetPrivateProfileString(Section, "LogTimestampFormat", "%Y-%m-%d %H:%M:%S.%N",
1276 ts->LogTimestampFormat, sizeof(ts->LogTimestampFormat),
1277 FName);
1278
1279 /* Timestamp type */
1280 GetPrivateProfileString(Section, "LogTimestampType", "", Temp, sizeof(Temp), FName);
1281 if (_stricmp(Temp, "UTC") == 0)
1282 ts->LogTimestampType = TIMESTAMP_UTC;
1283 else if (_stricmp(Temp, "LoggingElapsed") == 0)
1284 ts->LogTimestampType = TIMESTAMP_ELAPSED_LOGSTART;
1285 else if (_stricmp(Temp, "ConnectionElapsed") == 0)
1286 ts->LogTimestampType = TIMESTAMP_ELAPSED_CONNECTED;
1287 else if (_stricmp(Temp, "") == 0 && GetOnOff(Section, "LogTimestampUTC", FName, FALSE))
1288 // LogTimestampType ���������������� LogTimestampUTC ���l���Q������
1289 ts->LogTimestampType = TIMESTAMP_UTC;
1290 else
1291 ts->LogTimestampType = TIMESTAMP_LOCAL;
1292
1293 /* File Transfer dialog visibility */
1294 ts->FTHideDialog = GetOnOff(Section, "FTHideDialog", FName, FALSE);
1295
1296 /* Default Log file name (2006.8.28 maya) */
1297 GetPrivateProfileString(Section, "LogDefaultName", "teraterm.log",
1298 ts->LogDefaultName, sizeof(ts->LogDefaultName),
1299 FName);
1300
1301 /* Default Log file path */
1302 hGetPrivateProfileStringW(SectionW, L"LogDefaultPath", ts->LogDirW, FName, &ts->LogDefaultPathW);
1303 if (ts->LogDefaultPathW[0] == 0) {
1304 // ���w��("LogDefaultPath=")�������A�f�t�H���g�l������������
1305 free(ts->LogDefaultPathW);
1306 ts->LogDefaultPathW = _wcsdup(ts->LogDirW);
1307 }
1308
1309 /* Auto start logging (2007.5.31 maya) */
1310 ts->LogAutoStart = GetOnOff(Section, "LogAutoStart", FName, FALSE);
1311
1312 /* Log Rotate (2013.3.24 yutaka) */
1313 ts->LogRotate = GetPrivateProfileInt(Section, "LogRotate", 0, FName);
1314 ts->LogRotateSize = GetPrivateProfileInt(Section, "LogRotateSize", 0, FName);
1315 ts->LogRotateSizeType = GetPrivateProfileInt(Section, "LogRotateSizeType", 0, FName);
1316 ts->LogRotateStep = GetPrivateProfileInt(Section, "LogRotateStep", 0, FName);
1317
1318 /* Deferred Log Write Mode (2013.4.20 yutaka) */
1319 ts->DeferredLogWriteMode = GetOnOff(Section, "DeferredLogWriteMode", FName, TRUE);
1320
1321
1322 /* XMODEM option */
1323 GetPrivateProfileString(Section, "XmodemOpt", "",
1324 Temp, sizeof(Temp), FName);
1325 if (_stricmp(Temp, "crc") == 0)
1326 ts->XmodemOpt = XoptCRC;
1327 else if (_stricmp(Temp, "1k") == 0)
1328 ts->XmodemOpt = Xopt1kCRC;
1329 else if (_stricmp(Temp, "1ksum") == 0)
1330 ts->XmodemOpt = Xopt1kCksum;
1331 else
1332 ts->XmodemOpt = XoptCheck;
1333
1334 /* XMODEM binary file */
1335 ts->XmodemBin = GetOnOff(Section, "XmodemBin", FName, TRUE);
1336
1337 /* XMODEM ���M�R�}���h (2007.12.21 yutaka) */
1338 GetPrivateProfileString(Section, "XModemRcvCommand", "",
1339 ts->XModemRcvCommand,
1340 sizeof(ts->XModemRcvCommand), FName);
1341
1342 /* Default directory for file transfer */
1343 hGetPrivateProfileStringW(SectionW, L"FileDir", L"", FName, &ts->FileDirW);
1344 if (ts->FileDirW != NULL && ts->FileDirW[0] != 0) {
1345 wchar_t *FileDirExpanded;
1346 hExpandEnvironmentStringsW(ts->FileDirW, &FileDirExpanded);
1347 if (!DoesFolderExistW(FileDirExpanded)) {
1348 free(ts->FileDirW);
1349 ts->FileDirW = NULL;
1350 }
1351 free(FileDirExpanded);
1352 }
1353 if (ts->FileDirW == NULL || ts->FileDirW[0] == 0) {
1354 // �f�t�H���g�t�H���_���Z�b�g����
1355 free(ts->FileDirW);
1356 ts->FileDirW = GetDownloadFolderW();
1357 }
1358 WideCharToACP_t(ts->FileDirW, ts->FileDir, sizeof(ts->FileDir));
1359
1360 /* filter on file send (2007.6.5 maya) */
1361 GetPrivateProfileString(Section, "FileSendFilter", "",
1362 ts->FileSendFilter, sizeof(ts->FileSendFilter),
1363 FName);
1364
1365 /* SCP���M���p�X (2012.4.6 yutaka) */
1366 GetPrivateProfileString(Section, "ScpSendDir", "",
1367 ts->ScpSendDir, sizeof(ts->ScpSendDir), FName);
1368
1369
1370 /*--------------------------------------------------*/
1371 /* 8 bit control code flag -- special option */
1372 if (GetOnOff(Section, "Accept8BitCtrl", FName, TRUE))
1373 ts->TermFlag |= TF_ACCEPT8BITCTRL;
1374
1375 /* Wrong sequence flag -- special option */
1376 if (GetOnOff(Section, "AllowWrongSequence", FName, FALSE))
1377 ts->TermFlag |= TF_ALLOWWRONGSEQUENCE;
1378
1379 if (((ts->TermFlag & TF_ALLOWWRONGSEQUENCE) == 0) &&
1380 (ts->KanjiOut == IdKanjiOutH))
1381 ts->KanjiOut = IdKanjiOutJ;
1382
1383 // Detect disconnect/reconnect of serial port --- special option
1384 ts->AutoComPortReconnect = GetOnOff(Section, "AutoComPortReconnect", FName, TRUE);
1385
1386 // Auto file renaming --- special option
1387 if (GetOnOff(Section, "AutoFileRename", FName, FALSE))
1388 ts->FTFlag |= FT_RENAME;
1389
1390 // Auto invoking (character set->G0->GL) --- special option
1391 if (GetOnOff(Section, "AutoInvoke", FName, FALSE))
1392 ts->TermFlag |= TF_AUTOINVOKE;
1393
1394 // Auto text copy --- special option
1395 ts->AutoTextCopy = GetOnOff(Section, "AutoTextCopy", FName, TRUE);
1396
1397 /* Back wrap -- special option */
1398 if (GetOnOff(Section, "BackWrap", FName, FALSE))
1399 ts->TermFlag |= TF_BACKWRAP;
1400
1401 /* Beep type -- special option */
1402 GetPrivateProfileString(Section, "Beep", "", Temp, sizeof(Temp), FName);
1403 if (_stricmp(Temp, "off") == 0)
1404 ts->Beep = IdBeepOff;
1405 else if (_stricmp(Temp, "visual") == 0)
1406 ts->Beep = IdBeepVisual;
1407 else
1408 ts->Beep = IdBeepOn;
1409
1410 /* Beep on connection & disconnection -- special option */
1411 if (GetOnOff(Section, "BeepOnConnect", FName, FALSE))
1412 ts->PortFlag |= PF_BEEPONCONNECT;
1413
1414 /* Auto B-Plus activation -- special option */
1415 if (GetOnOff(Section, "BPAuto", FName, FALSE))
1416 ts->FTFlag |= FT_BPAUTO;
1417 if ((ts->FTFlag & FT_BPAUTO) != 0) { /* Answerback */
1418 strncpy_s(ts->Answerback, sizeof(ts->Answerback), "\020++\0200",
1419 _TRUNCATE);
1420 ts->AnswerbackLen = 5;
1421 }
1422
1423 /* B-Plus ESCCTL flag -- special option */
1424 if (GetOnOff(Section, "BPEscCtl", FName, FALSE))
1425 ts->FTFlag |= FT_BPESCCTL;
1426
1427 /* B-Plus log -- special option */
1428 if (GetOnOff(Section, "BPLog", FName, FALSE))
1429 ts->LogFlag |= LOG_BP;
1430
1431 /* Clear serial port buffer when port opening -- special option */
1432 ts->ClearComBuffOnOpen =
1433 GetOnOff(Section, "ClearComBuffOnOpen", FName, TRUE);
1434
1435 /* When serial port is specified with with /C= option and the port does not exist, Tera Term will wait for port connection. */
1436 ts->WaitCom = GetOnOff(Section, "WaitCom", FName, FALSE);
1437
1438 /* Confirm disconnection -- special option */
1439 if (GetOnOff(Section, "ConfirmDisconnect", FName, TRUE))
1440 ts->PortFlag |= PF_CONFIRMDISCONN;
1441
1442 /* Ctrl code in Kanji -- special option */
1443 if (GetOnOff(Section, "CtrlInKanji", FName, TRUE))
1444 ts->TermFlag |= TF_CTRLINKANJI;
1445
1446 /* Debug flag -- special option */
1447 ts->Debug = GetOnOff(Section, "Debug", FName, FALSE);
1448
1449 /* Delimiter list -- special option */
1450 GetPrivateProfileString(Section, "DelimList",
1451 "$20!\"#$24%&\'()*+,-./:;<=>?@[\\]^`{|}~",
1452 Temp, sizeof(Temp), FName);
1453 Hex2Str(Temp, ts->DelimList, sizeof(ts->DelimList));
1454
1455 /* regard DBCS characters as delimiters -- special option */
1456 ts->DelimDBCS = GetOnOff(Section, "DelimDBCS", FName, TRUE);
1457
1458 // Enable popup menu -- special option
1459 if (!GetOnOff(Section, "EnablePopupMenu", FName, TRUE))
1460 ts->MenuFlag |= MF_NOPOPUP;
1461
1462 // Enable "Show menu" -- special option
1463 if (!GetOnOff(Section, "EnableShowMenu", FName, TRUE))
1464 ts->MenuFlag |= MF_NOSHOWMENU;
1465
1466 // Enable the status line -- special option
1467 if (GetOnOff(Section, "EnableStatusLine", FName, TRUE))
1468 ts->TermFlag |= TF_ENABLESLINE;
1469
1470 // Enable multiple bytes send -- special option
1471 ts->FileSendHighSpeedMode = GetOnOff(Section, "FileSendHighSpeedMode", FName, TRUE);
1472
1473 // fixed JIS --- special
1474 if (GetOnOff(Section, "FixedJIS", FName, FALSE))
1475 ts->TermFlag |= TF_FIXEDJIS;
1476
1477 /* IME Flag -- special option */
1478 ts->UseIME = GetOnOff(Section, "IME", FName, TRUE);
1479
1480 /* IME-inline Flag -- special option */
1481 ts->IMEInline = GetOnOff(Section, "IMEInline", FName, TRUE);
1482
1483 /* Kermit log -- special option */
1484 if (GetOnOff(Section, "KmtLog", FName, FALSE))
1485 ts->LogFlag |= LOG_KMT;
1486 if (GetOnOff(Section, "KmtLongPacket", FName, FALSE))
1487 ts->KermitOpt |= KmtOptLongPacket;
1488 if (GetOnOff(Section, "KmtFileAttr", FName, FALSE))
1489 ts->KermitOpt |= KmtOptFileAttr;
1490
1491 // Enable language selection -- special option
1492 if (!GetOnOff(Section, "LanguageSelection", FName, TRUE))
1493 ts->MenuFlag |= MF_NOLANGUAGE;
1494
1495 /* Maximum scroll buffer size -- special option */
1496 ts->ScrollBuffMax =
1497 GetPrivateProfileInt(Section, "MaxBuffSize", 10000, FName);
1498 if (ts->ScrollBuffMax < 24)
1499 ts->ScrollBuffMax = 10000;
1500
1501 /* Max com port number -- special option */
1502 ts->MaxComPort = GetPrivateProfileInt(Section, "MaxComPort", 256, FName);
1503 if (ts->MaxComPort < 4)
1504 ts->MaxComPort = 4;
1505 if (ts->MaxComPort > MAXCOMPORT)
1506 ts->MaxComPort = MAXCOMPORT;
1507 if ((ts->ComPort < 1) || (ts->ComPort > ts->MaxComPort))
1508 ts->ComPort = 1;
1509
1510 /* Non-blinking cursor -- special option */
1511 ts->NonblinkingCursor =
1512 GetOnOff(Section, "NonblinkingCursor", FName, FALSE);
1513
1514 // �t�H�[�J�X���������|���S���J�[�\�� (2008.1.24 yutaka)
1515 ts->KillFocusCursor =
1516 GetOnOff(Section, "KillFocusCursor", FName, TRUE);
1517
1518 /* Delay for pass-thru printing activation */
1519 /* -- special option */
1520 ts->PassThruDelay =
1521 GetPrivateProfileInt(Section, "PassThruDelay", 3, FName);
1522
1523 /* Printer port for pass-thru printing */
1524 /* -- special option */
1525 GetPrivateProfileString(Section, "PassThruPort", "",
1526 ts->PrnDev, sizeof(ts->PrnDev), FName);
1527
1528 /* �v�����^�p�����R�[�h�������t������ */
1529 if (GetOnOff(Section, "PrinterCtrlSequence", FName, TRUE))
1530 ts->TermFlag |= TF_PRINTERCTRL;
1531
1532 /* Printer Font --- special option */
1533 ReadFont(Section, "PrnFont", NULL, FName,
1534 ts->PrnFont, _countof(ts->PrnFont),
1535 &ts->PrnFontSize, &(ts->PrnFontCharSet));
1536
1537 // Page margins (left, right, top, bottom) for printing
1538 // -- special option
1539 GetPrivateProfileString(Section, "PrnMargin", "50,50,50,50",
1540 Temp, sizeof(Temp), FName);
1541 for (i = 0; i <= 3; i++)
1542 GetNthNum(Temp, 1 + i, &ts->PrnMargin[i]);
1543
1544 /* Disable (convert to NL) Form Feed when printing */
1545 /* --- special option */
1546 ts->PrnConvFF =
1547 GetOnOff(Section, "PrnConvFF", FName, FALSE);
1548
1549 /* Quick-VAN log -- special option */
1550 if (GetOnOff(Section, "QVLog", FName, FALSE))
1551 ts->LogFlag |= LOG_QV;
1552
1553 /* Quick-VAN window size -- special */
1554 ts->QVWinSize = GetPrivateProfileInt(Section, "QVWinSize", 8, FName);
1555
1556 /* Scroll threshold -- special option */
1557 ts->ScrollThreshold =
1558 GetPrivateProfileInt(Section, "ScrollThreshold", 12, FName);
1559
1560 ts->MouseWheelScrollLine =
1561 GetPrivateProfileInt(Section, "MouseWheelScrollLine", 3, FName);
1562
1563 // Select on activate -- special option
1564 ts->SelOnActive = GetOnOff(Section, "SelectOnActivate", FName, TRUE);
1565
1566 /* Send 8bit control sequence -- special option */
1567 ts->Send8BitCtrl = GetOnOff(Section, "Send8BitCtrl", FName, FALSE);
1568
1569 /* SendBreak time (in msec) -- special option */
1570 ts->SendBreakTime =
1571 GetPrivateProfileInt(Section, "SendBreakTime", 1000, FName);
1572
1573 /* Startup macro -- special option */
1574 hGetPrivateProfileStringW(SectionW, L"StartupMacro", L"", FName, &ts->MacroFNW);
1575 WideCharToACP_t(ts->MacroFNW, ts->MacroFN, sizeof(ts->MacroFN));
1576
1577 /* TEK GIN Mouse keycode -- special option */
1578 ts->GINMouseCode =
1579 GetPrivateProfileInt(Section, "TEKGINMouseCode", 32, FName);
1580
1581 /* Telnet Auto Detect -- special option */
1582 ts->TelAutoDetect = GetOnOff(Section, "TelAutoDetect", FName, TRUE);
1583
1584 /* Telnet binary flag -- special option */
1585 ts->TelBin = GetOnOff(Section, "TelBin", FName, FALSE);
1586
1587 /* Telnet Echo flag -- special option */
1588 ts->TelEcho = GetOnOff(Section, "TelEcho", FName, FALSE);
1589
1590 /* Telnet log -- special option */
1591 if (GetOnOff(Section, "TelLog", FName, FALSE))
1592 ts->LogFlag |= LOG_TEL;
1593
1594 /* TCP port num for telnet -- special option */
1595 ts->TelPort = GetPrivateProfileInt(Section, "TelPort", 23, FName);
1596
1597 /* Telnet keep-alive packet(NOP command) interval -- special option */
1598 ts->TelKeepAliveInterval =
1599 GetPrivateProfileInt(Section, "TelKeepAliveInterval", 300, FName);
1600
1601 /* Max number of broadcast commad history */
1602 ts->MaxBroadcatHistory =
1603 GetPrivateProfileInt(Section, "MaxBroadcatHistory", 99, FName);
1604
1605 /* Local echo for non-telnet */
1606 ts->TCPLocalEcho = GetOnOff(Section, "TCPLocalEcho", FName, FALSE);
1607
1608 /* "new-line (transmit)" option for non-telnet -- special option */
1609 GetPrivateProfileString(Section, "TCPCRSend", "",
1610 Temp, sizeof(Temp), FName);
1611 if (_stricmp(Temp, "CR") == 0)
1612 ts->TCPCRSend = IdCR;
1613 else if (_stricmp(Temp, "CRLF") == 0)
1614 ts->TCPCRSend = IdCRLF;
1615 else
1616 ts->TCPCRSend = 0; // disabled
1617
1618 /* Use text (background) color for "white (black)" --- special option */
1619 if (GetOnOff(Section, "UseTextColor", FName, FALSE))
1620 ts->ColorFlag |= CF_USETEXTCOLOR;
1621
1622 /* Title format -- special option */
1623 ts->TitleFormat =
1624 GetPrivateProfileInt(Section, "TitleFormat", 13, FName);
1625
1626 /* VT Compatible Tab -- special option */
1627 ts->VTCompatTab = GetOnOff(Section, "VTCompatTab", FName, FALSE);
1628
1629 /* VT Font space --- special option */
1630 GetPrivateProfileString(Section, "VTFontSpace", "0,0,0,0",
1631 Temp, sizeof(Temp), FName);
1632 GetNthNum(Temp, 1, &ts->FontDX);
1633 GetNthNum(Temp, 2, &ts->FontDW);
1634 GetNthNum(Temp, 3, &ts->FontDY);
1635 GetNthNum(Temp, 4, &ts->FontDH);
1636 if (ts->FontDX < 0)
1637 ts->FontDX = 0;
1638 if (ts->FontDW < 0)
1639 ts->FontDW = 0;
1640 ts->FontDW = ts->FontDW + ts->FontDX;
1641 if (ts->FontDY < 0)
1642 ts->FontDY = 0;
1643 if (ts->FontDH < 0)
1644 ts->FontDH = 0;
1645 ts->FontDH = ts->FontDH + ts->FontDY;
1646
1647 // VT-print scaling factors (pixels per inch) --- special option
1648 GetPrivateProfileString(Section, "VTPPI", "0,0",
1649 Temp, sizeof(Temp), FName);
1650 GetNthNum(Temp, 1, (int *) &ts->VTPPI.x);
1651 GetNthNum(Temp, 2, (int *) &ts->VTPPI.y);
1652
1653 // TEK-print scaling factors (pixels per inch) --- special option
1654 GetPrivateProfileString(Section, "TEKPPI", "0,0",
1655 Temp, sizeof(Temp), FName);
1656 GetNthNum(Temp, 1, (int *) &ts->TEKPPI.x);
1657 GetNthNum(Temp, 2, (int *) &ts->TEKPPI.y);
1658
1659 // Show "Window" menu -- special option
1660 if (GetOnOff(Section, "WindowMenu", FName, TRUE))
1661 ts->MenuFlag |= MF_SHOWWINMENU;
1662
1663 /* XMODEM log -- special option */
1664 if (GetOnOff(Section, "XmodemLog", FName, FALSE))
1665 ts->LogFlag |= LOG_X;
1666
1667 /* YMODEM log -- special option */
1668 if (GetOnOff(Section, "YmodemLog", FName, FALSE))
1669 ts->LogFlag |= LOG_Y;
1670
1671 /* YMODEM ���M�R�}���h (2010.3.23 yutaka) */
1672 GetPrivateProfileString(Section, "YModemRcvCommand", "rb",
1673 ts->YModemRcvCommand, sizeof(ts->YModemRcvCommand), FName);
1674
1675 /* Auto ZMODEM activation -- special option */
1676 if (GetOnOff(Section, "ZmodemAuto", FName, FALSE))
1677 ts->FTFlag |= FT_ZAUTO;
1678
1679 /* ZMODEM data subpacket length for sending -- special */
1680 ts->ZmodemDataLen =
1681 GetPrivateProfileInt(Section, "ZmodemDataLen", 1024, FName);
1682 /* ZMODEM window size for sending -- special */
1683 ts->ZmodemWinSize =
1684 GetPrivateProfileInt(Section, "ZmodemWinSize", 32767, FName);
1685
1686 /* ZMODEM ESCCTL flag -- special option */
1687 if (GetOnOff(Section, "ZmodemEscCtl", FName, FALSE))
1688 ts->FTFlag |= FT_ZESCCTL;
1689
1690 /* ZMODEM log -- special option */
1691 if (GetOnOff(Section, "ZmodemLog", FName, FALSE))
1692 ts->LogFlag |= LOG_Z;
1693
1694 /* ZMODEM ���M�R�}���h (2007.12.21 yutaka) */
1695 GetPrivateProfileString(Section, "ZModemRcvCommand", "rz",
1696 ts->ZModemRcvCommand, sizeof(ts->ZModemRcvCommand), FName);
1697
1698 /* Enable continued-line copy -- special option */
1699 ts->EnableContinuedLineCopy =
1700 GetOnOff(Section, "EnableContinuedLineCopy", FName, FALSE);
1701
1702 if (GetOnOff(Section, "DisablePasteMouseRButton", FName, FALSE))
1703 ts->PasteFlag |= CPF_DISABLE_RBUTTON;
1704
1705 if (GetOnOff(Section, "DisablePasteMouseMButton", FName, TRUE))
1706 ts->PasteFlag |= CPF_DISABLE_MBUTTON;
1707
1708 if (GetOnOff(Section, "ConfirmPasteMouseRButton", FName, FALSE))
1709 ts->PasteFlag |= CPF_CONFIRM_RBUTTON;
1710
1711 if (GetOnOff(Section, "ConfirmChangePaste", FName, TRUE))
1712 ts->PasteFlag |= CPF_CONFIRM_CHANGEPASTE;
1713
1714 if (GetOnOff(Section, "ConfirmChangePasteCR", FName, TRUE))
1715 ts->PasteFlag |= CPF_CONFIRM_CHANGEPASTE_CR;
1716
1717 GetPrivateProfileString(Section, "ConfirmChangePasteStringFile", "",
1718 Temp, sizeof(Temp), FName);
1719
1720 strncpy_s(ts->ConfirmChangePasteStringFile, sizeof(ts->ConfirmChangePasteStringFile), Temp,
1721 _TRUNCATE);
1722
1723 // added ScrollWindowClearScreen (2008.5.3 yutaka)
1724 ts->ScrollWindowClearScreen =
1725 GetOnOff(Section, "ScrollWindowClearScreen", FName, TRUE);
1726
1727 // added SelectOnlyByLButton (2007.11.20 maya)
1728 ts->SelectOnlyByLButton =
1729 GetOnOff(Section, "SelectOnlyByLButton", FName, TRUE);
1730
1731 // added DisableAcceleratorSendBreak (2007.3.17 maya)
1732 ts->DisableAcceleratorSendBreak =
1733 GetOnOff(Section, "DisableAcceleratorSendBreak", FName, FALSE);
1734
1735 // WinSock connecting timeout value (2007.1.11 yutaka)
1736 ts->ConnectingTimeout =
1737 GetPrivateProfileInt(Section, "ConnectingTimeout", 0, FName);
1738
1739 // mouse cursor
1740 GetPrivateProfileString(Section, "MouseCursor", "IBEAM",
1741 Temp, sizeof(Temp), FName);
1742 strncpy_s(ts->MouseCursorName, sizeof(ts->MouseCursorName), Temp,
1743 _TRUNCATE);
1744
1745 // Translucent window
1746 ts->AlphaBlendInactive =
1747 GetPrivateProfileInt(Section, "AlphaBlend", 255, FName);
1748 ts->AlphaBlendInactive = max(0, ts->AlphaBlendInactive);
1749 ts->AlphaBlendInactive = min(255, ts->AlphaBlendInactive);
1750 ts->AlphaBlendActive =
1751 GetPrivateProfileInt(Section, "AlphaBlendActive", ts->AlphaBlendInactive, FName);
1752 ts->AlphaBlendActive = max(0, ts->AlphaBlendActive);
1753 ts->AlphaBlendActive = min(255, ts->AlphaBlendActive);
1754
1755 // Cygwin install path
1756 GetPrivateProfileString(Section, "CygwinDirectory ", "c:\\cygwin",
1757 Temp, sizeof(Temp), FName);
1758 strncpy_s(ts->CygwinDirectory, sizeof(ts->CygwinDirectory), Temp,
1759 _TRUNCATE);
1760
1761 // Viewlog Editor path
1762 if (GetWindowsDirectory(Temp, sizeof(Temp)) + 13 < sizeof(Temp)) { // "\\notepad.exe"(12) + NUL(1)
1763 strncat_s(Temp, sizeof(Temp), "\\notepad.exe", _TRUNCATE);
1764 }
1765 else {
1766 Temp[0] = '\0';
1767 }
1768 GetPrivateProfileString(Section, "ViewlogEditor ", Temp,
1769 ts->ViewlogEditor, sizeof(ts->ViewlogEditor), FName);
1770
1771 // UI language message file (�����p�X)
1772 hGetPrivateProfileStringW(SectionW, L"UILanguageFile", NULL, FName, &ts->UILanguageFileW_ini);
1773 if (ts->UILanguageFileW_ini[0] == 0) {
1774 free(ts->UILanguageFileW_ini);
1775 ts->UILanguageFileW_ini = _wcsdup(L"lang\\Default.lng");
1776 }
1777 WideCharToACP_t(ts->UILanguageFileW_ini, ts->UILanguageFile_ini, sizeof(ts->UILanguageFile_ini));
1778
1779 // UI language message file (full path)
1780 ts->UILanguageFileW = GetUILanguageFileFullW(ts->ExeDirW, ts->UILanguageFileW_ini);
1781 WideCharToACP_t(ts->UILanguageFileW, ts->UILanguageFile, sizeof(ts->UILanguageFile));
1782
1783
1784 // Broadcast Command History (2007.3.3 maya)
1785 ts->BroadcastCommandHistory =
1786 GetOnOff(Section, "BroadcastCommandHistory", FName, FALSE);
1787
1788 // 337: 2007/03/20 Accept Broadcast
1789 ts->AcceptBroadcast =
1790 GetOnOff(Section, "AcceptBroadcast", FName, TRUE);
1791
1792 // Confirm send a file when drag and drop (2007.12.28 maya)
1793 ts->ConfirmFileDragAndDrop =
1794 GetOnOff(Section, "ConfirmFileDragAndDrop", FName, TRUE);
1795
1796 // Translate mouse wheel to cursor key when application cursor mode
1797 ts->TranslateWheelToCursor =
1798 GetOnOff(Section, "TranslateWheelToCursor", FName, TRUE);
1799
1800 // Display "New Connection" dialog on startup (2008.1.18 maya)
1801 ts->HostDialogOnStartup =
1802 GetOnOff(Section, "HostDialogOnStartup", FName, TRUE);
1803
1804 // Mouse event tracking
1805 ts->MouseEventTracking =
1806 GetOnOff(Section, "MouseEventTracking", FName, TRUE);
1807
1808 // Maximized bug tweak
1809 GetPrivateProfileString(Section, "MaximizedBugTweak", "2", Temp,
1810 sizeof(Temp), FName);
1811 if (_stricmp(Temp, "on") == 0) {
1812 ts->MaximizedBugTweak = 2;
1813 }
1814 else {
1815 ts->MaximizedBugTweak = atoi(Temp);
1816 }
1817
1818 // Convert Unicode symbol characters to DEC Special characters
1819 ts->UnicodeDecSpMapping =
1820 GetPrivateProfileInt(Section, "UnicodeToDecSpMapping", 3, FName);
1821
1822 // VT Window Icon
1823 GetPrivateProfileString(Section, "VTIcon", "Default",
1824 Temp, sizeof(Temp), FName);
1825 ts->VTIcon = IconName2IconIdA(Temp);
1826
1827 // Tek Window Icon
1828 GetPrivateProfileString(Section, "TEKIcon", "Default",
1829 Temp, sizeof(Temp), FName);
1830 ts->TEKIcon = IconName2IconIdA(Temp);
1831
1832 // Unknown Unicode Character
1833 ts->UnknownUnicodeCharaAsWide =
1834 GetOnOff(Section, "UnknownUnicodeCharacterAsWide", FName, FALSE);
1835
1836 #ifdef USE_NORMAL_BGCOLOR
1837 // UseNormalBGColor
1838 ts->UseNormalBGColor =
1839 GetOnOff(Section, "UseNormalBGColor", FName, FALSE);
1840 // 2006/03/11 by 337
1841 if (ts->UseNormalBGColor) {
1842 ts->VTBoldColor[1] =
1843 ts->VTBlinkColor[1] = ts->URLColor[1] = ts->VTColor[1];
1844 }
1845 #endif
1846
1847 // AutoScrollOnlyInBottomLine
1848 ts->AutoScrollOnlyInBottomLine =
1849 GetOnOff(Section, "AutoScrollOnlyInBottomLine", FName, FALSE);
1850
1851 // Accept remote-controlled window title changing
1852 GetPrivateProfileString(Section, "AcceptTitleChangeRequest", "overwrite",
1853 Temp, sizeof(Temp), FName);
1854 if (_stricmp(Temp, "overwrite") == 0 || _stricmp(Temp, "on") == 0)
1855 ts->AcceptTitleChangeRequest = IdTitleChangeRequestOverwrite;
1856 else if (_stricmp(Temp, "ahead") == 0)
1857 ts->AcceptTitleChangeRequest = IdTitleChangeRequestAhead;
1858 else if (_stricmp(Temp, "last") == 0)
1859 ts->AcceptTitleChangeRequest = IdTitleChangeRequestLast;
1860 else
1861 ts->AcceptTitleChangeRequest = IdTitleChangeRequestOff;
1862
1863 // Size of paste confirm dialog
1864 GetPrivateProfileString(Section, "PasteDialogSize", "330,220",
1865 Temp, sizeof(Temp), FName);
1866 GetNthNum(Temp, 1, &ts->PasteDialogSize.cx);
1867 GetNthNum(Temp, 2, &ts->PasteDialogSize.cy);
1868 if (ts->PasteDialogSize.cx < 0)
1869 ts->PasteDialogSize.cx = 330;
1870 if (ts->PasteDialogSize.cy < 0)
1871 ts->PasteDialogSize.cy = 220;
1872
1873 // Disable mouse event tracking when Control-Key is pressed.
1874 ts->DisableMouseTrackingByCtrl =
1875 GetOnOff(Section, "DisableMouseTrackingByCtrl", FName, TRUE);
1876
1877 // Disable TranslateWheelToCursor setting when Control-Key is pressed.
1878 ts->DisableWheelToCursorByCtrl =
1879 GetOnOff(Section, "DisableWheelToCursorByCtrl", FName, TRUE);
1880
1881 // Strict Key Mapping.
1882 ts->StrictKeyMapping =
1883 GetOnOff(Section, "StrictKeyMapping", FName, FALSE);
1884
1885 // added Wait4allMacroCommand (2009.3.23 yutaka)
1886 ts->Wait4allMacroCommand =
1887 GetOnOff(Section, "Wait4allMacroCommand", FName, FALSE);
1888
1889 // added DisableMenuSendBreak (2009.4.6 maya)
1890 ts->DisableMenuSendBreak =
1891 GetOnOff(Section, "DisableMenuSendBreak", FName, FALSE);
1892
1893 // added ClearScreenOnCloseConnection (2009.4.6 maya)
1894 ts->ClearScreenOnCloseConnection =
1895 GetOnOff(Section, "ClearScreenOnCloseConnection", FName, FALSE);
1896
1897 // added DisableAcceleratorDuplicateSession (2009.4.6 maya)
1898 ts->DisableAcceleratorDuplicateSession =
1899 GetOnOff(Section, "DisableAcceleratorDuplicateSession", FName, FALSE);
1900
1901 ts->AcceleratorNewConnection =
1902 GetOnOff(Section, "AcceleratorNewConnection", FName, TRUE);
1903
1904 ts->AcceleratorCygwinConnection =
1905 GetOnOff(Section, "AcceleratorCygwinConnection", FName, TRUE);
1906
1907 // added DisableMenuDuplicateSession (2010.8.3 maya)
1908 ts->DisableMenuDuplicateSession =
1909 GetOnOff(Section, "DisableMenuDuplicateSession", FName, FALSE);
1910
1911 // added DisableMenuNewConnection (2010.8.4 maya)
1912 ts->DisableMenuNewConnection =
1913 GetOnOff(Section, "DisableMenuNewConnection", FName, FALSE);
1914
1915 // added PasteDelayPerLine (2009.4.12 maya)
1916 ts->PasteDelayPerLine =
1917 GetPrivateProfileInt(Section, "PasteDelayPerLine", 10, FName);
1918 {
1919 int tmp = min(max(0, ts->PasteDelayPerLine), 5000);
1920 ts->PasteDelayPerLine = tmp;
1921 }
1922
1923 // Font scaling -- test
1924 ts->FontScaling = GetOnOff(Section, "FontScaling", FName, FALSE);
1925
1926 // Meta sets MSB
1927 GetPrivateProfileString(Section, "Meta8Bit", "off", Temp, sizeof(Temp), FName);
1928 if (_stricmp(Temp, "raw") == 0 || _stricmp(Temp, "on") == 0)
1929 ts->Meta8Bit = IdMeta8BitRaw;
1930 else if (_stricmp(Temp, "text") == 0)
1931 ts->Meta8Bit = IdMeta8BitText;
1932 else
1933 ts->Meta8Bit = IdMeta8BitOff;
1934
1935 // Window control sequence
1936 if (GetOnOff(Section, "WindowCtrlSequence", FName, TRUE))
1937 ts->WindowFlag |= WF_WINDOWCHANGE;
1938
1939 // Cursor control sequence
1940 if (GetOnOff(Section, "CursorCtrlSequence", FName, FALSE))
1941 ts->WindowFlag |= WF_CURSORCHANGE;
1942
1943 // Window report sequence
1944 if (GetOnOff(Section, "WindowReportSequence", FName, TRUE))
1945 ts->WindowFlag |= WF_WINDOWREPORT;
1946
1947 // Title report sequence
1948 GetPrivateProfileString(Section, "TitleReportSequence", "Empty", Temp, sizeof(Temp), FName);
1949 if (_stricmp(Temp, "accept") == 0)
1950 ts->WindowFlag |= IdTitleReportAccept;
1951 else if (_stricmp(Temp, "ignore") == 0 || _stricmp(Temp, "off") == 0)
1952 ts->WindowFlag &= ~WF_TITLEREPORT;
1953 else // empty
1954 ts->WindowFlag |= IdTitleReportEmpty;
1955
1956 // Line at a time mode
1957 ts->EnableLineMode = GetOnOff(Section, "EnableLineMode", FName, TRUE);
1958
1959 // Clear window on resize
1960 if (GetOnOff(Section, "ClearOnResize", FName, TRUE))
1961 ts->TermFlag |= TF_CLEARONRESIZE;
1962
1963 // Alternate Screen Buffer
1964 if (GetOnOff(Section, "AlternateScreenBuffer", FName, TRUE))
1965 ts->TermFlag |= TF_ALTSCR;
1966
1967 // IME status related cursor style
1968 if (GetOnOff(Section, "IMERelatedCursor", FName, FALSE))
1969 ts->WindowFlag |= WF_IMECURSORCHANGE;
1970
1971 // Terminal Unique ID
1972 GetPrivateProfileString(Section, "TerminalUID", "FFFFFFFF", Temp, sizeof(Temp), FName);
1973 if (strlen(Temp) == 8) {
1974 for (i=0; i<8 && isxdigit((unsigned char)Temp[i]); i++) {
1975 if (islower(Temp[i])) {
1976 ts->TerminalUID[i] = toupper(Temp[i]);
1977 }
1978 else {
1979 ts->TerminalUID[i] = Temp[i];
1980 }
1981 }
1982 if (i == 8) {
1983 ts->TerminalUID[i] = 0;
1984 }
1985 else {
1986 strncpy_s(ts->TerminalUID, sizeof(ts->TerminalUID), "FFFFFFFF", _TRUNCATE);
1987 }
1988 }
1989 else {
1990 strncpy_s(ts->TerminalUID, sizeof(ts->TerminalUID), "FFFFFFFF", _TRUNCATE);
1991 }
1992
1993 // Lock Terminal UID
1994 if (GetOnOff(Section, "LockTUID", FName, TRUE))
1995 ts->TermFlag |= TF_LOCKTUID;
1996
1997 // Jump List
1998 ts->JumpList = GetOnOff(Section, "JumpList", FName, TRUE);
1999
2000 // TabStopModifySequence
2001 GetPrivateProfileString(Section, "TabStopModifySequence", "on", Temp, sizeof(Temp), FName);
2002 if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "all") == 0)
2003 ts->TabStopFlag = TABF_ALL;
2004 else if (_stricmp(Temp, "off") == 0 || _stricmp(Temp, "none") == 0)
2005 ts->TabStopFlag = TABF_NONE;
2006 else {
2007 ts->TabStopFlag = TABF_NONE;
2008 for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
2009 if (_stricmp(Temp2, "HTS") == 0)
2010 ts->TabStopFlag |= TABF_HTS;
2011 else if (_stricmp(Temp2, "HTS7") == 0)
2012 ts->TabStopFlag |= TABF_HTS7;
2013 else if (_stricmp(Temp2, "HTS8") == 0)
2014 ts->TabStopFlag |= TABF_HTS8;
2015 else if (_stricmp(Temp2, "TBC") == 0)
2016 ts->TabStopFlag |= TABF_TBC;
2017 else if (_stricmp(Temp2, "TBC0") == 0)
2018 ts->TabStopFlag |= TABF_TBC0;
2019 else if (_stricmp(Temp2, "TBC3") == 0)
2020 ts->TabStopFlag |= TABF_TBC3;
2021 }
2022 }
2023
2024 // Clipboard Access from Remote
2025 ts->CtrlFlag &= ~CSF_CBMASK;
2026 GetPrivateProfileString(Section, "ClipboardAccessFromRemote", "off", Temp, sizeof(Temp), FName);
2027 if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "readwrite") == 0)
2028 ts->CtrlFlag |= CSF_CBRW;
2029 else if (_stricmp(Temp, "read") == 0)
2030 ts->CtrlFlag |= CSF_CBREAD;
2031 else if (_stricmp(Temp, "write") == 0)
2032 ts->CtrlFlag |= CSF_CBWRITE;
2033 else
2034 ts->CtrlFlag |= CSF_CBNONE; // ��������������
2035
2036 // Notify Clipboard Access from Remote
2037 ts->NotifyClipboardAccess = GetOnOff(Section, "NotifyClipboardAccess", FName, TRUE);
2038
2039 // Use invalid DECRPSS (for testing)
2040 if (GetOnOff(Section, "UseInvalidDECRQSSResponse", FName, FALSE))
2041 ts->TermFlag |= TF_INVALIDDECRPSS;
2042
2043 // ClickableUrlBrowser
2044 GetPrivateProfileString(Section, "ClickableUrlBrowser", "",
2045 ts->ClickableUrlBrowser, sizeof(ts->ClickableUrlBrowser), FName);
2046 GetPrivateProfileString(Section, "ClickableUrlBrowserArg", "",
2047 ts->ClickableUrlBrowserArg, sizeof(ts->ClickableUrlBrowserArg), FName);
2048
2049 // Exclusive Lock when open the log file
2050 ts->LogLockExclusive = GetOnOff(Section, "LogLockExclusive", FName, TRUE);
2051
2052 // Font quality
2053 GetPrivateProfileString(Section, "FontQuality", "default",
2054 Temp, sizeof(Temp), FName);
2055 if (_stricmp(Temp, "nonantialiased") == 0)
2056 ts->FontQuality = NONANTIALIASED_QUALITY;
2057 else if (_stricmp(Temp, "antialiased") == 0)
2058 ts->FontQuality = ANTIALIASED_QUALITY;
2059 else if (_stricmp(Temp, "cleartype") == 0)
2060 ts->FontQuality = CLEARTYPE_QUALITY;
2061 else
2062 ts->FontQuality = DEFAULT_QUALITY;
2063
2064 // Beep Over Used
2065 ts->BeepOverUsedCount =
2066 GetPrivateProfileInt(Section, "BeepOverUsedCount", 5, FName);
2067 ts->BeepOverUsedTime =
2068 GetPrivateProfileInt(Section, "BeepOverUsedTime", 2, FName);
2069 ts->BeepSuppressTime =
2070 GetPrivateProfileInt(Section, "BeepSuppressTime", 5, FName);
2071
2072 // Max OSC string buffer size
2073 ts->MaxOSCBufferSize =
2074 GetPrivateProfileInt(Section, "MaxOSCBufferSize", 4096, FName);
2075
2076 ts->JoinSplitURL = GetOnOff(Section, "JoinSplitURL", FName, FALSE);
2077
2078 GetPrivateProfileString(Section, "JoinSplitURLIgnoreEOLChar", "\\", Temp, sizeof(Temp), FName);
2079 ts->JoinSplitURLIgnoreEOLChar = Temp[0];
2080
2081 // Debug modes.
2082 GetPrivateProfileString(Section, "DebugModes", "all", Temp, sizeof(Temp), FName);
2083 if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "all") == 0)
2084 ts->DebugModes = DBGF_ALL;
2085 else if (_stricmp(Temp, "off") == 0 || _stricmp(Temp, "none") == 0) {
2086 ts->DebugModes = DBGF_NONE;
2087 ts->Debug = FALSE;
2088 }
2089 else {
2090 ts->DebugModes = DBGF_NONE;
2091 for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
2092 if (_stricmp(Temp2, "normal") == 0)
2093 ts->DebugModes |= DBGF_NORM;
2094 else if (_stricmp(Temp2, "hex") == 0)
2095 ts->DebugModes |= DBGF_HEXD;
2096 else if (_stricmp(Temp2, "noout") == 0)
2097 ts->DebugModes |= DBGF_NOUT;
2098 }
2099 if (ts->DebugModes == DBGF_NONE)
2100 ts->Debug = FALSE;
2101 }
2102
2103 // Xmodem Timeout
2104 GetPrivateProfileString(Section, "XmodemTimeouts", "10,3,10,20,60", Temp, sizeof(Temp), FName);
2105 ts->XmodemTimeOutInit = GetNthNum2(Temp, 1, 10);
2106 if (ts->XmodemTimeOutInit < 1)
2107 ts->XmodemTimeOutInit = 1;
2108 ts->XmodemTimeOutInitCRC = GetNthNum2(Temp, 2, 3);
2109 if (ts->XmodemTimeOutInitCRC < 1)
2110 ts->XmodemTimeOutInitCRC = 1;
2111 ts->XmodemTimeOutShort = GetNthNum2(Temp, 3, 10);
2112 if (ts->XmodemTimeOutShort < 1)
2113 ts->XmodemTimeOutShort = 1;
2114 ts->XmodemTimeOutLong = GetNthNum2(Temp, 4, 20);
2115 if (ts->XmodemTimeOutLong < 1)
2116 ts->XmodemTimeOutLong = 1;
2117 ts->XmodemTimeOutVLong = GetNthNum2(Temp, 5, 60);
2118 if (ts->XmodemTimeOutVLong < 1)
2119 ts->XmodemTimeOutVLong = 1;
2120
2121 // Ymodem Timeout
2122 GetPrivateProfileString(Section, "YmodemTimeouts", "10,3,10,20,60", Temp, sizeof(Temp), FName);
2123 ts->YmodemTimeOutInit = GetNthNum2(Temp, 1, 10);
2124 if (ts->YmodemTimeOutInit < 1)
2125 ts->YmodemTimeOutInit = 1;
2126 ts->YmodemTimeOutInitCRC = GetNthNum2(Temp, 2, 3);
2127 if (ts->YmodemTimeOutInitCRC < 1)
2128 ts->YmodemTimeOutInitCRC = 1;
2129 ts->YmodemTimeOutShort = GetNthNum2(Temp, 3, 10);
2130 if (ts->YmodemTimeOutShort < 1)
2131 ts->YmodemTimeOutShort = 1;
2132 ts->YmodemTimeOutLong = GetNthNum2(Temp, 4, 20);
2133 if (ts->YmodemTimeOutLong < 1)
2134 ts->YmodemTimeOutLong = 1;
2135 ts->YmodemTimeOutVLong = GetNthNum2(Temp, 5, 60);
2136 if (ts->YmodemTimeOutVLong < 1)
2137 ts->YmodemTimeOutVLong = 1;
2138
2139 // Zmodem Timeout
2140 GetPrivateProfileString(Section, "ZmodemTimeouts", "10,0,10,3", Temp, sizeof(Temp), FName);
2141 ts->ZmodemTimeOutNormal = GetNthNum2(Temp, 1, 10);
2142 if (ts->ZmodemTimeOutNormal < 1)
2143 ts->ZmodemTimeOutNormal = 1;
2144 ts->ZmodemTimeOutTCPIP = GetNthNum2(Temp, 2, 0);
2145 if (ts->ZmodemTimeOutTCPIP < 0)
2146 ts->ZmodemTimeOutTCPIP = 0;
2147 ts->ZmodemTimeOutInit = GetNthNum2(Temp, 3, 10);
2148 if (ts->ZmodemTimeOutInit < 1)
2149 ts->ZmodemTimeOutInit = 1;
2150 ts->ZmodemTimeOutFin = GetNthNum2(Temp, 4, 3);
2151 if (ts->ZmodemTimeOutFin < 1)
2152 ts->ZmodemTimeOutFin = 1;
2153
2154 // Trim trailing new line character when pasting
2155 if (GetOnOff(Section, "TrimTrailingNLonPaste", FName, FALSE))
2156 ts->PasteFlag |= CPF_TRIM_TRAILING_NL;
2157
2158 // List Inactive Font
2159 ts->ListHiddenFonts = GetOnOff(Section, "ListHiddenFonts", FName, FALSE);
2160
2161 // ISO2022ShiftFunction
2162 GetPrivateProfileString(Section, "ISO2022ShiftFunction", "on", Temp, sizeof(Temp), FName);
2163 ts->ISO2022Flag = ISO2022_SHIFT_NONE;
2164 for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
2165 BOOL add=TRUE;
2166 char *p = Temp2, *p2;
2167 int mask = 0;
2168
2169 while (*p == ' ' || *p == '\t') {
2170 p++;
2171 }
2172 p2 = p + strlen(p);
2173 while (p2 > p) {
2174 p2--;
2175 if (*p2 != ' ' && *p2 != '\t') {
2176 break;
2177 }
2178 }
2179 *++p2 = 0;
2180
2181 if (*p == '-') {
2182 p++;
2183 add=FALSE;
2184 }
2185 else if (*p == '+') {
2186 p++;
2187 }
2188
2189 if (_stricmp(p, "on") == 0 || _stricmp(p, "all") == 0)
2190 ts->ISO2022Flag = ISO2022_SHIFT_ALL;
2191 else if (_stricmp(p, "off") == 0 || _stricmp(p, "none") == 0)
2192 ts->ISO2022Flag = ISO2022_SHIFT_NONE;
2193 else if (_stricmp(p, "SI") == 0 || _stricmp(p, "LS0") == 0)
2194 mask = ISO2022_SI;
2195 else if (_stricmp(p, "SO") == 0 || _stricmp(p, "LS1") == 0)
2196 mask = ISO2022_SO;
2197 else if (_stricmp(p, "LS2") == 0)
2198 mask = ISO2022_LS2;
2199 else if (_stricmp(p, "LS3") == 0)
2200 mask = ISO2022_LS3;
2201 else if (_stricmp(p, "LS1R") == 0)
2202 mask = ISO2022_LS1R;
2203 else if (_stricmp(p, "LS2R") == 0)
2204 mask = ISO2022_LS2R;
2205 else if (_stricmp(p, "LS3R") == 0)
2206 mask = ISO2022_LS3R;
2207 else if (_stricmp(p, "SS2") == 0)
2208 mask = ISO2022_SS2;
2209 else if (_stricmp(p, "SS3") == 0)
2210 mask = ISO2022_SS3;
2211
2212 if (mask) {
2213 if (add) {
2214 ts->ISO2022Flag |= mask;
2215 }
2216 else {
2217 ts->ISO2022Flag &= ~mask;
2218 }
2219 }
2220 }
2221
2222 // Terminal Speed (Used by telnet and ssh)
2223 GetPrivateProfileString(Section, "TerminalSpeed", "38400", Temp, sizeof(Temp), FName);
2224 GetNthNum(Temp, 1, &i);
2225 if (i > 0)
2226 ts->TerminalInputSpeed = i;
2227 else
2228 ts->TerminalInputSpeed = 38400;
2229 GetNthNum(Temp, 2, &i);
2230 if (i > 0)
2231 ts->TerminalOutputSpeed = i;
2232 else
2233 ts->TerminalOutputSpeed = ts->TerminalInputSpeed;
2234
2235 // Clear scroll buffer from remote -- special option
2236 if (GetOnOff(Section, "ClearScrollBufferFromRemote", FName, TRUE))
2237 ts->TermFlag |= TF_REMOTECLEARSBUFF;
2238
2239 // Delay for start of mouse selection
2240 ts->SelectStartDelay =
2241 GetPrivateProfileInt(Section, "MouseSelectStartDelay", 0, FName);
2242
2243 // Fallback to CP932 (Experimental)
2244 ts->FallbackToCP932 = GetOnOff(Section, "FallbackToCP932", FName, FALSE);
2245
2246 // CygTerm Configuration File
2247 ReadCygtermConfFile(ts);
2248
2249 // dialog font
2250 ReadFont3("Tera Term", "DlgFont", NULL, FName,
2251 ts->DialogFontName, sizeof(ts->DialogFontName),
2252 &ts->DialogFontPoint, &ts->DialogFontCharSet);
2253
2254 // Unicode����
2255 ts->UnicodeAmbiguousWidth = GetPrivateProfileInt(Section, "UnicodeAmbiguousWidth", 1, FName);
2256 if (ts->UnicodeAmbiguousWidth < 1 || 2 < ts->UnicodeAmbiguousWidth) {
2257 ts->UnicodeAmbiguousWidth = 1;
2258 }
2259 ts->UnicodeEmojiOverride = (BYTE)GetOnOff(Section, "UnicodeEmojiOverride", FName, FALSE);
2260 ts->UnicodeEmojiWidth = GetPrivateProfileInt(Section, "UnicodeEmojiWidth", 1, FName);
2261 if (ts->UnicodeEmojiWidth < 1 || 2 < ts->UnicodeEmojiWidth) {
2262 ts->UnicodeEmojiWidth = 1;
2263 }
2264
2265 DispReadIni(FName, ts);
2266
2267 // rounded corner preference for VT/TEK window
2268 ts->WindowCornerDontround = GetOnOff(Section, "WindowCornerDontround", FName, FALSE);
2269
2270 // Experimental
2271 ts->ExperimentalTreeProprtySheetEnable = GetOnOff("Experimental", "TreeProprtySheet", FName, FALSE);
2272 }
2273
2274 void PASCAL WriteIniFile(const wchar_t *FName, PTTSet ts)
2275 {
2276 int i;
2277 char Temp[MAX_PATH];
2278 char buf[20];
2279 int ret;
2280 char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG], msg[MAX_UIMSG];
2281 WORD TmpColor[12][6];
2282
2283 /* version */
2284 ret = WritePrivateProfileString(Section, "Version", TT_VERSION_STR("."), FName);
2285 if (ret == 0) {
2286 // ini�t�@�C�����������������s�������A�G���[���b�Z�[�W���\�������B(2012.10.18 yutaka)
2287 ret = GetLastError();
2288 get_lang_msg("MSG_INI_WRITE_ERROR", uimsg, sizeof(uimsg), "Cannot write ini file", ts->UILanguageFile);
2289 _snprintf_s(msg, sizeof(msg), _TRUNCATE, "%s (%d)", uimsg, ret);
2290
2291 get_lang_msg("MSG_INI_ERROR", uimsg2, sizeof(uimsg2), "Tera Term: Error", ts->UILanguageFile);
2292
2293 MessageBox(NULL, msg, uimsg2, MB_ICONEXCLAMATION);
2294 }
2295
2296 /* Language */
2297 {
2298 const char *language_str = GetLanguageStr(ts->Language);
2299 WritePrivateProfileString(Section, "Language", language_str, FName);
2300 }
2301
2302 /* Port type */
2303 WritePrivateProfileString(Section, "Port", (ts->PortType==IdSerial)?"serial":"tcpip", FName);
2304
2305 /* Save win position */
2306 if (ts->SaveVTWinPos) {
2307 /* VT win position */
2308 WriteInt2(Section, "VTPos", FName, ts->VTPos.x, ts->VTPos.y);
2309 }
2310
2311 /* VT terminal size */
2312 WriteInt2(Section, "TerminalSize", FName,
2313 ts->TerminalWidth, ts->TerminalHeight);
2314
2315 /* Terminal size = Window size */
2316 WriteOnOff(Section, "TermIsWin", FName, ts->TermIsWin);
2317
2318 /* Auto window resize flag */
2319 WriteOnOff(Section, "AutoWinResize", FName, ts->AutoWinResize);
2320
2321 /* CR Receive */
2322 if (ts->CRReceive == IdCRLF) {
2323 strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
2324 }
2325 else if (ts->CRReceive == IdLF) {
2326 strncpy_s(Temp, sizeof(Temp), "LF", _TRUNCATE);
2327 }
2328 else if (ts->CRReceive == IdAUTO) {
2329 strncpy_s(Temp, sizeof(Temp), "AUTO", _TRUNCATE);
2330 }
2331 else {
2332 strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
2333 }
2334 WritePrivateProfileString(Section, "CRReceive", Temp, FName);
2335
2336 /* CR Send */
2337 if (ts->CRSend == IdCRLF) {
2338 strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
2339 }
2340 else if (ts->CRSend == IdLF) {
2341 strncpy_s(Temp, sizeof(Temp), "LF", _TRUNCATE);
2342 }
2343 else {
2344 strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
2345 }
2346 WritePrivateProfileString(Section, "CRSend", Temp, FName);
2347
2348 /* Local echo */
2349 WriteOnOff(Section, "LocalEcho", FName, ts->LocalEcho);
2350
2351 /* Answerback */
2352 if ((ts->FTFlag & FT_BPAUTO) == 0) {
2353 Str2Hex(ts->Answerback, Temp, ts->AnswerbackLen,
2354 sizeof(Temp) - 1, TRUE);
2355 WritePrivateProfileString(Section, "Answerback", Temp, FName);
2356 }
2357
2358 /* Kanji Code (receive) */
2359 {
2360 const char *code_str = GetKanjiCodeStr(ts->Language, ts->KanjiCode);
2361 WritePrivateProfileString(Section, "KanjiReceive", code_str, FName);
2362 }
2363
2364 /* Katakana (receive) */
2365 if (ts->JIS7Katakana == 1)
2366 strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
2367 else
2368 strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
2369
2370 WritePrivateProfileString(Section, "KatakanaReceive", Temp, FName);
2371
2372 /* Kanji Code (transmit) */
2373 {
2374 const char *code_str = GetKanjiCodeStr(ts->Language, ts->KanjiCodeSend);
2375 WritePrivateProfileString(Section, "KanjiSend", code_str, FName);
2376 }
2377
2378 /* Katakana (transmit) */
2379 if (ts->JIS7KatakanaSend == 1)
2380 strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
2381 else
2382 strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
2383
2384 WritePrivateProfileString(Section, "KatakanaSend", Temp, FName);
2385
2386 /* KanjiIn */
2387 if (ts->KanjiIn == IdKanjiInA)
2388 strncpy_s(Temp, sizeof(Temp), "@", _TRUNCATE);
2389 else
2390 strncpy_s(Temp, sizeof(Temp), "B", _TRUNCATE);
2391
2392 WritePrivateProfileString(Section, "KanjiIn", Temp, FName);
2393
2394 /* KanjiOut */
2395 switch (ts->KanjiOut) {
2396 case IdKanjiOutB:
2397 strncpy_s(Temp, sizeof(Temp), "B", _TRUNCATE);
2398 break;
2399 case IdKanjiOutH:
2400 strncpy_s(Temp, sizeof(Temp), "H", _TRUNCATE);
2401 break;
2402 default:
2403 strncpy_s(Temp, sizeof(Temp), "J", _TRUNCATE);
2404 }
2405 WritePrivateProfileString(Section, "KanjiOut", Temp, FName);
2406
2407 // new configuration
2408 WriteInt(Section, "ConnectingTimeout", FName, ts->ConnectingTimeout);
2409
2410 WriteOnOff(Section, "DisablePasteMouseRButton", FName,
2411 (WORD) (ts->PasteFlag & CPF_DISABLE_RBUTTON));
2412
2413 WriteOnOff(Section, "DisablePasteMouseMButton", FName,
2414 (WORD) (ts->PasteFlag & CPF_DISABLE_MBUTTON));
2415
2416 WriteOnOff(Section, "ConfirmPasteMouseRButton", FName,
2417 (WORD) (ts->PasteFlag & CPF_CONFIRM_RBUTTON));
2418
2419 // added ConfirmChangePaste
2420 WriteOnOff(Section, "ConfirmChangePaste", FName,
2421 (WORD) (ts->PasteFlag & CPF_CONFIRM_CHANGEPASTE));
2422
2423 WriteOnOff(Section, "ConfirmChangePasteCR", FName,
2424 (WORD) (ts->PasteFlag & CPF_CONFIRM_CHANGEPASTE_CR));
2425
2426 WritePrivateProfileString(Section, "ConfirmChangePasteStringFile",
2427 ts->ConfirmChangePasteStringFile, FName);
2428
2429 // added ScrollWindowClearScreen
2430 WriteOnOff(Section, "ScrollWindowClearScreen", FName,
2431 ts->ScrollWindowClearScreen);
2432
2433 // added SelectOnlyByLButton (2007.11.20 maya)
2434 WriteOnOff(Section, "SelectOnlyByLButton", FName,
2435 ts->SelectOnlyByLButton);
2436 // added DisableAcceleratorSendBreak (2007.3.17 maya)
2437 WriteOnOff(Section, "DisableAcceleratorSendBreak", FName,
2438 ts->DisableAcceleratorSendBreak);
2439 WriteOnOff(Section, "EnableContinuedLineCopy", FName,
2440 ts->EnableContinuedLineCopy);
2441 WritePrivateProfileString(Section, "MouseCursor", ts->MouseCursorName,
2442 FName);
2443 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->AlphaBlendInactive);
2444 WritePrivateProfileString(Section, "AlphaBlend", Temp, FName);
2445 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->AlphaBlendActive);
2446 WritePrivateProfileString(Section, "AlphaBlendActive", Temp, FName);
2447 WritePrivateProfileString(Section, "CygwinDirectory",
2448 ts->CygwinDirectory, FName);
2449 WritePrivateProfileString(Section, "ViewlogEditor", ts->ViewlogEditor,
2450 FName);
2451
2452 // ANSI color(2004.9.5 yutaka)
2453 Temp[0] = '\0';
2454 for (i = 0; i < 15; i++) {
2455 _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d,%d,%d,%d, ",
2456 i,
2457 GetRValue(ts->ANSIColor[i]),
2458 GetGValue(ts->ANSIColor[i]),
2459 GetBValue(ts->ANSIColor[i])
2460 );
2461 strncat_s(Temp, sizeof(Temp), buf, _TRUNCATE);
2462 }
2463 i = 15;
2464 _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d,%d,%d,%d",
2465 i,
2466 GetRValue(ts->ANSIColor[i]),
2467 GetGValue(ts->ANSIColor[i]),
2468 GetBValue(ts->ANSIColor[i])
2469 );
2470 strncat_s(Temp, sizeof(Temp), buf, _TRUNCATE);
2471 WritePrivateProfileString(Section, "ANSIColor", Temp, FName);
2472
2473 /* AutoWinChange VT<->TEK */
2474 WriteOnOff(Section, "AutoWinSwitch", FName, ts->AutoWinSwitch);
2475
2476 /* Terminal ID */
2477 id2str(TermList, ts->TerminalID, IdVT100, Temp, sizeof(Temp));
2478 WritePrivateProfileString(Section, "TerminalID", Temp, FName);
2479
2480 /* Title text */
2481 WritePrivateProfileString(Section, "Title", ts->Title, FName);
2482
2483 /* Cursor shape */
2484 switch (ts->CursorShape) {
2485 case IdVCur:
2486 strncpy_s(Temp, sizeof(Temp), "vertical", _TRUNCATE);
2487 break;
2488 case IdHCur:
2489 strncpy_s(Temp, sizeof(Temp), "horizontal", _TRUNCATE);
2490 break;
2491 default:
2492 strncpy_s(Temp, sizeof(Temp), "block", _TRUNCATE);
2493 }
2494 WritePrivateProfileString(Section, "CursorShape", Temp, FName);
2495
2496 /* Hide title */
2497 WriteOnOff(Section, "HideTitle", FName, ts->HideTitle);
2498
2499 /* Popup menu */
2500 WriteOnOff(Section, "PopupMenu", FName, ts->PopupMenu);
2501
2502 /* PC-Style bold color mapping */
2503 WriteOnOff(Section, "PcBoldColor", FName,
2504 (WORD) (ts->ColorFlag & CF_PCBOLD16));
2505
2506 /* aixterm 16 colors mode */
2507 WriteOnOff(Section, "Aixterm16Color", FName,
2508 (WORD) (ts->ColorFlag & CF_AIXTERM16));
2509
2510 /* xterm 256 colors mode */
2511 WriteOnOff(Section, "Xterm256Color", FName,
2512 (WORD) (ts->ColorFlag & CF_XTERM256));
2513
2514 /* Enable scroll buffer */
2515 WriteOnOff(Section, "EnableScrollBuff", FName, ts->EnableScrollBuff);
2516
2517 /* Scroll buffer size */
2518 WriteInt(Section, "ScrollBuffSize", FName, ts->ScrollBuffSize);
2519
2520 /* VT Color */
2521 for (i = 0; i <= 1; i++) {
2522 if (ts->ColorFlag & CF_REVERSEVIDEO) {
2523 if (ts->ColorFlag & CF_REVERSECOLOR) {
2524 TmpColor[0][i * 3] = GetRValue(ts->VTReverseColor[i]);
2525 TmpColor[0][i * 3 + 1] = GetGValue(ts->VTReverseColor[i]);
2526 TmpColor[0][i * 3 + 2] = GetBValue(ts->VTReverseColor[i]);
2527 }
2528 else {
2529 TmpColor[0][i * 3] = GetRValue(ts->VTColor[!i]);
2530 TmpColor[0][i * 3 + 1] = GetGValue(ts->VTColor[!i]);
2531 TmpColor[0][i * 3 + 2] = GetBValue(ts->VTColor[!i]);
2532 }
2533 }
2534 else {
2535 TmpColor[0][i * 3] = GetRValue(ts->VTColor[i]);
2536 TmpColor[0][i * 3 + 1] = GetGValue(ts->VTColor[i]);
2537 TmpColor[0][i * 3 + 2] = GetBValue(ts->VTColor[i]);
2538 }
2539 }
2540 WriteInt6(Section, "VTColor", FName,
2541 TmpColor[0][0], TmpColor[0][1], TmpColor[0][2],
2542 TmpColor[0][3], TmpColor[0][4], TmpColor[0][5]);
2543
2544 /* VT Bold Color */
2545 for (i = 0; i <= 1; i++) {
2546 if (ts->ColorFlag & CF_REVERSEVIDEO) {
2547 TmpColor[0][i * 3] = GetRValue(ts->VTBoldColor[!i]);
2548 TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBoldColor[!i]);
2549 TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBoldColor[!i]);
2550 }
2551 else {
2552 TmpColor[0][i * 3] = GetRValue(ts->VTBoldColor[i]);
2553 TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBoldColor[i]);
2554 TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBoldColor[i]);
2555 }
2556 }
2557 WriteInt6(Section, "VTBoldColor", FName,
2558 TmpColor[0][0], TmpColor[0][1], TmpColor[0][2],
2559 TmpColor[0][3], TmpColor[0][4], TmpColor[0][5]);
2560
2561 /* VT Blink Color */
2562 for (i = 0; i <= 1; i++) {
2563 if (ts->ColorFlag & CF_REVERSEVIDEO) {
2564 TmpColor[0][i * 3] = GetRValue(ts->VTBlinkColor[!i]);
2565 TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBlinkColor[!i]);
2566 TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBlinkColor[!i]);
2567 }
2568 else {
2569 TmpColor[0][i * 3] = GetRValue(ts->VTBlinkColor[i]);
2570 TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBlinkColor[i]);
2571 TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBlinkColor[i]);
2572 }
2573 }
2574 WriteInt6(Section, "VTBlinkColor", FName,
2575 TmpColor[0][0], TmpColor[0][1], TmpColor[0][2],
2576 TmpColor[0][3], TmpColor[0][4], TmpColor[0][5]);
2577
2578 /* VT Reverse Color */
2579 for (i = 0; i <= 1; i++) {
2580 if (ts->ColorFlag & CF_REVERSEVIDEO && ts->ColorFlag & CF_REVERSECOLOR) {
2581 TmpColor[0][i * 3] = GetRValue(ts->VTColor[i]);
2582 TmpColor[0][i * 3 + 1] = GetGValue(ts->VTColor[i]);
2583 TmpColor[0][i * 3 + 2] = GetBValue(ts->VTColor[i]);
2584 }
2585 else {
2586 TmpColor[0][i * 3] = GetRValue(ts->VTReverseColor[i]);
2587 TmpColor[0][i * 3 + 1] = GetGValue(ts->VTReverseColor[i]);
2588 TmpColor[0][i * 3 + 2] = GetBValue(ts->VTReverseColor[i]);
2589 }
2590 }
2591 WriteInt6(Section, "VTReverseColor", FName,
2592 TmpColor[0][0], TmpColor[0][1], TmpColor[0][2],
2593 TmpColor[0][3], TmpColor[0][4], TmpColor[0][5]);
2594
2595 WriteOnOff(Section, "EnableClickableUrl", FName,
2596 ts->EnableClickableUrl);
2597
2598 /* URL color */
2599 for (i = 0; i <= 1; i++) {
2600 if (ts->ColorFlag & CF_REVERSEVIDEO) {
2601 TmpColor[0][i * 3] = GetRValue(ts->URLColor[!i]);
2602 TmpColor[0][i * 3 + 1] = GetGValue(ts->URLColor[!i]);
2603 TmpColor[0][i * 3 + 2] = GetBValue(ts->URLColor[!i]);
2604 }
2605 else {
2606 TmpColor[0][i * 3] = GetRValue(ts->URLColor[i]);
2607 TmpColor[0][i * 3 + 1] = GetGValue(ts->URLColor[i]);
2608 TmpColor[0][i * 3 + 2] = GetBValue(ts->URLColor[i]);
2609 }
2610 }
2611 WriteInt6(Section, "URLColor", FName,
2612 TmpColor[0][0], TmpColor[0][1], TmpColor[0][2],
2613 TmpColor[0][3], TmpColor[0][4], TmpColor[0][5]);
2614
2615 WriteOnOff(Section, "EnableBoldAttrColor", FName,
2616 (WORD) (ts->ColorFlag & CF_BOLDCOLOR));
2617
2618 WriteOnOff(Section, "EnableBlinkAttrColor", FName,
2619 (WORD) (ts->ColorFlag & CF_BLINKCOLOR));
2620
2621 WriteOnOff(Section, "EnableReverseAttrColor", FName,
2622 (WORD) (ts->ColorFlag & CF_REVERSECOLOR));
2623
2624 WriteOnOff(Section, "EnableURLColor", FName,
2625 (WORD) (ts->ColorFlag & CF_URLCOLOR));
2626
2627 WriteOnOff(Section, "URLUnderline", FName,
2628 (WORD) (ts->FontFlag & FF_URLUNDERLINE));
2629
2630 WriteOnOff(Section, "EnableANSIColor", FName,
2631 (WORD) (ts->ColorFlag & CF_ANSICOLOR));
2632
2633 /* TEK Color */
2634 for (i = 0; i <= 1; i++) {
2635 TmpColor[0][i * 3] = GetRValue(ts->TEKColor[i]);
2636 TmpColor[0][i * 3 + 1] = GetGValue(ts->TEKColor[i]);
2637 TmpColor[0][i * 3 + 2] = GetBValue(ts->TEKColor[i]);
2638 }
2639 WriteInt6(Section, "TEKColor", FName,
2640 TmpColor[0][0], TmpColor[0][1], TmpColor[0][2],
2641 TmpColor[0][3], TmpColor[0][4], TmpColor[0][5]);
2642
2643 /* TEK color emulation */
2644 WriteOnOff(Section, "TEKColorEmulation", FName, ts->TEKColorEmu);
2645
2646 /* VT Font */
2647 WriteFont(Section, "VTFont", FName,
2648 ts->VTFont, ts->VTFontSize.x, ts->VTFontSize.y,
2649 ts->VTFontCharSet);
2650
2651 /* Enable bold font flag */
2652 WriteOnOff(Section, "EnableBold", FName,
2653 (WORD) (ts->FontFlag & FF_BOLD));
2654
2655 /* TEK Font */
2656 WriteFont(Section, "TEKFont", FName,
2657 ts->TEKFont, ts->TEKFontSize.x, ts->TEKFontSize.y,
2658 ts->TEKFontCharSet);
2659
2660 /* BS key */
2661 if (ts->BSKey == IdDEL)
2662 strncpy_s(Temp, sizeof(Temp), "DEL", _TRUNCATE);
2663 else
2664 strncpy_s(Temp, sizeof(Temp), "BS", _TRUNCATE);
2665 WritePrivateProfileString(Section, "BSKey", Temp, FName);
2666
2667 /* Delete key */
2668 WriteOnOff(Section, "DeleteKey", FName, ts->DelKey);
2669
2670 /* Meta key */
2671 switch (ts->MetaKey) {
2672 case 1:
2673 strncpy_s(Temp, sizeof(Temp), "on", _TRUNCATE);
2674 break;
2675 case 2:
2676 strncpy_s(Temp, sizeof(Temp), "left", _TRUNCATE);
2677 break;
2678 case 3:
2679 strncpy_s(Temp, sizeof(Temp), "right", _TRUNCATE);
2680 break;
2681 default:
2682 strncpy_s(Temp, sizeof(Temp), "off", _TRUNCATE);
2683 }
2684 WritePrivateProfileString(Section, "Metakey", Temp, FName);
2685
2686 /* Application Keypad */
2687 WriteOnOff(Section, "DisableAppKeypad", FName, ts->DisableAppKeypad);
2688
2689 /* Application Cursor */
2690 WriteOnOff(Section, "DisableAppCursor", FName, ts->DisableAppCursor);
2691
2692 /* Russian keyboard type */
2693 id2str(RussList2, ts->RussKeyb, IdWindows, Temp, sizeof(Temp));
2694 WritePrivateProfileString(Section, "RussKeyb", Temp, FName);
2695
2696 /* Serial port ID */
2697 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->ComPort);
2698 WritePrivateProfileString(Section, "ComPort", Temp, FName);
2699
2700 /* Baud rate */
2701 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->Baud);
2702 WritePrivateProfileString(Section, "BaudRate", Temp, FName);
2703
2704 /* Parity */
2705 if (!SerialPortConfconvertId2Str(COM_PARITY, ts->Parity, Temp, sizeof(Temp))) {
2706 strncpy_s(Temp, sizeof(Temp), "none", _TRUNCATE);
2707 }
2708 WritePrivateProfileString(Section, "Parity", Temp, FName);
2709
2710 /* Data bit */
2711 if (!SerialPortConfconvertId2Str(COM_DATABIT, ts->DataBit, Temp, sizeof(Temp))) {
2712 strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
2713 }
2714 WritePrivateProfileString(Section, "DataBit", Temp, FName);
2715
2716 /* Stop bit */
2717 if (!SerialPortConfconvertId2Str(COM_STOPBIT, ts->StopBit, Temp, sizeof(Temp))) {
2718 strncpy_s(Temp, sizeof(Temp), "1", _TRUNCATE);
2719 }
2720 WritePrivateProfileString(Section, "StopBit", Temp, FName);
2721
2722 /* Flow control */
2723 if (!SerialPortConfconvertId2Str(COM_FLOWCTRL, ts->Flow, Temp, sizeof(Temp))) {
2724 strncpy_s(Temp, sizeof(Temp), "none", _TRUNCATE);
2725 }
2726 WritePrivateProfileString(Section, "FlowCtrl", Temp, FName);
2727
2728 /* Delay per character */
2729 WriteInt(Section, "DelayPerChar", FName, ts->DelayPerChar);
2730
2731 /* Delay per line */
2732 WriteInt(Section, "DelayPerLine", FName, ts->DelayPerLine);
2733
2734 /* Telnet flag */
2735 WriteOnOff(Section, "Telnet", FName, ts->Telnet);
2736
2737 /* Telnet terminal type */
2738 WritePrivateProfileString(Section, "TermType", ts->TermType, FName);
2739
2740 /* TCP port num for non-telnet */
2741 WriteUint(Section, "TCPPort", FName, ts->TCPPort);
2742
2743 /* Auto close flag */
2744 WriteOnOff(Section, "AutoWinClose", FName, ts->AutoWinClose);
2745
2746 /* History list */
2747 WriteOnOff(Section, "Historylist", FName, ts->HistoryList);
2748
2749 /* File transfer binary flag */
2750 WriteOnOff(Section, "TransBin", FName, ts->TransBin);
2751
2752 /* Log binary flag */
2753 WriteOnOff(Section, "LogBinary", FName, ts->LogBinary);
2754
2755 /* Log append */
2756 WriteOnOff(Section, "LogAppend", FName, ts->Append);
2757
2758 /* Log plain text flag */
2759 WriteOnOff(Section, "LogTypePlainText", FName, ts->LogTypePlainText);
2760
2761 /* Log with timestamp (2006.7.23 maya) */
2762 WriteOnOff(Section, "LogTimestamp", FName, ts->LogTimestamp);
2763
2764 /* Log without transfer dialog */
2765 WriteOnOff(Section, "LogHideDialog", FName, ts->LogHideDialog);
2766
2767 WriteOnOff(Section, "LogIncludeScreenBuffer", FName, ts->LogAllBuffIncludedInFirst);
2768
2769 /* Timestamp format of Log each line */
2770 WritePrivateProfileString(Section, "LogTimestampFormat",
2771 ts->LogTimestampFormat, FName);
2772
2773 /* Timestamp type */
2774 switch (ts->LogTimestampType) {
2775 case TIMESTAMP_LOCAL:
2776 WritePrivateProfileString(Section, "LogTimestampType", "Local", FName);
2777 break;
2778 case TIMESTAMP_UTC:
2779 WritePrivateProfileString(Section, "LogTimestampType", "UTC", FName);
2780 break;
2781 case TIMESTAMP_ELAPSED_LOGSTART:
2782 WritePrivateProfileString(Section, "LogTimestampType", "LoggingElapsed", FName);
2783 break;
2784 case TIMESTAMP_ELAPSED_CONNECTED:
2785 WritePrivateProfileString(Section, "LogTimestampType", "ConnectionElapsed", FName);
2786 break;
2787 }
2788
2789 /* Default Log file name (2006.8.28 maya) */
2790 WritePrivateProfileString(Section, "Log