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 9618 - (show annotations) (download) (as text)
Thu Dec 23 13:19:06 2021 UTC (2 years, 3 months ago) by zmatsuo
File MIME type: text/x-csrc
File size: 136115 byte(s)
ダウンロードフォルダをUnicode化

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