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 7706 - (hide annotations) (download) (as text)
Tue May 21 15:20:52 2019 UTC (4 years, 10 months ago) by zmatsuo
File MIME type: text/x-csrc
File size: 141060 byte(s)
ダイアログフォントの設定をメモリに持つようにした

- common/tttype.h に ダイアログフォントに関するメンバを追加
- SetDialogFont()#common/dlglib_cpp.cpp の仕様を変更
- CVTWindow::OnSetupDlgFont#teraterm/vtwin.cpp
  ダイアログフォント設定でiniファイルに書き込まないようにした
- ReadIniFile(),WriteIniFile()#ttpset/ttset.cで読み,書き追加
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     else
1074     ts->Flow = IdFlowNone;
1075    
1076     /* Delay per character */
1077     ts->DelayPerChar =
1078     GetPrivateProfileInt(Section, "DelayPerChar", 0, FName);
1079    
1080     /* Delay per line */
1081     ts->DelayPerLine =
1082     GetPrivateProfileInt(Section, "DelayPerLine", 0, FName);
1083    
1084     /* Telnet flag */
1085     ts->Telnet = GetOnOff(Section, "Telnet", FName, TRUE);
1086    
1087     /* Telnet terminal type */
1088     GetPrivateProfileString(Section, "TermType", "xterm", ts->TermType,
1089     sizeof(ts->TermType), FName);
1090    
1091     /* TCP port num */
1092     ts->TCPPort =
1093     GetPrivateProfileInt(Section, "TCPPort", ts->TelPort, FName);
1094    
1095     /* Auto window close flag */
1096     ts->AutoWinClose = GetOnOff(Section, "AutoWinClose", FName, TRUE);
1097    
1098     /* History list */
1099     ts->HistoryList = GetOnOff(Section, "HistoryList", FName, FALSE);
1100    
1101     /* File transfer binary flag */
1102     ts->TransBin = GetOnOff(Section, "TransBin", FName, FALSE);
1103    
1104 doda 3887 /* Log binary flag */
1105     ts->LogBinary = GetOnOff(Section, "LogBinary", FName, FALSE);
1106    
1107 maya 3227 /* Log append */
1108     ts->Append = GetOnOff(Section, "LogAppend", FName, FALSE);
1109    
1110     /* Log plain text (2005.5.7 yutaka) */
1111     ts->LogTypePlainText =
1112     GetOnOff(Section, "LogTypePlainText", FName, FALSE);
1113    
1114     /* Log with timestamp (2006.7.23 maya) */
1115     ts->LogTimestamp = GetOnOff(Section, "LogTimestamp", FName, FALSE);
1116    
1117     /* Log without transfer dialog */
1118     ts->LogHideDialog = GetOnOff(Section, "LogHideDialog", FName, FALSE);
1119    
1120 yutakapon 5444 ts->LogAllBuffIncludedInFirst = GetOnOff(Section, "LogIncludeScreenBuffer", FName, FALSE);
1121 yutakapon 5392
1122 maya 6767 /* Timestamp format of Log each line */
1123 maya 6795 GetPrivateProfileString(Section, "LogTimestampFormat", "%Y-%m-%d %H:%M:%S.%N",
1124 maya 6767 ts->LogTimestampFormat, sizeof(ts->LogTimestampFormat),
1125     FName);
1126    
1127 doda 6947 /* Timestamp type */
1128     GetPrivateProfileString(Section, "LogTimestampType", "", Temp, sizeof(Temp), FName);
1129     if (_stricmp(Temp, "UTC") == 0)
1130     ts->LogTimestampType = TIMESTAMP_UTC;
1131     else if (_stricmp(Temp, "LoggingElapsed") == 0)
1132     ts->LogTimestampType = TIMESTAMP_ELAPSED_LOGSTART;
1133     else if (_stricmp(Temp, "ConnectionElapsed") == 0)
1134     ts->LogTimestampType = TIMESTAMP_ELAPSED_CONNECTED;
1135     else if (_stricmp(Temp, "") == 0 && GetOnOff(Section, "LogTimestampUTC", FName, FALSE))
1136     // LogTimestampType ���������������� LogTimestampUTC ���l���Q������
1137     ts->LogTimestampType = TIMESTAMP_UTC;
1138     else
1139     ts->LogTimestampType = TIMESTAMP_LOCAL;
1140 maya 6768
1141 doda 5312 /* File Transfer dialog visibility */
1142     ts->FTHideDialog = GetOnOff(Section, "FTHideDialog", FName, FALSE);
1143    
1144 maya 3227 /* Default Log file name (2006.8.28 maya) */
1145     GetPrivateProfileString(Section, "LogDefaultName", "teraterm.log",
1146     ts->LogDefaultName, sizeof(ts->LogDefaultName),
1147     FName);
1148    
1149     /* Default Log file path (2007.5.30 maya) */
1150     GetPrivateProfileString(Section, "LogDefaultPath", "",
1151     ts->LogDefaultPath, sizeof(ts->LogDefaultPath),
1152     FName);
1153    
1154     /* Auto start logging (2007.5.31 maya) */
1155     ts->LogAutoStart = GetOnOff(Section, "LogAutoStart", FName, FALSE);
1156    
1157 yutakapon 5171 /* Log Rotate (2013.3.24 yutaka) */
1158     ts->LogRotate = GetPrivateProfileInt(Section, "LogRotate", 0, FName);
1159     ts->LogRotateSize = GetPrivateProfileInt(Section, "LogRotateSize", 0, FName);
1160     ts->LogRotateSizeType = GetPrivateProfileInt(Section, "LogRotateSizeType", 0, FName);
1161     ts->LogRotateStep = GetPrivateProfileInt(Section, "LogRotateStep", 0, FName);
1162    
1163 yutakapon 5206 /* Deferred Log Write Mode (2013.4.20 yutaka) */
1164     ts->DeferredLogWriteMode = GetOnOff(Section, "DeferredLogWriteMode", FName, TRUE);
1165 yutakapon 5171
1166 yutakapon 5206
1167 maya 3227 /* XMODEM option */
1168     GetPrivateProfileString(Section, "XmodemOpt", "",
1169     Temp, sizeof(Temp), FName);
1170     if (_stricmp(Temp, "crc") == 0)
1171     ts->XmodemOpt = XoptCRC;
1172     else if (_stricmp(Temp, "1k") == 0)
1173 doda 6219 ts->XmodemOpt = Xopt1kCRC;
1174 doda 6328 else if (_stricmp(Temp, "1ksum") == 0)
1175     ts->XmodemOpt = Xopt1kCksum;
1176 maya 3227 else
1177     ts->XmodemOpt = XoptCheck;
1178    
1179     /* XMODEM binary file */
1180     ts->XmodemBin = GetOnOff(Section, "XmodemBin", FName, TRUE);
1181    
1182     /* XMODEM ���M�R�}���h (2007.12.21 yutaka) */
1183     GetPrivateProfileString(Section, "XModemRcvCommand", "",
1184     ts->XModemRcvCommand,
1185     sizeof(ts->XModemRcvCommand), FName);
1186    
1187     /* Default directory for file transfer */
1188     GetPrivateProfileString(Section, "FileDir", "",
1189     ts->FileDir, sizeof(ts->FileDir), FName);
1190     if (strlen(ts->FileDir) == 0)
1191 maya 6749 GetDownloadFolder(ts->FileDir, sizeof(ts->FileDir));
1192 maya 3227 else {
1193     _getcwd(Temp, sizeof(Temp));
1194     if (_chdir(ts->FileDir) != 0)
1195 maya 6749 GetDownloadFolder(ts->FileDir, sizeof(ts->FileDir));
1196 maya 3227 _chdir(Temp);
1197     }
1198    
1199     /* filter on file send (2007.6.5 maya) */
1200     GetPrivateProfileString(Section, "FileSendFilter", "",
1201     ts->FileSendFilter, sizeof(ts->FileSendFilter),
1202     FName);
1203    
1204 yutakapon 4880 /* SCP���M���p�X (2012.4.6 yutaka) */
1205 doda 6457 GetPrivateProfileString(Section, "ScpSendDir", "",
1206 yutakapon 4880 ts->ScpSendDir, sizeof(ts->ScpSendDir), FName);
1207    
1208    
1209 maya 3227 /*--------------------------------------------------*/
1210     /* 8 bit control code flag -- special option */
1211     if (GetOnOff(Section, "Accept8BitCtrl", FName, TRUE))
1212     ts->TermFlag |= TF_ACCEPT8BITCTRL;
1213    
1214     /* Wrong sequence flag -- special option */
1215     if (GetOnOff(Section, "AllowWrongSequence", FName, FALSE))
1216     ts->TermFlag |= TF_ALLOWWRONGSEQUENCE;
1217    
1218     if (((ts->TermFlag & TF_ALLOWWRONGSEQUENCE) == 0) &&
1219     (ts->KanjiOut == IdKanjiOutH))
1220     ts->KanjiOut = IdKanjiOutJ;
1221    
1222 maya 6083 // Detect disconnect/reconnect of serial port --- special option
1223 maya 6115 ts->AutoComPortReconnect = GetOnOff(Section, "AutoComPortReconnect", FName, TRUE);
1224 maya 6083
1225 maya 3227 // Auto file renaming --- special option
1226     if (GetOnOff(Section, "AutoFileRename", FName, FALSE))
1227     ts->FTFlag |= FT_RENAME;
1228    
1229     // Auto invoking (character set->G0->GL) --- special option
1230     if (GetOnOff(Section, "AutoInvoke", FName, FALSE))
1231     ts->TermFlag |= TF_AUTOINVOKE;
1232    
1233     // Auto text copy --- special option
1234     ts->AutoTextCopy = GetOnOff(Section, "AutoTextCopy", FName, TRUE);
1235    
1236     /* Back wrap -- special option */
1237     if (GetOnOff(Section, "BackWrap", FName, FALSE))
1238     ts->TermFlag |= TF_BACKWRAP;
1239    
1240     /* Beep type -- special option */
1241 doda 4082 GetPrivateProfileString(Section, "Beep", "", Temp, sizeof(Temp), FName);
1242 maya 3227 if (_stricmp(Temp, "off") == 0)
1243     ts->Beep = IdBeepOff;
1244     else if (_stricmp(Temp, "visual") == 0)
1245     ts->Beep = IdBeepVisual;
1246     else
1247     ts->Beep = IdBeepOn;
1248    
1249     /* Beep on connection & disconnection -- special option */
1250     if (GetOnOff(Section, "BeepOnConnect", FName, FALSE))
1251     ts->PortFlag |= PF_BEEPONCONNECT;
1252    
1253     /* Auto B-Plus activation -- special option */
1254     if (GetOnOff(Section, "BPAuto", FName, FALSE))
1255     ts->FTFlag |= FT_BPAUTO;
1256     if ((ts->FTFlag & FT_BPAUTO) != 0) { /* Answerback */
1257     strncpy_s(ts->Answerback, sizeof(ts->Answerback), "\020++\0200",
1258     _TRUNCATE);
1259     ts->AnswerbackLen = 5;
1260     }
1261    
1262     /* B-Plus ESCCTL flag -- special option */
1263     if (GetOnOff(Section, "BPEscCtl", FName, FALSE))
1264     ts->FTFlag |= FT_BPESCCTL;
1265    
1266     /* B-Plus log -- special option */
1267     if (GetOnOff(Section, "BPLog", FName, FALSE))
1268     ts->LogFlag |= LOG_BP;
1269    
1270     /* Clear serial port buffer when port opening -- special option */
1271     ts->ClearComBuffOnOpen =
1272     GetOnOff(Section, "ClearComBuffOnOpen", FName, TRUE);
1273    
1274 salarm 6349 /* When serial port is specified with with /C= option and the port does not exist, Tera Term will wait for port connection. */
1275     ts->WaitCom = GetOnOff(Section, "WaitCom", FName, FALSE);
1276    
1277 maya 3227 /* Confirm disconnection -- special option */
1278     if (GetOnOff(Section, "ConfirmDisconnect", FName, TRUE))
1279     ts->PortFlag |= PF_CONFIRMDISCONN;
1280    
1281     /* Ctrl code in Kanji -- special option */
1282     if (GetOnOff(Section, "CtrlInKanji", FName, TRUE))
1283     ts->TermFlag |= TF_CTRLINKANJI;
1284    
1285     /* Debug flag -- special option */
1286     ts->Debug = GetOnOff(Section, "Debug", FName, FALSE);
1287    
1288     /* Delimiter list -- special option */
1289     GetPrivateProfileString(Section, "DelimList",
1290     "$20!\"#$24%&\'()*+,-./:;<=>?@[\\]^`{|}~",
1291     Temp, sizeof(Temp), FName);
1292     Hex2Str(Temp, ts->DelimList, sizeof(ts->DelimList));
1293    
1294     /* regard DBCS characters as delimiters -- special option */
1295     ts->DelimDBCS = GetOnOff(Section, "DelimDBCS", FName, TRUE);
1296    
1297     // Enable popup menu -- special option
1298     if (!GetOnOff(Section, "EnablePopupMenu", FName, TRUE))
1299     ts->MenuFlag |= MF_NOPOPUP;
1300    
1301     // Enable "Show menu" -- special option
1302     if (!GetOnOff(Section, "EnableShowMenu", FName, TRUE))
1303     ts->MenuFlag |= MF_NOSHOWMENU;
1304    
1305     // Enable the status line -- special option
1306     if (GetOnOff(Section, "EnableStatusLine", FName, TRUE))
1307     ts->TermFlag |= TF_ENABLESLINE;
1308    
1309 maya 6079 // Enable multiple bytes send -- special option
1310 maya 6115 ts->FileSendHighSpeedMode = GetOnOff(Section, "FileSendHighSpeedMode", FName, TRUE);
1311 maya 6079
1312 maya 3227 // fixed JIS --- special
1313     if (GetOnOff(Section, "FixedJIS", FName, FALSE))
1314     ts->TermFlag |= TF_FIXEDJIS;
1315    
1316     /* IME Flag -- special option */
1317     ts->UseIME = GetOnOff(Section, "IME", FName, TRUE);
1318    
1319     /* IME-inline Flag -- special option */
1320     ts->IMEInline = GetOnOff(Section, "IMEInline", FName, TRUE);
1321    
1322     /* Kermit log -- special option */
1323     if (GetOnOff(Section, "KmtLog", FName, FALSE))
1324     ts->LogFlag |= LOG_KMT;
1325 yutakapon 4810 if (GetOnOff(Section, "KmtLongPacket", FName, FALSE))
1326     ts->KermitOpt |= KmtOptLongPacket;
1327     if (GetOnOff(Section, "KmtFileAttr", FName, FALSE))
1328     ts->KermitOpt |= KmtOptFileAttr;
1329 maya 3227
1330     // Enable language selection -- special option
1331     if (!GetOnOff(Section, "LanguageSelection", FName, TRUE))
1332     ts->MenuFlag |= MF_NOLANGUAGE;
1333    
1334     /* Maximum scroll buffer size -- special option */
1335     ts->ScrollBuffMax =
1336     GetPrivateProfileInt(Section, "MaxBuffSize", 10000, FName);
1337     if (ts->ScrollBuffMax < 24)
1338     ts->ScrollBuffMax = 10000;
1339    
1340     /* Max com port number -- special option */
1341 doda 6467 ts->MaxComPort = GetPrivateProfileInt(Section, "MaxComPort", 256, FName);
1342 maya 3227 if (ts->MaxComPort < 4)
1343     ts->MaxComPort = 4;
1344     if (ts->MaxComPort > MAXCOMPORT)
1345     ts->MaxComPort = MAXCOMPORT;
1346     if ((ts->ComPort < 1) || (ts->ComPort > ts->MaxComPort))
1347     ts->ComPort = 1;
1348    
1349     /* Non-blinking cursor -- special option */
1350     ts->NonblinkingCursor =
1351     GetOnOff(Section, "NonblinkingCursor", FName, FALSE);
1352    
1353     // �t�H�[�J�X���������|���S���J�[�\�� (2008.1.24 yutaka)
1354     ts->KillFocusCursor =
1355     GetOnOff(Section, "KillFocusCursor", FName, TRUE);
1356    
1357     /* Delay for pass-thru printing activation */
1358     /* -- special option */
1359     ts->PassThruDelay =
1360     GetPrivateProfileInt(Section, "PassThruDelay", 3, FName);
1361    
1362     /* Printer port for pass-thru printing */
1363     /* -- special option */
1364     GetPrivateProfileString(Section, "PassThruPort", "",
1365     ts->PrnDev, sizeof(ts->PrnDev), FName);
1366    
1367 doda 4397 /* �v�����^�p�����R�[�h�������t������ */
1368     if (GetOnOff(Section, "PrinterCtrlSequence", FName, TRUE))
1369     ts->TermFlag |= TF_PRINTERCTRL;
1370 yutakapon 4393
1371 maya 3227 /* Printer Font --- special option */
1372 zmatsuo 7705 ReadFont(Section, "PrnFont", NULL, FName,
1373     ts->PrnFont, _countof(ts->PrnFont),
1374     &ts->PrnFontSize, &(ts->PrnFontCharSet));
1375 maya 3227
1376     // Page margins (left, right, top, bottom) for printing
1377     // -- special option
1378     GetPrivateProfileString(Section, "PrnMargin", "50,50,50,50",
1379     Temp, sizeof(Temp), FName);
1380     for (i = 0; i <= 3; i++)
1381     GetNthNum(Temp, 1 + i, &ts->PrnMargin[i]);
1382    
1383 maya 6921 /* Disable (convert to NL) Form Feed when printing */
1384     /* --- special option */
1385     ts->PrnConvFF =
1386     GetOnOff(Section, "PrnConvFF", FName, FALSE);
1387    
1388 maya 3227 /* Quick-VAN log -- special option */
1389     if (GetOnOff(Section, "QVLog", FName, FALSE))
1390     ts->LogFlag |= LOG_QV;
1391    
1392     /* Quick-VAN window size -- special */
1393     ts->QVWinSize = GetPrivateProfileInt(Section, "QVWinSize", 8, FName);
1394    
1395     /* Russian character set (print) -- special option */
1396     GetPrivateProfileString(Section, "RussPrint", "",
1397     Temp, sizeof(Temp), FName);
1398     ts->RussPrint = str2id(RussList, Temp, IdWindows);
1399    
1400     /* Scroll threshold -- special option */
1401     ts->ScrollThreshold =
1402     GetPrivateProfileInt(Section, "ScrollThreshold", 12, FName);
1403    
1404     ts->MouseWheelScrollLine =
1405     GetPrivateProfileInt(Section, "MouseWheelScrollLine", 3, FName);
1406    
1407     // Select on activate -- special option
1408     ts->SelOnActive = GetOnOff(Section, "SelectOnActivate", FName, TRUE);
1409    
1410     /* Send 8bit control sequence -- special option */
1411     ts->Send8BitCtrl = GetOnOff(Section, "Send8BitCtrl", FName, FALSE);
1412    
1413 maya 5694 /* SendBreak time (in msec) -- special option */
1414     ts->SendBreakTime =
1415     GetPrivateProfileInt(Section, "SendBreakTime", 1000, FName);
1416    
1417 maya 3227 /* Startup macro -- special option */
1418     GetPrivateProfileString(Section, "StartupMacro", "",
1419     ts->MacroFN, sizeof(ts->MacroFN), FName);
1420    
1421     /* TEK GIN Mouse keycode -- special option */
1422     ts->GINMouseCode =
1423     GetPrivateProfileInt(Section, "TEKGINMouseCode", 32, FName);
1424    
1425     /* Telnet Auto Detect -- special option */
1426     ts->TelAutoDetect = GetOnOff(Section, "TelAutoDetect", FName, TRUE);
1427    
1428     /* Telnet binary flag -- special option */
1429     ts->TelBin = GetOnOff(Section, "TelBin", FName, FALSE);
1430    
1431     /* Telnet Echo flag -- special option */
1432     ts->TelEcho = GetOnOff(Section, "TelEcho", FName, FALSE);
1433    
1434     /* Telnet log -- special option */
1435     if (GetOnOff(Section, "TelLog", FName, FALSE))
1436     ts->LogFlag |= LOG_TEL;
1437    
1438     /* TCP port num for telnet -- special option */
1439     ts->TelPort = GetPrivateProfileInt(Section, "TelPort", 23, FName);
1440    
1441     /* Telnet keep-alive packet(NOP command) interval -- special option */
1442     ts->TelKeepAliveInterval =
1443     GetPrivateProfileInt(Section, "TelKeepAliveInterval", 300, FName);
1444    
1445     /* Max number of broadcast commad history */
1446     ts->MaxBroadcatHistory =
1447     GetPrivateProfileInt(Section, "MaxBroadcatHistory", 99, FName);
1448    
1449     /* Local echo for non-telnet */
1450     ts->TCPLocalEcho = GetOnOff(Section, "TCPLocalEcho", FName, FALSE);
1451    
1452     /* "new-line (transmit)" option for non-telnet -- special option */
1453     GetPrivateProfileString(Section, "TCPCRSend", "",
1454     Temp, sizeof(Temp), FName);
1455     if (_stricmp(Temp, "CR") == 0)
1456     ts->TCPCRSend = IdCR;
1457     else if (_stricmp(Temp, "CRLF") == 0)
1458     ts->TCPCRSend = IdCRLF;
1459     else
1460     ts->TCPCRSend = 0; // disabled
1461    
1462     /* Use text (background) color for "white (black)" --- special option */
1463     if (GetOnOff(Section, "UseTextColor", FName, FALSE))
1464     ts->ColorFlag |= CF_USETEXTCOLOR;
1465    
1466     /* Title format -- special option */
1467     ts->TitleFormat =
1468 maya 6170 GetPrivateProfileInt(Section, "TitleFormat", 13, FName);
1469 maya 3227
1470     /* VT Compatible Tab -- special option */
1471     ts->VTCompatTab = GetOnOff(Section, "VTCompatTab", FName, FALSE);
1472    
1473     /* VT Font space --- special option */
1474     GetPrivateProfileString(Section, "VTFontSpace", "0,0,0,0",
1475     Temp, sizeof(Temp), FName);
1476     GetNthNum(Temp, 1, &ts->FontDX);
1477     GetNthNum(Temp, 2, &ts->FontDW);
1478     GetNthNum(Temp, 3, &ts->FontDY);
1479     GetNthNum(Temp, 4, &ts->FontDH);
1480     if (ts->FontDX < 0)
1481     ts->FontDX = 0;
1482     if (ts->FontDW < 0)
1483     ts->FontDW = 0;
1484     ts->FontDW = ts->FontDW + ts->FontDX;
1485     if (ts->FontDY < 0)
1486     ts->FontDY = 0;
1487     if (ts->FontDH < 0)
1488     ts->FontDH = 0;
1489     ts->FontDH = ts->FontDH + ts->FontDY;
1490    
1491     // VT-print scaling factors (pixels per inch) --- special option
1492     GetPrivateProfileString(Section, "VTPPI", "0,0",
1493     Temp, sizeof(Temp), FName);
1494     GetNthNum(Temp, 1, (int far *) &ts->VTPPI.x);
1495     GetNthNum(Temp, 2, (int far *) &ts->VTPPI.y);
1496    
1497     // TEK-print scaling factors (pixels per inch) --- special option
1498     GetPrivateProfileString(Section, "TEKPPI", "0,0",
1499     Temp, sizeof(Temp), FName);
1500     GetNthNum(Temp, 1, (int far *) &ts->TEKPPI.x);
1501     GetNthNum(Temp, 2, (int far *) &ts->TEKPPI.y);
1502    
1503     // Show "Window" menu -- special option
1504     if (GetOnOff(Section, "WindowMenu", FName, TRUE))
1505     ts->MenuFlag |= MF_SHOWWINMENU;
1506    
1507     /* XMODEM log -- special option */
1508     if (GetOnOff(Section, "XmodemLog", FName, FALSE))
1509     ts->LogFlag |= LOG_X;
1510    
1511     /* YMODEM log -- special option */
1512     if (GetOnOff(Section, "YmodemLog", FName, FALSE))
1513     ts->LogFlag |= LOG_Y;
1514    
1515 yutakapon 3815 /* YMODEM ���M�R�}���h (2010.3.23 yutaka) */
1516     GetPrivateProfileString(Section, "YModemRcvCommand", "rb",
1517     ts->YModemRcvCommand, sizeof(ts->YModemRcvCommand), FName);
1518    
1519 maya 3227 /* Auto ZMODEM activation -- special option */
1520     if (GetOnOff(Section, "ZmodemAuto", FName, FALSE))
1521     ts->FTFlag |= FT_ZAUTO;
1522    
1523     /* ZMODEM data subpacket length for sending -- special */
1524     ts->ZmodemDataLen =
1525     GetPrivateProfileInt(Section, "ZmodemDataLen", 1024, FName);
1526     /* ZMODEM window size for sending -- special */
1527     ts->ZmodemWinSize =
1528     GetPrivateProfileInt(Section, "ZmodemWinSize", 32767, FName);
1529    
1530     /* ZMODEM ESCCTL flag -- special option */
1531     if (GetOnOff(Section, "ZmodemEscCtl", FName, FALSE))
1532     ts->FTFlag |= FT_ZESCCTL;
1533    
1534     /* ZMODEM log -- special option */
1535     if (GetOnOff(Section, "ZmodemLog", FName, FALSE))
1536     ts->LogFlag |= LOG_Z;
1537    
1538     /* ZMODEM ���M�R�}���h (2007.12.21 yutaka) */
1539     GetPrivateProfileString(Section, "ZModemRcvCommand", "rz",
1540     ts->ZModemRcvCommand, sizeof(ts->ZModemRcvCommand), FName);
1541    
1542     /* Enable continued-line copy -- special option */
1543     ts->EnableContinuedLineCopy =
1544     GetOnOff(Section, "EnableContinuedLineCopy", FName, FALSE);
1545    
1546 doda 6594 if (GetOnOff(Section, "DisablePasteMouseRButton", FName, FALSE))
1547     ts->PasteFlag |= CPF_DISABLE_RBUTTON;
1548 maya 3227
1549 doda 6594 if (GetOnOff(Section, "DisablePasteMouseMButton", FName, TRUE))
1550     ts->PasteFlag |= CPF_DISABLE_MBUTTON;
1551 maya 3227
1552 doda 6594 if (GetOnOff(Section, "ConfirmPasteMouseRButton", FName, FALSE))
1553     ts->PasteFlag |= CPF_CONFIRM_RBUTTON;
1554 maya 3227
1555 doda 6594 if (GetOnOff(Section, "ConfirmChangePaste", FName, TRUE))
1556     ts->PasteFlag |= CPF_CONFIRM_CHANGEPASTE;
1557    
1558     if (GetOnOff(Section, "ConfirmChangePasteCR", FName, TRUE))
1559     ts->PasteFlag |= CPF_CONFIRM_CHANGEPASTE_CR;
1560    
1561 yutakapon 3535 GetPrivateProfileString(Section, "ConfirmChangePasteStringFile", "",
1562     Temp, sizeof(Temp), FName);
1563 doda 6594
1564 yutakapon 3535 strncpy_s(ts->ConfirmChangePasteStringFile, sizeof(ts->ConfirmChangePasteStringFile), Temp,
1565     _TRUNCATE);
1566 maya 3227
1567     // added ScrollWindowClearScreen (2008.5.3 yutaka)
1568     ts->ScrollWindowClearScreen =
1569     GetOnOff(Section, "ScrollWindowClearScreen", FName, TRUE);
1570    
1571     // added SelectOnlyByLButton (2007.11.20 maya)
1572     ts->SelectOnlyByLButton =
1573     GetOnOff(Section, "SelectOnlyByLButton", FName, TRUE);
1574    
1575     // added DisableAcceleratorSendBreak (2007.3.17 maya)
1576     ts->DisableAcceleratorSendBreak =
1577     GetOnOff(Section, "DisableAcceleratorSendBreak", FName, FALSE);
1578    
1579     // WinSock connecting timeout value (2007.1.11 yutaka)
1580     ts->ConnectingTimeout =
1581     GetPrivateProfileInt(Section, "ConnectingTimeout", 0, FName);
1582    
1583 doda 6435 // mouse cursor
1584 maya 3227 GetPrivateProfileString(Section, "MouseCursor", "IBEAM",
1585     Temp, sizeof(Temp), FName);
1586     strncpy_s(ts->MouseCursorName, sizeof(ts->MouseCursorName), Temp,
1587     _TRUNCATE);
1588    
1589     // Translucent window
1590 zmatsuo 7390 ts->AlphaBlendInactive =
1591     GetPrivateProfileInt(Section, "AlphaBlend", 255, FName);
1592     ts->AlphaBlendInactive = max(0, ts->AlphaBlendInactive);
1593     ts->AlphaBlendInactive = min(255, ts->AlphaBlendInactive);
1594     ts->AlphaBlendActive =
1595 doda 7447 GetPrivateProfileInt(Section, "AlphaBlendActive", ts->AlphaBlendInactive, FName);
1596 zmatsuo 7390 ts->AlphaBlendActive = max(0, ts->AlphaBlendActive);
1597     ts->AlphaBlendActive = min(255, ts->AlphaBlendActive);
1598 maya 3227
1599     // Cygwin install path
1600     GetPrivateProfileString(Section, "CygwinDirectory ", "c:\\cygwin",
1601     Temp, sizeof(Temp), FName);
1602     strncpy_s(ts->CygwinDirectory, sizeof(ts->CygwinDirectory), Temp,
1603     _TRUNCATE);
1604    
1605     // Viewlog Editor path
1606 doda 4198 if (GetWindowsDirectory(Temp, sizeof(Temp)) + 13 < sizeof(Temp)) { // "\\notepad.exe"(12) + NUL(1)
1607     strncat_s(Temp, sizeof(Temp), "\\notepad.exe", _TRUNCATE);
1608     }
1609     else {
1610     Temp[0] = '\0';
1611     }
1612     GetPrivateProfileString(Section, "ViewlogEditor ", Temp,
1613     ts->ViewlogEditor, sizeof(ts->ViewlogEditor), FName);
1614 maya 3227
1615     // Locale for UTF-8
1616     GetPrivateProfileString(Section, "Locale ", DEFAULT_LOCALE,
1617     Temp, sizeof(Temp), FName);
1618     strncpy_s(ts->Locale, sizeof(ts->Locale), Temp, _TRUNCATE);
1619    
1620 zmatsuo 7674 // UI language message file (�����p�X)
1621 maya 3227 GetPrivateProfileString(Section, "UILanguageFile", "lang\\Default.lng",
1622 zmatsuo 7674 ts->UILanguageFile_ini, sizeof(ts->UILanguageFile_ini), FName);
1623 maya 3227
1624 zmatsuo 7674 // UI language message file (full path)
1625     GetUILanguageFileFull(ts->HomeDir, ts->UILanguageFile_ini,
1626     ts->UILanguageFile, sizeof(ts->UILanguageFile));
1627 maya 3227
1628     // Broadcast Command History (2007.3.3 maya)
1629     ts->BroadcastCommandHistory =
1630     GetOnOff(Section, "BroadcastCommandHistory", FName, FALSE);
1631    
1632     // 337: 2007/03/20 Accept Broadcast
1633     ts->AcceptBroadcast =
1634     GetOnOff(Section, "AcceptBroadcast", FName, TRUE);
1635    
1636     // Confirm send a file when drag and drop (2007.12.28 maya)
1637     ts->ConfirmFileDragAndDrop =
1638     GetOnOff(Section, "ConfirmFileDragAndDrop", FName, TRUE);
1639    
1640     // Translate mouse wheel to cursor key when application cursor mode
1641     ts->TranslateWheelToCursor =
1642     GetOnOff(Section, "TranslateWheelToCursor", FName, TRUE);
1643    
1644     // Display "New Connection" dialog on startup (2008.1.18 maya)
1645     ts->HostDialogOnStartup =
1646     GetOnOff(Section, "HostDialogOnStartup", FName, TRUE);
1647    
1648     // Mouse event tracking
1649     ts->MouseEventTracking =
1650     GetOnOff(Section, "MouseEventTracking", FName, TRUE);
1651    
1652     // Maximized bug tweak
1653 doda 6730 GetPrivateProfileString(Section, "MaximizedBugTweak", "2", Temp,
1654 doda 6671 sizeof(Temp), FName);
1655     if (_stricmp(Temp, "on") == 0) {
1656 doda 6730 ts->MaximizedBugTweak = 2;
1657 doda 6671 }
1658     else {
1659     ts->MaximizedBugTweak = atoi(Temp);
1660     }
1661 maya 3227
1662     // Convert Unicode symbol characters to DEC Special characters
1663     ts->UnicodeDecSpMapping =
1664     GetPrivateProfileInt(Section, "UnicodeToDecSpMapping", 3, FName);
1665    
1666     // VT Window Icon
1667     GetPrivateProfileString(Section, "VTIcon", "Default",
1668     Temp, sizeof(Temp), FName);
1669     ts->VTIcon = IconName2IconId(Temp);
1670    
1671     // Tek Window Icon
1672     GetPrivateProfileString(Section, "TEKIcon", "Default",
1673     Temp, sizeof(Temp), FName);
1674     ts->TEKIcon = IconName2IconId(Temp);
1675    
1676     // Unknown Unicode Character
1677     ts->UnknownUnicodeCharaAsWide =
1678     GetOnOff(Section, "UnknownUnicodeCharacterAsWide", FName, FALSE);
1679    
1680     #ifdef USE_NORMAL_BGCOLOR
1681     // UseNormalBGColor
1682     ts->UseNormalBGColor =
1683     GetOnOff(Section, "UseNormalBGColor", FName, FALSE);
1684     // 2006/03/11 by 337
1685     if (ts->UseNormalBGColor) {
1686     ts->VTBoldColor[1] =
1687     ts->VTBlinkColor[1] = ts->URLColor[1] = ts->VTColor[1];
1688     }
1689     #endif
1690    
1691     // AutoScrollOnlyInBottomLine
1692     ts->AutoScrollOnlyInBottomLine =
1693     GetOnOff(Section, "AutoScrollOnlyInBottomLine", FName, FALSE);
1694    
1695     // Accept remote-controlled window title changing
1696     GetPrivateProfileString(Section, "AcceptTitleChangeRequest", "overwrite",
1697     Temp, sizeof(Temp), FName);
1698     if (_stricmp(Temp, "overwrite") == 0 || _stricmp(Temp, "on") == 0)
1699     ts->AcceptTitleChangeRequest = IdTitleChangeRequestOverwrite;
1700     else if (_stricmp(Temp, "ahead") == 0)
1701     ts->AcceptTitleChangeRequest = IdTitleChangeRequestAhead;
1702     else if (_stricmp(Temp, "last") == 0)
1703     ts->AcceptTitleChangeRequest = IdTitleChangeRequestLast;
1704     else
1705     ts->AcceptTitleChangeRequest = IdTitleChangeRequestOff;
1706    
1707     // Size of paste confirm dialog
1708     GetPrivateProfileString(Section, "PasteDialogSize", "330,220",
1709     Temp, sizeof(Temp), FName);
1710     GetNthNum(Temp, 1, &ts->PasteDialogSize.cx);
1711     GetNthNum(Temp, 2, &ts->PasteDialogSize.cy);
1712     if (ts->PasteDialogSize.cx < 0)
1713     ts->PasteDialogSize.cx = 330;
1714     if (ts->PasteDialogSize.cy < 0)
1715     ts->PasteDialogSize.cy = 220;
1716    
1717     // Disable mouse event tracking when Control-Key is pressed.
1718     ts->DisableMouseTrackingByCtrl =
1719     GetOnOff(Section, "DisableMouseTrackingByCtrl", FName, TRUE);
1720    
1721     // Disable TranslateWheelToCursor setting when Control-Key is pressed.
1722     ts->DisableWheelToCursorByCtrl =
1723     GetOnOff(Section, "DisableWheelToCursorByCtrl", FName, TRUE);
1724    
1725     // Strict Key Mapping.
1726     ts->StrictKeyMapping =
1727     GetOnOff(Section, "StrictKeyMapping", FName, FALSE);
1728    
1729     // added Wait4allMacroCommand (2009.3.23 yutaka)
1730     ts->Wait4allMacroCommand =
1731     GetOnOff(Section, "Wait4allMacroCommand", FName, FALSE);
1732 maya 3279
1733 maya 3283 // added DisableMenuSendBreak (2009.4.6 maya)
1734     ts->DisableMenuSendBreak =
1735     GetOnOff(Section, "DisableMenuSendBreak", FName, FALSE);
1736 maya 3282
1737 maya 3283 // added ClearScreenOnCloseConnection (2009.4.6 maya)
1738     ts->ClearScreenOnCloseConnection =
1739     GetOnOff(Section, "ClearScreenOnCloseConnection", FName, FALSE);
1740    
1741     // added DisableAcceleratorDuplicateSession (2009.4.6 maya)
1742 maya 3282 ts->DisableAcceleratorDuplicateSession =
1743     GetOnOff(Section, "DisableAcceleratorDuplicateSession", FName, FALSE);
1744 maya 3306
1745 maya 5684 ts->AcceleratorNewConnection =
1746     GetOnOff(Section, "AcceleratorNewConnection", FName, TRUE);
1747    
1748     ts->AcceleratorCygwinConnection =
1749     GetOnOff(Section, "AcceleratorCygwinConnection", FName, TRUE);
1750    
1751 maya 3964 // added DisableMenuDuplicateSession (2010.8.3 maya)
1752     ts->DisableMenuDuplicateSession =
1753     GetOnOff(Section, "DisableMenuDuplicateSession", FName, FALSE);
1754    
1755 maya 3965 // added DisableMenuNewConnection (2010.8.4 maya)
1756     ts->DisableMenuNewConnection =
1757     GetOnOff(Section, "DisableMenuNewConnection", FName, FALSE);
1758    
1759 maya 3306 // added PasteDelayPerLine (2009.4.12 maya)
1760     ts->PasteDelayPerLine =
1761     GetPrivateProfileInt(Section, "PasteDelayPerLine", 10, FName);
1762 maya 3315 {
1763     int tmp = min(max(0, ts->PasteDelayPerLine), 5000);
1764     ts->PasteDelayPerLine = tmp;
1765     }
1766 doda 3395
1767     // Font scaling -- test
1768     ts->FontScaling = GetOnOff(Section, "FontScaling", FName, FALSE);
1769 doda 3441
1770     // Meta sets MSB
1771 doda 3507 GetPrivateProfileString(Section, "Meta8Bit", "off", Temp, sizeof(Temp), FName);
1772     if (_stricmp(Temp, "raw") == 0 || _stricmp(Temp, "on") == 0)
1773     ts->Meta8Bit = IdMeta8BitRaw;
1774     else if (_stricmp(Temp, "text") == 0)
1775     ts->Meta8Bit = IdMeta8BitText;
1776     else
1777     ts->Meta8Bit = IdMeta8BitOff;
1778    
1779 maya 3479 // Window control sequence
1780 doda 3485 if (GetOnOff(Section, "WindowCtrlSequence", FName, TRUE))
1781     ts->WindowFlag |= WF_WINDOWCHANGE;
1782 maya 3479
1783     // Cursor control sequence
1784 doda 3485 if (GetOnOff(Section, "CursorCtrlSequence", FName, FALSE))
1785     ts->WindowFlag |= WF_CURSORCHANGE;
1786    
1787     // Window report sequence
1788     if (GetOnOff(Section, "WindowReportSequence", FName, TRUE))
1789     ts->WindowFlag |= WF_WINDOWREPORT;
1790    
1791 doda 3749 // Title report sequence
1792 doda 3747 GetPrivateProfileString(Section, "TitleReportSequence", "Empty", Temp, sizeof(Temp), FName);
1793 doda 3774 if (_stricmp(Temp, "accept") == 0)
1794     ts->WindowFlag |= IdTitleReportAccept;
1795     else if (_stricmp(Temp, "ignore") == 0 || _stricmp(Temp, "off") == 0)
1796 doda 3747 ts->WindowFlag &= ~WF_TITLEREPORT;
1797     else // empty
1798     ts->WindowFlag |= IdTitleReportEmpty;
1799 doda 3501
1800     // Line at a time mode
1801     ts->EnableLineMode = GetOnOff(Section, "EnableLineMode", FName, TRUE);
1802 doda 3721
1803     // Clear window on resize
1804     if (GetOnOff(Section, "ClearOnResize", FName, TRUE))
1805     ts->TermFlag |= TF_CLEARONRESIZE;
1806 doda 3743
1807     // Alternate Screen Buffer
1808     if (GetOnOff(Section, "AlternateScreenBuffer", FName, TRUE))
1809     ts->TermFlag |= TF_ALTSCR;
1810 doda 3969
1811     // IME status related cursor style
1812     if (GetOnOff(Section, "IMERelatedCursor", FName, FALSE))
1813     ts->WindowFlag |= WF_IMECURSORCHANGE;
1814 doda 4217
1815     // Terminal Unique ID
1816     GetPrivateProfileString(Section, "TerminalUID", "FFFFFFFF", Temp, sizeof(Temp), FName);
1817     if (strlen(Temp) == 8) {
1818 doda 4228 for (i=0; i<8 && isxdigit((unsigned char)Temp[i]); i++) {
1819 doda 4217 if (islower(Temp[i])) {
1820     ts->TerminalUID[i] = toupper(Temp[i]);
1821     }
1822     else {
1823     ts->TerminalUID[i] = Temp[i];
1824     }
1825     }
1826     if (i == 8) {
1827     ts->TerminalUID[i] = 0;
1828     }
1829     else {
1830     strncpy_s(ts->TerminalUID, sizeof(ts->TerminalUID), "FFFFFFFF", _TRUNCATE);
1831     }
1832     }
1833     else {
1834     strncpy_s(ts->TerminalUID, sizeof(ts->TerminalUID), "FFFFFFFF", _TRUNCATE);
1835     }
1836 doda 4225
1837     // Lock Terminal UID
1838     if (GetOnOff(Section, "LockTUID", FName, TRUE))
1839     ts->TermFlag |= TF_LOCKTUID;
1840 doda 6435
1841 doda 4480 // Jump List
1842     ts->JumpList = GetOnOff(Section, "JumpList", FName, TRUE);
1843    
1844 doda 4699 // TabStopModifySequence
1845 doda 4687 GetPrivateProfileString(Section, "TabStopModifySequence", "on", Temp, sizeof(Temp), FName);
1846     if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "all") == 0)
1847     ts->TabStopFlag = TABF_ALL;
1848     else if (_stricmp(Temp, "off") == 0 || _stricmp(Temp, "none") == 0)
1849     ts->TabStopFlag = TABF_NONE;
1850     else {
1851     ts->TabStopFlag = TABF_NONE;
1852     for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
1853     if (_stricmp(Temp2, "HTS") == 0)
1854     ts->TabStopFlag |= TABF_HTS;
1855     else if (_stricmp(Temp2, "HTS7") == 0)
1856     ts->TabStopFlag |= TABF_HTS7;
1857     else if (_stricmp(Temp2, "HTS8") == 0)
1858     ts->TabStopFlag |= TABF_HTS8;
1859     else if (_stricmp(Temp2, "TBC") == 0)
1860     ts->TabStopFlag |= TABF_TBC;
1861     else if (_stricmp(Temp2, "TBC0") == 0)
1862     ts->TabStopFlag |= TABF_TBC0;
1863     else if (_stricmp(Temp2, "TBC3") == 0)
1864     ts->TabStopFlag |= TABF_TBC3;
1865     }
1866     }
1867    
1868 doda 4700 // Clipboard Access from Remote
1869     GetPrivateProfileString(Section, "ClipboardAccessFromRemote", "off", Temp, sizeof(Temp), FName);
1870     if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "readwrite") == 0)
1871     ts->CtrlFlag |= CSF_CBRW;
1872     else if (_stricmp(Temp, "read") == 0)
1873     ts->CtrlFlag |= CSF_CBREAD;
1874     else if (_stricmp(Temp, "write") == 0)
1875     ts->CtrlFlag |= CSF_CBWRITE;
1876    
1877 doda 6666 // Notify Clipboard Access from Remote
1878     ts->NotifyClipboardAccess = GetOnOff(Section, "NotifyClipboardAccess", FName, TRUE);
1879    
1880 doda 4281 // Use invalid DECRPSS (for testing)
1881     if (GetOnOff(Section, "UseInvalidDECRQSSResponse", FName, FALSE))
1882     ts->TermFlag |= TF_INVALIDDECRPSS;
1883 maya 4704
1884     // ClickableUrlBrowser
1885     GetPrivateProfileString(Section, "ClickableUrlBrowser", "",
1886     ts->ClickableUrlBrowser, sizeof(ts->ClickableUrlBrowser), FName);
1887     GetPrivateProfileString(Section, "ClickableUrlBrowserArg", "",
1888     ts->ClickableUrlBrowserArg, sizeof(ts->ClickableUrlBrowserArg), FName);
1889 maya 4786
1890     // Exclusive Lock when open the log file
1891     ts->LogLockExclusive = GetOnOff(Section, "LogLockExclusive", FName, TRUE);
1892 maya 4874
1893     // Font quality
1894     GetPrivateProfileString(Section, "FontQuality", "default",
1895     Temp, sizeof(Temp), FName);
1896     if (_stricmp(Temp, "nonantialiased") == 0)
1897     ts->FontQuality = NONANTIALIASED_QUALITY;
1898     else if (_stricmp(Temp, "antialiased") == 0)
1899     ts->FontQuality = ANTIALIASED_QUALITY;
1900     else if (_stricmp(Temp, "cleartype") == 0)
1901     ts->FontQuality = CLEARTYPE_QUALITY;
1902     else
1903     ts->FontQuality = DEFAULT_QUALITY;
1904 doda 5316
1905     // Beep Over Used
1906     ts->BeepOverUsedCount =
1907     GetPrivateProfileInt(Section, "BeepOverUsedCount", 5, FName);
1908     ts->BeepOverUsedTime =
1909     GetPrivateProfileInt(Section, "BeepOverUsedTime", 2, FName);
1910     ts->BeepSuppressTime =
1911     GetPrivateProfileInt(Section, "BeepSuppressTime", 5, FName);
1912 doda 5410
1913     // Max OSC string buffer size
1914     ts->MaxOSCBufferSize =
1915     GetPrivateProfileInt(Section, "MaxOSCBufferSize", 4096, FName);
1916 doda 5428
1917 doda 5438 ts->JoinSplitURL = GetOnOff(Section, "JoinSplitURL", FName, FALSE);
1918 doda 5428
1919 doda 5438 GetPrivateProfileString(Section, "JoinSplitURLIgnoreEOLChar", "\\", Temp, sizeof(Temp), FName);
1920     ts->JoinSplitURLIgnoreEOLChar = Temp[0];
1921 doda 5590
1922     // Debug modes.
1923     GetPrivateProfileString(Section, "DebugModes", "all", Temp, sizeof(Temp), FName);
1924     if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "all") == 0)
1925     ts->DebugModes = DBGF_ALL;
1926     else if (_stricmp(Temp, "off") == 0 || _stricmp(Temp, "none") == 0) {
1927     ts->DebugModes = DBGF_NONE;
1928     ts->Debug = FALSE;
1929     }
1930     else {
1931     ts->DebugModes = DBGF_NONE;
1932     for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
1933     if (_stricmp(Temp2, "normal") == 0)
1934     ts->DebugModes |= DBGF_NORM;
1935     else if (_stricmp(Temp2, "hex") == 0)
1936     ts->DebugModes |= DBGF_HEXD;
1937     else if (_stricmp(Temp2, "noout") == 0)
1938     ts->DebugModes |= DBGF_NOUT;
1939     }
1940     if (ts->DebugModes == DBGF_NONE)
1941     ts->Debug = FALSE;
1942     }
1943 yutakapon 6119
1944 doda 6318 // Xmodem Timeout
1945     GetPrivateProfileString(Section, "XmodemTimeouts", "10,3,10,20,60", Temp, sizeof(Temp), FName);
1946     ts->XmodemTimeOutInit = GetNthNum2(Temp, 1, 10);
1947     if (ts->XmodemTimeOutInit < 1)
1948     ts->XmodemTimeOutInit = 1;
1949     ts->XmodemTimeOutInitCRC = GetNthNum2(Temp, 2, 3);
1950     if (ts->XmodemTimeOutInitCRC < 1)
1951     ts->XmodemTimeOutInitCRC = 1;
1952     ts->XmodemTimeOutShort = GetNthNum2(Temp, 3, 10);
1953     if (ts->XmodemTimeOutShort < 1)
1954     ts->XmodemTimeOutShort = 1;
1955     ts->XmodemTimeOutLong = GetNthNum2(Temp, 4, 20);
1956     if (ts->XmodemTimeOutLong < 1)
1957     ts->XmodemTimeOutLong = 1;
1958     ts->XmodemTimeOutVLong = GetNthNum2(Temp, 5, 60);
1959     if (ts->XmodemTimeOutVLong < 1)
1960     ts->XmodemTimeOutVLong = 1;
1961    
1962 maya 6319 // Ymodem Timeout
1963     GetPrivateProfileString(Section, "YmodemTimeouts", "10,3,10,20,60", Temp, sizeof(Temp), FName);
1964     ts->YmodemTimeOutInit = GetNthNum2(Temp, 1, 10);
1965     if (ts->YmodemTimeOutInit < 1)
1966     ts->YmodemTimeOutInit = 1;
1967     ts->YmodemTimeOutInitCRC = GetNthNum2(Temp, 2, 3);
1968     if (ts->YmodemTimeOutInitCRC < 1)
1969     ts->YmodemTimeOutInitCRC = 1;
1970     ts->YmodemTimeOutShort = GetNthNum2(Temp, 3, 10);
1971     if (ts->YmodemTimeOutShort < 1)
1972     ts->YmodemTimeOutShort = 1;
1973     ts->YmodemTimeOutLong = GetNthNum2(Temp, 4, 20);
1974     if (ts->YmodemTimeOutLong < 1)
1975     ts->YmodemTimeOutLong = 1;
1976     ts->YmodemTimeOutVLong = GetNthNum2(Temp, 5, 60);
1977     if (ts->YmodemTimeOutVLong < 1)
1978     ts->YmodemTimeOutVLong = 1;
1979    
1980     // Zmodem Timeout
1981     GetPrivateProfileString(Section, "ZmodemTimeouts", "10,0,10,3", Temp, sizeof(Temp), FName);
1982     ts->ZmodemTimeOutNormal = GetNthNum2(Temp, 1, 10);
1983     if (ts->ZmodemTimeOutNormal < 1)
1984     ts->ZmodemTimeOutNormal = 1;
1985     ts->ZmodemTimeOutTCPIP = GetNthNum2(Temp, 2, 0);
1986     if (ts->ZmodemTimeOutTCPIP < 0)
1987     ts->ZmodemTimeOutTCPIP = 0;
1988     ts->ZmodemTimeOutInit = GetNthNum2(Temp, 3, 10);
1989     if (ts->ZmodemTimeOutInit < 1)
1990     ts->ZmodemTimeOutInit = 1;
1991     ts->ZmodemTimeOutFin = GetNthNum2(Temp, 4, 3);
1992     if (ts->ZmodemTimeOutFin < 1)
1993     ts->ZmodemTimeOutFin = 1;
1994    
1995 doda 6418 // Trim trailing new line character when pasting
1996 doda 6594 if (GetOnOff(Section, "TrimTrailingNLonPaste", FName, FALSE))
1997     ts->PasteFlag |= CPF_TRIM_TRAILING_NL;
1998 doda 6418
1999 doda 6595 // Normalize line break when pasting
2000     if (GetOnOff(Section, "NormalizeLineBreakOnPaste", FName, FALSE))
2001     ts->PasteFlag |= CPF_NORMALIZE_LINEBREAK;
2002    
2003 doda 6856 // List Inactive Font
2004     ts->ListHiddenFonts = GetOnOff(Section, "ListHiddenFonts", FName, FALSE);
2005    
2006 doda 6916 // ISO2022ShiftFunction
2007     GetPrivateProfileString(Section, "ISO2022ShiftFunction", "on", Temp, sizeof(Temp), FName);
2008 doda 6915 ts->ISO2022Flag = ISO2022_SHIFT_NONE;
2009     for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
2010     BOOL add=TRUE;
2011 doda 6918 char *p = Temp2, *p2;
2012 doda 6915 int mask = 0;
2013    
2014 doda 6918 while (*p == ' ' || *p == '\t') {
2015     p++;
2016     }
2017     p2 = p + strlen(p);
2018     while (p2 > p) {
2019     p2--;
2020     if (*p2 != ' ' && *p2 != '\t') {
2021     break;
2022     }
2023     }
2024     *++p2 = 0;
2025    
2026 doda 6915 if (*p == '-') {
2027     p++;
2028     add=FALSE;
2029 doda 6913 }
2030 doda 6918 else if (*p == '+') {
2031     p++;
2032     }
2033    
2034 doda 6915 if (_stricmp(p, "on") == 0 || _stricmp(p, "all") == 0)
2035     ts->ISO2022Flag = ISO2022_SHIFT_ALL;
2036     else if (_stricmp(p, "off") == 0 || _stricmp(p, "none") == 0)
2037     ts->ISO2022Flag = ISO2022_SHIFT_NONE;
2038     else if (_stricmp(p, "SI") == 0 || _stricmp(p, "LS0") == 0)
2039     mask = ISO2022_SI;
2040     else if (_stricmp(p, "SO") == 0 || _stricmp(p, "LS1") == 0)
2041     mask = ISO2022_SO;
2042     else if (_stricmp(p, "LS2") == 0)
2043     mask = ISO2022_LS2;
2044     else if (_stricmp(p, "LS3") == 0)
2045     mask = ISO2022_LS3;
2046     else if (_stricmp(p, "LS1R") == 0)
2047     mask = ISO2022_LS1R;
2048     else if (_stricmp(p, "LS2R") == 0)
2049     mask = ISO2022_LS2R;
2050     else if (_stricmp(p, "LS3R") == 0)
2051     mask = ISO2022_LS3R;
2052     else if (_stricmp(p, "SS2") == 0)
2053     mask = ISO2022_SS2;
2054     else if (_stricmp(p, "SS3") == 0)
2055     mask = ISO2022_SS3;
2056    
2057     if (mask) {
2058     if (add) {
2059     ts->ISO2022Flag |= mask;
2060     }
2061     else {
2062     ts->ISO2022Flag &= ~mask;
2063     }
2064     }
2065 doda 6913 }
2066    
2067 doda 6958 // Terminal Speed (Used by telnet and ssh)
2068     GetPrivateProfileString(Section, "TerminalSpeed", "38400", Temp, sizeof(Temp), FName);
2069     GetNthNum(Temp, 1, &i);
2070     if (i > 0)
2071     ts->TerminalInputSpeed = i;
2072     else
2073     ts->TerminalInputSpeed = 38400;
2074     GetNthNum(Temp, 2, &i);
2075     if (i > 0)
2076     ts->TerminalOutputSpeed = i;
2077     else
2078     ts->TerminalOutputSpeed = ts->TerminalInputSpeed;
2079    
2080 doda 6603 // Fallback to CP932 (Experimental)
2081     ts->FallbackToCP932 = GetOnOff(Section, "FallbackToCP932", FName, FALSE);
2082    
2083 yutakapon 6119 // CygTerm Configuration File
2084     ReadCygtermConfFile(ts);
2085 zmatsuo 7706
2086     // dialog font
2087     ReadFont3("Tera Term", "DlgFont", NULL, FName,
2088     ts->DialogFontName, sizeof(ts->DialogFontName),
2089     &ts->DialogFontPoint, &ts->DialogFontCharSet);
2090 maya 3227 }
2091    
2092 doda 6801 void PASCAL WriteIniFile(PCHAR FName, PTTSet ts)
2093 maya 3227 {
2094     int i;
2095 maya 4031 char Temp[MAX_PATH];
2096 maya 3227 char buf[20];
2097 yutakapon 5052 int ret;
2098     char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG], msg[MAX_UIMSG];
2099 maya 3227
2100     /* version */
2101 doda 6899 ret = WritePrivateProfileString(Section, "Version", TT_VERSION_STR("."), FName);
2102 yutakapon 5052 if (ret == 0) {
2103     // ini�t�@�C�����������������s�������A�G���[���b�Z�[�W���\�������B(2012.10.18 yutaka)
2104     ret = GetLastError();
2105     get_lang_msg("MSG_INI_WRITE_ERROR", uimsg, sizeof(uimsg), "Cannot write ini file", ts->UILanguageFile);
2106     _snprintf_s(msg, sizeof(msg), _TRUNCATE, "%s (%d)", uimsg, ret);
2107 maya 3227
2108 yutakapon 5052 get_lang_msg("MSG_INI_ERROR", uimsg2, sizeof(uimsg2), "Tera Term: Error", ts->UILanguageFile);
2109    
2110     MessageBox(NULL, msg, uimsg2, MB_ICONEXCLAMATION);
2111     }
2112    
2113 maya 3227 /* Language */
2114 doda 3359 switch (ts->Language) {
2115     case IdJapanese:
2116 maya 3227 strncpy_s(Temp, sizeof(Temp), "Japanese", _TRUNCATE);
2117 doda 3359 break;
2118     case IdKorean:
2119 doda 6435 strncpy_s(Temp, sizeof(Temp), "Korean", _TRUNCATE);
2120 doda 3359 break;
2121     case IdRussian:
2122 doda 6435 strncpy_s(Temp, sizeof(Temp), "Russian", _TRUNCATE);
2123 doda 3359 break;
2124 maya 3401 case IdUtf8:
2125 doda 6435 strncpy_s(Temp, sizeof(Temp), "UTF-8", _TRUNCATE);
2126 maya 3401 break;
2127 doda 3359 default:
2128 doda 6435 strncpy_s(Temp, sizeof(Temp), "English", _TRUNCATE);
2129 doda 3359 }
2130    
2131 maya 3227 WritePrivateProfileString(Section, "Language", Temp, FName);
2132    
2133     /* Port type */
2134 doda 6696 WritePrivateProfileString(Section, "Port", (ts->PortType==IdSerial)?"serial":"tcpip", FName);
2135 maya 3227
2136     /* Save win position */
2137     if (ts->SaveVTWinPos) {
2138     /* VT win position */
2139     WriteInt2(Section, "VTPos", FName, ts->VTPos.x, ts->VTPos.y);
2140     }
2141    
2142     /* VT terminal size */
2143     WriteInt2(Section, "TerminalSize", FName,
2144     ts->TerminalWidth, ts->TerminalHeight);
2145    
2146     /* Terminal size = Window size */
2147     WriteOnOff(Section, "TermIsWin", FName, ts->TermIsWin);
2148    
2149     /* Auto window resize flag */
2150     WriteOnOff(Section, "AutoWinResize", FName, ts->AutoWinResize);
2151    
2152     /* CR Receive */
2153     if (ts->CRReceive == IdCRLF) {
2154     strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
2155     }
2156     else if (ts->CRReceive == IdLF) {
2157     strncpy_s(Temp, sizeof(Temp), "LF", _TRUNCATE);
2158     }
2159 maya 4893 else if (ts->CRReceive == IdAUTO) {
2160     strncpy_s(Temp, sizeof(Temp), "AUTO", _TRUNCATE);
2161     }
2162 maya 3227 else {
2163     strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE);
2164     }
2165     WritePrivateProfileString(Section, "CRReceive", Temp, FName);
2166    
2167     /* CR Send */
2168 maya 6369 if (ts->CRSend == IdCRLF) {
2169 maya 3227 strncpy_s(Temp, sizeof(Temp), "CRLF", _TRUNCATE);
2170 maya 6369 }
2171     else if (ts->CRSend == IdLF) {
2172     strncpy_s(Temp, sizeof(Temp), "LF", _TRUNCATE);
2173     }
2174     else {