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 9301 - (hide annotations) (download) (as text)
Sat Jun 12 15:26:01 2021 UTC (2 years, 9 months ago) by zmatsuo
File MIME type: text/x-csrc
File size: 143557 byte(s)
メモリリーク修正

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