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 9858 - (show annotations) (download) (as text)
Tue Apr 12 13:21:35 2022 UTC (23 months, 4 weeks ago) by zmatsuo
File MIME type: text/x-csrc
File size: 136475 byte(s)
ログフォルダをUnicode化

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