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