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 9244 - (hide annotations) (download) (as text)
Mon May 10 14:12:02 2021 UTC (2 years, 11 months ago) by zmatsuo
File MIME type: text/x-csrc
File size: 143384 byte(s)
キーボードに関連する部分を別ファイルに分離

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