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 9497 - (show annotations) (download) (as text)
Sat Oct 23 16:09:33 2021 UTC (2 years, 5 months ago) by zmatsuo
File MIME type: text/x-csrc
File size: 139126 byte(s)
RussFontを削除、RussHost を KanjiCode に置き換え

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