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