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 9242 - (show annotations) (download) (as text)
Mon May 10 14:11:42 2021 UTC (2 years, 11 months ago) by zmatsuo
File MIME type: text/x-csrc
File size: 151445 byte(s)
iniファイルの読み書きAPIをunicode版に切り替え

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