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 9941 - (show annotations) (download) (as text)
Sat May 21 13:55:57 2022 UTC (22 months, 3 weeks ago) by zmatsuo
File MIME type: text/x-csrc
File size: 136443 byte(s)
TTTSet.TmpColor を使用しないようにした

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