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 6841 - (hide annotations) (download) (as text)
Tue Jul 4 15:02:28 2017 UTC (6 years, 9 months ago) by doda
File MIME type: text/x-csrc
File size: 134775 byte(s)
TeraTerm Project としてのライセンス表記を追加

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