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 6958 - (hide annotations) (download) (as text)
Tue Oct 24 12:05:11 2017 UTC (6 years, 5 months ago) by doda
File MIME type: text/x-csrc
File size: 139471 byte(s)
SSH 接続で通知する端末速度の値を設定可能にした。 #37598

TELNET TERMINAL SPEED OPTION と共通の設定にする為、設定は [Tera Term]
セクションに置く。

設定例:

[Tera Term]
TerminalSpeed=38400		; In/Out 共に 38400bps
; TerminalSped=38400,9600	; In が38400bps, Out が 9600bps

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