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 9432 - (show annotations) (download) (as text)
Sun Sep 19 15:14:27 2021 UTC (2 years, 6 months ago) by zmatsuo
File MIME type: text/x-csrc
File size: 139350 byte(s)
plugin AddValueToList() を利用しているところを Unicode化

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