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 10150 - (show annotations) (download) (as text)
Sat Aug 13 14:01:35 2022 UTC (19 months, 4 weeks ago) by zmatsuo
File MIME type: text/x-csrc
File size: 139785 byte(s)
ダイアログフォント名をUnicode化した

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