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 9301 - (show annotations) (download) (as text)
Sat Jun 12 15:26:01 2021 UTC (2 years, 9 months ago) by zmatsuo
File MIME type: text/x-csrc
File size: 143557 byte(s)
メモリリーク修正

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