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 8279 - (show annotations) (download) (as text)
Tue Oct 8 14:38:32 2019 UTC (4 years, 6 months ago) by zmatsuo
File MIME type: text/x-csrc
File size: 144116 byte(s)
ttpfile.dllのSerialPortConfconvertId2Str()のexport方法を変更

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