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 6921 - (show annotations) (download) (as text)
Sat Aug 26 15:04:49 2017 UTC (6 years, 7 months ago) by maya
File MIME type: text/x-csrc
File size: 137888 byte(s)
PrnConvFF の読み込み・保存に対応していない問題を修正

https://ja.osdn.net/ticket/browse.php?group_id=1412&tid=37452
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 /* Disable (convert to NL) Form Feed when printing */
1346 /* --- special option */
1347 ts->PrnConvFF =
1348 GetOnOff(Section, "PrnConvFF", FName, FALSE);
1349
1350 /* Quick-VAN log -- special option */
1351 if (GetOnOff(Section, "QVLog", FName, FALSE))
1352 ts->LogFlag |= LOG_QV;
1353
1354 /* Quick-VAN window size -- special */
1355 ts->QVWinSize = GetPrivateProfileInt(Section, "QVWinSize", 8, FName);
1356
1357 /* Russian character set (print) -- special option */
1358 GetPrivateProfileString(Section, "RussPrint", "",
1359 Temp, sizeof(Temp), FName);
1360 ts->RussPrint = str2id(RussList, Temp, IdWindows);
1361
1362 /* Scroll threshold -- special option */
1363 ts->ScrollThreshold =
1364 GetPrivateProfileInt(Section, "ScrollThreshold", 12, FName);
1365
1366 ts->MouseWheelScrollLine =
1367 GetPrivateProfileInt(Section, "MouseWheelScrollLine", 3, FName);
1368
1369 // Select on activate -- special option
1370 ts->SelOnActive = GetOnOff(Section, "SelectOnActivate", FName, TRUE);
1371
1372 /* Send 8bit control sequence -- special option */
1373 ts->Send8BitCtrl = GetOnOff(Section, "Send8BitCtrl", FName, FALSE);
1374
1375 /* SendBreak time (in msec) -- special option */
1376 ts->SendBreakTime =
1377 GetPrivateProfileInt(Section, "SendBreakTime", 1000, FName);
1378
1379 /* Startup macro -- special option */
1380 GetPrivateProfileString(Section, "StartupMacro", "",
1381 ts->MacroFN, sizeof(ts->MacroFN), FName);
1382
1383 /* TEK GIN Mouse keycode -- special option */
1384 ts->GINMouseCode =
1385 GetPrivateProfileInt(Section, "TEKGINMouseCode", 32, FName);
1386
1387 /* Telnet Auto Detect -- special option */
1388 ts->TelAutoDetect = GetOnOff(Section, "TelAutoDetect", FName, TRUE);
1389
1390 /* Telnet binary flag -- special option */
1391 ts->TelBin = GetOnOff(Section, "TelBin", FName, FALSE);
1392
1393 /* Telnet Echo flag -- special option */
1394 ts->TelEcho = GetOnOff(Section, "TelEcho", FName, FALSE);
1395
1396 /* Telnet log -- special option */
1397 if (GetOnOff(Section, "TelLog", FName, FALSE))
1398 ts->LogFlag |= LOG_TEL;
1399
1400 /* TCP port num for telnet -- special option */
1401 ts->TelPort = GetPrivateProfileInt(Section, "TelPort", 23, FName);
1402
1403 /* Telnet keep-alive packet(NOP command) interval -- special option */
1404 ts->TelKeepAliveInterval =
1405 GetPrivateProfileInt(Section, "TelKeepAliveInterval", 300, FName);
1406
1407 /* Max number of broadcast commad history */
1408 ts->MaxBroadcatHistory =
1409 GetPrivateProfileInt(Section, "MaxBroadcatHistory", 99, FName);
1410
1411 /* Local echo for non-telnet */
1412 ts->TCPLocalEcho = GetOnOff(Section, "TCPLocalEcho", FName, FALSE);
1413
1414 /* "new-line (transmit)" option for non-telnet -- special option */
1415 GetPrivateProfileString(Section, "TCPCRSend", "",
1416 Temp, sizeof(Temp), FName);
1417 if (_stricmp(Temp, "CR") == 0)
1418 ts->TCPCRSend = IdCR;
1419 else if (_stricmp(Temp, "CRLF") == 0)
1420 ts->TCPCRSend = IdCRLF;
1421 else
1422 ts->TCPCRSend = 0; // disabled
1423
1424 /* Use text (background) color for "white (black)" --- special option */
1425 if (GetOnOff(Section, "UseTextColor", FName, FALSE))
1426 ts->ColorFlag |= CF_USETEXTCOLOR;
1427
1428 /* Title format -- special option */
1429 ts->TitleFormat =
1430 GetPrivateProfileInt(Section, "TitleFormat", 13, FName);
1431
1432 /* VT Compatible Tab -- special option */
1433 ts->VTCompatTab = GetOnOff(Section, "VTCompatTab", FName, FALSE);
1434
1435 /* VT Font space --- special option */
1436 GetPrivateProfileString(Section, "VTFontSpace", "0,0,0,0",
1437 Temp, sizeof(Temp), FName);
1438 GetNthNum(Temp, 1, &ts->FontDX);
1439 GetNthNum(Temp, 2, &ts->FontDW);
1440 GetNthNum(Temp, 3, &ts->FontDY);
1441 GetNthNum(Temp, 4, &ts->FontDH);
1442 if (ts->FontDX < 0)
1443 ts->FontDX = 0;
1444 if (ts->FontDW < 0)
1445 ts->FontDW = 0;
1446 ts->FontDW = ts->FontDW + ts->FontDX;
1447 if (ts->FontDY < 0)
1448 ts->FontDY = 0;
1449 if (ts->FontDH < 0)
1450 ts->FontDH = 0;
1451 ts->FontDH = ts->FontDH + ts->FontDY;
1452
1453 // VT-print scaling factors (pixels per inch) --- special option
1454 GetPrivateProfileString(Section, "VTPPI", "0,0",
1455 Temp, sizeof(Temp), FName);
1456 GetNthNum(Temp, 1, (int far *) &ts->VTPPI.x);
1457 GetNthNum(Temp, 2, (int far *) &ts->VTPPI.y);
1458
1459 // TEK-print scaling factors (pixels per inch) --- special option
1460 GetPrivateProfileString(Section, "TEKPPI", "0,0",
1461 Temp, sizeof(Temp), FName);
1462 GetNthNum(Temp, 1, (int far *) &ts->TEKPPI.x);
1463 GetNthNum(Temp, 2, (int far *) &ts->TEKPPI.y);
1464
1465 // Show "Window" menu -- special option
1466 if (GetOnOff(Section, "WindowMenu", FName, TRUE))
1467 ts->MenuFlag |= MF_SHOWWINMENU;
1468
1469 /* XMODEM log -- special option */
1470 if (GetOnOff(Section, "XmodemLog", FName, FALSE))
1471 ts->LogFlag |= LOG_X;
1472
1473 /* YMODEM log -- special option */
1474 if (GetOnOff(Section, "YmodemLog", FName, FALSE))
1475 ts->LogFlag |= LOG_Y;
1476
1477 /* YMODEM ���M�R�}���h (2010.3.23 yutaka) */
1478 GetPrivateProfileString(Section, "YModemRcvCommand", "rb",
1479 ts->YModemRcvCommand, sizeof(ts->YModemRcvCommand), FName);
1480
1481 /* Auto ZMODEM activation -- special option */
1482 if (GetOnOff(Section, "ZmodemAuto", FName, FALSE))
1483 ts->FTFlag |= FT_ZAUTO;
1484
1485 /* ZMODEM data subpacket length for sending -- special */
1486 ts->ZmodemDataLen =
1487 GetPrivateProfileInt(Section, "ZmodemDataLen", 1024, FName);
1488 /* ZMODEM window size for sending -- special */
1489 ts->ZmodemWinSize =
1490 GetPrivateProfileInt(Section, "ZmodemWinSize", 32767, FName);
1491
1492 /* ZMODEM ESCCTL flag -- special option */
1493 if (GetOnOff(Section, "ZmodemEscCtl", FName, FALSE))
1494 ts->FTFlag |= FT_ZESCCTL;
1495
1496 /* ZMODEM log -- special option */
1497 if (GetOnOff(Section, "ZmodemLog", FName, FALSE))
1498 ts->LogFlag |= LOG_Z;
1499
1500 /* ZMODEM ���M�R�}���h (2007.12.21 yutaka) */
1501 GetPrivateProfileString(Section, "ZModemRcvCommand", "rz",
1502 ts->ZModemRcvCommand, sizeof(ts->ZModemRcvCommand), FName);
1503
1504 /* Enable continued-line copy -- special option */
1505 ts->EnableContinuedLineCopy =
1506 GetOnOff(Section, "EnableContinuedLineCopy", FName, FALSE);
1507
1508 if (GetOnOff(Section, "DisablePasteMouseRButton", FName, FALSE))
1509 ts->PasteFlag |= CPF_DISABLE_RBUTTON;
1510
1511 if (GetOnOff(Section, "DisablePasteMouseMButton", FName, TRUE))
1512 ts->PasteFlag |= CPF_DISABLE_MBUTTON;
1513
1514 if (GetOnOff(Section, "ConfirmPasteMouseRButton", FName, FALSE))
1515 ts->PasteFlag |= CPF_CONFIRM_RBUTTON;
1516
1517 if (GetOnOff(Section, "ConfirmChangePaste", FName, TRUE))
1518 ts->PasteFlag |= CPF_CONFIRM_CHANGEPASTE;
1519
1520 if (GetOnOff(Section, "ConfirmChangePasteCR", FName, TRUE))
1521 ts->PasteFlag |= CPF_CONFIRM_CHANGEPASTE_CR;
1522
1523 GetPrivateProfileString(Section, "ConfirmChangePasteStringFile", "",
1524 Temp, sizeof(Temp), FName);
1525
1526 strncpy_s(ts->ConfirmChangePasteStringFile, sizeof(ts->ConfirmChangePasteStringFile), Temp,
1527 _TRUNCATE);
1528
1529 // added ScrollWindowClearScreen (2008.5.3 yutaka)
1530 ts->ScrollWindowClearScreen =
1531 GetOnOff(Section, "ScrollWindowClearScreen", FName, TRUE);
1532
1533 // added SelectOnlyByLButton (2007.11.20 maya)
1534 ts->SelectOnlyByLButton =
1535 GetOnOff(Section, "SelectOnlyByLButton", FName, TRUE);
1536
1537 // added DisableAcceleratorSendBreak (2007.3.17 maya)
1538 ts->DisableAcceleratorSendBreak =
1539 GetOnOff(Section, "DisableAcceleratorSendBreak", FName, FALSE);
1540
1541 // WinSock connecting timeout value (2007.1.11 yutaka)
1542 ts->ConnectingTimeout =
1543 GetPrivateProfileInt(Section, "ConnectingTimeout", 0, FName);
1544
1545 // mouse cursor
1546 GetPrivateProfileString(Section, "MouseCursor", "IBEAM",
1547 Temp, sizeof(Temp), FName);
1548 strncpy_s(ts->MouseCursorName, sizeof(ts->MouseCursorName), Temp,
1549 _TRUNCATE);
1550
1551 // Translucent window
1552 ts->AlphaBlend =
1553 GetPrivateProfileInt(Section, "AlphaBlend ", 255, FName);
1554 ts->AlphaBlend = max(0, ts->AlphaBlend);
1555 ts->AlphaBlend = min(255, ts->AlphaBlend);
1556
1557 // Cygwin install path
1558 GetPrivateProfileString(Section, "CygwinDirectory ", "c:\\cygwin",
1559 Temp, sizeof(Temp), FName);
1560 strncpy_s(ts->CygwinDirectory, sizeof(ts->CygwinDirectory), Temp,
1561 _TRUNCATE);
1562
1563 // Viewlog Editor path
1564 if (GetWindowsDirectory(Temp, sizeof(Temp)) + 13 < sizeof(Temp)) { // "\\notepad.exe"(12) + NUL(1)
1565 strncat_s(Temp, sizeof(Temp), "\\notepad.exe", _TRUNCATE);
1566 }
1567 else {
1568 Temp[0] = '\0';
1569 }
1570 GetPrivateProfileString(Section, "ViewlogEditor ", Temp,
1571 ts->ViewlogEditor, sizeof(ts->ViewlogEditor), FName);
1572
1573 // Locale for UTF-8
1574 GetPrivateProfileString(Section, "Locale ", DEFAULT_LOCALE,
1575 Temp, sizeof(Temp), FName);
1576 strncpy_s(ts->Locale, sizeof(ts->Locale), Temp, _TRUNCATE);
1577
1578 // CodePage
1579 ts->CodePage =
1580 GetPrivateProfileInt(Section, "CodePage ", DEFAULT_CODEPAGE,
1581 FName);
1582
1583 // UI language message file
1584 GetPrivateProfileString(Section, "UILanguageFile", "lang\\Default.lng",
1585 Temp, sizeof(Temp), FName);
1586 {
1587 char CurDir[MAX_PATH];
1588
1589 // �t���p�X�������O������������������������������
1590 strncpy_s(ts->UILanguageFile_ini, sizeof(ts->UILanguageFile_ini), Temp, _TRUNCATE);
1591
1592 GetCurrentDirectory(sizeof(CurDir), CurDir);
1593 SetCurrentDirectory(ts->HomeDir);
1594 _fullpath(ts->UILanguageFile, Temp, sizeof(ts->UILanguageFile));
1595 SetCurrentDirectory(CurDir);
1596 }
1597
1598 // Broadcast Command History (2007.3.3 maya)
1599 ts->BroadcastCommandHistory =
1600 GetOnOff(Section, "BroadcastCommandHistory", FName, FALSE);
1601
1602 // 337: 2007/03/20 Accept Broadcast
1603 ts->AcceptBroadcast =
1604 GetOnOff(Section, "AcceptBroadcast", FName, TRUE);
1605
1606 // Confirm send a file when drag and drop (2007.12.28 maya)
1607 ts->ConfirmFileDragAndDrop =
1608 GetOnOff(Section, "ConfirmFileDragAndDrop", FName, TRUE);
1609
1610 // Translate mouse wheel to cursor key when application cursor mode
1611 ts->TranslateWheelToCursor =
1612 GetOnOff(Section, "TranslateWheelToCursor", FName, TRUE);
1613
1614 // Display "New Connection" dialog on startup (2008.1.18 maya)
1615 ts->HostDialogOnStartup =
1616 GetOnOff(Section, "HostDialogOnStartup", FName, TRUE);
1617
1618 // Mouse event tracking
1619 ts->MouseEventTracking =
1620 GetOnOff(Section, "MouseEventTracking", FName, TRUE);
1621
1622 // Maximized bug tweak
1623 GetPrivateProfileString(Section, "MaximizedBugTweak", "2", Temp,
1624 sizeof(Temp), FName);
1625 if (_stricmp(Temp, "on") == 0) {
1626 ts->MaximizedBugTweak = 2;
1627 }
1628 else {
1629 ts->MaximizedBugTweak = atoi(Temp);
1630 }
1631
1632 // Convert Unicode symbol characters to DEC Special characters
1633 ts->UnicodeDecSpMapping =
1634 GetPrivateProfileInt(Section, "UnicodeToDecSpMapping", 3, FName);
1635
1636 // VT Window Icon
1637 GetPrivateProfileString(Section, "VTIcon", "Default",
1638 Temp, sizeof(Temp), FName);
1639 ts->VTIcon = IconName2IconId(Temp);
1640
1641 // Tek Window Icon
1642 GetPrivateProfileString(Section, "TEKIcon", "Default",
1643 Temp, sizeof(Temp), FName);
1644 ts->TEKIcon = IconName2IconId(Temp);
1645
1646 // Unknown Unicode Character
1647 ts->UnknownUnicodeCharaAsWide =
1648 GetOnOff(Section, "UnknownUnicodeCharacterAsWide", FName, FALSE);
1649
1650 #ifdef USE_NORMAL_BGCOLOR
1651 // UseNormalBGColor
1652 ts->UseNormalBGColor =
1653 GetOnOff(Section, "UseNormalBGColor", FName, FALSE);
1654 // 2006/03/11 by 337
1655 if (ts->UseNormalBGColor) {
1656 ts->VTBoldColor[1] =
1657 ts->VTBlinkColor[1] = ts->URLColor[1] = ts->VTColor[1];
1658 }
1659 #endif
1660
1661 // AutoScrollOnlyInBottomLine
1662 ts->AutoScrollOnlyInBottomLine =
1663 GetOnOff(Section, "AutoScrollOnlyInBottomLine", FName, FALSE);
1664
1665 // Accept remote-controlled window title changing
1666 GetPrivateProfileString(Section, "AcceptTitleChangeRequest", "overwrite",
1667 Temp, sizeof(Temp), FName);
1668 if (_stricmp(Temp, "overwrite") == 0 || _stricmp(Temp, "on") == 0)
1669 ts->AcceptTitleChangeRequest = IdTitleChangeRequestOverwrite;
1670 else if (_stricmp(Temp, "ahead") == 0)
1671 ts->AcceptTitleChangeRequest = IdTitleChangeRequestAhead;
1672 else if (_stricmp(Temp, "last") == 0)
1673 ts->AcceptTitleChangeRequest = IdTitleChangeRequestLast;
1674 else
1675 ts->AcceptTitleChangeRequest = IdTitleChangeRequestOff;
1676
1677 // Size of paste confirm dialog
1678 GetPrivateProfileString(Section, "PasteDialogSize", "330,220",
1679 Temp, sizeof(Temp), FName);
1680 GetNthNum(Temp, 1, &ts->PasteDialogSize.cx);
1681 GetNthNum(Temp, 2, &ts->PasteDialogSize.cy);
1682 if (ts->PasteDialogSize.cx < 0)
1683 ts->PasteDialogSize.cx = 330;
1684 if (ts->PasteDialogSize.cy < 0)
1685 ts->PasteDialogSize.cy = 220;
1686
1687 // Disable mouse event tracking when Control-Key is pressed.
1688 ts->DisableMouseTrackingByCtrl =
1689 GetOnOff(Section, "DisableMouseTrackingByCtrl", FName, TRUE);
1690
1691 // Disable TranslateWheelToCursor setting when Control-Key is pressed.
1692 ts->DisableWheelToCursorByCtrl =
1693 GetOnOff(Section, "DisableWheelToCursorByCtrl", FName, TRUE);
1694
1695 // Strict Key Mapping.
1696 ts->StrictKeyMapping =
1697 GetOnOff(Section, "StrictKeyMapping", FName, FALSE);
1698
1699 // added Wait4allMacroCommand (2009.3.23 yutaka)
1700 ts->Wait4allMacroCommand =
1701 GetOnOff(Section, "Wait4allMacroCommand", FName, FALSE);
1702
1703 // added DisableMenuSendBreak (2009.4.6 maya)
1704 ts->DisableMenuSendBreak =
1705 GetOnOff(Section, "DisableMenuSendBreak", FName, FALSE);
1706
1707 // added ClearScreenOnCloseConnection (2009.4.6 maya)
1708 ts->ClearScreenOnCloseConnection =
1709 GetOnOff(Section, "ClearScreenOnCloseConnection", FName, FALSE);
1710
1711 // added DisableAcceleratorDuplicateSession (2009.4.6 maya)
1712 ts->DisableAcceleratorDuplicateSession =
1713 GetOnOff(Section, "DisableAcceleratorDuplicateSession", FName, FALSE);
1714
1715 ts->AcceleratorNewConnection =
1716 GetOnOff(Section, "AcceleratorNewConnection", FName, TRUE);
1717
1718 ts->AcceleratorCygwinConnection =
1719 GetOnOff(Section, "AcceleratorCygwinConnection", FName, TRUE);
1720
1721 // added DisableMenuDuplicateSession (2010.8.3 maya)
1722 ts->DisableMenuDuplicateSession =
1723 GetOnOff(Section, "DisableMenuDuplicateSession", FName, FALSE);
1724
1725 // added DisableMenuNewConnection (2010.8.4 maya)
1726 ts->DisableMenuNewConnection =
1727 GetOnOff(Section, "DisableMenuNewConnection", FName, FALSE);
1728
1729 // added PasteDelayPerLine (2009.4.12 maya)
1730 ts->PasteDelayPerLine =
1731 GetPrivateProfileInt(Section, "PasteDelayPerLine", 10, FName);
1732 {
1733 int tmp = min(max(0, ts->PasteDelayPerLine), 5000);
1734 ts->PasteDelayPerLine = tmp;
1735 }
1736
1737 // Font scaling -- test
1738 ts->FontScaling = GetOnOff(Section, "FontScaling", FName, FALSE);
1739
1740 // Meta sets MSB
1741 GetPrivateProfileString(Section, "Meta8Bit", "off", Temp, sizeof(Temp), FName);
1742 if (_stricmp(Temp, "raw") == 0 || _stricmp(Temp, "on") == 0)
1743 ts->Meta8Bit = IdMeta8BitRaw;
1744 else if (_stricmp(Temp, "text") == 0)
1745 ts->Meta8Bit = IdMeta8BitText;
1746 else
1747 ts->Meta8Bit = IdMeta8BitOff;
1748
1749 // Window control sequence
1750 if (GetOnOff(Section, "WindowCtrlSequence", FName, TRUE))
1751 ts->WindowFlag |= WF_WINDOWCHANGE;
1752
1753 // Cursor control sequence
1754 if (GetOnOff(Section, "CursorCtrlSequence", FName, FALSE))
1755 ts->WindowFlag |= WF_CURSORCHANGE;
1756
1757 // Window report sequence
1758 if (GetOnOff(Section, "WindowReportSequence", FName, TRUE))
1759 ts->WindowFlag |= WF_WINDOWREPORT;
1760
1761 // Title report sequence
1762 GetPrivateProfileString(Section, "TitleReportSequence", "Empty", Temp, sizeof(Temp), FName);
1763 if (_stricmp(Temp, "accept") == 0)
1764 ts->WindowFlag |= IdTitleReportAccept;
1765 else if (_stricmp(Temp, "ignore") == 0 || _stricmp(Temp, "off") == 0)
1766 ts->WindowFlag &= ~WF_TITLEREPORT;
1767 else // empty
1768 ts->WindowFlag |= IdTitleReportEmpty;
1769
1770 // Line at a time mode
1771 ts->EnableLineMode = GetOnOff(Section, "EnableLineMode", FName, TRUE);
1772
1773 // Clear window on resize
1774 if (GetOnOff(Section, "ClearOnResize", FName, TRUE))
1775 ts->TermFlag |= TF_CLEARONRESIZE;
1776
1777 // Alternate Screen Buffer
1778 if (GetOnOff(Section, "AlternateScreenBuffer", FName, TRUE))
1779 ts->TermFlag |= TF_ALTSCR;
1780
1781 // IME status related cursor style
1782 if (GetOnOff(Section, "IMERelatedCursor", FName, FALSE))
1783 ts->WindowFlag |= WF_IMECURSORCHANGE;
1784
1785 // Terminal Unique ID
1786 GetPrivateProfileString(Section, "TerminalUID", "FFFFFFFF", Temp, sizeof(Temp), FName);
1787 if (strlen(Temp) == 8) {
1788 for (i=0; i<8 && isxdigit((unsigned char)Temp[i]); i++) {
1789 if (islower(Temp[i])) {
1790 ts->TerminalUID[i] = toupper(Temp[i]);
1791 }
1792 else {
1793 ts->TerminalUID[i] = Temp[i];
1794 }
1795 }
1796 if (i == 8) {
1797 ts->TerminalUID[i] = 0;
1798 }
1799 else {
1800 strncpy_s(ts->TerminalUID, sizeof(ts->TerminalUID), "FFFFFFFF", _TRUNCATE);
1801 }
1802 }
1803 else {
1804 strncpy_s(ts->TerminalUID, sizeof(ts->TerminalUID), "FFFFFFFF", _TRUNCATE);
1805 }
1806
1807 // Lock Terminal UID
1808 if (GetOnOff(Section, "LockTUID", FName, TRUE))
1809 ts->TermFlag |= TF_LOCKTUID;
1810
1811 // Jump List
1812 ts->JumpList = GetOnOff(Section, "JumpList", FName, TRUE);
1813
1814 // TabStopModifySequence
1815 GetPrivateProfileString(Section, "TabStopModifySequence", "on", Temp, sizeof(Temp), FName);
1816 if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "all") == 0)
1817 ts->TabStopFlag = TABF_ALL;
1818 else if (_stricmp(Temp, "off") == 0 || _stricmp(Temp, "none") == 0)
1819 ts->TabStopFlag = TABF_NONE;
1820 else {
1821 ts->TabStopFlag = TABF_NONE;
1822 for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
1823 if (_stricmp(Temp2, "HTS") == 0)
1824 ts->TabStopFlag |= TABF_HTS;
1825 else if (_stricmp(Temp2, "HTS7") == 0)
1826 ts->TabStopFlag |= TABF_HTS7;
1827 else if (_stricmp(Temp2, "HTS8") == 0)
1828 ts->TabStopFlag |= TABF_HTS8;
1829 else if (_stricmp(Temp2, "TBC") == 0)
1830 ts->TabStopFlag |= TABF_TBC;
1831 else if (_stricmp(Temp2, "TBC0") == 0)
1832 ts->TabStopFlag |= TABF_TBC0;
1833 else if (_stricmp(Temp2, "TBC3") == 0)
1834 ts->TabStopFlag |= TABF_TBC3;
1835 }
1836 }
1837
1838 // Clipboard Access from Remote
1839 GetPrivateProfileString(Section, "ClipboardAccessFromRemote", "off", Temp, sizeof(Temp), FName);
1840 if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "readwrite") == 0)
1841 ts->CtrlFlag |= CSF_CBRW;
1842 else if (_stricmp(Temp, "read") == 0)
1843 ts->CtrlFlag |= CSF_CBREAD;
1844 else if (_stricmp(Temp, "write") == 0)
1845 ts->CtrlFlag |= CSF_CBWRITE;
1846
1847 // Notify Clipboard Access from Remote
1848 ts->NotifyClipboardAccess = GetOnOff(Section, "NotifyClipboardAccess", FName, TRUE);
1849
1850 // Use invalid DECRPSS (for testing)
1851 if (GetOnOff(Section, "UseInvalidDECRQSSResponse", FName, FALSE))
1852 ts->TermFlag |= TF_INVALIDDECRPSS;
1853
1854 // ClickableUrlBrowser
1855 GetPrivateProfileString(Section, "ClickableUrlBrowser", "",
1856 ts->ClickableUrlBrowser, sizeof(ts->ClickableUrlBrowser), FName);
1857 GetPrivateProfileString(Section, "ClickableUrlBrowserArg", "",
1858 ts->ClickableUrlBrowserArg, sizeof(ts->ClickableUrlBrowserArg), FName);
1859
1860 // Exclusive Lock when open the log file
1861 ts->LogLockExclusive = GetOnOff(Section, "LogLockExclusive", FName, TRUE);
1862
1863 // Font quality
1864 GetPrivateProfileString(Section, "FontQuality", "default",
1865 Temp, sizeof(Temp), FName);
1866 if (_stricmp(Temp, "nonantialiased") == 0)
1867 ts->FontQuality = NONANTIALIASED_QUALITY;
1868 else if (_stricmp(Temp, "antialiased") == 0)
1869 ts->FontQuality = ANTIALIASED_QUALITY;
1870 else if (_stricmp(Temp, "cleartype") == 0)
1871 ts->FontQuality = CLEARTYPE_QUALITY;
1872 else
1873 ts->FontQuality = DEFAULT_QUALITY;
1874
1875 // Beep Over Used
1876 ts->BeepOverUsedCount =
1877 GetPrivateProfileInt(Section, "BeepOverUsedCount", 5, FName);
1878 ts->BeepOverUsedTime =
1879 GetPrivateProfileInt(Section, "BeepOverUsedTime", 2, FName);
1880 ts->BeepSuppressTime =
1881 GetPrivateProfileInt(Section, "BeepSuppressTime", 5, FName);
1882
1883 // Max OSC string buffer size
1884 ts->MaxOSCBufferSize =
1885 GetPrivateProfileInt(Section, "MaxOSCBufferSize", 4096, FName);
1886
1887 ts->JoinSplitURL = GetOnOff(Section, "JoinSplitURL", FName, FALSE);
1888
1889 GetPrivateProfileString(Section, "JoinSplitURLIgnoreEOLChar", "\\", Temp, sizeof(Temp), FName);
1890 ts->JoinSplitURLIgnoreEOLChar = Temp[0];
1891
1892 // Debug modes.
1893 GetPrivateProfileString(Section, "DebugModes", "all", Temp, sizeof(Temp), FName);
1894 if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "all") == 0)
1895 ts->DebugModes = DBGF_ALL;
1896 else if (_stricmp(Temp, "off") == 0 || _stricmp(Temp, "none") == 0) {
1897 ts->DebugModes = DBGF_NONE;
1898 ts->Debug = FALSE;
1899 }
1900 else {
1901 ts->DebugModes = DBGF_NONE;
1902 for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
1903 if (_stricmp(Temp2, "normal") == 0)
1904 ts->DebugModes |= DBGF_NORM;
1905 else if (_stricmp(Temp2, "hex") == 0)
1906 ts->DebugModes |= DBGF_HEXD;
1907 else if (_stricmp(Temp2, "noout") == 0)
1908 ts->DebugModes |= DBGF_NOUT;
1909 }
1910 if (ts->DebugModes == DBGF_NONE)
1911 ts->Debug = FALSE;
1912 }
1913
1914 // Xmodem Timeout
1915 GetPrivateProfileString(Section, "XmodemTimeouts", "10,3,10,20,60", Temp, sizeof(Temp), FName);
1916 ts->XmodemTimeOutInit = GetNthNum2(Temp, 1, 10);
1917 if (ts->XmodemTimeOutInit < 1)
1918 ts->XmodemTimeOutInit = 1;
1919 ts->XmodemTimeOutInitCRC = GetNthNum2(Temp, 2, 3);
1920 if (ts->XmodemTimeOutInitCRC < 1)
1921 ts->XmodemTimeOutInitCRC = 1;
1922 ts->XmodemTimeOutShort = GetNthNum2(Temp, 3, 10);
1923 if (ts->XmodemTimeOutShort < 1)
1924 ts->XmodemTimeOutShort = 1;
1925 ts->XmodemTimeOutLong = GetNthNum2(Temp, 4, 20);
1926 if (ts->XmodemTimeOutLong < 1)
1927 ts->XmodemTimeOutLong = 1;
1928 ts->XmodemTimeOutVLong = GetNthNum2(Temp, 5, 60);
1929 if (ts->XmodemTimeOutVLong < 1)
1930 ts->XmodemTimeOutVLong = 1;
1931
1932 // Ymodem Timeout
1933 GetPrivateProfileString(Section, "YmodemTimeouts", "10,3,10,20,60", Temp, sizeof(Temp), FName);
1934 ts->YmodemTimeOutInit = GetNthNum2(Temp, 1, 10);
1935 if (ts->YmodemTimeOutInit < 1)
1936 ts->YmodemTimeOutInit = 1;
1937 ts->YmodemTimeOutInitCRC = GetNthNum2(Temp, 2, 3);
1938 if (ts->YmodemTimeOutInitCRC < 1)
1939 ts->YmodemTimeOutInitCRC = 1;
1940 ts->YmodemTimeOutShort = GetNthNum2(Temp, 3, 10);
1941 if (ts->YmodemTimeOutShort < 1)
1942 ts->YmodemTimeOutShort = 1;
1943 ts->YmodemTimeOutLong = GetNthNum2(Temp, 4, 20);
1944 if (ts->YmodemTimeOutLong < 1)
1945 ts->YmodemTimeOutLong = 1;
1946 ts->YmodemTimeOutVLong = GetNthNum2(Temp, 5, 60);
1947 if (ts->YmodemTimeOutVLong < 1)
1948 ts->YmodemTimeOutVLong = 1;
1949
1950 // Zmodem Timeout
1951 GetPrivateProfileString(Section, "ZmodemTimeouts", "10,0,10,3", Temp, sizeof(Temp), FName);
1952 ts->ZmodemTimeOutNormal = GetNthNum2(Temp, 1, 10);
1953 if (ts->ZmodemTimeOutNormal < 1)
1954 ts->ZmodemTimeOutNormal = 1;
1955 ts->ZmodemTimeOutTCPIP = GetNthNum2(Temp, 2, 0);
1956 if (ts->ZmodemTimeOutTCPIP < 0)
1957 ts->ZmodemTimeOutTCPIP = 0;
1958 ts->ZmodemTimeOutInit = GetNthNum2(Temp, 3, 10);
1959 if (ts->ZmodemTimeOutInit < 1)
1960 ts->ZmodemTimeOutInit = 1;
1961 ts->ZmodemTimeOutFin = GetNthNum2(Temp, 4, 3);
1962 if (ts->ZmodemTimeOutFin < 1)
1963 ts->ZmodemTimeOutFin = 1;
1964
1965 // Trim trailing new line character when pasting
1966 if (GetOnOff(Section, "TrimTrailingNLonPaste", FName, FALSE))
1967 ts->PasteFlag |= CPF_TRIM_TRAILING_NL;
1968
1969 // Normalize line break when pasting
1970 if (GetOnOff(Section, "NormalizeLineBreakOnPaste", FName, FALSE))
1971 ts->PasteFlag |= CPF_NORMALIZE_LINEBREAK;
1972
1973 // List Inactive Font
1974 ts->ListHiddenFonts = GetOnOff(Section, "ListHiddenFonts", FName, FALSE);
1975
1976 // ISO2022ShiftFunction
1977 GetPrivateProfileString(Section, "ISO2022ShiftFunction", "on", Temp, sizeof(Temp), FName);
1978 ts->ISO2022Flag = ISO2022_SHIFT_NONE;
1979 for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
1980 BOOL add=TRUE;
1981 char *p = Temp2, *p2;
1982 int mask = 0;
1983
1984 while (*p == ' ' || *p == '\t') {
1985 p++;
1986 }
1987 p2 = p + strlen(p);
1988 while (p2 > p) {
1989 p2--;
1990 if (*p2 != ' ' && *p2 != '\t') {
1991 break;
1992 }
1993 }
1994 *++p2 = 0;
1995
1996 if (*p == '-') {
1997 p++;
1998 add=FALSE;
1999 }
2000 else if (*p == '+') {
2001 p++;
2002 }
2003
2004 if (_stricmp(p, "on") == 0 || _stricmp(p, "all") == 0)
2005 ts->ISO2022Flag = ISO2022_SHIFT_ALL;
2006 else if (_stricmp(p, "off") == 0 || _stricmp(p, "none") == 0)
2007 ts->ISO2022Flag = ISO2022_SHIFT_NONE;
2008 else if (_stricmp(p, "SI") == 0 || _stricmp(p, "LS0") == 0)
2009 mask = ISO2022_SI;
2010 else if (_stricmp(p, "SO") == 0 || _stricmp(p, "LS1") == 0)
2011 mask = ISO2022_SO;
2012 else if (_stricmp(p, "LS2") == 0)
2013 mask = ISO2022_LS2;
2014 else if (_stricmp(p, "LS3") == 0)
2015 mask = ISO2022_LS3;
2016 else if (_stricmp(p, "LS1R") == 0)
2017 mask = ISO2022_LS1R;
2018 else if (_stricmp(p, "LS2R") == 0)
2019 mask = ISO2022_LS2R;
2020 else if (_stricmp(p, "LS3R") == 0)
2021 mask = ISO2022_LS3R;
2022 else if (_stricmp(p, "SS2") == 0)
2023 mask = ISO2022_SS2;
2024 else if (_stricmp(p, "SS3") == 0)
2025 mask = ISO2022_SS3;
2026
2027 if (mask) {
2028 if (add) {
2029 ts->ISO2022Flag |= mask;
2030 }
2031 else {
2032 ts->ISO2022Flag &= ~mask;
2033 }
2034 }
2035 }
2036
2037 // Fallback to CP932 (Experimental)
2038 ts->FallbackToCP932 = GetOnOff(Section, "FallbackToCP932", FName, FALSE);
2039
2040 // CygTerm Configuration File
2041 ReadCygtermConfFile(ts);
2042 }
2043
2044 void PASCAL WriteIniFile(PCHAR FName, PTTSet ts)
2045 {
2046 int i;
2047 char Temp[MAX_PATH];
2048 char buf[20];
2049 int ret;
2050 char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG], msg[MAX_UIMSG];
2051
2052 /* version */
2053 ret = WritePrivateProfileString(Section, "Version", TT_VERSION_STR("."), FName);
2054 if (ret == 0) {
2055 // ini�t�@�C�����������������s�������A�G���[���b�Z�[�W���\�������B(2012.10.18 yutaka)
2056 ret = GetLastError();
2057 get_lang_msg("MSG_INI_WRITE_ERROR", uimsg, sizeof(uimsg), "Cannot write ini file", ts->UILanguageFile);
2058 _snprintf_s(msg, sizeof(msg), _TRUNCATE, "%s (%d)", uimsg, ret);
2059
2060 get_lang_msg("MSG_INI_ERROR", uimsg2, sizeof(uimsg2), "Tera Term: Error", ts->UILanguageFile);
2061
2062 MessageBox(NULL, msg, uimsg2, MB_ICONEXCLAMATION);
2063 }
2064
2065 /* Language */
2066 switch (ts->Language) {
2067 case IdJapanese:
2068 strncpy_s(Temp, sizeof(Temp), "Japanese", _TRUNCATE);
2069 break;
2070 case IdKorean:
2071 strncpy_s(Temp, sizeof(Temp), "Korean", _TRUNCATE);
2072 break;
2073 case IdRussian:
2074 strncpy_s(Temp, sizeof(Temp), "Russian", _TRUNCATE);
2075 break;
2076 case IdUtf8:
2077 strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
2078 break;
2079 default:
2080 strncpy_s(Temp, sizeof(Temp), "English", _TRUNCATE);
2081 }
2082
2083 WritePrivateProfileString(Section, "Language", Temp, FName);
2084
2085 /* Port type */
2086 WritePrivateProfileString(Section, "Port", (ts->PortType==IdSerial)?"serial":"tcpip", FName);
2087
2088 /* Save win position */
2089 if (ts->SaveVTWinPos) {
2090 /* VT win position */
2091 WriteInt2(Section, "VTPos", FName, ts->VTPos.x, ts->VTPos.y);
2092 }
2093
2094 /* VT terminal size */
2095 WriteInt2(Section, "TerminalSize", FName,
2096 ts->TerminalWidth, ts->TerminalHeight);
2097
2098 /* Terminal size = Window size */
2099 WriteOnOff(Section, "TermIsWin", FName, ts->TermIsWin);
2100
2101 /* Auto window resize flag */
2102 WriteOnOff(Section, "AutoWinResize", FName, ts->AutoWinResize);
2103
2104 /* CR Receive */
2105 if (ts->CRReceive == IdCRLF) {
2106 strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
2107 }
2108 else if (ts->CRReceive == IdLF) {
2109 strncpy_s(Temp, sizeof(Temp), "LF", _TRUNCATE);
2110 }
2111 else if (ts->CRReceive == IdAUTO) {
2112 strncpy_s(Temp, sizeof(Temp), "AUTO", _TRUNCATE);
2113 }
2114 else {
2115 strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
2116 }
2117 WritePrivateProfileString(Section, "CRReceive", Temp, FName);
2118
2119 /* CR Send */
2120 if (ts->CRSend == IdCRLF) {
2121 strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
2122 }
2123 else if (ts->CRSend == IdLF) {
2124 strncpy_s(Temp, sizeof(Temp), "LF", _TRUNCATE);
2125 }
2126 else {
2127 strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
2128 }
2129 WritePrivateProfileString(Section, "CRSend", Temp, FName);
2130
2131 /* Local echo */
2132 WriteOnOff(Section, "LocalEcho", FName, ts->LocalEcho);
2133
2134 /* Answerback */
2135 if ((ts->FTFlag & FT_BPAUTO) == 0) {
2136 Str2Hex(ts->Answerback, Temp, ts->AnswerbackLen,
2137 sizeof(Temp) - 1, TRUE);
2138 WritePrivateProfileString(Section, "Answerback", Temp, FName);
2139 }
2140
2141 /* Kanji Code (receive) */
2142 switch (ts->KanjiCode) {
2143 case IdEUC:
2144 strncpy_s(Temp, sizeof(Temp), "EUC", _TRUNCATE);
2145 break;
2146 case IdJIS:
2147 strncpy_s(Temp, sizeof(Temp), "JIS", _TRUNCATE);
2148 break;
2149 case IdUTF8:
2150 strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
2151 break;
2152 case IdUTF8m:
2153 strncpy_s(Temp, sizeof(Temp), "UTF-8m", _TRUNCATE);
2154 break;
2155 default:
2156 switch (ts->Language) {
2157 case IdJapanese:
2158 strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2159 break;
2160 case IdKorean:
2161 strncpy_s(Temp, sizeof(Temp), "KS5601", _TRUNCATE);
2162 break;
2163 default:
2164 strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2165 }
2166 }
2167 WritePrivateProfileString(Section, "KanjiReceive", Temp, FName);
2168
2169 /* Katakana (receive) */
2170 if (ts->JIS7Katakana == 1)
2171 strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
2172 else
2173 strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
2174
2175 WritePrivateProfileString(Section, "KatakanaReceive", Temp, FName);
2176
2177 /* Kanji Code (transmit) */
2178 switch (ts->KanjiCodeSend) {
2179 case IdEUC:
2180 strncpy_s(Temp, sizeof(Temp), "EUC", _TRUNCATE);
2181 break;
2182 case IdJIS:
2183 strncpy_s(Temp, sizeof(Temp), "JIS", _TRUNCATE);
2184 break;
2185 case IdUTF8:
2186 strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
2187 break;
2188 default:
2189 switch (ts->Language) {
2190 case IdJapanese:
2191 strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2192 break;
2193 case IdKorean:
2194 strncpy_s(Temp, sizeof(Temp), "KS5601", _TRUNCATE);
2195 break;
2196 default:
2197 strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2198 }
2199 }
2200 WritePrivateProfileString(Section, "KanjiSend", Temp, FName);
2201
2202 /* Katakana (transmit) */
2203 if (ts->JIS7KatakanaSend == 1)
2204 strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
2205 else
2206 strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
2207
2208 WritePrivateProfileString(Section, "KatakanaSend", Temp, FName);
2209
2210 /* KanjiIn */
2211 if (ts->KanjiIn == IdKanjiInA)
2212 strncpy_s(Temp, sizeof(Temp), "@", _TRUNCATE);
2213 else
2214 strncpy_s(Temp, sizeof(Temp), "B", _TRUNCATE);
2215
2216 WritePrivateProfileString(Section, "KanjiIn", Temp, FName);
2217
2218 /* KanjiOut */
2219 switch (ts->KanjiOut) {
2220 case IdKanjiOutB:
2221 strncpy_s(Temp, sizeof(Temp), "B", _TRUNCATE);
2222 break;
2223 case IdKanjiOutH:
2224 strncpy_s(Temp, sizeof(Temp), "H", _TRUNCATE);
2225 break;
2226 default:
2227 strncpy_s(Temp, sizeof(Temp), "J", _TRUNCATE);
2228 }
2229 WritePrivateProfileString(Section, "KanjiOut", Temp, FName);
2230
2231 // new configuration
2232 WriteInt(Section, "ConnectingTimeout", FName, ts->ConnectingTimeout);
2233
2234 WriteOnOff(Section, "DisablePasteMouseRButton", FName,
2235 (WORD) (ts->PasteFlag & CPF_DISABLE_RBUTTON));
2236
2237 WriteOnOff(Section, "DisablePasteMouseMButton", FName,
2238 (WORD) (ts->PasteFlag & CPF_DISABLE_MBUTTON));
2239
2240 WriteOnOff(Section, "ConfirmPasteMouseRButton", FName,
2241 (WORD) (ts->PasteFlag & CPF_CONFIRM_RBUTTON));
2242
2243 // added ConfirmChangePaste
2244 WriteOnOff(Section, "ConfirmChangePaste", FName,
2245 (WORD) (ts->PasteFlag & CPF_CONFIRM_CHANGEPASTE));
2246
2247 WriteOnOff(Section, "ConfirmChangePasteCR", FName,
2248 (WORD) (ts->PasteFlag & CPF_CONFIRM_CHANGEPASTE_CR));
2249
2250 WritePrivateProfileString(Section, "ConfirmChangePasteStringFile",
2251 ts->ConfirmChangePasteStringFile, FName);
2252
2253 // added ScrollWindowClearScreen
2254 WriteOnOff(Section, "ScrollWindowClearScreen", FName,
2255 ts->ScrollWindowClearScreen);
2256
2257 // added SelectOnlyByLButton (2007.11.20 maya)
2258 WriteOnOff(Section, "SelectOnlyByLButton", FName,
2259 ts->SelectOnlyByLButton);
2260 // added DisableAcceleratorSendBreak (2007.3.17 maya)
2261 WriteOnOff(Section, "DisableAcceleratorSendBreak", FName,
2262 ts->DisableAcceleratorSendBreak);
2263 WriteOnOff(Section, "EnableContinuedLineCopy", FName,
2264 ts->EnableContinuedLineCopy);
2265 WritePrivateProfileString(Section, "MouseCursor", ts->MouseCursorName,
2266 FName);
2267 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->AlphaBlend);
2268 WritePrivateProfileString(Section, "AlphaBlend", Temp, FName);
2269 WritePrivateProfileString(Section, "CygwinDirectory",
2270 ts->CygwinDirectory, FName);
2271 WritePrivateProfileString(Section, "ViewlogEditor", ts->ViewlogEditor,
2272 FName);
2273 WritePrivateProfileString(Section, "Locale", ts->Locale, FName);
2274 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->CodePage);
2275 WritePrivateProfileString(Section, "CodePage", Temp, FName);
2276
2277 // ANSI color(2004.9.5 yutaka)
2278 Temp[0] = '\0';
2279 for (i = 0; i < 15; i++) {
2280 _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d,%d,%d,%d, ",
2281 i,
2282 GetRValue(ts->ANSIColor[i]),
2283 GetGValue(ts->ANSIColor[i]),
2284 GetBValue(ts->ANSIColor[i])
2285 );
2286 strncat_s(Temp, sizeof(Temp), buf, _TRUNCATE);
2287 }
2288 i = 15;
2289 _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d,%d,%d,%d",
2290 i,
2291 GetRValue(ts->ANSIColor[i]),
2292 GetGValue(ts->ANSIColor[i]),
2293 GetBValue(ts->ANSIColor[i])
2294 );
2295 strncat_s(Temp, sizeof(Temp), buf, _TRUNCATE);
2296 WritePrivateProfileString(Section, "ANSIColor", Temp, FName);
2297
2298 /* AutoWinChange VT<->TEK */
2299 WriteOnOff(Section, "AutoWinSwitch", FName, ts->AutoWinSwitch);
2300
2301 /* Terminal ID */
2302 id2str(TermList, ts->TerminalID, IdVT100, Temp, sizeof(Temp));
2303 WritePrivateProfileString(Section, "TerminalID", Temp, FName);
2304
2305 /* Russian character set (host) */
2306 id2str(RussList, ts->RussHost, IdKOI8, Temp, sizeof(Temp));
2307 WritePrivateProfileString(Section, "RussHost", Temp, FName);
2308
2309 /* Russian character set (client) */
2310 id2str(RussList, ts->RussClient, IdWindows, Temp, sizeof(Temp));
2311 WritePrivateProfileString(Section, "RussClient", Temp, FName);
2312
2313 /* Title text */
2314 WritePrivateProfileString(Section, "Title", ts->Title, FName);
2315
2316 /* Cursor shape */
2317 switch (ts->CursorShape) {
2318 case IdVCur:
2319 strncpy_s(Temp, sizeof(Temp), "vertical", _TRUNCATE);
2320 break;
2321 case IdHCur:
2322 strncpy_s(Temp, sizeof(Temp), "horizontal", _TRUNCATE);
2323 break;
2324 default:
2325 strncpy_s(Temp, sizeof(Temp), "block", _TRUNCATE);
2326 }
2327 WritePrivateProfileString(Section, "CursorShape", Temp, FName);
2328
2329 /* Hide title */
2330 WriteOnOff(Section, "HideTitle", FName, ts->HideTitle);
2331
2332 /* Popup menu */
2333 WriteOnOff(Section, "PopupMenu", FName, ts->PopupMenu);
2334
2335 /* PC-Style bold color mapping */
2336 WriteOnOff(Section, "PcBoldColor", FName,
2337 (WORD) (ts->ColorFlag & CF_PCBOLD16));
2338
2339 /* aixterm 16 colors mode */
2340 WriteOnOff(Section, "Aixterm16Color", FName,
2341 (WORD) (ts->ColorFlag & CF_AIXTERM16));
2342
2343 /* xterm 256 colors mode */
2344 WriteOnOff(Section, "Xterm256Color", FName,
2345 (WORD) (ts->ColorFlag & CF_XTERM256));
2346
2347 /* Enable scroll buffer */
2348 WriteOnOff(Section, "EnableScrollBuff", FName, ts->EnableScrollBuff);
2349
2350 /* Scroll buffer size */
2351 WriteInt(Section, "ScrollBuffSize", FName, ts->ScrollBuffSize);
2352
2353 /* VT Color */
2354 for (i = 0; i <= 1; i++) {
2355 if (ts->ColorFlag & CF_REVERSEVIDEO) {
2356 if (ts->ColorFlag & CF_REVERSECOLOR) {
2357 ts->TmpColor[0][i * 3] = GetRValue(ts->VTReverseColor[i]);
2358 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTReverseColor[i]);
2359 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTReverseColor[i]);
2360 }
2361 else {
2362 ts->TmpColor[0][i * 3] = GetRValue(ts->VTColor[!i]);
2363 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTColor[!i]);
2364 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTColor[!i]);
2365 }
2366 }
2367 else {
2368 ts->TmpColor[0][i * 3] = GetRValue(ts->VTColor[i]);
2369 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTColor[i]);
2370 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTColor[i]);
2371 }
2372 }
2373 WriteInt6(Section, "VTColor", FName,
2374 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
2375 ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
2376
2377 /* VT Bold Color */
2378 for (i = 0; i <= 1; i++) {
2379 if (ts->ColorFlag & CF_REVERSEVIDEO) {
2380 ts->TmpColor[0][i * 3] = GetRValue(ts->VTBoldColor[!i]);
2381 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBoldColor[!i]);
2382 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBoldColor[!i]);
2383 }
2384 else {
2385 ts->TmpColor[0][i * 3] = GetRValue(ts->VTBoldColor[i]);
2386 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBoldColor[i]);
2387 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBoldColor[i]);
2388 }
2389 }
2390 WriteInt6(Section, "VTBoldColor", FName,
2391 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
2392 ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
2393
2394 /* VT Blink Color */
2395 for (i = 0; i <= 1; i++) {
2396 if (ts->ColorFlag & CF_REVERSEVIDEO) {
2397 ts->TmpColor[0][i * 3] = GetRValue(ts->VTBlinkColor[!i]);
2398 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBlinkColor[!i]);
2399 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBlinkColor[!i]);
2400 }
2401 else {
2402 ts->TmpColor[0][i * 3] = GetRValue(ts->VTBlinkColor[i]);
2403 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBlinkColor[i]);
2404 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBlinkColor[i]);
2405 }
2406 }
2407 WriteInt6(Section, "VTBlinkColor", FName,
2408 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
2409 ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
2410
2411 /* VT Reverse Color */
2412 for (i = 0; i <= 1; i++) {
2413 if (ts->ColorFlag & CF_REVERSEVIDEO && ts->ColorFlag & CF_REVERSECOLOR) {
2414 ts->TmpColor[0][i * 3] = GetRValue(ts->VTColor[i]);
2415 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTColor[i]);
2416 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTColor[i]);
2417 }
2418 else {
2419 ts->TmpColor[0][i * 3] = GetRValue(ts->VTReverseColor[i]);
2420 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTReverseColor[i]);
2421 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTReverseColor[i]);
2422 }
2423 }
2424 WriteInt6(Section, "VTReverseColor", FName,
2425 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
2426 ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
2427
2428 WriteOnOff(Section, "EnableClickableUrl", FName,
2429 ts->EnableClickableUrl);
2430
2431 /* URL color */
2432 for (i = 0; i <= 1; i++) {
2433 if (ts->ColorFlag & CF_REVERSEVIDEO) {
2434 ts->TmpColor[0][i * 3] = GetRValue(ts->URLColor[!i]);
2435 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->URLColor[!i]);
2436 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->URLColor[!i]);
2437 }
2438 else {
2439 ts->TmpColor[0][i * 3] = GetRValue(ts->URLColor[i]);
2440 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->URLColor[i]);
2441 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->URLColor[i]);
2442 }
2443 }
2444 WriteInt6(Section, "URLColor", FName,
2445 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
2446 ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
2447
2448 WriteOnOff(Section, "EnableBoldAttrColor", FName,
2449 (WORD) (ts->ColorFlag & CF_BOLDCOLOR));
2450
2451 WriteOnOff(Section, "EnableBlinkAttrColor", FName,
2452 (WORD) (ts->ColorFlag & CF_BLINKCOLOR));
2453
2454 WriteOnOff(Section, "EnableReverseAttrColor", FName,
2455 (WORD) (ts->ColorFlag & CF_REVERSECOLOR));
2456
2457 WriteOnOff(Section, "EnableURLColor", FName,
2458 (WORD) (ts->ColorFlag & CF_URLCOLOR));
2459
2460 WriteOnOff(Section, "URLUnderline", FName,
2461 (WORD) (ts->FontFlag & FF_URLUNDERLINE));
2462
2463 WriteOnOff(Section, "EnableANSIColor", FName,
2464 (WORD) (ts->ColorFlag & CF_ANSICOLOR));
2465
2466 /* TEK Color */
2467 for (i = 0; i <= 1; i++) {
2468 ts->TmpColor[0][i * 3] = GetRValue(ts->TEKColor[i]);
2469 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->TEKColor[i]);
2470 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->TEKColor[i]);
2471 }
2472 WriteInt6(Section, "TEKColor", FName,
2473 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
2474 ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
2475
2476 /* TEK color emulation */
2477 WriteOnOff(Section, "TEKColorEmulation", FName, ts->TEKColorEmu);
2478
2479 /* VT Font */
2480 WriteFont(Section, "VTFont", FName,
2481 ts->VTFont, ts->VTFontSize.x, ts->VTFontSize.y,
2482 ts->VTFontCharSet);
2483
2484 /* Enable bold font flag */
2485 WriteOnOff(Section, "EnableBold", FName,
2486 (WORD) (ts->FontFlag & FF_BOLD));
2487
2488 /* Russian character set (font) */
2489 id2str(RussList, ts->RussFont, IdWindows, Temp, sizeof(Temp));
2490 WritePrivateProfileString(Section, "RussFont", Temp, FName);
2491
2492 /* TEK Font */
2493 WriteFont(Section, "TEKFont", FName,
2494 ts->TEKFont, ts->TEKFontSize.x, ts->TEKFontSize.y,
2495 ts->TEKFontCharSet);
2496
2497 /* BS key */
2498 if (ts->BSKey == IdDEL)
2499 strncpy_s(Temp, sizeof(Temp), "DEL", _TRUNCATE);
2500 else
2501 strncpy_s(Temp, sizeof(Temp), "BS", _TRUNCATE);
2502 WritePrivateProfileString(Section, "BSKey", Temp, FName);
2503
2504 /* Delete key */
2505 WriteOnOff(Section, "DeleteKey", FName, ts->DelKey);
2506
2507 /* Meta key */
2508 switch (ts->MetaKey) {
2509 case 1:
2510 strncpy_s(Temp, sizeof(Temp), "on", _TRUNCATE);
2511 break;
2512 case 2:
2513 strncpy_s(Temp, sizeof(Temp), "left", _TRUNCATE);
2514 break;
2515 case 3:
2516 strncpy_s(Temp, sizeof(Temp), "right", _TRUNCATE);
2517 break;
2518 default:
2519 strncpy_s(Temp, sizeof(Temp), "off", _TRUNCATE);
2520 }
2521 WritePrivateProfileString(Section, "Metakey", Temp, FName);
2522
2523 /* Application Keypad */
2524 WriteOnOff(Section, "DisableAppKeypad", FName, ts->DisableAppKeypad);
2525
2526 /* Application Cursor */
2527 WriteOnOff(Section, "DisableAppCursor", FName, ts->DisableAppCursor);
2528
2529 /* Russian keyboard type */
2530 id2str(RussList2, ts->RussKeyb, IdWindows, Temp, sizeof(Temp));
2531 WritePrivateProfileString(Section, "RussKeyb", Temp, FName);
2532
2533 /* Serial port ID */
2534 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->ComPort);
2535 WritePrivateProfileString(Section, "ComPort", Temp, FName);
2536
2537 /* Baud rate */
2538 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->Baud);
2539 WritePrivateProfileString(Section, "BaudRate", Temp, FName);
2540
2541 /* Parity */
2542 switch (ts->Parity) {
2543 case IdParityEven:
2544 strncpy_s(Temp, sizeof(Temp), "even", _TRUNCATE);
2545 break;
2546 case IdParityOdd:
2547 strncpy_s(Temp, sizeof(Temp), "odd", _TRUNCATE);
2548 break;
2549 case IdParityMark:
2550 strncpy_s(Temp, sizeof(Temp), "mark", _TRUNCATE);
2551 break;
2552 case IdParitySpace:
2553 strncpy_s(Temp, sizeof(Temp), "space", _TRUNCATE);
2554 break;
2555 default:
2556 strncpy_s(Temp, sizeof(Temp), "none", _TRUNCATE);
2557 }
2558 WritePrivateProfileString(Section, "Parity", Temp, FName);
2559
2560 /* Data bit */
2561 if (ts->DataBit == IdDataBit7)
2562 strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
2563 else
2564 strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
2565
2566 WritePrivateProfileString(Section, "DataBit", Temp, FName);
2567
2568 /* Stop bit */
2569 switch (ts->StopBit) {
2570 case IdStopBit2:
2571 strncpy_s(Temp, sizeof(Temp), "2", _TRUNCATE);
2572 break;
2573 case IdStopBit15:
2574 strncpy_s(Temp, sizeof(Temp), "1.5", _TRUNCATE);
2575 break;
2576 default:
2577 strncpy_s(Temp, sizeof(Temp), "1", _TRUNCATE);
2578 break;
2579 }
2580
2581 WritePrivateProfileString(Section, "StopBit", Temp, FName);
2582
2583 /* Flow control */
2584 switch (ts->Flow) {
2585 case IdFlowX:
2586 strncpy_s(Temp, sizeof(Temp), "x", _TRUNCATE);
2587 break;
2588 case IdFlowHard:
2589 strncpy_s(Temp, sizeof(Temp), "hard", _TRUNCATE);
2590 break;
2591 default:
2592 strncpy_s(Temp, sizeof(Temp), "none", _TRUNCATE);
2593 }
2594 WritePrivateProfileString(Section, "FlowCtrl", Temp, FName);
2595
2596 /* Delay per character */
2597 WriteInt(Section, "DelayPerChar", FName, ts->DelayPerChar);
2598
2599 /* Delay per line */
2600 WriteInt(Section, "DelayPerLine", FName, ts->DelayPerLine);
2601
2602 /* Telnet flag */
2603 WriteOnOff(Section, "Telnet", FName, ts->Telnet);
2604
2605 /* Telnet terminal type */
2606 WritePrivateProfileString(Section, "TermType", ts->TermType, FName);
2607
2608 /* TCP port num for non-telnet */
2609 WriteUint(Section, "TCPPort", FName, ts->TCPPort);
2610
2611 /* Auto close flag */
2612 WriteOnOff(Section, "AutoWinClose", FName, ts->AutoWinClose);
2613
2614 /* History list */
2615 WriteOnOff(Section, "Historylist", FName, ts->HistoryList);
2616
2617 /* File transfer binary flag */
2618 WriteOnOff(Section, "TransBin", FName, ts->TransBin);
2619
2620 /* Log binary flag */
2621 WriteOnOff(Section, "LogBinary", FName, ts->LogBinary);
2622
2623 /* Log append */
2624 WriteOnOff(Section, "LogAppend", FName, ts->Append);
2625
2626 /* Log plain text flag */
2627 WriteOnOff(Section, "LogTypePlainText", FName, ts->LogTypePlainText);
2628
2629 /* Log with timestamp (2006.7.23 maya) */
2630 WriteOnOff(Section, "LogTimestamp", FName, ts->LogTimestamp);
2631
2632 /* Log without transfer dialog */
2633 WriteOnOff(Section, "LogHideDialog", FName, ts->LogHideDialog);
2634
2635 WriteOnOff(Section, "LogIncludeScreenBuffer", FName, ts->LogAllBuffIncludedInFirst);
2636
2637 /* Timestamp format of Log each line */
2638 WritePrivateProfileString(Section, "LogTimestampFormat",
2639 ts->LogTimestampFormat, FName);
2640
2641 /* Use UTC/GMT time for Log each line timestamp */
2642 WriteOnOff(Section, "LogTimestampUTC", FName, ts->LogTimestampUTC);
2643
2644 /* Default Log file name (2006.8.28 maya) */
2645 WritePrivateProfileString(Section, "LogDefaultName",
2646 ts->LogDefaultName, FName);
2647
2648 /* Default Log file path (2007.5.30 maya) */
2649 WritePrivateProfileString(Section, "LogDefaultPath",
2650 ts->LogDefaultPath, FName);
2651
2652 /* Auto start logging (2007.5.31 maya) */
2653 WriteOnOff(Section, "LogAutoStart", FName, ts->LogAutoStart);
2654
2655 /* Log Rotate (2013.3.24 yutaka) */
2656 WriteInt(Section, "LogRotate", FName, ts->LogRotate);
2657 WriteInt(Section, "LogRotateSize", FName, ts->LogRotateSize);
2658 WriteInt(Section, "LogRotateSizeType", FName, ts->LogRotateSizeType);
2659 WriteInt(Section, "LogRotateStep", FName, ts->LogRotateStep);
2660
2661 /* Deferred Log Write Mode (2013.4.20 yutaka) */
2662 WriteOnOff(Section, "DeferredLogWriteMode", FName, ts->DeferredLogWriteMode);
2663
2664 /* XMODEM option */
2665 switch (ts->XmodemOpt) {
2666 case XoptCRC:
2667 strncpy_s(Temp, sizeof(Temp), "crc", _TRUNCATE);
2668 break;
2669 case Xopt1kCRC:
2670 strncpy_s(Temp, sizeof(Temp), "1k", _TRUNCATE);
2671 break;
2672 case Xopt1kCksum:
2673 strncpy_s(Temp, sizeof(Temp), "1ksum", _TRUNCATE);
2674 break;
2675 default:
2676 strncpy_s(Temp, sizeof(Temp), "checksum", _TRUNCATE);
2677 }
2678 WritePrivateProfileString(Section, "XmodemOpt", Temp, FName);
2679
2680 /* XMODEM binary flag */
2681 WriteOnOff(Section, "XmodemBin", FName, ts->XmodemBin);
2682
2683 /* XMODEM ���M�R�}���h (2007.12.21 yutaka) */
2684 WritePrivateProfileString(Section, "XmodemRcvCommand",
2685 ts->XModemRcvCommand, FName);
2686
2687 /* Default directory for file transfer */
2688 WritePrivateProfileString(Section, "FileDir", ts->FileDir, FName);
2689
2690 /* filter on file send (2007.6.5 maya) */
2691 WritePrivateProfileString(Section, "FileSendFilter",
2692 ts->FileSendFilter, FName);
2693
2694 WritePrivateProfileString(Section, "ScpSendDir", ts->ScpSendDir, FName);
2695
2696 /*------------------------------------------------------------------*/
2697 /* 8 bit control code flag -- special option */
2698 WriteOnOff(Section, "Accept8BitCtrl", FName,
2699 (WORD) (ts->TermFlag & TF_ACCEPT8BITCTRL));
2700
2701 /* Wrong sequence flag -- special option */
2702 WriteOnOff(Section, "AllowWrongSequence", FName,
2703 (WORD) (ts->TermFlag & TF_ALLOWWRONGSEQUENCE));
2704
2705 /* Detect disconnect/reconnect of serial port --- special option */
2706 WriteOnOff(Section, "AutoComPortReconnect", FName, ts->AutoComPortReconnect);
2707
2708 /* Auto file renaming --- special option */
2709 WriteOnOff(Section, "AutoFileRename", FName,
2710 (WORD) (ts->FTFlag & FT_RENAME));
2711
2712 /* Auto text copy --- special option */
2713 WriteOnOff(Section, "AutoTextCopy", FName, ts->AutoTextCopy);
2714
2715 /* Back wrap -- special option */
2716 WriteOnOff(Section, "BackWrap", FName,
2717 (WORD) (ts->TermFlag & TF_BACKWRAP));
2718
2719 /* Beep type -- special option */
2720 WriteOnOff(Section, "Beep", FName, ts->Beep);
2721 switch (ts->Beep) {
2722 case IdBeepOff:
2723 WritePrivateProfileString(Section, "Beep", "off", FName);
2724 break;
2725 case IdBeepOn:
2726 WritePrivateProfileString(Section, "Beep", "on", FName);
2727 break;
2728 case IdBeepVisual:
2729 WritePrivateProfileString(Section, "Beep", "visual", FName);
2730 break;
2731 }
2732
2733 /* Beep on connection & disconnection -- special option */
2734 WriteOnOff(Section, "BeepOnConnect", FName,
2735 (WORD) (ts->PortFlag & PF_BEEPONCONNECT));
2736
2737 /* Auto B-Plus activation -- special option */
2738 WriteOnOff(Section, "BPAuto", FName, (WORD) (ts->FTFlag & FT_BPAUTO));
2739
2740 /* B-Plus ESCCTL flag -- special option */
2741 WriteOnOff(Section, "BPEscCtl", FName,
2742 (WORD) (ts->FTFlag & FT_BPESCCTL));
2743
2744 /* B-Plus log -- special option */
2745 WriteOnOff(Section, "BPLog", FName, (WORD) (ts->LogFlag & LOG_BP));
2746
2747 /* Clear serial port buffer when port opening -- special option */
2748 WriteOnOff(Section, "ClearComBuffOnOpen", FName, ts->ClearComBuffOnOpen);
2749
2750 /* When serial port is specified with with /C= option and the port does not exist, Tera Term will wait for port connection. */
2751 WriteOnOff(Section, "WaitCom", FName, ts->WaitCom);
2752
2753