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