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 9429 - (show annotations) (download) (as text)
Sun Sep 19 15:13:51 2021 UTC (2 years, 6 months ago) by zmatsuo
File MIME type: text/x-csrc
File size: 139798 byte(s)
plugin iniファイルの読み書きをUnicode化

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