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