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 9313 - (show annotations) (download) (as text)
Sun Jun 20 01:07:40 2021 UTC (2 years, 9 months ago) by zmatsuo
File MIME type: text/x-csrc
File size: 143602 byte(s)
locale設定を削除

- Cランタイムの文字コードの設定
  - 従来Cランタイムの文字コード変換関数を使用していたため必要だった
    - wctomb()
  - 現在Cランタイムの文字コード変換は使用していないため不要
    - OSのAPI WideCharToMultiByte(), MultiByteToWideChar() を使用
- setlocale()を削除
- 不要な locale.h の include を削除
- 設定ダイアログの locale 設定を削除
  - IDC_LOCALE_LABEL 削除
  - lng 内の DLG_TERM_LOCALE 削除
  - ドキュメント locale 設定個所を削除
- iniファイルのlocale読み書きを削除
- r9145
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 // UI language message file (�����p�X)
1902 hGetPrivateProfileStringW(SectionW, L"UILanguageFile", NULL, FName, &ts->UILanguageFileW_ini);
1903 if (ts->UILanguageFileW_ini == NULL) {
1904 ts->UILanguageFileW_ini = wcsdup(L"lang\\Default.lng");
1905 }
1906 WideCharToACP_t(ts->UILanguageFileW_ini, ts->UILanguageFile_ini, sizeof(ts->UILanguageFile_ini));
1907
1908 // UI language message file (full path)
1909 ts->UILanguageFileW = GetUILanguageFileFullW(ts->HomeDirW, ts->UILanguageFileW_ini);
1910 WideCharToACP_t(ts->UILanguageFileW, ts->UILanguageFile, sizeof(ts->UILanguageFile));
1911
1912
1913 // Broadcast Command History (2007.3.3 maya)
1914 ts->BroadcastCommandHistory =
1915 GetOnOff(Section, "BroadcastCommandHistory", FName, FALSE);
1916
1917 // 337: 2007/03/20 Accept Broadcast
1918 ts->AcceptBroadcast =
1919 GetOnOff(Section, "AcceptBroadcast", FName, TRUE);
1920
1921 // Confirm send a file when drag and drop (2007.12.28 maya)
1922 ts->ConfirmFileDragAndDrop =
1923 GetOnOff(Section, "ConfirmFileDragAndDrop", FName, TRUE);
1924
1925 // Translate mouse wheel to cursor key when application cursor mode
1926 ts->TranslateWheelToCursor =
1927 GetOnOff(Section, "TranslateWheelToCursor", FName, TRUE);
1928
1929 // Display "New Connection" dialog on startup (2008.1.18 maya)
1930 ts->HostDialogOnStartup =
1931 GetOnOff(Section, "HostDialogOnStartup", FName, TRUE);
1932
1933 // Mouse event tracking
1934 ts->MouseEventTracking =
1935 GetOnOff(Section, "MouseEventTracking", FName, TRUE);
1936
1937 // Maximized bug tweak
1938 GetPrivateProfileString(Section, "MaximizedBugTweak", "2", Temp,
1939 sizeof(Temp), FName);
1940 if (_stricmp(Temp, "on") == 0) {
1941 ts->MaximizedBugTweak = 2;
1942 }
1943 else {
1944 ts->MaximizedBugTweak = atoi(Temp);
1945 }
1946
1947 // Convert Unicode symbol characters to DEC Special characters
1948 ts->UnicodeDecSpMapping =
1949 GetPrivateProfileInt(Section, "UnicodeToDecSpMapping", 3, FName);
1950
1951 // VT Window Icon
1952 GetPrivateProfileString(Section, "VTIcon", "Default",
1953 Temp, sizeof(Temp), FName);
1954 ts->VTIcon = IconName2IconId(Temp);
1955
1956 // Tek Window Icon
1957 GetPrivateProfileString(Section, "TEKIcon", "Default",
1958 Temp, sizeof(Temp), FName);
1959 ts->TEKIcon = IconName2IconId(Temp);
1960
1961 // Unknown Unicode Character
1962 ts->UnknownUnicodeCharaAsWide =
1963 GetOnOff(Section, "UnknownUnicodeCharacterAsWide", FName, FALSE);
1964
1965 #ifdef USE_NORMAL_BGCOLOR
1966 // UseNormalBGColor
1967 ts->UseNormalBGColor =
1968 GetOnOff(Section, "UseNormalBGColor", FName, FALSE);
1969 // 2006/03/11 by 337
1970 if (ts->UseNormalBGColor) {
1971 ts->VTBoldColor[1] =
1972 ts->VTBlinkColor[1] = ts->URLColor[1] = ts->VTColor[1];
1973 }
1974 #endif
1975
1976 // AutoScrollOnlyInBottomLine
1977 ts->AutoScrollOnlyInBottomLine =
1978 GetOnOff(Section, "AutoScrollOnlyInBottomLine", FName, FALSE);
1979
1980 // Accept remote-controlled window title changing
1981 GetPrivateProfileString(Section, "AcceptTitleChangeRequest", "overwrite",
1982 Temp, sizeof(Temp), FName);
1983 if (_stricmp(Temp, "overwrite") == 0 || _stricmp(Temp, "on") == 0)
1984 ts->AcceptTitleChangeRequest = IdTitleChangeRequestOverwrite;
1985 else if (_stricmp(Temp, "ahead") == 0)
1986 ts->AcceptTitleChangeRequest = IdTitleChangeRequestAhead;
1987 else if (_stricmp(Temp, "last") == 0)
1988 ts->AcceptTitleChangeRequest = IdTitleChangeRequestLast;
1989 else
1990 ts->AcceptTitleChangeRequest = IdTitleChangeRequestOff;
1991
1992 // Size of paste confirm dialog
1993 GetPrivateProfileString(Section, "PasteDialogSize", "330,220",
1994 Temp, sizeof(Temp), FName);
1995 GetNthNum(Temp, 1, &ts->PasteDialogSize.cx);
1996 GetNthNum(Temp, 2, &ts->PasteDialogSize.cy);
1997 if (ts->PasteDialogSize.cx < 0)
1998 ts->PasteDialogSize.cx = 330;
1999 if (ts->PasteDialogSize.cy < 0)
2000 ts->PasteDialogSize.cy = 220;
2001
2002 // Disable mouse event tracking when Control-Key is pressed.
2003 ts->DisableMouseTrackingByCtrl =
2004 GetOnOff(Section, "DisableMouseTrackingByCtrl", FName, TRUE);
2005
2006 // Disable TranslateWheelToCursor setting when Control-Key is pressed.
2007 ts->DisableWheelToCursorByCtrl =
2008 GetOnOff(Section, "DisableWheelToCursorByCtrl", FName, TRUE);
2009
2010 // Strict Key Mapping.
2011 ts->StrictKeyMapping =
2012 GetOnOff(Section, "StrictKeyMapping", FName, FALSE);
2013
2014 // added Wait4allMacroCommand (2009.3.23 yutaka)
2015 ts->Wait4allMacroCommand =
2016 GetOnOff(Section, "Wait4allMacroCommand", FName, FALSE);
2017
2018 // added DisableMenuSendBreak (2009.4.6 maya)
2019 ts->DisableMenuSendBreak =
2020 GetOnOff(Section, "DisableMenuSendBreak", FName, FALSE);
2021
2022 // added ClearScreenOnCloseConnection (2009.4.6 maya)
2023 ts->ClearScreenOnCloseConnection =
2024 GetOnOff(Section, "ClearScreenOnCloseConnection", FName, FALSE);
2025
2026 // added DisableAcceleratorDuplicateSession (2009.4.6 maya)
2027 ts->DisableAcceleratorDuplicateSession =
2028 GetOnOff(Section, "DisableAcceleratorDuplicateSession", FName, FALSE);
2029
2030 ts->AcceleratorNewConnection =
2031 GetOnOff(Section, "AcceleratorNewConnection", FName, TRUE);
2032
2033 ts->AcceleratorCygwinConnection =
2034 GetOnOff(Section, "AcceleratorCygwinConnection", FName, TRUE);
2035
2036 // added DisableMenuDuplicateSession (2010.8.3 maya)
2037 ts->DisableMenuDuplicateSession =
2038 GetOnOff(Section, "DisableMenuDuplicateSession", FName, FALSE);
2039
2040 // added DisableMenuNewConnection (2010.8.4 maya)
2041 ts->DisableMenuNewConnection =
2042 GetOnOff(Section, "DisableMenuNewConnection", FName, FALSE);
2043
2044 // added PasteDelayPerLine (2009.4.12 maya)
2045 ts->PasteDelayPerLine =
2046 GetPrivateProfileInt(Section, "PasteDelayPerLine", 10, FName);
2047 {
2048 int tmp = min(max(0, ts->PasteDelayPerLine), 5000);
2049 ts->PasteDelayPerLine = tmp;
2050 }
2051
2052 // Font scaling -- test
2053 ts->FontScaling = GetOnOff(Section, "FontScaling", FName, FALSE);
2054
2055 // Meta sets MSB
2056 GetPrivateProfileString(Section, "Meta8Bit", "off", Temp, sizeof(Temp), FName);
2057 if (_stricmp(Temp, "raw") == 0 || _stricmp(Temp, "on") == 0)
2058 ts->Meta8Bit = IdMeta8BitRaw;
2059 else if (_stricmp(Temp, "text") == 0)
2060 ts->Meta8Bit = IdMeta8BitText;
2061 else
2062 ts->Meta8Bit = IdMeta8BitOff;
2063
2064 // Window control sequence
2065 if (GetOnOff(Section, "WindowCtrlSequence", FName, TRUE))
2066 ts->WindowFlag |= WF_WINDOWCHANGE;
2067
2068 // Cursor control sequence
2069 if (GetOnOff(Section, "CursorCtrlSequence", FName, FALSE))
2070 ts->WindowFlag |= WF_CURSORCHANGE;
2071
2072 // Window report sequence
2073 if (GetOnOff(Section, "WindowReportSequence", FName, TRUE))
2074 ts->WindowFlag |= WF_WINDOWREPORT;
2075
2076 // Title report sequence
2077 GetPrivateProfileString(Section, "TitleReportSequence", "Empty", Temp, sizeof(Temp), FName);
2078 if (_stricmp(Temp, "accept") == 0)
2079 ts->WindowFlag |= IdTitleReportAccept;
2080 else if (_stricmp(Temp, "ignore") == 0 || _stricmp(Temp, "off") == 0)
2081 ts->WindowFlag &= ~WF_TITLEREPORT;
2082 else // empty
2083 ts->WindowFlag |= IdTitleReportEmpty;
2084
2085 // Line at a time mode
2086 ts->EnableLineMode = GetOnOff(Section, "EnableLineMode", FName, TRUE);
2087
2088 // Clear window on resize
2089 if (GetOnOff(Section, "ClearOnResize", FName, TRUE))
2090 ts->TermFlag |= TF_CLEARONRESIZE;
2091
2092 // Alternate Screen Buffer
2093 if (GetOnOff(Section, "AlternateScreenBuffer", FName, TRUE))
2094 ts->TermFlag |= TF_ALTSCR;
2095
2096 // IME status related cursor style
2097 if (GetOnOff(Section, "IMERelatedCursor", FName, FALSE))
2098 ts->WindowFlag |= WF_IMECURSORCHANGE;
2099
2100 // Terminal Unique ID
2101 GetPrivateProfileString(Section, "TerminalUID", "FFFFFFFF", Temp, sizeof(Temp), FName);
2102 if (strlen(Temp) == 8) {
2103 for (i=0; i<8 && isxdigit((unsigned char)Temp[i]); i++) {
2104 if (islower(Temp[i])) {
2105 ts->TerminalUID[i] = toupper(Temp[i]);
2106 }
2107 else {
2108 ts->TerminalUID[i] = Temp[i];
2109 }
2110 }
2111 if (i == 8) {
2112 ts->TerminalUID[i] = 0;
2113 }
2114 else {
2115 strncpy_s(ts->TerminalUID, sizeof(ts->TerminalUID), "FFFFFFFF", _TRUNCATE);
2116 }
2117 }
2118 else {
2119 strncpy_s(ts->TerminalUID, sizeof(ts->TerminalUID), "FFFFFFFF", _TRUNCATE);
2120 }
2121
2122 // Lock Terminal UID
2123 if (GetOnOff(Section, "LockTUID", FName, TRUE))
2124 ts->TermFlag |= TF_LOCKTUID;
2125
2126 // Jump List
2127 ts->JumpList = GetOnOff(Section, "JumpList", FName, TRUE);
2128
2129 // TabStopModifySequence
2130 GetPrivateProfileString(Section, "TabStopModifySequence", "on", Temp, sizeof(Temp), FName);
2131 if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "all") == 0)
2132 ts->TabStopFlag = TABF_ALL;
2133 else if (_stricmp(Temp, "off") == 0 || _stricmp(Temp, "none") == 0)
2134 ts->TabStopFlag = TABF_NONE;
2135 else {
2136 ts->TabStopFlag = TABF_NONE;
2137 for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
2138 if (_stricmp(Temp2, "HTS") == 0)
2139 ts->TabStopFlag |= TABF_HTS;
2140 else if (_stricmp(Temp2, "HTS7") == 0)
2141 ts->TabStopFlag |= TABF_HTS7;
2142 else if (_stricmp(Temp2, "HTS8") == 0)
2143 ts->TabStopFlag |= TABF_HTS8;
2144 else if (_stricmp(Temp2, "TBC") == 0)
2145 ts->TabStopFlag |= TABF_TBC;
2146 else if (_stricmp(Temp2, "TBC0") == 0)
2147 ts->TabStopFlag |= TABF_TBC0;
2148 else if (_stricmp(Temp2, "TBC3") == 0)
2149 ts->TabStopFlag |= TABF_TBC3;
2150 }
2151 }
2152
2153 // Clipboard Access from Remote
2154 ts->CtrlFlag &= ~CSF_CBMASK;
2155 GetPrivateProfileString(Section, "ClipboardAccessFromRemote", "off", Temp, sizeof(Temp), FName);
2156 if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "readwrite") == 0)
2157 ts->CtrlFlag |= CSF_CBRW;
2158 else if (_stricmp(Temp, "read") == 0)
2159 ts->CtrlFlag |= CSF_CBREAD;
2160 else if (_stricmp(Temp, "write") == 0)
2161 ts->CtrlFlag |= CSF_CBWRITE;
2162 else
2163 ts->CtrlFlag |= CSF_CBNONE; // ��������������
2164
2165 // Notify Clipboard Access from Remote
2166 ts->NotifyClipboardAccess = GetOnOff(Section, "NotifyClipboardAccess", FName, TRUE);
2167
2168 // Use invalid DECRPSS (for testing)
2169 if (GetOnOff(Section, "UseInvalidDECRQSSResponse", FName, FALSE))
2170 ts->TermFlag |= TF_INVALIDDECRPSS;
2171
2172 // ClickableUrlBrowser
2173 GetPrivateProfileString(Section, "ClickableUrlBrowser", "",
2174 ts->ClickableUrlBrowser, sizeof(ts->ClickableUrlBrowser), FName);
2175 GetPrivateProfileString(Section, "ClickableUrlBrowserArg", "",
2176 ts->ClickableUrlBrowserArg, sizeof(ts->ClickableUrlBrowserArg), FName);
2177
2178 // Exclusive Lock when open the log file
2179 ts->LogLockExclusive = GetOnOff(Section, "LogLockExclusive", FName, TRUE);
2180
2181 // Font quality
2182 GetPrivateProfileString(Section, "FontQuality", "default",
2183 Temp, sizeof(Temp), FName);
2184 if (_stricmp(Temp, "nonantialiased") == 0)
2185 ts->FontQuality = NONANTIALIASED_QUALITY;
2186 else if (_stricmp(Temp, "antialiased") == 0)
2187 ts->FontQuality = ANTIALIASED_QUALITY;
2188 else if (_stricmp(Temp, "cleartype") == 0)
2189 ts->FontQuality = CLEARTYPE_QUALITY;
2190 else
2191 ts->FontQuality = DEFAULT_QUALITY;
2192
2193 // Beep Over Used
2194 ts->BeepOverUsedCount =
2195 GetPrivateProfileInt(Section, "BeepOverUsedCount", 5, FName);
2196 ts->BeepOverUsedTime =
2197 GetPrivateProfileInt(Section, "BeepOverUsedTime", 2, FName);
2198 ts->BeepSuppressTime =
2199 GetPrivateProfileInt(Section, "BeepSuppressTime", 5, FName);
2200
2201 // Max OSC string buffer size
2202 ts->MaxOSCBufferSize =
2203 GetPrivateProfileInt(Section, "MaxOSCBufferSize", 4096, FName);
2204
2205 ts->JoinSplitURL = GetOnOff(Section, "JoinSplitURL", FName, FALSE);
2206
2207 GetPrivateProfileString(Section, "JoinSplitURLIgnoreEOLChar", "\\", Temp, sizeof(Temp), FName);
2208 ts->JoinSplitURLIgnoreEOLChar = Temp[0];
2209
2210 // Debug modes.
2211 GetPrivateProfileString(Section, "DebugModes", "all", Temp, sizeof(Temp), FName);
2212 if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "all") == 0)
2213 ts->DebugModes = DBGF_ALL;
2214 else if (_stricmp(Temp, "off") == 0 || _stricmp(Temp, "none") == 0) {
2215 ts->DebugModes = DBGF_NONE;
2216 ts->Debug = FALSE;
2217 }
2218 else {
2219 ts->DebugModes = DBGF_NONE;
2220 for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
2221 if (_stricmp(Temp2, "normal") == 0)
2222 ts->DebugModes |= DBGF_NORM;
2223 else if (_stricmp(Temp2, "hex") == 0)
2224 ts->DebugModes |= DBGF_HEXD;
2225 else if (_stricmp(Temp2, "noout") == 0)
2226 ts->DebugModes |= DBGF_NOUT;
2227 }
2228 if (ts->DebugModes == DBGF_NONE)
2229 ts->Debug = FALSE;
2230 }
2231
2232 // Xmodem Timeout
2233 GetPrivateProfileString(Section, "XmodemTimeouts", "10,3,10,20,60", Temp, sizeof(Temp), FName);
2234 ts->XmodemTimeOutInit = GetNthNum2(Temp, 1, 10);
2235 if (ts->XmodemTimeOutInit < 1)
2236 ts->XmodemTimeOutInit = 1;
2237 ts->XmodemTimeOutInitCRC = GetNthNum2(Temp, 2, 3);
2238 if (ts->XmodemTimeOutInitCRC < 1)
2239 ts->XmodemTimeOutInitCRC = 1;
2240 ts->XmodemTimeOutShort = GetNthNum2(Temp, 3, 10);
2241 if (ts->XmodemTimeOutShort < 1)
2242 ts->XmodemTimeOutShort = 1;
2243 ts->XmodemTimeOutLong = GetNthNum2(Temp, 4, 20);
2244 if (ts->XmodemTimeOutLong < 1)
2245 ts->XmodemTimeOutLong = 1;
2246 ts->XmodemTimeOutVLong = GetNthNum2(Temp, 5, 60);
2247 if (ts->XmodemTimeOutVLong < 1)
2248 ts->XmodemTimeOutVLong = 1;
2249
2250 // Ymodem Timeout
2251 GetPrivateProfileString(Section, "YmodemTimeouts", "10,3,10,20,60", Temp, sizeof(Temp), FName);
2252 ts->YmodemTimeOutInit = GetNthNum2(Temp, 1, 10);
2253 if (ts->YmodemTimeOutInit < 1)
2254 ts->YmodemTimeOutInit = 1;
2255 ts->YmodemTimeOutInitCRC = GetNthNum2(Temp, 2, 3);
2256 if (ts->YmodemTimeOutInitCRC < 1)
2257 ts->YmodemTimeOutInitCRC = 1;
2258 ts->YmodemTimeOutShort = GetNthNum2(Temp, 3, 10);
2259 if (ts->YmodemTimeOutShort < 1)
2260 ts->YmodemTimeOutShort = 1;
2261 ts->YmodemTimeOutLong = GetNthNum2(Temp, 4, 20);
2262 if (ts->YmodemTimeOutLong < 1)
2263 ts->YmodemTimeOutLong = 1;
2264 ts->YmodemTimeOutVLong = GetNthNum2(Temp, 5, 60);
2265 if (ts->YmodemTimeOutVLong < 1)
2266 ts->YmodemTimeOutVLong = 1;
2267
2268 // Zmodem Timeout
2269 GetPrivateProfileString(Section, "ZmodemTimeouts", "10,0,10,3", Temp, sizeof(Temp), FName);
2270 ts->ZmodemTimeOutNormal = GetNthNum2(Temp, 1, 10);
2271 if (ts->ZmodemTimeOutNormal < 1)
2272 ts->ZmodemTimeOutNormal = 1;
2273 ts->ZmodemTimeOutTCPIP = GetNthNum2(Temp, 2, 0);
2274 if (ts->ZmodemTimeOutTCPIP < 0)
2275 ts->ZmodemTimeOutTCPIP = 0;
2276 ts->ZmodemTimeOutInit = GetNthNum2(Temp, 3, 10);
2277 if (ts->ZmodemTimeOutInit < 1)
2278 ts->ZmodemTimeOutInit = 1;
2279 ts->ZmodemTimeOutFin = GetNthNum2(Temp, 4, 3);
2280 if (ts->ZmodemTimeOutFin < 1)
2281 ts->ZmodemTimeOutFin = 1;
2282
2283 // Trim trailing new line character when pasting
2284 if (GetOnOff(Section, "TrimTrailingNLonPaste", FName, FALSE))
2285 ts->PasteFlag |= CPF_TRIM_TRAILING_NL;
2286
2287 // List Inactive Font
2288 ts->ListHiddenFonts = GetOnOff(Section, "ListHiddenFonts", FName, FALSE);
2289
2290 // ISO2022ShiftFunction
2291 GetPrivateProfileString(Section, "ISO2022ShiftFunction", "on", Temp, sizeof(Temp), FName);
2292 ts->ISO2022Flag = ISO2022_SHIFT_NONE;
2293 for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
2294 BOOL add=TRUE;
2295 char *p = Temp2, *p2;
2296 int mask = 0;
2297
2298 while (*p == ' ' || *p == '\t') {
2299 p++;
2300 }
2301 p2 = p + strlen(p);
2302 while (p2 > p) {
2303 p2--;
2304 if (*p2 != ' ' && *p2 != '\t') {
2305 break;
2306 }
2307 }
2308 *++p2 = 0;
2309
2310 if (*p == '-') {
2311 p++;
2312 add=FALSE;
2313 }
2314 else if (*p == '+') {
2315 p++;
2316 }
2317
2318 if (_stricmp(p, "on") == 0 || _stricmp(p, "all") == 0)
2319 ts->ISO2022Flag = ISO2022_SHIFT_ALL;
2320 else if (_stricmp(p, "off") == 0 || _stricmp(p, "none") == 0)
2321 ts->ISO2022Flag = ISO2022_SHIFT_NONE;
2322 else if (_stricmp(p, "SI") == 0 || _stricmp(p, "LS0") == 0)
2323 mask = ISO2022_SI;
2324 else if (_stricmp(p, "SO") == 0 || _stricmp(p, "LS1") == 0)
2325 mask = ISO2022_SO;
2326 else if (_stricmp(p, "LS2") == 0)
2327 mask = ISO2022_LS2;
2328 else if (_stricmp(p, "LS3") == 0)
2329 mask = ISO2022_LS3;
2330 else if (_stricmp(p, "LS1R") == 0)
2331 mask = ISO2022_LS1R;
2332 else if (_stricmp(p, "LS2R") == 0)
2333 mask = ISO2022_LS2R;
2334 else if (_stricmp(p, "LS3R") == 0)
2335 mask = ISO2022_LS3R;
2336 else if (_stricmp(p, "SS2") == 0)
2337 mask = ISO2022_SS2;
2338 else if (_stricmp(p, "SS3") == 0)
2339 mask = ISO2022_SS3;
2340
2341 if (mask) {
2342 if (add) {
2343 ts->ISO2022Flag |= mask;
2344 }
2345 else {
2346 ts->ISO2022Flag &= ~mask;
2347 }
2348 }
2349 }
2350
2351 // Terminal Speed (Used by telnet and ssh)
2352 GetPrivateProfileString(Section, "TerminalSpeed", "38400", Temp, sizeof(Temp), FName);
2353 GetNthNum(Temp, 1, &i);
2354 if (i > 0)
2355 ts->TerminalInputSpeed = i;
2356 else
2357 ts->TerminalInputSpeed = 38400;
2358 GetNthNum(Temp, 2, &i);
2359 if (i > 0)
2360 ts->TerminalOutputSpeed = i;
2361 else
2362 ts->TerminalOutputSpeed = ts->TerminalInputSpeed;
2363
2364 // Clear scroll buffer from remote -- special option
2365 if (GetOnOff(Section, "ClearScrollBufferFromRemote", FName, TRUE))
2366 ts->TermFlag |= TF_REMOTECLEARSBUFF;
2367
2368 // Delay for start of mouse selection
2369 ts->SelectStartDelay =
2370 GetPrivateProfileInt(Section, "MouseSelectStartDelay", 0, FName);
2371
2372 // Fallback to CP932 (Experimental)
2373 ts->FallbackToCP932 = GetOnOff(Section, "FallbackToCP932", FName, FALSE);
2374
2375 // CygTerm Configuration File
2376 ReadCygtermConfFile(ts);
2377
2378 // dialog font
2379 ReadFont3("Tera Term", "DlgFont", NULL, FName,
2380 ts->DialogFontName, sizeof(ts->DialogFontName),
2381 &ts->DialogFontPoint, &ts->DialogFontCharSet);
2382
2383 // Unicode����
2384 ts->UnicodeAmbiguousWidth = GetPrivateProfileInt(Section, "UnicodeAmbiguousWidth", 1, FName);
2385 if (ts->UnicodeAmbiguousWidth < 1 || 2 < ts->UnicodeAmbiguousWidth) {
2386 ts->UnicodeAmbiguousWidth = 1;
2387 }
2388 ts->UnicodeEmojiOverride = GetOnOff(Section, "UnicodeEmojiOverride", FName, FALSE);
2389 ts->UnicodeEmojiWidth = GetPrivateProfileInt(Section, "UnicodeEmojiWidth", 1, FName);
2390 if (ts->UnicodeEmojiWidth < 1 || 2 < ts->UnicodeEmojiWidth) {
2391 ts->UnicodeEmojiWidth = 1;
2392 }
2393
2394 #if INI_FILE_IS_UNICODE
2395 free((void *)FName);
2396 #endif
2397 }
2398
2399 void PASCAL WriteIniFile(PCHAR FNameA, PTTSet ts)
2400 {
2401 int i;
2402 char Temp[MAX_PATH];
2403 char buf[20];
2404 int ret;
2405 char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG], msg[MAX_UIMSG];
2406 #if INI_FILE_IS_UNICODE
2407 const wchar_t *FName = ToWcharA(FNameA);
2408 #else
2409 const char *FName = FNameA;
2410 #endif
2411
2412 /* version */
2413 ret = WritePrivateProfileString(Section, "Version", TT_VERSION_STR("."), FName);
2414 if (ret == 0) {
2415 // ini�t�@�C�����������������s�������A�G���[���b�Z�[�W���\�������B(2012.10.18 yutaka)
2416 ret = GetLastError();
2417 get_lang_msg("MSG_INI_WRITE_ERROR", uimsg, sizeof(uimsg), "Cannot write ini file", ts->UILanguageFile);
2418 _snprintf_s(msg, sizeof(msg), _TRUNCATE, "%s (%d)", uimsg, ret);
2419
2420 get_lang_msg("MSG_INI_ERROR", uimsg2, sizeof(uimsg2), "Tera Term: Error", ts->UILanguageFile);
2421
2422 MessageBox(NULL, msg, uimsg2, MB_ICONEXCLAMATION);
2423 }
2424
2425 /* Language */
2426 switch (ts->Language) {
2427 case IdJapanese:
2428 strncpy_s(Temp, sizeof(Temp), "Japanese", _TRUNCATE);
2429 break;
2430 case IdKorean:
2431 strncpy_s(Temp, sizeof(Temp), "Korean", _TRUNCATE);
2432 break;
2433 case IdRussian:
2434 strncpy_s(Temp, sizeof(Temp), "Russian", _TRUNCATE);
2435 break;
2436 case IdUtf8:
2437 strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
2438 break;
2439 default:
2440 strncpy_s(Temp, sizeof(Temp), "English", _TRUNCATE);
2441 }
2442
2443 WritePrivateProfileString(Section, "Language", Temp, FName);
2444
2445 /* Port type */
2446 WritePrivateProfileString(Section, "Port", (ts->PortType==IdSerial)?"serial":"tcpip", FName);
2447
2448 /* Save win position */
2449 if (ts->SaveVTWinPos) {
2450 /* VT win position */
2451 WriteInt2(Section, "VTPos", FName, ts->VTPos.x, ts->VTPos.y);
2452 }
2453
2454 /* VT terminal size */
2455 WriteInt2(Section, "TerminalSize", FName,
2456 ts->TerminalWidth, ts->TerminalHeight);
2457
2458 /* Terminal size = Window size */
2459 WriteOnOff(Section, "TermIsWin", FName, ts->TermIsWin);
2460
2461 /* Auto window resize flag */
2462 WriteOnOff(Section, "AutoWinResize", FName, ts->AutoWinResize);
2463
2464 /* CR Receive */
2465 if (ts->CRReceive == IdCRLF) {
2466 strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
2467 }
2468 else if (ts->CRReceive == IdLF) {
2469 strncpy_s(Temp, sizeof(Temp), "LF", _TRUNCATE);
2470 }
2471 else if (ts->CRReceive == IdAUTO) {
2472 strncpy_s(Temp, sizeof(Temp), "AUTO", _TRUNCATE);
2473 }
2474 else {
2475 strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
2476 }
2477 WritePrivateProfileString(Section, "CRReceive", Temp, FName);
2478
2479 /* CR Send */
2480 if (ts->CRSend == IdCRLF) {
2481 strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
2482 }
2483 else if (ts->CRSend == IdLF) {
2484 strncpy_s(Temp, sizeof(Temp), "LF", _TRUNCATE);
2485 }
2486 else {
2487 strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
2488 }
2489 WritePrivateProfileString(Section, "CRSend", Temp, FName);
2490
2491 /* Local echo */
2492 WriteOnOff(Section, "LocalEcho", FName, ts->LocalEcho);
2493
2494 /* Answerback */
2495 if ((ts->FTFlag & FT_BPAUTO) == 0) {
2496 Str2Hex(ts->Answerback, Temp, ts->AnswerbackLen,
2497 sizeof(Temp) - 1, TRUE);
2498 WritePrivateProfileString(Section, "Answerback", Temp, FName);
2499 }
2500
2501 /* Kanji Code (receive) */
2502 switch (ts->KanjiCode) {
2503 case IdEUC:
2504 strncpy_s(Temp, sizeof(Temp), "EUC", _TRUNCATE);
2505 break;
2506 case IdJIS:
2507 strncpy_s(Temp, sizeof(Temp), "JIS", _TRUNCATE);
2508 break;
2509 case IdUTF8:
2510 strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
2511 break;
2512 case IdUTF8m:
2513 strncpy_s(Temp, sizeof(Temp), "UTF-8m", _TRUNCATE);
2514 break;
2515 default:
2516 switch (ts->Language) {
2517 case IdJapanese:
2518 strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2519 break;
2520 case IdKorean:
2521 strncpy_s(Temp, sizeof(Temp), "KS5601", _TRUNCATE);
2522 break;
2523 default:
2524 strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2525 }
2526 }
2527 WritePrivateProfileString(Section, "KanjiReceive", Temp, FName);
2528
2529 /* Katakana (receive) */
2530 if (ts->JIS7Katakana == 1)
2531 strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
2532 else
2533 strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
2534
2535 WritePrivateProfileString(Section, "KatakanaReceive", Temp, FName);
2536
2537 /* Kanji Code (transmit) */
2538 switch (ts->KanjiCodeSend) {
2539 case IdEUC:
2540 strncpy_s(Temp, sizeof(Temp), "EUC", _TRUNCATE);
2541 break;
2542 case IdJIS:
2543 strncpy_s(Temp, sizeof(Temp), "JIS", _TRUNCATE);
2544 break;
2545 case IdUTF8:
2546 strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
2547 break;
2548 default:
2549 switch (ts->Language) {
2550 case IdJapanese:
2551 strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2552 break;
2553 case IdKorean:
2554 strncpy_s(Temp, sizeof(Temp), "KS5601", _TRUNCATE);
2555 break;
2556 default:
2557 strncpy_s(Temp, sizeof(Temp), "SJIS", _TRUNCATE);
2558 }
2559 }
2560 WritePrivateProfileString(Section, "KanjiSend", Temp, FName);
2561
2562 /* Katakana (transmit) */
2563 if (ts->JIS7KatakanaSend == 1)
2564 strncpy_s(Temp, sizeof(Temp), "7", _TRUNCATE);
2565 else
2566 strncpy_s(Temp, sizeof(Temp), "8", _TRUNCATE);
2567
2568 WritePrivateProfileString(Section, "KatakanaSend", Temp, FName);
2569
2570 /* KanjiIn */
2571 if (ts->KanjiIn == IdKanjiInA)
2572 strncpy_s(Temp, sizeof(Temp), "@", _TRUNCATE);
2573 else
2574 strncpy_s(Temp, sizeof(Temp), "B", _TRUNCATE);
2575
2576 WritePrivateProfileString(Section, "KanjiIn", Temp, FName);
2577
2578 /* KanjiOut */
2579 switch (ts->KanjiOut) {
2580 case IdKanjiOutB:
2581 strncpy_s(Temp, sizeof(Temp), "B", _TRUNCATE);
2582 break;
2583 case IdKanjiOutH:
2584 strncpy_s(Temp, sizeof(Temp), "H", _TRUNCATE);
2585 break;
2586 default:
2587 strncpy_s(Temp, sizeof(Temp), "J", _TRUNCATE);
2588 }
2589 WritePrivateProfileString(Section, "KanjiOut", Temp, FName);
2590
2591 // new configuration
2592 WriteInt(Section, "ConnectingTimeout", FName, ts->ConnectingTimeout);
2593
2594 WriteOnOff(Section, "DisablePasteMouseRButton", FName,
2595 (WORD) (ts->PasteFlag & CPF_DISABLE_RBUTTON));
2596
2597 WriteOnOff(Section, "DisablePasteMouseMButton", FName,
2598 (WORD) (ts->PasteFlag & CPF_DISABLE_MBUTTON));
2599
2600 WriteOnOff(Section, "ConfirmPasteMouseRButton", FName,
2601 (WORD) (ts->PasteFlag & CPF_CONFIRM_RBUTTON));
2602
2603 // added ConfirmChangePaste
2604 WriteOnOff(Section, "ConfirmChangePaste", FName,
2605 (WORD) (ts->PasteFlag & CPF_CONFIRM_CHANGEPASTE));
2606
2607 WriteOnOff(Section, "ConfirmChangePasteCR", FName,
2608 (WORD) (ts->PasteFlag & CPF_CONFIRM_CHANGEPASTE_CR));
2609
2610 WritePrivateProfileString(Section, "ConfirmChangePasteStringFile",
2611 ts->ConfirmChangePasteStringFile, FName);
2612
2613 // added ScrollWindowClearScreen
2614 WriteOnOff(Section, "ScrollWindowClearScreen", FName,
2615 ts->ScrollWindowClearScreen);
2616
2617 // added SelectOnlyByLButton (2007.11.20 maya)
2618 WriteOnOff(Section, "SelectOnlyByLButton", FName,
2619 ts->SelectOnlyByLButton);
2620 // added DisableAcceleratorSendBreak (2007.3.17 maya)
2621 WriteOnOff(Section, "DisableAcceleratorSendBreak", FName,
2622 ts->DisableAcceleratorSendBreak);
2623 WriteOnOff(Section, "EnableContinuedLineCopy", FName,
2624 ts->EnableContinuedLineCopy);
2625 WritePrivateProfileString(Section, "MouseCursor", ts->MouseCursorName,
2626 FName);
2627 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->AlphaBlendInactive);
2628 WritePrivateProfileString(Section, "AlphaBlend", Temp, FName);
2629 _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->AlphaBlendActive);
2630 WritePrivateProfileString(Section, "AlphaBlendActive", Temp, FName);
2631 WritePrivateProfileString(Section, "CygwinDirectory",
2632 ts->CygwinDirectory, FName);
2633 WritePrivateProfileString(Section, "ViewlogEditor", ts->ViewlogEditor,
2634 FName);
2635
2636 // ANSI color(2004.9.5 yutaka)
2637 Temp[0] = '\0';
2638 for (i = 0; i < 15; i++) {
2639 _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d,%d,%d,%d, ",
2640 i,
2641 GetRValue(ts->ANSIColor[i]),
2642 GetGValue(ts->ANSIColor[i]),
2643 GetBValue(ts->ANSIColor[i])
2644 );
2645 strncat_s(Temp, sizeof(Temp), buf, _TRUNCATE);
2646 }
2647 i = 15;
2648 _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d,%d,%d,%d",
2649 i,
2650 GetRValue(ts->ANSIColor[i]),
2651 GetGValue(ts->ANSIColor[i]),
2652 GetBValue(ts->ANSIColor[i])
2653 );
2654 strncat_s(Temp, sizeof(Temp), buf, _TRUNCATE);
2655 WritePrivateProfileString(Section, "ANSIColor", Temp, FName);
2656
2657 /* AutoWinChange VT<->TEK */
2658 WriteOnOff(Section, "AutoWinSwitch", FName, ts->AutoWinSwitch);
2659
2660 /* Terminal ID */
2661 id2str(TermList, ts->TerminalID, IdVT100, Temp, sizeof(Temp));
2662 WritePrivateProfileString(Section, "TerminalID", Temp, FName);
2663
2664 /* Russian character set (host) */
2665 id2str(RussList, ts->RussHost, IdKOI8, Temp, sizeof(Temp));
2666 WritePrivateProfileString(Section, "RussHost", Temp, FName);
2667
2668 /* Russian character set (client) */
2669 id2str(RussList, ts->RussClient, IdWindows, Temp, sizeof(Temp));
2670 WritePrivateProfileString(Section, "RussClient", Temp, FName);
2671
2672 /* Title text */
2673 WritePrivateProfileString(Section, "Title", ts->Title, FName);
2674
2675 /* Cursor shape */
2676 switch (ts->CursorShape) {
2677 case IdVCur:
2678 strncpy_s(Temp, sizeof(Temp), "vertical", _TRUNCATE);
2679 break;
2680 case IdHCur:
2681 strncpy_s(Temp, sizeof(Temp), "horizontal", _TRUNCATE);
2682 break;
2683 default:
2684 strncpy_s(Temp, sizeof(Temp), "block", _TRUNCATE);
2685 }
2686 WritePrivateProfileString(Section, "CursorShape", Temp, FName);
2687
2688 /* Hide title */
2689 WriteOnOff(Section, "HideTitle", FName, ts->HideTitle);
2690
2691 /* Popup menu */
2692 WriteOnOff(Section, "PopupMenu", FName, ts->PopupMenu);
2693
2694 /* PC-Style bold color mapping */
2695 WriteOnOff(Section, "PcBoldColor", FName,
2696 (WORD) (ts->ColorFlag & CF_PCBOLD16));
2697
2698 /* aixterm 16 colors mode */
2699 WriteOnOff(Section, "Aixterm16Color", FName,
2700 (WORD) (ts->ColorFlag & CF_AIXTERM16));
2701
2702 /* xterm 256 colors mode */
2703 WriteOnOff(Section, "Xterm256Color", FName,
2704 (WORD) (ts->ColorFlag & CF_XTERM256));
2705
2706 /* Enable scroll buffer */
2707 WriteOnOff(Section, "EnableScrollBuff", FName, ts->EnableScrollBuff);
2708
2709 /* Scroll buffer size */
2710 WriteInt(Section, "ScrollBuffSize", FName, ts->ScrollBuffSize);
2711
2712 /* VT Color */
2713 for (i = 0; i <= 1; i++) {
2714 if (ts->ColorFlag & CF_REVERSEVIDEO) {
2715 if (ts->ColorFlag & CF_REVERSECOLOR) {
2716 ts->TmpColor[0][i * 3] = GetRValue(ts->VTReverseColor[i]);
2717 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTReverseColor[i]);
2718 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTReverseColor[i]);
2719 }
2720 else {
2721 ts->TmpColor[0][i * 3] = GetRValue(ts->VTColor[!i]);
2722 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTColor[!i]);
2723 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTColor[!i]);
2724 }
2725 }
2726 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 WriteInt6(Section, "VTColor", FName,
2733 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
2734 ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
2735
2736 /* VT Bold Color */
2737 for (i = 0; i <= 1; i++) {
2738 if (ts->ColorFlag & CF_REVERSEVIDEO) {
2739 ts->TmpColor[0][i * 3] = GetRValue(ts->VTBoldColor[!i]);
2740 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBoldColor[!i]);
2741 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBoldColor[!i]);
2742 }
2743 else {
2744 ts->TmpColor[0][i * 3] = GetRValue(ts->VTBoldColor[i]);
2745 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBoldColor[i]);
2746 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBoldColor[i]);
2747 }
2748 }
2749 WriteInt6(Section, "VTBoldColor", FName,
2750 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
2751 ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
2752
2753 /* VT Blink Color */
2754 for (i = 0; i <= 1; i++) {
2755 if (ts->ColorFlag & CF_REVERSEVIDEO) {
2756 ts->TmpColor[0][i * 3] = GetRValue(ts->VTBlinkColor[!i]);
2757 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBlinkColor[!i]);
2758 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBlinkColor[!i]);
2759 }
2760 else {
2761 ts->TmpColor[0][i * 3] = GetRValue(ts->VTBlinkColor[i]);
2762 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTBlinkColor[i]);
2763 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTBlinkColor[i]);
2764 }
2765 }
2766 WriteInt6(Section, "VTBlinkColor", FName,
2767 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
2768 ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
2769
2770 /* VT Reverse Color */
2771 for (i = 0; i <= 1; i++) {
2772 if (ts->ColorFlag & CF_REVERSEVIDEO && ts->ColorFlag & CF_REVERSECOLOR) {
2773 ts->TmpColor[0][i * 3] = GetRValue(ts->VTColor[i]);
2774 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTColor[i]);
2775 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTColor[i]);
2776 }
2777 else {
2778 ts->TmpColor[0][i * 3] = GetRValue(ts->VTReverseColor[i]);
2779 ts->TmpColor[0][i * 3 + 1] = GetGValue(ts->VTReverseColor[i]);
2780 ts->TmpColor[0][i * 3 + 2] = GetBValue(ts->VTReverseColor[i]);
2781 }
2782 }
2783 WriteInt6(Section, "VTReverseColor", FName,
2784 ts->TmpColor[0][0], ts->TmpColor[0][1], ts->TmpColor[0][2],
2785 ts->TmpColor[0][3], ts->TmpColor[0][4], ts->TmpColor[0][5]);
2786
2787 WriteOnOff(Section, "EnableClickableUrl", FName,
2788 ts->EnableClickableUrl);
2789