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