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 9789 - (show annotations) (download) (as text)
Tue Mar 8 14:36:45 2022 UTC (2 years, 1 month ago) by zmatsuo
File MIME type: text/x-csrc
File size: 136037 byte(s)
コンパイラ警告、ビルドに失敗する場合があったので修正

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