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 8106 - (hide annotations) (download) (as text)
Tue Sep 10 14:42:39 2019 UTC (4 years, 7 months ago) by yutakapon
File MIME type: text/x-csrc
File size: 141539 byte(s)
Eterm look-feel: 
- 「壁紙と画像を混合する」を設定できるようにした。
  -- teraterm.ini に BGIgnoreThemeFile エントリを追加した。デフォルトはoff。
- 壁紙と混合する画像ファイルをランダムに選択する際、無関係なファイルを選択することがある問題を修正した。

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