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 6806 - (hide annotations) (download) (as text)
Thu Jun 15 00:37:01 2017 UTC (6 years, 9 months ago) by doda
File MIME type: text/x-csrc
File size: 134779 byte(s)
TeraTerm Project としてのライセンス表記を追加

とりあえず Tera Term 本体分。
TeraTerm Project としての copyright 表記の年部分はコミットログを確認して書いたつもりだけど、ミスってたらすみません。

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