Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /trunk/teraterm/ttpset/ttset.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9313 - (hide 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 doda 6806 /*
2     * Copyright (C) 1994-1998 T. Teranishi
3 nmaya 9048 * (C) 2004- TeraTerm Project
4 doda 6806 * All rights reserved.
5     *
6 doda 6841 * Redistribution and use in source and binary forms, with or without
7     * modification, are permitted provided that the following conditions
8     * are met:
9 doda 6806 *
10 doda 6841 * 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 doda 6806 *
18 doda 6841 * 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 doda 6806 */
29 maya 3227 /* 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 doda 4217 #include <ctype.h>
40 maya 6121 #include <errno.h>
41 zmatsuo 9301 #define _CRTDBG_MAP_ALLOC
42     #include <stdlib.h>
43     #include <crtdbg.h>
44    
45 maya 3227 #include "ttlib.h"
46     #include "tt_res.h"
47 doda 7091 #include "servicenames.h"
48 zmatsuo 9242 #include "codeconv.h"
49 zmatsuo 9309 #include "layer_for_unicode.h"
50 zmatsuo 9306 #include "win32helper.h"
51 maya 3227
52 zmatsuo 8279 #define DllExport __declspec(dllexport)
53     #include "ttset.h"
54    
55 maya 4874 #ifndef CLEARTYPE_QUALITY
56     #define CLEARTYPE_QUALITY 5
57     #endif
58 zmatsuo 9242 #define INI_FILE_IS_UNICODE 1
59 maya 4874
60 maya 3227 #define Section "Tera Term"
61 zmatsuo 9306 #define SectionW L"Tera Term"
62 maya 3227
63 atsue 5126 #define MaxStrLen (LONG)512
64    
65 maya 3227 static PCHAR far TermList[] =
66     { "VT100", "VT100J", "VT101", "VT102", "VT102J", "VT220J", "VT282",
67 doda 4084 "VT320", "VT382", "VT420", "VT520", "VT525", NULL };
68 maya 3227
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 yutakapon 8205
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 zmatsuo 8279 int WINAPI SerialPortConfconvertId2Str(enum serial_port_conf type, WORD id, PCHAR str, int strlen)
124 yutakapon 8205 {
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 zmatsuo 9242 /**
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 zmatsuo 9309 DWORD lenW = _GetPrivateProfileStringW(appW, keyW, defW, strW, lenW_max, filenameW);
176 zmatsuo 9242 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 zmatsuo 9301 free(strW);
194 zmatsuo 9242 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 zmatsuo 9309 BOOL r = _WritePrivateProfileStringW(appW, keyW, strW, filenameW);
206 zmatsuo 9242 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 zmatsuo 9309 UINT r = _GetPrivateProfileIntW(appW, keyW, def, filenameW);
220 zmatsuo 9242 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 yutakapon 8205 /*
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 maya 3227 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 maya 6386 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 maya 3227 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 maya 6386 case IDI_TTERM_3D:
382     icon = "tterm_3d";
383     break;
384     case IDI_VT_3D:
385     icon = "vt_3d";
386     break;
387 maya 3227 case IDI_CYGTERM:
388     icon = "cygterm";
389     break;
390     default:
391     icon = "Default";
392     }
393     strncpy_s(name, len, icon, _TRUNCATE);
394     }
395    
396 zmatsuo 9242 #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 maya 3227 {
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 zmatsuo 9242 #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 maya 3227 {
424 zmatsuo 9242 const char *on_off = (Flag != 0) ? "on" : "off";
425     WritePrivateProfileStringA(Sect, Key, on_off, FName);
426 maya 3227 }
427    
428 zmatsuo 9242 #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 maya 3227 {
434     char Temp[15];
435     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", i);
436 zmatsuo 9242 WritePrivateProfileStringA(Sect, Key, Temp, FName);
437 maya 3227 }
438    
439 zmatsuo 9242 #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 maya 3227 {
445     char Temp[15];
446     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%u", i);
447 zmatsuo 9242 WritePrivateProfileStringA(Sect, Key, Temp, FName);
448 maya 3227 }
449    
450 zmatsuo 9242 #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 maya 3227 {
456     char Temp[32];
457     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d", i1, i2);
458 zmatsuo 9242 WritePrivateProfileStringA(Sect, Key, Temp, FName);
459 maya 3227 }
460    
461 zmatsuo 9242 #if INI_FILE_IS_UNICODE
462     void WriteInt4(PCHAR Sect, PCHAR Key, const wchar_t *FName,
463 maya 3227 int i1, int i2, int i3, int i4)
464 zmatsuo 9242 #else
465     void WriteInt4(PCHAR Sect, PCHAR Key, const char *FName,
466     int i1, int i2, int i3, int i4)
467     #endif
468 maya 3227 {
469     char Temp[64];
470     _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d,%d,%d",
471     i1, i2, i3, i4);
472 zmatsuo 9242 WritePrivateProfileStringA(Sect, Key, Temp, FName);
473 maya 3227 }
474    
475 zmatsuo 9242 #if INI_FILE_IS_UNICODE
476     void WriteInt6(PCHAR Sect, PCHAR Key, const wchar_t *FName,
477 maya 3227 int i1, int i2, int i3, int i4, int i5, int i6)
478 zmatsuo 9242 #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 maya 3227 {
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 zmatsuo 9242 WritePrivateProfileStringA(Sect, Key, Temp, FName);
487 maya 3227 }
488    
489 zmatsuo 7705 // �t�H���g�������������A4�p�����[�^��
490 zmatsuo 9242 #if INI_FILE_IS_UNICODE
491     static void WriteFont(PCHAR Sect, PCHAR Key, const wchar_t *FName,
492 zmatsuo 7705 PCHAR Name, int x, int y, int charset)
493 zmatsuo 9242 #else
494     static void WriteFont(PCHAR Sect, PCHAR Key, const char *FName,
495     PCHAR Name, int x, int y, int charset)
496     #endif
497 maya 3227 {
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 zmatsuo 9242 WritePrivateProfileStringA(Sect, Key, Temp, FName);
505 maya 3227 }
506    
507 zmatsuo 7705 // �t�H���g�������������A4�p�����[�^��
508 zmatsuo 9242 #if INI_FILE_IS_UNICODE
509 zmatsuo 7705 static void ReadFont(
510 zmatsuo 9242 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 zmatsuo 7705 const char *Sect, const char *Key, const char *Default, const char *FName,
515     char *FontName, size_t FontNameLen, POINT *FontSize, int *FontCharSet)
516 zmatsuo 9242 #endif
517 zmatsuo 7705 {
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 zmatsuo 7706 *FontCharSet = 0;
527 zmatsuo 7705 } 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 zmatsuo 7706 // TODO ���������p�[�X����
533 zmatsuo 7705 }
534     }
535 yutakapon 6119
536 zmatsuo 7706 // �t�H���g�������������A3�p�����[�^��
537 zmatsuo 9242 #if INI_FILE_IS_UNICODE
538 zmatsuo 7706 static void ReadFont3(
539 zmatsuo 9242 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 zmatsuo 7706 const char *Sect, const char *Key, const char *Default, const char *FName,
544     char *FontName, size_t FontNameLen, int *FontPoint, int *FontCharSet)
545 zmatsuo 9242 #endif
546 zmatsuo 7706 {
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 yutakapon 6119 #define CYGTERM_FILE "cygterm.cfg" // CygTerm configuration file
564 yutakapon 6126 #define CYGTERM_FILE_MAXLINE 100
565 yutakapon 6119
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 zmatsuo 9242 size_t len = strlen(buf);
595 yutakapon 6119
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 yutakapon 6126 char *line[CYGTERM_FILE_MAXLINE];
672 zmatsuo 9242 int i, linenum;
673 yutakapon 6119
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 yutakapon 6126 // cygterm.cfg �������������A�������������������������������B
691     memset(line, 0, sizeof(line));
692     linenum = 0;
693 yutakapon 6119 fp = fopen(cfg, "r");
694 yutakapon 6126 if (fp) {
695     i = 0;
696     while (fgets(buf, sizeof(buf), fp) != NULL) {
697 zmatsuo 9242 size_t len = strlen(buf);
698 yutakapon 6126 if (buf[len - 1] == '\n')
699     buf[len - 1] = '\0';
700     if (i < CYGTERM_FILE_MAXLINE)
701 yutakapon 6127 line[i++] = _strdup(buf);
702 yutakapon 6126 else
703     break;
704     }
705     linenum = i;
706     fclose(fp);
707     }
708    
709     tmp_fp = fopen(cfg, "w");
710 yutakapon 6119 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 yutakapon 6126 if (linenum > 0) {
719     for (i = 0; i < linenum; i++) {
720     split_buffer(line[i], '=', &head, &body);
721 yutakapon 6119 if (head == NULL || body == NULL) {
722 yutakapon 6126 fprintf(tmp_fp, "%s\n", line[i]);
723 yutakapon 6119 }
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 yutakapon 6126 // �_�C���N�g���t�@�C���������������������������A���L�������s�v�B
806     #if 0
807 yutakapon 6119 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 yutakapon 6126 }
834 yutakapon 6119 #endif
835     }
836 yutakapon 6126
837     // �Y�������������t���[���������B
838     for (i = 0; i < linenum; i++) {
839     free(line[i]);
840     }
841    
842 yutakapon 6119 }
843    
844 zmatsuo 9242 void PASCAL ReadIniFile(PCHAR FNameA, PTTSet ts)
845 maya 3227 {
846     int i;
847     HDC TmpDC;
848 doda 8386 char Temp[MAX_PATH], Temp2[MAX_PATH], *p;
849 zmatsuo 9242 #if INI_FILE_IS_UNICODE
850     const wchar_t *FName = ToWcharA(FNameA);
851     #else
852     const char *FName = FNameA;
853     #endif
854 maya 3227
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 doda 3666 ts->FontFlag = 0; // Font flag
863 maya 3227 ts->PortFlag = 0; // Port flags
864 doda 3485 ts->WindowFlag = 0; // Window flags
865 doda 4700 ts->CtrlFlag = 0; // Control sequence flags
866 doda 6594 ts->PasteFlag = 0; // Clipboard Paste flags
867 maya 3227 ts->TelPort = 23;
868    
869 doda 3388 ts->DisableTCPEchoCR = FALSE;
870    
871 doda 8386 /*
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 maya 3227
886 doda 8387 // TTX �� �m�F�����������ATera Term ���o�[�W�������i�[��������
887     ts->RunningVersion = TT_VERSION_MAJOR * 10000 + TT_VERSION_MINOR;
888    
889 maya 3227 /* 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 maya 3401 else if (_stricmp(Temp,"UTF-8") == 0)
901     ts->Language = IdUtf8;
902 maya 3227 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 doda 3354 case LANG_KOREAN: // HKS
911 doda 6435 ts->Language = IdKorean;
912     break;
913 maya 3227 default:
914     ts->Language = IdEnglish;
915     }
916     }
917    
918     /* Port type */
919     GetPrivateProfileString(Section, "Port", "",
920     Temp, sizeof(Temp), FName);
921 doda 6696 if (_stricmp(Temp, "serial") == 0)
922 maya 3227 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 doda 6784 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 maya 3227
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 maya 4893 else if (_stricmp(Temp, "AUTO") == 0) {
970     ts->CRReceive = IdAUTO;
971     }
972 maya 3227 else {
973     ts->CRReceive = IdCR;
974     }
975     /* CR Send */
976     GetPrivateProfileString(Section, "CRSend", "",
977     Temp, sizeof(Temp), FName);
978 maya 6369 if (_stricmp(Temp, "CRLF") == 0) {
979 maya 3227 ts->CRSend = IdCRLF;
980 maya 6369 }
981     else if (_stricmp(Temp, "LF") == 0) {
982     ts->CRSend = IdLF;
983     }
984     else {
985 maya 3227 ts->CRSend = IdCR;
986 maya 6369 }
987 maya 3227 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 doda 3420 else if (_stricmp(Temp, "KS5601") == 0)
1011     ts->KanjiCode = IdSJIS;
1012 maya 3227 else
1013     ts->KanjiCode = IdSJIS;
1014 maya 3401 // KanjiCode/KanjiCodeSend �������� Language �����������l���u��������
1015     {
1016     WORD KanjiCode = ts->KanjiCode;
1017     ts->KanjiCode = KanjiCodeTranslate(ts->Language,KanjiCode);
1018     }
1019 maya 3227
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 doda 3420 else if (_stricmp(Temp, "KS5601") == 0)
1038     ts->KanjiCode = IdSJIS;
1039 maya 3227 else
1040     ts->KanjiCodeSend = IdSJIS;
1041 maya 3401 // KanjiCode/KanjiCodeSend �������� Language �����������l���u��������
1042     {
1043     WORD KanjiCodeSend = ts->KanjiCodeSend;
1044     ts->KanjiCodeSend = KanjiCodeTranslate(ts->Language,KanjiCodeSend);
1045     }
1046 maya 3227
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 doda 3660 if (GetOnOff(Section, "URLUnderline", FName, TRUE))
1193 doda 3666 ts->FontFlag |= FF_URLUNDERLINE;
1194 doda 3660
1195 maya 3227 /* 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 doda 4640 for (i = 0; i < n; i++) {
1236 maya 3227 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 zmatsuo 7705 ReadFont(Section, "VTFont", "Terminal,0,-13,1", FName,
1270     ts->VTFont, _countof(ts->VTFont),
1271     &ts->VTFontSize, &(ts->VTFontCharSet));
1272 maya 3227
1273     /* Bold font flag */
1274 doda 3666 if (GetOnOff(Section, "EnableBold", FName, TRUE))
1275     ts->FontFlag |= FF_BOLD;
1276 maya 3227
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 zmatsuo 7705 ReadFont(Section, "TEKFont", "Courier,0,-13,0", FName,
1284     ts->TEKFont, _countof(ts->TEKFont),
1285     &ts->TEKFontSize, &(ts->TEKFontCharSet));
1286 maya 3227
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 doda 4414 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 maya 3227
1308 doda 4414 // Windows95 �n�����E�� Alt ��������������
1309 yutakapon 6286 if (!IsWindowsNTKernel() && ts->MetaKey != IdMetaOff) {
1310 doda 4414 ts->MetaKey = IdMetaOn;
1311     }
1312    
1313 maya 3227 /* 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 maya 3874 ts->Baud = GetPrivateProfileInt(Section, "BaudRate", 9600, FName);
1331 maya 3227
1332     /* Parity */
1333     GetPrivateProfileString(Section, "Parity", "",
1334     Temp, sizeof(Temp), FName);
1335 yutakapon 8205 if (!SerialPortConfconvertStr2Id(COM_PARITY, Temp, &ts->Parity)) {
1336 maya 3227 ts->Parity = IdParityNone;
1337 yutakapon 8205 }
1338 maya 3227
1339     /* Data bit */
1340     GetPrivateProfileString(Section, "DataBit", "",
1341     Temp, sizeof(Temp), FName);
1342 yutakapon 8205 if (!SerialPortConfconvertStr2Id(COM_DATABIT, Temp, &ts->DataBit)) {
1343 maya 3227 ts->DataBit = IdDataBit8;
1344 yutakapon 8205 }
1345 maya 3227
1346     /* Stop bit */
1347     GetPrivateProfileString(Section, "StopBit", "",
1348     Temp, sizeof(Temp), FName);
1349 yutakapon 8205 if (!SerialPortConfconvertStr2Id(COM_STOPBIT, Temp, &ts->StopBit)) {
1350 maya 3227 ts->StopBit = IdStopBit1;
1351 yutakapon 8205 }
1352 maya 3227
1353     /* Flow control */
1354     GetPrivateProfileString(Section, "FlowCtrl", "",
1355     Temp, sizeof(Temp), FName);
1356 yutakapon 8205 if (!SerialPortConfconvertStr2Id(COM_FLOWCTRL, Temp, &ts->Flow)) {
1357 maya 3227 ts->Flow = IdFlowNone;
1358 yutakapon 8205 }
1359 maya 3227
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 doda 3887 /* Log binary flag */
1389     ts->LogBinary = GetOnOff(Section, "LogBinary", FName, FALSE);
1390    
1391 maya 3227 /* 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 yutakapon 5444 ts->LogAllBuffIncludedInFirst = GetOnOff(Section, "LogIncludeScreenBuffer", FName, FALSE);
1405 yutakapon 5392
1406 maya 6767 /* Timestamp format of Log each line */
1407 maya 6795 GetPrivateProfileString(Section, "LogTimestampFormat", "%Y-%m-%d %H:%M:%S.%N",
1408 maya 6767 ts->LogTimestampFormat, sizeof(ts->LogTimestampFormat),
1409     FName);
1410    
1411 doda 6947 /* 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 maya 6768
1425 doda 5312 /* File Transfer dialog visibility */
1426     ts->FTHideDialog = GetOnOff(Section, "FTHideDialog", FName, FALSE);
1427    
1428 maya 3227 /* 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 yutakapon 5171 /* 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 yutakapon 5206 /* Deferred Log Write Mode (2013.4.20 yutaka) */
1448     ts->DeferredLogWriteMode = GetOnOff(Section, "DeferredLogWriteMode", FName, TRUE);
1449 yutakapon 5171
1450 yutakapon 5206
1451 maya 3227 /* 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 doda 6219 ts->XmodemOpt = Xopt1kCRC;
1458 doda 6328 else if (_stricmp(Temp, "1ksum") == 0)
1459     ts->XmodemOpt = Xopt1kCksum;
1460 maya 3227 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 maya 6749 GetDownloadFolder(ts->FileDir, sizeof(ts->FileDir));
1476 maya 3227 else {
1477 maya 7951 char FileDirExpanded[MAX_PATH];
1478     ExpandEnvironmentStrings(ts->FileDir, FileDirExpanded, sizeof(FileDirExpanded));
1479 maya 3227 _getcwd(Temp, sizeof(Temp));
1480 maya 7951 if (_chdir(FileDirExpanded) != 0)
1481 maya 6749 GetDownloadFolder(ts->FileDir, sizeof(ts->FileDir));
1482 maya 3227 _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 yutakapon 4880 /* SCP���M���p�X (2012.4.6 yutaka) */
1491 doda 6457 GetPrivateProfileString(Section, "ScpSendDir", "",
1492 yutakapon 4880 ts->ScpSendDir, sizeof(ts->ScpSendDir), FName);
1493    
1494    
1495 maya 3227 /*--------------------------------------------------*/
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 maya 6083 // Detect disconnect/reconnect of serial port --- special option
1509 maya 6115 ts->AutoComPortReconnect = GetOnOff(Section, "AutoComPortReconnect", FName, TRUE);
1510 maya 6083
1511 maya 3227 // 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 doda 4082 GetPrivateProfileString(Section, "Beep", "", Temp, sizeof(Temp), FName);
1528 maya 3227 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 salarm 6349 /* 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 maya 3227 /* 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 maya 6079 // Enable multiple bytes send -- special option
1596 maya 6115 ts->FileSendHighSpeedMode = GetOnOff(Section, "FileSendHighSpeedMode", FName, TRUE);
1597 maya 6079
1598 maya 3227 // 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 yutakapon 4810 if (GetOnOff(Section, "KmtLongPacket", FName, FALSE))
1612     ts->KermitOpt |= KmtOptLongPacket;
1613     if (GetOnOff(Section, "KmtFileAttr", FName, FALSE))
1614     ts->KermitOpt |= KmtOptFileAttr;
1615 maya 3227
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 doda 6467 ts->MaxComPort = GetPrivateProfileInt(Section, "MaxComPort", 256, FName);
1628 maya 3227 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 doda 4397 /* �v�����^�p�����R�[�h�������t������ */
1654     if (GetOnOff(Section, "PrinterCtrlSequence", FName, TRUE))
1655     ts->TermFlag |= TF_PRINTERCTRL;
1656 yutakapon 4393
1657 maya 3227 /* Printer Font --- special option */
1658 zmatsuo 7705 ReadFont(Section, "PrnFont", NULL, FName,
1659     ts->PrnFont, _countof(ts->PrnFont),
1660     &ts->PrnFontSize, &(ts->PrnFontCharSet));
1661 maya 3227
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 maya 6921 /* Disable (convert to NL) Form Feed when printing */
1670     /* --- special option */
1671     ts->PrnConvFF =
1672     GetOnOff(Section, "PrnConvFF", FName, FALSE);
1673    
1674 maya 3227 /* 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 maya 5694 /* SendBreak time (in msec) -- special option */
1700     ts->SendBreakTime =
1701     GetPrivateProfileInt(Section, "SendBreakTime", 1000, FName);
1702    
1703 maya 3227 /* Startup macro -- special option */
1704 zmatsuo 9306 hGetPrivateProfileStringW(SectionW, L"StartupMacro", L"", FName, &ts->MacroFNW);
1705     WideCharToACP_t(ts->MacroFNW, ts->MacroFN, sizeof(ts->MacroFN));
1706 maya 3227
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 maya 6170 GetPrivateProfileInt(Section, "TitleFormat", 13, FName);
1755 maya 3227
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 yutakapon 3815 /* YMODEM ���M�R�}���h (2010.3.23 yutaka) */
1802     GetPrivateProfileString(Section, "YModemRcvCommand", "rb",
1803     ts->YModemRcvCommand, sizeof(ts->YModemRcvCommand), FName);
1804    
1805 maya 3227 /* 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 doda 6594 if (GetOnOff(Section, "DisablePasteMouseRButton", FName, FALSE))
1833     ts->PasteFlag |= CPF_DISABLE_RBUTTON;
1834 maya 3227
1835 doda 6594 if (GetOnOff(Section, "DisablePasteMouseMButton", FName, TRUE))
1836     ts->PasteFlag |= CPF_DISABLE_MBUTTON;
1837 maya 3227
1838 doda 6594 if (GetOnOff(Section, "ConfirmPasteMouseRButton", FName, FALSE))
1839     ts->PasteFlag |= CPF_CONFIRM_RBUTTON;
1840 maya 3227
1841 doda 6594 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 yutakapon 3535 GetPrivateProfileString(Section, "ConfirmChangePasteStringFile", "",
1848     Temp, sizeof(Temp), FName);
1849 doda 6594
1850 yutakapon 3535 strncpy_s(ts->ConfirmChangePasteStringFile, sizeof(ts->ConfirmChangePasteStringFile), Temp,
1851     _TRUNCATE);
1852 maya 3227
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 doda 6435 // mouse cursor
1870 maya 3227 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 zmatsuo 7390 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 doda 7447 GetPrivateProfileInt(Section, "AlphaBlendActive", ts->AlphaBlendInactive, FName);
1882 zmatsuo 7390 ts->AlphaBlendActive = max(0, ts->AlphaBlendActive);
1883     ts->AlphaBlendActive = min(255, ts->AlphaBlendActive);
1884 maya 3227
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 doda 4198 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 maya 3227
1901 zmatsuo 7674 // UI language message file (�����p�X)
1902 zmatsuo 9306 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 maya 3227
1908 zmatsuo 7674 // UI language message file (full path)
1909 zmatsuo 9306 ts->UILanguageFileW = GetUILanguageFileFullW(ts->HomeDirW, ts->UILanguageFileW_ini);
1910     WideCharToACP_t(ts->UILanguageFileW, ts->UILanguageFile, sizeof(ts->UILanguageFile));
1911 maya 3227
1912 zmatsuo 9306
1913 maya 3227 // 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 doda 6730 GetPrivateProfileString(Section, "MaximizedBugTweak", "2", Temp,
1939 doda 6671 sizeof(Temp), FName);
1940     if (_stricmp(Temp, "on") == 0) {
1941 doda 6730 ts->MaximizedBugTweak = 2;
1942 doda 6671 }
1943     else {
1944     ts->MaximizedBugTweak = atoi(Temp);
1945     }
1946 maya 3227
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 maya 3279
2018 maya 3283 // added DisableMenuSendBreak (2009.4.6 maya)
2019     ts->DisableMenuSendBreak =
2020     GetOnOff(Section, "DisableMenuSendBreak", FName, FALSE);
2021 maya 3282
2022 maya 3283 // added ClearScreenOnCloseConnection (2009.4.6 maya)
2023     ts->ClearScreenOnCloseConnection =
2024     GetOnOff(Section, "ClearScreenOnCloseConnection", FName, FALSE);
2025    
2026     // added DisableAcceleratorDuplicateSession (2009.4.6 maya)
2027 maya 3282 ts->DisableAcceleratorDuplicateSession =
2028     GetOnOff(Section, "DisableAcceleratorDuplicateSession", FName, FALSE);
2029 maya 3306
2030 maya 5684 ts->AcceleratorNewConnection =
2031     GetOnOff(Section, "AcceleratorNewConnection", FName, TRUE);
2032    
2033     ts->AcceleratorCygwinConnection =
2034     GetOnOff(Section, "AcceleratorCygwinConnection", FName, TRUE);
2035    
2036 maya 3964 // added DisableMenuDuplicateSession (2010.8.3 maya)
2037     ts->DisableMenuDuplicateSession =
2038     GetOnOff(Section, "DisableMenuDuplicateSession", FName, FALSE);
2039    
2040 maya 3965 // added DisableMenuNewConnection (2010.8.4 maya)
2041     ts->DisableMenuNewConnection =
2042     GetOnOff(Section, "DisableMenuNewConnection", FName, FALSE);
2043    
2044 maya 3306 // added PasteDelayPerLine (2009.4.12 maya)
2045     ts->PasteDelayPerLine =
2046     GetPrivateProfileInt(Section, "PasteDelayPerLine", 10, FName);
2047 maya 3315 {
2048     int tmp = min(max(0, ts->PasteDelayPerLine), 5000);
2049     ts->PasteDelayPerLine = tmp;
2050     }
2051 doda 3395
2052     // Font scaling -- test
2053     ts->FontScaling = GetOnOff(Section, "FontScaling", FName, FALSE);
2054 doda 3441
2055     // Meta sets MSB
2056 doda 3507 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 maya 3479 // Window control sequence
2065 doda 3485 if (GetOnOff(Section, "WindowCtrlSequence", FName, TRUE))
2066     ts->WindowFlag |= WF_WINDOWCHANGE;
2067 maya 3479
2068     // Cursor control sequence
2069 doda 3485 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 doda 3749 // Title report sequence
2077 doda 3747 GetPrivateProfileString(Section, "TitleReportSequence", "Empty", Temp, sizeof(Temp), FName);
2078 doda 3774 if (_stricmp(Temp, "accept") == 0)
2079     ts->WindowFlag |= IdTitleReportAccept;
2080     else if (_stricmp(Temp, "ignore") == 0 || _stricmp(Temp, "off") == 0)
2081 doda 3747 ts->WindowFlag &= ~WF_TITLEREPORT;
2082     else // empty
2083     ts->WindowFlag |= IdTitleReportEmpty;
2084 doda 3501
2085     // Line at a time mode
2086     ts->EnableLineMode = GetOnOff(Section, "EnableLineMode", FName, TRUE);
2087 doda 3721
2088     // Clear window on resize
2089     if (GetOnOff(Section, "ClearOnResize", FName, TRUE))
2090     ts->TermFlag |= TF_CLEARONRESIZE;
2091 doda 3743
2092     // Alternate Screen Buffer
2093     if (GetOnOff(Section, "AlternateScreenBuffer", FName, TRUE))
2094     ts->TermFlag |= TF_ALTSCR;
2095 doda 3969
2096     // IME status related cursor style
2097     if (GetOnOff(Section, "IMERelatedCursor", FName, FALSE))
2098     ts->WindowFlag |= WF_IMECURSORCHANGE;
2099 doda 4217
2100     // Terminal Unique ID
2101     GetPrivateProfileString(Section, "TerminalUID", "FFFFFFFF", Temp, sizeof(Temp), FName);
2102     if (strlen(Temp) == 8) {
2103 doda 4228 for (i=0; i<8 && isxdigit((unsigned char)Temp[i]); i++) {
2104 doda 4217 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 doda 4225
2122     // Lock Terminal UID
2123     if (GetOnOff(Section, "LockTUID", FName, TRUE))
2124     ts->TermFlag |= TF_LOCKTUID;
2125 doda 6435
2126 doda 4480 // Jump List
2127     ts->JumpList = GetOnOff(Section, "JumpList", FName, TRUE);
2128    
2129 doda 4699 // TabStopModifySequence
2130 doda 4687 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 doda 4700 // Clipboard Access from Remote
2154 doda 8384 ts->CtrlFlag &= ~CSF_CBMASK;
2155 doda 4700 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 doda 8384 else
2163     ts->CtrlFlag |= CSF_CBNONE; // ��������������
2164 doda 4700
2165 doda 6666 // Notify Clipboard Access from Remote
2166     ts->NotifyClipboardAccess = GetOnOff(Section, "NotifyClipboardAccess", FName, TRUE);
2167    
2168 doda 4281 // Use invalid DECRPSS (for testing)
2169     if (GetOnOff(Section, "UseInvalidDECRQSSResponse", FName, FALSE))
2170     ts->TermFlag |= TF_INVALIDDECRPSS;
2171 maya 4704
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 maya 4786
2178     // Exclusive Lock when open the log file
2179     ts->LogLockExclusive = GetOnOff(Section, "LogLockExclusive", FName, TRUE);
2180 maya 4874
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 doda 5316
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 doda 5410
2201     // Max OSC string buffer size
2202     ts->MaxOSCBufferSize =
2203     GetPrivateProfileInt(Section, "MaxOSCBufferSize", 4096, FName);
2204 doda 5428
2205 doda 5438 ts->JoinSplitURL = GetOnOff(Section, "JoinSplitURL", FName, FALSE);
2206 doda 5428
2207 doda 5438 GetPrivateProfileString(Section, "JoinSplitURLIgnoreEOLChar", "\\", Temp,