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 9158 - (hide annotations) (download) (as text)
Mon Feb 15 15:02:58 2021 UTC (3 years, 1 month ago) by zmatsuo
File MIME type: text/x-csrc
File size: 146104 byte(s)
設定ファイル選択ダイアログをUnicode化

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