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